{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "empty-states-04",
  "title": "Empty states with a scene",
  "description": "Four calm scenes for no runs, an empty inbox, no tools and no agents, drawn with dashed slots and key caps and looping on opacity and transform while on screen, each with a title, a line and one action that morphs from idle to done.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/toggle-group.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-04/index.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\nimport { useAutoplay } from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  PRESS_LEAD_MS,\n  pressedQuietOf,\n  pressedSolidOf,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport {\n  ArchiveIcon,\n  BotIcon,\n  PlayIcon,\n  PlusIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { ToggleGroup, ToggleGroupItem } from '@/registry/ndeko/ui/toggle-group';\n\nimport { FIRST_SCENE, SCENES, type SceneCopy, type SceneId } from './data';\nimport { SceneArt } from './scenes';\n\nconst THUMB =\n  'bg-card shadow-[0_1px_2px_rgb(0_0_0/0.08)] hairline-ring ring-foreground/10 dark:bg-foreground/[0.09] dark:ring-foreground/15';\n\nconst CROSSFADE_TRANSITION: Transition = {\n  duration: 0.22,\n  ease: [0.23, 1, 0.32, 1],\n};\n\nconst CROSSFADE_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.98, filter: 'blur(4px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.98, filter: 'blur(4px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nconst ACTION_ICONS: Record<SceneId, React.ReactNode> = {\n  runs: <PlayIcon />,\n  inbox: <ArchiveIcon />,\n  tools: <PlusIcon />,\n  agents: <BotIcon />,\n};\n\nconst LOOK_MS = 2400;\n\nconst BUSY_MS = 700;\n\nconst DONE_MS = 2000;\n\nconst REST_MS = 2800;\n\nconst RESET_AFTER_MS = 3200;\n\nfunction crossfadeVariantsOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return CROSSFADE_VARIANTS;\n}\n\nfunction sceneOf(value: unknown) {\n  return SCENES.find((candidate) => candidate.id === value);\n}\n\nfunction labelsOf(scene: SceneCopy): Record<MorphState, string> {\n  return { idle: scene.idle, busy: scene.busy, done: scene.done };\n}\n\nexport default function EmptyStates04() {\n  const [sceneId, setSceneId] = useState<SceneId>(FIRST_SCENE);\n  const [actionState, setActionState] = useState<MorphState>('idle');\n  const [message, setMessage] = useState('');\n  const { pressed, press } = usePress<string>();\n  const { schedule, clearAll } = useTimeouts();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const isVisible = useDocumentVisible();\n  const found = SCENES.find((candidate) => candidate.id === sceneId);\n  const scene = found ?? SCENES[0];\n  const variants = crossfadeVariantsOf(shouldReduceMotion);\n  const pressedValues = [sceneId];\n\n  function showScene(id: SceneId) {\n    clearAll();\n    setActionState('idle');\n    setSceneId(id);\n  }\n\n  function runAction() {\n    setActionState('busy');\n    schedule(() => setActionState('done'), BUSY_MS);\n    schedule(() => setActionState('idle'), DONE_MS);\n  }\n\n  function sequenceOf(index: number) {\n    const sequence = [\n      { after: LOOK_MS, run: () => press('action') },\n      { after: PRESS_LEAD_MS, run: runAction },\n    ];\n    const next = SCENES[index + 1];\n    if (next) {\n      sequence.push(\n        { after: REST_MS, run: () => press(`scene-${next.id}`) },\n        { after: PRESS_LEAD_MS, run: () => showScene(next.id) }\n      );\n    }\n    return sequence;\n  }\n\n  const steps = SCENES.flatMap((_, index) => sequenceOf(index));\n  const { ref, isInView, isAutoplaying } = useAutoplay<HTMLDivElement>(steps, {\n    loopAfter: RESET_AFTER_MS,\n    onReset: () => showScene(FIRST_SCENE),\n  });\n  const isPlaying = isInView && isVisible;\n  const spoken = spokenUnless(isAutoplaying, message);\n\n  function pickScene(nextValues: unknown[]) {\n    const [next] = nextValues;\n    const picked = sceneOf(next);\n    if (!picked) {\n      return;\n    }\n    showScene(picked.id);\n    setMessage(picked.title);\n  }\n\n  return (\n    <div ref={ref} className='@container px-4 py-16 @2xl:px-6 @2xl:py-24'>\n      <div className='mx-auto flex max-w-3xl flex-col items-center gap-8'>\n        <div className='relative max-w-full overflow-x-auto'>\n          <ToggleGroup\n            aria-label='Empty states'\n            value={pressedValues}\n            onValueChange={pickScene}\n            travel\n            size='sm'\n            indicatorClassName={THUMB}\n            className='bg-foreground/[0.05] rounded-lg p-0.5'\n          >\n            {SCENES.map((item) => (\n              <ToggleGroupItem\n                key={item.id}\n                value={item.id}\n                className={cn(\n                  'h-7 rounded-md px-2.5 text-xs',\n                  pressedQuietOf(pressed === `scene-${item.id}`)\n                )}\n              >\n                {item.tab}\n              </ToggleGroupItem>\n            ))}\n          </ToggleGroup>\n        </div>\n        <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] w-full rounded-2xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <div className='bg-foreground/[0.04] relative grid min-h-[26rem] place-items-center rounded-[calc(var(--radius-2xl)-0.5rem)] p-6 @2xl:p-10'>\n            <AnimatePresence mode='popLayout' initial={false}>\n              <motion.div\n                key={scene.id}\n                variants={variants}\n                initial='enter'\n                animate='visible'\n                exit='exit'\n                transition={CROSSFADE_TRANSITION}\n                className='flex w-full flex-col items-center gap-6 text-center'\n              >\n                <SceneArt sceneId={scene.id} isPlaying={isPlaying} />\n                <div className='flex max-w-sm flex-col gap-1.5'>\n                  <h3 className='text-base font-semibold text-balance'>\n                    {scene.title}\n                  </h3>\n                  <p className='text-muted-foreground text-[13px] text-pretty'>\n                    {scene.description}\n                  </p>\n                </div>\n                <MorphButton\n                  type='button'\n                  state={actionState}\n                  labels={labelsOf(scene)}\n                  idleIcon={ACTION_ICONS[scene.id]}\n                  onClick={runAction}\n                  className={cn(pressedSolidOf(pressed === 'action'))}\n                />\n              </motion.div>\n            </AnimatePresence>\n          </div>\n        </div>\n      </div>\n      <LiveRegion message={spoken} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-04/scenes.tsx",
      "content": "'use client';\n\nimport { useRef } from 'react';\n\nimport {\n  CheckIcon,\n  InboxIcon,\n  PlayIcon,\n  PlusIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport type { SceneId } from './data';\nimport { useSceneLoops, type SceneLoop } from './use-scene-loops';\n\n/** An empty slot that invites an addition is the only dashed hairline of the system. */\nconst SLOT = 'hairline-border border-dashed border-foreground/20';\n\nconst RUN_BAR_WIDTHS = ['w-3/5', 'w-2/5', 'w-1/3'];\n\nconst AGENT_SLOTS = [0, 1, 2];\n\nconst TOOL_SLOTS = [0, 1, 2, 3];\n\nconst RISE_OFFSETS = ['start-[28%]', 'start-1/2', 'start-[72%]'];\n\nfunction RunsArt() {\n  return (\n    <div className='flex h-full w-full flex-col justify-center gap-2.5'>\n      {RUN_BAR_WIDTHS.map((width, index) => (\n        <div\n          key={width}\n          data-loop='row'\n          className={`${SLOT} flex h-10 items-center gap-3 rounded-lg px-3`}\n        >\n          <span className={`${SLOT} size-4 shrink-0 rounded-full`} />\n          <span className={`bg-foreground/10 h-1.5 rounded-full ${width}`} />\n          {index === 0 && (\n            <span className='keycap-3d text-muted-foreground ms-auto flex size-6 shrink-0 items-center justify-center rounded-md'>\n              <PlayIcon className='size-3' />\n            </span>\n          )}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction InboxArt() {\n  return (\n    <div className='relative flex h-full w-full items-center justify-center'>\n      {RISE_OFFSETS.map((offset) => (\n        <span\n          key={offset}\n          data-loop='rise'\n          className={`chip-3d absolute bottom-[58%] -translate-x-1/2 opacity-0 [--chip:var(--success)] ${offset} flex size-[18px] items-center justify-center rounded-full`}\n        >\n          <CheckIcon className='size-3' />\n        </span>\n      ))}\n      <span className='keycap-3d text-muted-foreground flex size-16 items-center justify-center rounded-2xl'>\n        <InboxIcon className='size-7' />\n      </span>\n    </div>\n  );\n}\n\nfunction ToolsArt() {\n  return (\n    <div className='flex h-full w-full items-center justify-center gap-3'>\n      {TOOL_SLOTS.map((slot) => (\n        <span\n          key={slot}\n          className={`${SLOT} text-muted-foreground relative flex size-14 items-center justify-center rounded-xl`}\n        >\n          <span\n            data-loop='slot'\n            aria-hidden='true'\n            className='bg-primary/10 absolute inset-0 rounded-xl opacity-0'\n          />\n          <PlusIcon className='size-4 opacity-60' />\n        </span>\n      ))}\n    </div>\n  );\n}\n\nfunction AgentsArt() {\n  return (\n    <div className='flex h-full w-full items-center justify-center gap-3'>\n      {AGENT_SLOTS.map((slot) => {\n        if (slot === 0) {\n          return (\n            <span key={slot} data-loop='ghost' className='opacity-30'>\n              <MeshTile seed='Planner' className='size-14 rounded-xl' />\n            </span>\n          );\n        }\n        return (\n          <span\n            key={slot}\n            className={`${SLOT} text-muted-foreground flex size-14 items-center justify-center rounded-xl`}\n          >\n            <PlusIcon className='size-4 opacity-60' />\n          </span>\n        );\n      })}\n    </div>\n  );\n}\n\nconst ART: Record<SceneId, () => React.JSX.Element> = {\n  runs: RunsArt,\n  inbox: InboxArt,\n  tools: ToolsArt,\n  agents: AgentsArt,\n};\n\nconst BREATH: Keyframe[] = [\n  { opacity: 0.45 },\n  { opacity: 1 },\n  { opacity: 0.45 },\n];\n\nconst RISE: Keyframe[] = [\n  { opacity: 0, transform: 'translateY(10px) scale(0.9)' },\n  { opacity: 1, transform: 'translateY(0) scale(1)', offset: 0.3 },\n  { opacity: 0, transform: 'translateY(-26px) scale(1)' },\n];\n\nconst LIGHT: Keyframe[] = [\n  { opacity: 0 },\n  { opacity: 1, offset: 0.25 },\n  { opacity: 0, offset: 0.5 },\n  { opacity: 0 },\n];\n\nconst GHOST: Keyframe[] = [\n  { opacity: 0.3, transform: 'scale(0.97)' },\n  { opacity: 0.75, transform: 'scale(1)' },\n  { opacity: 0.3, transform: 'scale(0.97)' },\n];\n\nconst LOOPS: Record<SceneId, SceneLoop[]> = {\n  runs: [\n    {\n      selector: '[data-loop=\"row\"]',\n      keyframes: BREATH,\n      duration: 3600,\n      stagger: 600,\n    },\n  ],\n  inbox: [\n    {\n      selector: '[data-loop=\"rise\"]',\n      keyframes: RISE,\n      duration: 3200,\n      stagger: 1000,\n    },\n  ],\n  tools: [\n    {\n      selector: '[data-loop=\"slot\"]',\n      keyframes: LIGHT,\n      duration: 3200,\n      stagger: 800,\n    },\n  ],\n  agents: [\n    { selector: '[data-loop=\"ghost\"]', keyframes: GHOST, duration: 3600 },\n  ],\n};\n\ntype SceneArtProps = {\n  sceneId: SceneId;\n  isPlaying: boolean;\n};\n\nexport function SceneArt({ sceneId, isPlaying }: SceneArtProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const Art = ART[sceneId];\n  useSceneLoops(rootRef, LOOPS[sceneId], isPlaying);\n\n  return (\n    <div ref={rootRef} aria-hidden='true' className='h-40 w-full max-w-xs'>\n      <Art />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-04/scenes.tsx"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-04/use-scene-loops.ts",
      "content": "'use client';\n\nimport { useEffect, useRef, type RefObject } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\n\nexport type SceneLoop = {\n  selector: string;\n  keyframes: Keyframe[];\n  duration: number;\n  /** Each part after the first starts this much later, so the loop travels across them. */\n  stagger?: number;\n};\n\n/**\n * Calm loops on opacity and transform only, as Web Animations made once and paused whenever the\n * scene is not on screen. Under reduced motion none is made, so the scene stays as drawn.\n */\nexport function useSceneLoops(\n  rootRef: RefObject<HTMLElement | null>,\n  loops: readonly SceneLoop[],\n  isPlaying: boolean\n) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const animations = useRef<Animation[]>([]);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!root || shouldReduceMotion) {\n      return;\n    }\n    const created: Animation[] = [];\n    for (const loop of loops) {\n      const parts = root.querySelectorAll<HTMLElement>(loop.selector);\n      const stagger = loop.stagger ?? 0;\n      parts.forEach((part, index) => {\n        const animation = part.animate(loop.keyframes, {\n          duration: loop.duration,\n          delay: index * stagger,\n          iterations: Infinity,\n          easing: 'ease-in-out',\n        });\n        animation.pause();\n        created.push(animation);\n      });\n    }\n    animations.current = created;\n    return () => {\n      created.forEach((animation) => animation.cancel());\n      animations.current = [];\n    };\n  }, [rootRef, loops, shouldReduceMotion]);\n\n  useEffect(() => {\n    for (const animation of animations.current) {\n      if (isPlaying) {\n        animation.play();\n      } else {\n        animation.pause();\n      }\n    }\n  }, [isPlaying, loops, shouldReduceMotion]);\n}\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-04/use-scene-loops.ts"
    },
    {
      "path": "registry/ndeko/blocks/empty-states/empty-states-04/data.ts",
      "content": "export type SceneId = 'runs' | 'inbox' | 'tools' | 'agents';\n\nexport type SceneCopy = {\n  id: SceneId;\n  tab: string;\n  title: string;\n  description: string;\n  idle: string;\n  busy: string;\n  done: string;\n};\n\nexport const SCENES: SceneCopy[] = [\n  {\n    id: 'runs',\n    tab: 'No runs',\n    title: 'No runs yet',\n    description:\n      'Runs appear here as soon as an agent starts one. Start the first and follow it step by step.',\n    idle: 'Start a run',\n    busy: 'Starting',\n    done: 'Started',\n  },\n  {\n    id: 'inbox',\n    tab: 'Empty inbox',\n    title: 'Inbox zero',\n    description:\n      'Every request has an answer. New ones land here the moment they arrive.',\n    idle: 'Open the archive',\n    busy: 'Opening',\n    done: 'Opened',\n  },\n  {\n    id: 'tools',\n    tab: 'No tools',\n    title: 'No tools connected',\n    description:\n      'Connect the tools your agents work in, and they can read and act on them with your approval.',\n    idle: 'Connect a tool',\n    busy: 'Connecting',\n    done: 'Connected',\n  },\n  {\n    id: 'agents',\n    tab: 'No agents',\n    title: 'No agents yet',\n    description:\n      'An agent takes a job and works through it while you do something else. Add one to begin.',\n    idle: 'Add an agent',\n    busy: 'Adding',\n    done: 'Added',\n  },\n];\n\nexport const FIRST_SCENE: SceneId = 'runs';\n",
      "type": "registry:component",
      "target": "components/blocks/empty-states-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "empty-states"
  ],
  "type": "registry:block"
}