@telegraph/modal 0.0.84 → 0.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +1,90 @@
1
- import { jsx as d, jsxs as S } from "react/jsx-runtime";
2
- import * as v from "@radix-ui/react-dialog";
3
- import * as i from "react";
4
- import g from "react";
5
- import * as H from "react-dom";
6
- import { FocusScope as Z } from "@radix-ui/react-focus-scope";
7
- import * as q from "@radix-ui/react-portal";
8
- import * as G from "@radix-ui/react-visually-hidden";
9
- import { Button as J } from "@telegraph/button";
10
- import { RefToTgphRef as Q } from "@telegraph/helpers";
11
- import { Lucide as ee } from "@telegraph/icon";
12
- import { Stack as E, Box as te } from "@telegraph/layout";
13
- import { AnimatePresence as ne, motion as T } from "framer-motion";
14
- function O(e, t, { checkForDefaultPrevented: r = !0 } = {}) {
15
- return function(n) {
16
- if (e == null || e(n), r === !1 || !n.defaultPrevented)
17
- return t == null ? void 0 : t(n);
18
- };
19
- }
20
- function F(e, t) {
1
+ import { jsx as M, jsxs as Ve } from "react/jsx-runtime";
2
+ import * as J from "@radix-ui/react-dialog";
3
+ import * as v from "react";
4
+ import ne, { createContext as se, useRef as fe, useLayoutEffect as Us, useEffect as dt, useState as Gs, useContext as I, useMemo as Fe, useCallback as zs, useInsertionEffect as Hs, forwardRef as Ys, Fragment as Tn, createElement as Xs } from "react";
5
+ import * as qs from "react-dom";
6
+ import { FocusScope as Zs } from "@radix-ui/react-focus-scope";
7
+ import * as Js from "@radix-ui/react-portal";
8
+ import * as Qs from "@radix-ui/react-visually-hidden";
9
+ import { Button as ei } from "@telegraph/button";
10
+ import { RefToTgphRef as ti } from "@telegraph/helpers";
11
+ import { Stack as ee, Box as ni } from "@telegraph/layout";
12
+ import { X as si } from "lucide-react";
13
+ function Ke(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
14
+ return function(i) {
15
+ if (e == null || e(i), n === !1 || !i.defaultPrevented)
16
+ return t == null ? void 0 : t(i);
17
+ };
18
+ }
19
+ function Kt(e, t) {
21
20
  if (typeof e == "function")
22
21
  return e(t);
23
22
  e != null && (e.current = t);
24
23
  }
25
- function $(...e) {
24
+ function wn(...e) {
26
25
  return (t) => {
27
- let r = !1;
28
- const o = e.map((n) => {
29
- const s = F(n, t);
30
- return !r && typeof s == "function" && (r = !0), s;
26
+ let n = !1;
27
+ const s = e.map((i) => {
28
+ const r = Kt(i, t);
29
+ return !n && typeof r == "function" && (n = !0), r;
31
30
  });
32
- if (r)
31
+ if (n)
33
32
  return () => {
34
- for (let n = 0; n < o.length; n++) {
35
- const s = o[n];
36
- typeof s == "function" ? s() : F(e[n], null);
33
+ for (let i = 0; i < s.length; i++) {
34
+ const r = s[i];
35
+ typeof r == "function" ? r() : Kt(e[i], null);
37
36
  }
38
37
  };
39
38
  };
40
39
  }
41
- function M(...e) {
42
- return i.useCallback($(...e), e);
40
+ function Sn(...e) {
41
+ return v.useCallback(wn(...e), e);
43
42
  }
44
43
  // @__NO_SIDE_EFFECTS__
45
- function re(e) {
46
- const t = /* @__PURE__ */ oe(e), r = i.forwardRef((o, n) => {
47
- const { children: s, ...l } = o, a = i.Children.toArray(s), f = a.find(ie);
48
- if (f) {
49
- const u = f.props.children, c = a.map((y) => y === f ? i.Children.count(u) > 1 ? i.Children.only(null) : i.isValidElement(u) ? u.props.children : null : y);
50
- return /* @__PURE__ */ d(t, { ...l, ref: n, children: i.isValidElement(u) ? i.cloneElement(u, void 0, c) : null });
51
- }
52
- return /* @__PURE__ */ d(t, { ...l, ref: n, children: s });
44
+ function ii(e) {
45
+ const t = /* @__PURE__ */ ri(e), n = v.forwardRef((s, i) => {
46
+ const { children: r, ...o } = s, a = v.Children.toArray(r), l = a.find(ai);
47
+ if (l) {
48
+ const u = l.props.children, c = a.map((d) => d === l ? v.Children.count(u) > 1 ? v.Children.only(null) : v.isValidElement(u) ? u.props.children : null : d);
49
+ return /* @__PURE__ */ M(t, { ...o, ref: i, children: v.isValidElement(u) ? v.cloneElement(u, void 0, c) : null });
50
+ }
51
+ return /* @__PURE__ */ M(t, { ...o, ref: i, children: r });
53
52
  });
54
- return r.displayName = `${e}.Slot`, r;
53
+ return n.displayName = `${e}.Slot`, n;
55
54
  }
56
55
  // @__NO_SIDE_EFFECTS__
57
- function oe(e) {
58
- const t = i.forwardRef((r, o) => {
59
- const { children: n, ...s } = r;
60
- if (i.isValidElement(n)) {
61
- const l = ce(n), a = ae(s, n.props);
62
- return n.type !== i.Fragment && (a.ref = o ? $(o, l) : l), i.cloneElement(n, a);
63
- }
64
- return i.Children.count(n) > 1 ? i.Children.only(null) : null;
56
+ function ri(e) {
57
+ const t = v.forwardRef((n, s) => {
58
+ const { children: i, ...r } = n;
59
+ if (v.isValidElement(i)) {
60
+ const o = ui(i), a = ci(r, i.props);
61
+ return i.type !== v.Fragment && (a.ref = s ? wn(s, o) : o), v.cloneElement(i, a);
62
+ }
63
+ return v.Children.count(i) > 1 ? v.Children.only(null) : null;
65
64
  });
66
65
  return t.displayName = `${e}.SlotClone`, t;
67
66
  }
68
- var se = Symbol("radix.slottable");
69
- function ie(e) {
70
- return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === se;
67
+ var oi = Symbol("radix.slottable");
68
+ function ai(e) {
69
+ return v.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === oi;
71
70
  }
72
- function ae(e, t) {
73
- const r = { ...t };
74
- for (const o in t) {
75
- const n = e[o], s = t[o];
76
- /^on[A-Z]/.test(o) ? n && s ? r[o] = (...a) => {
77
- const f = s(...a);
78
- return n(...a), f;
79
- } : n && (r[o] = n) : o === "style" ? r[o] = { ...n, ...s } : o === "className" && (r[o] = [n, s].filter(Boolean).join(" "));
71
+ function ci(e, t) {
72
+ const n = { ...t };
73
+ for (const s in t) {
74
+ const i = e[s], r = t[s];
75
+ /^on[A-Z]/.test(s) ? i && r ? n[s] = (...a) => {
76
+ const l = r(...a);
77
+ return i(...a), l;
78
+ } : i && (n[s] = i) : s === "style" ? n[s] = { ...i, ...r } : s === "className" && (n[s] = [i, r].filter(Boolean).join(" "));
80
79
  }
81
- return { ...e, ...r };
80
+ return { ...e, ...n };
82
81
  }
83
- function ce(e) {
84
- var o, n;
85
- let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, r = t && "isReactWarning" in t && t.isReactWarning;
86
- return r ? e.ref : (t = (n = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : n.get, r = t && "isReactWarning" in t && t.isReactWarning, r ? e.props.ref : e.props.ref || e.ref);
82
+ function ui(e) {
83
+ var s, i;
84
+ let t = (s = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning;
85
+ return n ? e.ref : (t = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
87
86
  }
88
- var le = [
87
+ var li = [
89
88
  "a",
90
89
  "button",
91
90
  "div",
@@ -103,354 +102,3610 @@ var le = [
103
102
  "span",
104
103
  "svg",
105
104
  "ul"
106
- ], j = le.reduce((e, t) => {
107
- const r = /* @__PURE__ */ re(`Primitive.${t}`), o = i.forwardRef((n, s) => {
108
- const { asChild: l, ...a } = n, f = l ? r : t;
109
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ d(f, { ...a, ref: s });
105
+ ], xn = li.reduce((e, t) => {
106
+ const n = /* @__PURE__ */ ii(`Primitive.${t}`), s = v.forwardRef((i, r) => {
107
+ const { asChild: o, ...a } = i, l = o ? n : t;
108
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ M(l, { ...a, ref: r });
110
109
  });
111
- return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
110
+ return s.displayName = `Primitive.${t}`, { ...e, [t]: s };
112
111
  }, {});
113
- function ue(e, t) {
114
- e && H.flushSync(() => e.dispatchEvent(t));
112
+ function fi(e, t) {
113
+ e && qs.flushSync(() => e.dispatchEvent(t));
115
114
  }
116
- function I(e) {
117
- const t = i.useRef(e);
118
- return i.useEffect(() => {
115
+ function ht(e) {
116
+ const t = v.useRef(e);
117
+ return v.useEffect(() => {
119
118
  t.current = e;
120
- }), i.useMemo(() => (...r) => {
121
- var o;
122
- return (o = t.current) == null ? void 0 : o.call(t, ...r);
119
+ }), v.useMemo(() => (...n) => {
120
+ var s;
121
+ return (s = t.current) == null ? void 0 : s.call(t, ...n);
123
122
  }, []);
124
123
  }
125
- function de(e, t = globalThis == null ? void 0 : globalThis.document) {
126
- const r = I(e);
127
- i.useEffect(() => {
128
- const o = (n) => {
129
- n.key === "Escape" && r(n);
124
+ function di(e, t = globalThis == null ? void 0 : globalThis.document) {
125
+ const n = ht(e);
126
+ v.useEffect(() => {
127
+ const s = (i) => {
128
+ i.key === "Escape" && n(i);
130
129
  };
131
- return t.addEventListener("keydown", o, { capture: !0 }), () => t.removeEventListener("keydown", o, { capture: !0 });
132
- }, [r, t]);
130
+ return t.addEventListener("keydown", s, { capture: !0 }), () => t.removeEventListener("keydown", s, { capture: !0 });
131
+ }, [n, t]);
133
132
  }
134
- var fe = "DismissableLayer", B = "dismissableLayer.update", pe = "dismissableLayer.pointerDownOutside", ye = "dismissableLayer.focusOutside", A, U = i.createContext({
133
+ var hi = "DismissableLayer", He = "dismissableLayer.update", pi = "dismissableLayer.pointerDownOutside", mi = "dismissableLayer.focusOutside", Wt, Vn = v.createContext({
135
134
  layers: /* @__PURE__ */ new Set(),
136
135
  layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
137
136
  branches: /* @__PURE__ */ new Set()
138
- }), z = i.forwardRef(
137
+ }), An = v.forwardRef(
139
138
  (e, t) => {
140
139
  const {
141
- disableOutsidePointerEvents: r = !1,
142
- onEscapeKeyDown: o,
143
- onPointerDownOutside: n,
144
- onFocusOutside: s,
145
- onInteractOutside: l,
140
+ disableOutsidePointerEvents: n = !1,
141
+ onEscapeKeyDown: s,
142
+ onPointerDownOutside: i,
143
+ onFocusOutside: r,
144
+ onInteractOutside: o,
146
145
  onDismiss: a,
147
- ...f
148
- } = e, u = i.useContext(U), [c, y] = i.useState(null), m = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, L] = i.useState({}), b = M(t, (p) => y(p)), C = Array.from(u.layers), [P] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), h = C.indexOf(P), x = c ? C.indexOf(c) : -1, w = u.layersWithOutsidePointerEventsDisabled.size > 0, W = x >= h, Y = ve((p) => {
149
- const R = p.target, k = [...u.branches].some((D) => D.contains(R));
150
- !W || k || (n == null || n(p), l == null || l(p), p.defaultPrevented || a == null || a());
151
- }, m), N = Ee((p) => {
152
- const R = p.target;
153
- [...u.branches].some((D) => D.contains(R)) || (s == null || s(p), l == null || l(p), p.defaultPrevented || a == null || a());
154
- }, m);
155
- return de((p) => {
156
- x === u.layers.size - 1 && (o == null || o(p), !p.defaultPrevented && a && (p.preventDefault(), a()));
157
- }, m), i.useEffect(() => {
146
+ ...l
147
+ } = e, u = v.useContext(Vn), [c, d] = v.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, h] = v.useState({}), g = Sn(t, (x) => d(x)), y = Array.from(u.layers), [T] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), p = y.indexOf(T), V = c ? y.indexOf(c) : -1, m = u.layersWithOutsidePointerEventsDisabled.size > 0, C = V >= p, w = bi((x) => {
148
+ const S = x.target, D = [...u.branches].some((F) => F.contains(S));
149
+ !C || D || (i == null || i(x), o == null || o(x), x.defaultPrevented || a == null || a());
150
+ }, f), A = vi((x) => {
151
+ const S = x.target;
152
+ [...u.branches].some((F) => F.contains(S)) || (r == null || r(x), o == null || o(x), x.defaultPrevented || a == null || a());
153
+ }, f);
154
+ return di((x) => {
155
+ V === u.layers.size - 1 && (s == null || s(x), !x.defaultPrevented && a && (x.preventDefault(), a()));
156
+ }, f), v.useEffect(() => {
158
157
  if (c)
159
- return r && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (A = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), _(), () => {
160
- r && u.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = A);
158
+ return n && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (Wt = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), $t(), () => {
159
+ n && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = Wt);
161
160
  };
162
- }, [c, m, r, u]), i.useEffect(() => () => {
163
- c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), _());
164
- }, [c, u]), i.useEffect(() => {
165
- const p = () => L({});
166
- return document.addEventListener(B, p), () => document.removeEventListener(B, p);
167
- }, []), /* @__PURE__ */ d(
168
- j.div,
161
+ }, [c, f, n, u]), v.useEffect(() => () => {
162
+ c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), $t());
163
+ }, [c, u]), v.useEffect(() => {
164
+ const x = () => h({});
165
+ return document.addEventListener(He, x), () => document.removeEventListener(He, x);
166
+ }, []), /* @__PURE__ */ M(
167
+ xn.div,
169
168
  {
170
- ...f,
171
- ref: b,
169
+ ...l,
170
+ ref: g,
172
171
  style: {
173
- pointerEvents: w ? W ? "auto" : "none" : void 0,
172
+ pointerEvents: m ? C ? "auto" : "none" : void 0,
174
173
  ...e.style
175
174
  },
176
- onFocusCapture: O(e.onFocusCapture, N.onFocusCapture),
177
- onBlurCapture: O(e.onBlurCapture, N.onBlurCapture),
178
- onPointerDownCapture: O(
175
+ onFocusCapture: Ke(e.onFocusCapture, A.onFocusCapture),
176
+ onBlurCapture: Ke(e.onBlurCapture, A.onBlurCapture),
177
+ onPointerDownCapture: Ke(
179
178
  e.onPointerDownCapture,
180
- Y.onPointerDownCapture
179
+ w.onPointerDownCapture
181
180
  )
182
181
  }
183
182
  );
184
183
  }
185
184
  );
186
- z.displayName = fe;
187
- var me = "DismissableLayerBranch", he = i.forwardRef((e, t) => {
188
- const r = i.useContext(U), o = i.useRef(null), n = M(t, o);
189
- return i.useEffect(() => {
190
- const s = o.current;
191
- if (s)
192
- return r.branches.add(s), () => {
193
- r.branches.delete(s);
185
+ An.displayName = hi;
186
+ var gi = "DismissableLayerBranch", yi = v.forwardRef((e, t) => {
187
+ const n = v.useContext(Vn), s = v.useRef(null), i = Sn(t, s);
188
+ return v.useEffect(() => {
189
+ const r = s.current;
190
+ if (r)
191
+ return n.branches.add(r), () => {
192
+ n.branches.delete(r);
194
193
  };
195
- }, [r.branches]), /* @__PURE__ */ d(j.div, { ...e, ref: n });
194
+ }, [n.branches]), /* @__PURE__ */ M(xn.div, { ...e, ref: i });
196
195
  });
197
- he.displayName = me;
198
- function ve(e, t = globalThis == null ? void 0 : globalThis.document) {
199
- const r = I(e), o = i.useRef(!1), n = i.useRef(() => {
196
+ yi.displayName = gi;
197
+ function bi(e, t = globalThis == null ? void 0 : globalThis.document) {
198
+ const n = ht(e), s = v.useRef(!1), i = v.useRef(() => {
200
199
  });
201
- return i.useEffect(() => {
202
- const s = (a) => {
203
- if (a.target && !o.current) {
204
- let f = function() {
205
- V(
206
- pe,
207
- r,
200
+ return v.useEffect(() => {
201
+ const r = (a) => {
202
+ if (a.target && !s.current) {
203
+ let l = function() {
204
+ Cn(
205
+ pi,
206
+ n,
208
207
  u,
209
208
  { discrete: !0 }
210
209
  );
211
210
  };
212
211
  const u = { originalEvent: a };
213
- a.pointerType === "touch" ? (t.removeEventListener("click", n.current), n.current = f, t.addEventListener("click", n.current, { once: !0 })) : f();
212
+ a.pointerType === "touch" ? (t.removeEventListener("click", i.current), i.current = l, t.addEventListener("click", i.current, { once: !0 })) : l();
214
213
  } else
215
- t.removeEventListener("click", n.current);
216
- o.current = !1;
217
- }, l = window.setTimeout(() => {
218
- t.addEventListener("pointerdown", s);
214
+ t.removeEventListener("click", i.current);
215
+ s.current = !1;
216
+ }, o = window.setTimeout(() => {
217
+ t.addEventListener("pointerdown", r);
219
218
  }, 0);
220
219
  return () => {
221
- window.clearTimeout(l), t.removeEventListener("pointerdown", s), t.removeEventListener("click", n.current);
220
+ window.clearTimeout(o), t.removeEventListener("pointerdown", r), t.removeEventListener("click", i.current);
222
221
  };
223
- }, [t, r]), {
222
+ }, [t, n]), {
224
223
  // ensures we check React component tree (not just DOM tree)
225
- onPointerDownCapture: () => o.current = !0
224
+ onPointerDownCapture: () => s.current = !0
226
225
  };
227
226
  }
228
- function Ee(e, t = globalThis == null ? void 0 : globalThis.document) {
229
- const r = I(e), o = i.useRef(!1);
230
- return i.useEffect(() => {
231
- const n = (s) => {
232
- s.target && !o.current && V(ye, r, { originalEvent: s }, {
227
+ function vi(e, t = globalThis == null ? void 0 : globalThis.document) {
228
+ const n = ht(e), s = v.useRef(!1);
229
+ return v.useEffect(() => {
230
+ const i = (r) => {
231
+ r.target && !s.current && Cn(mi, n, { originalEvent: r }, {
233
232
  discrete: !1
234
233
  });
235
234
  };
236
- return t.addEventListener("focusin", n), () => t.removeEventListener("focusin", n);
237
- }, [t, r]), {
238
- onFocusCapture: () => o.current = !0,
239
- onBlurCapture: () => o.current = !1
235
+ return t.addEventListener("focusin", i), () => t.removeEventListener("focusin", i);
236
+ }, [t, n]), {
237
+ onFocusCapture: () => s.current = !0,
238
+ onBlurCapture: () => s.current = !1
240
239
  };
241
240
  }
242
- function _() {
243
- const e = new CustomEvent(B);
241
+ function $t() {
242
+ const e = new CustomEvent(He);
244
243
  document.dispatchEvent(e);
245
244
  }
246
- function V(e, t, r, { discrete: o }) {
247
- const n = r.originalEvent.target, s = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: r });
248
- t && n.addEventListener(e, t, { once: !0 }), o ? ue(n, s) : n.dispatchEvent(s);
245
+ function Cn(e, t, n, { discrete: s }) {
246
+ const i = n.originalEvent.target, r = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
247
+ t && i.addEventListener(e, t, { once: !0 }), s ? fi(i, r) : i.dispatchEvent(r);
249
248
  }
250
- var ge = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
251
- }, be = i[" useInsertionEffect ".trim().toString()] || ge;
252
- function Ce({
249
+ var Ti = globalThis != null && globalThis.document ? v.useLayoutEffect : () => {
250
+ }, wi = v[" useInsertionEffect ".trim().toString()] || Ti;
251
+ function Si({
253
252
  prop: e,
254
253
  defaultProp: t,
255
- onChange: r = () => {
254
+ onChange: n = () => {
256
255
  },
257
- caller: o
256
+ caller: s
258
257
  }) {
259
- const [n, s, l] = Le({
258
+ const [i, r, o] = xi({
260
259
  defaultProp: t,
261
- onChange: r
262
- }), a = e !== void 0, f = a ? e : n;
260
+ onChange: n
261
+ }), a = e !== void 0, l = a ? e : i;
263
262
  {
264
- const c = i.useRef(e !== void 0);
265
- i.useEffect(() => {
266
- const y = c.current;
267
- y !== a && console.warn(
268
- `${o} is changing from ${y ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
263
+ const c = v.useRef(e !== void 0);
264
+ v.useEffect(() => {
265
+ const d = c.current;
266
+ d !== a && console.warn(
267
+ `${s} is changing from ${d ? "controlled" : "uncontrolled"} to ${a ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
269
268
  ), c.current = a;
270
- }, [a, o]);
269
+ }, [a, s]);
271
270
  }
272
- const u = i.useCallback(
271
+ const u = v.useCallback(
273
272
  (c) => {
274
- var y;
273
+ var d;
275
274
  if (a) {
276
- const m = Pe(c) ? c(e) : c;
277
- m !== e && ((y = l.current) == null || y.call(l, m));
275
+ const f = Vi(c) ? c(e) : c;
276
+ f !== e && ((d = o.current) == null || d.call(o, f));
278
277
  } else
279
- s(c);
278
+ r(c);
280
279
  },
281
- [a, e, s, l]
280
+ [a, e, r, o]
282
281
  );
283
- return [f, u];
282
+ return [l, u];
284
283
  }
285
- function Le({
284
+ function xi({
286
285
  defaultProp: e,
287
286
  onChange: t
288
287
  }) {
289
- const [r, o] = i.useState(e), n = i.useRef(r), s = i.useRef(t);
290
- return be(() => {
291
- s.current = t;
292
- }, [t]), i.useEffect(() => {
293
- var l;
294
- n.current !== r && ((l = s.current) == null || l.call(s, r), n.current = r);
295
- }, [r, n]), [r, o, s];
296
- }
297
- function Pe(e) {
288
+ const [n, s] = v.useState(e), i = v.useRef(n), r = v.useRef(t);
289
+ return wi(() => {
290
+ r.current = t;
291
+ }, [t]), v.useEffect(() => {
292
+ var o;
293
+ i.current !== n && ((o = r.current) == null || o.call(r, n), i.current = n);
294
+ }, [n, i]), [n, s, r];
295
+ }
296
+ function Vi(e) {
298
297
  return typeof e == "function";
299
298
  }
300
- const K = g.createContext({
301
- layers: [],
302
- setLayers: () => {
303
- },
304
- addLayer: () => {
299
+ const Ai = se({});
300
+ function Ci(e) {
301
+ const t = fe(null);
302
+ return t.current === null && (t.current = e()), t.current;
303
+ }
304
+ const pt = typeof window < "u", Mi = pt ? Us : dt, Mn = /* @__PURE__ */ se(null);
305
+ function Pi(e, t) {
306
+ e.indexOf(t) === -1 && e.push(t);
307
+ }
308
+ function Ei(e, t) {
309
+ const n = e.indexOf(t);
310
+ n > -1 && e.splice(n, 1);
311
+ }
312
+ const H = (e, t, n) => n > t ? t : n < e ? e : n;
313
+ let ye = () => {
314
+ }, Y = () => {
315
+ };
316
+ process.env.NODE_ENV !== "production" && (ye = (e, t) => {
317
+ !e && typeof console < "u" && console.warn(t);
318
+ }, Y = (e, t) => {
319
+ if (!e)
320
+ throw new Error(t);
321
+ });
322
+ const W = {}, Pn = (e) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);
323
+ function Di(e) {
324
+ return typeof e == "object" && e !== null;
325
+ }
326
+ const En = (e) => /^0[^.\s]+$/u.test(e);
327
+ // @__NO_SIDE_EFFECTS__
328
+ function mt(e) {
329
+ let t;
330
+ return () => (t === void 0 && (t = e()), t);
331
+ }
332
+ const ie = /* @__NO_SIDE_EFFECTS__ */ (e) => e, Fi = (e, t) => (n) => t(e(n)), Re = (...e) => e.reduce(Fi), Dn = /* @__NO_SIDE_EFFECTS__ */ (e, t, n) => {
333
+ const s = t - e;
334
+ return s === 0 ? 1 : (n - e) / s;
335
+ };
336
+ class Fn {
337
+ constructor() {
338
+ this.subscriptions = [];
339
+ }
340
+ add(t) {
341
+ return Pi(this.subscriptions, t), () => Ei(this.subscriptions, t);
342
+ }
343
+ notify(t, n, s) {
344
+ const i = this.subscriptions.length;
345
+ if (i)
346
+ if (i === 1)
347
+ this.subscriptions[0](t, n, s);
348
+ else
349
+ for (let r = 0; r < i; r++) {
350
+ const o = this.subscriptions[r];
351
+ o && o(t, n, s);
352
+ }
353
+ }
354
+ getSize() {
355
+ return this.subscriptions.length;
356
+ }
357
+ clear() {
358
+ this.subscriptions.length = 0;
359
+ }
360
+ }
361
+ const N = /* @__NO_SIDE_EFFECTS__ */ (e) => e * 1e3, K = /* @__NO_SIDE_EFFECTS__ */ (e) => e / 1e3;
362
+ function Rn(e, t) {
363
+ return t ? e * (1e3 / t) : 0;
364
+ }
365
+ const _t = /* @__PURE__ */ new Set();
366
+ function On(e, t, n) {
367
+ e || _t.has(t) || (console.warn(t), _t.add(t));
368
+ }
369
+ const Ln = (e, t, n) => (((1 - 3 * n + 3 * t) * e + (3 * n - 6 * t)) * e + 3 * t) * e, Ri = 1e-7, Oi = 12;
370
+ function Li(e, t, n, s, i) {
371
+ let r, o, a = 0;
372
+ do
373
+ o = t + (n - t) / 2, r = Ln(o, s, i) - e, r > 0 ? n = o : t = o;
374
+ while (Math.abs(r) > Ri && ++a < Oi);
375
+ return o;
376
+ }
377
+ function be(e, t, n, s) {
378
+ if (e === t && n === s)
379
+ return ie;
380
+ const i = (r) => Li(r, 0, 1, e, n);
381
+ return (r) => r === 0 || r === 1 ? r : Ln(i(r), t, s);
382
+ }
383
+ const In = (e) => (t) => t <= 0.5 ? e(2 * t) / 2 : (2 - e(2 * (1 - t))) / 2, kn = (e) => (t) => 1 - e(1 - t), Nn = /* @__PURE__ */ be(0.33, 1.53, 0.69, 0.99), gt = /* @__PURE__ */ kn(Nn), Bn = /* @__PURE__ */ In(gt), Kn = (e) => (e *= 2) < 1 ? 0.5 * gt(e) : 0.5 * (2 - Math.pow(2, -10 * (e - 1))), yt = (e) => 1 - Math.sin(Math.acos(e)), Ii = kn(yt), Wn = In(yt), ki = /* @__PURE__ */ be(0.42, 0, 1, 1), Ni = /* @__PURE__ */ be(0, 0, 0.58, 1), $n = /* @__PURE__ */ be(0.42, 0, 0.58, 1), Bi = (e) => Array.isArray(e) && typeof e[0] != "number", _n = (e) => Array.isArray(e) && typeof e[0] == "number", jt = {
384
+ linear: ie,
385
+ easeIn: ki,
386
+ easeInOut: $n,
387
+ easeOut: Ni,
388
+ circIn: yt,
389
+ circInOut: Wn,
390
+ circOut: Ii,
391
+ backIn: gt,
392
+ backInOut: Bn,
393
+ backOut: Nn,
394
+ anticipate: Kn
395
+ }, Ki = (e) => typeof e == "string", Ut = (e) => {
396
+ if (_n(e)) {
397
+ Y(e.length === 4, "Cubic bezier arrays must contain four numerical values.");
398
+ const [t, n, s, i] = e;
399
+ return be(t, n, s, i);
400
+ } else if (Ki(e))
401
+ return Y(jt[e] !== void 0, `Invalid easing type '${e}'`), jt[e];
402
+ return e;
403
+ }, Te = [
404
+ "setup",
405
+ // Compute
406
+ "read",
407
+ // Read
408
+ "resolveKeyframes",
409
+ // Write/Read/Write/Read
410
+ "preUpdate",
411
+ // Compute
412
+ "update",
413
+ // Compute
414
+ "preRender",
415
+ // Compute
416
+ "render",
417
+ // Write
418
+ "postRender"
419
+ // Compute
420
+ ];
421
+ function Wi(e, t) {
422
+ let n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = !1, r = !1;
423
+ const o = /* @__PURE__ */ new WeakSet();
424
+ let a = {
425
+ delta: 0,
426
+ timestamp: 0,
427
+ isProcessing: !1
428
+ };
429
+ function l(c) {
430
+ o.has(c) && (u.schedule(c), e()), c(a);
431
+ }
432
+ const u = {
433
+ /**
434
+ * Schedule a process to run on the next frame.
435
+ */
436
+ schedule: (c, d = !1, f = !1) => {
437
+ const g = f && i ? n : s;
438
+ return d && o.add(c), g.has(c) || g.add(c), c;
439
+ },
440
+ /**
441
+ * Cancel the provided callback from running on the next frame.
442
+ */
443
+ cancel: (c) => {
444
+ s.delete(c), o.delete(c);
445
+ },
446
+ /**
447
+ * Execute all schedule callbacks.
448
+ */
449
+ process: (c) => {
450
+ if (a = c, i) {
451
+ r = !0;
452
+ return;
453
+ }
454
+ i = !0, [n, s] = [s, n], n.forEach(l), n.clear(), i = !1, r && (r = !1, u.process(c));
455
+ }
456
+ };
457
+ return u;
458
+ }
459
+ const $i = 40;
460
+ function jn(e, t) {
461
+ let n = !1, s = !0;
462
+ const i = {
463
+ delta: 0,
464
+ timestamp: 0,
465
+ isProcessing: !1
466
+ }, r = () => n = !0, o = Te.reduce((m, C) => (m[C] = Wi(r), m), {}), { setup: a, read: l, resolveKeyframes: u, preUpdate: c, update: d, preRender: f, render: h, postRender: g } = o, y = () => {
467
+ const m = W.useManualTiming ? i.timestamp : performance.now();
468
+ n = !1, W.useManualTiming || (i.delta = s ? 1e3 / 60 : Math.max(Math.min(m - i.timestamp, $i), 1)), i.timestamp = m, i.isProcessing = !0, a.process(i), l.process(i), u.process(i), c.process(i), d.process(i), f.process(i), h.process(i), g.process(i), i.isProcessing = !1, n && t && (s = !1, e(y));
469
+ }, T = () => {
470
+ n = !0, s = !0, i.isProcessing || e(y);
471
+ };
472
+ return { schedule: Te.reduce((m, C) => {
473
+ const w = o[C];
474
+ return m[C] = (A, x = !1, S = !1) => (n || T(), w.schedule(A, x, S)), m;
475
+ }, {}), cancel: (m) => {
476
+ for (let C = 0; C < Te.length; C++)
477
+ o[Te[C]].cancel(m);
478
+ }, state: i, steps: o };
479
+ }
480
+ const { schedule: k, cancel: Ye, state: Ae } = /* @__PURE__ */ jn(typeof requestAnimationFrame < "u" ? requestAnimationFrame : ie, !0);
481
+ let Se;
482
+ function _i() {
483
+ Se = void 0;
484
+ }
485
+ const L = {
486
+ now: () => (Se === void 0 && L.set(Ae.isProcessing || W.useManualTiming ? Ae.timestamp : performance.now()), Se),
487
+ set: (e) => {
488
+ Se = e, queueMicrotask(_i);
489
+ }
490
+ }, Un = (e) => (t) => typeof t == "string" && t.startsWith(e), Gn = /* @__PURE__ */ Un("--"), ji = /* @__PURE__ */ Un("var(--"), bt = (e) => ji(e) ? Ui.test(e.split("/*")[0].trim()) : !1, Ui = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, re = {
491
+ test: (e) => typeof e == "number",
492
+ parse: parseFloat,
493
+ transform: (e) => e
494
+ }, he = {
495
+ ...re,
496
+ transform: (e) => H(0, 1, e)
497
+ }, we = {
498
+ ...re,
499
+ default: 1
500
+ }, de = (e) => Math.round(e * 1e5) / 1e5, vt = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
501
+ function Gi(e) {
502
+ return e == null;
503
+ }
504
+ const zi = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, Tt = (e, t) => (n) => !!(typeof n == "string" && zi.test(n) && n.startsWith(e) || t && !Gi(n) && Object.prototype.hasOwnProperty.call(n, t)), zn = (e, t, n) => (s) => {
505
+ if (typeof s != "string")
506
+ return s;
507
+ const [i, r, o, a] = s.match(vt);
508
+ return {
509
+ [e]: parseFloat(i),
510
+ [t]: parseFloat(r),
511
+ [n]: parseFloat(o),
512
+ alpha: a !== void 0 ? parseFloat(a) : 1
513
+ };
514
+ }, Hi = (e) => H(0, 255, e), We = {
515
+ ...re,
516
+ transform: (e) => Math.round(Hi(e))
517
+ }, j = {
518
+ test: /* @__PURE__ */ Tt("rgb", "red"),
519
+ parse: /* @__PURE__ */ zn("red", "green", "blue"),
520
+ transform: ({ red: e, green: t, blue: n, alpha: s = 1 }) => "rgba(" + We.transform(e) + ", " + We.transform(t) + ", " + We.transform(n) + ", " + de(he.transform(s)) + ")"
521
+ };
522
+ function Yi(e) {
523
+ let t = "", n = "", s = "", i = "";
524
+ return e.length > 5 ? (t = e.substring(1, 3), n = e.substring(3, 5), s = e.substring(5, 7), i = e.substring(7, 9)) : (t = e.substring(1, 2), n = e.substring(2, 3), s = e.substring(3, 4), i = e.substring(4, 5), t += t, n += n, s += s, i += i), {
525
+ red: parseInt(t, 16),
526
+ green: parseInt(n, 16),
527
+ blue: parseInt(s, 16),
528
+ alpha: i ? parseInt(i, 16) / 255 : 1
529
+ };
530
+ }
531
+ const Xe = {
532
+ test: /* @__PURE__ */ Tt("#"),
533
+ parse: Yi,
534
+ transform: j.transform
535
+ }, ve = /* @__NO_SIDE_EFFECTS__ */ (e) => ({
536
+ test: (t) => typeof t == "string" && t.endsWith(e) && t.split(" ").length === 1,
537
+ parse: parseFloat,
538
+ transform: (t) => `${t}${e}`
539
+ }), $ = /* @__PURE__ */ ve("deg"), Q = /* @__PURE__ */ ve("%"), b = /* @__PURE__ */ ve("px"), Xi = /* @__PURE__ */ ve("vh"), qi = /* @__PURE__ */ ve("vw"), Gt = {
540
+ ...Q,
541
+ parse: (e) => Q.parse(e) / 100,
542
+ transform: (e) => Q.transform(e * 100)
543
+ }, q = {
544
+ test: /* @__PURE__ */ Tt("hsl", "hue"),
545
+ parse: /* @__PURE__ */ zn("hue", "saturation", "lightness"),
546
+ transform: ({ hue: e, saturation: t, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(e) + ", " + Q.transform(de(t)) + ", " + Q.transform(de(n)) + ", " + de(he.transform(s)) + ")"
547
+ }, E = {
548
+ test: (e) => j.test(e) || Xe.test(e) || q.test(e),
549
+ parse: (e) => j.test(e) ? j.parse(e) : q.test(e) ? q.parse(e) : Xe.parse(e),
550
+ transform: (e) => typeof e == "string" ? e : e.hasOwnProperty("red") ? j.transform(e) : q.transform(e),
551
+ getAnimatableNone: (e) => {
552
+ const t = E.parse(e);
553
+ return t.alpha = 0, E.transform(t);
554
+ }
555
+ }, Zi = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
556
+ function Ji(e) {
557
+ var t, n;
558
+ return isNaN(e) && typeof e == "string" && (((t = e.match(vt)) == null ? void 0 : t.length) || 0) + (((n = e.match(Zi)) == null ? void 0 : n.length) || 0) > 0;
559
+ }
560
+ const Hn = "number", Yn = "color", Qi = "var", er = "var(", zt = "${}", tr = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;
561
+ function pe(e) {
562
+ const t = e.toString(), n = [], s = {
563
+ color: [],
564
+ number: [],
565
+ var: []
566
+ }, i = [];
567
+ let r = 0;
568
+ const a = t.replace(tr, (l) => (E.test(l) ? (s.color.push(r), i.push(Yn), n.push(E.parse(l))) : l.startsWith(er) ? (s.var.push(r), i.push(Qi), n.push(l)) : (s.number.push(r), i.push(Hn), n.push(parseFloat(l))), ++r, zt)).split(zt);
569
+ return { values: n, split: a, indexes: s, types: i };
570
+ }
571
+ function Xn(e) {
572
+ return pe(e).values;
573
+ }
574
+ function qn(e) {
575
+ const { split: t, types: n } = pe(e), s = t.length;
576
+ return (i) => {
577
+ let r = "";
578
+ for (let o = 0; o < s; o++)
579
+ if (r += t[o], i[o] !== void 0) {
580
+ const a = n[o];
581
+ a === Hn ? r += de(i[o]) : a === Yn ? r += E.transform(i[o]) : r += i[o];
582
+ }
583
+ return r;
584
+ };
585
+ }
586
+ const nr = (e) => typeof e == "number" ? 0 : E.test(e) ? E.getAnimatableNone(e) : e;
587
+ function sr(e) {
588
+ const t = Xn(e);
589
+ return qn(e)(t.map(nr));
590
+ }
591
+ const oe = {
592
+ test: Ji,
593
+ parse: Xn,
594
+ createTransformer: qn,
595
+ getAnimatableNone: sr
596
+ };
597
+ function $e(e, t, n) {
598
+ return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e;
599
+ }
600
+ function ir({ hue: e, saturation: t, lightness: n, alpha: s }) {
601
+ e /= 360, t /= 100, n /= 100;
602
+ let i = 0, r = 0, o = 0;
603
+ if (!t)
604
+ i = r = o = n;
605
+ else {
606
+ const a = n < 0.5 ? n * (1 + t) : n + t - n * t, l = 2 * n - a;
607
+ i = $e(l, a, e + 1 / 3), r = $e(l, a, e), o = $e(l, a, e - 1 / 3);
608
+ }
609
+ return {
610
+ red: Math.round(i * 255),
611
+ green: Math.round(r * 255),
612
+ blue: Math.round(o * 255),
613
+ alpha: s
614
+ };
615
+ }
616
+ function Ce(e, t) {
617
+ return (n) => n > 0 ? t : e;
618
+ }
619
+ const Oe = (e, t, n) => e + (t - e) * n, _e = (e, t, n) => {
620
+ const s = e * e, i = n * (t * t - s) + s;
621
+ return i < 0 ? 0 : Math.sqrt(i);
622
+ }, rr = [Xe, j, q], or = (e) => rr.find((t) => t.test(e));
623
+ function Ht(e) {
624
+ const t = or(e);
625
+ if (ye(!!t, `'${e}' is not an animatable color. Use the equivalent color code instead.`), !t)
626
+ return !1;
627
+ let n = t.parse(e);
628
+ return t === q && (n = ir(n)), n;
629
+ }
630
+ const Yt = (e, t) => {
631
+ const n = Ht(e), s = Ht(t);
632
+ if (!n || !s)
633
+ return Ce(e, t);
634
+ const i = { ...n };
635
+ return (r) => (i.red = _e(n.red, s.red, r), i.green = _e(n.green, s.green, r), i.blue = _e(n.blue, s.blue, r), i.alpha = Oe(n.alpha, s.alpha, r), j.transform(i));
636
+ }, qe = /* @__PURE__ */ new Set(["none", "hidden"]);
637
+ function ar(e, t) {
638
+ return qe.has(e) ? (n) => n <= 0 ? e : t : (n) => n >= 1 ? t : e;
639
+ }
640
+ function cr(e, t) {
641
+ return (n) => Oe(e, t, n);
642
+ }
643
+ function wt(e) {
644
+ return typeof e == "number" ? cr : typeof e == "string" ? bt(e) ? Ce : E.test(e) ? Yt : fr : Array.isArray(e) ? Zn : typeof e == "object" ? E.test(e) ? Yt : ur : Ce;
645
+ }
646
+ function Zn(e, t) {
647
+ const n = [...e], s = n.length, i = e.map((r, o) => wt(r)(r, t[o]));
648
+ return (r) => {
649
+ for (let o = 0; o < s; o++)
650
+ n[o] = i[o](r);
651
+ return n;
652
+ };
653
+ }
654
+ function ur(e, t) {
655
+ const n = { ...e, ...t }, s = {};
656
+ for (const i in n)
657
+ e[i] !== void 0 && t[i] !== void 0 && (s[i] = wt(e[i])(e[i], t[i]));
658
+ return (i) => {
659
+ for (const r in s)
660
+ n[r] = s[r](i);
661
+ return n;
662
+ };
663
+ }
664
+ function lr(e, t) {
665
+ const n = [], s = { color: 0, var: 0, number: 0 };
666
+ for (let i = 0; i < t.values.length; i++) {
667
+ const r = t.types[i], o = e.indexes[r][s[r]], a = e.values[o] ?? 0;
668
+ n[i] = a, s[r]++;
669
+ }
670
+ return n;
671
+ }
672
+ const fr = (e, t) => {
673
+ const n = oe.createTransformer(t), s = pe(e), i = pe(t);
674
+ return s.indexes.var.length === i.indexes.var.length && s.indexes.color.length === i.indexes.color.length && s.indexes.number.length >= i.indexes.number.length ? qe.has(e) && !i.values.length || qe.has(t) && !s.values.length ? ar(e, t) : Re(Zn(lr(s, i), i.values), n) : (ye(!0, `Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), Ce(e, t));
675
+ };
676
+ function Jn(e, t, n) {
677
+ return typeof e == "number" && typeof t == "number" && typeof n == "number" ? Oe(e, t, n) : wt(e)(e, t);
678
+ }
679
+ const dr = (e) => {
680
+ const t = ({ timestamp: n }) => e(n);
681
+ return {
682
+ start: (n = !0) => k.update(t, n),
683
+ stop: () => Ye(t),
684
+ /**
685
+ * If we're processing this frame we can use the
686
+ * framelocked timestamp to keep things in sync.
687
+ */
688
+ now: () => Ae.isProcessing ? Ae.timestamp : L.now()
689
+ };
690
+ }, Qn = (e, t, n = 10) => {
691
+ let s = "";
692
+ const i = Math.max(Math.round(t / n), 2);
693
+ for (let r = 0; r < i; r++)
694
+ s += Math.round(e(r / (i - 1)) * 1e4) / 1e4 + ", ";
695
+ return `linear(${s.substring(0, s.length - 2)})`;
696
+ }, Me = 2e4;
697
+ function St(e) {
698
+ let t = 0;
699
+ const n = 50;
700
+ let s = e.next(t);
701
+ for (; !s.done && t < Me; )
702
+ t += n, s = e.next(t);
703
+ return t >= Me ? 1 / 0 : t;
704
+ }
705
+ function hr(e, t = 100, n) {
706
+ const s = n({ ...e, keyframes: [0, t] }), i = Math.min(St(s), Me);
707
+ return {
708
+ type: "keyframes",
709
+ ease: (r) => s.next(i * r).value / t,
710
+ duration: /* @__PURE__ */ K(i)
711
+ };
712
+ }
713
+ const pr = 5;
714
+ function es(e, t, n) {
715
+ const s = Math.max(t - pr, 0);
716
+ return Rn(n - e(s), t - s);
717
+ }
718
+ const P = {
719
+ // Default spring physics
720
+ stiffness: 100,
721
+ damping: 10,
722
+ mass: 1,
723
+ velocity: 0,
724
+ // Default duration/bounce-based options
725
+ duration: 800,
726
+ // in ms
727
+ bounce: 0.3,
728
+ visualDuration: 0.3,
729
+ // in seconds
730
+ // Rest thresholds
731
+ restSpeed: {
732
+ granular: 0.01,
733
+ default: 2
305
734
  },
306
- removeLayer: () => {
735
+ restDelta: {
736
+ granular: 5e-3,
737
+ default: 0.5
307
738
  },
308
- removeTopLayer: () => {
739
+ // Limits
740
+ minDuration: 0.01,
741
+ // in seconds
742
+ maxDuration: 10,
743
+ // in seconds
744
+ minDamping: 0.05,
745
+ maxDamping: 1
746
+ }, je = 1e-3;
747
+ function mr({ duration: e = P.duration, bounce: t = P.bounce, velocity: n = P.velocity, mass: s = P.mass }) {
748
+ let i, r;
749
+ ye(e <= /* @__PURE__ */ N(P.maxDuration), "Spring duration must be 10 seconds or less");
750
+ let o = 1 - t;
751
+ o = H(P.minDamping, P.maxDamping, o), e = H(P.minDuration, P.maxDuration, /* @__PURE__ */ K(e)), o < 1 ? (i = (u) => {
752
+ const c = u * o, d = c * e, f = c - n, h = Ze(u, o), g = Math.exp(-d);
753
+ return je - f / h * g;
754
+ }, r = (u) => {
755
+ const d = u * o * e, f = d * n + n, h = Math.pow(o, 2) * Math.pow(u, 2) * e, g = Math.exp(-d), y = Ze(Math.pow(u, 2), o);
756
+ return (-i(u) + je > 0 ? -1 : 1) * ((f - h) * g) / y;
757
+ }) : (i = (u) => {
758
+ const c = Math.exp(-u * e), d = (u - n) * e + 1;
759
+ return -je + c * d;
760
+ }, r = (u) => {
761
+ const c = Math.exp(-u * e), d = (n - u) * (e * e);
762
+ return c * d;
763
+ });
764
+ const a = 5 / e, l = yr(i, r, a);
765
+ if (e = /* @__PURE__ */ N(e), isNaN(l))
766
+ return {
767
+ stiffness: P.stiffness,
768
+ damping: P.damping,
769
+ duration: e
770
+ };
771
+ {
772
+ const u = Math.pow(l, 2) * s;
773
+ return {
774
+ stiffness: u,
775
+ damping: o * 2 * Math.sqrt(s * u),
776
+ duration: e
777
+ };
309
778
  }
310
- }), je = ({ children: e }) => {
311
- const [t, r] = g.useState([]), o = (l) => {
312
- r((a) => [...a, l]);
313
- }, n = (l) => {
314
- r(t.filter((a) => a !== l));
315
- }, s = () => {
316
- const l = t[t.length - 1];
317
- l && n(l);
318
- };
319
- return /* @__PURE__ */ d(
320
- K.Provider,
321
- {
322
- value: { layers: t, setLayers: r, addLayer: o, removeLayer: n, removeTopLayer: s },
323
- children: e
779
+ }
780
+ const gr = 12;
781
+ function yr(e, t, n) {
782
+ let s = n;
783
+ for (let i = 1; i < gr; i++)
784
+ s = s - e(s) / t(s);
785
+ return s;
786
+ }
787
+ function Ze(e, t) {
788
+ return e * Math.sqrt(1 - t * t);
789
+ }
790
+ const br = ["duration", "bounce"], vr = ["stiffness", "damping", "mass"];
791
+ function Xt(e, t) {
792
+ return t.some((n) => e[n] !== void 0);
793
+ }
794
+ function Tr(e) {
795
+ let t = {
796
+ velocity: P.velocity,
797
+ stiffness: P.stiffness,
798
+ damping: P.damping,
799
+ mass: P.mass,
800
+ isResolvedFromDuration: !1,
801
+ ...e
802
+ };
803
+ if (!Xt(e, vr) && Xt(e, br))
804
+ if (e.visualDuration) {
805
+ const n = e.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * H(0.05, 1, 1 - (e.bounce || 0)) * Math.sqrt(i);
806
+ t = {
807
+ ...t,
808
+ mass: P.mass,
809
+ stiffness: i,
810
+ damping: r
811
+ };
812
+ } else {
813
+ const n = mr(e);
814
+ t = {
815
+ ...t,
816
+ ...n,
817
+ mass: P.mass
818
+ }, t.isResolvedFromDuration = !0;
324
819
  }
325
- );
326
- }, X = () => g.useContext(K), we = ({
327
- defaultOpen: e,
328
- open: t,
329
- onOpenChange: r,
330
- ...o
331
- }) => {
332
- const [n, s] = Ce({
333
- prop: t,
334
- onChange: r,
335
- defaultProp: e ?? !1
336
- }), l = X(), a = o.a11yTitle;
337
- if (g.useEffect(() => {
338
- !n && l.layers.includes(a) && l.removeLayer(a);
339
- }, [a, l, n]), !!n)
340
- return /* @__PURE__ */ d(Re, { open: n, onOpenChange: s, ...o });
341
- }, Re = ({
342
- open: e,
343
- onOpenChange: t,
344
- a11yTitle: r,
345
- a11yDescription: o,
346
- children: n,
347
- // Focus scope props
348
- trapped: s,
349
- onMountAutoFocus: l,
350
- onUnmountAutoFocus: a,
351
- ...f
352
- }) => {
353
- var C, P;
354
- const u = r, c = X();
355
- g.useEffect(() => {
356
- !c || !e || c.layers.includes(u) || c.addLayer(u);
357
- }, [u, c, e]);
358
- const y = ((C = c.layers) == null ? void 0 : C.indexOf(u)) || 0, m = ((P = c.layers) == null ? void 0 : P.length) || 0, L = y !== 0, b = u === c.layers[c.layers.length - 1];
359
- return /* @__PURE__ */ d(
360
- z,
361
- {
362
- onEscapeKeyDown: (h) => {
363
- b && (h.preventDefault(), c.removeTopLayer(), t(!1));
364
- },
365
- onPointerDownOutside: (h) => {
366
- b && (h.preventDefault(), c.removeTopLayer(), t(!1));
367
- },
368
- children: /* @__PURE__ */ S(
369
- v.Root,
370
- {
371
- open: e,
372
- onOpenChange: (h) => {
373
- var w;
374
- if (((w = c == null ? void 0 : c.layers) == null ? void 0 : w.length) > 0)
375
- return h === !1 && u === c.layers[c.layers.length - 1] ? (c.removeLayer(u), t(!1)) : void 0;
376
- t(h);
377
- },
378
- children: [
379
- /* @__PURE__ */ S(G.Root, { children: [
380
- /* @__PURE__ */ d(v.Title, { children: r }),
381
- o && /* @__PURE__ */ d(v.Description, { children: o })
382
- ] }),
383
- /* @__PURE__ */ d(ne, { children: e && // We add the className "tgph" here so that styles within
384
- // the portal get scoped properly to telegraph
385
- /* @__PURE__ */ d(q.Root, { className: "tgph", children: /* @__PURE__ */ d(xe, { layer: y, children: /* @__PURE__ */ d(
386
- Z,
387
- {
388
- trapped: typeof s == "boolean" ? s : b,
389
- onMountAutoFocus: l,
390
- onUnmountAutoFocus: a,
391
- asChild: !0,
392
- children: /* @__PURE__ */ d(Q, { children: /* @__PURE__ */ d(
393
- E,
394
- {
395
- as: T.div,
396
- initial: {
397
- top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${m - 1})`
398
- },
399
- animate: {
400
- top: L ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${y} )` : "var(--tgph-spacing-16)"
401
- },
402
- exit: { top: 0 },
403
- transition: { type: "spring", duration: 0.3, bounce: 0 },
404
- w: "full",
405
- justify: "center",
406
- style: {
407
- position: "fixed",
408
- left: 0,
409
- maxHeight: "calc(100vh - var(--tgph-spacing-32))",
410
- maxWidth: "calc(100vw - var(--tgph-spacing-8))",
411
- zIndex: `calc(var(--tgph-zIndex-modal) + ${y})`
412
- },
413
- children: /* @__PURE__ */ d(
414
- E,
415
- {
416
- direction: "column",
417
- as: T.div,
418
- animate: {
419
- scale: 1.02 - Math.abs(m - y) * 0.02,
420
- transformOrigin: "center center"
421
- },
422
- transition: {
423
- duration: 0.2,
424
- bounce: 0,
425
- type: "spring"
426
- },
427
- maxW: f.maxW ?? "160",
428
- w: f.w ?? "full",
429
- bg: "surface-1",
430
- border: "px",
431
- rounded: "4",
432
- shadow: "3",
433
- ...f,
434
- children: n
435
- },
436
- `content-${u}`
437
- )
438
- },
439
- `container-${u}`
440
- ) })
441
- }
442
- ) }) }) })
443
- ]
444
- },
445
- u
446
- )
820
+ return t;
821
+ }
822
+ function Pe(e = P.visualDuration, t = P.bounce) {
823
+ const n = typeof e != "object" ? {
824
+ visualDuration: e,
825
+ keyframes: [0, 1],
826
+ bounce: t
827
+ } : e;
828
+ let { restSpeed: s, restDelta: i } = n;
829
+ const r = n.keyframes[0], o = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: r }, { stiffness: l, damping: u, mass: c, duration: d, velocity: f, isResolvedFromDuration: h } = Tr({
830
+ ...n,
831
+ velocity: -/* @__PURE__ */ K(n.velocity || 0)
832
+ }), g = f || 0, y = u / (2 * Math.sqrt(l * c)), T = o - r, p = /* @__PURE__ */ K(Math.sqrt(l / c)), V = Math.abs(T) < 5;
833
+ s || (s = V ? P.restSpeed.granular : P.restSpeed.default), i || (i = V ? P.restDelta.granular : P.restDelta.default);
834
+ let m;
835
+ if (y < 1) {
836
+ const w = Ze(p, y);
837
+ m = (A) => {
838
+ const x = Math.exp(-y * p * A);
839
+ return o - x * ((g + y * p * T) / w * Math.sin(w * A) + T * Math.cos(w * A));
840
+ };
841
+ } else if (y === 1)
842
+ m = (w) => o - Math.exp(-p * w) * (T + (g + p * T) * w);
843
+ else {
844
+ const w = p * Math.sqrt(y * y - 1);
845
+ m = (A) => {
846
+ const x = Math.exp(-y * p * A), S = Math.min(w * A, 300);
847
+ return o - x * ((g + y * p * T) * Math.sinh(S) + w * T * Math.cosh(S)) / w;
848
+ };
849
+ }
850
+ const C = {
851
+ calculatedDuration: h && d || null,
852
+ next: (w) => {
853
+ const A = m(w);
854
+ if (h)
855
+ a.done = w >= d;
856
+ else {
857
+ let x = w === 0 ? g : 0;
858
+ y < 1 && (x = w === 0 ? /* @__PURE__ */ N(g) : es(m, w, A));
859
+ const S = Math.abs(x) <= s, D = Math.abs(o - A) <= i;
860
+ a.done = S && D;
861
+ }
862
+ return a.value = a.done ? o : A, a;
863
+ },
864
+ toString: () => {
865
+ const w = Math.min(St(C), Me), A = Qn((x) => C.next(w * x).value, w, 30);
866
+ return w + "ms " + A;
867
+ },
868
+ toTransition: () => {
447
869
  }
448
- );
449
- }, xe = ({ layer: e, children: t }) => e > 0 ? t : /* @__PURE__ */ S(v.Overlay, { children: [
450
- /* @__PURE__ */ d(
451
- te,
870
+ };
871
+ return C;
872
+ }
873
+ Pe.applyToOptions = (e) => {
874
+ const t = hr(e, 100, Pe);
875
+ return e.ease = t.ease, e.duration = /* @__PURE__ */ N(t.duration), e.type = "keyframes", e;
876
+ };
877
+ function Je({ keyframes: e, velocity: t = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: r = 500, modifyTarget: o, min: a, max: l, restDelta: u = 0.5, restSpeed: c }) {
878
+ const d = e[0], f = {
879
+ done: !1,
880
+ value: d
881
+ }, h = (S) => a !== void 0 && S < a || l !== void 0 && S > l, g = (S) => a === void 0 ? l : l === void 0 || Math.abs(a - S) < Math.abs(l - S) ? a : l;
882
+ let y = n * t;
883
+ const T = d + y, p = o === void 0 ? T : o(T);
884
+ p !== T && (y = p - d);
885
+ const V = (S) => -y * Math.exp(-S / s), m = (S) => p + V(S), C = (S) => {
886
+ const D = V(S), F = m(S);
887
+ f.done = Math.abs(D) <= u, f.value = f.done ? p : F;
888
+ };
889
+ let w, A;
890
+ const x = (S) => {
891
+ h(f.value) && (w = S, A = Pe({
892
+ keyframes: [f.value, g(f.value)],
893
+ velocity: es(m, S, f.value),
894
+ // TODO: This should be passing * 1000
895
+ damping: i,
896
+ stiffness: r,
897
+ restDelta: u,
898
+ restSpeed: c
899
+ }));
900
+ };
901
+ return x(0), {
902
+ calculatedDuration: null,
903
+ next: (S) => {
904
+ let D = !1;
905
+ return !A && w === void 0 && (D = !0, C(S), x(S)), w !== void 0 && S >= w ? A.next(S - w) : (!D && C(S), f);
906
+ }
907
+ };
908
+ }
909
+ function wr(e, t, n) {
910
+ const s = [], i = n || W.mix || Jn, r = e.length - 1;
911
+ for (let o = 0; o < r; o++) {
912
+ let a = i(e[o], e[o + 1]);
913
+ if (t) {
914
+ const l = Array.isArray(t) ? t[o] || ie : t;
915
+ a = Re(l, a);
916
+ }
917
+ s.push(a);
918
+ }
919
+ return s;
920
+ }
921
+ function Sr(e, t, { clamp: n = !0, ease: s, mixer: i } = {}) {
922
+ const r = e.length;
923
+ if (Y(r === t.length, "Both input and output ranges must be the same length"), r === 1)
924
+ return () => t[0];
925
+ if (r === 2 && t[0] === t[1])
926
+ return () => t[1];
927
+ const o = e[0] === e[1];
928
+ e[0] > e[r - 1] && (e = [...e].reverse(), t = [...t].reverse());
929
+ const a = wr(t, s, i), l = a.length, u = (c) => {
930
+ if (o && c < e[0])
931
+ return t[0];
932
+ let d = 0;
933
+ if (l > 1)
934
+ for (; d < e.length - 2 && !(c < e[d + 1]); d++)
935
+ ;
936
+ const f = /* @__PURE__ */ Dn(e[d], e[d + 1], c);
937
+ return a[d](f);
938
+ };
939
+ return n ? (c) => u(H(e[0], e[r - 1], c)) : u;
940
+ }
941
+ function xr(e, t) {
942
+ const n = e[e.length - 1];
943
+ for (let s = 1; s <= t; s++) {
944
+ const i = /* @__PURE__ */ Dn(0, t, s);
945
+ e.push(Oe(n, 1, i));
946
+ }
947
+ }
948
+ function Vr(e) {
949
+ const t = [0];
950
+ return xr(t, e.length - 1), t;
951
+ }
952
+ function Ar(e, t) {
953
+ return e.map((n) => n * t);
954
+ }
955
+ function Cr(e, t) {
956
+ return e.map(() => t || $n).splice(0, e.length - 1);
957
+ }
958
+ function Z({ duration: e = 300, keyframes: t, times: n, ease: s = "easeInOut" }) {
959
+ const i = Bi(s) ? s.map(Ut) : Ut(s), r = {
960
+ done: !1,
961
+ value: t[0]
962
+ }, o = Ar(
963
+ // Only use the provided offsets if they're the correct length
964
+ // TODO Maybe we should warn here if there's a length mismatch
965
+ n && n.length === t.length ? n : Vr(t),
966
+ e
967
+ ), a = Sr(o, t, {
968
+ ease: Array.isArray(i) ? i : Cr(t, i)
969
+ });
970
+ return {
971
+ calculatedDuration: e,
972
+ next: (l) => (r.value = a(l), r.done = l >= e, r)
973
+ };
974
+ }
975
+ const Mr = (e) => e !== null;
976
+ function xt(e, { repeat: t, repeatType: n = "loop" }, s, i = 1) {
977
+ const r = e.filter(Mr), a = i < 0 || t && n !== "loop" && t % 2 === 1 ? 0 : r.length - 1;
978
+ return !a || s === void 0 ? r[a] : s;
979
+ }
980
+ const Pr = {
981
+ decay: Je,
982
+ inertia: Je,
983
+ tween: Z,
984
+ keyframes: Z,
985
+ spring: Pe
986
+ };
987
+ function ts(e) {
988
+ typeof e.type == "string" && (e.type = Pr[e.type]);
989
+ }
990
+ class Vt {
991
+ constructor() {
992
+ this.updateFinished();
993
+ }
994
+ get finished() {
995
+ return this._finished;
996
+ }
997
+ updateFinished() {
998
+ this._finished = new Promise((t) => {
999
+ this.resolve = t;
1000
+ });
1001
+ }
1002
+ notifyFinished() {
1003
+ this.resolve();
1004
+ }
1005
+ /**
1006
+ * Allows the animation to be awaited.
1007
+ *
1008
+ * @deprecated Use `finished` instead.
1009
+ */
1010
+ then(t, n) {
1011
+ return this.finished.then(t, n);
1012
+ }
1013
+ }
1014
+ const Er = (e) => e / 100;
1015
+ class At extends Vt {
1016
+ constructor(t) {
1017
+ super(), this.state = "idle", this.startTime = null, this.isStopped = !1, this.currentTime = 0, this.holdTime = null, this.playbackSpeed = 1, this.stop = () => {
1018
+ var s, i;
1019
+ const { motionValue: n } = this.options;
1020
+ n && n.updatedAt !== L.now() && this.tick(L.now()), this.isStopped = !0, this.state !== "idle" && (this.teardown(), (i = (s = this.options).onStop) == null || i.call(s));
1021
+ }, this.options = t, this.initAnimation(), this.play(), t.autoplay === !1 && this.pause();
1022
+ }
1023
+ initAnimation() {
1024
+ const { options: t } = this;
1025
+ ts(t);
1026
+ const { type: n = Z, repeat: s = 0, repeatDelay: i = 0, repeatType: r, velocity: o = 0 } = t;
1027
+ let { keyframes: a } = t;
1028
+ const l = n || Z;
1029
+ process.env.NODE_ENV !== "production" && l !== Z && Y(a.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`), l !== Z && typeof a[0] != "number" && (this.mixKeyframes = Re(Er, Jn(a[0], a[1])), a = [0, 100]);
1030
+ const u = l({ ...t, keyframes: a });
1031
+ r === "mirror" && (this.mirroredGenerator = l({
1032
+ ...t,
1033
+ keyframes: [...a].reverse(),
1034
+ velocity: -o
1035
+ })), u.calculatedDuration === null && (u.calculatedDuration = St(u));
1036
+ const { calculatedDuration: c } = u;
1037
+ this.calculatedDuration = c, this.resolvedDuration = c + i, this.totalDuration = this.resolvedDuration * (s + 1) - i, this.generator = u;
1038
+ }
1039
+ updateTime(t) {
1040
+ const n = Math.round(t - this.startTime) * this.playbackSpeed;
1041
+ this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = n;
1042
+ }
1043
+ tick(t, n = !1) {
1044
+ const { generator: s, totalDuration: i, mixKeyframes: r, mirroredGenerator: o, resolvedDuration: a, calculatedDuration: l } = this;
1045
+ if (this.startTime === null)
1046
+ return s.next(0);
1047
+ const { delay: u = 0, keyframes: c, repeat: d, repeatType: f, repeatDelay: h, type: g, onUpdate: y, finalKeyframe: T } = this.options;
1048
+ this.speed > 0 ? this.startTime = Math.min(this.startTime, t) : this.speed < 0 && (this.startTime = Math.min(t - i / this.speed, this.startTime)), n ? this.currentTime = t : this.updateTime(t);
1049
+ const p = this.currentTime - u * (this.playbackSpeed >= 0 ? 1 : -1), V = this.playbackSpeed >= 0 ? p < 0 : p > i;
1050
+ this.currentTime = Math.max(p, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = i);
1051
+ let m = this.currentTime, C = s;
1052
+ if (d) {
1053
+ const S = Math.min(this.currentTime, i) / a;
1054
+ let D = Math.floor(S), F = S % 1;
1055
+ !F && S >= 1 && (F = 1), F === 1 && D--, D = Math.min(D, d + 1), !!(D % 2) && (f === "reverse" ? (F = 1 - F, h && (F -= h / a)) : f === "mirror" && (C = o)), m = H(0, 1, F) * a;
1056
+ }
1057
+ const w = V ? { done: !1, value: c[0] } : C.next(m);
1058
+ r && (w.value = r(w.value));
1059
+ let { done: A } = w;
1060
+ !V && l !== null && (A = this.playbackSpeed >= 0 ? this.currentTime >= i : this.currentTime <= 0);
1061
+ const x = this.holdTime === null && (this.state === "finished" || this.state === "running" && A);
1062
+ return x && g !== Je && (w.value = xt(c, this.options, T, this.speed)), y && y(w.value), x && this.finish(), w;
1063
+ }
1064
+ /**
1065
+ * Allows the returned animation to be awaited or promise-chained. Currently
1066
+ * resolves when the animation finishes at all but in a future update could/should
1067
+ * reject if its cancels.
1068
+ */
1069
+ then(t, n) {
1070
+ return this.finished.then(t, n);
1071
+ }
1072
+ get duration() {
1073
+ return /* @__PURE__ */ K(this.calculatedDuration);
1074
+ }
1075
+ get time() {
1076
+ return /* @__PURE__ */ K(this.currentTime);
1077
+ }
1078
+ set time(t) {
1079
+ var n;
1080
+ t = /* @__PURE__ */ N(t), this.currentTime = t, this.startTime === null || this.holdTime !== null || this.playbackSpeed === 0 ? this.holdTime = t : this.driver && (this.startTime = this.driver.now() - t / this.playbackSpeed), (n = this.driver) == null || n.start(!1);
1081
+ }
1082
+ get speed() {
1083
+ return this.playbackSpeed;
1084
+ }
1085
+ set speed(t) {
1086
+ this.updateTime(L.now());
1087
+ const n = this.playbackSpeed !== t;
1088
+ this.playbackSpeed = t, n && (this.time = /* @__PURE__ */ K(this.currentTime));
1089
+ }
1090
+ play() {
1091
+ var i, r;
1092
+ if (this.isStopped)
1093
+ return;
1094
+ const { driver: t = dr, startTime: n } = this.options;
1095
+ this.driver || (this.driver = t((o) => this.tick(o))), (r = (i = this.options).onPlay) == null || r.call(i);
1096
+ const s = this.driver.now();
1097
+ this.state === "finished" ? (this.updateFinished(), this.startTime = s) : this.holdTime !== null ? this.startTime = s - this.holdTime : this.startTime || (this.startTime = n ?? s), this.state === "finished" && this.speed < 0 && (this.startTime += this.calculatedDuration), this.holdTime = null, this.state = "running", this.driver.start();
1098
+ }
1099
+ pause() {
1100
+ this.state = "paused", this.updateTime(L.now()), this.holdTime = this.currentTime;
1101
+ }
1102
+ complete() {
1103
+ this.state !== "running" && this.play(), this.state = "finished", this.holdTime = null;
1104
+ }
1105
+ finish() {
1106
+ var t, n;
1107
+ this.notifyFinished(), this.teardown(), this.state = "finished", (n = (t = this.options).onComplete) == null || n.call(t);
1108
+ }
1109
+ cancel() {
1110
+ var t, n;
1111
+ this.holdTime = null, this.startTime = 0, this.tick(0), this.teardown(), (n = (t = this.options).onCancel) == null || n.call(t);
1112
+ }
1113
+ teardown() {
1114
+ this.state = "idle", this.stopDriver(), this.startTime = this.holdTime = null;
1115
+ }
1116
+ stopDriver() {
1117
+ this.driver && (this.driver.stop(), this.driver = void 0);
1118
+ }
1119
+ sample(t) {
1120
+ return this.startTime = 0, this.tick(t, !0);
1121
+ }
1122
+ attachTimeline(t) {
1123
+ var n;
1124
+ return this.options.allowFlatten && (this.options.type = "keyframes", this.options.ease = "linear", this.initAnimation()), (n = this.driver) == null || n.stop(), t.observe(this);
1125
+ }
1126
+ }
1127
+ function Dr(e) {
1128
+ for (let t = 1; t < e.length; t++)
1129
+ e[t] ?? (e[t] = e[t - 1]);
1130
+ }
1131
+ const U = (e) => e * 180 / Math.PI, Qe = (e) => {
1132
+ const t = U(Math.atan2(e[1], e[0]));
1133
+ return et(t);
1134
+ }, Fr = {
1135
+ x: 4,
1136
+ y: 5,
1137
+ translateX: 4,
1138
+ translateY: 5,
1139
+ scaleX: 0,
1140
+ scaleY: 3,
1141
+ scale: (e) => (Math.abs(e[0]) + Math.abs(e[3])) / 2,
1142
+ rotate: Qe,
1143
+ rotateZ: Qe,
1144
+ skewX: (e) => U(Math.atan(e[1])),
1145
+ skewY: (e) => U(Math.atan(e[2])),
1146
+ skew: (e) => (Math.abs(e[1]) + Math.abs(e[2])) / 2
1147
+ }, et = (e) => (e = e % 360, e < 0 && (e += 360), e), qt = Qe, Zt = (e) => Math.sqrt(e[0] * e[0] + e[1] * e[1]), Jt = (e) => Math.sqrt(e[4] * e[4] + e[5] * e[5]), Rr = {
1148
+ x: 12,
1149
+ y: 13,
1150
+ z: 14,
1151
+ translateX: 12,
1152
+ translateY: 13,
1153
+ translateZ: 14,
1154
+ scaleX: Zt,
1155
+ scaleY: Jt,
1156
+ scale: (e) => (Zt(e) + Jt(e)) / 2,
1157
+ rotateX: (e) => et(U(Math.atan2(e[6], e[5]))),
1158
+ rotateY: (e) => et(U(Math.atan2(-e[2], e[0]))),
1159
+ rotateZ: qt,
1160
+ rotate: qt,
1161
+ skewX: (e) => U(Math.atan(e[4])),
1162
+ skewY: (e) => U(Math.atan(e[1])),
1163
+ skew: (e) => (Math.abs(e[1]) + Math.abs(e[4])) / 2
1164
+ };
1165
+ function tt(e) {
1166
+ return e.includes("scale") ? 1 : 0;
1167
+ }
1168
+ function nt(e, t) {
1169
+ if (!e || e === "none")
1170
+ return tt(t);
1171
+ const n = e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
1172
+ let s, i;
1173
+ if (n)
1174
+ s = Rr, i = n;
1175
+ else {
1176
+ const a = e.match(/^matrix\(([-\d.e\s,]+)\)$/u);
1177
+ s = Fr, i = a;
1178
+ }
1179
+ if (!i)
1180
+ return tt(t);
1181
+ const r = s[t], o = i[1].split(",").map(Lr);
1182
+ return typeof r == "function" ? r(o) : o[r];
1183
+ }
1184
+ const Or = (e, t) => {
1185
+ const { transform: n = "none" } = getComputedStyle(e);
1186
+ return nt(n, t);
1187
+ };
1188
+ function Lr(e) {
1189
+ return parseFloat(e.trim());
1190
+ }
1191
+ const ae = [
1192
+ "transformPerspective",
1193
+ "x",
1194
+ "y",
1195
+ "z",
1196
+ "translateX",
1197
+ "translateY",
1198
+ "translateZ",
1199
+ "scale",
1200
+ "scaleX",
1201
+ "scaleY",
1202
+ "rotate",
1203
+ "rotateX",
1204
+ "rotateY",
1205
+ "rotateZ",
1206
+ "skew",
1207
+ "skewX",
1208
+ "skewY"
1209
+ ], ce = new Set(ae), Qt = (e) => e === re || e === b, Ir = /* @__PURE__ */ new Set(["x", "y", "z"]), kr = ae.filter((e) => !Ir.has(e));
1210
+ function Nr(e) {
1211
+ const t = [];
1212
+ return kr.forEach((n) => {
1213
+ const s = e.getValue(n);
1214
+ s !== void 0 && (t.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
1215
+ }), t;
1216
+ }
1217
+ const G = {
1218
+ // Dimensions
1219
+ width: ({ x: e }, { paddingLeft: t = "0", paddingRight: n = "0" }) => e.max - e.min - parseFloat(t) - parseFloat(n),
1220
+ height: ({ y: e }, { paddingTop: t = "0", paddingBottom: n = "0" }) => e.max - e.min - parseFloat(t) - parseFloat(n),
1221
+ top: (e, { top: t }) => parseFloat(t),
1222
+ left: (e, { left: t }) => parseFloat(t),
1223
+ bottom: ({ y: e }, { top: t }) => parseFloat(t) + (e.max - e.min),
1224
+ right: ({ x: e }, { left: t }) => parseFloat(t) + (e.max - e.min),
1225
+ // Transform
1226
+ x: (e, { transform: t }) => nt(t, "x"),
1227
+ y: (e, { transform: t }) => nt(t, "y")
1228
+ };
1229
+ G.translateX = G.x;
1230
+ G.translateY = G.y;
1231
+ const z = /* @__PURE__ */ new Set();
1232
+ let st = !1, it = !1, rt = !1;
1233
+ function ns() {
1234
+ if (it) {
1235
+ const e = Array.from(z).filter((s) => s.needsMeasurement), t = new Set(e.map((s) => s.element)), n = /* @__PURE__ */ new Map();
1236
+ t.forEach((s) => {
1237
+ const i = Nr(s);
1238
+ i.length && (n.set(s, i), s.render());
1239
+ }), e.forEach((s) => s.measureInitialState()), t.forEach((s) => {
1240
+ s.render();
1241
+ const i = n.get(s);
1242
+ i && i.forEach(([r, o]) => {
1243
+ var a;
1244
+ (a = s.getValue(r)) == null || a.set(o);
1245
+ });
1246
+ }), e.forEach((s) => s.measureEndState()), e.forEach((s) => {
1247
+ s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
1248
+ });
1249
+ }
1250
+ it = !1, st = !1, z.forEach((e) => e.complete(rt)), z.clear();
1251
+ }
1252
+ function ss() {
1253
+ z.forEach((e) => {
1254
+ e.readKeyframes(), e.needsMeasurement && (it = !0);
1255
+ });
1256
+ }
1257
+ function Br() {
1258
+ rt = !0, ss(), ns(), rt = !1;
1259
+ }
1260
+ class Ct {
1261
+ constructor(t, n, s, i, r, o = !1) {
1262
+ this.state = "pending", this.isAsync = !1, this.needsMeasurement = !1, this.unresolvedKeyframes = [...t], this.onComplete = n, this.name = s, this.motionValue = i, this.element = r, this.isAsync = o;
1263
+ }
1264
+ scheduleResolve() {
1265
+ this.state = "scheduled", this.isAsync ? (z.add(this), st || (st = !0, k.read(ss), k.resolveKeyframes(ns))) : (this.readKeyframes(), this.complete());
1266
+ }
1267
+ readKeyframes() {
1268
+ const { unresolvedKeyframes: t, name: n, element: s, motionValue: i } = this;
1269
+ if (t[0] === null) {
1270
+ const r = i == null ? void 0 : i.get(), o = t[t.length - 1];
1271
+ if (r !== void 0)
1272
+ t[0] = r;
1273
+ else if (s && n) {
1274
+ const a = s.readValue(n, o);
1275
+ a != null && (t[0] = a);
1276
+ }
1277
+ t[0] === void 0 && (t[0] = o), i && r === void 0 && i.set(t[0]);
1278
+ }
1279
+ Dr(t);
1280
+ }
1281
+ setFinalKeyframe() {
1282
+ }
1283
+ measureInitialState() {
1284
+ }
1285
+ renderEndStyles() {
1286
+ }
1287
+ measureEndState() {
1288
+ }
1289
+ complete(t = !1) {
1290
+ this.state = "complete", this.onComplete(this.unresolvedKeyframes, this.finalKeyframe, t), z.delete(this);
1291
+ }
1292
+ cancel() {
1293
+ this.state === "scheduled" && (z.delete(this), this.state = "pending");
1294
+ }
1295
+ resume() {
1296
+ this.state === "pending" && this.scheduleResolve();
1297
+ }
1298
+ }
1299
+ const Kr = (e) => e.startsWith("--");
1300
+ function Wr(e, t, n) {
1301
+ Kr(t) ? e.style.setProperty(t, n) : e.style[t] = n;
1302
+ }
1303
+ const $r = /* @__PURE__ */ mt(() => window.ScrollTimeline !== void 0), _r = {};
1304
+ function jr(e, t) {
1305
+ const n = /* @__PURE__ */ mt(e);
1306
+ return () => _r[t] ?? n();
1307
+ }
1308
+ const is = /* @__PURE__ */ jr(() => {
1309
+ try {
1310
+ document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
1311
+ } catch {
1312
+ return !1;
1313
+ }
1314
+ return !0;
1315
+ }, "linearEasing"), le = ([e, t, n, s]) => `cubic-bezier(${e}, ${t}, ${n}, ${s})`, en = {
1316
+ linear: "linear",
1317
+ ease: "ease",
1318
+ easeIn: "ease-in",
1319
+ easeOut: "ease-out",
1320
+ easeInOut: "ease-in-out",
1321
+ circIn: /* @__PURE__ */ le([0, 0.65, 0.55, 1]),
1322
+ circOut: /* @__PURE__ */ le([0.55, 0, 1, 0.45]),
1323
+ backIn: /* @__PURE__ */ le([0.31, 0.01, 0.66, -0.59]),
1324
+ backOut: /* @__PURE__ */ le([0.33, 1.53, 0.69, 0.99])
1325
+ };
1326
+ function rs(e, t) {
1327
+ if (e)
1328
+ return typeof e == "function" ? is() ? Qn(e, t) : "ease-out" : _n(e) ? le(e) : Array.isArray(e) ? e.map((n) => rs(n, t) || en.easeOut) : en[e];
1329
+ }
1330
+ function Ur(e, t, n, { delay: s = 0, duration: i = 300, repeat: r = 0, repeatType: o = "loop", ease: a = "easeOut", times: l } = {}, u = void 0) {
1331
+ const c = {
1332
+ [t]: n
1333
+ };
1334
+ l && (c.offset = l);
1335
+ const d = rs(a, i);
1336
+ Array.isArray(d) && (c.easing = d);
1337
+ const f = {
1338
+ delay: s,
1339
+ duration: i,
1340
+ easing: Array.isArray(d) ? "linear" : d,
1341
+ fill: "both",
1342
+ iterations: r + 1,
1343
+ direction: o === "reverse" ? "alternate" : "normal"
1344
+ };
1345
+ return u && (f.pseudoElement = u), e.animate(c, f);
1346
+ }
1347
+ function os(e) {
1348
+ return typeof e == "function" && "applyToOptions" in e;
1349
+ }
1350
+ function Gr({ type: e, ...t }) {
1351
+ return os(e) && is() ? e.applyToOptions(t) : (t.duration ?? (t.duration = 300), t.ease ?? (t.ease = "easeOut"), t);
1352
+ }
1353
+ class zr extends Vt {
1354
+ constructor(t) {
1355
+ if (super(), this.finishedTime = null, this.isStopped = !1, !t)
1356
+ return;
1357
+ const { element: n, name: s, keyframes: i, pseudoElement: r, allowFlatten: o = !1, finalKeyframe: a, onComplete: l } = t;
1358
+ this.isPseudoElement = !!r, this.allowFlatten = o, this.options = t, Y(typeof t.type != "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
1359
+ const u = Gr(t);
1360
+ this.animation = Ur(n, s, i, u, r), u.autoplay === !1 && this.animation.pause(), this.animation.onfinish = () => {
1361
+ if (this.finishedTime = this.time, !r) {
1362
+ const c = xt(i, this.options, a, this.speed);
1363
+ this.updateMotionValue ? this.updateMotionValue(c) : Wr(n, s, c), this.animation.cancel();
1364
+ }
1365
+ l == null || l(), this.notifyFinished();
1366
+ };
1367
+ }
1368
+ play() {
1369
+ this.isStopped || (this.animation.play(), this.state === "finished" && this.updateFinished());
1370
+ }
1371
+ pause() {
1372
+ this.animation.pause();
1373
+ }
1374
+ complete() {
1375
+ var t, n;
1376
+ (n = (t = this.animation).finish) == null || n.call(t);
1377
+ }
1378
+ cancel() {
1379
+ try {
1380
+ this.animation.cancel();
1381
+ } catch {
1382
+ }
1383
+ }
1384
+ stop() {
1385
+ if (this.isStopped)
1386
+ return;
1387
+ this.isStopped = !0;
1388
+ const { state: t } = this;
1389
+ t === "idle" || t === "finished" || (this.updateMotionValue ? this.updateMotionValue() : this.commitStyles(), this.isPseudoElement || this.cancel());
1390
+ }
1391
+ /**
1392
+ * WAAPI doesn't natively have any interruption capabilities.
1393
+ *
1394
+ * In this method, we commit styles back to the DOM before cancelling
1395
+ * the animation.
1396
+ *
1397
+ * This is designed to be overridden by NativeAnimationExtended, which
1398
+ * will create a renderless JS animation and sample it twice to calculate
1399
+ * its current value, "previous" value, and therefore allow
1400
+ * Motion to also correctly calculate velocity for any subsequent animation
1401
+ * while deferring the commit until the next animation frame.
1402
+ */
1403
+ commitStyles() {
1404
+ var t, n;
1405
+ this.isPseudoElement || (n = (t = this.animation).commitStyles) == null || n.call(t);
1406
+ }
1407
+ get duration() {
1408
+ var n, s;
1409
+ const t = ((s = (n = this.animation.effect) == null ? void 0 : n.getComputedTiming) == null ? void 0 : s.call(n).duration) || 0;
1410
+ return /* @__PURE__ */ K(Number(t));
1411
+ }
1412
+ get time() {
1413
+ return /* @__PURE__ */ K(Number(this.animation.currentTime) || 0);
1414
+ }
1415
+ set time(t) {
1416
+ this.finishedTime = null, this.animation.currentTime = /* @__PURE__ */ N(t);
1417
+ }
1418
+ /**
1419
+ * The playback speed of the animation.
1420
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1421
+ */
1422
+ get speed() {
1423
+ return this.animation.playbackRate;
1424
+ }
1425
+ set speed(t) {
1426
+ t < 0 && (this.finishedTime = null), this.animation.playbackRate = t;
1427
+ }
1428
+ get state() {
1429
+ return this.finishedTime !== null ? "finished" : this.animation.playState;
1430
+ }
1431
+ get startTime() {
1432
+ return Number(this.animation.startTime);
1433
+ }
1434
+ set startTime(t) {
1435
+ this.animation.startTime = t;
1436
+ }
1437
+ /**
1438
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1439
+ */
1440
+ attachTimeline({ timeline: t, observe: n }) {
1441
+ var s;
1442
+ return this.allowFlatten && ((s = this.animation.effect) == null || s.updateTiming({ easing: "linear" })), this.animation.onfinish = null, t && $r() ? (this.animation.timeline = t, ie) : n(this);
1443
+ }
1444
+ }
1445
+ const as = {
1446
+ anticipate: Kn,
1447
+ backInOut: Bn,
1448
+ circInOut: Wn
1449
+ };
1450
+ function Hr(e) {
1451
+ return e in as;
1452
+ }
1453
+ function Yr(e) {
1454
+ typeof e.ease == "string" && Hr(e.ease) && (e.ease = as[e.ease]);
1455
+ }
1456
+ const tn = 10;
1457
+ class Xr extends zr {
1458
+ constructor(t) {
1459
+ Yr(t), ts(t), super(t), t.startTime && (this.startTime = t.startTime), this.options = t;
1460
+ }
1461
+ /**
1462
+ * WAAPI doesn't natively have any interruption capabilities.
1463
+ *
1464
+ * Rather than read commited styles back out of the DOM, we can
1465
+ * create a renderless JS animation and sample it twice to calculate
1466
+ * its current value, "previous" value, and therefore allow
1467
+ * Motion to calculate velocity for any subsequent animation.
1468
+ */
1469
+ updateMotionValue(t) {
1470
+ const { motionValue: n, onUpdate: s, onComplete: i, element: r, ...o } = this.options;
1471
+ if (!n)
1472
+ return;
1473
+ if (t !== void 0) {
1474
+ n.set(t);
1475
+ return;
1476
+ }
1477
+ const a = new At({
1478
+ ...o,
1479
+ autoplay: !1
1480
+ }), l = /* @__PURE__ */ N(this.finishedTime ?? this.time);
1481
+ n.setWithVelocity(a.sample(l - tn).value, a.sample(l).value, tn), a.stop();
1482
+ }
1483
+ }
1484
+ const nn = (e, t) => t === "zIndex" ? !1 : !!(typeof e == "number" || Array.isArray(e) || typeof e == "string" && // It's animatable if we have a string
1485
+ (oe.test(e) || e === "0") && // And it contains numbers and/or colors
1486
+ !e.startsWith("url("));
1487
+ function qr(e) {
1488
+ const t = e[0];
1489
+ if (e.length === 1)
1490
+ return !0;
1491
+ for (let n = 0; n < e.length; n++)
1492
+ if (e[n] !== t)
1493
+ return !0;
1494
+ }
1495
+ function Zr(e, t, n, s) {
1496
+ const i = e[0];
1497
+ if (i === null)
1498
+ return !1;
1499
+ if (t === "display" || t === "visibility")
1500
+ return !0;
1501
+ const r = e[e.length - 1], o = nn(i, t), a = nn(r, t);
1502
+ return ye(o === a, `You are trying to animate ${t} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`), !o || !a ? !1 : qr(e) || (n === "spring" || os(n)) && s;
1503
+ }
1504
+ function cs(e) {
1505
+ return Di(e) && "offsetHeight" in e;
1506
+ }
1507
+ const Jr = /* @__PURE__ */ new Set([
1508
+ "opacity",
1509
+ "clipPath",
1510
+ "filter",
1511
+ "transform"
1512
+ // TODO: Could be re-enabled now we have support for linear() easing
1513
+ // "background-color"
1514
+ ]), Qr = /* @__PURE__ */ mt(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
1515
+ function eo(e) {
1516
+ var u;
1517
+ const { motionValue: t, name: n, repeatDelay: s, repeatType: i, damping: r, type: o } = e;
1518
+ if (!cs((u = t == null ? void 0 : t.owner) == null ? void 0 : u.current))
1519
+ return !1;
1520
+ const { onUpdate: a, transformTemplate: l } = t.owner.getProps();
1521
+ return Qr() && n && Jr.has(n) && (n !== "transform" || !l) && /**
1522
+ * If we're outputting values to onUpdate then we can't use WAAPI as there's
1523
+ * no way to read the value from WAAPI every frame.
1524
+ */
1525
+ !a && !s && i !== "mirror" && r !== 0 && o !== "inertia";
1526
+ }
1527
+ const to = 40;
1528
+ class no extends Vt {
1529
+ constructor({ autoplay: t = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: r = 0, repeatType: o = "loop", keyframes: a, name: l, motionValue: u, element: c, ...d }) {
1530
+ var g;
1531
+ super(), this.stop = () => {
1532
+ var y, T;
1533
+ this._animation && (this._animation.stop(), (y = this.stopTimeline) == null || y.call(this)), (T = this.keyframeResolver) == null || T.cancel();
1534
+ }, this.createdAt = L.now();
1535
+ const f = {
1536
+ autoplay: t,
1537
+ delay: n,
1538
+ type: s,
1539
+ repeat: i,
1540
+ repeatDelay: r,
1541
+ repeatType: o,
1542
+ name: l,
1543
+ motionValue: u,
1544
+ element: c,
1545
+ ...d
1546
+ }, h = (c == null ? void 0 : c.KeyframeResolver) || Ct;
1547
+ this.keyframeResolver = new h(a, (y, T, p) => this.onKeyframesResolved(y, T, f, !p), l, u, c), (g = this.keyframeResolver) == null || g.scheduleResolve();
1548
+ }
1549
+ onKeyframesResolved(t, n, s, i) {
1550
+ this.keyframeResolver = void 0;
1551
+ const { name: r, type: o, velocity: a, delay: l, isHandoff: u, onUpdate: c } = s;
1552
+ this.resolvedAt = L.now(), Zr(t, r, o, a) || ((W.instantAnimations || !l) && (c == null || c(xt(t, s, n))), t[0] = t[t.length - 1], s.duration = 0, s.repeat = 0);
1553
+ const f = {
1554
+ startTime: i ? this.resolvedAt ? this.resolvedAt - this.createdAt > to ? this.resolvedAt : this.createdAt : this.createdAt : void 0,
1555
+ finalKeyframe: n,
1556
+ ...s,
1557
+ keyframes: t
1558
+ }, h = !u && eo(f) ? new Xr({
1559
+ ...f,
1560
+ element: f.motionValue.owner.current
1561
+ }) : new At(f);
1562
+ h.finished.then(() => this.notifyFinished()).catch(ie), this.pendingTimeline && (this.stopTimeline = h.attachTimeline(this.pendingTimeline), this.pendingTimeline = void 0), this._animation = h;
1563
+ }
1564
+ get finished() {
1565
+ return this._animation ? this.animation.finished : this._finished;
1566
+ }
1567
+ then(t, n) {
1568
+ return this.finished.finally(t).then(() => {
1569
+ });
1570
+ }
1571
+ get animation() {
1572
+ var t;
1573
+ return this._animation || ((t = this.keyframeResolver) == null || t.resume(), Br()), this._animation;
1574
+ }
1575
+ get duration() {
1576
+ return this.animation.duration;
1577
+ }
1578
+ get time() {
1579
+ return this.animation.time;
1580
+ }
1581
+ set time(t) {
1582
+ this.animation.time = t;
1583
+ }
1584
+ get speed() {
1585
+ return this.animation.speed;
1586
+ }
1587
+ get state() {
1588
+ return this.animation.state;
1589
+ }
1590
+ set speed(t) {
1591
+ this.animation.speed = t;
1592
+ }
1593
+ get startTime() {
1594
+ return this.animation.startTime;
1595
+ }
1596
+ attachTimeline(t) {
1597
+ return this._animation ? this.stopTimeline = this.animation.attachTimeline(t) : this.pendingTimeline = t, () => this.stop();
1598
+ }
1599
+ play() {
1600
+ this.animation.play();
1601
+ }
1602
+ pause() {
1603
+ this.animation.pause();
1604
+ }
1605
+ complete() {
1606
+ this.animation.complete();
1607
+ }
1608
+ cancel() {
1609
+ var t;
1610
+ this._animation && this.animation.cancel(), (t = this.keyframeResolver) == null || t.cancel();
1611
+ }
1612
+ }
1613
+ const so = (
1614
+ // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
1615
+ /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
1616
+ );
1617
+ function io(e) {
1618
+ const t = so.exec(e);
1619
+ if (!t)
1620
+ return [,];
1621
+ const [, n, s, i] = t;
1622
+ return [`--${n ?? s}`, i];
1623
+ }
1624
+ const ro = 4;
1625
+ function us(e, t, n = 1) {
1626
+ Y(n <= ro, `Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);
1627
+ const [s, i] = io(e);
1628
+ if (!s)
1629
+ return;
1630
+ const r = window.getComputedStyle(t).getPropertyValue(s);
1631
+ if (r) {
1632
+ const o = r.trim();
1633
+ return Pn(o) ? parseFloat(o) : o;
1634
+ }
1635
+ return bt(i) ? us(i, t, n + 1) : i;
1636
+ }
1637
+ function ls(e, t) {
1638
+ return (e == null ? void 0 : e[t]) ?? (e == null ? void 0 : e.default) ?? e;
1639
+ }
1640
+ const fs = /* @__PURE__ */ new Set([
1641
+ "width",
1642
+ "height",
1643
+ "top",
1644
+ "left",
1645
+ "right",
1646
+ "bottom",
1647
+ ...ae
1648
+ ]), oo = {
1649
+ test: (e) => e === "auto",
1650
+ parse: (e) => e
1651
+ }, ds = (e) => (t) => t.test(e), hs = [re, b, Q, $, qi, Xi, oo], sn = (e) => hs.find(ds(e));
1652
+ function ao(e) {
1653
+ return typeof e == "number" ? e === 0 : e !== null ? e === "none" || e === "0" || En(e) : !0;
1654
+ }
1655
+ const co = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
1656
+ function uo(e) {
1657
+ const [t, n] = e.slice(0, -1).split("(");
1658
+ if (t === "drop-shadow")
1659
+ return e;
1660
+ const [s] = n.match(vt) || [];
1661
+ if (!s)
1662
+ return e;
1663
+ const i = n.replace(s, "");
1664
+ let r = co.has(t) ? 1 : 0;
1665
+ return s !== n && (r *= 100), t + "(" + r + i + ")";
1666
+ }
1667
+ const lo = /\b([a-z-]*)\(.*?\)/gu, ot = {
1668
+ ...oe,
1669
+ getAnimatableNone: (e) => {
1670
+ const t = e.match(lo);
1671
+ return t ? t.map(uo).join(" ") : e;
1672
+ }
1673
+ }, rn = {
1674
+ ...re,
1675
+ transform: Math.round
1676
+ }, fo = {
1677
+ rotate: $,
1678
+ rotateX: $,
1679
+ rotateY: $,
1680
+ rotateZ: $,
1681
+ scale: we,
1682
+ scaleX: we,
1683
+ scaleY: we,
1684
+ scaleZ: we,
1685
+ skew: $,
1686
+ skewX: $,
1687
+ skewY: $,
1688
+ distance: b,
1689
+ translateX: b,
1690
+ translateY: b,
1691
+ translateZ: b,
1692
+ x: b,
1693
+ y: b,
1694
+ z: b,
1695
+ perspective: b,
1696
+ transformPerspective: b,
1697
+ opacity: he,
1698
+ originX: Gt,
1699
+ originY: Gt,
1700
+ originZ: b
1701
+ }, Mt = {
1702
+ // Border props
1703
+ borderWidth: b,
1704
+ borderTopWidth: b,
1705
+ borderRightWidth: b,
1706
+ borderBottomWidth: b,
1707
+ borderLeftWidth: b,
1708
+ borderRadius: b,
1709
+ radius: b,
1710
+ borderTopLeftRadius: b,
1711
+ borderTopRightRadius: b,
1712
+ borderBottomRightRadius: b,
1713
+ borderBottomLeftRadius: b,
1714
+ // Positioning props
1715
+ width: b,
1716
+ maxWidth: b,
1717
+ height: b,
1718
+ maxHeight: b,
1719
+ top: b,
1720
+ right: b,
1721
+ bottom: b,
1722
+ left: b,
1723
+ // Spacing props
1724
+ padding: b,
1725
+ paddingTop: b,
1726
+ paddingRight: b,
1727
+ paddingBottom: b,
1728
+ paddingLeft: b,
1729
+ margin: b,
1730
+ marginTop: b,
1731
+ marginRight: b,
1732
+ marginBottom: b,
1733
+ marginLeft: b,
1734
+ // Misc
1735
+ backgroundPositionX: b,
1736
+ backgroundPositionY: b,
1737
+ ...fo,
1738
+ zIndex: rn,
1739
+ // SVG
1740
+ fillOpacity: he,
1741
+ strokeOpacity: he,
1742
+ numOctaves: rn
1743
+ }, ho = {
1744
+ ...Mt,
1745
+ // Color props
1746
+ color: E,
1747
+ backgroundColor: E,
1748
+ outlineColor: E,
1749
+ fill: E,
1750
+ stroke: E,
1751
+ // Border props
1752
+ borderColor: E,
1753
+ borderTopColor: E,
1754
+ borderRightColor: E,
1755
+ borderBottomColor: E,
1756
+ borderLeftColor: E,
1757
+ filter: ot,
1758
+ WebkitFilter: ot
1759
+ }, ps = (e) => ho[e];
1760
+ function ms(e, t) {
1761
+ let n = ps(e);
1762
+ return n !== ot && (n = oe), n.getAnimatableNone ? n.getAnimatableNone(t) : void 0;
1763
+ }
1764
+ const po = /* @__PURE__ */ new Set(["auto", "none", "0"]);
1765
+ function mo(e, t, n) {
1766
+ let s = 0, i;
1767
+ for (; s < e.length && !i; ) {
1768
+ const r = e[s];
1769
+ typeof r == "string" && !po.has(r) && pe(r).values.length && (i = e[s]), s++;
1770
+ }
1771
+ if (i && n)
1772
+ for (const r of t)
1773
+ e[r] = ms(n, i);
1774
+ }
1775
+ class go extends Ct {
1776
+ constructor(t, n, s, i, r) {
1777
+ super(t, n, s, i, r, !0);
1778
+ }
1779
+ readKeyframes() {
1780
+ const { unresolvedKeyframes: t, element: n, name: s } = this;
1781
+ if (!n || !n.current)
1782
+ return;
1783
+ super.readKeyframes();
1784
+ for (let l = 0; l < t.length; l++) {
1785
+ let u = t[l];
1786
+ if (typeof u == "string" && (u = u.trim(), bt(u))) {
1787
+ const c = us(u, n.current);
1788
+ c !== void 0 && (t[l] = c), l === t.length - 1 && (this.finalKeyframe = u);
1789
+ }
1790
+ }
1791
+ if (this.resolveNoneKeyframes(), !fs.has(s) || t.length !== 2)
1792
+ return;
1793
+ const [i, r] = t, o = sn(i), a = sn(r);
1794
+ if (o !== a)
1795
+ if (Qt(o) && Qt(a))
1796
+ for (let l = 0; l < t.length; l++) {
1797
+ const u = t[l];
1798
+ typeof u == "string" && (t[l] = parseFloat(u));
1799
+ }
1800
+ else G[s] && (this.needsMeasurement = !0);
1801
+ }
1802
+ resolveNoneKeyframes() {
1803
+ const { unresolvedKeyframes: t, name: n } = this, s = [];
1804
+ for (let i = 0; i < t.length; i++)
1805
+ (t[i] === null || ao(t[i])) && s.push(i);
1806
+ s.length && mo(t, s, n);
1807
+ }
1808
+ measureInitialState() {
1809
+ const { element: t, unresolvedKeyframes: n, name: s } = this;
1810
+ if (!t || !t.current)
1811
+ return;
1812
+ s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = G[s](t.measureViewportBox(), window.getComputedStyle(t.current)), n[0] = this.measuredOrigin;
1813
+ const i = n[n.length - 1];
1814
+ i !== void 0 && t.getValue(s, i).jump(i, !1);
1815
+ }
1816
+ measureEndState() {
1817
+ var a;
1818
+ const { element: t, name: n, unresolvedKeyframes: s } = this;
1819
+ if (!t || !t.current)
1820
+ return;
1821
+ const i = t.getValue(n);
1822
+ i && i.jump(this.measuredOrigin, !1);
1823
+ const r = s.length - 1, o = s[r];
1824
+ s[r] = G[n](t.measureViewportBox(), window.getComputedStyle(t.current)), o !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = o), (a = this.removedTransforms) != null && a.length && this.removedTransforms.forEach(([l, u]) => {
1825
+ t.getValue(l).set(u);
1826
+ }), this.resolveNoneKeyframes();
1827
+ }
1828
+ }
1829
+ function yo(e, t, n) {
1830
+ if (e instanceof EventTarget)
1831
+ return [e];
1832
+ if (typeof e == "string") {
1833
+ let s = document;
1834
+ const i = (n == null ? void 0 : n[e]) ?? s.querySelectorAll(e);
1835
+ return i ? Array.from(i) : [];
1836
+ }
1837
+ return Array.from(e);
1838
+ }
1839
+ const gs = (e, t) => t && typeof e == "number" ? t.transform(e) : e, on = 30, bo = (e) => !isNaN(parseFloat(e));
1840
+ class vo {
1841
+ /**
1842
+ * @param init - The initiating value
1843
+ * @param config - Optional configuration options
1844
+ *
1845
+ * - `transformer`: A function to transform incoming values with.
1846
+ */
1847
+ constructor(t, n = {}) {
1848
+ this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s, i = !0) => {
1849
+ var o, a;
1850
+ const r = L.now();
1851
+ if (this.updatedAt !== r && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(s), this.current !== this.prev && ((o = this.events.change) == null || o.notify(this.current), this.dependents))
1852
+ for (const l of this.dependents)
1853
+ l.dirty();
1854
+ i && ((a = this.events.renderRequest) == null || a.notify(this.current));
1855
+ }, this.hasAnimated = !1, this.setCurrent(t), this.owner = n.owner;
1856
+ }
1857
+ setCurrent(t) {
1858
+ this.current = t, this.updatedAt = L.now(), this.canTrackVelocity === null && t !== void 0 && (this.canTrackVelocity = bo(this.current));
1859
+ }
1860
+ setPrevFrameValue(t = this.current) {
1861
+ this.prevFrameValue = t, this.prevUpdatedAt = this.updatedAt;
1862
+ }
1863
+ /**
1864
+ * Adds a function that will be notified when the `MotionValue` is updated.
1865
+ *
1866
+ * It returns a function that, when called, will cancel the subscription.
1867
+ *
1868
+ * When calling `onChange` inside a React component, it should be wrapped with the
1869
+ * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1870
+ * from the `useEffect` function to ensure you don't add duplicate subscribers..
1871
+ *
1872
+ * ```jsx
1873
+ * export const MyComponent = () => {
1874
+ * const x = useMotionValue(0)
1875
+ * const y = useMotionValue(0)
1876
+ * const opacity = useMotionValue(1)
1877
+ *
1878
+ * useEffect(() => {
1879
+ * function updateOpacity() {
1880
+ * const maxXY = Math.max(x.get(), y.get())
1881
+ * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1882
+ * opacity.set(newOpacity)
1883
+ * }
1884
+ *
1885
+ * const unsubscribeX = x.on("change", updateOpacity)
1886
+ * const unsubscribeY = y.on("change", updateOpacity)
1887
+ *
1888
+ * return () => {
1889
+ * unsubscribeX()
1890
+ * unsubscribeY()
1891
+ * }
1892
+ * }, [])
1893
+ *
1894
+ * return <motion.div style={{ x }} />
1895
+ * }
1896
+ * ```
1897
+ *
1898
+ * @param subscriber - A function that receives the latest value.
1899
+ * @returns A function that, when called, will cancel this subscription.
1900
+ *
1901
+ * @deprecated
1902
+ */
1903
+ onChange(t) {
1904
+ return process.env.NODE_ENV !== "production" && On(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", t);
1905
+ }
1906
+ on(t, n) {
1907
+ this.events[t] || (this.events[t] = new Fn());
1908
+ const s = this.events[t].add(n);
1909
+ return t === "change" ? () => {
1910
+ s(), k.read(() => {
1911
+ this.events.change.getSize() || this.stop();
1912
+ });
1913
+ } : s;
1914
+ }
1915
+ clearListeners() {
1916
+ for (const t in this.events)
1917
+ this.events[t].clear();
1918
+ }
1919
+ /**
1920
+ * Attaches a passive effect to the `MotionValue`.
1921
+ */
1922
+ attach(t, n) {
1923
+ this.passiveEffect = t, this.stopPassiveEffect = n;
1924
+ }
1925
+ /**
1926
+ * Sets the state of the `MotionValue`.
1927
+ *
1928
+ * @remarks
1929
+ *
1930
+ * ```jsx
1931
+ * const x = useMotionValue(0)
1932
+ * x.set(10)
1933
+ * ```
1934
+ *
1935
+ * @param latest - Latest value to set.
1936
+ * @param render - Whether to notify render subscribers. Defaults to `true`
1937
+ *
1938
+ * @public
1939
+ */
1940
+ set(t, n = !0) {
1941
+ !n || !this.passiveEffect ? this.updateAndNotify(t, n) : this.passiveEffect(t, this.updateAndNotify);
1942
+ }
1943
+ setWithVelocity(t, n, s) {
1944
+ this.set(n), this.prev = void 0, this.prevFrameValue = t, this.prevUpdatedAt = this.updatedAt - s;
1945
+ }
1946
+ /**
1947
+ * Set the state of the `MotionValue`, stopping any active animations,
1948
+ * effects, and resets velocity to `0`.
1949
+ */
1950
+ jump(t, n = !0) {
1951
+ this.updateAndNotify(t), this.prev = t, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1952
+ }
1953
+ dirty() {
1954
+ var t;
1955
+ (t = this.events.change) == null || t.notify(this.current);
1956
+ }
1957
+ addDependent(t) {
1958
+ this.dependents || (this.dependents = /* @__PURE__ */ new Set()), this.dependents.add(t);
1959
+ }
1960
+ removeDependent(t) {
1961
+ this.dependents && this.dependents.delete(t);
1962
+ }
1963
+ /**
1964
+ * Returns the latest state of `MotionValue`
1965
+ *
1966
+ * @returns - The latest state of `MotionValue`
1967
+ *
1968
+ * @public
1969
+ */
1970
+ get() {
1971
+ return this.current;
1972
+ }
1973
+ /**
1974
+ * @public
1975
+ */
1976
+ getPrevious() {
1977
+ return this.prev;
1978
+ }
1979
+ /**
1980
+ * Returns the latest velocity of `MotionValue`
1981
+ *
1982
+ * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1983
+ *
1984
+ * @public
1985
+ */
1986
+ getVelocity() {
1987
+ const t = L.now();
1988
+ if (!this.canTrackVelocity || this.prevFrameValue === void 0 || t - this.updatedAt > on)
1989
+ return 0;
1990
+ const n = Math.min(this.updatedAt - this.prevUpdatedAt, on);
1991
+ return Rn(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
1992
+ }
1993
+ /**
1994
+ * Registers a new animation to control this `MotionValue`. Only one
1995
+ * animation can drive a `MotionValue` at one time.
1996
+ *
1997
+ * ```jsx
1998
+ * value.start()
1999
+ * ```
2000
+ *
2001
+ * @param animation - A function that starts the provided animation
2002
+ */
2003
+ start(t) {
2004
+ return this.stop(), new Promise((n) => {
2005
+ this.hasAnimated = !0, this.animation = t(n), this.events.animationStart && this.events.animationStart.notify();
2006
+ }).then(() => {
2007
+ this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
2008
+ });
2009
+ }
2010
+ /**
2011
+ * Stop the currently active animation.
2012
+ *
2013
+ * @public
2014
+ */
2015
+ stop() {
2016
+ this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
2017
+ }
2018
+ /**
2019
+ * Returns `true` if this value is currently animating.
2020
+ *
2021
+ * @public
2022
+ */
2023
+ isAnimating() {
2024
+ return !!this.animation;
2025
+ }
2026
+ clearAnimation() {
2027
+ delete this.animation;
2028
+ }
2029
+ /**
2030
+ * Destroy and clean up subscribers to this `MotionValue`.
2031
+ *
2032
+ * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
2033
+ * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
2034
+ * created a `MotionValue` via the `motionValue` function.
2035
+ *
2036
+ * @public
2037
+ */
2038
+ destroy() {
2039
+ var t, n;
2040
+ (t = this.dependents) == null || t.clear(), (n = this.events.destroy) == null || n.notify(), this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
2041
+ }
2042
+ }
2043
+ function Ee(e, t) {
2044
+ return new vo(e, t);
2045
+ }
2046
+ const { schedule: To } = /* @__PURE__ */ jn(queueMicrotask, !1), wo = {
2047
+ y: !1
2048
+ };
2049
+ function So() {
2050
+ return wo.y;
2051
+ }
2052
+ function ys(e, t) {
2053
+ const n = yo(e), s = new AbortController(), i = {
2054
+ passive: !0,
2055
+ ...t,
2056
+ signal: s.signal
2057
+ };
2058
+ return [n, i, () => s.abort()];
2059
+ }
2060
+ function an(e) {
2061
+ return !(e.pointerType === "touch" || So());
2062
+ }
2063
+ function xo(e, t, n = {}) {
2064
+ const [s, i, r] = ys(e, n), o = (a) => {
2065
+ if (!an(a))
2066
+ return;
2067
+ const { target: l } = a, u = t(l, a);
2068
+ if (typeof u != "function" || !l)
2069
+ return;
2070
+ const c = (d) => {
2071
+ an(d) && (u(d), l.removeEventListener("pointerleave", c));
2072
+ };
2073
+ l.addEventListener("pointerleave", c, i);
2074
+ };
2075
+ return s.forEach((a) => {
2076
+ a.addEventListener("pointerenter", o, i);
2077
+ }), r;
2078
+ }
2079
+ const bs = (e, t) => t ? e === t ? !0 : bs(e, t.parentElement) : !1, Vo = (e) => e.pointerType === "mouse" ? typeof e.button != "number" || e.button <= 0 : e.isPrimary !== !1, Ao = /* @__PURE__ */ new Set([
2080
+ "BUTTON",
2081
+ "INPUT",
2082
+ "SELECT",
2083
+ "TEXTAREA",
2084
+ "A"
2085
+ ]);
2086
+ function Co(e) {
2087
+ return Ao.has(e.tagName) || e.tabIndex !== -1;
2088
+ }
2089
+ const xe = /* @__PURE__ */ new WeakSet();
2090
+ function cn(e) {
2091
+ return (t) => {
2092
+ t.key === "Enter" && e(t);
2093
+ };
2094
+ }
2095
+ function Ue(e, t) {
2096
+ e.dispatchEvent(new PointerEvent("pointer" + t, { isPrimary: !0, bubbles: !0 }));
2097
+ }
2098
+ const Mo = (e, t) => {
2099
+ const n = e.currentTarget;
2100
+ if (!n)
2101
+ return;
2102
+ const s = cn(() => {
2103
+ if (xe.has(n))
2104
+ return;
2105
+ Ue(n, "down");
2106
+ const i = cn(() => {
2107
+ Ue(n, "up");
2108
+ }), r = () => Ue(n, "cancel");
2109
+ n.addEventListener("keyup", i, t), n.addEventListener("blur", r, t);
2110
+ });
2111
+ n.addEventListener("keydown", s, t), n.addEventListener("blur", () => n.removeEventListener("keydown", s), t);
2112
+ };
2113
+ function un(e) {
2114
+ return Vo(e) && !0;
2115
+ }
2116
+ function Po(e, t, n = {}) {
2117
+ const [s, i, r] = ys(e, n), o = (a) => {
2118
+ const l = a.currentTarget;
2119
+ if (!un(a))
2120
+ return;
2121
+ xe.add(l);
2122
+ const u = t(l, a), c = (h, g) => {
2123
+ window.removeEventListener("pointerup", d), window.removeEventListener("pointercancel", f), xe.has(l) && xe.delete(l), un(h) && typeof u == "function" && u(h, { success: g });
2124
+ }, d = (h) => {
2125
+ c(h, l === window || l === document || n.useGlobalTarget || bs(l, h.target));
2126
+ }, f = (h) => {
2127
+ c(h, !1);
2128
+ };
2129
+ window.addEventListener("pointerup", d, i), window.addEventListener("pointercancel", f, i);
2130
+ };
2131
+ return s.forEach((a) => {
2132
+ (n.useGlobalTarget ? window : a).addEventListener("pointerdown", o, i), cs(a) && (a.addEventListener("focus", (u) => Mo(u, i)), !Co(a) && !a.hasAttribute("tabindex") && (a.tabIndex = 0));
2133
+ }), r;
2134
+ }
2135
+ const O = (e) => !!(e && e.getVelocity), Eo = [...hs, E, oe], Do = (e) => Eo.find(ds(e)), vs = se({
2136
+ transformPagePoint: (e) => e,
2137
+ isStatic: !1,
2138
+ reducedMotion: "never"
2139
+ }), Pt = se({ strict: !1 }), ln = {
2140
+ animation: [
2141
+ "animate",
2142
+ "variants",
2143
+ "whileHover",
2144
+ "whileTap",
2145
+ "exit",
2146
+ "whileInView",
2147
+ "whileFocus",
2148
+ "whileDrag"
2149
+ ],
2150
+ exit: ["exit"],
2151
+ drag: ["drag", "dragControls"],
2152
+ focus: ["whileFocus"],
2153
+ hover: ["whileHover", "onHoverStart", "onHoverEnd"],
2154
+ tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
2155
+ pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
2156
+ inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
2157
+ layout: ["layout", "layoutId"]
2158
+ }, te = {};
2159
+ for (const e in ln)
2160
+ te[e] = {
2161
+ isEnabled: (t) => ln[e].some((n) => !!t[n])
2162
+ };
2163
+ function fn(e) {
2164
+ for (const t in e)
2165
+ te[t] = {
2166
+ ...te[t],
2167
+ ...e[t]
2168
+ };
2169
+ }
2170
+ function Fo({ children: e, features: t, strict: n = !1 }) {
2171
+ const [, s] = Gs(!Ge(t)), i = fe(void 0);
2172
+ if (!Ge(t)) {
2173
+ const { renderer: r, ...o } = t;
2174
+ i.current = r, fn(o);
2175
+ }
2176
+ return dt(() => {
2177
+ Ge(t) && t().then(({ renderer: r, ...o }) => {
2178
+ fn(o), i.current = r, s(!0);
2179
+ });
2180
+ }, []), M(Pt.Provider, { value: { renderer: i.current, strict: n }, children: e });
2181
+ }
2182
+ function Ge(e) {
2183
+ return typeof e == "function";
2184
+ }
2185
+ const Ro = /* @__PURE__ */ new Set([
2186
+ "animate",
2187
+ "exit",
2188
+ "variants",
2189
+ "initial",
2190
+ "style",
2191
+ "values",
2192
+ "variants",
2193
+ "transition",
2194
+ "transformTemplate",
2195
+ "custom",
2196
+ "inherit",
2197
+ "onBeforeLayoutMeasure",
2198
+ "onAnimationStart",
2199
+ "onAnimationComplete",
2200
+ "onUpdate",
2201
+ "onDragStart",
2202
+ "onDrag",
2203
+ "onDragEnd",
2204
+ "onMeasureDragConstraints",
2205
+ "onDirectionLock",
2206
+ "onDragTransitionEnd",
2207
+ "_dragX",
2208
+ "_dragY",
2209
+ "onHoverStart",
2210
+ "onHoverEnd",
2211
+ "onViewportEnter",
2212
+ "onViewportLeave",
2213
+ "globalTapTarget",
2214
+ "ignoreStrict",
2215
+ "viewport"
2216
+ ]);
2217
+ function De(e) {
2218
+ return e.startsWith("while") || e.startsWith("drag") && e !== "draggable" || e.startsWith("layout") || e.startsWith("onTap") || e.startsWith("onPan") || e.startsWith("onLayout") || Ro.has(e);
2219
+ }
2220
+ let Ts = (e) => !De(e);
2221
+ function Oo(e) {
2222
+ typeof e == "function" && (Ts = (t) => t.startsWith("on") ? !De(t) : e(t));
2223
+ }
2224
+ try {
2225
+ Oo(require("@emotion/is-prop-valid").default);
2226
+ } catch {
2227
+ }
2228
+ function Lo(e, t, n) {
2229
+ const s = {};
2230
+ for (const i in e)
2231
+ i === "values" && typeof e.values == "object" || (Ts(i) || n === !0 && De(i) || !t && !De(i) || // If trying to use native HTML drag events, forward drag listeners
2232
+ e.draggable && i.startsWith("onDrag")) && (s[i] = e[i]);
2233
+ return s;
2234
+ }
2235
+ const Le = /* @__PURE__ */ se({});
2236
+ function Ie(e) {
2237
+ return e !== null && typeof e == "object" && typeof e.start == "function";
2238
+ }
2239
+ function me(e) {
2240
+ return typeof e == "string" || Array.isArray(e);
2241
+ }
2242
+ const Et = [
2243
+ "animate",
2244
+ "whileInView",
2245
+ "whileFocus",
2246
+ "whileHover",
2247
+ "whileTap",
2248
+ "whileDrag",
2249
+ "exit"
2250
+ ], Dt = ["initial", ...Et];
2251
+ function ke(e) {
2252
+ return Ie(e.animate) || Dt.some((t) => me(e[t]));
2253
+ }
2254
+ function ws(e) {
2255
+ return !!(ke(e) || e.variants);
2256
+ }
2257
+ function Io(e, t) {
2258
+ if (ke(e)) {
2259
+ const { initial: n, animate: s } = e;
2260
+ return {
2261
+ initial: n === !1 || me(n) ? n : void 0,
2262
+ animate: me(s) ? s : void 0
2263
+ };
2264
+ }
2265
+ return e.inherit !== !1 ? t : {};
2266
+ }
2267
+ function ko(e) {
2268
+ const { initial: t, animate: n } = Io(e, I(Le));
2269
+ return Fe(() => ({ initial: t, animate: n }), [dn(t), dn(n)]);
2270
+ }
2271
+ function dn(e) {
2272
+ return Array.isArray(e) ? e.join(" ") : e;
2273
+ }
2274
+ const No = Symbol.for("motionComponentSymbol");
2275
+ function Ss(e) {
2276
+ return e && typeof e == "object" && Object.prototype.hasOwnProperty.call(e, "current");
2277
+ }
2278
+ function Bo(e, t, n) {
2279
+ return zs(
2280
+ (s) => {
2281
+ s && e.onMount && e.onMount(s), t && (s ? t.mount(s) : t.unmount()), n && (typeof n == "function" ? n(s) : Ss(n) && (n.current = s));
2282
+ },
2283
+ /**
2284
+ * Only pass a new ref callback to React if we've received a visual element
2285
+ * factory. Otherwise we'll be mounting/remounting every time externalRef
2286
+ * or other dependencies change.
2287
+ */
2288
+ [t]
2289
+ );
2290
+ }
2291
+ const Ft = (e) => e.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), Ko = "framerAppearId", xs = "data-" + Ft(Ko), Wo = se({});
2292
+ function $o(e, t, n, s, i) {
2293
+ var y, T;
2294
+ const { visualElement: r } = I(Le), o = I(Pt), a = I(Mn), l = I(vs).reducedMotion, u = fe(null);
2295
+ s = s || o.renderer, !u.current && s && (u.current = s(e, {
2296
+ visualState: t,
2297
+ parent: r,
2298
+ props: n,
2299
+ presenceContext: a,
2300
+ blockInitialAnimation: a ? a.initial === !1 : !1,
2301
+ reducedMotionConfig: l
2302
+ }));
2303
+ const c = u.current, d = I(Wo);
2304
+ c && !c.projection && i && (c.type === "html" || c.type === "svg") && _o(u.current, n, i, d);
2305
+ const f = fe(!1);
2306
+ Hs(() => {
2307
+ c && f.current && c.update(n, a);
2308
+ });
2309
+ const h = n[xs], g = fe(!!h && !((y = window.MotionHandoffIsComplete) != null && y.call(window, h)) && ((T = window.MotionHasOptimisedAnimation) == null ? void 0 : T.call(window, h)));
2310
+ return Mi(() => {
2311
+ c && (f.current = !0, window.MotionIsMounted = !0, c.updateFeatures(), To.render(c.render), g.current && c.animationState && c.animationState.animateChanges());
2312
+ }), dt(() => {
2313
+ c && (!g.current && c.animationState && c.animationState.animateChanges(), g.current && (queueMicrotask(() => {
2314
+ var p;
2315
+ (p = window.MotionHandoffMarkAsComplete) == null || p.call(window, h);
2316
+ }), g.current = !1));
2317
+ }), c;
2318
+ }
2319
+ function _o(e, t, n, s) {
2320
+ const { layoutId: i, layout: r, drag: o, dragConstraints: a, layoutScroll: l, layoutRoot: u, layoutCrossfade: c } = t;
2321
+ e.projection = new n(e.latestValues, t["data-framer-portal-id"] ? void 0 : Vs(e.parent)), e.projection.setOptions({
2322
+ layoutId: i,
2323
+ layout: r,
2324
+ alwaysMeasureLayout: !!o || a && Ss(a),
2325
+ visualElement: e,
2326
+ /**
2327
+ * TODO: Update options in an effect. This could be tricky as it'll be too late
2328
+ * to update by the time layout animations run.
2329
+ * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
2330
+ * ensuring it gets called if there's no potential layout animations.
2331
+ *
2332
+ */
2333
+ animationType: typeof r == "string" ? r : "both",
2334
+ initialPromotionConfig: s,
2335
+ crossfade: c,
2336
+ layoutScroll: l,
2337
+ layoutRoot: u
2338
+ });
2339
+ }
2340
+ function Vs(e) {
2341
+ if (e)
2342
+ return e.options.allowProjection !== !1 ? e.projection : Vs(e.parent);
2343
+ }
2344
+ function jo({ preloadedFeatures: e, createVisualElement: t, useRender: n, useVisualState: s, Component: i }) {
2345
+ function r(a, l) {
2346
+ let u;
2347
+ const c = {
2348
+ ...I(vs),
2349
+ ...a,
2350
+ layoutId: Uo(a)
2351
+ }, { isStatic: d } = c, f = ko(a), h = s(a, d);
2352
+ if (!d && pt) {
2353
+ Go(c, e);
2354
+ const g = zo(c);
2355
+ u = g.MeasureLayout, f.visualElement = $o(i, h, c, t, g.ProjectionNode);
2356
+ }
2357
+ return Ve(Le.Provider, { value: f, children: [u && f.visualElement ? M(u, { visualElement: f.visualElement, ...c }) : null, n(i, a, Bo(h, f.visualElement, l), h, d, f.visualElement)] });
2358
+ }
2359
+ r.displayName = `motion.${typeof i == "string" ? i : `create(${i.displayName ?? i.name ?? ""})`}`;
2360
+ const o = Ys(r);
2361
+ return o[No] = i, o;
2362
+ }
2363
+ function Uo({ layoutId: e }) {
2364
+ const t = I(Ai).id;
2365
+ return t && e !== void 0 ? t + "-" + e : e;
2366
+ }
2367
+ function Go(e, t) {
2368
+ I(Pt).strict, process.env.NODE_ENV;
2369
+ }
2370
+ function zo(e) {
2371
+ const { drag: t, layout: n } = te;
2372
+ if (!t && !n)
2373
+ return {};
2374
+ const s = { ...t, ...n };
2375
+ return {
2376
+ MeasureLayout: t != null && t.isEnabled(e) || n != null && n.isEnabled(e) ? s.MeasureLayout : void 0,
2377
+ ProjectionNode: s.ProjectionNode
2378
+ };
2379
+ }
2380
+ const Ho = {};
2381
+ function As(e, { layout: t, layoutId: n }) {
2382
+ return ce.has(e) || e.startsWith("origin") || (t || n !== void 0) && (!!Ho[e] || e === "opacity");
2383
+ }
2384
+ const Yo = {
2385
+ x: "translateX",
2386
+ y: "translateY",
2387
+ z: "translateZ",
2388
+ transformPerspective: "perspective"
2389
+ }, Xo = ae.length;
2390
+ function qo(e, t, n) {
2391
+ let s = "", i = !0;
2392
+ for (let r = 0; r < Xo; r++) {
2393
+ const o = ae[r], a = e[o];
2394
+ if (a === void 0)
2395
+ continue;
2396
+ let l = !0;
2397
+ if (typeof a == "number" ? l = a === (o.startsWith("scale") ? 1 : 0) : l = parseFloat(a) === 0, !l || n) {
2398
+ const u = gs(a, Mt[o]);
2399
+ if (!l) {
2400
+ i = !1;
2401
+ const c = Yo[o] || o;
2402
+ s += `${c}(${u}) `;
2403
+ }
2404
+ n && (t[o] = u);
2405
+ }
2406
+ }
2407
+ return s = s.trim(), n ? s = n(t, i ? "" : s) : i && (s = "none"), s;
2408
+ }
2409
+ function Rt(e, t, n) {
2410
+ const { style: s, vars: i, transformOrigin: r } = e;
2411
+ let o = !1, a = !1;
2412
+ for (const l in t) {
2413
+ const u = t[l];
2414
+ if (ce.has(l)) {
2415
+ o = !0;
2416
+ continue;
2417
+ } else if (Gn(l)) {
2418
+ i[l] = u;
2419
+ continue;
2420
+ } else {
2421
+ const c = gs(u, Mt[l]);
2422
+ l.startsWith("origin") ? (a = !0, r[l] = c) : s[l] = c;
2423
+ }
2424
+ }
2425
+ if (t.transform || (o || n ? s.transform = qo(t, e.transform, n) : s.transform && (s.transform = "none")), a) {
2426
+ const { originX: l = "50%", originY: u = "50%", originZ: c = 0 } = r;
2427
+ s.transformOrigin = `${l} ${u} ${c}`;
2428
+ }
2429
+ }
2430
+ const Ot = () => ({
2431
+ style: {},
2432
+ transform: {},
2433
+ transformOrigin: {},
2434
+ vars: {}
2435
+ });
2436
+ function Cs(e, t, n) {
2437
+ for (const s in t)
2438
+ !O(t[s]) && !As(s, n) && (e[s] = t[s]);
2439
+ }
2440
+ function Zo({ transformTemplate: e }, t) {
2441
+ return Fe(() => {
2442
+ const n = Ot();
2443
+ return Rt(n, t, e), Object.assign({}, n.vars, n.style);
2444
+ }, [t]);
2445
+ }
2446
+ function Jo(e, t) {
2447
+ const n = e.style || {}, s = {};
2448
+ return Cs(s, n, e), Object.assign(s, Zo(e, t)), s;
2449
+ }
2450
+ function Qo(e, t) {
2451
+ const n = {}, s = Jo(e, t);
2452
+ return e.drag && e.dragListener !== !1 && (n.draggable = !1, s.userSelect = s.WebkitUserSelect = s.WebkitTouchCallout = "none", s.touchAction = e.drag === !0 ? "none" : `pan-${e.drag === "x" ? "y" : "x"}`), e.tabIndex === void 0 && (e.onTap || e.onTapStart || e.whileTap) && (n.tabIndex = 0), n.style = s, n;
2453
+ }
2454
+ const ea = {
2455
+ offset: "stroke-dashoffset",
2456
+ array: "stroke-dasharray"
2457
+ }, ta = {
2458
+ offset: "strokeDashoffset",
2459
+ array: "strokeDasharray"
2460
+ };
2461
+ function na(e, t, n = 1, s = 0, i = !0) {
2462
+ e.pathLength = 1;
2463
+ const r = i ? ea : ta;
2464
+ e[r.offset] = b.transform(-s);
2465
+ const o = b.transform(t), a = b.transform(n);
2466
+ e[r.array] = `${o} ${a}`;
2467
+ }
2468
+ function Ms(e, {
2469
+ attrX: t,
2470
+ attrY: n,
2471
+ attrScale: s,
2472
+ pathLength: i,
2473
+ pathSpacing: r = 1,
2474
+ pathOffset: o = 0,
2475
+ // This is object creation, which we try to avoid per-frame.
2476
+ ...a
2477
+ }, l, u, c) {
2478
+ if (Rt(e, a, u), l) {
2479
+ e.style.viewBox && (e.attrs.viewBox = e.style.viewBox);
2480
+ return;
2481
+ }
2482
+ e.attrs = e.style, e.style = {};
2483
+ const { attrs: d, style: f } = e;
2484
+ d.transform && (f.transform = d.transform, delete d.transform), (f.transform || d.transformOrigin) && (f.transformOrigin = d.transformOrigin ?? "50% 50%", delete d.transformOrigin), f.transform && (f.transformBox = (c == null ? void 0 : c.transformBox) ?? "fill-box", delete d.transformBox), t !== void 0 && (d.x = t), n !== void 0 && (d.y = n), s !== void 0 && (d.scale = s), i !== void 0 && na(d, i, r, o, !1);
2485
+ }
2486
+ const Ps = () => ({
2487
+ ...Ot(),
2488
+ attrs: {}
2489
+ }), Es = (e) => typeof e == "string" && e.toLowerCase() === "svg";
2490
+ function sa(e, t, n, s) {
2491
+ const i = Fe(() => {
2492
+ const r = Ps();
2493
+ return Ms(r, t, Es(s), e.transformTemplate, e.style), {
2494
+ ...r.attrs,
2495
+ style: { ...r.style }
2496
+ };
2497
+ }, [t]);
2498
+ if (e.style) {
2499
+ const r = {};
2500
+ Cs(r, e.style, e), i.style = { ...r, ...i.style };
2501
+ }
2502
+ return i;
2503
+ }
2504
+ const ia = [
2505
+ "animate",
2506
+ "circle",
2507
+ "defs",
2508
+ "desc",
2509
+ "ellipse",
2510
+ "g",
2511
+ "image",
2512
+ "line",
2513
+ "filter",
2514
+ "marker",
2515
+ "mask",
2516
+ "metadata",
2517
+ "path",
2518
+ "pattern",
2519
+ "polygon",
2520
+ "polyline",
2521
+ "rect",
2522
+ "stop",
2523
+ "switch",
2524
+ "symbol",
2525
+ "svg",
2526
+ "text",
2527
+ "tspan",
2528
+ "use",
2529
+ "view"
2530
+ ];
2531
+ function Lt(e) {
2532
+ return (
2533
+ /**
2534
+ * If it's not a string, it's a custom React component. Currently we only support
2535
+ * HTML custom React components.
2536
+ */
2537
+ typeof e != "string" || /**
2538
+ * If it contains a dash, the element is a custom HTML webcomponent.
2539
+ */
2540
+ e.includes("-") ? !1 : (
2541
+ /**
2542
+ * If it's in our list of lowercase SVG tags, it's an SVG component
2543
+ */
2544
+ !!(ia.indexOf(e) > -1 || /**
2545
+ * If it contains a capital letter, it's an SVG component
2546
+ */
2547
+ /[A-Z]/u.test(e))
2548
+ )
2549
+ );
2550
+ }
2551
+ function ra(e = !1) {
2552
+ return (n, s, i, { latestValues: r }, o) => {
2553
+ const l = (Lt(n) ? sa : Qo)(s, r, o, n), u = Lo(s, typeof n == "string", e), c = n !== Tn ? { ...u, ...l, ref: i } : {}, { children: d } = s, f = Fe(() => O(d) ? d.get() : d, [d]);
2554
+ return Xs(n, {
2555
+ ...c,
2556
+ children: f
2557
+ });
2558
+ };
2559
+ }
2560
+ function hn(e) {
2561
+ const t = [{}, {}];
2562
+ return e == null || e.values.forEach((n, s) => {
2563
+ t[0][s] = n.get(), t[1][s] = n.getVelocity();
2564
+ }), t;
2565
+ }
2566
+ function It(e, t, n, s) {
2567
+ if (typeof t == "function") {
2568
+ const [i, r] = hn(s);
2569
+ t = t(n !== void 0 ? n : e.custom, i, r);
2570
+ }
2571
+ if (typeof t == "string" && (t = e.variants && e.variants[t]), typeof t == "function") {
2572
+ const [i, r] = hn(s);
2573
+ t = t(n !== void 0 ? n : e.custom, i, r);
2574
+ }
2575
+ return t;
2576
+ }
2577
+ function oa(e) {
2578
+ return O(e) ? e.get() : e;
2579
+ }
2580
+ function aa({ scrapeMotionValuesFromProps: e, createRenderState: t }, n, s, i) {
2581
+ return {
2582
+ latestValues: ca(n, s, i, e),
2583
+ renderState: t()
2584
+ };
2585
+ }
2586
+ const Ds = (e) => (t, n) => {
2587
+ const s = I(Le), i = I(Mn), r = () => aa(e, t, s, i);
2588
+ return n ? r() : Ci(r);
2589
+ };
2590
+ function ca(e, t, n, s) {
2591
+ const i = {}, r = s(e, {});
2592
+ for (const f in r)
2593
+ i[f] = oa(r[f]);
2594
+ let { initial: o, animate: a } = e;
2595
+ const l = ke(e), u = ws(e);
2596
+ t && u && !l && e.inherit !== !1 && (o === void 0 && (o = t.initial), a === void 0 && (a = t.animate));
2597
+ let c = n ? n.initial === !1 : !1;
2598
+ c = c || o === !1;
2599
+ const d = c ? a : o;
2600
+ if (d && typeof d != "boolean" && !Ie(d)) {
2601
+ const f = Array.isArray(d) ? d : [d];
2602
+ for (let h = 0; h < f.length; h++) {
2603
+ const g = It(e, f[h]);
2604
+ if (g) {
2605
+ const { transitionEnd: y, transition: T, ...p } = g;
2606
+ for (const V in p) {
2607
+ let m = p[V];
2608
+ if (Array.isArray(m)) {
2609
+ const C = c ? m.length - 1 : 0;
2610
+ m = m[C];
2611
+ }
2612
+ m !== null && (i[V] = m);
2613
+ }
2614
+ for (const V in y)
2615
+ i[V] = y[V];
2616
+ }
2617
+ }
2618
+ }
2619
+ return i;
2620
+ }
2621
+ function kt(e, t, n) {
2622
+ var r;
2623
+ const { style: s } = e, i = {};
2624
+ for (const o in s)
2625
+ (O(s[o]) || t.style && O(t.style[o]) || As(o, e) || ((r = n == null ? void 0 : n.getValue(o)) == null ? void 0 : r.liveStyle) !== void 0) && (i[o] = s[o]);
2626
+ return i;
2627
+ }
2628
+ const ua = {
2629
+ useVisualState: Ds({
2630
+ scrapeMotionValuesFromProps: kt,
2631
+ createRenderState: Ot
2632
+ })
2633
+ };
2634
+ function Fs(e, t, n) {
2635
+ const s = kt(e, t, n);
2636
+ for (const i in e)
2637
+ if (O(e[i]) || O(t[i])) {
2638
+ const r = ae.indexOf(i) !== -1 ? "attr" + i.charAt(0).toUpperCase() + i.substring(1) : i;
2639
+ s[r] = e[i];
2640
+ }
2641
+ return s;
2642
+ }
2643
+ const la = {
2644
+ useVisualState: Ds({
2645
+ scrapeMotionValuesFromProps: Fs,
2646
+ createRenderState: Ps
2647
+ })
2648
+ };
2649
+ function fa(e, t) {
2650
+ return function(s, { forwardMotionProps: i } = { forwardMotionProps: !1 }) {
2651
+ const o = {
2652
+ ...Lt(s) ? la : ua,
2653
+ preloadedFeatures: e,
2654
+ useRender: ra(i),
2655
+ createVisualElement: t,
2656
+ Component: s
2657
+ };
2658
+ return jo(o);
2659
+ };
2660
+ }
2661
+ const da = /* @__PURE__ */ fa();
2662
+ function ge(e, t, n) {
2663
+ const s = e.getProps();
2664
+ return It(s, t, n !== void 0 ? n : s.custom, e);
2665
+ }
2666
+ const at = (e) => Array.isArray(e);
2667
+ function ha(e, t, n) {
2668
+ e.hasValue(t) ? e.getValue(t).set(n) : e.addValue(t, Ee(n));
2669
+ }
2670
+ function pa(e) {
2671
+ return at(e) ? e[e.length - 1] || 0 : e;
2672
+ }
2673
+ function ma(e, t) {
2674
+ const n = ge(e, t);
2675
+ let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {};
2676
+ r = { ...r, ...s };
2677
+ for (const o in r) {
2678
+ const a = pa(r[o]);
2679
+ ha(e, o, a);
2680
+ }
2681
+ }
2682
+ function ga(e) {
2683
+ return !!(O(e) && e.add);
2684
+ }
2685
+ function ya(e, t) {
2686
+ const n = e.getValue("willChange");
2687
+ if (ga(n))
2688
+ return n.add(t);
2689
+ if (!n && W.WillChange) {
2690
+ const s = new W.WillChange("auto");
2691
+ e.addValue("willChange", s), s.add(t);
2692
+ }
2693
+ }
2694
+ function ba(e) {
2695
+ return e.props[xs];
2696
+ }
2697
+ const va = (e) => e !== null;
2698
+ function Ta(e, { repeat: t, repeatType: n = "loop" }, s) {
2699
+ const i = e.filter(va), r = t && n !== "loop" && t % 2 === 1 ? 0 : i.length - 1;
2700
+ return i[r];
2701
+ }
2702
+ const wa = {
2703
+ type: "spring",
2704
+ stiffness: 500,
2705
+ damping: 25,
2706
+ restSpeed: 10
2707
+ }, Sa = (e) => ({
2708
+ type: "spring",
2709
+ stiffness: 550,
2710
+ damping: e === 0 ? 2 * Math.sqrt(550) : 30,
2711
+ restSpeed: 10
2712
+ }), xa = {
2713
+ type: "keyframes",
2714
+ duration: 0.8
2715
+ }, Va = {
2716
+ type: "keyframes",
2717
+ ease: [0.25, 0.1, 0.35, 1],
2718
+ duration: 0.3
2719
+ }, Aa = (e, { keyframes: t }) => t.length > 2 ? xa : ce.has(e) ? e.startsWith("scale") ? Sa(t[1]) : wa : Va;
2720
+ function Ca({ when: e, delay: t, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: r, repeatType: o, repeatDelay: a, from: l, elapsed: u, ...c }) {
2721
+ return !!Object.keys(c).length;
2722
+ }
2723
+ const Ma = (e, t, n, s = {}, i, r) => (o) => {
2724
+ const a = ls(s, e) || {}, l = a.delay || s.delay || 0;
2725
+ let { elapsed: u = 0 } = s;
2726
+ u = u - /* @__PURE__ */ N(l);
2727
+ const c = {
2728
+ keyframes: Array.isArray(n) ? n : [null, n],
2729
+ ease: "easeOut",
2730
+ velocity: t.getVelocity(),
2731
+ ...a,
2732
+ delay: -u,
2733
+ onUpdate: (f) => {
2734
+ t.set(f), a.onUpdate && a.onUpdate(f);
2735
+ },
2736
+ onComplete: () => {
2737
+ o(), a.onComplete && a.onComplete();
2738
+ },
2739
+ name: e,
2740
+ motionValue: t,
2741
+ element: r ? void 0 : i
2742
+ };
2743
+ Ca(a) || Object.assign(c, Aa(e, c)), c.duration && (c.duration = /* @__PURE__ */ N(c.duration)), c.repeatDelay && (c.repeatDelay = /* @__PURE__ */ N(c.repeatDelay)), c.from !== void 0 && (c.keyframes[0] = c.from);
2744
+ let d = !1;
2745
+ if ((c.type === !1 || c.duration === 0 && !c.repeatDelay) && (c.duration = 0, c.delay === 0 && (d = !0)), (W.instantAnimations || W.skipAnimations) && (d = !0, c.duration = 0, c.delay = 0), c.allowFlatten = !a.type && !a.ease, d && !r && t.get() !== void 0) {
2746
+ const f = Ta(c.keyframes, a);
2747
+ if (f !== void 0) {
2748
+ k.update(() => {
2749
+ c.onUpdate(f), c.onComplete();
2750
+ });
2751
+ return;
2752
+ }
2753
+ }
2754
+ return a.isSync ? new At(c) : new no(c);
2755
+ };
2756
+ function Pa({ protectedKeys: e, needsAnimating: t }, n) {
2757
+ const s = e.hasOwnProperty(n) && t[n] !== !0;
2758
+ return t[n] = !1, s;
2759
+ }
2760
+ function Rs(e, t, { delay: n = 0, transitionOverride: s, type: i } = {}) {
2761
+ let { transition: r = e.getDefaultTransition(), transitionEnd: o, ...a } = t;
2762
+ s && (r = s);
2763
+ const l = [], u = i && e.animationState && e.animationState.getState()[i];
2764
+ for (const c in a) {
2765
+ const d = e.getValue(c, e.latestValues[c] ?? null), f = a[c];
2766
+ if (f === void 0 || u && Pa(u, c))
2767
+ continue;
2768
+ const h = {
2769
+ delay: n,
2770
+ ...ls(r || {}, c)
2771
+ }, g = d.get();
2772
+ if (g !== void 0 && !d.isAnimating && !Array.isArray(f) && f === g && !h.velocity)
2773
+ continue;
2774
+ let y = !1;
2775
+ if (window.MotionHandoffAnimation) {
2776
+ const p = ba(e);
2777
+ if (p) {
2778
+ const V = window.MotionHandoffAnimation(p, c, k);
2779
+ V !== null && (h.startTime = V, y = !0);
2780
+ }
2781
+ }
2782
+ ya(e, c), d.start(Ma(c, d, f, e.shouldReduceMotion && fs.has(c) ? { type: !1 } : h, e, y));
2783
+ const T = d.animation;
2784
+ T && l.push(T);
2785
+ }
2786
+ return o && Promise.all(l).then(() => {
2787
+ k.update(() => {
2788
+ o && ma(e, o);
2789
+ });
2790
+ }), l;
2791
+ }
2792
+ function ct(e, t, n = {}) {
2793
+ var l;
2794
+ const s = ge(e, t, n.type === "exit" ? (l = e.presenceContext) == null ? void 0 : l.custom : void 0);
2795
+ let { transition: i = e.getDefaultTransition() || {} } = s || {};
2796
+ n.transitionOverride && (i = n.transitionOverride);
2797
+ const r = s ? () => Promise.all(Rs(e, s, n)) : () => Promise.resolve(), o = e.variantChildren && e.variantChildren.size ? (u = 0) => {
2798
+ const { delayChildren: c = 0, staggerChildren: d, staggerDirection: f } = i;
2799
+ return Ea(e, t, u, c, d, f, n);
2800
+ } : () => Promise.resolve(), { when: a } = i;
2801
+ if (a) {
2802
+ const [u, c] = a === "beforeChildren" ? [r, o] : [o, r];
2803
+ return u().then(() => c());
2804
+ } else
2805
+ return Promise.all([r(), o(n.delay)]);
2806
+ }
2807
+ function Ea(e, t, n = 0, s = 0, i = 0, r = 1, o) {
2808
+ const a = [], l = e.variantChildren.size, u = (l - 1) * i, c = typeof s == "function", d = c ? (f) => s(f, l) : (
2809
+ // Support deprecated staggerChildren
2810
+ r === 1 ? (f = 0) => f * i : (f = 0) => u - f * i
2811
+ );
2812
+ return Array.from(e.variantChildren).sort(Da).forEach((f, h) => {
2813
+ f.notify("AnimationStart", t), a.push(ct(f, t, {
2814
+ ...o,
2815
+ delay: n + (c ? 0 : s) + d(h)
2816
+ }).then(() => f.notify("AnimationComplete", t)));
2817
+ }), Promise.all(a);
2818
+ }
2819
+ function Da(e, t) {
2820
+ return e.sortNodePosition(t);
2821
+ }
2822
+ function Fa(e, t, n = {}) {
2823
+ e.notify("AnimationStart", t);
2824
+ let s;
2825
+ if (Array.isArray(t)) {
2826
+ const i = t.map((r) => ct(e, r, n));
2827
+ s = Promise.all(i);
2828
+ } else if (typeof t == "string")
2829
+ s = ct(e, t, n);
2830
+ else {
2831
+ const i = typeof t == "function" ? ge(e, t, n.custom) : t;
2832
+ s = Promise.all(Rs(e, i, n));
2833
+ }
2834
+ return s.then(() => {
2835
+ e.notify("AnimationComplete", t);
2836
+ });
2837
+ }
2838
+ function Os(e, t) {
2839
+ if (!Array.isArray(t))
2840
+ return !1;
2841
+ const n = t.length;
2842
+ if (n !== e.length)
2843
+ return !1;
2844
+ for (let s = 0; s < n; s++)
2845
+ if (t[s] !== e[s])
2846
+ return !1;
2847
+ return !0;
2848
+ }
2849
+ const Ra = Dt.length;
2850
+ function Ls(e) {
2851
+ if (!e)
2852
+ return;
2853
+ if (!e.isControllingVariants) {
2854
+ const n = e.parent ? Ls(e.parent) || {} : {};
2855
+ return e.props.initial !== void 0 && (n.initial = e.props.initial), n;
2856
+ }
2857
+ const t = {};
2858
+ for (let n = 0; n < Ra; n++) {
2859
+ const s = Dt[n], i = e.props[s];
2860
+ (me(i) || i === !1) && (t[s] = i);
2861
+ }
2862
+ return t;
2863
+ }
2864
+ const Oa = [...Et].reverse(), La = Et.length;
2865
+ function Ia(e) {
2866
+ return (t) => Promise.all(t.map(({ animation: n, options: s }) => Fa(e, n, s)));
2867
+ }
2868
+ function ka(e) {
2869
+ let t = Ia(e), n = pn(), s = !0;
2870
+ const i = (l) => (u, c) => {
2871
+ var f;
2872
+ const d = ge(e, c, l === "exit" ? (f = e.presenceContext) == null ? void 0 : f.custom : void 0);
2873
+ if (d) {
2874
+ const { transition: h, transitionEnd: g, ...y } = d;
2875
+ u = { ...u, ...y, ...g };
2876
+ }
2877
+ return u;
2878
+ };
2879
+ function r(l) {
2880
+ t = l(e);
2881
+ }
2882
+ function o(l) {
2883
+ const { props: u } = e, c = Ls(e.parent) || {}, d = [], f = /* @__PURE__ */ new Set();
2884
+ let h = {}, g = 1 / 0;
2885
+ for (let T = 0; T < La; T++) {
2886
+ const p = Oa[T], V = n[p], m = u[p] !== void 0 ? u[p] : c[p], C = me(m), w = p === l ? V.isActive : null;
2887
+ w === !1 && (g = T);
2888
+ let A = m === c[p] && m !== u[p] && C;
2889
+ if (A && s && e.manuallyAnimateOnMount && (A = !1), V.protectedKeys = { ...h }, // If it isn't active and hasn't *just* been set as inactive
2890
+ !V.isActive && w === null || // If we didn't and don't have any defined prop for this animation type
2891
+ !m && !V.prevProp || // Or if the prop doesn't define an animation
2892
+ Ie(m) || typeof m == "boolean")
2893
+ continue;
2894
+ const x = Na(V.prevProp, m);
2895
+ let S = x || // If we're making this variant active, we want to always make it active
2896
+ p === l && V.isActive && !A && C || // If we removed a higher-priority variant (i is in reverse order)
2897
+ T > g && C, D = !1;
2898
+ const F = Array.isArray(m) ? m : [m];
2899
+ let X = F.reduce(i(p), {});
2900
+ w === !1 && (X = {});
2901
+ const { prevResolvedValues: Nt = {} } = V, js = {
2902
+ ...Nt,
2903
+ ...X
2904
+ }, Bt = (R) => {
2905
+ S = !0, f.has(R) && (D = !0, f.delete(R)), V.needsAnimating[R] = !0;
2906
+ const B = e.getValue(R);
2907
+ B && (B.liveStyle = !1);
2908
+ };
2909
+ for (const R in js) {
2910
+ const B = X[R], Ne = Nt[R];
2911
+ if (h.hasOwnProperty(R))
2912
+ continue;
2913
+ let Be = !1;
2914
+ at(B) && at(Ne) ? Be = !Os(B, Ne) : Be = B !== Ne, Be ? B != null ? Bt(R) : f.add(R) : B !== void 0 && f.has(R) ? Bt(R) : V.protectedKeys[R] = !0;
2915
+ }
2916
+ V.prevProp = m, V.prevResolvedValues = X, V.isActive && (h = { ...h, ...X }), s && e.blockInitialAnimation && (S = !1), S && (!(A && x) || D) && d.push(...F.map((R) => ({
2917
+ animation: R,
2918
+ options: { type: p }
2919
+ })));
2920
+ }
2921
+ if (f.size) {
2922
+ const T = {};
2923
+ if (typeof u.initial != "boolean") {
2924
+ const p = ge(e, Array.isArray(u.initial) ? u.initial[0] : u.initial);
2925
+ p && p.transition && (T.transition = p.transition);
2926
+ }
2927
+ f.forEach((p) => {
2928
+ const V = e.getBaseTarget(p), m = e.getValue(p);
2929
+ m && (m.liveStyle = !0), T[p] = V ?? null;
2930
+ }), d.push({ animation: T });
2931
+ }
2932
+ let y = !!d.length;
2933
+ return s && (u.initial === !1 || u.initial === u.animate) && !e.manuallyAnimateOnMount && (y = !1), s = !1, y ? t(d) : Promise.resolve();
2934
+ }
2935
+ function a(l, u) {
2936
+ var d;
2937
+ if (n[l].isActive === u)
2938
+ return Promise.resolve();
2939
+ (d = e.variantChildren) == null || d.forEach((f) => {
2940
+ var h;
2941
+ return (h = f.animationState) == null ? void 0 : h.setActive(l, u);
2942
+ }), n[l].isActive = u;
2943
+ const c = o(l);
2944
+ for (const f in n)
2945
+ n[f].protectedKeys = {};
2946
+ return c;
2947
+ }
2948
+ return {
2949
+ animateChanges: o,
2950
+ setActive: a,
2951
+ setAnimateFunction: r,
2952
+ getState: () => n,
2953
+ reset: () => {
2954
+ n = pn(), s = !0;
2955
+ }
2956
+ };
2957
+ }
2958
+ function Na(e, t) {
2959
+ return typeof t == "string" ? t !== e : Array.isArray(t) ? !Os(t, e) : !1;
2960
+ }
2961
+ function _(e = !1) {
2962
+ return {
2963
+ isActive: e,
2964
+ protectedKeys: {},
2965
+ needsAnimating: {},
2966
+ prevResolvedValues: {}
2967
+ };
2968
+ }
2969
+ function pn() {
2970
+ return {
2971
+ animate: _(!0),
2972
+ whileInView: _(),
2973
+ whileHover: _(),
2974
+ whileTap: _(),
2975
+ whileDrag: _(),
2976
+ whileFocus: _(),
2977
+ exit: _()
2978
+ };
2979
+ }
2980
+ class ue {
2981
+ constructor(t) {
2982
+ this.isMounted = !1, this.node = t;
2983
+ }
2984
+ update() {
2985
+ }
2986
+ }
2987
+ class Ba extends ue {
2988
+ /**
2989
+ * We dynamically generate the AnimationState manager as it contains a reference
2990
+ * to the underlying animation library. We only want to load that if we load this,
2991
+ * so people can optionally code split it out using the `m` component.
2992
+ */
2993
+ constructor(t) {
2994
+ super(t), t.animationState || (t.animationState = ka(t));
2995
+ }
2996
+ updateAnimationControlsSubscription() {
2997
+ const { animate: t } = this.node.getProps();
2998
+ Ie(t) && (this.unmountControls = t.subscribe(this.node));
2999
+ }
3000
+ /**
3001
+ * Subscribe any provided AnimationControls to the component's VisualElement
3002
+ */
3003
+ mount() {
3004
+ this.updateAnimationControlsSubscription();
3005
+ }
3006
+ update() {
3007
+ const { animate: t } = this.node.getProps(), { animate: n } = this.node.prevProps || {};
3008
+ t !== n && this.updateAnimationControlsSubscription();
3009
+ }
3010
+ unmount() {
3011
+ var t;
3012
+ this.node.animationState.reset(), (t = this.unmountControls) == null || t.call(this);
3013
+ }
3014
+ }
3015
+ let Ka = 0;
3016
+ class Wa extends ue {
3017
+ constructor() {
3018
+ super(...arguments), this.id = Ka++;
3019
+ }
3020
+ update() {
3021
+ if (!this.node.presenceContext)
3022
+ return;
3023
+ const { isPresent: t, onExitComplete: n } = this.node.presenceContext, { isPresent: s } = this.node.prevPresenceContext || {};
3024
+ if (!this.node.animationState || t === s)
3025
+ return;
3026
+ const i = this.node.animationState.setActive("exit", !t);
3027
+ n && !t && i.then(() => {
3028
+ n(this.id);
3029
+ });
3030
+ }
3031
+ mount() {
3032
+ const { register: t, onExitComplete: n } = this.node.presenceContext || {};
3033
+ n && n(this.id), t && (this.unmount = t(this.id));
3034
+ }
3035
+ unmount() {
3036
+ }
3037
+ }
3038
+ const $a = {
3039
+ animation: {
3040
+ Feature: Ba
3041
+ },
3042
+ exit: {
3043
+ Feature: Wa
3044
+ }
3045
+ };
3046
+ function mn(e, t, n, s = { passive: !0 }) {
3047
+ return e.addEventListener(t, n, s), () => e.removeEventListener(t, n);
3048
+ }
3049
+ function Is(e) {
3050
+ return {
3051
+ point: {
3052
+ x: e.pageX,
3053
+ y: e.pageY
3054
+ }
3055
+ };
3056
+ }
3057
+ function _a({ top: e, left: t, right: n, bottom: s }) {
3058
+ return {
3059
+ x: { min: t, max: n },
3060
+ y: { min: e, max: s }
3061
+ };
3062
+ }
3063
+ function ja(e, t) {
3064
+ if (!t)
3065
+ return e;
3066
+ const n = t({ x: e.left, y: e.top }), s = t({ x: e.right, y: e.bottom });
3067
+ return {
3068
+ top: n.y,
3069
+ left: n.x,
3070
+ bottom: s.y,
3071
+ right: s.x
3072
+ };
3073
+ }
3074
+ const gn = () => ({ min: 0, max: 0 }), ks = () => ({
3075
+ x: gn(),
3076
+ y: gn()
3077
+ });
3078
+ function Ua(e, t) {
3079
+ return _a(ja(e.getBoundingClientRect(), t));
3080
+ }
3081
+ function yn(e, t, n) {
3082
+ const { props: s } = e;
3083
+ e.animationState && s.whileHover && e.animationState.setActive("whileHover", n === "Start");
3084
+ const i = "onHover" + n, r = s[i];
3085
+ r && k.postRender(() => r(t, Is(t)));
3086
+ }
3087
+ class Ga extends ue {
3088
+ mount() {
3089
+ const { current: t } = this.node;
3090
+ t && (this.unmount = xo(t, (n, s) => (yn(this.node, s, "Start"), (i) => yn(this.node, i, "End"))));
3091
+ }
3092
+ unmount() {
3093
+ }
3094
+ }
3095
+ class za extends ue {
3096
+ constructor() {
3097
+ super(...arguments), this.isActive = !1;
3098
+ }
3099
+ onFocus() {
3100
+ let t = !1;
3101
+ try {
3102
+ t = this.node.current.matches(":focus-visible");
3103
+ } catch {
3104
+ t = !0;
3105
+ }
3106
+ !t || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
3107
+ }
3108
+ onBlur() {
3109
+ !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
3110
+ }
3111
+ mount() {
3112
+ this.unmount = Re(mn(this.node.current, "focus", () => this.onFocus()), mn(this.node.current, "blur", () => this.onBlur()));
3113
+ }
3114
+ unmount() {
3115
+ }
3116
+ }
3117
+ function bn(e, t, n) {
3118
+ const { props: s } = e;
3119
+ if (e.current instanceof HTMLButtonElement && e.current.disabled)
3120
+ return;
3121
+ e.animationState && s.whileTap && e.animationState.setActive("whileTap", n === "Start");
3122
+ const i = "onTap" + (n === "End" ? "" : n), r = s[i];
3123
+ r && k.postRender(() => r(t, Is(t)));
3124
+ }
3125
+ class Ha extends ue {
3126
+ mount() {
3127
+ const { current: t } = this.node;
3128
+ t && (this.unmount = Po(t, (n, s) => (bn(this.node, s, "Start"), (i, { success: r }) => bn(this.node, i, r ? "End" : "Cancel")), { useGlobalTarget: this.node.props.globalTapTarget }));
3129
+ }
3130
+ unmount() {
3131
+ }
3132
+ }
3133
+ const ut = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), Ya = (e) => {
3134
+ const t = ut.get(e.target);
3135
+ t && t(e);
3136
+ }, Xa = (e) => {
3137
+ e.forEach(Ya);
3138
+ };
3139
+ function qa({ root: e, ...t }) {
3140
+ const n = e || document;
3141
+ ze.has(n) || ze.set(n, {});
3142
+ const s = ze.get(n), i = JSON.stringify(t);
3143
+ return s[i] || (s[i] = new IntersectionObserver(Xa, { root: e, ...t })), s[i];
3144
+ }
3145
+ function Za(e, t, n) {
3146
+ const s = qa(t);
3147
+ return ut.set(e, n), s.observe(e), () => {
3148
+ ut.delete(e), s.unobserve(e);
3149
+ };
3150
+ }
3151
+ const Ja = {
3152
+ some: 0,
3153
+ all: 1
3154
+ };
3155
+ class Qa extends ue {
3156
+ constructor() {
3157
+ super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
3158
+ }
3159
+ startObserver() {
3160
+ this.unmount();
3161
+ const { viewport: t = {} } = this.node.getProps(), { root: n, margin: s, amount: i = "some", once: r } = t, o = {
3162
+ root: n ? n.current : void 0,
3163
+ rootMargin: s,
3164
+ threshold: typeof i == "number" ? i : Ja[i]
3165
+ }, a = (l) => {
3166
+ const { isIntersecting: u } = l;
3167
+ if (this.isInView === u || (this.isInView = u, r && !u && this.hasEnteredView))
3168
+ return;
3169
+ u && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", u);
3170
+ const { onViewportEnter: c, onViewportLeave: d } = this.node.getProps(), f = u ? c : d;
3171
+ f && f(l);
3172
+ };
3173
+ return Za(this.node.current, o, a);
3174
+ }
3175
+ mount() {
3176
+ this.startObserver();
3177
+ }
3178
+ update() {
3179
+ if (typeof IntersectionObserver > "u")
3180
+ return;
3181
+ const { props: t, prevProps: n } = this.node;
3182
+ ["amount", "margin", "root"].some(ec(t, n)) && this.startObserver();
3183
+ }
3184
+ unmount() {
3185
+ }
3186
+ }
3187
+ function ec({ viewport: e = {} }, { viewport: t = {} } = {}) {
3188
+ return (n) => e[n] !== t[n];
3189
+ }
3190
+ const tc = {
3191
+ inView: {
3192
+ Feature: Qa
3193
+ },
3194
+ tap: {
3195
+ Feature: Ha
3196
+ },
3197
+ focus: {
3198
+ Feature: za
3199
+ },
3200
+ hover: {
3201
+ Feature: Ga
3202
+ }
3203
+ }, lt = { current: null }, Ns = { current: !1 };
3204
+ function nc() {
3205
+ if (Ns.current = !0, !!pt)
3206
+ if (window.matchMedia) {
3207
+ const e = window.matchMedia("(prefers-reduced-motion)"), t = () => lt.current = e.matches;
3208
+ e.addEventListener("change", t), t();
3209
+ } else
3210
+ lt.current = !1;
3211
+ }
3212
+ const sc = /* @__PURE__ */ new WeakMap();
3213
+ function ic(e, t, n) {
3214
+ for (const s in t) {
3215
+ const i = t[s], r = n[s];
3216
+ if (O(i))
3217
+ e.addValue(s, i);
3218
+ else if (O(r))
3219
+ e.addValue(s, Ee(i, { owner: e }));
3220
+ else if (r !== i)
3221
+ if (e.hasValue(s)) {
3222
+ const o = e.getValue(s);
3223
+ o.liveStyle === !0 ? o.jump(i) : o.hasAnimated || o.set(i);
3224
+ } else {
3225
+ const o = e.getStaticValue(s);
3226
+ e.addValue(s, Ee(o !== void 0 ? o : i, { owner: e }));
3227
+ }
3228
+ }
3229
+ for (const s in n)
3230
+ t[s] === void 0 && e.removeValue(s);
3231
+ return t;
3232
+ }
3233
+ const vn = [
3234
+ "AnimationStart",
3235
+ "AnimationComplete",
3236
+ "Update",
3237
+ "BeforeLayoutMeasure",
3238
+ "LayoutMeasure",
3239
+ "LayoutAnimationStart",
3240
+ "LayoutAnimationComplete"
3241
+ ];
3242
+ class rc {
3243
+ /**
3244
+ * This method takes React props and returns found MotionValues. For example, HTML
3245
+ * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
3246
+ *
3247
+ * This isn't an abstract method as it needs calling in the constructor, but it is
3248
+ * intended to be one.
3249
+ */
3250
+ scrapeMotionValuesFromProps(t, n, s) {
3251
+ return {};
3252
+ }
3253
+ constructor({ parent: t, props: n, presenceContext: s, reducedMotionConfig: i, blockInitialAnimation: r, visualState: o }, a = {}) {
3254
+ this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = Ct, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => {
3255
+ this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
3256
+ }, this.renderScheduledAt = 0, this.scheduleRender = () => {
3257
+ const f = L.now();
3258
+ this.renderScheduledAt < f && (this.renderScheduledAt = f, k.render(this.render, !1, !0));
3259
+ };
3260
+ const { latestValues: l, renderState: u } = o;
3261
+ this.latestValues = l, this.baseTarget = { ...l }, this.initialValues = n.initial ? { ...l } : {}, this.renderState = u, this.parent = t, this.props = n, this.presenceContext = s, this.depth = t ? t.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!r, this.isControllingVariants = ke(n), this.isVariantNode = ws(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(t && t.current);
3262
+ const { willChange: c, ...d } = this.scrapeMotionValuesFromProps(n, {}, this);
3263
+ for (const f in d) {
3264
+ const h = d[f];
3265
+ l[f] !== void 0 && O(h) && h.set(l[f], !1);
3266
+ }
3267
+ }
3268
+ mount(t) {
3269
+ this.current = t, sc.set(t, this), this.projection && !this.projection.instance && this.projection.mount(t), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((n, s) => this.bindToMotionValue(s, n)), Ns.current || nc(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : lt.current, process.env.NODE_ENV !== "production" && On(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected."), this.parent && this.parent.children.add(this), this.update(this.props, this.presenceContext);
3270
+ }
3271
+ unmount() {
3272
+ this.projection && this.projection.unmount(), Ye(this.notifyUpdate), Ye(this.render), this.valueSubscriptions.forEach((t) => t()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent && this.parent.children.delete(this);
3273
+ for (const t in this.events)
3274
+ this.events[t].clear();
3275
+ for (const t in this.features) {
3276
+ const n = this.features[t];
3277
+ n && (n.unmount(), n.isMounted = !1);
3278
+ }
3279
+ this.current = null;
3280
+ }
3281
+ bindToMotionValue(t, n) {
3282
+ this.valueSubscriptions.has(t) && this.valueSubscriptions.get(t)();
3283
+ const s = ce.has(t);
3284
+ s && this.onBindTransform && this.onBindTransform();
3285
+ const i = n.on("change", (a) => {
3286
+ this.latestValues[t] = a, this.props.onUpdate && k.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0);
3287
+ }), r = n.on("renderRequest", this.scheduleRender);
3288
+ let o;
3289
+ window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, t, n)), this.valueSubscriptions.set(t, () => {
3290
+ i(), r(), o && o(), n.owner && n.stop();
3291
+ });
3292
+ }
3293
+ sortNodePosition(t) {
3294
+ return !this.current || !this.sortInstanceNodePosition || this.type !== t.type ? 0 : this.sortInstanceNodePosition(this.current, t.current);
3295
+ }
3296
+ updateFeatures() {
3297
+ let t = "animation";
3298
+ for (t in te) {
3299
+ const n = te[t];
3300
+ if (!n)
3301
+ continue;
3302
+ const { isEnabled: s, Feature: i } = n;
3303
+ if (!this.features[t] && i && s(this.props) && (this.features[t] = new i(this)), this.features[t]) {
3304
+ const r = this.features[t];
3305
+ r.isMounted ? r.update() : (r.mount(), r.isMounted = !0);
3306
+ }
3307
+ }
3308
+ }
3309
+ triggerBuild() {
3310
+ this.build(this.renderState, this.latestValues, this.props);
3311
+ }
3312
+ /**
3313
+ * Measure the current viewport box with or without transforms.
3314
+ * Only measures axis-aligned boxes, rotate and skew must be manually
3315
+ * removed with a re-render to work.
3316
+ */
3317
+ measureViewportBox() {
3318
+ return this.current ? this.measureInstanceViewportBox(this.current, this.props) : ks();
3319
+ }
3320
+ getStaticValue(t) {
3321
+ return this.latestValues[t];
3322
+ }
3323
+ setStaticValue(t, n) {
3324
+ this.latestValues[t] = n;
3325
+ }
3326
+ /**
3327
+ * Update the provided props. Ensure any newly-added motion values are
3328
+ * added to our map, old ones removed, and listeners updated.
3329
+ */
3330
+ update(t, n) {
3331
+ (t.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = t, this.prevPresenceContext = this.presenceContext, this.presenceContext = n;
3332
+ for (let s = 0; s < vn.length; s++) {
3333
+ const i = vn[s];
3334
+ this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]);
3335
+ const r = "on" + i, o = t[r];
3336
+ o && (this.propEventSubscriptions[i] = this.on(i, o));
3337
+ }
3338
+ this.prevMotionValues = ic(this, this.scrapeMotionValuesFromProps(t, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue();
3339
+ }
3340
+ getProps() {
3341
+ return this.props;
3342
+ }
3343
+ /**
3344
+ * Returns the variant definition with a given name.
3345
+ */
3346
+ getVariant(t) {
3347
+ return this.props.variants ? this.props.variants[t] : void 0;
3348
+ }
3349
+ /**
3350
+ * Returns the defined default transition on this component.
3351
+ */
3352
+ getDefaultTransition() {
3353
+ return this.props.transition;
3354
+ }
3355
+ getTransformPagePoint() {
3356
+ return this.props.transformPagePoint;
3357
+ }
3358
+ getClosestVariantNode() {
3359
+ return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0;
3360
+ }
3361
+ /**
3362
+ * Add a child visual element to our set of children.
3363
+ */
3364
+ addVariantChild(t) {
3365
+ const n = this.getClosestVariantNode();
3366
+ if (n)
3367
+ return n.variantChildren && n.variantChildren.add(t), () => n.variantChildren.delete(t);
3368
+ }
3369
+ /**
3370
+ * Add a motion value and bind it to this visual element.
3371
+ */
3372
+ addValue(t, n) {
3373
+ const s = this.values.get(t);
3374
+ n !== s && (s && this.removeValue(t), this.bindToMotionValue(t, n), this.values.set(t, n), this.latestValues[t] = n.get());
3375
+ }
3376
+ /**
3377
+ * Remove a motion value and unbind any active subscriptions.
3378
+ */
3379
+ removeValue(t) {
3380
+ this.values.delete(t);
3381
+ const n = this.valueSubscriptions.get(t);
3382
+ n && (n(), this.valueSubscriptions.delete(t)), delete this.latestValues[t], this.removeValueFromRenderState(t, this.renderState);
3383
+ }
3384
+ /**
3385
+ * Check whether we have a motion value for this key
3386
+ */
3387
+ hasValue(t) {
3388
+ return this.values.has(t);
3389
+ }
3390
+ getValue(t, n) {
3391
+ if (this.props.values && this.props.values[t])
3392
+ return this.props.values[t];
3393
+ let s = this.values.get(t);
3394
+ return s === void 0 && n !== void 0 && (s = Ee(n === null ? void 0 : n, { owner: this }), this.addValue(t, s)), s;
3395
+ }
3396
+ /**
3397
+ * If we're trying to animate to a previously unencountered value,
3398
+ * we need to check for it in our state and as a last resort read it
3399
+ * directly from the instance (which might have performance implications).
3400
+ */
3401
+ readValue(t, n) {
3402
+ let s = this.latestValues[t] !== void 0 || !this.current ? this.latestValues[t] : this.getBaseTargetFromProps(this.props, t) ?? this.readValueFromInstance(this.current, t, this.options);
3403
+ return s != null && (typeof s == "string" && (Pn(s) || En(s)) ? s = parseFloat(s) : !Do(s) && oe.test(n) && (s = ms(t, n)), this.setBaseTarget(t, O(s) ? s.get() : s)), O(s) ? s.get() : s;
3404
+ }
3405
+ /**
3406
+ * Set the base target to later animate back to. This is currently
3407
+ * only hydrated on creation and when we first read a value.
3408
+ */
3409
+ setBaseTarget(t, n) {
3410
+ this.baseTarget[t] = n;
3411
+ }
3412
+ /**
3413
+ * Find the base target for a value thats been removed from all animation
3414
+ * props.
3415
+ */
3416
+ getBaseTarget(t) {
3417
+ var r;
3418
+ const { initial: n } = this.props;
3419
+ let s;
3420
+ if (typeof n == "string" || typeof n == "object") {
3421
+ const o = It(this.props, n, (r = this.presenceContext) == null ? void 0 : r.custom);
3422
+ o && (s = o[t]);
3423
+ }
3424
+ if (n && s !== void 0)
3425
+ return s;
3426
+ const i = this.getBaseTargetFromProps(this.props, t);
3427
+ return i !== void 0 && !O(i) ? i : this.initialValues[t] !== void 0 && s === void 0 ? void 0 : this.baseTarget[t];
3428
+ }
3429
+ on(t, n) {
3430
+ return this.events[t] || (this.events[t] = new Fn()), this.events[t].add(n);
3431
+ }
3432
+ notify(t, ...n) {
3433
+ this.events[t] && this.events[t].notify(...n);
3434
+ }
3435
+ }
3436
+ class Bs extends rc {
3437
+ constructor() {
3438
+ super(...arguments), this.KeyframeResolver = go;
3439
+ }
3440
+ sortInstanceNodePosition(t, n) {
3441
+ return t.compareDocumentPosition(n) & 2 ? 1 : -1;
3442
+ }
3443
+ getBaseTargetFromProps(t, n) {
3444
+ return t.style ? t.style[n] : void 0;
3445
+ }
3446
+ removeValueFromRenderState(t, { vars: n, style: s }) {
3447
+ delete n[t], delete s[t];
3448
+ }
3449
+ handleChildMotionValue() {
3450
+ this.childSubscription && (this.childSubscription(), delete this.childSubscription);
3451
+ const { children: t } = this.props;
3452
+ O(t) && (this.childSubscription = t.on("change", (n) => {
3453
+ this.current && (this.current.textContent = `${n}`);
3454
+ }));
3455
+ }
3456
+ }
3457
+ function Ks(e, { style: t, vars: n }, s, i) {
3458
+ const r = e.style;
3459
+ let o;
3460
+ for (o in t)
3461
+ r[o] = t[o];
3462
+ i == null || i.applyProjectionStyles(r, s);
3463
+ for (o in n)
3464
+ r.setProperty(o, n[o]);
3465
+ }
3466
+ function oc(e) {
3467
+ return window.getComputedStyle(e);
3468
+ }
3469
+ class ac extends Bs {
3470
+ constructor() {
3471
+ super(...arguments), this.type = "html", this.renderInstance = Ks;
3472
+ }
3473
+ readValueFromInstance(t, n) {
3474
+ var s;
3475
+ if (ce.has(n))
3476
+ return (s = this.projection) != null && s.isProjecting ? tt(n) : Or(t, n);
3477
+ {
3478
+ const i = oc(t), r = (Gn(n) ? i.getPropertyValue(n) : i[n]) || 0;
3479
+ return typeof r == "string" ? r.trim() : r;
3480
+ }
3481
+ }
3482
+ measureInstanceViewportBox(t, { transformPagePoint: n }) {
3483
+ return Ua(t, n);
3484
+ }
3485
+ build(t, n, s) {
3486
+ Rt(t, n, s.transformTemplate);
3487
+ }
3488
+ scrapeMotionValuesFromProps(t, n, s) {
3489
+ return kt(t, n, s);
3490
+ }
3491
+ }
3492
+ const Ws = /* @__PURE__ */ new Set([
3493
+ "baseFrequency",
3494
+ "diffuseConstant",
3495
+ "kernelMatrix",
3496
+ "kernelUnitLength",
3497
+ "keySplines",
3498
+ "keyTimes",
3499
+ "limitingConeAngle",
3500
+ "markerHeight",
3501
+ "markerWidth",
3502
+ "numOctaves",
3503
+ "targetX",
3504
+ "targetY",
3505
+ "surfaceScale",
3506
+ "specularConstant",
3507
+ "specularExponent",
3508
+ "stdDeviation",
3509
+ "tableValues",
3510
+ "viewBox",
3511
+ "gradientTransform",
3512
+ "pathLength",
3513
+ "startOffset",
3514
+ "textLength",
3515
+ "lengthAdjust"
3516
+ ]);
3517
+ function cc(e, t, n, s) {
3518
+ Ks(e, t, void 0, s);
3519
+ for (const i in t.attrs)
3520
+ e.setAttribute(Ws.has(i) ? i : Ft(i), t.attrs[i]);
3521
+ }
3522
+ class uc extends Bs {
3523
+ constructor() {
3524
+ super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = ks;
3525
+ }
3526
+ getBaseTargetFromProps(t, n) {
3527
+ return t[n];
3528
+ }
3529
+ readValueFromInstance(t, n) {
3530
+ if (ce.has(n)) {
3531
+ const s = ps(n);
3532
+ return s && s.default || 0;
3533
+ }
3534
+ return n = Ws.has(n) ? n : Ft(n), t.getAttribute(n);
3535
+ }
3536
+ scrapeMotionValuesFromProps(t, n, s) {
3537
+ return Fs(t, n, s);
3538
+ }
3539
+ build(t, n, s) {
3540
+ Ms(t, n, this.isSVGTag, s.transformTemplate, s.style);
3541
+ }
3542
+ renderInstance(t, n, s, i) {
3543
+ cc(t, n, s, i);
3544
+ }
3545
+ mount(t) {
3546
+ this.isSVGTag = Es(t.tagName), super.mount(t);
3547
+ }
3548
+ }
3549
+ const lc = (e, t) => Lt(e) ? new uc(t) : new ac(t, {
3550
+ allowProjection: e !== Tn
3551
+ }), fc = {
3552
+ renderer: lc,
3553
+ ...$a,
3554
+ ...tc
3555
+ }, ft = /* @__PURE__ */ da("div"), $s = ne.createContext({
3556
+ layers: [],
3557
+ setLayers: () => {
3558
+ },
3559
+ addLayer: () => {
3560
+ },
3561
+ removeLayer: () => {
3562
+ },
3563
+ removeTopLayer: () => {
3564
+ }
3565
+ }), Dc = ({ children: e }) => {
3566
+ const [t, n] = ne.useState([]), s = (o) => {
3567
+ n((a) => [...a, o]);
3568
+ }, i = (o) => {
3569
+ n(t.filter((a) => a !== o));
3570
+ }, r = () => {
3571
+ const o = t[t.length - 1];
3572
+ o && i(o);
3573
+ };
3574
+ return /* @__PURE__ */ M(
3575
+ $s.Provider,
3576
+ {
3577
+ value: { layers: t, setLayers: n, addLayer: s, removeLayer: i, removeTopLayer: r },
3578
+ children: e
3579
+ }
3580
+ );
3581
+ }, _s = () => ne.useContext($s), dc = ({
3582
+ defaultOpen: e,
3583
+ open: t,
3584
+ onOpenChange: n,
3585
+ ...s
3586
+ }) => {
3587
+ const [i, r] = Si({
3588
+ prop: t,
3589
+ onChange: n,
3590
+ defaultProp: e ?? !1
3591
+ }), o = _s(), a = s.a11yTitle;
3592
+ if (ne.useEffect(() => {
3593
+ !i && o.layers.includes(a) && o.removeLayer(a);
3594
+ }, [a, o, i]), !!i)
3595
+ return /* @__PURE__ */ M(hc, { open: i, onOpenChange: r, ...s });
3596
+ }, hc = ({
3597
+ open: e,
3598
+ onOpenChange: t,
3599
+ a11yTitle: n,
3600
+ a11yDescription: s,
3601
+ children: i,
3602
+ // Focus scope props
3603
+ trapped: r,
3604
+ onMountAutoFocus: o,
3605
+ onUnmountAutoFocus: a,
3606
+ ...l
3607
+ }) => {
3608
+ var y, T;
3609
+ const u = n, c = _s();
3610
+ ne.useEffect(() => {
3611
+ !c || !e || c.layers.includes(u) || c.addLayer(u);
3612
+ }, [u, c, e]);
3613
+ const d = ((y = c.layers) == null ? void 0 : y.indexOf(u)) || 0, f = ((T = c.layers) == null ? void 0 : T.length) || 0, h = d !== 0, g = u === c.layers[c.layers.length - 1];
3614
+ return /* @__PURE__ */ M(Fo, { features: fc, children: /* @__PURE__ */ M(
3615
+ An,
3616
+ {
3617
+ onEscapeKeyDown: (p) => {
3618
+ g && (p.preventDefault(), c.removeTopLayer(), t(!1));
3619
+ },
3620
+ onPointerDownOutside: (p) => {
3621
+ g && (p.preventDefault(), c.removeTopLayer(), t(!1));
3622
+ },
3623
+ children: /* @__PURE__ */ Ve(
3624
+ J.Root,
3625
+ {
3626
+ open: e,
3627
+ onOpenChange: (p) => {
3628
+ var m;
3629
+ if (((m = c == null ? void 0 : c.layers) == null ? void 0 : m.length) > 0)
3630
+ return p === !1 && u === c.layers[c.layers.length - 1] ? (c.removeLayer(u), t(!1)) : void 0;
3631
+ t(p);
3632
+ },
3633
+ children: [
3634
+ /* @__PURE__ */ Ve(Qs.Root, { children: [
3635
+ /* @__PURE__ */ M(J.Title, { children: n }),
3636
+ s && /* @__PURE__ */ M(J.Description, { children: s })
3637
+ ] }),
3638
+ e && // We add the className "tgph" here so that styles within
3639
+ // the portal get scoped properly to telegraph
3640
+ /* @__PURE__ */ M(Js.Root, { className: "tgph", children: /* @__PURE__ */ M(pc, { layer: d, children: /* @__PURE__ */ M(
3641
+ Zs,
3642
+ {
3643
+ trapped: typeof r == "boolean" ? r : g,
3644
+ onMountAutoFocus: o,
3645
+ onUnmountAutoFocus: a,
3646
+ asChild: !0,
3647
+ children: /* @__PURE__ */ M(ti, { children: /* @__PURE__ */ M(
3648
+ ee,
3649
+ {
3650
+ as: ft,
3651
+ initial: {
3652
+ top: `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${f - 1})`
3653
+ },
3654
+ animate: {
3655
+ top: h ? `calc(var(--tgph-spacing-16) + var(--tgph-spacing-4) * ${d} )` : "var(--tgph-spacing-16)"
3656
+ },
3657
+ exit: { top: 0 },
3658
+ transition: { type: "spring", duration: 0.3, bounce: 0 },
3659
+ w: "full",
3660
+ justify: "center",
3661
+ style: {
3662
+ position: "fixed",
3663
+ left: 0,
3664
+ maxHeight: "calc(100vh - var(--tgph-spacing-32))",
3665
+ maxWidth: "calc(100vw - var(--tgph-spacing-8))",
3666
+ zIndex: `calc(var(--tgph-zIndex-modal) + ${d})`
3667
+ },
3668
+ children: /* @__PURE__ */ M(
3669
+ ee,
3670
+ {
3671
+ direction: "column",
3672
+ as: ft,
3673
+ animate: {
3674
+ scale: 1.02 - Math.abs(f - d) * 0.02,
3675
+ transformOrigin: "center center"
3676
+ },
3677
+ transition: {
3678
+ duration: 0.2,
3679
+ bounce: 0,
3680
+ type: "spring"
3681
+ },
3682
+ maxW: l.maxW ?? "160",
3683
+ w: l.w ?? "full",
3684
+ bg: "surface-1",
3685
+ border: "px",
3686
+ rounded: "4",
3687
+ shadow: "3",
3688
+ ...l,
3689
+ children: i
3690
+ },
3691
+ `content-${u}`
3692
+ )
3693
+ },
3694
+ `container-${u}`
3695
+ ) })
3696
+ }
3697
+ ) }) })
3698
+ ]
3699
+ },
3700
+ u
3701
+ )
3702
+ }
3703
+ ) });
3704
+ }, pc = ({ layer: e, children: t }) => e > 0 ? t : /* @__PURE__ */ Ve(J.Overlay, { children: [
3705
+ /* @__PURE__ */ M(
3706
+ ni,
452
3707
  {
453
- as: T.div,
3708
+ as: ft,
454
3709
  initial: { opacity: 0 },
455
3710
  animate: { opacity: 1 },
456
3711
  exit: { opacity: 0 },
@@ -467,26 +3722,26 @@ const K = g.createContext({
467
3722
  }
468
3723
  ),
469
3724
  t
470
- ] }), De = g.forwardRef(
471
- ({ children: e, ...t }, r) => /* @__PURE__ */ d(v.Content, { ref: r, asChild: !0, ...t, children: /* @__PURE__ */ d(E, { direction: "column", h: "full", ...t, children: e }) })
472
- ), Oe = ({
3725
+ ] }), mc = ne.forwardRef(
3726
+ ({ children: e, ...t }, n) => /* @__PURE__ */ M(J.Content, { ref: n, asChild: !0, ...t, children: /* @__PURE__ */ M(ee, { direction: "column", h: "full", ...t, children: e }) })
3727
+ ), gc = ({
473
3728
  size: e = "1",
474
3729
  variant: t = "ghost",
475
- ...r
476
- }) => /* @__PURE__ */ d(v.Close, { asChild: !0, children: /* @__PURE__ */ d(
477
- J,
3730
+ ...n
3731
+ }) => /* @__PURE__ */ M(J.Close, { asChild: !0, children: /* @__PURE__ */ M(
3732
+ ei,
478
3733
  {
479
- icon: { icon: ee.X, alt: "Close Modal" },
3734
+ icon: { icon: si, alt: "Close Modal" },
480
3735
  variant: t,
481
3736
  size: e,
482
- ...r
3737
+ ...n
483
3738
  }
484
- ) }), Se = ({
3739
+ ) }), yc = ({
485
3740
  style: e,
486
3741
  children: t,
487
- ...r
488
- }) => /* @__PURE__ */ d(
489
- E,
3742
+ ...n
3743
+ }) => /* @__PURE__ */ M(
3744
+ ee,
490
3745
  {
491
3746
  direction: "column",
492
3747
  px: "6",
@@ -495,14 +3750,14 @@ const K = g.createContext({
495
3750
  overflowY: "auto",
496
3751
  ...e
497
3752
  },
498
- ...r,
3753
+ ...n,
499
3754
  children: t
500
3755
  }
501
- ), Te = ({
3756
+ ), bc = ({
502
3757
  children: e,
503
3758
  ...t
504
- }) => /* @__PURE__ */ d(
505
- E,
3759
+ }) => /* @__PURE__ */ M(
3760
+ ee,
506
3761
  {
507
3762
  direction: "row",
508
3763
  justify: "space-between",
@@ -513,11 +3768,11 @@ const K = g.createContext({
513
3768
  ...t,
514
3769
  children: e
515
3770
  }
516
- ), Be = ({
3771
+ ), vc = ({
517
3772
  children: e,
518
3773
  ...t
519
- }) => /* @__PURE__ */ d(
520
- E,
3774
+ }) => /* @__PURE__ */ M(
3775
+ ee,
521
3776
  {
522
3777
  direction: "row",
523
3778
  align: "center",
@@ -529,17 +3784,17 @@ const K = g.createContext({
529
3784
  ...t,
530
3785
  children: e
531
3786
  }
532
- ), Ie = {};
533
- Object.assign(Ie, {
534
- Root: we,
535
- Content: De,
536
- Close: Oe,
537
- Body: Se,
538
- Header: Te,
539
- Footer: Be
3787
+ ), Tc = {};
3788
+ Object.assign(Tc, {
3789
+ Root: dc,
3790
+ Content: mc,
3791
+ Close: gc,
3792
+ Body: yc,
3793
+ Header: bc,
3794
+ Footer: vc
540
3795
  });
541
3796
  export {
542
- Ie as Modal,
543
- je as ModalStackingProvider
3797
+ Tc as Modal,
3798
+ Dc as ModalStackingProvider
544
3799
  };
545
3800
  //# sourceMappingURL=index.mjs.map