{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "prompt-02",
  "title": "Composer with modes",
  "description": "A composer with attachments that upload behind a ring, menus for permission, model, apps and folder, dictation in a live recording strip, and Send that turns into Stop.",
  "dependencies": [
    "@base-ui/react",
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/level-bars.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/media-clock.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/recipes.json",
    "https://ui.ndekocode.dev/r/textarea.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.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",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/prompt/prompt-02.tsx",
      "content": "'use client';\n\nimport { Menu as MenuPrimitive } from '@base-ui/react/menu';\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useContext, useEffect, useRef, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport { ClockGateContext } from '@/registry/ndeko/hooks/use-agent-run';\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  hold,\n  PRESS_LEAD_MS,\n  pressedQuietOf,\n  pressedSolidOf,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport {\n  ArrowUpIcon,\n  CalendarIcon,\n  ChevronDownIcon,\n  CircleAlertIcon,\n  CircleCheckIcon,\n  FileTextIcon,\n  FolderIcon,\n  HandIcon,\n  ImageIcon,\n  ListChecksIcon,\n  LoaderIcon,\n  MicIcon,\n  PaperclipIcon,\n  PencilIcon,\n  PlugIcon,\n  TableIcon,\n  UploadCloudIcon,\n  XIcon,\n  type Icon,\n} from '@/registry/ndeko/lib/icons';\nimport {\n  fadePresence,\n  risePresenceOf,\n  springOf,\n} from '@/registry/ndeko/lib/motion-presets';\nimport { MENU_ITEM } from '@/registry/ndeko/lib/recipes';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { appendWord, countOf, wordsOf } from '@/registry/ndeko/lib/words';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuGroup,\n  DropdownMenuGroupLabel,\n  DropdownMenuRadioGroup,\n  DropdownMenuRadioItem,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { Textarea } from '@/registry/ndeko/ui/textarea';\n\nimport { ClockSince } from './_parts/clock';\nimport { LabTile } from './_parts/lab-tile';\nimport { MODELS, modelOf } from './_parts/labs';\nimport { LevelBars } from '@/registry/ndeko/ui/level-bars';\nimport {\n  caretToEnd,\n  isOwnKey,\n  isSendKey,\n  useAutosize,\n} from './_parts/use-autosize';\n\nexport type PermissionMode = 'ask' | 'accept' | 'plan';\n\ntype ModeLook = {\n  label: string;\n  hint: string;\n  icon: Icon;\n};\n\nconst MODES: PermissionMode[] = ['ask', 'accept', 'plan'];\n\nconst MODE_LOOK: Record<PermissionMode, ModeLook> = {\n  ask: {\n    label: 'Ask before edits',\n    hint: 'Asks you before it changes a file',\n    icon: HandIcon,\n  },\n  accept: {\n    label: 'Accept edits',\n    hint: 'Changes files and tells you after',\n    icon: PencilIcon,\n  },\n  plan: {\n    label: 'Plan only',\n    hint: 'Writes a plan and changes nothing',\n    icon: ListChecksIcon,\n  },\n};\n\nconst MODE_LABELS = MODES.map((mode) => MODE_LOOK[mode].label);\n\nfunction isPermissionMode(value: unknown): value is PermissionMode {\n  return MODES.some((mode) => mode === value);\n}\n\ntype PermissionModeMenuProps = {\n  value: PermissionMode;\n  onValueChange: (mode: PermissionMode) => void;\n  disabled?: boolean;\n};\n\nexport function PermissionModeMenu({\n  value,\n  onValueChange,\n  disabled,\n}: PermissionModeMenuProps) {\n  const look = MODE_LOOK[value];\n  const ModeIcon = look.icon;\n\n  function change(next: unknown) {\n    if (isPermissionMode(next)) {\n      onValueChange(next);\n    }\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        disabled={disabled}\n        render={\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            aria-label={`Permission mode: ${look.label}`}\n            className='text-muted-foreground hover:text-foreground gap-1.5 px-2'\n          />\n        }\n      >\n        <Swap swapKey={value}>\n          <ModeIcon className='size-3.5' />\n        </Swap>\n        <WordRoll text={look.label} labels={MODE_LABELS} />\n        <ChevronDownIcon className='size-3.5 opacity-60' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-64'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>\n            Before the agent changes files\n          </DropdownMenuGroupLabel>\n          <DropdownMenuRadioGroup value={value} onValueChange={change}>\n            {MODES.map((mode) => {\n              const modeLook = MODE_LOOK[mode];\n              const ItemIcon = modeLook.icon;\n              return (\n                <DropdownMenuRadioItem\n                  key={mode}\n                  value={mode}\n                  closeOnClick\n                  className='h-auto items-start py-1.5'\n                >\n                  <ItemIcon className='mt-0.5' />\n                  <span className='flex min-w-0 flex-col'>\n                    <span>{modeLook.label}</span>\n                    <span className='text-muted-foreground text-xs'>\n                      {modeLook.hint}\n                    </span>\n                  </span>\n                </DropdownMenuRadioItem>\n              );\n            })}\n          </DropdownMenuRadioGroup>\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n\nconst FAMILY_MODELS = MODELS.filter((model) => model.lab === 'anthropic');\n\nconst FAMILY_IDS = FAMILY_MODELS.map((model) => model.id);\n\nconst FAMILY_LABELS = FAMILY_MODELS.map((model) => model.name);\n\nfunction isFamilyModel(value: unknown): value is string {\n  return FAMILY_IDS.some((id) => id === value);\n}\n\ntype ModelMenuProps = {\n  value: string;\n  onValueChange: (modelId: string) => void;\n  disabled?: boolean;\n};\n\nexport function ModelMenu({ value, onValueChange, disabled }: ModelMenuProps) {\n  const model = modelOf(value);\n\n  function change(next: unknown) {\n    if (isFamilyModel(next)) {\n      onValueChange(next);\n    }\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        disabled={disabled}\n        render={\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            aria-label={`Model: ${model.name}`}\n            className='text-muted-foreground hover:text-foreground gap-1.5 px-2'\n          />\n        }\n      >\n        <LabTile lab={model.lab} size='sm' />\n        <WordRoll text={model.name} labels={FAMILY_LABELS} />\n        <ChevronDownIcon className='size-3.5 opacity-60' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-64'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Model</DropdownMenuGroupLabel>\n          <DropdownMenuRadioGroup value={value} onValueChange={change}>\n            {FAMILY_MODELS.map((option) => (\n              <DropdownMenuRadioItem\n                key={option.id}\n                value={option.id}\n                closeOnClick\n                className='h-auto items-start py-1.5'\n              >\n                <LabTile lab={option.lab} size='sm' className='mt-0.5' />\n                <span className='flex min-w-0 flex-col'>\n                  <span>{option.name}</span>\n                  <span className='text-muted-foreground text-xs'>\n                    {option.hint}\n                  </span>\n                </span>\n              </DropdownMenuRadioItem>\n            ))}\n          </DropdownMenuRadioGroup>\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n\nexport type AppId = 'calendar' | 'drive' | 'tracker';\n\ntype ConnectedApp = {\n  id: AppId;\n  name: string;\n  hint: string;\n  icon: Icon;\n};\n\nconst APPS: ConnectedApp[] = [\n  {\n    id: 'calendar',\n    name: 'Calendar',\n    hint: 'Reads your meetings',\n    icon: CalendarIcon,\n  },\n  {\n    id: 'drive',\n    name: 'Drive',\n    hint: 'Opens shared documents',\n    icon: FolderIcon,\n  },\n  {\n    id: 'tracker',\n    name: 'Tracker',\n    hint: 'Reads and files issues',\n    icon: TableIcon,\n  },\n];\n\nconst SWITCH_TRACK =\n  'bg-foreground/15 dark:bg-foreground/20 group-data-checked/app:bg-primary flex h-4 w-7 shrink-0 items-center rounded-full p-0.5 transition-colors duration-200';\n\nconst SWITCH_THUMB =\n  'block size-3 rounded-full bg-white shadow-[0_1px_2px_rgb(0_0_0/0.2)] transition-transform duration-200 ease-(--ease-out-strong) group-data-checked/app:translate-x-3 rtl:group-data-checked/app:-translate-x-3';\n\nfunction withApp(apps: AppId[], id: AppId, isOn: boolean) {\n  const others = apps.filter((app) => app !== id);\n  if (isOn) {\n    return [...others, id];\n  }\n  return others;\n}\n\nfunction appsLabelOf(count: number) {\n  const apps = countOf(count, 'app');\n  return `Connected apps, ${apps} on`;\n}\n\ntype ConnectedAppsMenuProps = {\n  value: AppId[];\n  onValueChange: (apps: AppId[]) => void;\n  disabled?: boolean;\n};\n\nexport function ConnectedAppsMenu({\n  value,\n  onValueChange,\n  disabled,\n}: ConnectedAppsMenuProps) {\n  const count = value.length;\n\n  function toggle(id: AppId, isOn: boolean) {\n    const next = withApp(value, id, isOn);\n    onValueChange(next);\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        disabled={disabled}\n        render={\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            aria-label={appsLabelOf(count)}\n            className='text-muted-foreground hover:text-foreground gap-1.5 px-2'\n          />\n        }\n      >\n        <PlugIcon className='size-3.5' />\n        <MotionNumber value={count} />\n        <ChevronDownIcon className='size-3.5 opacity-60' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-64'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Connected apps</DropdownMenuGroupLabel>\n          {APPS.map((app) => {\n            const AppIcon = app.icon;\n            const isOn = value.includes(app.id);\n            return (\n              <MenuPrimitive.CheckboxItem\n                key={app.id}\n                checked={isOn}\n                onCheckedChange={(checked) => toggle(app.id, checked)}\n                className={cn(MENU_ITEM, 'group/app h-auto py-1.5')}\n              >\n                <AppIcon />\n                <span className='flex min-w-0 flex-1 flex-col'>\n                  <span>{app.name}</span>\n                  <span className='text-muted-foreground text-xs'>\n                    {app.hint}\n                  </span>\n                </span>\n                <span aria-hidden='true' className={SWITCH_TRACK}>\n                  <span className={SWITCH_THUMB} />\n                </span>\n              </MenuPrimitive.CheckboxItem>\n            );\n          })}\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n\ntype FolderMenuProps = {\n  value: string;\n  folders: string[];\n  onValueChange: (folder: string) => void;\n  disabled?: boolean;\n};\n\nfunction isFolderIn(folders: string[], value: unknown): value is string {\n  return folders.some((folder) => folder === value);\n}\n\nexport function FolderMenu({\n  value,\n  folders,\n  onValueChange,\n  disabled,\n}: FolderMenuProps) {\n  function change(next: unknown) {\n    if (isFolderIn(folders, next)) {\n      onValueChange(next);\n    }\n  }\n\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        disabled={disabled}\n        render={\n          <Button\n            type='button'\n            variant='outline'\n            size='sm'\n            aria-label={`Working folder: ${value}`}\n            className='max-w-full gap-1.5 px-2.5'\n          />\n        }\n      >\n        <FolderIcon className='text-muted-foreground size-3.5' />\n        <span className='min-w-0 truncate font-mono text-[11px]'>\n          <Swap swapKey={value}>{value}</Swap>\n        </span>\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-60'>\n        <DropdownMenuGroup>\n          <DropdownMenuGroupLabel>Working folder</DropdownMenuGroupLabel>\n          <DropdownMenuRadioGroup value={value} onValueChange={change}>\n            {folders.map((folder) => (\n              <DropdownMenuRadioItem key={folder} value={folder} closeOnClick>\n                <FolderIcon />\n                <span className='truncate font-mono text-xs'>{folder}</span>\n              </DropdownMenuRadioItem>\n            ))}\n          </DropdownMenuRadioGroup>\n        </DropdownMenuGroup>\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n\nexport type ComposerAttachment = {\n  id: string;\n  name: string;\n  size: number;\n  kind: 'image' | 'file';\n  isUploading: boolean;\n  /** An object URL for the thumbnail, revoked when the file is removed or sent. */\n  previewUrl?: string;\n};\n\nconst KILOBYTE = 1024;\n\nconst MEGABYTE = KILOBYTE * 1024;\n\nexport function formatBytes(size: number) {\n  if (size < KILOBYTE) {\n    return `${size} B`;\n  }\n  if (size < MEGABYTE) {\n    const kilobytes = Math.round(size / KILOBYTE);\n    return `${kilobytes} KB`;\n  }\n  const tenths = Math.round((size / MEGABYTE) * 10);\n  const megabytes = tenths / 10;\n  return `${megabytes} MB`;\n}\n\nconst UPLOAD_MS = 1100;\n\n/** How long the closed ring keeps its check before the tile shows what it holds. */\nconst CHECK_HOLD_MS = 900;\n\nconst RING_RADIUS = 7;\n\nconst RING_CHECK = 'M5.7 9.2 8 11.4 12.4 6.6';\n\nconst CHECK_DRAW = { duration: 0.24, ease: [0.23, 1, 0.32, 1] } as const;\n\ntype UploadPhase = 'uploading' | 'confirming' | 'settled';\n\n/** After the upload, the tile confirms it for a moment before it settles. */\nfunction useUploadPhase(isUploading: boolean): UploadPhase {\n  const [wasUploading, setWasUploading] = useState(isUploading);\n  const [isConfirming, setIsConfirming] = useState(false);\n  const hasChanged = wasUploading !== isUploading;\n  if (hasChanged) {\n    setWasUploading(isUploading);\n    setIsConfirming(!isUploading);\n  }\n\n  useEffect(() => {\n    if (!isConfirming) {\n      return;\n    }\n    const timer = setTimeout(() => setIsConfirming(false), CHECK_HOLD_MS);\n    return () => clearTimeout(timer);\n  }, [isConfirming]);\n\n  if (isUploading) {\n    return 'uploading';\n  }\n  if (isConfirming) {\n    return 'confirming';\n  }\n  return 'settled';\n}\n\ntype UploadRingProps = {\n  /** The ring is closed: a check draws itself inside it. */\n  isDone: boolean;\n  className?: string;\n};\n\nfunction UploadRing({ isDone, className }: UploadRingProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const transition = ringTransitionOf(shouldReduceMotion);\n\n  return (\n    <svg\n      aria-hidden='true'\n      viewBox='0 0 18 18'\n      className={cn('size-[18px]', className)}\n    >\n      <g transform='rotate(-90 9 9)'>\n        <circle\n          cx='9'\n          cy='9'\n          r={RING_RADIUS}\n          fill='none'\n          strokeWidth='2'\n          className='stroke-current opacity-25'\n        />\n        <motion.circle\n          cx='9'\n          cy='9'\n          r={RING_RADIUS}\n          fill='none'\n          strokeWidth='2'\n          strokeLinecap='round'\n          className='stroke-current'\n          initial={{ pathLength: 0.04 }}\n          animate={{ pathLength: 1 }}\n          transition={transition}\n        />\n      </g>\n      {isDone && (\n        <motion.path\n          d={RING_CHECK}\n          fill='none'\n          strokeWidth='1.75'\n          strokeLinecap='round'\n          strokeLinejoin='round'\n          className='stroke-current'\n          initial={checkStartOf(shouldReduceMotion)}\n          animate={{ pathLength: 1 }}\n          transition={CHECK_DRAW}\n        />\n      )}\n    </svg>\n  );\n}\n\nfunction checkStartOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return { pathLength: 1 };\n  }\n  return { pathLength: 0 };\n}\n\nfunction ringTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return { duration: 0 };\n  }\n  const seconds = UPLOAD_MS / 1000;\n  return { duration: seconds, ease: [0.4, 0, 0.2, 1] as const };\n}\n\nfunction glyphKeyOf(showsRing: boolean) {\n  if (showsRing) {\n    return 'ring';\n  }\n  return 'file';\n}\n\nfunction thumbnailStyleOf(previewUrl: string | undefined) {\n  if (!previewUrl) {\n    return undefined;\n  }\n  return { backgroundImage: `url(\"${previewUrl}\")` };\n}\n\nfunction uploadWordOf(attachment: ComposerAttachment) {\n  if (attachment.isUploading) {\n    return 'Uploading';\n  }\n  return formatBytes(attachment.size);\n}\n\ntype AttachmentTileProps = {\n  attachment: ComposerAttachment;\n  onRemove: (id: string) => void;\n  disabled?: boolean;\n};\n\nexport function AttachmentTile({\n  attachment,\n  onRemove,\n  disabled,\n}: AttachmentTileProps) {\n  const phase = useUploadPhase(attachment.isUploading);\n  const isImage = attachment.kind === 'image';\n  const thumbnailStyle = thumbnailStyleOf(attachment.previewUrl);\n  const hasPreview = thumbnailStyle !== undefined;\n  const detail = uploadWordOf(attachment);\n  const removeLabel = `Remove ${attachment.name}`;\n  const showsRing = phase !== 'settled';\n  const isConfirmed = phase === 'confirming';\n\n  if (isImage) {\n    return (\n      <div className='group/tile relative size-11'>\n        <span\n          role='img'\n          aria-label={`${attachment.name}, ${detail}`}\n          style={thumbnailStyle}\n          className='bg-foreground/[0.06] hairline-ring ring-border flex size-full items-center justify-center overflow-hidden rounded-lg bg-cover bg-center'\n        >\n          {!hasPreview && (\n            <ImageIcon className='text-muted-foreground size-4' />\n          )}\n          <AnimatePresence initial={false}>\n            {showsRing && (\n              <motion.span\n                key='upload'\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0 }}\n                className='bg-card/70 text-primary absolute inset-0 flex items-center justify-center rounded-lg'\n              >\n                <UploadRing isDone={isConfirmed} />\n              </motion.span>\n            )}\n          </AnimatePresence>\n        </span>\n        <Button\n          type='button'\n          variant='outline'\n          size='icon-sm'\n          aria-label={removeLabel}\n          disabled={disabled}\n          onClick={() => onRemove(attachment.id)}\n          className='absolute -end-1.5 -top-1.5 size-5'\n        >\n          <XIcon className='size-3' />\n        </Button>\n      </div>\n    );\n  }\n\n  return (\n    <div className='bg-card hairline-ring ring-border flex h-11 max-w-56 items-center gap-2 rounded-lg ps-1.5 pe-1 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n      <span\n        aria-hidden='true'\n        className='text-primary bg-primary/10 flex size-7 shrink-0 items-center justify-center rounded-md'\n      >\n        <Swap swapKey={glyphKeyOf(showsRing)}>\n          {showsRing && <UploadRing isDone={isConfirmed} />}\n          {!showsRing && <FileTextIcon className='size-3.5' />}\n        </Swap>\n      </span>\n      <span className='min-w-0 flex-1'>\n        <span className='block truncate text-xs font-medium'>\n          {attachment.name}\n        </span>\n        <span className='text-muted-foreground block text-xs tabular-nums'>\n          <Swap swapKey={detail}>{detail}</Swap>\n        </span>\n      </span>\n      <Button\n        type='button'\n        variant='ghost'\n        size='icon-sm'\n        aria-label={removeLabel}\n        disabled={disabled}\n        onClick={() => onRemove(attachment.id)}\n        className='text-muted-foreground'\n      >\n        <XIcon className='size-3.5' />\n      </Button>\n    </div>\n  );\n}\n\nfunction RecordingDot({ isBlinking }: { isBlinking: boolean }) {\n  return (\n    <span\n      aria-hidden='true'\n      className={cn(\n        'bg-destructive size-2 shrink-0 rounded-full',\n        isBlinking && 'animate-pulse'\n      )}\n    />\n  );\n}\n\ntype RecordingStripProps = {\n  startedAt: number;\n  onCancel: () => void;\n  onDone: () => void;\n  doneRef?: React.Ref<HTMLButtonElement>;\n  /** Shows Done held down, for a demonstration that presses it. */\n  isDonePressed?: boolean;\n};\n\nexport function RecordingStrip({\n  startedAt,\n  onCancel,\n  onDone,\n  doneRef,\n  isDonePressed = false,\n}: RecordingStripProps) {\n  const isOnScreen = useContext(ClockGateContext);\n\n  return (\n    <div className='flex h-8 items-center gap-2.5 ps-2'>\n      <RecordingDot isBlinking={isOnScreen} />\n      <LevelBars\n        isActive={isOnScreen}\n        count={28}\n        seed={0.6}\n        className='min-w-0 flex-1 justify-end overflow-hidden'\n      />\n      <ClockSince\n        startedAt={startedAt}\n        isRunning\n        className='text-muted-foreground w-9 shrink-0 text-end text-xs'\n      />\n      <Button\n        type='button'\n        variant='ghost'\n        size='sm'\n        onClick={onCancel}\n        className='text-muted-foreground'\n      >\n        Cancel\n      </Button>\n      <Button\n        ref={doneRef}\n        type='button'\n        size='sm'\n        onClick={onDone}\n        className={pressedSolidOf(isDonePressed)}\n      >\n        Done\n      </Button>\n    </div>\n  );\n}\n\ntype Phase = 'idle' | 'recording' | 'answering';\n\ntype NoticeTone = 'working' | 'done' | 'stopped' | 'refusal';\n\ntype Notice = {\n  tone: NoticeTone;\n  text: string;\n};\n\nconst NOTICE_ICON: Record<NoticeTone, React.ReactNode> = {\n  working: <LoaderIcon className='text-muted-foreground size-4 animate-spin' />,\n  done: <CircleCheckIcon className='text-success-foreground size-4' />,\n  stopped: (\n    <span className='flex size-4 items-center justify-center'>\n      <span className='bg-muted-foreground size-2 rounded-[2px]' />\n    </span>\n  ),\n  refusal: <CircleAlertIcon className='text-warning-foreground size-4' />,\n};\n\nconst FOLDERS = [\n  '~/projects/atlas',\n  '~/projects/atlas/web',\n  '~/projects/atlas/api',\n  '~/notes',\n];\n\nconst SEED_ATTACHMENTS: ComposerAttachment[] = [\n  {\n    id: 'seed-whiteboard',\n    name: 'whiteboard.png',\n    size: 482_000,\n    kind: 'image',\n    isUploading: false,\n  },\n  {\n    id: 'seed-roadmap',\n    name: 'atlas-roadmap.md',\n    size: 12_400,\n    kind: 'file',\n    isUploading: false,\n  },\n];\n\nconst MAX_FILES = 4;\n\nconst MAX_BYTES = 10 * MEGABYTE;\n\nconst ANSWER_MS = 3200;\n\nconst WORD_GAP_MS = 70;\n\nconst MAX_FIELD_HEIGHT = 200;\n\nconst TRANSCRIPT = 'Keep the old settings page live until the launch';\n\nconst SEED_DRAFT = 'Plan the billing move with the roadmap attached.';\n\nconst SEED_NOTICE: Notice = { tone: 'done', text: 'Answered' };\n\n/** What a picked, pasted or dropped file brings; a demonstration attaches one without a file behind it. */\ntype Incoming = {\n  name: string;\n  size: number;\n  kind: ComposerAttachment['kind'];\n  file?: File;\n};\n\nconst DEMO_FILE: Incoming = {\n  name: 'q3-invoices.csv',\n  size: 86_400,\n  kind: 'file',\n};\n\ntype PressKey = 'attach' | 'mic' | 'done' | 'send';\n\nconst MODE_PHRASE: Record<PermissionMode, string> = {\n  ask: 'it asks before each edit',\n  accept: 'it edits files as it goes',\n  plan: 'it only writes a plan',\n};\n\nfunction kindOf(file: File): ComposerAttachment['kind'] {\n  const isImage = file.type.startsWith('image/');\n  if (isImage) {\n    return 'image';\n  }\n  return 'file';\n}\n\nfunction incomingOf(file: File): Incoming {\n  return { name: file.name, size: file.size, kind: kindOf(file), file };\n}\n\nfunction previewUrlOf(incoming: Incoming) {\n  if (!incoming.file) {\n    return undefined;\n  }\n  if (incoming.kind !== 'image') {\n    return undefined;\n  }\n  return URL.createObjectURL(incoming.file);\n}\n\nfunction footerClassOf(isRecording: boolean) {\n  if (isRecording) {\n    return 'opacity-0';\n  }\n  return 'opacity-100';\n}\n\nfunction refusalOf(tooLargeName: string | null, hasOverflow: boolean) {\n  if (tooLargeName) {\n    const limit = formatBytes(MAX_BYTES);\n    return `“${tooLargeName}” is over ${limit}. Attach a smaller copy`;\n  }\n  if (hasOverflow) {\n    const files = countOf(MAX_FILES, 'file');\n    return `${files} fit in one prompt. Remove one to add another`;\n  }\n  return null;\n}\n\nfunction hasDraggedFiles(event: React.DragEvent) {\n  const types = Array.from(event.dataTransfer.types);\n  return types.includes('Files');\n}\n\nfunction revokePreview(attachment: ComposerAttachment) {\n  if (attachment.previewUrl) {\n    URL.revokeObjectURL(attachment.previewUrl);\n  }\n}\n\nfunction sendKeyLabelOf(isAnswering: boolean) {\n  if (isAnswering) {\n    return 'Stop the answer';\n  }\n  return 'Send the prompt';\n}\n\nfunction noticeKeyOf(notice: Notice) {\n  return `${notice.tone}:${notice.text}`;\n}\n\nexport default function Prompt02() {\n  const [draft, setDraft] = useState(SEED_DRAFT);\n  const [attachments, setAttachments] =\n    useState<ComposerAttachment[]>(SEED_ATTACHMENTS);\n  const [mode, setMode] = useState<PermissionMode>('ask');\n  const [modelId, setModelId] = useState('claude-sonnet');\n  const [apps, setApps] = useState<AppId[]>(['calendar', 'tracker']);\n  const [folder, setFolder] = useState(FOLDERS[0]);\n  const [phase, setPhase] = useState<Phase>('idle');\n  const [recordingSince, setRecordingSince] = useState(0);\n  const [notice, setNotice] = useState<Notice | null>(SEED_NOTICE);\n  const [isDraggingFiles, setIsDraggingFiles] = useState(false);\n  const { schedule, clearAll } = useTimeouts();\n  const { pressed, press } = usePress<PressKey>();\n  const textareaRef = useRef<HTMLTextAreaElement>(null);\n  const fileInputRef = useRef<HTMLInputElement>(null);\n  const doneRef = useRef<HTMLButtonElement>(null);\n  const micRef = useRef<HTMLButtonElement>(null);\n  const previews = useRef(new Set<string>());\n  const dragDepth = useRef(0);\n  const idCounter = useRef(0);\n  const sentDraft = useRef('');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const noticePresence = fadePresence();\n  const stripPresence = risePresenceOf(shouldReduceMotion);\n  const layoutSpring = springOf(shouldReduceMotion);\n  const isRecording = phase === 'recording';\n  const isAnswering = phase === 'answering';\n  const isBusy = phase !== 'idle';\n  const hasText = draft.trim().length > 0;\n  const hasAttachments = attachments.length > 0;\n  const isUploading = attachments.some((item) => item.isUploading);\n  const hasContent = hasText || hasAttachments;\n  const canSend = hasContent && !isUploading;\n  const isKeyEnabled = isAnswering || canSend;\n  const model = modelOf(modelId);\n  const announcement = notice?.text ?? '';\n  const attachmentIds = attachments.map((item) => item.id);\n  const attachmentOrder = attachmentIds.join(' ');\n  useAutosize(textareaRef, draft, MAX_FIELD_HEIGHT);\n\n  useEffect(() => {\n    const urls = previews.current;\n    return () => {\n      urls.forEach((url) => URL.revokeObjectURL(url));\n      urls.clear();\n    };\n  }, []);\n\n  function nextId() {\n    idCounter.current += 1;\n    return `file-${idCounter.current}`;\n  }\n\n  function finishUpload(id: string) {\n    setAttachments((current) =>\n      current.map((item) => {\n        if (item.id !== id) {\n          return item;\n        }\n        return { ...item, isUploading: false };\n      })\n    );\n  }\n\n  function attach(incoming: Incoming[]) {\n    const room = MAX_FILES - attachments.length;\n    const accepted: ComposerAttachment[] = [];\n    let tooLargeName: string | null = null;\n    let hasOverflow = false;\n    for (const item of incoming) {\n      const isTooLarge = item.size > MAX_BYTES;\n      if (isTooLarge) {\n        tooLargeName = item.name;\n        continue;\n      }\n      const isOutOfRoom = accepted.length >= room;\n      if (isOutOfRoom) {\n        hasOverflow = true;\n        continue;\n      }\n      const previewUrl = previewUrlOf(item);\n      if (previewUrl) {\n        previews.current.add(previewUrl);\n      }\n      accepted.push({\n        id: nextId(),\n        name: item.name,\n        size: item.size,\n        kind: item.kind,\n        isUploading: true,\n        previewUrl,\n      });\n    }\n    setAttachments((current) => [...current, ...accepted]);\n    accepted.forEach((item, index) => {\n      const stagger = index * 250;\n      schedule(() => finishUpload(item.id), UPLOAD_MS + stagger);\n    });\n    const refusal = refusalOf(tooLargeName, hasOverflow);\n    if (refusal) {\n      setNotice({ tone: 'refusal', text: refusal });\n    }\n  }\n\n  function addFiles(files: File[]) {\n    attach(files.map(incomingOf));\n  }\n\n  function removeAttachment(id: string) {\n    const removed = attachments.find((item) => item.id === id);\n    if (removed) {\n      revokePreview(removed);\n    }\n    setAttachments((current) => current.filter((item) => item.id !== id));\n    setNotice(null);\n  }\n\n  function pickFiles(event: React.ChangeEvent<HTMLInputElement>) {\n    const list = event.target.files;\n    if (list) {\n      addFiles(Array.from(list));\n    }\n    event.target.value = '';\n  }\n\n  function pasteFiles(event: React.ClipboardEvent<HTMLTextAreaElement>) {\n    const files = Array.from(event.clipboardData.files);\n    if (files.length === 0) {\n      return;\n    }\n    event.preventDefault();\n    addFiles(files);\n  }\n\n  function enterDrag(event: React.DragEvent<HTMLDivElement>) {\n    if (!hasDraggedFiles(event)) {\n      return;\n    }\n    event.preventDefault();\n    dragDepth.current += 1;\n    setIsDraggingFiles(true);\n  }\n\n  function holdDrag(event: React.DragEvent<HTMLDivElement>) {\n    if (hasDraggedFiles(event)) {\n      event.preventDefault();\n    }\n  }\n\n  function leaveDrag(event: React.DragEvent<HTMLDivElement>) {\n    if (!hasDraggedFiles(event)) {\n      return;\n    }\n    dragDepth.current = Math.max(0, dragDepth.current - 1);\n    if (dragDepth.current === 0) {\n      setIsDraggingFiles(false);\n    }\n  }\n\n  function dropFiles(event: React.DragEvent<HTMLDivElement>) {\n    if (!hasDraggedFiles(event)) {\n      return;\n    }\n    event.preventDefault();\n    dragDepth.current = 0;\n    setIsDraggingFiles(false);\n    const files = Array.from(event.dataTransfer.files);\n    if (isBusy) {\n      return;\n    }\n    addFiles(files);\n  }\n\n  function startRecording() {\n    setNotice(null);\n    setRecordingSince(Date.now());\n    setPhase('recording');\n    if (isAutoplaying) {\n      return;\n    }\n    requestAnimationFrame(() => doneRef.current?.focus());\n  }\n\n  function cancelRecording() {\n    setPhase('idle');\n    requestAnimationFrame(() => micRef.current?.focus());\n  }\n\n  function finishRecording() {\n    setPhase('idle');\n    const words = wordsOf(TRANSCRIPT);\n    words.forEach((word, index) => {\n      const delay = (index + 1) * WORD_GAP_MS;\n      schedule(() => setDraft((current) => appendWord(current, word)), delay);\n    });\n    if (isAutoplaying) {\n      return;\n    }\n    const streamEnd = (words.length + 1) * WORD_GAP_MS;\n    schedule(() => caretToEnd(textareaRef), streamEnd);\n    caretToEnd(textareaRef);\n  }\n\n  function send() {\n    if (!canSend) {\n      return;\n    }\n    if (isBusy) {\n      return;\n    }\n    clearAll();\n    sentDraft.current = draft;\n    const phrase = MODE_PHRASE[mode];\n    setPhase('answering');\n    setNotice({\n      tone: 'working',\n      text: `${model.name} is working in ${folder}, ${phrase}`,\n    });\n    schedule(() => {\n      attachments.forEach(revokePreview);\n      setPhase('idle');\n      setDraft('');\n      setAttachments([]);\n      setNotice({ tone: 'done', text: `${model.name} answered` });\n    }, ANSWER_MS);\n  }\n\n  function stop() {\n    clearAll();\n    setPhase('idle');\n    setDraft(sentDraft.current);\n    setNotice({\n      tone: 'stopped',\n      text: 'Stopped. Your prompt is back in the field',\n    });\n    caretToEnd(textareaRef);\n  }\n\n  function pressSendKey() {\n    if (isAnswering) {\n      stop();\n      return;\n    }\n    send();\n  }\n\n  function handleFieldKeys(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n    if (!isSendKey(event)) {\n      return;\n    }\n    event.preventDefault();\n    send();\n  }\n\n  function handleEscape(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key !== 'Escape') {\n      return;\n    }\n    if (!isOwnKey(event)) {\n      return;\n    }\n    if (isRecording) {\n      event.preventDefault();\n      cancelRecording();\n      return;\n    }\n    if (isAnswering) {\n      event.preventDefault();\n      stop();\n    }\n  }\n\n  function resetDemo() {\n    clearAll();\n    setAttachments(SEED_ATTACHMENTS);\n    setDraft(SEED_DRAFT);\n    setMode('ask');\n    setModelId('claude-sonnet');\n    setPhase('idle');\n    setNotice(SEED_NOTICE);\n  }\n\n  const dictatedWords = wordsOf(TRANSCRIPT);\n  const streamMs = (dictatedWords.length + 1) * WORD_GAP_MS;\n  const steps: AutoplayStep[] = [\n    { after: 1500, run: () => press('attach') },\n    { after: PRESS_LEAD_MS, run: () => attach([DEMO_FILE]) },\n    { after: UPLOAD_MS + CHECK_HOLD_MS + 500, run: () => setMode('accept') },\n    { after: 1300, run: () => setMode('ask') },\n    { after: 900, run: () => setModelId('claude-opus') },\n    { after: 1100, run: () => press('mic') },\n    { after: PRESS_LEAD_MS, run: startRecording },\n    { after: 2400, run: () => press('done') },\n    { after: PRESS_LEAD_MS, run: finishRecording },\n    { after: streamMs + 700, run: () => press('send') },\n    { after: PRESS_LEAD_MS, run: pressSendKey },\n    { after: ANSWER_MS + 500, run: hold },\n  ];\n  const { ref, isInView, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 2600,\n    onReset: resetDemo,\n  });\n\n  useKeptHeight(ref);\n\n  return (\n    <div\n      ref={ref}\n      onKeyDown={handleEscape}\n      className='flex w-full max-w-2xl flex-col gap-2'\n    >\n      <ClockGate isActive={isInView}>\n        <div\n          onDragEnter={enterDrag}\n          onDragOver={holdDrag}\n          onDragLeave={leaveDrag}\n          onDrop={dropFiles}\n          className='bg-card hairline-ring ring-foreground/12 dark:ring-foreground/15 has-[textarea:focus]:ring-ring/25 relative flex flex-col rounded-xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-shadow duration-150 has-[textarea:focus]:ring-[3px]'\n        >\n          <AnimatedSize>\n            <ul\n              aria-label='Attachments'\n              className={cn(\n                'flex flex-wrap gap-2',\n                hasAttachments && 'px-1 pt-1.5 pb-2'\n              )}\n            >\n              <AnimatePresence initial={false} mode='popLayout'>\n                {attachments.map((attachment) => (\n                  <motion.li\n                    key={attachment.id}\n                    layout\n                    layoutDependency={attachmentOrder}\n                    initial={{ opacity: 0, scale: 0.95 }}\n                    animate={{ opacity: 1, scale: 1 }}\n                    exit={{ opacity: 0, scale: 0.95 }}\n                    transition={layoutSpring}\n                  >\n                    <AttachmentTile\n                      attachment={attachment}\n                      onRemove={removeAttachment}\n                      disabled={isBusy}\n                    />\n                  </motion.li>\n                ))}\n              </AnimatePresence>\n            </ul>\n            <Textarea\n              ref={textareaRef}\n              rows={1}\n              value={draft}\n              onChange={(event) => setDraft(event.target.value)}\n              onKeyDown={handleFieldKeys}\n              onPaste={pasteFiles}\n              readOnly={isRecording}\n              aria-label='Prompt'\n              placeholder='Ask to plan, edit or explain. Paste or drop files'\n              className='max-h-none min-h-10 border-0 bg-transparent px-2 py-1.5 shadow-none ring-0 focus-visible:ring-0 dark:bg-transparent'\n            />\n            <input\n              ref={fileInputRef}\n              type='file'\n              multiple\n              tabIndex={-1}\n              aria-hidden='true'\n              className='hidden'\n              onChange={pickFiles}\n            />\n          </AnimatedSize>\n          {/*\n                The strip lies over a footer that keeps its place, so nothing resizes when one\n                becomes the other and the clock of the strip ticks outside any resizing box.\n              */}\n          <div className='relative pt-1'>\n            <div\n              inert={isRecording}\n              className={cn(\n                'flex flex-wrap items-center gap-1 transition-opacity duration-150',\n                footerClassOf(isRecording)\n              )}\n            >\n              <Button\n                type='button'\n                variant='ghost'\n                size='icon'\n                aria-label='Attach files'\n                disabled={isBusy}\n                onClick={() => fileInputRef.current?.click()}\n                className={cn(\n                  'text-muted-foreground',\n                  pressedQuietOf(pressed === 'attach')\n                )}\n              >\n                <PaperclipIcon />\n              </Button>\n              <PermissionModeMenu\n                value={mode}\n                onValueChange={setMode}\n                disabled={isBusy}\n              />\n              <ModelMenu\n                value={modelId}\n                onValueChange={setModelId}\n                disabled={isBusy}\n              />\n              <ConnectedAppsMenu\n                value={apps}\n                onValueChange={setApps}\n                disabled={isBusy}\n              />\n              <FolderMenu\n                value={folder}\n                folders={FOLDERS}\n                onValueChange={setFolder}\n                disabled={isBusy}\n              />\n              <span className='ms-auto flex items-center gap-1'>\n                <Button\n                  ref={micRef}\n                  type='button'\n                  variant='ghost'\n                  size='icon'\n                  aria-label='Dictate'\n                  disabled={isBusy}\n                  onClick={startRecording}\n                  className={cn(\n                    'text-muted-foreground',\n                    pressedQuietOf(pressed === 'mic')\n                  )}\n                >\n                  <MicIcon />\n                </Button>\n                <Button\n                  type='button'\n                  size='icon'\n                  aria-label={sendKeyLabelOf(isAnswering)}\n                  disabled={!isKeyEnabled}\n                  focusableWhenDisabled\n                  onClick={pressSendKey}\n                  className={pressedSolidOf(pressed === 'send')}\n                >\n                  <Swap swapKey={String(isAnswering)}>\n                    {isAnswering && (\n                      <span\n                        aria-hidden='true'\n                        className='size-2.5 rounded-[2px] bg-current'\n                      />\n                    )}\n                    {!isAnswering && <ArrowUpIcon />}\n                  </Swap>\n                </Button>\n              </span>\n            </div>\n            <AnimatePresence initial={false}>\n              {isRecording && (\n                <motion.div\n                  key='strip'\n                  className='absolute inset-x-0 bottom-0'\n                  {...stripPresence}\n                >\n                  <RecordingStrip\n                    startedAt={recordingSince}\n                    onCancel={cancelRecording}\n                    onDone={finishRecording}\n                    doneRef={doneRef}\n                    isDonePressed={pressed === 'done'}\n                  />\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n          <AnimatePresence>\n            {isDraggingFiles && (\n              <motion.div\n                key='drop'\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0 }}\n                transition={{ duration: 0.15 }}\n                className='bg-card/90 hairline-border border-primary/50 pointer-events-none absolute inset-1 flex flex-col items-center justify-center gap-1.5 rounded-[calc(var(--radius-xl)-0.25rem)] border-dashed'\n              >\n                <UploadCloudIcon className='text-primary-ink size-5' />\n                <p className='text-[13px] font-medium'>Drop to attach</p>\n                <p className='text-muted-foreground text-xs'>\n                  Up to {countOf(MAX_FILES, 'file')}, {formatBytes(MAX_BYTES)}{' '}\n                  each\n                </p>\n              </motion.div>\n            )}\n          </AnimatePresence>\n        </div>\n        <AnimatedSize>\n          <AnimatePresence initial={false} mode='popLayout'>\n            {notice && (\n              <motion.p\n                key={noticeKeyOf(notice)}\n                className='text-muted-foreground flex items-start gap-2 px-1 pt-1 text-[13px] leading-5'\n                {...noticePresence}\n              >\n                <span className='mt-0.5 shrink-0'>\n                  {NOTICE_ICON[notice.tone]}\n                </span>\n                {notice.text}\n              </motion.p>\n            )}\n          </AnimatePresence>\n        </AnimatedSize>\n      </ClockGate>\n      <LiveRegion message={spokenUnless(isAutoplaying, announcement)} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/prompt/prompt-02.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/clock.tsx",
      "content": "'use client';\n\nimport { useNow } from '@/registry/ndeko/hooks/use-agent-run';\nimport { formatClock } from '@/registry/ndeko/lib/media-clock';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\ntype ClockSinceProps = {\n  startedAt: number;\n  isRunning: boolean;\n  className?: string;\n};\n\n/** A minutes and seconds clock; only this text re-renders while it runs. */\nexport function ClockSince({\n  startedAt,\n  isRunning,\n  className,\n}: ClockSinceProps) {\n  const now = useNow(250, isRunning);\n  const elapsed = now - startedAt;\n  const text = formatClock(elapsed);\n\n  return <span className={cn('tabular-nums', className)}>{text}</span>;\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/clock.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/lab-tile.tsx",
      "content": "import { BrandTile, type BrandTileSize } from '@/registry/ndeko/ui/brand-tile';\n\nimport { labOf, type LabId } from './labs';\n\ntype LabTileProps = {\n  lab: LabId;\n  size?: BrandTileSize;\n  className?: string;\n};\n\nexport function LabTile({ lab, size = 'md', className }: LabTileProps) {\n  const entry = labOf(lab);\n\n  return <BrandTile brand={entry.brand} size={size} className={className} />;\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/lab-tile.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/labs.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type LabId = 'anthropic' | 'openai' | 'google' | 'deepseek';\n\nexport type Lab = {\n  id: LabId;\n  name: string;\n  brand: BrandSlug;\n};\n\nexport type Capability = 'vision' | 'tools' | 'reasoning' | 'long-context';\n\nexport type Tier = 1 | 2 | 3;\n\nexport type ModelOption = {\n  id: string;\n  name: string;\n  lab: LabId;\n  /** How many tokens the model reads at once. Illustrative in the demos. */\n  contextTokens: number;\n  /** 1 is the slowest, 3 the fastest. */\n  speed: Tier;\n  /** 1 is the cheapest, 3 the dearest. */\n  price: Tier;\n  capabilities: Capability[];\n  hint: string;\n};\n\nexport const LABS: Lab[] = [\n  { id: 'anthropic', name: 'Anthropic', brand: 'claude' },\n  { id: 'openai', name: 'OpenAI', brand: 'openai' },\n  { id: 'google', name: 'Google', brand: 'gemini' },\n  { id: 'deepseek', name: 'DeepSeek', brand: 'deepseek' },\n];\n\n/** Families without a version number; context, speed and price are coarse tiers for the demos, not facts about a model. */\nexport const MODELS: ModelOption[] = [\n  {\n    id: 'claude-haiku',\n    name: 'Claude Haiku',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 3,\n    price: 1,\n    capabilities: ['tools'],\n    hint: 'Quick replies and small edits',\n  },\n  {\n    id: 'claude-sonnet',\n    name: 'Claude Sonnet',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 2,\n    price: 2,\n    capabilities: ['vision', 'tools', 'long-context'],\n    hint: 'Everyday work across long files',\n  },\n  {\n    id: 'claude-opus',\n    name: 'Claude Opus',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 1,\n    price: 3,\n    capabilities: ['vision', 'tools', 'reasoning', 'long-context'],\n    hint: 'Hard problems that need a plan',\n  },\n  {\n    id: 'gpt-mini',\n    name: 'GPT mini',\n    lab: 'openai',\n    contextTokens: 128_000,\n    speed: 3,\n    price: 1,\n    capabilities: ['tools'],\n    hint: 'Cheap bulk tasks',\n  },\n  {\n    id: 'gemini-pro',\n    name: 'Gemini Pro',\n    lab: 'google',\n    contextTokens: 1_000_000,\n    speed: 1,\n    price: 3,\n    capabilities: ['vision', 'tools', 'reasoning', 'long-context'],\n    hint: 'Whole repositories at once',\n  },\n  {\n    id: 'deepseek',\n    name: 'DeepSeek',\n    lab: 'deepseek',\n    contextTokens: 64_000,\n    speed: 2,\n    price: 1,\n    capabilities: ['tools', 'reasoning'],\n    hint: 'Reasoning on a budget',\n  },\n];\n\nexport const CAPABILITIES: Capability[] = [\n  'vision',\n  'tools',\n  'reasoning',\n  'long-context',\n];\n\nexport const CAPABILITY_LABEL: Record<Capability, string> = {\n  vision: 'Vision',\n  tools: 'Tools',\n  reasoning: 'Reasoning',\n  'long-context': 'Long context',\n};\n\nexport const SPEED_WORD: Record<Tier, string> = {\n  1: 'Slow',\n  2: 'Medium speed',\n  3: 'Fast',\n};\n\nexport const PRICE_WORD: Record<Tier, string> = {\n  1: 'Low price',\n  2: 'Medium price',\n  3: 'High price',\n};\n\nconst FALLBACK_LAB = LABS[0];\n\nconst FALLBACK_MODEL = MODELS[0];\n\nexport function labOf(id: LabId) {\n  const lab = LABS.find((candidate) => candidate.id === id);\n  return lab ?? FALLBACK_LAB;\n}\n\nexport function modelOf(id: string) {\n  const model = MODELS.find((candidate) => candidate.id === id);\n  return model ?? FALLBACK_MODEL;\n}\n\n/** 32k, 200k, 1M. */\nexport function contextLabelOf(tokens: number) {\n  const isMillion = tokens >= 1_000_000;\n  if (isMillion) {\n    const millions = Math.round(tokens / 1_000_000);\n    return `${millions}M`;\n  }\n  const thousands = Math.round(tokens / 1000);\n  return `${thousands}k`;\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/labs.ts"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/use-autosize.ts",
      "content": "'use client';\n\nimport { useLayoutEffect } from 'react';\n\nfunction fitHeight(textarea: HTMLTextAreaElement, maxHeight: number) {\n  textarea.style.height = 'auto';\n  const height = Math.min(textarea.scrollHeight, maxHeight);\n  textarea.style.height = `${height}px`;\n}\n\n/** Also fits again when the width changes, and when `remountKey` changes for a textarea shown again. */\nexport function useAutosize(\n  ref: React.RefObject<HTMLTextAreaElement | null>,\n  value: string,\n  maxHeight: number,\n  remountKey?: unknown\n) {\n  useLayoutEffect(() => {\n    const textarea = ref.current;\n    if (!textarea) {\n      return;\n    }\n    fitHeight(textarea, maxHeight);\n    let lastWidth = textarea.offsetWidth;\n    const observer = new ResizeObserver(() => {\n      const width = textarea.offsetWidth;\n      if (width === lastWidth) {\n        return;\n      }\n      lastWidth = width;\n      fitHeight(textarea, maxHeight);\n    });\n    observer.observe(textarea);\n    return () => observer.disconnect();\n  }, [ref, value, maxHeight, remountKey]);\n}\n\nexport function isSendKey(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n  const isEnter = event.key === 'Enter';\n  const isNewLine = event.shiftKey;\n  const isComposing = event.nativeEvent.isComposing;\n  const isPlainEnter = isEnter && !isNewLine;\n  return isPlainEnter && !isComposing;\n}\n\n/** Puts the caret after the last character once React has committed the new text. */\nexport function caretToEnd(ref: React.RefObject<HTMLTextAreaElement | null>) {\n  requestAnimationFrame(() => {\n    const textarea = ref.current;\n    if (!textarea) {\n      return;\n    }\n    const end = textarea.value.length;\n    textarea.focus();\n    textarea.setSelectionRange(end, end);\n  });\n}\n\n/** Keydown that started inside this element, not in a menu or popover portalled out of it. */\nexport function isOwnKey(event: React.KeyboardEvent<HTMLElement>) {\n  const target = event.target;\n  if (!(target instanceof Node)) {\n    return false;\n  }\n  return event.currentTarget.contains(target);\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/use-autosize.ts"
    }
  ],
  "categories": [
    "components",
    "prompt"
  ],
  "type": "registry:component"
}