@spear-ai/spectral 1.1.2 → 1.1.4

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/Drawer.js DELETED
@@ -1,2163 +0,0 @@
1
- import { jsx as P, jsxs as Ce, Fragment as Dt } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import h, { useState as zn, useMemo as Yn, useLayoutEffect as Xn, useEffect as Kn } from "react";
4
- import { u as We, a as ce, P as J, c as oe, d as qn, b as Gn, e as Zn, f as Qn, g as Jn } from "./index-C-ErIYr7.js";
5
- import er from "react-dom";
6
- var tr = s[" useId ".trim().toString()] || (() => {
7
- }), nr = 0;
8
- function qe(e) {
9
- const [t, n] = s.useState(tr());
10
- return We(() => {
11
- n((r) => r ?? String(nr++));
12
- }, [e]), e || (t ? `radix-${t}` : "");
13
- }
14
- function De(e) {
15
- const t = s.useRef(e);
16
- return s.useEffect(() => {
17
- t.current = e;
18
- }), s.useMemo(() => (...n) => t.current?.(...n), []);
19
- }
20
- function rr(e, t = globalThis?.document) {
21
- const n = De(e);
22
- s.useEffect(() => {
23
- const r = (a) => {
24
- a.key === "Escape" && n(a);
25
- };
26
- return t.addEventListener("keydown", r, { capture: !0 }), () => t.removeEventListener("keydown", r, { capture: !0 });
27
- }, [n, t]);
28
- }
29
- var ar = "DismissableLayer", st = "dismissableLayer.update", or = "dismissableLayer.pointerDownOutside", ir = "dismissableLayer.focusOutside", Tt, Ht = s.createContext({
30
- layers: /* @__PURE__ */ new Set(),
31
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
32
- branches: /* @__PURE__ */ new Set()
33
- }), Vt = s.forwardRef(
34
- (e, t) => {
35
- const {
36
- disableOutsidePointerEvents: n = !1,
37
- onEscapeKeyDown: r,
38
- onPointerDownOutside: a,
39
- onFocusOutside: o,
40
- onInteractOutside: u,
41
- onDismiss: i,
42
- ...g
43
- } = e, l = s.useContext(Ht), [d, f] = s.useState(null), m = d?.ownerDocument ?? globalThis?.document, [, E] = s.useState({}), N = ce(t, (v) => f(v)), c = Array.from(l.layers), [y] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), p = c.indexOf(y), R = d ? c.indexOf(d) : -1, C = l.layersWithOutsidePointerEventsDisabled.size > 0, w = R >= p, x = cr((v) => {
44
- const T = v.target, O = [...l.branches].some((F) => F.contains(T));
45
- !w || O || (a?.(v), u?.(v), v.defaultPrevented || i?.());
46
- }, m), W = lr((v) => {
47
- const T = v.target;
48
- [...l.branches].some((F) => F.contains(T)) || (o?.(v), u?.(v), v.defaultPrevented || i?.());
49
- }, m);
50
- return rr((v) => {
51
- R === l.layers.size - 1 && (r?.(v), !v.defaultPrevented && i && (v.preventDefault(), i()));
52
- }, m), s.useEffect(() => {
53
- if (d)
54
- return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (Tt = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(d)), l.layers.add(d), Ot(), () => {
55
- n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = Tt);
56
- };
57
- }, [d, m, n, l]), s.useEffect(() => () => {
58
- d && (l.layers.delete(d), l.layersWithOutsidePointerEventsDisabled.delete(d), Ot());
59
- }, [d, l]), s.useEffect(() => {
60
- const v = () => E({});
61
- return document.addEventListener(st, v), () => document.removeEventListener(st, v);
62
- }, []), /* @__PURE__ */ P(
63
- J.div,
64
- {
65
- ...g,
66
- ref: N,
67
- style: {
68
- pointerEvents: C ? w ? "auto" : "none" : void 0,
69
- ...e.style
70
- },
71
- onFocusCapture: oe(e.onFocusCapture, W.onFocusCapture),
72
- onBlurCapture: oe(e.onBlurCapture, W.onBlurCapture),
73
- onPointerDownCapture: oe(
74
- e.onPointerDownCapture,
75
- x.onPointerDownCapture
76
- )
77
- }
78
- );
79
- }
80
- );
81
- Vt.displayName = ar;
82
- var sr = "DismissableLayerBranch", ur = s.forwardRef((e, t) => {
83
- const n = s.useContext(Ht), r = s.useRef(null), a = ce(t, r);
84
- return s.useEffect(() => {
85
- const o = r.current;
86
- if (o)
87
- return n.branches.add(o), () => {
88
- n.branches.delete(o);
89
- };
90
- }, [n.branches]), /* @__PURE__ */ P(J.div, { ...e, ref: a });
91
- });
92
- ur.displayName = sr;
93
- function cr(e, t = globalThis?.document) {
94
- const n = De(e), r = s.useRef(!1), a = s.useRef(() => {
95
- });
96
- return s.useEffect(() => {
97
- const o = (i) => {
98
- if (i.target && !r.current) {
99
- let g = function() {
100
- jt(
101
- or,
102
- n,
103
- l,
104
- { discrete: !0 }
105
- );
106
- };
107
- const l = { originalEvent: i };
108
- i.pointerType === "touch" ? (t.removeEventListener("click", a.current), a.current = g, t.addEventListener("click", a.current, { once: !0 })) : g();
109
- } else
110
- t.removeEventListener("click", a.current);
111
- r.current = !1;
112
- }, u = window.setTimeout(() => {
113
- t.addEventListener("pointerdown", o);
114
- }, 0);
115
- return () => {
116
- window.clearTimeout(u), t.removeEventListener("pointerdown", o), t.removeEventListener("click", a.current);
117
- };
118
- }, [t, n]), {
119
- // ensures we check React component tree (not just DOM tree)
120
- onPointerDownCapture: () => r.current = !0
121
- };
122
- }
123
- function lr(e, t = globalThis?.document) {
124
- const n = De(e), r = s.useRef(!1);
125
- return s.useEffect(() => {
126
- const a = (o) => {
127
- o.target && !r.current && jt(ir, n, { originalEvent: o }, {
128
- discrete: !1
129
- });
130
- };
131
- return t.addEventListener("focusin", a), () => t.removeEventListener("focusin", a);
132
- }, [t, n]), {
133
- onFocusCapture: () => r.current = !0,
134
- onBlurCapture: () => r.current = !1
135
- };
136
- }
137
- function Ot() {
138
- const e = new CustomEvent(st);
139
- document.dispatchEvent(e);
140
- }
141
- function jt(e, t, n, { discrete: r }) {
142
- const a = n.originalEvent.target, o = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
143
- t && a.addEventListener(e, t, { once: !0 }), r ? qn(a, o) : a.dispatchEvent(o);
144
- }
145
- var Ge = "focusScope.autoFocusOnMount", Ze = "focusScope.autoFocusOnUnmount", At = { bubbles: !1, cancelable: !0 }, dr = "FocusScope", zt = s.forwardRef((e, t) => {
146
- const {
147
- loop: n = !1,
148
- trapped: r = !1,
149
- onMountAutoFocus: a,
150
- onUnmountAutoFocus: o,
151
- ...u
152
- } = e, [i, g] = s.useState(null), l = De(a), d = De(o), f = s.useRef(null), m = ce(t, (c) => g(c)), E = s.useRef({
153
- paused: !1,
154
- pause() {
155
- this.paused = !0;
156
- },
157
- resume() {
158
- this.paused = !1;
159
- }
160
- }).current;
161
- s.useEffect(() => {
162
- if (r) {
163
- let c = function(C) {
164
- if (E.paused || !i) return;
165
- const w = C.target;
166
- i.contains(w) ? f.current = w : ae(f.current, { select: !0 });
167
- }, y = function(C) {
168
- if (E.paused || !i) return;
169
- const w = C.relatedTarget;
170
- w !== null && (i.contains(w) || ae(f.current, { select: !0 }));
171
- }, p = function(C) {
172
- if (document.activeElement === document.body)
173
- for (const x of C)
174
- x.removedNodes.length > 0 && ae(i);
175
- };
176
- document.addEventListener("focusin", c), document.addEventListener("focusout", y);
177
- const R = new MutationObserver(p);
178
- return i && R.observe(i, { childList: !0, subtree: !0 }), () => {
179
- document.removeEventListener("focusin", c), document.removeEventListener("focusout", y), R.disconnect();
180
- };
181
- }
182
- }, [r, i, E.paused]), s.useEffect(() => {
183
- if (i) {
184
- Pt.add(E);
185
- const c = document.activeElement;
186
- if (!i.contains(c)) {
187
- const p = new CustomEvent(Ge, At);
188
- i.addEventListener(Ge, l), i.dispatchEvent(p), p.defaultPrevented || (fr(gr(Yt(i)), { select: !0 }), document.activeElement === c && ae(i));
189
- }
190
- return () => {
191
- i.removeEventListener(Ge, l), setTimeout(() => {
192
- const p = new CustomEvent(Ze, At);
193
- i.addEventListener(Ze, d), i.dispatchEvent(p), p.defaultPrevented || ae(c ?? document.body, { select: !0 }), i.removeEventListener(Ze, d), Pt.remove(E);
194
- }, 0);
195
- };
196
- }
197
- }, [i, l, d, E]);
198
- const N = s.useCallback(
199
- (c) => {
200
- if (!n && !r || E.paused) return;
201
- const y = c.key === "Tab" && !c.altKey && !c.ctrlKey && !c.metaKey, p = document.activeElement;
202
- if (y && p) {
203
- const R = c.currentTarget, [C, w] = mr(R);
204
- C && w ? !c.shiftKey && p === w ? (c.preventDefault(), n && ae(C, { select: !0 })) : c.shiftKey && p === C && (c.preventDefault(), n && ae(w, { select: !0 })) : p === R && c.preventDefault();
205
- }
206
- },
207
- [n, r, E.paused]
208
- );
209
- return /* @__PURE__ */ P(J.div, { tabIndex: -1, ...u, ref: m, onKeyDown: N });
210
- });
211
- zt.displayName = dr;
212
- function fr(e, { select: t = !1 } = {}) {
213
- const n = document.activeElement;
214
- for (const r of e)
215
- if (ae(r, { select: t }), document.activeElement !== n) return;
216
- }
217
- function mr(e) {
218
- const t = Yt(e), n = Nt(t, e), r = Nt(t.reverse(), e);
219
- return [n, r];
220
- }
221
- function Yt(e) {
222
- const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
223
- acceptNode: (r) => {
224
- const a = r.tagName === "INPUT" && r.type === "hidden";
225
- return r.disabled || r.hidden || a ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
226
- }
227
- });
228
- for (; n.nextNode(); ) t.push(n.currentNode);
229
- return t;
230
- }
231
- function Nt(e, t) {
232
- for (const n of e)
233
- if (!vr(n, { upTo: t })) return n;
234
- }
235
- function vr(e, { upTo: t }) {
236
- if (getComputedStyle(e).visibility === "hidden") return !0;
237
- for (; e; ) {
238
- if (t !== void 0 && e === t) return !1;
239
- if (getComputedStyle(e).display === "none") return !0;
240
- e = e.parentElement;
241
- }
242
- return !1;
243
- }
244
- function pr(e) {
245
- return e instanceof HTMLInputElement && "select" in e;
246
- }
247
- function ae(e, { select: t = !1 } = {}) {
248
- if (e && e.focus) {
249
- const n = document.activeElement;
250
- e.focus({ preventScroll: !0 }), e !== n && pr(e) && t && e.select();
251
- }
252
- }
253
- var Pt = hr();
254
- function hr() {
255
- let e = [];
256
- return {
257
- add(t) {
258
- const n = e[0];
259
- t !== n && n?.pause(), e = xt(e, t), e.unshift(t);
260
- },
261
- remove(t) {
262
- e = xt(e, t), e[0]?.resume();
263
- }
264
- };
265
- }
266
- function xt(e, t) {
267
- const n = [...e], r = n.indexOf(t);
268
- return r !== -1 && n.splice(r, 1), n;
269
- }
270
- function gr(e) {
271
- return e.filter((t) => t.tagName !== "A");
272
- }
273
- var wr = "Portal", Xt = s.forwardRef((e, t) => {
274
- const { container: n, ...r } = e, [a, o] = s.useState(!1);
275
- We(() => o(!0), []);
276
- const u = n || a && globalThis?.document?.body;
277
- return u ? er.createPortal(/* @__PURE__ */ P(J.div, { ...r, ref: t }), u) : null;
278
- });
279
- Xt.displayName = wr;
280
- function yr(e, t) {
281
- return s.useReducer((n, r) => t[n][r] ?? n, e);
282
- }
283
- var Ue = (e) => {
284
- const { present: t, children: n } = e, r = br(t), a = typeof n == "function" ? n({ present: r.isPresent }) : s.Children.only(n), o = ce(r.ref, Er(a));
285
- return typeof n == "function" || r.isPresent ? s.cloneElement(a, { ref: o }) : null;
286
- };
287
- Ue.displayName = "Presence";
288
- function br(e) {
289
- const [t, n] = s.useState(), r = s.useRef(null), a = s.useRef(e), o = s.useRef("none"), u = e ? "mounted" : "unmounted", [i, g] = yr(u, {
290
- mounted: {
291
- UNMOUNT: "unmounted",
292
- ANIMATION_OUT: "unmountSuspended"
293
- },
294
- unmountSuspended: {
295
- MOUNT: "mounted",
296
- ANIMATION_END: "unmounted"
297
- },
298
- unmounted: {
299
- MOUNT: "mounted"
300
- }
301
- });
302
- return s.useEffect(() => {
303
- const l = Pe(r.current);
304
- o.current = i === "mounted" ? l : "none";
305
- }, [i]), We(() => {
306
- const l = r.current, d = a.current;
307
- if (d !== e) {
308
- const m = o.current, E = Pe(l);
309
- e ? g("MOUNT") : E === "none" || l?.display === "none" ? g("UNMOUNT") : g(d && m !== E ? "ANIMATION_OUT" : "UNMOUNT"), a.current = e;
310
- }
311
- }, [e, g]), We(() => {
312
- if (t) {
313
- let l;
314
- const d = t.ownerDocument.defaultView ?? window, f = (E) => {
315
- const c = Pe(r.current).includes(CSS.escape(E.animationName));
316
- if (E.target === t && c && (g("ANIMATION_END"), !a.current)) {
317
- const y = t.style.animationFillMode;
318
- t.style.animationFillMode = "forwards", l = d.setTimeout(() => {
319
- t.style.animationFillMode === "forwards" && (t.style.animationFillMode = y);
320
- });
321
- }
322
- }, m = (E) => {
323
- E.target === t && (o.current = Pe(r.current));
324
- };
325
- return t.addEventListener("animationstart", m), t.addEventListener("animationcancel", f), t.addEventListener("animationend", f), () => {
326
- d.clearTimeout(l), t.removeEventListener("animationstart", m), t.removeEventListener("animationcancel", f), t.removeEventListener("animationend", f);
327
- };
328
- } else
329
- g("ANIMATION_END");
330
- }, [t, g]), {
331
- isPresent: ["mounted", "unmountSuspended"].includes(i),
332
- ref: s.useCallback((l) => {
333
- r.current = l ? getComputedStyle(l) : null, n(l);
334
- }, [])
335
- };
336
- }
337
- function Pe(e) {
338
- return e?.animationName || "none";
339
- }
340
- function Er(e) {
341
- let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
342
- return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
343
- }
344
- var Qe = 0;
345
- function Sr() {
346
- s.useEffect(() => {
347
- const e = document.querySelectorAll("[data-radix-focus-guard]");
348
- return document.body.insertAdjacentElement("afterbegin", e[0] ?? Mt()), document.body.insertAdjacentElement("beforeend", e[1] ?? Mt()), Qe++, () => {
349
- Qe === 1 && document.querySelectorAll("[data-radix-focus-guard]").forEach((t) => t.remove()), Qe--;
350
- };
351
- }, []);
352
- }
353
- function Mt() {
354
- const e = document.createElement("span");
355
- return e.setAttribute("data-radix-focus-guard", ""), e.tabIndex = 0, e.style.outline = "none", e.style.opacity = "0", e.style.position = "fixed", e.style.pointerEvents = "none", e;
356
- }
357
- var Z = function() {
358
- return Z = Object.assign || function(t) {
359
- for (var n, r = 1, a = arguments.length; r < a; r++) {
360
- n = arguments[r];
361
- for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
362
- }
363
- return t;
364
- }, Z.apply(this, arguments);
365
- };
366
- function Kt(e, t) {
367
- var n = {};
368
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
369
- if (e != null && typeof Object.getOwnPropertySymbols == "function")
370
- for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
371
- t.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (n[r[a]] = e[r[a]]);
372
- return n;
373
- }
374
- function Rr(e, t, n) {
375
- if (n || arguments.length === 2) for (var r = 0, a = t.length, o; r < a; r++)
376
- (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
377
- return e.concat(o || Array.prototype.slice.call(t));
378
- }
379
- var Fe = "right-scroll-bar-position", $e = "width-before-scroll-bar", Cr = "with-scroll-bars-hidden", Dr = "--removed-body-scroll-bar-size";
380
- function Je(e, t) {
381
- return typeof e == "function" ? e(t) : e && (e.current = t), e;
382
- }
383
- function Tr(e, t) {
384
- var n = zn(function() {
385
- return {
386
- // value
387
- value: e,
388
- // last callback
389
- callback: t,
390
- // "memoized" public interface
391
- facade: {
392
- get current() {
393
- return n.value;
394
- },
395
- set current(r) {
396
- var a = n.value;
397
- a !== r && (n.value = r, n.callback(r, a));
398
- }
399
- }
400
- };
401
- })[0];
402
- return n.callback = t, n.facade;
403
- }
404
- var Or = typeof window < "u" ? s.useLayoutEffect : s.useEffect, It = /* @__PURE__ */ new WeakMap();
405
- function Ar(e, t) {
406
- var n = Tr(null, function(r) {
407
- return e.forEach(function(a) {
408
- return Je(a, r);
409
- });
410
- });
411
- return Or(function() {
412
- var r = It.get(n);
413
- if (r) {
414
- var a = new Set(r), o = new Set(e), u = n.current;
415
- a.forEach(function(i) {
416
- o.has(i) || Je(i, null);
417
- }), o.forEach(function(i) {
418
- a.has(i) || Je(i, u);
419
- });
420
- }
421
- It.set(n, e);
422
- }, [e]), n;
423
- }
424
- function Nr(e) {
425
- return e;
426
- }
427
- function Pr(e, t) {
428
- t === void 0 && (t = Nr);
429
- var n = [], r = !1, a = {
430
- read: function() {
431
- if (r)
432
- throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
433
- return n.length ? n[n.length - 1] : e;
434
- },
435
- useMedium: function(o) {
436
- var u = t(o, r);
437
- return n.push(u), function() {
438
- n = n.filter(function(i) {
439
- return i !== u;
440
- });
441
- };
442
- },
443
- assignSyncMedium: function(o) {
444
- for (r = !0; n.length; ) {
445
- var u = n;
446
- n = [], u.forEach(o);
447
- }
448
- n = {
449
- push: function(i) {
450
- return o(i);
451
- },
452
- filter: function() {
453
- return n;
454
- }
455
- };
456
- },
457
- assignMedium: function(o) {
458
- r = !0;
459
- var u = [];
460
- if (n.length) {
461
- var i = n;
462
- n = [], i.forEach(o), u = n;
463
- }
464
- var g = function() {
465
- var d = u;
466
- u = [], d.forEach(o);
467
- }, l = function() {
468
- return Promise.resolve().then(g);
469
- };
470
- l(), n = {
471
- push: function(d) {
472
- u.push(d), l();
473
- },
474
- filter: function(d) {
475
- return u = u.filter(d), n;
476
- }
477
- };
478
- }
479
- };
480
- return a;
481
- }
482
- function xr(e) {
483
- e === void 0 && (e = {});
484
- var t = Pr(null);
485
- return t.options = Z({ async: !0, ssr: !1 }, e), t;
486
- }
487
- var qt = function(e) {
488
- var t = e.sideCar, n = Kt(e, ["sideCar"]);
489
- if (!t)
490
- throw new Error("Sidecar: please provide `sideCar` property to import the right car");
491
- var r = t.read();
492
- if (!r)
493
- throw new Error("Sidecar medium not found");
494
- return s.createElement(r, Z({}, n));
495
- };
496
- qt.isSideCarExport = !0;
497
- function Mr(e, t) {
498
- return e.useMedium(t), qt;
499
- }
500
- var Gt = xr(), et = function() {
501
- }, He = s.forwardRef(function(e, t) {
502
- var n = s.useRef(null), r = s.useState({
503
- onScrollCapture: et,
504
- onWheelCapture: et,
505
- onTouchMoveCapture: et
506
- }), a = r[0], o = r[1], u = e.forwardProps, i = e.children, g = e.className, l = e.removeScrollBar, d = e.enabled, f = e.shards, m = e.sideCar, E = e.noRelative, N = e.noIsolation, c = e.inert, y = e.allowPinchZoom, p = e.as, R = p === void 0 ? "div" : p, C = e.gapMode, w = Kt(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), x = m, W = Ar([n, t]), v = Z(Z({}, w), a);
507
- return s.createElement(
508
- s.Fragment,
509
- null,
510
- d && s.createElement(x, { sideCar: Gt, removeScrollBar: l, shards: f, noRelative: E, noIsolation: N, inert: c, setCallbacks: o, allowPinchZoom: !!y, lockRef: n, gapMode: C }),
511
- u ? s.cloneElement(s.Children.only(i), Z(Z({}, v), { ref: W })) : s.createElement(R, Z({}, v, { className: g, ref: W }), i)
512
- );
513
- });
514
- He.defaultProps = {
515
- enabled: !0,
516
- removeScrollBar: !0,
517
- inert: !1
518
- };
519
- He.classNames = {
520
- fullWidth: $e,
521
- zeroRight: Fe
522
- };
523
- var Ir = function() {
524
- if (typeof __webpack_nonce__ < "u")
525
- return __webpack_nonce__;
526
- };
527
- function _r() {
528
- if (!document)
529
- return null;
530
- var e = document.createElement("style");
531
- e.type = "text/css";
532
- var t = Ir();
533
- return t && e.setAttribute("nonce", t), e;
534
- }
535
- function Lr(e, t) {
536
- e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
537
- }
538
- function kr(e) {
539
- var t = document.head || document.getElementsByTagName("head")[0];
540
- t.appendChild(e);
541
- }
542
- var Fr = function() {
543
- var e = 0, t = null;
544
- return {
545
- add: function(n) {
546
- e == 0 && (t = _r()) && (Lr(t, n), kr(t)), e++;
547
- },
548
- remove: function() {
549
- e--, !e && t && (t.parentNode && t.parentNode.removeChild(t), t = null);
550
- }
551
- };
552
- }, $r = function() {
553
- var e = Fr();
554
- return function(t, n) {
555
- s.useEffect(function() {
556
- return e.add(t), function() {
557
- e.remove();
558
- };
559
- }, [t && n]);
560
- };
561
- }, Zt = function() {
562
- var e = $r(), t = function(n) {
563
- var r = n.styles, a = n.dynamic;
564
- return e(r, a), null;
565
- };
566
- return t;
567
- }, Wr = {
568
- left: 0,
569
- top: 0,
570
- right: 0,
571
- gap: 0
572
- }, tt = function(e) {
573
- return parseInt(e || "", 10) || 0;
574
- }, Br = function(e) {
575
- var t = window.getComputedStyle(document.body), n = t[e === "padding" ? "paddingLeft" : "marginLeft"], r = t[e === "padding" ? "paddingTop" : "marginTop"], a = t[e === "padding" ? "paddingRight" : "marginRight"];
576
- return [tt(n), tt(r), tt(a)];
577
- }, Ur = function(e) {
578
- if (e === void 0 && (e = "margin"), typeof window > "u")
579
- return Wr;
580
- var t = Br(e), n = document.documentElement.clientWidth, r = window.innerWidth;
581
- return {
582
- left: t[0],
583
- top: t[1],
584
- right: t[2],
585
- gap: Math.max(0, r - n + t[2] - t[0])
586
- };
587
- }, Hr = Zt(), he = "data-scroll-locked", Vr = function(e, t, n, r) {
588
- var a = e.left, o = e.top, u = e.right, i = e.gap;
589
- return n === void 0 && (n = "margin"), `
590
- .`.concat(Cr, ` {
591
- overflow: hidden `).concat(r, `;
592
- padding-right: `).concat(i, "px ").concat(r, `;
593
- }
594
- body[`).concat(he, `] {
595
- overflow: hidden `).concat(r, `;
596
- overscroll-behavior: contain;
597
- `).concat([
598
- t && "position: relative ".concat(r, ";"),
599
- n === "margin" && `
600
- padding-left: `.concat(a, `px;
601
- padding-top: `).concat(o, `px;
602
- padding-right: `).concat(u, `px;
603
- margin-left:0;
604
- margin-top:0;
605
- margin-right: `).concat(i, "px ").concat(r, `;
606
- `),
607
- n === "padding" && "padding-right: ".concat(i, "px ").concat(r, ";")
608
- ].filter(Boolean).join(""), `
609
- }
610
-
611
- .`).concat(Fe, ` {
612
- right: `).concat(i, "px ").concat(r, `;
613
- }
614
-
615
- .`).concat($e, ` {
616
- margin-right: `).concat(i, "px ").concat(r, `;
617
- }
618
-
619
- .`).concat(Fe, " .").concat(Fe, ` {
620
- right: 0 `).concat(r, `;
621
- }
622
-
623
- .`).concat($e, " .").concat($e, ` {
624
- margin-right: 0 `).concat(r, `;
625
- }
626
-
627
- body[`).concat(he, `] {
628
- `).concat(Dr, ": ").concat(i, `px;
629
- }
630
- `);
631
- }, _t = function() {
632
- var e = parseInt(document.body.getAttribute(he) || "0", 10);
633
- return isFinite(e) ? e : 0;
634
- }, jr = function() {
635
- s.useEffect(function() {
636
- return document.body.setAttribute(he, (_t() + 1).toString()), function() {
637
- var e = _t() - 1;
638
- e <= 0 ? document.body.removeAttribute(he) : document.body.setAttribute(he, e.toString());
639
- };
640
- }, []);
641
- }, zr = function(e) {
642
- var t = e.noRelative, n = e.noImportant, r = e.gapMode, a = r === void 0 ? "margin" : r;
643
- jr();
644
- var o = s.useMemo(function() {
645
- return Ur(a);
646
- }, [a]);
647
- return s.createElement(Hr, { styles: Vr(o, !t, a, n ? "" : "!important") });
648
- }, ut = !1;
649
- if (typeof window < "u")
650
- try {
651
- var xe = Object.defineProperty({}, "passive", {
652
- get: function() {
653
- return ut = !0, !0;
654
- }
655
- });
656
- window.addEventListener("test", xe, xe), window.removeEventListener("test", xe, xe);
657
- } catch {
658
- ut = !1;
659
- }
660
- var me = ut ? { passive: !1 } : !1, Yr = function(e) {
661
- return e.tagName === "TEXTAREA";
662
- }, Qt = function(e, t) {
663
- if (!(e instanceof Element))
664
- return !1;
665
- var n = window.getComputedStyle(e);
666
- return (
667
- // not-not-scrollable
668
- n[t] !== "hidden" && // contains scroll inside self
669
- !(n.overflowY === n.overflowX && !Yr(e) && n[t] === "visible")
670
- );
671
- }, Xr = function(e) {
672
- return Qt(e, "overflowY");
673
- }, Kr = function(e) {
674
- return Qt(e, "overflowX");
675
- }, Lt = function(e, t) {
676
- var n = t.ownerDocument, r = t;
677
- do {
678
- typeof ShadowRoot < "u" && r instanceof ShadowRoot && (r = r.host);
679
- var a = Jt(e, r);
680
- if (a) {
681
- var o = en(e, r), u = o[1], i = o[2];
682
- if (u > i)
683
- return !0;
684
- }
685
- r = r.parentNode;
686
- } while (r && r !== n.body);
687
- return !1;
688
- }, qr = function(e) {
689
- var t = e.scrollTop, n = e.scrollHeight, r = e.clientHeight;
690
- return [
691
- t,
692
- n,
693
- r
694
- ];
695
- }, Gr = function(e) {
696
- var t = e.scrollLeft, n = e.scrollWidth, r = e.clientWidth;
697
- return [
698
- t,
699
- n,
700
- r
701
- ];
702
- }, Jt = function(e, t) {
703
- return e === "v" ? Xr(t) : Kr(t);
704
- }, en = function(e, t) {
705
- return e === "v" ? qr(t) : Gr(t);
706
- }, Zr = function(e, t) {
707
- return e === "h" && t === "rtl" ? -1 : 1;
708
- }, Qr = function(e, t, n, r, a) {
709
- var o = Zr(e, window.getComputedStyle(t).direction), u = o * r, i = n.target, g = t.contains(i), l = !1, d = u > 0, f = 0, m = 0;
710
- do {
711
- if (!i)
712
- break;
713
- var E = en(e, i), N = E[0], c = E[1], y = E[2], p = c - y - o * N;
714
- (N || p) && Jt(e, i) && (f += p, m += N);
715
- var R = i.parentNode;
716
- i = R && R.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? R.host : R;
717
- } while (
718
- // portaled content
719
- !g && i !== document.body || // self content
720
- g && (t.contains(i) || t === i)
721
- );
722
- return (d && Math.abs(f) < 1 || !d && Math.abs(m) < 1) && (l = !0), l;
723
- }, Me = function(e) {
724
- return "changedTouches" in e ? [e.changedTouches[0].clientX, e.changedTouches[0].clientY] : [0, 0];
725
- }, kt = function(e) {
726
- return [e.deltaX, e.deltaY];
727
- }, Ft = function(e) {
728
- return e && "current" in e ? e.current : e;
729
- }, Jr = function(e, t) {
730
- return e[0] === t[0] && e[1] === t[1];
731
- }, ea = function(e) {
732
- return `
733
- .block-interactivity-`.concat(e, ` {pointer-events: none;}
734
- .allow-interactivity-`).concat(e, ` {pointer-events: all;}
735
- `);
736
- }, ta = 0, ve = [];
737
- function na(e) {
738
- var t = s.useRef([]), n = s.useRef([0, 0]), r = s.useRef(), a = s.useState(ta++)[0], o = s.useState(Zt)[0], u = s.useRef(e);
739
- s.useEffect(function() {
740
- u.current = e;
741
- }, [e]), s.useEffect(function() {
742
- if (e.inert) {
743
- document.body.classList.add("block-interactivity-".concat(a));
744
- var c = Rr([e.lockRef.current], (e.shards || []).map(Ft), !0).filter(Boolean);
745
- return c.forEach(function(y) {
746
- return y.classList.add("allow-interactivity-".concat(a));
747
- }), function() {
748
- document.body.classList.remove("block-interactivity-".concat(a)), c.forEach(function(y) {
749
- return y.classList.remove("allow-interactivity-".concat(a));
750
- });
751
- };
752
- }
753
- }, [e.inert, e.lockRef.current, e.shards]);
754
- var i = s.useCallback(function(c, y) {
755
- if ("touches" in c && c.touches.length === 2 || c.type === "wheel" && c.ctrlKey)
756
- return !u.current.allowPinchZoom;
757
- var p = Me(c), R = n.current, C = "deltaX" in c ? c.deltaX : R[0] - p[0], w = "deltaY" in c ? c.deltaY : R[1] - p[1], x, W = c.target, v = Math.abs(C) > Math.abs(w) ? "h" : "v";
758
- if ("touches" in c && v === "h" && W.type === "range")
759
- return !1;
760
- var T = Lt(v, W);
761
- if (!T)
762
- return !0;
763
- if (T ? x = v : (x = v === "v" ? "h" : "v", T = Lt(v, W)), !T)
764
- return !1;
765
- if (!r.current && "changedTouches" in c && (C || w) && (r.current = x), !x)
766
- return !0;
767
- var O = r.current || x;
768
- return Qr(O, y, c, O === "h" ? C : w);
769
- }, []), g = s.useCallback(function(c) {
770
- var y = c;
771
- if (!(!ve.length || ve[ve.length - 1] !== o)) {
772
- var p = "deltaY" in y ? kt(y) : Me(y), R = t.current.filter(function(x) {
773
- return x.name === y.type && (x.target === y.target || y.target === x.shadowParent) && Jr(x.delta, p);
774
- })[0];
775
- if (R && R.should) {
776
- y.cancelable && y.preventDefault();
777
- return;
778
- }
779
- if (!R) {
780
- var C = (u.current.shards || []).map(Ft).filter(Boolean).filter(function(x) {
781
- return x.contains(y.target);
782
- }), w = C.length > 0 ? i(y, C[0]) : !u.current.noIsolation;
783
- w && y.cancelable && y.preventDefault();
784
- }
785
- }
786
- }, []), l = s.useCallback(function(c, y, p, R) {
787
- var C = { name: c, delta: y, target: p, should: R, shadowParent: ra(p) };
788
- t.current.push(C), setTimeout(function() {
789
- t.current = t.current.filter(function(w) {
790
- return w !== C;
791
- });
792
- }, 1);
793
- }, []), d = s.useCallback(function(c) {
794
- n.current = Me(c), r.current = void 0;
795
- }, []), f = s.useCallback(function(c) {
796
- l(c.type, kt(c), c.target, i(c, e.lockRef.current));
797
- }, []), m = s.useCallback(function(c) {
798
- l(c.type, Me(c), c.target, i(c, e.lockRef.current));
799
- }, []);
800
- s.useEffect(function() {
801
- return ve.push(o), e.setCallbacks({
802
- onScrollCapture: f,
803
- onWheelCapture: f,
804
- onTouchMoveCapture: m
805
- }), document.addEventListener("wheel", g, me), document.addEventListener("touchmove", g, me), document.addEventListener("touchstart", d, me), function() {
806
- ve = ve.filter(function(c) {
807
- return c !== o;
808
- }), document.removeEventListener("wheel", g, me), document.removeEventListener("touchmove", g, me), document.removeEventListener("touchstart", d, me);
809
- };
810
- }, []);
811
- var E = e.removeScrollBar, N = e.inert;
812
- return s.createElement(
813
- s.Fragment,
814
- null,
815
- N ? s.createElement(o, { styles: ea(a) }) : null,
816
- E ? s.createElement(zr, { noRelative: e.noRelative, gapMode: e.gapMode }) : null
817
- );
818
- }
819
- function ra(e) {
820
- for (var t = null; e !== null; )
821
- e instanceof ShadowRoot && (t = e.host, e = e.host), e = e.parentNode;
822
- return t;
823
- }
824
- const aa = Mr(Gt, na);
825
- var tn = s.forwardRef(function(e, t) {
826
- return s.createElement(He, Z({}, e, { ref: t, sideCar: aa }));
827
- });
828
- tn.classNames = He.classNames;
829
- var oa = function(e) {
830
- if (typeof document > "u")
831
- return null;
832
- var t = Array.isArray(e) ? e[0] : e;
833
- return t.ownerDocument.body;
834
- }, pe = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakMap(), _e = {}, nt = 0, nn = function(e) {
835
- return e && (e.host || nn(e.parentNode));
836
- }, ia = function(e, t) {
837
- return t.map(function(n) {
838
- if (e.contains(n))
839
- return n;
840
- var r = nn(n);
841
- return r && e.contains(r) ? r : (console.error("aria-hidden", n, "in not contained inside", e, ". Doing nothing"), null);
842
- }).filter(function(n) {
843
- return !!n;
844
- });
845
- }, sa = function(e, t, n, r) {
846
- var a = ia(t, Array.isArray(e) ? e : [e]);
847
- _e[n] || (_e[n] = /* @__PURE__ */ new WeakMap());
848
- var o = _e[n], u = [], i = /* @__PURE__ */ new Set(), g = new Set(a), l = function(f) {
849
- !f || i.has(f) || (i.add(f), l(f.parentNode));
850
- };
851
- a.forEach(l);
852
- var d = function(f) {
853
- !f || g.has(f) || Array.prototype.forEach.call(f.children, function(m) {
854
- if (i.has(m))
855
- d(m);
856
- else
857
- try {
858
- var E = m.getAttribute(r), N = E !== null && E !== "false", c = (pe.get(m) || 0) + 1, y = (o.get(m) || 0) + 1;
859
- pe.set(m, c), o.set(m, y), u.push(m), c === 1 && N && Ie.set(m, !0), y === 1 && m.setAttribute(n, "true"), N || m.setAttribute(r, "true");
860
- } catch (p) {
861
- console.error("aria-hidden: cannot operate on ", m, p);
862
- }
863
- });
864
- };
865
- return d(t), i.clear(), nt++, function() {
866
- u.forEach(function(f) {
867
- var m = pe.get(f) - 1, E = o.get(f) - 1;
868
- pe.set(f, m), o.set(f, E), m || (Ie.has(f) || f.removeAttribute(r), Ie.delete(f)), E || f.removeAttribute(n);
869
- }), nt--, nt || (pe = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakMap(), _e = {});
870
- };
871
- }, ua = function(e, t, n) {
872
- n === void 0 && (n = "data-aria-hidden");
873
- var r = Array.from(Array.isArray(e) ? e : [e]), a = oa(e);
874
- return a ? (r.push.apply(r, Array.from(a.querySelectorAll("[aria-live], script"))), sa(r, a, n, "aria-hidden")) : function() {
875
- return null;
876
- };
877
- }, Ve = "Dialog", [rn, ao] = Gn(Ve), [ca, q] = rn(Ve), an = (e) => {
878
- const {
879
- __scopeDialog: t,
880
- children: n,
881
- open: r,
882
- defaultOpen: a,
883
- onOpenChange: o,
884
- modal: u = !0
885
- } = e, i = s.useRef(null), g = s.useRef(null), [l, d] = Jn({
886
- prop: r,
887
- defaultProp: a ?? !1,
888
- onChange: o,
889
- caller: Ve
890
- });
891
- return /* @__PURE__ */ P(
892
- ca,
893
- {
894
- scope: t,
895
- triggerRef: i,
896
- contentRef: g,
897
- contentId: qe(),
898
- titleId: qe(),
899
- descriptionId: qe(),
900
- open: l,
901
- onOpenChange: d,
902
- onOpenToggle: s.useCallback(() => d((f) => !f), [d]),
903
- modal: u,
904
- children: n
905
- }
906
- );
907
- };
908
- an.displayName = Ve;
909
- var on = "DialogTrigger", sn = s.forwardRef(
910
- (e, t) => {
911
- const { __scopeDialog: n, ...r } = e, a = q(on, n), o = ce(t, a.triggerRef);
912
- return /* @__PURE__ */ P(
913
- J.button,
914
- {
915
- type: "button",
916
- "aria-haspopup": "dialog",
917
- "aria-expanded": a.open,
918
- "aria-controls": a.contentId,
919
- "data-state": mt(a.open),
920
- ...r,
921
- ref: o,
922
- onClick: oe(e.onClick, a.onOpenToggle)
923
- }
924
- );
925
- }
926
- );
927
- sn.displayName = on;
928
- var dt = "DialogPortal", [la, un] = rn(dt, {
929
- forceMount: void 0
930
- }), cn = (e) => {
931
- const { __scopeDialog: t, forceMount: n, children: r, container: a } = e, o = q(dt, t);
932
- return /* @__PURE__ */ P(la, { scope: t, forceMount: n, children: s.Children.map(r, (u) => /* @__PURE__ */ P(Ue, { present: n || o.open, children: /* @__PURE__ */ P(Xt, { asChild: !0, container: a, children: u }) })) });
933
- };
934
- cn.displayName = dt;
935
- var Be = "DialogOverlay", ln = s.forwardRef(
936
- (e, t) => {
937
- const n = un(Be, e.__scopeDialog), { forceMount: r = n.forceMount, ...a } = e, o = q(Be, e.__scopeDialog);
938
- return o.modal ? /* @__PURE__ */ P(Ue, { present: r || o.open, children: /* @__PURE__ */ P(fa, { ...a, ref: t }) }) : null;
939
- }
940
- );
941
- ln.displayName = Be;
942
- var da = Zn("DialogOverlay.RemoveScroll"), fa = s.forwardRef(
943
- (e, t) => {
944
- const { __scopeDialog: n, ...r } = e, a = q(Be, n);
945
- return (
946
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
947
- // ie. when `Overlay` and `Content` are siblings
948
- /* @__PURE__ */ P(tn, { as: da, allowPinchZoom: !0, shards: [a.contentRef], children: /* @__PURE__ */ P(
949
- J.div,
950
- {
951
- "data-state": mt(a.open),
952
- ...r,
953
- ref: t,
954
- style: { pointerEvents: "auto", ...r.style }
955
- }
956
- ) })
957
- );
958
- }
959
- ), ue = "DialogContent", dn = s.forwardRef(
960
- (e, t) => {
961
- const n = un(ue, e.__scopeDialog), { forceMount: r = n.forceMount, ...a } = e, o = q(ue, e.__scopeDialog);
962
- return /* @__PURE__ */ P(Ue, { present: r || o.open, children: o.modal ? /* @__PURE__ */ P(ma, { ...a, ref: t }) : /* @__PURE__ */ P(va, { ...a, ref: t }) });
963
- }
964
- );
965
- dn.displayName = ue;
966
- var ma = s.forwardRef(
967
- (e, t) => {
968
- const n = q(ue, e.__scopeDialog), r = s.useRef(null), a = ce(t, n.contentRef, r);
969
- return s.useEffect(() => {
970
- const o = r.current;
971
- if (o) return ua(o);
972
- }, []), /* @__PURE__ */ P(
973
- fn,
974
- {
975
- ...e,
976
- ref: a,
977
- trapFocus: n.open,
978
- disableOutsidePointerEvents: !0,
979
- onCloseAutoFocus: oe(e.onCloseAutoFocus, (o) => {
980
- o.preventDefault(), n.triggerRef.current?.focus();
981
- }),
982
- onPointerDownOutside: oe(e.onPointerDownOutside, (o) => {
983
- const u = o.detail.originalEvent, i = u.button === 0 && u.ctrlKey === !0;
984
- (u.button === 2 || i) && o.preventDefault();
985
- }),
986
- onFocusOutside: oe(
987
- e.onFocusOutside,
988
- (o) => o.preventDefault()
989
- )
990
- }
991
- );
992
- }
993
- ), va = s.forwardRef(
994
- (e, t) => {
995
- const n = q(ue, e.__scopeDialog), r = s.useRef(!1), a = s.useRef(!1);
996
- return /* @__PURE__ */ P(
997
- fn,
998
- {
999
- ...e,
1000
- ref: t,
1001
- trapFocus: !1,
1002
- disableOutsidePointerEvents: !1,
1003
- onCloseAutoFocus: (o) => {
1004
- e.onCloseAutoFocus?.(o), o.defaultPrevented || (r.current || n.triggerRef.current?.focus(), o.preventDefault()), r.current = !1, a.current = !1;
1005
- },
1006
- onInteractOutside: (o) => {
1007
- e.onInteractOutside?.(o), o.defaultPrevented || (r.current = !0, o.detail.originalEvent.type === "pointerdown" && (a.current = !0));
1008
- const u = o.target;
1009
- n.triggerRef.current?.contains(u) && o.preventDefault(), o.detail.originalEvent.type === "focusin" && a.current && o.preventDefault();
1010
- }
1011
- }
1012
- );
1013
- }
1014
- ), fn = s.forwardRef(
1015
- (e, t) => {
1016
- const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: a, onCloseAutoFocus: o, ...u } = e, i = q(ue, n), g = s.useRef(null), l = ce(t, g);
1017
- return Sr(), /* @__PURE__ */ Ce(Dt, { children: [
1018
- /* @__PURE__ */ P(
1019
- zt,
1020
- {
1021
- asChild: !0,
1022
- loop: !0,
1023
- trapped: r,
1024
- onMountAutoFocus: a,
1025
- onUnmountAutoFocus: o,
1026
- children: /* @__PURE__ */ P(
1027
- Vt,
1028
- {
1029
- role: "dialog",
1030
- id: i.contentId,
1031
- "aria-describedby": i.descriptionId,
1032
- "aria-labelledby": i.titleId,
1033
- "data-state": mt(i.open),
1034
- ...u,
1035
- ref: l,
1036
- onDismiss: () => i.onOpenChange(!1)
1037
- }
1038
- )
1039
- }
1040
- ),
1041
- /* @__PURE__ */ Ce(Dt, { children: [
1042
- /* @__PURE__ */ P(pa, { titleId: i.titleId }),
1043
- /* @__PURE__ */ P(ga, { contentRef: g, descriptionId: i.descriptionId })
1044
- ] })
1045
- ] });
1046
- }
1047
- ), ft = "DialogTitle", mn = s.forwardRef(
1048
- (e, t) => {
1049
- const { __scopeDialog: n, ...r } = e, a = q(ft, n);
1050
- return /* @__PURE__ */ P(J.h2, { id: a.titleId, ...r, ref: t });
1051
- }
1052
- );
1053
- mn.displayName = ft;
1054
- var vn = "DialogDescription", pn = s.forwardRef(
1055
- (e, t) => {
1056
- const { __scopeDialog: n, ...r } = e, a = q(vn, n);
1057
- return /* @__PURE__ */ P(J.p, { id: a.descriptionId, ...r, ref: t });
1058
- }
1059
- );
1060
- pn.displayName = vn;
1061
- var hn = "DialogClose", gn = s.forwardRef(
1062
- (e, t) => {
1063
- const { __scopeDialog: n, ...r } = e, a = q(hn, n);
1064
- return /* @__PURE__ */ P(
1065
- J.button,
1066
- {
1067
- type: "button",
1068
- ...r,
1069
- ref: t,
1070
- onClick: oe(e.onClick, () => a.onOpenChange(!1))
1071
- }
1072
- );
1073
- }
1074
- );
1075
- gn.displayName = hn;
1076
- function mt(e) {
1077
- return e ? "open" : "closed";
1078
- }
1079
- var wn = "DialogTitleWarning", [oo, yn] = Qn(wn, {
1080
- contentName: ue,
1081
- titleName: ft,
1082
- docsSlug: "dialog"
1083
- }), pa = ({ titleId: e }) => {
1084
- const t = yn(wn), n = `\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1085
-
1086
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
1087
-
1088
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;
1089
- return s.useEffect(() => {
1090
- e && (document.getElementById(e) || console.error(n));
1091
- }, [n, e]), null;
1092
- }, ha = "DialogDescriptionWarning", ga = ({ contentRef: e, descriptionId: t }) => {
1093
- const r = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${yn(ha).contentName}}.`;
1094
- return s.useEffect(() => {
1095
- const a = e.current?.getAttribute("aria-describedby");
1096
- t && a && (document.getElementById(t) || console.warn(r));
1097
- }, [r, e, t]), null;
1098
- }, wa = an, ya = sn, ba = cn, Ea = ln, Sa = dn, Ra = mn, Ca = pn, Da = gn;
1099
- function Ta(e) {
1100
- if (typeof document > "u") return;
1101
- let t = document.head || document.getElementsByTagName("head")[0], n = document.createElement("style");
1102
- n.type = "text/css", t.appendChild(n), n.styleSheet ? n.styleSheet.cssText = e : n.appendChild(document.createTextNode(e));
1103
- }
1104
- const bn = h.createContext({
1105
- drawerRef: {
1106
- current: null
1107
- },
1108
- overlayRef: {
1109
- current: null
1110
- },
1111
- onPress: () => {
1112
- },
1113
- onRelease: () => {
1114
- },
1115
- onDrag: () => {
1116
- },
1117
- onNestedDrag: () => {
1118
- },
1119
- onNestedOpenChange: () => {
1120
- },
1121
- onNestedRelease: () => {
1122
- },
1123
- openProp: void 0,
1124
- dismissible: !1,
1125
- isOpen: !1,
1126
- isDragging: !1,
1127
- keyboardIsOpen: {
1128
- current: !1
1129
- },
1130
- snapPointsOffset: null,
1131
- snapPoints: null,
1132
- handleOnly: !1,
1133
- modal: !1,
1134
- shouldFade: !1,
1135
- activeSnapPoint: null,
1136
- onOpenChange: () => {
1137
- },
1138
- setActiveSnapPoint: () => {
1139
- },
1140
- closeDrawer: () => {
1141
- },
1142
- direction: "bottom",
1143
- shouldAnimate: {
1144
- current: !0
1145
- },
1146
- shouldScaleBackground: !1,
1147
- setBackgroundColorOnScale: !0,
1148
- noBodyStyles: !1,
1149
- container: null,
1150
- autoFocus: !1
1151
- }), Te = () => {
1152
- const e = h.useContext(bn);
1153
- if (!e)
1154
- throw new Error("useDrawerContext must be used within a Drawer.Root");
1155
- return e;
1156
- };
1157
- Ta(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
1158
- [data-state=closed]
1159
- ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);
1160
- function Oa() {
1161
- const e = navigator.userAgent;
1162
- return typeof window < "u" && (/Firefox/.test(e) && /Mobile/.test(e) || // Android Firefox
1163
- /FxiOS/.test(e));
1164
- }
1165
- function Aa() {
1166
- return vt(/^Mac/);
1167
- }
1168
- function Na() {
1169
- return vt(/^iPhone/);
1170
- }
1171
- function $t() {
1172
- return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
1173
- }
1174
- function Pa() {
1175
- return vt(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
1176
- Aa() && navigator.maxTouchPoints > 1;
1177
- }
1178
- function En() {
1179
- return Na() || Pa();
1180
- }
1181
- function vt(e) {
1182
- return typeof window < "u" && window.navigator != null ? e.test(window.navigator.platform) : void 0;
1183
- }
1184
- const xa = 24, Ma = typeof window < "u" ? Xn : Kn;
1185
- function Wt(...e) {
1186
- return (...t) => {
1187
- for (let n of e)
1188
- typeof n == "function" && n(...t);
1189
- };
1190
- }
1191
- const rt = typeof document < "u" && window.visualViewport;
1192
- function Bt(e) {
1193
- let t = window.getComputedStyle(e);
1194
- return /(auto|scroll)/.test(t.overflow + t.overflowX + t.overflowY);
1195
- }
1196
- function Sn(e) {
1197
- for (Bt(e) && (e = e.parentElement); e && !Bt(e); )
1198
- e = e.parentElement;
1199
- return e || document.scrollingElement || document.documentElement;
1200
- }
1201
- const Ia = /* @__PURE__ */ new Set([
1202
- "checkbox",
1203
- "radio",
1204
- "range",
1205
- "color",
1206
- "file",
1207
- "image",
1208
- "button",
1209
- "submit",
1210
- "reset"
1211
- ]);
1212
- let Le = 0, at;
1213
- function _a(e = {}) {
1214
- let { isDisabled: t } = e;
1215
- Ma(() => {
1216
- if (!t)
1217
- return Le++, Le === 1 && En() && (at = La()), () => {
1218
- Le--, Le === 0 && at?.();
1219
- };
1220
- }, [
1221
- t
1222
- ]);
1223
- }
1224
- function La() {
1225
- let e, t = 0, n = (f) => {
1226
- e = Sn(f.target), !(e === document.documentElement && e === document.body) && (t = f.changedTouches[0].pageY);
1227
- }, r = (f) => {
1228
- if (!e || e === document.documentElement || e === document.body) {
1229
- f.preventDefault();
1230
- return;
1231
- }
1232
- let m = f.changedTouches[0].pageY, E = e.scrollTop, N = e.scrollHeight - e.clientHeight;
1233
- N !== 0 && ((E <= 0 && m > t || E >= N && m < t) && f.preventDefault(), t = m);
1234
- }, a = (f) => {
1235
- let m = f.target;
1236
- ct(m) && m !== document.activeElement && (f.preventDefault(), m.style.transform = "translateY(-2000px)", m.focus(), requestAnimationFrame(() => {
1237
- m.style.transform = "";
1238
- }));
1239
- }, o = (f) => {
1240
- let m = f.target;
1241
- ct(m) && (m.style.transform = "translateY(-2000px)", requestAnimationFrame(() => {
1242
- m.style.transform = "", rt && (rt.height < window.innerHeight ? requestAnimationFrame(() => {
1243
- Ut(m);
1244
- }) : rt.addEventListener("resize", () => Ut(m), {
1245
- once: !0
1246
- }));
1247
- }));
1248
- }, u = () => {
1249
- window.scrollTo(0, 0);
1250
- }, i = window.pageXOffset, g = window.pageYOffset, l = Wt(ka(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
1251
- window.scrollTo(0, 0);
1252
- let d = Wt(Se(document, "touchstart", n, {
1253
- passive: !1,
1254
- capture: !0
1255
- }), Se(document, "touchmove", r, {
1256
- passive: !1,
1257
- capture: !0
1258
- }), Se(document, "touchend", a, {
1259
- passive: !1,
1260
- capture: !0
1261
- }), Se(document, "focus", o, !0), Se(window, "scroll", u));
1262
- return () => {
1263
- l(), d(), window.scrollTo(i, g);
1264
- };
1265
- }
1266
- function ka(e, t, n) {
1267
- let r = e.style[t];
1268
- return e.style[t] = n, () => {
1269
- e.style[t] = r;
1270
- };
1271
- }
1272
- function Se(e, t, n, r) {
1273
- return e.addEventListener(t, n, r), () => {
1274
- e.removeEventListener(t, n, r);
1275
- };
1276
- }
1277
- function Ut(e) {
1278
- let t = document.scrollingElement || document.documentElement;
1279
- for (; e && e !== t; ) {
1280
- let n = Sn(e);
1281
- if (n !== document.documentElement && n !== document.body && n !== e) {
1282
- let r = n.getBoundingClientRect().top, a = e.getBoundingClientRect().top, o = e.getBoundingClientRect().bottom;
1283
- const u = n.getBoundingClientRect().bottom + xa;
1284
- o > u && (n.scrollTop += a - r);
1285
- }
1286
- e = n.parentElement;
1287
- }
1288
- }
1289
- function ct(e) {
1290
- return e instanceof HTMLInputElement && !Ia.has(e.type) || e instanceof HTMLTextAreaElement || e instanceof HTMLElement && e.isContentEditable;
1291
- }
1292
- function Fa(e, t) {
1293
- typeof e == "function" ? e(t) : e != null && (e.current = t);
1294
- }
1295
- function $a(...e) {
1296
- return (t) => e.forEach((n) => Fa(n, t));
1297
- }
1298
- function Rn(...e) {
1299
- return s.useCallback($a(...e), e);
1300
- }
1301
- const Cn = /* @__PURE__ */ new WeakMap();
1302
- function $(e, t, n = !1) {
1303
- if (!e || !(e instanceof HTMLElement)) return;
1304
- let r = {};
1305
- Object.entries(t).forEach(([a, o]) => {
1306
- if (a.startsWith("--")) {
1307
- e.style.setProperty(a, o);
1308
- return;
1309
- }
1310
- r[a] = e.style[a], e.style[a] = o;
1311
- }), !n && Cn.set(e, r);
1312
- }
1313
- function Wa(e, t) {
1314
- if (!e || !(e instanceof HTMLElement)) return;
1315
- let n = Cn.get(e);
1316
- n && (e.style[t] = n[t]);
1317
- }
1318
- const k = (e) => {
1319
- switch (e) {
1320
- case "top":
1321
- case "bottom":
1322
- return !0;
1323
- case "left":
1324
- case "right":
1325
- return !1;
1326
- default:
1327
- return e;
1328
- }
1329
- };
1330
- function ke(e, t) {
1331
- if (!e)
1332
- return null;
1333
- const n = window.getComputedStyle(e), r = (
1334
- // @ts-ignore
1335
- n.transform || n.webkitTransform || n.mozTransform
1336
- );
1337
- let a = r.match(/^matrix3d\((.+)\)$/);
1338
- return a ? parseFloat(a[1].split(", ")[k(t) ? 13 : 12]) : (a = r.match(/^matrix\((.+)\)$/), a ? parseFloat(a[1].split(", ")[k(t) ? 5 : 4]) : null);
1339
- }
1340
- function Ba(e) {
1341
- return 8 * (Math.log(e + 1) - 2);
1342
- }
1343
- function ot(e, t) {
1344
- if (!e) return () => {
1345
- };
1346
- const n = e.style.cssText;
1347
- return Object.assign(e.style, t), () => {
1348
- e.style.cssText = n;
1349
- };
1350
- }
1351
- function Ua(...e) {
1352
- return (...t) => {
1353
- for (const n of e)
1354
- typeof n == "function" && n(...t);
1355
- };
1356
- }
1357
- const _ = {
1358
- DURATION: 0.5,
1359
- EASE: [
1360
- 0.32,
1361
- 0.72,
1362
- 0,
1363
- 1
1364
- ]
1365
- }, Dn = 0.4, Ha = 0.25, Va = 100, Tn = 8, se = 16, lt = 26, it = "vaul-dragging";
1366
- function On(e) {
1367
- const t = h.useRef(e);
1368
- return h.useEffect(() => {
1369
- t.current = e;
1370
- }), h.useMemo(() => (...n) => t.current == null ? void 0 : t.current.call(t, ...n), []);
1371
- }
1372
- function ja({ defaultProp: e, onChange: t }) {
1373
- const n = h.useState(e), [r] = n, a = h.useRef(r), o = On(t);
1374
- return h.useEffect(() => {
1375
- a.current !== r && (o(r), a.current = r);
1376
- }, [
1377
- r,
1378
- a,
1379
- o
1380
- ]), n;
1381
- }
1382
- function An({ prop: e, defaultProp: t, onChange: n = () => {
1383
- } }) {
1384
- const [r, a] = ja({
1385
- defaultProp: t,
1386
- onChange: n
1387
- }), o = e !== void 0, u = o ? e : r, i = On(n), g = h.useCallback((l) => {
1388
- if (o) {
1389
- const f = typeof l == "function" ? l(e) : l;
1390
- f !== e && i(f);
1391
- } else
1392
- a(l);
1393
- }, [
1394
- o,
1395
- e,
1396
- a,
1397
- i
1398
- ]);
1399
- return [
1400
- u,
1401
- g
1402
- ];
1403
- }
1404
- function za({ activeSnapPointProp: e, setActiveSnapPointProp: t, snapPoints: n, drawerRef: r, overlayRef: a, fadeFromIndex: o, onSnapPointChange: u, direction: i = "bottom", container: g, snapToSequentialPoint: l }) {
1405
- const [d, f] = An({
1406
- prop: e,
1407
- defaultProp: n?.[0],
1408
- onChange: t
1409
- }), [m, E] = h.useState(typeof window < "u" ? {
1410
- innerWidth: window.innerWidth,
1411
- innerHeight: window.innerHeight
1412
- } : void 0);
1413
- h.useEffect(() => {
1414
- function v() {
1415
- E({
1416
- innerWidth: window.innerWidth,
1417
- innerHeight: window.innerHeight
1418
- });
1419
- }
1420
- return window.addEventListener("resize", v), () => window.removeEventListener("resize", v);
1421
- }, []);
1422
- const N = h.useMemo(() => d === n?.[n.length - 1] || null, [
1423
- n,
1424
- d
1425
- ]), c = h.useMemo(() => {
1426
- var v;
1427
- return (v = n?.findIndex((T) => T === d)) != null ? v : null;
1428
- }, [
1429
- n,
1430
- d
1431
- ]), y = n && n.length > 0 && (o || o === 0) && !Number.isNaN(o) && n[o] === d || !n, p = h.useMemo(() => {
1432
- const v = g ? {
1433
- width: g.getBoundingClientRect().width,
1434
- height: g.getBoundingClientRect().height
1435
- } : typeof window < "u" ? {
1436
- width: window.innerWidth,
1437
- height: window.innerHeight
1438
- } : {
1439
- width: 0,
1440
- height: 0
1441
- };
1442
- var T;
1443
- return (T = n?.map((O) => {
1444
- const F = typeof O == "string";
1445
- let B = 0;
1446
- if (F && (B = parseInt(O, 10)), k(i)) {
1447
- const S = F ? B : m ? O * v.height : 0;
1448
- return m ? i === "bottom" ? v.height - S : -v.height + S : S;
1449
- }
1450
- const Y = F ? B : m ? O * v.width : 0;
1451
- return m ? i === "right" ? v.width - Y : -v.width + Y : Y;
1452
- })) != null ? T : [];
1453
- }, [
1454
- n,
1455
- m,
1456
- g
1457
- ]), R = h.useMemo(() => c !== null ? p?.[c] : null, [
1458
- p,
1459
- c
1460
- ]), C = h.useCallback((v) => {
1461
- var T;
1462
- const O = (T = p?.findIndex((F) => F === v)) != null ? T : null;
1463
- u(O), $(r.current, {
1464
- transition: `transform ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1465
- transform: k(i) ? `translate3d(0, ${v}px, 0)` : `translate3d(${v}px, 0, 0)`
1466
- }), p && O !== p.length - 1 && o !== void 0 && O !== o && O < o ? $(a.current, {
1467
- transition: `opacity ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1468
- opacity: "0"
1469
- }) : $(a.current, {
1470
- transition: `opacity ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1471
- opacity: "1"
1472
- }), f(n?.[Math.max(O, 0)]);
1473
- }, [
1474
- r.current,
1475
- n,
1476
- p,
1477
- o,
1478
- a,
1479
- f
1480
- ]);
1481
- h.useEffect(() => {
1482
- if (d || e) {
1483
- var v;
1484
- const T = (v = n?.findIndex((O) => O === e || O === d)) != null ? v : -1;
1485
- p && T !== -1 && typeof p[T] == "number" && C(p[T]);
1486
- }
1487
- }, [
1488
- d,
1489
- e,
1490
- n,
1491
- p,
1492
- C
1493
- ]);
1494
- function w({ draggedDistance: v, closeDrawer: T, velocity: O, dismissible: F }) {
1495
- if (o === void 0) return;
1496
- const B = i === "bottom" || i === "right" ? (R ?? 0) - v : (R ?? 0) + v, Y = c === o - 1, S = c === 0, z = v > 0;
1497
- if (Y && $(a.current, {
1498
- transition: `opacity ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`
1499
- }), !l && O > 2 && !z) {
1500
- F ? T() : C(p[0]);
1501
- return;
1502
- }
1503
- if (!l && O > 2 && z && p && n) {
1504
- C(p[n.length - 1]);
1505
- return;
1506
- }
1507
- const H = p?.reduce((U, Q) => typeof U != "number" || typeof Q != "number" ? U : Math.abs(Q - B) < Math.abs(U - B) ? Q : U), X = k(i) ? window.innerHeight : window.innerWidth;
1508
- if (O > Dn && Math.abs(v) < X * 0.4) {
1509
- const U = z ? 1 : -1;
1510
- if (U > 0 && N && n) {
1511
- C(p[n.length - 1]);
1512
- return;
1513
- }
1514
- if (S && U < 0 && F && T(), c === null) return;
1515
- C(p[c + U]);
1516
- return;
1517
- }
1518
- C(H);
1519
- }
1520
- function x({ draggedDistance: v }) {
1521
- if (R === null) return;
1522
- const T = i === "bottom" || i === "right" ? R - v : R + v;
1523
- (i === "bottom" || i === "right") && T < p[p.length - 1] || (i === "top" || i === "left") && T > p[p.length - 1] || $(r.current, {
1524
- transform: k(i) ? `translate3d(0, ${T}px, 0)` : `translate3d(${T}px, 0, 0)`
1525
- });
1526
- }
1527
- function W(v, T) {
1528
- if (!n || typeof c != "number" || !p || o === void 0) return null;
1529
- const O = c === o - 1;
1530
- if (c >= o && T)
1531
- return 0;
1532
- if (O && !T) return 1;
1533
- if (!y && !O) return null;
1534
- const B = O ? c + 1 : c - 1, Y = O ? p[B] - p[B - 1] : p[B + 1] - p[B], S = v / Math.abs(Y);
1535
- return O ? 1 - S : S;
1536
- }
1537
- return {
1538
- isLastSnapPoint: N,
1539
- activeSnapPoint: d,
1540
- shouldFade: y,
1541
- getPercentageDragged: W,
1542
- setActiveSnapPoint: f,
1543
- activeSnapPointIndex: c,
1544
- onRelease: w,
1545
- onDrag: x,
1546
- snapPointsOffset: p
1547
- };
1548
- }
1549
- const Ya = () => () => {
1550
- };
1551
- function Xa() {
1552
- const { direction: e, isOpen: t, shouldScaleBackground: n, setBackgroundColorOnScale: r, noBodyStyles: a } = Te(), o = h.useRef(null), u = Yn(() => document.body.style.backgroundColor, []);
1553
- function i() {
1554
- return (window.innerWidth - lt) / window.innerWidth;
1555
- }
1556
- h.useEffect(() => {
1557
- if (t && n) {
1558
- o.current && clearTimeout(o.current);
1559
- const g = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[vaul-drawer-wrapper]");
1560
- if (!g) return;
1561
- Ua(r && !a ? ot(document.body, {
1562
- background: "black"
1563
- }) : Ya, ot(g, {
1564
- transformOrigin: k(e) ? "top" : "left",
1565
- transitionProperty: "transform, border-radius",
1566
- transitionDuration: `${_.DURATION}s`,
1567
- transitionTimingFunction: `cubic-bezier(${_.EASE.join(",")})`
1568
- }));
1569
- const l = ot(g, {
1570
- borderRadius: `${Tn}px`,
1571
- overflow: "hidden",
1572
- ...k(e) ? {
1573
- transform: `scale(${i()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
1574
- } : {
1575
- transform: `scale(${i()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
1576
- }
1577
- });
1578
- return () => {
1579
- l(), o.current = window.setTimeout(() => {
1580
- u ? document.body.style.background = u : document.body.style.removeProperty("background");
1581
- }, _.DURATION * 1e3);
1582
- };
1583
- }
1584
- }, [
1585
- t,
1586
- n,
1587
- u
1588
- ]);
1589
- }
1590
- let Re = null;
1591
- function Ka({ isOpen: e, modal: t, nested: n, hasBeenOpened: r, preventScrollRestoration: a, noBodyStyles: o }) {
1592
- const [u, i] = h.useState(() => typeof window < "u" ? window.location.href : ""), g = h.useRef(0), l = h.useCallback(() => {
1593
- if ($t() && Re === null && e && !o) {
1594
- Re = {
1595
- position: document.body.style.position,
1596
- top: document.body.style.top,
1597
- left: document.body.style.left,
1598
- height: document.body.style.height,
1599
- right: "unset"
1600
- };
1601
- const { scrollX: f, innerHeight: m } = window;
1602
- document.body.style.setProperty("position", "fixed", "important"), Object.assign(document.body.style, {
1603
- top: `${-g.current}px`,
1604
- left: `${-f}px`,
1605
- right: "0px",
1606
- height: "auto"
1607
- }), window.setTimeout(() => window.requestAnimationFrame(() => {
1608
- const E = m - window.innerHeight;
1609
- E && g.current >= m && (document.body.style.top = `${-(g.current + E)}px`);
1610
- }), 300);
1611
- }
1612
- }, [
1613
- e
1614
- ]), d = h.useCallback(() => {
1615
- if ($t() && Re !== null && !o) {
1616
- const f = -parseInt(document.body.style.top, 10), m = -parseInt(document.body.style.left, 10);
1617
- Object.assign(document.body.style, Re), window.requestAnimationFrame(() => {
1618
- if (a && u !== window.location.href) {
1619
- i(window.location.href);
1620
- return;
1621
- }
1622
- window.scrollTo(m, f);
1623
- }), Re = null;
1624
- }
1625
- }, [
1626
- u
1627
- ]);
1628
- return h.useEffect(() => {
1629
- function f() {
1630
- g.current = window.scrollY;
1631
- }
1632
- return f(), window.addEventListener("scroll", f), () => {
1633
- window.removeEventListener("scroll", f);
1634
- };
1635
- }, []), h.useEffect(() => {
1636
- if (t)
1637
- return () => {
1638
- typeof document > "u" || document.querySelector("[data-vaul-drawer]") || d();
1639
- };
1640
- }, [
1641
- t,
1642
- d
1643
- ]), h.useEffect(() => {
1644
- n || !r || (e ? (!window.matchMedia("(display-mode: standalone)").matches && l(), t || window.setTimeout(() => {
1645
- d();
1646
- }, 500)) : d());
1647
- }, [
1648
- e,
1649
- r,
1650
- u,
1651
- t,
1652
- n,
1653
- l,
1654
- d
1655
- ]), {
1656
- restorePositionSetting: d
1657
- };
1658
- }
1659
- function qa({ open: e, onOpenChange: t, children: n, onDrag: r, onRelease: a, snapPoints: o, shouldScaleBackground: u = !1, setBackgroundColorOnScale: i = !0, closeThreshold: g = Ha, scrollLockTimeout: l = Va, dismissible: d = !0, handleOnly: f = !1, fadeFromIndex: m = o && o.length - 1, activeSnapPoint: E, setActiveSnapPoint: N, fixed: c, modal: y = !0, onClose: p, nested: R, noBodyStyles: C = !1, direction: w = "bottom", defaultOpen: x = !1, disablePreventScroll: W = !0, snapToSequentialPoint: v = !1, preventScrollRestoration: T = !1, repositionInputs: O = !0, onAnimationEnd: F, container: B, autoFocus: Y = !1 }) {
1660
- var S, z;
1661
- const [H = !1, X] = An({
1662
- defaultProp: x,
1663
- prop: e,
1664
- onChange: (b) => {
1665
- t?.(b), !b && !R && Fn(), setTimeout(() => {
1666
- F?.(b);
1667
- }, _.DURATION * 1e3), b && !y && typeof window < "u" && window.requestAnimationFrame(() => {
1668
- document.body.style.pointerEvents = "auto";
1669
- }), b || (document.body.style.pointerEvents = "auto");
1670
- }
1671
- }), [U, Q] = h.useState(!1), [ee, ge] = h.useState(!1), [xn, pt] = h.useState(!1), le = h.useRef(null), Oe = h.useRef(null), je = h.useRef(null), ze = h.useRef(null), we = h.useRef(null), ye = h.useRef(!1), Ye = h.useRef(null), Xe = h.useRef(0), de = h.useRef(!1), ht = h.useRef(!x), gt = h.useRef(0), D = h.useRef(null), wt = h.useRef(((S = D.current) == null ? void 0 : S.getBoundingClientRect().height) || 0), yt = h.useRef(((z = D.current) == null ? void 0 : z.getBoundingClientRect().width) || 0), Ke = h.useRef(0), Mn = h.useCallback((b) => {
1672
- o && b === be.length - 1 && (Oe.current = /* @__PURE__ */ new Date());
1673
- }, []), { activeSnapPoint: In, activeSnapPointIndex: fe, setActiveSnapPoint: bt, onRelease: _n, snapPointsOffset: be, onDrag: Ln, shouldFade: Et, getPercentageDragged: kn } = za({
1674
- snapPoints: o,
1675
- activeSnapPointProp: E,
1676
- setActiveSnapPointProp: N,
1677
- drawerRef: D,
1678
- fadeFromIndex: m,
1679
- overlayRef: le,
1680
- onSnapPointChange: Mn,
1681
- direction: w,
1682
- container: B,
1683
- snapToSequentialPoint: v
1684
- });
1685
- _a({
1686
- isDisabled: !H || ee || !y || xn || !U || !O || !W
1687
- });
1688
- const { restorePositionSetting: Fn } = Ka({
1689
- isOpen: H,
1690
- modal: y,
1691
- nested: R ?? !1,
1692
- hasBeenOpened: U,
1693
- preventScrollRestoration: T,
1694
- noBodyStyles: C
1695
- });
1696
- function Ae() {
1697
- return (window.innerWidth - lt) / window.innerWidth;
1698
- }
1699
- function $n(b) {
1700
- var M, I;
1701
- !d && !o || D.current && !D.current.contains(b.target) || (wt.current = ((M = D.current) == null ? void 0 : M.getBoundingClientRect().height) || 0, yt.current = ((I = D.current) == null ? void 0 : I.getBoundingClientRect().width) || 0, ge(!0), je.current = /* @__PURE__ */ new Date(), En() && window.addEventListener("touchend", () => ye.current = !1, {
1702
- once: !0
1703
- }), b.target.setPointerCapture(b.pointerId), Xe.current = k(w) ? b.pageY : b.pageX);
1704
- }
1705
- function St(b, M) {
1706
- var I;
1707
- let A = b;
1708
- const L = (I = window.getSelection()) == null ? void 0 : I.toString(), j = D.current ? ke(D.current, w) : null, V = /* @__PURE__ */ new Date();
1709
- if (A.tagName === "SELECT" || A.hasAttribute("data-vaul-no-drag") || A.closest("[data-vaul-no-drag]"))
1710
- return !1;
1711
- if (w === "right" || w === "left")
1712
- return !0;
1713
- if (Oe.current && V.getTime() - Oe.current.getTime() < 500)
1714
- return !1;
1715
- if (j !== null && (w === "bottom" ? j > 0 : j < 0))
1716
- return !0;
1717
- if (L && L.length > 0)
1718
- return !1;
1719
- if (we.current && V.getTime() - we.current.getTime() < l && j === 0 || M)
1720
- return we.current = V, !1;
1721
- for (; A; ) {
1722
- if (A.scrollHeight > A.clientHeight) {
1723
- if (A.scrollTop !== 0)
1724
- return we.current = /* @__PURE__ */ new Date(), !1;
1725
- if (A.getAttribute("role") === "dialog")
1726
- return !0;
1727
- }
1728
- A = A.parentNode;
1729
- }
1730
- return !0;
1731
- }
1732
- function Wn(b) {
1733
- if (D.current && ee) {
1734
- const M = w === "bottom" || w === "right" ? 1 : -1, I = (Xe.current - (k(w) ? b.pageY : b.pageX)) * M, A = I > 0, L = o && !d && !A;
1735
- if (L && fe === 0) return;
1736
- const j = Math.abs(I), V = document.querySelector("[data-vaul-drawer-wrapper]"), te = w === "bottom" || w === "top" ? wt.current : yt.current;
1737
- let K = j / te;
1738
- const ie = kn(j, A);
1739
- if (ie !== null && (K = ie), L && K >= 1 || !ye.current && !St(b.target, A)) return;
1740
- if (D.current.classList.add(it), ye.current = !0, $(D.current, {
1741
- transition: "none"
1742
- }), $(le.current, {
1743
- transition: "none"
1744
- }), o && Ln({
1745
- draggedDistance: I
1746
- }), A && !o) {
1747
- const G = Ba(I), Ne = Math.min(G * -1, 0) * M;
1748
- $(D.current, {
1749
- transform: k(w) ? `translate3d(0, ${Ne}px, 0)` : `translate3d(${Ne}px, 0, 0)`
1750
- });
1751
- return;
1752
- }
1753
- const ne = 1 - K;
1754
- if ((Et || m && fe === m - 1) && (r?.(b, K), $(le.current, {
1755
- opacity: `${ne}`,
1756
- transition: "none"
1757
- }, !0)), V && le.current && u) {
1758
- const G = Math.min(Ae() + K * (1 - Ae()), 1), Ne = 8 - K * 8, Ct = Math.max(0, 14 - K * 14);
1759
- $(V, {
1760
- borderRadius: `${Ne}px`,
1761
- transform: k(w) ? `scale(${G}) translate3d(0, ${Ct}px, 0)` : `scale(${G}) translate3d(${Ct}px, 0, 0)`,
1762
- transition: "none"
1763
- }, !0);
1764
- }
1765
- if (!o) {
1766
- const G = j * M;
1767
- $(D.current, {
1768
- transform: k(w) ? `translate3d(0, ${G}px, 0)` : `translate3d(${G}px, 0, 0)`
1769
- });
1770
- }
1771
- }
1772
- }
1773
- h.useEffect(() => {
1774
- window.requestAnimationFrame(() => {
1775
- ht.current = !0;
1776
- });
1777
- }, []), h.useEffect(() => {
1778
- var b;
1779
- function M() {
1780
- if (!D.current || !O) return;
1781
- const I = document.activeElement;
1782
- if (ct(I) || de.current) {
1783
- var A;
1784
- const L = ((A = window.visualViewport) == null ? void 0 : A.height) || 0, j = window.innerHeight;
1785
- let V = j - L;
1786
- const te = D.current.getBoundingClientRect().height || 0, K = te > j * 0.8;
1787
- Ke.current || (Ke.current = te);
1788
- const ie = D.current.getBoundingClientRect().top;
1789
- if (Math.abs(gt.current - V) > 60 && (de.current = !de.current), o && o.length > 0 && be && fe) {
1790
- const ne = be[fe] || 0;
1791
- V += ne;
1792
- }
1793
- if (gt.current = V, te > L || de.current) {
1794
- const ne = D.current.getBoundingClientRect().height;
1795
- let G = ne;
1796
- ne > L && (G = L - (K ? ie : lt)), c ? D.current.style.height = `${ne - Math.max(V, 0)}px` : D.current.style.height = `${Math.max(G, L - ie)}px`;
1797
- } else Oa() || (D.current.style.height = `${Ke.current}px`);
1798
- o && o.length > 0 && !de.current ? D.current.style.bottom = "0px" : D.current.style.bottom = `${Math.max(V, 0)}px`;
1799
- }
1800
- }
1801
- return (b = window.visualViewport) == null || b.addEventListener("resize", M), () => {
1802
- var I;
1803
- return (I = window.visualViewport) == null ? void 0 : I.removeEventListener("resize", M);
1804
- };
1805
- }, [
1806
- fe,
1807
- o,
1808
- be
1809
- ]);
1810
- function Ee(b) {
1811
- Bn(), p?.(), b || X(!1), setTimeout(() => {
1812
- o && bt(o[0]);
1813
- }, _.DURATION * 1e3);
1814
- }
1815
- function Rt() {
1816
- if (!D.current) return;
1817
- const b = document.querySelector("[data-vaul-drawer-wrapper]"), M = ke(D.current, w);
1818
- $(D.current, {
1819
- transform: "translate3d(0, 0, 0)",
1820
- transition: `transform ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`
1821
- }), $(le.current, {
1822
- transition: `opacity ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1823
- opacity: "1"
1824
- }), u && M && M > 0 && H && $(b, {
1825
- borderRadius: `${Tn}px`,
1826
- overflow: "hidden",
1827
- ...k(w) ? {
1828
- transform: `scale(${Ae()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
1829
- transformOrigin: "top"
1830
- } : {
1831
- transform: `scale(${Ae()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
1832
- transformOrigin: "left"
1833
- },
1834
- transitionProperty: "transform, border-radius",
1835
- transitionDuration: `${_.DURATION}s`,
1836
- transitionTimingFunction: `cubic-bezier(${_.EASE.join(",")})`
1837
- }, !0);
1838
- }
1839
- function Bn() {
1840
- !ee || !D.current || (D.current.classList.remove(it), ye.current = !1, ge(!1), ze.current = /* @__PURE__ */ new Date());
1841
- }
1842
- function Un(b) {
1843
- if (!ee || !D.current) return;
1844
- D.current.classList.remove(it), ye.current = !1, ge(!1), ze.current = /* @__PURE__ */ new Date();
1845
- const M = ke(D.current, w);
1846
- if (!b || !St(b.target, !1) || !M || Number.isNaN(M) || je.current === null) return;
1847
- const I = ze.current.getTime() - je.current.getTime(), A = Xe.current - (k(w) ? b.pageY : b.pageX), L = Math.abs(A) / I;
1848
- if (L > 0.05 && (pt(!0), setTimeout(() => {
1849
- pt(!1);
1850
- }, 200)), o) {
1851
- _n({
1852
- draggedDistance: A * (w === "bottom" || w === "right" ? 1 : -1),
1853
- closeDrawer: Ee,
1854
- velocity: L,
1855
- dismissible: d
1856
- }), a?.(b, !0);
1857
- return;
1858
- }
1859
- if (w === "bottom" || w === "right" ? A > 0 : A < 0) {
1860
- Rt(), a?.(b, !0);
1861
- return;
1862
- }
1863
- if (L > Dn) {
1864
- Ee(), a?.(b, !1);
1865
- return;
1866
- }
1867
- var j;
1868
- const V = Math.min((j = D.current.getBoundingClientRect().height) != null ? j : 0, window.innerHeight);
1869
- var te;
1870
- const K = Math.min((te = D.current.getBoundingClientRect().width) != null ? te : 0, window.innerWidth), ie = w === "left" || w === "right";
1871
- if (Math.abs(M) >= (ie ? K : V) * g) {
1872
- Ee(), a?.(b, !1);
1873
- return;
1874
- }
1875
- a?.(b, !0), Rt();
1876
- }
1877
- h.useEffect(() => (H && ($(document.documentElement, {
1878
- scrollBehavior: "auto"
1879
- }), Oe.current = /* @__PURE__ */ new Date()), () => {
1880
- Wa(document.documentElement, "scrollBehavior");
1881
- }), [
1882
- H
1883
- ]);
1884
- function Hn(b) {
1885
- const M = b ? (window.innerWidth - se) / window.innerWidth : 1, I = b ? -se : 0;
1886
- Ye.current && window.clearTimeout(Ye.current), $(D.current, {
1887
- transition: `transform ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1888
- transform: k(w) ? `scale(${M}) translate3d(0, ${I}px, 0)` : `scale(${M}) translate3d(${I}px, 0, 0)`
1889
- }), !b && D.current && (Ye.current = setTimeout(() => {
1890
- const A = ke(D.current, w);
1891
- $(D.current, {
1892
- transition: "none",
1893
- transform: k(w) ? `translate3d(0, ${A}px, 0)` : `translate3d(${A}px, 0, 0)`
1894
- });
1895
- }, 500));
1896
- }
1897
- function Vn(b, M) {
1898
- if (M < 0) return;
1899
- const I = (window.innerWidth - se) / window.innerWidth, A = I + M * (1 - I), L = -se + M * se;
1900
- $(D.current, {
1901
- transform: k(w) ? `scale(${A}) translate3d(0, ${L}px, 0)` : `scale(${A}) translate3d(${L}px, 0, 0)`,
1902
- transition: "none"
1903
- });
1904
- }
1905
- function jn(b, M) {
1906
- const I = k(w) ? window.innerHeight : window.innerWidth, A = M ? (I - se) / I : 1, L = M ? -se : 0;
1907
- M && $(D.current, {
1908
- transition: `transform ${_.DURATION}s cubic-bezier(${_.EASE.join(",")})`,
1909
- transform: k(w) ? `scale(${A}) translate3d(0, ${L}px, 0)` : `scale(${A}) translate3d(${L}px, 0, 0)`
1910
- });
1911
- }
1912
- return h.useEffect(() => {
1913
- y || window.requestAnimationFrame(() => {
1914
- document.body.style.pointerEvents = "auto";
1915
- });
1916
- }, [
1917
- y
1918
- ]), /* @__PURE__ */ h.createElement(wa, {
1919
- defaultOpen: x,
1920
- onOpenChange: (b) => {
1921
- !d && !b || (b ? Q(!0) : Ee(!0), X(b));
1922
- },
1923
- open: H
1924
- }, /* @__PURE__ */ h.createElement(bn.Provider, {
1925
- value: {
1926
- activeSnapPoint: In,
1927
- snapPoints: o,
1928
- setActiveSnapPoint: bt,
1929
- drawerRef: D,
1930
- overlayRef: le,
1931
- onOpenChange: t,
1932
- onPress: $n,
1933
- onRelease: Un,
1934
- onDrag: Wn,
1935
- dismissible: d,
1936
- shouldAnimate: ht,
1937
- handleOnly: f,
1938
- isOpen: H,
1939
- isDragging: ee,
1940
- shouldFade: Et,
1941
- closeDrawer: Ee,
1942
- onNestedDrag: Vn,
1943
- onNestedOpenChange: Hn,
1944
- onNestedRelease: jn,
1945
- keyboardIsOpen: de,
1946
- modal: y,
1947
- snapPointsOffset: be,
1948
- activeSnapPointIndex: fe,
1949
- direction: w,
1950
- shouldScaleBackground: u,
1951
- setBackgroundColorOnScale: i,
1952
- noBodyStyles: C,
1953
- container: B,
1954
- autoFocus: Y
1955
- }
1956
- }, n));
1957
- }
1958
- const Nn = /* @__PURE__ */ h.forwardRef(function({ ...e }, t) {
1959
- const { overlayRef: n, snapPoints: r, onRelease: a, shouldFade: o, isOpen: u, modal: i, shouldAnimate: g } = Te(), l = Rn(t, n), d = r && r.length > 0;
1960
- if (!i)
1961
- return null;
1962
- const f = h.useCallback((m) => a(m), [
1963
- a
1964
- ]);
1965
- return /* @__PURE__ */ h.createElement(Ea, {
1966
- onMouseUp: f,
1967
- ref: l,
1968
- "data-vaul-overlay": "",
1969
- "data-vaul-snap-points": u && d ? "true" : "false",
1970
- "data-vaul-snap-points-overlay": u && o ? "true" : "false",
1971
- "data-vaul-animate": g?.current ? "true" : "false",
1972
- ...e
1973
- });
1974
- });
1975
- Nn.displayName = "Drawer.Overlay";
1976
- const Pn = /* @__PURE__ */ h.forwardRef(function({ onPointerDownOutside: e, style: t, onOpenAutoFocus: n, ...r }, a) {
1977
- const { drawerRef: o, onPress: u, onRelease: i, onDrag: g, keyboardIsOpen: l, snapPointsOffset: d, activeSnapPointIndex: f, modal: m, isOpen: E, direction: N, snapPoints: c, container: y, handleOnly: p, shouldAnimate: R, autoFocus: C } = Te(), [w, x] = h.useState(!1), W = Rn(a, o), v = h.useRef(null), T = h.useRef(null), O = h.useRef(!1), F = c && c.length > 0;
1978
- Xa();
1979
- const B = (S, z, H = 0) => {
1980
- if (O.current) return !0;
1981
- const X = Math.abs(S.y), U = Math.abs(S.x), Q = U > X, ee = [
1982
- "bottom",
1983
- "right"
1984
- ].includes(z) ? 1 : -1;
1985
- if (z === "left" || z === "right") {
1986
- if (!(S.x * ee < 0) && U >= 0 && U <= H)
1987
- return Q;
1988
- } else if (!(S.y * ee < 0) && X >= 0 && X <= H)
1989
- return !Q;
1990
- return O.current = !0, !0;
1991
- };
1992
- h.useEffect(() => {
1993
- F && window.requestAnimationFrame(() => {
1994
- x(!0);
1995
- });
1996
- }, []);
1997
- function Y(S) {
1998
- v.current = null, O.current = !1, i(S);
1999
- }
2000
- return /* @__PURE__ */ h.createElement(Sa, {
2001
- "data-vaul-drawer-direction": N,
2002
- "data-vaul-drawer": "",
2003
- "data-vaul-delayed-snap-points": w ? "true" : "false",
2004
- "data-vaul-snap-points": E && F ? "true" : "false",
2005
- "data-vaul-custom-container": y ? "true" : "false",
2006
- "data-vaul-animate": R?.current ? "true" : "false",
2007
- ...r,
2008
- ref: W,
2009
- style: d && d.length > 0 ? {
2010
- "--snap-point-height": `${d[f ?? 0]}px`,
2011
- ...t
2012
- } : t,
2013
- onPointerDown: (S) => {
2014
- p || (r.onPointerDown == null || r.onPointerDown.call(r, S), v.current = {
2015
- x: S.pageX,
2016
- y: S.pageY
2017
- }, u(S));
2018
- },
2019
- onOpenAutoFocus: (S) => {
2020
- n?.(S), C || S.preventDefault();
2021
- },
2022
- onPointerDownOutside: (S) => {
2023
- if (e?.(S), !m || S.defaultPrevented) {
2024
- S.preventDefault();
2025
- return;
2026
- }
2027
- l.current && (l.current = !1);
2028
- },
2029
- onFocusOutside: (S) => {
2030
- if (!m) {
2031
- S.preventDefault();
2032
- return;
2033
- }
2034
- },
2035
- onPointerMove: (S) => {
2036
- if (T.current = S, p || (r.onPointerMove == null || r.onPointerMove.call(r, S), !v.current)) return;
2037
- const z = S.pageY - v.current.y, H = S.pageX - v.current.x, X = S.pointerType === "touch" ? 10 : 2;
2038
- B({
2039
- x: H,
2040
- y: z
2041
- }, N, X) ? g(S) : (Math.abs(H) > X || Math.abs(z) > X) && (v.current = null);
2042
- },
2043
- onPointerUp: (S) => {
2044
- r.onPointerUp == null || r.onPointerUp.call(r, S), v.current = null, O.current = !1, i(S);
2045
- },
2046
- onPointerOut: (S) => {
2047
- r.onPointerOut == null || r.onPointerOut.call(r, S), Y(T.current);
2048
- },
2049
- onContextMenu: (S) => {
2050
- r.onContextMenu == null || r.onContextMenu.call(r, S), T.current && Y(T.current);
2051
- }
2052
- });
2053
- });
2054
- Pn.displayName = "Drawer.Content";
2055
- const Ga = 250, Za = 120, Qa = /* @__PURE__ */ h.forwardRef(function({ preventCycle: e = !1, children: t, ...n }, r) {
2056
- const { closeDrawer: a, isDragging: o, snapPoints: u, activeSnapPoint: i, setActiveSnapPoint: g, dismissible: l, handleOnly: d, isOpen: f, onPress: m, onDrag: E } = Te(), N = h.useRef(null), c = h.useRef(!1);
2057
- function y() {
2058
- if (c.current) {
2059
- C();
2060
- return;
2061
- }
2062
- window.setTimeout(() => {
2063
- p();
2064
- }, Za);
2065
- }
2066
- function p() {
2067
- if (o || e || c.current) {
2068
- C();
2069
- return;
2070
- }
2071
- if (C(), !u || u.length === 0) {
2072
- l || a();
2073
- return;
2074
- }
2075
- if (i === u[u.length - 1] && l) {
2076
- a();
2077
- return;
2078
- }
2079
- const x = u.findIndex((v) => v === i);
2080
- if (x === -1) return;
2081
- const W = u[x + 1];
2082
- g(W);
2083
- }
2084
- function R() {
2085
- N.current = window.setTimeout(() => {
2086
- c.current = !0;
2087
- }, Ga);
2088
- }
2089
- function C() {
2090
- N.current && window.clearTimeout(N.current), c.current = !1;
2091
- }
2092
- return /* @__PURE__ */ h.createElement("div", {
2093
- onClick: y,
2094
- onPointerCancel: C,
2095
- onPointerDown: (w) => {
2096
- d && m(w), R();
2097
- },
2098
- onPointerMove: (w) => {
2099
- d && E(w);
2100
- },
2101
- // onPointerUp is already handled by the content component
2102
- ref: r,
2103
- "data-vaul-drawer-visible": f ? "true" : "false",
2104
- "data-vaul-handle": "",
2105
- "aria-hidden": "true",
2106
- ...n
2107
- }, /* @__PURE__ */ h.createElement("span", {
2108
- "data-vaul-handle-hitarea": "",
2109
- "aria-hidden": "true"
2110
- }, t));
2111
- });
2112
- Qa.displayName = "Drawer.Handle";
2113
- function Ja(e) {
2114
- const t = Te(), { container: n = t.container, ...r } = e;
2115
- return /* @__PURE__ */ h.createElement(ba, {
2116
- container: n,
2117
- ...r
2118
- });
2119
- }
2120
- const re = {
2121
- Root: qa,
2122
- Content: Pn,
2123
- Overlay: Nn,
2124
- Trigger: ya,
2125
- Portal: Ja,
2126
- Close: Da,
2127
- Title: Ra,
2128
- Description: Ca
2129
- }, io = ({ trigger: e, title: t, description: n, children: r, direction: a = "right", size: o = "320px" }) => {
2130
- const u = "!font-sans fixed", i = {
2131
- left: {
2132
- className: `${u} top-0 bottom-0 left-0 shadow-[20px_0_20px_rgba(0,0,0,0.4)]`,
2133
- style: { width: o }
2134
- },
2135
- right: {
2136
- className: `${u} top-0 bottom-0 right-0 shadow-[-20px_0_20px_rgba(0,0,0,0.4)]`,
2137
- style: { width: o }
2138
- },
2139
- top: {
2140
- className: `${u} top-0 left-0 right-0 shadow-[0_20px_20px_rgba(0,0,0,0.4)]`,
2141
- style: { height: o }
2142
- },
2143
- bottom: {
2144
- className: `${u} bottom-0 left-0 right-0 shadow-[0_-20px_20px_rgba(0,0,0,0.4)]`,
2145
- style: { height: o }
2146
- }
2147
- }, { className: g, style: l } = i[a];
2148
- return /* @__PURE__ */ Ce(re.Root, { direction: a, children: [
2149
- /* @__PURE__ */ P(re.Trigger, { asChild: !0, children: e }),
2150
- /* @__PURE__ */ Ce(re.Portal, { children: [
2151
- /* @__PURE__ */ P(re.Overlay, { className: "fixed inset-0 bg-transparent" }),
2152
- /* @__PURE__ */ Ce(re.Content, { className: `bg-drawer-bg z-10 flex flex-col p-4 outline-none ${g}`, style: l, children: [
2153
- /* @__PURE__ */ P(re.Close, {}),
2154
- /* @__PURE__ */ P(re.Title, { className: "text-text-primary mb-2 text-lg font-semibold", children: t }),
2155
- /* @__PURE__ */ P(re.Description, { className: "!text-text-secondary mb-2 !text-xs uppercase", children: n }),
2156
- /* @__PURE__ */ P("div", { className: "pt-2", children: r })
2157
- ] })
2158
- ] })
2159
- ] });
2160
- };
2161
- export {
2162
- io as Drawer
2163
- };