@ai-matrx/alchemy 0.12.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/actions.cjs.map +1 -1
  3. package/dist/actions.d.cts +19 -24
  4. package/dist/actions.d.ts +19 -24
  5. package/dist/actions.js.map +1 -1
  6. package/dist/checks.d.cts +2 -0
  7. package/dist/checks.d.ts +2 -0
  8. package/dist/core.cjs +4 -4
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +8 -58
  11. package/dist/core.d.ts +8 -58
  12. package/dist/core.js +4 -4
  13. package/dist/core.js.map +1 -1
  14. package/dist/declare/schema.json +3 -0
  15. package/dist/declare.cjs +1 -1
  16. package/dist/declare.cjs.map +1 -1
  17. package/dist/declare.d.cts +26 -1
  18. package/dist/declare.d.ts +26 -1
  19. package/dist/declare.js +1 -1
  20. package/dist/declare.js.map +1 -1
  21. package/dist/index.cjs +4 -4
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +8 -58
  24. package/dist/index.d.ts +8 -58
  25. package/dist/index.js +4 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/menu.d.cts +17 -22
  28. package/dist/menu.d.ts +17 -22
  29. package/dist/operate-document.cjs +2 -2
  30. package/dist/operate-document.cjs.map +1 -1
  31. package/dist/operate-document.d.cts +4 -42
  32. package/dist/operate-document.d.ts +4 -42
  33. package/dist/operate-document.js +2 -2
  34. package/dist/operate-document.js.map +1 -1
  35. package/dist/operate-rich-html.cjs +1 -1
  36. package/dist/operate-rich-html.cjs.map +1 -1
  37. package/dist/operate-rich-html.d.cts +3 -42
  38. package/dist/operate-rich-html.d.ts +3 -42
  39. package/dist/operate-rich-html.js +1 -1
  40. package/dist/operate-rich-html.js.map +1 -1
  41. package/dist/operate-server.cjs +1 -1
  42. package/dist/operate-server.cjs.map +1 -1
  43. package/dist/operate-server.d.cts +8 -46
  44. package/dist/operate-server.d.ts +8 -46
  45. package/dist/operate-server.js +1 -1
  46. package/dist/operate-server.js.map +1 -1
  47. package/dist/operate-xlsx.cjs +2 -2
  48. package/dist/operate-xlsx.cjs.map +1 -1
  49. package/dist/operate-xlsx.d.cts +4 -42
  50. package/dist/operate-xlsx.d.ts +4 -42
  51. package/dist/operate-xlsx.js +2 -2
  52. package/dist/operate-xlsx.js.map +1 -1
  53. package/dist/operate.cjs +4 -4
  54. package/dist/operate.cjs.map +1 -1
  55. package/dist/operate.d.cts +8 -58
  56. package/dist/operate.d.ts +8 -58
  57. package/dist/operate.js +4 -4
  58. package/dist/operate.js.map +1 -1
  59. package/dist/ports.d.cts +11 -15
  60. package/dist/ports.d.ts +11 -15
  61. package/dist/react-bar.cjs.map +1 -1
  62. package/dist/react-bar.d.cts +3 -1
  63. package/dist/react-bar.d.ts +3 -1
  64. package/dist/react-bar.js.map +1 -1
  65. package/dist/react-host.d.cts +17 -22
  66. package/dist/react-host.d.ts +17 -22
  67. package/dist/react-menu.cjs.map +1 -1
  68. package/dist/react-menu.d.cts +3 -1
  69. package/dist/react-menu.d.ts +3 -1
  70. package/dist/react-menu.js.map +1 -1
  71. package/dist/react-overflow.cjs.map +1 -1
  72. package/dist/react-overflow.d.cts +17 -22
  73. package/dist/react-overflow.d.ts +17 -22
  74. package/dist/react-overflow.js.map +1 -1
  75. package/dist/react-palette.cjs.map +1 -1
  76. package/dist/react-palette.d.cts +3 -1
  77. package/dist/react-palette.d.ts +3 -1
  78. package/dist/react-palette.js.map +1 -1
  79. package/dist/react-selection.cjs.map +1 -1
  80. package/dist/react-selection.d.cts +3 -1
  81. package/dist/react-selection.d.ts +3 -1
  82. package/dist/react-selection.js.map +1 -1
  83. package/dist/react-sheet.cjs.map +1 -1
  84. package/dist/react-sheet.d.cts +3 -1
  85. package/dist/react-sheet.d.ts +3 -1
  86. package/dist/react-sheet.js.map +1 -1
  87. package/dist/react-workspace.cjs +7 -0
  88. package/dist/react-workspace.cjs.map +1 -0
  89. package/dist/react-workspace.d.cts +441 -0
  90. package/dist/react-workspace.d.ts +441 -0
  91. package/dist/react-workspace.js +7 -0
  92. package/dist/react-workspace.js.map +1 -0
  93. package/dist/react.cjs +1 -1
  94. package/dist/react.cjs.map +1 -1
  95. package/dist/react.d.cts +2 -2
  96. package/dist/react.d.ts +2 -2
  97. package/dist/react.js +1 -1
  98. package/dist/react.js.map +1 -1
  99. package/dist/surface.cjs +1 -1
  100. package/dist/surface.cjs.map +1 -1
  101. package/dist/surface.d.cts +222 -16
  102. package/dist/surface.d.ts +222 -16
  103. package/dist/surface.js +1 -1
  104. package/dist/surface.js.map +1 -1
  105. package/package.json +14 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/react-palette.ts","../src/react/palette.tsx","../src/menu/layouts.ts","../src/react/engine.tsx","../src/declare/sensitivity.ts","../src/actions/projection.ts","../src/actions/run.ts","../src/menu/headings.ts","../src/menu/model.ts","../src/react/context.ts","../src/react/expansion-latest.ts","../src/react/search-opens-libraries.ts"],"sourcesContent":["/** `@ai-matrx/alchemy/react/palette` — the command palette layout. */\nexport { ActionPalette, type ActionPaletteProps } from \"./react/palette\";\n","\"use client\";\n/**\n * `@ai-matrx/alchemy/react/palette` — the command palette layout (Linear):\n * every leaf of the one model, flattened with its breadcrumb, type to filter.\n */\nimport * as React from \"react\";\nimport { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"@ai-matrx/design-system\";\nimport { palette } from \"../menu/layouts\";\nimport type { ClickTarget } from \"../actions/types\";\nimport { useMenuEngine, type MenuEngineOptions } from \"./engine\";\nimport { useSearchOpensLibraries } from \"./search-opens-libraries\";\n\nexport interface ActionPaletteProps extends MenuEngineOptions {\n target: ClickTarget;\n open: boolean;\n onOpenChange(open: boolean): void;\n placeholder?: string;\n}\n\nexport function ActionPalette({ target, open, onOpenChange, placeholder = \"Search actions…\", ...options }: ActionPaletteProps): React.ReactElement {\n const engine = useMenuEngine(target, {\n ...options,\n active: open,\n onRan: (id, r, ran) => {\n options.onRan?.(id, r, ran);\n // An in-place reload (Retry) keeps the layout open on the rows it reloads.\n if (!ran?.keepOpen) onOpenChange(false);\n },\n });\n // A palette IS a search: every lazy library opens so its rows are findable.\n useSearchOpensLibraries(engine, open);\n const arranged = engine.model ? palette(engine.model) : { leaves: [] };\n return (\n <CommandDialog open={open} onOpenChange={onOpenChange}>\n <CommandInput placeholder={placeholder} />\n <CommandList data-alchemy-layout=\"palette\">\n <CommandEmpty>No action matches.</CommandEmpty>\n <CommandGroup>\n {arranged.leaves.map(({ node, breadcrumb }) => {\n const unavailable = node.kind === \"item\" ? node.unavailable : undefined;\n return (\n <CommandItem\n key={node.id}\n value={`${node.label} ${breadcrumb.join(\" \")} ${node.id}`}\n data-alchemy-node={node.id}\n disabled={Boolean(unavailable)}\n onSelect={() => {\n if (node.kind === \"submenu\") void engine.expand(node.id);\n else if (node.kind === \"link\") window.location.assign(node.href);\n else void engine.run(node.id);\n }}\n className=\"gap-2\"\n >\n {\"icon\" in node ? engine.icon(node.icon) : null}\n <span className=\"flex-1 truncate\">{node.label}</span>\n <span className=\"text-xs text-muted-foreground\">\n {unavailable ? unavailable.sentence : node.kind === \"submenu\" && node.pending ? \"Loading…\" : breadcrumb.join(\" › \")}\n </span>\n </CommandItem>\n );\n })}\n </CommandGroup>\n </CommandList>\n </CommandDialog>\n );\n}\n\nexport default ActionPalette;\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n // A section keeps its declared heading in EVERY layout (the Lossless\n // Law covers headings: ⋯, the bar's ⋯ and the phone sheet show it too).\n sections.push(s);\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * FOLD UNDER THE SUBJECT — a control that belongs to a CONTAINER of the thing\n * (a tab's \"…\" over the note it shows) draws the container's own rows (the\n * primary sections) on top, and EVERY other row — the verb strip included —\n * under ONE submenu named for the subject (\"Note ▸\"). The label is the\n * subject's name the host supplies (the menu header's label), never a coined\n * group heading. Lossless: rows move, none is dropped or renamed. With no\n * primary section there is nothing to put first, so the arrangement is left\n * as it was. (page-pass /notes, 2026-09-28, Arman's ruling for the tab \"…\".)\n */\nexport function foldUnderSubject(arranged: ArrangedContext, subject: string): ArrangedContext {\n const label = subject.trim();\n const primary = arranged.sections.filter((s) => s.primary);\n const rest = arranged.sections.filter((s) => !s.primary);\n if (!label || primary.length === 0 || (rest.length === 0 && arranged.strip.length === 0)) return arranged;\n const children: MenuNode[] = [];\n if (arranged.strip.length) children.push(...arranged.strip);\n for (const s of rest) {\n if (rowCount(s.nodes) === 0) continue;\n if (children.length) children.push({ kind: \"separator\", id: `${s.id}:subject-sep` });\n if (s.label) children.push({ kind: \"label\", id: `${s.id}:subject-label`, label: s.label });\n children.push(...s.nodes);\n }\n if (rowCount(children) === 0) return { ...arranged, strip: [] };\n return {\n strip: [],\n filterable: false,\n sections: [\n ...primary,\n { id: \"subject\", group: rest[0]?.group ?? primary[0]!.group, nodes: [{ kind: \"submenu\", id: \"subject:fold\", label, children }] },\n ],\n };\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/**\n * A SEARCH REACHES EVERY ROW (clone 2026-10-01: \"Patient\" found nothing while\n * \"Patient reminder card\" sat under AI Actions ▸ My Personal). `palette` lists a\n * lazy submenu as ONE leaf — its label only — because its rows load on open.\n * A layout that searches opens every lazy submenu it can see: these are the\n * ones still to open (not already loading).\n */\nexport function lazySubmenuIds(model: MenuModel | null): string[] {\n if (!model) return [];\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind !== \"submenu\") continue;\n if (n.lazy) {\n if (!n.loading) out.push(n.id);\n } else walk(n.children);\n }\n };\n for (const s of model.sections) walk(s.nodes);\n return out;\n}\n\n/** True while some submenu's rows are not in the model yet (a search could still find more). */\nexport function paletteStillOpening(model: MenuModel | null): boolean {\n if (!model) return true;\n const walk = (nodes: readonly MenuNode[]): boolean =>\n nodes.some((n) => n.kind === \"submenu\" && (n.lazy || n.loading || n.pending || walk(n.children)));\n return model.sections.some((s) => walk(s.nodes));\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","\"use client\";\n/**\n * The React half of T1e: one hook every renderer uses to resolve the registry\n * at a target, build the model and run a node. Handlers never live in a\n * renderer — they live in providers and run through `runAction`.\n *\n * The context object is shared through globalThis so every per-layout entry\n * (each bundled separately) reads the same provider (module state is banned\n * across dual-loader graphs).\n */\nimport * as React from \"react\";\nimport { runAction, type RunResult } from \"../actions/run\";\nimport type { ProjectionSource } from \"../actions/projection\";\nimport type { Action, ClickTarget, ResolveRestriction, ResolvedAction } from \"../actions/types\";\nimport { actionToNode, buildMenuModel, findNode, withExpandedChildren, withGroupDividers } from \"../menu/model\";\nimport type { MenuModel, MenuNode } from \"../menu/types\";\nimport { useAlchemyActions } from \"./context\";\nimport { isLatestExpansion } from \"./expansion-latest\";\n\nexport interface MenuEngineOptions {\n restrict?: ResolveRestriction;\n /** Raw sources for projection (the host's mounted surface / clicked item). */\n source?: ProjectionSource;\n /** Content the menu acts on when nothing is selected (header text). */\n content?: string | null;\n /** The field's name, when the content is a field's text (see buildMenuModel). */\n contentLabel?: string | null;\n contentFingerprint?: string;\n /**\n * Called after a node ran (close the menu, announce). `keepOpen` is true for a row that reloads\n * the menu it sits in (`Action.keepsMenuOpen`): a layout never closes on it.\n */\n onRan?: (nodeId: string, result: RunResult, ran?: { keepOpen: boolean }) => void;\n /** Resolve only while true (renderers resolve on open). Default true. */\n active?: boolean;\n /**\n * Re-resolve when this changes even if the target object is the same (a\n * host that keeps one target per mount and reads live state through it).\n */\n revision?: string | number;\n}\n\nexport interface MenuEngine {\n model: MenuModel | null;\n resolved: readonly ResolvedAction[];\n run(nodeId: string): Promise<RunResult | null>;\n expand(nodeId: string): Promise<void>;\n /** The host's glyph for a key; `tone` is the action's colour class (iconTone). */\n icon(key: string | undefined, tone?: string): React.ReactNode;\n /** Say why a greyed verb is greyed (a tap on touch, where tooltips never open). */\n explain(sentence: string): void;\n}\n\nfunction nodeInModel(model: MenuModel, id: string): MenuNode | null {\n for (const s of model.sections) {\n const hit = findNode(s.nodes, id);\n if (hit) return hit;\n }\n return null;\n}\n\nfunction hasLoadedRows(model: MenuModel, id: string): boolean {\n const n = nodeInModel(model, id);\n return Boolean(n && n.kind === \"submenu\" && !n.lazy && !n.loading);\n}\n\nfunction loadedChildren(model: MenuModel, id: string): readonly MenuNode[] {\n const n = nodeInModel(model, id);\n return n && n.kind === \"submenu\" && !n.lazy ? n.children : [];\n}\n\n/**\n * The rebuilt rows, with every OPENED submenu that came back lazy keeping the\n * rows it last showed (its re-expansion replaces them when it lands).\n */\nexport function carryOpened(prev: readonly MenuNode[], next: MenuNode[], opened: ReadonlySet<string>): MenuNode[] {\n return next.map((n) => {\n if (n.kind !== \"submenu\") return n;\n const old = prev.find((o) => o.id === n.id);\n if (!old || old.kind !== \"submenu\" || old.lazy) return n;\n if (n.lazy) {\n return opened.has(n.id) ? { ...n, lazy: false, loading: false, pending: false, children: old.children } : n;\n }\n return { ...n, children: carryOpened(old.children, n.children, opened) };\n });\n}\n\nfunction carryOpenedModel(prev: MenuModel, next: MenuModel, opened: ReadonlySet<string>): MenuModel {\n if (opened.size === 0) return next;\n const prevNodes = prev.sections.flatMap((s) => s.nodes);\n return { ...next, sections: next.sections.map((s) => ({ ...s, nodes: carryOpened(prevNodes, s.nodes, opened) })) };\n}\n\nexport function useMenuEngine(target: ClickTarget | null, options: MenuEngineOptions = {}): MenuEngine {\n const { registry, ports } = useAlchemyActions();\n const [resolved, setResolved] = React.useState<readonly ResolvedAction[]>([]);\n const [model, setModel] = React.useState<MenuModel | null>(null);\n const [tick, setTick] = React.useState(0);\n // Every action an expansion returned, by id (a nested row is found here).\n const expanded = React.useRef(new Map<string, Action>());\n // Every submenu the person (or a search) opened, at ANY depth. A re-resolve\n // rebuilds the model with each of them lazy again; these are re-opened, and\n // their last rows are carried over meanwhile so an open submenu never blanks.\n const opened = React.useRef(new Set<string>());\n const expandSeq = React.useRef(new Map<string, number>());\n const targetEpoch = React.useRef(0);\n const currentTarget = React.useRef(target);\n if (currentTarget.current !== target) {\n currentTarget.current = target;\n targetEpoch.current += 1;\n }\n const active = options.active ?? true;\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n React.useEffect(() => registry.subscribe(() => setTick((t) => t + 1)), [registry]);\n\n const expandAction = React.useCallback(\n async (action: Action, nodeId: string) => {\n if (!target || !action.expand) return;\n const epoch = targetEpoch.current;\n const seq = (expandSeq.current.get(nodeId) ?? 0) + 1;\n expandSeq.current.set(nodeId, seq);\n const latest = () => isLatestExpansion(epoch, targetEpoch.current, seq, expandSeq.current.get(nodeId));\n // \"Loading…\" only over a submenu with no rows yet: a refresh keeps the\n // rows on screen until the new ones land (a blank flash unmounts the\n // focused row and Radix closes the parent submenu under the pointer).\n setModel((m) => (m && !hasLoadedRows(m, nodeId) ? withExpandedChildren(m, nodeId, \"loading\") : m));\n try {\n // A programmatic-only Action (surfaces without \"menu\") never becomes a row, even inside a submenu.\n const children = (await action.expand(target, new AbortController().signal)).filter(\n (child) => !child.surfaces || child.surfaces.includes(\"menu\"),\n );\n if (!latest()) return;\n const nodes: MenuNode[] = withGroupDividers(\n children,\n children.map((child) => {\n expanded.current.set(child.id, child);\n return actionToNode({ action: child, eligibility: { status: \"available\" } }, target, ports.i18n ? { i18n: ports.i18n } : {});\n }),\n );\n setModel((m) => (m ? withExpandedChildren(m, nodeId, carryOpened(loadedChildren(m, nodeId), nodes, opened.current)) : m));\n // A nested submenu that was open stays open: re-open it under its new parent rows.\n for (const child of children) if (child.expand && opened.current.has(child.id)) void expandAction(child, child.id);\n } catch (error) {\n if (!latest()) return;\n ports.diagnostics.capture(error, { area: \"menu\", detail: { nodeId, stage: \"expand\" } });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, []) : m));\n }\n },\n [target, ports],\n );\n\n React.useEffect(() => {\n expanded.current.clear();\n opened.current.clear();\n }, [target]);\n\n React.useEffect(() => {\n if (!target || !active) return;\n let live = true;\n void registry.resolve(target, optionsRef.current.restrict).then((list) => {\n if (!live) return;\n setResolved(list);\n const built = buildMenuModel(target, list, { ...(ports.i18n ? { i18n: ports.i18n } : {}), content: optionsRef.current.content ?? null, contentLabel: optionsRef.current.contentLabel ?? null });\n setModel((prev) => (prev ? carryOpenedModel(prev, built, opened.current) : built));\n for (const { action } of list) {\n if (opened.current.has(action.id) && action.expand) void expandAction(action, action.id);\n }\n });\n return () => {\n live = false;\n };\n }, [registry, ports, target, active, tick, options.revision, expandAction]);\n\n // Live toggles (read-aloud, thumbs): re-resolve when an action's store\n // changes. Subscriptions are keyed by the resolved ids (not the array, which\n // every resolve replaces) and a notify fired synchronously INSIDE subscribe\n // (a store's hydration read) is ignored — otherwise subscribe → notify →\n // resolve → resubscribe never ends.\n const resolvedRef = React.useRef(resolved);\n resolvedRef.current = resolved;\n const subscribedIds = resolved.map((r) => r.action.id).join(\"\\n\");\n React.useEffect(() => {\n if (!target) return;\n let subscribing = true;\n const onChange = () => {\n if (!subscribing) setTick((t) => t + 1);\n };\n const offs = resolvedRef.current\n .map((r) => r.action.subscribe?.(onChange, target))\n .filter((off): off is () => void => typeof off === \"function\");\n subscribing = false;\n return () => offs.forEach((off) => off());\n }, [subscribedIds, target]);\n\n const findAction = React.useCallback(\n (id: string): Action | undefined => resolved.find((r) => r.action.id === id)?.action ?? expanded.current.get(id) ?? undefined,\n [resolved],\n );\n\n const run = React.useCallback(\n async (nodeId: string) => {\n if (!target || !model) return null;\n const node = model.sections.map((s) => findNode(s.nodes, nodeId)).find(Boolean) ?? null;\n const action = findAction(node && \"actionId\" in node && node.actionId ? node.actionId : nodeId);\n if (!action) return null;\n const o = optionsRef.current;\n const result = await runAction(action, target, {\n ports,\n ...(o.source ? { source: o.source } : {}),\n ...(o.contentFingerprint ? { contentFingerprint: o.contentFingerprint } : {}),\n });\n o.onRan?.(nodeId, result, { keepOpen: Boolean(action.keepsMenuOpen) });\n return result;\n },\n [target, model, findAction, ports],\n );\n\n const expand = React.useCallback(\n async (nodeId: string) => {\n const action = findAction(nodeId);\n if (!target || !action?.expand) return;\n // Remembered so late resolver data (a re-resolve) re-opens it, at any depth.\n opened.current.add(nodeId);\n await expandAction(action, nodeId);\n },\n [findAction, target, expandAction],\n );\n\n const icon = React.useCallback(\n (key: string | undefined, tone?: string): React.ReactNode => {\n if (!key || !ports.icons) return null;\n const Resolved = ports.icons.resolve(key) as React.ComponentType<{ className?: string; \"aria-hidden\"?: boolean }> | null;\n return Resolved ? <Resolved className={`h-4 w-4 shrink-0 ${tone ?? \"\"}`} aria-hidden /> : null;\n },\n [ports.icons],\n );\n\n const explain = React.useCallback(\n (sentence: string) => {\n if (ports.notify) ports.notify.info(sentence);\n else ports.diagnostics.capture(new Error(`No notify port to explain: ${sentence}`), { area: \"menu\", detail: { sentence } });\n },\n [ports],\n );\n\n return { model, resolved, run, expand, icon, explain };\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * PROJECTION BEFORE PROVIDERS (CONTRACT §2.4).\n *\n * The only place a raw read (`MountedSurface.readValues`,\n * `InternalResolvedItem.readValues`) is consumed on behalf of an action.\n * What leaves is projected: a value is kept only when it is DECLARED, its\n * classification is \"ordinary\" and it is exportable. Everything removed is\n * recorded as an omission, so the person and the agent can see what was held\n * back. No caller can relax this.\n */\nimport { resolveSensitivity } from \"../declare/sensitivity\";\nimport type { InternalResolvedItem, MountedSurface } from \"../declare/host\";\nimport type { DeclaredValue, Json, LiveValues, ResolvedSurfaceDeclaration } from \"../declare/types\";\nimport type { ProjectedReads, ReadOmission } from \"./types\";\n\nexport interface ProjectionSource {\n surface: MountedSurface | null;\n declaration: ResolvedSurfaceDeclaration | null;\n item: InternalResolvedItem | null;\n}\n\nfunction toJson(value: unknown): Json | undefined {\n if (value === undefined || typeof value === \"function\" || typeof value === \"symbol\") return undefined;\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return Number.isFinite(value) ? value : null;\n if (typeof value === \"bigint\") return value.toString();\n if (value instanceof Date) return value.toISOString();\n if (Array.isArray(value)) return value.map((v) => toJson(v) ?? null);\n if (typeof value === \"object\") {\n const out: { [key: string]: Json } = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const j = toJson(v);\n if (j !== undefined) out[k] = j;\n }\n return out;\n }\n return undefined;\n}\n\n/** Keep declared, ordinary, exportable values; record every removal. */\nexport function projectValues(\n raw: Record<string, unknown>,\n declared: readonly Pick<DeclaredValue, \"name\" | \"sensitivity\">[],\n pathPrefix = \"\",\n): { values: Record<string, Json>; omissions: ReadOmission[] } {\n const byName = new Map(declared.map((d) => [d.name, d]));\n const values: Record<string, Json> = {};\n const omissions: ReadOmission[] = [];\n for (const [name, value] of Object.entries(raw)) {\n const path = pathPrefix ? `${pathPrefix}.${name}` : name;\n const decl = byName.get(name);\n if (!decl) {\n omissions.push({ path, reason: \"filtered\" });\n continue;\n }\n const sensitivity = resolveSensitivity(decl);\n if (sensitivity.classification !== \"ordinary\") {\n omissions.push({ path, reason: \"excluded\", classification: sensitivity.classification });\n continue;\n }\n if (!sensitivity.exportable) {\n omissions.push({ path, reason: \"excluded\" });\n continue;\n }\n const json = toJson(value);\n if (json === undefined) continue;\n values[name] = json;\n }\n return { values, omissions };\n}\n\nexport function createProjectedReads(source: ProjectionSource): ProjectedReads {\n return {\n async values(signal) {\n if (!source.surface || !source.declaration) return { values: {}, omissions: [] };\n const raw = await source.surface.readValues(signal);\n const screenValues = source.declaration.values;\n return projectValues(raw, screenValues);\n },\n async item(signal) {\n const item = source.item;\n if (!item || !source.declaration) return null;\n const type = source.declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) return { values: {}, omissions: [{ path: item.itemType, reason: \"filtered\" }] };\n const raw = await item.readValues(signal);\n return projectValues(raw, type.values, item.itemType);\n },\n async live(signal): Promise<LiveValues> {\n if (!source.surface?.readLive) return {};\n return source.surface.readLive(signal);\n },\n };\n}\n","/**\n * The one run path (T1e). Every layout runs an action through here, so the\n * sign-in-then-resume rule, projection and failure capture live once.\n */\nimport type { TransferOutcome } from \"@ai-matrx/kit/content-transfer\";\nimport type { AlchemyHostPorts } from \"../ports\";\nimport { createProjectedReads, type ProjectionSource } from \"./projection\";\nimport type { Action, ClickTarget } from \"./types\";\n\nexport interface RunActionOptions {\n ports: AlchemyHostPorts;\n /** Raw sources; projected before the action sees them. */\n source?: ProjectionSource;\n /** Stable fingerprint of the content, for sign-in-then-resume. */\n contentFingerprint?: string;\n signal?: AbortSignal;\n}\n\nexport type RunResult =\n | { status: \"ran\"; outcome: TransferOutcome | void }\n | { status: \"auth-pending\" }\n | { status: \"failed\"; error: unknown };\n\nexport async function runAction(action: Action, target: ClickTarget, options: RunActionOptions): Promise<RunResult> {\n const { ports } = options;\n if (action.requiresAuth && !target.auth.authenticated) {\n if (!ports.auth) {\n // Unreachable through resolve (the action is absent without the port); guard direct callers.\n ports.diagnostics.capture(new Error(`requiresAuth action \"${action.id}\" ran signed out with no auth port`), {\n area: \"actions\",\n detail: { actionId: action.id },\n });\n return { status: \"failed\", error: new Error(\"sign-in unavailable\") };\n }\n ports.auth.signInThenResume({ actionId: action.id, contentFingerprint: options.contentFingerprint ?? action.id });\n return { status: \"auth-pending\" };\n }\n const reads = createProjectedReads(options.source ?? { surface: null, declaration: target.declaration, item: null });\n const signal = options.signal ?? new AbortController().signal;\n try {\n const outcome = await action.run(target, { reads, ports, signal });\n return { status: \"ran\", outcome };\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"actions\", detail: { actionId: action.id, stage: \"run\" } });\n const label = typeof action.label === \"string\" ? action.label : action.id;\n ports.notify?.error(`${label} did not finish.`, \"Try again; if it keeps failing, report it from the feedback button.\");\n return { status: \"failed\", error };\n }\n}\n","/**\n * THE ONE APPROVED-HEADING LIST (ALC-15, chair rulings 7 and D1; the Lossless\n * Law and the vocabulary law). A heading a person sees above or around rows\n * must be a name the classic menus used before agents started coining names.\n *\n * 🚨 ADDING A HEADING TO THIS LIST IS ARMAN'S CALL — never an agent's.\n *\n * Two kinds of section heading exist:\n * - a GROUP heading (\"Copy as\", \"History\"): must be in APPROVED_HEADINGS;\n * - a TARGET label, the thing the person clicked, supplied by the surface at\n * run time (\"Cell · Visit date\", \"Row · Widget A\", \"This finding\", the\n * surface's own label): allowed as declared (`section.kind: \"target\"`, or\n * the \"<Target> · <name>\" shape), except a generic container word.\n * A generic container word (\"More…\", \"Other\", \"Actions\") is never a heading.\n * An unapproved heading renders its rows INLINE in production; in development\n * and tests `buildMenuModel` throws with the remedy.\n */\nimport type { MenuModel, MenuNode } from \"./types\";\n\n/** Names with their provenance (the commit where each classic menu used them). */\nexport const APPROVED_HEADINGS: ReadonlySet<string> = new Set([\n \"Save\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Copy as\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Export\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Edit\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Creator tools\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Admin\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"App\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Compare\", // rich-document menuStructure, 2e3a8a9fdf (2026-06-11)\n \"History\", // context-menu-v3 tiered layout — the one grouping Arman approved, 2026-08-22\n]);\n\n// Ruling (chair, 2026-09-26, per R26): \"Conversation\" is a TARGET label (`kind: \"target\"`) — it names the thing its rows act on (the whole conversation), like \"Cell · …\" and \"Table · …\"; it is not a group heading and is not added above.\n\nconst CONTAINER_WORD =\n /^(more|more…|more\\.\\.\\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i;\n\n/** \"Cell · Visit date\", \"Row · Widget A\", \"Column · Price\", \"Table · Route sheet\". */\nconst TARGET_SHAPE = /^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;\n\nexport function isContainerWord(label: string): boolean {\n return CONTAINER_WORD.test(label.trim());\n}\n\nexport type HeadingKind = \"group\" | \"target\";\n\n/** Is this heading allowed? */\nexport function isApprovedHeading(label: string, kind: HeadingKind = \"group\", approved: ReadonlySet<string> = APPROVED_HEADINGS): boolean {\n const l = label.trim();\n if (!l || isContainerWord(l)) return false;\n if (approved.has(l)) return true;\n return kind === \"target\" || TARGET_SHAPE.test(l);\n}\n\nexport type HeadingPolicy = \"throw\" | \"inline\";\n\n/** Development and tests throw; production shows the rows inline. */\nexport function defaultHeadingPolicy(): HeadingPolicy {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.NODE_ENV;\n return env === \"production\" ? \"inline\" : \"throw\";\n}\n\nexport class UnapprovedHeadingError extends Error {\n readonly heading: string;\n constructor(heading: string, where: string) {\n super(\n `Menu heading \"${heading}\" (${where}) is not an approved heading. Remedy: show these rows inline — declare no section ` +\n `(or kind \"target\" for the clicked thing's own label) — or ask Arman to add the name to APPROVED_HEADINGS in ` +\n `@ai-matrx/alchemy/menu. A generic container word (\"More…\", \"Other\") is never approved.`,\n );\n this.name = \"UnapprovedHeadingError\";\n this.heading = heading;\n }\n}\n\n/** Every heading in a model: section labels, folds, and submenu rows at any depth. */\nexport function menuHeadings(model: Pick<MenuModel, \"sections\">): string[] {\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind === \"submenu\") {\n out.push(n.label);\n walk(n.children);\n }\n }\n };\n for (const s of model.sections) {\n if (s.label) out.push(s.label);\n walk(s.nodes);\n }\n return [...new Set(out)];\n}\n\n/** Section headings not in the approved set (container words are never approved). */\nexport function unapprovedHeadings(model: Pick<MenuModel, \"sections\">, approved: ReadonlySet<string> = APPROVED_HEADINGS): string[] {\n const out = new Set<string>();\n for (const s of model.sections) {\n if (s.label && !isApprovedHeading(s.label, s.primary || s.target ? \"target\" : \"group\", approved)) out.add(s.label);\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) if (n.kind === \"submenu\") {\n if (isContainerWord(n.label)) out.add(n.label);\n walk(n.children);\n }\n };\n walk(s.nodes);\n }\n return [...out];\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { Action, ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\nimport { UnapprovedHeadingError, defaultHeadingPolicy, isApprovedHeading, isContainerWord, type HeadingPolicy } from \"./headings\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n applet: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"applet\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n /** What an unapproved heading does: \"throw\" (development/tests) or \"inline\" (production). */\n headingPolicy?: HeadingPolicy;\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n /**\n * The name of the field the content is (a text box's label, \"Body\"). The\n * header then names the field — never \"Content: {{reply.body}}\", its raw text.\n */\n contentLabel?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n ...(action.pending?.(target) ? { pending: true } : {}),\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(action.keepsMenuOpen ? { keepsMenuOpen: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" || eligibility.status === \"unavailable\"\n ? { unavailable: { sentence: eligibility.sentence } }\n : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n // THE ONE HEADING CHECK, for every host: an unapproved heading's rows go\n // inline (production) or the build throws with the remedy (dev/tests).\n const policy = options.headingPolicy ?? defaultHeadingPolicy();\n resolved = resolved.map((r) => {\n const sec = r.action.section;\n if (r.action.expand && isContainerWord(typeof r.action.label === \"string\" ? r.action.label : \"\") && policy === \"throw\") {\n throw new UnapprovedHeadingError(r.action.label as string, `submenu of ${r.action.id}`);\n }\n if (!sec) return r;\n const kind = sec.kind ?? (sec.primary ? \"target\" : \"group\");\n if (isApprovedHeading(sec.label, kind)) return r;\n if (policy === \"throw\") throw new UnapprovedHeadingError(sec.label, `section of ${r.action.id}`);\n const { section: _dropped, ...rest } = r.action;\n return { ...r, action: rest };\n });\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n ...(sec && (sec.kind ?? (sec.primary ? \"target\" : \"group\")) === \"target\" ? { target: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n if (row.action.startsGroup && section.nodes.length > 0) {\n section.nodes.push({ kind: \"separator\", id: `${row.action.id}:group` });\n }\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const fieldName = options.contentLabel?.trim();\n const header = selected\n ? { label: \"Selected\", text: target.selection?.text ?? \"\" }\n : fieldName\n ? { label: fieldName, text: options.content ?? \"\" }\n : content\n ? { label: \"Content\", text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\n/**\n * AN EXPANDED SUBMENU KEEPS ITS GROUPS (DATA-V2-BASICS-2, 2026-09-28). A provider's rows arrive flat,\n * so a submenu drew \"Highlight row\" and \"Delete row…\" as neighbours with no divider, while the same\n * rows in a top-level menu sit in their sections. A divider now goes wherever the rows' `section`\n * changes — a row with no section and a row with one are different groups too.\n */\nexport function withGroupDividers(children: readonly Action[], nodes: readonly MenuNode[]): MenuNode[] {\n const out: MenuNode[] = [];\n children.forEach((child, i) => {\n const node = nodes[i];\n if (!node) return;\n if (i > 0 && (child.startsGroup || (children[i - 1]!.section?.id ?? null) !== (child.section?.id ?? null))) {\n out.push({ kind: \"separator\", id: `${child.id}:group` });\n }\n out.push(node);\n });\n return out;\n}\n\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, pending: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * The shared React context (T0-safe: imports only React and types). Shared\n * through globalThis so every per-layout bundle reads the same provider.\n */\nimport * as React from \"react\";\nimport type { ActionRegistry } from \"../actions/types\";\nimport type { AlchemyHostPorts } from \"../ports\";\n\nexport interface AlchemyActionsValue {\n registry: ActionRegistry;\n ports: AlchemyHostPorts;\n}\n\nconst KEY = Symbol.for(\"ai-matrx.alchemy.actions-context\");\ntype Holder = { [KEY]?: React.Context<AlchemyActionsValue | null> };\nexport const AlchemyActionsContext: React.Context<AlchemyActionsValue | null> =\n ((globalThis as Holder)[KEY] ??= React.createContext<AlchemyActionsValue | null>(null));\n\nexport function useAlchemyActions(): AlchemyActionsValue {\n const value = React.useContext(AlchemyActionsContext);\n if (!value) throw new Error(\"Alchemy actions: render inside <AlchemyActionsProvider> (@ai-matrx/alchemy/react/host).\");\n return value;\n}\n\n/**\n * The registry + ports when rendered inside `<AlchemyActionsProvider>`, else null. For callers that\n * must never crash a render outside the host (a kind component, an assist chip, a bare test render):\n * they answer honestly (\"actions aren't available here\") instead of throwing.\n */\nexport function useOptionalAlchemyActions(): AlchemyActionsValue | null {\n return React.useContext(AlchemyActionsContext);\n}\n","/**\n * The completion of an expansion belongs to both the target that started it\n * and that node's most recent request. Either identity changing makes a late\n * result stale.\n */\nexport function isLatestExpansion(\n capturedTargetEpoch: number,\n currentTargetEpoch: number,\n capturedNodeSequence: number,\n currentNodeSequence: number | undefined,\n): boolean {\n return capturedTargetEpoch === currentTargetEpoch && capturedNodeSequence === currentNodeSequence;\n}\n","\"use client\";\n/**\n * While a layout is SEARCHING, every lazy submenu it can see is opened, so the\n * filter walks real rows instead of a library's label (clone 2026-10-01:\n * \"Patient\" found nothing while \"Patient reminder card\" sat two lazy levels\n * down under AI Actions ▸ My Personal). Nested submenus open as their parents'\n * rows arrive. Re-run on every model: a re-resolve rebuilds the model and a\n * nested submenu comes back lazy.\n */\nimport * as React from \"react\";\nimport { lazySubmenuIds } from \"../menu/layouts\";\nimport type { MenuEngine } from \"./engine\";\n\nexport function useSearchOpensLibraries(engine: MenuEngine, searching: boolean): void {\n const { model, expand } = engine;\n React.useEffect(() => {\n if (!searching) return;\n for (const id of lazySubmenuIds(model)) void expand(id);\n }, [searching, model, expand]);\n}\n"],"mappings":";y5BAAA,kJCMA,yBAAkG,mCCiClG,SAAS,OAAO,KAAsC,CACpD,OAAO,KAAK,OAAS,QAAU,KAAK,OAAS,YAAc,KAAK,OAAS,MAC3E,CAsOO,SAAS,QAAQ,MAAmC,CACzD,IAAM,OAAoC,CAAC,EACrC,KAAO,CAAC,MAA4B,QAAoB,CAC5D,QAAW,KAAK,MACV,OAAO,CAAC,EAAG,OAAO,KAAK,CAAE,KAAM,EAAG,WAAY,KAAM,CAAC,EAChD,EAAE,OAAS,YACd,EAAE,KAAM,OAAO,KAAK,CAAE,KAAM,EAAG,WAAY,KAAM,CAAC,EACjD,KAAK,EAAE,SAAU,CAAC,GAAG,MAAO,EAAE,KAAK,CAAC,EAG/C,EACA,QAAW,KAAK,MAAM,SAAU,KAAK,EAAE,MAAO,EAAE,MAAQ,CAAC,EAAE,KAAK,EAAI,CAAC,CAAC,EACtE,MAAO,CAAE,MAAO,CAClB,CASO,SAAS,eAAe,MAAmC,CAChE,GAAI,CAAC,MAAO,MAAO,CAAC,EACpB,IAAM,IAAgB,CAAC,EACjB,KAAQ,OAA+B,CAC3C,QAAW,KAAK,MACV,EAAE,OAAS,YACX,EAAE,KACC,EAAE,SAAS,IAAI,KAAK,EAAE,EAAE,EACxB,KAAK,EAAE,QAAQ,EAE1B,EACA,QAAW,KAAK,MAAM,SAAU,KAAK,EAAE,KAAK,EAC5C,OAAO,GACT,CCxSA,IAAAA,OAAuB,4BCHhB,IAAM,oBAAmC,OAAO,OAAO,CAC5D,WAAY,GACZ,eAAgB,WAChB,kBAAmB,EACrB,CAAC,EAEM,SAAS,mBAAmB,MAAw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D,SACE,0BAAC,kCAEC,MAAO,GAAG,KAAK,KAAK,IAAI,WAAW,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,GACvD,oBAAmB,KAAK,GACxB,SAAU,EAAQ,YAClB,SAAU,IAAM,CACV,KAAK,OAAS,UAAgB,OAAO,OAAO,KAAK,EAAE,EAC9C,KAAK,OAAS,OAAQ,OAAO,SAAS,OAAO,KAAK,IAAI,EACrD,OAAO,IAAI,KAAK,EAAE,CAC9B,EACA,UAAU,QAET,mBAAU,KAAO,OAAO,KAAK,KAAK,IAAI,EAAI,QAC3C,yBAAC,QAAK,UAAU,kBAAmB,cAAK,MAAM,KAC9C,yBAAC,QAAK,UAAU,gCACb,qBAAc,YAAY,SAAW,KAAK,OAAS,WAAa,KAAK,QAAU,gBAAa,WAAW,KAAK,UAAK,EACpH,IAfK,KAAK,EAgBZ,CAEJ,CAAC,EACH,GACF,GACF,CAEJ","names":["React","React","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../src/react-palette.ts","../src/react/palette.tsx","../src/menu/layouts.ts","../src/react/engine.tsx","../src/declare/sensitivity.ts","../src/actions/projection.ts","../src/actions/run.ts","../src/menu/headings.ts","../src/menu/model.ts","../src/react/context.ts","../src/react/expansion-latest.ts","../src/react/search-opens-libraries.ts"],"sourcesContent":["/** `@ai-matrx/alchemy/react/palette` — the command palette layout. */\nexport { ActionPalette, type ActionPaletteProps } from \"./react/palette\";\n","\"use client\";\n/**\n * `@ai-matrx/alchemy/react/palette` — the command palette layout (Linear):\n * every leaf of the one model, flattened with its breadcrumb, type to filter.\n */\nimport * as React from \"react\";\nimport { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"@ai-matrx/design-system\";\nimport { palette } from \"../menu/layouts\";\nimport type { ClickTarget } from \"../actions/types\";\nimport { useMenuEngine, type MenuEngineOptions } from \"./engine\";\nimport { useSearchOpensLibraries } from \"./search-opens-libraries\";\n\nexport interface ActionPaletteProps extends MenuEngineOptions {\n target: ClickTarget;\n open: boolean;\n onOpenChange(open: boolean): void;\n placeholder?: string;\n}\n\nexport function ActionPalette({ target, open, onOpenChange, placeholder = \"Search actions…\", ...options }: ActionPaletteProps): React.ReactElement {\n const engine = useMenuEngine(target, {\n ...options,\n active: open,\n onRan: (id, r, ran) => {\n options.onRan?.(id, r, ran);\n // An in-place reload (Retry) keeps the layout open on the rows it reloads.\n if (!ran?.keepOpen) onOpenChange(false);\n },\n });\n // A palette IS a search: every lazy library opens so its rows are findable.\n useSearchOpensLibraries(engine, open);\n const arranged = engine.model ? palette(engine.model) : { leaves: [] };\n return (\n <CommandDialog open={open} onOpenChange={onOpenChange}>\n <CommandInput placeholder={placeholder} />\n <CommandList data-alchemy-layout=\"palette\">\n <CommandEmpty>No action matches.</CommandEmpty>\n <CommandGroup>\n {arranged.leaves.map(({ node, breadcrumb }) => {\n const unavailable = node.kind === \"item\" ? node.unavailable : undefined;\n return (\n <CommandItem\n key={node.id}\n value={`${node.label} ${breadcrumb.join(\" \")} ${node.id}`}\n data-alchemy-node={node.id}\n disabled={Boolean(unavailable)}\n onSelect={() => {\n if (node.kind === \"submenu\") void engine.expand(node.id);\n else if (node.kind === \"link\") window.location.assign(node.href);\n else void engine.run(node.id);\n }}\n className=\"gap-2\"\n >\n {\"icon\" in node ? engine.icon(node.icon) : null}\n <span className=\"flex-1 truncate\">{node.label}</span>\n <span className=\"text-xs text-muted-foreground\">\n {unavailable ? unavailable.sentence : node.kind === \"submenu\" && node.pending ? \"Loading…\" : breadcrumb.join(\" › \")}\n </span>\n </CommandItem>\n );\n })}\n </CommandGroup>\n </CommandList>\n </CommandDialog>\n );\n}\n\nexport default ActionPalette;\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n // A section keeps its declared heading in EVERY layout (the Lossless\n // Law covers headings: ⋯, the bar's ⋯ and the phone sheet show it too).\n sections.push(s);\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * FOLD UNDER THE SUBJECT — a control that belongs to a CONTAINER of the thing\n * (a tab's \"…\" over the note it shows) draws the container's own rows (the\n * primary sections) on top, and EVERY other row — the verb strip included —\n * under ONE submenu named for the subject (\"Note ▸\"). The label is the\n * subject's name the host supplies (the menu header's label), never a coined\n * group heading. Lossless: rows move, none is dropped or renamed. With no\n * primary section there is nothing to put first, so the arrangement is left\n * as it was. (page-pass /notes, 2026-09-28, Arman's ruling for the tab \"…\".)\n */\nexport function foldUnderSubject(arranged: ArrangedContext, subject: string): ArrangedContext {\n const label = subject.trim();\n const primary = arranged.sections.filter((s) => s.primary);\n const rest = arranged.sections.filter((s) => !s.primary);\n if (!label || primary.length === 0 || (rest.length === 0 && arranged.strip.length === 0)) return arranged;\n const children: MenuNode[] = [];\n if (arranged.strip.length) children.push(...arranged.strip);\n for (const s of rest) {\n if (rowCount(s.nodes) === 0) continue;\n if (children.length) children.push({ kind: \"separator\", id: `${s.id}:subject-sep` });\n if (s.label) children.push({ kind: \"label\", id: `${s.id}:subject-label`, label: s.label });\n children.push(...s.nodes);\n }\n if (rowCount(children) === 0) return { ...arranged, strip: [] };\n return {\n strip: [],\n filterable: false,\n sections: [\n ...primary,\n { id: \"subject\", group: rest[0]?.group ?? primary[0]!.group, nodes: [{ kind: \"submenu\", id: \"subject:fold\", label, children }] },\n ],\n };\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/**\n * A SEARCH REACHES EVERY ROW (clone 2026-10-01: \"Patient\" found nothing while\n * \"Patient reminder card\" sat under AI Actions ▸ My Personal). `palette` lists a\n * lazy submenu as ONE leaf — its label only — because its rows load on open.\n * A layout that searches opens every lazy submenu it can see: these are the\n * ones still to open (not already loading).\n */\nexport function lazySubmenuIds(model: MenuModel | null): string[] {\n if (!model) return [];\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind !== \"submenu\") continue;\n if (n.lazy) {\n if (!n.loading) out.push(n.id);\n } else walk(n.children);\n }\n };\n for (const s of model.sections) walk(s.nodes);\n return out;\n}\n\n/** True while some submenu's rows are not in the model yet (a search could still find more). */\nexport function paletteStillOpening(model: MenuModel | null): boolean {\n if (!model) return true;\n const walk = (nodes: readonly MenuNode[]): boolean =>\n nodes.some((n) => n.kind === \"submenu\" && (n.lazy || n.loading || n.pending || walk(n.children)));\n return model.sections.some((s) => walk(s.nodes));\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","\"use client\";\n/**\n * The React half of T1e: one hook every renderer uses to resolve the registry\n * at a target, build the model and run a node. Handlers never live in a\n * renderer — they live in providers and run through `runAction`.\n *\n * The context object is shared through globalThis so every per-layout entry\n * (each bundled separately) reads the same provider (module state is banned\n * across dual-loader graphs).\n */\nimport * as React from \"react\";\nimport { runAction, type RunResult } from \"../actions/run\";\nimport type { ProjectionSource } from \"../actions/projection\";\nimport type { Action, ClickTarget, ResolveRestriction, ResolvedAction } from \"../actions/types\";\nimport { actionToNode, buildMenuModel, findNode, withExpandedChildren, withGroupDividers } from \"../menu/model\";\nimport type { MenuModel, MenuNode } from \"../menu/types\";\nimport { useAlchemyActions } from \"./context\";\nimport { isLatestExpansion } from \"./expansion-latest\";\n\nexport interface MenuEngineOptions {\n restrict?: ResolveRestriction;\n /** Raw sources for projection (the host's mounted surface / clicked item). */\n source?: ProjectionSource;\n /** Content the menu acts on when nothing is selected (header text). */\n content?: string | null;\n /** The field's name, when the content is a field's text (see buildMenuModel). */\n contentLabel?: string | null;\n contentFingerprint?: string;\n /**\n * Called after a node ran (close the menu, announce). `keepOpen` is true for a row that reloads\n * the menu it sits in (`Action.keepsMenuOpen`): a layout never closes on it.\n */\n onRan?: (nodeId: string, result: RunResult, ran?: { keepOpen: boolean }) => void;\n /** Resolve only while true (renderers resolve on open). Default true. */\n active?: boolean;\n /**\n * Re-resolve when this changes even if the target object is the same (a\n * host that keeps one target per mount and reads live state through it).\n */\n revision?: string | number;\n}\n\nexport interface MenuEngine {\n model: MenuModel | null;\n resolved: readonly ResolvedAction[];\n run(nodeId: string): Promise<RunResult | null>;\n expand(nodeId: string): Promise<void>;\n /** The host's glyph for a key; `tone` is the action's colour class (iconTone). */\n icon(key: string | undefined, tone?: string): React.ReactNode;\n /** Say why a greyed verb is greyed (a tap on touch, where tooltips never open). */\n explain(sentence: string): void;\n}\n\nfunction nodeInModel(model: MenuModel, id: string): MenuNode | null {\n for (const s of model.sections) {\n const hit = findNode(s.nodes, id);\n if (hit) return hit;\n }\n return null;\n}\n\nfunction hasLoadedRows(model: MenuModel, id: string): boolean {\n const n = nodeInModel(model, id);\n return Boolean(n && n.kind === \"submenu\" && !n.lazy && !n.loading);\n}\n\nfunction loadedChildren(model: MenuModel, id: string): readonly MenuNode[] {\n const n = nodeInModel(model, id);\n return n && n.kind === \"submenu\" && !n.lazy ? n.children : [];\n}\n\n/**\n * The rebuilt rows, with every OPENED submenu that came back lazy keeping the\n * rows it last showed (its re-expansion replaces them when it lands).\n */\nexport function carryOpened(prev: readonly MenuNode[], next: MenuNode[], opened: ReadonlySet<string>): MenuNode[] {\n return next.map((n) => {\n if (n.kind !== \"submenu\") return n;\n const old = prev.find((o) => o.id === n.id);\n if (!old || old.kind !== \"submenu\" || old.lazy) return n;\n if (n.lazy) {\n return opened.has(n.id) ? { ...n, lazy: false, loading: false, pending: false, children: old.children } : n;\n }\n return { ...n, children: carryOpened(old.children, n.children, opened) };\n });\n}\n\nfunction carryOpenedModel(prev: MenuModel, next: MenuModel, opened: ReadonlySet<string>): MenuModel {\n if (opened.size === 0) return next;\n const prevNodes = prev.sections.flatMap((s) => s.nodes);\n return { ...next, sections: next.sections.map((s) => ({ ...s, nodes: carryOpened(prevNodes, s.nodes, opened) })) };\n}\n\nexport function useMenuEngine(target: ClickTarget | null, options: MenuEngineOptions = {}): MenuEngine {\n const { registry, ports } = useAlchemyActions();\n const [resolved, setResolved] = React.useState<readonly ResolvedAction[]>([]);\n const [model, setModel] = React.useState<MenuModel | null>(null);\n const [tick, setTick] = React.useState(0);\n // Every action an expansion returned, by id (a nested row is found here).\n const expanded = React.useRef(new Map<string, Action>());\n // Every submenu the person (or a search) opened, at ANY depth. A re-resolve\n // rebuilds the model with each of them lazy again; these are re-opened, and\n // their last rows are carried over meanwhile so an open submenu never blanks.\n const opened = React.useRef(new Set<string>());\n const expandSeq = React.useRef(new Map<string, number>());\n const targetEpoch = React.useRef(0);\n const currentTarget = React.useRef(target);\n if (currentTarget.current !== target) {\n currentTarget.current = target;\n targetEpoch.current += 1;\n }\n const active = options.active ?? true;\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n React.useEffect(() => registry.subscribe(() => setTick((t) => t + 1)), [registry]);\n\n const expandAction = React.useCallback(\n async (action: Action, nodeId: string) => {\n if (!target || !action.expand) return;\n const epoch = targetEpoch.current;\n const seq = (expandSeq.current.get(nodeId) ?? 0) + 1;\n expandSeq.current.set(nodeId, seq);\n const latest = () => isLatestExpansion(epoch, targetEpoch.current, seq, expandSeq.current.get(nodeId));\n // \"Loading…\" only over a submenu with no rows yet: a refresh keeps the\n // rows on screen until the new ones land (a blank flash unmounts the\n // focused row and Radix closes the parent submenu under the pointer).\n setModel((m) => (m && !hasLoadedRows(m, nodeId) ? withExpandedChildren(m, nodeId, \"loading\") : m));\n try {\n // A programmatic-only Action (surfaces without \"menu\") never becomes a row, even inside a submenu.\n const children = (await action.expand(target, new AbortController().signal)).filter(\n (child) => !child.surfaces || child.surfaces.includes(\"menu\"),\n );\n if (!latest()) return;\n const nodes: MenuNode[] = withGroupDividers(\n children,\n children.map((child) => {\n expanded.current.set(child.id, child);\n return actionToNode({ action: child, eligibility: { status: \"available\" } }, target, ports.i18n ? { i18n: ports.i18n } : {});\n }),\n );\n setModel((m) => (m ? withExpandedChildren(m, nodeId, carryOpened(loadedChildren(m, nodeId), nodes, opened.current)) : m));\n // A nested submenu that was open stays open: re-open it under its new parent rows.\n for (const child of children) if (child.expand && opened.current.has(child.id)) void expandAction(child, child.id);\n } catch (error) {\n if (!latest()) return;\n ports.diagnostics.capture(error, { area: \"menu\", detail: { nodeId, stage: \"expand\" } });\n setModel((m) => (m ? withExpandedChildren(m, nodeId, []) : m));\n }\n },\n [target, ports],\n );\n\n React.useEffect(() => {\n expanded.current.clear();\n opened.current.clear();\n }, [target]);\n\n React.useEffect(() => {\n if (!target || !active) return;\n let live = true;\n void registry.resolve(target, optionsRef.current.restrict).then((list) => {\n if (!live) return;\n setResolved(list);\n const built = buildMenuModel(target, list, { ...(ports.i18n ? { i18n: ports.i18n } : {}), content: optionsRef.current.content ?? null, contentLabel: optionsRef.current.contentLabel ?? null });\n setModel((prev) => (prev ? carryOpenedModel(prev, built, opened.current) : built));\n for (const { action } of list) {\n if (opened.current.has(action.id) && action.expand) void expandAction(action, action.id);\n }\n });\n return () => {\n live = false;\n };\n }, [registry, ports, target, active, tick, options.revision, expandAction]);\n\n // Live toggles (read-aloud, thumbs): re-resolve when an action's store\n // changes. Subscriptions are keyed by the resolved ids (not the array, which\n // every resolve replaces) and a notify fired synchronously INSIDE subscribe\n // (a store's hydration read) is ignored — otherwise subscribe → notify →\n // resolve → resubscribe never ends.\n const resolvedRef = React.useRef(resolved);\n resolvedRef.current = resolved;\n const subscribedIds = resolved.map((r) => r.action.id).join(\"\\n\");\n React.useEffect(() => {\n if (!target) return;\n let subscribing = true;\n const onChange = () => {\n if (!subscribing) setTick((t) => t + 1);\n };\n const offs = resolvedRef.current\n .map((r) => r.action.subscribe?.(onChange, target))\n .filter((off): off is () => void => typeof off === \"function\");\n subscribing = false;\n return () => offs.forEach((off) => off());\n }, [subscribedIds, target]);\n\n const findAction = React.useCallback(\n (id: string): Action | undefined => resolved.find((r) => r.action.id === id)?.action ?? expanded.current.get(id) ?? undefined,\n [resolved],\n );\n\n const run = React.useCallback(\n async (nodeId: string) => {\n if (!target || !model) return null;\n const node = model.sections.map((s) => findNode(s.nodes, nodeId)).find(Boolean) ?? null;\n const action = findAction(node && \"actionId\" in node && node.actionId ? node.actionId : nodeId);\n if (!action) return null;\n const o = optionsRef.current;\n const result = await runAction(action, target, {\n ports,\n ...(o.source ? { source: o.source } : {}),\n ...(o.contentFingerprint ? { contentFingerprint: o.contentFingerprint } : {}),\n });\n o.onRan?.(nodeId, result, { keepOpen: Boolean(action.keepsMenuOpen) });\n return result;\n },\n [target, model, findAction, ports],\n );\n\n const expand = React.useCallback(\n async (nodeId: string) => {\n const action = findAction(nodeId);\n if (!target || !action?.expand) return;\n // Remembered so late resolver data (a re-resolve) re-opens it, at any depth.\n opened.current.add(nodeId);\n await expandAction(action, nodeId);\n },\n [findAction, target, expandAction],\n );\n\n const icon = React.useCallback(\n (key: string | undefined, tone?: string): React.ReactNode => {\n if (!key || !ports.icons) return null;\n const Resolved = ports.icons.resolve(key) as React.ComponentType<{ className?: string; \"aria-hidden\"?: boolean }> | null;\n return Resolved ? <Resolved className={`h-4 w-4 shrink-0 ${tone ?? \"\"}`} aria-hidden /> : null;\n },\n [ports.icons],\n );\n\n const explain = React.useCallback(\n (sentence: string) => {\n if (ports.notify) ports.notify.info(sentence);\n else ports.diagnostics.capture(new Error(`No notify port to explain: ${sentence}`), { area: \"menu\", detail: { sentence } });\n },\n [ports],\n );\n\n return { model, resolved, run, expand, icon, explain };\n}\n","/**\n * Sensitivity defaults and resolution (CONTRACT §2.1). Its own module so the\n * lightweight entries (`/actions`, the T0 React host) can project without\n * pulling the declaration registry.\n */\nimport type { DeclaredValue, Sensitivity } from \"./types\";\n\nexport const DEFAULT_SENSITIVITY: Sensitivity = Object.freeze({\n exportable: true,\n classification: \"ordinary\",\n includedByDefault: true,\n});\n\nexport function resolveSensitivity(value: Pick<DeclaredValue, \"sensitivity\">): Sensitivity {\n return {\n exportable: value.sensitivity?.exportable ?? DEFAULT_SENSITIVITY.exportable,\n classification: value.sensitivity?.classification ?? DEFAULT_SENSITIVITY.classification,\n includedByDefault: value.sensitivity?.includedByDefault ?? DEFAULT_SENSITIVITY.includedByDefault,\n };\n}\n","/**\n * PROJECTION BEFORE PROVIDERS (CONTRACT §2.4).\n *\n * The only place a raw read (`MountedSurface.readValues`,\n * `InternalResolvedItem.readValues`) is consumed on behalf of an action.\n * What leaves is projected: a value is kept only when it is DECLARED, its\n * classification is \"ordinary\" and it is exportable. Everything removed is\n * recorded as an omission, so the person and the agent can see what was held\n * back. No caller can relax this.\n */\nimport { resolveSensitivity } from \"../declare/sensitivity\";\nimport type { InternalResolvedItem, MountedSurface } from \"../declare/host\";\nimport type { DeclaredValue, Json, LiveValues, ResolvedSurfaceDeclaration } from \"../declare/types\";\nimport type { ProjectedReads, ReadOmission } from \"./types\";\n\nexport interface ProjectionSource {\n surface: MountedSurface | null;\n declaration: ResolvedSurfaceDeclaration | null;\n item: InternalResolvedItem | null;\n}\n\nfunction toJson(value: unknown): Json | undefined {\n if (value === undefined || typeof value === \"function\" || typeof value === \"symbol\") return undefined;\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return Number.isFinite(value) ? value : null;\n if (typeof value === \"bigint\") return value.toString();\n if (value instanceof Date) return value.toISOString();\n if (Array.isArray(value)) return value.map((v) => toJson(v) ?? null);\n if (typeof value === \"object\") {\n const out: { [key: string]: Json } = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const j = toJson(v);\n if (j !== undefined) out[k] = j;\n }\n return out;\n }\n return undefined;\n}\n\n/** Keep declared, ordinary, exportable values; record every removal. */\nexport function projectValues(\n raw: Record<string, unknown>,\n declared: readonly Pick<DeclaredValue, \"name\" | \"sensitivity\">[],\n pathPrefix = \"\",\n): { values: Record<string, Json>; omissions: ReadOmission[] } {\n const byName = new Map(declared.map((d) => [d.name, d]));\n const values: Record<string, Json> = {};\n const omissions: ReadOmission[] = [];\n for (const [name, value] of Object.entries(raw)) {\n const path = pathPrefix ? `${pathPrefix}.${name}` : name;\n const decl = byName.get(name);\n if (!decl) {\n omissions.push({ path, reason: \"filtered\" });\n continue;\n }\n const sensitivity = resolveSensitivity(decl);\n if (sensitivity.classification !== \"ordinary\") {\n omissions.push({ path, reason: \"excluded\", classification: sensitivity.classification });\n continue;\n }\n if (!sensitivity.exportable) {\n omissions.push({ path, reason: \"excluded\" });\n continue;\n }\n const json = toJson(value);\n if (json === undefined) continue;\n values[name] = json;\n }\n return { values, omissions };\n}\n\nexport function createProjectedReads(source: ProjectionSource): ProjectedReads {\n return {\n async values(signal) {\n if (!source.surface || !source.declaration) return { values: {}, omissions: [] };\n const raw = await source.surface.readValues(signal);\n const screenValues = source.declaration.values;\n return projectValues(raw, screenValues);\n },\n async item(signal) {\n const item = source.item;\n if (!item || !source.declaration) return null;\n const type = source.declaration.itemTypes?.find((t) => t.name === item.itemType);\n if (!type) return { values: {}, omissions: [{ path: item.itemType, reason: \"filtered\" }] };\n const raw = await item.readValues(signal);\n return projectValues(raw, type.values, item.itemType);\n },\n async live(signal): Promise<LiveValues> {\n if (!source.surface?.readLive) return {};\n return source.surface.readLive(signal);\n },\n };\n}\n","/**\n * The one run path (T1e). Every layout runs an action through here, so the\n * sign-in-then-resume rule, projection and failure capture live once.\n */\nimport type { TransferOutcome } from \"@ai-matrx/alchemy/operate\";\nimport type { AlchemyHostPorts } from \"../ports\";\nimport { createProjectedReads, type ProjectionSource } from \"./projection\";\nimport type { Action, ClickTarget } from \"./types\";\n\nexport interface RunActionOptions {\n ports: AlchemyHostPorts;\n /** Raw sources; projected before the action sees them. */\n source?: ProjectionSource;\n /** Stable fingerprint of the content, for sign-in-then-resume. */\n contentFingerprint?: string;\n signal?: AbortSignal;\n}\n\nexport type RunResult =\n | { status: \"ran\"; outcome: TransferOutcome | void }\n | { status: \"auth-pending\" }\n | { status: \"failed\"; error: unknown };\n\nexport async function runAction(action: Action, target: ClickTarget, options: RunActionOptions): Promise<RunResult> {\n const { ports } = options;\n if (action.requiresAuth && !target.auth.authenticated) {\n if (!ports.auth) {\n // Unreachable through resolve (the action is absent without the port); guard direct callers.\n ports.diagnostics.capture(new Error(`requiresAuth action \"${action.id}\" ran signed out with no auth port`), {\n area: \"actions\",\n detail: { actionId: action.id },\n });\n return { status: \"failed\", error: new Error(\"sign-in unavailable\") };\n }\n ports.auth.signInThenResume({ actionId: action.id, contentFingerprint: options.contentFingerprint ?? action.id });\n return { status: \"auth-pending\" };\n }\n const reads = createProjectedReads(options.source ?? { surface: null, declaration: target.declaration, item: null });\n const signal = options.signal ?? new AbortController().signal;\n try {\n const outcome = await action.run(target, { reads, ports, signal });\n return { status: \"ran\", outcome };\n } catch (error) {\n ports.diagnostics.capture(error, { area: \"actions\", detail: { actionId: action.id, stage: \"run\" } });\n const label = typeof action.label === \"string\" ? action.label : action.id;\n ports.notify?.error(`${label} did not finish.`, \"Try again; if it keeps failing, report it from the feedback button.\");\n return { status: \"failed\", error };\n }\n}\n","/**\n * THE ONE APPROVED-HEADING LIST (ALC-15, chair rulings 7 and D1; the Lossless\n * Law and the vocabulary law). A heading a person sees above or around rows\n * must be a name the classic menus used before agents started coining names.\n *\n * 🚨 ADDING A HEADING TO THIS LIST IS ARMAN'S CALL — never an agent's.\n *\n * Two kinds of section heading exist:\n * - a GROUP heading (\"Copy as\", \"History\"): must be in APPROVED_HEADINGS;\n * - a TARGET label, the thing the person clicked, supplied by the surface at\n * run time (\"Cell · Visit date\", \"Row · Widget A\", \"This finding\", the\n * surface's own label): allowed as declared (`section.kind: \"target\"`, or\n * the \"<Target> · <name>\" shape), except a generic container word.\n * A generic container word (\"More…\", \"Other\", \"Actions\") is never a heading.\n * An unapproved heading renders its rows INLINE in production; in development\n * and tests `buildMenuModel` throws with the remedy.\n */\nimport type { MenuModel, MenuNode } from \"./types\";\n\n/** Names with their provenance (the commit where each classic menu used them). */\nexport const APPROVED_HEADINGS: ReadonlySet<string> = new Set([\n \"Save\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Copy as\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Export\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Edit\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Creator tools\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Admin\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"App\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Compare\", // rich-document menuStructure, 2e3a8a9fdf (2026-06-11)\n \"History\", // context-menu-v3 tiered layout — the one grouping Arman approved, 2026-08-22\n]);\n\n// Ruling (chair, 2026-09-26, per R26): \"Conversation\" is a TARGET label (`kind: \"target\"`) — it names the thing its rows act on (the whole conversation), like \"Cell · …\" and \"Table · …\"; it is not a group heading and is not added above.\n\nconst CONTAINER_WORD =\n /^(more|more…|more\\.\\.\\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i;\n\n/** \"Cell · Visit date\", \"Row · Widget A\", \"Column · Price\", \"Table · Route sheet\". */\nconst TARGET_SHAPE = /^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;\n\nexport function isContainerWord(label: string): boolean {\n return CONTAINER_WORD.test(label.trim());\n}\n\nexport type HeadingKind = \"group\" | \"target\";\n\n/** Is this heading allowed? */\nexport function isApprovedHeading(label: string, kind: HeadingKind = \"group\", approved: ReadonlySet<string> = APPROVED_HEADINGS): boolean {\n const l = label.trim();\n if (!l || isContainerWord(l)) return false;\n if (approved.has(l)) return true;\n return kind === \"target\" || TARGET_SHAPE.test(l);\n}\n\nexport type HeadingPolicy = \"throw\" | \"inline\";\n\n/** Development and tests throw; production shows the rows inline. */\nexport function defaultHeadingPolicy(): HeadingPolicy {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.NODE_ENV;\n return env === \"production\" ? \"inline\" : \"throw\";\n}\n\nexport class UnapprovedHeadingError extends Error {\n readonly heading: string;\n constructor(heading: string, where: string) {\n super(\n `Menu heading \"${heading}\" (${where}) is not an approved heading. Remedy: show these rows inline — declare no section ` +\n `(or kind \"target\" for the clicked thing's own label) — or ask Arman to add the name to APPROVED_HEADINGS in ` +\n `@ai-matrx/alchemy/menu. A generic container word (\"More…\", \"Other\") is never approved.`,\n );\n this.name = \"UnapprovedHeadingError\";\n this.heading = heading;\n }\n}\n\n/** Every heading in a model: section labels, folds, and submenu rows at any depth. */\nexport function menuHeadings(model: Pick<MenuModel, \"sections\">): string[] {\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind === \"submenu\") {\n out.push(n.label);\n walk(n.children);\n }\n }\n };\n for (const s of model.sections) {\n if (s.label) out.push(s.label);\n walk(s.nodes);\n }\n return [...new Set(out)];\n}\n\n/** Section headings not in the approved set (container words are never approved). */\nexport function unapprovedHeadings(model: Pick<MenuModel, \"sections\">, approved: ReadonlySet<string> = APPROVED_HEADINGS): string[] {\n const out = new Set<string>();\n for (const s of model.sections) {\n if (s.label && !isApprovedHeading(s.label, s.primary || s.target ? \"target\" : \"group\", approved)) out.add(s.label);\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) if (n.kind === \"submenu\") {\n if (isContainerWord(n.label)) out.add(n.label);\n walk(n.children);\n }\n };\n walk(s.nodes);\n }\n return [...out];\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { Action, ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\nimport { UnapprovedHeadingError, defaultHeadingPolicy, isApprovedHeading, isContainerWord, type HeadingPolicy } from \"./headings\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n applet: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"applet\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n /** What an unapproved heading does: \"throw\" (development/tests) or \"inline\" (production). */\n headingPolicy?: HeadingPolicy;\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n /**\n * The name of the field the content is (a text box's label, \"Body\"). The\n * header then names the field — never \"Content: {{reply.body}}\", its raw text.\n */\n contentLabel?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n ...(action.pending?.(target) ? { pending: true } : {}),\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(action.keepsMenuOpen ? { keepsMenuOpen: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" || eligibility.status === \"unavailable\"\n ? { unavailable: { sentence: eligibility.sentence } }\n : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n // THE ONE HEADING CHECK, for every host: an unapproved heading's rows go\n // inline (production) or the build throws with the remedy (dev/tests).\n const policy = options.headingPolicy ?? defaultHeadingPolicy();\n resolved = resolved.map((r) => {\n const sec = r.action.section;\n if (r.action.expand && isContainerWord(typeof r.action.label === \"string\" ? r.action.label : \"\") && policy === \"throw\") {\n throw new UnapprovedHeadingError(r.action.label as string, `submenu of ${r.action.id}`);\n }\n if (!sec) return r;\n const kind = sec.kind ?? (sec.primary ? \"target\" : \"group\");\n if (isApprovedHeading(sec.label, kind)) return r;\n if (policy === \"throw\") throw new UnapprovedHeadingError(sec.label, `section of ${r.action.id}`);\n const { section: _dropped, ...rest } = r.action;\n return { ...r, action: rest };\n });\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n ...(sec && (sec.kind ?? (sec.primary ? \"target\" : \"group\")) === \"target\" ? { target: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n if (row.action.startsGroup && section.nodes.length > 0) {\n section.nodes.push({ kind: \"separator\", id: `${row.action.id}:group` });\n }\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const fieldName = options.contentLabel?.trim();\n const header = selected\n ? { label: \"Selected\", text: target.selection?.text ?? \"\" }\n : fieldName\n ? { label: fieldName, text: options.content ?? \"\" }\n : content\n ? { label: \"Content\", text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\n/**\n * AN EXPANDED SUBMENU KEEPS ITS GROUPS (DATA-V2-BASICS-2, 2026-09-28). A provider's rows arrive flat,\n * so a submenu drew \"Highlight row\" and \"Delete row…\" as neighbours with no divider, while the same\n * rows in a top-level menu sit in their sections. A divider now goes wherever the rows' `section`\n * changes — a row with no section and a row with one are different groups too.\n */\nexport function withGroupDividers(children: readonly Action[], nodes: readonly MenuNode[]): MenuNode[] {\n const out: MenuNode[] = [];\n children.forEach((child, i) => {\n const node = nodes[i];\n if (!node) return;\n if (i > 0 && (child.startsGroup || (children[i - 1]!.section?.id ?? null) !== (child.section?.id ?? null))) {\n out.push({ kind: \"separator\", id: `${child.id}:group` });\n }\n out.push(node);\n });\n return out;\n}\n\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, pending: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * The shared React context (T0-safe: imports only React and types). Shared\n * through globalThis so every per-layout bundle reads the same provider.\n */\nimport * as React from \"react\";\nimport type { ActionRegistry } from \"../actions/types\";\nimport type { AlchemyHostPorts } from \"../ports\";\n\nexport interface AlchemyActionsValue {\n registry: ActionRegistry;\n ports: AlchemyHostPorts;\n}\n\nconst KEY = Symbol.for(\"ai-matrx.alchemy.actions-context\");\ntype Holder = { [KEY]?: React.Context<AlchemyActionsValue | null> };\nexport const AlchemyActionsContext: React.Context<AlchemyActionsValue | null> =\n ((globalThis as Holder)[KEY] ??= React.createContext<AlchemyActionsValue | null>(null));\n\nexport function useAlchemyActions(): AlchemyActionsValue {\n const value = React.useContext(AlchemyActionsContext);\n if (!value) throw new Error(\"Alchemy actions: render inside <AlchemyActionsProvider> (@ai-matrx/alchemy/react/host).\");\n return value;\n}\n\n/**\n * The registry + ports when rendered inside `<AlchemyActionsProvider>`, else null. For callers that\n * must never crash a render outside the host (a kind component, an assist chip, a bare test render):\n * they answer honestly (\"actions aren't available here\") instead of throwing.\n */\nexport function useOptionalAlchemyActions(): AlchemyActionsValue | null {\n return React.useContext(AlchemyActionsContext);\n}\n","/**\n * The completion of an expansion belongs to both the target that started it\n * and that node's most recent request. Either identity changing makes a late\n * result stale.\n */\nexport function isLatestExpansion(\n capturedTargetEpoch: number,\n currentTargetEpoch: number,\n capturedNodeSequence: number,\n currentNodeSequence: number | undefined,\n): boolean {\n return capturedTargetEpoch === currentTargetEpoch && capturedNodeSequence === currentNodeSequence;\n}\n","\"use client\";\n/**\n * While a layout is SEARCHING, every lazy submenu it can see is opened, so the\n * filter walks real rows instead of a library's label (clone 2026-10-01:\n * \"Patient\" found nothing while \"Patient reminder card\" sat two lazy levels\n * down under AI Actions ▸ My Personal). Nested submenus open as their parents'\n * rows arrive. Re-run on every model: a re-resolve rebuilds the model and a\n * nested submenu comes back lazy.\n */\nimport * as React from \"react\";\nimport { lazySubmenuIds } from \"../menu/layouts\";\nimport type { MenuEngine } from \"./engine\";\n\nexport function useSearchOpensLibraries(engine: MenuEngine, searching: boolean): void {\n const { model, expand } = engine;\n React.useEffect(() => {\n if (!searching) return;\n for (const id of lazySubmenuIds(model)) void expand(id);\n }, [searching, model, expand]);\n}\n"],"mappings":";y5BAAA,kJCMA,yBAAkG,mCCiClG,SAAS,OAAO,KAAsC,CACpD,OAAO,KAAK,OAAS,QAAU,KAAK,OAAS,YAAc,KAAK,OAAS,MAC3E,CAsOO,SAAS,QAAQ,MAAmC,CACzD,IAAM,OAAoC,CAAC,EACrC,KAAO,CAAC,MAA4B,QAAoB,CAC5D,QAAW,KAAK,MACV,OAAO,CAAC,EAAG,OAAO,KAAK,CAAE,KAAM,EAAG,WAAY,KAAM,CAAC,EAChD,EAAE,OAAS,YACd,EAAE,KAAM,OAAO,KAAK,CAAE,KAAM,EAAG,WAAY,KAAM,CAAC,EACjD,KAAK,EAAE,SAAU,CAAC,GAAG,MAAO,EAAE,KAAK,CAAC,EAG/C,EACA,QAAW,KAAK,MAAM,SAAU,KAAK,EAAE,MAAO,EAAE,MAAQ,CAAC,EAAE,KAAK,EAAI,CAAC,CAAC,EACtE,MAAO,CAAE,MAAO,CAClB,CASO,SAAS,eAAe,MAAmC,CAChE,GAAI,CAAC,MAAO,MAAO,CAAC,EACpB,IAAM,IAAgB,CAAC,EACjB,KAAQ,OAA+B,CAC3C,QAAW,KAAK,MACV,EAAE,OAAS,YACX,EAAE,KACC,EAAE,SAAS,IAAI,KAAK,EAAE,EAAE,EACxB,KAAK,EAAE,QAAQ,EAE1B,EACA,QAAW,KAAK,MAAM,SAAU,KAAK,EAAE,KAAK,E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AC/B,sCAAC,mCAAa,8BAAkB,KAChC,yBAAC,mCACE,kBAAS,OAAO,IAAI,CAAC,CAAE,KAAM,UAAW,IAAM,CAC7C,IAAM,YAAc,KAAK,OAAS,OAAS,KAAK,YAAc,OAC9D,SACE,0BAAC,kCAEC,MAAO,GAAG,KAAK,KAAK,IAAI,WAAW,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,GACvD,oBAAmB,KAAK,GACxB,SAAU,EAAQ,YAClB,SAAU,IAAM,CACV,KAAK,OAAS,UAAgB,OAAO,OAAO,KAAK,EAAE,EAC9C,KAAK,OAAS,OAAQ,OAAO,SAAS,OAAO,KAAK,IAAI,EACrD,OAAO,IAAI,KAAK,EAAE,CAC9B,EACA,UAAU,QAET,mBAAU,KAAO,OAAO,KAAK,KAAK,IAAI,EAAI,QAC3C,yBAAC,QAAK,UAAU,kBAAmB,cAAK,MAAM,KAC9C,yBAAC,QAAK,UAAU,gCACb,qBAAc,YAAY,SAAW,KAAK,OAAS,WAAa,KAAK,QAAU,gBAAa,WAAW,KAAK,UAAK,EACpH,IAfK,KAAK,EAgBZ,CAEJ,CAAC,EACH,GACF,GACF,CAEJ","names":["React","React","import_jsx_runtime"]}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { TransferOutcome } from '@ai-matrx/kit/content-transfer';
2
+ import { TransferOutcome } from '@ai-matrx/alchemy/operate';
3
3
 
4
4
  /**
5
5
  * Matrx Alchemy — Declare types (CONTRACT §2.1).
@@ -139,6 +139,8 @@ interface SurfaceDeclaration {
139
139
  configNamespaces?: readonly ConfigNamespaceDeclaration[];
140
140
  evidenceSources?: readonly EvidenceSourceDeclaration[];
141
141
  skipBaselineValues?: boolean;
142
+ /** Opt out of the host's baseline item types (`baselineItemTypes`, e.g. `TABLE_ROW_ITEM_TYPE`). */
143
+ skipBaselineItemTypes?: boolean;
142
144
  }
143
145
  type ValueProvenance = {
144
146
  kind: "own";
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { TransferOutcome } from '@ai-matrx/kit/content-transfer';
2
+ import { TransferOutcome } from '@ai-matrx/alchemy/operate';
3
3
 
4
4
  /**
5
5
  * Matrx Alchemy — Declare types (CONTRACT §2.1).
@@ -139,6 +139,8 @@ interface SurfaceDeclaration {
139
139
  configNamespaces?: readonly ConfigNamespaceDeclaration[];
140
140
  evidenceSources?: readonly EvidenceSourceDeclaration[];
141
141
  skipBaselineValues?: boolean;
142
+ /** Opt out of the host's baseline item types (`baselineItemTypes`, e.g. `TABLE_ROW_ITEM_TYPE`). */
143
+ skipBaselineItemTypes?: boolean;
142
144
  }
143
145
  type ValueProvenance = {
144
146
  kind: "own";