{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "modal-command-pages",
  "type": "registry:component",
  "title": "Nested Command Modal",
  "description": "A command modal where items open sub-pages, shown as breadcrumb chips inside the search field, and Backspace walks back out. Searching from the root also finds options nested one level down.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "modals",
    "command",
    "palette",
    "search",
    "keyboard",
    "nested",
    "modal"
  ],
  "docs": "https://hyperblur.dev/effects/modal-command-pages",
  "files": [
    {
      "path": "registry/hyperblur/modal-command-pages.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/modal-command-pages.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CommandPageItem {\n  id: string;\n  label: string;\n  group?: string;\n  hint?: string;\n  shortcut?: string[];\n  icon?: string;\n  keywords?: string[];\n  children?: CommandPageItem[];\n}\n\nexport interface ModalCommandPagesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  embedded?: boolean;\n  trigger?: React.ReactNode;\n  items?: CommandPageItem[];\n  placeholder?: string;\n  hotkey?: boolean;\n  onSelect?: (item: CommandPageItem, path: string[]) => void;\n  accent?: string;\n}\n\nconst icons = {\n  home: \"M2.5 7.5 8 3l5.5 4.5V13a.5.5 0 0 1-.5.5H10V10H6v3.5H3a.5.5 0 0 1-.5-.5Z\",\n  inbox: \"M2.5 9.5h3l1 1.5h3l1-1.5h3M3.5 3.5h9l1 6v3h-11v-3Z\",\n  folder: \"M2.5 4.5a1 1 0 0 1 1-1h3l1.5 1.5h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1Z\",\n  plus: \"M8 3.5v9M3.5 8h9\",\n  user: \"M8 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM3 13.5a5 5 0 0 1 10 0\",\n  sun: \"M8 10.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM8 1.5v1.5M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1 1M11.6 11.6l1 1M3.4 12.6l1-1M11.6 4.4l1-1\",\n  globe: \"M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11ZM2.5 8h11M8 2.5c1.6 1.6 2.3 3.4 2.3 5.5S9.6 11.9 8 13.5C6.4 11.9 5.7 10.1 5.7 8S6.4 4.1 8 2.5Z\",\n  flag: \"M3.5 13.5v-10M3.5 3.5h7l-1.5 2.5 1.5 2.5h-7\",\n  gear: \"M8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM13 8.8V7.2l-1.5-.4-.4-1 .8-1.3-1.2-1.2-1.3.8-1-.4L8.8 2H7.2l-.4 1.5-1 .4-1.3-.8-1.2 1.2.8 1.3-.4 1L2 7.2v1.6l1.5.4.4 1-.8 1.3 1.2 1.2 1.3-.8 1 .4.4 1.5h1.6l.4-1.5 1-.4 1.3.8 1.2-1.2-.8-1.3.4-1Z\",\n};\n\nconst defaultItems: CommandPageItem[] = [\n  { id: \"go-inbox\", label: \"Go to Inbox\", group: \"Navigate\", icon: icons.inbox, shortcut: [\"G\", \"I\"] },\n  { id: \"go-projects\", label: \"Go to Projects\", group: \"Navigate\", icon: icons.folder, shortcut: [\"G\", \"P\"] },\n  { id: \"new-issue\", label: \"Create issue\", group: \"Actions\", icon: icons.plus, shortcut: [\"C\"] },\n  {\n    id: \"assign\",\n    label: \"Assign to…\",\n    group: \"Actions\",\n    icon: icons.user,\n    children: [\n      { id: \"assign-me\", label: \"Me\", hint: \"Alex Moreno\" },\n      { id: \"assign-dana\", label: \"Dana Whitfield\", hint: \"Design\" },\n      { id: \"assign-kenji\", label: \"Kenji Sato\", hint: \"Engineering\" },\n      { id: \"assign-ruth\", label: \"Ruth Adeyemi\", hint: \"Product\" },\n      { id: \"assign-none\", label: \"Unassigned\" },\n    ],\n  },\n  {\n    id: \"priority\",\n    label: \"Set priority…\",\n    group: \"Actions\",\n    icon: icons.flag,\n    children: [\n      { id: \"p-urgent\", label: \"Urgent\", shortcut: [\"1\"] },\n      { id: \"p-high\", label: \"High\", shortcut: [\"2\"] },\n      { id: \"p-medium\", label: \"Medium\", shortcut: [\"3\"] },\n      { id: \"p-low\", label: \"Low\", shortcut: [\"4\"] },\n    ],\n  },\n  {\n    id: \"theme\",\n    label: \"Change theme…\",\n    group: \"Preferences\",\n    icon: icons.sun,\n    keywords: [\"appearance\", \"dark\", \"light\"],\n    children: [\n      { id: \"theme-system\", label: \"Match system\" },\n      { id: \"theme-dark\", label: \"Dark\" },\n      { id: \"theme-light\", label: \"Light\" },\n      { id: \"theme-contrast\", label: \"High contrast\" },\n    ],\n  },\n  {\n    id: \"language\",\n    label: \"Change language…\",\n    group: \"Preferences\",\n    icon: icons.globe,\n    children: [\n      { id: \"lang-en\", label: \"English\", hint: \"English\" },\n      { id: \"lang-pt\", label: \"Português\", hint: \"Portuguese\" },\n      { id: \"lang-es\", label: \"Español\", hint: \"Spanish\" },\n      { id: \"lang-de\", label: \"Deutsch\", hint: \"German\" },\n      { id: \"lang-ja\", label: \"日本語\", hint: \"Japanese\" },\n    ],\n  },\n  { id: \"settings\", label: \"Open settings\", group: \"Preferences\", icon: icons.gear, shortcut: [\"⌘\", \",\"] },\n];\n\nconst css = `\n.hb-xe10 { --hb-xe10-accent: #2f7bff; display: inline-block; box-sizing: border-box; color: #ededed; font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif); }\n.hb-xe10 *, .hb-xe10 *::before, .hb-xe10 *::after { box-sizing: border-box; }\n.hb-xe10[data-embedded] { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-height: 190px; border-radius: 16px; overflow: hidden; isolation: isolate; background: #0a0a0a; }\n.hb-xe10-trigger { display: inline-flex; align-items: center; gap: 10px; width: 240px; height: 36px; padding: 0 6px 0 11px; border: 1px solid #262626; border-radius: 10px; background: #111; color: #8f8f8f; font: inherit; font-size: 13px; cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease; }\n.hb-xe10-trigger:hover { border-color: #363636; color: #c4c4c4; }\n.hb-xe10-trigger > svg { width: 14px; height: 14px; flex: none; }\n.hb-xe10-trigger > span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe10 button:focus-visible { outline: 2px solid var(--hb-xe10-accent); outline-offset: 2px; }\n.hb-xe10-keys { display: inline-flex; gap: 3px; }\n.hb-xe10-keys kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; background: #1a1a1a; box-shadow: inset 0 -1px 0 #2e2e2e, inset 0 0 0 1px #262626; color: #a1a1a1; font-family: inherit; font-size: 11px; }\n.hb-xe10-layer { position: fixed; inset: 0; z-index: 1000; height: 100dvh; display: flex; justify-content: center; align-items: flex-start; padding: 14dvh 16px 16px; }\n.hb-xe10[data-embedded] .hb-xe10-layer { position: absolute; height: auto; z-index: 2; padding: 10px; align-items: center; }\n.hb-xe10-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: hb-xe10-fade 0.18s ease both; }\n.hb-xe10-layer[data-state=\"closed\"] .hb-xe10-scrim { animation: hb-xe10-fade-out 0.16s ease both; }\n.hb-xe10-panel { container-type: inline-size; position: relative; display: flex; flex-direction: column; width: 100%; max-width: 580px; max-height: min(460px, 100%); overflow: hidden; border: 1px solid #2a2a2a; border-radius: 14px; background: rgba(20, 20, 20, 0.92); -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 30px 80px -20px rgba(0, 0, 0, 0.9); animation: hb-xe10-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }\n.hb-xe10[data-embedded] .hb-xe10-panel { height: 100%; max-height: 100%; }\n.hb-xe10-layer[data-state=\"closed\"] .hb-xe10-panel { animation: hb-xe10-out 0.16s ease both; }\n.hb-xe10-panel[data-bump=\"a\"] { animation: hb-xe10-bump-a 0.22s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe10-panel[data-bump=\"b\"] { animation: hb-xe10-bump-b 0.22s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-xe10-search { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 14px; border-bottom: 1px solid #232323; }\n.hb-xe10-search > svg { width: 16px; height: 16px; flex: none; color: #7a7a7a; }\n.hb-xe10-crumb { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: color-mix(in srgb, var(--hb-xe10-accent) 18%, #1a1a1a); color: color-mix(in srgb, var(--hb-xe10-accent) 45%, #fff); font-size: 12px; font-weight: 550; white-space: nowrap; animation: hb-xe10-chip 0.25s cubic-bezier(0.3, 0.7, 0.4, 1.3) both; }\n.hb-xe10-input { flex: 1; min-width: 120px; height: 26px; border: 0; background: transparent; color: #ededed; font: inherit; font-size: 15px; outline: none; }\n.hb-xe10-input::placeholder { color: #6a6a6a; }\n.hb-xe10-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px; scroll-padding: 8px; animation: hb-xe10-push 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both; }\n.hb-xe10-list[data-dir=\"pop\"] { animation-name: hb-xe10-pop; }\n.hb-xe10-group { padding: 8px 10px 4px; color: #6f6f6f; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }\n.hb-xe10-opt { position: relative; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 8px; color: #d4d4d4; font-size: 13.5px; cursor: pointer; user-select: none; }\n.hb-xe10-opt[aria-selected=\"true\"] { background: #232323; color: #fff; }\n.hb-xe10-opt[aria-selected=\"true\"]::before { content: \"\"; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--hb-xe10-accent); }\n.hb-xe10-ico { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 6px; background: #1c1c1c; box-shadow: inset 0 0 0 1px #2a2a2a; color: #a8a8a8; }\n.hb-xe10-opt[aria-selected=\"true\"] .hb-xe10-ico { color: #fff; }\n.hb-xe10-ico svg { width: 13px; height: 13px; }\n.hb-xe10-lab { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-xe10-lab mark { background: none; color: #fff; font-weight: 650; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--hb-xe10-accent) 70%, transparent); text-underline-offset: 3px; }\n.hb-xe10-hint { color: #6f6f6f; font-size: 12px; white-space: nowrap; }\n.hb-xe10-chev { width: 13px; height: 13px; color: #6f6f6f; }\n.hb-xe10-tick { width: 14px; height: 14px; color: var(--hb-xe10-accent); }\n.hb-xe10-empty { padding: 28px 12px; color: #7a7a7a; font-size: 13px; text-align: center; }\n.hb-xe10-foot { flex: none; display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-top: 1px solid #232323; color: #6f6f6f; font-size: 11.5px; }\n.hb-xe10-foot span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }\n.hb-xe10-foot kbd { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; background: #1c1c1c; box-shadow: inset 0 0 0 1px #2a2a2a; color: #9a9a9a; font-family: inherit; font-size: 10.5px; }\n.hb-xe10-done { margin-left: auto; color: #4fd18b; animation: hb-xe10-chip 0.25s ease both; }\n@container (max-width: 380px) { .hb-xe10-foot span:nth-child(3) { display: none; } }\n@keyframes hb-xe10-fade { from { opacity: 0; } to { opacity: 1; } }\n@keyframes hb-xe10-fade-out { from { opacity: 1; } to { opacity: 0; } }\n@keyframes hb-xe10-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe10-out { from { opacity: 1; } to { opacity: 0; transform: scale(0.98); } }\n@keyframes hb-xe10-bump-a { 50% { transform: scale(0.985); } }\n@keyframes hb-xe10-bump-b { 50% { transform: scale(0.985); } }\n@keyframes hb-xe10-push { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe10-pop { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }\n@keyframes hb-xe10-chip { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-xe10-scrim, .hb-xe10-panel, .hb-xe10-panel[data-bump], .hb-xe10-list, .hb-xe10-crumb, .hb-xe10-done, .hb-xe10-layer[data-state=\"closed\"] .hb-xe10-panel, .hb-xe10-layer[data-state=\"closed\"] .hb-xe10-scrim { animation: none; }\n  .hb-xe10-layer[data-state=\"closed\"] { opacity: 0; }\n  .hb-xe10-trigger { transition: none; }\n}\n`;\n\nconst focusable =\n  'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex=\"-1\"])';\n\nfunction useLayer(\n  open: boolean,\n  embedded: boolean,\n  panel: React.RefObject<HTMLElement | null>,\n  onClose: () => void,\n  userOpened: React.RefObject<boolean>,\n) {\n  const closeRef = React.useRef(onClose);\n  React.useEffect(() => {\n    closeRef.current = onClose;\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const node = panel.current;\n    const steal = !embedded || userOpened.current;\n    const previous = document.activeElement as HTMLElement | null;\n    const html = document.documentElement;\n    const overflow = html.style.overflow;\n    if (!embedded) html.style.overflow = \"hidden\";\n    if (steal && node) {\n      const target = node.querySelector<HTMLElement>(\"[data-autofocus]\") ?? node.querySelector<HTMLElement>(focusable) ?? node;\n      target.focus({ preventScroll: true });\n    }\n    const onKey = (e: KeyboardEvent) => {\n      if (!node) return;\n      if (embedded && !node.contains(document.activeElement)) return;\n      if (e.key === \"Escape\") {\n        e.preventDefault();\n        closeRef.current();\n        return;\n      }\n      if (e.key !== \"Tab\") return;\n      const items = Array.from(node.querySelectorAll<HTMLElement>(focusable)).filter((el) => el.getClientRects().length > 0);\n      if (!items.length) {\n        e.preventDefault();\n        node.focus();\n        return;\n      }\n      const first = items[0];\n      const last = items[items.length - 1];\n      const active = document.activeElement;\n      if (!node.contains(active)) {\n        e.preventDefault();\n        first.focus();\n      } else if (e.shiftKey && (active === first || active === node)) {\n        e.preventDefault();\n        last.focus();\n      } else if (!e.shiftKey && active === last) {\n        e.preventDefault();\n        first.focus();\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      if (!embedded) html.style.overflow = overflow;\n      if (steal && previous && previous.isConnected && previous !== document.body) previous.focus({ preventScroll: true });\n    };\n  }, [open, embedded, panel, userOpened]);\n}\n\ninterface Row {\n  item: CommandPageItem;\n  parent?: CommandPageItem;\n}\n\nfunction highlight(label: string, q: string) {\n  if (!q) return label;\n  const i = label.toLowerCase().indexOf(q.toLowerCase());\n  if (i < 0) return label;\n  return (\n    <>\n      {label.slice(0, i)}\n      <mark>{label.slice(i, i + q.length)}</mark>\n      {label.slice(i + q.length)}\n    </>\n  );\n}\n\nexport function ModalCommandPages({\n  open,\n  defaultOpen,\n  onOpenChange,\n  embedded = false,\n  trigger = \"Search or jump to…\",\n  items = defaultItems,\n  placeholder = \"Type a command or search\",\n  hotkey = true,\n  onSelect,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: ModalCommandPagesProps) {\n  const [inner, setInner] = React.useState(defaultOpen ?? embedded);\n  const isOpen = open ?? inner;\n  const [present, setPresent] = React.useState(isOpen);\n  const [stack, setStack] = React.useState<CommandPageItem[]>([]);\n  const [query, setQuery] = React.useState(\"\");\n  const [active, setActive] = React.useState(0);\n  const [dir, setDir] = React.useState<\"push\" | \"pop\">(\"push\");\n  const [bump, setBump] = React.useState<\"a\" | \"b\" | undefined>(undefined);\n  const [choices, setChoices] = React.useState<Record<string, string>>({ theme: \"theme-dark\", language: \"lang-en\" });\n  const [done, setDone] = React.useState(\"\");\n  const userOpened = React.useRef(false);\n  const panel = React.useRef<HTMLDivElement>(null);\n  const list = React.useRef<HTMLDivElement>(null);\n  const timer = React.useRef(0);\n  const id = React.useId();\n\n  if (isOpen && !present) setPresent(true);\n\n  const setOpen = React.useCallback(\n    (next: boolean) => {\n      if (next) {\n        userOpened.current = true;\n        setStack([]);\n        setQuery(\"\");\n        setActive(0);\n        setDone(\"\");\n      }\n      if (open === undefined) setInner(next);\n      onOpenChange?.(next);\n    },\n    [open, onOpenChange],\n  );\n  const close = React.useCallback(() => setOpen(false), [setOpen]);\n\n  React.useEffect(() => {\n    if (isOpen || !present) return;\n    const t = setTimeout(() => setPresent(false), 180);\n    return () => clearTimeout(t);\n  }, [isOpen, present]);\n\n  React.useEffect(() => () => clearTimeout(timer.current), []);\n\n  const openRef = React.useRef(setOpen);\n  React.useEffect(() => {\n    openRef.current = setOpen;\n  });\n  React.useEffect(() => {\n    if (!hotkey || embedded) return;\n    const onKey = (e: KeyboardEvent) => {\n      if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === \"k\") {\n        e.preventDefault();\n        openRef.current(true);\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [hotkey, embedded]);\n\n  const page = stack[stack.length - 1];\n  const source = page?.children ?? items;\n  const q = query.trim().toLowerCase();\n\n  const rows: Row[] = React.useMemo(() => {\n    const match = (it: CommandPageItem) =>\n      it.label.toLowerCase().includes(q) || (it.keywords ?? []).some((k) => k.includes(q)) || (it.hint ?? \"\").toLowerCase().includes(q);\n    if (!q) return source.map((item) => ({ item, parent: page }));\n    const own = source.filter(match).map((item) => ({ item, parent: page }));\n    if (page) return own;\n    const deep: Row[] = [];\n    for (const it of source) for (const c of it.children ?? []) if (c.label.toLowerCase().includes(q)) deep.push({ item: c, parent: it });\n    return [...own, ...deep];\n  }, [source, q, page]);\n\n  const current = Math.min(active, Math.max(rows.length - 1, 0));\n\n  React.useEffect(() => {\n    list.current?.querySelector<HTMLElement>('[aria-selected=\"true\"]')?.scrollIntoView({ block: \"nearest\" });\n  }, [current, rows]);\n\n  function push(item: CommandPageItem) {\n    setDir(\"push\");\n    setStack((s) => [...s, item]);\n    setQuery(\"\");\n    setActive(Math.max(0, (item.children ?? []).findIndex((c) => c.id === choices[item.id])));\n    setBump((b) => (b === \"a\" ? \"b\" : \"a\"));\n  }\n\n  function pop() {\n    if (!stack.length) return;\n    const leaving = stack[stack.length - 1];\n    const parentList = stack[stack.length - 2]?.children ?? items;\n    setDir(\"pop\");\n    setStack((s) => s.slice(0, -1));\n    setActive(Math.max(0, parentList.findIndex((c) => c.id === leaving.id)));\n  }\n\n  function run(row: Row) {\n    if (row.item.children) {\n      push(row.item);\n      return;\n    }\n    const path = [...stack.map((s) => s.id), ...(row.parent && !stack.includes(row.parent) ? [row.parent.id] : []), row.item.id];\n    const parent = row.parent;\n    if (parent) setChoices((c) => ({ ...c, [parent.id]: row.item.id }));\n    onSelect?.(row.item, path);\n    setDone(row.parent ? `${row.parent.label.replace(\"…\", \"\")}: ${row.item.label}` : row.item.label);\n    clearTimeout(timer.current);\n    timer.current = window.setTimeout(() => {\n      if (embedded) {\n        setStack([]);\n        setQuery(\"\");\n        setActive(0);\n        setDone(\"\");\n      } else {\n        setOpen(false);\n      }\n    }, 650);\n  }\n\n  function onKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      if (!rows.length) return;\n      setActive((current + (e.key === \"ArrowDown\" ? 1 : -1) + rows.length) % rows.length);\n    } else if (e.key === \"Enter\") {\n      e.preventDefault();\n      if (rows[current]) run(rows[current]);\n    } else if (e.key === \"Backspace\" && !query && stack.length) {\n      e.preventDefault();\n      pop();\n    } else if (e.key === \"ArrowRight\" && rows[current]?.item.children && (e.currentTarget.selectionStart ?? 0) === query.length) {\n      e.preventDefault();\n      push(rows[current].item);\n    } else if (e.key === \"ArrowLeft\" && !query && stack.length) {\n      e.preventDefault();\n      pop();\n    }\n  }\n\n  useLayer(isOpen, embedded, panel, () => (stack.length ? pop() : close()), userOpened);\n\n  const groupOf = (row?: Row) => (!row ? undefined : q && row.parent && !page ? row.parent.label.replace(\"…\", \"\") : page ? undefined : row.item.group);\n  const vars = { \"--hb-xe10-accent\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div className={`hb-xe10 ${className}`} data-embedded={embedded || undefined} style={vars} {...rest}>\n      <style href=\"hb-xe10-css\" precedence=\"default\">{css}</style>\n      {trigger !== null && (\n        <button type=\"button\" className=\"hb-xe10-trigger\" aria-haspopup=\"dialog\" aria-expanded={isOpen} onClick={() => setOpen(true)}>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" aria-hidden=\"true\"><circle cx=\"7\" cy=\"7\" r=\"4.5\" /><path d=\"m10.5 10.5 3 3\" /></svg>\n          <span>{trigger}</span>\n          <span className=\"hb-xe10-keys\" aria-hidden=\"true\" style={{ flex: \"none\" }}><kbd>⌘</kbd><kbd>K</kbd></span>\n        </button>\n      )}\n      {present && (\n        <div className=\"hb-xe10-layer\" data-state={isOpen ? \"open\" : \"closed\"}>\n          <div className=\"hb-xe10-scrim\" onClick={close} aria-hidden=\"true\" />\n          <div ref={panel} role=\"dialog\" aria-modal=\"true\" aria-label=\"Command menu\" tabIndex={-1} className=\"hb-xe10-panel\" data-bump={bump}>\n            <div className=\"hb-xe10-search\">\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" aria-hidden=\"true\"><circle cx=\"7\" cy=\"7\" r=\"4.5\" /><path d=\"m10.5 10.5 3 3\" /></svg>\n              {stack.map((s) => (\n                <span key={s.id} className=\"hb-xe10-crumb\">{s.label.replace(\"…\", \"\")}</span>\n              ))}\n              <input\n                className=\"hb-xe10-input\"\n                data-autofocus=\"\"\n                role=\"combobox\"\n                aria-expanded=\"true\"\n                aria-controls={`${id}-l`}\n                aria-activedescendant={rows[current] ? `${id}-o-${current}` : undefined}\n                aria-autocomplete=\"list\"\n                placeholder={page ? `Search ${page.label.replace(\"…\", \"\").toLowerCase()}` : placeholder}\n                value={query}\n                onChange={(e) => {\n                  setQuery(e.target.value);\n                  setActive(0);\n                }}\n                onKeyDown={onKeyDown}\n              />\n            </div>\n            <div key={stack.length} ref={list} id={`${id}-l`} role=\"listbox\" aria-label={page?.label ?? \"Commands\"} className=\"hb-xe10-list\" data-dir={dir}>\n              {rows.length === 0 && <div className=\"hb-xe10-empty\">No results for “{query}”</div>}\n              {rows.map((row, i) => {\n                const group = groupOf(row);\n                const showGroup = group && group !== groupOf(rows[i - 1]);\n                const chosen = row.parent && choices[row.parent.id] === row.item.id;\n                return (\n                  <React.Fragment key={`${row.parent?.id ?? \"root\"}-${row.item.id}`}>\n                    {showGroup && <div className=\"hb-xe10-group\" role=\"presentation\">{group}</div>}\n                    <div\n                      id={`${id}-o-${i}`}\n                      role=\"option\"\n                      aria-selected={i === current}\n                      className=\"hb-xe10-opt\"\n                      onMouseMove={() => i !== current && setActive(i)}\n                      onClick={() => run(row)}\n                    >\n                      <span className=\"hb-xe10-ico\" aria-hidden=\"true\">\n                        <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                          <path d={row.item.icon ?? row.parent?.icon ?? icons.home} />\n                        </svg>\n                      </span>\n                      <span className=\"hb-xe10-lab\">{highlight(row.item.label, query.trim())}</span>\n                      {row.item.hint && <span className=\"hb-xe10-hint\">{row.item.hint}</span>}\n                      {chosen && (\n                        <svg className=\"hb-xe10-tick\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-label=\"Current\">\n                          <path d=\"m3.5 8.4 3 3 6-6.4\" />\n                        </svg>\n                      )}\n                      {row.item.shortcut && (\n                        <span className=\"hb-xe10-keys\" aria-hidden=\"true\">{row.item.shortcut.map((k) => <kbd key={k}>{k}</kbd>)}</span>\n                      )}\n                      {row.item.children && (\n                        <svg className=\"hb-xe10-chev\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M6 3.5 10.5 8 6 12.5\" /></svg>\n                      )}\n                    </div>\n                  </React.Fragment>\n                );\n              })}\n            </div>\n            <div className=\"hb-xe10-foot\">\n              <span><kbd>↑</kbd><kbd>↓</kbd> Navigate</span>\n              <span><kbd>↵</kbd> {rows[current]?.item.children ? \"Open\" : \"Run\"}</span>\n              {stack.length > 0 ? <span><kbd>⌫</kbd> Back</span> : <span><kbd>esc</kbd> Close</span>}\n              {done && <span className=\"hb-xe10-done\" role=\"status\">✓ {done}</span>}\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}