{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "prompt-10",
  "title": "Conversation list",
  "description": "Chats grouped by day under the pinned ones, with a highlight that travels, rename in place, delete asked in the row, and arrows, F2 and Delete.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/dropdown-menu.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/words.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/prompt/prompt-10.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useImperativeHandle, useRef, useState } from 'react';\n\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  hold,\n  keyDelayOf,\n  prefixesOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport {\n  EllipsisIcon,\n  PencilIcon,\n  PinIcon,\n  PinOffIcon,\n  SearchIcon,\n  TrashIcon,\n  XIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { rowPresenceOf, springOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { countOf } from '@/registry/ndeko/lib/words';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuItem,\n  DropdownMenuSeparator,\n  DropdownMenuShortcut,\n  DropdownMenuTrigger,\n} from '@/registry/ndeko/ui/dropdown-menu';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { Marked, includesQuery } from './_parts/marked';\n\nexport type Conversation = {\n  id: string;\n  title: string;\n  /** The last message, searched along with the title. */\n  preview: string;\n  updatedAt: number;\n  isPinned: boolean;\n};\n\ntype GroupId = 'pinned' | 'today' | 'yesterday' | 'week' | 'older';\n\nconst GROUP_ORDER: GroupId[] = [\n  'pinned',\n  'today',\n  'yesterday',\n  'week',\n  'older',\n];\n\nconst GROUP_LABEL: Record<GroupId, string> = {\n  pinned: 'Pinned',\n  today: 'Today',\n  yesterday: 'Yesterday',\n  week: 'Previous 7 days',\n  older: 'Older',\n};\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\ntype Entry =\n  | { kind: 'heading'; key: string; label: string }\n  | { kind: 'row'; key: string; conversation: Conversation; group: GroupId };\n\ntype RowMode = 'view' | 'rename' | 'confirm';\n\nfunction dayOf(time: number) {\n  return Math.floor(time / DAY_MS);\n}\n\nfunction groupOf(conversation: Conversation, now: number): GroupId {\n  if (conversation.isPinned) {\n    return 'pinned';\n  }\n  const age = dayOf(now) - dayOf(conversation.updatedAt);\n  if (age <= 0) {\n    return 'today';\n  }\n  if (age === 1) {\n    return 'yesterday';\n  }\n  if (age <= 7) {\n    return 'week';\n  }\n  return 'older';\n}\n\nfunction matchesConversation(conversation: Conversation, query: string) {\n  const text = `${conversation.title} ${conversation.preview}`;\n  return includesQuery(text, query);\n}\n\nfunction byGroupThenRecent(now: number) {\n  return function compare(first: Conversation, second: Conversation) {\n    const firstGroup = GROUP_ORDER.indexOf(groupOf(first, now));\n    const secondGroup = GROUP_ORDER.indexOf(groupOf(second, now));\n    const groupOrder = firstGroup - secondGroup;\n    if (groupOrder !== 0) {\n      return groupOrder;\n    }\n    return second.updatedAt - first.updatedAt;\n  };\n}\n\n/** Headings and rows in one list, so a pinned row glides to its new group instead of jumping. */\nfunction entriesOf(conversations: Conversation[], now: number, query: string) {\n  const matching = conversations.filter((conversation) =>\n    matchesConversation(conversation, query)\n  );\n  const sorted = [...matching].sort(byGroupThenRecent(now));\n  const entries: Entry[] = [];\n  let lastGroup: GroupId | null = null;\n  for (const conversation of sorted) {\n    const group = groupOf(conversation, now);\n    if (group !== lastGroup) {\n      entries.push({\n        kind: 'heading',\n        key: `heading-${group}`,\n        label: GROUP_LABEL[group],\n      });\n      lastGroup = group;\n    }\n    entries.push({ kind: 'row', key: conversation.id, conversation, group });\n  }\n  return entries;\n}\n\nfunction rowsOf(entries: Entry[]) {\n  const rows: Conversation[] = [];\n  for (const entry of entries) {\n    if (entry.kind === 'row') {\n      rows.push(entry.conversation);\n    }\n  }\n  return rows;\n}\n\nfunction rowToneOf(isActive: boolean) {\n  if (isActive) {\n    return 'text-foreground';\n  }\n  return 'text-foreground/80 hover:bg-foreground/[0.04] hover:text-foreground';\n}\n\nfunction pinLabelOf(isPinned: boolean) {\n  if (isPinned) {\n    return 'Unpin';\n  }\n  return 'Pin';\n}\n\nexport type ConversationListHandle = {\n  /** Opens a chat, as a click on its row does. */\n  select: (id: string) => void;\n  /** Pins or unpins a chat, as its menu does. */\n  pin: (id: string, isPinned: boolean) => void;\n  /** Turns a row into its rename field, as F2 does. */\n  startRename: (id: string) => void;\n  /** Replaces the title being typed in the rename field. */\n  typeRename: (title: string) => void;\n  /** Saves the rename, as Enter does. */\n  saveRename: () => void;\n  search: (query: string) => void;\n};\n\nconst POP = {\n  initial: { opacity: 0, scale: 0.6 },\n  animate: { opacity: 1, scale: 1 },\n  exit: { opacity: 0, scale: 0.6, transition: { duration: 0.1 } },\n  transition: { duration: 0.15 },\n};\n\nconst POP_FADE = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0, transition: { duration: 0.1 } },\n  transition: { duration: 0.15 },\n};\n\n/** A small mark that comes with a change of state: the pin of a row, the cross of a search. */\nfunction popOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return POP_FADE;\n  }\n  return POP;\n}\n\ntype RenameFieldProps = {\n  draft: string;\n  onDraftChange: (draft: string) => void;\n  onEnd: (title: string | null) => void;\n  /** False in a demonstration, which types into the field without taking the focus. */\n  takesFocus: boolean;\n};\n\n/** Mounted for each rename; Enter or leaving saves, Escape keeps the old title. */\nfunction RenameField({\n  draft,\n  onDraftChange,\n  onEnd,\n  takesFocus,\n}: RenameFieldProps) {\n  const isDone = useRef(false);\n\n  function end(next: string | null) {\n    if (isDone.current) {\n      return;\n    }\n    isDone.current = true;\n    onEnd(next);\n  }\n\n  function handleKeys(event: React.KeyboardEvent<HTMLInputElement>) {\n    if (event.key === 'Enter') {\n      event.preventDefault();\n      end(draft);\n      return;\n    }\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      end(null);\n    }\n  }\n\n  return (\n    <input\n      data-rename-field=''\n      value={draft}\n      onChange={(event) => onDraftChange(event.target.value)}\n      onKeyDown={handleKeys}\n      onBlur={() => end(draft)}\n      onFocus={(event) => event.currentTarget.select()}\n      aria-label='Rename the chat'\n      autoFocus={takesFocus}\n      className='bg-card hairline-ring ring-ring/40 focus-visible:ring-ring/25 relative h-7 w-full min-w-0 rounded-md px-2 text-[13px] outline-none focus-visible:ring-[3px]'\n    />\n  );\n}\n\ntype ConversationRowProps = {\n  conversation: Conversation;\n  group: GroupId;\n  query: string;\n  isActive: boolean;\n  isTabStop: boolean;\n  mode: RowMode;\n  highlightId: string;\n  /** The chat that is open: the highlight is only measured again when it changes. */\n  activeId: string;\n  renameDraft: string;\n  takesFocus: boolean;\n  onRenameDraftChange: (draft: string) => void;\n  onSelect: (id: string) => void;\n  onKeys: (event: React.KeyboardEvent<HTMLButtonElement>, id: string) => void;\n  onStartRename: (id: string) => void;\n  onEndRename: (id: string, title: string | null) => void;\n  onAskDelete: (id: string) => void;\n  onCancelDelete: (id: string) => void;\n  onDelete: (id: string) => void;\n  onPinChange: (id: string, isPinned: boolean) => void;\n};\n\nfunction ConversationRow({\n  conversation,\n  group,\n  query,\n  isActive,\n  isTabStop,\n  mode,\n  highlightId,\n  activeId,\n  renameDraft,\n  takesFocus,\n  onRenameDraftChange,\n  onSelect,\n  onKeys,\n  onStartRename,\n  onEndRename,\n  onAskDelete,\n  onCancelDelete,\n  onDelete,\n  onPinChange,\n}: ConversationRowProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const spring = springOf(shouldReduceMotion);\n  const pinPop = popOf(shouldReduceMotion);\n  const tabIndex = tabIndexOf(isTabStop);\n  const groupWord = GROUP_LABEL[group];\n  const isRenaming = mode === 'rename';\n  const isConfirming = mode === 'confirm';\n  const isViewing = mode === 'view';\n  const showsHighlight = isActive && isViewing;\n\n  function handleConfirmKeys(event: React.KeyboardEvent<HTMLDivElement>) {\n    if (event.key === 'Escape') {\n      event.preventDefault();\n      onCancelDelete(conversation.id);\n    }\n  }\n\n  return (\n    <div\n      data-row={conversation.id}\n      className={cn(\n        'group/row relative flex h-8 items-center rounded-md transition-colors duration-150',\n        isConfirming && 'bg-destructive/[0.07]'\n      )}\n    >\n      {showsHighlight && (\n        <motion.span\n          layoutId={highlightId}\n          layoutDependency={activeId}\n          transition={spring}\n          aria-hidden='true'\n          className='bg-foreground/[0.06] dark:bg-foreground/[0.08] absolute inset-0 rounded-md'\n        />\n      )}\n      {isRenaming && (\n        <RenameField\n          draft={renameDraft}\n          onDraftChange={onRenameDraftChange}\n          onEnd={(title) => onEndRename(conversation.id, title)}\n          takesFocus={takesFocus}\n        />\n      )}\n      {isConfirming && (\n        <div\n          role='group'\n          aria-label={`Delete “${conversation.title}”?`}\n          onKeyDown={handleConfirmKeys}\n          className='flex w-full min-w-0 items-center gap-1.5 ps-2 pe-0.5'\n        >\n          <p className='text-destructive-ink min-w-0 flex-1 truncate text-xs'>\n            Delete this chat?\n          </p>\n          <Button\n            type='button'\n            variant='destructive'\n            size='sm'\n            data-action='confirm-delete'\n            onClick={() => onDelete(conversation.id)}\n            className='h-6 px-2'\n          >\n            Delete\n          </Button>\n          <Button\n            type='button'\n            variant='ghost'\n            size='sm'\n            onClick={() => onCancelDelete(conversation.id)}\n            className='h-6 px-2'\n          >\n            Cancel\n          </Button>\n        </div>\n      )}\n      {isViewing && (\n        <>\n          <button\n            type='button'\n            data-action='open'\n            tabIndex={tabIndex}\n            aria-current={currentOf(isActive)}\n            aria-keyshortcuts='F2 Delete'\n            onClick={() => onSelect(conversation.id)}\n            onKeyDown={(event) => onKeys(event, conversation.id)}\n            className={cn(\n              'focus-visible:ring-ring/25 relative flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md ps-2 pe-8 text-start text-[13px] outline-none focus-visible:ring-[3px]',\n              rowToneOf(isActive)\n            )}\n          >\n            <AnimatePresence initial={false}>\n              {conversation.isPinned && (\n                <motion.span key='pin' className='flex shrink-0' {...pinPop}>\n                  <PinIcon className='text-muted-foreground size-3.5' />\n                </motion.span>\n              )}\n            </AnimatePresence>\n            <span className='truncate'>\n              <Marked text={conversation.title} query={query} />\n            </span>\n            <span className='sr-only'>, {groupWord}</span>\n          </button>\n          <DropdownMenu>\n            <DropdownMenuTrigger\n              render={\n                <Button\n                  type='button'\n                  variant='ghost'\n                  size='icon-sm'\n                  tabIndex={tabIndex}\n                  data-action='menu'\n                  aria-label={`More for “${conversation.title}”`}\n                  className='text-muted-foreground absolute end-0.5 size-7 opacity-0 transition-opacity duration-150 group-focus-within/row:opacity-100 group-hover/row:opacity-100 data-popup-open:opacity-100 pointer-coarse:opacity-100'\n                />\n              }\n            >\n              <EllipsisIcon />\n            </DropdownMenuTrigger>\n            <DropdownMenuContent align='end' className='min-w-44'>\n              <DropdownMenuItem\n                onClick={() =>\n                  onPinChange(conversation.id, !conversation.isPinned)\n                }\n              >\n                {conversation.isPinned && <PinOffIcon />}\n                {!conversation.isPinned && <PinIcon />}\n                {pinLabelOf(conversation.isPinned)}\n              </DropdownMenuItem>\n              <DropdownMenuItem onClick={() => onStartRename(conversation.id)}>\n                <PencilIcon />\n                Rename\n                <DropdownMenuShortcut>F2</DropdownMenuShortcut>\n              </DropdownMenuItem>\n              <DropdownMenuSeparator />\n              <DropdownMenuItem\n                variant='destructive'\n                onClick={() => onAskDelete(conversation.id)}\n              >\n                <TrashIcon />\n                Delete\n                <DropdownMenuShortcut>Del</DropdownMenuShortcut>\n              </DropdownMenuItem>\n            </DropdownMenuContent>\n          </DropdownMenu>\n        </>\n      )}\n    </div>\n  );\n}\n\nfunction tabIndexOf(isTabStop: boolean) {\n  if (isTabStop) {\n    return 0;\n  }\n  return -1;\n}\n\nfunction currentOf(isActive: boolean) {\n  if (isActive) {\n    return 'page';\n  }\n  return undefined;\n}\n\nfunction nextFocusOf(key: string, index: number, count: number) {\n  if (key === 'ArrowDown') {\n    return Math.min(count - 1, index + 1);\n  }\n  if (key === 'ArrowUp') {\n    return Math.max(0, index - 1);\n  }\n  if (key === 'Home') {\n    return 0;\n  }\n  if (key === 'End') {\n    return count - 1;\n  }\n  return null;\n}\n\nfunction isDeleteKey(key: string) {\n  return key === 'Delete' || key === 'Backspace';\n}\n\n/** The row that holds the single tab stop: the focused one if it is still shown, else the active one, else the first. */\nfunction tabStopOf(\n  rows: Conversation[],\n  focusId: string | null,\n  activeId: string\n) {\n  const isFocusShown = rows.some((row) => row.id === focusId);\n  if (isFocusShown) {\n    return focusId;\n  }\n  const isActiveShown = rows.some((row) => row.id === activeId);\n  if (isActiveShown) {\n    return activeId;\n  }\n  return rows[0]?.id ?? null;\n}\n\nfunction resultsLineOf(query: string, count: number) {\n  const trimmed = query.trim();\n  if (trimmed === '') {\n    return '';\n  }\n  if (count === 0) {\n    return `No chat matches “${trimmed}”`;\n  }\n  return countOf(count, 'chat');\n}\n\nexport type ConversationListProps = {\n  conversations: Conversation[];\n  activeId: string;\n  /** The time the groups are counted from: Today, Yesterday, Previous 7 days. */\n  now: number;\n  onSelect: (id: string) => void;\n  onRename: (id: string, title: string) => void;\n  onPinChange: (id: string, isPinned: boolean) => void;\n  onDelete: (id: string) => void;\n  /** Runs what the rows, their menus and the search do, for a demonstration or a control beside the list. */\n  handleRef?: React.Ref<ConversationListHandle>;\n  /** A demonstration drives the list: nothing takes the focus and nothing is read aloud. */\n  isDemonstrated?: boolean;\n  className?: string;\n};\n\nexport function ConversationList({\n  conversations,\n  activeId,\n  now,\n  onSelect,\n  onRename,\n  onPinChange,\n  onDelete,\n  handleRef,\n  isDemonstrated = false,\n  className,\n}: ConversationListProps) {\n  const [query, setQuery] = useState('');\n  const [focusId, setFocusId] = useState<string | null>(null);\n  const [renamingId, setRenamingId] = useState<string | null>(null);\n  const [renameDraft, setRenameDraft] = useState('');\n  const [confirmingId, setConfirmingId] = useState<string | null>(null);\n  const [announcement, setAnnouncement] = useState('');\n  const listRef = useRef<HTMLUListElement>(null);\n  const searchId = useId();\n  const highlightId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const rowPresence = rowPresenceOf(shouldReduceMotion);\n  const spring = springOf(shouldReduceMotion);\n  const rowTransition = { ...rowPresence.transition, layout: spring };\n  const clearPop = popOf(shouldReduceMotion);\n  const entries = entriesOf(conversations, now, query);\n  const entryKeys = entries.map((entry) => entry.key);\n  const order = entryKeys.join(' ');\n  const rows = rowsOf(entries);\n  const tabStopId = tabStopOf(rows, focusId, activeId);\n  const isEmpty = rows.length === 0;\n  const hasQuery = query !== '';\n  const results = resultsLineOf(query, rows.length);\n  const message = announcementOrResults(announcement, results);\n\n  function focusRow(id: string, action: string) {\n    setFocusId(id);\n    if (isDemonstrated) {\n      return;\n    }\n    requestAnimationFrame(() => {\n      const selector = `[data-row=\"${id}\"] [data-action=\"${action}\"]`;\n      const target = listRef.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  function modeOf(id: string): RowMode {\n    if (renamingId === id) {\n      return 'rename';\n    }\n    if (confirmingId === id) {\n      return 'confirm';\n    }\n    return 'view';\n  }\n\n  function startRename(id: string) {\n    const conversation = conversations.find((item) => item.id === id);\n    setConfirmingId(null);\n    setRenameDraft(conversation?.title ?? '');\n    setRenamingId(id);\n    setFocusId(id);\n  }\n\n  function saveRename() {\n    if (renamingId === null) {\n      return;\n    }\n    endRename(renamingId, renameDraft);\n  }\n\n  /** A rename the demonstration left open ends when the person acts anywhere but in its field. */\n  function endScriptedRename(event: React.SyntheticEvent) {\n    const isScripted = isDemonstrated && renamingId !== null;\n    if (!isScripted) {\n      return;\n    }\n    const target = event.target;\n    if (!(target instanceof Element)) {\n      return;\n    }\n    const field = target.closest('[data-rename-field]');\n    if (field) {\n      return;\n    }\n    setRenamingId(null);\n  }\n\n  function endRename(id: string, title: string | null) {\n    setRenamingId(null);\n    const trimmed = title?.trim() ?? '';\n    const hasTitle = trimmed !== '';\n    if (hasTitle) {\n      onRename(id, trimmed);\n      setAnnouncement(`Renamed to ${trimmed}`);\n    }\n    focusRow(id, 'open');\n  }\n\n  function askDelete(id: string) {\n    setRenamingId(null);\n    setConfirmingId(id);\n    setFocusId(id);\n    setAnnouncement('Delete this chat? Enter deletes it, Escape keeps it');\n    focusRow(id, 'confirm-delete');\n  }\n\n  function cancelDelete(id: string) {\n    setConfirmingId(null);\n    setAnnouncement('Kept the chat');\n    focusRow(id, 'open');\n  }\n\n  function remove(id: string) {\n    const index = rows.findIndex((row) => row.id === id);\n    const neighbour = rows[index + 1] ?? rows[index - 1];\n    const removed = rows[index];\n    const wasActive = id === activeId;\n    setConfirmingId(null);\n    onDelete(id);\n    setAnnouncement(`Deleted “${removed?.title ?? ''}”`);\n    if (!neighbour) {\n      return;\n    }\n    if (wasActive) {\n      onSelect(neighbour.id);\n    }\n    focusRow(neighbour.id, 'open');\n  }\n\n  function changePin(id: string, isPinned: boolean) {\n    onPinChange(id, isPinned);\n    setAnnouncement(pinMessageOf(isPinned));\n    focusRow(id, 'open');\n  }\n\n  function select(id: string) {\n    setFocusId(id);\n    onSelect(id);\n  }\n\n  function handleRowKeys(\n    event: React.KeyboardEvent<HTMLButtonElement>,\n    id: string\n  ) {\n    if (event.key === 'F2') {\n      event.preventDefault();\n      startRename(id);\n      return;\n    }\n    if (isDeleteKey(event.key)) {\n      event.preventDefault();\n      askDelete(id);\n      return;\n    }\n    const index = rows.findIndex((row) => row.id === id);\n    const nextIndex = nextFocusOf(event.key, index, rows.length);\n    if (nextIndex === null) {\n      return;\n    }\n    event.preventDefault();\n    const next = rows[nextIndex];\n    focusRow(next.id, 'open');\n  }\n\n  function clearSearch() {\n    setQuery('');\n  }\n\n  useImperativeHandle(handleRef, () => ({\n    select,\n    pin: changePin,\n    startRename,\n    typeRename: setRenameDraft,\n    saveRename,\n    search: setQuery,\n  }));\n\n  return (\n    <nav\n      aria-label='Chat history'\n      onPointerDownCapture={endScriptedRename}\n      onKeyDownCapture={endScriptedRename}\n      className={cn('flex flex-col gap-2', className)}\n    >\n      <div className='relative'>\n        <label htmlFor={searchId} className='sr-only'>\n          Search chats\n        </label>\n        <SearchIcon className='text-muted-foreground pointer-events-none absolute start-2.5 top-1/2 size-4 -translate-y-1/2' />\n        <Input\n          id={searchId}\n          type='search'\n          size='sm'\n          value={query}\n          onChange={(event) => setQuery(event.target.value)}\n          placeholder='Search chats'\n          className='ps-8 pe-8'\n        />\n        <AnimatePresence initial={false}>\n          {hasQuery && (\n            <motion.span\n              key='clear'\n              className='absolute end-0.5 top-1/2 flex -translate-y-1/2'\n              {...clearPop}\n            >\n              <Button\n                type='button'\n                variant='ghost'\n                size='icon-sm'\n                aria-label='Clear the search'\n                onClick={clearSearch}\n                className='text-muted-foreground size-6'\n              >\n                <XIcon className='size-3.5' />\n              </Button>\n            </motion.span>\n          )}\n        </AnimatePresence>\n      </div>\n      <ul ref={listRef} aria-label='Chats' className='flex flex-col'>\n        <AnimatePresence initial={false}>\n          {entries.map((entry) => (\n            <motion.li\n              key={entry.key}\n              role={roleOf(entry)}\n              layout='position'\n              layoutDependency={order}\n              className='overflow-hidden'\n              {...rowPresence}\n              transition={rowTransition}\n            >\n              {entry.kind === 'heading' && (\n                <p\n                  aria-hidden='true'\n                  className='text-muted-foreground px-2 pt-3 pb-1 text-xs font-medium'\n                >\n                  {entry.label}\n                </p>\n              )}\n              {entry.kind === 'row' && (\n                <ConversationRow\n                  conversation={entry.conversation}\n                  group={entry.group}\n                  query={query}\n                  isActive={entry.conversation.id === activeId}\n                  isTabStop={entry.conversation.id === tabStopId}\n                  mode={modeOf(entry.conversation.id)}\n                  highlightId={highlightId}\n                  activeId={activeId}\n                  renameDraft={renameDraft}\n                  takesFocus={!isDemonstrated}\n                  onRenameDraftChange={setRenameDraft}\n                  onSelect={select}\n                  onKeys={handleRowKeys}\n                  onStartRename={startRename}\n                  onEndRename={endRename}\n                  onAskDelete={askDelete}\n                  onCancelDelete={cancelDelete}\n                  onDelete={remove}\n                  onPinChange={changePin}\n                />\n              )}\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ul>\n      <AnimatePresence initial={false}>\n        {isEmpty && (\n          <motion.div key='empty' className='overflow-hidden' {...rowPresence}>\n            <div className='bg-foreground/[0.03] dark:bg-foreground/[0.05] flex flex-col items-center gap-2.5 rounded-lg px-3 py-5 text-center'>\n              <p className='text-muted-foreground text-[13px] text-balance'>\n                {emptyLineOf(query)}\n              </p>\n              {hasQuery && (\n                <Button\n                  type='button'\n                  variant='outline'\n                  size='sm'\n                  onClick={clearSearch}\n                >\n                  Clear the search\n                </Button>\n              )}\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n      <LiveRegion message={spokenUnless(isDemonstrated, message)} />\n    </nav>\n  );\n}\n\nfunction roleOf(entry: Entry) {\n  if (entry.kind === 'heading') {\n    return 'presentation';\n  }\n  return undefined;\n}\n\nfunction emptyLineOf(query: string) {\n  const trimmed = query.trim();\n  if (trimmed === '') {\n    return 'No chats yet';\n  }\n  return `No chat matches “${trimmed}”`;\n}\n\nfunction announcementOrResults(announcement: string, results: string) {\n  if (results !== '') {\n    return results;\n  }\n  return announcement;\n}\n\nfunction pinMessageOf(isPinned: boolean) {\n  if (isPinned) {\n    return 'Pinned. It moved to the Pinned group';\n  }\n  return 'Unpinned. It went back to its day';\n}\n\nconst HOUR_MS = 60 * 60 * 1000;\n\n/** A fixed afternoon, so the groups read the same in every catalogue visit. */\nconst NOW = Date.UTC(2026, 2, 18, 15, 0);\n\nconst CONVERSATIONS: Conversation[] = [\n  {\n    id: 'vendor-review',\n    title: 'Q3 vendor review',\n    preview: 'Six lines were billed above the list price',\n    updatedAt: NOW - 2 * DAY_MS,\n    isPinned: true,\n  },\n  {\n    id: 'style-guide',\n    title: 'Writing style guide',\n    preview: 'Keep vendor emails under 150 words',\n    updatedAt: NOW - 5 * DAY_MS,\n    isPinned: true,\n  },\n  {\n    id: 'credit-request',\n    title: 'Brightmoor credit request',\n    preview: 'Draft ready, 186 words',\n    updatedAt: NOW - 4 * HOUR_MS,\n    isPinned: false,\n  },\n  {\n    id: 'shipping-terms',\n    title: 'Shipping terms compared',\n    preview: 'Brightmoor ships within 3 working days',\n    updatedAt: NOW - 6 * HOUR_MS,\n    isPinned: false,\n  },\n  {\n    id: 'csv-import',\n    title: 'Fix the invoice CSV import',\n    preview: 'The SKU column was missing',\n    updatedAt: NOW - 7 * HOUR_MS,\n    isPinned: false,\n  },\n  {\n    id: 'refund-policy',\n    title: 'Refund policy summary',\n    preview: 'Store credit only, within 14 days',\n    updatedAt: NOW - 1 * DAY_MS,\n    isPinned: false,\n  },\n  {\n    id: 'onboarding',\n    title: 'Onboarding email draft',\n    preview: 'Welcome to Atlas, here is your first week',\n    updatedAt: NOW - 1 * DAY_MS - 3 * HOUR_MS,\n    isPinned: false,\n  },\n  {\n    id: 'roadmap',\n    title: 'Atlas roadmap questions',\n    preview: 'Billing settings move to the account page',\n    updatedAt: NOW - 3 * DAY_MS,\n    isPinned: false,\n  },\n  {\n    id: 'pricing-copy',\n    title: 'Pricing page copy',\n    preview: 'One plan, billed monthly or yearly',\n    updatedAt: NOW - 4 * DAY_MS,\n    isPinned: false,\n  },\n  {\n    id: 'offsite',\n    title: 'Team offsite agenda',\n    preview: 'Half a day for the roadmap',\n    updatedAt: NOW - 6 * DAY_MS,\n    isPinned: false,\n  },\n];\n\nconst START_CHAT = 'credit-request';\n\nconst RENAMED_TITLE = 'Invoice and shipping terms';\n\nconst DEMO_SEARCH = 'invoice';\n\nexport default function Prompt10() {\n  const [conversations, setConversations] = useState(CONVERSATIONS);\n  const [activeId, setActiveId] = useState(START_CHAT);\n  const list = useRef<ConversationListHandle>(null);\n\n  function update(id: string, patch: Partial<Conversation>) {\n    setConversations((current) =>\n      current.map((conversation) => {\n        if (conversation.id !== id) {\n          return conversation;\n        }\n        return { ...conversation, ...patch };\n      })\n    );\n  }\n\n  function rename(id: string, title: string) {\n    update(id, { title });\n  }\n\n  function changePin(id: string, isPinned: boolean) {\n    update(id, { isPinned });\n  }\n\n  function remove(id: string) {\n    setConversations((current) =>\n      current.filter((conversation) => conversation.id !== id)\n    );\n  }\n\n  function resetDemo() {\n    setConversations(CONVERSATIONS);\n    setActiveId(START_CHAT);\n    list.current?.search('');\n  }\n\n  const renameTyping = prefixesOf(RENAMED_TITLE).map((typed, index) => ({\n    after: keyDelayOf(index, 500, 48),\n    run: () => list.current?.typeRename(typed),\n  }));\n  const searchTyping = prefixesOf(DEMO_SEARCH).map((typed, index) => ({\n    after: keyDelayOf(index, 1200, 95),\n    run: () => list.current?.search(typed),\n  }));\n  const steps: AutoplayStep[] = [\n    { after: 1400, run: () => list.current?.select('shipping-terms') },\n    { after: 650, run: () => list.current?.select('csv-import') },\n    { after: 1000, run: () => list.current?.pin('csv-import', true) },\n    { after: 1700, run: () => list.current?.startRename('shipping-terms') },\n    ...renameTyping,\n    { after: 600, run: () => list.current?.saveRename() },\n    ...searchTyping,\n    { after: 1800, run: () => list.current?.search('') },\n    { after: 900, run: hold },\n  ];\n  const { ref, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 2400,\n    onReset: resetDemo,\n  });\n\n  useKeptHeight(ref);\n\n  return (\n    <div\n      ref={ref}\n      className='bg-card hairline-ring ring-border flex w-full max-w-[19rem] flex-col rounded-xl p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n    >\n      <ConversationList\n        conversations={conversations}\n        activeId={activeId}\n        now={NOW}\n        onSelect={setActiveId}\n        onRename={rename}\n        onPinChange={changePin}\n        onDelete={remove}\n        handleRef={list}\n        isDemonstrated={isAutoplaying}\n      />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/prompt/prompt-10.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/marked.tsx",
      "content": "type TextPiece = { text: string; isMatch: boolean };\n\nexport function piecesOf(text: string, query: string): TextPiece[] {\n  const needle = query.trim().toLowerCase();\n  if (needle === '') {\n    return [{ text, isMatch: false }];\n  }\n  const haystack = text.toLowerCase();\n  const pieces: TextPiece[] = [];\n  let cursor = 0;\n  let found = haystack.indexOf(needle, cursor);\n  while (found >= 0) {\n    const before = text.slice(cursor, found);\n    const matchEnd = found + needle.length;\n    const match = text.slice(found, matchEnd);\n    if (before !== '') {\n      pieces.push({ text: before, isMatch: false });\n    }\n    pieces.push({ text: match, isMatch: true });\n    cursor = matchEnd;\n    found = haystack.indexOf(needle, cursor);\n  }\n  const rest = text.slice(cursor);\n  if (rest !== '') {\n    pieces.push({ text: rest, isMatch: false });\n  }\n  return pieces;\n}\n\nexport function includesQuery(text: string, query: string) {\n  const needle = query.trim().toLowerCase();\n  if (needle === '') {\n    return true;\n  }\n  const haystack = text.toLowerCase();\n  return haystack.includes(needle);\n}\n\ntype MarkedProps = {\n  text: string;\n  query: string;\n};\n\nexport function Marked({ text, query }: MarkedProps) {\n  const pieces = piecesOf(text, query);\n\n  return (\n    <>\n      {pieces.map((piece, index) => {\n        if (piece.isMatch) {\n          return (\n            <mark\n              key={index}\n              className='bg-warning/25 text-foreground rounded-[3px] px-px'\n            >\n              {piece.text}\n            </mark>\n          );\n        }\n        return <span key={index}>{piece.text}</span>;\n      })}\n    </>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/marked.tsx"
    }
  ],
  "categories": [
    "components",
    "prompt"
  ],
  "type": "registry:component"
}