@loopstack/loopstack-studio 0.21.0-rc.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/components/LoadingCentered.js +28 -0
  2. package/dist/components/data-table/DataList.js +102 -102
  3. package/dist/components/data-table/DataTable.js +3 -3
  4. package/dist/components/dynamic-form/fields/RadioField.js +3 -3
  5. package/dist/components/dynamic-form/fields/SliderField.js +13 -13
  6. package/dist/components/dynamic-form/fields/SwitchField.js +1 -1
  7. package/dist/components/dynamic-form/fields/TextareaField.js +4 -4
  8. package/dist/components/index.js +45 -0
  9. package/dist/components/messages/CompletionMessagePaper.js +110 -0
  10. package/dist/components/snackbars/ErrorSnackbar.js +1 -1
  11. package/dist/components/ui/DiscordLogo.js +31 -0
  12. package/dist/components/ui/GoogleLogo.js +44 -0
  13. package/dist/components/ui/accordion.js +64 -0
  14. package/dist/components/ui/alert-dialog.js +91 -82
  15. package/dist/components/ui/alert.js +50 -0
  16. package/dist/components/ui/avatar.js +42 -0
  17. package/dist/components/ui/badge.js +1 -1
  18. package/dist/components/ui/breadcrumb.js +76 -56
  19. package/dist/components/ui/card.js +79 -19
  20. package/dist/components/ui/dialog.js +89 -47
  21. package/dist/components/ui/drawer.js +122 -0
  22. package/dist/components/ui/dropdown-menu.js +190 -0
  23. package/dist/components/ui/popover.js +47 -0
  24. package/dist/components/ui/scroll-area.js +50 -0
  25. package/dist/components/ui/select.js +115 -82
  26. package/dist/components/ui/separator.js +20 -0
  27. package/dist/components/ui/sheet.js +87 -57
  28. package/dist/components/ui/sidebar.js +557 -0
  29. package/dist/components/ui/skeleton.js +16 -0
  30. package/dist/components/ui/table.js +85 -61
  31. package/dist/features/health/LocalHealthCheck.js +1 -1
  32. package/dist/features/workspaces/Workspaces.js +1 -1
  33. package/dist/features/workspaces/components/CreateWorkspace.js +4 -4
  34. package/dist/features/workspaces/components/ExecutionTimeline.js +1 -1
  35. package/dist/features/workspaces/components/PipelineForm.js +2 -2
  36. package/dist/hooks/useApi.js +1 -1
  37. package/dist/index.d.ts +751 -9
  38. package/dist/index.js +47 -1
  39. package/dist/loopstack-studio.css +1 -1
  40. package/dist/node_modules/katex/dist/katex.js +717 -861
  41. package/dist/node_modules/vaul/dist/index.js +912 -0
  42. package/dist/pages/WorkspacePage.js +1 -1
  43. package/package.json +16 -16
