@cloudvoyant/helical-ui 0.21.1 → 0.22.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.
package/dist/index.cjs CHANGED
@@ -45,6 +45,7 @@ __export(index_exports, {
45
45
  THEMES: () => THEMES,
46
46
  THEME_NAMES: () => THEME_NAMES,
47
47
  TitleHeading: () => TitleHeading,
48
+ announceCommandMessage: () => announceCommandMessage,
48
49
  badgeVariants: () => badgeVariants,
49
50
  buildChartDefinition: () => buildChartDefinition,
50
51
  buildExtensions: () => buildExtensions,
@@ -80,6 +81,15 @@ __export(index_exports, {
80
81
  codeBlockSpinnerBase: () => codeBlockSpinnerBase,
81
82
  codeBlockTitleBase: () => codeBlockTitleBase,
82
83
  colBase: () => colBase,
84
+ colonCommandDialogContentBase: () => colonCommandDialogContentBase,
85
+ colonCommandErrorBase: () => colonCommandErrorBase,
86
+ colonCommandInputVariants: () => colonCommandInputVariants,
87
+ colonCommandItemVariants: () => colonCommandItemVariants,
88
+ colonCommandListVariants: () => colonCommandListVariants,
89
+ colonCommandPositionerBase: () => colonCommandPositionerBase,
90
+ colonCommandPrefixBase: () => colonCommandPrefixBase,
91
+ colonCommandPromptBarVariants: () => colonCommandPromptBarVariants,
92
+ colonCommandVariants: () => colonCommandVariants,
83
93
  comboboxClearTriggerBase: () => comboboxClearTriggerBase,
84
94
  comboboxContentBase: () => comboboxContentBase,
85
95
  comboboxControlBase: () => comboboxControlBase,
@@ -91,8 +101,27 @@ __export(index_exports, {
91
101
  comboboxListBase: () => comboboxListBase,
92
102
  comboboxPositionerBase: () => comboboxPositionerBase,
93
103
  comboboxTriggerBase: () => comboboxTriggerBase,
104
+ commandMenuDialogContentBase: () => commandMenuDialogContentBase,
105
+ commandMenuErrorBase: () => commandMenuErrorBase,
106
+ commandMenuInputVariants: () => commandMenuInputVariants,
107
+ commandMenuItemVariants: () => commandMenuItemVariants,
108
+ commandMenuListVariants: () => commandMenuListVariants,
109
+ commandMenuPositionerBase: () => commandMenuPositionerBase,
110
+ commandMenuPrefixBase: () => commandMenuPrefixBase,
111
+ commandMenuPromptBarVariants: () => commandMenuPromptBarVariants,
112
+ commandMenuVariants: () => commandMenuVariants,
113
+ commandPaletteBreadcrumbBase: () => commandPaletteBreadcrumbBase,
114
+ commandPaletteDialogContentBase: () => commandPaletteDialogContentBase,
115
+ commandPaletteFooterBase: () => commandPaletteFooterBase,
116
+ commandPaletteHeaderBase: () => commandPaletteHeaderBase,
117
+ commandPaletteInputBase: () => commandPaletteInputBase,
118
+ commandPaletteItemBase: () => commandPaletteItemBase,
119
+ commandPaletteListBase: () => commandPaletteListBase,
120
+ commandPalettePositionerBase: () => commandPalettePositionerBase,
121
+ commandPaletteVariants: () => commandPaletteVariants,
94
122
  containerBase: () => containerBase,
95
123
  createCodeBlockCustom: () => createCodeBlockCustom,
124
+ createCommandTree: () => createCommandTree,
96
125
  createHelixPreset: () => createHelixPreset,
97
126
  createImageNode: () => createImageNode,
98
127
  createInternalMention: () => createInternalMention,
@@ -137,9 +166,12 @@ __export(index_exports, {
137
166
  findDirectionalPane: () => findDirectionalPane,
138
167
  findEditorScrollContainer: () => findEditorScrollContainer,
139
168
  flattenKeymapEntries: () => flattenKeymapEntries,
169
+ formatColonCompletionInput: () => formatColonCompletionInput,
170
+ formatCommandMenuCompletionInput: () => formatCommandMenuCompletionInput,
140
171
  formatKeyChord: () => formatKeyChord,
141
172
  formatKeySequence: () => formatKeySequence,
142
173
  formatTime: () => formatTime,
174
+ formatWhichKeyLabel: () => formatWhichKeyLabel,
143
175
  generateJumpLabels: () => generateJumpLabels,
144
176
  getDocumentWhichKeyController: () => getDocumentWhichKeyController,
145
177
  getEditorModalTarget: () => getEditorModalTarget,
@@ -147,9 +179,11 @@ __export(index_exports, {
147
179
  getNodeChildren: () => getNodeChildren,
148
180
  getPresetKeymap: () => getPresetKeymap,
149
181
  hstackBase: () => hstackBase,
182
+ inferPlatform: () => inferPlatform,
150
183
  injectCodeBlockStyles: () => injectCodeBlockStyles,
151
184
  inputVariants: () => inputVariants,
152
185
  insertPastedUrlAsLink: () => insertPastedUrlAsLink,
186
+ isChordCommandString: () => isChordCommandString,
153
187
  isEditorInInsertMode: () => isEditorInInsertMode,
154
188
  isGroupNode: () => isGroupNode,
155
189
  itemVariants: () => itemVariants,
@@ -179,6 +213,7 @@ __export(index_exports, {
179
213
  manimPlaceholderBase: () => manimPlaceholderBase,
180
214
  manimPlaceholderLabelBase: () => manimPlaceholderLabelBase,
181
215
  manimRootBase: () => manimRootBase,
216
+ matchesCommandHotkey: () => matchesCommandHotkey,
182
217
  mermaidLoadingBase: () => mermaidLoadingBase,
183
218
  mermaidRootBase: () => mermaidRootBase,
184
219
  mermaidSourceBase: () => mermaidSourceBase,
@@ -280,6 +315,14 @@ __export(index_exports, {
280
315
  renderChartSvgString: () => renderChartSvgString,
281
316
  renderCodeToHtml: () => renderCodeToHtml,
282
317
  renderMermaidSource: () => renderMermaidSource,
318
+ resolveColonCommandGridNavigation: () => resolveColonCommandGridNavigation,
319
+ resolveColonCommandGridStyle: () => resolveColonCommandGridStyle,
320
+ resolveColonCommandState: () => resolveColonCommandState,
321
+ resolveCommandLevel: () => resolveCommandLevel,
322
+ resolveCommandMenuGridNavigation: () => resolveCommandMenuGridNavigation,
323
+ resolveCommandMenuGridStyle: () => resolveCommandMenuGridStyle,
324
+ resolveCommandMenuState: () => resolveCommandMenuState,
325
+ resolveKbdSteps: () => resolveKbdSteps,
283
326
  resolveMermaidThemeVariables: () => resolveMermaidThemeVariables,
284
327
  resolveNode: () => resolveNode,
285
328
  revealChevronBase: () => revealChevronBase,
@@ -303,9 +346,11 @@ __export(index_exports, {
303
346
  selectPositionerBase: () => selectPositionerBase,
304
347
  selectTriggerBase: () => selectTriggerBase,
305
348
  selectValueBase: () => selectValueBase,
349
+ shouldHandleCommandHotkey: () => shouldHandleCommandHotkey,
306
350
  sidebarMenuButtonVariants: () => sidebarMenuButtonVariants,
307
351
  sidebarStyles: () => sidebarStyles,
308
352
  slashCommands: () => slashCommands,
353
+ splitHighlightSegments: () => splitHighlightSegments,
309
354
  splitterPanelBase: () => splitterPanelBase,
310
355
  splitterResizeTriggerBase: () => splitterResizeTriggerBase,
311
356
  splitterResizeTriggerIndicatorBase: () => splitterResizeTriggerIndicatorBase,
@@ -334,6 +379,13 @@ __export(index_exports, {
334
379
  tagsInputRootBase: () => tagsInputRootBase,
335
380
  textareaBase: () => textareaBase,
336
381
  toLaTeX: () => toLaTeX,
382
+ toastActionTriggerBase: () => toastActionTriggerBase,
383
+ toastCloseTriggerBase: () => toastCloseTriggerBase,
384
+ toastDescriptionBase: () => toastDescriptionBase,
385
+ toastIconBase: () => toastIconBase,
386
+ toastTitleBase: () => toastTitleBase,
387
+ toastVariants: () => toastVariants,
388
+ toasterBase: () => toasterBase,
337
389
  toggleButtonVariants: () => toggleButtonVariants,
338
390
  toggleGroupRootVariants: () => toggleGroupRootVariants,
339
391
  tooltipArrowBase: () => tooltipArrowBase,
@@ -341,6 +393,8 @@ __export(index_exports, {
341
393
  tooltipPositionerBase: () => tooltipPositionerBase,
342
394
  unregisterImageInsertCallback: () => unregisterImageInsertCallback,
343
395
  unregisterYouTubeInsertCallback: () => unregisterYouTubeInsertCallback,
396
+ validateKbdChord: () => validateKbdChord,
397
+ validateKbdHotkey: () => validateKbdHotkey,
344
398
  vstackBase: () => vstackBase,
345
399
  whichKeyBodyVariants: () => whichKeyBodyVariants,
346
400
  whichKeyBreadcrumbBase: () => whichKeyBreadcrumbBase,
@@ -1604,30 +1658,115 @@ var kbdVariants = (0, import_class_variance_authority19.cva)(
1604
1658
  sm: "min-h-4 min-w-4 px-1 py-0.5 text-[10px]",
1605
1659
  md: "min-h-5 min-w-5 px-1.5 py-0.5 text-xs",
1606
1660
  lg: "min-h-6 min-w-6 px-2 py-1 text-sm"
1661
+ },
1662
+ invalid: {
1663
+ true: "border-destructive/70 bg-destructive/10 text-destructive line-through decoration-destructive/70",
1664
+ false: ""
1607
1665
  }
1608
1666
  },
1609
1667
  defaultVariants: {
1610
1668
  variant: "outline",
1611
- size: "md"
1669
+ size: "md",
1670
+ invalid: false
1612
1671
  }
1613
1672
  }
1614
1673
  );
1615
1674
  var kbdGroupBase = "inline-flex items-center gap-1";
1616
1675
  var KEY_LABEL_OVERRIDES = {
1617
1676
  Space: "Space",
1677
+ Spacebar: "Space",
1618
1678
  " ": "Space",
1619
1679
  Escape: "Esc",
1680
+ Esc: "Esc",
1620
1681
  Backspace: "\u232B",
1682
+ Delete: "\u2326",
1683
+ Del: "\u2326",
1621
1684
  Enter: "\u21B5",
1685
+ Return: "\u21B5",
1686
+ Tab: "Tab",
1622
1687
  ArrowUp: "\u2191",
1623
1688
  ArrowDown: "\u2193",
1624
1689
  ArrowLeft: "\u2190",
1625
1690
  ArrowRight: "\u2192"
1626
1691
  };
1692
+ var ALL_KEYS_SET = import_hotkeys.ALL_KEYS;
1693
+ function isKnownSingleKey(keyPart) {
1694
+ if (!keyPart) return false;
1695
+ if (Object.hasOwn(KEY_LABEL_OVERRIDES, keyPart)) return true;
1696
+ if (ALL_KEYS_SET.has(keyPart)) return true;
1697
+ if (keyPart.length === 1 && ALL_KEYS_SET.has((0, import_hotkeys.normalizeKeyName)(keyPart))) return true;
1698
+ if (/^\[[A-Za-z][A-Za-z0-9]*\]$/.test(keyPart)) {
1699
+ return (0, import_hotkeys.validateHotkey)(keyPart).valid;
1700
+ }
1701
+ return false;
1702
+ }
1703
+ function inferPlatform() {
1704
+ const hint = typeof navigator !== "undefined" ? `${navigator.platform ?? ""} ${navigator.userAgent ?? ""}`.trim() : void 0;
1705
+ return (0, import_hotkeys.detectPlatform)(hint || void 0);
1706
+ }
1707
+ function validateKbdChord(chord) {
1708
+ const trimmed = chord.trim();
1709
+ if (!trimmed) {
1710
+ return { valid: false, warnings: [], errors: ["Hotkey cannot be empty"] };
1711
+ }
1712
+ if (trimmed.length > 1 && (trimmed.startsWith("+") || /[^+]\+$/.test(trimmed) || trimmed.includes("++") && !trimmed.endsWith("++"))) {
1713
+ return {
1714
+ valid: false,
1715
+ warnings: [],
1716
+ errors: [`Invalid hotkey format in '${trimmed}': empty modifier or key part`]
1717
+ };
1718
+ }
1719
+ const baseResult = (0, import_hotkeys.validateHotkey)(trimmed);
1720
+ if (!baseResult.valid) {
1721
+ return baseResult;
1722
+ }
1723
+ if (trimmed.includes("+") && trimmed.length > 1) {
1724
+ if (!(0, import_hotkeys.hasNonModifierKey)(trimmed)) {
1725
+ return {
1726
+ valid: false,
1727
+ warnings: baseResult.warnings,
1728
+ errors: [...baseResult.errors, `Modifier-only chord '${trimmed}' is missing an action key`]
1729
+ };
1730
+ }
1731
+ const rawParts = trimmed.endsWith("++") ? [...trimmed.slice(0, -2).split("+"), "+"] : trimmed.split("+");
1732
+ const keyPart = rawParts[rawParts.length - 1]?.trim() ?? "";
1733
+ if (!isKnownSingleKey(keyPart)) {
1734
+ return {
1735
+ valid: false,
1736
+ warnings: baseResult.warnings,
1737
+ errors: [...baseResult.errors, `Unknown key: '${keyPart}'`]
1738
+ };
1739
+ }
1740
+ return baseResult;
1741
+ }
1742
+ if (trimmed.length === 1 || isKnownSingleKey(trimmed) || (0, import_hotkeys.isModifierKey)(trimmed)) {
1743
+ return baseResult;
1744
+ }
1745
+ return {
1746
+ valid: false,
1747
+ warnings: baseResult.warnings,
1748
+ errors: [...baseResult.errors, `Unknown key: '${trimmed}'`]
1749
+ };
1750
+ }
1751
+ function validateKbdHotkey(hotkey) {
1752
+ const rawSteps = Array.isArray(hotkey) ? hotkey : typeof hotkey === "string" ? hotkey.trim().split(/\s+/).filter(Boolean) : [];
1753
+ if (rawSteps.length === 0) {
1754
+ return { valid: false, warnings: [], errors: ["Hotkey cannot be empty"] };
1755
+ }
1756
+ if (rawSteps.length === 1) {
1757
+ return validateKbdChord(rawSteps[0]);
1758
+ }
1759
+ const results = rawSteps.map((step) => validateKbdChord(step));
1760
+ return {
1761
+ valid: results.every((r) => r.valid),
1762
+ warnings: results.flatMap((r, idx) => r.warnings.map((w) => `Step ${idx + 1}: ${w}`)),
1763
+ errors: results.flatMap((r, idx) => r.errors.map((e) => `Step ${idx + 1}: ${e}`))
1764
+ };
1765
+ }
1627
1766
  function formatKeyChord(chord, options) {
1628
1767
  const trimmed = chord.trim();
1629
1768
  if (!trimmed) return "";
1630
- if (KEY_LABEL_OVERRIDES[trimmed]) {
1769
+ if (Object.hasOwn(KEY_LABEL_OVERRIDES, trimmed)) {
1631
1770
  return KEY_LABEL_OVERRIDES[trimmed];
1632
1771
  }
1633
1772
  if (trimmed.length === 1) {
@@ -1636,9 +1775,13 @@ function formatKeyChord(chord, options) {
1636
1775
  if (/^Shift\+([a-zA-Z])$/.test(trimmed)) {
1637
1776
  return trimmed.slice(-1).toUpperCase();
1638
1777
  }
1778
+ const validation = validateKbdChord(trimmed);
1779
+ if (!validation.valid) {
1780
+ return trimmed;
1781
+ }
1639
1782
  try {
1640
1783
  const formatted = (0, import_hotkeys.formatForDisplay)(trimmed, {
1641
- platform: options?.platform,
1784
+ platform: inferPlatform(),
1642
1785
  useSymbols: options?.useSymbols ?? true
1643
1786
  });
1644
1787
  return formatted || trimmed;
@@ -1647,9 +1790,721 @@ function formatKeyChord(chord, options) {
1647
1790
  }
1648
1791
  }
1649
1792
  function formatKeySequence(hotkey, options) {
1650
- const steps = Array.isArray(hotkey) ? hotkey : hotkey.trim().split(/\s+/).filter(Boolean);
1793
+ const steps = typeof hotkey === "string" ? hotkey.trim().split(/\s+/).filter(Boolean) : hotkey;
1651
1794
  return steps.map((step) => formatKeyChord(step, options));
1652
1795
  }
1796
+ function resolveKbdSteps(hotkey, options) {
1797
+ const rawSteps = Array.isArray(hotkey) ? [...hotkey] : typeof hotkey === "string" ? hotkey.trim().split(/\s+/).filter(Boolean) : [];
1798
+ if (rawSteps.length === 0) {
1799
+ const msg = "Hotkey cannot be empty";
1800
+ if (options?.warn !== false) {
1801
+ console.warn(`[helical-ui/Kbd] Invalid hotkey "${String(hotkey)}": ${msg}`);
1802
+ }
1803
+ return {
1804
+ steps: [{ raw: "", label: "?", valid: false, errors: [msg], warnings: [] }],
1805
+ valid: false,
1806
+ message: msg
1807
+ };
1808
+ }
1809
+ const steps = rawSteps.map((raw) => {
1810
+ const validation = validateKbdChord(raw);
1811
+ const label = validation.valid ? formatKeyChord(raw, options) : raw.trim() || "?";
1812
+ return {
1813
+ raw,
1814
+ label,
1815
+ valid: validation.valid,
1816
+ errors: validation.errors,
1817
+ warnings: validation.warnings
1818
+ };
1819
+ });
1820
+ const valid = steps.every((s) => s.valid);
1821
+ const allMessages = steps.flatMap((s, idx) => {
1822
+ const prefix = steps.length > 1 ? `Step ${idx + 1} (${s.raw}): ` : "";
1823
+ return [...s.errors, ...s.warnings].map((m) => `${prefix}${m}`);
1824
+ });
1825
+ const message = allMessages.length > 0 ? allMessages.join("; ") : void 0;
1826
+ if (!valid && options?.warn !== false) {
1827
+ const rawDisplay = Array.isArray(hotkey) ? hotkey.join(" ") : hotkey;
1828
+ console.warn(`[helical-ui/Kbd] Invalid hotkey "${rawDisplay}": ${message}`);
1829
+ }
1830
+ return { steps, valid, message };
1831
+ }
1832
+ function isChordCommandString(value) {
1833
+ const trimmed = value.trim();
1834
+ if (!trimmed || trimmed.length <= 1) return false;
1835
+ if (trimmed.includes("+")) return true;
1836
+ if (/\s+/.test(trimmed)) {
1837
+ const tokens = trimmed.split(/\s+/).filter(Boolean);
1838
+ return tokens.length > 1 && tokens.every((t) => validateKbdChord(t).valid);
1839
+ }
1840
+ return false;
1841
+ }
1842
+
1843
+ // src/toast.ts
1844
+ var import_class_variance_authority20 = require("class-variance-authority");
1845
+ var toasterBase = [
1846
+ "w-[calc(100%-var(--viewport-offset-left))] sm:w-(--width) [--width:22.25rem]",
1847
+ "data-[align=center]:left-[calc(var(--viewport-offset-right)/2)]!",
1848
+ "sm:data-[align=center]:w-full"
1849
+ ].join(" ");
1850
+ var toastVariants = (0, import_class_variance_authority20.cva)(
1851
+ [
1852
+ "z-(--z-index) translate-x-(--x) translate-y-(--y) opacity-(--opacity)",
1853
+ "data-[overlap]:scale-[calc(1-var(--index,0)*0.04)]",
1854
+ "relative w-[calc(100%-var(--viewport-offset-left))] sm:w-(--width)",
1855
+ "flex items-start justify-between gap-2.5 rounded-lg border border-border bg-popover px-3.5 py-3 text-sm text-popover-foreground shadow-lg select-none outline-none",
1856
+ "transition-[translate,scale,opacity,height] duration-250 ease-[cubic-bezier(0.21,1.02,0.73,1)] will-change-[translate,opacity,scale]",
1857
+ "data-[state=closed]:duration-200 data-[state=closed]:ease-[cubic-bezier(0.06,0.71,0.55,1)]",
1858
+ "motion-reduce:transition-none!",
1859
+ "data-[type=info]:border-info/30",
1860
+ "data-[type=success]:border-success/30",
1861
+ "data-[type=warning]:border-warn/30",
1862
+ "data-[type=error]:border-danger/30"
1863
+ ].join(" ")
1864
+ );
1865
+ var toastIconBase = [
1866
+ "mt-0.5 shrink-0",
1867
+ "in-data-[type=warning]:text-warn",
1868
+ "in-data-[type=success]:text-success",
1869
+ "in-data-[type=error]:text-danger",
1870
+ "in-data-[type=info]:text-info",
1871
+ "in-data-[type=loading]:text-primary",
1872
+ "[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"
1873
+ ].join(" ");
1874
+ var toastTitleBase = "text-sm font-medium leading-tight text-popover-foreground";
1875
+ var toastDescriptionBase = "text-xs leading-relaxed text-muted-foreground";
1876
+ var toastActionTriggerBase = "inline-flex h-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-border bg-secondary px-2.5 text-xs font-medium text-secondary-foreground transition-colors hover:bg-secondary/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50";
1877
+ var toastCloseTriggerBase = "inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground opacity-70 transition-opacity hover:bg-accent hover:text-accent-foreground hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&_svg]:pointer-events-none [&_svg]:size-3.5";
1878
+
1879
+ // src/command/core.ts
1880
+ var import_hotkeys2 = require("@tanstack/hotkeys");
1881
+ var import_collection = require("@zag-js/collection");
1882
+ var import_i18n_utils = require("@zag-js/i18n-utils");
1883
+ var import_live_region = require("@zag-js/live-region");
1884
+ var import_fzf = require("fzf");
1885
+ var ROOT_NODE_VALUE = "__root__";
1886
+ var DEFAULT_GROUP_LABEL = "Commands";
1887
+ var i18nFilter = (0, import_i18n_utils.createFilter)({ sensitivity: "base" });
1888
+ var sharedLiveRegion = null;
1889
+ function getNodeCommandToken(node) {
1890
+ return (node.command ?? node.value).trim();
1891
+ }
1892
+ function isEditableTarget(target) {
1893
+ if (!target || typeof target !== "object") return false;
1894
+ const el = target;
1895
+ if (el.isContentEditable) return true;
1896
+ const tag = el.tagName?.toLowerCase();
1897
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
1898
+ if (typeof el.closest === "function" && el.closest('[contenteditable="true"], .ProseMirror')) {
1899
+ return true;
1900
+ }
1901
+ return false;
1902
+ }
1903
+ function toFlatItem(node, ancestorPath, ancestorLabels, ancestorCommands, tree, fallbackGroup) {
1904
+ const cmd = getNodeCommandToken(node);
1905
+ const valuePath = [...ancestorPath, node.value];
1906
+ const commandTokens = [...ancestorCommands, cmd];
1907
+ const isBranch = tree.isBranchNode(node);
1908
+ const group = node.group ?? fallbackGroup ?? (ancestorLabels.length > 0 ? ancestorLabels[ancestorLabels.length - 1] : DEFAULT_GROUP_LABEL);
1909
+ return {
1910
+ value: valuePath.join("/"),
1911
+ label: node.label,
1912
+ description: node.description,
1913
+ group,
1914
+ command: cmd,
1915
+ fullCommand: `:${commandTokens.join(" ")}`,
1916
+ aliases: node.aliases ?? [],
1917
+ shortcut: node.shortcut,
1918
+ badge: node.badge,
1919
+ active: Boolean(node.active),
1920
+ disabled: Boolean(node.disabled),
1921
+ isBranch,
1922
+ valuePath,
1923
+ breadcrumbLabels: ancestorLabels,
1924
+ node
1925
+ };
1926
+ }
1927
+ function groupCommandItems(items) {
1928
+ const map = /* @__PURE__ */ new Map();
1929
+ for (const item of items) {
1930
+ const groupLabel = item.group || DEFAULT_GROUP_LABEL;
1931
+ const list = map.get(groupLabel);
1932
+ if (list) {
1933
+ list.push(item);
1934
+ } else {
1935
+ map.set(groupLabel, [item]);
1936
+ }
1937
+ }
1938
+ return Array.from(map.entries()).map(([label, groupItems]) => ({
1939
+ label,
1940
+ items: groupItems
1941
+ }));
1942
+ }
1943
+ function collectDeepFlatItems(parentNode, ancestorPath, ancestorLabels, ancestorCommands, tree, out) {
1944
+ const children = tree.getNodeChildren(parentNode);
1945
+ for (const child of children) {
1946
+ const flat = toFlatItem(child, ancestorPath, ancestorLabels, ancestorCommands, tree);
1947
+ out.push(flat);
1948
+ if (tree.isBranchNode(child)) {
1949
+ collectDeepFlatItems(
1950
+ child,
1951
+ [...ancestorPath, child.value],
1952
+ [...ancestorLabels, child.label],
1953
+ [...ancestorCommands, getNodeCommandToken(child)],
1954
+ tree,
1955
+ out
1956
+ );
1957
+ }
1958
+ }
1959
+ }
1960
+ function matchesCommandToken(node, token) {
1961
+ const lower = token.toLowerCase();
1962
+ const cmd = getNodeCommandToken(node).toLowerCase();
1963
+ if (cmd === lower || node.value.toLowerCase() === lower) {
1964
+ return true;
1965
+ }
1966
+ return (node.aliases ?? []).some((alias) => alias.toLowerCase() === lower);
1967
+ }
1968
+ function createCommandTree(items) {
1969
+ if (items instanceof import_collection.TreeCollection) {
1970
+ return items;
1971
+ }
1972
+ const rootNode = {
1973
+ value: ROOT_NODE_VALUE,
1974
+ label: "Root",
1975
+ children: items ?? []
1976
+ };
1977
+ return new import_collection.TreeCollection({
1978
+ rootNode,
1979
+ nodeToValue: (node) => node.value,
1980
+ nodeToString: (node) => node.label,
1981
+ isNodeDisabled: (node) => Boolean(node.disabled),
1982
+ nodeToChildren: (node) => node.children ?? []
1983
+ });
1984
+ }
1985
+ function resolveCommandLevel(tree, activePath = [], query = "", options) {
1986
+ const rootChildren = tree.getNodeChildren(tree.rootNode);
1987
+ const hasCommands = rootChildren.length > 0;
1988
+ if (!hasCommands) {
1989
+ return {
1990
+ hasCommands: false,
1991
+ breadcrumbs: [],
1992
+ items: [],
1993
+ groups: []
1994
+ };
1995
+ }
1996
+ const breadcrumbs = [];
1997
+ const resolvedValuePath = [];
1998
+ const resolvedLabels = [];
1999
+ const resolvedCommands = [];
2000
+ let currentNode = tree.rootNode;
2001
+ for (const segment of activePath) {
2002
+ const children = tree.getNodeChildren(currentNode);
2003
+ const match = children.find((child) => child.value === segment);
2004
+ if (!match || !tree.isBranchNode(match)) {
2005
+ break;
2006
+ }
2007
+ const cmd = getNodeCommandToken(match);
2008
+ breadcrumbs.push({
2009
+ value: match.value,
2010
+ label: match.label,
2011
+ command: cmd
2012
+ });
2013
+ resolvedValuePath.push(match.value);
2014
+ resolvedLabels.push(match.label);
2015
+ resolvedCommands.push(cmd);
2016
+ currentNode = match;
2017
+ }
2018
+ const trimmedQuery = query.trim();
2019
+ const directChildren = tree.getNodeChildren(currentNode);
2020
+ const directItems = directChildren.map(
2021
+ (child) => toFlatItem(child, resolvedValuePath, resolvedLabels, resolvedCommands, tree)
2022
+ );
2023
+ if (!trimmedQuery) {
2024
+ return {
2025
+ hasCommands: true,
2026
+ breadcrumbs,
2027
+ items: directItems,
2028
+ groups: groupCommandItems(directItems)
2029
+ };
2030
+ }
2031
+ const normalizedQuery = trimmedQuery.startsWith(":") ? trimmedQuery.slice(1).trim() : trimmedQuery;
2032
+ if (!normalizedQuery) {
2033
+ return {
2034
+ hasCommands: true,
2035
+ breadcrumbs,
2036
+ items: directItems,
2037
+ groups: groupCommandItems(directItems)
2038
+ };
2039
+ }
2040
+ const allowDeepSearch = options?.deepSearch !== false && breadcrumbs.length === 0;
2041
+ const candidatePool = [];
2042
+ if (allowDeepSearch) {
2043
+ collectDeepFlatItems(currentNode, resolvedValuePath, resolvedLabels, resolvedCommands, tree, candidatePool);
2044
+ } else {
2045
+ candidatePool.push(...directItems);
2046
+ }
2047
+ const labelFzf = new import_fzf.Fzf(candidatePool, {
2048
+ selector: (item) => item.label,
2049
+ tiebreakers: [import_fzf.byLengthAsc],
2050
+ casing: "case-insensitive"
2051
+ });
2052
+ const labelResults = labelFzf.find(normalizedQuery);
2053
+ const labelMatchMap = /* @__PURE__ */ new Map();
2054
+ for (const res of labelResults) {
2055
+ labelMatchMap.set(res.item.value, {
2056
+ score: res.score,
2057
+ positions: Array.from(res.positions).sort((a, b) => a - b)
2058
+ });
2059
+ }
2060
+ const compositeFzf = new import_fzf.Fzf(candidatePool, {
2061
+ selector: (item) => [
2062
+ item.label,
2063
+ item.command,
2064
+ item.fullCommand,
2065
+ ...item.aliases,
2066
+ ...item.breadcrumbLabels,
2067
+ item.description ?? "",
2068
+ ...item.node.keywords ?? []
2069
+ ].join(" "),
2070
+ tiebreakers: [import_fzf.byLengthAsc],
2071
+ casing: "case-insensitive"
2072
+ });
2073
+ const compositeResults = compositeFzf.find(normalizedQuery);
2074
+ const matchedByValue = /* @__PURE__ */ new Map();
2075
+ for (const res of compositeResults) {
2076
+ const labelHit = labelMatchMap.get(res.item.value);
2077
+ const depthPenalty = (res.item.valuePath.length - 1) * 2;
2078
+ const effectiveScore = (labelHit ? labelHit.score + 20 : res.score) - depthPenalty;
2079
+ matchedByValue.set(res.item.value, {
2080
+ ...res.item,
2081
+ matchPositions: labelHit?.positions ?? [],
2082
+ score: effectiveScore
2083
+ });
2084
+ }
2085
+ for (const candidate of candidatePool) {
2086
+ if (matchedByValue.has(candidate.value)) continue;
2087
+ if (i18nFilter.contains(candidate.label, normalizedQuery) || i18nFilter.contains(candidate.command, normalizedQuery)) {
2088
+ matchedByValue.set(candidate.value, {
2089
+ ...candidate,
2090
+ matchPositions: [],
2091
+ score: 1
2092
+ });
2093
+ }
2094
+ }
2095
+ const rankedItems = Array.from(matchedByValue.values()).sort((a, b) => {
2096
+ const scoreDiff = (b.score ?? 0) - (a.score ?? 0);
2097
+ if (scoreDiff !== 0) return scoreDiff;
2098
+ if (a.valuePath.length !== b.valuePath.length) {
2099
+ return a.valuePath.length - b.valuePath.length;
2100
+ }
2101
+ return a.label.length - b.label.length;
2102
+ });
2103
+ return {
2104
+ hasCommands: true,
2105
+ breadcrumbs,
2106
+ items: rankedItems,
2107
+ groups: groupCommandItems(rankedItems)
2108
+ };
2109
+ }
2110
+ function resolveCommandMenuState(tree, rawInput = "") {
2111
+ const rootChildren = tree.getNodeChildren(tree.rootNode);
2112
+ const hasCommands = rootChildren.length > 0;
2113
+ const withoutColon = rawInput.startsWith(":") ? rawInput.slice(1) : rawInput;
2114
+ const normalizedInput = `:${withoutColon}`;
2115
+ if (!hasCommands) {
2116
+ return {
2117
+ hasCommands: false,
2118
+ normalizedInput,
2119
+ completedTokens: [],
2120
+ partialToken: withoutColon.trim(),
2121
+ breadcrumbs: [],
2122
+ suggestions: [],
2123
+ exactNode: null,
2124
+ error: null
2125
+ };
2126
+ }
2127
+ const hasTrailingSpace = /\s+$/.test(withoutColon);
2128
+ const trimmed = withoutColon.trim();
2129
+ const rawTokens = trimmed.length > 0 ? trimmed.split(/\s+/) : [];
2130
+ const tokensToWalk = hasTrailingSpace ? rawTokens : rawTokens.slice(0, -1);
2131
+ const partialToken = hasTrailingSpace ? "" : rawTokens[rawTokens.length - 1] ?? "";
2132
+ const completedTokens = [];
2133
+ const breadcrumbs = [];
2134
+ const ancestorPath = [];
2135
+ const ancestorLabels = [];
2136
+ let currentNode = tree.rootNode;
2137
+ for (let i = 0; i < tokensToWalk.length; i++) {
2138
+ const token = tokensToWalk[i];
2139
+ const children = tree.getNodeChildren(currentNode);
2140
+ const matchedChild = children.find((child) => matchesCommandToken(child, token));
2141
+ if (!matchedChild) {
2142
+ return {
2143
+ hasCommands: true,
2144
+ normalizedInput,
2145
+ completedTokens,
2146
+ partialToken: rawTokens.slice(i).join(" "),
2147
+ breadcrumbs,
2148
+ suggestions: [],
2149
+ exactNode: null,
2150
+ error: `Unknown command: ${token}`
2151
+ };
2152
+ }
2153
+ const canonicalCmd = getNodeCommandToken(matchedChild);
2154
+ if (!tree.isBranchNode(matchedChild)) {
2155
+ const extraTokens = rawTokens.slice(i + 1);
2156
+ const hasExtra = extraTokens.length > 0 || partialToken.length > 0;
2157
+ if (hasExtra) {
2158
+ return {
2159
+ hasCommands: true,
2160
+ normalizedInput,
2161
+ completedTokens: [...completedTokens, canonicalCmd],
2162
+ partialToken,
2163
+ breadcrumbs,
2164
+ suggestions: [],
2165
+ exactNode: null,
2166
+ error: `Command ':${[...completedTokens, canonicalCmd].join(" ")}' does not take arguments`
2167
+ };
2168
+ }
2169
+ const exactFlat = toFlatItem(matchedChild, ancestorPath, ancestorLabels, completedTokens, tree);
2170
+ return {
2171
+ hasCommands: true,
2172
+ normalizedInput,
2173
+ completedTokens: [...completedTokens, canonicalCmd],
2174
+ partialToken: "",
2175
+ breadcrumbs,
2176
+ suggestions: [exactFlat],
2177
+ exactNode: exactFlat,
2178
+ error: null
2179
+ };
2180
+ }
2181
+ completedTokens.push(canonicalCmd);
2182
+ breadcrumbs.push({
2183
+ value: matchedChild.value,
2184
+ label: matchedChild.label,
2185
+ command: canonicalCmd
2186
+ });
2187
+ ancestorPath.push(matchedChild.value);
2188
+ ancestorLabels.push(matchedChild.label);
2189
+ currentNode = matchedChild;
2190
+ }
2191
+ const branchChildren = tree.getNodeChildren(currentNode);
2192
+ const branchItems = branchChildren.map(
2193
+ (child) => toFlatItem(child, ancestorPath, ancestorLabels, completedTokens, tree)
2194
+ );
2195
+ if (!partialToken) {
2196
+ return {
2197
+ hasCommands: true,
2198
+ normalizedInput,
2199
+ completedTokens,
2200
+ partialToken: "",
2201
+ breadcrumbs,
2202
+ suggestions: branchItems,
2203
+ exactNode: null,
2204
+ error: null
2205
+ };
2206
+ }
2207
+ const exactChild = branchItems.find((item) => matchesCommandToken(item.node, partialToken)) ?? null;
2208
+ const cmdFzf = new import_fzf.Fzf(branchItems, {
2209
+ selector: (item) => item.command,
2210
+ tiebreakers: [import_fzf.byLengthAsc],
2211
+ casing: "case-insensitive"
2212
+ });
2213
+ const cmdHits = /* @__PURE__ */ new Map();
2214
+ for (const res of cmdFzf.find(partialToken)) {
2215
+ cmdHits.set(res.item.value, {
2216
+ score: res.score,
2217
+ positions: Array.from(res.positions).sort((a, b) => a - b)
2218
+ });
2219
+ }
2220
+ const labelFzf = new import_fzf.Fzf(branchItems, {
2221
+ selector: (item) => item.label,
2222
+ tiebreakers: [import_fzf.byLengthAsc],
2223
+ casing: "case-insensitive"
2224
+ });
2225
+ const labelHits = /* @__PURE__ */ new Map();
2226
+ for (const res of labelFzf.find(partialToken)) {
2227
+ labelHits.set(res.item.value, {
2228
+ score: res.score,
2229
+ positions: Array.from(res.positions).sort((a, b) => a - b)
2230
+ });
2231
+ }
2232
+ const combinedFzf = new import_fzf.Fzf(branchItems, {
2233
+ selector: (item) => [item.command, ...item.aliases, item.label, item.description ?? "", ...item.node.keywords ?? []].join(" "),
2234
+ tiebreakers: [import_fzf.byLengthAsc],
2235
+ casing: "case-insensitive"
2236
+ });
2237
+ const suggestionMap = /* @__PURE__ */ new Map();
2238
+ for (const res of combinedFzf.find(partialToken)) {
2239
+ const cmdHit = cmdHits.get(res.item.value);
2240
+ const labelHit = labelHits.get(res.item.value);
2241
+ const isExact = exactChild?.value === res.item.value;
2242
+ const isPrefix = res.item.command.toLowerCase().startsWith(partialToken.toLowerCase());
2243
+ const score = (cmdHit ? cmdHit.score + 50 : res.score) + (isExact ? 500 : 0) + (isPrefix ? 100 : 0);
2244
+ suggestionMap.set(res.item.value, {
2245
+ ...res.item,
2246
+ commandMatchPositions: cmdHit?.positions ?? [],
2247
+ matchPositions: labelHit?.positions ?? [],
2248
+ score
2249
+ });
2250
+ }
2251
+ const suggestions = Array.from(suggestionMap.values()).sort((a, b) => {
2252
+ const scoreDiff = (b.score ?? 0) - (a.score ?? 0);
2253
+ if (scoreDiff !== 0) return scoreDiff;
2254
+ return a.command.length - b.command.length;
2255
+ });
2256
+ const error = suggestions.length === 0 ? `Unknown command: ${[...completedTokens, partialToken].join(" ")}` : null;
2257
+ return {
2258
+ hasCommands: true,
2259
+ normalizedInput,
2260
+ completedTokens,
2261
+ partialToken,
2262
+ breadcrumbs,
2263
+ suggestions,
2264
+ exactNode: exactChild ? suggestionMap.get(exactChild.value) ?? exactChild : null,
2265
+ error
2266
+ };
2267
+ }
2268
+ var resolveColonCommandState = resolveCommandMenuState;
2269
+ function formatCommandMenuCompletionInput(completedTokens, item, appendBranchSpace = true) {
2270
+ const nextTokens = [...completedTokens, item.command].join(" ");
2271
+ return item.isBranch && appendBranchSpace ? `:${nextTokens} ` : `:${nextTokens}`;
2272
+ }
2273
+ var formatColonCompletionInput = formatCommandMenuCompletionInput;
2274
+ function splitHighlightSegments(text, matchPositions) {
2275
+ if (!text) return [];
2276
+ if (!matchPositions || matchPositions.length === 0) {
2277
+ return [{ text, highlight: false }];
2278
+ }
2279
+ const posSet = new Set(matchPositions);
2280
+ const segments = [];
2281
+ let currentText = "";
2282
+ let currentHighlight = posSet.has(0);
2283
+ for (let i = 0; i < text.length; i++) {
2284
+ const isHighlighted = posSet.has(i);
2285
+ if (i > 0 && isHighlighted !== currentHighlight) {
2286
+ segments.push({ text: currentText, highlight: currentHighlight });
2287
+ currentText = text[i];
2288
+ currentHighlight = isHighlighted;
2289
+ } else {
2290
+ currentText += text[i];
2291
+ }
2292
+ }
2293
+ if (currentText.length > 0) {
2294
+ segments.push({ text: currentText, highlight: currentHighlight });
2295
+ }
2296
+ return segments;
2297
+ }
2298
+ function announceCommandMessage(message) {
2299
+ if (typeof document === "undefined" || !message) return;
2300
+ try {
2301
+ if (!sharedLiveRegion) {
2302
+ sharedLiveRegion = (0, import_live_region.createLiveRegion)({ level: "polite", document });
2303
+ }
2304
+ sharedLiveRegion.announce(message, 150);
2305
+ } catch {
2306
+ }
2307
+ }
2308
+ function matchesCommandHotkey(event, hotkey) {
2309
+ if (!hotkey) return false;
2310
+ const trimmed = hotkey.trim();
2311
+ if (trimmed === ":") {
2312
+ if (isEditableTarget(event.target)) return false;
2313
+ return !event.metaKey && !event.ctrlKey && !event.altKey && event.key === ":";
2314
+ }
2315
+ try {
2316
+ if ((0, import_hotkeys2.matchesKeyboardEvent)(event, hotkey)) {
2317
+ return true;
2318
+ }
2319
+ } catch {
2320
+ }
2321
+ const normalized = trimmed.toLowerCase();
2322
+ if (normalized === "mod+k" || normalized === "cmd+k" || normalized === "ctrl+k") {
2323
+ return (event.metaKey || event.ctrlKey) && !event.altKey && event.key.toLowerCase() === "k";
2324
+ }
2325
+ return false;
2326
+ }
2327
+ function isHotkeyAnchorVisible(el) {
2328
+ if (el.closest("[hidden]")) return false;
2329
+ const fwWrapper = el.closest("[data-fw]");
2330
+ const activeFw = el.ownerDocument?.documentElement?.getAttribute("data-framework");
2331
+ if (fwWrapper && activeFw && fwWrapper.getAttribute("data-fw") !== activeFw) {
2332
+ return false;
2333
+ }
2334
+ return true;
2335
+ }
2336
+ function shouldHandleCommandHotkey(anchorEl, selector) {
2337
+ if (!anchorEl || typeof document === "undefined") return true;
2338
+ if (!isHotkeyAnchorVisible(anchorEl)) return false;
2339
+ const myPreview = anchorEl.closest("[data-example-preview]");
2340
+ const activePreview = document.activeElement?.closest?.("[data-example-preview]") ?? null;
2341
+ if (activePreview) {
2342
+ return myPreview === activePreview;
2343
+ }
2344
+ if (myPreview) {
2345
+ const previewAnchors = Array.from(
2346
+ document.querySelectorAll(`[data-example-preview] ${selector}`)
2347
+ ).filter(isHotkeyAnchorVisible);
2348
+ return previewAnchors[0] === anchorEl;
2349
+ }
2350
+ return true;
2351
+ }
2352
+ function resolveCommandMenuGridStyle(columns = "auto", itemCount) {
2353
+ if (columns === 1 || itemCount <= 0) {
2354
+ return void 0;
2355
+ }
2356
+ const maxCols = columns === "auto" ? itemCount <= 6 ? 2 : itemCount <= 12 ? 3 : 4 : columns;
2357
+ const colCount = Math.max(1, Math.min(maxCols, itemCount));
2358
+ const rowCount = Math.max(1, Math.ceil(itemCount / colCount));
2359
+ return {
2360
+ display: "grid",
2361
+ gridAutoFlow: "column",
2362
+ gridTemplateRows: `repeat(${rowCount}, minmax(0, auto))`,
2363
+ gridTemplateColumns: `repeat(${colCount}, minmax(0, 1fr))`
2364
+ };
2365
+ }
2366
+ var resolveColonCommandGridStyle = resolveCommandMenuGridStyle;
2367
+ function resolveCommandMenuGridNavigation(columns = "auto", itemCount, currentIdx, key) {
2368
+ if (itemCount <= 0) return -1;
2369
+ const safeIdx = currentIdx >= 0 && currentIdx < itemCount ? currentIdx : 0;
2370
+ if (key === "ArrowDown") {
2371
+ return (safeIdx + 1) % itemCount;
2372
+ }
2373
+ if (key === "ArrowUp") {
2374
+ return (safeIdx - 1 + itemCount) % itemCount;
2375
+ }
2376
+ if (columns === 1) {
2377
+ return safeIdx;
2378
+ }
2379
+ const maxCols = columns === "auto" ? itemCount <= 6 ? 2 : itemCount <= 12 ? 3 : 4 : columns;
2380
+ const colCount = Math.max(1, Math.min(maxCols, itemCount));
2381
+ const rowCount = Math.max(1, Math.ceil(itemCount / colCount));
2382
+ const totalCols = Math.max(1, Math.ceil(itemCount / rowCount));
2383
+ const row = safeIdx % rowCount;
2384
+ const col = Math.floor(safeIdx / rowCount);
2385
+ const nextCol = key === "ArrowRight" ? (col + 1) % totalCols : (col - 1 + totalCols) % totalCols;
2386
+ return Math.min(nextCol * rowCount + row, itemCount - 1);
2387
+ }
2388
+ var resolveColonCommandGridNavigation = resolveCommandMenuGridNavigation;
2389
+
2390
+ // src/command/styles.ts
2391
+ var import_class_variance_authority21 = require("class-variance-authority");
2392
+ var commandPaletteVariants = (0, import_class_variance_authority21.cva)(
2393
+ "flex w-full flex-col overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-2xl outline-none",
2394
+ {
2395
+ variants: {
2396
+ size: {
2397
+ sm: "max-w-md",
2398
+ md: "max-w-xl",
2399
+ lg: "max-w-2xl"
2400
+ }
2401
+ },
2402
+ defaultVariants: {
2403
+ size: "md"
2404
+ }
2405
+ }
2406
+ );
2407
+ var commandPalettePositionerBase = "items-center justify-center p-4";
2408
+ var commandPaletteDialogContentBase = "my-auto gap-0 overflow-hidden p-0 sm:max-w-xl";
2409
+ var commandPaletteHeaderBase = "flex items-center gap-2 border-b border-border px-3 py-2.5";
2410
+ var commandPaletteBreadcrumbBase = "inline-flex shrink-0 items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground";
2411
+ var commandPaletteInputBase = "flex-1 border-0 bg-transparent px-1 py-0.5 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-0";
2412
+ var commandPaletteListBase = "max-h-80 overflow-y-auto p-1.5 outline-none";
2413
+ var commandPaletteItemBase = "group relative flex w-full cursor-pointer select-none items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-sm outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
2414
+ var commandPaletteFooterBase = "flex flex-wrap items-center justify-between gap-2 border-t border-border bg-muted/30 px-3 py-2 text-[11px] text-muted-foreground";
2415
+ var commandMenuVariants = (0, import_class_variance_authority21.cva)(
2416
+ "flex w-full flex-col overflow-hidden border border-border bg-popover font-mono text-popover-foreground shadow-2xl outline-none",
2417
+ {
2418
+ variants: {
2419
+ size: {
2420
+ sm: "text-xs",
2421
+ md: "text-sm",
2422
+ lg: "text-base"
2423
+ }
2424
+ },
2425
+ defaultVariants: {
2426
+ size: "md"
2427
+ }
2428
+ }
2429
+ );
2430
+ var commandMenuPositionerBase = "items-end justify-stretch p-0!";
2431
+ var commandMenuDialogContentBase = "fixed inset-x-0 bottom-0 top-auto my-0 w-full max-w-none translate-x-0 translate-y-0 gap-0 overflow-hidden rounded-none border-x-0 border-b-0 border-t border-border p-0 shadow-2xl sm:max-w-none sm:rounded-none";
2432
+ var commandMenuListVariants = (0, import_class_variance_authority21.cva)("overflow-y-auto border-b border-border bg-popover/95 outline-none", {
2433
+ variants: {
2434
+ columns: {
2435
+ auto: "grid! grid-flow-col!",
2436
+ 1: "flex flex-col",
2437
+ 2: "grid! grid-flow-col!",
2438
+ 3: "grid! grid-flow-col!",
2439
+ 4: "grid! grid-flow-col!"
2440
+ },
2441
+ size: {
2442
+ sm: "max-h-44 gap-x-2 gap-y-0.5 px-2 py-1",
2443
+ md: "max-h-60 gap-x-3 gap-y-1 p-2",
2444
+ lg: "max-h-72 gap-x-4 gap-y-1.5 p-3"
2445
+ }
2446
+ },
2447
+ defaultVariants: {
2448
+ columns: "auto",
2449
+ size: "md"
2450
+ }
2451
+ });
2452
+ var commandMenuItemVariants = (0, import_class_variance_authority21.cva)(
2453
+ "group relative flex min-w-0 w-full cursor-pointer select-none items-center justify-between gap-2 rounded-md font-mono outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
2454
+ {
2455
+ variants: {
2456
+ size: {
2457
+ sm: "px-1.5 py-0.5 text-[11px] leading-tight",
2458
+ md: "px-2.5 py-1.5 text-xs",
2459
+ lg: "px-3 py-2 text-sm"
2460
+ }
2461
+ },
2462
+ defaultVariants: {
2463
+ size: "md"
2464
+ }
2465
+ }
2466
+ );
2467
+ var commandMenuPromptBarVariants = (0, import_class_variance_authority21.cva)(
2468
+ "flex w-full items-center border-t border-border/60 bg-muted/50 font-mono",
2469
+ {
2470
+ variants: {
2471
+ size: {
2472
+ sm: "gap-1 px-2 py-1 text-xs",
2473
+ md: "gap-1.5 px-3 py-2 text-sm",
2474
+ lg: "gap-2 px-4 py-2.5 text-base"
2475
+ }
2476
+ },
2477
+ defaultVariants: {
2478
+ size: "md"
2479
+ }
2480
+ }
2481
+ );
2482
+ var commandMenuPrefixBase = "select-none font-mono font-bold text-primary";
2483
+ var commandMenuInputVariants = (0, import_class_variance_authority21.cva)(
2484
+ "flex-1 border-0 bg-transparent font-mono text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-0",
2485
+ {
2486
+ variants: {
2487
+ size: {
2488
+ sm: "px-0.5 py-0 text-xs",
2489
+ md: "px-1 py-0.5 text-sm",
2490
+ lg: "px-1.5 py-1 text-base"
2491
+ }
2492
+ },
2493
+ defaultVariants: {
2494
+ size: "md"
2495
+ }
2496
+ }
2497
+ );
2498
+ var commandMenuErrorBase = "flex items-center justify-between gap-2 border-t border-destructive/30 bg-destructive/10 px-3 py-1.5 font-mono text-xs text-destructive";
2499
+ var colonCommandVariants = commandMenuVariants;
2500
+ var colonCommandPositionerBase = commandMenuPositionerBase;
2501
+ var colonCommandDialogContentBase = commandMenuDialogContentBase;
2502
+ var colonCommandListVariants = commandMenuListVariants;
2503
+ var colonCommandItemVariants = commandMenuItemVariants;
2504
+ var colonCommandPromptBarVariants = commandMenuPromptBarVariants;
2505
+ var colonCommandPrefixBase = commandMenuPrefixBase;
2506
+ var colonCommandInputVariants = commandMenuInputVariants;
2507
+ var colonCommandErrorBase = commandMenuErrorBase;
1653
2508
 
1654
2509
  // src/which-key/core.ts
1655
2510
  var DEFAULT_JUMP_ALPHABET = "asdfghjklqwertyuiopzxcvbnm";
@@ -1708,6 +2563,14 @@ function isGroupNode(node, rootTrie) {
1708
2563
  const children = getNodeChildren(node, rootTrie);
1709
2564
  return Object.keys(children).length > 0;
1710
2565
  }
2566
+ function formatWhichKeyLabel(label) {
2567
+ const trimmed = label.trim();
2568
+ if (!trimmed.startsWith("+")) return trimmed;
2569
+ const withoutPlus = trimmed.slice(1).trim();
2570
+ if (!withoutPlus) return trimmed;
2571
+ if (withoutPlus.toLowerCase() === "goto") return "Go to";
2572
+ return withoutPlus.charAt(0).toUpperCase() + withoutPlus.slice(1);
2573
+ }
1711
2574
  function buildWhichKeyTree(rootTrie, activePath, mode) {
1712
2575
  if (activePath.length === 0) {
1713
2576
  const items2 = Object.values(rootTrie).filter((item) => !item.hidden && nodeMatchesMode(item, mode));
@@ -1963,7 +2826,7 @@ function createTextObjectChildren() {
1963
2826
  return {
1964
2827
  i: {
1965
2828
  key: "i",
1966
- label: "+inner",
2829
+ label: "Inner",
1967
2830
  group: "Inner Text Object",
1968
2831
  category: "Match / Text Objects",
1969
2832
  mode: ["normal", "select"],
@@ -2007,7 +2870,7 @@ function createTextObjectChildren() {
2007
2870
  },
2008
2871
  a: {
2009
2872
  key: "a",
2010
- label: "+around",
2873
+ label: "Around",
2011
2874
  group: "Around Text Object",
2012
2875
  category: "Match / Text Objects",
2013
2876
  mode: ["normal", "select"],
@@ -2054,7 +2917,7 @@ function createTextObjectChildren() {
2054
2917
  function createWindowMenu() {
2055
2918
  return {
2056
2919
  key: "Control+w",
2057
- label: "+window",
2920
+ label: "Window",
2058
2921
  group: "Window / Pane",
2059
2922
  category: "Window / Pane",
2060
2923
  mode: ["normal", "select"],
@@ -2131,7 +2994,7 @@ function createWindowMenu() {
2131
2994
  },
2132
2995
  s: {
2133
2996
  key: "s",
2134
- label: "+sticky window",
2997
+ label: "Sticky Window",
2135
2998
  group: "Sticky Window Mode",
2136
2999
  description: "Keep Window menu open until Escape",
2137
3000
  category: "Window / Pane",
@@ -2156,7 +3019,7 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
2156
3019
  }
2157
3020
  return {
2158
3021
  key: leaderKey,
2159
- label: "+leader",
3022
+ label: "Leader",
2160
3023
  group: "Leader",
2161
3024
  category: "Leader",
2162
3025
  mode: ["normal", "select"],
@@ -2170,7 +3033,7 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
2170
3033
  },
2171
3034
  w: {
2172
3035
  key: "w",
2173
- label: "+window",
3036
+ label: "Window",
2174
3037
  group: "Window / Pane",
2175
3038
  description: "Spatial and indexed pane navigation",
2176
3039
  category: "Window / Pane",
@@ -2185,15 +3048,15 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
2185
3048
  },
2186
3049
  g: {
2187
3050
  key: "g",
2188
- label: "+goto",
2189
- group: "Goto",
3051
+ label: "Go to",
3052
+ group: "Go to",
2190
3053
  description: "Go to locations and boundaries",
2191
3054
  category: "Goto",
2192
3055
  proxy: ["g"]
2193
3056
  },
2194
3057
  v: {
2195
3058
  key: "v",
2196
- label: "+view",
3059
+ label: "View",
2197
3060
  group: "View / Scroll",
2198
3061
  description: "Scroll and align viewport",
2199
3062
  category: "View",
@@ -2201,7 +3064,7 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
2201
3064
  },
2202
3065
  k: {
2203
3066
  key: "k",
2204
- label: "+preset",
3067
+ label: "Preset",
2205
3068
  group: "Keybinding Preset",
2206
3069
  description: "Switch modal grammar (Helix / Vim / Kakoune)",
2207
3070
  category: "Space",
@@ -2236,7 +3099,7 @@ function createSpaceMenu(leaderKey = "Space", viewKey = "z") {
2236
3099
  function createViewMenu(key, centerKey) {
2237
3100
  return {
2238
3101
  key,
2239
- label: "+view",
3102
+ label: "View",
2240
3103
  group: "View",
2241
3104
  category: "View",
2242
3105
  mode: ["normal", "select"],
@@ -2290,7 +3153,7 @@ function createUnimpairedMenus() {
2290
3153
  return {
2291
3154
  "[": {
2292
3155
  key: "[",
2293
- label: "+prev",
3156
+ label: "Previous",
2294
3157
  group: "Previous (Unimpaired)",
2295
3158
  category: "Unimpaired",
2296
3159
  mode: ["normal", "select"],
@@ -2334,7 +3197,7 @@ function createUnimpairedMenus() {
2334
3197
  },
2335
3198
  "]": {
2336
3199
  key: "]",
2337
- label: "+next",
3200
+ label: "Next",
2338
3201
  group: "Next (Unimpaired)",
2339
3202
  category: "Unimpaired",
2340
3203
  mode: ["normal", "select"],
@@ -2587,8 +3450,8 @@ function createHelixPreset(leaderKey = "Space") {
2587
3450
  "Control+w": createWindowMenu(),
2588
3451
  g: {
2589
3452
  key: "g",
2590
- label: "+goto",
2591
- group: "Goto",
3453
+ label: "Go to",
3454
+ group: "Go to",
2592
3455
  category: "Goto",
2593
3456
  mode: ["normal", "select"],
2594
3457
  children: {
@@ -2674,7 +3537,7 @@ function createHelixPreset(leaderKey = "Space") {
2674
3537
  z: createViewMenu("z", "z"),
2675
3538
  Z: {
2676
3539
  key: "Z",
2677
- label: "+sticky view",
3540
+ label: "Sticky View",
2678
3541
  group: "View (Sticky)",
2679
3542
  description: "Lock View menu open until Escape",
2680
3543
  category: "View",
@@ -2685,7 +3548,7 @@ function createHelixPreset(leaderKey = "Space") {
2685
3548
  },
2686
3549
  m: {
2687
3550
  key: "m",
2688
- label: "+match",
3551
+ label: "Match",
2689
3552
  group: "Match / Text Objects",
2690
3553
  category: "Match / Text Objects",
2691
3554
  mode: ["normal", "select"],
@@ -2768,8 +3631,8 @@ function createVimPreset(leaderKey = "Space") {
2768
3631
  "Control+w": createWindowMenu(),
2769
3632
  g: {
2770
3633
  key: "g",
2771
- label: "+goto",
2772
- group: "Goto",
3634
+ label: "Go to",
3635
+ group: "Go to",
2773
3636
  category: "Goto",
2774
3637
  mode: ["normal", "select"],
2775
3638
  children: {
@@ -2880,7 +3743,7 @@ function createVimPreset(leaderKey = "Space") {
2880
3743
  z: createViewMenu("z", "z"),
2881
3744
  m: {
2882
3745
  key: "m",
2883
- label: "+text-objects",
3746
+ label: "Text Objects",
2884
3747
  group: "Text Objects",
2885
3748
  category: "Match / Text Objects",
2886
3749
  mode: ["normal", "select"],
@@ -2906,8 +3769,8 @@ function createKakounePreset(leaderKey = "Space") {
2906
3769
  "Control+w": createWindowMenu(),
2907
3770
  g: {
2908
3771
  key: "g",
2909
- label: "+goto",
2910
- group: "Goto",
3772
+ label: "Go to",
3773
+ group: "Go to",
2911
3774
  category: "Goto",
2912
3775
  mode: ["normal", "select"],
2913
3776
  children: {
@@ -3014,7 +3877,7 @@ function createKakounePreset(leaderKey = "Space") {
3014
3877
  v: createViewMenu("v", "v"),
3015
3878
  V: {
3016
3879
  key: "V",
3017
- label: "+lock view",
3880
+ label: "Lock View",
3018
3881
  group: "View (Lock)",
3019
3882
  description: "Lock Kakoune View mode open until Escape (V)",
3020
3883
  category: "View",
@@ -3025,7 +3888,7 @@ function createKakounePreset(leaderKey = "Space") {
3025
3888
  },
3026
3889
  m: {
3027
3890
  key: "m",
3028
- label: "+object",
3891
+ label: "Object",
3029
3892
  group: "Object / Match",
3030
3893
  category: "Match / Text Objects",
3031
3894
  mode: ["normal", "select"],
@@ -3095,11 +3958,11 @@ function getPresetKeymap(preset, leaderKey = "Space") {
3095
3958
  }
3096
3959
 
3097
3960
  // src/which-key/controller.ts
3098
- var import_hotkeys2 = require("@tanstack/hotkeys");
3961
+ var import_hotkeys3 = require("@tanstack/hotkeys");
3099
3962
  var import_dismissable = require("@zag-js/dismissable");
3100
3963
  var import_dom_query = require("@zag-js/dom-query");
3101
3964
  var import_focus_visible = require("@zag-js/focus-visible");
3102
- var import_live_region = require("@zag-js/live-region");
3965
+ var import_live_region2 = require("@zag-js/live-region");
3103
3966
  function mergeKeymapTrees(base, overlay) {
3104
3967
  const result = { ...base };
3105
3968
  for (const [key, node] of Object.entries(overlay)) {
@@ -3164,8 +4027,8 @@ function isTextEntryElement(el) {
3164
4027
  function eventToChordKeys(event) {
3165
4028
  const rawKey = event.key;
3166
4029
  if (!rawKey) return [];
3167
- const normalizedName = (0, import_hotkeys2.normalizeKeyName)(rawKey);
3168
- if ((0, import_hotkeys2.isModifierKey)(normalizedName) || rawKey === "Shift" || rawKey === "Control" || rawKey === "Alt" || rawKey === "Meta") {
4030
+ const normalizedName = (0, import_hotkeys3.normalizeKeyName)(rawKey);
4031
+ if ((0, import_hotkeys3.isModifierKey)(normalizedName) || rawKey === "Shift" || rawKey === "Control" || rawKey === "Alt" || rawKey === "Meta") {
3169
4032
  return [];
3170
4033
  }
3171
4034
  const hasCtrl = event.ctrlKey;
@@ -3186,7 +4049,7 @@ function eventToChordKeys(event) {
3186
4049
  candidates2.push([...mods, baseKey.toLowerCase()].join("+"));
3187
4050
  }
3188
4051
  try {
3189
- const parsed = (0, import_hotkeys2.parseKeyboardEvent)(event);
4052
+ const parsed = (0, import_hotkeys3.parseKeyboardEvent)(event);
3190
4053
  if (parsed?.key) {
3191
4054
  const parsedMods = [];
3192
4055
  if (parsed.ctrl) parsedMods.push("Control");
@@ -3226,15 +4089,18 @@ function getTopMostModalDialog(doc) {
3226
4089
  }
3227
4090
  return dialogs[dialogs.length - 1] ?? null;
3228
4091
  }
3229
- function getPaneFocusableItems(container, ownScope) {
4092
+ function getPaneFocusableItems(container, ownScope, ignoreEnteredExample = false) {
3230
4093
  const doc = container.ownerDocument;
3231
4094
  const activeEl = doc?.activeElement instanceof HTMLElement ? doc.activeElement : null;
3232
- const enteredExample = !ownScope && activeEl && !activeEl.hasAttribute("data-example") ? activeEl.closest("[data-example]") : null;
4095
+ const enteredExample = !ignoreEnteredExample && !ownScope && activeEl && !activeEl.hasAttribute("data-example") ? activeEl.closest("[data-example]") : null;
3233
4096
  const searchRoot = enteredExample && container.contains(enteredExample) ? enteredExample.querySelector("[data-example-preview]") ?? enteredExample : container;
3234
4097
  const raw = (0, import_dom_query.getFocusables)(searchRoot, { includeContainer: false });
3235
4098
  return raw.filter((el) => {
3236
4099
  if (!(el instanceof HTMLElement)) return false;
3237
- if (el.closest("[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay]")) {
4100
+ if (el.tabIndex < 0 && el.getAttribute("role") !== "tab") return false;
4101
+ if (el.closest(
4102
+ '[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay], [data-scope="toast"]'
4103
+ )) {
3238
4104
  return false;
3239
4105
  }
3240
4106
  const fwEl = el.closest("[data-fw]");
@@ -3269,7 +4135,10 @@ function getJumpableItems(container, ownScope) {
3269
4135
  for (const el of [...rawFocusables, ...rawTabs]) {
3270
4136
  if (!(el instanceof HTMLElement) || seen.has(el)) continue;
3271
4137
  seen.add(el);
3272
- if (el.closest("[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay]")) {
4138
+ if (el.tabIndex < 0 && el.getAttribute("role") !== "tab") continue;
4139
+ if (el.closest(
4140
+ '[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay], [data-scope="toast"]'
4141
+ )) {
3273
4142
  continue;
3274
4143
  }
3275
4144
  const fwEl = el.closest("[data-fw]");
@@ -3420,9 +4289,31 @@ function createWhichKeyController(options = {}) {
3420
4289
  } catch {
3421
4290
  }
3422
4291
  }
4292
+ function readStoredLeaderOnly() {
4293
+ if (!storageKey || typeof window === "undefined") return null;
4294
+ try {
4295
+ const raw = window.localStorage.getItem(`${storageKey}:leader-only`);
4296
+ if (raw === "true") return true;
4297
+ if (raw === "false") return false;
4298
+ } catch {
4299
+ }
4300
+ return null;
4301
+ }
4302
+ function writeStoredLeaderOnly(next) {
4303
+ const doc = resolveDoc();
4304
+ if (doc?.documentElement && !options.getScopeElement?.()) {
4305
+ doc.documentElement.dataset.whichKeyLeaderOnly = String(next);
4306
+ }
4307
+ if (!storageKey || typeof window === "undefined") return;
4308
+ try {
4309
+ window.localStorage.setItem(`${storageKey}:leader-only`, String(next));
4310
+ } catch {
4311
+ }
4312
+ }
3423
4313
  let preset = options.preset ?? readStoredPreset() ?? "helix";
3424
4314
  let mode = options.defaultMode ?? "normal";
3425
4315
  const leaderKey = options.leaderKey ?? "Space";
4316
+ let leaderOnly = options.leaderOnly ?? readStoredLeaderOnly() ?? false;
3426
4317
  let jumpAction = options.jumpAction ?? readStoredJumpAction() ?? "activate";
3427
4318
  const jumpAlphabet = options.jumpAlphabet ?? DEFAULT_JUMP_ALPHABET;
3428
4319
  const listeners = /* @__PURE__ */ new Set();
@@ -3512,7 +4403,7 @@ function createWhichKeyController(options = {}) {
3512
4403
  order,
3513
4404
  lastFocusedElement: existing?.lastFocusedElement ?? null
3514
4405
  });
3515
- if (!activePaneId && !disabled) {
4406
+ if (!disabled && (!activePaneId || id === "docs-main" && activePaneId === "docs-sidebar")) {
3516
4407
  activePaneId = id;
3517
4408
  }
3518
4409
  }
@@ -3542,11 +4433,12 @@ function createWhichKeyController(options = {}) {
3542
4433
  preset,
3543
4434
  mode,
3544
4435
  leaderKey,
4436
+ leaderOnly,
3545
4437
  activePath: [...activePath],
3546
4438
  breadcrumb: tree.breadcrumb,
3547
4439
  title: tree.title,
3548
4440
  items: tree.items,
3549
- isOpen: activePath.length > 0 && tree.items.length > 0,
4441
+ isOpen: activePath.length > 0 && tree.items.length > 0 && (!leaderOnly || activePath[0] === leaderKey),
3550
4442
  sticky: sticky || tree.sticky,
3551
4443
  countBuffer,
3552
4444
  explorerOpen,
@@ -3635,6 +4527,13 @@ function createWhichKeyController(options = {}) {
3635
4527
  announce(`Switched to ${nextPreset} preset`);
3636
4528
  emit();
3637
4529
  }
4530
+ function setLeaderOnly(nextLeaderOnly) {
4531
+ if (leaderOnly === nextLeaderOnly) return;
4532
+ leaderOnly = nextLeaderOnly;
4533
+ writeStoredLeaderOnly(nextLeaderOnly);
4534
+ options.onLeaderOnlyChange?.(nextLeaderOnly);
4535
+ emit();
4536
+ }
3638
4537
  function setJumpAction(action) {
3639
4538
  if (jumpAction === action) return;
3640
4539
  jumpAction = action;
@@ -3782,17 +4681,23 @@ function createWhichKeyController(options = {}) {
3782
4681
  function jumpToBoundary(boundary) {
3783
4682
  const container = getActiveContainer();
3784
4683
  if (!container) return false;
3785
- const items = getPaneFocusableItems(container, options.getScopeElement?.());
3786
- if (items.length === 0) return false;
4684
+ const ownScope = options.getScopeElement?.() ?? null;
4685
+ const ignoreEnteredExample = boundary === "start" || boundary === "end";
4686
+ const items = getPaneFocusableItems(container, ownScope, ignoreEnteredExample);
3787
4687
  const doc = resolveDoc();
3788
4688
  const win = doc?.defaultView ?? null;
4689
+ if (items.length === 0 && boundary !== "start" && boundary !== "end") {
4690
+ return false;
4691
+ }
3789
4692
  recordCurrentLocation();
3790
4693
  if (boundary === "start" || boundary === "first-in-group") {
3791
4694
  const target2 = items[0];
3792
- focusElementInActivePane(target2);
4695
+ if (target2) {
4696
+ focusElementInActivePane(target2);
4697
+ }
3793
4698
  if (boundary === "start") {
3794
4699
  container.scrollTop = 0;
3795
- if (win && !isScrollableContainer(container, doc)) {
4700
+ if (win && !ownScope && !isScrollableContainer(container, doc)) {
3796
4701
  try {
3797
4702
  win.scrollTo({ top: 0, behavior: "instant" });
3798
4703
  } catch {
@@ -3805,10 +4710,12 @@ function createWhichKeyController(options = {}) {
3805
4710
  return true;
3806
4711
  }
3807
4712
  const target = items[items.length - 1];
3808
- focusElementInActivePane(target);
4713
+ if (target) {
4714
+ focusElementInActivePane(target);
4715
+ }
3809
4716
  if (boundary === "end") {
3810
4717
  container.scrollTop = container.scrollHeight;
3811
- if (win && !isScrollableContainer(container, doc)) {
4718
+ if (win && !ownScope && !isScrollableContainer(container, doc)) {
3812
4719
  const scrollMax = Math.max(
3813
4720
  doc?.documentElement?.scrollHeight ?? 0,
3814
4721
  doc?.body?.scrollHeight ?? 0,
@@ -4730,6 +5637,11 @@ function createWhichKeyController(options = {}) {
4730
5637
  }
4731
5638
  const doc = resolveDoc();
4732
5639
  const targetEl = (isElementLike(event.target) ? event.target : null) ?? doc?.activeElement ?? null;
5640
+ if (targetEl && isHTMLElementLike(targetEl) && typeof targetEl.closest === "function" && (targetEl.closest(
5641
+ '[data-command-palette][data-modal="true"], [data-command-menu][data-modal="true"], [data-colon-command][data-modal="true"]'
5642
+ ) || isTextEntryElement(targetEl) && targetEl.closest("[data-command-palette], [data-command-menu], [data-colon-command]"))) {
5643
+ return false;
5644
+ }
4733
5645
  const editorTarget = getModalEditor(targetEl);
4734
5646
  const inEditable = isTextEntryElement(targetEl);
4735
5647
  if (mode === "insert") {
@@ -4907,7 +5819,7 @@ function createWhichKeyController(options = {}) {
4907
5819
  } catch {
4908
5820
  }
4909
5821
  try {
4910
- liveRegion = (0, import_live_region.createLiveRegion)({
5822
+ liveRegion = (0, import_live_region2.createLiveRegion)({
4911
5823
  level: "polite",
4912
5824
  document: doc
4913
5825
  });
@@ -4940,9 +5852,14 @@ function createWhichKeyController(options = {}) {
4940
5852
  if (storedJump && !options.jumpAction) {
4941
5853
  jumpAction = storedJump;
4942
5854
  }
5855
+ const storedLeaderOnly = readStoredLeaderOnly();
5856
+ if (storedLeaderOnly !== null && options.leaderOnly === void 0) {
5857
+ leaderOnly = storedLeaderOnly;
5858
+ }
4943
5859
  if (doc.documentElement) {
4944
5860
  doc.documentElement.dataset.keymapPreset = preset;
4945
5861
  doc.documentElement.dataset.jumpAction = jumpAction;
5862
+ doc.documentElement.dataset.whichKeyLeaderOnly = String(leaderOnly);
4946
5863
  }
4947
5864
  rootControllerByDoc.set(doc, controllerApi);
4948
5865
  notifyRootControllerListeners(doc);
@@ -4977,7 +5894,9 @@ function createWhichKeyController(options = {}) {
4977
5894
  break;
4978
5895
  }
4979
5896
  }
4980
- if (isTextEntryElement(targetNode) && (mode === "normal" || mode === "select")) {
5897
+ if (isTextEntryElement(targetNode) && !targetNode.closest(
5898
+ "[data-which-key-explorer], [data-command-palette], [data-command-menu], [data-colon-command]"
5899
+ ) && (mode === "normal" || mode === "select")) {
4981
5900
  setMode("insert");
4982
5901
  }
4983
5902
  };
@@ -4989,8 +5908,13 @@ function createWhichKeyController(options = {}) {
4989
5908
  '[data-which-key-root], [data-which-key-explorer], [data-which-key-jump-overlay], [data-scope="dialog"]'
4990
5909
  )) {
4991
5910
  const focusedScope = targetNode.closest("[data-which-key-scope]") ?? null;
4992
- if (!focusedScope || isScopeElementActive(focusedScope, doc)) {
5911
+ if (focusedScope && isScopeElementActive(focusedScope, doc)) {
4993
5912
  lastInteractedScopeByDoc.set(doc, focusedScope);
5913
+ } else if (!focusedScope) {
5914
+ const currentRemembered = lastInteractedScopeByDoc.get(doc) ?? null;
5915
+ if (!currentRemembered || !targetNode.contains(currentRemembered)) {
5916
+ lastInteractedScopeByDoc.set(doc, null);
5917
+ }
4994
5918
  }
4995
5919
  }
4996
5920
  if (!shouldEntryHandleEvent(entry, doc)) return;
@@ -5008,7 +5932,9 @@ function createWhichKeyController(options = {}) {
5008
5932
  if (programmaticFocusDepth > 0) {
5009
5933
  return;
5010
5934
  }
5011
- if (isTextEntryElement(targetNode) && !getModalEditor(targetNode)) {
5935
+ if (isTextEntryElement(targetNode) && !getModalEditor(targetNode) && !targetNode.closest(
5936
+ "[data-which-key-explorer], [data-command-palette], [data-command-menu], [data-colon-command]"
5937
+ )) {
5012
5938
  if (mode === "normal" || mode === "select") {
5013
5939
  setMode("insert");
5014
5940
  }
@@ -5106,6 +6032,7 @@ function createWhichKeyController(options = {}) {
5106
6032
  handleKeyDown,
5107
6033
  setPreset,
5108
6034
  setMode,
6035
+ setLeaderOnly,
5109
6036
  setJumpAction,
5110
6037
  openPrefix,
5111
6038
  closePrefix,
@@ -5135,8 +6062,8 @@ function createWhichKeyController(options = {}) {
5135
6062
  }
5136
6063
 
5137
6064
  // src/which-key/styles.ts
5138
- var import_class_variance_authority20 = require("class-variance-authority");
5139
- var whichKeyVariants = (0, import_class_variance_authority20.cva)(
6065
+ var import_class_variance_authority22 = require("class-variance-authority");
6066
+ var whichKeyVariants = (0, import_class_variance_authority22.cva)(
5140
6067
  "fixed z-50 flex flex-col overflow-hidden border bg-popover/95 text-popover-foreground shadow-xl backdrop-blur-md transition-all duration-150 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
5141
6068
  {
5142
6069
  variants: {
@@ -5154,7 +6081,7 @@ var whichKeyVariants = (0, import_class_variance_authority20.cva)(
5154
6081
  var whichKeyHeaderBase = "flex items-center justify-between gap-2 px-3 pt-2.5 pb-1 text-xs font-medium";
5155
6082
  var whichKeyTitleBase = "flex items-center gap-1.5 font-semibold text-foreground";
5156
6083
  var whichKeyBreadcrumbBase = "flex items-center gap-1 text-[11px] text-muted-foreground";
5157
- var whichKeyBodyVariants = (0, import_class_variance_authority20.cva)("p-1.5", {
6084
+ var whichKeyBodyVariants = (0, import_class_variance_authority22.cva)("p-1.5", {
5158
6085
  variants: {
5159
6086
  variant: {
5160
6087
  helix: "flex flex-col gap-0.5",
@@ -5167,9 +6094,9 @@ var whichKeyBodyVariants = (0, import_class_variance_authority20.cva)("p-1.5", {
5167
6094
  }
5168
6095
  });
5169
6096
  var whichKeyItemBase = "group flex w-full cursor-pointer items-center justify-between gap-3 rounded-md px-2 py-1 text-left text-xs transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none";
5170
- var whichKeyItemLabelBase = "truncate text-foreground group-hover:text-accent-foreground data-[group=true]:font-medium data-[group=true]:text-primary";
5171
- var whichKeyFooterBase = "flex items-center justify-between gap-2 px-3 pt-1 pb-2 text-[10px] text-muted-foreground";
5172
- var whichKeyModeBadgeVariants = (0, import_class_variance_authority20.cva)(
6097
+ var whichKeyItemLabelBase = "inline-flex min-w-0 items-center gap-1 truncate text-foreground group-hover:text-accent-foreground data-[group=true]:font-medium data-[group=true]:text-primary";
6098
+ var whichKeyFooterBase = "pointer-events-none h-2 shrink-0";
6099
+ var whichKeyModeBadgeVariants = (0, import_class_variance_authority22.cva)(
5173
6100
  "inline-flex items-center gap-1 rounded font-mono font-semibold tracking-wider uppercase select-none",
5174
6101
  {
5175
6102
  variants: {
@@ -5198,7 +6125,7 @@ var whichKeyExplorerInputBase = "mx-4 mb-2 w-[calc(100%-2rem)] rounded-md border
5198
6125
  var whichKeyExplorerListContentBase = "max-h-none flex-1 overflow-visible px-2.5 pt-1 pb-3 outline-none";
5199
6126
  var whichKeyExplorerItemBase = "flex w-full cursor-pointer items-center justify-between gap-3 rounded-md px-2.5 py-1.5 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground";
5200
6127
  var whichKeyExplorerHighlightMarkBase = "rounded-xs bg-primary/20 px-0.5 font-semibold text-foreground";
5201
- var paneVariants = (0, import_class_variance_authority20.cva)(
6128
+ var paneVariants = (0, import_class_variance_authority22.cva)(
5202
6129
  "relative transition-shadow duration-150 data-[pane-active=true]:ring-1 data-[pane-active=true]:ring-primary/40",
5203
6130
  {
5204
6131
  variants: {
@@ -5213,7 +6140,7 @@ var paneVariants = (0, import_class_variance_authority20.cva)(
5213
6140
  }
5214
6141
  );
5215
6142
  var jumpOverlayRootBase = "pointer-events-none fixed inset-0 z-[60] overflow-hidden";
5216
- var jumpBadgeVariants = (0, import_class_variance_authority20.cva)(
6143
+ var jumpBadgeVariants = (0, import_class_variance_authority22.cva)(
5217
6144
  "pointer-events-auto fixed z-[61] inline-flex items-center justify-center rounded border px-1 py-0.5 font-mono text-[11px] leading-none font-bold shadow-md transition-transform select-none",
5218
6145
  {
5219
6146
  variants: {
@@ -7172,6 +8099,7 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7172
8099
  THEMES,
7173
8100
  THEME_NAMES,
7174
8101
  TitleHeading,
8102
+ announceCommandMessage,
7175
8103
  badgeVariants,
7176
8104
  buildChartDefinition,
7177
8105
  buildExtensions,
@@ -7207,6 +8135,15 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7207
8135
  codeBlockSpinnerBase,
7208
8136
  codeBlockTitleBase,
7209
8137
  colBase,
8138
+ colonCommandDialogContentBase,
8139
+ colonCommandErrorBase,
8140
+ colonCommandInputVariants,
8141
+ colonCommandItemVariants,
8142
+ colonCommandListVariants,
8143
+ colonCommandPositionerBase,
8144
+ colonCommandPrefixBase,
8145
+ colonCommandPromptBarVariants,
8146
+ colonCommandVariants,
7210
8147
  comboboxClearTriggerBase,
7211
8148
  comboboxContentBase,
7212
8149
  comboboxControlBase,
@@ -7218,8 +8155,27 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7218
8155
  comboboxListBase,
7219
8156
  comboboxPositionerBase,
7220
8157
  comboboxTriggerBase,
8158
+ commandMenuDialogContentBase,
8159
+ commandMenuErrorBase,
8160
+ commandMenuInputVariants,
8161
+ commandMenuItemVariants,
8162
+ commandMenuListVariants,
8163
+ commandMenuPositionerBase,
8164
+ commandMenuPrefixBase,
8165
+ commandMenuPromptBarVariants,
8166
+ commandMenuVariants,
8167
+ commandPaletteBreadcrumbBase,
8168
+ commandPaletteDialogContentBase,
8169
+ commandPaletteFooterBase,
8170
+ commandPaletteHeaderBase,
8171
+ commandPaletteInputBase,
8172
+ commandPaletteItemBase,
8173
+ commandPaletteListBase,
8174
+ commandPalettePositionerBase,
8175
+ commandPaletteVariants,
7221
8176
  containerBase,
7222
8177
  createCodeBlockCustom,
8178
+ createCommandTree,
7223
8179
  createHelixPreset,
7224
8180
  createImageNode,
7225
8181
  createInternalMention,
@@ -7264,9 +8220,12 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7264
8220
  findDirectionalPane,
7265
8221
  findEditorScrollContainer,
7266
8222
  flattenKeymapEntries,
8223
+ formatColonCompletionInput,
8224
+ formatCommandMenuCompletionInput,
7267
8225
  formatKeyChord,
7268
8226
  formatKeySequence,
7269
8227
  formatTime,
8228
+ formatWhichKeyLabel,
7270
8229
  generateJumpLabels,
7271
8230
  getDocumentWhichKeyController,
7272
8231
  getEditorModalTarget,
@@ -7274,9 +8233,11 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7274
8233
  getNodeChildren,
7275
8234
  getPresetKeymap,
7276
8235
  hstackBase,
8236
+ inferPlatform,
7277
8237
  injectCodeBlockStyles,
7278
8238
  inputVariants,
7279
8239
  insertPastedUrlAsLink,
8240
+ isChordCommandString,
7280
8241
  isEditorInInsertMode,
7281
8242
  isGroupNode,
7282
8243
  itemVariants,
@@ -7306,6 +8267,7 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7306
8267
  manimPlaceholderBase,
7307
8268
  manimPlaceholderLabelBase,
7308
8269
  manimRootBase,
8270
+ matchesCommandHotkey,
7309
8271
  mermaidLoadingBase,
7310
8272
  mermaidRootBase,
7311
8273
  mermaidSourceBase,
@@ -7407,6 +8369,14 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7407
8369
  renderChartSvgString,
7408
8370
  renderCodeToHtml,
7409
8371
  renderMermaidSource,
8372
+ resolveColonCommandGridNavigation,
8373
+ resolveColonCommandGridStyle,
8374
+ resolveColonCommandState,
8375
+ resolveCommandLevel,
8376
+ resolveCommandMenuGridNavigation,
8377
+ resolveCommandMenuGridStyle,
8378
+ resolveCommandMenuState,
8379
+ resolveKbdSteps,
7410
8380
  resolveMermaidThemeVariables,
7411
8381
  resolveNode,
7412
8382
  revealChevronBase,
@@ -7430,9 +8400,11 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7430
8400
  selectPositionerBase,
7431
8401
  selectTriggerBase,
7432
8402
  selectValueBase,
8403
+ shouldHandleCommandHotkey,
7433
8404
  sidebarMenuButtonVariants,
7434
8405
  sidebarStyles,
7435
8406
  slashCommands,
8407
+ splitHighlightSegments,
7436
8408
  splitterPanelBase,
7437
8409
  splitterResizeTriggerBase,
7438
8410
  splitterResizeTriggerIndicatorBase,
@@ -7461,6 +8433,13 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7461
8433
  tagsInputRootBase,
7462
8434
  textareaBase,
7463
8435
  toLaTeX,
8436
+ toastActionTriggerBase,
8437
+ toastCloseTriggerBase,
8438
+ toastDescriptionBase,
8439
+ toastIconBase,
8440
+ toastTitleBase,
8441
+ toastVariants,
8442
+ toasterBase,
7464
8443
  toggleButtonVariants,
7465
8444
  toggleGroupRootVariants,
7466
8445
  tooltipArrowBase,
@@ -7468,6 +8447,8 @@ function lockEditorOverlayScroll(editorElement, overlayElement) {
7468
8447
  tooltipPositionerBase,
7469
8448
  unregisterImageInsertCallback,
7470
8449
  unregisterYouTubeInsertCallback,
8450
+ validateKbdChord,
8451
+ validateKbdHotkey,
7471
8452
  vstackBase,
7472
8453
  whichKeyBodyVariants,
7473
8454
  whichKeyBreadcrumbBase,