@still-forest/canopy 0.42.0 → 0.43.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.
@@ -1,3163 +0,0 @@
1
- import { j as r } from "./jsx-runtime-B0GD0xBr.js";
2
- import { e as Q, J as ge, aa as ft, K as te, M as _, U as T, ab as U, G as Me, H as pe, ac as Et, B as Ae, Q as jt, ad as De, L as fe, ae as _t, af as Nt, ag as Pt, ah as po, b as Oe, c as ue, ai as Tt, aj as fo, ak as mo, al as oe, am as ho, an as vo, ao as go, ap as xo, aq as bo, ar as So, as as wo, at as yo, au as Co, av as Io, aw as Mt, R as Ro, P as ko, O as Eo, w as jo, ax as Ee, ay as _o } from "./sidebar-Dub2Iudi.js";
3
- import * as c from "react";
4
- import { useState as we, useEffect as mt, useRef as No, useMemo as wt, useId as Po } from "react";
5
- import { F as re, G as To } from "./Layout-CvVv48kM.js";
6
- import { T as tt } from "./Heading-DjVutKs1.js";
7
- import { L as Mo } from "./Loader-DDhZhyvW.js";
8
- import { c as B } from "./index-CRiPKpXj.js";
9
- import * as At from "react-dom";
10
- /**
11
- * @license lucide-react v0.544.0 - ISC
12
- *
13
- * This source code is licensed under the ISC license.
14
- * See the LICENSE file in the root directory of this source tree.
15
- */
16
- const Ao = [
17
- ["path", { d: "M8 2v4", key: "1cmpym" }],
18
- ["path", { d: "M16 2v4", key: "4m81vk" }],
19
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
20
- ["path", { d: "M3 10h18", key: "8toen8" }]
21
- ], Do = Q("calendar", Ao);
22
- /**
23
- * @license lucide-react v0.544.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */
28
- const Oo = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], ht = Q("check", Oo);
29
- /**
30
- * @license lucide-react v0.544.0 - ISC
31
- *
32
- * This source code is licensed under the ISC license.
33
- * See the LICENSE file in the root directory of this source tree.
34
- */
35
- const Lo = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], Fo = Q("chevron-up", Lo);
36
- /**
37
- * @license lucide-react v0.544.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */
42
- const Bo = [
43
- ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
44
- ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
45
- ], $o = Q("chevrons-up-down", Bo);
46
- /**
47
- * @license lucide-react v0.544.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */
52
- const Vo = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]], Ko = Q("circle", Vo);
53
- /**
54
- * @license lucide-react v0.544.0 - ISC
55
- *
56
- * This source code is licensed under the ISC license.
57
- * See the LICENSE file in the root directory of this source tree.
58
- */
59
- const Ho = [
60
- ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
61
- [
62
- "path",
63
- {
64
- d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
65
- key: "116196"
66
- }
67
- ],
68
- ["path", { d: "m9 14 2 2 4-4", key: "df797q" }]
69
- ], Uo = Q("clipboard-check", Ho);
70
- /**
71
- * @license lucide-react v0.544.0 - ISC
72
- *
73
- * This source code is licensed under the ISC license.
74
- * See the LICENSE file in the root directory of this source tree.
75
- */
76
- const Go = [
77
- ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
78
- [
79
- "path",
80
- {
81
- d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
82
- key: "116196"
83
- }
84
- ]
85
- ], zo = Q("clipboard", Go);
86
- /**
87
- * @license lucide-react v0.544.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */
92
- const Wo = [
93
- [
94
- "path",
95
- {
96
- d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
97
- key: "ct8e1f"
98
- }
99
- ],
100
- ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
101
- [
102
- "path",
103
- {
104
- d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
105
- key: "13bj9a"
106
- }
107
- ],
108
- ["path", { d: "m2 2 20 20", key: "1ooewy" }]
109
- ], qo = Q("eye-off", Wo);
110
- /**
111
- * @license lucide-react v0.544.0 - ISC
112
- *
113
- * This source code is licensed under the ISC license.
114
- * See the LICENSE file in the root directory of this source tree.
115
- */
116
- const Yo = [
117
- [
118
- "path",
119
- {
120
- d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
121
- key: "1nclc0"
122
- }
123
- ],
124
- ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
125
- ], Xo = Q("eye", Yo);
126
- /**
127
- * @license lucide-react v0.544.0 - ISC
128
- *
129
- * This source code is licensed under the ISC license.
130
- * See the LICENSE file in the root directory of this source tree.
131
- */
132
- const Zo = [
133
- [
134
- "path",
135
- {
136
- d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
137
- key: "1c8476"
138
- }
139
- ],
140
- ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
141
- ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
142
- ], Jo = Q("save", Zo);
143
- /**
144
- * @license lucide-react v0.544.0 - ISC
145
- *
146
- * This source code is licensed under the ISC license.
147
- * See the LICENSE file in the root directory of this source tree.
148
- */
149
- const Qo = [
150
- ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
151
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
152
- ], Dt = Q("search", Qo);
153
- /**
154
- * @license lucide-react v0.544.0 - ISC
155
- *
156
- * This source code is licensed under the ISC license.
157
- * See the LICENSE file in the root directory of this source tree.
158
- */
159
- const er = [
160
- [
161
- "path",
162
- {
163
- d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
164
- key: "1ffxy3"
165
- }
166
- ],
167
- ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
168
- ], qe = Q("send", er);
169
- /**
170
- * @license lucide-react v0.544.0 - ISC
171
- *
172
- * This source code is licensed under the ISC license.
173
- * See the LICENSE file in the root directory of this source tree.
174
- */
175
- const tr = [
176
- ["path", { d: "M10 11v6", key: "nco0om" }],
177
- ["path", { d: "M14 11v6", key: "outv1u" }],
178
- ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
179
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
180
- ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
181
- ], nr = Q("trash-2", tr);
182
- var Ye = "rovingFocusGroup.onEntryFocus", or = { bubbles: !1, cancelable: !0 }, je = "RovingFocusGroup", [nt, Ot, rr] = ft(je), [ar, Lt] = ge(
183
- je,
184
- [rr]
185
- ), [sr, ir] = ar(je), Ft = c.forwardRef(
186
- (e, n) => /* @__PURE__ */ r.jsx(nt.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(nt.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(cr, { ...e, ref: n }) }) })
187
- );
188
- Ft.displayName = je;
189
- var cr = c.forwardRef((e, n) => {
190
- const {
191
- __scopeRovingFocusGroup: t,
192
- orientation: a,
193
- loop: o = !1,
194
- dir: i,
195
- currentTabStopId: s,
196
- defaultCurrentTabStopId: l,
197
- onCurrentTabStopIdChange: d,
198
- onEntryFocus: u,
199
- preventScrollOnEntryFocus: f = !1,
200
- ...p
201
- } = e, h = c.useRef(null), x = U(n, h), S = Me(i), [m, v] = pe({
202
- prop: s,
203
- defaultProp: l ?? null,
204
- onChange: d,
205
- caller: je
206
- }), [b, w] = c.useState(!1), y = Et(u), R = Ot(t), M = c.useRef(!1), [N, E] = c.useState(0);
207
- return c.useEffect(() => {
208
- const L = h.current;
209
- if (L)
210
- return L.addEventListener(Ye, y), () => L.removeEventListener(Ye, y);
211
- }, [y]), /* @__PURE__ */ r.jsx(
212
- sr,
213
- {
214
- scope: t,
215
- orientation: a,
216
- dir: S,
217
- loop: o,
218
- currentTabStopId: m,
219
- onItemFocus: c.useCallback(
220
- (L) => v(L),
221
- [v]
222
- ),
223
- onItemShiftTab: c.useCallback(() => w(!0), []),
224
- onFocusableItemAdd: c.useCallback(
225
- () => E((L) => L + 1),
226
- []
227
- ),
228
- onFocusableItemRemove: c.useCallback(
229
- () => E((L) => L - 1),
230
- []
231
- ),
232
- children: /* @__PURE__ */ r.jsx(
233
- _.div,
234
- {
235
- tabIndex: b || N === 0 ? -1 : 0,
236
- "data-orientation": a,
237
- ...p,
238
- ref: x,
239
- style: { outline: "none", ...e.style },
240
- onMouseDown: T(e.onMouseDown, () => {
241
- M.current = !0;
242
- }),
243
- onFocus: T(e.onFocus, (L) => {
244
- const P = !M.current;
245
- if (L.target === L.currentTarget && P && !b) {
246
- const H = new CustomEvent(Ye, or);
247
- if (L.currentTarget.dispatchEvent(H), !H.defaultPrevented) {
248
- const A = R().filter((F) => F.focusable), K = A.find((F) => F.active), X = A.find((F) => F.id === m), W = [K, X, ...A].filter(
249
- Boolean
250
- ).map((F) => F.ref.current);
251
- Vt(W, f);
252
- }
253
- }
254
- M.current = !1;
255
- }),
256
- onBlur: T(e.onBlur, () => w(!1))
257
- }
258
- )
259
- }
260
- );
261
- }), Bt = "RovingFocusGroupItem", $t = c.forwardRef(
262
- (e, n) => {
263
- const {
264
- __scopeRovingFocusGroup: t,
265
- focusable: a = !0,
266
- active: o = !1,
267
- tabStopId: i,
268
- children: s,
269
- ...l
270
- } = e, d = te(), u = i || d, f = ir(Bt, t), p = f.currentTabStopId === u, h = Ot(t), { onFocusableItemAdd: x, onFocusableItemRemove: S, currentTabStopId: m } = f;
271
- return c.useEffect(() => {
272
- if (a)
273
- return x(), () => S();
274
- }, [a, x, S]), /* @__PURE__ */ r.jsx(
275
- nt.ItemSlot,
276
- {
277
- scope: t,
278
- id: u,
279
- focusable: a,
280
- active: o,
281
- children: /* @__PURE__ */ r.jsx(
282
- _.span,
283
- {
284
- tabIndex: p ? 0 : -1,
285
- "data-orientation": f.orientation,
286
- ...l,
287
- ref: n,
288
- onMouseDown: T(e.onMouseDown, (v) => {
289
- a ? f.onItemFocus(u) : v.preventDefault();
290
- }),
291
- onFocus: T(e.onFocus, () => f.onItemFocus(u)),
292
- onKeyDown: T(e.onKeyDown, (v) => {
293
- if (v.key === "Tab" && v.shiftKey) {
294
- f.onItemShiftTab();
295
- return;
296
- }
297
- if (v.target !== v.currentTarget) return;
298
- const b = ur(v, f.orientation, f.dir);
299
- if (b !== void 0) {
300
- if (v.metaKey || v.ctrlKey || v.altKey || v.shiftKey) return;
301
- v.preventDefault();
302
- let y = h().filter((R) => R.focusable).map((R) => R.ref.current);
303
- if (b === "last") y.reverse();
304
- else if (b === "prev" || b === "next") {
305
- b === "prev" && y.reverse();
306
- const R = y.indexOf(v.currentTarget);
307
- y = f.loop ? pr(y, R + 1) : y.slice(R + 1);
308
- }
309
- setTimeout(() => Vt(y));
310
- }
311
- }),
312
- children: typeof s == "function" ? s({ isCurrentTabStop: p, hasTabStop: m != null }) : s
313
- }
314
- )
315
- }
316
- );
317
- }
318
- );
319
- $t.displayName = Bt;
320
- var lr = {
321
- ArrowLeft: "prev",
322
- ArrowUp: "prev",
323
- ArrowRight: "next",
324
- ArrowDown: "next",
325
- PageUp: "first",
326
- Home: "first",
327
- PageDown: "last",
328
- End: "last"
329
- };
330
- function dr(e, n) {
331
- return n !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
332
- }
333
- function ur(e, n, t) {
334
- const a = dr(e.key, t);
335
- if (!(n === "vertical" && ["ArrowLeft", "ArrowRight"].includes(a)) && !(n === "horizontal" && ["ArrowUp", "ArrowDown"].includes(a)))
336
- return lr[a];
337
- }
338
- function Vt(e, n = !1) {
339
- const t = document.activeElement;
340
- for (const a of e)
341
- if (a === t || (a.focus({ preventScroll: n }), document.activeElement !== t)) return;
342
- }
343
- function pr(e, n) {
344
- return e.map((t, a) => e[(n + a) % e.length]);
345
- }
346
- var fr = Ft, mr = $t;
347
- const As = ({ disabled: e = !1, handleDelete: n, ...t }) => /* @__PURE__ */ r.jsx(
348
- Ae,
349
- {
350
- disabled: e,
351
- icon: /* @__PURE__ */ r.jsx(nr, {}),
352
- onClick: n,
353
- variant: "outline",
354
- ...t,
355
- className: "border-destructive text-destructive hover:bg-destructive hover:text-white",
356
- children: "Delete"
357
- }
358
- ), yt = {
359
- default: { label: "Submit", submittingLabel: "Submitting", IconComponent: qe },
360
- submit: { label: "Submit", submittingLabel: "Submitting", IconComponent: qe },
361
- save: { label: "Save", submittingLabel: "Saving", IconComponent: Jo },
362
- send: { label: "Send", submittingLabel: "Sending", IconComponent: qe }
363
- }, Ds = ({
364
- submitting: e = !1,
365
- disabled: n = !1,
366
- submittingIcon: t,
367
- action: a = "default",
368
- label: o,
369
- submittingLabel: i,
370
- icon: s,
371
- noIcon: l = !1,
372
- ...d
373
- }) => {
374
- if (!yt[a])
375
- throw new Error(`Invalid action: ${a}`);
376
- const u = yt[a], f = o || u.label, p = i || u.submittingLabel, h = s || u.IconComponent, x = e ? /* @__PURE__ */ r.jsx(Mo, { icon: t }) : /* @__PURE__ */ r.jsx(h, {});
377
- return /* @__PURE__ */ r.jsx(
378
- Ae,
379
- {
380
- disabled: n || e,
381
- icon: l ? void 0 : x,
382
- type: "submit",
383
- variant: "primary",
384
- ...d,
385
- children: e ? p : f
386
- }
387
- );
388
- };
389
- function _e(e) {
390
- const n = c.useRef({ value: e, previous: e });
391
- return c.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
392
- }
393
- var Le = "Checkbox", [hr, Os] = ge(Le), [vr, vt] = hr(Le);
394
- function gr(e) {
395
- const {
396
- __scopeCheckbox: n,
397
- checked: t,
398
- children: a,
399
- defaultChecked: o,
400
- disabled: i,
401
- form: s,
402
- name: l,
403
- onCheckedChange: d,
404
- required: u,
405
- value: f = "on",
406
- // @ts-expect-error
407
- internal_do_not_use_render: p
408
- } = e, [h, x] = pe({
409
- prop: t,
410
- defaultProp: o ?? !1,
411
- onChange: d,
412
- caller: Le
413
- }), [S, m] = c.useState(null), [v, b] = c.useState(null), w = c.useRef(!1), y = S ? !!s || !!S.closest("form") : (
414
- // We set this to true by default so that events bubble to forms without JS (SSR)
415
- !0
416
- ), R = {
417
- checked: h,
418
- disabled: i,
419
- setChecked: x,
420
- control: S,
421
- setControl: m,
422
- name: l,
423
- form: s,
424
- value: f,
425
- hasConsumerStoppedPropagationRef: w,
426
- required: u,
427
- defaultChecked: ne(o) ? !1 : o,
428
- isFormControl: y,
429
- bubbleInput: v,
430
- setBubbleInput: b
431
- };
432
- return /* @__PURE__ */ r.jsx(
433
- vr,
434
- {
435
- scope: n,
436
- ...R,
437
- children: xr(p) ? p(R) : a
438
- }
439
- );
440
- }
441
- var Kt = "CheckboxTrigger", Ht = c.forwardRef(
442
- ({ __scopeCheckbox: e, onKeyDown: n, onClick: t, ...a }, o) => {
443
- const {
444
- control: i,
445
- value: s,
446
- disabled: l,
447
- checked: d,
448
- required: u,
449
- setControl: f,
450
- setChecked: p,
451
- hasConsumerStoppedPropagationRef: h,
452
- isFormControl: x,
453
- bubbleInput: S
454
- } = vt(Kt, e), m = U(o, f), v = c.useRef(d);
455
- return c.useEffect(() => {
456
- const b = i?.form;
457
- if (b) {
458
- const w = () => p(v.current);
459
- return b.addEventListener("reset", w), () => b.removeEventListener("reset", w);
460
- }
461
- }, [i, p]), /* @__PURE__ */ r.jsx(
462
- _.button,
463
- {
464
- type: "button",
465
- role: "checkbox",
466
- "aria-checked": ne(d) ? "mixed" : d,
467
- "aria-required": u,
468
- "data-state": Yt(d),
469
- "data-disabled": l ? "" : void 0,
470
- disabled: l,
471
- value: s,
472
- ...a,
473
- ref: m,
474
- onKeyDown: T(n, (b) => {
475
- b.key === "Enter" && b.preventDefault();
476
- }),
477
- onClick: T(t, (b) => {
478
- p((w) => ne(w) ? !0 : !w), S && x && (h.current = b.isPropagationStopped(), h.current || b.stopPropagation());
479
- })
480
- }
481
- );
482
- }
483
- );
484
- Ht.displayName = Kt;
485
- var Ut = c.forwardRef(
486
- (e, n) => {
487
- const {
488
- __scopeCheckbox: t,
489
- name: a,
490
- checked: o,
491
- defaultChecked: i,
492
- required: s,
493
- disabled: l,
494
- value: d,
495
- onCheckedChange: u,
496
- form: f,
497
- ...p
498
- } = e;
499
- return /* @__PURE__ */ r.jsx(
500
- gr,
501
- {
502
- __scopeCheckbox: t,
503
- checked: o,
504
- defaultChecked: i,
505
- disabled: l,
506
- required: s,
507
- onCheckedChange: u,
508
- name: a,
509
- form: f,
510
- value: d,
511
- internal_do_not_use_render: ({ isFormControl: h }) => /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
512
- /* @__PURE__ */ r.jsx(
513
- Ht,
514
- {
515
- ...p,
516
- ref: n,
517
- __scopeCheckbox: t
518
- }
519
- ),
520
- h && /* @__PURE__ */ r.jsx(
521
- qt,
522
- {
523
- __scopeCheckbox: t
524
- }
525
- )
526
- ] })
527
- }
528
- );
529
- }
530
- );
531
- Ut.displayName = Le;
532
- var Gt = "CheckboxIndicator", zt = c.forwardRef(
533
- (e, n) => {
534
- const { __scopeCheckbox: t, forceMount: a, ...o } = e, i = vt(Gt, t);
535
- return /* @__PURE__ */ r.jsx(
536
- jt,
537
- {
538
- present: a || ne(i.checked) || i.checked === !0,
539
- children: /* @__PURE__ */ r.jsx(
540
- _.span,
541
- {
542
- "data-state": Yt(i.checked),
543
- "data-disabled": i.disabled ? "" : void 0,
544
- ...o,
545
- ref: n,
546
- style: { pointerEvents: "none", ...e.style }
547
- }
548
- )
549
- }
550
- );
551
- }
552
- );
553
- zt.displayName = Gt;
554
- var Wt = "CheckboxBubbleInput", qt = c.forwardRef(
555
- ({ __scopeCheckbox: e, ...n }, t) => {
556
- const {
557
- control: a,
558
- hasConsumerStoppedPropagationRef: o,
559
- checked: i,
560
- defaultChecked: s,
561
- required: l,
562
- disabled: d,
563
- name: u,
564
- value: f,
565
- form: p,
566
- bubbleInput: h,
567
- setBubbleInput: x
568
- } = vt(Wt, e), S = U(t, x), m = _e(i), v = De(a);
569
- c.useEffect(() => {
570
- const w = h;
571
- if (!w) return;
572
- const y = window.HTMLInputElement.prototype, M = Object.getOwnPropertyDescriptor(
573
- y,
574
- "checked"
575
- ).set, N = !o.current;
576
- if (m !== i && M) {
577
- const E = new Event("click", { bubbles: N });
578
- w.indeterminate = ne(i), M.call(w, ne(i) ? !1 : i), w.dispatchEvent(E);
579
- }
580
- }, [h, m, i, o]);
581
- const b = c.useRef(ne(i) ? !1 : i);
582
- return /* @__PURE__ */ r.jsx(
583
- _.input,
584
- {
585
- type: "checkbox",
586
- "aria-hidden": !0,
587
- defaultChecked: s ?? b.current,
588
- required: l,
589
- disabled: d,
590
- name: u,
591
- value: f,
592
- form: p,
593
- ...n,
594
- tabIndex: -1,
595
- ref: S,
596
- style: {
597
- ...n.style,
598
- ...v,
599
- position: "absolute",
600
- pointerEvents: "none",
601
- opacity: 0,
602
- margin: 0,
603
- // We transform because the input is absolutely positioned but we have
604
- // rendered it **after** the button. This pulls it back to sit on top
605
- // of the button.
606
- transform: "translateX(-100%)"
607
- }
608
- }
609
- );
610
- }
611
- );
612
- qt.displayName = Wt;
613
- function xr(e) {
614
- return typeof e == "function";
615
- }
616
- function ne(e) {
617
- return e === "indeterminate";
618
- }
619
- function Yt(e) {
620
- return ne(e) ? "indeterminate" : e ? "checked" : "unchecked";
621
- }
622
- function br({ className: e, ...n }) {
623
- return /* @__PURE__ */ r.jsx(
624
- Ut,
625
- {
626
- className: B(
627
- "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
628
- e
629
- ),
630
- "data-slot": "checkbox",
631
- ...n,
632
- children: /* @__PURE__ */ r.jsx(
633
- zt,
634
- {
635
- className: "flex items-center justify-center text-current transition-none",
636
- "data-slot": "checkbox-indicator",
637
- children: /* @__PURE__ */ r.jsx(ht, { className: "size-3.5" })
638
- }
639
- )
640
- }
641
- );
642
- }
643
- const Ls = ({ label: e, name: n, value: t, checked: a, onCheckedChange: o }) => {
644
- const [i, s] = we(a);
645
- mt(() => {
646
- s(a);
647
- }, [a]);
648
- let l = n;
649
- const d = t || n;
650
- t && (l += `[${t}]`);
651
- const u = (f) => {
652
- s(f), o?.(f);
653
- };
654
- return /* @__PURE__ */ r.jsxs(re, { align: "center", gap: "2", children: [
655
- /* @__PURE__ */ r.jsx(
656
- br,
657
- {
658
- checked: i,
659
- id: l,
660
- name: n,
661
- onCheckedChange: u,
662
- value: d
663
- }
664
- ),
665
- /* @__PURE__ */ r.jsx(fe, { className: "cursor-pointer", htmlFor: l, children: e })
666
- ] });
667
- }, Fs = ({ content: e, className: n, size: t = "md", ...a }) => {
668
- const [o, i] = we(!1), s = No(null);
669
- mt(() => () => {
670
- s.current && clearTimeout(s.current);
671
- }, []);
672
- const l = () => {
673
- const d = navigator.clipboard?.writeText;
674
- d && (i(!0), d.call(navigator.clipboard, e).then(() => {
675
- s.current && clearTimeout(s.current), s.current = setTimeout(() => {
676
- i(!1), s.current = null;
677
- }, 2e3);
678
- }).catch(() => {
679
- i(!1);
680
- }));
681
- };
682
- return /* @__PURE__ */ r.jsx(
683
- Ae,
684
- {
685
- className: B(
686
- {
687
- "w-[88px]": t === "xs",
688
- "w-[96px]": t === "sm",
689
- "w-[100px]": t === "md",
690
- "w-[125px]": t === "lg",
691
- "w-[144px]": t === "xl"
692
- },
693
- "justify-start",
694
- n
695
- ),
696
- disabled: o,
697
- icon: o ? /* @__PURE__ */ r.jsx(Uo, {}) : /* @__PURE__ */ r.jsx(zo, {}),
698
- label: o ? "Copied" : "Copy",
699
- onClick: l,
700
- size: t,
701
- ...a
702
- }
703
- );
704
- }, Bs = ({ onDateSelection: e, initialValue: n, className: t, size: a = "default", error: o }) => {
705
- const [i, s] = we(n), l = (d) => {
706
- s(d), d && e(d);
707
- };
708
- return /* @__PURE__ */ r.jsxs(re, { direction: "col", gap: "2", children: [
709
- /* @__PURE__ */ r.jsxs(_t, { children: [
710
- /* @__PURE__ */ r.jsx(Nt, { asChild: !0, children: /* @__PURE__ */ r.jsxs(
711
- Ae,
712
- {
713
- className: B("w-[280px] justify-start text-left font-normal", !i && "text-muted-foreground", t),
714
- size: a,
715
- variant: "outline",
716
- children: [
717
- /* @__PURE__ */ r.jsx(Do, { className: "mr-2 h-4 w-4" }),
718
- i ? i.toISOString().split("T")[0] : /* @__PURE__ */ r.jsx("span", { children: "Select a date" })
719
- ]
720
- }
721
- ) }),
722
- /* @__PURE__ */ r.jsx(Pt, { className: "w-auto p-0", children: /* @__PURE__ */ r.jsx(po, { autoFocus: !0, mode: "single", onSelect: l, selected: i }) })
723
- ] }),
724
- o && /* @__PURE__ */ r.jsx(Oe, { message: o })
725
- ] });
726
- }, Sr = ({
727
- label: e,
728
- labelFor: n,
729
- className: t = "",
730
- labelClassName: a = "",
731
- children: o
732
- }) => /* @__PURE__ */ r.jsxs(re, { direction: "col", gap: "2", children: [
733
- e && /* @__PURE__ */ r.jsx(fe, { className: a, htmlFor: n, children: e }),
734
- /* @__PURE__ */ r.jsx(re, { className: `rounded-md border border-input bg-card p-2 shadow-xs ${t}`, gapY: "1", children: o })
735
- ] }), $s = ({
736
- name: e,
737
- size: n = "md",
738
- label: t,
739
- labelOrientation: a = "top",
740
- note: o,
741
- error: i,
742
- ...s
743
- }) => {
744
- const [l, d] = we(!1), u = () => {
745
- d(!l);
746
- };
747
- return /* @__PURE__ */ r.jsxs(re, { className: "w-full", direction: a === "left" ? "row" : "col", gap: "2", children: [
748
- t && /* @__PURE__ */ r.jsx(fe, { className: a === "left" ? "text-nowrap" : "", htmlFor: e, size: n, children: t }),
749
- /* @__PURE__ */ r.jsxs(ue, { children: [
750
- /* @__PURE__ */ r.jsx(ue.Input, { type: l ? "text" : "password", ...s, name: e, size: n }),
751
- /* @__PURE__ */ r.jsx(ue.Addon, { right: !0, children: /* @__PURE__ */ r.jsx(
752
- ue.Button,
753
- {
754
- "aria-label": l ? "Hide password" : "Show password",
755
- asIcon: !0,
756
- onClick: u,
757
- size: "xs",
758
- variant: "ghost",
759
- children: l ? /* @__PURE__ */ r.jsx(Xo, {}) : /* @__PURE__ */ r.jsx(qo, {})
760
- }
761
- ) })
762
- ] }),
763
- o && /* @__PURE__ */ r.jsx(tt, { size: "sm", variant: "muted", children: o }),
764
- i && /* @__PURE__ */ r.jsx(Oe, { message: i })
765
- ] });
766
- };
767
- var gt = "Radio", [wr, Xt] = ge(gt), [yr, Cr] = wr(gt), Zt = c.forwardRef(
768
- (e, n) => {
769
- const {
770
- __scopeRadio: t,
771
- name: a,
772
- checked: o = !1,
773
- required: i,
774
- disabled: s,
775
- value: l = "on",
776
- onCheck: d,
777
- form: u,
778
- ...f
779
- } = e, [p, h] = c.useState(null), x = U(n, (v) => h(v)), S = c.useRef(!1), m = p ? u || !!p.closest("form") : !0;
780
- return /* @__PURE__ */ r.jsxs(yr, { scope: t, checked: o, disabled: s, children: [
781
- /* @__PURE__ */ r.jsx(
782
- _.button,
783
- {
784
- type: "button",
785
- role: "radio",
786
- "aria-checked": o,
787
- "data-state": tn(o),
788
- "data-disabled": s ? "" : void 0,
789
- disabled: s,
790
- value: l,
791
- ...f,
792
- ref: x,
793
- onClick: T(e.onClick, (v) => {
794
- o || d?.(), m && (S.current = v.isPropagationStopped(), S.current || v.stopPropagation());
795
- })
796
- }
797
- ),
798
- m && /* @__PURE__ */ r.jsx(
799
- en,
800
- {
801
- control: p,
802
- bubbles: !S.current,
803
- name: a,
804
- value: l,
805
- checked: o,
806
- required: i,
807
- disabled: s,
808
- form: u,
809
- style: { transform: "translateX(-100%)" }
810
- }
811
- )
812
- ] });
813
- }
814
- );
815
- Zt.displayName = gt;
816
- var Jt = "RadioIndicator", Qt = c.forwardRef(
817
- (e, n) => {
818
- const { __scopeRadio: t, forceMount: a, ...o } = e, i = Cr(Jt, t);
819
- return /* @__PURE__ */ r.jsx(jt, { present: a || i.checked, children: /* @__PURE__ */ r.jsx(
820
- _.span,
821
- {
822
- "data-state": tn(i.checked),
823
- "data-disabled": i.disabled ? "" : void 0,
824
- ...o,
825
- ref: n
826
- }
827
- ) });
828
- }
829
- );
830
- Qt.displayName = Jt;
831
- var Ir = "RadioBubbleInput", en = c.forwardRef(
832
- ({
833
- __scopeRadio: e,
834
- control: n,
835
- checked: t,
836
- bubbles: a = !0,
837
- ...o
838
- }, i) => {
839
- const s = c.useRef(null), l = U(s, i), d = _e(t), u = De(n);
840
- return c.useEffect(() => {
841
- const f = s.current;
842
- if (!f) return;
843
- const p = window.HTMLInputElement.prototype, x = Object.getOwnPropertyDescriptor(
844
- p,
845
- "checked"
846
- ).set;
847
- if (d !== t && x) {
848
- const S = new Event("click", { bubbles: a });
849
- x.call(f, t), f.dispatchEvent(S);
850
- }
851
- }, [d, t, a]), /* @__PURE__ */ r.jsx(
852
- _.input,
853
- {
854
- type: "radio",
855
- "aria-hidden": !0,
856
- defaultChecked: t,
857
- ...o,
858
- tabIndex: -1,
859
- ref: l,
860
- style: {
861
- ...o.style,
862
- ...u,
863
- position: "absolute",
864
- pointerEvents: "none",
865
- opacity: 0,
866
- margin: 0
867
- }
868
- }
869
- );
870
- }
871
- );
872
- en.displayName = Ir;
873
- function tn(e) {
874
- return e ? "checked" : "unchecked";
875
- }
876
- var Rr = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], Fe = "RadioGroup", [kr, Vs] = ge(Fe, [
877
- Lt,
878
- Xt
879
- ]), nn = Lt(), on = Xt(), [Er, jr] = kr(Fe), rn = c.forwardRef(
880
- (e, n) => {
881
- const {
882
- __scopeRadioGroup: t,
883
- name: a,
884
- defaultValue: o,
885
- value: i,
886
- required: s = !1,
887
- disabled: l = !1,
888
- orientation: d,
889
- dir: u,
890
- loop: f = !0,
891
- onValueChange: p,
892
- ...h
893
- } = e, x = nn(t), S = Me(u), [m, v] = pe({
894
- prop: i,
895
- defaultProp: o ?? null,
896
- onChange: p,
897
- caller: Fe
898
- });
899
- return /* @__PURE__ */ r.jsx(
900
- Er,
901
- {
902
- scope: t,
903
- name: a,
904
- required: s,
905
- disabled: l,
906
- value: m,
907
- onValueChange: v,
908
- children: /* @__PURE__ */ r.jsx(
909
- fr,
910
- {
911
- asChild: !0,
912
- ...x,
913
- orientation: d,
914
- dir: S,
915
- loop: f,
916
- children: /* @__PURE__ */ r.jsx(
917
- _.div,
918
- {
919
- role: "radiogroup",
920
- "aria-required": s,
921
- "aria-orientation": d,
922
- "data-disabled": l ? "" : void 0,
923
- dir: S,
924
- ...h,
925
- ref: n
926
- }
927
- )
928
- }
929
- )
930
- }
931
- );
932
- }
933
- );
934
- rn.displayName = Fe;
935
- var an = "RadioGroupItem", sn = c.forwardRef(
936
- (e, n) => {
937
- const { __scopeRadioGroup: t, disabled: a, ...o } = e, i = jr(an, t), s = i.disabled || a, l = nn(t), d = on(t), u = c.useRef(null), f = U(n, u), p = i.value === o.value, h = c.useRef(!1);
938
- return c.useEffect(() => {
939
- const x = (m) => {
940
- Rr.includes(m.key) && (h.current = !0);
941
- }, S = () => h.current = !1;
942
- return document.addEventListener("keydown", x), document.addEventListener("keyup", S), () => {
943
- document.removeEventListener("keydown", x), document.removeEventListener("keyup", S);
944
- };
945
- }, []), /* @__PURE__ */ r.jsx(
946
- mr,
947
- {
948
- asChild: !0,
949
- ...l,
950
- focusable: !s,
951
- active: p,
952
- children: /* @__PURE__ */ r.jsx(
953
- Zt,
954
- {
955
- disabled: s,
956
- required: i.required,
957
- checked: p,
958
- ...d,
959
- ...o,
960
- name: i.name,
961
- ref: f,
962
- onCheck: () => i.onValueChange(o.value),
963
- onKeyDown: T((x) => {
964
- x.key === "Enter" && x.preventDefault();
965
- }),
966
- onFocus: T(o.onFocus, () => {
967
- h.current && u.current?.click();
968
- })
969
- }
970
- )
971
- }
972
- );
973
- }
974
- );
975
- sn.displayName = an;
976
- var _r = "RadioGroupIndicator", cn = c.forwardRef(
977
- (e, n) => {
978
- const { __scopeRadioGroup: t, ...a } = e, o = on(t);
979
- return /* @__PURE__ */ r.jsx(Qt, { ...o, ...a, ref: n });
980
- }
981
- );
982
- cn.displayName = _r;
983
- var Nr = rn, Pr = sn, Tr = cn;
984
- function Mr({ className: e, ...n }) {
985
- return /* @__PURE__ */ r.jsx(Nr, { className: B("grid gap-3", e), "data-slot": "radio-group", ...n });
986
- }
987
- function Ar({ className: e, ...n }) {
988
- return /* @__PURE__ */ r.jsx(
989
- Pr,
990
- {
991
- className: B(
992
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
993
- e
994
- ),
995
- "data-slot": "radio-group-item",
996
- ...n,
997
- children: /* @__PURE__ */ r.jsx(
998
- Tr,
999
- {
1000
- className: "relative flex items-center justify-center",
1001
- "data-slot": "radio-group-indicator",
1002
- children: /* @__PURE__ */ r.jsx(Ko, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" })
1003
- }
1004
- )
1005
- }
1006
- );
1007
- }
1008
- const Ks = ({ label: e, name: n, options: t, value: a, onChange: o, error: i }) => /* @__PURE__ */ r.jsxs(Sr, { className: "flex flex-col gap-4 px-2 py-1", label: e, labelFor: n, children: [
1009
- /* @__PURE__ */ r.jsx(Mr, { className: "w-full", name: n, onValueChange: o, value: a, children: /* @__PURE__ */ r.jsx(To, { cols: "2", children: t.map((s, l) => /* @__PURE__ */ r.jsxs(re, { align: "center", gap: "2", justify: "start", children: [
1010
- /* @__PURE__ */ r.jsx(Ar, { id: s.value, value: s.value }),
1011
- /* @__PURE__ */ r.jsx(fe, { htmlFor: s.value, children: s.label })
1012
- ] }, l)) }) }),
1013
- i && /* @__PURE__ */ r.jsx(Oe, { message: i })
1014
- ] });
1015
- function Pe(e, [n, t]) {
1016
- return Math.min(t, Math.max(n, e));
1017
- }
1018
- var Dr = [" ", "Enter", "ArrowUp", "ArrowDown"], Or = [" ", "Enter"], me = "Select", [Be, $e, Lr] = ft(me), [ye, Hs] = ge(me, [
1019
- Lr,
1020
- Tt
1021
- ]), Ve = Tt(), [Fr, se] = ye(me), [Br, $r] = ye(me), ln = (e) => {
1022
- const {
1023
- __scopeSelect: n,
1024
- children: t,
1025
- open: a,
1026
- defaultOpen: o,
1027
- onOpenChange: i,
1028
- value: s,
1029
- defaultValue: l,
1030
- onValueChange: d,
1031
- dir: u,
1032
- name: f,
1033
- autoComplete: p,
1034
- disabled: h,
1035
- required: x,
1036
- form: S
1037
- } = e, m = Ve(n), [v, b] = c.useState(null), [w, y] = c.useState(null), [R, M] = c.useState(!1), N = Me(u), [E, L] = pe({
1038
- prop: a,
1039
- defaultProp: o ?? !1,
1040
- onChange: i,
1041
- caller: me
1042
- }), [P, H] = pe({
1043
- prop: s,
1044
- defaultProp: l,
1045
- onChange: d,
1046
- caller: me
1047
- }), A = c.useRef(null), K = v ? S || !!v.closest("form") : !0, [X, G] = c.useState(/* @__PURE__ */ new Set()), W = Array.from(X).map((F) => F.props.value).join(";");
1048
- return /* @__PURE__ */ r.jsx(fo, { ...m, children: /* @__PURE__ */ r.jsxs(
1049
- Fr,
1050
- {
1051
- required: x,
1052
- scope: n,
1053
- trigger: v,
1054
- onTriggerChange: b,
1055
- valueNode: w,
1056
- onValueNodeChange: y,
1057
- valueNodeHasChildren: R,
1058
- onValueNodeHasChildrenChange: M,
1059
- contentId: te(),
1060
- value: P,
1061
- onValueChange: H,
1062
- open: E,
1063
- onOpenChange: L,
1064
- dir: N,
1065
- triggerPointerDownPosRef: A,
1066
- disabled: h,
1067
- children: [
1068
- /* @__PURE__ */ r.jsx(Be.Provider, { scope: n, children: /* @__PURE__ */ r.jsx(
1069
- Br,
1070
- {
1071
- scope: e.__scopeSelect,
1072
- onNativeOptionAdd: c.useCallback((F) => {
1073
- G((q) => new Set(q).add(F));
1074
- }, []),
1075
- onNativeOptionRemove: c.useCallback((F) => {
1076
- G((q) => {
1077
- const Y = new Set(q);
1078
- return Y.delete(F), Y;
1079
- });
1080
- }, []),
1081
- children: t
1082
- }
1083
- ) }),
1084
- K ? /* @__PURE__ */ r.jsxs(
1085
- An,
1086
- {
1087
- "aria-hidden": !0,
1088
- required: x,
1089
- tabIndex: -1,
1090
- name: f,
1091
- autoComplete: p,
1092
- value: P,
1093
- onChange: (F) => H(F.target.value),
1094
- disabled: h,
1095
- form: S,
1096
- children: [
1097
- P === void 0 ? /* @__PURE__ */ r.jsx("option", { value: "" }) : null,
1098
- Array.from(X)
1099
- ]
1100
- },
1101
- W
1102
- ) : null
1103
- ]
1104
- }
1105
- ) });
1106
- };
1107
- ln.displayName = me;
1108
- var dn = "SelectTrigger", un = c.forwardRef(
1109
- (e, n) => {
1110
- const { __scopeSelect: t, disabled: a = !1, ...o } = e, i = Ve(t), s = se(dn, t), l = s.disabled || a, d = U(n, s.onTriggerChange), u = $e(t), f = c.useRef("touch"), [p, h, x] = On((m) => {
1111
- const v = u().filter((y) => !y.disabled), b = v.find((y) => y.value === s.value), w = Ln(v, m, b);
1112
- w !== void 0 && s.onValueChange(w.value);
1113
- }), S = (m) => {
1114
- l || (s.onOpenChange(!0), x()), m && (s.triggerPointerDownPosRef.current = {
1115
- x: Math.round(m.pageX),
1116
- y: Math.round(m.pageY)
1117
- });
1118
- };
1119
- return /* @__PURE__ */ r.jsx(mo, { asChild: !0, ...i, children: /* @__PURE__ */ r.jsx(
1120
- _.button,
1121
- {
1122
- type: "button",
1123
- role: "combobox",
1124
- "aria-controls": s.contentId,
1125
- "aria-expanded": s.open,
1126
- "aria-required": s.required,
1127
- "aria-autocomplete": "none",
1128
- dir: s.dir,
1129
- "data-state": s.open ? "open" : "closed",
1130
- disabled: l,
1131
- "data-disabled": l ? "" : void 0,
1132
- "data-placeholder": Dn(s.value) ? "" : void 0,
1133
- ...o,
1134
- ref: d,
1135
- onClick: T(o.onClick, (m) => {
1136
- m.currentTarget.focus(), f.current !== "mouse" && S(m);
1137
- }),
1138
- onPointerDown: T(o.onPointerDown, (m) => {
1139
- f.current = m.pointerType;
1140
- const v = m.target;
1141
- v.hasPointerCapture(m.pointerId) && v.releasePointerCapture(m.pointerId), m.button === 0 && m.ctrlKey === !1 && m.pointerType === "mouse" && (S(m), m.preventDefault());
1142
- }),
1143
- onKeyDown: T(o.onKeyDown, (m) => {
1144
- const v = p.current !== "";
1145
- !(m.ctrlKey || m.altKey || m.metaKey) && m.key.length === 1 && h(m.key), !(v && m.key === " ") && Dr.includes(m.key) && (S(), m.preventDefault());
1146
- })
1147
- }
1148
- ) });
1149
- }
1150
- );
1151
- un.displayName = dn;
1152
- var pn = "SelectValue", fn = c.forwardRef(
1153
- (e, n) => {
1154
- const { __scopeSelect: t, className: a, style: o, children: i, placeholder: s = "", ...l } = e, d = se(pn, t), { onValueNodeHasChildrenChange: u } = d, f = i !== void 0, p = U(n, d.onValueNodeChange);
1155
- return oe(() => {
1156
- u(f);
1157
- }, [u, f]), /* @__PURE__ */ r.jsx(
1158
- _.span,
1159
- {
1160
- ...l,
1161
- ref: p,
1162
- style: { pointerEvents: "none" },
1163
- children: Dn(d.value) ? /* @__PURE__ */ r.jsx(r.Fragment, { children: s }) : i
1164
- }
1165
- );
1166
- }
1167
- );
1168
- fn.displayName = pn;
1169
- var Vr = "SelectIcon", mn = c.forwardRef(
1170
- (e, n) => {
1171
- const { __scopeSelect: t, children: a, ...o } = e;
1172
- return /* @__PURE__ */ r.jsx(_.span, { "aria-hidden": !0, ...o, ref: n, children: a || "▼" });
1173
- }
1174
- );
1175
- mn.displayName = Vr;
1176
- var Kr = "SelectPortal", hn = (e) => /* @__PURE__ */ r.jsx(ho, { asChild: !0, ...e });
1177
- hn.displayName = Kr;
1178
- var he = "SelectContent", vn = c.forwardRef(
1179
- (e, n) => {
1180
- const t = se(he, e.__scopeSelect), [a, o] = c.useState();
1181
- if (oe(() => {
1182
- o(new DocumentFragment());
1183
- }, []), !t.open) {
1184
- const i = a;
1185
- return i ? At.createPortal(
1186
- /* @__PURE__ */ r.jsx(gn, { scope: e.__scopeSelect, children: /* @__PURE__ */ r.jsx(Be.Slot, { scope: e.__scopeSelect, children: /* @__PURE__ */ r.jsx("div", { children: e.children }) }) }),
1187
- i
1188
- ) : null;
1189
- }
1190
- return /* @__PURE__ */ r.jsx(xn, { ...e, ref: n });
1191
- }
1192
- );
1193
- vn.displayName = he;
1194
- var ee = 10, [gn, ie] = ye(he), Hr = "SelectContentImpl", Ur = So("SelectContent.RemoveScroll"), xn = c.forwardRef(
1195
- (e, n) => {
1196
- const {
1197
- __scopeSelect: t,
1198
- position: a = "item-aligned",
1199
- onCloseAutoFocus: o,
1200
- onEscapeKeyDown: i,
1201
- onPointerDownOutside: s,
1202
- //
1203
- // PopperContent props
1204
- side: l,
1205
- sideOffset: d,
1206
- align: u,
1207
- alignOffset: f,
1208
- arrowPadding: p,
1209
- collisionBoundary: h,
1210
- collisionPadding: x,
1211
- sticky: S,
1212
- hideWhenDetached: m,
1213
- avoidCollisions: v,
1214
- //
1215
- ...b
1216
- } = e, w = se(he, t), [y, R] = c.useState(null), [M, N] = c.useState(null), E = U(n, (C) => R(C)), [L, P] = c.useState(null), [H, A] = c.useState(
1217
- null
1218
- ), K = $e(t), [X, G] = c.useState(!1), W = c.useRef(!1);
1219
- c.useEffect(() => {
1220
- if (y) return go(y);
1221
- }, [y]), xo();
1222
- const F = c.useCallback(
1223
- (C) => {
1224
- const [O, ...$] = K().map((Z) => Z.ref.current), [V] = $.slice(-1), z = document.activeElement;
1225
- for (const Z of C)
1226
- if (Z === z || (Z?.scrollIntoView({ block: "nearest" }), Z === O && M && (M.scrollTop = 0), Z === V && M && (M.scrollTop = M.scrollHeight), Z?.focus(), document.activeElement !== z)) return;
1227
- },
1228
- [K, M]
1229
- ), q = c.useCallback(
1230
- () => F([L, y]),
1231
- [F, L, y]
1232
- );
1233
- c.useEffect(() => {
1234
- X && q();
1235
- }, [X, q]);
1236
- const { onOpenChange: Y, triggerPointerDownPosRef: J } = w;
1237
- c.useEffect(() => {
1238
- if (y) {
1239
- let C = { x: 0, y: 0 };
1240
- const O = (V) => {
1241
- C = {
1242
- x: Math.abs(Math.round(V.pageX) - (J.current?.x ?? 0)),
1243
- y: Math.abs(Math.round(V.pageY) - (J.current?.y ?? 0))
1244
- };
1245
- }, $ = (V) => {
1246
- C.x <= 10 && C.y <= 10 ? V.preventDefault() : y.contains(V.target) || Y(!1), document.removeEventListener("pointermove", O), J.current = null;
1247
- };
1248
- return J.current !== null && (document.addEventListener("pointermove", O), document.addEventListener("pointerup", $, { capture: !0, once: !0 })), () => {
1249
- document.removeEventListener("pointermove", O), document.removeEventListener("pointerup", $, { capture: !0 });
1250
- };
1251
- }
1252
- }, [y, Y, J]), c.useEffect(() => {
1253
- const C = () => Y(!1);
1254
- return window.addEventListener("blur", C), window.addEventListener("resize", C), () => {
1255
- window.removeEventListener("blur", C), window.removeEventListener("resize", C);
1256
- };
1257
- }, [Y]);
1258
- const [xe, ce] = On((C) => {
1259
- const O = K().filter((z) => !z.disabled), $ = O.find((z) => z.ref.current === document.activeElement), V = Ln(O, C, $);
1260
- V && setTimeout(() => V.ref.current.focus());
1261
- }), g = c.useCallback(
1262
- (C, O, $) => {
1263
- const V = !W.current && !$;
1264
- (w.value !== void 0 && w.value === O || V) && (P(C), V && (W.current = !0));
1265
- },
1266
- [w.value]
1267
- ), k = c.useCallback(() => y?.focus(), [y]), j = c.useCallback(
1268
- (C, O, $) => {
1269
- const V = !W.current && !$;
1270
- (w.value !== void 0 && w.value === O || V) && A(C);
1271
- },
1272
- [w.value]
1273
- ), I = a === "popper" ? ot : bn, D = I === ot ? {
1274
- side: l,
1275
- sideOffset: d,
1276
- align: u,
1277
- alignOffset: f,
1278
- arrowPadding: p,
1279
- collisionBoundary: h,
1280
- collisionPadding: x,
1281
- sticky: S,
1282
- hideWhenDetached: m,
1283
- avoidCollisions: v
1284
- } : {};
1285
- return /* @__PURE__ */ r.jsx(
1286
- gn,
1287
- {
1288
- scope: t,
1289
- content: y,
1290
- viewport: M,
1291
- onViewportChange: N,
1292
- itemRefCallback: g,
1293
- selectedItem: L,
1294
- onItemLeave: k,
1295
- itemTextRefCallback: j,
1296
- focusSelectedItem: q,
1297
- selectedItemText: H,
1298
- position: a,
1299
- isPositioned: X,
1300
- searchRef: xe,
1301
- children: /* @__PURE__ */ r.jsx(bo, { as: Ur, allowPinchZoom: !0, children: /* @__PURE__ */ r.jsx(
1302
- wo,
1303
- {
1304
- asChild: !0,
1305
- trapped: w.open,
1306
- onMountAutoFocus: (C) => {
1307
- C.preventDefault();
1308
- },
1309
- onUnmountAutoFocus: T(o, (C) => {
1310
- w.trigger?.focus({ preventScroll: !0 }), C.preventDefault();
1311
- }),
1312
- children: /* @__PURE__ */ r.jsx(
1313
- yo,
1314
- {
1315
- asChild: !0,
1316
- disableOutsidePointerEvents: !0,
1317
- onEscapeKeyDown: i,
1318
- onPointerDownOutside: s,
1319
- onFocusOutside: (C) => C.preventDefault(),
1320
- onDismiss: () => w.onOpenChange(!1),
1321
- children: /* @__PURE__ */ r.jsx(
1322
- I,
1323
- {
1324
- role: "listbox",
1325
- id: w.contentId,
1326
- "data-state": w.open ? "open" : "closed",
1327
- dir: w.dir,
1328
- onContextMenu: (C) => C.preventDefault(),
1329
- ...b,
1330
- ...D,
1331
- onPlaced: () => G(!0),
1332
- ref: E,
1333
- style: {
1334
- // flex layout so we can place the scroll buttons properly
1335
- display: "flex",
1336
- flexDirection: "column",
1337
- // reset the outline by default as the content MAY get focused
1338
- outline: "none",
1339
- ...b.style
1340
- },
1341
- onKeyDown: T(b.onKeyDown, (C) => {
1342
- const O = C.ctrlKey || C.altKey || C.metaKey;
1343
- if (C.key === "Tab" && C.preventDefault(), !O && C.key.length === 1 && ce(C.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(C.key)) {
1344
- let V = K().filter((z) => !z.disabled).map((z) => z.ref.current);
1345
- if (["ArrowUp", "End"].includes(C.key) && (V = V.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(C.key)) {
1346
- const z = C.target, Z = V.indexOf(z);
1347
- V = V.slice(Z + 1);
1348
- }
1349
- setTimeout(() => F(V)), C.preventDefault();
1350
- }
1351
- })
1352
- }
1353
- )
1354
- }
1355
- )
1356
- }
1357
- ) })
1358
- }
1359
- );
1360
- }
1361
- );
1362
- xn.displayName = Hr;
1363
- var Gr = "SelectItemAlignedPosition", bn = c.forwardRef((e, n) => {
1364
- const { __scopeSelect: t, onPlaced: a, ...o } = e, i = se(he, t), s = ie(he, t), [l, d] = c.useState(null), [u, f] = c.useState(null), p = U(n, (E) => f(E)), h = $e(t), x = c.useRef(!1), S = c.useRef(!0), { viewport: m, selectedItem: v, selectedItemText: b, focusSelectedItem: w } = s, y = c.useCallback(() => {
1365
- if (i.trigger && i.valueNode && l && u && m && v && b) {
1366
- const E = i.trigger.getBoundingClientRect(), L = u.getBoundingClientRect(), P = i.valueNode.getBoundingClientRect(), H = b.getBoundingClientRect();
1367
- if (i.dir !== "rtl") {
1368
- const z = H.left - L.left, Z = P.left - z, le = E.left - Z, de = E.width + le, Ge = Math.max(de, L.width), ze = window.innerWidth - ee, We = Pe(Z, [
1369
- ee,
1370
- // Prevents the content from going off the starting edge of the
1371
- // viewport. It may still go off the ending edge, but this can be
1372
- // controlled by the user since they may want to manage overflow in a
1373
- // specific way.
1374
- // https://github.com/radix-ui/primitives/issues/2049
1375
- Math.max(ee, ze - Ge)
1376
- ]);
1377
- l.style.minWidth = de + "px", l.style.left = We + "px";
1378
- } else {
1379
- const z = L.right - H.right, Z = window.innerWidth - P.right - z, le = window.innerWidth - E.right - Z, de = E.width + le, Ge = Math.max(de, L.width), ze = window.innerWidth - ee, We = Pe(Z, [
1380
- ee,
1381
- Math.max(ee, ze - Ge)
1382
- ]);
1383
- l.style.minWidth = de + "px", l.style.right = We + "px";
1384
- }
1385
- const A = h(), K = window.innerHeight - ee * 2, X = m.scrollHeight, G = window.getComputedStyle(u), W = parseInt(G.borderTopWidth, 10), F = parseInt(G.paddingTop, 10), q = parseInt(G.borderBottomWidth, 10), Y = parseInt(G.paddingBottom, 10), J = W + F + X + Y + q, xe = Math.min(v.offsetHeight * 5, J), ce = window.getComputedStyle(m), g = parseInt(ce.paddingTop, 10), k = parseInt(ce.paddingBottom, 10), j = E.top + E.height / 2 - ee, I = K - j, D = v.offsetHeight / 2, C = v.offsetTop + D, O = W + F + C, $ = J - O;
1386
- if (O <= j) {
1387
- const z = A.length > 0 && v === A[A.length - 1].ref.current;
1388
- l.style.bottom = "0px";
1389
- const Z = u.clientHeight - m.offsetTop - m.offsetHeight, le = Math.max(
1390
- I,
1391
- D + // viewport might have padding bottom, include it to avoid a scrollable viewport
1392
- (z ? k : 0) + Z + q
1393
- ), de = O + le;
1394
- l.style.height = de + "px";
1395
- } else {
1396
- const z = A.length > 0 && v === A[0].ref.current;
1397
- l.style.top = "0px";
1398
- const le = Math.max(
1399
- j,
1400
- W + m.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
1401
- (z ? g : 0) + D
1402
- ) + $;
1403
- l.style.height = le + "px", m.scrollTop = O - j + m.offsetTop;
1404
- }
1405
- l.style.margin = `${ee}px 0`, l.style.minHeight = xe + "px", l.style.maxHeight = K + "px", a?.(), requestAnimationFrame(() => x.current = !0);
1406
- }
1407
- }, [
1408
- h,
1409
- i.trigger,
1410
- i.valueNode,
1411
- l,
1412
- u,
1413
- m,
1414
- v,
1415
- b,
1416
- i.dir,
1417
- a
1418
- ]);
1419
- oe(() => y(), [y]);
1420
- const [R, M] = c.useState();
1421
- oe(() => {
1422
- u && M(window.getComputedStyle(u).zIndex);
1423
- }, [u]);
1424
- const N = c.useCallback(
1425
- (E) => {
1426
- E && S.current === !0 && (y(), w?.(), S.current = !1);
1427
- },
1428
- [y, w]
1429
- );
1430
- return /* @__PURE__ */ r.jsx(
1431
- Wr,
1432
- {
1433
- scope: t,
1434
- contentWrapper: l,
1435
- shouldExpandOnScrollRef: x,
1436
- onScrollButtonChange: N,
1437
- children: /* @__PURE__ */ r.jsx(
1438
- "div",
1439
- {
1440
- ref: d,
1441
- style: {
1442
- display: "flex",
1443
- flexDirection: "column",
1444
- position: "fixed",
1445
- zIndex: R
1446
- },
1447
- children: /* @__PURE__ */ r.jsx(
1448
- _.div,
1449
- {
1450
- ...o,
1451
- ref: p,
1452
- style: {
1453
- // When we get the height of the content, it includes borders. If we were to set
1454
- // the height without having `boxSizing: 'border-box'` it would be too big.
1455
- boxSizing: "border-box",
1456
- // We need to ensure the content doesn't get taller than the wrapper
1457
- maxHeight: "100%",
1458
- ...o.style
1459
- }
1460
- }
1461
- )
1462
- }
1463
- )
1464
- }
1465
- );
1466
- });
1467
- bn.displayName = Gr;
1468
- var zr = "SelectPopperPosition", ot = c.forwardRef((e, n) => {
1469
- const {
1470
- __scopeSelect: t,
1471
- align: a = "start",
1472
- collisionPadding: o = ee,
1473
- ...i
1474
- } = e, s = Ve(t);
1475
- return /* @__PURE__ */ r.jsx(
1476
- Co,
1477
- {
1478
- ...s,
1479
- ...i,
1480
- ref: n,
1481
- align: a,
1482
- collisionPadding: o,
1483
- style: {
1484
- // Ensure border-box for floating-ui calculations
1485
- boxSizing: "border-box",
1486
- ...i.style,
1487
- "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
1488
- "--radix-select-content-available-width": "var(--radix-popper-available-width)",
1489
- "--radix-select-content-available-height": "var(--radix-popper-available-height)",
1490
- "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
1491
- "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
1492
- }
1493
- }
1494
- );
1495
- });
1496
- ot.displayName = zr;
1497
- var [Wr, xt] = ye(he, {}), rt = "SelectViewport", Sn = c.forwardRef(
1498
- (e, n) => {
1499
- const { __scopeSelect: t, nonce: a, ...o } = e, i = ie(rt, t), s = xt(rt, t), l = U(n, i.onViewportChange), d = c.useRef(0);
1500
- return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
1501
- /* @__PURE__ */ r.jsx(
1502
- "style",
1503
- {
1504
- dangerouslySetInnerHTML: {
1505
- __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
1506
- },
1507
- nonce: a
1508
- }
1509
- ),
1510
- /* @__PURE__ */ r.jsx(Be.Slot, { scope: t, children: /* @__PURE__ */ r.jsx(
1511
- _.div,
1512
- {
1513
- "data-radix-select-viewport": "",
1514
- role: "presentation",
1515
- ...o,
1516
- ref: l,
1517
- style: {
1518
- // we use position: 'relative' here on the `viewport` so that when we call
1519
- // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
1520
- // (independent of the scrollUpButton).
1521
- position: "relative",
1522
- flex: 1,
1523
- // Viewport should only be scrollable in the vertical direction.
1524
- // This won't work in vertical writing modes, so we'll need to
1525
- // revisit this if/when that is supported
1526
- // https://developer.chrome.com/blog/vertical-form-controls
1527
- overflow: "hidden auto",
1528
- ...o.style
1529
- },
1530
- onScroll: T(o.onScroll, (u) => {
1531
- const f = u.currentTarget, { contentWrapper: p, shouldExpandOnScrollRef: h } = s;
1532
- if (h?.current && p) {
1533
- const x = Math.abs(d.current - f.scrollTop);
1534
- if (x > 0) {
1535
- const S = window.innerHeight - ee * 2, m = parseFloat(p.style.minHeight), v = parseFloat(p.style.height), b = Math.max(m, v);
1536
- if (b < S) {
1537
- const w = b + x, y = Math.min(S, w), R = w - y;
1538
- p.style.height = y + "px", p.style.bottom === "0px" && (f.scrollTop = R > 0 ? R : 0, p.style.justifyContent = "flex-end");
1539
- }
1540
- }
1541
- }
1542
- d.current = f.scrollTop;
1543
- })
1544
- }
1545
- ) })
1546
- ] });
1547
- }
1548
- );
1549
- Sn.displayName = rt;
1550
- var wn = "SelectGroup", [qr, Yr] = ye(wn), yn = c.forwardRef(
1551
- (e, n) => {
1552
- const { __scopeSelect: t, ...a } = e, o = te();
1553
- return /* @__PURE__ */ r.jsx(qr, { scope: t, id: o, children: /* @__PURE__ */ r.jsx(_.div, { role: "group", "aria-labelledby": o, ...a, ref: n }) });
1554
- }
1555
- );
1556
- yn.displayName = wn;
1557
- var Cn = "SelectLabel", In = c.forwardRef(
1558
- (e, n) => {
1559
- const { __scopeSelect: t, ...a } = e, o = Yr(Cn, t);
1560
- return /* @__PURE__ */ r.jsx(_.div, { id: o.id, ...a, ref: n });
1561
- }
1562
- );
1563
- In.displayName = Cn;
1564
- var Te = "SelectItem", [Xr, Rn] = ye(Te), kn = c.forwardRef(
1565
- (e, n) => {
1566
- const {
1567
- __scopeSelect: t,
1568
- value: a,
1569
- disabled: o = !1,
1570
- textValue: i,
1571
- ...s
1572
- } = e, l = se(Te, t), d = ie(Te, t), u = l.value === a, [f, p] = c.useState(i ?? ""), [h, x] = c.useState(!1), S = U(
1573
- n,
1574
- (w) => d.itemRefCallback?.(w, a, o)
1575
- ), m = te(), v = c.useRef("touch"), b = () => {
1576
- o || (l.onValueChange(a), l.onOpenChange(!1));
1577
- };
1578
- if (a === "")
1579
- throw new Error(
1580
- "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
1581
- );
1582
- return /* @__PURE__ */ r.jsx(
1583
- Xr,
1584
- {
1585
- scope: t,
1586
- value: a,
1587
- disabled: o,
1588
- textId: m,
1589
- isSelected: u,
1590
- onItemTextChange: c.useCallback((w) => {
1591
- p((y) => y || (w?.textContent ?? "").trim());
1592
- }, []),
1593
- children: /* @__PURE__ */ r.jsx(
1594
- Be.ItemSlot,
1595
- {
1596
- scope: t,
1597
- value: a,
1598
- disabled: o,
1599
- textValue: f,
1600
- children: /* @__PURE__ */ r.jsx(
1601
- _.div,
1602
- {
1603
- role: "option",
1604
- "aria-labelledby": m,
1605
- "data-highlighted": h ? "" : void 0,
1606
- "aria-selected": u && h,
1607
- "data-state": u ? "checked" : "unchecked",
1608
- "aria-disabled": o || void 0,
1609
- "data-disabled": o ? "" : void 0,
1610
- tabIndex: o ? void 0 : -1,
1611
- ...s,
1612
- ref: S,
1613
- onFocus: T(s.onFocus, () => x(!0)),
1614
- onBlur: T(s.onBlur, () => x(!1)),
1615
- onClick: T(s.onClick, () => {
1616
- v.current !== "mouse" && b();
1617
- }),
1618
- onPointerUp: T(s.onPointerUp, () => {
1619
- v.current === "mouse" && b();
1620
- }),
1621
- onPointerDown: T(s.onPointerDown, (w) => {
1622
- v.current = w.pointerType;
1623
- }),
1624
- onPointerMove: T(s.onPointerMove, (w) => {
1625
- v.current = w.pointerType, o ? d.onItemLeave?.() : v.current === "mouse" && w.currentTarget.focus({ preventScroll: !0 });
1626
- }),
1627
- onPointerLeave: T(s.onPointerLeave, (w) => {
1628
- w.currentTarget === document.activeElement && d.onItemLeave?.();
1629
- }),
1630
- onKeyDown: T(s.onKeyDown, (w) => {
1631
- d.searchRef?.current !== "" && w.key === " " || (Or.includes(w.key) && b(), w.key === " " && w.preventDefault());
1632
- })
1633
- }
1634
- )
1635
- }
1636
- )
1637
- }
1638
- );
1639
- }
1640
- );
1641
- kn.displayName = Te;
1642
- var ke = "SelectItemText", En = c.forwardRef(
1643
- (e, n) => {
1644
- const { __scopeSelect: t, className: a, style: o, ...i } = e, s = se(ke, t), l = ie(ke, t), d = Rn(ke, t), u = $r(ke, t), [f, p] = c.useState(null), h = U(
1645
- n,
1646
- (b) => p(b),
1647
- d.onItemTextChange,
1648
- (b) => l.itemTextRefCallback?.(b, d.value, d.disabled)
1649
- ), x = f?.textContent, S = c.useMemo(
1650
- () => /* @__PURE__ */ r.jsx("option", { value: d.value, disabled: d.disabled, children: x }, d.value),
1651
- [d.disabled, d.value, x]
1652
- ), { onNativeOptionAdd: m, onNativeOptionRemove: v } = u;
1653
- return oe(() => (m(S), () => v(S)), [m, v, S]), /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
1654
- /* @__PURE__ */ r.jsx(_.span, { id: d.textId, ...i, ref: h }),
1655
- d.isSelected && s.valueNode && !s.valueNodeHasChildren ? At.createPortal(i.children, s.valueNode) : null
1656
- ] });
1657
- }
1658
- );
1659
- En.displayName = ke;
1660
- var jn = "SelectItemIndicator", _n = c.forwardRef(
1661
- (e, n) => {
1662
- const { __scopeSelect: t, ...a } = e;
1663
- return Rn(jn, t).isSelected ? /* @__PURE__ */ r.jsx(_.span, { "aria-hidden": !0, ...a, ref: n }) : null;
1664
- }
1665
- );
1666
- _n.displayName = jn;
1667
- var at = "SelectScrollUpButton", Nn = c.forwardRef((e, n) => {
1668
- const t = ie(at, e.__scopeSelect), a = xt(at, e.__scopeSelect), [o, i] = c.useState(!1), s = U(n, a.onScrollButtonChange);
1669
- return oe(() => {
1670
- if (t.viewport && t.isPositioned) {
1671
- let l = function() {
1672
- const u = d.scrollTop > 0;
1673
- i(u);
1674
- };
1675
- const d = t.viewport;
1676
- return l(), d.addEventListener("scroll", l), () => d.removeEventListener("scroll", l);
1677
- }
1678
- }, [t.viewport, t.isPositioned]), o ? /* @__PURE__ */ r.jsx(
1679
- Tn,
1680
- {
1681
- ...e,
1682
- ref: s,
1683
- onAutoScroll: () => {
1684
- const { viewport: l, selectedItem: d } = t;
1685
- l && d && (l.scrollTop = l.scrollTop - d.offsetHeight);
1686
- }
1687
- }
1688
- ) : null;
1689
- });
1690
- Nn.displayName = at;
1691
- var st = "SelectScrollDownButton", Pn = c.forwardRef((e, n) => {
1692
- const t = ie(st, e.__scopeSelect), a = xt(st, e.__scopeSelect), [o, i] = c.useState(!1), s = U(n, a.onScrollButtonChange);
1693
- return oe(() => {
1694
- if (t.viewport && t.isPositioned) {
1695
- let l = function() {
1696
- const u = d.scrollHeight - d.clientHeight, f = Math.ceil(d.scrollTop) < u;
1697
- i(f);
1698
- };
1699
- const d = t.viewport;
1700
- return l(), d.addEventListener("scroll", l), () => d.removeEventListener("scroll", l);
1701
- }
1702
- }, [t.viewport, t.isPositioned]), o ? /* @__PURE__ */ r.jsx(
1703
- Tn,
1704
- {
1705
- ...e,
1706
- ref: s,
1707
- onAutoScroll: () => {
1708
- const { viewport: l, selectedItem: d } = t;
1709
- l && d && (l.scrollTop = l.scrollTop + d.offsetHeight);
1710
- }
1711
- }
1712
- ) : null;
1713
- });
1714
- Pn.displayName = st;
1715
- var Tn = c.forwardRef((e, n) => {
1716
- const { __scopeSelect: t, onAutoScroll: a, ...o } = e, i = ie("SelectScrollButton", t), s = c.useRef(null), l = $e(t), d = c.useCallback(() => {
1717
- s.current !== null && (window.clearInterval(s.current), s.current = null);
1718
- }, []);
1719
- return c.useEffect(() => () => d(), [d]), oe(() => {
1720
- l().find((f) => f.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
1721
- }, [l]), /* @__PURE__ */ r.jsx(
1722
- _.div,
1723
- {
1724
- "aria-hidden": !0,
1725
- ...o,
1726
- ref: n,
1727
- style: { flexShrink: 0, ...o.style },
1728
- onPointerDown: T(o.onPointerDown, () => {
1729
- s.current === null && (s.current = window.setInterval(a, 50));
1730
- }),
1731
- onPointerMove: T(o.onPointerMove, () => {
1732
- i.onItemLeave?.(), s.current === null && (s.current = window.setInterval(a, 50));
1733
- }),
1734
- onPointerLeave: T(o.onPointerLeave, () => {
1735
- d();
1736
- })
1737
- }
1738
- );
1739
- }), Zr = "SelectSeparator", Mn = c.forwardRef(
1740
- (e, n) => {
1741
- const { __scopeSelect: t, ...a } = e;
1742
- return /* @__PURE__ */ r.jsx(_.div, { "aria-hidden": !0, ...a, ref: n });
1743
- }
1744
- );
1745
- Mn.displayName = Zr;
1746
- var it = "SelectArrow", Jr = c.forwardRef(
1747
- (e, n) => {
1748
- const { __scopeSelect: t, ...a } = e, o = Ve(t), i = se(it, t), s = ie(it, t);
1749
- return i.open && s.position === "popper" ? /* @__PURE__ */ r.jsx(Io, { ...o, ...a, ref: n }) : null;
1750
- }
1751
- );
1752
- Jr.displayName = it;
1753
- var Qr = "SelectBubbleInput", An = c.forwardRef(
1754
- ({ __scopeSelect: e, value: n, ...t }, a) => {
1755
- const o = c.useRef(null), i = U(a, o), s = _e(n);
1756
- return c.useEffect(() => {
1757
- const l = o.current;
1758
- if (!l) return;
1759
- const d = window.HTMLSelectElement.prototype, f = Object.getOwnPropertyDescriptor(
1760
- d,
1761
- "value"
1762
- ).set;
1763
- if (s !== n && f) {
1764
- const p = new Event("change", { bubbles: !0 });
1765
- f.call(l, n), l.dispatchEvent(p);
1766
- }
1767
- }, [s, n]), /* @__PURE__ */ r.jsx(
1768
- _.select,
1769
- {
1770
- ...t,
1771
- style: { ...vo, ...t.style },
1772
- ref: i,
1773
- defaultValue: n
1774
- }
1775
- );
1776
- }
1777
- );
1778
- An.displayName = Qr;
1779
- function Dn(e) {
1780
- return e === "" || e === void 0;
1781
- }
1782
- function On(e) {
1783
- const n = Et(e), t = c.useRef(""), a = c.useRef(0), o = c.useCallback(
1784
- (s) => {
1785
- const l = t.current + s;
1786
- n(l), function d(u) {
1787
- t.current = u, window.clearTimeout(a.current), u !== "" && (a.current = window.setTimeout(() => d(""), 1e3));
1788
- }(l);
1789
- },
1790
- [n]
1791
- ), i = c.useCallback(() => {
1792
- t.current = "", window.clearTimeout(a.current);
1793
- }, []);
1794
- return c.useEffect(() => () => window.clearTimeout(a.current), []), [t, o, i];
1795
- }
1796
- function Ln(e, n, t) {
1797
- const o = n.length > 1 && Array.from(n).every((u) => u === n[0]) ? n[0] : n, i = t ? e.indexOf(t) : -1;
1798
- let s = ea(e, Math.max(i, 0));
1799
- o.length === 1 && (s = s.filter((u) => u !== t));
1800
- const d = s.find(
1801
- (u) => u.textValue.toLowerCase().startsWith(o.toLowerCase())
1802
- );
1803
- return d !== t ? d : void 0;
1804
- }
1805
- function ea(e, n) {
1806
- return e.map((t, a) => e[(n + a) % e.length]);
1807
- }
1808
- var ta = ln, na = un, oa = fn, ra = mn, aa = hn, sa = vn, ia = Sn, ca = yn, la = In, da = kn, ua = En, pa = _n, fa = Nn, ma = Pn, ha = Mn;
1809
- function va({ ...e }) {
1810
- return /* @__PURE__ */ r.jsx(ta, { "data-slot": "select", ...e });
1811
- }
1812
- function Xe({ ...e }) {
1813
- return /* @__PURE__ */ r.jsx(ca, { "data-slot": "select-group", ...e });
1814
- }
1815
- function ga({ ...e }) {
1816
- return /* @__PURE__ */ r.jsx(oa, { "data-slot": "select-value", ...e });
1817
- }
1818
- function xa({
1819
- className: e,
1820
- size: n = "default",
1821
- children: t,
1822
- ...a
1823
- }) {
1824
- return /* @__PURE__ */ r.jsxs(
1825
- na,
1826
- {
1827
- className: B(
1828
- "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
1829
- e
1830
- ),
1831
- "data-size": n,
1832
- "data-slot": "select-trigger",
1833
- ...a,
1834
- children: [
1835
- t,
1836
- /* @__PURE__ */ r.jsx(ra, { asChild: !0, children: /* @__PURE__ */ r.jsx(Mt, { className: "size-4 opacity-50" }) })
1837
- ]
1838
- }
1839
- );
1840
- }
1841
- function ba({
1842
- className: e,
1843
- children: n,
1844
- position: t = "popper",
1845
- align: a = "center",
1846
- ...o
1847
- }) {
1848
- return /* @__PURE__ */ r.jsx(aa, { children: /* @__PURE__ */ r.jsxs(
1849
- sa,
1850
- {
1851
- align: a,
1852
- className: B(
1853
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
1854
- t === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
1855
- e
1856
- ),
1857
- "data-slot": "select-content",
1858
- position: t,
1859
- ...o,
1860
- children: [
1861
- /* @__PURE__ */ r.jsx(wa, {}),
1862
- /* @__PURE__ */ r.jsx(
1863
- ia,
1864
- {
1865
- className: B(
1866
- "p-1",
1867
- t === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
1868
- ),
1869
- children: n
1870
- }
1871
- ),
1872
- /* @__PURE__ */ r.jsx(ya, {})
1873
- ]
1874
- }
1875
- ) });
1876
- }
1877
- function Sa({ className: e, ...n }) {
1878
- return /* @__PURE__ */ r.jsx(
1879
- la,
1880
- {
1881
- className: B("text-muted-foreground px-2 py-1.5 text-xs", e),
1882
- "data-slot": "select-label",
1883
- ...n
1884
- }
1885
- );
1886
- }
1887
- function Ct({ className: e, children: n, ...t }) {
1888
- return /* @__PURE__ */ r.jsxs(
1889
- da,
1890
- {
1891
- className: B(
1892
- "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
1893
- e
1894
- ),
1895
- "data-slot": "select-item",
1896
- ...t,
1897
- children: [
1898
- /* @__PURE__ */ r.jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ r.jsx(pa, { children: /* @__PURE__ */ r.jsx(ht, { className: "size-4" }) }) }),
1899
- /* @__PURE__ */ r.jsx(ua, { children: n })
1900
- ]
1901
- }
1902
- );
1903
- }
1904
- function Ze({ className: e, ...n }) {
1905
- return /* @__PURE__ */ r.jsx(
1906
- ha,
1907
- {
1908
- className: B("bg-border pointer-events-none -mx-1 my-1 h-px", e),
1909
- "data-slot": "select-separator",
1910
- ...n
1911
- }
1912
- );
1913
- }
1914
- function wa({ className: e, ...n }) {
1915
- return /* @__PURE__ */ r.jsx(
1916
- fa,
1917
- {
1918
- className: B("flex cursor-default items-center justify-center py-1", e),
1919
- "data-slot": "select-scroll-up-button",
1920
- ...n,
1921
- children: /* @__PURE__ */ r.jsx(Fo, { className: "size-4" })
1922
- }
1923
- );
1924
- }
1925
- function ya({
1926
- className: e,
1927
- ...n
1928
- }) {
1929
- return /* @__PURE__ */ r.jsx(
1930
- ma,
1931
- {
1932
- className: B("flex cursor-default items-center justify-center py-1", e),
1933
- "data-slot": "select-scroll-down-button",
1934
- ...n,
1935
- children: /* @__PURE__ */ r.jsx(Mt, { className: "size-4" })
1936
- }
1937
- );
1938
- }
1939
- const Us = ({
1940
- name: e,
1941
- defaultValue: n,
1942
- options: t,
1943
- label: a,
1944
- placeholder: o,
1945
- note: i,
1946
- className: s,
1947
- value: l,
1948
- onValueChange: d,
1949
- error: u,
1950
- emptyOptionLabel: f,
1951
- size: p = "md",
1952
- ...h
1953
- }) => {
1954
- const x = B(
1955
- "min-w-[180px]",
1956
- p === "xs" && "h-7 text-xs md:text-xs",
1957
- p === "sm" && "h-8 text-sm md:text-xs",
1958
- p === "md" && "h-9 text-base md:text-sm",
1959
- p === "lg" && "h-10 text-lg md:text-base",
1960
- p === "xl" && "h-11 text-xl md:text-lg",
1961
- s
1962
- ), S = t.some((P) => "options" in P), m = S ? t : [
1963
- {
1964
- label: "",
1965
- options: t
1966
- }
1967
- ], v = p === "xs" || p === "sm" ? "sm" : "default", b = "__none__", [w, y] = we(""), R = (P) => {
1968
- d(P === b ? "" : P);
1969
- }, M = (P) => {
1970
- y(P);
1971
- }, N = (P) => {
1972
- P || y("");
1973
- }, E = m.map((P) => ({
1974
- ...P,
1975
- options: P.options.filter((H) => H.label.toLowerCase().includes(w.toLowerCase()))
1976
- })), L = E.some((P) => P.options.length > 0);
1977
- return /* @__PURE__ */ r.jsxs(re, { className: "w-full", direction: "col", gap: "2", children: [
1978
- a && /* @__PURE__ */ r.jsx(fe, { htmlFor: e, children: a }),
1979
- /* @__PURE__ */ r.jsxs(
1980
- va,
1981
- {
1982
- defaultValue: n,
1983
- name: e,
1984
- onOpenChange: N,
1985
- onValueChange: R,
1986
- value: l,
1987
- ...h,
1988
- children: [
1989
- /* @__PURE__ */ r.jsx(xa, { className: x, "data-testid": `select-input-${e}`, size: v, children: /* @__PURE__ */ r.jsx(ga, { placeholder: o }) }),
1990
- /* @__PURE__ */ r.jsxs(ba, { children: [
1991
- /* @__PURE__ */ r.jsx(Xe, { children: /* @__PURE__ */ r.jsxs(ue, { className: "border-0 shadow-none", children: [
1992
- /* @__PURE__ */ r.jsx(
1993
- ue.Input,
1994
- {
1995
- name: "search",
1996
- onChange: (P) => M(P.target.value),
1997
- placeholder: "Search"
1998
- }
1999
- ),
2000
- /* @__PURE__ */ r.jsx(ue.Addon, { children: /* @__PURE__ */ r.jsx(Dt, {}) })
2001
- ] }) }),
2002
- /* @__PURE__ */ r.jsx(Ze, {}),
2003
- /* @__PURE__ */ r.jsx(Ct, { value: b, children: f || /* @__PURE__ */ r.jsx(r.Fragment, { children: " " }) }, "empty-option"),
2004
- /* @__PURE__ */ r.jsx(Ze, {}),
2005
- !L && w && /* @__PURE__ */ r.jsx(Xe, { children: /* @__PURE__ */ r.jsx(re, { align: "center", className: "py-6", justify: "center", children: /* @__PURE__ */ r.jsx(tt, { size: "sm", variant: "muted", children: "No results found" }) }) }),
2006
- E.map(({ label: P, options: H }, A) => H.length === 0 ? null : /* @__PURE__ */ r.jsxs(Xe, { children: [
2007
- P && /* @__PURE__ */ r.jsx(Sa, { children: P }),
2008
- H.map(({ value: K, label: X, icon: G }) => /* @__PURE__ */ r.jsxs(Ct, { value: K, children: [
2009
- G ? /* @__PURE__ */ r.jsx("span", { children: G }) : "",
2010
- X
2011
- ] }, `option-${K}`)),
2012
- S && A < E.length - 1 && /* @__PURE__ */ r.jsx(Ze, {})
2013
- ] }, P))
2014
- ] })
2015
- ]
2016
- }
2017
- ),
2018
- i && /* @__PURE__ */ r.jsx(tt, { size: "sm", variant: "muted", children: i }),
2019
- u && /* @__PURE__ */ r.jsx(Oe, { message: u })
2020
- ] });
2021
- };
2022
- var It = 1, Ca = 0.9, Ia = 0.8, Ra = 0.17, Je = 0.1, Qe = 0.999, ka = 0.9999, Ea = 0.99, ja = /[\\\/_+.#"@\[\(\{&]/, _a = /[\\\/_+.#"@\[\(\{&]/g, Na = /[\s-]/, Fn = /[\s-]/g;
2023
- function ct(e, n, t, a, o, i, s) {
2024
- if (i === n.length) return o === e.length ? It : Ea;
2025
- var l = `${o},${i}`;
2026
- if (s[l] !== void 0) return s[l];
2027
- for (var d = a.charAt(i), u = t.indexOf(d, o), f = 0, p, h, x, S; u >= 0; ) p = ct(e, n, t, a, u + 1, i + 1, s), p > f && (u === o ? p *= It : ja.test(e.charAt(u - 1)) ? (p *= Ia, x = e.slice(o, u - 1).match(_a), x && o > 0 && (p *= Math.pow(Qe, x.length))) : Na.test(e.charAt(u - 1)) ? (p *= Ca, S = e.slice(o, u - 1).match(Fn), S && o > 0 && (p *= Math.pow(Qe, S.length))) : (p *= Ra, o > 0 && (p *= Math.pow(Qe, u - o))), e.charAt(u) !== n.charAt(i) && (p *= ka)), (p < Je && t.charAt(u - 1) === a.charAt(i + 1) || a.charAt(i + 1) === a.charAt(i) && t.charAt(u - 1) !== a.charAt(i)) && (h = ct(e, n, t, a, u + 1, i + 2, s), h * Je > p && (p = h * Je)), p > f && (f = p), u = t.indexOf(d, u + 1);
2028
- return s[l] = f, f;
2029
- }
2030
- function Rt(e) {
2031
- return e.toLowerCase().replace(Fn, " ");
2032
- }
2033
- function Pa(e, n, t) {
2034
- return e = t && t.length > 0 ? `${e + " " + t.join(" ")}` : e, ct(e, n, Rt(e), Rt(n), 0, 0, {});
2035
- }
2036
- var Re = '[cmdk-group=""]', et = '[cmdk-group-items=""]', Ta = '[cmdk-group-heading=""]', Bn = '[cmdk-item=""]', kt = `${Bn}:not([aria-disabled="true"])`, lt = "cmdk-item-select", be = "data-value", Ma = (e, n, t) => Pa(e, n, t), $n = c.createContext(void 0), Ne = () => c.useContext($n), Vn = c.createContext(void 0), bt = () => c.useContext(Vn), Kn = c.createContext(void 0), Hn = c.forwardRef((e, n) => {
2037
- let t = Se(() => {
2038
- var g, k;
2039
- return { search: "", value: (k = (g = e.value) != null ? g : e.defaultValue) != null ? k : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
2040
- }), a = Se(() => /* @__PURE__ */ new Set()), o = Se(() => /* @__PURE__ */ new Map()), i = Se(() => /* @__PURE__ */ new Map()), s = Se(() => /* @__PURE__ */ new Set()), l = Un(e), { label: d, children: u, value: f, onValueChange: p, filter: h, shouldFilter: x, loop: S, disablePointerSelection: m = !1, vimBindings: v = !0, ...b } = e, w = te(), y = te(), R = te(), M = c.useRef(null), N = Ua();
2041
- ve(() => {
2042
- if (f !== void 0) {
2043
- let g = f.trim();
2044
- t.current.value = g, E.emit();
2045
- }
2046
- }, [f]), ve(() => {
2047
- N(6, X);
2048
- }, []);
2049
- let E = c.useMemo(() => ({ subscribe: (g) => (s.current.add(g), () => s.current.delete(g)), snapshot: () => t.current, setState: (g, k, j) => {
2050
- var I, D, C, O;
2051
- if (!Object.is(t.current[g], k)) {
2052
- if (t.current[g] = k, g === "search") K(), H(), N(1, A);
2053
- else if (g === "value") {
2054
- if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
2055
- let $ = document.getElementById(R);
2056
- $ ? $.focus() : (I = document.getElementById(w)) == null || I.focus();
2057
- }
2058
- if (N(7, () => {
2059
- var $;
2060
- t.current.selectedItemId = ($ = G()) == null ? void 0 : $.id, E.emit();
2061
- }), j || N(5, X), ((D = l.current) == null ? void 0 : D.value) !== void 0) {
2062
- let $ = k ?? "";
2063
- (O = (C = l.current).onValueChange) == null || O.call(C, $);
2064
- return;
2065
- }
2066
- }
2067
- E.emit();
2068
- }
2069
- }, emit: () => {
2070
- s.current.forEach((g) => g());
2071
- } }), []), L = c.useMemo(() => ({ value: (g, k, j) => {
2072
- var I;
2073
- k !== ((I = i.current.get(g)) == null ? void 0 : I.value) && (i.current.set(g, { value: k, keywords: j }), t.current.filtered.items.set(g, P(k, j)), N(2, () => {
2074
- H(), E.emit();
2075
- }));
2076
- }, item: (g, k) => (a.current.add(g), k && (o.current.has(k) ? o.current.get(k).add(g) : o.current.set(k, /* @__PURE__ */ new Set([g]))), N(3, () => {
2077
- K(), H(), t.current.value || A(), E.emit();
2078
- }), () => {
2079
- i.current.delete(g), a.current.delete(g), t.current.filtered.items.delete(g);
2080
- let j = G();
2081
- N(4, () => {
2082
- K(), j?.getAttribute("id") === g && A(), E.emit();
2083
- });
2084
- }), group: (g) => (o.current.has(g) || o.current.set(g, /* @__PURE__ */ new Set()), () => {
2085
- i.current.delete(g), o.current.delete(g);
2086
- }), filter: () => l.current.shouldFilter, label: d || e["aria-label"], getDisablePointerSelection: () => l.current.disablePointerSelection, listId: w, inputId: R, labelId: y, listInnerRef: M }), []);
2087
- function P(g, k) {
2088
- var j, I;
2089
- let D = (I = (j = l.current) == null ? void 0 : j.filter) != null ? I : Ma;
2090
- return g ? D(g, t.current.search, k) : 0;
2091
- }
2092
- function H() {
2093
- if (!t.current.search || l.current.shouldFilter === !1) return;
2094
- let g = t.current.filtered.items, k = [];
2095
- t.current.filtered.groups.forEach((I) => {
2096
- let D = o.current.get(I), C = 0;
2097
- D.forEach((O) => {
2098
- let $ = g.get(O);
2099
- C = Math.max($, C);
2100
- }), k.push([I, C]);
2101
- });
2102
- let j = M.current;
2103
- W().sort((I, D) => {
2104
- var C, O;
2105
- let $ = I.getAttribute("id"), V = D.getAttribute("id");
2106
- return ((C = g.get(V)) != null ? C : 0) - ((O = g.get($)) != null ? O : 0);
2107
- }).forEach((I) => {
2108
- let D = I.closest(et);
2109
- D ? D.appendChild(I.parentElement === D ? I : I.closest(`${et} > *`)) : j.appendChild(I.parentElement === j ? I : I.closest(`${et} > *`));
2110
- }), k.sort((I, D) => D[1] - I[1]).forEach((I) => {
2111
- var D;
2112
- let C = (D = M.current) == null ? void 0 : D.querySelector(`${Re}[${be}="${encodeURIComponent(I[0])}"]`);
2113
- C?.parentElement.appendChild(C);
2114
- });
2115
- }
2116
- function A() {
2117
- let g = W().find((j) => j.getAttribute("aria-disabled") !== "true"), k = g?.getAttribute(be);
2118
- E.setState("value", k || void 0);
2119
- }
2120
- function K() {
2121
- var g, k, j, I;
2122
- if (!t.current.search || l.current.shouldFilter === !1) {
2123
- t.current.filtered.count = a.current.size;
2124
- return;
2125
- }
2126
- t.current.filtered.groups = /* @__PURE__ */ new Set();
2127
- let D = 0;
2128
- for (let C of a.current) {
2129
- let O = (k = (g = i.current.get(C)) == null ? void 0 : g.value) != null ? k : "", $ = (I = (j = i.current.get(C)) == null ? void 0 : j.keywords) != null ? I : [], V = P(O, $);
2130
- t.current.filtered.items.set(C, V), V > 0 && D++;
2131
- }
2132
- for (let [C, O] of o.current) for (let $ of O) if (t.current.filtered.items.get($) > 0) {
2133
- t.current.filtered.groups.add(C);
2134
- break;
2135
- }
2136
- t.current.filtered.count = D;
2137
- }
2138
- function X() {
2139
- var g, k, j;
2140
- let I = G();
2141
- I && (((g = I.parentElement) == null ? void 0 : g.firstChild) === I && ((j = (k = I.closest(Re)) == null ? void 0 : k.querySelector(Ta)) == null || j.scrollIntoView({ block: "nearest" })), I.scrollIntoView({ block: "nearest" }));
2142
- }
2143
- function G() {
2144
- var g;
2145
- return (g = M.current) == null ? void 0 : g.querySelector(`${Bn}[aria-selected="true"]`);
2146
- }
2147
- function W() {
2148
- var g;
2149
- return Array.from(((g = M.current) == null ? void 0 : g.querySelectorAll(kt)) || []);
2150
- }
2151
- function F(g) {
2152
- let k = W()[g];
2153
- k && E.setState("value", k.getAttribute(be));
2154
- }
2155
- function q(g) {
2156
- var k;
2157
- let j = G(), I = W(), D = I.findIndex((O) => O === j), C = I[D + g];
2158
- (k = l.current) != null && k.loop && (C = D + g < 0 ? I[I.length - 1] : D + g === I.length ? I[0] : I[D + g]), C && E.setState("value", C.getAttribute(be));
2159
- }
2160
- function Y(g) {
2161
- let k = G(), j = k?.closest(Re), I;
2162
- for (; j && !I; ) j = g > 0 ? Ka(j, Re) : Ha(j, Re), I = j?.querySelector(kt);
2163
- I ? E.setState("value", I.getAttribute(be)) : q(g);
2164
- }
2165
- let J = () => F(W().length - 1), xe = (g) => {
2166
- g.preventDefault(), g.metaKey ? J() : g.altKey ? Y(1) : q(1);
2167
- }, ce = (g) => {
2168
- g.preventDefault(), g.metaKey ? F(0) : g.altKey ? Y(-1) : q(-1);
2169
- };
2170
- return c.createElement(_.div, { ref: n, tabIndex: -1, ...b, "cmdk-root": "", onKeyDown: (g) => {
2171
- var k;
2172
- (k = b.onKeyDown) == null || k.call(b, g);
2173
- let j = g.nativeEvent.isComposing || g.keyCode === 229;
2174
- if (!(g.defaultPrevented || j)) switch (g.key) {
2175
- case "n":
2176
- case "j": {
2177
- v && g.ctrlKey && xe(g);
2178
- break;
2179
- }
2180
- case "ArrowDown": {
2181
- xe(g);
2182
- break;
2183
- }
2184
- case "p":
2185
- case "k": {
2186
- v && g.ctrlKey && ce(g);
2187
- break;
2188
- }
2189
- case "ArrowUp": {
2190
- ce(g);
2191
- break;
2192
- }
2193
- case "Home": {
2194
- g.preventDefault(), F(0);
2195
- break;
2196
- }
2197
- case "End": {
2198
- g.preventDefault(), J();
2199
- break;
2200
- }
2201
- case "Enter": {
2202
- g.preventDefault();
2203
- let I = G();
2204
- if (I) {
2205
- let D = new Event(lt);
2206
- I.dispatchEvent(D);
2207
- }
2208
- }
2209
- }
2210
- } }, c.createElement("label", { "cmdk-label": "", htmlFor: L.inputId, id: L.labelId, style: za }, d), Ke(e, (g) => c.createElement(Vn.Provider, { value: E }, c.createElement($n.Provider, { value: L }, g))));
2211
- }), Aa = c.forwardRef((e, n) => {
2212
- var t, a;
2213
- let o = te(), i = c.useRef(null), s = c.useContext(Kn), l = Ne(), d = Un(e), u = (a = (t = d.current) == null ? void 0 : t.forceMount) != null ? a : s?.forceMount;
2214
- ve(() => {
2215
- if (!u) return l.item(o, s?.id);
2216
- }, [u]);
2217
- let f = Gn(o, i, [e.value, e.children, i], e.keywords), p = bt(), h = ae((N) => N.value && N.value === f.current), x = ae((N) => u || l.filter() === !1 ? !0 : N.search ? N.filtered.items.get(o) > 0 : !0);
2218
- c.useEffect(() => {
2219
- let N = i.current;
2220
- if (!(!N || e.disabled)) return N.addEventListener(lt, S), () => N.removeEventListener(lt, S);
2221
- }, [x, e.onSelect, e.disabled]);
2222
- function S() {
2223
- var N, E;
2224
- m(), (E = (N = d.current).onSelect) == null || E.call(N, f.current);
2225
- }
2226
- function m() {
2227
- p.setState("value", f.current, !0);
2228
- }
2229
- if (!x) return null;
2230
- let { disabled: v, value: b, onSelect: w, forceMount: y, keywords: R, ...M } = e;
2231
- return c.createElement(_.div, { ref: Ee(i, n), ...M, id: o, "cmdk-item": "", role: "option", "aria-disabled": !!v, "aria-selected": !!h, "data-disabled": !!v, "data-selected": !!h, onPointerMove: v || l.getDisablePointerSelection() ? void 0 : m, onClick: v ? void 0 : S }, e.children);
2232
- }), Da = c.forwardRef((e, n) => {
2233
- let { heading: t, children: a, forceMount: o, ...i } = e, s = te(), l = c.useRef(null), d = c.useRef(null), u = te(), f = Ne(), p = ae((x) => o || f.filter() === !1 ? !0 : x.search ? x.filtered.groups.has(s) : !0);
2234
- ve(() => f.group(s), []), Gn(s, l, [e.value, e.heading, d]);
2235
- let h = c.useMemo(() => ({ id: s, forceMount: o }), [o]);
2236
- return c.createElement(_.div, { ref: Ee(l, n), ...i, "cmdk-group": "", role: "presentation", hidden: p ? void 0 : !0 }, t && c.createElement("div", { ref: d, "cmdk-group-heading": "", "aria-hidden": !0, id: u }, t), Ke(e, (x) => c.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? u : void 0 }, c.createElement(Kn.Provider, { value: h }, x))));
2237
- }), Oa = c.forwardRef((e, n) => {
2238
- let { alwaysRender: t, ...a } = e, o = c.useRef(null), i = ae((s) => !s.search);
2239
- return !t && !i ? null : c.createElement(_.div, { ref: Ee(o, n), ...a, "cmdk-separator": "", role: "separator" });
2240
- }), La = c.forwardRef((e, n) => {
2241
- let { onValueChange: t, ...a } = e, o = e.value != null, i = bt(), s = ae((u) => u.search), l = ae((u) => u.selectedItemId), d = Ne();
2242
- return c.useEffect(() => {
2243
- e.value != null && i.setState("search", e.value);
2244
- }, [e.value]), c.createElement(_.input, { ref: n, ...a, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": d.listId, "aria-labelledby": d.labelId, "aria-activedescendant": l, id: d.inputId, type: "text", value: o ? e.value : s, onChange: (u) => {
2245
- o || i.setState("search", u.target.value), t?.(u.target.value);
2246
- } });
2247
- }), Fa = c.forwardRef((e, n) => {
2248
- let { children: t, label: a = "Suggestions", ...o } = e, i = c.useRef(null), s = c.useRef(null), l = ae((u) => u.selectedItemId), d = Ne();
2249
- return c.useEffect(() => {
2250
- if (s.current && i.current) {
2251
- let u = s.current, f = i.current, p, h = new ResizeObserver(() => {
2252
- p = requestAnimationFrame(() => {
2253
- let x = u.offsetHeight;
2254
- f.style.setProperty("--cmdk-list-height", x.toFixed(1) + "px");
2255
- });
2256
- });
2257
- return h.observe(u), () => {
2258
- cancelAnimationFrame(p), h.unobserve(u);
2259
- };
2260
- }
2261
- }, []), c.createElement(_.div, { ref: Ee(i, n), ...o, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": l, "aria-label": a, id: d.listId }, Ke(e, (u) => c.createElement("div", { ref: Ee(s, d.listInnerRef), "cmdk-list-sizer": "" }, u)));
2262
- }), Ba = c.forwardRef((e, n) => {
2263
- let { open: t, onOpenChange: a, overlayClassName: o, contentClassName: i, container: s, ...l } = e;
2264
- return c.createElement(Ro, { open: t, onOpenChange: a }, c.createElement(ko, { container: s }, c.createElement(Eo, { "cmdk-overlay": "", className: o }), c.createElement(jo, { "aria-label": e.label, "cmdk-dialog": "", className: i }, c.createElement(Hn, { ref: n, ...l }))));
2265
- }), $a = c.forwardRef((e, n) => ae((t) => t.filtered.count === 0) ? c.createElement(_.div, { ref: n, ...e, "cmdk-empty": "", role: "presentation" }) : null), Va = c.forwardRef((e, n) => {
2266
- let { progress: t, children: a, label: o = "Loading...", ...i } = e;
2267
- return c.createElement(_.div, { ref: n, ...i, "cmdk-loading": "", role: "progressbar", "aria-valuenow": t, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": o }, Ke(e, (s) => c.createElement("div", { "aria-hidden": !0 }, s)));
2268
- }), Ce = Object.assign(Hn, { List: Fa, Item: Aa, Input: La, Group: Da, Separator: Oa, Dialog: Ba, Empty: $a, Loading: Va });
2269
- function Ka(e, n) {
2270
- let t = e.nextElementSibling;
2271
- for (; t; ) {
2272
- if (t.matches(n)) return t;
2273
- t = t.nextElementSibling;
2274
- }
2275
- }
2276
- function Ha(e, n) {
2277
- let t = e.previousElementSibling;
2278
- for (; t; ) {
2279
- if (t.matches(n)) return t;
2280
- t = t.previousElementSibling;
2281
- }
2282
- }
2283
- function Un(e) {
2284
- let n = c.useRef(e);
2285
- return ve(() => {
2286
- n.current = e;
2287
- }), n;
2288
- }
2289
- var ve = typeof window > "u" ? c.useEffect : c.useLayoutEffect;
2290
- function Se(e) {
2291
- let n = c.useRef();
2292
- return n.current === void 0 && (n.current = e()), n;
2293
- }
2294
- function ae(e) {
2295
- let n = bt(), t = () => e(n.snapshot());
2296
- return c.useSyncExternalStore(n.subscribe, t, t);
2297
- }
2298
- function Gn(e, n, t, a = []) {
2299
- let o = c.useRef(), i = Ne();
2300
- return ve(() => {
2301
- var s;
2302
- let l = (() => {
2303
- var u;
2304
- for (let f of t) {
2305
- if (typeof f == "string") return f.trim();
2306
- if (typeof f == "object" && "current" in f) return f.current ? (u = f.current.textContent) == null ? void 0 : u.trim() : o.current;
2307
- }
2308
- })(), d = a.map((u) => u.trim());
2309
- i.value(e, l, d), (s = n.current) == null || s.setAttribute(be, l), o.current = l;
2310
- }), o;
2311
- }
2312
- var Ua = () => {
2313
- let [e, n] = c.useState(), t = Se(() => /* @__PURE__ */ new Map());
2314
- return ve(() => {
2315
- t.current.forEach((a) => a()), t.current = /* @__PURE__ */ new Map();
2316
- }, [e]), (a, o) => {
2317
- t.current.set(a, o), n({});
2318
- };
2319
- };
2320
- function Ga(e) {
2321
- let n = e.type;
2322
- return typeof n == "function" ? n(e.props) : "render" in n ? n.render(e.props) : e;
2323
- }
2324
- function Ke({ asChild: e, children: n }, t) {
2325
- return e && c.isValidElement(n) ? c.cloneElement(Ga(n), { ref: n.ref }, t(n.props.children)) : t(n);
2326
- }
2327
- var za = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
2328
- function Wa({ className: e, ...n }) {
2329
- return /* @__PURE__ */ r.jsx(
2330
- Ce,
2331
- {
2332
- className: B(
2333
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
2334
- e
2335
- ),
2336
- "data-slot": "command",
2337
- ...n
2338
- }
2339
- );
2340
- }
2341
- function qa({ className: e, ...n }) {
2342
- return /* @__PURE__ */ r.jsxs("div", { className: "flex h-9 items-center gap-2 border-b px-3", "data-slot": "command-input-wrapper", children: [
2343
- /* @__PURE__ */ r.jsx(Dt, { className: "size-4 shrink-0 opacity-50" }),
2344
- /* @__PURE__ */ r.jsx(
2345
- Ce.Input,
2346
- {
2347
- className: B(
2348
- "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
2349
- e
2350
- ),
2351
- "data-slot": "command-input",
2352
- ...n
2353
- }
2354
- )
2355
- ] });
2356
- }
2357
- function Ya({ className: e, ...n }) {
2358
- return /* @__PURE__ */ r.jsx(
2359
- Ce.List,
2360
- {
2361
- className: B("max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden", e),
2362
- "data-slot": "command-list",
2363
- ...n
2364
- }
2365
- );
2366
- }
2367
- function Xa({ ...e }) {
2368
- return /* @__PURE__ */ r.jsx(Ce.Empty, { className: "py-6 text-center text-sm", "data-slot": "command-empty", ...e });
2369
- }
2370
- function Za({ className: e, ...n }) {
2371
- return /* @__PURE__ */ r.jsx(
2372
- Ce.Group,
2373
- {
2374
- className: B(
2375
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs",
2376
- e
2377
- ),
2378
- "data-slot": "command-group",
2379
- ...n
2380
- }
2381
- );
2382
- }
2383
- function Ja({ className: e, ...n }) {
2384
- return /* @__PURE__ */ r.jsx(
2385
- Ce.Item,
2386
- {
2387
- className: B(
2388
- "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
2389
- e
2390
- ),
2391
- "data-slot": "command-item",
2392
- ...n
2393
- }
2394
- );
2395
- }
2396
- const Qa = ({
2397
- placeholder: e,
2398
- selected: n,
2399
- className: t,
2400
- open: a,
2401
- renderSelected: o = (i) => i.label
2402
- }) => /* @__PURE__ */ r.jsx(Nt, { asChild: !0, children: /* @__PURE__ */ r.jsxs(_o, { "aria-expanded": a, className: `justify-between ${t}`, role: "combobox", variant: "outline", children: [
2403
- o(n || { label: e, value: "" }),
2404
- /* @__PURE__ */ r.jsx($o, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
2405
- ] }) }), Gs = ({
2406
- options: e,
2407
- value: n = "",
2408
- placeholder: t = "Select a value...",
2409
- className: a = "",
2410
- onSelect: o = () => {
2411
- },
2412
- renderSelected: i = (s) => s.label
2413
- }) => {
2414
- mt(() => {
2415
- console.warn("SelectPicker is deprecated and will be removed in a future version. Please use SelectInput instead.");
2416
- }, []);
2417
- const [s, l] = we(!1), d = e.length === 1, u = wt(() => e.flatMap((p) => p.options), [e]), f = wt(
2418
- () => u.find((p) => p.value === n),
2419
- [u, n]
2420
- );
2421
- return /* @__PURE__ */ r.jsxs(_t, { onOpenChange: l, open: s, children: [
2422
- /* @__PURE__ */ r.jsx(
2423
- Qa,
2424
- {
2425
- className: `w-full ${a}`,
2426
- open: s,
2427
- placeholder: t,
2428
- renderSelected: i,
2429
- selected: f
2430
- }
2431
- ),
2432
- /* @__PURE__ */ r.jsx(Pt, { className: "w-full p-0", children: /* @__PURE__ */ r.jsxs(Wa, { value: n, children: [
2433
- /* @__PURE__ */ r.jsx(qa, { "aria-label": "Search options", className: "h-9", placeholder: "Search" }),
2434
- /* @__PURE__ */ r.jsxs(Ya, { children: [
2435
- /* @__PURE__ */ r.jsx(Xa, { children: "No results found" }),
2436
- e.map((p) => /* @__PURE__ */ r.jsx(Za, { heading: d ? void 0 : p.label, children: p.options.map((h) => /* @__PURE__ */ r.jsxs(
2437
- Ja,
2438
- {
2439
- onSelect: () => {
2440
- l(!1), o(h.value);
2441
- },
2442
- value: h.value,
2443
- children: [
2444
- h.icon ? /* @__PURE__ */ r.jsx("span", { className: "mr-2", children: h.icon }) : "",
2445
- h.label,
2446
- /* @__PURE__ */ r.jsx(ht, { className: B("ml-auto", h.value === n ? "opacity-100" : "opacity-0") })
2447
- ]
2448
- },
2449
- h.value
2450
- )) }, p.label))
2451
- ] })
2452
- ] }) })
2453
- ] });
2454
- };
2455
- var zn = ["PageUp", "PageDown"], Wn = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], qn = {
2456
- "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
2457
- "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
2458
- "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
2459
- "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
2460
- }, Ie = "Slider", [dt, es, ts] = ft(Ie), [Yn, zs] = ge(Ie, [
2461
- ts
2462
- ]), [ns, He] = Yn(Ie), Xn = c.forwardRef(
2463
- (e, n) => {
2464
- const {
2465
- name: t,
2466
- min: a = 0,
2467
- max: o = 100,
2468
- step: i = 1,
2469
- orientation: s = "horizontal",
2470
- disabled: l = !1,
2471
- minStepsBetweenThumbs: d = 0,
2472
- defaultValue: u = [a],
2473
- value: f,
2474
- onValueChange: p = () => {
2475
- },
2476
- onValueCommit: h = () => {
2477
- },
2478
- inverted: x = !1,
2479
- form: S,
2480
- ...m
2481
- } = e, v = c.useRef(/* @__PURE__ */ new Set()), b = c.useRef(0), y = s === "horizontal" ? os : rs, [R = [], M] = pe({
2482
- prop: f,
2483
- defaultProp: u,
2484
- onChange: (A) => {
2485
- [...v.current][b.current]?.focus(), p(A);
2486
- }
2487
- }), N = c.useRef(R);
2488
- function E(A) {
2489
- const K = ls(R, A);
2490
- H(A, K);
2491
- }
2492
- function L(A) {
2493
- H(A, b.current);
2494
- }
2495
- function P() {
2496
- const A = N.current[b.current];
2497
- R[b.current] !== A && h(R);
2498
- }
2499
- function H(A, K, { commit: X } = { commit: !1 }) {
2500
- const G = fs(i), W = ms(Math.round((A - a) / i) * i + a, G), F = Pe(W, [a, o]);
2501
- M((q = []) => {
2502
- const Y = is(q, F, K);
2503
- if (ps(Y, d * i)) {
2504
- b.current = Y.indexOf(F);
2505
- const J = String(Y) !== String(q);
2506
- return J && X && h(Y), J ? Y : q;
2507
- } else
2508
- return q;
2509
- });
2510
- }
2511
- return /* @__PURE__ */ r.jsx(
2512
- ns,
2513
- {
2514
- scope: e.__scopeSlider,
2515
- name: t,
2516
- disabled: l,
2517
- min: a,
2518
- max: o,
2519
- valueIndexToChangeRef: b,
2520
- thumbs: v.current,
2521
- values: R,
2522
- orientation: s,
2523
- form: S,
2524
- children: /* @__PURE__ */ r.jsx(dt.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ r.jsx(dt.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ r.jsx(
2525
- y,
2526
- {
2527
- "aria-disabled": l,
2528
- "data-disabled": l ? "" : void 0,
2529
- ...m,
2530
- ref: n,
2531
- onPointerDown: T(m.onPointerDown, () => {
2532
- l || (N.current = R);
2533
- }),
2534
- min: a,
2535
- max: o,
2536
- inverted: x,
2537
- onSlideStart: l ? void 0 : E,
2538
- onSlideMove: l ? void 0 : L,
2539
- onSlideEnd: l ? void 0 : P,
2540
- onHomeKeyDown: () => !l && H(a, 0, { commit: !0 }),
2541
- onEndKeyDown: () => !l && H(o, R.length - 1, { commit: !0 }),
2542
- onStepKeyDown: ({ event: A, direction: K }) => {
2543
- if (!l) {
2544
- const W = zn.includes(A.key) || A.shiftKey && Wn.includes(A.key) ? 10 : 1, F = b.current, q = R[F], Y = i * W * K;
2545
- H(q + Y, F, { commit: !0 });
2546
- }
2547
- }
2548
- }
2549
- ) }) })
2550
- }
2551
- );
2552
- }
2553
- );
2554
- Xn.displayName = Ie;
2555
- var [Zn, Jn] = Yn(Ie, {
2556
- startEdge: "left",
2557
- endEdge: "right",
2558
- size: "width",
2559
- direction: 1
2560
- }), os = c.forwardRef(
2561
- (e, n) => {
2562
- const {
2563
- min: t,
2564
- max: a,
2565
- dir: o,
2566
- inverted: i,
2567
- onSlideStart: s,
2568
- onSlideMove: l,
2569
- onSlideEnd: d,
2570
- onStepKeyDown: u,
2571
- ...f
2572
- } = e, [p, h] = c.useState(null), x = U(n, (y) => h(y)), S = c.useRef(void 0), m = Me(o), v = m === "ltr", b = v && !i || !v && i;
2573
- function w(y) {
2574
- const R = S.current || p.getBoundingClientRect(), M = [0, R.width], E = St(M, b ? [t, a] : [a, t]);
2575
- return S.current = R, E(y - R.left);
2576
- }
2577
- return /* @__PURE__ */ r.jsx(
2578
- Zn,
2579
- {
2580
- scope: e.__scopeSlider,
2581
- startEdge: b ? "left" : "right",
2582
- endEdge: b ? "right" : "left",
2583
- direction: b ? 1 : -1,
2584
- size: "width",
2585
- children: /* @__PURE__ */ r.jsx(
2586
- Qn,
2587
- {
2588
- dir: m,
2589
- "data-orientation": "horizontal",
2590
- ...f,
2591
- ref: x,
2592
- style: {
2593
- ...f.style,
2594
- "--radix-slider-thumb-transform": "translateX(-50%)"
2595
- },
2596
- onSlideStart: (y) => {
2597
- const R = w(y.clientX);
2598
- s?.(R);
2599
- },
2600
- onSlideMove: (y) => {
2601
- const R = w(y.clientX);
2602
- l?.(R);
2603
- },
2604
- onSlideEnd: () => {
2605
- S.current = void 0, d?.();
2606
- },
2607
- onStepKeyDown: (y) => {
2608
- const M = qn[b ? "from-left" : "from-right"].includes(y.key);
2609
- u?.({ event: y, direction: M ? -1 : 1 });
2610
- }
2611
- }
2612
- )
2613
- }
2614
- );
2615
- }
2616
- ), rs = c.forwardRef(
2617
- (e, n) => {
2618
- const {
2619
- min: t,
2620
- max: a,
2621
- inverted: o,
2622
- onSlideStart: i,
2623
- onSlideMove: s,
2624
- onSlideEnd: l,
2625
- onStepKeyDown: d,
2626
- ...u
2627
- } = e, f = c.useRef(null), p = U(n, f), h = c.useRef(void 0), x = !o;
2628
- function S(m) {
2629
- const v = h.current || f.current.getBoundingClientRect(), b = [0, v.height], y = St(b, x ? [a, t] : [t, a]);
2630
- return h.current = v, y(m - v.top);
2631
- }
2632
- return /* @__PURE__ */ r.jsx(
2633
- Zn,
2634
- {
2635
- scope: e.__scopeSlider,
2636
- startEdge: x ? "bottom" : "top",
2637
- endEdge: x ? "top" : "bottom",
2638
- size: "height",
2639
- direction: x ? 1 : -1,
2640
- children: /* @__PURE__ */ r.jsx(
2641
- Qn,
2642
- {
2643
- "data-orientation": "vertical",
2644
- ...u,
2645
- ref: p,
2646
- style: {
2647
- ...u.style,
2648
- "--radix-slider-thumb-transform": "translateY(50%)"
2649
- },
2650
- onSlideStart: (m) => {
2651
- const v = S(m.clientY);
2652
- i?.(v);
2653
- },
2654
- onSlideMove: (m) => {
2655
- const v = S(m.clientY);
2656
- s?.(v);
2657
- },
2658
- onSlideEnd: () => {
2659
- h.current = void 0, l?.();
2660
- },
2661
- onStepKeyDown: (m) => {
2662
- const b = qn[x ? "from-bottom" : "from-top"].includes(m.key);
2663
- d?.({ event: m, direction: b ? -1 : 1 });
2664
- }
2665
- }
2666
- )
2667
- }
2668
- );
2669
- }
2670
- ), Qn = c.forwardRef(
2671
- (e, n) => {
2672
- const {
2673
- __scopeSlider: t,
2674
- onSlideStart: a,
2675
- onSlideMove: o,
2676
- onSlideEnd: i,
2677
- onHomeKeyDown: s,
2678
- onEndKeyDown: l,
2679
- onStepKeyDown: d,
2680
- ...u
2681
- } = e, f = He(Ie, t);
2682
- return /* @__PURE__ */ r.jsx(
2683
- _.span,
2684
- {
2685
- ...u,
2686
- ref: n,
2687
- onKeyDown: T(e.onKeyDown, (p) => {
2688
- p.key === "Home" ? (s(p), p.preventDefault()) : p.key === "End" ? (l(p), p.preventDefault()) : zn.concat(Wn).includes(p.key) && (d(p), p.preventDefault());
2689
- }),
2690
- onPointerDown: T(e.onPointerDown, (p) => {
2691
- const h = p.target;
2692
- h.setPointerCapture(p.pointerId), p.preventDefault(), f.thumbs.has(h) ? h.focus() : a(p);
2693
- }),
2694
- onPointerMove: T(e.onPointerMove, (p) => {
2695
- p.target.hasPointerCapture(p.pointerId) && o(p);
2696
- }),
2697
- onPointerUp: T(e.onPointerUp, (p) => {
2698
- const h = p.target;
2699
- h.hasPointerCapture(p.pointerId) && (h.releasePointerCapture(p.pointerId), i(p));
2700
- })
2701
- }
2702
- );
2703
- }
2704
- ), eo = "SliderTrack", to = c.forwardRef(
2705
- (e, n) => {
2706
- const { __scopeSlider: t, ...a } = e, o = He(eo, t);
2707
- return /* @__PURE__ */ r.jsx(
2708
- _.span,
2709
- {
2710
- "data-disabled": o.disabled ? "" : void 0,
2711
- "data-orientation": o.orientation,
2712
- ...a,
2713
- ref: n
2714
- }
2715
- );
2716
- }
2717
- );
2718
- to.displayName = eo;
2719
- var ut = "SliderRange", no = c.forwardRef(
2720
- (e, n) => {
2721
- const { __scopeSlider: t, ...a } = e, o = He(ut, t), i = Jn(ut, t), s = c.useRef(null), l = U(n, s), d = o.values.length, u = o.values.map(
2722
- (h) => ao(h, o.min, o.max)
2723
- ), f = d > 1 ? Math.min(...u) : 0, p = 100 - Math.max(...u);
2724
- return /* @__PURE__ */ r.jsx(
2725
- _.span,
2726
- {
2727
- "data-orientation": o.orientation,
2728
- "data-disabled": o.disabled ? "" : void 0,
2729
- ...a,
2730
- ref: l,
2731
- style: {
2732
- ...e.style,
2733
- [i.startEdge]: f + "%",
2734
- [i.endEdge]: p + "%"
2735
- }
2736
- }
2737
- );
2738
- }
2739
- );
2740
- no.displayName = ut;
2741
- var pt = "SliderThumb", oo = c.forwardRef(
2742
- (e, n) => {
2743
- const t = es(e.__scopeSlider), [a, o] = c.useState(null), i = U(n, (l) => o(l)), s = c.useMemo(
2744
- () => a ? t().findIndex((l) => l.ref.current === a) : -1,
2745
- [t, a]
2746
- );
2747
- return /* @__PURE__ */ r.jsx(as, { ...e, ref: i, index: s });
2748
- }
2749
- ), as = c.forwardRef(
2750
- (e, n) => {
2751
- const { __scopeSlider: t, index: a, name: o, ...i } = e, s = He(pt, t), l = Jn(pt, t), [d, u] = c.useState(null), f = U(n, (w) => u(w)), p = d ? s.form || !!d.closest("form") : !0, h = De(d), x = s.values[a], S = x === void 0 ? 0 : ao(x, s.min, s.max), m = cs(a, s.values.length), v = h?.[l.size], b = v ? ds(v, S, l.direction) : 0;
2752
- return c.useEffect(() => {
2753
- if (d)
2754
- return s.thumbs.add(d), () => {
2755
- s.thumbs.delete(d);
2756
- };
2757
- }, [d, s.thumbs]), /* @__PURE__ */ r.jsxs(
2758
- "span",
2759
- {
2760
- style: {
2761
- transform: "var(--radix-slider-thumb-transform)",
2762
- position: "absolute",
2763
- [l.startEdge]: `calc(${S}% + ${b}px)`
2764
- },
2765
- children: [
2766
- /* @__PURE__ */ r.jsx(dt.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ r.jsx(
2767
- _.span,
2768
- {
2769
- role: "slider",
2770
- "aria-label": e["aria-label"] || m,
2771
- "aria-valuemin": s.min,
2772
- "aria-valuenow": x,
2773
- "aria-valuemax": s.max,
2774
- "aria-orientation": s.orientation,
2775
- "data-orientation": s.orientation,
2776
- "data-disabled": s.disabled ? "" : void 0,
2777
- tabIndex: s.disabled ? void 0 : 0,
2778
- ...i,
2779
- ref: f,
2780
- style: x === void 0 ? { display: "none" } : e.style,
2781
- onFocus: T(e.onFocus, () => {
2782
- s.valueIndexToChangeRef.current = a;
2783
- })
2784
- }
2785
- ) }),
2786
- p && /* @__PURE__ */ r.jsx(
2787
- ro,
2788
- {
2789
- name: o ?? (s.name ? s.name + (s.values.length > 1 ? "[]" : "") : void 0),
2790
- form: s.form,
2791
- value: x
2792
- },
2793
- a
2794
- )
2795
- ]
2796
- }
2797
- );
2798
- }
2799
- );
2800
- oo.displayName = pt;
2801
- var ss = "RadioBubbleInput", ro = c.forwardRef(
2802
- ({ __scopeSlider: e, value: n, ...t }, a) => {
2803
- const o = c.useRef(null), i = U(o, a), s = _e(n);
2804
- return c.useEffect(() => {
2805
- const l = o.current;
2806
- if (!l) return;
2807
- const d = window.HTMLInputElement.prototype, f = Object.getOwnPropertyDescriptor(d, "value").set;
2808
- if (s !== n && f) {
2809
- const p = new Event("input", { bubbles: !0 });
2810
- f.call(l, n), l.dispatchEvent(p);
2811
- }
2812
- }, [s, n]), /* @__PURE__ */ r.jsx(
2813
- _.input,
2814
- {
2815
- style: { display: "none" },
2816
- ...t,
2817
- ref: i,
2818
- defaultValue: n
2819
- }
2820
- );
2821
- }
2822
- );
2823
- ro.displayName = ss;
2824
- function is(e = [], n, t) {
2825
- const a = [...e];
2826
- return a[t] = n, a.sort((o, i) => o - i);
2827
- }
2828
- function ao(e, n, t) {
2829
- const i = 100 / (t - n) * (e - n);
2830
- return Pe(i, [0, 100]);
2831
- }
2832
- function cs(e, n) {
2833
- return n > 2 ? `Value ${e + 1} of ${n}` : n === 2 ? ["Minimum", "Maximum"][e] : void 0;
2834
- }
2835
- function ls(e, n) {
2836
- if (e.length === 1) return 0;
2837
- const t = e.map((o) => Math.abs(o - n)), a = Math.min(...t);
2838
- return t.indexOf(a);
2839
- }
2840
- function ds(e, n, t) {
2841
- const a = e / 2, i = St([0, 50], [0, a]);
2842
- return (a - i(n) * t) * t;
2843
- }
2844
- function us(e) {
2845
- return e.slice(0, -1).map((n, t) => e[t + 1] - n);
2846
- }
2847
- function ps(e, n) {
2848
- if (n > 0) {
2849
- const t = us(e);
2850
- return Math.min(...t) >= n;
2851
- }
2852
- return !0;
2853
- }
2854
- function St(e, n) {
2855
- return (t) => {
2856
- if (e[0] === e[1] || n[0] === n[1]) return n[0];
2857
- const a = (n[1] - n[0]) / (e[1] - e[0]);
2858
- return n[0] + a * (t - e[0]);
2859
- };
2860
- }
2861
- function fs(e) {
2862
- return (String(e).split(".")[1] || "").length;
2863
- }
2864
- function ms(e, n) {
2865
- const t = Math.pow(10, n);
2866
- return Math.round(e * t) / t;
2867
- }
2868
- var hs = Xn, vs = to, gs = no, xs = oo;
2869
- function bs({
2870
- className: e,
2871
- trackClassName: n,
2872
- thumbClassName: t,
2873
- defaultValue: a,
2874
- value: o,
2875
- min: i = 0,
2876
- max: s = 100,
2877
- ...l
2878
- }) {
2879
- const d = c.useMemo(
2880
- () => Array.isArray(o) ? o : Array.isArray(a) ? a : [i, s],
2881
- [o, a, i, s]
2882
- );
2883
- return /* @__PURE__ */ r.jsxs(
2884
- hs,
2885
- {
2886
- className: B(
2887
- "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
2888
- e
2889
- ),
2890
- "data-slot": "slider",
2891
- defaultValue: a,
2892
- max: s,
2893
- min: i,
2894
- value: o,
2895
- ...l,
2896
- children: [
2897
- /* @__PURE__ */ r.jsx(
2898
- vs,
2899
- {
2900
- className: B(
2901
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",
2902
- n
2903
- ),
2904
- "data-slot": "slider-track",
2905
- children: /* @__PURE__ */ r.jsx(
2906
- gs,
2907
- {
2908
- className: B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"),
2909
- "data-slot": "slider-range"
2910
- }
2911
- )
2912
- }
2913
- ),
2914
- Array.from({ length: d.length }, (u, f) => /* @__PURE__ */ r.jsx(
2915
- xs,
2916
- {
2917
- className: B(
2918
- "border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50",
2919
- t
2920
- ),
2921
- "data-slot": "slider-thumb"
2922
- },
2923
- f
2924
- ))
2925
- ]
2926
- }
2927
- );
2928
- }
2929
- const Ws = ({ size: e = "md", thumbClassName: n, trackClassName: t, value: a, defaultValue: o, ...i }) => {
2930
- const s = o !== void 0 ? Array.isArray(o) ? o : [o] : void 0, l = a !== void 0 ? Array.isArray(a) ? a : [a] : void 0;
2931
- return /* @__PURE__ */ r.jsx(
2932
- bs,
2933
- {
2934
- defaultValue: s,
2935
- thumbClassName: B(
2936
- {
2937
- "size-2": e === "xs",
2938
- "size-3": e === "sm",
2939
- "size-4": e === "md",
2940
- "size-5": e === "lg",
2941
- "size-6": e === "xl"
2942
- },
2943
- "bg-primary",
2944
- n
2945
- ),
2946
- trackClassName: B(
2947
- {
2948
- "data-[orientation=horizontal]:h-1 data-[orientation=vertical]:w-1": e === "xs",
2949
- "data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5": e === "sm",
2950
- "data-[orientation=horizontal]:h-2 data-[orientation=vertical]:w-2": e === "md",
2951
- "data-[orientation=horizontal]:h-3 data-[orientation=vertical]:w-3": e === "lg",
2952
- "data-[orientation=horizontal]:h-4 data-[orientation=vertical]:w-4": e === "xl"
2953
- },
2954
- t
2955
- ),
2956
- value: l,
2957
- ...i
2958
- }
2959
- );
2960
- };
2961
- var Ue = "Switch", [Ss, qs] = ge(Ue), [ws, ys] = Ss(Ue), so = c.forwardRef(
2962
- (e, n) => {
2963
- const {
2964
- __scopeSwitch: t,
2965
- name: a,
2966
- checked: o,
2967
- defaultChecked: i,
2968
- required: s,
2969
- disabled: l,
2970
- value: d = "on",
2971
- onCheckedChange: u,
2972
- form: f,
2973
- ...p
2974
- } = e, [h, x] = c.useState(null), S = U(n, (y) => x(y)), m = c.useRef(!1), v = h ? f || !!h.closest("form") : !0, [b, w] = pe({
2975
- prop: o,
2976
- defaultProp: i ?? !1,
2977
- onChange: u,
2978
- caller: Ue
2979
- });
2980
- return /* @__PURE__ */ r.jsxs(ws, { scope: t, checked: b, disabled: l, children: [
2981
- /* @__PURE__ */ r.jsx(
2982
- _.button,
2983
- {
2984
- type: "button",
2985
- role: "switch",
2986
- "aria-checked": b,
2987
- "aria-required": s,
2988
- "data-state": uo(b),
2989
- "data-disabled": l ? "" : void 0,
2990
- disabled: l,
2991
- value: d,
2992
- ...p,
2993
- ref: S,
2994
- onClick: T(e.onClick, (y) => {
2995
- w((R) => !R), v && (m.current = y.isPropagationStopped(), m.current || y.stopPropagation());
2996
- })
2997
- }
2998
- ),
2999
- v && /* @__PURE__ */ r.jsx(
3000
- lo,
3001
- {
3002
- control: h,
3003
- bubbles: !m.current,
3004
- name: a,
3005
- value: d,
3006
- checked: b,
3007
- required: s,
3008
- disabled: l,
3009
- form: f,
3010
- style: { transform: "translateX(-100%)" }
3011
- }
3012
- )
3013
- ] });
3014
- }
3015
- );
3016
- so.displayName = Ue;
3017
- var io = "SwitchThumb", co = c.forwardRef(
3018
- (e, n) => {
3019
- const { __scopeSwitch: t, ...a } = e, o = ys(io, t);
3020
- return /* @__PURE__ */ r.jsx(
3021
- _.span,
3022
- {
3023
- "data-state": uo(o.checked),
3024
- "data-disabled": o.disabled ? "" : void 0,
3025
- ...a,
3026
- ref: n
3027
- }
3028
- );
3029
- }
3030
- );
3031
- co.displayName = io;
3032
- var Cs = "SwitchBubbleInput", lo = c.forwardRef(
3033
- ({
3034
- __scopeSwitch: e,
3035
- control: n,
3036
- checked: t,
3037
- bubbles: a = !0,
3038
- ...o
3039
- }, i) => {
3040
- const s = c.useRef(null), l = U(s, i), d = _e(t), u = De(n);
3041
- return c.useEffect(() => {
3042
- const f = s.current;
3043
- if (!f) return;
3044
- const p = window.HTMLInputElement.prototype, x = Object.getOwnPropertyDescriptor(
3045
- p,
3046
- "checked"
3047
- ).set;
3048
- if (d !== t && x) {
3049
- const S = new Event("click", { bubbles: a });
3050
- x.call(f, t), f.dispatchEvent(S);
3051
- }
3052
- }, [d, t, a]), /* @__PURE__ */ r.jsx(
3053
- "input",
3054
- {
3055
- type: "checkbox",
3056
- "aria-hidden": !0,
3057
- defaultChecked: t,
3058
- ...o,
3059
- tabIndex: -1,
3060
- ref: l,
3061
- style: {
3062
- ...o.style,
3063
- ...u,
3064
- position: "absolute",
3065
- pointerEvents: "none",
3066
- opacity: 0,
3067
- margin: 0
3068
- }
3069
- }
3070
- );
3071
- }
3072
- );
3073
- lo.displayName = Cs;
3074
- function uo(e) {
3075
- return e ? "checked" : "unchecked";
3076
- }
3077
- var Is = so, Rs = co;
3078
- function ks({
3079
- className: e,
3080
- thumbClassName: n,
3081
- ...t
3082
- }) {
3083
- return /* @__PURE__ */ r.jsx(
3084
- Is,
3085
- {
3086
- className: B(
3087
- "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
3088
- e
3089
- ),
3090
- "data-slot": "switch",
3091
- ...t,
3092
- children: /* @__PURE__ */ r.jsx(
3093
- Rs,
3094
- {
3095
- className: B(
3096
- "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0",
3097
- n
3098
- ),
3099
- "data-slot": "switch-thumb"
3100
- }
3101
- )
3102
- }
3103
- );
3104
- }
3105
- const Ys = ({
3106
- id: e,
3107
- label: n,
3108
- className: t,
3109
- thumbClassName: a,
3110
- labelClassName: o,
3111
- size: i = "md",
3112
- ...s
3113
- }) => {
3114
- const l = Po(), d = e || l, [u, f] = Array.isArray(n) ? n : [null, n], p = "cursor-pointer", h = o && Array.isArray(o) ? o[0] : o, x = o && Array.isArray(o) ? o[1] : o;
3115
- return /* @__PURE__ */ r.jsxs("div", { className: "flex items-center space-x-2", children: [
3116
- u && /* @__PURE__ */ r.jsx(fe, { className: B(p, h), htmlFor: d, size: i, children: u }),
3117
- /* @__PURE__ */ r.jsx(
3118
- ks,
3119
- {
3120
- className: B(
3121
- {
3122
- "h-[10px] w-4": i === "xs",
3123
- "h-[14px] w-6": i === "sm",
3124
- "h-[18px] w-8": i === "md",
3125
- "h-[22px] w-10": i === "lg",
3126
- "h-[26px] w-12": i === "xl"
3127
- },
3128
- t
3129
- ),
3130
- id: d,
3131
- thumbClassName: B(
3132
- {
3133
- "size-2": i === "xs",
3134
- "size-3": i === "sm",
3135
- "size-4": i === "md",
3136
- "size-5": i === "lg",
3137
- "size-6": i === "xl"
3138
- },
3139
- a
3140
- ),
3141
- ...s
3142
- }
3143
- ),
3144
- /* @__PURE__ */ r.jsx(fe, { className: B(p, x), htmlFor: d, size: i, children: f })
3145
- ] });
3146
- };
3147
- export {
3148
- Ls as C,
3149
- As as D,
3150
- mr as I,
3151
- Sr as L,
3152
- $s as P,
3153
- Ks as R,
3154
- Ds as S,
3155
- Fs as a,
3156
- Bs as b,
3157
- Us as c,
3158
- Gs as d,
3159
- Ws as e,
3160
- Ys as f,
3161
- Lt as g,
3162
- fr as h
3163
- };