@@ -0,0 +1,912 @@
1
+ "use client";
2
+ import * as React$1 from "react";
3
+ import React, { useEffect, useLayoutEffect, useMemo } from "react";
4
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
5
+ function __insertCSS(e) {
6
+ if (!e || typeof document > "u") return;
7
+ let t = document.head || document.getElementsByTagName("head")[0], n = document.createElement("style");
8
+ n.type = "text/css", t.appendChild(n), n.styleSheet ? n.styleSheet.cssText = e : n.appendChild(document.createTextNode(e));
9
+ }
10
+ var DrawerContext = React.createContext({
11
+ drawerRef: { current: null },
12
+ overlayRef: { current: null },
13
+ onPress: () => {},
14
+ onRelease: () => {},
15
+ onDrag: () => {},
16
+ onNestedDrag: () => {},
17
+ onNestedOpenChange: () => {},
18
+ onNestedRelease: () => {},
19
+ openProp: void 0,
20
+ dismissible: !1,
21
+ isOpen: !1,
22
+ isDragging: !1,
23
+ keyboardIsOpen: { current: !1 },
24
+ snapPointsOffset: null,
25
+ snapPoints: null,
26
+ handleOnly: !1,
27
+ modal: !1,
28
+ shouldFade: !1,
29
+ activeSnapPoint: null,
30
+ onOpenChange: () => {},
31
+ setActiveSnapPoint: () => {},
32
+ closeDrawer: () => {},
33
+ direction: "bottom",
34
+ shouldAnimate: { current: !0 },
35
+ shouldScaleBackground: !1,
36
+ setBackgroundColorOnScale: !0,
37
+ noBodyStyles: !1,
38
+ container: null,
39
+ autoFocus: !1
40
+ }), useDrawerContext = () => {
41
+ let e = React.useContext(DrawerContext);
42
+ if (!e) throw Error("useDrawerContext must be used within a Drawer.Root");
43
+ return e;
44
+ };
45
+ __insertCSS("[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(\n[data-state=closed]\n){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)}}");
46
+ function isMobileFirefox() {
47
+ let e = navigator.userAgent;
48
+ return typeof window < "u" && (/Firefox/.test(e) && /Mobile/.test(e) || /FxiOS/.test(e));
49
+ }
50
+ function isMac() {
51
+ return testPlatform(/^Mac/);
52
+ }
53
+ function isIPhone() {
54
+ return testPlatform(/^iPhone/);
55
+ }
56
+ function isSafari() {
57
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
58
+ }
59
+ function isIPad() {
60
+ return testPlatform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
61
+ }
62
+ function isIOS() {
63
+ return isIPhone() || isIPad();
64
+ }
65
+ function testPlatform(e) {
66
+ return typeof window < "u" && window.navigator != null ? e.test(window.navigator.platform) : void 0;
67
+ }
68
+ var KEYBOARD_BUFFER = 24, useIsomorphicLayoutEffect = typeof window < "u" ? useLayoutEffect : useEffect;
69
+ function chain$1(...e) {
70
+ return (...t) => {
71
+ for (let n of e) typeof n == "function" && n(...t);
72
+ };
73
+ }
74
+ var visualViewport = typeof document < "u" && window.visualViewport;
75
+ function isScrollable(e) {
76
+ let t = window.getComputedStyle(e);
77
+ return /(auto|scroll)/.test(t.overflow + t.overflowX + t.overflowY);
78
+ }
79
+ function getScrollParent(e) {
80
+ for (isScrollable(e) && (e = e.parentElement); e && !isScrollable(e);) e = e.parentElement;
81
+ return e || document.scrollingElement || document.documentElement;
82
+ }
83
+ var nonTextInputTypes = new Set([
84
+ "checkbox",
85
+ "radio",
86
+ "range",
87
+ "color",
88
+ "file",
89
+ "image",
90
+ "button",
91
+ "submit",
92
+ "reset"
93
+ ]), preventScrollCount = 0, restore;
94
+ function usePreventScroll(e = {}) {
95
+ let { isDisabled: t } = e;
96
+ useIsomorphicLayoutEffect(() => {
97
+ if (!t) return preventScrollCount++, preventScrollCount === 1 && isIOS() && (restore = preventScrollMobileSafari()), () => {
98
+ preventScrollCount--, preventScrollCount === 0 && restore?.();
99
+ };
100
+ }, [t]);
101
+ }
102
+ function preventScrollMobileSafari() {
103
+ let e, t = 0, n = (n) => {
104
+ e = getScrollParent(n.target), !(e === document.documentElement && e === document.body) && (t = n.changedTouches[0].pageY);
105
+ }, r = (n) => {
106
+ if (!e || e === document.documentElement || e === document.body) {
107
+ n.preventDefault();
108
+ return;
109
+ }
110
+ let r = n.changedTouches[0].pageY, i = e.scrollTop, a = e.scrollHeight - e.clientHeight;
111
+ a !== 0 && ((i <= 0 && r > t || i >= a && r < t) && n.preventDefault(), t = r);
112
+ }, i = (e) => {
113
+ let t = e.target;
114
+ isInput(t) && t !== document.activeElement && (e.preventDefault(), t.style.transform = "translateY(-2000px)", t.focus(), requestAnimationFrame(() => {
115
+ t.style.transform = "";
116
+ }));
117
+ }, a = (e) => {
118
+ let t = e.target;
119
+ isInput(t) && (t.style.transform = "translateY(-2000px)", requestAnimationFrame(() => {
120
+ t.style.transform = "", visualViewport && (visualViewport.height < window.innerHeight ? requestAnimationFrame(() => {
121
+ scrollIntoView(t);
122
+ }) : visualViewport.addEventListener("resize", () => scrollIntoView(t), { once: !0 }));
123
+ }));
124
+ }, o = () => {
125
+ window.scrollTo(0, 0);
126
+ }, s = window.pageXOffset, c = window.pageYOffset, l = chain$1(setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
127
+ window.scrollTo(0, 0);
128
+ let u = chain$1(addEvent(document, "touchstart", n, {
129
+ passive: !1,
130
+ capture: !0
131
+ }), addEvent(document, "touchmove", r, {
132
+ passive: !1,
133
+ capture: !0
134
+ }), addEvent(document, "touchend", i, {
135
+ passive: !1,
136
+ capture: !0
137
+ }), addEvent(document, "focus", a, !0), addEvent(window, "scroll", o));
138
+ return () => {
139
+ l(), u(), window.scrollTo(s, c);
140
+ };
141
+ }
142
+ function setStyle(e, t, n) {
143
+ let r = e.style[t];
144
+ return e.style[t] = n, () => {
145
+ e.style[t] = r;
146
+ };
147
+ }
148
+ function addEvent(e, t, n, r) {
149
+ return e.addEventListener(t, n, r), () => {
150
+ e.removeEventListener(t, n, r);
151
+ };
152
+ }
153
+ function scrollIntoView(e) {
154
+ let t = document.scrollingElement || document.documentElement;
155
+ for (; e && e !== t;) {
156
+ let t = getScrollParent(e);
157
+ if (t !== document.documentElement && t !== document.body && t !== e) {
158
+ let n = t.getBoundingClientRect().top, r = e.getBoundingClientRect().top;
159
+ e.getBoundingClientRect().bottom > t.getBoundingClientRect().bottom + KEYBOARD_BUFFER && (t.scrollTop += r - n);
160
+ }
161
+ e = t.parentElement;
162
+ }
163
+ }
164
+ function isInput(e) {
165
+ return e instanceof HTMLInputElement && !nonTextInputTypes.has(e.type) || e instanceof HTMLTextAreaElement || e instanceof HTMLElement && e.isContentEditable;
166
+ }
167
+ function setRef(e, t) {
168
+ typeof e == "function" ? e(t) : e != null && (e.current = t);
169
+ }
170
+ function composeRefs(...e) {
171
+ return (t) => e.forEach((e) => setRef(e, t));
172
+ }
173
+ function useComposedRefs(...t) {
174
+ return React$1.useCallback(composeRefs(...t), t);
175
+ }
176
+ var cache = /* @__PURE__ */ new WeakMap();
177
+ function set(e, t, n = !1) {
178
+ if (!e || !(e instanceof HTMLElement)) return;
179
+ let r = {};
180
+ Object.entries(t).forEach(([t, n]) => {
181
+ if (t.startsWith("--")) {
182
+ e.style.setProperty(t, n);
183
+ return;
184
+ }
185
+ r[t] = e.style[t], e.style[t] = n;
186
+ }), !n && cache.set(e, r);
187
+ }
188
+ function reset(e, t) {
189
+ if (!e || !(e instanceof HTMLElement)) return;
190
+ let n = cache.get(e);
191
+ n && (e.style[t] = n[t]);
192
+ }
193
+ var isVertical = (e) => {
194
+ switch (e) {
195
+ case "top":
196
+ case "bottom": return !0;
197
+ case "left":
198
+ case "right": return !1;
199
+ default: return e;
200
+ }
201
+ };
202
+ function getTranslate(e, t) {
203
+ if (!e) return null;
204
+ let n = window.getComputedStyle(e), r = n.transform || n.webkitTransform || n.mozTransform, i = r.match(/^matrix3d\((.+)\)$/);
205
+ return i ? parseFloat(i[1].split(", ")[isVertical(t) ? 13 : 12]) : (i = r.match(/^matrix\((.+)\)$/), i ? parseFloat(i[1].split(", ")[isVertical(t) ? 5 : 4]) : null);
206
+ }
207
+ function dampenValue(e) {
208
+ return 8 * (Math.log(e + 1) - 2);
209
+ }
210
+ function assignStyle(e, t) {
211
+ if (!e) return () => {};
212
+ let n = e.style.cssText;
213
+ return Object.assign(e.style, t), () => {
214
+ e.style.cssText = n;
215
+ };
216
+ }
217
+ var TRANSITIONS = {
218
+ DURATION: .5,
219
+ EASE: [
220
+ .32,
221
+ .72,
222
+ 0,
223
+ 1
224
+ ]
225
+ }, VELOCITY_THRESHOLD = .4, CLOSE_THRESHOLD = .25, SCROLL_LOCK_TIMEOUT = 100, BORDER_RADIUS = 8, NESTED_DISPLACEMENT = 16, WINDOW_TOP_OFFSET = 26, DRAG_CLASS = "vaul-dragging";
226
+ function useCallbackRef(e) {
227
+ let n = React.useRef(e);
228
+ return React.useEffect(() => {
229
+ n.current = e;
230
+ }), React.useMemo(() => (...e) => n.current == null ? void 0 : n.current.call(n, ...e), []);
231
+ }
232
+ function useUncontrolledState({ defaultProp: e, onChange: n }) {
233
+ let r = React.useState(e), [i] = r, a = React.useRef(i), o = useCallbackRef(n);
234
+ return React.useEffect(() => {
235
+ a.current !== i && (o(i), a.current = i);
236
+ }, [
237
+ i,
238
+ a,
239
+ o
240
+ ]), r;
241
+ }
242
+ function useControllableState({ prop: e, defaultProp: n, onChange: r = () => {} }) {
243
+ let [i, a] = useUncontrolledState({
244
+ defaultProp: n,
245
+ onChange: r
246
+ }), o = e !== void 0, s = o ? e : i, c = useCallbackRef(r);
247
+ return [s, React.useCallback((t) => {
248
+ if (o) {
249
+ let n = typeof t == "function" ? t(e) : t;
250
+ n !== e && c(n);
251
+ } else a(t);
252
+ }, [
253
+ o,
254
+ e,
255
+ a,
256
+ c
257
+ ])];
258
+ }
259
+ function useSnapPoints({ activeSnapPointProp: e, setActiveSnapPointProp: n, snapPoints: r, drawerRef: i, overlayRef: a, fadeFromIndex: o, onSnapPointChange: s, direction: c = "bottom", container: l, snapToSequentialPoint: u }) {
260
+ let [d, f] = useControllableState({
261
+ prop: e,
262
+ defaultProp: r?.[0],
263
+ onChange: n
264
+ }), [p, m] = React.useState(typeof window < "u" ? {
265
+ innerWidth: window.innerWidth,
266
+ innerHeight: window.innerHeight
267
+ } : void 0);
268
+ React.useEffect(() => {
269
+ function e() {
270
+ m({
271
+ innerWidth: window.innerWidth,
272
+ innerHeight: window.innerHeight
273
+ });
274
+ }
275
+ return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
276
+ }, []);
277
+ let h = React.useMemo(() => d === r?.[r.length - 1] || null, [r, d]), g = React.useMemo(() => r?.findIndex((e) => e === d) ?? null, [r, d]), _ = r && r.length > 0 && (o || o === 0) && !Number.isNaN(o) && r[o] === d || !r, v = React.useMemo(() => {
278
+ let e = l ? {
279
+ width: l.getBoundingClientRect().width,
280
+ height: l.getBoundingClientRect().height
281
+ } : typeof window < "u" ? {
282
+ width: window.innerWidth,
283
+ height: window.innerHeight
284
+ } : {
285
+ width: 0,
286
+ height: 0
287
+ };
288
+ return r?.map((t) => {
289
+ let n = typeof t == "string", r = 0;
290
+ if (n && (r = parseInt(t, 10)), isVertical(c)) {
291
+ let i = n ? r : p ? t * e.height : 0;
292
+ return p ? c === "bottom" ? e.height - i : -e.height + i : i;
293
+ }
294
+ let i = n ? r : p ? t * e.width : 0;
295
+ return p ? c === "right" ? e.width - i : -e.width + i : i;
296
+ }) ?? [];
297
+ }, [
298
+ r,
299
+ p,
300
+ l
301
+ ]), y = React.useMemo(() => g === null ? null : v?.[g], [v, g]), b = React.useCallback((e) => {
302
+ let t = v?.findIndex((t) => t === e) ?? null;
303
+ s(t), set(i.current, {
304
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
305
+ transform: isVertical(c) ? `translate3d(0, ${e}px, 0)` : `translate3d(${e}px, 0, 0)`
306
+ }), v && t !== v.length - 1 && o !== void 0 && t !== o && t < o ? set(a.current, {
307
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
308
+ opacity: "0"
309
+ }) : set(a.current, {
310
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
311
+ opacity: "1"
312
+ }), f(r?.[Math.max(t, 0)]);
313
+ }, [
314
+ i.current,
315
+ r,
316
+ v,
317
+ o,
318
+ a,
319
+ f
320
+ ]);
321
+ React.useEffect(() => {
322
+ if (d || e) {
323
+ let t = r?.findIndex((t) => t === e || t === d) ?? -1;
324
+ v && t !== -1 && typeof v[t] == "number" && b(v[t]);
325
+ }
326
+ }, [
327
+ d,
328
+ e,
329
+ r,
330
+ v,
331
+ b
332
+ ]);
333
+ function x({ draggedDistance: e, closeDrawer: t, velocity: n, dismissible: i }) {
334
+ if (o === void 0) return;
335
+ let s = c === "bottom" || c === "right" ? (y ?? 0) - e : (y ?? 0) + e, l = g === o - 1, d = g === 0, f = e > 0;
336
+ if (l && set(a.current, { transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})` }), !u && n > 2 && !f) {
337
+ i ? t() : b(v[0]);
338
+ return;
339
+ }
340
+ if (!u && n > 2 && f && v && r) {
341
+ b(v[r.length - 1]);
342
+ return;
343
+ }
344
+ let p = v?.reduce((e, t) => typeof e != "number" || typeof t != "number" ? e : Math.abs(t - s) < Math.abs(e - s) ? t : e), m = isVertical(c) ? window.innerHeight : window.innerWidth;
345
+ if (n > VELOCITY_THRESHOLD && Math.abs(e) < m * .4) {
346
+ let e = f ? 1 : -1;
347
+ if (e > 0 && h && r) {
348
+ b(v[r.length - 1]);
349
+ return;
350
+ }
351
+ if (d && e < 0 && i && t(), g === null) return;
352
+ b(v[g + e]);
353
+ return;
354
+ }
355
+ b(p);
356
+ }
357
+ function S({ draggedDistance: e }) {
358
+ if (y === null) return;
359
+ let t = c === "bottom" || c === "right" ? y - e : y + e;
360
+ (c === "bottom" || c === "right") && t < v[v.length - 1] || (c === "top" || c === "left") && t > v[v.length - 1] || set(i.current, { transform: isVertical(c) ? `translate3d(0, ${t}px, 0)` : `translate3d(${t}px, 0, 0)` });
361
+ }
362
+ function C(e, t) {
363
+ if (!r || typeof g != "number" || !v || o === void 0) return null;
364
+ let n = g === o - 1;
365
+ if (g >= o && t) return 0;
366
+ if (n && !t) return 1;
367
+ if (!_ && !n) return null;
368
+ let i = n ? g + 1 : g - 1, a = n ? v[i] - v[i - 1] : v[i + 1] - v[i], s = e / Math.abs(a);
369
+ return n ? 1 - s : s;
370
+ }
371
+ return {
372
+ isLastSnapPoint: h,
373
+ activeSnapPoint: d,
374
+ shouldFade: _,
375
+ getPercentageDragged: C,
376
+ setActiveSnapPoint: f,
377
+ activeSnapPointIndex: g,
378
+ onRelease: x,
379
+ onDrag: S,
380
+ snapPointsOffset: v
381
+ };
382
+ }
383
+ function useScaleBackground() {
384
+ let { direction: e, isOpen: n, shouldScaleBackground: r, setBackgroundColorOnScale: a, noBodyStyles: o } = useDrawerContext(), s = React.useRef(null), l = useMemo(() => document.body.style.backgroundColor, []);
385
+ function u() {
386
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
387
+ }
388
+ React.useEffect(() => {
389
+ if (n && r) {
390
+ s.current && clearTimeout(s.current);
391
+ let t = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[vaul-drawer-wrapper]");
392
+ if (!t) return;
393
+ a && !o && assignStyle(document.body, { background: "black" }), assignStyle(t, {
394
+ transformOrigin: isVertical(e) ? "top" : "left",
395
+ transitionProperty: "transform, border-radius",
396
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
397
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
398
+ });
399
+ let n = assignStyle(t, {
400
+ borderRadius: `${BORDER_RADIUS}px`,
401
+ overflow: "hidden",
402
+ ...isVertical(e) ? { transform: `scale(${u()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)` } : { transform: `scale(${u()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)` }
403
+ });
404
+ return () => {
405
+ n(), s.current = window.setTimeout(() => {
406
+ l ? document.body.style.background = l : document.body.style.removeProperty("background");
407
+ }, TRANSITIONS.DURATION * 1e3);
408
+ };
409
+ }
410
+ }, [
411
+ n,
412
+ r,
413
+ l
414
+ ]);
415
+ }
416
+ var previousBodyPosition = null;
417
+ function usePositionFixed({ isOpen: e, modal: n, nested: r, hasBeenOpened: i, preventScrollRestoration: a, noBodyStyles: o }) {
418
+ let [s, c] = React.useState(() => typeof window < "u" ? window.location.href : ""), l = React.useRef(0), u = React.useCallback(() => {
419
+ if (isSafari() && previousBodyPosition === null && e && !o) {
420
+ previousBodyPosition = {
421
+ position: document.body.style.position,
422
+ top: document.body.style.top,
423
+ left: document.body.style.left,
424
+ height: document.body.style.height,
425
+ right: "unset"
426
+ };
427
+ let { scrollX: e, innerHeight: t } = window;
428
+ document.body.style.setProperty("position", "fixed", "important"), Object.assign(document.body.style, {
429
+ top: `${-l.current}px`,
430
+ left: `${-e}px`,
431
+ right: "0px",
432
+ height: "auto"
433
+ }), window.setTimeout(() => window.requestAnimationFrame(() => {
434
+ let e = t - window.innerHeight;
435
+ e && l.current >= t && (document.body.style.top = `${-(l.current + e)}px`);
436
+ }), 300);
437
+ }
438
+ }, [e]), d = React.useCallback(() => {
439
+ if (isSafari() && previousBodyPosition !== null && !o) {
440
+ let e = -parseInt(document.body.style.top, 10), t = -parseInt(document.body.style.left, 10);
441
+ Object.assign(document.body.style, previousBodyPosition), window.requestAnimationFrame(() => {
442
+ if (a && s !== window.location.href) {
443
+ c(window.location.href);
444
+ return;
445
+ }
446
+ window.scrollTo(t, e);
447
+ }), previousBodyPosition = null;
448
+ }
449
+ }, [s]);
450
+ return React.useEffect(() => {
451
+ function e() {
452
+ l.current = window.scrollY;
453
+ }
454
+ return e(), window.addEventListener("scroll", e), () => {
455
+ window.removeEventListener("scroll", e);
456
+ };
457
+ }, []), React.useEffect(() => {
458
+ if (n) return () => {
459
+ typeof document > "u" || document.querySelector("[data-vaul-drawer]") || d();
460
+ };
461
+ }, [n, d]), React.useEffect(() => {
462
+ r || !i || (e ? (!window.matchMedia("(display-mode: standalone)").matches && u(), n || window.setTimeout(() => {
463
+ d();
464
+ }, 500)) : d());
465
+ }, [
466
+ e,
467
+ i,
468
+ s,
469
+ n,
470
+ r,
471
+ u,
472
+ d
473
+ ]), { restorePositionSetting: d };
474
+ }
475
+ function Root({ open: e, onOpenChange: n, children: r, onDrag: i, onRelease: o, snapPoints: c, shouldScaleBackground: u = !1, setBackgroundColorOnScale: d = !0, closeThreshold: f = CLOSE_THRESHOLD, scrollLockTimeout: p = SCROLL_LOCK_TIMEOUT, dismissible: h = !0, handleOnly: g = !1, fadeFromIndex: _ = c && c.length - 1, activeSnapPoint: v, setActiveSnapPoint: y, fixed: b, modal: x = !0, onClose: S, nested: C, noBodyStyles: w = !1, direction: T = "bottom", defaultOpen: E = !1, disablePreventScroll: D = !0, snapToSequentialPoint: O = !1, preventScrollRestoration: k = !1, repositionInputs: A = !0, onAnimationEnd: ve, container: j, autoFocus: ye = !1 }) {
476
+ let [M = !1, N] = useControllableState({
477
+ defaultProp: E,
478
+ prop: e,
479
+ onChange: (e) => {
480
+ n?.(e), !e && !C && je(), setTimeout(() => {
481
+ ve?.(e);
482
+ }, TRANSITIONS.DURATION * 1e3), e && !x && typeof window < "u" && window.requestAnimationFrame(() => {
483
+ document.body.style.pointerEvents = "auto";
484
+ }), e || (document.body.style.pointerEvents = "auto");
485
+ }
486
+ }), [P, be] = React.useState(!1), [F, I] = React.useState(!1), [xe, L] = React.useState(!1), R = React.useRef(null), z = React.useRef(null), B = React.useRef(null), V = React.useRef(null), H = React.useRef(null), U = React.useRef(!1), W = React.useRef(null), G = React.useRef(0), K = React.useRef(!1), q = React.useRef(!E), Se = React.useRef(0), J = React.useRef(null), Ce = React.useRef(J.current?.getBoundingClientRect().height || 0), we = React.useRef(J.current?.getBoundingClientRect().width || 0), Te = React.useRef(0), { activeSnapPoint: Ee, activeSnapPointIndex: Y, setActiveSnapPoint: De, onRelease: Oe, snapPointsOffset: X, onDrag: ke, shouldFade: Z, getPercentageDragged: Ae } = useSnapPoints({
487
+ snapPoints: c,
488
+ activeSnapPointProp: v,
489
+ setActiveSnapPointProp: y,
490
+ drawerRef: J,
491
+ fadeFromIndex: _,
492
+ overlayRef: R,
493
+ onSnapPointChange: React.useCallback((e) => {
494
+ c && e === X.length - 1 && (z.current = /* @__PURE__ */ new Date());
495
+ }, []),
496
+ direction: T,
497
+ container: j,
498
+ snapToSequentialPoint: O
499
+ });
500
+ usePreventScroll({ isDisabled: !M || F || !x || xe || !P || !A || !D });
501
+ let { restorePositionSetting: je } = usePositionFixed({
502
+ isOpen: M,
503
+ modal: x,
504
+ nested: C ?? !1,
505
+ hasBeenOpened: P,
506
+ preventScrollRestoration: k,
507
+ noBodyStyles: w
508
+ });
509
+ function Q() {
510
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
511
+ }
512
+ function Me(e) {
513
+ !h && !c || J.current && !J.current.contains(e.target) || (Ce.current = J.current?.getBoundingClientRect().height || 0, we.current = J.current?.getBoundingClientRect().width || 0, I(!0), B.current = /* @__PURE__ */ new Date(), isIOS() && window.addEventListener("touchend", () => U.current = !1, { once: !0 }), e.target.setPointerCapture(e.pointerId), G.current = isVertical(T) ? e.pageY : e.pageX);
514
+ }
515
+ function Ne(e, t) {
516
+ let n = e, r = window.getSelection()?.toString(), i = J.current ? getTranslate(J.current, T) : null, a = /* @__PURE__ */ new Date();
517
+ if (n.tagName === "SELECT" || n.hasAttribute("data-vaul-no-drag") || n.closest("[data-vaul-no-drag]")) return !1;
518
+ if (T === "right" || T === "left") return !0;
519
+ if (z.current && a.getTime() - z.current.getTime() < 500) return !1;
520
+ if (i !== null && (T === "bottom" ? i > 0 : i < 0)) return !0;
521
+ if (r && r.length > 0) return !1;
522
+ if (H.current && a.getTime() - H.current.getTime() < p && i === 0 || t) return H.current = a, !1;
523
+ for (; n;) {
524
+ if (n.scrollHeight > n.clientHeight) {
525
+ if (n.scrollTop !== 0) return H.current = /* @__PURE__ */ new Date(), !1;
526
+ if (n.getAttribute("role") === "dialog") return !0;
527
+ }
528
+ n = n.parentNode;
529
+ }
530
+ return !0;
531
+ }
532
+ function Pe(e) {
533
+ if (J.current && F) {
534
+ let t = T === "bottom" || T === "right" ? 1 : -1, n = (G.current - (isVertical(T) ? e.pageY : e.pageX)) * t, r = n > 0, a = c && !h && !r;
535
+ if (a && Y === 0) return;
536
+ let o = Math.abs(n), s = document.querySelector("[data-vaul-drawer-wrapper]"), l = o / (T === "bottom" || T === "top" ? Ce.current : we.current), d = Ae(o, r);
537
+ if (d !== null && (l = d), a && l >= 1 || !U.current && !Ne(e.target, r)) return;
538
+ if (J.current.classList.add(DRAG_CLASS), U.current = !0, set(J.current, { transition: "none" }), set(R.current, { transition: "none" }), c && ke({ draggedDistance: n }), r && !c) {
539
+ let e = dampenValue(n), r = Math.min(e * -1, 0) * t;
540
+ set(J.current, { transform: isVertical(T) ? `translate3d(0, ${r}px, 0)` : `translate3d(${r}px, 0, 0)` });
541
+ return;
542
+ }
543
+ let f = 1 - l;
544
+ if ((Z || _ && Y === _ - 1) && (i?.(e, l), set(R.current, {
545
+ opacity: `${f}`,
546
+ transition: "none"
547
+ }, !0)), s && R.current && u) {
548
+ let e = Math.min(Q() + l * (1 - Q()), 1), t = 8 - l * 8, n = Math.max(0, 14 - l * 14);
549
+ set(s, {
550
+ borderRadius: `${t}px`,
551
+ transform: isVertical(T) ? `scale(${e}) translate3d(0, ${n}px, 0)` : `scale(${e}) translate3d(${n}px, 0, 0)`,
552
+ transition: "none"
553
+ }, !0);
554
+ }
555
+ if (!c) {
556
+ let e = o * t;
557
+ set(J.current, { transform: isVertical(T) ? `translate3d(0, ${e}px, 0)` : `translate3d(${e}px, 0, 0)` });
558
+ }
559
+ }
560
+ }
561
+ React.useEffect(() => {
562
+ window.requestAnimationFrame(() => {
563
+ q.current = !0;
564
+ });
565
+ }, []), React.useEffect(() => {
566
+ var e;
567
+ function t() {
568
+ if (!J.current || !A) return;
569
+ let e = document.activeElement;
570
+ if (isInput(e) || K.current) {
571
+ let e = window.visualViewport?.height || 0, t = window.innerHeight, n = t - e, r = J.current.getBoundingClientRect().height || 0, i = r > t * .8;
572
+ Te.current ||= r;
573
+ let a = J.current.getBoundingClientRect().top;
574
+ if (Math.abs(Se.current - n) > 60 && (K.current = !K.current), c && c.length > 0 && X && Y) {
575
+ let e = X[Y] || 0;
576
+ n += e;
577
+ }
578
+ if (Se.current = n, r > e || K.current) {
579
+ let t = J.current.getBoundingClientRect().height, r = t;
580
+ t > e && (r = e - (i ? a : WINDOW_TOP_OFFSET)), b ? J.current.style.height = `${t - Math.max(n, 0)}px` : J.current.style.height = `${Math.max(r, e - a)}px`;
581
+ } else isMobileFirefox() || (J.current.style.height = `${Te.current}px`);
582
+ c && c.length > 0 && !K.current ? J.current.style.bottom = "0px" : J.current.style.bottom = `${Math.max(n, 0)}px`;
583
+ }
584
+ }
585
+ return (e = window.visualViewport) == null || e.addEventListener("resize", t), () => window.visualViewport?.removeEventListener("resize", t);
586
+ }, [
587
+ Y,
588
+ c,
589
+ X
590
+ ]);
591
+ function $(e) {
592
+ Ie(), S?.(), e || N(!1), setTimeout(() => {
593
+ c && De(c[0]);
594
+ }, TRANSITIONS.DURATION * 1e3);
595
+ }
596
+ function Fe() {
597
+ if (!J.current) return;
598
+ let e = document.querySelector("[data-vaul-drawer-wrapper]"), t = getTranslate(J.current, T);
599
+ set(J.current, {
600
+ transform: "translate3d(0, 0, 0)",
601
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`
602
+ }), set(R.current, {
603
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
604
+ opacity: "1"
605
+ }), u && t && t > 0 && M && set(e, {
606
+ borderRadius: `${BORDER_RADIUS}px`,
607
+ overflow: "hidden",
608
+ ...isVertical(T) ? {
609
+ transform: `scale(${Q()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
610
+ transformOrigin: "top"
611
+ } : {
612
+ transform: `scale(${Q()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
613
+ transformOrigin: "left"
614
+ },
615
+ transitionProperty: "transform, border-radius",
616
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
617
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
618
+ }, !0);
619
+ }
620
+ function Ie() {
621
+ !F || !J.current || (J.current.classList.remove(DRAG_CLASS), U.current = !1, I(!1), V.current = /* @__PURE__ */ new Date());
622
+ }
623
+ function Le(e) {
624
+ if (!F || !J.current) return;
625
+ J.current.classList.remove(DRAG_CLASS), U.current = !1, I(!1), V.current = /* @__PURE__ */ new Date();
626
+ let t = getTranslate(J.current, T);
627
+ if (!e || !Ne(e.target, !1) || !t || Number.isNaN(t) || B.current === null) return;
628
+ let n = V.current.getTime() - B.current.getTime(), r = G.current - (isVertical(T) ? e.pageY : e.pageX), i = Math.abs(r) / n;
629
+ if (i > .05 && (L(!0), setTimeout(() => {
630
+ L(!1);
631
+ }, 200)), c) {
632
+ Oe({
633
+ draggedDistance: r * (T === "bottom" || T === "right" ? 1 : -1),
634
+ closeDrawer: $,
635
+ velocity: i,
636
+ dismissible: h
637
+ }), o?.(e, !0);
638
+ return;
639
+ }
640
+ if (T === "bottom" || T === "right" ? r > 0 : r < 0) {
641
+ Fe(), o?.(e, !0);
642
+ return;
643
+ }
644
+ if (i > VELOCITY_THRESHOLD) {
645
+ $(), o?.(e, !1);
646
+ return;
647
+ }
648
+ let a = Math.min(J.current.getBoundingClientRect().height ?? 0, window.innerHeight), s = Math.min(J.current.getBoundingClientRect().width ?? 0, window.innerWidth), l = T === "left" || T === "right";
649
+ if (Math.abs(t) >= (l ? s : a) * f) {
650
+ $(), o?.(e, !1);
651
+ return;
652
+ }
653
+ o?.(e, !0), Fe();
654
+ }
655
+ React.useEffect(() => (M && (set(document.documentElement, { scrollBehavior: "auto" }), z.current = /* @__PURE__ */ new Date()), () => {
656
+ reset(document.documentElement, "scrollBehavior");
657
+ }), [M]);
658
+ function Re(e) {
659
+ let t = e ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1, n = e ? -NESTED_DISPLACEMENT : 0;
660
+ W.current && window.clearTimeout(W.current), set(J.current, {
661
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
662
+ transform: isVertical(T) ? `scale(${t}) translate3d(0, ${n}px, 0)` : `scale(${t}) translate3d(${n}px, 0, 0)`
663
+ }), !e && J.current && (W.current = setTimeout(() => {
664
+ let e = getTranslate(J.current, T);
665
+ set(J.current, {
666
+ transition: "none",
667
+ transform: isVertical(T) ? `translate3d(0, ${e}px, 0)` : `translate3d(${e}px, 0, 0)`
668
+ });
669
+ }, 500));
670
+ }
671
+ function ze(e, t) {
672
+ if (t < 0) return;
673
+ let n = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth, r = n + t * (1 - n), i = -NESTED_DISPLACEMENT + t * NESTED_DISPLACEMENT;
674
+ set(J.current, {
675
+ transform: isVertical(T) ? `scale(${r}) translate3d(0, ${i}px, 0)` : `scale(${r}) translate3d(${i}px, 0, 0)`,
676
+ transition: "none"
677
+ });
678
+ }
679
+ function Be(e, t) {
680
+ let n = isVertical(T) ? window.innerHeight : window.innerWidth, r = t ? (n - NESTED_DISPLACEMENT) / n : 1, i = t ? -NESTED_DISPLACEMENT : 0;
681
+ t && set(J.current, {
682
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
683
+ transform: isVertical(T) ? `scale(${r}) translate3d(0, ${i}px, 0)` : `scale(${r}) translate3d(${i}px, 0, 0)`
684
+ });
685
+ }
686
+ return React.useEffect(() => {
687
+ x || window.requestAnimationFrame(() => {
688
+ document.body.style.pointerEvents = "auto";
689
+ });
690
+ }, [x]), /* @__PURE__ */ React.createElement(DialogPrimitive.Root, {
691
+ defaultOpen: E,
692
+ onOpenChange: (e) => {
693
+ !h && !e || (e ? be(!0) : $(!0), N(e));
694
+ },
695
+ open: M
696
+ }, /* @__PURE__ */ React.createElement(DrawerContext.Provider, { value: {
697
+ activeSnapPoint: Ee,
698
+ snapPoints: c,
699
+ setActiveSnapPoint: De,
700
+ drawerRef: J,
701
+ overlayRef: R,
702
+ onOpenChange: n,
703
+ onPress: Me,
704
+ onRelease: Le,
705
+ onDrag: Pe,
706
+ dismissible: h,
707
+ shouldAnimate: q,
708
+ handleOnly: g,
709
+ isOpen: M,
710
+ isDragging: F,
711
+ shouldFade: Z,
712
+ closeDrawer: $,
713
+ onNestedDrag: ze,
714
+ onNestedOpenChange: Re,
715
+ onNestedRelease: Be,
716
+ keyboardIsOpen: K,
717
+ modal: x,
718
+ snapPointsOffset: X,
719
+ activeSnapPointIndex: Y,
720
+ direction: T,
721
+ shouldScaleBackground: u,
722
+ setBackgroundColorOnScale: d,
723
+ noBodyStyles: w,
724
+ container: j,
725
+ autoFocus: ye
726
+ } }, r));
727
+ }
728
+ var Overlay = /* @__PURE__ */ React.forwardRef(function({ ...e }, n) {
729
+ let { overlayRef: r, snapPoints: i, onRelease: o, shouldFade: s, isOpen: l, modal: u, shouldAnimate: d } = useDrawerContext(), f = useComposedRefs(n, r), p = i && i.length > 0;
730
+ if (!u) return null;
731
+ let m = React.useCallback((e) => o(e), [o]);
732
+ return /* @__PURE__ */ React.createElement(DialogPrimitive.Overlay, {
733
+ onMouseUp: m,
734
+ ref: f,
735
+ "data-vaul-overlay": "",
736
+ "data-vaul-snap-points": l && p ? "true" : "false",
737
+ "data-vaul-snap-points-overlay": l && s ? "true" : "false",
738
+ "data-vaul-animate": d?.current ? "true" : "false",
739
+ ...e
740
+ });
741
+ });
742
+ Overlay.displayName = "Drawer.Overlay";
743
+ var Content = /* @__PURE__ */ React.forwardRef(function({ onPointerDownOutside: e, style: n, onOpenAutoFocus: r, ...i }, o) {
744
+ let { drawerRef: s, onPress: l, onRelease: u, onDrag: d, keyboardIsOpen: f, snapPointsOffset: p, activeSnapPointIndex: m, modal: h, isOpen: g, direction: _, snapPoints: v, container: y, handleOnly: b, shouldAnimate: x, autoFocus: S } = useDrawerContext(), [C, w] = React.useState(!1), ge = useComposedRefs(o, s), T = React.useRef(null), E = React.useRef(null), D = React.useRef(!1), O = v && v.length > 0;
745
+ useScaleBackground();
746
+ let _e = (e, t, n = 0) => {
747
+ if (D.current) return !0;
748
+ let r = Math.abs(e.y), i = Math.abs(e.x), a = i > r, o = ["bottom", "right"].includes(t) ? 1 : -1;
749
+ if (t === "left" || t === "right") {
750
+ if (!(e.x * o < 0) && i >= 0 && i <= n) return a;
751
+ } else if (!(e.y * o < 0) && r >= 0 && r <= n) return !a;
752
+ return D.current = !0, !0;
753
+ };
754
+ React.useEffect(() => {
755
+ O && window.requestAnimationFrame(() => {
756
+ w(!0);
757
+ });
758
+ }, []);
759
+ function k(e) {
760
+ T.current = null, D.current = !1, u(e);
761
+ }
762
+ return /* @__PURE__ */ React.createElement(DialogPrimitive.Content, {
763
+ "data-vaul-drawer-direction": _,
764
+ "data-vaul-drawer": "",
765
+ "data-vaul-delayed-snap-points": C ? "true" : "false",
766
+ "data-vaul-snap-points": g && O ? "true" : "false",
767
+ "data-vaul-custom-container": y ? "true" : "false",
768
+ "data-vaul-animate": x?.current ? "true" : "false",
769
+ ...i,
770
+ ref: ge,
771
+ style: p && p.length > 0 ? {
772
+ "--snap-point-height": `${p[m ?? 0]}px`,
773
+ ...n
774
+ } : n,
775
+ onPointerDown: (e) => {
776
+ b || (i.onPointerDown == null || i.onPointerDown.call(i, e), T.current = {
777
+ x: e.pageX,
778
+ y: e.pageY
779
+ }, l(e));
780
+ },
781
+ onOpenAutoFocus: (e) => {
782
+ r?.(e), S || e.preventDefault();
783
+ },
784
+ onPointerDownOutside: (t) => {
785
+ if (e?.(t), !h || t.defaultPrevented) {
786
+ t.preventDefault();
787
+ return;
788
+ }
789
+ f.current &&= !1;
790
+ },
791
+ onFocusOutside: (e) => {
792
+ if (!h) {
793
+ e.preventDefault();
794
+ return;
795
+ }
796
+ },
797
+ onPointerMove: (e) => {
798
+ if (E.current = e, b || (i.onPointerMove == null || i.onPointerMove.call(i, e), !T.current)) return;
799
+ let t = e.pageY - T.current.y, n = e.pageX - T.current.x, r = e.pointerType === "touch" ? 10 : 2;
800
+ _e({
801
+ x: n,
802
+ y: t
803
+ }, _, r) ? d(e) : (Math.abs(n) > r || Math.abs(t) > r) && (T.current = null);
804
+ },
805
+ onPointerUp: (e) => {
806
+ i.onPointerUp == null || i.onPointerUp.call(i, e), T.current = null, D.current = !1, u(e);
807
+ },
808
+ onPointerOut: (e) => {
809
+ i.onPointerOut == null || i.onPointerOut.call(i, e), k(E.current);
810
+ },
811
+ onContextMenu: (e) => {
812
+ i.onContextMenu == null || i.onContextMenu.call(i, e), E.current && k(E.current);
813
+ }
814
+ });
815
+ });
816
+ Content.displayName = "Drawer.Content";
817
+ var LONG_HANDLE_PRESS_TIMEOUT = 250, DOUBLE_TAP_TIMEOUT = 120, Handle = /* @__PURE__ */ React.forwardRef(function({ preventCycle: e = !1, children: n, ...r }, i) {
818
+ let { closeDrawer: a, isDragging: o, snapPoints: s, activeSnapPoint: l, setActiveSnapPoint: u, dismissible: d, handleOnly: f, isOpen: p, onPress: m, onDrag: h } = useDrawerContext(), g = React.useRef(null), _ = React.useRef(!1);
819
+ function v() {
820
+ if (_.current) {
821
+ x();
822
+ return;
823
+ }
824
+ window.setTimeout(() => {
825
+ y();
826
+ }, DOUBLE_TAP_TIMEOUT);
827
+ }
828
+ function y() {
829
+ if (o || e || _.current) {
830
+ x();
831
+ return;
832
+ }
833
+ if (x(), !s || s.length === 0) {
834
+ d || a();
835
+ return;
836
+ }
837
+ if (l === s[s.length - 1] && d) {
838
+ a();
839
+ return;
840
+ }
841
+ let t = s.findIndex((e) => e === l);
842
+ if (t === -1) return;
843
+ let n = s[t + 1];
844
+ u(n);
845
+ }
846
+ function b() {
847
+ g.current = window.setTimeout(() => {
848
+ _.current = !0;
849
+ }, LONG_HANDLE_PRESS_TIMEOUT);
850
+ }
851
+ function x() {
852
+ g.current && window.clearTimeout(g.current), _.current = !1;
853
+ }
854
+ return /* @__PURE__ */ React.createElement("div", {
855
+ onClick: v,
856
+ onPointerCancel: x,
857
+ onPointerDown: (e) => {
858
+ f && m(e), b();
859
+ },
860
+ onPointerMove: (e) => {
861
+ f && h(e);
862
+ },
863
+ ref: i,
864
+ "data-vaul-drawer-visible": p ? "true" : "false",
865
+ "data-vaul-handle": "",
866
+ "aria-hidden": "true",
867
+ ...r
868
+ }, /* @__PURE__ */ React.createElement("span", {
869
+ "data-vaul-handle-hitarea": "",
870
+ "aria-hidden": "true"
871
+ }, n));
872
+ });
873
+ Handle.displayName = "Drawer.Handle";
874
+ function NestedRoot({ onDrag: e, onOpenChange: n, open: r, ...i }) {
875
+ let { onNestedDrag: a, onNestedOpenChange: o, onNestedRelease: s } = useDrawerContext();
876
+ if (!a) throw Error("Drawer.NestedRoot must be placed in another drawer");
877
+ return /* @__PURE__ */ React.createElement(Root, {
878
+ nested: !0,
879
+ open: r,
880
+ onClose: () => {
881
+ o(!1);
882
+ },
883
+ onDrag: (t, n) => {
884
+ a(t, n), e?.(t, n);
885
+ },
886
+ onOpenChange: (e) => {
887
+ e && o(e), n?.(e);
888
+ },
889
+ onRelease: s,
890
+ ...i
891
+ });
892
+ }
893
+ function Portal(e) {
894
+ let n = useDrawerContext(), { container: r = n.container, ...i } = e;
895
+ return /* @__PURE__ */ React.createElement(DialogPrimitive.Portal, {
896
+ container: r,
897
+ ...i
898
+ });
899
+ }
900
+ var Drawer = {
901
+ Root,
902
+ NestedRoot,
903
+ Content,
904
+ Overlay,
905
+ Trigger: DialogPrimitive.Trigger,
906
+ Portal,
907
+ Handle,
908
+ Close: DialogPrimitive.Close,
909
+ Title: DialogPrimitive.Title,
910
+ Description: DialogPrimitive.Description
911
+ };
912
+ export { Drawer };