{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "application-05",
  "title": "Assistant",
  "description": "A Quillstone assistant: conversations on the left that go into a sheet on phones, a reply that streams in while Send becomes Stop, a composer that takes files and a model, a reply that folds its reasoning and runs two tool calls, and a new chat that starts from suggested prompts.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-container.json",
    "https://ui.ndekocode.dev/r/chat-file-upload.json",
    "https://ui.ndekocode.dev/r/chat-loader.json",
    "https://ui.ndekocode.dev/r/chat-message.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chat-prompt-input.json",
    "https://ui.ndekocode.dev/r/chat-prompt-suggestion.json",
    "https://ui.ndekocode.dev/r/chat-reasoning.json",
    "https://ui.ndekocode.dev/r/chat-response-stream.json",
    "https://ui.ndekocode.dev/r/chat-scroll-button.json",
    "https://ui.ndekocode.dev/r/chat-source.json",
    "https://ui.ndekocode.dev/r/chat-tool.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/kbd.json",
    "https://ui.ndekocode.dev/r/select.json",
    "https://ui.ndekocode.dev/r/sheet.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/templates/chat/application-05/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { Sheet, SheetContent, SheetTitle } from '@/registry/ndeko/ui/sheet';\n\nimport { ConversationSidebar } from './conversation-list';\nimport { ConversationView } from './conversation-view';\nimport {\n  NEW_CHAT_TITLE,\n  TITLE_WORD_LIMIT,\n  newChatReplies,\n  reader,\n  seedConversations,\n  type Conversation,\n} from './data';\n\nfunction titleOf(text: string) {\n  const words = text.trim().split(/\\s+/);\n  const shown = words.slice(0, TITLE_WORD_LIMIT);\n  return shown.join(' ');\n}\n\nfunction isListed(conversation: Conversation) {\n  return !conversation.isDraft;\n}\n\nfunction namedConversation(\n  conversation: Conversation,\n  conversationId: string,\n  title: string\n): Conversation {\n  if (conversation.id !== conversationId) {\n    return conversation;\n  }\n  return { ...conversation, title, isDraft: false };\n}\n\nfunction draftOf(draftNumber: number): Conversation {\n  return {\n    id: `chat-${draftNumber}`,\n    title: NEW_CHAT_TITLE,\n    turns: [],\n    replies: newChatReplies,\n    isDraft: true,\n  };\n}\n\nexport default function Application05() {\n  const [conversations, setConversations] =\n    useState<Conversation[]>(seedConversations);\n  const [activeId, setActiveId] = useState(seedConversations[0].id);\n  const [draftCount, setDraftCount] = useState(0);\n  const [isNavigationOpen, setIsNavigationOpen] = useState(false);\n  const listedConversations = conversations.filter(isListed);\n\n  function openConversation(conversationId: string) {\n    setActiveId(conversationId);\n    setIsNavigationOpen(false);\n  }\n\n  function startNewChat() {\n    setIsNavigationOpen(false);\n    const openDraft = conversations.find(\n      (conversation) => conversation.isDraft\n    );\n    if (openDraft) {\n      setActiveId(openDraft.id);\n      return;\n    }\n    const draftNumber = draftCount + 1;\n    const draft = draftOf(draftNumber);\n    setDraftCount(draftNumber);\n    setConversations((current) => [draft, ...current]);\n    setActiveId(draft.id);\n  }\n\n  function nameConversation(conversationId: string, titleSource: string) {\n    const title = titleOf(titleSource);\n    setConversations((current) =>\n      current.map((conversation) =>\n        namedConversation(conversation, conversationId, title)\n      )\n    );\n  }\n\n  function openNavigation() {\n    setIsNavigationOpen(true);\n  }\n\n  const sidebarProps = {\n    conversations: listedConversations,\n    activeId,\n    person: reader,\n    onSelect: openConversation,\n    onNewChat: startNewChat,\n  };\n\n  return (\n    <div className='bg-sidebar text-foreground flex h-dvh min-h-[30rem] w-full md:p-2'>\n      <aside\n        aria-label='Conversations'\n        className='hidden w-64 shrink-0 pr-2 md:block'\n      >\n        <ConversationSidebar {...sidebarProps} />\n      </aside>\n      <Sheet open={isNavigationOpen} onOpenChange={setIsNavigationOpen}>\n        <SheetContent\n          side='left'\n          showCloseButton={false}\n          className='bg-sidebar w-72 gap-0 p-2'\n        >\n          <SheetTitle className='sr-only'>Conversations</SheetTitle>\n          <ConversationSidebar {...sidebarProps} />\n        </SheetContent>\n      </Sheet>\n      <main className='bg-background md:hairline-ring md:ring-border flex min-w-0 flex-1 flex-col overflow-clip md:rounded-xl md:shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n        {conversations.map((conversation) => (\n          <div\n            key={conversation.id}\n            hidden={conversation.id !== activeId}\n            className='flex min-h-0 flex-1 flex-col'\n          >\n            <ConversationView\n              conversation={conversation}\n              onFirstMessage={nameConversation}\n              onOpenNavigation={openNavigation}\n            />\n          </div>\n        ))}\n      </main>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/index.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/conversation-list.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  FeatherIcon,\n  MessageCircleIcon,\n  PlusIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport { AccountMenu } from './account-menu';\nimport { PRODUCT_NAME, type Conversation, type Person } from './data';\nimport { revealVariantsOf } from './presence';\nimport { ActiveRowIndicator, NAV_ROW, ariaCurrentOf } from './sidebar-parts';\n\nexport function QuillstoneMark() {\n  return (\n    <span\n      aria-hidden='true'\n      className='gem-plate inline-flex size-6 shrink-0 items-center justify-center rounded-md [--gem:var(--primary)] [&_svg]:size-3.5'\n    >\n      <FeatherIcon />\n    </span>\n  );\n}\n\ntype ConversationRowProps = {\n  conversation: Conversation;\n  isActive: boolean;\n  indicatorId: string;\n  onSelect: (conversationId: string) => void;\n};\n\nfunction ConversationRow({\n  conversation,\n  isActive,\n  indicatorId,\n  onSelect,\n}: ConversationRowProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = revealVariantsOf(shouldReduceMotion);\n  const ariaCurrent = ariaCurrentOf(isActive);\n\n  function select() {\n    onSelect(conversation.id);\n  }\n\n  return (\n    <motion.li\n      variants={variants}\n      initial='hidden'\n      animate='shown'\n      exit='hidden'\n    >\n      <button\n        type='button'\n        aria-current={ariaCurrent}\n        onClick={select}\n        className={NAV_ROW}\n      >\n        {isActive && <ActiveRowIndicator layoutId={indicatorId} />}\n        <MessageCircleIcon />\n        <span className='relative min-w-0 flex-1 truncate'>\n          {conversation.title}\n        </span>\n      </button>\n    </motion.li>\n  );\n}\n\ntype ConversationSidebarProps = {\n  conversations: Conversation[];\n  activeId: string;\n  person: Person;\n  onSelect: (conversationId: string) => void;\n  onNewChat: () => void;\n};\n\nexport function ConversationSidebar({\n  conversations,\n  activeId,\n  person,\n  onSelect,\n  onNewChat,\n}: ConversationSidebarProps) {\n  const indicatorId = useId();\n\n  return (\n    <div className='flex h-full min-h-0 flex-col gap-3'>\n      <div className='flex flex-col gap-2'>\n        <div className='flex h-9 items-center gap-2 px-1.5'>\n          <QuillstoneMark />\n          <span className='text-[13px] font-semibold'>{PRODUCT_NAME}</span>\n        </div>\n        <Button\n          variant='outline'\n          onClick={onNewChat}\n          className='w-full justify-start'\n        >\n          <PlusIcon />\n          New chat\n        </Button>\n      </div>\n      <nav\n        aria-label='Conversations'\n        className='-mx-2 flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2'\n      >\n        <p className='text-muted-foreground flex h-6 items-center px-2 text-xs font-medium'>\n          Recent\n        </p>\n        <ul className='flex flex-col'>\n          <AnimatePresence initial={false}>\n            {conversations.map((conversation) => (\n              <ConversationRow\n                key={conversation.id}\n                conversation={conversation}\n                isActive={conversation.id === activeId}\n                indicatorId={indicatorId}\n                onSelect={onSelect}\n              />\n            ))}\n          </AnimatePresence>\n        </ul>\n      </nav>\n      <AccountMenu person={person} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/conversation-list.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/sidebar-parts.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport type { Person } from './data';\n\nexport const NAV_ROW = [\n  'relative flex h-7 w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-[13px] font-medium text-foreground outline-none',\n  'transition-colors duration-150 hover:bg-foreground/5 focus-visible:ring-[3px] focus-visible:ring-ring/25',\n  \"[&_svg]:pointer-events-none [&_svg]:relative [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground\",\n].join(' ');\n\nconst INDICATOR_TRAVEL: Transition = {\n  duration: 0.25,\n  ease: [0.77, 0, 0.175, 1],\n};\n\nconst INSTANT: Transition = { duration: 0 };\n\nfunction travelOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return INDICATOR_TRAVEL;\n}\n\n/** The one highlight of the active row. It travels from the old row to the new one. */\nexport function ActiveRowIndicator({ layoutId }: { layoutId: string }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <motion.span\n      aria-hidden='true'\n      layoutId={layoutId}\n      transition={travelOf(shouldReduceMotion)}\n      className='bg-foreground/[0.07] absolute inset-0 rounded-md'\n    />\n  );\n}\n\nexport function PersonAvatar({\n  person,\n  className,\n}: {\n  person: Person;\n  className?: string;\n}) {\n  return <Avatar className={className} seed={person.name} />;\n}\n\nexport function ariaCurrentOf(isActive: boolean) {\n  if (isActive) {\n    return 'page' as const;\n  }\n  return undefined;\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/sidebar-parts.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/account-menu.tsx",
      "content": "'use client';\n\nimport {\n  ChevronsUpDownIcon,\n  CommandIcon,\n  LifeBuoyIcon,\n  LogOutIcon,\n  SettingsIcon,\n  UserIcon,\n} from '@/registry/ndeko/lib/icons';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\n\nimport type { Person } from './data';\nimport { PersonAvatar } from './sidebar-parts';\n\nconst TRIGGER = [\n  'flex h-9 w-full min-w-0 items-center gap-2 rounded-md px-1.5 text-left outline-none',\n  'transition-colors duration-150 hover:bg-foreground/5 data-popup-open:bg-foreground/5 focus-visible:ring-[3px] focus-visible:ring-ring/25',\n].join(' ');\n\nexport function AccountMenuItems({ person }: { person: Person }) {\n  return (\n    <>\n      <div className='flex items-center gap-2.5 px-2 py-2'>\n        <PersonAvatar person={person} />\n        <div className='min-w-0'>\n          <p className='truncate text-[13px] font-medium'>{person.name}</p>\n          <p className='text-muted-foreground truncate text-xs'>\n            {person.role}\n          </p>\n        </div>\n      </div>\n      <DropdownMenuSeparator />\n      <DropdownMenuItem>\n        <UserIcon />\n        Profile\n      </DropdownMenuItem>\n      <DropdownMenuItem>\n        <SettingsIcon />\n        Preferences\n      </DropdownMenuItem>\n      <DropdownMenuItem>\n        <CommandIcon />\n        Keyboard shortcuts\n        <Kbd className='ml-auto'>?</Kbd>\n      </DropdownMenuItem>\n      <DropdownMenuItem>\n        <LifeBuoyIcon />\n        Help and docs\n      </DropdownMenuItem>\n      <DropdownMenuSeparator />\n      <DropdownMenuItem variant='destructive'>\n        <LogOutIcon />\n        Log out\n      </DropdownMenuItem>\n    </>\n  );\n}\n\nexport function AccountMenu({ person }: { person: Person }) {\n  return (\n    <DropdownMenu>\n      <DropdownMenuTrigger\n        render={\n          <button\n            type='button'\n            aria-label={`Account: ${person.name}`}\n            className={TRIGGER}\n          />\n        }\n      >\n        <PersonAvatar person={person} className='size-6 text-[10px]' />\n        <span className='min-w-0 flex-1 truncate text-[13px] font-medium'>\n          {person.name}\n        </span>\n        <ChevronsUpDownIcon className='text-muted-foreground size-3.5 shrink-0' />\n      </DropdownMenuTrigger>\n      <DropdownMenuContent side='top' align='start' className='w-60'>\n        <AccountMenuItems person={person} />\n      </DropdownMenuContent>\n    </DropdownMenu>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/account-menu.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/conversation-view.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { FileTextIcon, MenuIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  ChatContainerContent,\n  ChatContainerRoot,\n  type ChatContainerContext,\n} from '@/registry/ndeko/ui/chat-container';\nimport { useTextStream } from '@/registry/ndeko/ui/chat-response-stream';\nimport { ScrollButton } from '@/registry/ndeko/ui/chat-scroll-button';\n\nimport { Composer, type SentPrompt } from './composer';\nimport {\n  PRODUCT_NAME,\n  thinkingMs,\n  wordDelayMs,\n  type AssistantTurn,\n  type ChatTurn,\n  type Conversation,\n  type Feedback,\n  type PageContext,\n  type ReplyStatus,\n} from './data';\nimport { rowPresenceOf } from './presence';\nimport { ReasoningReply } from './reasoning-reply';\nimport { AssistantMessage, UserMessage } from './turns';\n\ntype FeedbackByTurn = Record<string, Feedback | undefined>;\n\nfunction replyAt(replies: string[], count: number) {\n  const index = count % replies.length;\n  return replies[index];\n}\n\nfunction withReply(\n  turns: ChatTurn[],\n  id: string,\n  status: ReplyStatus,\n  text: string\n) {\n  return turns.map((turn) => {\n    if (turn.id !== id) {\n      return turn;\n    }\n    const updated: AssistantTurn = { id, role: 'assistant', status, text };\n    return updated;\n  });\n}\n\nfunction withoutTurn(turns: ChatTurn[], id: string) {\n  return turns.filter((turn) => turn.id !== id);\n}\n\nfunction titleSourceOf(prompt: SentPrompt) {\n  if (prompt.text.length > 0) {\n    return prompt.text;\n  }\n  return prompt.attachments[0].name;\n}\n\nfunction placeholderOf(page: PageContext | undefined) {\n  if (page) {\n    return 'Ask about this page';\n  }\n  return `Ask ${PRODUCT_NAME} to draft, rewrite or summarise`;\n}\n\nfunction PageHeading({ page }: { page: PageContext }) {\n  return (\n    <>\n      <span className='gem-plate inline-flex size-7 shrink-0 items-center justify-center rounded-lg [--gem:var(--primary)] [&_svg]:size-4'>\n        <FileTextIcon />\n      </span>\n      <div className='min-w-0'>\n        <h1 className='truncate text-sm font-medium'>{page.title}</h1>\n        <p className='text-muted-foreground truncate text-xs'>\n          {page.space} · Ask {PRODUCT_NAME} about this page\n        </p>\n      </div>\n    </>\n  );\n}\n\ntype ConversationViewProps = {\n  conversation: Conversation;\n  onFirstMessage: (conversationId: string, titleSource: string) => void;\n  onOpenNavigation: () => void;\n};\n\nexport function ConversationView({\n  conversation,\n  onFirstMessage,\n  onOpenNavigation,\n}: ConversationViewProps) {\n  const [turns, setTurns] = useState<ChatTurn[]>(conversation.turns);\n  const [activeId, setActiveId] = useState<string | null>(null);\n  const [activeText, setActiveText] = useState('');\n  const [isThinking, setIsThinking] = useState(false);\n  const [sentCount, setSentCount] = useState(0);\n  const [feedback, setFeedback] = useState<FeedbackByTurn>({});\n  const thinkingTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const chatRef = useRef<ChatContainerContext | null>(null);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const isBusy = activeId !== null;\n  const hasTurns = turns.length > 0;\n  const isStart = !hasTurns;\n  const page = conversation.page;\n\n  const stream = useTextStream({\n    textStream: activeText,\n    mode: 'fade',\n    segmentDelay: wordDelayMs,\n    onComplete: finishReply,\n  });\n\n  useEffect(() => {\n    return () => {\n      if (thinkingTimer.current) {\n        clearTimeout(thinkingTimer.current);\n      }\n    };\n  }, []);\n\n  function settle(id: string, status: ReplyStatus, text: string) {\n    setTurns((current) => withReply(current, id, status, text));\n    setActiveId(null);\n    setActiveText('');\n  }\n\n  function finishReply() {\n    if (!activeId) {\n      return;\n    }\n    settle(activeId, 'done', activeText);\n  }\n\n  function startReply(id: string, text: string) {\n    setIsThinking(false);\n    setTurns((current) => withReply(current, id, 'streaming', ''));\n    setActiveText(text);\n    stream.startStreaming();\n  }\n\n  function send(prompt: SentPrompt) {\n    if (isBusy) {\n      return;\n    }\n    const prefix = `${conversation.id}-sent-${sentCount}`;\n    const userId = `${prefix}-user`;\n    const replyId = `${prefix}-reply`;\n    const reply = replyAt(conversation.replies, sentCount);\n    const userTurn: ChatTurn = {\n      id: userId,\n      role: 'user',\n      text: prompt.text,\n      attachments: prompt.attachments,\n    };\n    const replyTurn: ChatTurn = {\n      id: replyId,\n      role: 'assistant',\n      status: 'thinking',\n      text: '',\n    };\n    if (conversation.isDraft) {\n      onFirstMessage(conversation.id, titleSourceOf(prompt));\n    }\n    setTurns((current) => [...current, userTurn, replyTurn]);\n    setSentCount((count) => count + 1);\n    setActiveId(replyId);\n    setIsThinking(true);\n    chatRef.current?.scrollToBottom();\n    thinkingTimer.current = setTimeout(\n      () => startReply(replyId, reply),\n      thinkingMs\n    );\n  }\n\n  function stop() {\n    if (!activeId) {\n      return;\n    }\n    if (isThinking) {\n      if (thinkingTimer.current) {\n        clearTimeout(thinkingTimer.current);\n      }\n      setIsThinking(false);\n      setTurns((current) => withoutTurn(current, activeId));\n      setActiveId(null);\n      return;\n    }\n    stream.pause();\n    settle(activeId, 'stopped', stream.displayedText);\n  }\n\n  function changeFeedback(id: string, choice: Feedback | undefined) {\n    setFeedback((current) => ({ ...current, [id]: choice }));\n  }\n\n  return (\n    <>\n      <header className='flex h-14 shrink-0 items-center gap-2.5 px-4 sm:px-6'>\n        <Button\n          variant='ghost'\n          size='icon-sm'\n          aria-label='Open conversations'\n          onClick={onOpenNavigation}\n          className='text-muted-foreground -ms-1.5 md:hidden'\n        >\n          <MenuIcon />\n        </Button>\n        {page && <PageHeading page={page} />}\n        {!page && (\n          <h1 className='min-w-0 truncate text-sm font-medium'>\n            {conversation.title}\n          </h1>\n        )}\n      </header>\n\n      {hasTurns && (\n        <ChatContainerRoot contextRef={chatRef} className='flex-1'>\n          <ChatContainerContent className='mx-auto max-w-2xl px-4 pt-4 pb-2 sm:px-6'>\n            <AnimatePresence initial={false}>\n              {turns.map((turn) => (\n                <motion.div\n                  key={turn.id}\n                  className='-mx-1 overflow-hidden px-1'\n                  {...rowPresence}\n                >\n                  <div className='pb-6'>\n                    {turn.role === 'user' && <UserMessage turn={turn} />}\n                    {turn.role === 'reasoning' && <ReasoningReply />}\n                    {turn.role === 'assistant' && (\n                      <AssistantMessage\n                        turn={turn}\n                        segments={stream.segments}\n                        feedback={feedback[turn.id]}\n                        onFeedback={(choice) => changeFeedback(turn.id, choice)}\n                      />\n                    )}\n                  </div>\n                </motion.div>\n              ))}\n            </AnimatePresence>\n          </ChatContainerContent>\n          <div className='pointer-events-none absolute inset-x-0 bottom-3 flex justify-center'>\n            <ScrollButton wrapperClassName='pointer-events-auto' />\n          </div>\n        </ChatContainerRoot>\n      )}\n\n      {isStart && (\n        <div className='flex flex-1 flex-col justify-end px-4 pb-5 sm:px-6'>\n          <div className='mx-auto w-full max-w-xl space-y-1.5 text-center'>\n            <h2 className='text-xl font-semibold text-balance sm:text-2xl'>\n              Draft with {PRODUCT_NAME}\n            </h2>\n            <p className='text-muted-foreground text-sm text-balance'>\n              Attach notes or a page, pick a model and say what you need\n            </p>\n          </div>\n        </div>\n      )}\n\n      <div\n        className={cn('shrink-0 px-4 pb-4 sm:px-6', isStart && 'flex-1 pb-10')}\n      >\n        <div\n          className={cn(\n            'mx-auto w-full',\n            hasTurns && 'max-w-2xl',\n            isStart && 'max-w-xl'\n          )}\n        >\n          <Composer\n            isBusy={isBusy}\n            placeholder={placeholderOf(page)}\n            withSuggestions={isStart}\n            onSend={send}\n            onStop={stop}\n          />\n        </div>\n      </div>\n    </>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/conversation-view.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/turns.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { FeatherIcon } from '@/registry/ndeko/lib/icons';\nimport { TextLoader } from '@/registry/ndeko/ui/chat-loader';\nimport {\n  Message,\n  MessageAvatar,\n  MessageContent,\n  MessageGlyph,\n} from '@/registry/ndeko/ui/chat-message';\nimport {\n  ResponseStreamSegments,\n  type StreamSegment,\n} from '@/registry/ndeko/ui/chat-response-stream';\n\nimport { AttachmentList } from './attachment-list';\nimport type { AssistantTurn, Feedback, UserTurn } from './data';\nimport { reader } from './data';\nimport { fadePresence } from './presence';\nimport { ReplyActions } from './reply-actions';\n\nexport function UserMessage({ turn }: { turn: UserTurn }) {\n  const hasText = turn.text.length > 0;\n  const hasAttachments = turn.attachments.length > 0;\n\n  return (\n    <Message className='justify-end'>\n      <div className='flex max-w-[85%] min-w-0 flex-col items-end gap-2 sm:max-w-[75%]'>\n        {hasAttachments && (\n          <AttachmentList\n            attachments={turn.attachments}\n            className='justify-end'\n          />\n        )}\n        {hasText && <MessageContent>{turn.text}</MessageContent>}\n      </div>\n      <MessageAvatar alt={reader.name} className='hidden sm:inline-flex' />\n    </Message>\n  );\n}\n\ntype AssistantMessageProps = {\n  turn: AssistantTurn;\n  segments: StreamSegment[];\n  feedback: Feedback | undefined;\n  onFeedback: (feedback: Feedback | undefined) => void;\n};\n\nexport function AssistantMessage({\n  turn,\n  segments,\n  feedback,\n  onFeedback,\n}: AssistantMessageProps) {\n  const isThinking = turn.status === 'thinking';\n  const isStreaming = turn.status === 'streaming';\n  const isStopped = turn.status === 'stopped';\n  const isDone = turn.status === 'done';\n  const isSettled = isDone || isStopped;\n  const presence = fadePresence();\n\n  return (\n    <Message>\n      <MessageGlyph>\n        <FeatherIcon />\n      </MessageGlyph>\n      <div className='min-w-0 flex-1 space-y-2 pt-1'>\n        {isThinking && <TextLoader text='Thinking' />}\n        {isStreaming && (\n          <MessageContent variant='plain'>\n            <ResponseStreamSegments segments={segments} />\n          </MessageContent>\n        )}\n        {isSettled && (\n          <MessageContent variant='plain'>{turn.text}</MessageContent>\n        )}\n        <AnimatePresence initial={false}>\n          {isStopped && (\n            <motion.p\n              key='stopped'\n              className='text-muted-foreground text-xs'\n              {...presence}\n            >\n              Stopped\n            </motion.p>\n          )}\n          {isSettled && (\n            <motion.div key='actions' {...presence}>\n              <ReplyActions\n                text={turn.text}\n                feedback={feedback}\n                onFeedback={onFeedback}\n              />\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </Message>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/turns.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/reply-actions.tsx",
      "content": "'use client';\n\nimport { CheckIcon, CopyIcon, ThumbsUpIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  MessageAction,\n  MessageActions,\n} from '@/registry/ndeko/ui/chat-message';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\n\nimport type { CopyStatus } from './use-copied';\nimport { useCopied } from './use-copied';\nimport type { Feedback } from './data';\n\nconst COPY_TOOLTIP: Record<CopyStatus, string> = {\n  idle: 'Copy',\n  copied: 'Copied',\n  failed: 'Couldn’t copy, select the text instead',\n};\n\nconst ACTION_BUTTON =\n  'text-muted-foreground aria-pressed:bg-foreground/[0.06] aria-pressed:text-foreground';\n\ntype ReplyActionsProps = {\n  text: string;\n  feedback: Feedback | undefined;\n  onFeedback: (feedback: Feedback | undefined) => void;\n};\n\nfunction toggled(current: Feedback | undefined, choice: Feedback) {\n  if (current === choice) {\n    return undefined;\n  }\n  return choice;\n}\n\nexport function ReplyActions({\n  text,\n  feedback,\n  onFeedback,\n}: ReplyActionsProps) {\n  const { status, copy } = useCopied();\n  const isCopied = status === 'copied';\n  const isHelpful = feedback === 'helpful';\n  const isNotHelpful = feedback === 'not-helpful';\n  const tooltip = COPY_TOOLTIP[status];\n\n  function copyReply() {\n    copy(text);\n  }\n\n  function markHelpful() {\n    onFeedback(toggled(feedback, 'helpful'));\n  }\n\n  function markNotHelpful() {\n    onFeedback(toggled(feedback, 'not-helpful'));\n  }\n\n  return (\n    <MessageActions className='-ms-1.5'>\n      <MessageAction tooltip={tooltip}>\n        <Button\n          type='button'\n          variant='ghost'\n          size='icon-sm'\n          aria-label={tooltip}\n          onClick={copyReply}\n          className={ACTION_BUTTON}\n        >\n          <Swap swapKey={String(isCopied)}>\n            {isCopied && <CheckIcon className='size-3.5' />}\n            {!isCopied && <CopyIcon className='size-3.5' />}\n          </Swap>\n        </Button>\n      </MessageAction>\n      <MessageAction tooltip='Helpful'>\n        <Button\n          type='button'\n          variant='ghost'\n          size='icon-sm'\n          aria-label='Helpful'\n          aria-pressed={isHelpful}\n          onClick={markHelpful}\n          className={ACTION_BUTTON}\n        >\n          <ThumbsUpIcon className='size-3.5' />\n        </Button>\n      </MessageAction>\n      <MessageAction tooltip='Not helpful'>\n        <Button\n          type='button'\n          variant='ghost'\n          size='icon-sm'\n          aria-label='Not helpful'\n          aria-pressed={isNotHelpful}\n          onClick={markNotHelpful}\n          className={ACTION_BUTTON}\n        >\n          <ThumbsUpIcon className='size-3.5 rotate-180' />\n        </Button>\n      </MessageAction>\n    </MessageActions>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/reply-actions.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/use-copied.ts",
      "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport type CopyStatus = 'idle' | 'copied' | 'failed';\n\nconst RESET_AFTER_MS = 1600;\n\nexport function useCopied() {\n  const [status, setStatus] = useState<CopyStatus>('idle');\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  useEffect(() => {\n    return () => {\n      if (timer.current) {\n        clearTimeout(timer.current);\n      }\n    };\n  }, []);\n\n  function showFor(nextStatus: CopyStatus) {\n    if (timer.current) {\n      clearTimeout(timer.current);\n    }\n    setStatus(nextStatus);\n    timer.current = setTimeout(() => setStatus('idle'), RESET_AFTER_MS);\n  }\n\n  async function copy(text: string) {\n    try {\n      await navigator.clipboard.writeText(text);\n    } catch {\n      showFor('failed');\n      return;\n    }\n    showFor('copied');\n  }\n\n  return { status, copy };\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/use-copied.ts"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/reasoning-reply.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { FeatherIcon, RotateCcwIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { TextLoader } from '@/registry/ndeko/ui/chat-loader';\nimport {\n  Message,\n  MessageContent,\n  MessageGlyph,\n} from '@/registry/ndeko/ui/chat-message';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport {\n  Reasoning,\n  ReasoningContent,\n  ReasoningTrigger,\n} from '@/registry/ndeko/ui/chat-reasoning';\nimport {\n  ResponseStreamSegments,\n  useTextStream,\n} from '@/registry/ndeko/ui/chat-response-stream';\nimport {\n  Tool,\n  type ToolPart,\n  type ToolState,\n} from '@/registry/ndeko/ui/chat-tool';\n\nimport {\n  answer,\n  finishedStep,\n  reasoning,\n  reasoningWordMs,\n  runSchedule,\n  thoughtLabel,\n  toolCalls,\n  type RunStep,\n  type ToolCall,\n} from './data';\nimport { rowPresenceOf } from './presence';\nimport { ReplySources } from './reply-sources';\n\nfunction toolStateOf(tool: ToolCall, step: RunStep): ToolState {\n  const isDone = step >= tool.doneAt;\n  if (isDone) {\n    return 'output-available';\n  }\n  return 'input-available';\n}\n\nfunction outputOf(tool: ToolCall, state: ToolState) {\n  const isDone = state === 'output-available';\n  if (isDone) {\n    return tool.output;\n  }\n  return undefined;\n}\n\nfunction toolPartOf(tool: ToolCall, step: RunStep): ToolPart {\n  const state = toolStateOf(tool, step);\n  return {\n    type: tool.type,\n    state,\n    input: tool.input,\n    output: outputOf(tool, state),\n    toolCallId: tool.toolCallId,\n  };\n}\n\nfunction hasAppeared(tool: ToolCall, step: RunStep) {\n  return step >= tool.appearsAt;\n}\n\nfunction ReasoningBody({\n  isRunning,\n  segments,\n}: {\n  isRunning: boolean;\n  segments: ReturnType<typeof useTextStream>['segments'];\n}) {\n  if (isRunning) {\n    return <ResponseStreamSegments segments={segments} />;\n  }\n  return reasoning;\n}\n\nexport function ReasoningReply() {\n  const [step, setStep] = useState<RunStep>(finishedStep);\n  const [reasoningSource, setReasoningSource] = useState('');\n  const timers = useRef(new Set<ReturnType<typeof setTimeout>>());\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const isRunning = step < finishedStep;\n  const isFinished = !isRunning;\n  const visibleTools = toolCalls.filter((tool) => hasAppeared(tool, step));\n  const reasoningStream = useTextStream({\n    textStream: reasoningSource,\n    mode: 'fade',\n    segmentDelay: reasoningWordMs,\n  });\n\n  useEffect(() => {\n    const pending = timers.current;\n    return () => {\n      pending.forEach((timer) => clearTimeout(timer));\n    };\n  }, []);\n\n  function schedule(task: () => void, delay: number) {\n    const timer = setTimeout(() => {\n      timers.current.delete(timer);\n      task();\n    }, delay);\n    timers.current.add(timer);\n  }\n\n  function runAgain() {\n    if (isRunning) {\n      return;\n    }\n    setStep(0);\n    setReasoningSource(reasoning);\n    reasoningStream.startStreaming();\n    for (const entry of runSchedule) {\n      schedule(() => setStep(entry.step), entry.atMs);\n    }\n  }\n\n  return (\n    <Message>\n      <MessageGlyph>\n        <FeatherIcon />\n      </MessageGlyph>\n      <div className='min-w-0 flex-1 space-y-3 pt-1.5'>\n        <Reasoning isStreaming={isRunning}>\n          <ReasoningTrigger>\n            <Swap swapKey={String(isRunning)}>\n              {isRunning && <TextLoader text='Thinking' />}\n              {isFinished && thoughtLabel}\n            </Swap>\n          </ReasoningTrigger>\n          <ReasoningContent>\n            <ReasoningBody\n              isRunning={isRunning}\n              segments={reasoningStream.segments}\n            />\n          </ReasoningContent>\n        </Reasoning>\n\n        <ul aria-label='Tool calls' className='flex flex-col'>\n          <AnimatePresence initial={false}>\n            {visibleTools.map((tool) => (\n              <motion.li\n                key={tool.id}\n                className='-mx-1 overflow-hidden px-1'\n                {...rowPresence}\n              >\n                <div className='pb-2'>\n                  <Tool toolPart={toolPartOf(tool, step)} />\n                </div>\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ul>\n\n        <AnimatePresence initial={false}>\n          {isFinished && (\n            <motion.div\n              key='answer'\n              className='-mx-1 overflow-hidden px-1'\n              {...rowPresence}\n            >\n              <div className='space-y-4 pb-1'>\n                <MessageContent markdown variant='plain'>\n                  {answer}\n                </MessageContent>\n                <ReplySources />\n                <Button\n                  type='button'\n                  variant='ghost'\n                  size='sm'\n                  onClick={runAgain}\n                  className='text-muted-foreground -ms-2'\n                >\n                  <RotateCcwIcon />\n                  Run again\n                </Button>\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </Message>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/reasoning-reply.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/reply-sources.tsx",
      "content": "import {\n  Source,\n  SourceContent,\n  SourceTrigger,\n} from '@/registry/ndeko/ui/chat-source';\n\nimport { sources } from './data';\n\nexport function ReplySources() {\n  return (\n    <div className='space-y-2'>\n      <p className='text-muted-foreground text-xs font-medium'>Sources</p>\n      <ul className='flex flex-wrap gap-1.5'>\n        {sources.map((source) => (\n          <li key={source.href}>\n            <Source href={source.href}>\n              <SourceTrigger label={source.title} showMark />\n              <SourceContent\n                title={source.title}\n                description={source.description}\n              />\n            </Source>\n          </li>\n        ))}\n      </ul>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/reply-sources.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/composer.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CircleAlertIcon,\n  CircleCheckIcon,\n  PaperclipIcon,\n  UploadCloudIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  FileUpload,\n  FileUploadContent,\n  useFileUpload,\n} from '@/registry/ndeko/ui/chat-file-upload';\nimport {\n  PromptInput,\n  PromptInputAction,\n  PromptInputActions,\n  PromptInputSubmit,\n  PromptInputTextarea,\n} from '@/registry/ndeko/ui/chat-prompt-input';\nimport { PromptSuggestion } from '@/registry/ndeko/ui/chat-prompt-suggestion';\n\nimport { AttachmentList, formatBytes } from './attachment-list';\nimport {\n  maxBytes,\n  maxFiles,\n  models,\n  suggestions,\n  type Attachment,\n  type AttachmentKind,\n  type ModelValue,\n} from './data';\nimport { ModelPicker } from './model-picker';\nimport { risePresenceOf } from './presence';\n\nexport type SentPrompt = {\n  text: string;\n  attachments: Attachment[];\n};\n\ntype NoticeTone = 'refusal' | 'sent';\n\ntype Notice = {\n  tone: NoticeTone;\n  text: string;\n};\n\nconst NOTICE_ICON: Record<NoticeTone, React.ReactNode> = {\n  refusal: <CircleAlertIcon className='text-warning-foreground size-4' />,\n  sent: <CircleCheckIcon className='text-success-foreground size-4' />,\n};\n\nfunction kindOf(file: File): AttachmentKind {\n  const isImage = file.type.startsWith('image/');\n  if (isImage) {\n    return 'image';\n  }\n  return 'document';\n}\n\nfunction modelLabelOf(value: ModelValue) {\n  const model = models.find((candidate) => candidate.value === value);\n  return model?.label ?? value;\n}\n\nfunction fileCountOf(count: number) {\n  if (count === 1) {\n    return '1 file';\n  }\n  return `${count} files`;\n}\n\nfunction sentTextOf(modelLabel: string, fileCount: number) {\n  if (fileCount === 0) {\n    return `Sent to ${modelLabel}`;\n  }\n  const files = fileCountOf(fileCount);\n  return `Sent to ${modelLabel} with ${files}`;\n}\n\nfunction refusalOf(tooLargeName: string | null, hasOverflow: boolean) {\n  if (tooLargeName) {\n    const limit = formatBytes(maxBytes);\n    const text = `“${tooLargeName}” is over ${limit}. Attach a smaller copy`;\n    return { tone: 'refusal' as const, text };\n  }\n  if (hasOverflow) {\n    const text = `${fileCountOf(maxFiles)} fit in one prompt. Remove one to add another`;\n    return { tone: 'refusal' as const, text };\n  }\n  return null;\n}\n\nfunction focusAtEnd(id: string) {\n  const element = document.getElementById(id);\n  if (!(element instanceof HTMLTextAreaElement)) {\n    return;\n  }\n  const end = element.value.length;\n  element.focus();\n  element.setSelectionRange(end, end);\n}\n\ntype AttachButtonProps = {\n  isFull: boolean;\n  onRefuse: () => void;\n};\n\nfunction AttachButton({ isFull, onRefuse }: AttachButtonProps) {\n  const { openPicker } = useFileUpload();\n\n  function attach() {\n    if (isFull) {\n      onRefuse();\n      return;\n    }\n    openPicker();\n  }\n\n  return (\n    <PromptInputAction tooltip='Attach files'>\n      <Button\n        type='button'\n        variant='ghost'\n        size='icon'\n        aria-label='Attach files'\n        onClick={attach}\n        className='text-muted-foreground'\n      >\n        <PaperclipIcon />\n      </Button>\n    </PromptInputAction>\n  );\n}\n\ntype ComposerProps = {\n  isBusy: boolean;\n  placeholder: string;\n  withSuggestions: boolean;\n  onSend: (prompt: SentPrompt) => void;\n  onStop: () => void;\n};\n\nexport function Composer({\n  isBusy,\n  placeholder,\n  withSuggestions,\n  onSend,\n  onStop,\n}: ComposerProps) {\n  const [draft, setDraft] = useState('');\n  const [attachments, setAttachments] = useState<Attachment[]>([]);\n  const [model, setModel] = useState<ModelValue>('deep');\n  const [notice, setNotice] = useState<Notice | null>(null);\n  const idCounter = useRef(0);\n  const textareaId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = risePresenceOf(shouldReduceMotion);\n  const hasText = draft.trim().length > 0;\n  const hasAttachments = attachments.length > 0;\n  const canSend = hasText || hasAttachments;\n  const isFull = attachments.length >= maxFiles;\n  const isDraftEmpty = draft.length === 0;\n  const isIdle = !isBusy;\n  const isQuiet = isDraftEmpty && isIdle;\n  const showsSuggestions = withSuggestions && isQuiet;\n\n  function nextId() {\n    idCounter.current += 1;\n    return `file-${idCounter.current}`;\n  }\n\n  function addFiles(files: File[]) {\n    const room = maxFiles - attachments.length;\n    const accepted: Attachment[] = [];\n    let tooLargeName: string | null = null;\n    let hasOverflow = false;\n    for (const file of files) {\n      const isTooLarge = file.size > maxBytes;\n      if (isTooLarge) {\n        tooLargeName = file.name;\n        continue;\n      }\n      const isOutOfRoom = accepted.length >= room;\n      if (isOutOfRoom) {\n        hasOverflow = true;\n        continue;\n      }\n      const attachment: Attachment = {\n        id: nextId(),\n        name: file.name,\n        size: file.size,\n        kind: kindOf(file),\n      };\n      accepted.push(attachment);\n    }\n    setAttachments((current) => [...current, ...accepted]);\n    setNotice(refusalOf(tooLargeName, hasOverflow));\n  }\n\n  function removeAttachment(id: string) {\n    setAttachments((current) => current.filter((item) => item.id !== id));\n    setNotice(null);\n  }\n\n  function refuseMoreFiles() {\n    setNotice(refusalOf(null, true));\n  }\n\n  function changeDraft(value: string) {\n    setDraft(value);\n    if (notice?.tone === 'sent') {\n      setNotice(null);\n    }\n  }\n\n  function applySuggestion(text: string) {\n    setDraft(text);\n    requestAnimationFrame(() => focusAtEnd(textareaId));\n  }\n\n  function send() {\n    if (isBusy) {\n      return;\n    }\n    if (!canSend) {\n      return;\n    }\n    const modelLabel = modelLabelOf(model);\n    const sentText = sentTextOf(modelLabel, attachments.length);\n    onSend({ text: draft.trim(), attachments });\n    setDraft('');\n    setAttachments([]);\n    setNotice({ tone: 'sent', text: sentText });\n  }\n\n  return (\n    <div>\n      <FileUpload onFilesAdded={addFiles}>\n        <PromptInput\n          value={draft}\n          onValueChange={changeDraft}\n          onSubmit={send}\n          isLoading={isBusy}\n        >\n          <AnimatedSize>\n            <AttachmentList\n              attachments={attachments}\n              onRemove={removeAttachment}\n            />\n            <PromptInputTextarea\n              id={textareaId}\n              aria-label='Prompt'\n              placeholder={placeholder}\n            />\n            <PromptInputActions className='justify-between gap-2 pt-1'>\n              <div className='flex min-w-0 items-center gap-1'>\n                <AttachButton isFull={isFull} onRefuse={refuseMoreFiles} />\n                <ModelPicker value={model} onChange={setModel} />\n              </div>\n              <PromptInputSubmit onStop={onStop} canSubmit={canSend} />\n            </PromptInputActions>\n          </AnimatedSize>\n        </PromptInput>\n        <FileUploadContent>\n          <div className='bg-card hairline-border border-foreground/25 flex flex-col items-center gap-2 rounded-2xl border-dashed px-10 py-8 text-center shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n            <UploadCloudIcon className='text-muted-foreground size-6' />\n            <p className='text-sm font-medium'>Drop files to attach them</p>\n            <p className='text-muted-foreground text-xs'>\n              Up to {fileCountOf(maxFiles)}, {formatBytes(maxBytes)} each\n            </p>\n          </div>\n        </FileUploadContent>\n      </FileUpload>\n\n      <AnimatedSize>\n        <div aria-live='polite'>\n          <AnimatePresence initial={false} mode='popLayout'>\n            {notice && (\n              <motion.p\n                key={notice.text}\n                className='text-muted-foreground flex items-start gap-2 px-1 pt-3 text-[13px]'\n                {...presence}\n              >\n                <span className='mt-px shrink-0'>\n                  {NOTICE_ICON[notice.tone]}\n                </span>\n                {notice.text}\n              </motion.p>\n            )}\n          </AnimatePresence>\n        </div>\n      </AnimatedSize>\n\n      <AnimatePresence initial={false}>\n        {showsSuggestions && (\n          <motion.ul\n            key='suggestions'\n            aria-label='Suggested prompts'\n            className='mt-4 flex flex-wrap justify-center gap-2'\n            {...presence}\n          >\n            {suggestions.map((suggestion) => (\n              <li key={suggestion}>\n                <PromptSuggestion onClick={() => applySuggestion(suggestion)}>\n                  {suggestion}\n                </PromptSuggestion>\n              </li>\n            ))}\n          </motion.ul>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/composer.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/attachment-list.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { FileTextIcon, ImageIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport type { Attachment, AttachmentKind } from './data';\nimport { layoutTransitionOf, settlePresenceOf } from './presence';\n\nconst KILOBYTE = 1024;\n\nconst MEGABYTE = KILOBYTE * 1024;\n\nconst KIND_LOOK: Record<\n  AttachmentKind,\n  { icon: React.ReactNode; gem: string }\n> = {\n  document: { icon: <FileTextIcon />, gem: 'var(--primary)' },\n  image: { icon: <ImageIcon />, gem: 'var(--info)' },\n};\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\ntype AttachmentListProps = {\n  attachments: Attachment[];\n  onRemove?: (id: string) => void;\n  disabled?: boolean;\n  className?: string;\n};\n\nexport function AttachmentList({\n  attachments,\n  onRemove,\n  disabled = false,\n  className,\n}: AttachmentListProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const presence = settlePresenceOf(shouldReduceMotion);\n  const layoutTransition = layoutTransitionOf(shouldReduceMotion);\n  const transition = { ...presence.transition, layout: layoutTransition };\n  const hasAttachments = attachments.length > 0;\n  const isRemovable = onRemove !== undefined;\n  const isPadded = hasAttachments && isRemovable;\n\n  return (\n    <ul\n      aria-label='Attachments'\n      className={cn(\n        'flex flex-wrap gap-1.5',\n        isPadded && 'px-1 pt-1 pb-2',\n        className\n      )}\n    >\n      <AnimatePresence mode='popLayout' initial={false}>\n        {attachments.map((attachment) => {\n          const look = KIND_LOOK[attachment.kind];\n          const plateStyle = { '--gem': look.gem } as React.CSSProperties;\n          const size = formatBytes(attachment.size);\n\n          function remove() {\n            onRemove?.(attachment.id);\n          }\n\n          return (\n            <motion.li\n              key={attachment.id}\n              layout\n              initial={presence.initial}\n              animate={presence.animate}\n              exit={presence.exit}\n              transition={transition}\n              className={cn(\n                'bg-card hairline-ring ring-border flex h-11 max-w-60 items-center gap-2 rounded-lg ps-1.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]',\n                isRemovable && 'pe-1',\n                !isRemovable && 'pe-3'\n              )}\n            >\n              <span\n                aria-hidden='true'\n                style={plateStyle}\n                className='gem-plate inline-flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5'\n              >\n                {look.icon}\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                  {size}\n                </span>\n              </span>\n              {isRemovable && (\n                <Button\n                  type='button'\n                  variant='ghost'\n                  size='icon-sm'\n                  aria-label={`Remove ${attachment.name}`}\n                  disabled={disabled}\n                  onClick={remove}\n                  className='text-muted-foreground'\n                >\n                  <XIcon className='size-3.5' />\n                </Button>\n              )}\n            </motion.li>\n          );\n        })}\n      </AnimatePresence>\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/attachment-list.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/model-picker.tsx",
      "content": "'use client';\n\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/registry/ndeko/ui/select';\n\nimport { models, type ModelValue } from './data';\n\nfunction isModelValue(value: unknown): value is ModelValue {\n  return models.some((model) => model.value === value);\n}\n\ntype ModelPickerProps = {\n  value: ModelValue;\n  onChange: (value: ModelValue) => void;\n  disabled?: boolean;\n};\n\nexport function ModelPicker({ value, onChange, disabled }: ModelPickerProps) {\n  function change(next: unknown) {\n    if (isModelValue(next)) {\n      onChange(next);\n    }\n  }\n\n  return (\n    <Select\n      items={models}\n      value={value}\n      onValueChange={change}\n      disabled={disabled}\n    >\n      <SelectTrigger size='sm' aria-label='Model' className='w-auto min-w-32'>\n        <SelectValue />\n      </SelectTrigger>\n      <SelectContent className='min-w-64'>\n        {models.map((model) => (\n          <SelectItem key={model.value} value={model.value}>\n            <span className='shrink-0'>{model.label}</span>\n            <span className='text-muted-foreground truncate text-xs'>\n              {model.hint}\n            </span>\n          </SelectItem>\n        ))}\n      </SelectContent>\n    </Select>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/model-picker.tsx"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/presence.ts",
      "content": "import type { MotionProps, Transition, Variants } from 'motion/react';\n\ntype PresenceProps = Pick<\n  MotionProps,\n  'initial' | 'animate' | 'exit' | 'transition'\n>;\n\nconst EASE_OUT_STRONG: [number, number, number, number] = [0.23, 1, 0.32, 1];\n\nconst ENTER: Transition = { duration: 0.2, ease: EASE_OUT_STRONG };\n\nconst EXIT: Transition = { duration: 0.14, ease: EASE_OUT_STRONG };\n\nconst ROW_PRESENCE: PresenceProps = {\n  initial: { height: 0, opacity: 0 },\n  animate: { height: 'auto', opacity: 1 },\n  exit: { height: 0, opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\nconst SETTLE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0, scale: 0.95 },\n  animate: { opacity: 1, scale: 1 },\n  exit: { opacity: 0, scale: 0.95, transition: EXIT },\n  transition: ENTER,\n};\n\nconst RISE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0, y: 4 },\n  animate: { opacity: 1, y: 0 },\n  exit: { opacity: 0, y: 4, transition: EXIT },\n  transition: ENTER,\n};\n\nconst FADE_PRESENCE: PresenceProps = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: EXIT },\n  transition: ENTER,\n};\n\n/** Rows whose focus ring must stay visible: they clip only while they grow or shrink. */\nconst REVEAL_VARIANTS: Variants = {\n  hidden: { height: 0, opacity: 0, overflow: 'hidden', transition: EXIT },\n  shown: {\n    height: 'auto',\n    opacity: 1,\n    transition: ENTER,\n    transitionEnd: { overflow: 'visible' },\n  },\n};\n\nconst REVEAL_FADE: Variants = {\n  hidden: { opacity: 0, transition: EXIT },\n  shown: { opacity: 1, transition: ENTER },\n};\n\nconst LAYOUT_SPRING: Transition = {\n  type: 'spring',\n  bounce: 0,\n  duration: 0.3,\n};\n\nconst INSTANT: Transition = { duration: 0 };\n\nexport function rowPresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return ROW_PRESENCE;\n}\n\nexport function revealVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return REVEAL_FADE;\n  }\n  return REVEAL_VARIANTS;\n}\n\nexport function settlePresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return SETTLE_PRESENCE;\n}\n\nexport function risePresenceOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_PRESENCE;\n  }\n  return RISE_PRESENCE;\n}\n\nexport function fadePresence() {\n  return FADE_PRESENCE;\n}\n\nexport function layoutTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return LAYOUT_SPRING;\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-05/presence.ts"
    },
    {
      "path": "registry/ndeko/templates/chat/application-05/data.ts",
      "content": "export type Person = {\n  id: string;\n  name: string;\n  role: string;\n};\n\nexport type ReplyStatus = 'thinking' | 'streaming' | 'done' | 'stopped';\n\nexport type AttachmentKind = 'document' | 'image';\n\nexport type Attachment = {\n  id: string;\n  name: string;\n  size: number;\n  kind: AttachmentKind;\n};\n\nexport type UserTurn = {\n  id: string;\n  role: 'user';\n  text: string;\n  attachments: Attachment[];\n};\n\nexport type AssistantTurn = {\n  id: string;\n  role: 'assistant';\n  text: string;\n  status: ReplyStatus;\n};\n\nexport type ReasoningTurn = {\n  id: string;\n  role: 'reasoning';\n};\n\nexport type ChatTurn = UserTurn | AssistantTurn | ReasoningTurn;\n\nexport type Feedback = 'helpful' | 'not-helpful';\n\nexport type ModelValue = 'swift' | 'deep';\n\nexport type Model = {\n  value: ModelValue;\n  label: string;\n  hint: string;\n};\n\nexport type PageContext = {\n  title: string;\n  space: string;\n};\n\nexport type Conversation = {\n  id: string;\n  title: string;\n  page?: PageContext;\n  turns: ChatTurn[];\n  replies: string[];\n  isDraft: boolean;\n};\n\nexport type RunStep = 0 | 1 | 2 | 3 | 4 | 5;\n\nexport type ScheduledStep = {\n  step: RunStep;\n  atMs: number;\n};\n\nexport type ToolCall = {\n  id: string;\n  type: string;\n  toolCallId: string;\n  appearsAt: RunStep;\n  doneAt: RunStep;\n  input: Record<string, unknown>;\n  output: Record<string, unknown>;\n};\n\nexport type CitedSource = {\n  href: string;\n  title: string;\n  description: string;\n};\n\nexport const PRODUCT_NAME = 'Quillstone';\n\nexport const reader: Person = {\n  id: 'amara',\n  name: 'Amara Diallo',\n  role: 'People team',\n};\n\nexport const models: Model[] = [\n  { value: 'swift', label: 'Quill Swift', hint: 'Quick drafts and rewrites' },\n  { value: 'deep', label: 'Quill Deep', hint: 'Careful edits on long pages' },\n];\n\nexport const suggestions = [\n  'Summarise this page in five lines',\n  'Rewrite the intro for new hires',\n  'Turn my meeting notes into a checklist',\n];\n\nexport const maxFiles = 4;\n\nexport const maxBytes = 10 * 1024 * 1024;\n\nexport const thinkingMs = 700;\n\nexport const wordDelayMs = 45;\n\nexport const NEW_CHAT_TITLE = 'New chat';\n\nexport const TITLE_WORD_LIMIT = 6;\n\nexport const newChatReplies = [\n  'Here is a first draft. I kept your headings, put the open questions at the end and marked the two places where the notes disagree.\\n\\nTell me which part to expand and I will rework only that one.',\n  'Done. It is shorter now and every sentence starts with what the reader does. The earlier version stays in the page history if you want to compare.',\n];\n\nexport const question =\n  'Check the API reference against the changelog and tell me what changed in 2.4';\n\nexport const seedConversations: Conversation[] = [\n  {\n    id: 'onboarding',\n    title: 'Tighten the onboarding intro',\n    page: { title: 'Onboarding guide', space: 'People team' },\n    isDraft: false,\n    turns: [\n      {\n        id: 'turn-1',\n        role: 'user',\n        text: 'The intro of the onboarding guide runs long. Can you tighten it without losing the part about buddies?',\n        attachments: [],\n      },\n      {\n        id: 'turn-2',\n        role: 'assistant',\n        status: 'done',\n        text: 'Here is a tighter intro, down from 182 words to 74:\\n\\nWelcome to Fernhill. Your first two weeks are about meeting people, not shipping. Each new teammate gets a buddy who has been here at least a year. They book your first coffee and answer the questions you would rather not ask in a channel.\\n\\nI moved the paragraph on laptops and accounts to the Setup section, where people already look for it.',\n      },\n    ],\n    replies: [\n      'A title that says what the page is for: \"Your first two weeks at Fernhill\". It matches how the other guides in People team are named, and it reads well in search.\\n\\nI can also write a one-line summary under it, so the link preview in chat says something useful.',\n      'Done. The buddy paragraph is now second, since it is what most new people ask about, and the history of the office is a single sentence that links to the About page.\\n\\nThe intro fits on one phone screen now. The rest of the guide is unchanged.',\n      'Three sections repeat the same advice about the calendar: Day one, Meetings and Tools. I would keep it in Meetings and link to it from the other two.\\n\\nWant me to make that change and leave a comment for Jonas, who owns the Tools section?',\n    ],\n  },\n  {\n    id: 'api-changes',\n    title: 'What changed in 2.4',\n    page: { title: 'API reference', space: 'Engineering' },\n    isDraft: false,\n    turns: [\n      { id: 'api-1', role: 'user', text: question, attachments: [] },\n      { id: 'api-2', role: 'reasoning' },\n    ],\n    replies: [\n      'I drafted the four edits as suggestions on the API reference: the cursor parameter on /documents, the new limit for workspace tokens, the DELETE endpoint for comments and the removal of archived=true on /spaces.\\n\\nWhoever owns the page can accept them one by one.',\n      'The 2.4 entry of the changelog says nothing about webhooks, and the reference lists no change there either, so that part is up to date.\\n\\nI can run the same check on 2.3 if you want the whole year.',\n    ],\n  },\n];\n\nexport const finishedStep: RunStep = 5;\n\nexport const runSchedule: ScheduledStep[] = [\n  { step: 1, atMs: 500 },\n  { step: 2, atMs: 1700 },\n  { step: 3, atMs: 2000 },\n  { step: 4, atMs: 3400 },\n  { step: 5, atMs: 4000 },\n];\n\nexport const reasoning =\n  'The API reference was last edited on 12 March, before 2.4 shipped, so it is probably behind. I will find the 2.4 entry in the changelog first, then read the parts of the API reference it touches: pagination, rate limits and the comment endpoints.';\n\nexport const thoughtLabel = 'Thought for 4 seconds';\n\nexport const answer = [\n  'Three changes from 2.4 are missing from the API reference:',\n  '',\n  '1. **Pagination** on `/documents` moved from `page` to `cursor`.',\n  '2. Workspace tokens now get 120 requests a minute instead of 60.',\n  '3. `DELETE /comments/{id}` is new and not listed yet.',\n  '',\n  'The reference also still documents `archived=true` on `/spaces`, which 2.4 removed. I can draft the edits as suggestions on the page.',\n].join('\\n');\n\nexport const reasoningWordMs = 55;\n\nexport const toolCalls: ToolCall[] = [\n  {\n    id: 'search',\n    type: 'search_pages',\n    toolCallId: 'call_7hq2',\n    appearsAt: 1,\n    doneAt: 2,\n    input: { query: 'changelog 2.4', space: 'Engineering' },\n    output: {\n      matches: 3,\n      best: 'Changelog / 2.4',\n      updated: '2026-10-21',\n    },\n  },\n  {\n    id: 'read',\n    type: 'read_page',\n    toolCallId: 'call_9kd4',\n    appearsAt: 3,\n    doneAt: 4,\n    input: { page: 'API reference', sections: ['Pagination', 'Rate limits'] },\n    output: {\n      words: 1240,\n      lastEdited: '2026-03-12',\n      endpoints: ['/documents', '/spaces', '/comments'],\n    },\n  },\n];\n\nexport const sources: CitedSource[] = [\n  {\n    href: 'https://docs.quillstone.example/engineering/changelog#2-4',\n    title: 'Changelog, 2.4',\n    description:\n      'Cursor pagination, higher limits for workspace tokens and comment deletion.',\n  },\n  {\n    href: 'https://docs.quillstone.example/engineering/api-reference',\n    title: 'API reference',\n    description:\n      'Endpoints, parameters and errors of the public API, last edited in March.',\n  },\n  {\n    href: 'https://docs.quillstone.example/engineering/rate-limits',\n    title: 'Rate limits',\n    description:\n      'How requests are counted per token and what happens past the limit.',\n  },\n];\n",
      "type": "registry:component",
      "target": "components/templates/application-05/data.ts"
    }
  ],
  "categories": [
    "templates",
    "chat"
  ],
  "type": "registry:block"
}