{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "application-11",
  "title": "Support inbox",
  "description": "An Oatfield support inbox: tickets with status, priority and unread marks beside the conversation and a copilot that reads the ticket, fills the customer card and searches the help center, then its draft arrives in the reply box with its sources to insert, edit or discard, a refund waits for Allow or Deny and the answered ticket travels to Solved. Plug your help desk into onSend, onApprove and onDeny.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.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/call-status.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/company-mark.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/inline-sheet.json",
    "https://ui.ndekocode.dev/r/kbd.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/mesh-tile.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/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/replay-button.json",
    "https://ui.ndekocode.dev/r/run-session.json",
    "https://ui.ndekocode.dev/r/spinner.json",
    "https://ui.ndekocode.dev/r/streamed-text.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-follow-bottom.json",
    "https://ui.ndekocode.dev/r/use-is-narrow.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.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/templates/inbox/application-11/index.tsx",
      "content": "'use client';\n\nimport { useIsNarrow } from '@/registry/ndeko/hooks/use-is-narrow';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport { spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { InlineSheet } from '@/registry/ndeko/ui/inline-sheet';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { Conversation, ConversationHeader } from './conversation';\nimport { CopilotPanel, type CopilotWork } from './copilot-panel';\nimport { SCRIPTED_TICKET } from './data';\nimport { RefundRequest } from './refund-request';\nimport { ReplyComposer } from './reply-composer';\nimport {\n  INITIAL,\n  LOOP_AFTER_MS,\n  openOf,\n  placementOf,\n  reducer,\n  REFUND_MS,\n  RESTING,\n  SCRIPT,\n  SEND_MS,\n  type Decision,\n  type DraftStatus,\n  type InboxState,\n  type OpenTicket,\n  type RefundStatus,\n} from './session';\nimport { TicketList } from './ticket-list';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\n/** The width of the `@4xl` container variant: under it the ticket list lives in a sheet. */\nconst LIST_SHEET_BELOW_REM = 56;\n\n/** The width of the `@2xl` container variant: under it the copilot lives in a sheet. */\nconst COPILOT_SHEET_BELOW_REM = 42;\n\nfunction ticketOfOpen(open: OpenTicket | null) {\n  if (!open) {\n    return null;\n  }\n  return open.ticket;\n}\n\n/** The copilot follows one ticket: its work, its draft and its refund show on that ticket only. */\nfunction workOf(state: InboxState): CopilotWork | null {\n  if (state.openId !== SCRIPTED_TICKET) {\n    return null;\n  }\n  return {\n    steps: state.steps,\n    lookedUpFields: state.customerFields,\n    articlesFound: state.articlesFound,\n    refund: state.refund,\n  };\n}\n\nfunction draftOf(state: InboxState): DraftStatus {\n  if (state.openId !== SCRIPTED_TICKET) {\n    return 'none';\n  }\n  return state.draft;\n}\n\nfunction refundOf(state: InboxState): RefundStatus {\n  if (state.openId !== SCRIPTED_TICKET) {\n    return 'none';\n  }\n  return state.refund;\n}\n\n/** Nothing calls a network. A real help desk plugs in here: the reply a person sends, and their answer to the refund. */\nexport type Application11Props = {\n  onSend?: (text: string) => void;\n  onApprove?: () => void;\n  onDeny?: () => void;\n};\n\nexport default function Application11({\n  onSend,\n  onApprove,\n  onDeny,\n}: Application11Props) {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule } = useTimeouts();\n  const isCompact = useIsNarrow(ref, LIST_SHEET_BELOW_REM);\n  const isPhone = useIsNarrow(ref, COPILOT_SHEET_BELOW_REM);\n  const open = openOf(state);\n  const work = workOf(state);\n  const draft = draftOf(state);\n  const refund = refundOf(state);\n  const isListShown = isCompact && state.isListOpen;\n  const isCopilotShown = isPhone && state.isCopilotOpen;\n  const isBehindSheet = isListShown || isCopilotShown;\n  const hasRefund = refund !== 'none';\n  const showsRefundAboveReply = isPhone && hasRefund;\n  const canReplay = isFinished && !isAutoplaying;\n  const message = spokenUnless(isAutoplaying, state.spoken);\n\n  function focusLater(selector: string) {\n    requestAnimationFrame(() => {\n      const target = ref.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  function focusReplyAtEnd() {\n    requestAnimationFrame(() => {\n      const field =\n        ref.current?.querySelector<HTMLTextAreaElement>('[data-reply-field]');\n      if (!field) {\n        return;\n      }\n      const end = field.value.length;\n      field.focus();\n      field.setSelectionRange(end, end);\n    });\n  }\n\n  function openTicket(id: string) {\n    act({ type: 'opened', id });\n    if (isListShown) {\n      focusLater('[data-sheet-open=\"list\"]');\n    }\n  }\n\n  function send() {\n    if (!open) {\n      return;\n    }\n    if (open.live.send === 'sending') {\n      return;\n    }\n    const { id } = open;\n    const text = open.live.reply.trim();\n    act({ type: 'sendPressed' });\n    if (text === '') {\n      return;\n    }\n    schedule(() => act({ type: 'delivered', id }), SEND_MS);\n    onSend?.(text);\n  }\n\n  /** Insert leaves the reply ready to send as it is; Edit puts the caret at its end. */\n  function insert() {\n    act({ type: 'draftInserted' });\n    focusLater('[data-reply-send]');\n  }\n\n  function edit() {\n    act({ type: 'draftInserted' });\n    focusReplyAtEnd();\n  }\n\n  function discard() {\n    act({ type: 'draftDiscarded' });\n    focusLater('[data-draft-restore]');\n  }\n\n  function restore() {\n    act({ type: 'draftRestored' });\n    focusLater('[data-reply-field]');\n  }\n\n  /** The two buttons leave with the request, so the focus goes to what replaces them: the line that says what was decided. */\n  function decide(decision: Decision) {\n    act({ type: 'refundDecided', decision });\n    focusLater('[data-request]');\n    if (decision === 'denied') {\n      onDeny?.();\n      return;\n    }\n    schedule(() => act({ type: 'refunded' }), REFUND_MS);\n    onApprove?.();\n  }\n\n  function openList() {\n    act({ type: 'listSheet', isOpen: true });\n    focusLater('[data-sheet-close=\"list\"]');\n  }\n\n  function closeList() {\n    act({ type: 'listSheet', isOpen: false });\n    focusLater('[data-sheet-open=\"list\"]');\n  }\n\n  function openCopilot() {\n    act({ type: 'copilotSheet', isOpen: true });\n    focusLater('[data-sheet-close=\"copilot\"]');\n  }\n\n  function closeCopilot() {\n    act({ type: 'copilotSheet', isOpen: false });\n    focusLater('[data-sheet-open=\"copilot\"]');\n  }\n\n  const list = {\n    live: state.live,\n    openId: state.openId,\n    placement: placementOf(state),\n    pressed,\n    onOpen: openTicket,\n  };\n\n  const copilot = {\n    ticket: ticketOfOpen(open),\n    work,\n    pressed,\n    onDecide: decide,\n  };\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-sidebar text-foreground @container min-h-dvh w-full'\n      >\n        <div className='relative flex h-dvh min-h-[40rem] overflow-hidden'>\n          <div\n            inert={isBehindSheet}\n            className='flex min-w-0 flex-1 gap-2 @2xl:p-2'\n          >\n            <aside\n              aria-label='Tickets'\n              className='hidden w-60 shrink-0 @4xl:flex'\n            >\n              {!isCompact && <TicketList {...list} />}\n            </aside>\n            <main className='bg-background @2xl:hairline-ring @2xl:ring-border flex min-w-0 flex-1 flex-col overflow-clip @2xl:rounded-xl @2xl:shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n              <ConversationHeader\n                open={open}\n                canReplay={canReplay}\n                onReplay={restart}\n                onOpenList={openList}\n                onOpenCopilot={openCopilot}\n              />\n              {!open && <Conversation ticket={null} />}\n              {open && (\n                <Conversation\n                  ticket={open.ticket}\n                  live={open.live}\n                  refund={refund}\n                />\n              )}\n              {open && (\n                <div className='mx-auto flex min-h-0 w-full max-w-2xl shrink flex-col gap-2 overflow-y-auto px-3 pt-1 pb-3 @2xl:px-4 @2xl:pb-4'>\n                  {showsRefundAboveReply && (\n                    <RefundRequest\n                      status={refund}\n                      pressed={pressed}\n                      isCompact\n                      onDecide={decide}\n                      className='shrink-0'\n                    />\n                  )}\n                  <ReplyComposer\n                    live={open.live}\n                    draft={draft}\n                    showsSendHint={state.showsSendHint}\n                    emptySends={state.emptySends}\n                    isActive={isInView}\n                    isInsertPressed={pressed === 'insert'}\n                    isSendPressed={pressed === 'send'}\n                    onType={(text) => act({ type: 'replyTyped', text })}\n                    onSend={send}\n                    onInsert={insert}\n                    onEdit={edit}\n                    onDiscard={discard}\n                    onRestore={restore}\n                  />\n                </div>\n              )}\n            </main>\n            <aside\n              aria-label='Copilot'\n              className='hidden w-72 shrink-0 py-1 @2xl:flex @4xl:w-80'\n            >\n              {!isPhone && (\n                <CopilotPanel {...copilot} showsRefund className='w-full' />\n              )}\n            </aside>\n          </div>\n\n          <InlineSheet\n            name='list'\n            label='Tickets'\n            closeLabel='Close the ticket list'\n            side='start'\n            isOpen={isListShown}\n            className='@4xl:hidden'\n            panelClassName='bg-sidebar gap-1 p-3'\n            onClose={closeList}\n          >\n            {isCompact && <TicketList {...list} />}\n          </InlineSheet>\n          <InlineSheet\n            name='copilot'\n            label='Copilot'\n            closeLabel='Close the copilot'\n            side='bottom'\n            isOpen={isCopilotShown}\n            className='@2xl:hidden'\n            panelClassName='bg-sidebar h-[80%] gap-1 p-3'\n            onClose={closeCopilot}\n          >\n            {isPhone && (\n              <CopilotPanel\n                {...copilot}\n                showsRefund={false}\n                className='min-h-0 flex-1'\n              />\n            )}\n          </InlineSheet>\n          <LiveRegion message={message} />\n        </div>\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/index.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/ticket-list.tsx",
      "content": "'use client';\n\nimport { LayoutGroup, motion, type Transition } from 'motion/react';\nimport { useId } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { springOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\n\nimport {\n  BRAND,\n  TICKETS,\n  type Priority,\n  type Ticket,\n  type TicketStatus,\n} from './data';\nimport type { TicketLive } from './session';\n\ntype GroupId = 'open' | 'solved';\n\nconst GROUPS: { id: GroupId; label: string; emptyLine: string }[] = [\n  { id: 'open', label: 'Open', emptyLine: 'Every ticket is solved' },\n  { id: 'solved', label: 'Solved', emptyLine: 'Solved tickets land here' },\n];\n\nconst STATUS_WORD: Record<TicketStatus, string> = {\n  open: 'Open',\n  pending: 'Pending',\n  solved: 'Solved',\n};\n\nconst STATUS_VARIANT: Record<TicketStatus, 'info' | 'warning' | 'success'> = {\n  open: 'info',\n  pending: 'warning',\n  solved: 'success',\n};\n\nconst PRIORITY_WORD: Record<Priority, string> = {\n  high: 'High priority',\n  normal: 'Normal priority',\n  low: 'Low priority',\n};\n\nconst PRIORITY_BARS: Record<Priority, number> = { high: 3, normal: 2, low: 1 };\n\nconst BAR_HEIGHTS = ['h-1', 'h-2', 'h-3'];\n\nfunction groupOf(status: TicketStatus): GroupId {\n  if (status === 'solved') {\n    return 'solved';\n  }\n  return 'open';\n}\n\nfunction barToneOf(isFilled: boolean) {\n  if (isFilled) {\n    return 'bg-foreground/70';\n  }\n  return 'bg-foreground/15';\n}\n\nexport function PriorityBars({ priority }: { priority: Priority }) {\n  const filled = PRIORITY_BARS[priority];\n\n  return (\n    <span className='inline-flex shrink-0 items-end gap-0.5'>\n      {BAR_HEIGHTS.map((height, index) => {\n        const isFilled = index < filled;\n        return (\n          <span\n            key={height}\n            aria-hidden='true'\n            className={cn('w-[3px] rounded-full', height, barToneOf(isFilled))}\n          />\n        );\n      })}\n      <span className='sr-only'>{PRIORITY_WORD[priority]}</span>\n    </span>\n  );\n}\n\nexport function StatusBadge({ status }: { status: TicketStatus }) {\n  return (\n    <Swap swapKey={status}>\n      <Badge variant={STATUS_VARIANT[status]}>{STATUS_WORD[status]}</Badge>\n    </Swap>\n  );\n}\n\nfunction currentOf(isOpen: boolean): 'true' | undefined {\n  if (isOpen) {\n    return 'true';\n  }\n  return undefined;\n}\n\nfunction rowToneOf(isOpen: boolean) {\n  if (isOpen) {\n    return 'bg-foreground/[0.07]';\n  }\n  return 'hover:bg-foreground/[0.04]';\n}\n\nfunction nameWeightOf(isUnread: boolean) {\n  if (isUnread) {\n    return 'font-semibold';\n  }\n  return 'font-medium';\n}\n\ntype TicketRowProps = {\n  ticket: Ticket;\n  live: TicketLive;\n  isOpen: boolean;\n  isPressed: boolean;\n  placement: string;\n  travel: Transition;\n  onOpen: (id: string) => void;\n};\n\n/** A ticket that is solved keeps its layout id, so its row travels from Open to Solved. */\nfunction TicketRow({\n  ticket,\n  live,\n  isOpen,\n  isPressed,\n  placement,\n  travel,\n  onOpen,\n}: TicketRowProps) {\n  function open() {\n    onOpen(ticket.id);\n  }\n\n  return (\n    <motion.li\n      layout='position'\n      layoutId={ticket.id}\n      layoutDependency={placement}\n      transition={{ layout: travel }}\n    >\n      <button\n        type='button'\n        aria-current={currentOf(isOpen)}\n        onClick={open}\n        className={cn(\n          'focus-visible:ring-ring/25 flex w-full cursor-pointer flex-col gap-1 rounded-lg px-2.5 py-2 text-start transition-[background-color,scale] duration-150 outline-none focus-visible:ring-[3px]',\n          rowToneOf(isOpen),\n          pressedQuietOf(isPressed)\n        )}\n      >\n        <span className='flex items-center gap-2'>\n          {live.isUnread && (\n            <span className='bg-primary size-1.5 shrink-0 rounded-full'>\n              <span className='sr-only'>Unread</span>\n            </span>\n          )}\n          <span\n            className={cn(\n              'min-w-0 flex-1 truncate text-[13px]',\n              nameWeightOf(live.isUnread)\n            )}\n          >\n            {ticket.customer.name}\n          </span>\n          <span className='text-muted-foreground shrink-0 text-xs tabular-nums'>\n            {ticket.receivedAgo}\n          </span>\n        </span>\n        <span className='text-muted-foreground truncate text-xs'>\n          {ticket.subject}\n        </span>\n        <span className='flex items-center gap-2 pt-0.5'>\n          <StatusBadge status={live.status} />\n          <PriorityBars priority={ticket.priority} />\n        </span>\n      </button>\n    </motion.li>\n  );\n}\n\ntype TicketListProps = {\n  live: Record<string, TicketLive>;\n  openId: string | null;\n  placement: string;\n  pressed: string | null;\n  onOpen: (id: string) => void;\n};\n\nexport function TicketList({\n  live,\n  openId,\n  placement,\n  pressed,\n  onOpen,\n}: TicketListProps) {\n  const groupId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const travel = springOf(shouldReduceMotion);\n\n  return (\n    <div className='flex min-h-0 w-full flex-col gap-3'>\n      <div className='flex h-9 shrink-0 items-center gap-2 px-1.5'>\n        <CompanyMark seed={BRAND.name} className='size-6 rounded-md' />\n        <span className='text-[13px] font-semibold'>{BRAND.name}</span>\n        <span className='text-muted-foreground text-xs'>{BRAND.desk}</span>\n      </div>\n      <LayoutGroup id={groupId}>\n        <nav\n          aria-label='Tickets'\n          className='-mx-1 flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-1'\n        >\n          {GROUPS.map((group) => {\n            const tickets = TICKETS.filter((ticket) => {\n              const ticketGroup = groupOf(live[ticket.id].status);\n              return ticketGroup === group.id;\n            });\n            const isEmpty = tickets.length === 0;\n            return (\n              <section key={group.id} className='flex flex-col gap-1'>\n                <motion.h2\n                  layout='position'\n                  layoutDependency={placement}\n                  transition={{ layout: travel }}\n                  className='text-muted-foreground flex h-6 items-center gap-1.5 px-2.5 text-xs font-medium'\n                >\n                  {group.label}\n                  <LayoutGroup inherit={false}>\n                    <MotionNumber value={tickets.length} />\n                  </LayoutGroup>\n                </motion.h2>\n                <ul className='flex flex-col gap-px'>\n                  {tickets.map((ticket) => {\n                    const pressKey = `ticket-${ticket.id}`;\n                    return (\n                      <TicketRow\n                        key={ticket.id}\n                        ticket={ticket}\n                        live={live[ticket.id]}\n                        isOpen={ticket.id === openId}\n                        isPressed={pressed === pressKey}\n                        placement={placement}\n                        travel={travel}\n                        onOpen={onOpen}\n                      />\n                    );\n                  })}\n                </ul>\n                {isEmpty && (\n                  <p className='text-muted-foreground px-2.5 text-xs'>\n                    {group.emptyLine}\n                  </p>\n                )}\n              </section>\n            );\n          })}\n        </nav>\n      </LayoutGroup>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/ticket-list.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/conversation.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\n\nimport { useFollowBottom } from '@/registry/ndeko/hooks/use-follow-bottom';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CheckIcon,\n  CircleXIcon,\n  ImageIcon,\n  InboxIcon,\n  MenuIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\n\nimport { ME, REFUND, type Ticket } from './data';\nimport type { OpenTicket, RefundStatus, TicketLive } from './session';\nimport { PriorityBars, StatusBadge } from './ticket-list';\n\nfunction PersonAvatar({ name }: { name: string }) {\n  return <Avatar className='size-7 shrink-0' seed={name} />;\n}\n\nfunction CustomerBubble({ ticket }: { ticket: Ticket }) {\n  return (\n    <div className='flex items-end gap-2 pb-4'>\n      <PersonAvatar name={ticket.customer.name} />\n      <div className='flex max-w-[85%] flex-col gap-1.5'>\n        <p className='bg-foreground/[0.06] rounded-2xl rounded-es-md px-3.5 py-2 text-sm leading-relaxed'>\n          {ticket.message}\n        </p>\n        {ticket.attachment && (\n          <span className='bg-foreground/[0.04] text-muted-foreground flex h-7 w-fit items-center gap-1.5 rounded-lg px-2 text-xs'>\n            <ImageIcon className='size-3.5' />\n            {ticket.attachment}\n          </span>\n        )}\n      </div>\n    </div>\n  );\n}\n\nfunction ReplyBubble({ text }: { text: string }) {\n  return (\n    <div className='flex items-end justify-end gap-2 pb-4'>\n      <p className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] max-w-[85%] rounded-2xl rounded-ee-md px-3.5 py-2 text-sm leading-relaxed whitespace-pre-line shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n        {text}\n      </p>\n      <PersonAvatar name={ME.name} />\n    </div>\n  );\n}\n\ntype EventLineProps = {\n  icon: React.ReactNode;\n  children: React.ReactNode;\n};\n\nfunction EventLine({ icon, children }: EventLineProps) {\n  return (\n    <p className='text-muted-foreground flex items-center justify-center gap-1.5 pb-4 text-center text-xs'>\n      {icon}\n      {children}\n    </p>\n  );\n}\n\nfunction RefundLine({ status }: { status: RefundStatus }) {\n  if (status === 'issued') {\n    return (\n      <EventLine\n        icon={<CheckIcon className='text-success-foreground size-3.5' />}\n      >\n        Refund of {REFUND.amount} issued to {REFUND.card}\n      </EventLine>\n    );\n  }\n  return (\n    <EventLine icon={<CircleXIcon className='size-3.5' />}>\n      No refund was issued\n    </EventLine>\n  );\n}\n\ntype ConversationHeaderProps = {\n  open: OpenTicket | null;\n  canReplay: boolean;\n  onReplay: () => void;\n  onOpenList: () => void;\n  onOpenCopilot: () => void;\n};\n\nexport function ConversationHeader({\n  open,\n  canReplay,\n  onReplay,\n  onOpenList,\n  onOpenCopilot,\n}: ConversationHeaderProps) {\n  return (\n    <header className='flex h-14 shrink-0 items-center gap-2.5 px-3 @2xl:px-4'>\n      <Button\n        type='button'\n        variant='ghost'\n        size='icon-sm'\n        data-sheet-open='list'\n        aria-label='Open the ticket list'\n        aria-haspopup='dialog'\n        onClick={onOpenList}\n        className='text-muted-foreground @4xl:hidden'\n      >\n        <MenuIcon />\n      </Button>\n      {!open && (\n        <h1 className='min-w-0 flex-1 truncate text-sm font-medium'>Inbox</h1>\n      )}\n      {open && (\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <h1 className='truncate text-sm font-medium'>\n            {open.ticket.subject}\n          </h1>\n          <p className='text-muted-foreground truncate text-xs'>\n            {open.ticket.customer.name}\n          </p>\n        </div>\n      )}\n      {open && (\n        <span className='hidden @sm:inline-flex'>\n          <PriorityBars priority={open.ticket.priority} />\n        </span>\n      )}\n      {open && <StatusBadge status={open.live.status} />}\n      <ReplayButton isShown={canReplay} onReplay={onReplay} label='Replay' />\n      <Button\n        type='button'\n        variant='outline'\n        size='sm'\n        data-sheet-open='copilot'\n        aria-haspopup='dialog'\n        onClick={onOpenCopilot}\n        className='@2xl:hidden'\n      >\n        Copilot\n      </Button>\n    </header>\n  );\n}\n\nfunction EmptyConversation() {\n  return (\n    <div className='m-auto flex max-w-xs flex-col items-center gap-3 px-4 text-center'>\n      <span\n        aria-hidden='true'\n        className='keycap-3d text-muted-foreground inline-flex size-10 items-center justify-center rounded-lg'\n      >\n        <InboxIcon className='size-5' />\n      </span>\n      <p className='text-sm font-medium'>Pick a ticket</p>\n      <p className='text-muted-foreground text-[13px] leading-relaxed'>\n        The copilot reads it, looks up the customer and drafts a reply you can\n        insert, edit or discard.\n      </p>\n    </div>\n  );\n}\n\ntype MessagesProps = {\n  ticket: Ticket;\n  live: TicketLive;\n  refund: RefundStatus;\n};\n\n/** The refund belongs to one ticket: on any other, `refund` is `none` and no line about it shows. */\nfunction Messages({ ticket, live, refund }: MessagesProps) {\n  const { scrollerRef, contentRef, updatePinned } = useFollowBottom();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const isRefundSettled = refund === 'issued' || refund === 'denied';\n  const isSolved = live.status === 'solved';\n\n  return (\n    <div\n      ref={scrollerRef}\n      onScroll={updatePinned}\n      className='min-h-24 flex-1 overflow-y-auto'\n    >\n      <div\n        ref={contentRef}\n        className='mx-auto flex w-full max-w-2xl flex-col px-4 pt-4'\n      >\n        <CustomerBubble ticket={ticket} />\n        <AnimatePresence initial={false}>\n          {isRefundSettled && (\n            <motion.div\n              key='refund'\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <RefundLine status={refund} />\n            </motion.div>\n          )}\n          {live.sentReplies.map((reply, index) => (\n            <motion.div\n              key={`reply-${index}`}\n              className='-mx-1 overflow-hidden px-1'\n              {...rowPresence}\n            >\n              <ReplyBubble text={reply} />\n            </motion.div>\n          ))}\n          {isSolved && (\n            <motion.div\n              key='solved'\n              className='overflow-hidden'\n              {...rowPresence}\n            >\n              <EventLine\n                icon={\n                  <CheckIcon className='text-success-foreground size-3.5' />\n                }\n              >\n                Marked as solved\n              </EventLine>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </div>\n  );\n}\n\ntype ConversationProps = MessagesProps | { ticket: null };\n\n/** Keyed by ticket, so opening another one swaps the messages without replaying their entrance. */\nexport function Conversation(props: ConversationProps) {\n  if (props.ticket === null) {\n    return (\n      <div className='flex min-h-0 flex-1'>\n        <EmptyConversation />\n      </div>\n    );\n  }\n  return <Messages key={props.ticket.id} {...props} />;\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/conversation.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/reply-composer.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport {\n  CircleCheckIcon,\n  SendIcon,\n  UndoIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Kbd, KbdGroup } from '@/registry/ndeko/ui/kbd';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\n\nimport { EMPTY_SEND_HINT } from './data';\nimport { DraftCard } from './draft-card';\nimport type { DraftStatus, SendStatus, TicketLive } from './session';\n\nconst SEND_STATE: Record<SendStatus, MorphState> = {\n  idle: 'idle',\n  sending: 'busy',\n  sent: 'done',\n};\n\nconst SEND_LABELS: Record<MorphState, string> = {\n  idle: 'Send',\n  busy: 'Sending',\n  done: 'Sent',\n};\n\n/** The gap under the draft sits inside what resizes, so an empty draft area takes no room at all. */\nconst TRACE =\n  'text-muted-foreground mb-2 flex min-h-7 items-center gap-1.5 px-1 text-xs transition-opacity duration-300 starting:opacity-0';\n\nconst NUDGE = { x: [0, -4, 4, 0] };\n\nconst STILL = { x: 0 };\n\n/** A refused entry nudges its reason once. Reduced motion keeps it still. */\nfunction nudgeOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return STILL;\n  }\n  return NUDGE;\n}\n\nfunction describedByOf(showsHint: boolean, hintId: string) {\n  if (showsHint) {\n    return hintId;\n  }\n  return undefined;\n}\n\nfunction placeholderOf(draft: DraftStatus) {\n  if (draft === 'streaming') {\n    return 'The copilot is drafting a reply';\n  }\n  return 'Write a reply';\n}\n\ntype DraftAreaProps = {\n  draft: DraftStatus;\n  isActive: boolean;\n  isInsertPressed: boolean;\n  onInsert: () => void;\n  onEdit: () => void;\n  onDiscard: () => void;\n  onRestore: () => void;\n};\n\nfunction DraftArea({\n  draft,\n  isActive,\n  isInsertPressed,\n  onInsert,\n  onEdit,\n  onDiscard,\n  onRestore,\n}: DraftAreaProps) {\n  const isStreaming = draft === 'streaming';\n  const showsCard = isStreaming || draft === 'ready';\n\n  if (showsCard) {\n    return (\n      <div className='pb-2'>\n        <DraftCard\n          isStreaming={isStreaming}\n          isActive={isActive}\n          isInsertPressed={isInsertPressed}\n          onInsert={onInsert}\n          onEdit={onEdit}\n          onDiscard={onDiscard}\n        />\n      </div>\n    );\n  }\n  if (draft === 'inserted') {\n    return (\n      <p className={TRACE}>\n        <CircleCheckIcon className='text-success-foreground size-3.5 shrink-0' />\n        Draft inserted. Read it through before you send\n      </p>\n    );\n  }\n  if (draft === 'discarded') {\n    return (\n      <p className={TRACE}>\n        Draft discarded\n        <Button\n          type='button'\n          variant='ghost'\n          size='sm'\n          data-draft-restore\n          onClick={onRestore}\n          className='text-muted-foreground h-6 px-1.5'\n        >\n          <UndoIcon className='size-3.5' />\n          Restore\n        </Button>\n      </p>\n    );\n  }\n  return null;\n}\n\ntype ReplyComposerProps = DraftAreaProps & {\n  live: TicketLive;\n  showsSendHint: boolean;\n  emptySends: number;\n  isSendPressed: boolean;\n  onType: (text: string) => void;\n  onSend: () => void;\n};\n\n/** The draft arrives in the box a person answers from, above the field it will be inserted into. */\nexport function ReplyComposer({\n  live,\n  showsSendHint,\n  emptySends,\n  isSendPressed,\n  onType,\n  onSend,\n  ...draftArea\n}: ReplyComposerProps) {\n  const hintId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  function sendFromKeys(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n    const hasModifier = event.metaKey || event.ctrlKey;\n    const isSendKey = event.key === 'Enter' && hasModifier;\n    if (!isSendKey) {\n      return;\n    }\n    event.preventDefault();\n    onSend();\n  }\n\n  return (\n    <div className='bg-card hairline-ring ring-foreground/12 has-[textarea:focus-visible]:ring-ring/25 dark:bg-foreground/[0.04] dark:ring-foreground/15 flex flex-col rounded-2xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.05)] transition-[box-shadow] duration-150 has-[textarea:focus-visible]:ring-[3px]'>\n      <AnimatedSize>\n        <DraftArea {...draftArea} />\n      </AnimatedSize>\n      <textarea\n        data-reply-field\n        value={live.reply}\n        rows={2}\n        aria-label='Reply to the customer'\n        aria-invalid={showsSendHint}\n        aria-describedby={describedByOf(showsSendHint, hintId)}\n        placeholder={placeholderOf(draftArea.draft)}\n        onChange={(event) => onType(event.target.value)}\n        onKeyDown={sendFromKeys}\n        className='placeholder:text-muted-foreground/75 field-sizing-content max-h-[9lh] min-h-[2lh] resize-none bg-transparent px-1.5 py-1 text-base leading-normal outline-none md:text-[13px]'\n      />\n      <div className='flex min-h-7 items-center gap-2 pt-2'>\n        <div className='min-w-0 flex-1 px-1.5'>\n          {showsSendHint && (\n            <motion.p\n              key={emptySends}\n              id={hintId}\n              animate={nudgeOf(shouldReduceMotion)}\n              transition={{ duration: 0.28 }}\n              className='text-destructive-ink text-xs'\n            >\n              {EMPTY_SEND_HINT}\n            </motion.p>\n          )}\n          {!showsSendHint && (\n            <p className='text-muted-foreground hidden items-center gap-1.5 text-xs @md:flex'>\n              <KbdGroup aria-hidden='true'>\n                <Kbd>Ctrl</Kbd>\n                <Kbd>Enter</Kbd>\n              </KbdGroup>\n              <span className='sr-only'>Control or Command with Enter</span>\n              sends\n            </p>\n          )}\n        </div>\n        <MorphButton\n          type='button'\n          size='sm'\n          data-reply-send\n          state={SEND_STATE[live.send]}\n          labels={SEND_LABELS}\n          idleIcon={<SendIcon />}\n          onClick={onSend}\n          className={pressedSolidOf(isSendPressed)}\n        />\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/reply-composer.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/draft-card.tsx",
      "content": "'use client';\n\nimport { Fragment } from 'react';\n\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { BookOpenIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { countOf, leadingSpaceOf } from '@/registry/ndeko/lib/words';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\nimport {\n  inkClassOf,\n  shownCountOf,\n  StreamCaret,\n  useRevealedCount,\n} from '@/registry/ndeko/ui/streamed-text';\n\nimport { ARTICLES, DRAFT_TOKENS, WRITER, type Article } from './data';\nimport { DRAFT_WORD_MS } from './session';\n\nconst MARK =\n  'keycap-3d text-muted-foreground inline-flex h-4 min-w-4 items-center justify-center rounded-[4px] px-1 text-[10px] leading-none font-medium tabular-nums';\n\n/** Each source lands a little after the one before it. */\nconst LANDING_DELAY = ['delay-0', 'delay-100', 'delay-200'];\n\nfunction statusOf(isStreaming: boolean) {\n  if (isStreaming) {\n    return 'Writing';\n  }\n  return countOf(ARTICLES.length, 'source');\n}\n\n/** A source waits out of sight while the draft streams, then settles from a slightly larger size. */\nfunction landingOf(hasLanded: boolean) {\n  if (hasLanded) {\n    return 'scale-100 opacity-100';\n  }\n  return 'invisible scale-[1.04] opacity-0';\n}\n\ntype SourceChipProps = {\n  article: Article;\n  order: number;\n  hasLanded: boolean;\n};\n\nfunction SourceChip({ article, order, hasLanded }: SourceChipProps) {\n  return (\n    <li\n      className={cn(\n        'bg-card dark:bg-foreground/[0.06] flex h-7 max-w-full items-center gap-1.5 rounded-full ps-1.5 pe-2.5 text-xs transition-[opacity,scale] duration-300 ease-(--ease-out-strong)',\n        LANDING_DELAY[order],\n        landingOf(hasLanded)\n      )}\n    >\n      <span className={cn(MARK, 'rounded-full')}>{article.number}</span>\n      <BookOpenIcon className='text-muted-foreground size-3.5 shrink-0' />\n      <span className='min-w-0 truncate'>{article.title}</span>\n    </li>\n  );\n}\n\ntype DraftCardProps = {\n  isStreaming: boolean;\n  isActive: boolean;\n  isInsertPressed: boolean;\n  onInsert: () => void;\n  onEdit: () => void;\n  onDiscard: () => void;\n};\n\n/** Only the draft re-renders while it streams. */\nexport function DraftCard({\n  isStreaming,\n  isActive,\n  isInsertPressed,\n  onInsert,\n  onEdit,\n  onDiscard,\n}: DraftCardProps) {\n  const total = DRAFT_TOKENS.length;\n  const isRunning = isStreaming && isActive;\n  const count = useRevealedCount(total, isRunning, DRAFT_WORD_MS);\n  const shown = shownCountOf(isStreaming, count, total);\n  const lastShown = shown - 1;\n  const status = statusOf(isStreaming);\n\n  return (\n    <section\n      aria-label='Draft from the copilot'\n      className='bg-foreground/[0.04] flex flex-col gap-2.5 rounded-lg p-3'\n    >\n      <header className='flex items-center gap-2'>\n        <MeshTile seed={WRITER.name} color={seriesColorOf(WRITER.series)} />\n        <h2 className='min-w-0 flex-1 truncate text-[13px] font-medium'>\n          Draft from the copilot\n        </h2>\n        <Swap swapKey={status} className='text-muted-foreground text-xs'>\n          {status}\n        </Swap>\n      </header>\n      <p className='text-[13px] leading-relaxed'>\n        {DRAFT_TOKENS.map((token, index) => {\n          const isShown = index < shown;\n          const ink = inkClassOf(isStreaming, isShown);\n          if (token.kind === 'cite') {\n            return (\n              <span\n                key={index}\n                className={cn(MARK, 'ms-1 align-[0.12em]', ink)}\n              >\n                <span className='sr-only'>Source </span>\n                {token.article}\n              </span>\n            );\n          }\n          const hasCaret = isStreaming && index === lastShown;\n          return (\n            <Fragment key={index}>\n              {leadingSpaceOf(index)}\n              <span className={ink}>\n                {token.text}\n                {hasCaret && <StreamCaret />}\n              </span>\n            </Fragment>\n          );\n        })}\n      </p>\n      <ul aria-label='Sources of the draft' className='flex flex-wrap gap-1.5'>\n        {ARTICLES.map((article, index) => (\n          <SourceChip\n            key={article.number}\n            article={article}\n            order={index}\n            hasLanded={!isStreaming}\n          />\n        ))}\n      </ul>\n      <div className='flex flex-wrap items-center gap-2'>\n        <Button\n          type='button'\n          size='sm'\n          aria-label='Insert the draft'\n          disabled={isStreaming}\n          onClick={onInsert}\n          className={pressedSolidOf(isInsertPressed)}\n        >\n          Insert\n        </Button>\n        <Button\n          type='button'\n          size='sm'\n          variant='outline'\n          aria-label='Edit the draft'\n          disabled={isStreaming}\n          onClick={onEdit}\n        >\n          Edit\n        </Button>\n        <Button\n          type='button'\n          size='sm'\n          variant='ghost'\n          aria-label='Discard the draft'\n          disabled={isStreaming}\n          onClick={onDiscard}\n          className='text-muted-foreground'\n        >\n          Discard\n        </Button>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/draft-card.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/copilot-panel.tsx",
      "content": "'use client';\n\nimport { WordRoll } from '@/components/core/word-roll';\nimport { useFollowBottom } from '@/registry/ndeko/hooks/use-follow-bottom';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { MeshTile } from '@/registry/ndeko/ui/mesh-tile';\n\nimport { CopilotSteps } from './copilot-steps';\nimport { CustomerCard } from './customer-card';\nimport {\n  CUSTOMER_FIELDS,\n  MODEL,\n  WRITER,\n  type StepId,\n  type Ticket,\n} from './data';\nimport { RefundRequest } from './refund-request';\nimport type { Decision, RefundStatus, StepRun } from './session';\n\nconst WORKING_WORD: Record<StepId, string> = {\n  read: 'Reading the ticket',\n  lookup: 'Looking up the customer',\n  search: 'Searching the help center',\n  draft: 'Drafting a reply',\n};\n\nconst RESTING_WORDS = [\n  'Nothing to suggest',\n  'Waiting on you',\n  'Starting',\n  'Done',\n];\n\nconst WORKING_WORDS = Object.values(WORKING_WORD);\n\nconst STATUS_WORDS = [...WORKING_WORDS, ...RESTING_WORDS];\n\nexport type CopilotWork = {\n  steps: StepRun[];\n  lookedUpFields: number;\n  articlesFound: number;\n  refund: RefundStatus;\n};\n\nfunction statusOf(work: CopilotWork | null) {\n  if (!work) {\n    return 'Nothing to suggest';\n  }\n  if (work.refund === 'asking') {\n    return 'Waiting on you';\n  }\n  const running = work.steps.find((run) => run.status === 'running');\n  if (running) {\n    return WORKING_WORD[running.id];\n  }\n  if (work.steps.length === 0) {\n    return 'Starting';\n  }\n  return 'Done';\n}\n\nfunction lookedUpOf(work: CopilotWork | null) {\n  if (!work) {\n    return CUSTOMER_FIELDS.length;\n  }\n  return work.lookedUpFields;\n}\n\n/** The request only shows where the panel is asked to show it, and only once the copilot has asked. */\nfunction requestOf(work: CopilotWork | null, showsRefund: boolean) {\n  if (!work || !showsRefund) {\n    return null;\n  }\n  if (work.refund === 'none') {\n    return null;\n  }\n  return work.refund;\n}\n\n/**\n * The copilot follows one ticket: `work` is null on any other, where the panel shows the customer and\n * nothing to suggest. On a phone the refund request sits above the reply box, so `showsRefund` is false.\n */\ntype CopilotPanelProps = {\n  ticket: Ticket | null;\n  work: CopilotWork | null;\n  showsRefund: boolean;\n  pressed: string | null;\n  onDecide: (decision: Decision) => void;\n  className?: string;\n};\n\nexport function CopilotPanel({\n  ticket,\n  work,\n  showsRefund,\n  pressed,\n  onDecide,\n  className,\n}: CopilotPanelProps) {\n  const { scrollerRef, contentRef, updatePinned } = useFollowBottom();\n  const status = statusOf(work);\n  const request = requestOf(work, showsRefund);\n  const hasTicket = ticket !== null;\n  const showsNothingToSuggest = hasTicket && !work;\n\n  return (\n    <div className={cn('flex min-h-0 flex-col gap-3', className)}>\n      <header className='flex shrink-0 items-start gap-2.5 px-1'>\n        <MeshTile\n          seed={WRITER.name}\n          color={seriesColorOf(WRITER.series)}\n          size='lg'\n        />\n        <div className='flex min-w-0 flex-1 flex-col leading-tight'>\n          <div className='flex items-center gap-2'>\n            <h2 className='min-w-0 flex-1 truncate text-sm font-medium'>\n              Copilot\n            </h2>\n            <span className='text-muted-foreground flex shrink-0 items-center gap-1.5 text-xs'>\n              <BrandTile brand={MODEL.brand} />\n              {MODEL.name}\n            </span>\n          </div>\n          {ticket && (\n            <span className='text-muted-foreground text-xs'>\n              <WordRoll text={status} labels={STATUS_WORDS} />\n            </span>\n          )}\n        </div>\n      </header>\n\n      {/* The scroller exists before a ticket is open, so it is there to follow once cards arrive. */}\n      <div\n        ref={scrollerRef}\n        onScroll={updatePinned}\n        className='-mx-1 min-h-0 flex-1 overflow-y-auto px-1 pb-1'\n      >\n        <div ref={contentRef} className='flex flex-col gap-3'>\n          {!ticket && (\n            <p className='text-muted-foreground px-1 text-[13px] leading-relaxed'>\n              Open a ticket and the copilot gets to work: it reads the message,\n              looks up the customer and searches the help center.\n            </p>\n          )}\n          {ticket && (\n            <CustomerCard\n              customer={ticket.customer}\n              lookedUpFields={lookedUpOf(work)}\n            />\n          )}\n          {work && (\n            <div className='px-2'>\n              <CopilotSteps\n                steps={work.steps}\n                articlesFound={work.articlesFound}\n              />\n            </div>\n          )}\n          {showsNothingToSuggest && (\n            <p className='text-muted-foreground px-1 text-xs leading-5'>\n              Nothing to suggest here. This demonstration follows one ticket,\n              the torn bag.\n            </p>\n          )}\n          {request && (\n            <RefundRequest\n              status={request}\n              pressed={pressed}\n              onDecide={onDecide}\n            />\n          )}\n          {ticket && (\n            <Badge variant='secondary' className='mx-1'>\n              Illustrative figures\n            </Badge>\n          )}\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/copilot-panel.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/customer-card.tsx",
      "content": "import { Avatar } from '@/registry/ndeko/ui/avatar';\n\nimport { CUSTOMER_FIELDS, type Customer } from './data';\n\ntype CustomerCardProps = {\n  customer: Customer;\n  lookedUpFields: number;\n};\n\n/** A field the copilot has not looked up yet shows a bar where its value will be. */\nexport function CustomerCard({ customer, lookedUpFields }: CustomerCardProps) {\n  return (\n    <section\n      aria-label='Customer'\n      className='bg-card hairline-ring ring-border dark:bg-foreground/[0.04] flex flex-col gap-3 rounded-xl p-3 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <div className='flex items-center gap-2.5'>\n        <Avatar seed={customer.name} />\n        <div className='flex min-w-0 flex-col leading-tight'>\n          <h3 className='truncate text-[13px] font-medium'>{customer.name}</h3>\n          <span className='text-muted-foreground truncate text-xs'>\n            {customer.email}\n          </span>\n        </div>\n      </div>\n      <dl className='flex flex-col gap-1.5 text-xs'>\n        {CUSTOMER_FIELDS.map((field, index) => {\n          const isFilled = index < lookedUpFields;\n          return (\n            <div key={field.key} className='flex h-5 items-center gap-2'>\n              <dt className='text-muted-foreground w-24 shrink-0'>\n                {field.label}\n              </dt>\n              <dd className='min-w-0 flex-1 truncate'>\n                {isFilled && (\n                  <span className='transition-opacity duration-300 starting:opacity-0'>\n                    {customer[field.key]}\n                  </span>\n                )}\n                {!isFilled && (\n                  <span className='bg-foreground/10 block h-2 w-20 rounded-full'>\n                    <span className='sr-only'>Not looked up yet</span>\n                  </span>\n                )}\n              </dd>\n            </div>\n          );\n        })}\n      </dl>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/customer-card.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/copilot-steps.tsx",
      "content": "'use client';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { CallStatusMark } from '@/registry/ndeko/ui/call-status';\nimport { LiveDuration } from '@/registry/ndeko/ui/live-duration';\n\nimport { ARTICLES, stepOf, type Article, type CopilotStep } from './data';\nimport type { StepRun } from './session';\n\nfunction sublineOf(step: CopilotStep, run: StepRun) {\n  if (run.status === 'done') {\n    return step.doneSummary;\n  }\n  return step.detail;\n}\n\n/** A row rises in while the copilot is at that step. Coming back to the ticket shows what is already there, still. */\nfunction arrivalOf(isArriving: boolean) {\n  if (isArriving) {\n    return 'transition-[opacity,translate] duration-300 ease-(--ease-out-strong) starting:translate-y-1 starting:opacity-0';\n  }\n  return undefined;\n}\n\ntype ArticleRowProps = {\n  article: Article;\n  isArriving: boolean;\n};\n\nfunction ArticleRow({ article, isArriving }: ArticleRowProps) {\n  return (\n    <li\n      className={cn(\n        'bg-foreground/[0.04] flex items-start gap-2 rounded-md px-2 py-1.5 text-xs',\n        arrivalOf(isArriving)\n      )}\n    >\n      <span className='keycap-3d text-muted-foreground mt-px inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-[4px] px-1 text-[10px] leading-none font-medium tabular-nums'>\n        {article.number}\n      </span>\n      <span className='flex min-w-0 flex-col'>\n        <span className='truncate font-medium'>{article.title}</span>\n        <span className='text-muted-foreground leading-4'>\n          {article.excerpt}\n        </span>\n      </span>\n    </li>\n  );\n}\n\ntype StepRowProps = {\n  run: StepRun;\n  isLast: boolean;\n  articlesFound: number;\n};\n\nfunction StepRow({ run, isLast, articlesFound }: StepRowProps) {\n  const step = stepOf(run.id);\n  const isRunning = run.status === 'running';\n  const articles = ARTICLES.slice(0, articlesFound);\n  const showsArticles = run.id === 'search' && articles.length > 0;\n\n  return (\n    <li\n      className={cn(\n        'relative flex gap-2.5 pb-3 last:pb-0',\n        arrivalOf(isRunning)\n      )}\n    >\n      {!isLast && (\n        <span\n          aria-hidden='true'\n          className='bg-border absolute start-2 top-6 bottom-1 w-px'\n        />\n      )}\n      <span className='flex h-5 shrink-0 items-center'>\n        <CallStatusMark status={run.status} />\n      </span>\n      <div className='flex min-w-0 flex-1 flex-col'>\n        <p className='flex h-5 items-center gap-2 text-[13px]'>\n          <span className='min-w-0 flex-1 truncate font-medium'>\n            {step.title}\n          </span>\n          <LiveDuration\n            item={run}\n            isRunning={isRunning}\n            className='text-muted-foreground w-10 shrink-0 text-end text-xs'\n          />\n        </p>\n        <p\n          key={run.status}\n          className='text-muted-foreground text-xs leading-5 transition-opacity duration-300 starting:opacity-0'\n        >\n          {sublineOf(step, run)}\n        </p>\n        {showsArticles && (\n          <ul aria-label='Articles found' className='flex flex-col gap-1 pt-1'>\n            {articles.map((article) => (\n              <ArticleRow\n                key={article.number}\n                article={article}\n                isArriving={isRunning}\n              />\n            ))}\n          </ul>\n        )}\n      </div>\n    </li>\n  );\n}\n\ntype CopilotStepsProps = {\n  steps: StepRun[];\n  articlesFound: number;\n};\n\n/** Rows arrive at the end of the list, where nothing sits under them, so a fade is enough and nothing is resized by script. */\nexport function CopilotSteps({ steps, articlesFound }: CopilotStepsProps) {\n  const lastIndex = steps.length - 1;\n\n  return (\n    <ol aria-label='What the copilot did' className='flex flex-col'>\n      {steps.map((run, index) => (\n        <StepRow\n          key={run.id}\n          run={run}\n          isLast={index === lastIndex}\n          articlesFound={articlesFound}\n        />\n      ))}\n    </ol>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/copilot-steps.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/refund-request.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId } from 'react';\n\nimport { pressedSolidOf } from '@/registry/ndeko/lib/demonstration';\nimport { CircleXIcon, ReceiptIcon } from '@/registry/ndeko/lib/icons';\nimport { fadePresence } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { Kbd } from '@/registry/ndeko/ui/kbd';\nimport { Spinner } from '@/registry/ndeko/ui/spinner';\n\nimport { REFUND } from './data';\nimport type { Decision, RefundStatus } from './session';\n\ntype RequestBodyProps = {\n  pressed: string | null;\n  isCompact?: boolean;\n  onDecide: (decision: Decision) => void;\n};\n\n/** On a phone the request sits above the reply box, where it keeps to the amount, the reason and the answer. */\nfunction RequestBody({\n  pressed,\n  isCompact = false,\n  onDecide,\n}: RequestBodyProps) {\n  const titleId = useId();\n  const keysId = useId();\n\n  function allow() {\n    onDecide('approved');\n  }\n\n  function deny() {\n    onDecide('denied');\n  }\n\n  function decideFromKeys(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      deny();\n      return;\n    }\n    const isOnCard = event.target === event.currentTarget;\n    const isEnter = event.key === 'Enter';\n    if (isEnter && isOnCard) {\n      event.preventDefault();\n      allow();\n    }\n  }\n\n  return (\n    <div\n      role='group'\n      tabIndex={0}\n      aria-labelledby={titleId}\n      aria-describedby={keysId}\n      onKeyDown={decideFromKeys}\n      className='focus-visible:ring-ring/25 flex flex-col gap-3 rounded-xl p-3 outline-none focus-visible:ring-[3px] focus-visible:ring-inset'\n    >\n      {isCompact && (\n        <h3 id={titleId} className='sr-only'>\n          Issue this refund\n        </h3>\n      )}\n      {!isCompact && (\n        <div className='flex items-center gap-2.5'>\n          <span\n            aria-hidden='true'\n            className='keycap-3d text-muted-foreground inline-flex size-7 shrink-0 items-center justify-center rounded-md'\n          >\n            <ReceiptIcon className='size-3.5' />\n          </span>\n          <h3 id={titleId} className='min-w-0 flex-1 text-[13px] font-medium'>\n            Issue this refund\n          </h3>\n          <Badge variant='warning'>Waiting on you</Badge>\n        </div>\n      )}\n      <div className='flex flex-wrap items-baseline gap-x-2 gap-y-1'>\n        <span className='text-2xl leading-8 font-semibold tabular-nums'>\n          {REFUND.amount}\n        </span>\n        <span className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n          to\n          <BrandTile brand={REFUND.cardBrand} />\n          {REFUND.card}\n        </span>\n      </div>\n      {isCompact && (\n        <p className='text-muted-foreground truncate text-xs'>\n          {REFUND.reason}\n        </p>\n      )}\n      {!isCompact && (\n        <dl className='bg-foreground/[0.04] flex flex-col gap-1.5 rounded-lg p-2.5 text-xs'>\n          <div className='flex gap-2'>\n            <dt className='text-muted-foreground w-14 shrink-0'>Reason</dt>\n            <dd className='min-w-0'>{REFUND.reason}</dd>\n          </div>\n          <div className='flex gap-2'>\n            <dt className='text-muted-foreground w-14 shrink-0'>Order</dt>\n            <dd className='min-w-0 font-mono'>{REFUND.order}</dd>\n          </div>\n        </dl>\n      )}\n      <div className='flex flex-wrap items-center gap-2'>\n        <Button\n          type='button'\n          size='sm'\n          onClick={allow}\n          className={pressedSolidOf(pressed === 'allow')}\n        >\n          Allow\n          <Kbd className='ms-0.5'>Enter</Kbd>\n        </Button>\n        <Button type='button' size='sm' variant='outline' onClick={deny}>\n          Deny\n          <Kbd className='ms-0.5'>Esc</Kbd>\n        </Button>\n        <Badge variant='secondary' className='ms-auto'>\n          Illustrative\n        </Badge>\n        <span id={keysId} className='sr-only'>\n          Enter allows, Escape denies\n        </span>\n      </div>\n    </div>\n  );\n}\n\nfunction ResultGlyph({ status }: { status: RefundStatus }) {\n  if (status === 'issuing') {\n    return <Spinner aria-hidden='true' />;\n  }\n  if (status === 'denied') {\n    return <CircleXIcon className='text-muted-foreground size-4 shrink-0' />;\n  }\n  return <DrawnCheck tone='success' entrance='draw' />;\n}\n\nfunction resultLineOf(status: RefundStatus) {\n  if (status === 'issuing') {\n    return `Issuing ${REFUND.amount}`;\n  }\n  if (status === 'denied') {\n    return 'No refund issued. The reply only says one was asked for';\n  }\n  return `Refunded ${REFUND.amount} to ${REFUND.card}`;\n}\n\nfunction ResultLine({ status }: { status: RefundStatus }) {\n  return (\n    <div className='flex min-h-11 items-start gap-2.5 p-3 text-[13px] leading-5'>\n      <Swap swapKey={status} className='mt-px'>\n        <ResultGlyph status={status} />\n      </Swap>\n      <p\n        key={status}\n        className='min-w-0 transition-opacity duration-300 starting:opacity-0'\n      >\n        {resultLineOf(status)}\n      </p>\n    </div>\n  );\n}\n\nfunction viewKeyOf(isAsking: boolean) {\n  if (isAsking) {\n    return 'request';\n  }\n  return 'result';\n}\n\ntype RefundRequestProps = RequestBodyProps & {\n  status: RefundStatus;\n  className?: string;\n};\n\n/** The request resizes into one line that keeps a trace of what the person decided. */\nexport function RefundRequest({\n  status,\n  pressed,\n  isCompact,\n  onDecide,\n  className,\n}: RefundRequestProps) {\n  const fade = fadePresence();\n  const isAsking = status === 'asking';\n\n  return (\n    <section\n      data-request\n      tabIndex={-1}\n      aria-label='Refund request'\n      className={cn(\n        'bg-card hairline-ring ring-border dark:bg-foreground/[0.04] overflow-hidden rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)] transition-opacity duration-300 outline-none starting:opacity-0',\n        className\n      )}\n    >\n      <AnimatedSize>\n        <AnimatePresence initial={false} mode='popLayout'>\n          <motion.div key={viewKeyOf(isAsking)} {...fade}>\n            {isAsking && (\n              <RequestBody\n                pressed={pressed}\n                isCompact={isCompact}\n                onDecide={onDecide}\n              />\n            )}\n            {!isAsking && <ResultLine status={status} />}\n          </motion.div>\n        </AnimatePresence>\n      </AnimatedSize>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-11/refund-request.tsx"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport { restingOf } from '@/registry/ndeko/lib/run-session';\n\nimport {\n  ARTICLES,\n  CUSTOMER_FIELDS,\n  DRAFT_TEXT,\n  DRAFT_TOKENS,\n  EARLIER_REPLIES,\n  EMPTY_SEND_HINT,\n  REFUND,\n  SCRIPTED_TICKET,\n  ticketOf,\n  TICKETS,\n  type StepId,\n  type Ticket,\n  type TicketStatus,\n} from './data';\n\nexport type SendStatus = 'idle' | 'sending' | 'sent';\n\nexport type DraftStatus =\n  'none' | 'streaming' | 'ready' | 'inserted' | 'discarded' | 'closed';\n\nexport type RefundStatus = 'none' | 'asking' | 'issuing' | 'issued' | 'denied';\n\nexport type Decision = 'approved' | 'denied';\n\nexport type TicketLive = {\n  isUnread: boolean;\n  status: TicketStatus;\n  reply: string;\n  send: SendStatus;\n  sentReplies: string[];\n};\n\nexport type StepRun = {\n  id: StepId;\n  status: 'running' | 'done';\n  startedAt: number;\n  endedAt?: number;\n};\n\nexport type InboxState = {\n  openId: string | null;\n  live: Record<string, TicketLive>;\n  steps: StepRun[];\n  customerFields: number;\n  articlesFound: number;\n  draft: DraftStatus;\n  refund: RefundStatus;\n  emptySends: number;\n  showsSendHint: boolean;\n  spoken: string;\n  isListOpen: boolean;\n  isCopilotOpen: boolean;\n};\n\nexport type InboxAction =\n  | { type: 'opened'; id: string }\n  | { type: 'stepStarted'; id: StepId }\n  | { type: 'stepDone'; id: StepId }\n  | { type: 'customerField' }\n  | { type: 'articleFound' }\n  | { type: 'draftStarted' }\n  | { type: 'draftReady' }\n  | { type: 'draftInserted' }\n  | { type: 'draftDiscarded' }\n  | { type: 'draftRestored' }\n  | { type: 'replyTyped'; text: string }\n  | { type: 'sendPressed' }\n  | { type: 'delivered'; id: string }\n  | { type: 'refundAsked' }\n  | { type: 'refundDecided'; decision: Decision }\n  | { type: 'refunded' }\n  | { type: 'listSheet'; isOpen: boolean }\n  | { type: 'copilotSheet'; isOpen: boolean }\n  | { type: 'batch'; actions: InboxAction[] };\n\ntype Step = SessionStep<InboxState, InboxAction>;\n\nfunction earlierRepliesOf(id: string) {\n  const reply = EARLIER_REPLIES[id];\n  if (reply === undefined) {\n    return [];\n  }\n  return [reply];\n}\n\nfunction liveOf(ticket: Ticket): TicketLive {\n  return {\n    isUnread: ticket.isUnread,\n    status: ticket.status,\n    reply: '',\n    send: 'idle',\n    sentReplies: earlierRepliesOf(ticket.id),\n  };\n}\n\nfunction initialLiveOf() {\n  const live: Record<string, TicketLive> = {};\n  for (const ticket of TICKETS) {\n    live[ticket.id] = liveOf(ticket);\n  }\n  return live;\n}\n\nexport const INITIAL: InboxState = {\n  openId: null,\n  live: initialLiveOf(),\n  steps: [],\n  customerFields: 0,\n  articlesFound: 0,\n  draft: 'none',\n  refund: 'none',\n  emptySends: 0,\n  showsSendHint: false,\n  spoken: '',\n  isListOpen: false,\n  isCopilotOpen: false,\n};\n\nexport type OpenTicket = {\n  id: string;\n  ticket: Ticket;\n  live: TicketLive;\n};\n\nexport function openOf(state: InboxState): OpenTicket | null {\n  const id = state.openId;\n  if (id === null) {\n    return null;\n  }\n  return { id, ticket: ticketOf(id), live: state.live[id] };\n}\n\n/** Which group every ticket sits in. The rows of the list only measure themselves again when it changes. */\nexport function placementOf(state: InboxState) {\n  const places = TICKETS.map((ticket) => {\n    const live = state.live[ticket.id];\n    return `${ticket.id}:${live.status}`;\n  });\n  return places.join(' ');\n}\n\nfunction patchedLive(\n  state: InboxState,\n  id: string,\n  change: (live: TicketLive) => TicketLive\n): InboxState {\n  const next = change(state.live[id]);\n  return { ...state, live: { ...state.live, [id]: next } };\n}\n\nfunction opened(state: InboxState, id: string): InboxState {\n  const ticket = ticketOf(id);\n  const spoken = `${ticket.subject}, from ${ticket.customer.name}`;\n  const read = patchedLive(state, id, (live) => ({ ...live, isUnread: false }));\n  return {\n    ...read,\n    openId: id,\n    showsSendHint: false,\n    isListOpen: false,\n    spoken,\n  };\n}\n\nfunction stepStarted(state: InboxState, id: StepId, now: number): InboxState {\n  const isKnown = state.steps.some((run) => run.id === id);\n  if (isKnown) {\n    return state;\n  }\n  const run: StepRun = { id, status: 'running', startedAt: now };\n  return { ...state, steps: [...state.steps, run] };\n}\n\nfunction stepDone(state: InboxState, id: StepId, now: number): InboxState {\n  const steps = state.steps.map((run) => {\n    const isTarget = run.id === id && run.status === 'running';\n    if (!isTarget) {\n      return run;\n    }\n    const ended: StepRun = { ...run, status: 'done', endedAt: now };\n    return ended;\n  });\n  return { ...state, steps };\n}\n\nfunction customerField(state: InboxState): InboxState {\n  const filled = state.customerFields + 1;\n  const customerFields = Math.min(CUSTOMER_FIELDS.length, filled);\n  return { ...state, customerFields };\n}\n\nfunction articleFound(state: InboxState): InboxState {\n  const found = state.articlesFound + 1;\n  const articlesFound = Math.min(ARTICLES.length, found);\n  return { ...state, articlesFound };\n}\n\nfunction draftMoved(\n  state: InboxState,\n  from: DraftStatus,\n  to: DraftStatus\n): InboxState {\n  if (state.draft !== from) {\n    return state;\n  }\n  return { ...state, draft: to };\n}\n\nfunction draftReady(state: InboxState): InboxState {\n  if (state.draft !== 'streaming') {\n    return state;\n  }\n  const sources = ARTICLES.length;\n  const spoken = `The copilot drafted a reply with ${sources} sources`;\n  return { ...state, draft: 'ready', spoken };\n}\n\n/** Insert never throws away what a person already wrote: the draft goes under it. */\nfunction withDraft(reply: string) {\n  const written = reply.trim();\n  if (written === '') {\n    return DRAFT_TEXT;\n  }\n  return `${written}\\n\\n${DRAFT_TEXT}`;\n}\n\nfunction draftInserted(state: InboxState): InboxState {\n  if (state.draft !== 'ready') {\n    return state;\n  }\n  const filled = patchedLive(state, SCRIPTED_TICKET, (live) => ({\n    ...live,\n    reply: withDraft(live.reply),\n    send: 'idle',\n  }));\n  return {\n    ...filled,\n    draft: 'inserted',\n    showsSendHint: false,\n    spoken: 'Draft inserted in the reply box',\n  };\n}\n\nfunction replyTyped(state: InboxState, text: string): InboxState {\n  const id = state.openId;\n  if (id === null) {\n    return state;\n  }\n  const typed = patchedLive(state, id, (live) => ({\n    ...live,\n    reply: text,\n    send: 'idle',\n  }));\n  return { ...typed, showsSendHint: false };\n}\n\nfunction sendPressed(state: InboxState): InboxState {\n  const id = state.openId;\n  if (id === null) {\n    return state;\n  }\n  const live = state.live[id];\n  if (live.send === 'sending') {\n    return state;\n  }\n  const isEmpty = live.reply.trim() === '';\n  if (isEmpty) {\n    const emptySends = state.emptySends + 1;\n    return {\n      ...state,\n      emptySends,\n      showsSendHint: true,\n      spoken: EMPTY_SEND_HINT,\n    };\n  }\n  const sending = patchedLive(state, id, (current) => ({\n    ...current,\n    send: 'sending',\n  }));\n  return { ...sending, showsSendHint: false };\n}\n\nfunction delivered(state: InboxState, id: string): InboxState {\n  const live = state.live[id];\n  if (live.send !== 'sending') {\n    return state;\n  }\n  const reply = live.reply.trim();\n  const sent = patchedLive(state, id, (current) => ({\n    ...current,\n    reply: '',\n    send: 'sent',\n    status: 'solved',\n    sentReplies: [...current.sentReplies, reply],\n  }));\n  const draft = draftAfterReply(state, id);\n  return { ...sent, draft, spoken: 'Reply sent. The ticket is solved' };\n}\n\n/** Once its ticket is answered, a draft has nothing left to offer: it leaves the reply box, used or not. */\nfunction draftAfterReply(state: InboxState, id: string): DraftStatus {\n  const isItsTicket = id === SCRIPTED_TICKET;\n  const hasDraft = state.draft !== 'none';\n  if (isItsTicket && hasDraft) {\n    return 'closed';\n  }\n  return state.draft;\n}\n\nfunction refundAsked(state: InboxState): InboxState {\n  if (state.refund !== 'none') {\n    return state;\n  }\n  const spoken = `The copilot asks to refund ${REFUND.amount} to ${REFUND.card}. Allow or deny it`;\n  return { ...state, refund: 'asking', spoken };\n}\n\nfunction refundDecided(state: InboxState, decision: Decision): InboxState {\n  if (state.refund !== 'asking') {\n    return state;\n  }\n  if (decision === 'approved') {\n    return { ...state, refund: 'issuing' };\n  }\n  return { ...state, refund: 'denied', spoken: 'No refund was issued' };\n}\n\nfunction refunded(state: InboxState): InboxState {\n  if (state.refund !== 'issuing') {\n    return state;\n  }\n  const spoken = `Refund of ${REFUND.amount} issued to ${REFUND.card}`;\n  return { ...state, refund: 'issued', spoken };\n}\n\nexport function applyAt(\n  state: InboxState,\n  action: InboxAction,\n  now: number\n): InboxState {\n  switch (action.type) {\n    case 'opened':\n      return opened(state, action.id);\n    case 'stepStarted':\n      return stepStarted(state, action.id, now);\n    case 'stepDone':\n      return stepDone(state, action.id, now);\n    case 'customerField':\n      return customerField(state);\n    case 'articleFound':\n      return articleFound(state);\n    case 'draftStarted':\n      return draftMoved(state, 'none', 'streaming');\n    case 'draftReady':\n      return draftReady(state);\n    case 'draftInserted':\n      return draftInserted(state);\n    case 'draftDiscarded':\n      return draftMoved(state, 'ready', 'discarded');\n    case 'draftRestored':\n      return draftMoved(state, 'discarded', 'ready');\n    case 'replyTyped':\n      return replyTyped(state, action.text);\n    case 'sendPressed':\n      return sendPressed(state);\n    case 'delivered':\n      return delivered(state, action.id);\n    case 'refundAsked':\n      return refundAsked(state);\n    case 'refundDecided':\n      return refundDecided(state, action.decision);\n    case 'refunded':\n      return refunded(state);\n    case 'listSheet':\n      return { ...state, isListOpen: action.isOpen };\n    case 'copilotSheet':\n      return { ...state, isCopilotOpen: action.isOpen };\n    case 'batch': {\n      let next = state;\n      for (const inner of action.actions) {\n        next = applyAt(next, inner, now);\n      }\n      return next;\n    }\n  }\n}\n\nexport function reducer(state: InboxState, action: InboxAction) {\n  return applyAt(state, action, Date.now());\n}\n\nfunction hasOpenedScripted(state: InboxState) {\n  return !state.live[SCRIPTED_TICKET].isUnread;\n}\n\nfunction hasDecidedRefund(state: InboxState) {\n  return state.refund !== 'asking';\n}\n\nfunction hasHandledDraft(state: InboxState) {\n  return state.draft !== 'ready';\n}\n\nfunction hasPressedSend(state: InboxState) {\n  return state.live[SCRIPTED_TICKET].send !== 'idle';\n}\n\nexport const DRAFT_WORD_MS = 45;\n\n/** A stream is given a little longer than its words need, so its last word lands before the next step. */\nconst STREAM_MARGIN_MS = 200;\n\nconst DRAFT_STREAM_MS = DRAFT_TOKENS.length * DRAFT_WORD_MS;\n\nconst DRAFT_MS = DRAFT_STREAM_MS + STREAM_MARGIN_MS;\n\nconst DEMO_DECIDES_AFTER_MS = 2500;\n\nexport const REFUND_MS = 900;\n\nexport const SEND_MS = 1000;\n\nfunction frame(after: number, actions: InboxAction[]): Step {\n  return { after, action: { type: 'batch', actions } };\n}\n\nfunction started(id: StepId): InboxAction {\n  return { type: 'stepStarted', id };\n}\n\nfunction done(id: StepId): InboxAction {\n  return { type: 'stepDone', id };\n}\n\nconst FIELD: InboxAction = { type: 'customerField' };\n\nconst ARTICLE: InboxAction = { type: 'articleFound' };\n\n/** On a narrow page the list and the copilot live in sheets, which the demonstration opens and closes as a person would. */\nconst OPENING: Step[] = [\n  { after: 1200, by: 'demo', action: { type: 'listSheet', isOpen: true } },\n  {\n    after: 900,\n    by: 'person',\n    press: `ticket-${SCRIPTED_TICKET}`,\n    action: { type: 'opened', id: SCRIPTED_TICKET },\n    isAnswered: hasOpenedScripted,\n  },\n  frame(600, [started('read')]),\n  { after: 400, by: 'demo', action: { type: 'copilotSheet', isOpen: true } },\n  frame(900, [done('read'), started('lookup')]),\n  frame(600, [FIELD]),\n  frame(450, [FIELD]),\n  frame(450, [FIELD, done('lookup'), started('search')]),\n  frame(900, [ARTICLE]),\n  frame(600, [ARTICLE]),\n  frame(500, [done('search'), started('draft')]),\n  { after: 800, by: 'demo', action: { type: 'copilotSheet', isOpen: false } },\n  frame(400, [{ type: 'draftStarted' }]),\n  frame(DRAFT_MS, [{ type: 'draftReady' }, done('draft')]),\n  frame(1100, [{ type: 'refundAsked' }]),\n];\n\nconst CLOSING: Step[] = [\n  {\n    after: DEMO_DECIDES_AFTER_MS,\n    by: 'person',\n    press: 'allow',\n    action: { type: 'refundDecided', decision: 'approved' },\n    isAnswered: hasDecidedRefund,\n  },\n  { after: REFUND_MS, action: { type: 'refunded' } },\n  {\n    after: 1400,\n    by: 'person',\n    press: 'insert',\n    action: { type: 'draftInserted' },\n    isAnswered: hasHandledDraft,\n  },\n  {\n    after: 1500,\n    by: 'person',\n    press: 'send',\n    action: { type: 'sendPressed' },\n    isAnswered: hasPressedSend,\n  },\n  { after: SEND_MS, action: { type: 'delivered', id: SCRIPTED_TICKET } },\n];\n\nexport const SCRIPT: Step[] = [...OPENING, ...CLOSING];\n\nconst ASKED = restingOf(INITIAL, OPENING, applyAt);\n\n/** Under reduced motion the draft waits in the reply box with its sources and the refund waits for an answer. */\nexport const RESTING: InboxState = {\n  ...ASKED,\n  isListOpen: false,\n  isCopilotOpen: false,\n  spoken: '',\n};\n\nexport const LOOP_AFTER_MS = 3600;\n",
      "type": "registry:component",
      "target": "components/templates/application-11/session.ts"
    },
    {
      "path": "registry/ndeko/templates/inbox/application-11/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\nimport { wordsOf } from '@/registry/ndeko/lib/words';\n\nexport const BRAND = { name: 'Oatfield', desk: 'Support' };\n\nexport const ME = { name: 'Noor Haddad' };\n\nexport type Agent = {\n  name: string;\n  series: SeriesSlot;\n};\n\nexport const WRITER: Agent = { name: 'Writer', series: 3 };\n\nexport type Model = {\n  name: string;\n  brand: BrandSlug;\n};\n\nexport const MODEL: Model = { name: 'Claude Haiku', brand: 'claude' };\n\nexport type TicketStatus = 'open' | 'pending' | 'solved';\n\nexport type Priority = 'high' | 'normal' | 'low';\n\nexport type Customer = {\n  name: string;\n  email: string;\n  plan: string;\n  orders: string;\n  lastContact: string;\n};\n\nexport type Ticket = {\n  id: string;\n  subject: string;\n  receivedAgo: string;\n  status: TicketStatus;\n  priority: Priority;\n  isUnread: boolean;\n  customer: Customer;\n  message: string;\n  attachment?: string;\n};\n\nexport const SCRIPTED_TICKET = 'torn-bag';\n\n/** Invented customers, orders and amounts. The figures are illustrative. */\nexport const TICKETS: Ticket[] = [\n  {\n    id: SCRIPTED_TICKET,\n    subject: 'One bag arrived torn',\n    receivedAgo: '12 min',\n    status: 'open',\n    priority: 'high',\n    isUnread: true,\n    customer: {\n      name: 'Ines Marchetti',\n      email: 'ines@marchetti.example',\n      plan: 'Monthly, 2 bags',\n      orders: '14 since March 2023',\n      lastContact: 'None before today',\n    },\n    message:\n      'Hi, my order OF-20418 came today and one of the two bags is torn open, there is coffee all over the box. Can I get a refund for that bag?',\n    attachment: 'torn-bag.jpg',\n  },\n  {\n    id: 'grind',\n    subject: 'Change my grind to espresso',\n    receivedAgo: '38 min',\n    status: 'open',\n    priority: 'normal',\n    isUnread: true,\n    customer: {\n      name: 'Tomas Brandt',\n      email: 'tomas@brandt.example',\n      plan: 'Every two weeks, 1 bag',\n      orders: '6 since January',\n      lastContact: '3 weeks ago',\n    },\n    message:\n      'I bought an espresso machine. Could my next bags be ground for espresso instead of filter?',\n  },\n  {\n    id: 'pause',\n    subject: 'Pause my plan for August',\n    receivedAgo: '2 h',\n    status: 'pending',\n    priority: 'low',\n    isUnread: false,\n    customer: {\n      name: 'Aiko Tanaka',\n      email: 'aiko@tanaka.example',\n      plan: 'Monthly, 2 bags',\n      orders: '9 since last June',\n      lastContact: 'Yesterday',\n    },\n    message:\n      'I am away all of August. Can you pause my plan and start it again in September?',\n  },\n  {\n    id: 'address',\n    subject: 'New delivery address',\n    receivedAgo: '3 h',\n    status: 'open',\n    priority: 'normal',\n    isUnread: false,\n    customer: {\n      name: 'Samuel Okoye',\n      email: 'samuel@okoye.example',\n      plan: 'Monthly, 1 bag',\n      orders: '22 since 2022',\n      lastContact: '5 months ago',\n    },\n    message:\n      'We move on the 1st. Please send the next delivery to the new address, it is saved in my account.',\n  },\n  {\n    id: 'gift',\n    subject: 'Gift card not applied',\n    receivedAgo: 'Yesterday',\n    status: 'solved',\n    priority: 'normal',\n    isUnread: false,\n    customer: {\n      name: 'Clara Jensen',\n      email: 'clara@jensen.example',\n      plan: 'One order',\n      orders: '1 this month',\n      lastContact: 'Yesterday',\n    },\n    message:\n      'I entered my gift card at checkout and still paid the full price.',\n  },\n];\n\nconst FALLBACK_TICKET = TICKETS[0];\n\nexport function ticketOf(id: string) {\n  const ticket = TICKETS.find((candidate) => candidate.id === id);\n  return ticket ?? FALLBACK_TICKET;\n}\n\nexport const EARLIER_REPLIES: Partial<Record<string, string>> = {\n  gift: 'Hi Clara, the card is now applied and the difference is back on your payment method. Noor, Oatfield support',\n};\n\nexport const CUSTOMER_FIELDS: { key: keyof Customer; label: string }[] = [\n  { key: 'plan', label: 'Plan' },\n  { key: 'orders', label: 'Orders' },\n  { key: 'lastContact', label: 'Last contact' },\n];\n\nexport type StepId = 'read' | 'lookup' | 'search' | 'draft';\n\nexport type CopilotStep = {\n  id: StepId;\n  title: string;\n  detail: string;\n  doneSummary: string;\n};\n\nexport const STEPS: CopilotStep[] = [\n  {\n    id: 'read',\n    title: 'Read the ticket',\n    detail: 'One message and one photo',\n    doneSummary: 'A torn bag, asks for a refund',\n  },\n  {\n    id: 'lookup',\n    title: 'Look up the customer',\n    detail: 'Plan, orders and earlier tickets',\n    doneSummary: 'On a monthly plan, never wrote before',\n  },\n  {\n    id: 'search',\n    title: 'Search the help center',\n    detail: 'damaged bag refund',\n    doneSummary: '2 articles apply',\n  },\n  {\n    id: 'draft',\n    title: 'Draft a reply',\n    detail: 'From the two articles',\n    doneSummary: 'Ready in the reply box',\n  },\n];\n\nconst FALLBACK_STEP = STEPS[0];\n\nexport function stepOf(id: StepId) {\n  const step = STEPS.find((candidate) => candidate.id === id);\n  return step ?? FALLBACK_STEP;\n}\n\nexport type Article = {\n  number: number;\n  title: string;\n  excerpt: string;\n};\n\nexport const ARTICLES: Article[] = [\n  {\n    number: 1,\n    title: 'Damaged or missing items',\n    excerpt: 'A bag that arrives damaged is refunded in full.',\n  },\n  {\n    number: 2,\n    title: 'When a refund reaches your card',\n    excerpt: 'Refunds reach the card in 3 to 5 working days.',\n  },\n];\n\nconst FALLBACK_ARTICLE = ARTICLES[0];\n\nexport function articleOf(number: number) {\n  const article = ARTICLES.find((candidate) => candidate.number === number);\n  return article ?? FALLBACK_ARTICLE;\n}\n\nexport type Refund = {\n  amount: string;\n  card: string;\n  cardBrand: BrandSlug;\n  order: string;\n  reason: string;\n};\n\nexport const REFUND: Refund = {\n  amount: '$19.00',\n  card: 'Visa ending 4417',\n  cardBrand: 'visa',\n  order: 'OF-20418',\n  reason: 'One of two bags arrived torn, with a photo',\n};\n\n/** True whether the refund is allowed or denied: the reply only says it was asked for. */\nconst DRAFT =\n  'Hi Ines, I am sorry one of your bags arrived torn. Damaged bags are refunded in full, [1] so I have asked for a refund of $19.00 on order OF-20418. You will get an email as soon as it is confirmed, and the money reaches your card within 3 to 5 working days. [2] Your next delivery is not affected. Noor, Oatfield support';\n\nexport type DraftToken =\n  { kind: 'word'; text: string } | { kind: 'cite'; article: number };\n\nconst CITE = /^\\[(\\d+)\\]$/;\n\nfunction tokenOf(piece: string): DraftToken {\n  const match = CITE.exec(piece);\n  if (match) {\n    const article = Number(match[1]);\n    return { kind: 'cite', article };\n  }\n  return { kind: 'word', text: piece };\n}\n\nconst DRAFT_PIECES = wordsOf(DRAFT);\n\nexport const DRAFT_TOKENS = DRAFT_PIECES.map(tokenOf);\n\nfunction isWordPiece(piece: string) {\n  return !CITE.test(piece);\n}\n\nconst DRAFT_WORDS = DRAFT_PIECES.filter(isWordPiece);\n\n/** What Insert puts in the reply box: the draft without its marks. */\nexport const DRAFT_TEXT = DRAFT_WORDS.join(' ');\n\nexport const EMPTY_SEND_HINT =\n  'Write a reply or insert the draft before you send';\n",
      "type": "registry:component",
      "target": "components/templates/application-11/data.ts"
    }
  ],
  "categories": [
    "templates",
    "inbox"
  ],
  "type": "registry:block"
}