{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command",
  "title": "Command",
  "description": "A command palette: a searchable list of every action in the app, in a dialog.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/avatar",
    "@ouro/dialog",
    "@ouro/kbd",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-control-ref",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-floating",
    "@ouro/lib-key-shortcuts",
    "@ouro/lib-last-input",
    "@ouro/lib-open-mode",
    "@ouro/lib-page-scroll-hold",
    "@ouro/lib-refs",
    "@ouro/lib-server-element",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-platform",
    "@ouro/lib-use-sheet-presentation",
    "@ouro/sheet",
    "@ouro/skeleton",
    "@ouro/unread-dot"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/command/command-styles.ts",
      "content": "export {\n  commandCloseClass,\n  commandEmptyClass,\n  commandEmptyRoomClass,\n  commandGroupLabelClass,\n  commandInputClass,\n  commandItemClass,\n  commandListClass,\n  commandListboxClass,\n  commandLoadingClass,\n  commandLoadingRowClass,\n  commandSearchClass,\n  commandSheetListClass,\n  commandSheetSearchClass,\n  commandMarkClass,\n  matchesQuery,\n  oneEditApart,\n  queryMatch,\n  queryRanges,\n  type QueryMatch,\n  type TextRange,\n};\n\n// Class strings and the search for Command, apart from the component so command.tsx exports\n// only components (React Fast Refresh). Class strings are literals so the app's Tailwind finds them.\n\n/**\n * The search row at the top of the palette: a magnifier and the input, over a hairline that takes the ring\n * colour while the input has keyboard focus.\n *\n * @internal\n * @claim \"over a hairline that takes the\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command search focus > draws the search row's line in the ring colour while the search input has keyboard focus)\n */\nconst commandSearchClass =\n  \"box-border flex shrink-0 items-center gap-2 border-0 border-b border-solid border-border has-[input:focus-visible]:border-ring px-4 text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0\";\n\n/**\n * The search row in the phone sheet: pinned to the top of the sheet's scrolling body, its field\n * ending clear of the sheet's close button in the top corner.\n *\n * @internal\n */\nconst commandSheetSearchClass =\n  \"sticky top-0 z-1 -mx-5 -mt-2 mb-1 box-border flex items-center gap-2 border-0 border-b border-solid border-border has-[input:focus-visible]:border-ring bg-popover ps-5 pe-14 text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0\";\n\n/**\n * The search input: borderless, 48px tall, 16px text on a coarse pointer (so iOS does not\n * zoom) and 14px with a fine pointer.\n *\n * @internal\n * @claim \"The search input: borderless, 48px tall\" registry/ouro/components/ouro/command/command.touch.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.touch.test.tsx::Command on a phone > opens from a tap as a full-height sheet focused on itself, with 44px commands and a 16px search input)\n * @claim \"The search input: borderless, 48px tall\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > keeps its size while results filter, so the search input stays put)\n */\nconst commandInputClass =\n  \"m-0 box-border h-12 min-w-0 flex-1 border-0 bg-transparent p-0 font-[inherit] text-base pointer-fine:text-sm text-popover-foreground outline-none placeholder:text-muted-foreground\";\n\n/**\n * \"Searching…\" at the end of the search row while results load; it never moves the input.\n *\n * @internal\n * @claim \"at the end of the search row while\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > keeps its size while results filter, so the search input stays put)\n * @claim \"at the end of the search row while\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > says it is searching politely, once while typing goes on, and shows the empty state only after loading)\n */\nconst commandLoadingClass = \"shrink-0 text-xs leading-4 text-muted-foreground\";\n\n/**\n * The results: a fixed height in the dialog, so the dialog keeps its size (and the input its\n * place) while results filter. The list inside it scrolls (`commandListboxClass`).\n *\n * @internal\n */\nconst commandListClass = \"box-border flex h-[min(22rem,60dvh)] flex-col outline-none\";\n\n/**\n * The list of results in the dialog, which scrolls itself: it is the search's own popup, so the\n * arrow keys from the search scroll it, and nothing but the search takes Tab, as in any combobox.\n * A box around the list that scrolled would be a region no keyboard could reach (axe\n * `scrollable-region-focusable`).\n *\n * @internal\n * @claim \"A box around the list that scrolled\" https://dequeuniversity.com/rules/axe/4.10/scrollable-region-focusable verify:urlOk(https://dequeuniversity.com/rules/axe/4.10/scrollable-region-focusable)\n * @claim \"it is the search's own popup\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > scrolls a long list by the arrow keys from the search, which keeps focus and Tab, and passes axe)\n */\nconst commandListboxClass = \"box-border min-h-0 overflow-y-auto overscroll-contain p-1 scroll-py-1 outline-none\";\n\n/**\n * The results in the phone sheet, which scroll with the sheet's body; the sheet keeps its\n * full height.\n *\n * @internal\n */\nconst commandSheetListClass = \"box-border -mx-3 outline-none\";\n\n/**\n * A group's heading: small and muted.\n *\n * @internal\n */\nconst commandGroupLabelClass = \"box-border px-2 pt-2 pb-1 text-xs leading-4 font-medium text-muted-foreground select-none\";\n\n/**\n * One command: 44px tall with 16px text on a coarse pointer, 36px and 14px with a fine\n * pointer, highlighted by keyboard or pointer, dimmed when disabled.\n *\n * @internal\n * @claim \"One command: 44px tall with 16px\" registry/ouro/components/ouro/command/command.touch.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.touch.test.tsx::Command on a phone > opens from a tap as a full-height sheet focused on itself, with 44px commands and a 16px search input)\n * @claim \"One command: 44px tall with 16px\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > moves the highlight with the arrow keys)\n */\nconst commandItemClass =\n  \"relative box-border flex min-h-11 pointer-fine:min-h-9 cursor-default items-center gap-3 rounded-ouro-md px-2 py-1.5 \" +\n  \"text-base leading-5 pointer-fine:text-sm text-popover-foreground outline-none select-none [-webkit-tap-highlight-color:transparent] \" +\n  \"data-highlighted:bg-accent data-highlighted:text-accent-foreground active:bg-accent active:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 \" +\n  // Forced colours drop the fill, so the highlight takes the system's pair.\n  \"forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText]\";\n\n/**\n * The close button: always present for screen readers (a phone has no Escape key), hidden\n * from view until it has keyboard focus, then shown at the top corner.\n *\n * @internal\n * @claim \"The close button: always present for\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > labels the search input and its close button, translated)\n */\nconst commandCloseClass =\n  \"sr-only focus-visible:top-2 focus-visible:end-2 focus-visible:z-1 focus-visible:m-0 focus-visible:size-auto \" +\n  \"focus-visible:overflow-visible focus-visible:[clip-path:none] focus-visible:px-2 focus-visible:py-1 \" +\n  \"focus-visible:rounded-ouro-md focus-visible:bg-muted focus-visible:text-foreground focus-visible:text-xs focus-visible:leading-4 focus-visible:font-medium \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid\";\n\n/**\n * The empty state's message.\n *\n * @internal\n */\nconst commandEmptyClass = \"box-border px-2 py-8 text-center text-sm leading-5 text-muted-foreground\";\n\n/**\n * Around the empty state in the dialog: while it shows, it takes the room the results had and centres\n * the message in it, so it does not hang at the top of a blank box. With results it takes none. The phone\n * sheet's results have no fixed room, so there the message stays at the top, above the keyboard.\n *\n * @internal\n * @claim \"while it shows, it takes the room\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > centres the empty state in the room the results had, and gives the results all of it again)\n * @claim \"With results it takes none\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > centres the empty state in the room the results had, and gives the results all of it again)\n * @claim \"The phone sheet's results have no fixed room\" registry/ouro/components/ouro/command/command.touch.test.tsx verify:fileLine(registry/ouro/components/ouro/command/command.touch.test.tsx, /The empty state sits right under the search/)\n */\nconst commandEmptyRoomClass = \"flex flex-col justify-center has-[>[data-ouro-command-empty]]:flex-1\";\n\n/** Lower case, without accents, so \"Thème\" matches \"theme\". */\nfunction fold(text: string): string {\n  return text.normalize(\"NFD\").replace(/\\p{Diacritic}/gu, \"\").toLocaleLowerCase();\n}\n\n/**\n * Whether `typed` becomes `word` with at most one edit: a letter dropped, added or changed, or two\n * neighbouring letters swapped.\n *\n * @internal\n * @claim \"Whether `typed` becomes `word` with at\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > forgives one slip in a word of four letters or more: a letter dropped, added, changed, or two swapped)\n */\nfunction oneEditApart(typed: string, word: string): boolean {\n  // Stryker disable next-line ConditionalExpression: equivalent; words two or more letters apart fail every comparison below, as their rests differ in length.\n  if (Math.abs(typed.length - word.length) > 1) return false;\n  let same = 0;\n  // Stryker disable next-line ConditionalExpression,EqualityOperator: equivalent; queryMatch asks only about a word the text lacks, so typed is never the same as word and the two differ, or one ends, before typed does.\n  while (same < typed.length && typed[same] === word[same]) same++;\n  const rest = (from: number, to: number) => typed.slice(from) === word.slice(to);\n  if (typed.length < word.length) return rest(same, same + 1);\n  if (typed.length > word.length) return rest(same + 1, same);\n  return rest(same + 1, same + 1) || (typed[same] === word[same + 1] && typed[same + 1] === word[same] && rest(same + 2, same + 2));\n}\n\n/**\n * How well a command matches a query, best first: 0 when its label starts with the query, 1 when it holds the query's\n * words, 2 when a word is one slip away.\n *\n * @claim \"How well a command matches a\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > ranks a command that starts with the search first, then one that holds it, then one a slip away)\n */\ntype QueryMatch = 0 | 1 | 2;\n\n/**\n * How a command matches the query, or undefined when it does not: every word of the query appears\n * in its label or keywords, ignoring case and accents (0 when the label starts with the first\n * word, else 1), or else each word that does not is four letters or more and one edit from a word\n * there, or from the start of one (2).\n *\n * @internal\n * @claim \"How a command matches the query\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > ranks a command that starts with the search first, then one that holds it, then one a slip away)\n */\nfunction queryMatch(label: string, keywords: readonly string[], query: string): QueryMatch | undefined {\n  const text = fold([label, ...keywords].join(\" \"));\n  // Stryker disable next-line Regex: an empty word between two spaces is in every text, as the one empty word they make is.\n  const words = fold(query).split(/\\s+/);\n  if (words.every((word) => text.includes(word))) return fold(label).startsWith(words[0]!) ? 0 : 1;\n  // Words split on anything but letters, their marks and digits, so a Devanagari vowel sign stays in its word.\n  const tokens = text.split(/[^\\p{L}\\p{M}\\p{N}]/u);\n  // A word of five letters or more may also be a slip of a word's start (\"confrim\" for Confirmation); a shorter one\n  // only of a whole word, or it would find every word sharing its first three letters.\n  // Stryker disable next-line ArrayDeclaration: a word shorter than five letters is one edit from no part but the token, whatever the list holds.\n  const starts = (word: string, token: string) => (word.length >= 5 ? [token.slice(0, word.length - 1), token.slice(0, word.length), token.slice(0, word.length + 1)] : []);\n  const near = (word: string) => word.length >= 4 && tokens.some((token) => [token, ...starts(word, token)].some((part) => oneEditApart(word, part)));\n  return words.every((word) => text.includes(word) || near(word)) ? 2 : undefined;\n}\n\n/**\n * Whether a command matches the query: every word of the query appears in its label or\n * keywords, ignoring case and accents, or is one slip from a word there (`queryMatch`).\n *\n * @internal\n * @claim \"Whether a command matches the query\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > filters by label and keywords, ignoring case and accents, and hides empty groups)\n */\nfunction matchesQuery(label: string, keywords: readonly string[], query: string): boolean {\n  return queryMatch(label, keywords, query) !== undefined;\n}\n\n/**\n * A row's shape while results are on their way: the item's own height, padding and line, so\n * the results that arrive take its place without moving the rows around them.\n *\n * @internal\n */\nconst commandLoadingRowClass =\n  \"box-border flex min-h-11 pointer-fine:min-h-9 items-center gap-3 px-2 py-1.5 text-base leading-5 pointer-fine:text-sm\";\n\n/** A range of a text, from `start` up to, and not including, `end`. */\ntype TextRange = readonly [start: number, end: number];\n\n/**\n * Where the words of a query appear in a text, ignoring case and accents, merged where they touch,\n * in order. Nothing when folding the text changes its length, so a range would land off its letters.\n *\n * @internal\n * @claim \"Where the words of a query\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > marks the words of the search in each command's label and description, and keeps the text as it was)\n */\nfunction queryRanges(text: string, query: string): TextRange[] {\n  const folded = fold(text);\n  if (folded.length !== text.length) return [];\n  const ranges: [number, number][] = [];\n  // Stryker disable next-line Regex: an empty word between two spaces is dropped by the filter after it.\n  for (const word of fold(query).split(/\\s+/).filter(Boolean)) {\n    for (let at = folded.indexOf(word); at !== -1; at = folded.indexOf(word, at + word.length)) ranges.push([at, at + word.length]);\n  }\n  ranges.sort((a, b) => a[0] - b[0]);\n  const merged: [number, number][] = [];\n  for (const range of ranges) {\n    const last = merged[merged.length - 1];\n    if (last && range[0] <= last[1]) last[1] = Math.max(last[1], range[1]);\n    else merged.push(range);\n  }\n  return merged;\n}\n\n/**\n * A marked word: a tint of the primary colour behind the text colour, in semibold, and the system's\n * mark colours under forced colours.\n *\n * @internal\n * @claim \"A marked word: a tint of\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > draws marked words that keep their contrast in light and dark, highlighted or not, and in forced colours)\n */\nconst commandMarkClass =\n  \"rounded-[0.2em] bg-[color-mix(in_oklab,var(--primary)_22%,transparent)] font-semibold text-foreground \" +\n  \"forced-colors:bg-[Mark] forced-colors:text-[MarkText]\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/command/command-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/command/command.tsx",
      "content": "\"use client\";\n\nimport { Autocomplete } from \"@base-ui/react/autocomplete\";\nimport { cloneElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type JSX, type KeyboardEvent, type MouseEvent, type PointerEvent, type ReactElement, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { floatingHint } from \"@/registry/ouro/lib/ouro/floating\";\nimport { lastInput } from \"@/registry/ouro/lib/ouro/last-input\";\nimport { holdPageAtPress } from \"@/registry/ouro/lib/ouro/page-scroll-hold\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { ariaKeyShortcuts } from \"@/registry/ouro/lib/ouro/key-shortcuts\";\nimport { checkOpenMode } from \"@/registry/ouro/lib/ouro/open-mode\";\nimport { controlRef } from \"@/registry/ouro/lib/ouro/control-ref\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { serverElement } from \"@/registry/ouro/lib/ouro/server-element\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { usePlatform } from \"@/registry/ouro/lib/ouro/use-platform\";\nimport { useSheetPresentation } from \"@/registry/ouro/lib/ouro/use-sheet-presentation\";\nimport { Avatar } from \"@/registry/ouro/components/ouro/avatar/avatar\";\nimport { Skeleton } from \"@/registry/ouro/components/ouro/skeleton/skeleton\";\nimport { Kbd } from \"@/registry/ouro/components/ouro/kbd/kbd\";\nimport { SheetFrame } from \"@/registry/ouro/components/ouro/sheet/sheet\";\nimport { UnreadDot } from \"@/registry/ouro/components/ouro/unread-dot/unread-dot\";\nimport {\n  DialogBackdrop,\n  DialogClose,\n  DialogPopupUnchecked,\n  DialogPortal,\n  DialogRoot,\n  DialogTitle,\n  DialogViewport,\n} from \"@/registry/ouro/components/ouro/dialog/dialog-parts\";\nimport {\n  commandCloseClass,\n  commandEmptyClass,\n  commandEmptyRoomClass,\n  commandGroupLabelClass,\n  commandInputClass,\n  commandItemClass,\n  commandMarkClass,\n  commandListClass,\n  commandListboxClass,\n  commandLoadingClass,\n  commandLoadingRowClass,\n  commandSearchClass,\n  commandSheetListClass,\n  commandSheetSearchClass,\n  matchesQuery,\n  queryMatch,\n  queryRanges,\n  type TextRange,\n} from \"@/registry/ouro/components/ouro/command/command-styles\";\n\n/** One command in a Command palette's `items`. */\nexport interface CommandItem {\n  /** The command's text, which the search matches and screen readers hear. */\n  label: string;\n  /**\n   * What the row shows in place of `label`, when plain text cannot draw it: a chat's name with\n   * its emoji as pictures (`<EmojiText text={chat.name} catalogue={catalogue} />`). `label`\n   * stays the text the search matches and the row's name for screen readers.\n   *\n   * @claim \"`label` stays the text the search matches\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > shows labelContent in place of the label, while the search and the row's name still use the label)\n   */\n  labelContent?: ReactNode;\n  /** Runs the command. The palette closes first. */\n  onSelect: () => void;\n  /**\n   * What tells this command apart from the others, when results change around it: the highlight\n   * stays on the command with the same value. Give one when two commands can share a label.\n   * @default its label\n   * @claim \"What tells this command apart from\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > tells commands with the same label apart by value)\n   */\n  value?: string | undefined;\n  /**\n   * Whether closing the palette after this command runs puts focus back where it was (the\n   * trigger). `false` leaves focus where `onSelect` puts it, as a command that opens a\n   * conversation and focuses its messages does. @default true, or false for a command that `navigates`\n   * @claim \"Whether closing the palette after this\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command and focus after a choice > returns focus to its trigger after a choice, and leaves it where the choice put it with restoreFocus false)\n   */\n  restoreFocus?: boolean | undefined;\n  /**\n   * This command takes the person somewhere: it opens a conversation, a page or a record. Closing the\n   * palette then leaves focus where the destination put it, never back on the trigger, which may be\n   * gone or covered by then (`restoreFocus` defaults to false). Give `restoreFocus` to say otherwise.\n   * @default false\n   * @claim \"This command takes the person somewhere\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command and focus after a choice > leaves focus where a command that navigates put it, unless it says restoreFocus)\n   * @claim \"Closing the palette then leaves focus where the destination put it\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command and focus after a choice > leaves focus where a command that navigates put it, unless it says restoreFocus)\n   */\n  navigates?: boolean | undefined;\n  /**\n   * A second line under the label, such as a snippet of a message, which the search matches too.\n   * @claim \"A second line under the label\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > marks nothing without highlightMatches, and searches a command's description)\n   */\n  description?: string | undefined;\n  /**\n   * Where to mark the label and the description, as `[start, end]` ranges of each, such as the\n   * matches a server found. With these, `highlightMatches` marks nothing else on this command.\n   * @claim \"Where to mark the label and\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > marks what the app's ranges say, in place of the search's words)\n   */\n  highlight?: { label?: readonly TextRange[] | undefined; description?: readonly TextRange[] | undefined } | undefined;\n  /**\n   * More words the search matches, which never show: `keywords: [\"dark mode\"]`.\n   *\n   * @claim \"More words the search matches, which\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > filters by label and keywords, ignoring case and accents, and hides empty groups)\n   */\n  keywords?: readonly string[] | undefined;\n  /** The keys of the command's shortcut, shown at its end with `Kbd`: `[\"mod\", \"n\"]`. It does not bind them. */\n  shortcut?: readonly string[] | undefined;\n  /**\n   * A picture before the label, for a person, a chat or a team: a URL, shown in an `<Avatar>`\n   * named by the label, or an element to show instead, such as\n   * `<Avatar name={person.name} alt=\"\" size=\"xs\" idForColor={person.id} />` for initials in the\n   * person's color or a presence dot. Give the element `alt=\"\"`, since the label names it.\n   *\n   * @claim \"A picture before the label, for\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > shows an avatar from a picture or an element, and a muted icon, before the label)\n   */\n  avatar?: string | ReactElement | undefined;\n  /**\n   * A small icon before the label, in the muted color: a gear for settings, a page for a document.\n   * It takes an extra-small avatar's width, so labels line up in a palette that mixes the two.\n   * Screen readers skip it; the label names the command. With `avatar`, the avatar shows instead.\n   *\n   * @claim \"It takes an extra-small avatar's width\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > shows an avatar from a picture or an element, and a muted icon, before the label)\n   * @claim \"Screen readers skip it; the label\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > shows an avatar from a picture or an element, and a muted icon, before the label)\n   */\n  icon?: ReactNode;\n  /**\n   * Something new waits there, as in a chat with unread messages: the label is bold, a dot\n   * ends the row, and screen readers hear `unreadLabel` after the label.\n   *\n   * @claim \"Something new waits there, as in\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > marks an unread command with a bold label, a dot and a spoken label)\n   */\n  unread?: boolean | undefined;\n  /**\n   * Something small at the end of the row, before the shortcut: an unread count's `<Badge>`, or\n   * words such as \"Draft\", which show small and muted. It takes the unread dot's place; screen\n   * readers still hear `unreadLabel`.\n   *\n   * @claim \"It takes the unread dot's place\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > ends the row with a mark in the unread dot's place, before the shortcut)\n   */\n  mark?: ReactNode;\n  /** Listed, but cannot be run. */\n  disabled?: boolean | undefined;\n\n  /** Not a prop. A command runs `onSelect`: `{ label: \"New recipe\", onSelect: create }`. (A `MenuItem` is the one that takes `onClick`.) */\n  onClick?: { 'Use onSelect: { label: \"New recipe\", onSelect: create }': never };\n}\n\n/** A labelled group of commands in a Command palette's `items`. */\nexport interface CommandGroup {\n  /** The group's heading: \"Recipes\". */\n  label: string;\n  /** The group's commands. */\n  items: readonly CommandItem[];\n}\n\n/** One entry in a Command palette's `items`: a command, or a group of them. */\nexport type CommandEntry = CommandItem | CommandGroup;\n\n/** Props shared by both ways of opening a Command palette. */\nexport interface CommandBaseProps {\n  /**\n   * Names the palette for screen readers; it is not shown. It is always required.\n   *\n   * @claim \"It is always required\" registry/ouro/components/ouro/command/command.test-d.ts verify:fileLine(registry/ouro/components/ouro/command/command.test-d.ts, /\\{\\strigger:\\sReactElement;\\sitems:\\sCommandEntry\\[\\]\\s\\}>\\(\\)\\.not\\.toExtend<CommandProps>/)\n   */\n  title: string;\n  /** The commands: groups (`{ label: \"Recipes\", items: [...] }`), single commands, or both. */\n  items: readonly CommandEntry[];\n  /** The search input's placeholder. @default \"Type a command or search…\" */\n  placeholder?: string | undefined;\n  /** The search input's label for screen readers. @default \"Search commands\" */\n  searchLabel?: string | undefined;\n  /**\n   * Marks the words of the search in each command's label and description, with the theme's\n   * colours (the system's mark colours under forced colours). The commands' names stay their\n   * plain text.\n   * @claim \"Marks the words of the search\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > marks the words of the search in each command's label and description, and keeps the text as it was)\n   * @claim \"Marks the words of the search\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command match highlighting > draws marked words that keep their contrast in light and dark, highlighted or not, and in forced colours)\n   */\n  highlightMatches?: boolean | undefined;\n  /** What shows when nothing matches the search. @default \"No results\" */\n  emptyLabel?: string | undefined;\n  /**\n   * Content for the empty state in place of `emptyLabel`, such as a picture with words:\n   * `empty={<Empty icon={<SearchIcon />} title=\"Nothing matches\" />}`. While `loading`, the loading\n   * line still shows under it.\n   * @claim \"Content for the empty state\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > takes content for its empty state, such as a picture with words, with the loading line under it while loading)\n   */\n  empty?: ReactNode;\n  /**\n   * The label of the close button, so screen-reader users on phones (who have no Escape key)\n   * can always close the palette. In the dialog it is hidden until it has keyboard focus, as a\n   * palette closes on Escape or a press outside; on a phone it is the sheet's icon button in the\n   * top corner. @default \"Close\"\n   * @claim \"The label of the close button\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > labels the search input and its close button, translated)\n   */\n  closeLabel?: string | undefined;\n  /** Layout only, applied to the dialog panel: margins (`mt-8`). Appearance classes warn in development. */\n  className?: string | undefined;\n  /**\n   * For results from a server: called with the search text on every change, and with the\n   * current text (`\"\"` at each opening) whenever the palette opens or swaps between dialog\n   * and sheet. The palette then stops filtering `items` itself and shows them as they are,\n   * so keep the last results in `items` until new ones arrive. `signal` aborts when a newer\n   * query replaces this one or the palette closes: pass it to `fetch`, or drop the response\n   * when `signal.aborted`, so a slow earlier response never overwrites a newer one. The app\n   * owns the request, and must set `loading` back to false when the request fails or its\n   * signal aborts, or \"Searching…\" stays up.\n   *\n   * @example\n   * onQueryChange={(query, { signal }) => {\n   *   setLoading(true);\n   *   signal.addEventListener(\"abort\", () => setLoading(false));\n   *   fetch(`/api/search?q=${encodeURIComponent(query)}`, { signal })\n   *     .then((response) => response.json())\n   *     .then((results) => { setResults(results); setLoading(false); })\n   *     .catch(() => { if (!signal.aborted) setLoading(false); });\n   * }}\n   * @claim \"For results from a server: called\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > asks again for the current query when the palette switches between dialog and sheet across 640px)\n   * @claim \"For results from a server: called\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > keeps the phone sheet's search input still while server results change)\n   * @claim \"For results from a server: called\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > passes each query to onQueryChange, shows the app's results unfiltered, and keeps stale results while loading)\n   * @claim \"`signal` aborts when a newer query\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > drops a slow earlier response that arrives after a newer one)\n   * @claim \"`signal` aborts when a newer query\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > takes a translated loading label, and aborts the last search when the palette closes)\n   */\n  onQueryChange?: ((query: string, context: { signal: AbortSignal }) => void) | undefined;\n  /**\n   * Whether results are on their way: shows `loadingLabel` beside the input, or under the\n   * empty state while nothing matches yet (\"No chats by that name.\" over \"Searching the\n   * directory…\"), and announces it politely for the first load of each opening (not again while\n   * typing goes on). Set it back to false when the request fails or aborts. While it is true,\n   * rows in a result's shape, as tall as a result, hold the place of the results on their way\n   * under the ones already shown (none while nothing matches), and screen readers skip them.\n   * @claim \"rows in a result's shape\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > holds the place of results on their way with rows a result's height, gone once loading ends)\n   * @claim \"Whether results are on their way\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > says it is searching politely, once while typing goes on, and shows the empty state only after loading)\n   * @claim \"Whether results are on their way\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > shows the empty state at once while loading finds nothing yet, with the loading line under it, and alone once loading ends)\n   * @claim \"Whether results are on their way\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > announces loading again after the palette closes and opens)\n   */\n  loading?: boolean | undefined;\n  /** What shows, and is announced, while `loading`. @default \"Searching…\" */\n  loadingLabel?: string | undefined;\n  /**\n   * What screen readers hear, politely and once, when the results for what was typed have settled\n   * (not while `loading`, and not for an empty search, whose list is the palette's own).\n   * @default (count) => count === 1 ? \"1 result\" : `${count} results`\n   * @claim \"What screen readers hear, politely and\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > says how many results there are, politely and once, after they settle)\n   */\n  resultsLabel?: ((count: number) => string) | undefined;\n  /** What screen readers hear after an `unread` command's label, for other languages. @default \"Unread\" */\n  unreadLabel?: string | undefined;\n  /**\n   * Keeps the dialog and its rows mounted while closed, hidden (no `dialog` role, nothing\n   * focusable), so opening only shows them: for a palette with many rows that a shortcut opens\n   * often. The search is emptied once the dialog has closed (with `onQueryChange(\"\")`), so the next\n   * opening shows the empty search's rows already drawn. The phone sheet mounts as it opens.\n   * @default false\n   * @claim \"Keeps the dialog and its rows mounted while closed\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command kept mounted > lets go of the width it held and holds the width it draws at each opening)\n   * @claim \"Keeps the dialog and its rows mounted while closed\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command kept mounted > keeps its rows mounted and hidden while closed, with no dialog role, and opens them at once)\n   * @claim \"The search is emptied once the dialog has closed\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command kept mounted > empties the search once it has closed, asking the app for the empty search's results, only when kept mounted (%s))\n   */\n  keepMounted?: boolean | undefined;\n\n  /** Not a prop. Ouro UI uses `open` with `onOpenChange`: `<Command open={open} onOpenChange={setOpen}>`. */\n  isOpen?: { \"Use <Command open={open} onOpenChange={setOpen}>\": never };\n  /** Not a prop. `onOpenChange(false)` fires on close: `<Command open={open} onOpenChange={setOpen}>`. */\n  onClose?: { \"Use <Command open={open} onOpenChange={setOpen}>\": never };\n  /** Not a prop. The commands are `items`: `items={[{ label: \"New recipe\", onSelect: create }]}`. */\n  children?: { 'Use items={[{ label: \"New recipe\", onSelect: create }]}': never };\n  /** Not a prop. The commands are `items`: `items={[{ label: \"New recipe\", onSelect: create }]}`. */\n  commands?: { 'Use items={[{ label: \"New recipe\", onSelect: create }]}': never };\n}\n\n/** An uncontrolled Command palette: `trigger` opens it. */\nexport type CommandWithTriggerProps = CommandBaseProps & {\n  /** The element that opens the palette, usually a Button: `trigger={<Button>Search</Button>}`. */\n  trigger: ReactElement;\n  /** Not with `trigger`. Remove `trigger` to control the palette with `open` and `onOpenChange`. */\n  open?: never;\n  /** Not with `trigger`. Remove `trigger` to control the palette with `open` and `onOpenChange`. */\n  onOpenChange?: never;\n};\n\n/** A controlled Command palette, usually opened by `useCommandShortcut`. */\nexport type CommandControlledProps = CommandBaseProps & {\n  /**\n   * Whether the palette is open. After a key press or a click it focuses the search input, in the\n   * dialog and in the phone sheet alike; after a touch or pen tap it focuses itself, so no software keyboard pops up.\n   * @claim \"After a key press or a click it focuses\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::controlled Command > focuses the palette, not the input, after a pen tap, so no keyboard pops up)\n   * @claim \"After a key press or a click it focuses\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command presentation > puts focus in the phone sheet's search after a key press below 640px)\n   * @claim \"after a touch or pen tap it focuses itself\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command presentation > focuses the phone sheet itself, not its search, after a %s tap below 640px, so no keyboard pops up)\n   * @claim \"After a key press or a click it focuses\" registry/ouro/components/ouro/command/command.touch.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.touch.test.tsx::Command on a phone > opens from a tap as a full-height sheet focused on itself, with 44px commands and a 16px search input)\n   */\n  open: boolean;\n  /** Called with `false` when the user closes the palette (Escape, outside press, swipe), and when a command runs. */\n  onOpenChange: (open: boolean) => void;\n  /** Not with `open`. Remove `open` and `onOpenChange` to let a trigger open the palette. */\n  trigger?: never;\n};\n\n/** Props for {@link Command}: either `trigger`, or `open` with `onOpenChange`. */\nexport type CommandProps = CommandWithTriggerProps | CommandControlledProps;\n\n/** The props Command reads from, and adds to, its trigger element. */\ntype TriggerProps = {\n  ref?: Ref<HTMLElement> | undefined;\n  onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;\n  onPointerDown?: ((event: PointerEvent<HTMLElement>) => void) | undefined;\n  onKeyDown?: ((event: KeyboardEvent<HTMLElement>) => void) | undefined;\n  \"aria-haspopup\"?: string;\n  \"aria-expanded\"?: boolean;\n};\n\n/**\n * A run of commands under one heading, or none for loose commands.\n *\n * @claim \"A run of commands under one\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > lists loose items without a group heading)\n */\ninterface Group {\n  label: string | undefined;\n  items: CommandItem[];\n}\n\nconst itemsFix = '<Command items={[{ label: \"New recipe\", onSelect: create }]}>';\n\n/** What the search reads in a command besides its label: its description and its keywords. */\nconst searchedWords = (item: CommandItem): string[] => [item.description ?? \"\", ...(item.keywords ?? [])];\n\n/**\n * Groups as given, with each run of loose commands in a group without a heading.\n *\n * @claim \"Groups as given, with each run\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > lists loose items without a group heading)\n */\nfunction toGroups(entries: readonly CommandEntry[]): Group[] {\n  const groups: Group[] = [];\n  for (const entry of entries) {\n    if (\"items\" in entry) {\n      groups.push({ label: entry.label, items: [...entry.items] });\n      continue;\n    }\n    const last = groups.at(-1);\n    if (last && last.label === undefined) last.items.push(entry);\n    else groups.push({ label: undefined, items: [entry] });\n  }\n  return groups;\n}\n\n/** The widths of the rows that hold the place of results on their way. */\nconst LOADING_ROWS = [\"w-2/3\", \"w-1/2\", \"w-3/4\"] as const;\n\nconst shown = (node: ReactNode): boolean => node !== undefined && node !== null && node !== false;\n\n// Muted, but mixed toward the text so it keeps its contrast on the highlighted row.\nconst quiet = \"text-[color-mix(in_oklab,var(--muted-foreground)_80%,var(--foreground))]\";\n\n/**\n * A 16px magnifier in the text color.\n *\n * @claim \"A 16px magnifier in the text\" registry/ouro/components/ouro/command/command.tsx verify:fileLine(registry/ouro/components/ouro/command/command.tsx, /<svg\\saria-hidden=\"true\"\\sviewBox=\"0\\s0\\s16\\s16\"\\sfill=\"none\">/)\n */\n/** Sets the palette's width to its width now, so it neither grows nor shrinks while it is open; it still narrows with the screen. */\nfunction holdWidth(popup: HTMLElement): void {\n  popup.style.width = `min(100%, ${getComputedStyle(popup).width})`;\n}\n\n/** Marks the hidden input Base UI keeps the query in. */\nconst markInput = controlRef(\"command\", \"hidden-input\");\n\nfunction SearchIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\">\n      <circle cx=\"7\" cy=\"7\" r=\"4.75\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n      <path d=\"m10.5 10.5 3 3\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\n/**\n * A command palette: a searchable list of every action in the app, in a dialog. Typing\n * filters the commands by label and keywords (ignoring case and accents, and forgiving one slip\n * in a word of four letters or more: \"dialg\" finds Dialog). Within each group, the commands whose\n * label starts with the search come first, then those that hold it, then those a slip away. The arrow keys\n * move the highlight, and Enter runs the highlighted command. Commands come in labelled\n * groups and show their shortcuts with `Kbd`; when nothing matches it says so. Below 640px\n * it is a full-height bottom sheet, whose search input stays put while the results filter.\n * Above it, the dialog fits the commands it opens with, from 32rem up to 40rem, and keeps that\n * width while they filter and while a server's results arrive, so nothing in it moves sideways;\n * a longer result is cut with an ellipsis.\n * A command can lead with an `avatar` or an `icon` and end with an `unread` dot or a `mark`,\n * so a palette that jumps to any chat shows who each one is with and what is new.\n *\n * Open it with `trigger`, or control it with `open` and `onOpenChange`, usually from\n * `useCommandShortcut`, which opens it on ⌘K (Ctrl+K elsewhere):\n * `import { useCommandShortcut } from \"@/lib/ouro/use-command-shortcut\"`.\n *\n * `useCommandShortcut(shortcut = \"mod+k\")` returns `[open, setOpen]` and toggles `open`\n * on the shortcut anywhere on the page. It takes the keys as `\"mod+k\"` or `[\"mod\", \"k\"]`,\n * with Kbd's names: `mod` (⌘ on Apple platforms, Ctrl elsewhere), `cmd`, `ctrl`, `alt`\n * and `shift`. It needs exactly those modifiers, ignores a held key's repeats and prevents\n * the browser's action for that combination. It never fires while an input method is\n * composing text, and in a text field it fires only when the shortcut includes `mod`,\n * `cmd` or `ctrl`, so a shortcut like `\"/\"` never takes a typed character.\n *\n * Use `Menu` instead for the few actions on one thing, and `Combobox` to pick a value for a form.\n *\n * @group Menus\n * @see https://ui.ouroboros.bot/docs/command\n *\n * @example\n * const [open, setOpen] = useCommandShortcut(\"mod+k\");\n * <Command\n *   title=\"Command palette\"\n *   open={open}\n *   onOpenChange={setOpen}\n *   items={[\n *     { label: \"Recipes\", items: [{ label: \"New recipe\", onSelect: create, shortcut: [\"mod\", \"n\"] }] },\n *     { label: \"Switch theme\", onSelect: toggleTheme, keywords: [\"dark mode\"] },\n *   ]}\n * />\n *\n * // A palette that jumps to any chat, with each person's avatar and what is unread.\n * <Command\n *   title=\"Go to a chat\"\n *   open={open}\n *   onOpenChange={setOpen}\n *   items={chats.map((chat) => ({\n *     label: chat.name,\n *     onSelect: () => openChat(chat.id),\n *     avatar: <Avatar name={chat.name} src={chat.picture} alt=\"\" size=\"xs\" idForColor={chat.id} />,\n *     unread: chat.unread > 0,\n *     mark: chat.unread > 0 && <Badge>{chat.unread}</Badge>,\n *   }))}\n * />\n * @claim \"Typing filters the commands by label\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > forgives one slip in a word of four letters or more: a letter dropped, added, changed, or two swapped)\n * @claim \"Within each group, the commands whose\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > ranks a command that starts with the search first, then one that holds it, then one a slip away)\n * @claim \"Above it, the dialog fits\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command width > widens to fit a longer command, up to 40rem)\n * @claim \"Above it, the dialog fits\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command width > keeps the width it opened at while results filter)\n * @claim \"Above it, the dialog fits\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command width > keeps the width it opened at while a server search's results change, and cuts a longer result with an ellipsis)\n * @claim \"so nothing in it moves sideways\" registry/ouro/e2e/ouro/command.spec.ts verify:testExists(registry/ouro/e2e/ouro/command.spec.ts::on a desktop > keeps the palette and its rows still while a server's longer results arrive)\n * @claim \"A command can lead with an\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command media > shows an avatar from a picture or an element, and a muted icon, before the label)\n * @claim \"Below 640px it is a full-height\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command presentation > is a full-height bottom sheet below 640px, whose search input stays put while results filter)\n * @claim \"A command palette: a searchable list\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command > opens a dialog named by its title, with the search input focused and every group listed)\n * @claim \"It never fires while an input\" registry/ouro/lib/ouro/use-command-shortcut.test.tsx verify:testExists(registry/ouro/lib/ouro/use-command-shortcut.test.tsx::useCommandShortcut > does not fire while an input method is composing text)\n * @claim \"It never fires while an input\" registry/ouro/lib/ouro/use-command-shortcut.test.tsx verify:fileLine(registry/ouro/lib/ouro/use-command-shortcut.test.tsx, /never\\stakes\\sa\\sshortcut\\swithout\\smod,\\smeta\\sor\\sctrl\\sfrom\\styping\\sin/)\n */\nexport function Command(props: CommandProps): JSX.Element {\n  const platform = usePlatform();\n  const {\n    title,\n    items,\n    placeholder = \"Type a command or search…\",\n    searchLabel = \"Search commands\",\n    emptyLabel = \"No results\",\n    empty,\n    highlightMatches = false,\n    closeLabel = \"Close\",\n    className,\n    onQueryChange,\n    loading = false,\n    loadingLabel = \"Searching…\",\n    resultsLabel = countResults,\n    unreadLabel = \"Unread\",\n    keepMounted = false,\n    trigger,\n    open,\n    onOpenChange,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    isOpen,\n    onClose,\n    children,\n    commands,\n  } = props as CommandBaseProps & { trigger?: ReactElement; open?: boolean; onOpenChange?: (open: boolean) => void };\n\n  checkOpenMode(\"Command\", \"command palette\", trigger !== undefined, open, onOpenChange);\n  if (items === undefined) {\n    devThrow(\"Command\", \"needs items\", process.env.NODE_ENV !== \"production\" ? itemsFix : /* istanbul ignore next @preserve -- production only */ \"\");\n  }\n\n  const groups = useMemo(() => toGroups(items), [items]);\n\n  useAppearanceClassNameCheck(\n    \"Command\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? floatingHint('<Command title=\"…\">', \"</Command>\") : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Command\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !title && ([\"title is required; it names the palette for screen readers\", '<Command title=\"Command palette\">'] as const),\n          isOpen !== undefined && ([\"isOpen is not a prop\", \"<Command open={open} onOpenChange={setOpen}>\"] as const),\n          onClose !== undefined && ([\"onClose is not a prop\", \"<Command open={open} onOpenChange={setOpen}>\"] as const),\n          children !== undefined && ([\"children is not a prop; the commands are items\", itemsFix] as const),\n          commands !== undefined && ([\"commands is not a prop; the commands are items\", itemsFix] as const),\n          ...groups.flatMap((group) =>\n            group.items\n              .filter((item) => item.onClick !== undefined)\n              .map(\n                (item) =>\n                  [`the item \"${item.label}\" has onClick; a command runs onSelect`, `{ label: \"${item.label}\", onSelect: run }`] as const,\n              ),\n          ),\n          ...groups.flatMap((group) =>\n            group.items\n              .filter((item) => item.avatar !== undefined && shown(item.icon))\n              .map(\n                (item) =>\n                  [`the item \"${item.label}\" has both avatar and icon, and shows only the avatar; pass one`, `{ label: \"${item.label}\", avatar: picture }`] as const,\n              ),\n          ),\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // The palette owns the open state even with a trigger, so it stays open when a resize\n  // across 640px swaps the dialog for the sheet.\n  const [ownOpen, setOwnOpen] = useState(false);\n  const controlled = open !== undefined;\n  const isOpenNow = controlled ? open : ownOpen;\n  const setOpen = controlled ? onOpenChange! : setOwnOpen;\n  const sheet = useSheetPresentation(\"auto\");\n\n  const triggerRef = useRef<HTMLElement>(null);\n  const popupRef = useRef<HTMLDivElement | null>(null);\n  const searchInputRef = useRef<HTMLInputElement | null>(null);\n  // The dialog fits the commands it opens with, from 32rem to 40rem, and then keeps that width while it is open: taken as\n  // it mounts with its rows, so filtering or a server's answer never moves the input or the rows sideways.\n  const holdOnOpen = useCallback(\n    (popup: HTMLDivElement | null) => {\n      popupRef.current = popup;\n      if (popup) holdWidth(popup);\n    },\n    // Stryker disable next-line ArrayDeclaration: the callback reads nothing from render, so any dependency list keeps it.\n    [],\n  );\n  // A Server Component's trigger can arrive as a lazy wrapper; resolve it before cloning.\n  const triggerElement = serverElement(trigger);\n  const triggerProps = (triggerElement?.props ?? {}) as TriggerProps;\n  const mergedTriggerRef = useMergedRef(triggerProps.ref, triggerRef);\n  const triggerNode =\n    trigger !== undefined &&\n    cloneElement(triggerElement as ReactElement<TriggerProps>, {\n      ref: mergedTriggerRef,\n      onClick: (event: MouseEvent<HTMLElement>) => {\n        triggerProps.onClick?.(event);\n        if (!event.defaultPrevented) setOpen(true);\n      },\n      onPointerDown: (event: PointerEvent<HTMLElement>) => {\n        triggerProps.onPointerDown?.(event);\n        holdPageAtPress.dialog.onPointerDown(event);\n      },\n      onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n        triggerProps.onKeyDown?.(event);\n        holdPageAtPress.dialog.onKeyDown(event);\n      },\n      \"aria-haspopup\": \"dialog\",\n      \"aria-expanded\": isOpenNow,\n    });\n  // Focus returns to the trigger on close; Safari does not focus a button on click.\n  // A command with restoreFocus: false, or one that navigates and says nothing else, leaves focus where its onSelect put it.\n  const keepFocus = useRef(false);\n  const finalFocus = {\n    finalFocus: () => {\n      const keep = keepFocus.current;\n      keepFocus.current = false;\n      if (keep) return false;\n      // Stryker disable next-line ConditionalExpression: a controlled palette has no trigger, so its ref is null, which Base UI takes as true.\n      if (trigger === undefined) return true;\n      return triggerRef.current;\n    },\n  };\n\n  // The search text: emptied when the palette opens (not when it closes, so a closing\n  // palette keeps showing what it showed), and kept across the swap between dialog and sheet.\n  const [query, setQuery] = useState(\"\");\n  const [wasOpen, setWasOpen] = useState(false);\n  if (isOpenNow !== wasOpen) {\n    setWasOpen(isOpenNow);\n    if (isOpenNow) setQuery(\"\");\n  }\n  // Within each group, the commands whose label starts with the search come first, then those that hold it, then those a\n  // slip away (queryMatch). A server search ranks its own results.\n  const ranked = useMemo(() => {\n    if (onQueryChange) return groups;\n    // Each command ranked once, then sorted by rank: the sort compares far more often than there are commands.\n    const rank = (item: CommandItem) => queryMatch(item.label, searchedWords(item), query) ?? 3;\n    return groups.map((group) => ({\n      ...group,\n      items: group.items\n        .map((item) => ({ item, at: rank(item) }))\n        .sort((a, b) => a.at - b.at)\n        .map(({ item }) => item),\n    }));\n  }, [groups, query, onQueryChange]);\n  // \"Searching…\" is announced for the first load of each opening only, and then cleared,\n  // so typing on while results load is not announced again.\n  const [announcement, setAnnouncement] = useState<\"idle\" | \"on\" | \"done\">(\"idle\");\n  // The latest search's controller: a newer query, or closing, aborts it.\n  const searchRef = useRef<AbortController | null>(null);\n  const search = (query: string) => {\n    searchRef.current?.abort();\n    const controller = new AbortController();\n    searchRef.current = controller;\n    onQueryChange!(query, { signal: controller.signal });\n  };\n  useEffect(() => {\n    if (!isOpenNow) searchRef.current?.abort();\n  }, [isOpenNow]);\n  useEffect(() => () => searchRef.current?.abort(), []);\n  // Opening (also when it cancels a close still animating) asks for the empty query's\n  // results, and the swap between dialog and sheet asks again for the current text.\n  const searchCurrent = useRef<(() => void) | null>(null);\n  useLayoutEffect(() => {\n    searchCurrent.current = onQueryChange ? () => search(query) : null;\n  });\n  useEffect(() => {\n    if (isOpenNow) searchCurrent.current?.();\n  }, [isOpenNow, sheet]);\n  // Adjusted while rendering, as React suggests for state that follows props.\n  if (loading && isOpenNow && announcement === \"idle\") setAnnouncement(\"on\");\n  if (!loading && announcement === \"on\") setAnnouncement(\"done\");\n  if (!isOpenNow && announcement !== \"idle\") setAnnouncement(\"idle\");\n\n  // Kept mounted, the hidden palette has no width to hold: each opening lets go of the last one and holds the width it\n  // draws at. The search is emptied once the palette has closed (emptyOnceClosed), off the opening's path.\n  useLayoutEffect(() => {\n    const popup = popupRef.current;\n    // Stryker disable next-line LogicalOperator,ConditionalExpression: a palette mounted as it opens already holds this width, and a closed one has none to hold, so these two run the same\n    if (!keepMounted || !isOpenNow || !popup) return;\n    popup.style.width = \"\";\n    const frame = requestAnimationFrame(() => holdWidth(popup));\n    // Stryker disable next-line ArrowFunction: a frame left to run after a close holds the width of a palette that is hidden, which the next opening lets go of\n    return () => cancelAnimationFrame(frame);\n  }, [keepMounted, isOpenNow]);\n  // Every key typed straight after the palette opens goes in its search: the search takes focus as the dialog or the\n  // phone sheet shows, in the same task as the key or click that opened it. Base UI focuses it a frame later, and a busy\n  // computer draws that frame late, so the first keys went to whatever had focus behind the palette.\n  // Never after a touch or pen tap, which opens the palette focused on itself, so no software keyboard pops up.\n  useLayoutEffect(() => {\n    if (!isOpenNow || lastInput() === \"touch\" || lastInput() === \"pen\") return;\n    // Base UI shows the palette in the commit just after this one, which a microtask comes after: still in the task of\n    // the key that opened it, before any later key. A palette shut again by then has no search to focus, or a hidden one.\n    // Stryker disable next-line OptionalChaining: Base UI mounts the palette in the commit before this microtask; the check only keeps one it mounts later from throwing\n    queueMicrotask(() => searchInputRef.current?.focus());\n  }, [isOpenNow, sheet]);\n  const emptyOnceClosed = (next: boolean) => {\n    if (next || !keepMounted) return;\n    setQuery(\"\");\n    if (onQueryChange) search(\"\");\n  };\n\n  // The command the person has highlighted, by its value, and what was typed when it was. Base UI\n  // keeps the highlight's position when the results change; KeepHighlight puts it back on this one.\n  // Stryker disable next-line ObjectLiteral,StringLiteral: before any highlight, every start moves it to the first command, where autoHighlight puts it anyway.\n  const held = useRef<{ value: string; query: string }>({ value: \"\", query: \"\" });\n\n  // The app's ranges for a command, or the search's words when the palette marks matches.\n  const rangesFor = (item: CommandItem, part: \"label\" | \"description\"): readonly TextRange[] =>\n    item.highlight?.[part] ?? (highlightMatches && item.highlight === undefined ? queryRanges(item[part]!, query) : []);\n\n  // An app's own label content is shown as it is, with the label for screen readers; a plain label is marked.\n  const labelOf = (item: CommandItem) =>\n    item.labelContent === undefined ? (\n      <Marked text={item.label} ranges={rangesFor(item, \"label\")} />\n    ) : (\n      <>\n        <span aria-hidden=\"true\">{item.labelContent}</span>\n        <span className=\"sr-only\">{item.label}</span>\n      </>\n    );\n\n  const run = (item: CommandItem) => {\n    keepFocus.current = item.restoreFocus === false || (item.navigates === true && item.restoreFocus !== true);\n    setOpen(false);\n    item.onSelect();\n  };\n\n  const palette = (inSheet: boolean) => (\n    <Autocomplete.Root\n      items={ranked}\n      inline\n      open\n      autoHighlight=\"always\"\n      keepHighlight\n      // A server search filters on the server: the items are already the results.\n      filter={onQueryChange ? null : (item: CommandItem, text: string) => matchesQuery(item.label, searchedWords(item), text)}\n      value={query}\n      inputRef={markInput}\n      onItemHighlighted={(item: CommandItem | undefined) => {\n        // No highlight holds no command: when the results come back, the first one is highlighted.\n        // Stryker disable next-line StringLiteral: a value no command has falls back to the first command, as the empty one does.\n        held.current = { value: item ? valueOf(item) : \"\", query };\n      }}\n      onValueChange={(next: string) => {\n        setQuery(next);\n        if (onQueryChange) search(next);\n      }}\n    >\n      <div data-ouro=\"command\" className=\"flex min-h-0 flex-1 flex-col\">\n        <div data-ouro-command-search=\"\" className={inSheet ? commandSheetSearchClass : commandSearchClass}>\n          <SearchIcon />\n          <Autocomplete.Input ref={searchInputRef} aria-label={searchLabel} placeholder={placeholder} data-ouro-control=\"command\" data-ouro-part=\"input\" className={commandInputClass} />\n          {loading && <SearchingLabel label={loadingLabel} />}\n\n          <span data-ouro-command-status=\"\" role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n            {announcement === \"on\" ? loadingLabel : \"\"}\n          </span>\n        </div>\n        <div data-ouro-command-list=\"\" className={inSheet ? commandSheetListClass : commandListClass}>\n          {/* Nothing here yet is said at once; while more is on its way, the loading line says so under it. */}\n          <Autocomplete.Empty className={commandEmptyRoomClass}>\n            <div data-ouro-command-empty=\"\" className={commandEmptyClass}>\n              {empty ?? emptyLabel}\n              {loading && <span className=\"mt-1 block text-xs\">{loadingLabel}</span>}\n            </div>\n          </Autocomplete.Empty>\n          <CommandList\n            className={inSheet ? \"outline-none\" : commandListboxClass}\n            // While results are on their way, rows in their shape hold their place under the ones already shown, scrolling with them.\n            after={loading && <LoadingRows />}\n          >\n            {(group: Group, index: number) => (\n              <Autocomplete.Group key={group.label ?? `loose-${index}`} items={group.items} data-ouro-command-group=\"\">\n                {group.label !== undefined && (\n                  <Autocomplete.GroupLabel data-ouro-command-group-label=\"\" className={commandGroupLabelClass}>\n                    {group.label}\n                  </Autocomplete.GroupLabel>\n                )}\n                <Autocomplete.Collection>\n                  {(item: CommandItem, itemIndex: number) => (\n                    <Autocomplete.Item\n                      // Two commands may share a label; the position keeps their rows apart.\n                      key={`${item.label}-${itemIndex}`}\n                      value={item}\n                      data-ouro-command-value={valueOf(item)}\n                      disabled={item.disabled}\n                      onClick={() => run(item)}\n                      data-ouro-control=\"command\"\n                      data-ouro-part=\"item\"\n                      className={commandItemClass}\n                      {...(item.shortcut ? { \"aria-keyshortcuts\": ariaKeyShortcuts(item.shortcut, platform) } : {})}\n                    >\n                      {item.avatar !== undefined ? (\n                        <span data-ouro-command-avatar=\"\" className=\"flex shrink-0\">\n                          {typeof item.avatar === \"string\" ? <Avatar name={item.label} src={item.avatar} alt=\"\" size=\"xs\" /> : item.avatar}\n                        </span>\n                      ) : (\n                        shown(item.icon) && (\n                          <span data-ouro-command-icon=\"\" aria-hidden=\"true\" className={cn(\"flex w-6 shrink-0 items-center justify-center [&_svg]:size-4\", quiet)}>\n                            {item.icon}\n                          </span>\n                        )\n                      )}\n                      {item.description === undefined ? (\n                        <span data-ouro-command-label=\"\" className={cn(\"min-w-0 flex-1 truncate\", item.unread ? \"font-semibold\" : \"font-normal\")}>\n                          {labelOf(item)}\n                        </span>\n                      ) : (\n                        <span className=\"flex min-w-0 flex-1 flex-col\">\n                          <span data-ouro-command-label=\"\" className={cn(\"block truncate\", item.unread ? \"font-semibold\" : \"font-normal\")}>\n                            {labelOf(item)}\n                          </span>\n                          <span data-ouro-command-description=\"\" className={cn(\"block truncate text-xs leading-4\", quiet)}>\n                            <Marked text={item.description} ranges={rangesFor(item, \"description\")} />\n                          </span>\n                        </span>\n                      )}\n                      {shown(item.mark) && (\n                        <span data-ouro-command-mark=\"\" className={cn(\"flex shrink-0 items-center text-xs\", quiet)}>\n                          {item.mark}\n                        </span>\n                      )}\n                      {item.unread && <UnreadDot data-ouro-command-unread=\"\" label={unreadLabel} dot={!shown(item.mark)} />}\n                      {item.shortcut && <Kbd keys={item.shortcut} aria-hidden=\"true\" />}\n                    </Autocomplete.Item>\n                  )}\n                </Autocomplete.Collection>\n              </Autocomplete.Group>\n            )}\n          </CommandList>\n        </div>\n        <KeepHighlight heldRef={held} query={query} />\n        <ResultCount query={query} loading={loading} label={resultsLabel} />\n      </div>\n    </Autocomplete.Root>\n  );\n\n  return (\n    <>\n      {triggerNode}\n      {sheet ? (\n        <SheetFrame\n          title={title}\n          hideTitle\n          closeLabel={closeLabel}\n          side=\"bottom\"\n          // One tall snap point: the sheet keeps its height as results filter, so the search\n          // input stays where the thumb left it.\n          snapPoints={[1]}\n          open={isOpenNow}\n          onOpenChange={setOpen}\n          presentation=\"sheet\"\n          // The sheet itself after a touch or pen tap, so no software keyboard pops up. Otherwise the search, unless focus\n          // is in the sheet already: the search took it above, and Base UI's focus, a frame later, would pull back a Tab\n          // pressed before that frame. A sheet that mounts already open mounts after that, so here its search takes focus.\n          initialFocus={() => {\n            const search = searchInputRef.current!;\n            const popup = search.closest<HTMLElement>('[data-ouro=\"sheet\"]')!;\n            if (lastInput() === \"touch\" || lastInput() === \"pen\") return popup;\n            return popup.contains(document.activeElement) ? false : search;\n          }}\n          {...finalFocus}\n        >\n          {palette(true)}\n        </SheetFrame>\n      ) : (\n        <DialogRoot open={isOpenNow} onOpenChange={(next) => setOpen(next)} onOpenChangeComplete={emptyOnceClosed}>\n          <DialogPortal keepMounted={keepMounted}>\n            <DialogBackdrop />\n            <DialogViewport>\n              <DialogPopupUnchecked\n                ref={holdOnOpen}\n                size=\"auto\"\n                className={cn(\"max-w-[min(100%,40rem)]\", className)}\n                // The palette itself after a touch or pen tap, so no software keyboard pops up. Once the search\n                // has focus (above), Base UI focuses nothing: its focus comes a frame later and would pull back a\n                // Tab pressed before that frame. When the dialog mounted too late for that, Base UI focuses the search.\n                initialFocus={() =>\n                  lastInput() === \"touch\" || lastInput() === \"pen\" ? popupRef.current : document.activeElement !== popupRef.current!.querySelector(\"input\")\n                }\n                // Kept mounted and closed, it is no dialog: nothing that looks for an open one finds it.\n                // Stryker disable next-line StringLiteral: an empty role takes the dialog role away as well\n                {...(keepMounted && !isOpenNow ? { role: \"presentation\" } : {})}\n                {...finalFocus}\n              >\n                <DialogTitle visuallyHidden>{title}</DialogTitle>\n                {palette(false)}\n                <DialogClose data-ouro-command-close=\"\" className={commandCloseClass}>\n                  {closeLabel}\n                </DialogClose>\n              </DialogPopupUnchecked>\n            </DialogViewport>\n          </DialogPortal>\n        </DialogRoot>\n      )}\n    </>\n  );\n}\n\n/** A text with its ranges marked; a range past the text's end is cut to it, and one with nothing left is dropped. */\nfunction Marked({ text, ranges }: { text: string; ranges: readonly TextRange[] }): ReactNode {\n  const parts: ReactNode[] = [];\n  let at = 0;\n  for (const [start, end] of ranges) {\n    const from = Math.max(start, at);\n    const to = Math.min(end, text.length);\n    if (to <= from) continue;\n    parts.push(text.slice(at, from), <mark key={from} className={commandMarkClass}>{text.slice(from, to)}</mark>);\n    at = to;\n  }\n  parts.push(text.slice(at));\n  return parts;\n}\n\n/** The default `resultsLabel`. */\nconst countResults = (count: number) => (count === 1 ? \"1 result\" : `${count} results`);\n\n/** What tells a command apart when the results change around it. */\nconst valueOf = (item: CommandItem) => item.value ?? item.label;\n\n/**\n * Puts the highlight back on the command the person had highlighted when the results change while\n * the query stays the same (results arriving from a slow source), or on the first command when that\n * one has gone. Base UI's Autocomplete takes no highlighted item as a prop, so it moves it the way\n * a pointer does, through the list's own handler for a pointer moving over a row. It runs after the\n * rows' own layout effects, as the last child of the list's root.\n * @claim \"Base UI's Autocomplete takes no\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > keeps the highlight on the same command when results arrive above it)\n */\nfunction KeepHighlight({\n  heldRef,\n  query,\n}: {\n  heldRef: { current: { value: string; query: string } };\n  query: string;\n}): JSX.Element {\n  // A mark of its own in the palette, since a dialog and a sheet may both be mounted while one replaces the other.\n  const mark = useRef<HTMLSpanElement | null>(null);\n  useLayoutEffect(() => {\n    const want = heldRef.current;\n    if (want.query !== query) return;\n    const rows = [...mark.current!.closest('[data-ouro=\"command\"]')!.querySelectorAll<HTMLElement>(\"[data-ouro-command-value]\")];\n    const row = rows.find((candidate) => candidate.getAttribute(\"data-ouro-command-value\") === want.value) ?? rows[0];\n    if (!row) return;\n    // Stryker disable next-line ConditionalExpression,StringLiteral: moving the highlight onto the row it is already on changes nothing.\n    if (row.hasAttribute(\"data-highlighted\")) return;\n    // movementX, so WebKit does not take it for a pointer that stands still.\n    row.dispatchEvent(new MouseEvent(\"mousemove\", { bubbles: true, movementX: 1 }));\n  });\n  return <span ref={mark} hidden data-ouro-command-keeper=\"\" />;\n}\n\n/**\n * Says how many results there are, politely, once they settle: 400ms after the last change, not\n * while loading, and not for an empty search. With no results, the empty state, a live region of\n * its own, says so instead.\n * @claim \"Says how many results there are\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > says how many results there are, politely and once, after they settle)\n * @claim \"Says how many results there are\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > says nothing of an empty search's results, which are the palette's own list)\n * @claim \"With no results, the empty\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command results that stream in > says how many results there are, politely and once, after they settle)\n */\nfunction ResultCount({ query, loading, label }: { query: string; loading: boolean; label: (count: number) => string }): JSX.Element {\n  const filtered = Autocomplete.useFilteredItems() as readonly Group[];\n  const count = filtered.reduce((sum, group) => sum + group.items.length, 0);\n  const [said, setSaid] = useState(\"\");\n  useEffect(() => {\n    if (loading || query === \"\") return undefined;\n    const timer = setTimeout(() => setSaid(count > 0 ? label(count) : \"\"), 400);\n    return () => clearTimeout(timer);\n  }, [loading, query, count, label]);\n  return (\n    <span data-ouro-command-results=\"\" role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n      {said}\n    </span>\n  );\n}\n\n/**\n * The loading label beside the input, while there are results to show; with an empty list, the\n * empty state carries it instead, so it shows once.\n * @claim \"The loading label beside the\" registry/ouro/components/ouro/command/command.test.tsx verify:testExists(registry/ouro/components/ouro/command/command.test.tsx::Command server search > shows the empty state at once while loading finds nothing yet, with the loading line under it, and alone once loading ends)\n */\nfunction SearchingLabel({ label }: { label: string }): JSX.Element | null {\n  if (Autocomplete.useFilteredItems().length === 0) return null;\n  return (\n    <span data-ouro-command-loading=\"\" aria-hidden=\"true\" className={commandLoadingClass}>\n      {label}\n    </span>\n  );\n}\n\n/**\n * The list of results, hidden while nothing matches: an empty listbox says nothing, and the\n * empty state beside it says why.\n */\n/** Rows in a result's shape under the results shown, while some match; otherwise the empty state speaks. */\nfunction LoadingRows(): JSX.Element | null {\n  if (Autocomplete.useFilteredItems().length === 0) return null;\n  return (\n    <div data-ouro-command-loading-rows=\"\" aria-hidden=\"true\">\n      {LOADING_ROWS.map((width) => (\n        <div key={width} className={commandLoadingRowClass}>\n          <Skeleton shape=\"circle\" size=\"xs\" className=\"shrink-0\" />\n          <Skeleton shape=\"text\" className={width} />\n        </div>\n      ))}\n    </div>\n  );\n}\n\nfunction CommandList({ children, className, after }: { children: (group: Group, index: number) => ReactNode; className: string; after: ReactNode }): JSX.Element {\n  const empty = Autocomplete.useFilteredItems().length === 0;\n  return (\n    <Autocomplete.List hidden={empty} className={className}>\n      <Autocomplete.Collection>{children}</Autocomplete.Collection>\n      {after}\n    </Autocomplete.List>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/command/command.tsx"
    }
  ],
  "docs": "A command palette: a searchable list of every action in the app, in a dialog. Import: import { Command } from \"@/components/ouro/command/command\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: avatar, dialog, kbd, sheet, skeleton, unread-dot, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/command.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}