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