@inkeep/cxkit-primitives 0.5.37 → 0.5.38

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.
@@ -1,18 +1,31 @@
1
- import { jsxs as Y, jsx as h } from "react/jsx-runtime";
2
- import * as G from "@radix-ui/react-dialog";
1
+ import { jsxs as ee, jsx as g } from "react/jsx-runtime";
2
+ import * as K from "@radix-ui/react-dialog";
3
3
  import * as c from "react";
4
- import { commandScore as be } from "./command-score.js";
5
- import { Primitive as R } from "@radix-ui/react-primitive";
6
- import { useId as T } from "@radix-ui/react-id";
7
- import { s as Se } from "../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.js";
8
- import { ASK_AI_TRIGGER_VALUE as Ee } from "../../components/embedded-search.js";
9
- import { useShadow as Ce } from "../shadow/context.js";
10
- const D = '[cmdk-group=""]', Q = '[cmdk-group-items=""]', we = '[cmdk-group-heading=""]', le = '[cmdk-item=""]', ie = `${le}:not([aria-disabled="true"])`, X = "cmdk-item-select", L = "data-value", ye = (r, n, t) => be(r, n, t ?? []), ue = c.createContext(void 0), O = () => c.useContext(ue), ae = c.createContext(void 0), Z = () => c.useContext(ae), de = c.createContext(void 0), fe = c.forwardRef((r, n) => {
11
- const t = M(() => ({
4
+ import { useCallback as ae, useMemo as Ee } from "react";
5
+ import { commandScore as Ce } from "./command-score.js";
6
+ import { Primitive as k } from "@radix-ui/react-primitive";
7
+ import { useId as F } from "@radix-ui/react-id";
8
+ import { s as we } from "../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@19.0.0/node_modules/use-sync-external-store/shim/index.js";
9
+ import { ASK_AI_TRIGGER_VALUE as ye } from "../../constants/search.js";
10
+ import { useShadow as Re } from "../shadow/context.js";
11
+ const T = '[cmdk-group=""]', Y = '[cmdk-group-items=""]', Ie = '[cmdk-group-heading=""]', de = '[cmdk-item=""]', ue = `${de}:not([aria-disabled="true"])`, Z = "cmdk-item-select", M = "data-value", xe = (t, n, r) => Ce(t, n, r ?? []), fe = c.createContext(void 0), G = () => c.useContext(fe), me = c.createContext(void 0), te = () => c.useContext(me), ve = c.createContext(void 0), he = c.forwardRef((t, n) => {
12
+ const r = P(() => /* @__PURE__ */ new Set()), i = P(() => /* @__PURE__ */ new Map()), u = P(() => /* @__PURE__ */ new Map()), f = P(() => /* @__PURE__ */ new Set()), s = ge(t), {
13
+ label: v,
14
+ children: d,
15
+ value: S,
16
+ onValueChange: C,
17
+ filter: y,
18
+ shouldFilter: w,
19
+ loop: R,
20
+ disablePointerSelection: L = !1,
21
+ vimBindings: N = !0,
22
+ defaultSearch: re,
23
+ ...U
24
+ } = t, h = P(() => ({
12
25
  /** Value of the search query. */
13
- search: "",
26
+ search: re ?? "",
14
27
  /** Currently selected item value. */
15
- value: r.value ?? r.defaultValue ?? "",
28
+ value: t.value ?? t.defaultValue ?? "",
16
29
  /** Currently selected item id. */
17
30
  selectedItemId: void 0,
18
31
  filtered: {
@@ -23,321 +36,315 @@ const D = '[cmdk-group=""]', Q = '[cmdk-group-items=""]', we = '[cmdk-group-head
23
36
  /** Set of groups with at least one visible item. */
24
37
  groups: /* @__PURE__ */ new Set()
25
38
  }
26
- })), a = M(() => /* @__PURE__ */ new Set()), s = M(() => /* @__PURE__ */ new Map()), d = M(() => /* @__PURE__ */ new Map()), f = M(() => /* @__PURE__ */ new Set()), m = me(r), {
27
- label: u,
28
- children: I,
29
- value: b,
30
- onValueChange: C,
31
- filter: x,
32
- shouldFilter: E,
33
- loop: _,
34
- disablePointerSelection: he = !1,
35
- vimBindings: B = !0,
36
- ...N
37
- } = r, ee = T(), U = T(), p = T(), w = c.useRef(null), y = De();
38
- A(() => {
39
- if (b !== void 0) {
40
- const e = b.trim();
41
- t.current.value = e, S.emit();
39
+ })), $ = F(), j = F(), b = F(), I = c.useRef(null), x = Oe();
40
+ _(() => {
41
+ if (S !== void 0) {
42
+ const e = S.trim();
43
+ h.current.value = e, E.emit();
42
44
  }
43
- }, [b]), A(() => {
44
- y(6, re);
45
+ }, [S]), _(() => {
46
+ x(6, oe);
45
47
  }, []);
46
- const ge = Ce(), S = c.useMemo(() => ({
48
+ const be = Re(), E = c.useMemo(() => ({
47
49
  subscribe: (e) => (f.current.add(e), () => f.current.delete(e)),
48
- snapshot: () => t.current,
49
- setState: (e, i, o) => {
50
- if (!Object.is(t.current[e], i)) {
51
- if (t.current[e] = i, e === "search")
52
- z(), j(), y(1, q);
53
- else if (e === "value" && (ge?.shadowHost?.shadowRoot?.activeElement?.hasAttribute("cmdk-input") || y(1, () => {
54
- k()?.focus();
55
- }), y(7, () => {
56
- t.current.selectedItemId = k()?.id, S.emit();
57
- }), o || y(5, re), m.current?.value !== void 0)) {
58
- const g = i ?? "";
59
- m.current.onValueChange?.(g);
50
+ snapshot: () => h.current,
51
+ setState: (e, l, o) => {
52
+ if (!Object.is(h.current[e], l)) {
53
+ if (h.current[e] = l, e === "search")
54
+ W(), z(), x(1, H);
55
+ else if (e === "value" && (be?.shadowHost?.shadowRoot?.activeElement?.hasAttribute("cmdk-input") || x(1, () => {
56
+ A()?.focus();
57
+ }), x(7, () => {
58
+ h.current.selectedItemId = A()?.id, E.emit();
59
+ }), o || x(5, oe), s.current?.value !== void 0)) {
60
+ const p = l ?? "";
61
+ s.current.onValueChange?.(p);
60
62
  return;
61
63
  }
62
- S.emit();
64
+ E.emit();
63
65
  }
64
66
  },
65
67
  emit: () => {
66
68
  f.current.forEach((e) => e());
67
69
  }
68
- }), []), $ = c.useMemo(
70
+ }), []), q = c.useMemo(
69
71
  () => ({
70
72
  // Keep id → {value, keywords} mapping up-to-date
71
- value: (e, i, o) => {
72
- i !== d.current.get(e)?.value && (d.current.set(e, { value: i, keywords: o }), t.current.filtered.items.set(e, te(i, o)), y(2, () => {
73
- j(), S.emit();
73
+ value: (e, l, o) => {
74
+ l !== u.current.get(e)?.value && (u.current.set(e, { value: l, keywords: o }), h.current.filtered.items.set(e, ne(l, o)), x(2, () => {
75
+ z(), E.emit();
74
76
  }));
75
77
  },
76
78
  // Track item lifecycle (mount, unmount)
77
- item: (e, i) => (a.current.add(e), i && (s.current.has(i) ? s.current?.get(i)?.add(e) : s.current.set(i, /* @__PURE__ */ new Set([e]))), y(3, () => {
78
- z(), j(), t.current.value || q(), S.emit();
79
+ item: (e, l) => (r.current.add(e), l && (i.current.has(l) ? i.current?.get(l)?.add(e) : i.current.set(l, /* @__PURE__ */ new Set([e]))), x(3, () => {
80
+ W(), z(), h.current.value || H(), E.emit();
79
81
  }), () => {
80
- d.current.delete(e), a.current.delete(e), t.current.filtered.items.delete(e);
81
- const o = k();
82
- y(4, () => {
83
- z(), o?.getAttribute("id") === e && q(), S.emit();
82
+ u.current.delete(e), r.current.delete(e), h.current.filtered.items.delete(e);
83
+ const o = A();
84
+ x(4, () => {
85
+ W(), o?.getAttribute("id") === e && H(), E.emit();
84
86
  });
85
87
  }),
86
88
  // Track group lifecycle (mount, unmount)
87
- group: (e) => (s.current.has(e) || s.current.set(e, /* @__PURE__ */ new Set()), () => {
88
- d.current.delete(e), s.current.delete(e);
89
+ group: (e) => (i.current.has(e) || i.current.set(e, /* @__PURE__ */ new Set()), () => {
90
+ u.current.delete(e), i.current.delete(e);
89
91
  }),
90
- filter: () => !!m.current.shouldFilter,
91
- label: u || r["aria-label"] || "",
92
- getDisablePointerSelection: () => !!m.current.disablePointerSelection,
93
- listId: ee,
94
- inputId: p,
95
- labelId: U,
96
- listInnerRef: w
92
+ filter: () => !!s.current.shouldFilter,
93
+ label: v || t["aria-label"] || "",
94
+ getDisablePointerSelection: () => !!s.current.disablePointerSelection,
95
+ listId: $,
96
+ inputId: b,
97
+ labelId: j,
98
+ listInnerRef: I
97
99
  }),
98
100
  []
99
101
  );
100
- function te(e, i) {
101
- const o = m.current?.filter ?? ye;
102
- return e ? o?.(e, t.current.search, i) : 0;
102
+ function ne(e, l) {
103
+ const o = s.current?.filter ?? xe;
104
+ return e ? o?.(e, h.current.search, l) : 0;
103
105
  }
104
- function j() {
105
- if (!t.current.search || // Explicitly false, because true | undefined is the default
106
- m.current.shouldFilter === !1)
106
+ function z() {
107
+ if (!h.current.search || // Explicitly false, because true | undefined is the default
108
+ s.current.shouldFilter === !1)
107
109
  return;
108
- const e = t.current.filtered.items, i = [];
109
- t.current.filtered.groups.forEach((l) => {
110
- const v = s.current.get(l);
111
- let g = 0;
112
- v.forEach((J) => {
113
- const pe = e.get(J);
114
- g = Math.max(pe, g);
115
- }), i.push([l, g]);
110
+ const e = h.current.filtered.items, l = [];
111
+ h.current.filtered.groups.forEach((a) => {
112
+ const m = i.current.get(a);
113
+ let p = 0;
114
+ m.forEach((X) => {
115
+ const Se = e.get(X);
116
+ p = Math.max(Se, p);
117
+ }), l.push([a, p]);
116
118
  });
117
- const o = w.current;
118
- V().sort((l, v) => {
119
- const g = l.getAttribute("id"), J = v.getAttribute("id");
120
- return (e.get(J) ?? 0) - (e.get(g) ?? 0);
121
- }).forEach((l) => {
122
- const v = l.closest(Q);
123
- if (v) {
124
- const g = l.parentElement === v ? l : l.closest(`${Q} > *`);
125
- g && v.appendChild(g);
119
+ const o = I.current;
120
+ D().sort((a, m) => {
121
+ const p = a.getAttribute("id"), X = m.getAttribute("id");
122
+ return (e.get(X) ?? 0) - (e.get(p) ?? 0);
123
+ }).forEach((a) => {
124
+ const m = a.closest(Y);
125
+ if (m) {
126
+ const p = a.parentElement === m ? a : a.closest(`${Y} > *`);
127
+ p && m.appendChild(p);
126
128
  } else {
127
- const g = l.parentElement === o ? l : l.closest(`${Q} > *`);
128
- g && o?.appendChild(g);
129
+ const p = a.parentElement === o ? a : a.closest(`${Y} > *`);
130
+ p && o?.appendChild(p);
129
131
  }
130
- }), i.sort((l, v) => v[1] - l[1]).forEach((l) => {
131
- const v = w.current?.querySelector(
132
- `${D}[${L}="${encodeURIComponent(l[0])}"]`
132
+ }), l.sort((a, m) => m[1] - a[1]).forEach((a) => {
133
+ const m = I.current?.querySelector(
134
+ `${T}[${M}="${encodeURIComponent(a[0])}"]`
133
135
  );
134
- v?.parentElement?.appendChild(v);
136
+ m?.parentElement?.appendChild(m);
135
137
  });
136
138
  }
137
- function q() {
138
- const i = V().find(
139
- (o) => o.getAttribute("aria-disabled") !== "true" && o.getAttribute("data-value") !== Ee
140
- )?.getAttribute(L);
141
- S.setState("value", i || void 0);
139
+ function H() {
140
+ const l = D().find(
141
+ (o) => o.getAttribute("aria-disabled") !== "true" && o.getAttribute("data-value") !== ye
142
+ )?.getAttribute(M);
143
+ E.setState("value", l || void 0);
142
144
  }
143
- function z() {
144
- if (!t.current.search || // Explicitly false, because true | undefined is the default
145
- m.current.shouldFilter === !1) {
146
- t.current.filtered.count = a.current.size;
145
+ function W() {
146
+ if (!h.current.search || // Explicitly false, because true | undefined is the default
147
+ s.current.shouldFilter === !1) {
148
+ h.current.filtered.count = r.current.size;
147
149
  return;
148
150
  }
149
- t.current.filtered.groups = /* @__PURE__ */ new Set();
151
+ h.current.filtered.groups = /* @__PURE__ */ new Set();
150
152
  let e = 0;
151
- for (const i of a.current) {
152
- const o = d.current.get(i)?.value ?? "", l = d.current.get(i)?.keywords ?? [], v = te(o, l);
153
- t.current.filtered.items.set(i, v), v > 0 && e++;
153
+ for (const l of r.current) {
154
+ const o = u.current.get(l)?.value ?? "", a = u.current.get(l)?.keywords ?? [], m = ne(o, a);
155
+ h.current.filtered.items.set(l, m), m > 0 && e++;
154
156
  }
155
- for (const [i, o] of s.current)
156
- for (const l of o) {
157
- const v = t.current.filtered.items.get(l);
158
- if (v && v > 0) {
159
- t.current.filtered.groups.add(i);
157
+ for (const [l, o] of i.current)
158
+ for (const a of o) {
159
+ const m = h.current.filtered.items.get(a);
160
+ if (m && m > 0) {
161
+ h.current.filtered.groups.add(l);
160
162
  break;
161
163
  }
162
164
  }
163
- t.current.filtered.count = e;
165
+ h.current.filtered.count = e;
164
166
  }
165
- function re() {
166
- const e = k();
167
- e && (e.parentElement?.firstChild === e && e.closest(D)?.querySelector(we)?.scrollIntoView({ block: "nearest" }), e.scrollIntoView({ block: "nearest" }));
167
+ function oe() {
168
+ const e = A();
169
+ e && (e.parentElement?.firstChild === e && e.closest(T)?.querySelector(Ie)?.scrollIntoView({ block: "nearest" }), e.scrollIntoView({ block: "nearest" }));
168
170
  }
169
- function k() {
170
- return w.current?.querySelector(`${le}[aria-selected="true"]`);
171
+ function A() {
172
+ return I.current?.querySelector(`${de}[aria-selected="true"]`);
171
173
  }
172
- function V() {
173
- return Array.from(w.current?.querySelectorAll(ie) || []);
174
+ function D() {
175
+ return Array.from(I.current?.querySelectorAll(ue) || []);
174
176
  }
175
- function H(e) {
176
- const o = V()[e];
177
- o && S.setState("value", o.getAttribute(L));
177
+ function J(e) {
178
+ const o = D()[e];
179
+ o && E.setState("value", o.getAttribute(M));
178
180
  }
179
- function W(e) {
180
- const i = k(), o = V(), l = o.findIndex((g) => g === i);
181
- let v = o[l + e];
182
- m.current?.loop && (v = l + e < 0 ? o[o.length - 1] : l + e === o.length ? o[0] : o[l + e]), v && S.setState("value", v.getAttribute(L));
181
+ function Q(e) {
182
+ const l = A(), o = D(), a = o.findIndex((p) => p === l);
183
+ let m = o[a + e];
184
+ s.current?.loop && (m = a + e < 0 ? o[o.length - 1] : a + e === o.length ? o[0] : o[a + e]), m && E.setState("value", m.getAttribute(M));
183
185
  }
184
- function ne(e) {
185
- let o = k()?.closest(D), l;
186
- for (; o && !l; )
187
- o = e > 0 ? Pe(o, D) : Ve(o, D), l = o?.querySelector(ie);
188
- l ? S.setState("value", l.getAttribute(L)) : W(e);
186
+ function ce(e) {
187
+ let o = A()?.closest(T), a;
188
+ for (; o && !a; )
189
+ o = e > 0 ? Te(o, T) : Fe(o, T), a = o?.querySelector(ue);
190
+ a ? E.setState("value", a.getAttribute(M)) : Q(e);
189
191
  }
190
- const oe = () => H(V().length - 1), ce = (e) => {
191
- e.preventDefault(), e.metaKey ? oe() : e.altKey ? ne(1) : W(1);
192
- }, se = (e) => {
193
- e.preventDefault(), e.metaKey ? H(0) : e.altKey ? ne(-1) : W(-1);
192
+ const se = () => J(D().length - 1), ie = (e) => {
193
+ e.preventDefault(), e.metaKey ? se() : e.altKey ? ce(1) : Q(1);
194
+ }, le = (e) => {
195
+ e.preventDefault(), e.metaKey ? J(0) : e.altKey ? ce(-1) : Q(-1);
194
196
  };
195
- return /* @__PURE__ */ Y(
196
- R.div,
197
+ return /* @__PURE__ */ ee(
198
+ k.div,
197
199
  {
198
200
  ref: n,
199
201
  tabIndex: -1,
200
- ...N,
202
+ ...U,
201
203
  "cmdk-root": "",
202
204
  onKeyDown: (e) => {
203
- if (N.onKeyDown?.(e), !e.defaultPrevented)
205
+ if (U.onKeyDown?.(e), !e.defaultPrevented)
204
206
  switch (e.key) {
205
207
  case "n":
206
208
  case "j": {
207
- B && e.ctrlKey && ce(e);
209
+ N && e.ctrlKey && ie(e);
208
210
  break;
209
211
  }
210
212
  case "ArrowDown": {
211
- ce(e);
213
+ ie(e);
212
214
  break;
213
215
  }
214
216
  case "p":
215
217
  case "k": {
216
- B && e.ctrlKey && se(e);
218
+ N && e.ctrlKey && le(e);
217
219
  break;
218
220
  }
219
221
  case "ArrowUp": {
220
- se(e);
222
+ le(e);
221
223
  break;
222
224
  }
223
225
  case "Home": {
224
- e.preventDefault(), H(0);
226
+ e.preventDefault(), J(0);
225
227
  break;
226
228
  }
227
229
  case "End": {
228
- e.preventDefault(), oe();
230
+ e.preventDefault(), se();
229
231
  break;
230
232
  }
231
233
  case "Enter":
232
234
  if (!e.nativeEvent.isComposing && e.keyCode !== 229) {
233
235
  e.preventDefault();
234
- const i = k();
235
- if (i) {
236
- const o = new Event(X);
237
- i.dispatchEvent(o);
236
+ const l = A();
237
+ if (l) {
238
+ const o = new Event(Z);
239
+ l.dispatchEvent(o);
238
240
  }
239
241
  }
240
242
  }
241
243
  },
244
+ style: {
245
+ display: "contents"
246
+ },
242
247
  children: [
243
- /* @__PURE__ */ h(
248
+ /* @__PURE__ */ g(
244
249
  "label",
245
250
  {
246
251
  "cmdk-label": "",
247
- htmlFor: $.inputId,
248
- id: $.labelId,
249
- style: Fe,
250
- children: u
252
+ htmlFor: q.inputId,
253
+ id: q.labelId,
254
+ style: Ke,
255
+ children: v
251
256
  }
252
257
  ),
253
- K(r, (e) => /* @__PURE__ */ h(ae.Provider, { value: S, children: /* @__PURE__ */ h(ue.Provider, { value: $, children: e }) }))
258
+ B(t, (e) => /* @__PURE__ */ g(me.Provider, { value: E, children: /* @__PURE__ */ g(fe.Provider, { value: q, children: e }) }))
254
259
  ]
255
260
  }
256
261
  );
257
- }), Re = c.forwardRef((r, n) => {
258
- const { id: t } = r, a = c.useRef(null), s = c.useContext(de), d = O(), f = me(r), m = f.current?.forceMount ?? s?.forceMount;
259
- A(() => {
260
- if (!m)
261
- return d.item(t, s?.id);
262
- }, [m]);
263
- const u = ve(t, a, [r.value, r.children, a], r.keywords), I = Z(), b = P((p) => p.value && p.value === u.current), C = P(
264
- (p) => m || d.filter() === !1 ? !0 : p.search ? p.filtered.items.get(t) > 0 : !0
262
+ }), ke = c.forwardRef((t, n) => {
263
+ const { id: r } = t, i = c.useRef(null), u = c.useContext(ve), f = G(), s = ge(t), v = s.current?.forceMount ?? u?.forceMount;
264
+ _(() => {
265
+ if (!v)
266
+ return f.item(r, u?.id);
267
+ }, [v]);
268
+ const d = pe(r, i, [t.value, t.children, i], t.keywords), S = te(), C = V((b) => b.value && b.value === d.current), y = V(
269
+ (b) => v || f.filter() === !1 ? !0 : b.search ? b.filtered.items.get(r) > 0 : !0
265
270
  );
266
271
  c.useEffect(() => {
267
- const p = a.current;
268
- if (!p || r.disabled) return;
269
- const w = () => x("keyboard");
270
- return p.addEventListener(X, w), () => p.removeEventListener(X, w);
271
- }, [C, r.onSelect, r.disabled]);
272
- function x(p = "click") {
273
- E(), f.current.onSelect?.({ value: u.current, trigger: p });
274
- }
275
- function E() {
276
- I.setState("value", u.current, !0);
277
- }
278
- if (!C) return null;
279
- const { disabled: _, value: he, onSelect: B, forceMount: N, keywords: ee, ...U } = r;
280
- return /* @__PURE__ */ h(
281
- R.div,
272
+ const b = i.current;
273
+ if (!b || t.disabled) return;
274
+ const I = () => R("keyboard");
275
+ return b.addEventListener(Z, I), () => b.removeEventListener(Z, I);
276
+ }, [y, t.onSelect, t.disabled]);
277
+ const w = ae(() => {
278
+ S.setState("value", d.current, !0);
279
+ }, [S, d]), R = ae(
280
+ (b = "click") => {
281
+ w(), s.current.onSelect?.({ value: d.current, trigger: b });
282
+ },
283
+ [w, s, d]
284
+ );
285
+ if (!y) return null;
286
+ const { disabled: L, value: N, onSelect: re, forceMount: U, keywords: h, ...$ } = t, j = Ee(() => O([i, n]), [i, n]);
287
+ return /* @__PURE__ */ g(
288
+ k.div,
282
289
  {
283
- ref: F([a, n]),
284
- ...U,
285
- id: t,
290
+ ref: j,
291
+ ...$,
292
+ id: r,
286
293
  "cmdk-item": "",
287
294
  role: "option",
288
- "aria-disabled": !!_,
289
- "aria-selected": !!b,
290
- "data-disabled": !!_,
291
- "data-selected": !!b,
292
- onPointerMove: _ || d.getDisablePointerSelection() ? void 0 : E,
293
- onClick: _ ? void 0 : () => x(),
294
- onFocus: _ ? void 0 : E,
295
- children: r.children
295
+ "aria-disabled": !!L,
296
+ "aria-selected": !!C,
297
+ "data-disabled": !!L,
298
+ "data-selected": !!C,
299
+ onPointerMove: L || f.getDisablePointerSelection() ? void 0 : w,
300
+ onClick: L ? void 0 : R,
301
+ onFocus: L ? void 0 : w,
302
+ children: t.children
296
303
  }
297
304
  );
298
- }), Ie = c.forwardRef((r, n) => {
299
- const { heading: t, children: a, forceMount: s, ...d } = r, f = T(), m = c.useRef(null), u = c.useRef(null), I = T(), b = O(), C = P(
300
- (E) => s || b.filter() === !1 ? !0 : E.search ? E.filtered.groups.has(f) : !0
305
+ }), Ae = c.forwardRef((t, n) => {
306
+ const { heading: r, children: i, forceMount: u, ...f } = t, s = F(), v = c.useRef(null), d = c.useRef(null), S = F(), C = G(), y = V(
307
+ (R) => u || C.filter() === !1 ? !0 : R.search ? R.filtered.groups.has(s) : !0
301
308
  );
302
- A(() => b.group(f), []), ve(f, m, [r.value, r.heading, u]);
303
- const x = c.useMemo(() => ({ id: f, forceMount: s }), [s]);
304
- return /* @__PURE__ */ Y(
305
- R.div,
309
+ _(() => C.group(s), []), pe(s, v, [t.value, t.heading, d]);
310
+ const w = c.useMemo(() => ({ id: s, forceMount: u }), [u]);
311
+ return /* @__PURE__ */ ee(
312
+ k.div,
306
313
  {
307
- ref: F([m, n]),
308
- ...d,
314
+ ref: O([v, n]),
315
+ ...f,
309
316
  "cmdk-group": "",
310
317
  role: "presentation",
311
- hidden: C ? void 0 : !0,
318
+ hidden: y ? void 0 : !0,
312
319
  children: [
313
- t && /* @__PURE__ */ h("div", { ref: u, "cmdk-group-heading": "", "aria-hidden": !0, id: I, children: t }),
314
- K(r, (E) => (
320
+ r && /* @__PURE__ */ g("div", { ref: d, "cmdk-group-heading": "", "aria-hidden": !0, id: S, children: r }),
321
+ B(t, (R) => (
315
322
  // biome-ignore lint/a11y/useSemanticElements: <explanation>
316
- /* @__PURE__ */ h("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? I : void 0, children: /* @__PURE__ */ h(de.Provider, { value: x, children: E }) })
323
+ /* @__PURE__ */ g("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": r ? S : void 0, children: /* @__PURE__ */ g(ve.Provider, { value: w, children: R }) })
317
324
  ))
318
325
  ]
319
326
  }
320
327
  );
321
- }), xe = c.forwardRef((r, n) => {
322
- const { alwaysRender: t, ...a } = r, s = c.useRef(null), d = P((f) => !f.search);
323
- return !t && !d ? null : /* @__PURE__ */ h(
324
- R.div,
328
+ }), _e = c.forwardRef((t, n) => {
329
+ const { alwaysRender: r, ...i } = t, u = c.useRef(null), f = V((s) => !s.search);
330
+ return !r && !f ? null : /* @__PURE__ */ g(
331
+ k.div,
325
332
  {
326
- ref: F([s, n]),
327
- ...a,
333
+ ref: O([u, n]),
334
+ ...i,
328
335
  "cmdk-separator": "",
329
336
  role: "separator"
330
337
  }
331
338
  );
332
- }), ke = c.forwardRef((r, n) => {
333
- const { onValueChange: t, ...a } = r, s = r.value != null, d = Z(), f = P((u) => u.search), m = O();
339
+ }), Le = c.forwardRef((t, n) => {
340
+ const { onValueChange: r, ...i } = t, u = t.value != null, f = te(), s = V((d) => d.search), v = G();
334
341
  return c.useEffect(() => {
335
- r.value != null && d.setState("search", r.value);
336
- }, [r.value]), /* @__PURE__ */ h(
337
- R.input,
342
+ t.value != null && f.setState("search", t.value);
343
+ }, [t.value]), /* @__PURE__ */ g(
344
+ k.input,
338
345
  {
339
346
  ref: n,
340
- ...a,
347
+ ...i,
341
348
  "cmdk-input": "",
342
349
  autoComplete: "off",
343
350
  autoCorrect: "off",
@@ -345,147 +352,147 @@ const D = '[cmdk-group=""]', Q = '[cmdk-group-items=""]', we = '[cmdk-group-head
345
352
  "aria-autocomplete": "list",
346
353
  role: "combobox",
347
354
  "aria-expanded": !0,
348
- "aria-controls": m.listId,
349
- "aria-labelledby": m.labelId,
350
- id: m.inputId,
355
+ "aria-controls": v.listId,
356
+ "aria-labelledby": v.labelId,
357
+ id: v.inputId,
351
358
  type: "text",
352
- value: s ? r.value : f,
353
- onChange: (u) => {
354
- s || d.setState("search", u.target.value), t?.(u.target.value);
359
+ value: u ? t.value : s,
360
+ onChange: (d) => {
361
+ u || f.setState("search", d.target.value), r?.(d.target.value);
355
362
  }
356
363
  }
357
364
  );
358
- }), Ae = c.forwardRef((r, n) => {
359
- const { children: t, label: a = "Suggestions", ...s } = r, d = c.useRef(null), f = c.useRef(null), m = O();
365
+ }), Me = c.forwardRef((t, n) => {
366
+ const { children: r, label: i = "Suggestions", ...u } = t, f = c.useRef(null), s = c.useRef(null), v = G();
360
367
  return c.useEffect(() => {
361
- if (f.current && d.current) {
362
- const u = f.current, I = d.current;
363
- let b;
364
- const C = new ResizeObserver(() => {
365
- b = requestAnimationFrame(() => {
366
- const x = u.offsetHeight;
367
- I.style.setProperty("--cmdk-list-height", x.toFixed(1) + "px");
368
+ if (s.current && f.current) {
369
+ const d = s.current, S = f.current;
370
+ let C;
371
+ const y = new ResizeObserver(() => {
372
+ C = requestAnimationFrame(() => {
373
+ const w = d.offsetHeight;
374
+ S.style.setProperty("--cmdk-list-height", w.toFixed(1) + "px");
368
375
  });
369
376
  });
370
- return C.observe(u), () => {
371
- cancelAnimationFrame(b), C.unobserve(u);
377
+ return y.observe(d), () => {
378
+ cancelAnimationFrame(C), y.unobserve(d);
372
379
  };
373
380
  }
374
- }, []), /* @__PURE__ */ h(
375
- R.div,
381
+ }, []), /* @__PURE__ */ g(
382
+ k.div,
376
383
  {
377
- ref: F([d, n]),
378
- ...s,
384
+ ref: O([f, n]),
385
+ ...u,
379
386
  "cmdk-list": "",
380
387
  tabIndex: -1,
381
- "aria-label": a,
382
- id: m.listId,
383
- children: K(r, (u) => /* @__PURE__ */ h("div", { ref: F([f, m.listInnerRef]), "cmdk-list-sizer": "", children: u }))
388
+ "aria-label": i,
389
+ id: v.listId,
390
+ children: B(t, (d) => /* @__PURE__ */ g("div", { ref: O([s, v.listInnerRef]), "cmdk-list-sizer": "", children: d }))
384
391
  }
385
392
  );
386
- }), _e = c.forwardRef((r, n) => {
387
- const { open: t, onOpenChange: a, overlayClassName: s, contentClassName: d, container: f, ...m } = r;
388
- return /* @__PURE__ */ h(G.Root, { open: t, onOpenChange: a, children: /* @__PURE__ */ Y(G.Portal, { container: f, children: [
389
- /* @__PURE__ */ h(G.Overlay, { "cmdk-overlay": "", className: s }),
390
- /* @__PURE__ */ h(G.Content, { "aria-label": r.label, "cmdk-dialog": "", className: d, children: /* @__PURE__ */ h(fe, { ref: n, ...m }) })
393
+ }), Pe = c.forwardRef((t, n) => {
394
+ const { open: r, onOpenChange: i, overlayClassName: u, contentClassName: f, container: s, ...v } = t;
395
+ return /* @__PURE__ */ g(K.Root, { open: r, onOpenChange: i, children: /* @__PURE__ */ ee(K.Portal, { container: s, children: [
396
+ /* @__PURE__ */ g(K.Overlay, { "cmdk-overlay": "", className: u }),
397
+ /* @__PURE__ */ g(K.Content, { "aria-label": t.label, "cmdk-dialog": "", className: f, children: /* @__PURE__ */ g(he, { ref: n, ...v }) })
391
398
  ] }) });
392
- }), Le = c.forwardRef((r, n) => P((a) => a.filtered.count === 0) ? /* @__PURE__ */ h(R.div, { ref: n, ...r, "cmdk-empty": "", role: "presentation" }) : null), Me = c.forwardRef((r, n) => {
393
- const { progress: t, children: a, label: s = "Loading...", ...d } = r;
394
- return /* @__PURE__ */ h(
395
- R.div,
399
+ }), Ve = c.forwardRef((t, n) => V((i) => i.filtered.count === 0) ? /* @__PURE__ */ g(k.div, { ref: n, ...t, "cmdk-empty": "", role: "presentation" }) : null), De = c.forwardRef((t, n) => {
400
+ const { progress: r, children: i, label: u = "Loading...", ...f } = t;
401
+ return /* @__PURE__ */ g(
402
+ k.div,
396
403
  {
397
404
  ref: n,
398
- ...d,
405
+ ...f,
399
406
  "cmdk-loading": "",
400
407
  role: "progressbar",
401
- "aria-valuenow": t,
408
+ "aria-valuenow": r,
402
409
  "aria-valuemin": 0,
403
410
  "aria-valuemax": 100,
404
- "aria-label": s,
405
- children: K(r, (f) => /* @__PURE__ */ h("div", { "aria-hidden": !0, children: f }))
411
+ "aria-label": u,
412
+ children: B(t, (s) => /* @__PURE__ */ g("div", { "aria-hidden": !0, children: s }))
406
413
  }
407
414
  );
408
- }), je = Object.assign(fe, {
409
- List: Ae,
410
- Item: Re,
411
- Input: ke,
412
- Group: Ie,
413
- Separator: xe,
414
- Dialog: _e,
415
- Empty: Le,
416
- Loading: Me
415
+ }), We = Object.assign(he, {
416
+ List: Me,
417
+ Item: ke,
418
+ Input: Le,
419
+ Group: Ae,
420
+ Separator: _e,
421
+ Dialog: Pe,
422
+ Empty: Ve,
423
+ Loading: De
417
424
  });
418
- function Pe(r, n) {
419
- let t = r.nextElementSibling;
420
- for (; t; ) {
421
- if (t.matches(n)) return t;
422
- t = t.nextElementSibling;
425
+ function Te(t, n) {
426
+ let r = t.nextElementSibling;
427
+ for (; r; ) {
428
+ if (r.matches(n)) return r;
429
+ r = r.nextElementSibling;
423
430
  }
424
431
  }
425
- function Ve(r, n) {
426
- let t = r.previousElementSibling;
427
- for (; t; ) {
428
- if (t.matches(n)) return t;
429
- t = t.previousElementSibling;
432
+ function Fe(t, n) {
433
+ let r = t.previousElementSibling;
434
+ for (; r; ) {
435
+ if (r.matches(n)) return r;
436
+ r = r.previousElementSibling;
430
437
  }
431
438
  }
432
- function me(r) {
433
- const n = c.useRef(r);
434
- return A(() => {
435
- n.current = r;
439
+ function ge(t) {
440
+ const n = c.useRef(t);
441
+ return _(() => {
442
+ n.current = t;
436
443
  }), n;
437
444
  }
438
- const A = typeof window > "u" ? c.useEffect : c.useLayoutEffect;
439
- function M(r) {
445
+ const _ = typeof window > "u" ? c.useEffect : c.useLayoutEffect;
446
+ function P(t) {
440
447
  const n = c.useRef(void 0);
441
- return n.current === void 0 && (n.current = r()), n;
448
+ return n.current === void 0 && (n.current = t()), n;
442
449
  }
443
- function F(r) {
450
+ function O(t) {
444
451
  return (n) => {
445
- r.forEach((t) => {
446
- typeof t == "function" ? t(n) : t != null && (t.current = n);
452
+ t.forEach((r) => {
453
+ typeof r == "function" ? r(n) : r != null && (r.current = n);
447
454
  });
448
455
  };
449
456
  }
450
- function P(r) {
451
- const n = Z(), t = () => r(n.snapshot());
452
- return Se.useSyncExternalStore(n.subscribe, t, t);
457
+ function V(t) {
458
+ const n = te(), r = () => t(n.snapshot());
459
+ return we.useSyncExternalStore(n.subscribe, r, r);
453
460
  }
454
- function ve(r, n, t, a = []) {
455
- const s = c.useRef(void 0), d = O();
456
- return A(() => {
457
- const f = (() => {
458
- for (const u of t) {
459
- if (typeof u == "string")
460
- return u.trim();
461
- if (typeof u == "object" && "current" in u)
462
- return u.current ? u.current.textContent?.trim() : s.current;
461
+ function pe(t, n, r, i = []) {
462
+ const u = c.useRef(void 0), f = G();
463
+ return _(() => {
464
+ const s = (() => {
465
+ for (const d of r) {
466
+ if (typeof d == "string")
467
+ return d.trim();
468
+ if (typeof d == "object" && "current" in d)
469
+ return d.current ? d.current.textContent?.trim() : u.current;
463
470
  }
464
- })(), m = a.map((u) => u.trim());
465
- d.value(r, f, m), n.current?.setAttribute(L, f), s.current = f;
466
- }), s;
471
+ })(), v = i.map((d) => d.trim());
472
+ f.value(t, s, v), n.current?.setAttribute(M, s), u.current = s;
473
+ }), u;
467
474
  }
468
- const De = () => {
469
- const [r, n] = c.useState(), t = M(() => /* @__PURE__ */ new Map());
470
- return A(() => {
471
- t.current.forEach((a) => a()), t.current = /* @__PURE__ */ new Map();
472
- }, [r]), (a, s) => {
473
- t.current.set(a, s), n({});
475
+ const Oe = () => {
476
+ const [t, n] = c.useState(), r = P(() => /* @__PURE__ */ new Map());
477
+ return _(() => {
478
+ r.current.forEach((i) => i()), r.current = /* @__PURE__ */ new Map();
479
+ }, [t]), (i, u) => {
480
+ r.current.set(i, u), n({});
474
481
  };
475
482
  };
476
- function Te(r) {
477
- const n = r.type;
478
- return typeof n == "function" ? n(r.props) : "render" in n ? n.render(r.props) : r;
483
+ function Ge(t) {
484
+ const n = t.type;
485
+ return typeof n == "function" ? n(t.props) : "render" in n ? n.render(t.props) : t;
479
486
  }
480
- function K({ asChild: r, children: n }, t) {
481
- return r && c.isValidElement(n) ? c.cloneElement(
482
- Te(n),
487
+ function B({ asChild: t, children: n }, r) {
488
+ return t && c.isValidElement(n) ? c.cloneElement(
489
+ Ge(n),
483
490
  { ref: n.ref },
484
491
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
485
- t(n.props.children)
486
- ) : t(n);
492
+ r(n.props.children)
493
+ ) : r(n);
487
494
  }
488
- const Fe = {
495
+ const Ke = {
489
496
  position: "absolute",
490
497
  width: "1px",
491
498
  height: "1px",
@@ -497,15 +504,16 @@ const Fe = {
497
504
  borderWidth: "0"
498
505
  };
499
506
  export {
500
- je as Command,
501
- _e as CommandDialog,
502
- Le as CommandEmpty,
503
- ke as CommandInput,
504
- Re as CommandItem,
505
- Ae as CommandList,
506
- Me as CommandLoading,
507
- fe as CommandRoot,
508
- xe as CommandSeparator,
509
- ye as defaultFilter,
510
- P as useCommandState
507
+ We as Command,
508
+ Pe as CommandDialog,
509
+ Ve as CommandEmpty,
510
+ Le as CommandInput,
511
+ ke as CommandItem,
512
+ Me as CommandList,
513
+ De as CommandLoading,
514
+ he as CommandRoot,
515
+ _e as CommandSeparator,
516
+ xe as defaultFilter,
517
+ V as useCommandState,
518
+ te as useCommandStore
511
519
  };