@mathwiz/ui-components 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2596 +0,0 @@
1
- import { i as q, n as _e, a as Ct, c as Y, p as Ve, w as he, b as Ue, d as Pt, t as Ft, e as kn, v as Kn, f as Bn, g as Ln, h as Dt, j as _n, k as Un, l as k, m as $n, o as Gn, q as fe, r as nt, s as Et, u as jn, x as Wn, y as Hn, z as Ot, A as zn, B as qn, C as Yn, D as Xn, E as Zn, F as It, G as Rt, H as Nt, I as kt } from "./index-B6Xq3xq4.js";
2
- import { Fragment as Jn } from "react";
3
- function Qn(t, e) {
4
- t.indexOf(e) === -1 && t.push(e);
5
- }
6
- function es(t, e) {
7
- const n = t.indexOf(e);
8
- n > -1 && t.splice(n, 1);
9
- }
10
- const N = {}, Kt = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), Bt = (t) => /^0[^.\s]+$/u.test(t);
11
- // @__NO_SIDE_EFFECTS__
12
- function $e(t) {
13
- let e;
14
- return () => (e === void 0 && (e = t()), e);
15
- }
16
- const X = /* @__NO_SIDE_EFFECTS__ */ (t) => t, ts = (t, e) => (n) => e(t(n)), de = (...t) => t.reduce(ts), Lt = /* @__NO_SIDE_EFFECTS__ */ (t, e, n) => {
17
- const s = e - t;
18
- return s === 0 ? 1 : (n - t) / s;
19
- };
20
- class _t {
21
- constructor() {
22
- this.subscriptions = [];
23
- }
24
- add(e) {
25
- return Qn(this.subscriptions, e), () => es(this.subscriptions, e);
26
- }
27
- notify(e, n, s) {
28
- const i = this.subscriptions.length;
29
- if (i)
30
- if (i === 1)
31
- this.subscriptions[0](e, n, s);
32
- else
33
- for (let r = 0; r < i; r++) {
34
- const a = this.subscriptions[r];
35
- a && a(e, n, s);
36
- }
37
- }
38
- getSize() {
39
- return this.subscriptions.length;
40
- }
41
- clear() {
42
- this.subscriptions.length = 0;
43
- }
44
- }
45
- const I = /* @__NO_SIDE_EFFECTS__ */ (t) => t * 1e3, R = /* @__NO_SIDE_EFFECTS__ */ (t) => t / 1e3;
46
- function Ut(t, e) {
47
- return e ? t * (1e3 / e) : 0;
48
- }
49
- const $t = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, ns = 1e-7, ss = 12;
50
- function is(t, e, n, s, i) {
51
- let r, a, o = 0;
52
- do
53
- a = e + (n - e) / 2, r = $t(a, s, i) - t, r > 0 ? n = a : e = a;
54
- while (Math.abs(r) > ns && ++o < ss);
55
- return a;
56
- }
57
- function ne(t, e, n, s) {
58
- if (t === e && n === s)
59
- return X;
60
- const i = (r) => is(r, 0, 1, t, n);
61
- return (r) => r === 0 || r === 1 ? r : $t(i(r), e, s);
62
- }
63
- const Gt = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, jt = (t) => (e) => 1 - t(1 - e), Wt = /* @__PURE__ */ ne(0.33, 1.53, 0.69, 0.99), Ge = /* @__PURE__ */ jt(Wt), Ht = /* @__PURE__ */ Gt(Ge), zt = (t) => (t *= 2) < 1 ? 0.5 * Ge(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), je = (t) => 1 - Math.sin(Math.acos(t)), rs = jt(je), qt = Gt(je), as = /* @__PURE__ */ ne(0.42, 0, 1, 1), os = /* @__PURE__ */ ne(0, 0, 0.58, 1), Yt = /* @__PURE__ */ ne(0.42, 0, 0.58, 1), us = (t) => Array.isArray(t) && typeof t[0] != "number", Xt = (t) => Array.isArray(t) && typeof t[0] == "number", st = {
64
- linear: X,
65
- easeIn: as,
66
- easeInOut: Yt,
67
- easeOut: os,
68
- circIn: je,
69
- circInOut: qt,
70
- circOut: rs,
71
- backIn: Ge,
72
- backInOut: Ht,
73
- backOut: Wt,
74
- anticipate: zt
75
- }, ls = (t) => typeof t == "string", it = (t) => {
76
- if (Xt(t)) {
77
- q(t.length === 4, "Cubic bezier arrays must contain four numerical values.", "cubic-bezier-length");
78
- const [e, n, s, i] = t;
79
- return ne(e, n, s, i);
80
- } else if (ls(t))
81
- return q(st[t] !== void 0, `Invalid easing type '${t}'`, "invalid-easing-type"), st[t];
82
- return t;
83
- }, se = [
84
- "setup",
85
- // Compute
86
- "read",
87
- // Read
88
- "resolveKeyframes",
89
- // Write/Read/Write/Read
90
- "preUpdate",
91
- // Compute
92
- "update",
93
- // Compute
94
- "preRender",
95
- // Compute
96
- "render",
97
- // Write
98
- "postRender"
99
- // Compute
100
- ];
101
- function cs(t, e) {
102
- let n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = !1, r = !1;
103
- const a = /* @__PURE__ */ new WeakSet();
104
- let o = {
105
- delta: 0,
106
- timestamp: 0,
107
- isProcessing: !1
108
- };
109
- function u(l) {
110
- a.has(l) && (c.schedule(l), t()), l(o);
111
- }
112
- const c = {
113
- /**
114
- * Schedule a process to run on the next frame.
115
- */
116
- schedule: (l, h = !1, f = !1) => {
117
- const v = f && i ? n : s;
118
- return h && a.add(l), v.has(l) || v.add(l), l;
119
- },
120
- /**
121
- * Cancel the provided callback from running on the next frame.
122
- */
123
- cancel: (l) => {
124
- s.delete(l), a.delete(l);
125
- },
126
- /**
127
- * Execute all schedule callbacks.
128
- */
129
- process: (l) => {
130
- if (o = l, i) {
131
- r = !0;
132
- return;
133
- }
134
- i = !0, [n, s] = [s, n], n.forEach(u), n.clear(), i = !1, r && (r = !1, c.process(l));
135
- }
136
- };
137
- return c;
138
- }
139
- const hs = 40;
140
- function Zt(t, e) {
141
- let n = !1, s = !0;
142
- const i = {
143
- delta: 0,
144
- timestamp: 0,
145
- isProcessing: !1
146
- }, r = () => n = !0, a = se.reduce((g, S) => (g[S] = cs(r), g), {}), { setup: o, read: u, resolveKeyframes: c, preUpdate: l, update: h, preRender: f, render: d, postRender: v } = a, T = () => {
147
- const g = N.useManualTiming ? i.timestamp : performance.now();
148
- n = !1, N.useManualTiming || (i.delta = s ? 1e3 / 60 : Math.max(Math.min(g - i.timestamp, hs), 1)), i.timestamp = g, i.isProcessing = !0, o.process(i), u.process(i), c.process(i), l.process(i), h.process(i), f.process(i), d.process(i), v.process(i), i.isProcessing = !1, n && e && (s = !1, t(T));
149
- }, b = () => {
150
- n = !0, s = !0, i.isProcessing || t(T);
151
- };
152
- return { schedule: se.reduce((g, S) => {
153
- const m = a[S];
154
- return g[S] = (A, M = !1, y = !1) => (n || b(), m.schedule(A, M, y)), g;
155
- }, {}), cancel: (g) => {
156
- for (let S = 0; S < se.length; S++)
157
- a[se[S]].cancel(g);
158
- }, state: i, steps: a };
159
- }
160
- const { schedule: O, cancel: Ae, state: ae } = /* @__PURE__ */ Zt(typeof requestAnimationFrame < "u" ? requestAnimationFrame : X, !0);
161
- let ie;
162
- function fs() {
163
- ie = void 0;
164
- }
165
- const E = {
166
- now: () => (ie === void 0 && E.set(ae.isProcessing || N.useManualTiming ? ae.timestamp : performance.now()), ie),
167
- set: (t) => {
168
- ie = t, queueMicrotask(fs);
169
- }
170
- }, ee = (t) => Math.round(t * 1e5) / 1e5, We = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
171
- function ds(t) {
172
- return t == null;
173
- }
174
- const ps = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, He = (t, e) => (n) => !!(typeof n == "string" && ps.test(n) && n.startsWith(t) || e && !ds(n) && Object.prototype.hasOwnProperty.call(n, e)), Jt = (t, e, n) => (s) => {
175
- if (typeof s != "string")
176
- return s;
177
- const [i, r, a, o] = s.match(We);
178
- return {
179
- [t]: parseFloat(i),
180
- [e]: parseFloat(r),
181
- [n]: parseFloat(a),
182
- alpha: o !== void 0 ? parseFloat(o) : 1
183
- };
184
- }, ms = (t) => Y(0, 255, t), me = {
185
- ..._e,
186
- transform: (t) => Math.round(ms(t))
187
- }, L = {
188
- test: /* @__PURE__ */ He("rgb", "red"),
189
- parse: /* @__PURE__ */ Jt("red", "green", "blue"),
190
- transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + me.transform(t) + ", " + me.transform(e) + ", " + me.transform(n) + ", " + ee(Ct.transform(s)) + ")"
191
- };
192
- function gs(t) {
193
- let e = "", n = "", s = "", i = "";
194
- return t.length > 5 ? (e = t.substring(1, 3), n = t.substring(3, 5), s = t.substring(5, 7), i = t.substring(7, 9)) : (e = t.substring(1, 2), n = t.substring(2, 3), s = t.substring(3, 4), i = t.substring(4, 5), e += e, n += n, s += s, i += i), {
195
- red: parseInt(e, 16),
196
- green: parseInt(n, 16),
197
- blue: parseInt(s, 16),
198
- alpha: i ? parseInt(i, 16) / 255 : 1
199
- };
200
- }
201
- const we = {
202
- test: /* @__PURE__ */ He("#"),
203
- parse: gs,
204
- transform: L.transform
205
- }, W = {
206
- test: /* @__PURE__ */ He("hsl", "hue"),
207
- parse: /* @__PURE__ */ Jt("hue", "saturation", "lightness"),
208
- transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + Ve.transform(ee(e)) + ", " + Ve.transform(ee(n)) + ", " + ee(Ct.transform(s)) + ")"
209
- }, x = {
210
- test: (t) => L.test(t) || we.test(t) || W.test(t),
211
- parse: (t) => L.test(t) ? L.parse(t) : W.test(t) ? W.parse(t) : we.parse(t),
212
- transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? L.transform(t) : W.transform(t),
213
- getAnimatableNone: (t) => {
214
- const e = x.parse(t);
215
- return e.alpha = 0, x.transform(e);
216
- }
217
- }, ys = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
218
- function bs(t) {
219
- return isNaN(t) && typeof t == "string" && (t.match(We)?.length || 0) + (t.match(ys)?.length || 0) > 0;
220
- }
221
- const Qt = "number", en = "color", vs = "var", Ts = "var(", rt = "${}", Vs = /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;
222
- function te(t) {
223
- const e = t.toString(), n = [], s = {
224
- color: [],
225
- number: [],
226
- var: []
227
- }, i = [];
228
- let r = 0;
229
- const o = e.replace(Vs, (u) => (x.test(u) ? (s.color.push(r), i.push(en), n.push(x.parse(u))) : u.startsWith(Ts) ? (s.var.push(r), i.push(vs), n.push(u)) : (s.number.push(r), i.push(Qt), n.push(parseFloat(u))), ++r, rt)).split(rt);
230
- return { values: n, split: o, indexes: s, types: i };
231
- }
232
- function tn(t) {
233
- return te(t).values;
234
- }
235
- function nn(t) {
236
- const { split: e, types: n } = te(t), s = e.length;
237
- return (i) => {
238
- let r = "";
239
- for (let a = 0; a < s; a++)
240
- if (r += e[a], i[a] !== void 0) {
241
- const o = n[a];
242
- o === Qt ? r += ee(i[a]) : o === en ? r += x.transform(i[a]) : r += i[a];
243
- }
244
- return r;
245
- };
246
- }
247
- const As = (t) => typeof t == "number" ? 0 : x.test(t) ? x.getAnimatableNone(t) : t;
248
- function ws(t) {
249
- const e = tn(t);
250
- return nn(t)(e.map(As));
251
- }
252
- const Z = {
253
- test: bs,
254
- parse: tn,
255
- createTransformer: nn,
256
- getAnimatableNone: ws
257
- };
258
- function ge(t, e, n) {
259
- return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (e - t) * 6 * n : n < 1 / 2 ? e : n < 2 / 3 ? t + (e - t) * (2 / 3 - n) * 6 : t;
260
- }
261
- function Ss({ hue: t, saturation: e, lightness: n, alpha: s }) {
262
- t /= 360, e /= 100, n /= 100;
263
- let i = 0, r = 0, a = 0;
264
- if (!e)
265
- i = r = a = n;
266
- else {
267
- const o = n < 0.5 ? n * (1 + e) : n + e - n * e, u = 2 * n - o;
268
- i = ge(u, o, t + 1 / 3), r = ge(u, o, t), a = ge(u, o, t - 1 / 3);
269
- }
270
- return {
271
- red: Math.round(i * 255),
272
- green: Math.round(r * 255),
273
- blue: Math.round(a * 255),
274
- alpha: s
275
- };
276
- }
277
- function oe(t, e) {
278
- return (n) => n > 0 ? e : t;
279
- }
280
- const pe = (t, e, n) => t + (e - t) * n, ye = (t, e, n) => {
281
- const s = t * t, i = n * (e * e - s) + s;
282
- return i < 0 ? 0 : Math.sqrt(i);
283
- }, xs = [we, L, W], Ms = (t) => xs.find((e) => e.test(t));
284
- function at(t) {
285
- const e = Ms(t);
286
- if (he(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`, "color-not-animatable"), !e)
287
- return !1;
288
- let n = e.parse(t);
289
- return e === W && (n = Ss(n)), n;
290
- }
291
- const ot = (t, e) => {
292
- const n = at(t), s = at(e);
293
- if (!n || !s)
294
- return oe(t, e);
295
- const i = { ...n };
296
- return (r) => (i.red = ye(n.red, s.red, r), i.green = ye(n.green, s.green, r), i.blue = ye(n.blue, s.blue, r), i.alpha = pe(n.alpha, s.alpha, r), L.transform(i));
297
- }, Se = /* @__PURE__ */ new Set(["none", "hidden"]);
298
- function Cs(t, e) {
299
- return Se.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
300
- }
301
- function Ps(t, e) {
302
- return (n) => pe(t, e, n);
303
- }
304
- function ze(t) {
305
- return typeof t == "number" ? Ps : typeof t == "string" ? Ue(t) ? oe : x.test(t) ? ot : Es : Array.isArray(t) ? sn : typeof t == "object" ? x.test(t) ? ot : Fs : oe;
306
- }
307
- function sn(t, e) {
308
- const n = [...t], s = n.length, i = t.map((r, a) => ze(r)(r, e[a]));
309
- return (r) => {
310
- for (let a = 0; a < s; a++)
311
- n[a] = i[a](r);
312
- return n;
313
- };
314
- }
315
- function Fs(t, e) {
316
- const n = { ...t, ...e }, s = {};
317
- for (const i in n)
318
- t[i] !== void 0 && e[i] !== void 0 && (s[i] = ze(t[i])(t[i], e[i]));
319
- return (i) => {
320
- for (const r in s)
321
- n[r] = s[r](i);
322
- return n;
323
- };
324
- }
325
- function Ds(t, e) {
326
- const n = [], s = { color: 0, var: 0, number: 0 };
327
- for (let i = 0; i < e.values.length; i++) {
328
- const r = e.types[i], a = t.indexes[r][s[r]], o = t.values[a] ?? 0;
329
- n[i] = o, s[r]++;
330
- }
331
- return n;
332
- }
333
- const Es = (t, e) => {
334
- const n = Z.createTransformer(e), s = te(t), i = te(e);
335
- 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 ? Se.has(t) && !i.values.length || Se.has(e) && !s.values.length ? Cs(t, e) : de(sn(Ds(s, i), i.values), n) : (he(!0, `Complex values '${t}' and '${e}' 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.`, "complex-values-different"), oe(t, e));
336
- };
337
- function rn(t, e, n) {
338
- return typeof t == "number" && typeof e == "number" && typeof n == "number" ? pe(t, e, n) : ze(t)(t, e);
339
- }
340
- const Os = (t) => {
341
- const e = ({ timestamp: n }) => t(n);
342
- return {
343
- start: (n = !0) => O.update(e, n),
344
- stop: () => Ae(e),
345
- /**
346
- * If we're processing this frame we can use the
347
- * framelocked timestamp to keep things in sync.
348
- */
349
- now: () => ae.isProcessing ? ae.timestamp : E.now()
350
- };
351
- }, an = (t, e, n = 10) => {
352
- let s = "";
353
- const i = Math.max(Math.round(e / n), 2);
354
- for (let r = 0; r < i; r++)
355
- s += Math.round(t(r / (i - 1)) * 1e4) / 1e4 + ", ";
356
- return `linear(${s.substring(0, s.length - 2)})`;
357
- }, ue = 2e4;
358
- function qe(t) {
359
- let e = 0;
360
- const n = 50;
361
- let s = t.next(e);
362
- for (; !s.done && e < ue; )
363
- e += n, s = t.next(e);
364
- return e >= ue ? 1 / 0 : e;
365
- }
366
- function Is(t, e = 100, n) {
367
- const s = n({ ...t, keyframes: [0, e] }), i = Math.min(qe(s), ue);
368
- return {
369
- type: "keyframes",
370
- ease: (r) => s.next(i * r).value / e,
371
- duration: /* @__PURE__ */ R(i)
372
- };
373
- }
374
- const Rs = 5;
375
- function on(t, e, n) {
376
- const s = Math.max(e - Rs, 0);
377
- return Ut(n - t(s), e - s);
378
- }
379
- const w = {
380
- // Default spring physics
381
- stiffness: 100,
382
- damping: 10,
383
- mass: 1,
384
- velocity: 0,
385
- // Default duration/bounce-based options
386
- duration: 800,
387
- // in ms
388
- bounce: 0.3,
389
- visualDuration: 0.3,
390
- // in seconds
391
- // Rest thresholds
392
- restSpeed: {
393
- granular: 0.01,
394
- default: 2
395
- },
396
- restDelta: {
397
- granular: 5e-3,
398
- default: 0.5
399
- },
400
- // Limits
401
- minDuration: 0.01,
402
- // in seconds
403
- maxDuration: 10,
404
- // in seconds
405
- minDamping: 0.05,
406
- maxDamping: 1
407
- }, be = 1e-3;
408
- function Ns({ duration: t = w.duration, bounce: e = w.bounce, velocity: n = w.velocity, mass: s = w.mass }) {
409
- let i, r;
410
- he(t <= /* @__PURE__ */ I(w.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
411
- let a = 1 - e;
412
- a = Y(w.minDamping, w.maxDamping, a), t = Y(w.minDuration, w.maxDuration, /* @__PURE__ */ R(t)), a < 1 ? (i = (c) => {
413
- const l = c * a, h = l * t, f = l - n, d = xe(c, a), v = Math.exp(-h);
414
- return be - f / d * v;
415
- }, r = (c) => {
416
- const h = c * a * t, f = h * n + n, d = Math.pow(a, 2) * Math.pow(c, 2) * t, v = Math.exp(-h), T = xe(Math.pow(c, 2), a);
417
- return (-i(c) + be > 0 ? -1 : 1) * ((f - d) * v) / T;
418
- }) : (i = (c) => {
419
- const l = Math.exp(-c * t), h = (c - n) * t + 1;
420
- return -be + l * h;
421
- }, r = (c) => {
422
- const l = Math.exp(-c * t), h = (n - c) * (t * t);
423
- return l * h;
424
- });
425
- const o = 5 / t, u = Ks(i, r, o);
426
- if (t = /* @__PURE__ */ I(t), isNaN(u))
427
- return {
428
- stiffness: w.stiffness,
429
- damping: w.damping,
430
- duration: t
431
- };
432
- {
433
- const c = Math.pow(u, 2) * s;
434
- return {
435
- stiffness: c,
436
- damping: a * 2 * Math.sqrt(s * c),
437
- duration: t
438
- };
439
- }
440
- }
441
- const ks = 12;
442
- function Ks(t, e, n) {
443
- let s = n;
444
- for (let i = 1; i < ks; i++)
445
- s = s - t(s) / e(s);
446
- return s;
447
- }
448
- function xe(t, e) {
449
- return t * Math.sqrt(1 - e * e);
450
- }
451
- const Bs = ["duration", "bounce"], Ls = ["stiffness", "damping", "mass"];
452
- function ut(t, e) {
453
- return e.some((n) => t[n] !== void 0);
454
- }
455
- function _s(t) {
456
- let e = {
457
- velocity: w.velocity,
458
- stiffness: w.stiffness,
459
- damping: w.damping,
460
- mass: w.mass,
461
- isResolvedFromDuration: !1,
462
- ...t
463
- };
464
- if (!ut(t, Ls) && ut(t, Bs))
465
- if (t.visualDuration) {
466
- const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, r = 2 * Y(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(i);
467
- e = {
468
- ...e,
469
- mass: w.mass,
470
- stiffness: i,
471
- damping: r
472
- };
473
- } else {
474
- const n = Ns(t);
475
- e = {
476
- ...e,
477
- ...n,
478
- mass: w.mass
479
- }, e.isResolvedFromDuration = !0;
480
- }
481
- return e;
482
- }
483
- function le(t = w.visualDuration, e = w.bounce) {
484
- const n = typeof t != "object" ? {
485
- visualDuration: t,
486
- keyframes: [0, 1],
487
- bounce: e
488
- } : t;
489
- let { restSpeed: s, restDelta: i } = n;
490
- const r = n.keyframes[0], a = n.keyframes[n.keyframes.length - 1], o = { done: !1, value: r }, { stiffness: u, damping: c, mass: l, duration: h, velocity: f, isResolvedFromDuration: d } = _s({
491
- ...n,
492
- velocity: -/* @__PURE__ */ R(n.velocity || 0)
493
- }), v = f || 0, T = c / (2 * Math.sqrt(u * l)), b = a - r, p = /* @__PURE__ */ R(Math.sqrt(u / l)), V = Math.abs(b) < 5;
494
- s || (s = V ? w.restSpeed.granular : w.restSpeed.default), i || (i = V ? w.restDelta.granular : w.restDelta.default);
495
- let g;
496
- if (T < 1) {
497
- const m = xe(p, T);
498
- g = (A) => {
499
- const M = Math.exp(-T * p * A);
500
- return a - M * ((v + T * p * b) / m * Math.sin(m * A) + b * Math.cos(m * A));
501
- };
502
- } else if (T === 1)
503
- g = (m) => a - Math.exp(-p * m) * (b + (v + p * b) * m);
504
- else {
505
- const m = p * Math.sqrt(T * T - 1);
506
- g = (A) => {
507
- const M = Math.exp(-T * p * A), y = Math.min(m * A, 300);
508
- return a - M * ((v + T * p * b) * Math.sinh(y) + m * b * Math.cosh(y)) / m;
509
- };
510
- }
511
- const S = {
512
- calculatedDuration: d && h || null,
513
- next: (m) => {
514
- const A = g(m);
515
- if (d)
516
- o.done = m >= h;
517
- else {
518
- let M = m === 0 ? v : 0;
519
- T < 1 && (M = m === 0 ? /* @__PURE__ */ I(v) : on(g, m, A));
520
- const y = Math.abs(M) <= s, P = Math.abs(a - A) <= i;
521
- o.done = y && P;
522
- }
523
- return o.value = o.done ? a : A, o;
524
- },
525
- toString: () => {
526
- const m = Math.min(qe(S), ue), A = an((M) => S.next(m * M).value, m, 30);
527
- return m + "ms " + A;
528
- },
529
- toTransition: () => {
530
- }
531
- };
532
- return S;
533
- }
534
- le.applyToOptions = (t) => {
535
- const e = Is(t, 100, le);
536
- return t.ease = e.ease, t.duration = /* @__PURE__ */ I(e.duration), t.type = "keyframes", t;
537
- };
538
- function Me({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: r = 500, modifyTarget: a, min: o, max: u, restDelta: c = 0.5, restSpeed: l }) {
539
- const h = t[0], f = {
540
- done: !1,
541
- value: h
542
- }, d = (y) => o !== void 0 && y < o || u !== void 0 && y > u, v = (y) => o === void 0 ? u : u === void 0 || Math.abs(o - y) < Math.abs(u - y) ? o : u;
543
- let T = n * e;
544
- const b = h + T, p = a === void 0 ? b : a(b);
545
- p !== b && (T = p - h);
546
- const V = (y) => -T * Math.exp(-y / s), g = (y) => p + V(y), S = (y) => {
547
- const P = V(y), F = g(y);
548
- f.done = Math.abs(P) <= c, f.value = f.done ? p : F;
549
- };
550
- let m, A;
551
- const M = (y) => {
552
- d(f.value) && (m = y, A = le({
553
- keyframes: [f.value, v(f.value)],
554
- velocity: on(g, y, f.value),
555
- // TODO: This should be passing * 1000
556
- damping: i,
557
- stiffness: r,
558
- restDelta: c,
559
- restSpeed: l
560
- }));
561
- };
562
- return M(0), {
563
- calculatedDuration: null,
564
- next: (y) => {
565
- let P = !1;
566
- return !A && m === void 0 && (P = !0, S(y), M(y)), m !== void 0 && y >= m ? A.next(y - m) : (!P && S(y), f);
567
- }
568
- };
569
- }
570
- function Us(t, e, n) {
571
- const s = [], i = n || N.mix || rn, r = t.length - 1;
572
- for (let a = 0; a < r; a++) {
573
- let o = i(t[a], t[a + 1]);
574
- if (e) {
575
- const u = Array.isArray(e) ? e[a] || X : e;
576
- o = de(u, o);
577
- }
578
- s.push(o);
579
- }
580
- return s;
581
- }
582
- function $s(t, e, { clamp: n = !0, ease: s, mixer: i } = {}) {
583
- const r = t.length;
584
- if (q(r === e.length, "Both input and output ranges must be the same length", "range-length"), r === 1)
585
- return () => e[0];
586
- if (r === 2 && e[0] === e[1])
587
- return () => e[1];
588
- const a = t[0] === t[1];
589
- t[0] > t[r - 1] && (t = [...t].reverse(), e = [...e].reverse());
590
- const o = Us(e, s, i), u = o.length, c = (l) => {
591
- if (a && l < t[0])
592
- return e[0];
593
- let h = 0;
594
- if (u > 1)
595
- for (; h < t.length - 2 && !(l < t[h + 1]); h++)
596
- ;
597
- const f = /* @__PURE__ */ Lt(t[h], t[h + 1], l);
598
- return o[h](f);
599
- };
600
- return n ? (l) => c(Y(t[0], t[r - 1], l)) : c;
601
- }
602
- function Gs(t, e) {
603
- const n = t[t.length - 1];
604
- for (let s = 1; s <= e; s++) {
605
- const i = /* @__PURE__ */ Lt(0, e, s);
606
- t.push(pe(n, 1, i));
607
- }
608
- }
609
- function js(t) {
610
- const e = [0];
611
- return Gs(e, t.length - 1), e;
612
- }
613
- function Ws(t, e) {
614
- return t.map((n) => n * e);
615
- }
616
- function Hs(t, e) {
617
- return t.map(() => e || Yt).splice(0, t.length - 1);
618
- }
619
- function H({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) {
620
- const i = us(s) ? s.map(it) : it(s), r = {
621
- done: !1,
622
- value: e[0]
623
- }, a = Ws(
624
- // Only use the provided offsets if they're the correct length
625
- // TODO Maybe we should warn here if there's a length mismatch
626
- n && n.length === e.length ? n : js(e),
627
- t
628
- ), o = $s(a, e, {
629
- ease: Array.isArray(i) ? i : Hs(e, i)
630
- });
631
- return {
632
- calculatedDuration: t,
633
- next: (u) => (r.value = o(u), r.done = u >= t, r)
634
- };
635
- }
636
- const zs = (t) => t !== null;
637
- function Ye(t, { repeat: e, repeatType: n = "loop" }, s, i = 1) {
638
- const r = t.filter(zs), o = i < 0 || e && n !== "loop" && e % 2 === 1 ? 0 : r.length - 1;
639
- return !o || s === void 0 ? r[o] : s;
640
- }
641
- const qs = {
642
- decay: Me,
643
- inertia: Me,
644
- tween: H,
645
- keyframes: H,
646
- spring: le
647
- };
648
- function un(t) {
649
- typeof t.type == "string" && (t.type = qs[t.type]);
650
- }
651
- class Xe {
652
- constructor() {
653
- this.updateFinished();
654
- }
655
- get finished() {
656
- return this._finished;
657
- }
658
- updateFinished() {
659
- this._finished = new Promise((e) => {
660
- this.resolve = e;
661
- });
662
- }
663
- notifyFinished() {
664
- this.resolve();
665
- }
666
- /**
667
- * Allows the animation to be awaited.
668
- *
669
- * @deprecated Use `finished` instead.
670
- */
671
- then(e, n) {
672
- return this.finished.then(e, n);
673
- }
674
- }
675
- const Ys = (t) => t / 100;
676
- class Ze extends Xe {
677
- constructor(e) {
678
- super(), this.state = "idle", this.startTime = null, this.isStopped = !1, this.currentTime = 0, this.holdTime = null, this.playbackSpeed = 1, this.stop = () => {
679
- const { motionValue: n } = this.options;
680
- n && n.updatedAt !== E.now() && this.tick(E.now()), this.isStopped = !0, this.state !== "idle" && (this.teardown(), this.options.onStop?.());
681
- }, this.options = e, this.initAnimation(), this.play(), e.autoplay === !1 && this.pause();
682
- }
683
- initAnimation() {
684
- const { options: e } = this;
685
- un(e);
686
- const { type: n = H, repeat: s = 0, repeatDelay: i = 0, repeatType: r, velocity: a = 0 } = e;
687
- let { keyframes: o } = e;
688
- const u = n || H;
689
- process.env.NODE_ENV !== "production" && u !== H && q(o.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${o}`, "spring-two-frames"), u !== H && typeof o[0] != "number" && (this.mixKeyframes = de(Ys, rn(o[0], o[1])), o = [0, 100]);
690
- const c = u({ ...e, keyframes: o });
691
- r === "mirror" && (this.mirroredGenerator = u({
692
- ...e,
693
- keyframes: [...o].reverse(),
694
- velocity: -a
695
- })), c.calculatedDuration === null && (c.calculatedDuration = qe(c));
696
- const { calculatedDuration: l } = c;
697
- this.calculatedDuration = l, this.resolvedDuration = l + i, this.totalDuration = this.resolvedDuration * (s + 1) - i, this.generator = c;
698
- }
699
- updateTime(e) {
700
- const n = Math.round(e - this.startTime) * this.playbackSpeed;
701
- this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = n;
702
- }
703
- tick(e, n = !1) {
704
- const { generator: s, totalDuration: i, mixKeyframes: r, mirroredGenerator: a, resolvedDuration: o, calculatedDuration: u } = this;
705
- if (this.startTime === null)
706
- return s.next(0);
707
- const { delay: c = 0, keyframes: l, repeat: h, repeatType: f, repeatDelay: d, type: v, onUpdate: T, finalKeyframe: b } = this.options;
708
- this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - i / this.speed, this.startTime)), n ? this.currentTime = e : this.updateTime(e);
709
- const p = this.currentTime - c * (this.playbackSpeed >= 0 ? 1 : -1), V = this.playbackSpeed >= 0 ? p < 0 : p > i;
710
- this.currentTime = Math.max(p, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = i);
711
- let g = this.currentTime, S = s;
712
- if (h) {
713
- const y = Math.min(this.currentTime, i) / o;
714
- let P = Math.floor(y), F = y % 1;
715
- !F && y >= 1 && (F = 1), F === 1 && P--, P = Math.min(P, h + 1), !!(P % 2) && (f === "reverse" ? (F = 1 - F, d && (F -= d / o)) : f === "mirror" && (S = a)), g = Y(0, 1, F) * o;
716
- }
717
- const m = V ? { done: !1, value: l[0] } : S.next(g);
718
- r && (m.value = r(m.value));
719
- let { done: A } = m;
720
- !V && u !== null && (A = this.playbackSpeed >= 0 ? this.currentTime >= i : this.currentTime <= 0);
721
- const M = this.holdTime === null && (this.state === "finished" || this.state === "running" && A);
722
- return M && v !== Me && (m.value = Ye(l, this.options, b, this.speed)), T && T(m.value), M && this.finish(), m;
723
- }
724
- /**
725
- * Allows the returned animation to be awaited or promise-chained. Currently
726
- * resolves when the animation finishes at all but in a future update could/should
727
- * reject if its cancels.
728
- */
729
- then(e, n) {
730
- return this.finished.then(e, n);
731
- }
732
- get duration() {
733
- return /* @__PURE__ */ R(this.calculatedDuration);
734
- }
735
- get time() {
736
- return /* @__PURE__ */ R(this.currentTime);
737
- }
738
- set time(e) {
739
- e = /* @__PURE__ */ I(e), this.currentTime = e, this.startTime === null || this.holdTime !== null || this.playbackSpeed === 0 ? this.holdTime = e : this.driver && (this.startTime = this.driver.now() - e / this.playbackSpeed), this.driver?.start(!1);
740
- }
741
- get speed() {
742
- return this.playbackSpeed;
743
- }
744
- set speed(e) {
745
- this.updateTime(E.now());
746
- const n = this.playbackSpeed !== e;
747
- this.playbackSpeed = e, n && (this.time = /* @__PURE__ */ R(this.currentTime));
748
- }
749
- play() {
750
- if (this.isStopped)
751
- return;
752
- const { driver: e = Os, startTime: n } = this.options;
753
- this.driver || (this.driver = e((i) => this.tick(i))), this.options.onPlay?.();
754
- const s = this.driver.now();
755
- 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();
756
- }
757
- pause() {
758
- this.state = "paused", this.updateTime(E.now()), this.holdTime = this.currentTime;
759
- }
760
- complete() {
761
- this.state !== "running" && this.play(), this.state = "finished", this.holdTime = null;
762
- }
763
- finish() {
764
- this.notifyFinished(), this.teardown(), this.state = "finished", this.options.onComplete?.();
765
- }
766
- cancel() {
767
- this.holdTime = null, this.startTime = 0, this.tick(0), this.teardown(), this.options.onCancel?.();
768
- }
769
- teardown() {
770
- this.state = "idle", this.stopDriver(), this.startTime = this.holdTime = null;
771
- }
772
- stopDriver() {
773
- this.driver && (this.driver.stop(), this.driver = void 0);
774
- }
775
- sample(e) {
776
- return this.startTime = 0, this.tick(e, !0);
777
- }
778
- attachTimeline(e) {
779
- return this.options.allowFlatten && (this.options.type = "keyframes", this.options.ease = "linear", this.initAnimation()), this.driver?.stop(), e.observe(this);
780
- }
781
- }
782
- function Xs(t) {
783
- for (let e = 1; e < t.length; e++)
784
- t[e] ?? (t[e] = t[e - 1]);
785
- }
786
- const _ = (t) => t * 180 / Math.PI, Ce = (t) => {
787
- const e = _(Math.atan2(t[1], t[0]));
788
- return Pe(e);
789
- }, Zs = {
790
- x: 4,
791
- y: 5,
792
- translateX: 4,
793
- translateY: 5,
794
- scaleX: 0,
795
- scaleY: 3,
796
- scale: (t) => (Math.abs(t[0]) + Math.abs(t[3])) / 2,
797
- rotate: Ce,
798
- rotateZ: Ce,
799
- skewX: (t) => _(Math.atan(t[1])),
800
- skewY: (t) => _(Math.atan(t[2])),
801
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[2])) / 2
802
- }, Pe = (t) => (t = t % 360, t < 0 && (t += 360), t), lt = Ce, ct = (t) => Math.sqrt(t[0] * t[0] + t[1] * t[1]), ht = (t) => Math.sqrt(t[4] * t[4] + t[5] * t[5]), Js = {
803
- x: 12,
804
- y: 13,
805
- z: 14,
806
- translateX: 12,
807
- translateY: 13,
808
- translateZ: 14,
809
- scaleX: ct,
810
- scaleY: ht,
811
- scale: (t) => (ct(t) + ht(t)) / 2,
812
- rotateX: (t) => Pe(_(Math.atan2(t[6], t[5]))),
813
- rotateY: (t) => Pe(_(Math.atan2(-t[2], t[0]))),
814
- rotateZ: lt,
815
- rotate: lt,
816
- skewX: (t) => _(Math.atan(t[4])),
817
- skewY: (t) => _(Math.atan(t[1])),
818
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[4])) / 2
819
- };
820
- function Fe(t) {
821
- return t.includes("scale") ? 1 : 0;
822
- }
823
- function De(t, e) {
824
- if (!t || t === "none")
825
- return Fe(e);
826
- const n = t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
827
- let s, i;
828
- if (n)
829
- s = Js, i = n;
830
- else {
831
- const o = t.match(/^matrix\(([-\d.e\s,]+)\)$/u);
832
- s = Zs, i = o;
833
- }
834
- if (!i)
835
- return Fe(e);
836
- const r = s[e], a = i[1].split(",").map(ei);
837
- return typeof r == "function" ? r(a) : a[r];
838
- }
839
- const Qs = (t, e) => {
840
- const { transform: n = "none" } = getComputedStyle(t);
841
- return De(n, e);
842
- };
843
- function ei(t) {
844
- return parseFloat(t.trim());
845
- }
846
- const ft = (t) => t === _e || t === Pt, ti = /* @__PURE__ */ new Set(["x", "y", "z"]), ni = Ft.filter((t) => !ti.has(t));
847
- function si(t) {
848
- const e = [];
849
- return ni.forEach((n) => {
850
- const s = t.getValue(n);
851
- s !== void 0 && (e.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
852
- }), e;
853
- }
854
- const U = {
855
- // Dimensions
856
- width: ({ x: t }, { paddingLeft: e = "0", paddingRight: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
857
- height: ({ y: t }, { paddingTop: e = "0", paddingBottom: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
858
- top: (t, { top: e }) => parseFloat(e),
859
- left: (t, { left: e }) => parseFloat(e),
860
- bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min),
861
- right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min),
862
- // Transform
863
- x: (t, { transform: e }) => De(e, "x"),
864
- y: (t, { transform: e }) => De(e, "y")
865
- };
866
- U.translateX = U.x;
867
- U.translateY = U.y;
868
- const $ = /* @__PURE__ */ new Set();
869
- let Ee = !1, Oe = !1, Ie = !1;
870
- function ln() {
871
- if (Oe) {
872
- const t = Array.from($).filter((s) => s.needsMeasurement), e = new Set(t.map((s) => s.element)), n = /* @__PURE__ */ new Map();
873
- e.forEach((s) => {
874
- const i = si(s);
875
- i.length && (n.set(s, i), s.render());
876
- }), t.forEach((s) => s.measureInitialState()), e.forEach((s) => {
877
- s.render();
878
- const i = n.get(s);
879
- i && i.forEach(([r, a]) => {
880
- s.getValue(r)?.set(a);
881
- });
882
- }), t.forEach((s) => s.measureEndState()), t.forEach((s) => {
883
- s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
884
- });
885
- }
886
- Oe = !1, Ee = !1, $.forEach((t) => t.complete(Ie)), $.clear();
887
- }
888
- function cn() {
889
- $.forEach((t) => {
890
- t.readKeyframes(), t.needsMeasurement && (Oe = !0);
891
- });
892
- }
893
- function ii() {
894
- Ie = !0, cn(), ln(), Ie = !1;
895
- }
896
- class Je {
897
- constructor(e, n, s, i, r, a = !1) {
898
- this.state = "pending", this.isAsync = !1, this.needsMeasurement = !1, this.unresolvedKeyframes = [...e], this.onComplete = n, this.name = s, this.motionValue = i, this.element = r, this.isAsync = a;
899
- }
900
- scheduleResolve() {
901
- this.state = "scheduled", this.isAsync ? ($.add(this), Ee || (Ee = !0, O.read(cn), O.resolveKeyframes(ln))) : (this.readKeyframes(), this.complete());
902
- }
903
- readKeyframes() {
904
- const { unresolvedKeyframes: e, name: n, element: s, motionValue: i } = this;
905
- if (e[0] === null) {
906
- const r = i?.get(), a = e[e.length - 1];
907
- if (r !== void 0)
908
- e[0] = r;
909
- else if (s && n) {
910
- const o = s.readValue(n, a);
911
- o != null && (e[0] = o);
912
- }
913
- e[0] === void 0 && (e[0] = a), i && r === void 0 && i.set(e[0]);
914
- }
915
- Xs(e);
916
- }
917
- setFinalKeyframe() {
918
- }
919
- measureInitialState() {
920
- }
921
- renderEndStyles() {
922
- }
923
- measureEndState() {
924
- }
925
- complete(e = !1) {
926
- this.state = "complete", this.onComplete(this.unresolvedKeyframes, this.finalKeyframe, e), $.delete(this);
927
- }
928
- cancel() {
929
- this.state === "scheduled" && ($.delete(this), this.state = "pending");
930
- }
931
- resume() {
932
- this.state === "pending" && this.scheduleResolve();
933
- }
934
- }
935
- const ri = (t) => t.startsWith("--");
936
- function ai(t, e, n) {
937
- ri(e) ? t.style.setProperty(e, n) : t.style[e] = n;
938
- }
939
- const oi = /* @__PURE__ */ $e(() => window.ScrollTimeline !== void 0), ui = {};
940
- function li(t, e) {
941
- const n = /* @__PURE__ */ $e(t);
942
- return () => ui[e] ?? n();
943
- }
944
- const hn = /* @__PURE__ */ li(() => {
945
- try {
946
- document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
947
- } catch {
948
- return !1;
949
- }
950
- return !0;
951
- }, "linearEasing"), Q = ([t, e, n, s]) => `cubic-bezier(${t}, ${e}, ${n}, ${s})`, dt = {
952
- linear: "linear",
953
- ease: "ease",
954
- easeIn: "ease-in",
955
- easeOut: "ease-out",
956
- easeInOut: "ease-in-out",
957
- circIn: /* @__PURE__ */ Q([0, 0.65, 0.55, 1]),
958
- circOut: /* @__PURE__ */ Q([0.55, 0, 1, 0.45]),
959
- backIn: /* @__PURE__ */ Q([0.31, 0.01, 0.66, -0.59]),
960
- backOut: /* @__PURE__ */ Q([0.33, 1.53, 0.69, 0.99])
961
- };
962
- function fn(t, e) {
963
- if (t)
964
- return typeof t == "function" ? hn() ? an(t, e) : "ease-out" : Xt(t) ? Q(t) : Array.isArray(t) ? t.map((n) => fn(n, e) || dt.easeOut) : dt[t];
965
- }
966
- function ci(t, e, n, { delay: s = 0, duration: i = 300, repeat: r = 0, repeatType: a = "loop", ease: o = "easeOut", times: u } = {}, c = void 0) {
967
- const l = {
968
- [e]: n
969
- };
970
- u && (l.offset = u);
971
- const h = fn(o, i);
972
- Array.isArray(h) && (l.easing = h);
973
- const f = {
974
- delay: s,
975
- duration: i,
976
- easing: Array.isArray(h) ? "linear" : h,
977
- fill: "both",
978
- iterations: r + 1,
979
- direction: a === "reverse" ? "alternate" : "normal"
980
- };
981
- return c && (f.pseudoElement = c), t.animate(l, f);
982
- }
983
- function dn(t) {
984
- return typeof t == "function" && "applyToOptions" in t;
985
- }
986
- function hi({ type: t, ...e }) {
987
- return dn(t) && hn() ? t.applyToOptions(e) : (e.duration ?? (e.duration = 300), e.ease ?? (e.ease = "easeOut"), e);
988
- }
989
- class fi extends Xe {
990
- constructor(e) {
991
- if (super(), this.finishedTime = null, this.isStopped = !1, !e)
992
- return;
993
- const { element: n, name: s, keyframes: i, pseudoElement: r, allowFlatten: a = !1, finalKeyframe: o, onComplete: u } = e;
994
- this.isPseudoElement = !!r, this.allowFlatten = a, this.options = e, q(typeof e.type != "string", `Mini animate() doesn't support "type" as a string.`, "mini-spring");
995
- const c = hi(e);
996
- this.animation = ci(n, s, i, c, r), c.autoplay === !1 && this.animation.pause(), this.animation.onfinish = () => {
997
- if (this.finishedTime = this.time, !r) {
998
- const l = Ye(i, this.options, o, this.speed);
999
- this.updateMotionValue ? this.updateMotionValue(l) : ai(n, s, l), this.animation.cancel();
1000
- }
1001
- u?.(), this.notifyFinished();
1002
- };
1003
- }
1004
- play() {
1005
- this.isStopped || (this.animation.play(), this.state === "finished" && this.updateFinished());
1006
- }
1007
- pause() {
1008
- this.animation.pause();
1009
- }
1010
- complete() {
1011
- this.animation.finish?.();
1012
- }
1013
- cancel() {
1014
- try {
1015
- this.animation.cancel();
1016
- } catch {
1017
- }
1018
- }
1019
- stop() {
1020
- if (this.isStopped)
1021
- return;
1022
- this.isStopped = !0;
1023
- const { state: e } = this;
1024
- e === "idle" || e === "finished" || (this.updateMotionValue ? this.updateMotionValue() : this.commitStyles(), this.isPseudoElement || this.cancel());
1025
- }
1026
- /**
1027
- * WAAPI doesn't natively have any interruption capabilities.
1028
- *
1029
- * In this method, we commit styles back to the DOM before cancelling
1030
- * the animation.
1031
- *
1032
- * This is designed to be overridden by NativeAnimationExtended, which
1033
- * will create a renderless JS animation and sample it twice to calculate
1034
- * its current value, "previous" value, and therefore allow
1035
- * Motion to also correctly calculate velocity for any subsequent animation
1036
- * while deferring the commit until the next animation frame.
1037
- */
1038
- commitStyles() {
1039
- this.isPseudoElement || this.animation.commitStyles?.();
1040
- }
1041
- get duration() {
1042
- const e = this.animation.effect?.getComputedTiming?.().duration || 0;
1043
- return /* @__PURE__ */ R(Number(e));
1044
- }
1045
- get time() {
1046
- return /* @__PURE__ */ R(Number(this.animation.currentTime) || 0);
1047
- }
1048
- set time(e) {
1049
- this.finishedTime = null, this.animation.currentTime = /* @__PURE__ */ I(e);
1050
- }
1051
- /**
1052
- * The playback speed of the animation.
1053
- * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1054
- */
1055
- get speed() {
1056
- return this.animation.playbackRate;
1057
- }
1058
- set speed(e) {
1059
- e < 0 && (this.finishedTime = null), this.animation.playbackRate = e;
1060
- }
1061
- get state() {
1062
- return this.finishedTime !== null ? "finished" : this.animation.playState;
1063
- }
1064
- get startTime() {
1065
- return Number(this.animation.startTime);
1066
- }
1067
- set startTime(e) {
1068
- this.animation.startTime = e;
1069
- }
1070
- /**
1071
- * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1072
- */
1073
- attachTimeline({ timeline: e, observe: n }) {
1074
- return this.allowFlatten && this.animation.effect?.updateTiming({ easing: "linear" }), this.animation.onfinish = null, e && oi() ? (this.animation.timeline = e, X) : n(this);
1075
- }
1076
- }
1077
- const pn = {
1078
- anticipate: zt,
1079
- backInOut: Ht,
1080
- circInOut: qt
1081
- };
1082
- function di(t) {
1083
- return t in pn;
1084
- }
1085
- function pi(t) {
1086
- typeof t.ease == "string" && di(t.ease) && (t.ease = pn[t.ease]);
1087
- }
1088
- const pt = 10;
1089
- class mi extends fi {
1090
- constructor(e) {
1091
- pi(e), un(e), super(e), e.startTime && (this.startTime = e.startTime), this.options = e;
1092
- }
1093
- /**
1094
- * WAAPI doesn't natively have any interruption capabilities.
1095
- *
1096
- * Rather than read commited styles back out of the DOM, we can
1097
- * create a renderless JS animation and sample it twice to calculate
1098
- * its current value, "previous" value, and therefore allow
1099
- * Motion to calculate velocity for any subsequent animation.
1100
- */
1101
- updateMotionValue(e) {
1102
- const { motionValue: n, onUpdate: s, onComplete: i, element: r, ...a } = this.options;
1103
- if (!n)
1104
- return;
1105
- if (e !== void 0) {
1106
- n.set(e);
1107
- return;
1108
- }
1109
- const o = new Ze({
1110
- ...a,
1111
- autoplay: !1
1112
- }), u = /* @__PURE__ */ I(this.finishedTime ?? this.time);
1113
- n.setWithVelocity(o.sample(u - pt).value, o.sample(u).value, pt), o.stop();
1114
- }
1115
- }
1116
- const mt = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string
1117
- (Z.test(t) || t === "0") && // And it contains numbers and/or colors
1118
- !t.startsWith("url("));
1119
- function gi(t) {
1120
- const e = t[0];
1121
- if (t.length === 1)
1122
- return !0;
1123
- for (let n = 0; n < t.length; n++)
1124
- if (t[n] !== e)
1125
- return !0;
1126
- }
1127
- function yi(t, e, n, s) {
1128
- const i = t[0];
1129
- if (i === null)
1130
- return !1;
1131
- if (e === "display" || e === "visibility")
1132
- return !0;
1133
- const r = t[t.length - 1], a = mt(i, e), o = mt(r, e);
1134
- return he(a === o, `You are trying to animate ${e} from "${i}" to "${r}". "${a ? r : i}" is not an animatable value.`, "value-not-animatable"), !a || !o ? !1 : gi(t) || (n === "spring" || dn(n)) && s;
1135
- }
1136
- function Re(t) {
1137
- t.duration = 0, t.type;
1138
- }
1139
- const bi = /* @__PURE__ */ new Set([
1140
- "opacity",
1141
- "clipPath",
1142
- "filter",
1143
- "transform"
1144
- // TODO: Could be re-enabled now we have support for linear() easing
1145
- // "background-color"
1146
- ]), vi = /* @__PURE__ */ $e(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
1147
- function Ti(t) {
1148
- const { motionValue: e, name: n, repeatDelay: s, repeatType: i, damping: r, type: a } = t;
1149
- if (!(e?.owner?.current instanceof HTMLElement))
1150
- return !1;
1151
- const { onUpdate: u, transformTemplate: c } = e.owner.getProps();
1152
- return vi() && n && bi.has(n) && (n !== "transform" || !c) && /**
1153
- * If we're outputting values to onUpdate then we can't use WAAPI as there's
1154
- * no way to read the value from WAAPI every frame.
1155
- */
1156
- !u && !s && i !== "mirror" && r !== 0 && a !== "inertia";
1157
- }
1158
- const Vi = 40;
1159
- class Ai extends Xe {
1160
- constructor({ autoplay: e = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: r = 0, repeatType: a = "loop", keyframes: o, name: u, motionValue: c, element: l, ...h }) {
1161
- super(), this.stop = () => {
1162
- this._animation && (this._animation.stop(), this.stopTimeline?.()), this.keyframeResolver?.cancel();
1163
- }, this.createdAt = E.now();
1164
- const f = {
1165
- autoplay: e,
1166
- delay: n,
1167
- type: s,
1168
- repeat: i,
1169
- repeatDelay: r,
1170
- repeatType: a,
1171
- name: u,
1172
- motionValue: c,
1173
- element: l,
1174
- ...h
1175
- }, d = l?.KeyframeResolver || Je;
1176
- this.keyframeResolver = new d(o, (v, T, b) => this.onKeyframesResolved(v, T, f, !b), u, c, l), this.keyframeResolver?.scheduleResolve();
1177
- }
1178
- onKeyframesResolved(e, n, s, i) {
1179
- this.keyframeResolver = void 0;
1180
- const { name: r, type: a, velocity: o, delay: u, isHandoff: c, onUpdate: l } = s;
1181
- this.resolvedAt = E.now(), yi(e, r, a, o) || ((N.instantAnimations || !u) && l?.(Ye(e, s, n)), e[0] = e[e.length - 1], Re(s), s.repeat = 0);
1182
- const f = {
1183
- startTime: i ? this.resolvedAt ? this.resolvedAt - this.createdAt > Vi ? this.resolvedAt : this.createdAt : this.createdAt : void 0,
1184
- finalKeyframe: n,
1185
- ...s,
1186
- keyframes: e
1187
- }, d = !c && Ti(f) ? new mi({
1188
- ...f,
1189
- element: f.motionValue.owner.current
1190
- }) : new Ze(f);
1191
- d.finished.then(() => this.notifyFinished()).catch(X), this.pendingTimeline && (this.stopTimeline = d.attachTimeline(this.pendingTimeline), this.pendingTimeline = void 0), this._animation = d;
1192
- }
1193
- get finished() {
1194
- return this._animation ? this.animation.finished : this._finished;
1195
- }
1196
- then(e, n) {
1197
- return this.finished.finally(e).then(() => {
1198
- });
1199
- }
1200
- get animation() {
1201
- return this._animation || (this.keyframeResolver?.resume(), ii()), this._animation;
1202
- }
1203
- get duration() {
1204
- return this.animation.duration;
1205
- }
1206
- get time() {
1207
- return this.animation.time;
1208
- }
1209
- set time(e) {
1210
- this.animation.time = e;
1211
- }
1212
- get speed() {
1213
- return this.animation.speed;
1214
- }
1215
- get state() {
1216
- return this.animation.state;
1217
- }
1218
- set speed(e) {
1219
- this.animation.speed = e;
1220
- }
1221
- get startTime() {
1222
- return this.animation.startTime;
1223
- }
1224
- attachTimeline(e) {
1225
- return this._animation ? this.stopTimeline = this.animation.attachTimeline(e) : this.pendingTimeline = e, () => this.stop();
1226
- }
1227
- play() {
1228
- this.animation.play();
1229
- }
1230
- pause() {
1231
- this.animation.pause();
1232
- }
1233
- complete() {
1234
- this.animation.complete();
1235
- }
1236
- cancel() {
1237
- this._animation && this.animation.cancel(), this.keyframeResolver?.cancel();
1238
- }
1239
- }
1240
- const wi = (
1241
- // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
1242
- /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
1243
- );
1244
- function Si(t) {
1245
- const e = wi.exec(t);
1246
- if (!e)
1247
- return [,];
1248
- const [, n, s, i] = e;
1249
- return [`--${n ?? s}`, i];
1250
- }
1251
- const xi = 4;
1252
- function mn(t, e, n = 1) {
1253
- q(n <= xi, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`, "max-css-var-depth");
1254
- const [s, i] = Si(t);
1255
- if (!s)
1256
- return;
1257
- const r = window.getComputedStyle(e).getPropertyValue(s);
1258
- if (r) {
1259
- const a = r.trim();
1260
- return Kt(a) ? parseFloat(a) : a;
1261
- }
1262
- return Ue(i) ? mn(i, e, n + 1) : i;
1263
- }
1264
- function gn(t, e) {
1265
- return t?.[e] ?? t?.default ?? t;
1266
- }
1267
- const yn = /* @__PURE__ */ new Set([
1268
- "width",
1269
- "height",
1270
- "top",
1271
- "left",
1272
- "right",
1273
- "bottom",
1274
- ...Ft
1275
- ]), Mi = {
1276
- test: (t) => t === "auto",
1277
- parse: (t) => t
1278
- }, bn = (t) => (e) => e.test(t), vn = [_e, Pt, Ve, kn, Kn, Bn, Mi], gt = (t) => vn.find(bn(t));
1279
- function Ci(t) {
1280
- return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || Bt(t) : !0;
1281
- }
1282
- const Pi = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
1283
- function Fi(t) {
1284
- const [e, n] = t.slice(0, -1).split("(");
1285
- if (e === "drop-shadow")
1286
- return t;
1287
- const [s] = n.match(We) || [];
1288
- if (!s)
1289
- return t;
1290
- const i = n.replace(s, "");
1291
- let r = Pi.has(e) ? 1 : 0;
1292
- return s !== n && (r *= 100), e + "(" + r + i + ")";
1293
- }
1294
- const Di = /\b([a-z-]*)\(.*?\)/gu, Ne = {
1295
- ...Z,
1296
- getAnimatableNone: (t) => {
1297
- const e = t.match(Di);
1298
- return e ? e.map(Fi).join(" ") : t;
1299
- }
1300
- }, Ei = {
1301
- ...Ln,
1302
- // Color props
1303
- color: x,
1304
- backgroundColor: x,
1305
- outlineColor: x,
1306
- fill: x,
1307
- stroke: x,
1308
- // Border props
1309
- borderColor: x,
1310
- borderTopColor: x,
1311
- borderRightColor: x,
1312
- borderBottomColor: x,
1313
- borderLeftColor: x,
1314
- filter: Ne,
1315
- WebkitFilter: Ne
1316
- }, Tn = (t) => Ei[t];
1317
- function Vn(t, e) {
1318
- let n = Tn(t);
1319
- return n !== Ne && (n = Z), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0;
1320
- }
1321
- const Oi = /* @__PURE__ */ new Set(["auto", "none", "0"]);
1322
- function Ii(t, e, n) {
1323
- let s = 0, i;
1324
- for (; s < t.length && !i; ) {
1325
- const r = t[s];
1326
- typeof r == "string" && !Oi.has(r) && te(r).values.length && (i = t[s]), s++;
1327
- }
1328
- if (i && n)
1329
- for (const r of e)
1330
- t[r] = Vn(n, i);
1331
- }
1332
- class Ri extends Je {
1333
- constructor(e, n, s, i, r) {
1334
- super(e, n, s, i, r, !0);
1335
- }
1336
- readKeyframes() {
1337
- const { unresolvedKeyframes: e, element: n, name: s } = this;
1338
- if (!n || !n.current)
1339
- return;
1340
- super.readKeyframes();
1341
- for (let u = 0; u < e.length; u++) {
1342
- let c = e[u];
1343
- if (typeof c == "string" && (c = c.trim(), Ue(c))) {
1344
- const l = mn(c, n.current);
1345
- l !== void 0 && (e[u] = l), u === e.length - 1 && (this.finalKeyframe = c);
1346
- }
1347
- }
1348
- if (this.resolveNoneKeyframes(), !yn.has(s) || e.length !== 2)
1349
- return;
1350
- const [i, r] = e, a = gt(i), o = gt(r);
1351
- if (a !== o)
1352
- if (ft(a) && ft(o))
1353
- for (let u = 0; u < e.length; u++) {
1354
- const c = e[u];
1355
- typeof c == "string" && (e[u] = parseFloat(c));
1356
- }
1357
- else U[s] && (this.needsMeasurement = !0);
1358
- }
1359
- resolveNoneKeyframes() {
1360
- const { unresolvedKeyframes: e, name: n } = this, s = [];
1361
- for (let i = 0; i < e.length; i++)
1362
- (e[i] === null || Ci(e[i])) && s.push(i);
1363
- s.length && Ii(e, s, n);
1364
- }
1365
- measureInitialState() {
1366
- const { element: e, unresolvedKeyframes: n, name: s } = this;
1367
- if (!e || !e.current)
1368
- return;
1369
- s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = U[s](e.measureViewportBox(), window.getComputedStyle(e.current)), n[0] = this.measuredOrigin;
1370
- const i = n[n.length - 1];
1371
- i !== void 0 && e.getValue(s, i).jump(i, !1);
1372
- }
1373
- measureEndState() {
1374
- const { element: e, name: n, unresolvedKeyframes: s } = this;
1375
- if (!e || !e.current)
1376
- return;
1377
- const i = e.getValue(n);
1378
- i && i.jump(this.measuredOrigin, !1);
1379
- const r = s.length - 1, a = s[r];
1380
- s[r] = U[n](e.measureViewportBox(), window.getComputedStyle(e.current)), a !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = a), this.removedTransforms?.length && this.removedTransforms.forEach(([o, u]) => {
1381
- e.getValue(o).set(u);
1382
- }), this.resolveNoneKeyframes();
1383
- }
1384
- }
1385
- function Ni(t, e, n) {
1386
- if (t instanceof EventTarget)
1387
- return [t];
1388
- if (typeof t == "string") {
1389
- let s = document;
1390
- const i = n?.[t] ?? s.querySelectorAll(t);
1391
- return i ? Array.from(i) : [];
1392
- }
1393
- return Array.from(t);
1394
- }
1395
- const yt = 30, ki = (t) => !isNaN(parseFloat(t));
1396
- class Ki {
1397
- /**
1398
- * @param init - The initiating value
1399
- * @param config - Optional configuration options
1400
- *
1401
- * - `transformer`: A function to transform incoming values with.
1402
- */
1403
- constructor(e, n = {}) {
1404
- this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s) => {
1405
- const i = E.now();
1406
- if (this.updatedAt !== i && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(s), this.current !== this.prev && (this.events.change?.notify(this.current), this.dependents))
1407
- for (const r of this.dependents)
1408
- r.dirty();
1409
- }, this.hasAnimated = !1, this.setCurrent(e), this.owner = n.owner;
1410
- }
1411
- setCurrent(e) {
1412
- this.current = e, this.updatedAt = E.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = ki(this.current));
1413
- }
1414
- setPrevFrameValue(e = this.current) {
1415
- this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt;
1416
- }
1417
- /**
1418
- * Adds a function that will be notified when the `MotionValue` is updated.
1419
- *
1420
- * It returns a function that, when called, will cancel the subscription.
1421
- *
1422
- * When calling `onChange` inside a React component, it should be wrapped with the
1423
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1424
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
1425
- *
1426
- * ```jsx
1427
- * export const MyComponent = () => {
1428
- * const x = useMotionValue(0)
1429
- * const y = useMotionValue(0)
1430
- * const opacity = useMotionValue(1)
1431
- *
1432
- * useEffect(() => {
1433
- * function updateOpacity() {
1434
- * const maxXY = Math.max(x.get(), y.get())
1435
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1436
- * opacity.set(newOpacity)
1437
- * }
1438
- *
1439
- * const unsubscribeX = x.on("change", updateOpacity)
1440
- * const unsubscribeY = y.on("change", updateOpacity)
1441
- *
1442
- * return () => {
1443
- * unsubscribeX()
1444
- * unsubscribeY()
1445
- * }
1446
- * }, [])
1447
- *
1448
- * return <motion.div style={{ x }} />
1449
- * }
1450
- * ```
1451
- *
1452
- * @param subscriber - A function that receives the latest value.
1453
- * @returns A function that, when called, will cancel this subscription.
1454
- *
1455
- * @deprecated
1456
- */
1457
- onChange(e) {
1458
- return process.env.NODE_ENV !== "production" && Dt(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e);
1459
- }
1460
- on(e, n) {
1461
- this.events[e] || (this.events[e] = new _t());
1462
- const s = this.events[e].add(n);
1463
- return e === "change" ? () => {
1464
- s(), O.read(() => {
1465
- this.events.change.getSize() || this.stop();
1466
- });
1467
- } : s;
1468
- }
1469
- clearListeners() {
1470
- for (const e in this.events)
1471
- this.events[e].clear();
1472
- }
1473
- /**
1474
- * Attaches a passive effect to the `MotionValue`.
1475
- */
1476
- attach(e, n) {
1477
- this.passiveEffect = e, this.stopPassiveEffect = n;
1478
- }
1479
- /**
1480
- * Sets the state of the `MotionValue`.
1481
- *
1482
- * @remarks
1483
- *
1484
- * ```jsx
1485
- * const x = useMotionValue(0)
1486
- * x.set(10)
1487
- * ```
1488
- *
1489
- * @param latest - Latest value to set.
1490
- * @param render - Whether to notify render subscribers. Defaults to `true`
1491
- *
1492
- * @public
1493
- */
1494
- set(e) {
1495
- this.passiveEffect ? this.passiveEffect(e, this.updateAndNotify) : this.updateAndNotify(e);
1496
- }
1497
- setWithVelocity(e, n, s) {
1498
- this.set(n), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - s;
1499
- }
1500
- /**
1501
- * Set the state of the `MotionValue`, stopping any active animations,
1502
- * effects, and resets velocity to `0`.
1503
- */
1504
- jump(e, n = !0) {
1505
- this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1506
- }
1507
- dirty() {
1508
- this.events.change?.notify(this.current);
1509
- }
1510
- addDependent(e) {
1511
- this.dependents || (this.dependents = /* @__PURE__ */ new Set()), this.dependents.add(e);
1512
- }
1513
- removeDependent(e) {
1514
- this.dependents && this.dependents.delete(e);
1515
- }
1516
- /**
1517
- * Returns the latest state of `MotionValue`
1518
- *
1519
- * @returns - The latest state of `MotionValue`
1520
- *
1521
- * @public
1522
- */
1523
- get() {
1524
- return this.current;
1525
- }
1526
- /**
1527
- * @public
1528
- */
1529
- getPrevious() {
1530
- return this.prev;
1531
- }
1532
- /**
1533
- * Returns the latest velocity of `MotionValue`
1534
- *
1535
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1536
- *
1537
- * @public
1538
- */
1539
- getVelocity() {
1540
- const e = E.now();
1541
- if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > yt)
1542
- return 0;
1543
- const n = Math.min(this.updatedAt - this.prevUpdatedAt, yt);
1544
- return Ut(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
1545
- }
1546
- /**
1547
- * Registers a new animation to control this `MotionValue`. Only one
1548
- * animation can drive a `MotionValue` at one time.
1549
- *
1550
- * ```jsx
1551
- * value.start()
1552
- * ```
1553
- *
1554
- * @param animation - A function that starts the provided animation
1555
- */
1556
- start(e) {
1557
- return this.stop(), new Promise((n) => {
1558
- this.hasAnimated = !0, this.animation = e(n), this.events.animationStart && this.events.animationStart.notify();
1559
- }).then(() => {
1560
- this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
1561
- });
1562
- }
1563
- /**
1564
- * Stop the currently active animation.
1565
- *
1566
- * @public
1567
- */
1568
- stop() {
1569
- this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
1570
- }
1571
- /**
1572
- * Returns `true` if this value is currently animating.
1573
- *
1574
- * @public
1575
- */
1576
- isAnimating() {
1577
- return !!this.animation;
1578
- }
1579
- clearAnimation() {
1580
- delete this.animation;
1581
- }
1582
- /**
1583
- * Destroy and clean up subscribers to this `MotionValue`.
1584
- *
1585
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1586
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1587
- * created a `MotionValue` via the `motionValue` function.
1588
- *
1589
- * @public
1590
- */
1591
- destroy() {
1592
- this.dependents?.clear(), this.events.destroy?.notify(), this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1593
- }
1594
- }
1595
- function ce(t, e) {
1596
- return new Ki(t, e);
1597
- }
1598
- const { schedule: Bi } = /* @__PURE__ */ Zt(queueMicrotask, !1), Li = {
1599
- y: !1
1600
- };
1601
- function _i() {
1602
- return Li.y;
1603
- }
1604
- function An(t, e) {
1605
- const n = Ni(t), s = new AbortController(), i = {
1606
- passive: !0,
1607
- ...e,
1608
- signal: s.signal
1609
- };
1610
- return [n, i, () => s.abort()];
1611
- }
1612
- function bt(t) {
1613
- return !(t.pointerType === "touch" || _i());
1614
- }
1615
- function Ui(t, e, n = {}) {
1616
- const [s, i, r] = An(t, n), a = (o) => {
1617
- if (!bt(o))
1618
- return;
1619
- const { target: u } = o, c = e(u, o);
1620
- if (typeof c != "function" || !u)
1621
- return;
1622
- const l = (h) => {
1623
- bt(h) && (c(h), u.removeEventListener("pointerleave", l));
1624
- };
1625
- u.addEventListener("pointerleave", l, i);
1626
- };
1627
- return s.forEach((o) => {
1628
- o.addEventListener("pointerenter", a, i);
1629
- }), r;
1630
- }
1631
- const wn = (t, e) => e ? t === e ? !0 : wn(t, e.parentElement) : !1, $i = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1, Gi = /* @__PURE__ */ new Set([
1632
- "BUTTON",
1633
- "INPUT",
1634
- "SELECT",
1635
- "TEXTAREA",
1636
- "A"
1637
- ]);
1638
- function ji(t) {
1639
- return Gi.has(t.tagName) || t.tabIndex !== -1;
1640
- }
1641
- const re = /* @__PURE__ */ new WeakSet();
1642
- function vt(t) {
1643
- return (e) => {
1644
- e.key === "Enter" && t(e);
1645
- };
1646
- }
1647
- function ve(t, e) {
1648
- t.dispatchEvent(new PointerEvent("pointer" + e, { isPrimary: !0, bubbles: !0 }));
1649
- }
1650
- const Wi = (t, e) => {
1651
- const n = t.currentTarget;
1652
- if (!n)
1653
- return;
1654
- const s = vt(() => {
1655
- if (re.has(n))
1656
- return;
1657
- ve(n, "down");
1658
- const i = vt(() => {
1659
- ve(n, "up");
1660
- }), r = () => ve(n, "cancel");
1661
- n.addEventListener("keyup", i, e), n.addEventListener("blur", r, e);
1662
- });
1663
- n.addEventListener("keydown", s, e), n.addEventListener("blur", () => n.removeEventListener("keydown", s), e);
1664
- };
1665
- function Tt(t) {
1666
- return $i(t) && !0;
1667
- }
1668
- function Hi(t, e, n = {}) {
1669
- const [s, i, r] = An(t, n), a = (o) => {
1670
- const u = o.currentTarget;
1671
- if (!Tt(o))
1672
- return;
1673
- re.add(u);
1674
- const c = e(u, o), l = (d, v) => {
1675
- window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", f), re.has(u) && re.delete(u), Tt(d) && typeof c == "function" && c(d, { success: v });
1676
- }, h = (d) => {
1677
- l(d, u === window || u === document || n.useGlobalTarget || wn(u, d.target));
1678
- }, f = (d) => {
1679
- l(d, !1);
1680
- };
1681
- window.addEventListener("pointerup", h, i), window.addEventListener("pointercancel", f, i);
1682
- };
1683
- return s.forEach((o) => {
1684
- (n.useGlobalTarget ? window : o).addEventListener("pointerdown", a, i), _n(o) && (o.addEventListener("focus", (c) => Wi(c, i)), !ji(o) && !o.hasAttribute("tabindex") && (o.tabIndex = 0));
1685
- }), r;
1686
- }
1687
- const zi = [...vn, x, Z], qi = (t) => zi.find(bn(t));
1688
- function Yi({ top: t, left: e, right: n, bottom: s }) {
1689
- return {
1690
- x: { min: e, max: n },
1691
- y: { min: t, max: s }
1692
- };
1693
- }
1694
- function Xi(t, e) {
1695
- if (!e)
1696
- return t;
1697
- const n = e({ x: t.left, y: t.top }), s = e({ x: t.right, y: t.bottom });
1698
- return {
1699
- top: n.y,
1700
- left: n.x,
1701
- bottom: s.y,
1702
- right: s.x
1703
- };
1704
- }
1705
- function Zi(t, e) {
1706
- return Yi(Xi(t.getBoundingClientRect(), e));
1707
- }
1708
- const Vt = () => ({ min: 0, max: 0 }), Sn = () => ({
1709
- x: Vt(),
1710
- y: Vt()
1711
- }), ke = { current: null }, xn = { current: !1 };
1712
- function Ji() {
1713
- if (xn.current = !0, !!Un)
1714
- if (window.matchMedia) {
1715
- const t = window.matchMedia("(prefers-reduced-motion)"), e = () => ke.current = t.matches;
1716
- t.addEventListener("change", e), e();
1717
- } else
1718
- ke.current = !1;
1719
- }
1720
- const Qi = /* @__PURE__ */ new WeakMap();
1721
- function er(t, e, n) {
1722
- for (const s in e) {
1723
- const i = e[s], r = n[s];
1724
- if (k(i))
1725
- t.addValue(s, i);
1726
- else if (k(r))
1727
- t.addValue(s, ce(i, { owner: t }));
1728
- else if (r !== i)
1729
- if (t.hasValue(s)) {
1730
- const a = t.getValue(s);
1731
- a.liveStyle === !0 ? a.jump(i) : a.hasAnimated || a.set(i);
1732
- } else {
1733
- const a = t.getStaticValue(s);
1734
- t.addValue(s, ce(a !== void 0 ? a : i, { owner: t }));
1735
- }
1736
- }
1737
- for (const s in n)
1738
- e[s] === void 0 && t.removeValue(s);
1739
- return e;
1740
- }
1741
- const At = [
1742
- "AnimationStart",
1743
- "AnimationComplete",
1744
- "Update",
1745
- "BeforeLayoutMeasure",
1746
- "LayoutMeasure",
1747
- "LayoutAnimationStart",
1748
- "LayoutAnimationComplete"
1749
- ];
1750
- class tr {
1751
- /**
1752
- * This method takes React props and returns found MotionValues. For example, HTML
1753
- * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
1754
- *
1755
- * This isn't an abstract method as it needs calling in the constructor, but it is
1756
- * intended to be one.
1757
- */
1758
- scrapeMotionValuesFromProps(e, n, s) {
1759
- return {};
1760
- }
1761
- constructor({ parent: e, props: n, presenceContext: s, reducedMotionConfig: i, blockInitialAnimation: r, visualState: a }, o = {}) {
1762
- this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = Je, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => {
1763
- this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
1764
- }, this.renderScheduledAt = 0, this.scheduleRender = () => {
1765
- const f = E.now();
1766
- this.renderScheduledAt < f && (this.renderScheduledAt = f, O.render(this.render, !1, !0));
1767
- };
1768
- const { latestValues: u, renderState: c } = a;
1769
- this.latestValues = u, this.baseTarget = { ...u }, this.initialValues = n.initial ? { ...u } : {}, this.renderState = c, this.parent = e, this.props = n, this.presenceContext = s, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = i, this.options = o, this.blockInitialAnimation = !!r, this.isControllingVariants = $n(n), this.isVariantNode = Gn(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current);
1770
- const { willChange: l, ...h } = this.scrapeMotionValuesFromProps(n, {}, this);
1771
- for (const f in h) {
1772
- const d = h[f];
1773
- u[f] !== void 0 && k(d) && d.set(u[f]);
1774
- }
1775
- }
1776
- mount(e) {
1777
- this.current = e, Qi.set(e, this), this.projection && !this.projection.instance && this.projection.mount(e), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((n, s) => this.bindToMotionValue(s, n)), xn.current || Ji(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : ke.current, process.env.NODE_ENV !== "production" && Dt(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled"), this.parent?.addChild(this), this.update(this.props, this.presenceContext);
1778
- }
1779
- unmount() {
1780
- this.projection && this.projection.unmount(), Ae(this.notifyUpdate), Ae(this.render), this.valueSubscriptions.forEach((e) => e()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent?.removeChild(this);
1781
- for (const e in this.events)
1782
- this.events[e].clear();
1783
- for (const e in this.features) {
1784
- const n = this.features[e];
1785
- n && (n.unmount(), n.isMounted = !1);
1786
- }
1787
- this.current = null;
1788
- }
1789
- addChild(e) {
1790
- this.children.add(e), this.enteringChildren ?? (this.enteringChildren = /* @__PURE__ */ new Set()), this.enteringChildren.add(e);
1791
- }
1792
- removeChild(e) {
1793
- this.children.delete(e), this.enteringChildren && this.enteringChildren.delete(e);
1794
- }
1795
- bindToMotionValue(e, n) {
1796
- this.valueSubscriptions.has(e) && this.valueSubscriptions.get(e)();
1797
- const s = fe.has(e);
1798
- s && this.onBindTransform && this.onBindTransform();
1799
- const i = n.on("change", (a) => {
1800
- this.latestValues[e] = a, this.props.onUpdate && O.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0), this.scheduleRender();
1801
- });
1802
- let r;
1803
- window.MotionCheckAppearSync && (r = window.MotionCheckAppearSync(this, e, n)), this.valueSubscriptions.set(e, () => {
1804
- i(), r && r(), n.owner && n.stop();
1805
- });
1806
- }
1807
- sortNodePosition(e) {
1808
- return !this.current || !this.sortInstanceNodePosition || this.type !== e.type ? 0 : this.sortInstanceNodePosition(this.current, e.current);
1809
- }
1810
- updateFeatures() {
1811
- let e = "animation";
1812
- for (e in nt) {
1813
- const n = nt[e];
1814
- if (!n)
1815
- continue;
1816
- const { isEnabled: s, Feature: i } = n;
1817
- if (!this.features[e] && i && s(this.props) && (this.features[e] = new i(this)), this.features[e]) {
1818
- const r = this.features[e];
1819
- r.isMounted ? r.update() : (r.mount(), r.isMounted = !0);
1820
- }
1821
- }
1822
- }
1823
- triggerBuild() {
1824
- this.build(this.renderState, this.latestValues, this.props);
1825
- }
1826
- /**
1827
- * Measure the current viewport box with or without transforms.
1828
- * Only measures axis-aligned boxes, rotate and skew must be manually
1829
- * removed with a re-render to work.
1830
- */
1831
- measureViewportBox() {
1832
- return this.current ? this.measureInstanceViewportBox(this.current, this.props) : Sn();
1833
- }
1834
- getStaticValue(e) {
1835
- return this.latestValues[e];
1836
- }
1837
- setStaticValue(e, n) {
1838
- this.latestValues[e] = n;
1839
- }
1840
- /**
1841
- * Update the provided props. Ensure any newly-added motion values are
1842
- * added to our map, old ones removed, and listeners updated.
1843
- */
1844
- update(e, n) {
1845
- (e.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = e, this.prevPresenceContext = this.presenceContext, this.presenceContext = n;
1846
- for (let s = 0; s < At.length; s++) {
1847
- const i = At[s];
1848
- this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]);
1849
- const r = "on" + i, a = e[r];
1850
- a && (this.propEventSubscriptions[i] = this.on(i, a));
1851
- }
1852
- this.prevMotionValues = er(this, this.scrapeMotionValuesFromProps(e, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue();
1853
- }
1854
- getProps() {
1855
- return this.props;
1856
- }
1857
- /**
1858
- * Returns the variant definition with a given name.
1859
- */
1860
- getVariant(e) {
1861
- return this.props.variants ? this.props.variants[e] : void 0;
1862
- }
1863
- /**
1864
- * Returns the defined default transition on this component.
1865
- */
1866
- getDefaultTransition() {
1867
- return this.props.transition;
1868
- }
1869
- getTransformPagePoint() {
1870
- return this.props.transformPagePoint;
1871
- }
1872
- getClosestVariantNode() {
1873
- return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0;
1874
- }
1875
- /**
1876
- * Add a child visual element to our set of children.
1877
- */
1878
- addVariantChild(e) {
1879
- const n = this.getClosestVariantNode();
1880
- if (n)
1881
- return n.variantChildren && n.variantChildren.add(e), () => n.variantChildren.delete(e);
1882
- }
1883
- /**
1884
- * Add a motion value and bind it to this visual element.
1885
- */
1886
- addValue(e, n) {
1887
- const s = this.values.get(e);
1888
- n !== s && (s && this.removeValue(e), this.bindToMotionValue(e, n), this.values.set(e, n), this.latestValues[e] = n.get());
1889
- }
1890
- /**
1891
- * Remove a motion value and unbind any active subscriptions.
1892
- */
1893
- removeValue(e) {
1894
- this.values.delete(e);
1895
- const n = this.valueSubscriptions.get(e);
1896
- n && (n(), this.valueSubscriptions.delete(e)), delete this.latestValues[e], this.removeValueFromRenderState(e, this.renderState);
1897
- }
1898
- /**
1899
- * Check whether we have a motion value for this key
1900
- */
1901
- hasValue(e) {
1902
- return this.values.has(e);
1903
- }
1904
- getValue(e, n) {
1905
- if (this.props.values && this.props.values[e])
1906
- return this.props.values[e];
1907
- let s = this.values.get(e);
1908
- return s === void 0 && n !== void 0 && (s = ce(n === null ? void 0 : n, { owner: this }), this.addValue(e, s)), s;
1909
- }
1910
- /**
1911
- * If we're trying to animate to a previously unencountered value,
1912
- * we need to check for it in our state and as a last resort read it
1913
- * directly from the instance (which might have performance implications).
1914
- */
1915
- readValue(e, n) {
1916
- let s = this.latestValues[e] !== void 0 || !this.current ? this.latestValues[e] : this.getBaseTargetFromProps(this.props, e) ?? this.readValueFromInstance(this.current, e, this.options);
1917
- return s != null && (typeof s == "string" && (Kt(s) || Bt(s)) ? s = parseFloat(s) : !qi(s) && Z.test(n) && (s = Vn(e, n)), this.setBaseTarget(e, k(s) ? s.get() : s)), k(s) ? s.get() : s;
1918
- }
1919
- /**
1920
- * Set the base target to later animate back to. This is currently
1921
- * only hydrated on creation and when we first read a value.
1922
- */
1923
- setBaseTarget(e, n) {
1924
- this.baseTarget[e] = n;
1925
- }
1926
- /**
1927
- * Find the base target for a value thats been removed from all animation
1928
- * props.
1929
- */
1930
- getBaseTarget(e) {
1931
- const { initial: n } = this.props;
1932
- let s;
1933
- if (typeof n == "string" || typeof n == "object") {
1934
- const r = Et(this.props, n, this.presenceContext?.custom);
1935
- r && (s = r[e]);
1936
- }
1937
- if (n && s !== void 0)
1938
- return s;
1939
- const i = this.getBaseTargetFromProps(this.props, e);
1940
- return i !== void 0 && !k(i) ? i : this.initialValues[e] !== void 0 && s === void 0 ? void 0 : this.baseTarget[e];
1941
- }
1942
- on(e, n) {
1943
- return this.events[e] || (this.events[e] = new _t()), this.events[e].add(n);
1944
- }
1945
- notify(e, ...n) {
1946
- this.events[e] && this.events[e].notify(...n);
1947
- }
1948
- scheduleRenderMicrotask() {
1949
- Bi.render(this.render);
1950
- }
1951
- }
1952
- class Mn extends tr {
1953
- constructor() {
1954
- super(...arguments), this.KeyframeResolver = Ri;
1955
- }
1956
- sortInstanceNodePosition(e, n) {
1957
- return e.compareDocumentPosition(n) & 2 ? 1 : -1;
1958
- }
1959
- getBaseTargetFromProps(e, n) {
1960
- return e.style ? e.style[n] : void 0;
1961
- }
1962
- removeValueFromRenderState(e, { vars: n, style: s }) {
1963
- delete n[e], delete s[e];
1964
- }
1965
- handleChildMotionValue() {
1966
- this.childSubscription && (this.childSubscription(), delete this.childSubscription);
1967
- const { children: e } = this.props;
1968
- k(e) && (this.childSubscription = e.on("change", (n) => {
1969
- this.current && (this.current.textContent = `${n}`);
1970
- }));
1971
- }
1972
- }
1973
- function Cn(t, { style: e, vars: n }, s, i) {
1974
- const r = t.style;
1975
- let a;
1976
- for (a in e)
1977
- r[a] = e[a];
1978
- i?.applyProjectionStyles(r, s);
1979
- for (a in n)
1980
- r.setProperty(a, n[a]);
1981
- }
1982
- function nr(t) {
1983
- return window.getComputedStyle(t);
1984
- }
1985
- class sr extends Mn {
1986
- constructor() {
1987
- super(...arguments), this.type = "html", this.renderInstance = Cn;
1988
- }
1989
- readValueFromInstance(e, n) {
1990
- if (fe.has(n))
1991
- return this.projection?.isProjecting ? Fe(n) : Qs(e, n);
1992
- {
1993
- const s = nr(e), i = (jn(n) ? s.getPropertyValue(n) : s[n]) || 0;
1994
- return typeof i == "string" ? i.trim() : i;
1995
- }
1996
- }
1997
- measureInstanceViewportBox(e, { transformPagePoint: n }) {
1998
- return Zi(e, n);
1999
- }
2000
- build(e, n, s) {
2001
- Wn(e, n, s.transformTemplate);
2002
- }
2003
- scrapeMotionValuesFromProps(e, n, s) {
2004
- return Hn(e, n, s);
2005
- }
2006
- }
2007
- const Pn = /* @__PURE__ */ new Set([
2008
- "baseFrequency",
2009
- "diffuseConstant",
2010
- "kernelMatrix",
2011
- "kernelUnitLength",
2012
- "keySplines",
2013
- "keyTimes",
2014
- "limitingConeAngle",
2015
- "markerHeight",
2016
- "markerWidth",
2017
- "numOctaves",
2018
- "targetX",
2019
- "targetY",
2020
- "surfaceScale",
2021
- "specularConstant",
2022
- "specularExponent",
2023
- "stdDeviation",
2024
- "tableValues",
2025
- "viewBox",
2026
- "gradientTransform",
2027
- "pathLength",
2028
- "startOffset",
2029
- "textLength",
2030
- "lengthAdjust"
2031
- ]);
2032
- function ir(t, e, n, s) {
2033
- Cn(t, e, void 0, s);
2034
- for (const i in e.attrs)
2035
- t.setAttribute(Pn.has(i) ? i : Ot(i), e.attrs[i]);
2036
- }
2037
- class rr extends Mn {
2038
- constructor() {
2039
- super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = Sn;
2040
- }
2041
- getBaseTargetFromProps(e, n) {
2042
- return e[n];
2043
- }
2044
- readValueFromInstance(e, n) {
2045
- if (fe.has(n)) {
2046
- const s = Tn(n);
2047
- return s && s.default || 0;
2048
- }
2049
- return n = Pn.has(n) ? n : Ot(n), e.getAttribute(n);
2050
- }
2051
- scrapeMotionValuesFromProps(e, n, s) {
2052
- return zn(e, n, s);
2053
- }
2054
- build(e, n, s) {
2055
- qn(e, n, this.isSVGTag, s.transformTemplate, s.style);
2056
- }
2057
- renderInstance(e, n, s, i) {
2058
- ir(e, n, s, i);
2059
- }
2060
- mount(e) {
2061
- this.isSVGTag = Yn(e.tagName), super.mount(e);
2062
- }
2063
- }
2064
- const ar = (t, e) => Xn(t) ? new rr(e) : new sr(e, {
2065
- allowProjection: t !== Jn
2066
- });
2067
- function z(t, e, n) {
2068
- const s = t.getProps();
2069
- return Et(s, e, n !== void 0 ? n : s.custom, t);
2070
- }
2071
- const Ke = (t) => Array.isArray(t);
2072
- function or(t, e, n) {
2073
- t.hasValue(e) ? t.getValue(e).set(n) : t.addValue(e, ce(n));
2074
- }
2075
- function ur(t) {
2076
- return Ke(t) ? t[t.length - 1] || 0 : t;
2077
- }
2078
- function lr(t, e) {
2079
- const n = z(t, e);
2080
- let { transitionEnd: s = {}, transition: i = {}, ...r } = n || {};
2081
- r = { ...r, ...s };
2082
- for (const a in r) {
2083
- const o = ur(r[a]);
2084
- or(t, a, o);
2085
- }
2086
- }
2087
- function cr(t) {
2088
- return !!(k(t) && t.add);
2089
- }
2090
- function hr(t, e) {
2091
- const n = t.getValue("willChange");
2092
- if (cr(n))
2093
- return n.add(e);
2094
- if (!n && N.WillChange) {
2095
- const s = new N.WillChange("auto");
2096
- t.addValue("willChange", s), s.add(e);
2097
- }
2098
- }
2099
- function fr(t) {
2100
- return t.props[Zn];
2101
- }
2102
- const dr = (t) => t !== null;
2103
- function pr(t, { repeat: e, repeatType: n = "loop" }, s) {
2104
- const i = t.filter(dr), r = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1;
2105
- return i[r];
2106
- }
2107
- const mr = {
2108
- type: "spring",
2109
- stiffness: 500,
2110
- damping: 25,
2111
- restSpeed: 10
2112
- }, gr = (t) => ({
2113
- type: "spring",
2114
- stiffness: 550,
2115
- damping: t === 0 ? 2 * Math.sqrt(550) : 30,
2116
- restSpeed: 10
2117
- }), yr = {
2118
- type: "keyframes",
2119
- duration: 0.8
2120
- }, br = {
2121
- type: "keyframes",
2122
- ease: [0.25, 0.1, 0.35, 1],
2123
- duration: 0.3
2124
- }, vr = (t, { keyframes: e }) => e.length > 2 ? yr : fe.has(t) ? t.startsWith("scale") ? gr(e[1]) : mr : br;
2125
- function Tr({ when: t, delay: e, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: r, repeatType: a, repeatDelay: o, from: u, elapsed: c, ...l }) {
2126
- return !!Object.keys(l).length;
2127
- }
2128
- const Vr = (t, e, n, s = {}, i, r) => (a) => {
2129
- const o = gn(s, t) || {}, u = o.delay || s.delay || 0;
2130
- let { elapsed: c = 0 } = s;
2131
- c = c - /* @__PURE__ */ I(u);
2132
- const l = {
2133
- keyframes: Array.isArray(n) ? n : [null, n],
2134
- ease: "easeOut",
2135
- velocity: e.getVelocity(),
2136
- ...o,
2137
- delay: -c,
2138
- onUpdate: (f) => {
2139
- e.set(f), o.onUpdate && o.onUpdate(f);
2140
- },
2141
- onComplete: () => {
2142
- a(), o.onComplete && o.onComplete();
2143
- },
2144
- name: t,
2145
- motionValue: e,
2146
- element: r ? void 0 : i
2147
- };
2148
- Tr(o) || Object.assign(l, vr(t, l)), l.duration && (l.duration = /* @__PURE__ */ I(l.duration)), l.repeatDelay && (l.repeatDelay = /* @__PURE__ */ I(l.repeatDelay)), l.from !== void 0 && (l.keyframes[0] = l.from);
2149
- let h = !1;
2150
- if ((l.type === !1 || l.duration === 0 && !l.repeatDelay) && (Re(l), l.delay === 0 && (h = !0)), (N.instantAnimations || N.skipAnimations) && (h = !0, Re(l), l.delay = 0), l.allowFlatten = !o.type && !o.ease, h && !r && e.get() !== void 0) {
2151
- const f = pr(l.keyframes, o);
2152
- if (f !== void 0) {
2153
- O.update(() => {
2154
- l.onUpdate(f), l.onComplete();
2155
- });
2156
- return;
2157
- }
2158
- }
2159
- return o.isSync ? new Ze(l) : new Ai(l);
2160
- };
2161
- function Ar({ protectedKeys: t, needsAnimating: e }, n) {
2162
- const s = t.hasOwnProperty(n) && e[n] !== !0;
2163
- return e[n] = !1, s;
2164
- }
2165
- function Fn(t, e, { delay: n = 0, transitionOverride: s, type: i } = {}) {
2166
- let { transition: r = t.getDefaultTransition(), transitionEnd: a, ...o } = e;
2167
- s && (r = s);
2168
- const u = [], c = i && t.animationState && t.animationState.getState()[i];
2169
- for (const l in o) {
2170
- const h = t.getValue(l, t.latestValues[l] ?? null), f = o[l];
2171
- if (f === void 0 || c && Ar(c, l))
2172
- continue;
2173
- const d = {
2174
- delay: n,
2175
- ...gn(r || {}, l)
2176
- }, v = h.get();
2177
- if (v !== void 0 && !h.isAnimating && !Array.isArray(f) && f === v && !d.velocity)
2178
- continue;
2179
- let T = !1;
2180
- if (window.MotionHandoffAnimation) {
2181
- const p = fr(t);
2182
- if (p) {
2183
- const V = window.MotionHandoffAnimation(p, l, O);
2184
- V !== null && (d.startTime = V, T = !0);
2185
- }
2186
- }
2187
- hr(t, l), h.start(Vr(l, h, f, t.shouldReduceMotion && yn.has(l) ? { type: !1 } : d, t, T));
2188
- const b = h.animation;
2189
- b && u.push(b);
2190
- }
2191
- return a && Promise.all(u).then(() => {
2192
- O.update(() => {
2193
- a && lr(t, a);
2194
- });
2195
- }), u;
2196
- }
2197
- function Dn(t, e, n, s = 0, i = 1) {
2198
- const r = Array.from(t).sort((c, l) => c.sortNodePosition(l)).indexOf(e), a = t.size, o = (a - 1) * s;
2199
- return typeof n == "function" ? n(r, a) : i === 1 ? r * s : o - r * s;
2200
- }
2201
- function Be(t, e, n = {}) {
2202
- const s = z(t, e, n.type === "exit" ? t.presenceContext?.custom : void 0);
2203
- let { transition: i = t.getDefaultTransition() || {} } = s || {};
2204
- n.transitionOverride && (i = n.transitionOverride);
2205
- const r = s ? () => Promise.all(Fn(t, s, n)) : () => Promise.resolve(), a = t.variantChildren && t.variantChildren.size ? (u = 0) => {
2206
- const { delayChildren: c = 0, staggerChildren: l, staggerDirection: h } = i;
2207
- return wr(t, e, u, c, l, h, n);
2208
- } : () => Promise.resolve(), { when: o } = i;
2209
- if (o) {
2210
- const [u, c] = o === "beforeChildren" ? [r, a] : [a, r];
2211
- return u().then(() => c());
2212
- } else
2213
- return Promise.all([r(), a(n.delay)]);
2214
- }
2215
- function wr(t, e, n = 0, s = 0, i = 0, r = 1, a) {
2216
- const o = [];
2217
- for (const u of t.variantChildren)
2218
- u.notify("AnimationStart", e), o.push(Be(u, e, {
2219
- ...a,
2220
- delay: n + (typeof s == "function" ? 0 : s) + Dn(t.variantChildren, u, s, i, r)
2221
- }).then(() => u.notify("AnimationComplete", e)));
2222
- return Promise.all(o);
2223
- }
2224
- function Sr(t, e, n = {}) {
2225
- t.notify("AnimationStart", e);
2226
- let s;
2227
- if (Array.isArray(e)) {
2228
- const i = e.map((r) => Be(t, r, n));
2229
- s = Promise.all(i);
2230
- } else if (typeof e == "string")
2231
- s = Be(t, e, n);
2232
- else {
2233
- const i = typeof e == "function" ? z(t, e, n.custom) : e;
2234
- s = Promise.all(Fn(t, i, n));
2235
- }
2236
- return s.then(() => {
2237
- t.notify("AnimationComplete", e);
2238
- });
2239
- }
2240
- function En(t, e) {
2241
- if (!Array.isArray(e))
2242
- return !1;
2243
- const n = e.length;
2244
- if (n !== t.length)
2245
- return !1;
2246
- for (let s = 0; s < n; s++)
2247
- if (e[s] !== t[s])
2248
- return !1;
2249
- return !0;
2250
- }
2251
- const xr = Rt.length;
2252
- function On(t) {
2253
- if (!t)
2254
- return;
2255
- if (!t.isControllingVariants) {
2256
- const n = t.parent ? On(t.parent) || {} : {};
2257
- return t.props.initial !== void 0 && (n.initial = t.props.initial), n;
2258
- }
2259
- const e = {};
2260
- for (let n = 0; n < xr; n++) {
2261
- const s = Rt[n], i = t.props[s];
2262
- (It(i) || i === !1) && (e[s] = i);
2263
- }
2264
- return e;
2265
- }
2266
- const Mr = [...kt].reverse(), Cr = kt.length;
2267
- function Pr(t) {
2268
- return (e) => Promise.all(e.map(({ animation: n, options: s }) => Sr(t, n, s)));
2269
- }
2270
- function Fr(t) {
2271
- let e = Pr(t), n = wt(), s = !0;
2272
- const i = (u) => (c, l) => {
2273
- const h = z(t, l, u === "exit" ? t.presenceContext?.custom : void 0);
2274
- if (h) {
2275
- const { transition: f, transitionEnd: d, ...v } = h;
2276
- c = { ...c, ...v, ...d };
2277
- }
2278
- return c;
2279
- };
2280
- function r(u) {
2281
- e = u(t);
2282
- }
2283
- function a(u) {
2284
- const { props: c } = t, l = On(t.parent) || {}, h = [], f = /* @__PURE__ */ new Set();
2285
- let d = {}, v = 1 / 0;
2286
- for (let b = 0; b < Cr; b++) {
2287
- const p = Mr[b], V = n[p], g = c[p] !== void 0 ? c[p] : l[p], S = It(g), m = p === u ? V.isActive : null;
2288
- m === !1 && (v = b);
2289
- let A = g === l[p] && g !== c[p] && S;
2290
- if (A && s && t.manuallyAnimateOnMount && (A = !1), V.protectedKeys = { ...d }, // If it isn't active and hasn't *just* been set as inactive
2291
- !V.isActive && m === null || // If we didn't and don't have any defined prop for this animation type
2292
- !g && !V.prevProp || // Or if the prop doesn't define an animation
2293
- Nt(g) || typeof g == "boolean")
2294
- continue;
2295
- const M = Dr(V.prevProp, g);
2296
- let y = M || // If we're making this variant active, we want to always make it active
2297
- p === u && V.isActive && !A && S || // If we removed a higher-priority variant (i is in reverse order)
2298
- b > v && S, P = !1;
2299
- const F = Array.isArray(g) ? g : [g];
2300
- let G = F.reduce(i(p), {});
2301
- m === !1 && (G = {});
2302
- const { prevResolvedValues: Qe = {} } = V, Rn = {
2303
- ...Qe,
2304
- ...G
2305
- }, et = (C) => {
2306
- y = !0, f.has(C) && (P = !0, f.delete(C)), V.needsAnimating[C] = !0;
2307
- const D = t.getValue(C);
2308
- D && (D.liveStyle = !1);
2309
- };
2310
- for (const C in Rn) {
2311
- const D = G[C], K = Qe[C];
2312
- if (d.hasOwnProperty(C))
2313
- continue;
2314
- let j = !1;
2315
- Ke(D) && Ke(K) ? j = !En(D, K) : j = D !== K, j ? D != null ? et(C) : f.add(C) : D !== void 0 && f.has(C) ? et(C) : V.protectedKeys[C] = !0;
2316
- }
2317
- V.prevProp = g, V.prevResolvedValues = G, V.isActive && (d = { ...d, ...G }), s && t.blockInitialAnimation && (y = !1);
2318
- const tt = A && M;
2319
- y && (!tt || P) && h.push(...F.map((C) => {
2320
- const D = { type: p };
2321
- if (typeof C == "string" && s && !tt && t.manuallyAnimateOnMount && t.parent) {
2322
- const { parent: K } = t, j = z(K, C);
2323
- if (K.enteringChildren && j) {
2324
- const { delayChildren: Nn } = j.transition || {};
2325
- D.delay = Dn(K.enteringChildren, t, Nn);
2326
- }
2327
- }
2328
- return {
2329
- animation: C,
2330
- options: D
2331
- };
2332
- }));
2333
- }
2334
- if (f.size) {
2335
- const b = {};
2336
- if (typeof c.initial != "boolean") {
2337
- const p = z(t, Array.isArray(c.initial) ? c.initial[0] : c.initial);
2338
- p && p.transition && (b.transition = p.transition);
2339
- }
2340
- f.forEach((p) => {
2341
- const V = t.getBaseTarget(p), g = t.getValue(p);
2342
- g && (g.liveStyle = !0), b[p] = V ?? null;
2343
- }), h.push({ animation: b });
2344
- }
2345
- let T = !!h.length;
2346
- return s && (c.initial === !1 || c.initial === c.animate) && !t.manuallyAnimateOnMount && (T = !1), s = !1, T ? e(h) : Promise.resolve();
2347
- }
2348
- function o(u, c) {
2349
- if (n[u].isActive === c)
2350
- return Promise.resolve();
2351
- t.variantChildren?.forEach((h) => h.animationState?.setActive(u, c)), n[u].isActive = c;
2352
- const l = a(u);
2353
- for (const h in n)
2354
- n[h].protectedKeys = {};
2355
- return l;
2356
- }
2357
- return {
2358
- animateChanges: a,
2359
- setActive: o,
2360
- setAnimateFunction: r,
2361
- getState: () => n,
2362
- reset: () => {
2363
- n = wt(), s = !0;
2364
- }
2365
- };
2366
- }
2367
- function Dr(t, e) {
2368
- return typeof e == "string" ? e !== t : Array.isArray(e) ? !En(e, t) : !1;
2369
- }
2370
- function B(t = !1) {
2371
- return {
2372
- isActive: t,
2373
- protectedKeys: {},
2374
- needsAnimating: {},
2375
- prevResolvedValues: {}
2376
- };
2377
- }
2378
- function wt() {
2379
- return {
2380
- animate: B(!0),
2381
- whileInView: B(),
2382
- whileHover: B(),
2383
- whileTap: B(),
2384
- whileDrag: B(),
2385
- whileFocus: B(),
2386
- exit: B()
2387
- };
2388
- }
2389
- class J {
2390
- constructor(e) {
2391
- this.isMounted = !1, this.node = e;
2392
- }
2393
- update() {
2394
- }
2395
- }
2396
- class Er extends J {
2397
- /**
2398
- * We dynamically generate the AnimationState manager as it contains a reference
2399
- * to the underlying animation library. We only want to load that if we load this,
2400
- * so people can optionally code split it out using the `m` component.
2401
- */
2402
- constructor(e) {
2403
- super(e), e.animationState || (e.animationState = Fr(e));
2404
- }
2405
- updateAnimationControlsSubscription() {
2406
- const { animate: e } = this.node.getProps();
2407
- Nt(e) && (this.unmountControls = e.subscribe(this.node));
2408
- }
2409
- /**
2410
- * Subscribe any provided AnimationControls to the component's VisualElement
2411
- */
2412
- mount() {
2413
- this.updateAnimationControlsSubscription();
2414
- }
2415
- update() {
2416
- const { animate: e } = this.node.getProps(), { animate: n } = this.node.prevProps || {};
2417
- e !== n && this.updateAnimationControlsSubscription();
2418
- }
2419
- unmount() {
2420
- this.node.animationState.reset(), this.unmountControls?.();
2421
- }
2422
- }
2423
- let Or = 0;
2424
- class Ir extends J {
2425
- constructor() {
2426
- super(...arguments), this.id = Or++;
2427
- }
2428
- update() {
2429
- if (!this.node.presenceContext)
2430
- return;
2431
- const { isPresent: e, onExitComplete: n } = this.node.presenceContext, { isPresent: s } = this.node.prevPresenceContext || {};
2432
- if (!this.node.animationState || e === s)
2433
- return;
2434
- const i = this.node.animationState.setActive("exit", !e);
2435
- n && !e && i.then(() => {
2436
- n(this.id);
2437
- });
2438
- }
2439
- mount() {
2440
- const { register: e, onExitComplete: n } = this.node.presenceContext || {};
2441
- n && n(this.id), e && (this.unmount = e(this.id));
2442
- }
2443
- unmount() {
2444
- }
2445
- }
2446
- const Rr = {
2447
- animation: {
2448
- Feature: Er
2449
- },
2450
- exit: {
2451
- Feature: Ir
2452
- }
2453
- };
2454
- function St(t, e, n, s = { passive: !0 }) {
2455
- return t.addEventListener(e, n, s), () => t.removeEventListener(e, n);
2456
- }
2457
- function In(t) {
2458
- return {
2459
- point: {
2460
- x: t.pageX,
2461
- y: t.pageY
2462
- }
2463
- };
2464
- }
2465
- function xt(t, e, n) {
2466
- const { props: s } = t;
2467
- t.animationState && s.whileHover && t.animationState.setActive("whileHover", n === "Start");
2468
- const i = "onHover" + n, r = s[i];
2469
- r && O.postRender(() => r(e, In(e)));
2470
- }
2471
- class Nr extends J {
2472
- mount() {
2473
- const { current: e } = this.node;
2474
- e && (this.unmount = Ui(e, (n, s) => (xt(this.node, s, "Start"), (i) => xt(this.node, i, "End"))));
2475
- }
2476
- unmount() {
2477
- }
2478
- }
2479
- class kr extends J {
2480
- constructor() {
2481
- super(...arguments), this.isActive = !1;
2482
- }
2483
- onFocus() {
2484
- let e = !1;
2485
- try {
2486
- e = this.node.current.matches(":focus-visible");
2487
- } catch {
2488
- e = !0;
2489
- }
2490
- !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
2491
- }
2492
- onBlur() {
2493
- !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
2494
- }
2495
- mount() {
2496
- this.unmount = de(St(this.node.current, "focus", () => this.onFocus()), St(this.node.current, "blur", () => this.onBlur()));
2497
- }
2498
- unmount() {
2499
- }
2500
- }
2501
- function Mt(t, e, n) {
2502
- const { props: s } = t;
2503
- if (t.current instanceof HTMLButtonElement && t.current.disabled)
2504
- return;
2505
- t.animationState && s.whileTap && t.animationState.setActive("whileTap", n === "Start");
2506
- const i = "onTap" + (n === "End" ? "" : n), r = s[i];
2507
- r && O.postRender(() => r(e, In(e)));
2508
- }
2509
- class Kr extends J {
2510
- mount() {
2511
- const { current: e } = this.node;
2512
- e && (this.unmount = Hi(e, (n, s) => (Mt(this.node, s, "Start"), (i, { success: r }) => Mt(this.node, i, r ? "End" : "Cancel")), { useGlobalTarget: this.node.props.globalTapTarget }));
2513
- }
2514
- unmount() {
2515
- }
2516
- }
2517
- const Le = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), Br = (t) => {
2518
- const e = Le.get(t.target);
2519
- e && e(t);
2520
- }, Lr = (t) => {
2521
- t.forEach(Br);
2522
- };
2523
- function _r({ root: t, ...e }) {
2524
- const n = t || document;
2525
- Te.has(n) || Te.set(n, {});
2526
- const s = Te.get(n), i = JSON.stringify(e);
2527
- return s[i] || (s[i] = new IntersectionObserver(Lr, { root: t, ...e })), s[i];
2528
- }
2529
- function Ur(t, e, n) {
2530
- const s = _r(e);
2531
- return Le.set(t, n), s.observe(t), () => {
2532
- Le.delete(t), s.unobserve(t);
2533
- };
2534
- }
2535
- const $r = {
2536
- some: 0,
2537
- all: 1
2538
- };
2539
- class Gr extends J {
2540
- constructor() {
2541
- super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
2542
- }
2543
- startObserver() {
2544
- this.unmount();
2545
- const { viewport: e = {} } = this.node.getProps(), { root: n, margin: s, amount: i = "some", once: r } = e, a = {
2546
- root: n ? n.current : void 0,
2547
- rootMargin: s,
2548
- threshold: typeof i == "number" ? i : $r[i]
2549
- }, o = (u) => {
2550
- const { isIntersecting: c } = u;
2551
- if (this.isInView === c || (this.isInView = c, r && !c && this.hasEnteredView))
2552
- return;
2553
- c && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", c);
2554
- const { onViewportEnter: l, onViewportLeave: h } = this.node.getProps(), f = c ? l : h;
2555
- f && f(u);
2556
- };
2557
- return Ur(this.node.current, a, o);
2558
- }
2559
- mount() {
2560
- this.startObserver();
2561
- }
2562
- update() {
2563
- if (typeof IntersectionObserver > "u")
2564
- return;
2565
- const { props: e, prevProps: n } = this.node;
2566
- ["amount", "margin", "root"].some(jr(e, n)) && this.startObserver();
2567
- }
2568
- unmount() {
2569
- }
2570
- }
2571
- function jr({ viewport: t = {} }, { viewport: e = {} } = {}) {
2572
- return (n) => t[n] !== e[n];
2573
- }
2574
- const Wr = {
2575
- inView: {
2576
- Feature: Gr
2577
- },
2578
- tap: {
2579
- Feature: Kr
2580
- },
2581
- focus: {
2582
- Feature: kr
2583
- },
2584
- hover: {
2585
- Feature: Nr
2586
- }
2587
- }, Hr = {
2588
- renderer: ar,
2589
- ...Rr,
2590
- ...Wr
2591
- };
2592
- var Xr = Hr;
2593
- export {
2594
- Xr as default
2595
- };
2596
- //# sourceMappingURL=index-ts2rjY-1.js.map