commerce-toolkit 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,776 @@
1
+ import { jsx as l, jsxs as V } from "react/jsx-runtime";
2
+ import * as i from "react";
3
+ import h, { useState as Ae, useEffect as xe, createContext as be, useContext as ye } from "react";
4
+ import "react-dom";
5
+ function vt({ colorScheme: e = "light", items: t, ...o }) {
6
+ return /* @__PURE__ */ l(ut, { colorScheme: e, children: /* @__PURE__ */ l(st, { ...o, children: t.map((n, r) => /* @__PURE__ */ V(at, { value: n.title, children: [
7
+ /* @__PURE__ */ l(dt, { children: n.title }),
8
+ /* @__PURE__ */ l(lt, { children: n.content })
9
+ ] }, r)) }) });
10
+ }
11
+ function W(e, t = []) {
12
+ let o = [];
13
+ function n(c, s) {
14
+ const a = i.createContext(s), d = o.length;
15
+ o = [...o, s];
16
+ const u = (f) => {
17
+ const { scope: A, children: v, ...b } = f, C = A?.[e]?.[d] || a, g = i.useMemo(() => b, Object.values(b));
18
+ return /* @__PURE__ */ l(C.Provider, { value: g, children: v });
19
+ };
20
+ u.displayName = c + "Provider";
21
+ function p(f, A) {
22
+ const v = A?.[e]?.[d] || a, b = i.useContext(v);
23
+ if (b) return b;
24
+ if (s !== void 0) return s;
25
+ throw new Error(`\`${f}\` must be used within \`${c}\``);
26
+ }
27
+ return [u, p];
28
+ }
29
+ const r = () => {
30
+ const c = o.map((s) => i.createContext(s));
31
+ return function(a) {
32
+ const d = a?.[e] || c;
33
+ return i.useMemo(
34
+ () => ({ [`__scope${e}`]: { ...a, [e]: d } }),
35
+ [a, d]
36
+ );
37
+ };
38
+ };
39
+ return r.scopeName = e, [n, Ne(r, ...t)];
40
+ }
41
+ function Ne(...e) {
42
+ const t = e[0];
43
+ if (e.length === 1) return t;
44
+ const o = () => {
45
+ const n = e.map((r) => ({
46
+ useScope: r(),
47
+ scopeName: r.scopeName
48
+ }));
49
+ return function(c) {
50
+ const s = n.reduce((a, { useScope: d, scopeName: u }) => {
51
+ const f = d(c)[`__scope${u}`];
52
+ return { ...a, ...f };
53
+ }, {});
54
+ return i.useMemo(() => ({ [`__scope${t.scopeName}`]: s }), [s]);
55
+ };
56
+ };
57
+ return o.scopeName = t.scopeName, o;
58
+ }
59
+ function Z(e, t) {
60
+ if (typeof e == "function")
61
+ return e(t);
62
+ e != null && (e.current = t);
63
+ }
64
+ function J(...e) {
65
+ return (t) => {
66
+ let o = !1;
67
+ const n = e.map((r) => {
68
+ const c = Z(r, t);
69
+ return !o && typeof c == "function" && (o = !0), c;
70
+ });
71
+ if (o)
72
+ return () => {
73
+ for (let r = 0; r < n.length; r++) {
74
+ const c = n[r];
75
+ typeof c == "function" ? c() : Z(e[r], null);
76
+ }
77
+ };
78
+ };
79
+ }
80
+ function w(...e) {
81
+ return i.useCallback(J(...e), e);
82
+ }
83
+ // @__NO_SIDE_EFFECTS__
84
+ function U(e) {
85
+ const t = /* @__PURE__ */ Re(e), o = i.forwardRef((n, r) => {
86
+ const { children: c, ...s } = n, a = i.Children.toArray(c), d = a.find(Se);
87
+ if (d) {
88
+ const u = d.props.children, p = a.map((f) => f === d ? i.Children.count(u) > 1 ? i.Children.only(null) : i.isValidElement(u) ? u.props.children : null : f);
89
+ return /* @__PURE__ */ l(t, { ...s, ref: r, children: i.isValidElement(u) ? i.cloneElement(u, void 0, p) : null });
90
+ }
91
+ return /* @__PURE__ */ l(t, { ...s, ref: r, children: c });
92
+ });
93
+ return o.displayName = `${e}.Slot`, o;
94
+ }
95
+ // @__NO_SIDE_EFFECTS__
96
+ function Re(e) {
97
+ const t = i.forwardRef((o, n) => {
98
+ const { children: r, ...c } = o;
99
+ if (i.isValidElement(r)) {
100
+ const s = Pe(r), a = we(c, r.props);
101
+ return r.type !== i.Fragment && (a.ref = n ? J(n, s) : s), i.cloneElement(r, a);
102
+ }
103
+ return i.Children.count(r) > 1 ? i.Children.only(null) : null;
104
+ });
105
+ return t.displayName = `${e}.SlotClone`, t;
106
+ }
107
+ var Ie = Symbol("radix.slottable");
108
+ function Se(e) {
109
+ return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === Ie;
110
+ }
111
+ function we(e, t) {
112
+ const o = { ...t };
113
+ for (const n in t) {
114
+ const r = e[n], c = t[n];
115
+ /^on[A-Z]/.test(n) ? r && c ? o[n] = (...a) => {
116
+ const d = c(...a);
117
+ return r(...a), d;
118
+ } : r && (o[n] = r) : n === "style" ? o[n] = { ...r, ...c } : n === "className" && (o[n] = [r, c].filter(Boolean).join(" "));
119
+ }
120
+ return { ...e, ...o };
121
+ }
122
+ function Pe(e) {
123
+ let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, o = t && "isReactWarning" in t && t.isReactWarning;
124
+ return o ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
125
+ }
126
+ function Ee(e) {
127
+ const t = e + "CollectionProvider", [o, n] = W(t), [r, c] = o(
128
+ t,
129
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
130
+ ), s = (C) => {
131
+ const { scope: g, children: y } = C, m = h.useRef(null), x = h.useRef(/* @__PURE__ */ new Map()).current;
132
+ return /* @__PURE__ */ l(r, { scope: g, itemMap: x, collectionRef: m, children: y });
133
+ };
134
+ s.displayName = t;
135
+ const a = e + "CollectionSlot", d = /* @__PURE__ */ U(a), u = h.forwardRef(
136
+ (C, g) => {
137
+ const { scope: y, children: m } = C, x = c(a, y), N = w(g, x.collectionRef);
138
+ return /* @__PURE__ */ l(d, { ref: N, children: m });
139
+ }
140
+ );
141
+ u.displayName = a;
142
+ const p = e + "CollectionItemSlot", f = "data-radix-collection-item", A = /* @__PURE__ */ U(p), v = h.forwardRef(
143
+ (C, g) => {
144
+ const { scope: y, children: m, ...x } = C, N = h.useRef(null), S = w(g, N), I = c(p, y);
145
+ return h.useEffect(() => (I.itemMap.set(N, { ref: N, ...x }), () => void I.itemMap.delete(N))), /* @__PURE__ */ l(A, { [f]: "", ref: S, children: m });
146
+ }
147
+ );
148
+ v.displayName = p;
149
+ function b(C) {
150
+ const g = c(e + "CollectionConsumer", C);
151
+ return h.useCallback(() => {
152
+ const m = g.collectionRef.current;
153
+ if (!m) return [];
154
+ const x = Array.from(m.querySelectorAll(`[${f}]`));
155
+ return Array.from(g.itemMap.values()).sort(
156
+ (I, $) => x.indexOf(I.ref.current) - x.indexOf($.ref.current)
157
+ );
158
+ }, [g.collectionRef, g.itemMap]);
159
+ }
160
+ return [
161
+ { Provider: s, Slot: u, ItemSlot: v },
162
+ b,
163
+ n
164
+ ];
165
+ }
166
+ function Q(e, t, { checkForDefaultPrevented: o = !0 } = {}) {
167
+ return function(r) {
168
+ if (e?.(r), o === !1 || !r.defaultPrevented)
169
+ return t?.(r);
170
+ };
171
+ }
172
+ var P = globalThis?.document ? i.useLayoutEffect : () => {
173
+ }, _e = i[" useInsertionEffect ".trim().toString()] || P;
174
+ function H({
175
+ prop: e,
176
+ defaultProp: t,
177
+ onChange: o = () => {
178
+ },
179
+ caller: n
180
+ }) {
181
+ const [r, c, s] = Me({
182
+ defaultProp: t,
183
+ onChange: o
184
+ }), a = e !== void 0, d = a ? e : r;
185
+ {
186
+ const p = i.useRef(e !== void 0);
187
+ i.useEffect(() => {
188
+ const f = p.current;
189
+ f !== a && console.warn(
190
+ `${n} is changing from ${f ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
191
+ ), p.current = a;
192
+ }, [a, n]);
193
+ }
194
+ const u = i.useCallback(
195
+ (p) => {
196
+ if (a) {
197
+ const f = Oe(p) ? p(e) : p;
198
+ f !== e && s.current?.(f);
199
+ } else
200
+ c(p);
201
+ },
202
+ [a, e, c, s]
203
+ );
204
+ return [d, u];
205
+ }
206
+ function Me({
207
+ defaultProp: e,
208
+ onChange: t
209
+ }) {
210
+ const [o, n] = i.useState(e), r = i.useRef(o), c = i.useRef(t);
211
+ return _e(() => {
212
+ c.current = t;
213
+ }, [t]), i.useEffect(() => {
214
+ r.current !== o && (c.current?.(o), r.current = o);
215
+ }, [o, r]), [o, n, c];
216
+ }
217
+ function Oe(e) {
218
+ return typeof e == "function";
219
+ }
220
+ var Te = [
221
+ "a",
222
+ "button",
223
+ "div",
224
+ "form",
225
+ "h2",
226
+ "h3",
227
+ "img",
228
+ "input",
229
+ "label",
230
+ "li",
231
+ "nav",
232
+ "ol",
233
+ "p",
234
+ "select",
235
+ "span",
236
+ "svg",
237
+ "ul"
238
+ ], _ = Te.reduce((e, t) => {
239
+ const o = /* @__PURE__ */ U(`Primitive.${t}`), n = i.forwardRef((r, c) => {
240
+ const { asChild: s, ...a } = r, d = s ? o : t;
241
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ l(d, { ...a, ref: c });
242
+ });
243
+ return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
244
+ }, {});
245
+ function ke(e, t) {
246
+ return i.useReducer((o, n) => t[o][n] ?? o, e);
247
+ }
248
+ var X = (e) => {
249
+ const { present: t, children: o } = e, n = De(t), r = typeof o == "function" ? o({ present: n.isPresent }) : i.Children.only(o), c = w(n.ref, $e(r));
250
+ return typeof o == "function" || n.isPresent ? i.cloneElement(r, { ref: c }) : null;
251
+ };
252
+ X.displayName = "Presence";
253
+ function De(e) {
254
+ const [t, o] = i.useState(), n = i.useRef(null), r = i.useRef(e), c = i.useRef("none"), s = e ? "mounted" : "unmounted", [a, d] = ke(s, {
255
+ mounted: {
256
+ UNMOUNT: "unmounted",
257
+ ANIMATION_OUT: "unmountSuspended"
258
+ },
259
+ unmountSuspended: {
260
+ MOUNT: "mounted",
261
+ ANIMATION_END: "unmounted"
262
+ },
263
+ unmounted: {
264
+ MOUNT: "mounted"
265
+ }
266
+ });
267
+ return i.useEffect(() => {
268
+ const u = M(n.current);
269
+ c.current = a === "mounted" ? u : "none";
270
+ }, [a]), P(() => {
271
+ const u = n.current, p = r.current;
272
+ if (p !== e) {
273
+ const A = c.current, v = M(u);
274
+ e ? d("MOUNT") : v === "none" || u?.display === "none" ? d("UNMOUNT") : d(p && A !== v ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
275
+ }
276
+ }, [e, d]), P(() => {
277
+ if (t) {
278
+ let u;
279
+ const p = t.ownerDocument.defaultView ?? window, f = (v) => {
280
+ const C = M(n.current).includes(CSS.escape(v.animationName));
281
+ if (v.target === t && C && (d("ANIMATION_END"), !r.current)) {
282
+ const g = t.style.animationFillMode;
283
+ t.style.animationFillMode = "forwards", u = p.setTimeout(() => {
284
+ t.style.animationFillMode === "forwards" && (t.style.animationFillMode = g);
285
+ });
286
+ }
287
+ }, A = (v) => {
288
+ v.target === t && (c.current = M(n.current));
289
+ };
290
+ return t.addEventListener("animationstart", A), t.addEventListener("animationcancel", f), t.addEventListener("animationend", f), () => {
291
+ p.clearTimeout(u), t.removeEventListener("animationstart", A), t.removeEventListener("animationcancel", f), t.removeEventListener("animationend", f);
292
+ };
293
+ } else
294
+ d("ANIMATION_END");
295
+ }, [t, d]), {
296
+ isPresent: ["mounted", "unmountSuspended"].includes(a),
297
+ ref: i.useCallback((u) => {
298
+ n.current = u ? getComputedStyle(u) : null, o(u);
299
+ }, [])
300
+ };
301
+ }
302
+ function M(e) {
303
+ return e?.animationName || "none";
304
+ }
305
+ function $e(e) {
306
+ let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, o = t && "isReactWarning" in t && t.isReactWarning;
307
+ return o ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, o = t && "isReactWarning" in t && t.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
308
+ }
309
+ var Le = i[" useId ".trim().toString()] || (() => {
310
+ }), Ve = 0;
311
+ function ee(e) {
312
+ const [t, o] = i.useState(Le());
313
+ return P(() => {
314
+ o((n) => n ?? String(Ve++));
315
+ }, [e]), t ? `radix-${t}` : "";
316
+ }
317
+ var T = "Collapsible", [Ue, te] = W(T), [Fe, j] = Ue(T), oe = i.forwardRef(
318
+ (e, t) => {
319
+ const {
320
+ __scopeCollapsible: o,
321
+ open: n,
322
+ defaultOpen: r,
323
+ disabled: c,
324
+ onOpenChange: s,
325
+ ...a
326
+ } = e, [d, u] = H({
327
+ prop: n,
328
+ defaultProp: r ?? !1,
329
+ onChange: s,
330
+ caller: T
331
+ });
332
+ return /* @__PURE__ */ l(
333
+ Fe,
334
+ {
335
+ scope: o,
336
+ disabled: c,
337
+ contentId: ee(),
338
+ open: d,
339
+ onOpenToggle: i.useCallback(() => u((p) => !p), [u]),
340
+ children: /* @__PURE__ */ l(
341
+ _.div,
342
+ {
343
+ "data-state": G(d),
344
+ "data-disabled": c ? "" : void 0,
345
+ ...a,
346
+ ref: t
347
+ }
348
+ )
349
+ }
350
+ );
351
+ }
352
+ );
353
+ oe.displayName = T;
354
+ var ne = "CollapsibleTrigger", re = i.forwardRef(
355
+ (e, t) => {
356
+ const { __scopeCollapsible: o, ...n } = e, r = j(ne, o);
357
+ return /* @__PURE__ */ l(
358
+ _.button,
359
+ {
360
+ type: "button",
361
+ "aria-controls": r.contentId,
362
+ "aria-expanded": r.open || !1,
363
+ "data-state": G(r.open),
364
+ "data-disabled": r.disabled ? "" : void 0,
365
+ disabled: r.disabled,
366
+ ...n,
367
+ ref: t,
368
+ onClick: Q(e.onClick, r.onOpenToggle)
369
+ }
370
+ );
371
+ }
372
+ );
373
+ re.displayName = ne;
374
+ var B = "CollapsibleContent", ce = i.forwardRef(
375
+ (e, t) => {
376
+ const { forceMount: o, ...n } = e, r = j(B, e.__scopeCollapsible);
377
+ return /* @__PURE__ */ l(X, { present: o || r.open, children: ({ present: c }) => /* @__PURE__ */ l(We, { ...n, ref: t, present: c }) });
378
+ }
379
+ );
380
+ ce.displayName = B;
381
+ var We = i.forwardRef((e, t) => {
382
+ const { __scopeCollapsible: o, present: n, children: r, ...c } = e, s = j(B, o), [a, d] = i.useState(n), u = i.useRef(null), p = w(t, u), f = i.useRef(0), A = f.current, v = i.useRef(0), b = v.current, C = s.open || a, g = i.useRef(C), y = i.useRef(void 0);
383
+ return i.useEffect(() => {
384
+ const m = requestAnimationFrame(() => g.current = !1);
385
+ return () => cancelAnimationFrame(m);
386
+ }, []), P(() => {
387
+ const m = u.current;
388
+ if (m) {
389
+ y.current = y.current || {
390
+ transitionDuration: m.style.transitionDuration,
391
+ animationName: m.style.animationName
392
+ }, m.style.transitionDuration = "0s", m.style.animationName = "none";
393
+ const x = m.getBoundingClientRect();
394
+ f.current = x.height, v.current = x.width, g.current || (m.style.transitionDuration = y.current.transitionDuration, m.style.animationName = y.current.animationName), d(n);
395
+ }
396
+ }, [s.open, n]), /* @__PURE__ */ l(
397
+ _.div,
398
+ {
399
+ "data-state": G(s.open),
400
+ "data-disabled": s.disabled ? "" : void 0,
401
+ id: s.contentId,
402
+ hidden: !C,
403
+ ...c,
404
+ ref: p,
405
+ style: {
406
+ "--radix-collapsible-content-height": A ? `${A}px` : void 0,
407
+ "--radix-collapsible-content-width": b ? `${b}px` : void 0,
408
+ ...e.style
409
+ },
410
+ children: C && r
411
+ }
412
+ );
413
+ });
414
+ function G(e) {
415
+ return e ? "open" : "closed";
416
+ }
417
+ var He = oe, je = re, Be = ce, Ge = i.createContext(void 0);
418
+ function Ke(e) {
419
+ const t = i.useContext(Ge);
420
+ return e || t || "ltr";
421
+ }
422
+ var R = "Accordion", qe = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"], [K, ze, Ye] = Ee(R), [k] = W(R, [
423
+ Ye,
424
+ te
425
+ ]), q = te(), ie = h.forwardRef(
426
+ (e, t) => {
427
+ const { type: o, ...n } = e, r = n, c = n;
428
+ return /* @__PURE__ */ l(K.Provider, { scope: e.__scopeAccordion, children: o === "multiple" ? /* @__PURE__ */ l(Xe, { ...c, ref: t }) : /* @__PURE__ */ l(Qe, { ...r, ref: t }) });
429
+ }
430
+ );
431
+ ie.displayName = R;
432
+ var [ae, Ze] = k(R), [se, Je] = k(
433
+ R,
434
+ { collapsible: !1 }
435
+ ), Qe = h.forwardRef(
436
+ (e, t) => {
437
+ const {
438
+ value: o,
439
+ defaultValue: n,
440
+ onValueChange: r = () => {
441
+ },
442
+ collapsible: c = !1,
443
+ ...s
444
+ } = e, [a, d] = H({
445
+ prop: o,
446
+ defaultProp: n ?? "",
447
+ onChange: r,
448
+ caller: R
449
+ });
450
+ return /* @__PURE__ */ l(
451
+ ae,
452
+ {
453
+ scope: e.__scopeAccordion,
454
+ value: h.useMemo(() => a ? [a] : [], [a]),
455
+ onItemOpen: d,
456
+ onItemClose: h.useCallback(() => c && d(""), [c, d]),
457
+ children: /* @__PURE__ */ l(se, { scope: e.__scopeAccordion, collapsible: c, children: /* @__PURE__ */ l(le, { ...s, ref: t }) })
458
+ }
459
+ );
460
+ }
461
+ ), Xe = h.forwardRef((e, t) => {
462
+ const {
463
+ value: o,
464
+ defaultValue: n,
465
+ onValueChange: r = () => {
466
+ },
467
+ ...c
468
+ } = e, [s, a] = H({
469
+ prop: o,
470
+ defaultProp: n ?? [],
471
+ onChange: r,
472
+ caller: R
473
+ }), d = h.useCallback(
474
+ (p) => a((f = []) => [...f, p]),
475
+ [a]
476
+ ), u = h.useCallback(
477
+ (p) => a((f = []) => f.filter((A) => A !== p)),
478
+ [a]
479
+ );
480
+ return /* @__PURE__ */ l(
481
+ ae,
482
+ {
483
+ scope: e.__scopeAccordion,
484
+ value: s,
485
+ onItemOpen: d,
486
+ onItemClose: u,
487
+ children: /* @__PURE__ */ l(se, { scope: e.__scopeAccordion, collapsible: !0, children: /* @__PURE__ */ l(le, { ...c, ref: t }) })
488
+ }
489
+ );
490
+ }), [et, D] = k(R), le = h.forwardRef(
491
+ (e, t) => {
492
+ const { __scopeAccordion: o, disabled: n, dir: r, orientation: c = "vertical", ...s } = e, a = h.useRef(null), d = w(a, t), u = ze(o), f = Ke(r) === "ltr", A = Q(e.onKeyDown, (v) => {
493
+ if (!qe.includes(v.key)) return;
494
+ const b = v.target, C = u().filter((L) => !L.ref.current?.disabled), g = C.findIndex((L) => L.ref.current === b), y = C.length;
495
+ if (g === -1) return;
496
+ v.preventDefault();
497
+ let m = g;
498
+ const x = 0, N = y - 1, S = () => {
499
+ m = g + 1, m > N && (m = x);
500
+ }, I = () => {
501
+ m = g - 1, m < x && (m = N);
502
+ };
503
+ switch (v.key) {
504
+ case "Home":
505
+ m = x;
506
+ break;
507
+ case "End":
508
+ m = N;
509
+ break;
510
+ case "ArrowRight":
511
+ c === "horizontal" && (f ? S() : I());
512
+ break;
513
+ case "ArrowDown":
514
+ c === "vertical" && S();
515
+ break;
516
+ case "ArrowLeft":
517
+ c === "horizontal" && (f ? I() : S());
518
+ break;
519
+ case "ArrowUp":
520
+ c === "vertical" && I();
521
+ break;
522
+ }
523
+ const $ = m % y;
524
+ C[$].ref.current?.focus();
525
+ });
526
+ return /* @__PURE__ */ l(
527
+ et,
528
+ {
529
+ scope: o,
530
+ disabled: n,
531
+ direction: r,
532
+ orientation: c,
533
+ children: /* @__PURE__ */ l(K.Slot, { scope: o, children: /* @__PURE__ */ l(
534
+ _.div,
535
+ {
536
+ ...s,
537
+ "data-orientation": c,
538
+ ref: d,
539
+ onKeyDown: n ? void 0 : A
540
+ }
541
+ ) })
542
+ }
543
+ );
544
+ }
545
+ ), O = "AccordionItem", [tt, z] = k(O), de = h.forwardRef(
546
+ (e, t) => {
547
+ const { __scopeAccordion: o, value: n, ...r } = e, c = D(O, o), s = Ze(O, o), a = q(o), d = ee(), u = n && s.value.includes(n) || !1, p = c.disabled || e.disabled;
548
+ return /* @__PURE__ */ l(
549
+ tt,
550
+ {
551
+ scope: o,
552
+ open: u,
553
+ disabled: p,
554
+ triggerId: d,
555
+ children: /* @__PURE__ */ l(
556
+ He,
557
+ {
558
+ "data-orientation": c.orientation,
559
+ "data-state": ge(u),
560
+ ...a,
561
+ ...r,
562
+ ref: t,
563
+ disabled: p,
564
+ open: u,
565
+ onOpenChange: (f) => {
566
+ f ? s.onItemOpen(n) : s.onItemClose(n);
567
+ }
568
+ }
569
+ )
570
+ }
571
+ );
572
+ }
573
+ );
574
+ de.displayName = O;
575
+ var ue = "AccordionHeader", fe = h.forwardRef(
576
+ (e, t) => {
577
+ const { __scopeAccordion: o, ...n } = e, r = D(R, o), c = z(ue, o);
578
+ return /* @__PURE__ */ l(
579
+ _.h3,
580
+ {
581
+ "data-orientation": r.orientation,
582
+ "data-state": ge(c.open),
583
+ "data-disabled": c.disabled ? "" : void 0,
584
+ ...n,
585
+ ref: t
586
+ }
587
+ );
588
+ }
589
+ );
590
+ fe.displayName = ue;
591
+ var F = "AccordionTrigger", pe = h.forwardRef(
592
+ (e, t) => {
593
+ const { __scopeAccordion: o, ...n } = e, r = D(R, o), c = z(F, o), s = Je(F, o), a = q(o);
594
+ return /* @__PURE__ */ l(K.ItemSlot, { scope: o, children: /* @__PURE__ */ l(
595
+ je,
596
+ {
597
+ "aria-disabled": c.open && !s.collapsible || void 0,
598
+ "data-orientation": r.orientation,
599
+ id: c.triggerId,
600
+ ...a,
601
+ ...n,
602
+ ref: t
603
+ }
604
+ ) });
605
+ }
606
+ );
607
+ pe.displayName = F;
608
+ var me = "AccordionContent", ve = h.forwardRef(
609
+ (e, t) => {
610
+ const { __scopeAccordion: o, ...n } = e, r = D(R, o), c = z(me, o), s = q(o);
611
+ return /* @__PURE__ */ l(
612
+ Be,
613
+ {
614
+ role: "region",
615
+ "aria-labelledby": c.triggerId,
616
+ "data-orientation": r.orientation,
617
+ ...s,
618
+ ...n,
619
+ ref: t,
620
+ style: {
621
+ "--radix-accordion-content-height": "var(--radix-collapsible-content-height)",
622
+ "--radix-accordion-content-width": "var(--radix-collapsible-content-width)",
623
+ ...e.style
624
+ }
625
+ }
626
+ );
627
+ }
628
+ );
629
+ ve.displayName = me;
630
+ function ge(e) {
631
+ return e ? "open" : "closed";
632
+ }
633
+ var ot = ie, nt = de, rt = fe, ct = pe, it = ve;
634
+ function he(e) {
635
+ var t, o, n = "";
636
+ if (typeof e == "string" || typeof e == "number") n += e;
637
+ else if (typeof e == "object") if (Array.isArray(e)) {
638
+ var r = e.length;
639
+ for (t = 0; t < r; t++) e[t] && (o = he(e[t])) && (n && (n += " "), n += o);
640
+ } else for (o in e) e[o] && (n && (n += " "), n += o);
641
+ return n;
642
+ }
643
+ function E() {
644
+ for (var e, t, o = 0, n = "", r = arguments.length; o < r; o++) (e = arguments[o]) && (t = he(e)) && (n && (n += " "), n += t);
645
+ return n;
646
+ }
647
+ function at({ children: e, className: t, ...o }) {
648
+ const { colorScheme: n } = Y();
649
+ return /* @__PURE__ */ l(
650
+ nt,
651
+ {
652
+ className: E(
653
+ "focus:outline-2 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-[var(--accordion-focus,hsl(var(--primary)))] has-[:focus-visible]:ring-offset-4",
654
+ {
655
+ light: "ring-offset-[var(--acordion-light-offset,hsl(var(--background)))]",
656
+ dark: "ring-offset-[var(--acordion-dark-offset,hsl(var(--foreground)))]"
657
+ }[n],
658
+ t
659
+ ),
660
+ "data-slot": "accordion-item",
661
+ ...o,
662
+ children: e
663
+ }
664
+ );
665
+ }
666
+ function st({ ...e }) {
667
+ return /* @__PURE__ */ l(ot, { "data-slot": "accordion-root", ...e });
668
+ }
669
+ function lt({ children: e, ...t }) {
670
+ const { colorScheme: o } = Y(), [n, r] = Ae(!1);
671
+ return xe(() => {
672
+ r(!0);
673
+ }, []), /* @__PURE__ */ l(
674
+ it,
675
+ {
676
+ className: E(
677
+ "overflow-hidden",
678
+ // We need to delay the animation until the component is mounted to avoid the animation from being triggered when the component is first rendered.
679
+ n && "data-[state=closed]:animate-collapse data-[state=open]:animate-expand"
680
+ ),
681
+ ...t,
682
+ children: /* @__PURE__ */ l(
683
+ "div",
684
+ {
685
+ className: E(
686
+ "py-3 text-base font-[var(--accordion-content-font-family,var(--font-family-body))] font-light leading-normal",
687
+ {
688
+ light: "text-[var(--accordion-light-content-text,hsl(var(--foreground)))]",
689
+ dark: "text-[var(--accordion-dark-content-text,hsl(var(--background)))]"
690
+ }[o]
691
+ ),
692
+ children: e
693
+ }
694
+ )
695
+ }
696
+ );
697
+ }
698
+ function dt({ children: e, ...t }) {
699
+ const { colorScheme: o } = Y();
700
+ return /* @__PURE__ */ l(rt, { children: /* @__PURE__ */ V(
701
+ ct,
702
+ {
703
+ className: "group flex w-full cursor-pointer items-start gap-8 border-none py-3 text-start focus:outline-none @md:py-4",
704
+ "data-slot": "accordion-trigger",
705
+ ...t,
706
+ children: [
707
+ /* @__PURE__ */ l(
708
+ "div",
709
+ {
710
+ className: E(
711
+ "flex-1 select-none text-sm font-[var(--accordion-title-font-family,var(--font-family-mono))] font-normal uppercase transition-colors duration-300 ease-out",
712
+ {
713
+ light: "text-[var(--accordion-light-title-text,hsl(var(--contrast-400)))] group-hover:text-[var(--accordion-light-title-text-hover,hsl(var(--foreground)))]",
714
+ dark: "text-[var(--accordion-dark-title-text,hsl(var(--contrast-200)))] group-hover:text-[var(--accordion-dark-title-text-hover,hsl(var(--background)))]"
715
+ }[o]
716
+ ),
717
+ children: e
718
+ }
719
+ ),
720
+ /* @__PURE__ */ V(
721
+ "svg",
722
+ {
723
+ className: E(
724
+ "mt-1 shrink-0 [&>line]:origin-center [&>line]:transition [&>line]:duration-300 [&>line]:ease-out",
725
+ {
726
+ light: "stroke-[var(--accordion-light-title-icon,hsl(var(--contrast-500)))] group-hover:stroke-[var(--accordion-light-title-icon-hover,hsl(var(--foreground)))]",
727
+ dark: "stroke-[var(--accordion-dark-title-icon,hsl(var(--contrast-200)))] group-hover:stroke-[var(--accordion-dark-title-icon-hover,hsl(var(--background)))]"
728
+ }[o]
729
+ ),
730
+ "data-slot": "accordion-chevron",
731
+ viewBox: "0 0 10 10",
732
+ width: 16,
733
+ children: [
734
+ /* @__PURE__ */ l(
735
+ "line",
736
+ {
737
+ className: "group-data-[state=open]:-translate-y-[3px] group-data-[state=open]:-rotate-90",
738
+ strokeLinecap: "round",
739
+ x1: 2,
740
+ x2: 5,
741
+ y1: 2,
742
+ y2: 5
743
+ }
744
+ ),
745
+ /* @__PURE__ */ l(
746
+ "line",
747
+ {
748
+ className: "group-data-[state=open]:-translate-y-[3px] group-data-[state=open]:rotate-90",
749
+ strokeLinecap: "round",
750
+ x1: 8,
751
+ x2: 5,
752
+ y1: 2,
753
+ y2: 5
754
+ }
755
+ )
756
+ ]
757
+ }
758
+ )
759
+ ]
760
+ }
761
+ ) });
762
+ }
763
+ const Ce = be(void 0);
764
+ function ut({ children: e, colorScheme: t = "light" }) {
765
+ return /* @__PURE__ */ l(Ce, { value: { colorScheme: t }, children: e });
766
+ }
767
+ function Y() {
768
+ const e = ye(Ce);
769
+ if (e === void 0)
770
+ throw new Error("useAccordionContext must be used within an AccordionProvider");
771
+ return e;
772
+ }
773
+ export {
774
+ vt as Accordion
775
+ };
776
+ //# sourceMappingURL=index.js.map