@spear-ai/spectral 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/Accordion.d.ts +7 -7
  2. package/dist/Accordion.js +53 -51
  3. package/dist/Alert/AlertBase.js +6 -6
  4. package/dist/Alert.js +1 -1
  5. package/dist/Avatar.d.ts +2 -2
  6. package/dist/Avatar.js +46 -46
  7. package/dist/Badge.js +3 -3
  8. package/dist/Button.js +19 -12
  9. package/dist/ButtonGroup/ButtonGroupButton.d.ts +1 -1
  10. package/dist/ButtonGroup/ButtonGroupButton.js +10 -10
  11. package/dist/ButtonGroup.d.ts +8 -5
  12. package/dist/ButtonGroup.js +22 -14
  13. package/dist/ButtonIcon.d.ts +1 -1
  14. package/dist/ButtonIcon.js +5 -5
  15. package/dist/Card.d.ts +1 -1
  16. package/dist/Card.js +10 -10
  17. package/dist/Checkbox/CheckboxBase.d.ts +6 -6
  18. package/dist/Checkbox/CheckboxBase.js +65 -63
  19. package/dist/Checkbox.js +16 -14
  20. package/dist/Dialog/DialogBase.d.ts +37 -25
  21. package/dist/Dialog/DialogBase.js +130 -104
  22. package/dist/Dialog.d.ts +8 -8
  23. package/dist/Dialog.js +46 -36
  24. package/dist/Drawer.js +17 -17
  25. package/dist/HoverCard.d.ts +4 -4
  26. package/dist/HoverCard.js +34 -33
  27. package/dist/Input.js +58 -58
  28. package/dist/InputOTP.d.ts +1 -1
  29. package/dist/InputOTP.js +113 -112
  30. package/dist/MultiSelect/MultiSelectBase.d.ts +16 -16
  31. package/dist/MultiSelect/MultiSelectBase.js +236 -177
  32. package/dist/MultiSelect/MutiSelect.d.ts +6 -4
  33. package/dist/MultiSelect/MutiSelect.js +13 -12
  34. package/dist/Popover.js +2 -1
  35. package/dist/RadioButtonGroup/RadioButtonGroupBase.js +18 -17
  36. package/dist/RadioGroup.js +5 -3
  37. package/dist/Select.js +70 -51
  38. package/dist/Slider.js +8 -4
  39. package/dist/Switch/SwitchBase.d.ts +6 -6
  40. package/dist/Switch/SwitchBase.js +39 -38
  41. package/dist/Switch.js +17 -16
  42. package/dist/Tabs/TabsBase.js +40 -25
  43. package/dist/Tabs.js +18 -21
  44. package/dist/Textarea.d.ts +1 -0
  45. package/dist/Textarea.js +33 -33
  46. package/dist/Toggle.js +4 -4
  47. package/dist/ToggleGroup/ToggleGroupBase.d.ts +7 -7
  48. package/dist/ToggleGroup/ToggleGroupBase.js +64 -64
  49. package/dist/ToggleGroup.js +19 -17
  50. package/dist/Tooltip/TooltipBase.d.ts +8 -8
  51. package/dist/Tooltip/TooltipBase.js +76 -74
  52. package/dist/Tooltip.d.ts +1 -1
  53. package/dist/Tooltip.js +12 -11
  54. package/dist/Tray.d.ts +1 -1
  55. package/dist/Tray.js +4910 -117
  56. package/dist/primitives/input.js +4 -4
  57. package/dist/primitives/select.d.ts +11 -11
  58. package/dist/primitives/select.d.ts.map +1 -1
  59. package/dist/primitives/select.js +28 -21
  60. package/dist/styles/main.css +1 -1
  61. package/dist/utils/{refs.d.ts → createForwardRef.d.ts} +1 -1
  62. package/dist/utils/createForwardRef.d.ts.map +1 -0
  63. package/dist/utils/formFieldUtils.d.ts +22 -18
  64. package/dist/utils/formFieldUtils.d.ts.map +1 -1
  65. package/dist/utils/formFieldUtils.js +46 -46
  66. package/package.json +9 -5
  67. package/dist/analyzer/list.yml.webp +0 -0
  68. package/dist/analyzer/network.webp +0 -0
  69. package/dist/analyzer/sunburst.webp +0 -0
  70. package/dist/analyzer/visual.webp +0 -0
  71. package/dist/auth-background.json +0 -90
  72. package/dist/favicon-invert.svg +0 -5
  73. package/dist/favicon.svg +0 -5
  74. package/dist/features/AuthCard/AuthCard.d.ts +0 -3
  75. package/dist/features/AuthCard/AuthCard.d.ts.map +0 -1
  76. package/dist/features/AuthCard/AuthToggle.d.ts +0 -9
  77. package/dist/features/AuthCard/AuthToggle.d.ts.map +0 -1
  78. package/dist/features/AuthCard/AuthToggle.js +0 -20
  79. package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts +0 -11
  80. package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts.map +0 -1
  81. package/dist/features/AuthCard/ForgotPasswordEmailForm.js +0 -86
  82. package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts +0 -11
  83. package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts.map +0 -1
  84. package/dist/features/AuthCard/ForgotPasswordResetForm.js +0 -21
  85. package/dist/features/AuthCard/OTPInput.d.ts +0 -12
  86. package/dist/features/AuthCard/OTPInput.d.ts.map +0 -1
  87. package/dist/features/AuthCard/OTPInput.js +0 -12
  88. package/dist/features/AuthCard/PasswordInput.d.ts +0 -13
  89. package/dist/features/AuthCard/PasswordInput.d.ts.map +0 -1
  90. package/dist/features/AuthCard/PasswordInput.js +0 -93
  91. package/dist/features/AuthCard/SignInForm.d.ts +0 -9
  92. package/dist/features/AuthCard/SignInForm.d.ts.map +0 -1
  93. package/dist/features/AuthCard/SignInForm.js +0 -86
  94. package/dist/features/AuthCard/SignUpForm.d.ts +0 -8
  95. package/dist/features/AuthCard/SignUpForm.d.ts.map +0 -1
  96. package/dist/features/AuthCard/SignUpForm.js +0 -100
  97. package/dist/features/AuthCard.js +0 -202
  98. package/dist/features/ClearDialog/ClearDialog.d.ts +0 -2
  99. package/dist/features/ClearDialog/ClearDialog.d.ts.map +0 -1
  100. package/dist/features/ClearDialog.js +0 -31
  101. package/dist/features/LabelingToolbar/LabelingToolbar.d.ts +0 -8
  102. package/dist/features/LabelingToolbar/LabelingToolbar.d.ts.map +0 -1
  103. package/dist/features/LabelingToolbar.js +0 -13
  104. package/dist/features/LabelingTools/LabelingTools.d.ts +0 -2
  105. package/dist/features/LabelingTools/LabelingTools.d.ts.map +0 -1
  106. package/dist/features/LabelingTools.js +0 -134
  107. package/dist/features/SensorMetadata/SensorMetadata.d.ts +0 -2
  108. package/dist/features/SensorMetadata/SensorMetadata.d.ts.map +0 -1
  109. package/dist/features/SensorMetadata.js +0 -117
  110. package/dist/features/SettingsPopover/SettingsPopover.d.ts +0 -2
  111. package/dist/features/SettingsPopover/SettingsPopover.d.ts.map +0 -1
  112. package/dist/features/SettingsPopover.js +0 -204
  113. package/dist/index-BIpuW_o8.js +0 -146
  114. package/dist/linear-cursor-small.png +0 -0
  115. package/dist/loader-circle-CdRVlFhN.js +0 -11
  116. package/dist/logo/wordmark-dark-side-by-side.svg +0 -6
  117. package/dist/logo/wordmark-light-side-by-side.svg +0 -6
  118. package/dist/message-alert-matte-glass-gradient.webp +0 -0
  119. package/dist/proxy-C9AqCss6.js +0 -4670
  120. package/dist/speech-bubble-fluid-glass-gradient.webp +0 -0
  121. package/dist/themes/grayscale-theme.webp +0 -0
  122. package/dist/themes/green-black-theme.webp +0 -0
  123. package/dist/themes/reverse-grayscale-theme.webp +0 -0
  124. package/dist/themes/viridis-theme.webp +0 -0
  125. package/dist/utils/refs.d.ts.map +0 -1
  126. package/dist/x-Dl66o_vF.js +0 -14
  127. /package/dist/utils/{refs.js → createForwardRef.js} +0 -0
@@ -1,4670 +0,0 @@
1
- import "./styles/main.css";
2
- import { createContext as vt, useRef as Wt, useLayoutEffect as yr, useEffect as Ne, useContext as I, useId as vr, useCallback as Bs, useMemo as Jt, Fragment as Is, createElement as Tr, useInsertionEffect as xr, forwardRef as Pr, Component as br } from "react";
3
- import { jsxs as Sr, jsx as Os } from "react/jsx-runtime";
4
- const js = vt({});
5
- function wr(t) {
6
- const e = Wt(null);
7
- return e.current === null && (e.current = t()), e.current;
8
- }
9
- const Ue = typeof window < "u", Ar = Ue ? yr : Ne, Ke = /* @__PURE__ */ vt(null);
10
- function We(t, e) {
11
- t.indexOf(e) === -1 && t.push(e);
12
- }
13
- function $e(t, e) {
14
- const n = t.indexOf(e);
15
- n > -1 && t.splice(n, 1);
16
- }
17
- const z = (t, e, n) => n > e ? e : n < t ? t : n;
18
- function ye(t, e) {
19
- return e ? `${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}` : t;
20
- }
21
- let Tt = () => {
22
- }, Y = () => {
23
- };
24
- process.env.NODE_ENV !== "production" && (Tt = (t, e, n) => {
25
- !t && typeof console < "u" && console.warn(ye(e, n));
26
- }, Y = (t, e, n) => {
27
- if (!t)
28
- throw new Error(ye(e, n));
29
- });
30
- const X = {}, Ns = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);
31
- function Us(t) {
32
- return typeof t == "object" && t !== null;
33
- }
34
- const Ks = (t) => /^0[^.\s]+$/u.test(t);
35
- // @__NO_SIDE_EFFECTS__
36
- function Ge(t) {
37
- let e;
38
- return () => (e === void 0 && (e = t()), e);
39
- }
40
- const $ = /* @__NO_SIDE_EFFECTS__ */ (t) => t, Vr = (t, e) => (n) => e(t(n)), Bt = (...t) => t.reduce(Vr), Ct = /* @__NO_SIDE_EFFECTS__ */ (t, e, n) => {
41
- const s = e - t;
42
- return s === 0 ? 1 : (n - t) / s;
43
- };
44
- class _e {
45
- constructor() {
46
- this.subscriptions = [];
47
- }
48
- add(e) {
49
- return We(this.subscriptions, e), () => $e(this.subscriptions, e);
50
- }
51
- notify(e, n, s) {
52
- const i = this.subscriptions.length;
53
- if (i)
54
- if (i === 1)
55
- this.subscriptions[0](e, n, s);
56
- else
57
- for (let o = 0; o < i; o++) {
58
- const r = this.subscriptions[o];
59
- r && r(e, n, s);
60
- }
61
- }
62
- getSize() {
63
- return this.subscriptions.length;
64
- }
65
- clear() {
66
- this.subscriptions.length = 0;
67
- }
68
- }
69
- const _ = /* @__NO_SIDE_EFFECTS__ */ (t) => t * 1e3, W = /* @__NO_SIDE_EFFECTS__ */ (t) => t / 1e3;
70
- function Ws(t, e) {
71
- return e ? t * (1e3 / e) : 0;
72
- }
73
- const bn = /* @__PURE__ */ new Set();
74
- function He(t, e, n) {
75
- t || bn.has(e) || (console.warn(ye(e, n)), bn.add(e));
76
- }
77
- const $s = (t, e, n) => (((1 - 3 * n + 3 * e) * t + (3 * n - 6 * e)) * t + 3 * e) * t, Dr = 1e-7, Mr = 12;
78
- function Cr(t, e, n, s, i) {
79
- let o, r, a = 0;
80
- do
81
- r = e + (n - e) / 2, o = $s(r, s, i) - t, o > 0 ? n = r : e = r;
82
- while (Math.abs(o) > Dr && ++a < Mr);
83
- return r;
84
- }
85
- function It(t, e, n, s) {
86
- if (t === e && n === s)
87
- return $;
88
- const i = (o) => Cr(o, 0, 1, t, n);
89
- return (o) => o === 0 || o === 1 ? o : $s(i(o), e, s);
90
- }
91
- const Gs = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, _s = (t) => (e) => 1 - t(1 - e), Hs = /* @__PURE__ */ It(0.33, 1.53, 0.69, 0.99), ze = /* @__PURE__ */ _s(Hs), zs = /* @__PURE__ */ Gs(ze), Ys = (t) => (t *= 2) < 1 ? 0.5 * ze(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), Ye = (t) => 1 - Math.sin(Math.acos(t)), Xs = _s(Ye), qs = Gs(Ye), Er = /* @__PURE__ */ It(0.42, 0, 1, 1), Rr = /* @__PURE__ */ It(0, 0, 0.58, 1), Zs = /* @__PURE__ */ It(0.42, 0, 0.58, 1), Lr = (t) => Array.isArray(t) && typeof t[0] != "number", Js = (t) => Array.isArray(t) && typeof t[0] == "number", Sn = {
92
- linear: $,
93
- easeIn: Er,
94
- easeInOut: Zs,
95
- easeOut: Rr,
96
- circIn: Ye,
97
- circInOut: qs,
98
- circOut: Xs,
99
- backIn: ze,
100
- backInOut: zs,
101
- backOut: Hs,
102
- anticipate: Ys
103
- }, kr = (t) => typeof t == "string", wn = (t) => {
104
- if (Js(t)) {
105
- Y(t.length === 4, "Cubic bezier arrays must contain four numerical values.", "cubic-bezier-length");
106
- const [e, n, s, i] = t;
107
- return It(e, n, s, i);
108
- } else if (kr(t))
109
- return Y(Sn[t] !== void 0, `Invalid easing type '${t}'`, "invalid-easing-type"), Sn[t];
110
- return t;
111
- }, Nt = [
112
- "setup",
113
- // Compute
114
- "read",
115
- // Read
116
- "resolveKeyframes",
117
- // Write/Read/Write/Read
118
- "preUpdate",
119
- // Compute
120
- "update",
121
- // Compute
122
- "preRender",
123
- // Compute
124
- "render",
125
- // Write
126
- "postRender"
127
- // Compute
128
- ];
129
- function Fr(t, e) {
130
- let n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = !1, o = !1;
131
- const r = /* @__PURE__ */ new WeakSet();
132
- let a = {
133
- delta: 0,
134
- timestamp: 0,
135
- isProcessing: !1
136
- };
137
- function l(u) {
138
- r.has(u) && (c.schedule(u), t()), u(a);
139
- }
140
- const c = {
141
- /**
142
- * Schedule a process to run on the next frame.
143
- */
144
- schedule: (u, h = !1, f = !1) => {
145
- const m = f && i ? n : s;
146
- return h && r.add(u), m.has(u) || m.add(u), u;
147
- },
148
- /**
149
- * Cancel the provided callback from running on the next frame.
150
- */
151
- cancel: (u) => {
152
- s.delete(u), r.delete(u);
153
- },
154
- /**
155
- * Execute all schedule callbacks.
156
- */
157
- process: (u) => {
158
- if (a = u, i) {
159
- o = !0;
160
- return;
161
- }
162
- i = !0, [n, s] = [s, n], n.forEach(l), n.clear(), i = !1, o && (o = !1, c.process(u));
163
- }
164
- };
165
- return c;
166
- }
167
- const Br = 40;
168
- function Qs(t, e) {
169
- let n = !1, s = !0;
170
- const i = {
171
- delta: 0,
172
- timestamp: 0,
173
- isProcessing: !1
174
- }, o = () => n = !0, r = Nt.reduce((g, S) => (g[S] = Fr(o), g), {}), { setup: a, read: l, resolveKeyframes: c, preUpdate: u, update: h, preRender: f, render: d, postRender: m } = r, v = () => {
175
- const g = X.useManualTiming ? i.timestamp : performance.now();
176
- n = !1, X.useManualTiming || (i.delta = s ? 1e3 / 60 : Math.max(Math.min(g - i.timestamp, Br), 1)), i.timestamp = g, i.isProcessing = !0, a.process(i), l.process(i), c.process(i), u.process(i), h.process(i), f.process(i), d.process(i), m.process(i), i.isProcessing = !1, n && e && (s = !1, t(v));
177
- }, y = () => {
178
- n = !0, s = !0, i.isProcessing || t(v);
179
- };
180
- return { schedule: Nt.reduce((g, S) => {
181
- const P = r[S];
182
- return g[S] = (w, E = !1, b = !1) => (n || y(), P.schedule(w, E, b)), g;
183
- }, {}), cancel: (g) => {
184
- for (let S = 0; S < Nt.length; S++)
185
- r[Nt[S]].cancel(g);
186
- }, state: i, steps: r };
187
- }
188
- const { schedule: A, cancel: Z, state: L, steps: ne } = /* @__PURE__ */ Qs(typeof requestAnimationFrame < "u" ? requestAnimationFrame : $, !0);
189
- let $t;
190
- function Ir() {
191
- $t = void 0;
192
- }
193
- const O = {
194
- now: () => ($t === void 0 && O.set(L.isProcessing || X.useManualTiming ? L.timestamp : performance.now()), $t),
195
- set: (t) => {
196
- $t = t, queueMicrotask(Ir);
197
- }
198
- }, ti = (t) => (e) => typeof e == "string" && e.startsWith(t), Xe = /* @__PURE__ */ ti("--"), Or = /* @__PURE__ */ ti("var(--"), qe = (t) => Or(t) ? jr.test(t.split("/*")[0].trim()) : !1, jr = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, xt = {
199
- test: (t) => typeof t == "number",
200
- parse: parseFloat,
201
- transform: (t) => t
202
- }, Et = {
203
- ...xt,
204
- transform: (t) => z(0, 1, t)
205
- }, Ut = {
206
- ...xt,
207
- default: 1
208
- }, At = (t) => Math.round(t * 1e5) / 1e5, Ze = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
209
- function Nr(t) {
210
- return t == null;
211
- }
212
- const Ur = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, Je = (t, e) => (n) => !!(typeof n == "string" && Ur.test(n) && n.startsWith(t) || e && !Nr(n) && Object.prototype.hasOwnProperty.call(n, e)), ei = (t, e, n) => (s) => {
213
- if (typeof s != "string")
214
- return s;
215
- const [i, o, r, a] = s.match(Ze);
216
- return {
217
- [t]: parseFloat(i),
218
- [e]: parseFloat(o),
219
- [n]: parseFloat(r),
220
- alpha: a !== void 0 ? parseFloat(a) : 1
221
- };
222
- }, Kr = (t) => z(0, 255, t), se = {
223
- ...xt,
224
- transform: (t) => Math.round(Kr(t))
225
- }, st = {
226
- test: /* @__PURE__ */ Je("rgb", "red"),
227
- parse: /* @__PURE__ */ ei("red", "green", "blue"),
228
- transform: ({ red: t, green: e, blue: n, alpha: s = 1 }) => "rgba(" + se.transform(t) + ", " + se.transform(e) + ", " + se.transform(n) + ", " + At(Et.transform(s)) + ")"
229
- };
230
- function Wr(t) {
231
- let e = "", n = "", s = "", i = "";
232
- 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), {
233
- red: parseInt(e, 16),
234
- green: parseInt(n, 16),
235
- blue: parseInt(s, 16),
236
- alpha: i ? parseInt(i, 16) / 255 : 1
237
- };
238
- }
239
- const ve = {
240
- test: /* @__PURE__ */ Je("#"),
241
- parse: Wr,
242
- transform: st.transform
243
- }, Ot = /* @__NO_SIDE_EFFECTS__ */ (t) => ({
244
- test: (e) => typeof e == "string" && e.endsWith(t) && e.split(" ").length === 1,
245
- parse: parseFloat,
246
- transform: (e) => `${e}${t}`
247
- }), q = /* @__PURE__ */ Ot("deg"), H = /* @__PURE__ */ Ot("%"), x = /* @__PURE__ */ Ot("px"), $r = /* @__PURE__ */ Ot("vh"), Gr = /* @__PURE__ */ Ot("vw"), An = {
248
- ...H,
249
- parse: (t) => H.parse(t) / 100,
250
- transform: (t) => H.transform(t * 100)
251
- }, ut = {
252
- test: /* @__PURE__ */ Je("hsl", "hue"),
253
- parse: /* @__PURE__ */ ei("hue", "saturation", "lightness"),
254
- transform: ({ hue: t, saturation: e, lightness: n, alpha: s = 1 }) => "hsla(" + Math.round(t) + ", " + H.transform(At(e)) + ", " + H.transform(At(n)) + ", " + At(Et.transform(s)) + ")"
255
- }, C = {
256
- test: (t) => st.test(t) || ve.test(t) || ut.test(t),
257
- parse: (t) => st.test(t) ? st.parse(t) : ut.test(t) ? ut.parse(t) : ve.parse(t),
258
- transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? st.transform(t) : ut.transform(t),
259
- getAnimatableNone: (t) => {
260
- const e = C.parse(t);
261
- return e.alpha = 0, C.transform(e);
262
- }
263
- }, _r = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
264
- function Hr(t) {
265
- return isNaN(t) && typeof t == "string" && (t.match(Ze)?.length || 0) + (t.match(_r)?.length || 0) > 0;
266
- }
267
- const ni = "number", si = "color", zr = "var", Yr = "var(", Vn = "${}", Xr = /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;
268
- function Rt(t) {
269
- const e = t.toString(), n = [], s = {
270
- color: [],
271
- number: [],
272
- var: []
273
- }, i = [];
274
- let o = 0;
275
- const a = e.replace(Xr, (l) => (C.test(l) ? (s.color.push(o), i.push(si), n.push(C.parse(l))) : l.startsWith(Yr) ? (s.var.push(o), i.push(zr), n.push(l)) : (s.number.push(o), i.push(ni), n.push(parseFloat(l))), ++o, Vn)).split(Vn);
276
- return { values: n, split: a, indexes: s, types: i };
277
- }
278
- function ii(t) {
279
- return Rt(t).values;
280
- }
281
- function ri(t) {
282
- const { split: e, types: n } = Rt(t), s = e.length;
283
- return (i) => {
284
- let o = "";
285
- for (let r = 0; r < s; r++)
286
- if (o += e[r], i[r] !== void 0) {
287
- const a = n[r];
288
- a === ni ? o += At(i[r]) : a === si ? o += C.transform(i[r]) : o += i[r];
289
- }
290
- return o;
291
- };
292
- }
293
- const qr = (t) => typeof t == "number" ? 0 : C.test(t) ? C.getAnimatableNone(t) : t;
294
- function Zr(t) {
295
- const e = ii(t);
296
- return ri(t)(e.map(qr));
297
- }
298
- const J = {
299
- test: Hr,
300
- parse: ii,
301
- createTransformer: ri,
302
- getAnimatableNone: Zr
303
- };
304
- function ie(t, e, n) {
305
- 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;
306
- }
307
- function Jr({ hue: t, saturation: e, lightness: n, alpha: s }) {
308
- t /= 360, e /= 100, n /= 100;
309
- let i = 0, o = 0, r = 0;
310
- if (!e)
311
- i = o = r = n;
312
- else {
313
- const a = n < 0.5 ? n * (1 + e) : n + e - n * e, l = 2 * n - a;
314
- i = ie(l, a, t + 1 / 3), o = ie(l, a, t), r = ie(l, a, t - 1 / 3);
315
- }
316
- return {
317
- red: Math.round(i * 255),
318
- green: Math.round(o * 255),
319
- blue: Math.round(r * 255),
320
- alpha: s
321
- };
322
- }
323
- function zt(t, e) {
324
- return (n) => n > 0 ? e : t;
325
- }
326
- const D = (t, e, n) => t + (e - t) * n, re = (t, e, n) => {
327
- const s = t * t, i = n * (e * e - s) + s;
328
- return i < 0 ? 0 : Math.sqrt(i);
329
- }, Qr = [ve, st, ut], to = (t) => Qr.find((e) => e.test(t));
330
- function Dn(t) {
331
- const e = to(t);
332
- if (Tt(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`, "color-not-animatable"), !e)
333
- return !1;
334
- let n = e.parse(t);
335
- return e === ut && (n = Jr(n)), n;
336
- }
337
- const Mn = (t, e) => {
338
- const n = Dn(t), s = Dn(e);
339
- if (!n || !s)
340
- return zt(t, e);
341
- const i = { ...n };
342
- return (o) => (i.red = re(n.red, s.red, o), i.green = re(n.green, s.green, o), i.blue = re(n.blue, s.blue, o), i.alpha = D(n.alpha, s.alpha, o), st.transform(i));
343
- }, Te = /* @__PURE__ */ new Set(["none", "hidden"]);
344
- function eo(t, e) {
345
- return Te.has(t) ? (n) => n <= 0 ? t : e : (n) => n >= 1 ? e : t;
346
- }
347
- function no(t, e) {
348
- return (n) => D(t, e, n);
349
- }
350
- function Qe(t) {
351
- return typeof t == "number" ? no : typeof t == "string" ? qe(t) ? zt : C.test(t) ? Mn : ro : Array.isArray(t) ? oi : typeof t == "object" ? C.test(t) ? Mn : so : zt;
352
- }
353
- function oi(t, e) {
354
- const n = [...t], s = n.length, i = t.map((o, r) => Qe(o)(o, e[r]));
355
- return (o) => {
356
- for (let r = 0; r < s; r++)
357
- n[r] = i[r](o);
358
- return n;
359
- };
360
- }
361
- function so(t, e) {
362
- const n = { ...t, ...e }, s = {};
363
- for (const i in n)
364
- t[i] !== void 0 && e[i] !== void 0 && (s[i] = Qe(t[i])(t[i], e[i]));
365
- return (i) => {
366
- for (const o in s)
367
- n[o] = s[o](i);
368
- return n;
369
- };
370
- }
371
- function io(t, e) {
372
- const n = [], s = { color: 0, var: 0, number: 0 };
373
- for (let i = 0; i < e.values.length; i++) {
374
- const o = e.types[i], r = t.indexes[o][s[o]], a = t.values[r] ?? 0;
375
- n[i] = a, s[o]++;
376
- }
377
- return n;
378
- }
379
- const ro = (t, e) => {
380
- const n = J.createTransformer(e), s = Rt(t), i = Rt(e);
381
- 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 ? Te.has(t) && !i.values.length || Te.has(e) && !s.values.length ? eo(t, e) : Bt(oi(io(s, i), i.values), n) : (Tt(!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"), zt(t, e));
382
- };
383
- function ai(t, e, n) {
384
- return typeof t == "number" && typeof e == "number" && typeof n == "number" ? D(t, e, n) : Qe(t)(t, e);
385
- }
386
- const oo = (t) => {
387
- const e = ({ timestamp: n }) => t(n);
388
- return {
389
- start: (n = !0) => A.update(e, n),
390
- stop: () => Z(e),
391
- /**
392
- * If we're processing this frame we can use the
393
- * framelocked timestamp to keep things in sync.
394
- */
395
- now: () => L.isProcessing ? L.timestamp : O.now()
396
- };
397
- }, li = (t, e, n = 10) => {
398
- let s = "";
399
- const i = Math.max(Math.round(e / n), 2);
400
- for (let o = 0; o < i; o++)
401
- s += Math.round(t(o / (i - 1)) * 1e4) / 1e4 + ", ";
402
- return `linear(${s.substring(0, s.length - 2)})`;
403
- }, Yt = 2e4;
404
- function tn(t) {
405
- let e = 0;
406
- const n = 50;
407
- let s = t.next(e);
408
- for (; !s.done && e < Yt; )
409
- e += n, s = t.next(e);
410
- return e >= Yt ? 1 / 0 : e;
411
- }
412
- function ao(t, e = 100, n) {
413
- const s = n({ ...t, keyframes: [0, e] }), i = Math.min(tn(s), Yt);
414
- return {
415
- type: "keyframes",
416
- ease: (o) => s.next(i * o).value / e,
417
- duration: /* @__PURE__ */ W(i)
418
- };
419
- }
420
- const lo = 5;
421
- function ui(t, e, n) {
422
- const s = Math.max(e - lo, 0);
423
- return Ws(n - t(s), e - s);
424
- }
425
- const V = {
426
- // Default spring physics
427
- stiffness: 100,
428
- damping: 10,
429
- mass: 1,
430
- velocity: 0,
431
- // Default duration/bounce-based options
432
- duration: 800,
433
- // in ms
434
- bounce: 0.3,
435
- visualDuration: 0.3,
436
- // in seconds
437
- // Rest thresholds
438
- restSpeed: {
439
- granular: 0.01,
440
- default: 2
441
- },
442
- restDelta: {
443
- granular: 5e-3,
444
- default: 0.5
445
- },
446
- // Limits
447
- minDuration: 0.01,
448
- // in seconds
449
- maxDuration: 10,
450
- // in seconds
451
- minDamping: 0.05,
452
- maxDamping: 1
453
- }, oe = 1e-3;
454
- function uo({ duration: t = V.duration, bounce: e = V.bounce, velocity: n = V.velocity, mass: s = V.mass }) {
455
- let i, o;
456
- Tt(t <= /* @__PURE__ */ _(V.maxDuration), "Spring duration must be 10 seconds or less", "spring-duration-limit");
457
- let r = 1 - e;
458
- r = z(V.minDamping, V.maxDamping, r), t = z(V.minDuration, V.maxDuration, /* @__PURE__ */ W(t)), r < 1 ? (i = (c) => {
459
- const u = c * r, h = u * t, f = u - n, d = xe(c, r), m = Math.exp(-h);
460
- return oe - f / d * m;
461
- }, o = (c) => {
462
- const h = c * r * t, f = h * n + n, d = Math.pow(r, 2) * Math.pow(c, 2) * t, m = Math.exp(-h), v = xe(Math.pow(c, 2), r);
463
- return (-i(c) + oe > 0 ? -1 : 1) * ((f - d) * m) / v;
464
- }) : (i = (c) => {
465
- const u = Math.exp(-c * t), h = (c - n) * t + 1;
466
- return -oe + u * h;
467
- }, o = (c) => {
468
- const u = Math.exp(-c * t), h = (n - c) * (t * t);
469
- return u * h;
470
- });
471
- const a = 5 / t, l = ho(i, o, a);
472
- if (t = /* @__PURE__ */ _(t), isNaN(l))
473
- return {
474
- stiffness: V.stiffness,
475
- damping: V.damping,
476
- duration: t
477
- };
478
- {
479
- const c = Math.pow(l, 2) * s;
480
- return {
481
- stiffness: c,
482
- damping: r * 2 * Math.sqrt(s * c),
483
- duration: t
484
- };
485
- }
486
- }
487
- const co = 12;
488
- function ho(t, e, n) {
489
- let s = n;
490
- for (let i = 1; i < co; i++)
491
- s = s - t(s) / e(s);
492
- return s;
493
- }
494
- function xe(t, e) {
495
- return t * Math.sqrt(1 - e * e);
496
- }
497
- const fo = ["duration", "bounce"], mo = ["stiffness", "damping", "mass"];
498
- function Cn(t, e) {
499
- return e.some((n) => t[n] !== void 0);
500
- }
501
- function po(t) {
502
- let e = {
503
- velocity: V.velocity,
504
- stiffness: V.stiffness,
505
- damping: V.damping,
506
- mass: V.mass,
507
- isResolvedFromDuration: !1,
508
- ...t
509
- };
510
- if (!Cn(t, mo) && Cn(t, fo))
511
- if (t.visualDuration) {
512
- const n = t.visualDuration, s = 2 * Math.PI / (n * 1.2), i = s * s, o = 2 * z(0.05, 1, 1 - (t.bounce || 0)) * Math.sqrt(i);
513
- e = {
514
- ...e,
515
- mass: V.mass,
516
- stiffness: i,
517
- damping: o
518
- };
519
- } else {
520
- const n = uo(t);
521
- e = {
522
- ...e,
523
- ...n,
524
- mass: V.mass
525
- }, e.isResolvedFromDuration = !0;
526
- }
527
- return e;
528
- }
529
- function Xt(t = V.visualDuration, e = V.bounce) {
530
- const n = typeof t != "object" ? {
531
- visualDuration: t,
532
- keyframes: [0, 1],
533
- bounce: e
534
- } : t;
535
- let { restSpeed: s, restDelta: i } = n;
536
- const o = n.keyframes[0], r = n.keyframes[n.keyframes.length - 1], a = { done: !1, value: o }, { stiffness: l, damping: c, mass: u, duration: h, velocity: f, isResolvedFromDuration: d } = po({
537
- ...n,
538
- velocity: -/* @__PURE__ */ W(n.velocity || 0)
539
- }), m = f || 0, v = c / (2 * Math.sqrt(l * u)), y = r - o, p = /* @__PURE__ */ W(Math.sqrt(l / u)), T = Math.abs(y) < 5;
540
- s || (s = T ? V.restSpeed.granular : V.restSpeed.default), i || (i = T ? V.restDelta.granular : V.restDelta.default);
541
- let g;
542
- if (v < 1) {
543
- const P = xe(p, v);
544
- g = (w) => {
545
- const E = Math.exp(-v * p * w);
546
- return r - E * ((m + v * p * y) / P * Math.sin(P * w) + y * Math.cos(P * w));
547
- };
548
- } else if (v === 1)
549
- g = (P) => r - Math.exp(-p * P) * (y + (m + p * y) * P);
550
- else {
551
- const P = p * Math.sqrt(v * v - 1);
552
- g = (w) => {
553
- const E = Math.exp(-v * p * w), b = Math.min(P * w, 300);
554
- return r - E * ((m + v * p * y) * Math.sinh(b) + P * y * Math.cosh(b)) / P;
555
- };
556
- }
557
- const S = {
558
- calculatedDuration: d && h || null,
559
- next: (P) => {
560
- const w = g(P);
561
- if (d)
562
- a.done = P >= h;
563
- else {
564
- let E = P === 0 ? m : 0;
565
- v < 1 && (E = P === 0 ? /* @__PURE__ */ _(m) : ui(g, P, w));
566
- const b = Math.abs(E) <= s, B = Math.abs(r - w) <= i;
567
- a.done = b && B;
568
- }
569
- return a.value = a.done ? r : w, a;
570
- },
571
- toString: () => {
572
- const P = Math.min(tn(S), Yt), w = li((E) => S.next(P * E).value, P, 30);
573
- return P + "ms " + w;
574
- },
575
- toTransition: () => {
576
- }
577
- };
578
- return S;
579
- }
580
- Xt.applyToOptions = (t) => {
581
- const e = ao(t, 100, Xt);
582
- return t.ease = e.ease, t.duration = /* @__PURE__ */ _(e.duration), t.type = "keyframes", t;
583
- };
584
- function Pe({ keyframes: t, velocity: e = 0, power: n = 0.8, timeConstant: s = 325, bounceDamping: i = 10, bounceStiffness: o = 500, modifyTarget: r, min: a, max: l, restDelta: c = 0.5, restSpeed: u }) {
585
- const h = t[0], f = {
586
- done: !1,
587
- value: h
588
- }, d = (b) => a !== void 0 && b < a || l !== void 0 && b > l, m = (b) => a === void 0 ? l : l === void 0 || Math.abs(a - b) < Math.abs(l - b) ? a : l;
589
- let v = n * e;
590
- const y = h + v, p = r === void 0 ? y : r(y);
591
- p !== y && (v = p - h);
592
- const T = (b) => -v * Math.exp(-b / s), g = (b) => p + T(b), S = (b) => {
593
- const B = T(b), j = g(b);
594
- f.done = Math.abs(B) <= c, f.value = f.done ? p : j;
595
- };
596
- let P, w;
597
- const E = (b) => {
598
- d(f.value) && (P = b, w = Xt({
599
- keyframes: [f.value, m(f.value)],
600
- velocity: ui(g, b, f.value),
601
- // TODO: This should be passing * 1000
602
- damping: i,
603
- stiffness: o,
604
- restDelta: c,
605
- restSpeed: u
606
- }));
607
- };
608
- return E(0), {
609
- calculatedDuration: null,
610
- next: (b) => {
611
- let B = !1;
612
- return !w && P === void 0 && (B = !0, S(b), E(b)), P !== void 0 && b >= P ? w.next(b - P) : (!B && S(b), f);
613
- }
614
- };
615
- }
616
- function go(t, e, n) {
617
- const s = [], i = n || X.mix || ai, o = t.length - 1;
618
- for (let r = 0; r < o; r++) {
619
- let a = i(t[r], t[r + 1]);
620
- if (e) {
621
- const l = Array.isArray(e) ? e[r] || $ : e;
622
- a = Bt(l, a);
623
- }
624
- s.push(a);
625
- }
626
- return s;
627
- }
628
- function yo(t, e, { clamp: n = !0, ease: s, mixer: i } = {}) {
629
- const o = t.length;
630
- if (Y(o === e.length, "Both input and output ranges must be the same length", "range-length"), o === 1)
631
- return () => e[0];
632
- if (o === 2 && e[0] === e[1])
633
- return () => e[1];
634
- const r = t[0] === t[1];
635
- t[0] > t[o - 1] && (t = [...t].reverse(), e = [...e].reverse());
636
- const a = go(e, s, i), l = a.length, c = (u) => {
637
- if (r && u < t[0])
638
- return e[0];
639
- let h = 0;
640
- if (l > 1)
641
- for (; h < t.length - 2 && !(u < t[h + 1]); h++)
642
- ;
643
- const f = /* @__PURE__ */ Ct(t[h], t[h + 1], u);
644
- return a[h](f);
645
- };
646
- return n ? (u) => c(z(t[0], t[o - 1], u)) : c;
647
- }
648
- function vo(t, e) {
649
- const n = t[t.length - 1];
650
- for (let s = 1; s <= e; s++) {
651
- const i = /* @__PURE__ */ Ct(0, e, s);
652
- t.push(D(n, 1, i));
653
- }
654
- }
655
- function To(t) {
656
- const e = [0];
657
- return vo(e, t.length - 1), e;
658
- }
659
- function xo(t, e) {
660
- return t.map((n) => n * e);
661
- }
662
- function Po(t, e) {
663
- return t.map(() => e || Zs).splice(0, t.length - 1);
664
- }
665
- function ct({ duration: t = 300, keyframes: e, times: n, ease: s = "easeInOut" }) {
666
- const i = Lr(s) ? s.map(wn) : wn(s), o = {
667
- done: !1,
668
- value: e[0]
669
- }, r = xo(
670
- // Only use the provided offsets if they're the correct length
671
- // TODO Maybe we should warn here if there's a length mismatch
672
- n && n.length === e.length ? n : To(e),
673
- t
674
- ), a = yo(r, e, {
675
- ease: Array.isArray(i) ? i : Po(e, i)
676
- });
677
- return {
678
- calculatedDuration: t,
679
- next: (l) => (o.value = a(l), o.done = l >= t, o)
680
- };
681
- }
682
- const bo = (t) => t !== null;
683
- function en(t, { repeat: e, repeatType: n = "loop" }, s, i = 1) {
684
- const o = t.filter(bo), a = i < 0 || e && n !== "loop" && e % 2 === 1 ? 0 : o.length - 1;
685
- return !a || s === void 0 ? o[a] : s;
686
- }
687
- const So = {
688
- decay: Pe,
689
- inertia: Pe,
690
- tween: ct,
691
- keyframes: ct,
692
- spring: Xt
693
- };
694
- function ci(t) {
695
- typeof t.type == "string" && (t.type = So[t.type]);
696
- }
697
- class nn {
698
- constructor() {
699
- this.updateFinished();
700
- }
701
- get finished() {
702
- return this._finished;
703
- }
704
- updateFinished() {
705
- this._finished = new Promise((e) => {
706
- this.resolve = e;
707
- });
708
- }
709
- notifyFinished() {
710
- this.resolve();
711
- }
712
- /**
713
- * Allows the animation to be awaited.
714
- *
715
- * @deprecated Use `finished` instead.
716
- */
717
- then(e, n) {
718
- return this.finished.then(e, n);
719
- }
720
- }
721
- const wo = (t) => t / 100;
722
- class sn extends nn {
723
- constructor(e) {
724
- super(), this.state = "idle", this.startTime = null, this.isStopped = !1, this.currentTime = 0, this.holdTime = null, this.playbackSpeed = 1, this.stop = () => {
725
- const { motionValue: n } = this.options;
726
- n && n.updatedAt !== O.now() && this.tick(O.now()), this.isStopped = !0, this.state !== "idle" && (this.teardown(), this.options.onStop?.());
727
- }, this.options = e, this.initAnimation(), this.play(), e.autoplay === !1 && this.pause();
728
- }
729
- initAnimation() {
730
- const { options: e } = this;
731
- ci(e);
732
- const { type: n = ct, repeat: s = 0, repeatDelay: i = 0, repeatType: o, velocity: r = 0 } = e;
733
- let { keyframes: a } = e;
734
- const l = n || ct;
735
- process.env.NODE_ENV !== "production" && l !== ct && Y(a.length <= 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`, "spring-two-frames"), l !== ct && typeof a[0] != "number" && (this.mixKeyframes = Bt(wo, ai(a[0], a[1])), a = [0, 100]);
736
- const c = l({ ...e, keyframes: a });
737
- o === "mirror" && (this.mirroredGenerator = l({
738
- ...e,
739
- keyframes: [...a].reverse(),
740
- velocity: -r
741
- })), c.calculatedDuration === null && (c.calculatedDuration = tn(c));
742
- const { calculatedDuration: u } = c;
743
- this.calculatedDuration = u, this.resolvedDuration = u + i, this.totalDuration = this.resolvedDuration * (s + 1) - i, this.generator = c;
744
- }
745
- updateTime(e) {
746
- const n = Math.round(e - this.startTime) * this.playbackSpeed;
747
- this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = n;
748
- }
749
- tick(e, n = !1) {
750
- const { generator: s, totalDuration: i, mixKeyframes: o, mirroredGenerator: r, resolvedDuration: a, calculatedDuration: l } = this;
751
- if (this.startTime === null)
752
- return s.next(0);
753
- const { delay: c = 0, keyframes: u, repeat: h, repeatType: f, repeatDelay: d, type: m, onUpdate: v, finalKeyframe: y } = this.options;
754
- 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);
755
- const p = this.currentTime - c * (this.playbackSpeed >= 0 ? 1 : -1), T = this.playbackSpeed >= 0 ? p < 0 : p > i;
756
- this.currentTime = Math.max(p, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = i);
757
- let g = this.currentTime, S = s;
758
- if (h) {
759
- const b = Math.min(this.currentTime, i) / a;
760
- let B = Math.floor(b), j = b % 1;
761
- !j && b >= 1 && (j = 1), j === 1 && B--, B = Math.min(B, h + 1), !!(B % 2) && (f === "reverse" ? (j = 1 - j, d && (j -= d / a)) : f === "mirror" && (S = r)), g = z(0, 1, j) * a;
762
- }
763
- const P = T ? { done: !1, value: u[0] } : S.next(g);
764
- o && (P.value = o(P.value));
765
- let { done: w } = P;
766
- !T && l !== null && (w = this.playbackSpeed >= 0 ? this.currentTime >= i : this.currentTime <= 0);
767
- const E = this.holdTime === null && (this.state === "finished" || this.state === "running" && w);
768
- return E && m !== Pe && (P.value = en(u, this.options, y, this.speed)), v && v(P.value), E && this.finish(), P;
769
- }
770
- /**
771
- * Allows the returned animation to be awaited or promise-chained. Currently
772
- * resolves when the animation finishes at all but in a future update could/should
773
- * reject if its cancels.
774
- */
775
- then(e, n) {
776
- return this.finished.then(e, n);
777
- }
778
- get duration() {
779
- return /* @__PURE__ */ W(this.calculatedDuration);
780
- }
781
- get iterationDuration() {
782
- const { delay: e = 0 } = this.options || {};
783
- return this.duration + /* @__PURE__ */ W(e);
784
- }
785
- get time() {
786
- return /* @__PURE__ */ W(this.currentTime);
787
- }
788
- set time(e) {
789
- e = /* @__PURE__ */ _(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);
790
- }
791
- get speed() {
792
- return this.playbackSpeed;
793
- }
794
- set speed(e) {
795
- this.updateTime(O.now());
796
- const n = this.playbackSpeed !== e;
797
- this.playbackSpeed = e, n && (this.time = /* @__PURE__ */ W(this.currentTime));
798
- }
799
- play() {
800
- if (this.isStopped)
801
- return;
802
- const { driver: e = oo, startTime: n } = this.options;
803
- this.driver || (this.driver = e((i) => this.tick(i))), this.options.onPlay?.();
804
- const s = this.driver.now();
805
- 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();
806
- }
807
- pause() {
808
- this.state = "paused", this.updateTime(O.now()), this.holdTime = this.currentTime;
809
- }
810
- complete() {
811
- this.state !== "running" && this.play(), this.state = "finished", this.holdTime = null;
812
- }
813
- finish() {
814
- this.notifyFinished(), this.teardown(), this.state = "finished", this.options.onComplete?.();
815
- }
816
- cancel() {
817
- this.holdTime = null, this.startTime = 0, this.tick(0), this.teardown(), this.options.onCancel?.();
818
- }
819
- teardown() {
820
- this.state = "idle", this.stopDriver(), this.startTime = this.holdTime = null;
821
- }
822
- stopDriver() {
823
- this.driver && (this.driver.stop(), this.driver = void 0);
824
- }
825
- sample(e) {
826
- return this.startTime = 0, this.tick(e, !0);
827
- }
828
- attachTimeline(e) {
829
- return this.options.allowFlatten && (this.options.type = "keyframes", this.options.ease = "linear", this.initAnimation()), this.driver?.stop(), e.observe(this);
830
- }
831
- }
832
- function Ao(t) {
833
- for (let e = 1; e < t.length; e++)
834
- t[e] ?? (t[e] = t[e - 1]);
835
- }
836
- const it = (t) => t * 180 / Math.PI, be = (t) => {
837
- const e = it(Math.atan2(t[1], t[0]));
838
- return Se(e);
839
- }, Vo = {
840
- x: 4,
841
- y: 5,
842
- translateX: 4,
843
- translateY: 5,
844
- scaleX: 0,
845
- scaleY: 3,
846
- scale: (t) => (Math.abs(t[0]) + Math.abs(t[3])) / 2,
847
- rotate: be,
848
- rotateZ: be,
849
- skewX: (t) => it(Math.atan(t[1])),
850
- skewY: (t) => it(Math.atan(t[2])),
851
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[2])) / 2
852
- }, Se = (t) => (t = t % 360, t < 0 && (t += 360), t), En = be, Rn = (t) => Math.sqrt(t[0] * t[0] + t[1] * t[1]), Ln = (t) => Math.sqrt(t[4] * t[4] + t[5] * t[5]), Do = {
853
- x: 12,
854
- y: 13,
855
- z: 14,
856
- translateX: 12,
857
- translateY: 13,
858
- translateZ: 14,
859
- scaleX: Rn,
860
- scaleY: Ln,
861
- scale: (t) => (Rn(t) + Ln(t)) / 2,
862
- rotateX: (t) => Se(it(Math.atan2(t[6], t[5]))),
863
- rotateY: (t) => Se(it(Math.atan2(-t[2], t[0]))),
864
- rotateZ: En,
865
- rotate: En,
866
- skewX: (t) => it(Math.atan(t[4])),
867
- skewY: (t) => it(Math.atan(t[1])),
868
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[4])) / 2
869
- };
870
- function we(t) {
871
- return t.includes("scale") ? 1 : 0;
872
- }
873
- function Ae(t, e) {
874
- if (!t || t === "none")
875
- return we(e);
876
- const n = t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
877
- let s, i;
878
- if (n)
879
- s = Do, i = n;
880
- else {
881
- const a = t.match(/^matrix\(([-\d.e\s,]+)\)$/u);
882
- s = Vo, i = a;
883
- }
884
- if (!i)
885
- return we(e);
886
- const o = s[e], r = i[1].split(",").map(Co);
887
- return typeof o == "function" ? o(r) : r[o];
888
- }
889
- const Mo = (t, e) => {
890
- const { transform: n = "none" } = getComputedStyle(t);
891
- return Ae(n, e);
892
- };
893
- function Co(t) {
894
- return parseFloat(t.trim());
895
- }
896
- const Pt = [
897
- "transformPerspective",
898
- "x",
899
- "y",
900
- "z",
901
- "translateX",
902
- "translateY",
903
- "translateZ",
904
- "scale",
905
- "scaleX",
906
- "scaleY",
907
- "rotate",
908
- "rotateX",
909
- "rotateY",
910
- "rotateZ",
911
- "skew",
912
- "skewX",
913
- "skewY"
914
- ], bt = new Set(Pt), kn = (t) => t === xt || t === x, Eo = /* @__PURE__ */ new Set(["x", "y", "z"]), Ro = Pt.filter((t) => !Eo.has(t));
915
- function Lo(t) {
916
- const e = [];
917
- return Ro.forEach((n) => {
918
- const s = t.getValue(n);
919
- s !== void 0 && (e.push([n, s.get()]), s.set(n.startsWith("scale") ? 1 : 0));
920
- }), e;
921
- }
922
- const rt = {
923
- // Dimensions
924
- width: ({ x: t }, { paddingLeft: e = "0", paddingRight: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
925
- height: ({ y: t }, { paddingTop: e = "0", paddingBottom: n = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(n),
926
- top: (t, { top: e }) => parseFloat(e),
927
- left: (t, { left: e }) => parseFloat(e),
928
- bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min),
929
- right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min),
930
- // Transform
931
- x: (t, { transform: e }) => Ae(e, "x"),
932
- y: (t, { transform: e }) => Ae(e, "y")
933
- };
934
- rt.translateX = rt.x;
935
- rt.translateY = rt.y;
936
- const ot = /* @__PURE__ */ new Set();
937
- let Ve = !1, De = !1, Me = !1;
938
- function hi() {
939
- if (De) {
940
- const t = Array.from(ot).filter((s) => s.needsMeasurement), e = new Set(t.map((s) => s.element)), n = /* @__PURE__ */ new Map();
941
- e.forEach((s) => {
942
- const i = Lo(s);
943
- i.length && (n.set(s, i), s.render());
944
- }), t.forEach((s) => s.measureInitialState()), e.forEach((s) => {
945
- s.render();
946
- const i = n.get(s);
947
- i && i.forEach(([o, r]) => {
948
- s.getValue(o)?.set(r);
949
- });
950
- }), t.forEach((s) => s.measureEndState()), t.forEach((s) => {
951
- s.suspendedScrollY !== void 0 && window.scrollTo(0, s.suspendedScrollY);
952
- });
953
- }
954
- De = !1, Ve = !1, ot.forEach((t) => t.complete(Me)), ot.clear();
955
- }
956
- function fi() {
957
- ot.forEach((t) => {
958
- t.readKeyframes(), t.needsMeasurement && (De = !0);
959
- });
960
- }
961
- function ko() {
962
- Me = !0, fi(), hi(), Me = !1;
963
- }
964
- class rn {
965
- constructor(e, n, s, i, o, r = !1) {
966
- this.state = "pending", this.isAsync = !1, this.needsMeasurement = !1, this.unresolvedKeyframes = [...e], this.onComplete = n, this.name = s, this.motionValue = i, this.element = o, this.isAsync = r;
967
- }
968
- scheduleResolve() {
969
- this.state = "scheduled", this.isAsync ? (ot.add(this), Ve || (Ve = !0, A.read(fi), A.resolveKeyframes(hi))) : (this.readKeyframes(), this.complete());
970
- }
971
- readKeyframes() {
972
- const { unresolvedKeyframes: e, name: n, element: s, motionValue: i } = this;
973
- if (e[0] === null) {
974
- const o = i?.get(), r = e[e.length - 1];
975
- if (o !== void 0)
976
- e[0] = o;
977
- else if (s && n) {
978
- const a = s.readValue(n, r);
979
- a != null && (e[0] = a);
980
- }
981
- e[0] === void 0 && (e[0] = r), i && o === void 0 && i.set(e[0]);
982
- }
983
- Ao(e);
984
- }
985
- setFinalKeyframe() {
986
- }
987
- measureInitialState() {
988
- }
989
- renderEndStyles() {
990
- }
991
- measureEndState() {
992
- }
993
- complete(e = !1) {
994
- this.state = "complete", this.onComplete(this.unresolvedKeyframes, this.finalKeyframe, e), ot.delete(this);
995
- }
996
- cancel() {
997
- this.state === "scheduled" && (ot.delete(this), this.state = "pending");
998
- }
999
- resume() {
1000
- this.state === "pending" && this.scheduleResolve();
1001
- }
1002
- }
1003
- const Fo = (t) => t.startsWith("--");
1004
- function Bo(t, e, n) {
1005
- Fo(e) ? t.style.setProperty(e, n) : t.style[e] = n;
1006
- }
1007
- const Io = /* @__PURE__ */ Ge(() => window.ScrollTimeline !== void 0), Oo = {};
1008
- function jo(t, e) {
1009
- const n = /* @__PURE__ */ Ge(t);
1010
- return () => Oo[e] ?? n();
1011
- }
1012
- const di = /* @__PURE__ */ jo(() => {
1013
- try {
1014
- document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" });
1015
- } catch {
1016
- return !1;
1017
- }
1018
- return !0;
1019
- }, "linearEasing"), wt = ([t, e, n, s]) => `cubic-bezier(${t}, ${e}, ${n}, ${s})`, Fn = {
1020
- linear: "linear",
1021
- ease: "ease",
1022
- easeIn: "ease-in",
1023
- easeOut: "ease-out",
1024
- easeInOut: "ease-in-out",
1025
- circIn: /* @__PURE__ */ wt([0, 0.65, 0.55, 1]),
1026
- circOut: /* @__PURE__ */ wt([0.55, 0, 1, 0.45]),
1027
- backIn: /* @__PURE__ */ wt([0.31, 0.01, 0.66, -0.59]),
1028
- backOut: /* @__PURE__ */ wt([0.33, 1.53, 0.69, 0.99])
1029
- };
1030
- function mi(t, e) {
1031
- if (t)
1032
- return typeof t == "function" ? di() ? li(t, e) : "ease-out" : Js(t) ? wt(t) : Array.isArray(t) ? t.map((n) => mi(n, e) || Fn.easeOut) : Fn[t];
1033
- }
1034
- function No(t, e, n, { delay: s = 0, duration: i = 300, repeat: o = 0, repeatType: r = "loop", ease: a = "easeOut", times: l } = {}, c = void 0) {
1035
- const u = {
1036
- [e]: n
1037
- };
1038
- l && (u.offset = l);
1039
- const h = mi(a, i);
1040
- Array.isArray(h) && (u.easing = h);
1041
- const f = {
1042
- delay: s,
1043
- duration: i,
1044
- easing: Array.isArray(h) ? "linear" : h,
1045
- fill: "both",
1046
- iterations: o + 1,
1047
- direction: r === "reverse" ? "alternate" : "normal"
1048
- };
1049
- return c && (f.pseudoElement = c), t.animate(u, f);
1050
- }
1051
- function pi(t) {
1052
- return typeof t == "function" && "applyToOptions" in t;
1053
- }
1054
- function Uo({ type: t, ...e }) {
1055
- return pi(t) && di() ? t.applyToOptions(e) : (e.duration ?? (e.duration = 300), e.ease ?? (e.ease = "easeOut"), e);
1056
- }
1057
- class Ko extends nn {
1058
- constructor(e) {
1059
- if (super(), this.finishedTime = null, this.isStopped = !1, !e)
1060
- return;
1061
- const { element: n, name: s, keyframes: i, pseudoElement: o, allowFlatten: r = !1, finalKeyframe: a, onComplete: l } = e;
1062
- this.isPseudoElement = !!o, this.allowFlatten = r, this.options = e, Y(typeof e.type != "string", `Mini animate() doesn't support "type" as a string.`, "mini-spring");
1063
- const c = Uo(e);
1064
- this.animation = No(n, s, i, c, o), c.autoplay === !1 && this.animation.pause(), this.animation.onfinish = () => {
1065
- if (this.finishedTime = this.time, !o) {
1066
- const u = en(i, this.options, a, this.speed);
1067
- this.updateMotionValue ? this.updateMotionValue(u) : Bo(n, s, u), this.animation.cancel();
1068
- }
1069
- l?.(), this.notifyFinished();
1070
- };
1071
- }
1072
- play() {
1073
- this.isStopped || (this.animation.play(), this.state === "finished" && this.updateFinished());
1074
- }
1075
- pause() {
1076
- this.animation.pause();
1077
- }
1078
- complete() {
1079
- this.animation.finish?.();
1080
- }
1081
- cancel() {
1082
- try {
1083
- this.animation.cancel();
1084
- } catch {
1085
- }
1086
- }
1087
- stop() {
1088
- if (this.isStopped)
1089
- return;
1090
- this.isStopped = !0;
1091
- const { state: e } = this;
1092
- e === "idle" || e === "finished" || (this.updateMotionValue ? this.updateMotionValue() : this.commitStyles(), this.isPseudoElement || this.cancel());
1093
- }
1094
- /**
1095
- * WAAPI doesn't natively have any interruption capabilities.
1096
- *
1097
- * In this method, we commit styles back to the DOM before cancelling
1098
- * the animation.
1099
- *
1100
- * This is designed to be overridden by NativeAnimationExtended, which
1101
- * will create a renderless JS animation and sample it twice to calculate
1102
- * its current value, "previous" value, and therefore allow
1103
- * Motion to also correctly calculate velocity for any subsequent animation
1104
- * while deferring the commit until the next animation frame.
1105
- */
1106
- commitStyles() {
1107
- this.isPseudoElement || this.animation.commitStyles?.();
1108
- }
1109
- get duration() {
1110
- const e = this.animation.effect?.getComputedTiming?.().duration || 0;
1111
- return /* @__PURE__ */ W(Number(e));
1112
- }
1113
- get iterationDuration() {
1114
- const { delay: e = 0 } = this.options || {};
1115
- return this.duration + /* @__PURE__ */ W(e);
1116
- }
1117
- get time() {
1118
- return /* @__PURE__ */ W(Number(this.animation.currentTime) || 0);
1119
- }
1120
- set time(e) {
1121
- this.finishedTime = null, this.animation.currentTime = /* @__PURE__ */ _(e);
1122
- }
1123
- /**
1124
- * The playback speed of the animation.
1125
- * 1 = normal speed, 2 = double speed, 0.5 = half speed.
1126
- */
1127
- get speed() {
1128
- return this.animation.playbackRate;
1129
- }
1130
- set speed(e) {
1131
- e < 0 && (this.finishedTime = null), this.animation.playbackRate = e;
1132
- }
1133
- get state() {
1134
- return this.finishedTime !== null ? "finished" : this.animation.playState;
1135
- }
1136
- get startTime() {
1137
- return Number(this.animation.startTime);
1138
- }
1139
- set startTime(e) {
1140
- this.animation.startTime = e;
1141
- }
1142
- /**
1143
- * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
1144
- */
1145
- attachTimeline({ timeline: e, observe: n }) {
1146
- return this.allowFlatten && this.animation.effect?.updateTiming({ easing: "linear" }), this.animation.onfinish = null, e && Io() ? (this.animation.timeline = e, $) : n(this);
1147
- }
1148
- }
1149
- const gi = {
1150
- anticipate: Ys,
1151
- backInOut: zs,
1152
- circInOut: qs
1153
- };
1154
- function Wo(t) {
1155
- return t in gi;
1156
- }
1157
- function $o(t) {
1158
- typeof t.ease == "string" && Wo(t.ease) && (t.ease = gi[t.ease]);
1159
- }
1160
- const Bn = 10;
1161
- class Go extends Ko {
1162
- constructor(e) {
1163
- $o(e), ci(e), super(e), e.startTime && (this.startTime = e.startTime), this.options = e;
1164
- }
1165
- /**
1166
- * WAAPI doesn't natively have any interruption capabilities.
1167
- *
1168
- * Rather than read commited styles back out of the DOM, we can
1169
- * create a renderless JS animation and sample it twice to calculate
1170
- * its current value, "previous" value, and therefore allow
1171
- * Motion to calculate velocity for any subsequent animation.
1172
- */
1173
- updateMotionValue(e) {
1174
- const { motionValue: n, onUpdate: s, onComplete: i, element: o, ...r } = this.options;
1175
- if (!n)
1176
- return;
1177
- if (e !== void 0) {
1178
- n.set(e);
1179
- return;
1180
- }
1181
- const a = new sn({
1182
- ...r,
1183
- autoplay: !1
1184
- }), l = /* @__PURE__ */ _(this.finishedTime ?? this.time);
1185
- n.setWithVelocity(a.sample(l - Bn).value, a.sample(l).value, Bn), a.stop();
1186
- }
1187
- }
1188
- const In = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string
1189
- (J.test(t) || t === "0") && // And it contains numbers and/or colors
1190
- !t.startsWith("url("));
1191
- function _o(t) {
1192
- const e = t[0];
1193
- if (t.length === 1)
1194
- return !0;
1195
- for (let n = 0; n < t.length; n++)
1196
- if (t[n] !== e)
1197
- return !0;
1198
- }
1199
- function Ho(t, e, n, s) {
1200
- const i = t[0];
1201
- if (i === null)
1202
- return !1;
1203
- if (e === "display" || e === "visibility")
1204
- return !0;
1205
- const o = t[t.length - 1], r = In(i, e), a = In(o, e);
1206
- return Tt(r === a, `You are trying to animate ${e} from "${i}" to "${o}". "${r ? o : i}" is not an animatable value.`, "value-not-animatable"), !r || !a ? !1 : _o(t) || (n === "spring" || pi(n)) && s;
1207
- }
1208
- function Ce(t) {
1209
- t.duration = 0, t.type = "keyframes";
1210
- }
1211
- const zo = /* @__PURE__ */ new Set([
1212
- "opacity",
1213
- "clipPath",
1214
- "filter",
1215
- "transform"
1216
- // TODO: Could be re-enabled now we have support for linear() easing
1217
- // "background-color"
1218
- ]), Yo = /* @__PURE__ */ Ge(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
1219
- function Xo(t) {
1220
- const { motionValue: e, name: n, repeatDelay: s, repeatType: i, damping: o, type: r } = t;
1221
- if (!(e?.owner?.current instanceof HTMLElement))
1222
- return !1;
1223
- const { onUpdate: l, transformTemplate: c } = e.owner.getProps();
1224
- return Yo() && n && zo.has(n) && (n !== "transform" || !c) && /**
1225
- * If we're outputting values to onUpdate then we can't use WAAPI as there's
1226
- * no way to read the value from WAAPI every frame.
1227
- */
1228
- !l && !s && i !== "mirror" && o !== 0 && r !== "inertia";
1229
- }
1230
- const qo = 40;
1231
- class Zo extends nn {
1232
- constructor({ autoplay: e = !0, delay: n = 0, type: s = "keyframes", repeat: i = 0, repeatDelay: o = 0, repeatType: r = "loop", keyframes: a, name: l, motionValue: c, element: u, ...h }) {
1233
- super(), this.stop = () => {
1234
- this._animation && (this._animation.stop(), this.stopTimeline?.()), this.keyframeResolver?.cancel();
1235
- }, this.createdAt = O.now();
1236
- const f = {
1237
- autoplay: e,
1238
- delay: n,
1239
- type: s,
1240
- repeat: i,
1241
- repeatDelay: o,
1242
- repeatType: r,
1243
- name: l,
1244
- motionValue: c,
1245
- element: u,
1246
- ...h
1247
- }, d = u?.KeyframeResolver || rn;
1248
- this.keyframeResolver = new d(a, (m, v, y) => this.onKeyframesResolved(m, v, f, !y), l, c, u), this.keyframeResolver?.scheduleResolve();
1249
- }
1250
- onKeyframesResolved(e, n, s, i) {
1251
- this.keyframeResolver = void 0;
1252
- const { name: o, type: r, velocity: a, delay: l, isHandoff: c, onUpdate: u } = s;
1253
- this.resolvedAt = O.now(), Ho(e, o, r, a) || ((X.instantAnimations || !l) && u?.(en(e, s, n)), e[0] = e[e.length - 1], Ce(s), s.repeat = 0);
1254
- const f = {
1255
- startTime: i ? this.resolvedAt ? this.resolvedAt - this.createdAt > qo ? this.resolvedAt : this.createdAt : this.createdAt : void 0,
1256
- finalKeyframe: n,
1257
- ...s,
1258
- keyframes: e
1259
- }, d = !c && Xo(f) ? new Go({
1260
- ...f,
1261
- element: f.motionValue.owner.current
1262
- }) : new sn(f);
1263
- d.finished.then(() => this.notifyFinished()).catch($), this.pendingTimeline && (this.stopTimeline = d.attachTimeline(this.pendingTimeline), this.pendingTimeline = void 0), this._animation = d;
1264
- }
1265
- get finished() {
1266
- return this._animation ? this.animation.finished : this._finished;
1267
- }
1268
- then(e, n) {
1269
- return this.finished.finally(e).then(() => {
1270
- });
1271
- }
1272
- get animation() {
1273
- return this._animation || (this.keyframeResolver?.resume(), ko()), this._animation;
1274
- }
1275
- get duration() {
1276
- return this.animation.duration;
1277
- }
1278
- get iterationDuration() {
1279
- return this.animation.iterationDuration;
1280
- }
1281
- get time() {
1282
- return this.animation.time;
1283
- }
1284
- set time(e) {
1285
- this.animation.time = e;
1286
- }
1287
- get speed() {
1288
- return this.animation.speed;
1289
- }
1290
- get state() {
1291
- return this.animation.state;
1292
- }
1293
- set speed(e) {
1294
- this.animation.speed = e;
1295
- }
1296
- get startTime() {
1297
- return this.animation.startTime;
1298
- }
1299
- attachTimeline(e) {
1300
- return this._animation ? this.stopTimeline = this.animation.attachTimeline(e) : this.pendingTimeline = e, () => this.stop();
1301
- }
1302
- play() {
1303
- this.animation.play();
1304
- }
1305
- pause() {
1306
- this.animation.pause();
1307
- }
1308
- complete() {
1309
- this.animation.complete();
1310
- }
1311
- cancel() {
1312
- this._animation && this.animation.cancel(), this.keyframeResolver?.cancel();
1313
- }
1314
- }
1315
- const Jo = (
1316
- // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words
1317
- /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u
1318
- );
1319
- function Qo(t) {
1320
- const e = Jo.exec(t);
1321
- if (!e)
1322
- return [,];
1323
- const [, n, s, i] = e;
1324
- return [`--${n ?? s}`, i];
1325
- }
1326
- const ta = 4;
1327
- function yi(t, e, n = 1) {
1328
- Y(n <= ta, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`, "max-css-var-depth");
1329
- const [s, i] = Qo(t);
1330
- if (!s)
1331
- return;
1332
- const o = window.getComputedStyle(e).getPropertyValue(s);
1333
- if (o) {
1334
- const r = o.trim();
1335
- return Ns(r) ? parseFloat(r) : r;
1336
- }
1337
- return qe(i) ? yi(i, e, n + 1) : i;
1338
- }
1339
- function on(t, e) {
1340
- return t?.[e] ?? t?.default ?? t;
1341
- }
1342
- const vi = /* @__PURE__ */ new Set([
1343
- "width",
1344
- "height",
1345
- "top",
1346
- "left",
1347
- "right",
1348
- "bottom",
1349
- ...Pt
1350
- ]), ea = {
1351
- test: (t) => t === "auto",
1352
- parse: (t) => t
1353
- }, Ti = (t) => (e) => e.test(t), xi = [xt, x, H, q, Gr, $r, ea], On = (t) => xi.find(Ti(t));
1354
- function na(t) {
1355
- return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || Ks(t) : !0;
1356
- }
1357
- const sa = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]);
1358
- function ia(t) {
1359
- const [e, n] = t.slice(0, -1).split("(");
1360
- if (e === "drop-shadow")
1361
- return t;
1362
- const [s] = n.match(Ze) || [];
1363
- if (!s)
1364
- return t;
1365
- const i = n.replace(s, "");
1366
- let o = sa.has(e) ? 1 : 0;
1367
- return s !== n && (o *= 100), e + "(" + o + i + ")";
1368
- }
1369
- const ra = /\b([a-z-]*)\(.*?\)/gu, Ee = {
1370
- ...J,
1371
- getAnimatableNone: (t) => {
1372
- const e = t.match(ra);
1373
- return e ? e.map(ia).join(" ") : t;
1374
- }
1375
- }, jn = {
1376
- ...xt,
1377
- transform: Math.round
1378
- }, oa = {
1379
- rotate: q,
1380
- rotateX: q,
1381
- rotateY: q,
1382
- rotateZ: q,
1383
- scale: Ut,
1384
- scaleX: Ut,
1385
- scaleY: Ut,
1386
- scaleZ: Ut,
1387
- skew: q,
1388
- skewX: q,
1389
- skewY: q,
1390
- distance: x,
1391
- translateX: x,
1392
- translateY: x,
1393
- translateZ: x,
1394
- x,
1395
- y: x,
1396
- z: x,
1397
- perspective: x,
1398
- transformPerspective: x,
1399
- opacity: Et,
1400
- originX: An,
1401
- originY: An,
1402
- originZ: x
1403
- }, an = {
1404
- // Border props
1405
- borderWidth: x,
1406
- borderTopWidth: x,
1407
- borderRightWidth: x,
1408
- borderBottomWidth: x,
1409
- borderLeftWidth: x,
1410
- borderRadius: x,
1411
- radius: x,
1412
- borderTopLeftRadius: x,
1413
- borderTopRightRadius: x,
1414
- borderBottomRightRadius: x,
1415
- borderBottomLeftRadius: x,
1416
- // Positioning props
1417
- width: x,
1418
- maxWidth: x,
1419
- height: x,
1420
- maxHeight: x,
1421
- top: x,
1422
- right: x,
1423
- bottom: x,
1424
- left: x,
1425
- // Spacing props
1426
- padding: x,
1427
- paddingTop: x,
1428
- paddingRight: x,
1429
- paddingBottom: x,
1430
- paddingLeft: x,
1431
- margin: x,
1432
- marginTop: x,
1433
- marginRight: x,
1434
- marginBottom: x,
1435
- marginLeft: x,
1436
- // Misc
1437
- backgroundPositionX: x,
1438
- backgroundPositionY: x,
1439
- ...oa,
1440
- zIndex: jn,
1441
- // SVG
1442
- fillOpacity: Et,
1443
- strokeOpacity: Et,
1444
- numOctaves: jn
1445
- }, aa = {
1446
- ...an,
1447
- // Color props
1448
- color: C,
1449
- backgroundColor: C,
1450
- outlineColor: C,
1451
- fill: C,
1452
- stroke: C,
1453
- // Border props
1454
- borderColor: C,
1455
- borderTopColor: C,
1456
- borderRightColor: C,
1457
- borderBottomColor: C,
1458
- borderLeftColor: C,
1459
- filter: Ee,
1460
- WebkitFilter: Ee
1461
- }, Pi = (t) => aa[t];
1462
- function bi(t, e) {
1463
- let n = Pi(t);
1464
- return n !== Ee && (n = J), n.getAnimatableNone ? n.getAnimatableNone(e) : void 0;
1465
- }
1466
- const la = /* @__PURE__ */ new Set(["auto", "none", "0"]);
1467
- function ua(t, e, n) {
1468
- let s = 0, i;
1469
- for (; s < t.length && !i; ) {
1470
- const o = t[s];
1471
- typeof o == "string" && !la.has(o) && Rt(o).values.length && (i = t[s]), s++;
1472
- }
1473
- if (i && n)
1474
- for (const o of e)
1475
- t[o] = bi(n, i);
1476
- }
1477
- class ca extends rn {
1478
- constructor(e, n, s, i, o) {
1479
- super(e, n, s, i, o, !0);
1480
- }
1481
- readKeyframes() {
1482
- const { unresolvedKeyframes: e, element: n, name: s } = this;
1483
- if (!n || !n.current)
1484
- return;
1485
- super.readKeyframes();
1486
- for (let l = 0; l < e.length; l++) {
1487
- let c = e[l];
1488
- if (typeof c == "string" && (c = c.trim(), qe(c))) {
1489
- const u = yi(c, n.current);
1490
- u !== void 0 && (e[l] = u), l === e.length - 1 && (this.finalKeyframe = c);
1491
- }
1492
- }
1493
- if (this.resolveNoneKeyframes(), !vi.has(s) || e.length !== 2)
1494
- return;
1495
- const [i, o] = e, r = On(i), a = On(o);
1496
- if (r !== a)
1497
- if (kn(r) && kn(a))
1498
- for (let l = 0; l < e.length; l++) {
1499
- const c = e[l];
1500
- typeof c == "string" && (e[l] = parseFloat(c));
1501
- }
1502
- else rt[s] && (this.needsMeasurement = !0);
1503
- }
1504
- resolveNoneKeyframes() {
1505
- const { unresolvedKeyframes: e, name: n } = this, s = [];
1506
- for (let i = 0; i < e.length; i++)
1507
- (e[i] === null || na(e[i])) && s.push(i);
1508
- s.length && ua(e, s, n);
1509
- }
1510
- measureInitialState() {
1511
- const { element: e, unresolvedKeyframes: n, name: s } = this;
1512
- if (!e || !e.current)
1513
- return;
1514
- s === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = rt[s](e.measureViewportBox(), window.getComputedStyle(e.current)), n[0] = this.measuredOrigin;
1515
- const i = n[n.length - 1];
1516
- i !== void 0 && e.getValue(s, i).jump(i, !1);
1517
- }
1518
- measureEndState() {
1519
- const { element: e, name: n, unresolvedKeyframes: s } = this;
1520
- if (!e || !e.current)
1521
- return;
1522
- const i = e.getValue(n);
1523
- i && i.jump(this.measuredOrigin, !1);
1524
- const o = s.length - 1, r = s[o];
1525
- s[o] = rt[n](e.measureViewportBox(), window.getComputedStyle(e.current)), r !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = r), this.removedTransforms?.length && this.removedTransforms.forEach(([a, l]) => {
1526
- e.getValue(a).set(l);
1527
- }), this.resolveNoneKeyframes();
1528
- }
1529
- }
1530
- function ha(t, e, n) {
1531
- if (t instanceof EventTarget)
1532
- return [t];
1533
- if (typeof t == "string") {
1534
- let s = document;
1535
- const i = n?.[t] ?? s.querySelectorAll(t);
1536
- return i ? Array.from(i) : [];
1537
- }
1538
- return Array.from(t);
1539
- }
1540
- const Si = (t, e) => e && typeof t == "number" ? e.transform(t) : t;
1541
- function fa(t) {
1542
- return Us(t) && "offsetHeight" in t;
1543
- }
1544
- const Nn = 30, da = (t) => !isNaN(parseFloat(t));
1545
- class ma {
1546
- /**
1547
- * @param init - The initiating value
1548
- * @param config - Optional configuration options
1549
- *
1550
- * - `transformer`: A function to transform incoming values with.
1551
- */
1552
- constructor(e, n = {}) {
1553
- this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (s) => {
1554
- const i = O.now();
1555
- 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))
1556
- for (const o of this.dependents)
1557
- o.dirty();
1558
- }, this.hasAnimated = !1, this.setCurrent(e), this.owner = n.owner;
1559
- }
1560
- setCurrent(e) {
1561
- this.current = e, this.updatedAt = O.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = da(this.current));
1562
- }
1563
- setPrevFrameValue(e = this.current) {
1564
- this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt;
1565
- }
1566
- /**
1567
- * Adds a function that will be notified when the `MotionValue` is updated.
1568
- *
1569
- * It returns a function that, when called, will cancel the subscription.
1570
- *
1571
- * When calling `onChange` inside a React component, it should be wrapped with the
1572
- * `useEffect` hook. As it returns an unsubscribe function, this should be returned
1573
- * from the `useEffect` function to ensure you don't add duplicate subscribers..
1574
- *
1575
- * ```jsx
1576
- * export const MyComponent = () => {
1577
- * const x = useMotionValue(0)
1578
- * const y = useMotionValue(0)
1579
- * const opacity = useMotionValue(1)
1580
- *
1581
- * useEffect(() => {
1582
- * function updateOpacity() {
1583
- * const maxXY = Math.max(x.get(), y.get())
1584
- * const newOpacity = transform(maxXY, [0, 100], [1, 0])
1585
- * opacity.set(newOpacity)
1586
- * }
1587
- *
1588
- * const unsubscribeX = x.on("change", updateOpacity)
1589
- * const unsubscribeY = y.on("change", updateOpacity)
1590
- *
1591
- * return () => {
1592
- * unsubscribeX()
1593
- * unsubscribeY()
1594
- * }
1595
- * }, [])
1596
- *
1597
- * return <motion.div style={{ x }} />
1598
- * }
1599
- * ```
1600
- *
1601
- * @param subscriber - A function that receives the latest value.
1602
- * @returns A function that, when called, will cancel this subscription.
1603
- *
1604
- * @deprecated
1605
- */
1606
- onChange(e) {
1607
- return process.env.NODE_ENV !== "production" && He(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e);
1608
- }
1609
- on(e, n) {
1610
- this.events[e] || (this.events[e] = new _e());
1611
- const s = this.events[e].add(n);
1612
- return e === "change" ? () => {
1613
- s(), A.read(() => {
1614
- this.events.change.getSize() || this.stop();
1615
- });
1616
- } : s;
1617
- }
1618
- clearListeners() {
1619
- for (const e in this.events)
1620
- this.events[e].clear();
1621
- }
1622
- /**
1623
- * Attaches a passive effect to the `MotionValue`.
1624
- */
1625
- attach(e, n) {
1626
- this.passiveEffect = e, this.stopPassiveEffect = n;
1627
- }
1628
- /**
1629
- * Sets the state of the `MotionValue`.
1630
- *
1631
- * @remarks
1632
- *
1633
- * ```jsx
1634
- * const x = useMotionValue(0)
1635
- * x.set(10)
1636
- * ```
1637
- *
1638
- * @param latest - Latest value to set.
1639
- * @param render - Whether to notify render subscribers. Defaults to `true`
1640
- *
1641
- * @public
1642
- */
1643
- set(e) {
1644
- this.passiveEffect ? this.passiveEffect(e, this.updateAndNotify) : this.updateAndNotify(e);
1645
- }
1646
- setWithVelocity(e, n, s) {
1647
- this.set(n), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - s;
1648
- }
1649
- /**
1650
- * Set the state of the `MotionValue`, stopping any active animations,
1651
- * effects, and resets velocity to `0`.
1652
- */
1653
- jump(e, n = !0) {
1654
- this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, n && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1655
- }
1656
- dirty() {
1657
- this.events.change?.notify(this.current);
1658
- }
1659
- addDependent(e) {
1660
- this.dependents || (this.dependents = /* @__PURE__ */ new Set()), this.dependents.add(e);
1661
- }
1662
- removeDependent(e) {
1663
- this.dependents && this.dependents.delete(e);
1664
- }
1665
- /**
1666
- * Returns the latest state of `MotionValue`
1667
- *
1668
- * @returns - The latest state of `MotionValue`
1669
- *
1670
- * @public
1671
- */
1672
- get() {
1673
- return this.current;
1674
- }
1675
- /**
1676
- * @public
1677
- */
1678
- getPrevious() {
1679
- return this.prev;
1680
- }
1681
- /**
1682
- * Returns the latest velocity of `MotionValue`
1683
- *
1684
- * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
1685
- *
1686
- * @public
1687
- */
1688
- getVelocity() {
1689
- const e = O.now();
1690
- if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > Nn)
1691
- return 0;
1692
- const n = Math.min(this.updatedAt - this.prevUpdatedAt, Nn);
1693
- return Ws(parseFloat(this.current) - parseFloat(this.prevFrameValue), n);
1694
- }
1695
- /**
1696
- * Registers a new animation to control this `MotionValue`. Only one
1697
- * animation can drive a `MotionValue` at one time.
1698
- *
1699
- * ```jsx
1700
- * value.start()
1701
- * ```
1702
- *
1703
- * @param animation - A function that starts the provided animation
1704
- */
1705
- start(e) {
1706
- return this.stop(), new Promise((n) => {
1707
- this.hasAnimated = !0, this.animation = e(n), this.events.animationStart && this.events.animationStart.notify();
1708
- }).then(() => {
1709
- this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation();
1710
- });
1711
- }
1712
- /**
1713
- * Stop the currently active animation.
1714
- *
1715
- * @public
1716
- */
1717
- stop() {
1718
- this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation();
1719
- }
1720
- /**
1721
- * Returns `true` if this value is currently animating.
1722
- *
1723
- * @public
1724
- */
1725
- isAnimating() {
1726
- return !!this.animation;
1727
- }
1728
- clearAnimation() {
1729
- delete this.animation;
1730
- }
1731
- /**
1732
- * Destroy and clean up subscribers to this `MotionValue`.
1733
- *
1734
- * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
1735
- * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
1736
- * created a `MotionValue` via the `motionValue` function.
1737
- *
1738
- * @public
1739
- */
1740
- destroy() {
1741
- this.dependents?.clear(), this.events.destroy?.notify(), this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect();
1742
- }
1743
- }
1744
- function gt(t, e) {
1745
- return new ma(t, e);
1746
- }
1747
- const { schedule: ln } = /* @__PURE__ */ Qs(queueMicrotask, !1), G = {
1748
- x: !1,
1749
- y: !1
1750
- };
1751
- function wi() {
1752
- return G.x || G.y;
1753
- }
1754
- function pa(t) {
1755
- return t === "x" || t === "y" ? G[t] ? null : (G[t] = !0, () => {
1756
- G[t] = !1;
1757
- }) : G.x || G.y ? null : (G.x = G.y = !0, () => {
1758
- G.x = G.y = !1;
1759
- });
1760
- }
1761
- function Ai(t, e) {
1762
- const n = ha(t), s = new AbortController(), i = {
1763
- passive: !0,
1764
- ...e,
1765
- signal: s.signal
1766
- };
1767
- return [n, i, () => s.abort()];
1768
- }
1769
- function Un(t) {
1770
- return !(t.pointerType === "touch" || wi());
1771
- }
1772
- function ga(t, e, n = {}) {
1773
- const [s, i, o] = Ai(t, n), r = (a) => {
1774
- if (!Un(a))
1775
- return;
1776
- const { target: l } = a, c = e(l, a);
1777
- if (typeof c != "function" || !l)
1778
- return;
1779
- const u = (h) => {
1780
- Un(h) && (c(h), l.removeEventListener("pointerleave", u));
1781
- };
1782
- l.addEventListener("pointerleave", u, i);
1783
- };
1784
- return s.forEach((a) => {
1785
- a.addEventListener("pointerenter", r, i);
1786
- }), o;
1787
- }
1788
- const Vi = (t, e) => e ? t === e ? !0 : Vi(t, e.parentElement) : !1, un = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1, ya = /* @__PURE__ */ new Set([
1789
- "BUTTON",
1790
- "INPUT",
1791
- "SELECT",
1792
- "TEXTAREA",
1793
- "A"
1794
- ]);
1795
- function va(t) {
1796
- return ya.has(t.tagName) || t.tabIndex !== -1;
1797
- }
1798
- const Gt = /* @__PURE__ */ new WeakSet();
1799
- function Kn(t) {
1800
- return (e) => {
1801
- e.key === "Enter" && t(e);
1802
- };
1803
- }
1804
- function ae(t, e) {
1805
- t.dispatchEvent(new PointerEvent("pointer" + e, { isPrimary: !0, bubbles: !0 }));
1806
- }
1807
- const Ta = (t, e) => {
1808
- const n = t.currentTarget;
1809
- if (!n)
1810
- return;
1811
- const s = Kn(() => {
1812
- if (Gt.has(n))
1813
- return;
1814
- ae(n, "down");
1815
- const i = Kn(() => {
1816
- ae(n, "up");
1817
- }), o = () => ae(n, "cancel");
1818
- n.addEventListener("keyup", i, e), n.addEventListener("blur", o, e);
1819
- });
1820
- n.addEventListener("keydown", s, e), n.addEventListener("blur", () => n.removeEventListener("keydown", s), e);
1821
- };
1822
- function Wn(t) {
1823
- return un(t) && !wi();
1824
- }
1825
- function xa(t, e, n = {}) {
1826
- const [s, i, o] = Ai(t, n), r = (a) => {
1827
- const l = a.currentTarget;
1828
- if (!Wn(a))
1829
- return;
1830
- Gt.add(l);
1831
- const c = e(l, a), u = (d, m) => {
1832
- window.removeEventListener("pointerup", h), window.removeEventListener("pointercancel", f), Gt.has(l) && Gt.delete(l), Wn(d) && typeof c == "function" && c(d, { success: m });
1833
- }, h = (d) => {
1834
- u(d, l === window || l === document || n.useGlobalTarget || Vi(l, d.target));
1835
- }, f = (d) => {
1836
- u(d, !1);
1837
- };
1838
- window.addEventListener("pointerup", h, i), window.addEventListener("pointercancel", f, i);
1839
- };
1840
- return s.forEach((a) => {
1841
- (n.useGlobalTarget ? window : a).addEventListener("pointerdown", r, i), fa(a) && (a.addEventListener("focus", (c) => Ta(c, i)), !va(a) && !a.hasAttribute("tabindex") && (a.tabIndex = 0));
1842
- }), o;
1843
- }
1844
- function Di(t) {
1845
- return Us(t) && "ownerSVGElement" in t;
1846
- }
1847
- function Pa(t) {
1848
- return Di(t) && t.tagName === "svg";
1849
- }
1850
- const k = (t) => !!(t && t.getVelocity), ba = [...xi, C, J], Sa = (t) => ba.find(Ti(t)), Mi = vt({
1851
- transformPagePoint: (t) => t,
1852
- isStatic: !1,
1853
- reducedMotion: "never"
1854
- });
1855
- function wa(t = !0) {
1856
- const e = I(Ke);
1857
- if (e === null)
1858
- return [!0, null];
1859
- const { isPresent: n, onExitComplete: s, register: i } = e, o = vr();
1860
- Ne(() => {
1861
- if (t)
1862
- return i(o);
1863
- }, [t]);
1864
- const r = Bs(() => t && s && s(o), [o, s, t]);
1865
- return !n && s ? [!1, r] : [!0];
1866
- }
1867
- const Ci = vt({ strict: !1 }), $n = {
1868
- animation: [
1869
- "animate",
1870
- "variants",
1871
- "whileHover",
1872
- "whileTap",
1873
- "exit",
1874
- "whileInView",
1875
- "whileFocus",
1876
- "whileDrag"
1877
- ],
1878
- exit: ["exit"],
1879
- drag: ["drag", "dragControls"],
1880
- focus: ["whileFocus"],
1881
- hover: ["whileHover", "onHoverStart", "onHoverEnd"],
1882
- tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
1883
- pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
1884
- inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
1885
- layout: ["layout", "layoutId"]
1886
- }, yt = {};
1887
- for (const t in $n)
1888
- yt[t] = {
1889
- isEnabled: (e) => $n[t].some((n) => !!e[n])
1890
- };
1891
- function Aa(t) {
1892
- for (const e in t)
1893
- yt[e] = {
1894
- ...yt[e],
1895
- ...t[e]
1896
- };
1897
- }
1898
- const Va = /* @__PURE__ */ new Set([
1899
- "animate",
1900
- "exit",
1901
- "variants",
1902
- "initial",
1903
- "style",
1904
- "values",
1905
- "variants",
1906
- "transition",
1907
- "transformTemplate",
1908
- "custom",
1909
- "inherit",
1910
- "onBeforeLayoutMeasure",
1911
- "onAnimationStart",
1912
- "onAnimationComplete",
1913
- "onUpdate",
1914
- "onDragStart",
1915
- "onDrag",
1916
- "onDragEnd",
1917
- "onMeasureDragConstraints",
1918
- "onDirectionLock",
1919
- "onDragTransitionEnd",
1920
- "_dragX",
1921
- "_dragY",
1922
- "onHoverStart",
1923
- "onHoverEnd",
1924
- "onViewportEnter",
1925
- "onViewportLeave",
1926
- "globalTapTarget",
1927
- "ignoreStrict",
1928
- "viewport"
1929
- ]);
1930
- function qt(t) {
1931
- return t.startsWith("while") || t.startsWith("drag") && t !== "draggable" || t.startsWith("layout") || t.startsWith("onTap") || t.startsWith("onPan") || t.startsWith("onLayout") || Va.has(t);
1932
- }
1933
- let Ei = (t) => !qt(t);
1934
- function Da(t) {
1935
- typeof t == "function" && (Ei = (e) => e.startsWith("on") ? !qt(e) : t(e));
1936
- }
1937
- try {
1938
- Da(require("@emotion/is-prop-valid").default);
1939
- } catch {
1940
- }
1941
- function Ma(t, e, n) {
1942
- const s = {};
1943
- for (const i in t)
1944
- i === "values" && typeof t.values == "object" || (Ei(i) || n === !0 && qt(i) || !e && !qt(i) || // If trying to use native HTML drag events, forward drag listeners
1945
- t.draggable && i.startsWith("onDrag")) && (s[i] = t[i]);
1946
- return s;
1947
- }
1948
- const Qt = /* @__PURE__ */ vt({});
1949
- function te(t) {
1950
- return t !== null && typeof t == "object" && typeof t.start == "function";
1951
- }
1952
- function Lt(t) {
1953
- return typeof t == "string" || Array.isArray(t);
1954
- }
1955
- const cn = [
1956
- "animate",
1957
- "whileInView",
1958
- "whileFocus",
1959
- "whileHover",
1960
- "whileTap",
1961
- "whileDrag",
1962
- "exit"
1963
- ], hn = ["initial", ...cn];
1964
- function ee(t) {
1965
- return te(t.animate) || hn.some((e) => Lt(t[e]));
1966
- }
1967
- function Ri(t) {
1968
- return !!(ee(t) || t.variants);
1969
- }
1970
- function Ca(t, e) {
1971
- if (ee(t)) {
1972
- const { initial: n, animate: s } = t;
1973
- return {
1974
- initial: n === !1 || Lt(n) ? n : void 0,
1975
- animate: Lt(s) ? s : void 0
1976
- };
1977
- }
1978
- return t.inherit !== !1 ? e : {};
1979
- }
1980
- function Ea(t) {
1981
- const { initial: e, animate: n } = Ca(t, I(Qt));
1982
- return Jt(() => ({ initial: e, animate: n }), [Gn(e), Gn(n)]);
1983
- }
1984
- function Gn(t) {
1985
- return Array.isArray(t) ? t.join(" ") : t;
1986
- }
1987
- const kt = {};
1988
- function Ra(t) {
1989
- for (const e in t)
1990
- kt[e] = t[e], Xe(e) && (kt[e].isCSSVariable = !0);
1991
- }
1992
- function Li(t, { layout: e, layoutId: n }) {
1993
- return bt.has(t) || t.startsWith("origin") || (e || n !== void 0) && (!!kt[t] || t === "opacity");
1994
- }
1995
- const La = {
1996
- x: "translateX",
1997
- y: "translateY",
1998
- z: "translateZ",
1999
- transformPerspective: "perspective"
2000
- }, ka = Pt.length;
2001
- function Fa(t, e, n) {
2002
- let s = "", i = !0;
2003
- for (let o = 0; o < ka; o++) {
2004
- const r = Pt[o], a = t[r];
2005
- if (a === void 0)
2006
- continue;
2007
- let l = !0;
2008
- if (typeof a == "number" ? l = a === (r.startsWith("scale") ? 1 : 0) : l = parseFloat(a) === 0, !l || n) {
2009
- const c = Si(a, an[r]);
2010
- if (!l) {
2011
- i = !1;
2012
- const u = La[r] || r;
2013
- s += `${u}(${c}) `;
2014
- }
2015
- n && (e[r] = c);
2016
- }
2017
- }
2018
- return s = s.trim(), n ? s = n(e, i ? "" : s) : i && (s = "none"), s;
2019
- }
2020
- function fn(t, e, n) {
2021
- const { style: s, vars: i, transformOrigin: o } = t;
2022
- let r = !1, a = !1;
2023
- for (const l in e) {
2024
- const c = e[l];
2025
- if (bt.has(l)) {
2026
- r = !0;
2027
- continue;
2028
- } else if (Xe(l)) {
2029
- i[l] = c;
2030
- continue;
2031
- } else {
2032
- const u = Si(c, an[l]);
2033
- l.startsWith("origin") ? (a = !0, o[l] = u) : s[l] = u;
2034
- }
2035
- }
2036
- if (e.transform || (r || n ? s.transform = Fa(e, t.transform, n) : s.transform && (s.transform = "none")), a) {
2037
- const { originX: l = "50%", originY: c = "50%", originZ: u = 0 } = o;
2038
- s.transformOrigin = `${l} ${c} ${u}`;
2039
- }
2040
- }
2041
- const dn = () => ({
2042
- style: {},
2043
- transform: {},
2044
- transformOrigin: {},
2045
- vars: {}
2046
- });
2047
- function ki(t, e, n) {
2048
- for (const s in e)
2049
- !k(e[s]) && !Li(s, n) && (t[s] = e[s]);
2050
- }
2051
- function Ba({ transformTemplate: t }, e) {
2052
- return Jt(() => {
2053
- const n = dn();
2054
- return fn(n, e, t), Object.assign({}, n.vars, n.style);
2055
- }, [e]);
2056
- }
2057
- function Ia(t, e) {
2058
- const n = t.style || {}, s = {};
2059
- return ki(s, n, t), Object.assign(s, Ba(t, e)), s;
2060
- }
2061
- function Oa(t, e) {
2062
- const n = {}, s = Ia(t, e);
2063
- return t.drag && t.dragListener !== !1 && (n.draggable = !1, s.userSelect = s.WebkitUserSelect = s.WebkitTouchCallout = "none", s.touchAction = t.drag === !0 ? "none" : `pan-${t.drag === "x" ? "y" : "x"}`), t.tabIndex === void 0 && (t.onTap || t.onTapStart || t.whileTap) && (n.tabIndex = 0), n.style = s, n;
2064
- }
2065
- const ja = {
2066
- offset: "stroke-dashoffset",
2067
- array: "stroke-dasharray"
2068
- }, Na = {
2069
- offset: "strokeDashoffset",
2070
- array: "strokeDasharray"
2071
- };
2072
- function Ua(t, e, n = 1, s = 0, i = !0) {
2073
- t.pathLength = 1;
2074
- const o = i ? ja : Na;
2075
- t[o.offset] = x.transform(-s);
2076
- const r = x.transform(e), a = x.transform(n);
2077
- t[o.array] = `${r} ${a}`;
2078
- }
2079
- function Fi(t, {
2080
- attrX: e,
2081
- attrY: n,
2082
- attrScale: s,
2083
- pathLength: i,
2084
- pathSpacing: o = 1,
2085
- pathOffset: r = 0,
2086
- // This is object creation, which we try to avoid per-frame.
2087
- ...a
2088
- }, l, c, u) {
2089
- if (fn(t, a, c), l) {
2090
- t.style.viewBox && (t.attrs.viewBox = t.style.viewBox);
2091
- return;
2092
- }
2093
- t.attrs = t.style, t.style = {};
2094
- const { attrs: h, style: f } = t;
2095
- h.transform && (f.transform = h.transform, delete h.transform), (f.transform || h.transformOrigin) && (f.transformOrigin = h.transformOrigin ?? "50% 50%", delete h.transformOrigin), f.transform && (f.transformBox = u?.transformBox ?? "fill-box", delete h.transformBox), e !== void 0 && (h.x = e), n !== void 0 && (h.y = n), s !== void 0 && (h.scale = s), i !== void 0 && Ua(h, i, o, r, !1);
2096
- }
2097
- const Bi = () => ({
2098
- ...dn(),
2099
- attrs: {}
2100
- }), Ii = (t) => typeof t == "string" && t.toLowerCase() === "svg";
2101
- function Ka(t, e, n, s) {
2102
- const i = Jt(() => {
2103
- const o = Bi();
2104
- return Fi(o, e, Ii(s), t.transformTemplate, t.style), {
2105
- ...o.attrs,
2106
- style: { ...o.style }
2107
- };
2108
- }, [e]);
2109
- if (t.style) {
2110
- const o = {};
2111
- ki(o, t.style, t), i.style = { ...o, ...i.style };
2112
- }
2113
- return i;
2114
- }
2115
- const Wa = [
2116
- "animate",
2117
- "circle",
2118
- "defs",
2119
- "desc",
2120
- "ellipse",
2121
- "g",
2122
- "image",
2123
- "line",
2124
- "filter",
2125
- "marker",
2126
- "mask",
2127
- "metadata",
2128
- "path",
2129
- "pattern",
2130
- "polygon",
2131
- "polyline",
2132
- "rect",
2133
- "stop",
2134
- "switch",
2135
- "symbol",
2136
- "svg",
2137
- "text",
2138
- "tspan",
2139
- "use",
2140
- "view"
2141
- ];
2142
- function mn(t) {
2143
- return (
2144
- /**
2145
- * If it's not a string, it's a custom React component. Currently we only support
2146
- * HTML custom React components.
2147
- */
2148
- typeof t != "string" || /**
2149
- * If it contains a dash, the element is a custom HTML webcomponent.
2150
- */
2151
- t.includes("-") ? !1 : (
2152
- /**
2153
- * If it's in our list of lowercase SVG tags, it's an SVG component
2154
- */
2155
- !!(Wa.indexOf(t) > -1 || /**
2156
- * If it contains a capital letter, it's an SVG component
2157
- */
2158
- /[A-Z]/u.test(t))
2159
- )
2160
- );
2161
- }
2162
- function $a(t, e, n, { latestValues: s }, i, o = !1) {
2163
- const a = (mn(t) ? Ka : Oa)(e, s, i, t), l = Ma(e, typeof t == "string", o), c = t !== Is ? { ...l, ...a, ref: n } : {}, { children: u } = e, h = Jt(() => k(u) ? u.get() : u, [u]);
2164
- return Tr(t, {
2165
- ...c,
2166
- children: h
2167
- });
2168
- }
2169
- function _n(t) {
2170
- const e = [{}, {}];
2171
- return t?.values.forEach((n, s) => {
2172
- e[0][s] = n.get(), e[1][s] = n.getVelocity();
2173
- }), e;
2174
- }
2175
- function pn(t, e, n, s) {
2176
- if (typeof e == "function") {
2177
- const [i, o] = _n(s);
2178
- e = e(n !== void 0 ? n : t.custom, i, o);
2179
- }
2180
- if (typeof e == "string" && (e = t.variants && t.variants[e]), typeof e == "function") {
2181
- const [i, o] = _n(s);
2182
- e = e(n !== void 0 ? n : t.custom, i, o);
2183
- }
2184
- return e;
2185
- }
2186
- function _t(t) {
2187
- return k(t) ? t.get() : t;
2188
- }
2189
- function Ga({ scrapeMotionValuesFromProps: t, createRenderState: e }, n, s, i) {
2190
- return {
2191
- latestValues: _a(n, s, i, t),
2192
- renderState: e()
2193
- };
2194
- }
2195
- function _a(t, e, n, s) {
2196
- const i = {}, o = s(t, {});
2197
- for (const f in o)
2198
- i[f] = _t(o[f]);
2199
- let { initial: r, animate: a } = t;
2200
- const l = ee(t), c = Ri(t);
2201
- e && c && !l && t.inherit !== !1 && (r === void 0 && (r = e.initial), a === void 0 && (a = e.animate));
2202
- let u = n ? n.initial === !1 : !1;
2203
- u = u || r === !1;
2204
- const h = u ? a : r;
2205
- if (h && typeof h != "boolean" && !te(h)) {
2206
- const f = Array.isArray(h) ? h : [h];
2207
- for (let d = 0; d < f.length; d++) {
2208
- const m = pn(t, f[d]);
2209
- if (m) {
2210
- const { transitionEnd: v, transition: y, ...p } = m;
2211
- for (const T in p) {
2212
- let g = p[T];
2213
- if (Array.isArray(g)) {
2214
- const S = u ? g.length - 1 : 0;
2215
- g = g[S];
2216
- }
2217
- g !== null && (i[T] = g);
2218
- }
2219
- for (const T in v)
2220
- i[T] = v[T];
2221
- }
2222
- }
2223
- }
2224
- return i;
2225
- }
2226
- const Oi = (t) => (e, n) => {
2227
- const s = I(Qt), i = I(Ke), o = () => Ga(t, e, s, i);
2228
- return n ? o() : wr(o);
2229
- };
2230
- function gn(t, e, n) {
2231
- const { style: s } = t, i = {};
2232
- for (const o in s)
2233
- (k(s[o]) || e.style && k(e.style[o]) || Li(o, t) || n?.getValue(o)?.liveStyle !== void 0) && (i[o] = s[o]);
2234
- return i;
2235
- }
2236
- const Ha = /* @__PURE__ */ Oi({
2237
- scrapeMotionValuesFromProps: gn,
2238
- createRenderState: dn
2239
- });
2240
- function ji(t, e, n) {
2241
- const s = gn(t, e, n);
2242
- for (const i in t)
2243
- if (k(t[i]) || k(e[i])) {
2244
- const o = Pt.indexOf(i) !== -1 ? "attr" + i.charAt(0).toUpperCase() + i.substring(1) : i;
2245
- s[o] = t[i];
2246
- }
2247
- return s;
2248
- }
2249
- const za = /* @__PURE__ */ Oi({
2250
- scrapeMotionValuesFromProps: ji,
2251
- createRenderState: Bi
2252
- }), Ya = Symbol.for("motionComponentSymbol");
2253
- function ht(t) {
2254
- return t && typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "current");
2255
- }
2256
- function Xa(t, e, n) {
2257
- return Bs(
2258
- (s) => {
2259
- s && t.onMount && t.onMount(s), e && (s ? e.mount(s) : e.unmount()), n && (typeof n == "function" ? n(s) : ht(n) && (n.current = s));
2260
- },
2261
- /**
2262
- * Include externalRef in dependencies to ensure the callback updates
2263
- * when the ref changes, allowing proper ref forwarding.
2264
- */
2265
- [e]
2266
- );
2267
- }
2268
- const yn = (t) => t.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), qa = "framerAppearId", Ni = "data-" + yn(qa), Ui = vt({});
2269
- function Za(t, e, n, s, i) {
2270
- const { visualElement: o } = I(Qt), r = I(Ci), a = I(Ke), l = I(Mi).reducedMotion, c = Wt(null);
2271
- s = s || r.renderer, !c.current && s && (c.current = s(t, {
2272
- visualState: e,
2273
- parent: o,
2274
- props: n,
2275
- presenceContext: a,
2276
- blockInitialAnimation: a ? a.initial === !1 : !1,
2277
- reducedMotionConfig: l
2278
- }));
2279
- const u = c.current, h = I(Ui);
2280
- u && !u.projection && i && (u.type === "html" || u.type === "svg") && Ja(c.current, n, i, h);
2281
- const f = Wt(!1);
2282
- xr(() => {
2283
- u && f.current && u.update(n, a);
2284
- });
2285
- const d = n[Ni], m = Wt(!!d && !window.MotionHandoffIsComplete?.(d) && window.MotionHasOptimisedAnimation?.(d));
2286
- return Ar(() => {
2287
- u && (f.current = !0, window.MotionIsMounted = !0, u.updateFeatures(), u.scheduleRenderMicrotask(), m.current && u.animationState && u.animationState.animateChanges());
2288
- }), Ne(() => {
2289
- u && (!m.current && u.animationState && u.animationState.animateChanges(), m.current && (queueMicrotask(() => {
2290
- window.MotionHandoffMarkAsComplete?.(d);
2291
- }), m.current = !1), u.enteringChildren = void 0);
2292
- }), u;
2293
- }
2294
- function Ja(t, e, n, s) {
2295
- const { layoutId: i, layout: o, drag: r, dragConstraints: a, layoutScroll: l, layoutRoot: c, layoutCrossfade: u } = e;
2296
- t.projection = new n(t.latestValues, e["data-framer-portal-id"] ? void 0 : Ki(t.parent)), t.projection.setOptions({
2297
- layoutId: i,
2298
- layout: o,
2299
- alwaysMeasureLayout: !!r || a && ht(a),
2300
- visualElement: t,
2301
- /**
2302
- * TODO: Update options in an effect. This could be tricky as it'll be too late
2303
- * to update by the time layout animations run.
2304
- * We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
2305
- * ensuring it gets called if there's no potential layout animations.
2306
- *
2307
- */
2308
- animationType: typeof o == "string" ? o : "both",
2309
- initialPromotionConfig: s,
2310
- crossfade: u,
2311
- layoutScroll: l,
2312
- layoutRoot: c
2313
- });
2314
- }
2315
- function Ki(t) {
2316
- if (t)
2317
- return t.options.allowProjection !== !1 ? t.projection : Ki(t.parent);
2318
- }
2319
- function le(t, { forwardMotionProps: e = !1 } = {}, n, s) {
2320
- n && Aa(n);
2321
- const i = mn(t) ? za : Ha;
2322
- function o(a, l) {
2323
- let c;
2324
- const u = {
2325
- ...I(Mi),
2326
- ...a,
2327
- layoutId: Qa(a)
2328
- }, { isStatic: h } = u, f = Ea(a), d = i(a, h);
2329
- if (!h && Ue) {
2330
- tl(u, n);
2331
- const m = el(u);
2332
- c = m.MeasureLayout, f.visualElement = Za(t, d, u, s, m.ProjectionNode);
2333
- }
2334
- return Sr(Qt.Provider, { value: f, children: [c && f.visualElement ? Os(c, { visualElement: f.visualElement, ...u }) : null, $a(t, a, Xa(d, f.visualElement, l), d, h, e)] });
2335
- }
2336
- o.displayName = `motion.${typeof t == "string" ? t : `create(${t.displayName ?? t.name ?? ""})`}`;
2337
- const r = Pr(o);
2338
- return r[Ya] = t, r;
2339
- }
2340
- function Qa({ layoutId: t }) {
2341
- const e = I(js).id;
2342
- return e && t !== void 0 ? e + "-" + t : t;
2343
- }
2344
- function tl(t, e) {
2345
- const n = I(Ci).strict;
2346
- if (process.env.NODE_ENV !== "production" && e && n) {
2347
- const s = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
2348
- t.ignoreStrict ? Tt(!1, s, "lazy-strict-mode") : Y(!1, s, "lazy-strict-mode");
2349
- }
2350
- }
2351
- function el(t) {
2352
- const { drag: e, layout: n } = yt;
2353
- if (!e && !n)
2354
- return {};
2355
- const s = { ...e, ...n };
2356
- return {
2357
- MeasureLayout: e?.isEnabled(t) || n?.isEnabled(t) ? s.MeasureLayout : void 0,
2358
- ProjectionNode: s.ProjectionNode
2359
- };
2360
- }
2361
- function nl(t, e) {
2362
- if (typeof Proxy > "u")
2363
- return le;
2364
- const n = /* @__PURE__ */ new Map(), s = (o, r) => le(o, r, t, e), i = (o, r) => (process.env.NODE_ENV !== "production" && He(!1, "motion() is deprecated. Use motion.create() instead."), s(o, r));
2365
- return new Proxy(i, {
2366
- /**
2367
- * Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc.
2368
- * The prop name is passed through as `key` and we can use that to generate a `motion`
2369
- * DOM component with that name.
2370
- */
2371
- get: (o, r) => r === "create" ? s : (n.has(r) || n.set(r, le(r, void 0, t, e)), n.get(r))
2372
- });
2373
- }
2374
- function Wi({ top: t, left: e, right: n, bottom: s }) {
2375
- return {
2376
- x: { min: e, max: n },
2377
- y: { min: t, max: s }
2378
- };
2379
- }
2380
- function sl({ x: t, y: e }) {
2381
- return { top: e.min, right: t.max, bottom: e.max, left: t.min };
2382
- }
2383
- function il(t, e) {
2384
- if (!e)
2385
- return t;
2386
- const n = e({ x: t.left, y: t.top }), s = e({ x: t.right, y: t.bottom });
2387
- return {
2388
- top: n.y,
2389
- left: n.x,
2390
- bottom: s.y,
2391
- right: s.x
2392
- };
2393
- }
2394
- function ue(t) {
2395
- return t === void 0 || t === 1;
2396
- }
2397
- function Re({ scale: t, scaleX: e, scaleY: n }) {
2398
- return !ue(t) || !ue(e) || !ue(n);
2399
- }
2400
- function nt(t) {
2401
- return Re(t) || $i(t) || t.z || t.rotate || t.rotateX || t.rotateY || t.skewX || t.skewY;
2402
- }
2403
- function $i(t) {
2404
- return Hn(t.x) || Hn(t.y);
2405
- }
2406
- function Hn(t) {
2407
- return t && t !== "0%";
2408
- }
2409
- function Zt(t, e, n) {
2410
- const s = t - n, i = e * s;
2411
- return n + i;
2412
- }
2413
- function zn(t, e, n, s, i) {
2414
- return i !== void 0 && (t = Zt(t, i, s)), Zt(t, n, s) + e;
2415
- }
2416
- function Le(t, e = 0, n = 1, s, i) {
2417
- t.min = zn(t.min, e, n, s, i), t.max = zn(t.max, e, n, s, i);
2418
- }
2419
- function Gi(t, { x: e, y: n }) {
2420
- Le(t.x, e.translate, e.scale, e.originPoint), Le(t.y, n.translate, n.scale, n.originPoint);
2421
- }
2422
- const Yn = 0.999999999999, Xn = 1.0000000000001;
2423
- function rl(t, e, n, s = !1) {
2424
- const i = n.length;
2425
- if (!i)
2426
- return;
2427
- e.x = e.y = 1;
2428
- let o, r;
2429
- for (let a = 0; a < i; a++) {
2430
- o = n[a], r = o.projectionDelta;
2431
- const { visualElement: l } = o.options;
2432
- l && l.props.style && l.props.style.display === "contents" || (s && o.options.layoutScroll && o.scroll && o !== o.root && dt(t, {
2433
- x: -o.scroll.offset.x,
2434
- y: -o.scroll.offset.y
2435
- }), r && (e.x *= r.x.scale, e.y *= r.y.scale, Gi(t, r)), s && nt(o.latestValues) && dt(t, o.latestValues));
2436
- }
2437
- e.x < Xn && e.x > Yn && (e.x = 1), e.y < Xn && e.y > Yn && (e.y = 1);
2438
- }
2439
- function ft(t, e) {
2440
- t.min = t.min + e, t.max = t.max + e;
2441
- }
2442
- function qn(t, e, n, s, i = 0.5) {
2443
- const o = D(t.min, t.max, i);
2444
- Le(t, e, n, o, s);
2445
- }
2446
- function dt(t, e) {
2447
- qn(t.x, e.x, e.scaleX, e.scale, e.originX), qn(t.y, e.y, e.scaleY, e.scale, e.originY);
2448
- }
2449
- function _i(t, e) {
2450
- return Wi(il(t.getBoundingClientRect(), e));
2451
- }
2452
- function ol(t, e, n) {
2453
- const s = _i(t, n), { scroll: i } = e;
2454
- return i && (ft(s.x, i.offset.x), ft(s.y, i.offset.y)), s;
2455
- }
2456
- const Zn = () => ({
2457
- translate: 0,
2458
- scale: 1,
2459
- origin: 0,
2460
- originPoint: 0
2461
- }), mt = () => ({
2462
- x: Zn(),
2463
- y: Zn()
2464
- }), Jn = () => ({ min: 0, max: 0 }), M = () => ({
2465
- x: Jn(),
2466
- y: Jn()
2467
- }), ke = { current: null }, Hi = { current: !1 };
2468
- function al() {
2469
- if (Hi.current = !0, !!Ue)
2470
- if (window.matchMedia) {
2471
- const t = window.matchMedia("(prefers-reduced-motion)"), e = () => ke.current = t.matches;
2472
- t.addEventListener("change", e), e();
2473
- } else
2474
- ke.current = !1;
2475
- }
2476
- const ll = /* @__PURE__ */ new WeakMap();
2477
- function ul(t, e, n) {
2478
- for (const s in e) {
2479
- const i = e[s], o = n[s];
2480
- if (k(i))
2481
- t.addValue(s, i);
2482
- else if (k(o))
2483
- t.addValue(s, gt(i, { owner: t }));
2484
- else if (o !== i)
2485
- if (t.hasValue(s)) {
2486
- const r = t.getValue(s);
2487
- r.liveStyle === !0 ? r.jump(i) : r.hasAnimated || r.set(i);
2488
- } else {
2489
- const r = t.getStaticValue(s);
2490
- t.addValue(s, gt(r !== void 0 ? r : i, { owner: t }));
2491
- }
2492
- }
2493
- for (const s in n)
2494
- e[s] === void 0 && t.removeValue(s);
2495
- return e;
2496
- }
2497
- const Qn = [
2498
- "AnimationStart",
2499
- "AnimationComplete",
2500
- "Update",
2501
- "BeforeLayoutMeasure",
2502
- "LayoutMeasure",
2503
- "LayoutAnimationStart",
2504
- "LayoutAnimationComplete"
2505
- ];
2506
- class cl {
2507
- /**
2508
- * This method takes React props and returns found MotionValues. For example, HTML
2509
- * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.
2510
- *
2511
- * This isn't an abstract method as it needs calling in the constructor, but it is
2512
- * intended to be one.
2513
- */
2514
- scrapeMotionValuesFromProps(e, n, s) {
2515
- return {};
2516
- }
2517
- constructor({ parent: e, props: n, presenceContext: s, reducedMotionConfig: i, blockInitialAnimation: o, visualState: r }, a = {}) {
2518
- this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = rn, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => {
2519
- this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection));
2520
- }, this.renderScheduledAt = 0, this.scheduleRender = () => {
2521
- const f = O.now();
2522
- this.renderScheduledAt < f && (this.renderScheduledAt = f, A.render(this.render, !1, !0));
2523
- };
2524
- const { latestValues: l, renderState: c } = r;
2525
- this.latestValues = l, this.baseTarget = { ...l }, this.initialValues = n.initial ? { ...l } : {}, this.renderState = c, this.parent = e, this.props = n, this.presenceContext = s, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!o, this.isControllingVariants = ee(n), this.isVariantNode = Ri(n), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current);
2526
- const { willChange: u, ...h } = this.scrapeMotionValuesFromProps(n, {}, this);
2527
- for (const f in h) {
2528
- const d = h[f];
2529
- l[f] !== void 0 && k(d) && d.set(l[f]);
2530
- }
2531
- }
2532
- mount(e) {
2533
- this.current = e, ll.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)), Hi.current || al(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : ke.current, process.env.NODE_ENV !== "production" && He(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);
2534
- }
2535
- unmount() {
2536
- this.projection && this.projection.unmount(), Z(this.notifyUpdate), Z(this.render), this.valueSubscriptions.forEach((e) => e()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent?.removeChild(this);
2537
- for (const e in this.events)
2538
- this.events[e].clear();
2539
- for (const e in this.features) {
2540
- const n = this.features[e];
2541
- n && (n.unmount(), n.isMounted = !1);
2542
- }
2543
- this.current = null;
2544
- }
2545
- addChild(e) {
2546
- this.children.add(e), this.enteringChildren ?? (this.enteringChildren = /* @__PURE__ */ new Set()), this.enteringChildren.add(e);
2547
- }
2548
- removeChild(e) {
2549
- this.children.delete(e), this.enteringChildren && this.enteringChildren.delete(e);
2550
- }
2551
- bindToMotionValue(e, n) {
2552
- this.valueSubscriptions.has(e) && this.valueSubscriptions.get(e)();
2553
- const s = bt.has(e);
2554
- s && this.onBindTransform && this.onBindTransform();
2555
- const i = n.on("change", (r) => {
2556
- this.latestValues[e] = r, this.props.onUpdate && A.preRender(this.notifyUpdate), s && this.projection && (this.projection.isTransformDirty = !0), this.scheduleRender();
2557
- });
2558
- let o;
2559
- window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, e, n)), this.valueSubscriptions.set(e, () => {
2560
- i(), o && o(), n.owner && n.stop();
2561
- });
2562
- }
2563
- sortNodePosition(e) {
2564
- return !this.current || !this.sortInstanceNodePosition || this.type !== e.type ? 0 : this.sortInstanceNodePosition(this.current, e.current);
2565
- }
2566
- updateFeatures() {
2567
- let e = "animation";
2568
- for (e in yt) {
2569
- const n = yt[e];
2570
- if (!n)
2571
- continue;
2572
- const { isEnabled: s, Feature: i } = n;
2573
- if (!this.features[e] && i && s(this.props) && (this.features[e] = new i(this)), this.features[e]) {
2574
- const o = this.features[e];
2575
- o.isMounted ? o.update() : (o.mount(), o.isMounted = !0);
2576
- }
2577
- }
2578
- }
2579
- triggerBuild() {
2580
- this.build(this.renderState, this.latestValues, this.props);
2581
- }
2582
- /**
2583
- * Measure the current viewport box with or without transforms.
2584
- * Only measures axis-aligned boxes, rotate and skew must be manually
2585
- * removed with a re-render to work.
2586
- */
2587
- measureViewportBox() {
2588
- return this.current ? this.measureInstanceViewportBox(this.current, this.props) : M();
2589
- }
2590
- getStaticValue(e) {
2591
- return this.latestValues[e];
2592
- }
2593
- setStaticValue(e, n) {
2594
- this.latestValues[e] = n;
2595
- }
2596
- /**
2597
- * Update the provided props. Ensure any newly-added motion values are
2598
- * added to our map, old ones removed, and listeners updated.
2599
- */
2600
- update(e, n) {
2601
- (e.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = e, this.prevPresenceContext = this.presenceContext, this.presenceContext = n;
2602
- for (let s = 0; s < Qn.length; s++) {
2603
- const i = Qn[s];
2604
- this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]);
2605
- const o = "on" + i, r = e[o];
2606
- r && (this.propEventSubscriptions[i] = this.on(i, r));
2607
- }
2608
- this.prevMotionValues = ul(this, this.scrapeMotionValuesFromProps(e, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue();
2609
- }
2610
- getProps() {
2611
- return this.props;
2612
- }
2613
- /**
2614
- * Returns the variant definition with a given name.
2615
- */
2616
- getVariant(e) {
2617
- return this.props.variants ? this.props.variants[e] : void 0;
2618
- }
2619
- /**
2620
- * Returns the defined default transition on this component.
2621
- */
2622
- getDefaultTransition() {
2623
- return this.props.transition;
2624
- }
2625
- getTransformPagePoint() {
2626
- return this.props.transformPagePoint;
2627
- }
2628
- getClosestVariantNode() {
2629
- return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0;
2630
- }
2631
- /**
2632
- * Add a child visual element to our set of children.
2633
- */
2634
- addVariantChild(e) {
2635
- const n = this.getClosestVariantNode();
2636
- if (n)
2637
- return n.variantChildren && n.variantChildren.add(e), () => n.variantChildren.delete(e);
2638
- }
2639
- /**
2640
- * Add a motion value and bind it to this visual element.
2641
- */
2642
- addValue(e, n) {
2643
- const s = this.values.get(e);
2644
- n !== s && (s && this.removeValue(e), this.bindToMotionValue(e, n), this.values.set(e, n), this.latestValues[e] = n.get());
2645
- }
2646
- /**
2647
- * Remove a motion value and unbind any active subscriptions.
2648
- */
2649
- removeValue(e) {
2650
- this.values.delete(e);
2651
- const n = this.valueSubscriptions.get(e);
2652
- n && (n(), this.valueSubscriptions.delete(e)), delete this.latestValues[e], this.removeValueFromRenderState(e, this.renderState);
2653
- }
2654
- /**
2655
- * Check whether we have a motion value for this key
2656
- */
2657
- hasValue(e) {
2658
- return this.values.has(e);
2659
- }
2660
- getValue(e, n) {
2661
- if (this.props.values && this.props.values[e])
2662
- return this.props.values[e];
2663
- let s = this.values.get(e);
2664
- return s === void 0 && n !== void 0 && (s = gt(n === null ? void 0 : n, { owner: this }), this.addValue(e, s)), s;
2665
- }
2666
- /**
2667
- * If we're trying to animate to a previously unencountered value,
2668
- * we need to check for it in our state and as a last resort read it
2669
- * directly from the instance (which might have performance implications).
2670
- */
2671
- readValue(e, n) {
2672
- let s = this.latestValues[e] !== void 0 || !this.current ? this.latestValues[e] : this.getBaseTargetFromProps(this.props, e) ?? this.readValueFromInstance(this.current, e, this.options);
2673
- return s != null && (typeof s == "string" && (Ns(s) || Ks(s)) ? s = parseFloat(s) : !Sa(s) && J.test(n) && (s = bi(e, n)), this.setBaseTarget(e, k(s) ? s.get() : s)), k(s) ? s.get() : s;
2674
- }
2675
- /**
2676
- * Set the base target to later animate back to. This is currently
2677
- * only hydrated on creation and when we first read a value.
2678
- */
2679
- setBaseTarget(e, n) {
2680
- this.baseTarget[e] = n;
2681
- }
2682
- /**
2683
- * Find the base target for a value thats been removed from all animation
2684
- * props.
2685
- */
2686
- getBaseTarget(e) {
2687
- const { initial: n } = this.props;
2688
- let s;
2689
- if (typeof n == "string" || typeof n == "object") {
2690
- const o = pn(this.props, n, this.presenceContext?.custom);
2691
- o && (s = o[e]);
2692
- }
2693
- if (n && s !== void 0)
2694
- return s;
2695
- const i = this.getBaseTargetFromProps(this.props, e);
2696
- return i !== void 0 && !k(i) ? i : this.initialValues[e] !== void 0 && s === void 0 ? void 0 : this.baseTarget[e];
2697
- }
2698
- on(e, n) {
2699
- return this.events[e] || (this.events[e] = new _e()), this.events[e].add(n);
2700
- }
2701
- notify(e, ...n) {
2702
- this.events[e] && this.events[e].notify(...n);
2703
- }
2704
- scheduleRenderMicrotask() {
2705
- ln.render(this.render);
2706
- }
2707
- }
2708
- class zi extends cl {
2709
- constructor() {
2710
- super(...arguments), this.KeyframeResolver = ca;
2711
- }
2712
- sortInstanceNodePosition(e, n) {
2713
- return e.compareDocumentPosition(n) & 2 ? 1 : -1;
2714
- }
2715
- getBaseTargetFromProps(e, n) {
2716
- return e.style ? e.style[n] : void 0;
2717
- }
2718
- removeValueFromRenderState(e, { vars: n, style: s }) {
2719
- delete n[e], delete s[e];
2720
- }
2721
- handleChildMotionValue() {
2722
- this.childSubscription && (this.childSubscription(), delete this.childSubscription);
2723
- const { children: e } = this.props;
2724
- k(e) && (this.childSubscription = e.on("change", (n) => {
2725
- this.current && (this.current.textContent = `${n}`);
2726
- }));
2727
- }
2728
- }
2729
- function Yi(t, { style: e, vars: n }, s, i) {
2730
- const o = t.style;
2731
- let r;
2732
- for (r in e)
2733
- o[r] = e[r];
2734
- i?.applyProjectionStyles(o, s);
2735
- for (r in n)
2736
- o.setProperty(r, n[r]);
2737
- }
2738
- function hl(t) {
2739
- return window.getComputedStyle(t);
2740
- }
2741
- class fl extends zi {
2742
- constructor() {
2743
- super(...arguments), this.type = "html", this.renderInstance = Yi;
2744
- }
2745
- readValueFromInstance(e, n) {
2746
- if (bt.has(n))
2747
- return this.projection?.isProjecting ? we(n) : Mo(e, n);
2748
- {
2749
- const s = hl(e), i = (Xe(n) ? s.getPropertyValue(n) : s[n]) || 0;
2750
- return typeof i == "string" ? i.trim() : i;
2751
- }
2752
- }
2753
- measureInstanceViewportBox(e, { transformPagePoint: n }) {
2754
- return _i(e, n);
2755
- }
2756
- build(e, n, s) {
2757
- fn(e, n, s.transformTemplate);
2758
- }
2759
- scrapeMotionValuesFromProps(e, n, s) {
2760
- return gn(e, n, s);
2761
- }
2762
- }
2763
- const Xi = /* @__PURE__ */ new Set([
2764
- "baseFrequency",
2765
- "diffuseConstant",
2766
- "kernelMatrix",
2767
- "kernelUnitLength",
2768
- "keySplines",
2769
- "keyTimes",
2770
- "limitingConeAngle",
2771
- "markerHeight",
2772
- "markerWidth",
2773
- "numOctaves",
2774
- "targetX",
2775
- "targetY",
2776
- "surfaceScale",
2777
- "specularConstant",
2778
- "specularExponent",
2779
- "stdDeviation",
2780
- "tableValues",
2781
- "viewBox",
2782
- "gradientTransform",
2783
- "pathLength",
2784
- "startOffset",
2785
- "textLength",
2786
- "lengthAdjust"
2787
- ]);
2788
- function dl(t, e, n, s) {
2789
- Yi(t, e, void 0, s);
2790
- for (const i in e.attrs)
2791
- t.setAttribute(Xi.has(i) ? i : yn(i), e.attrs[i]);
2792
- }
2793
- class ml extends zi {
2794
- constructor() {
2795
- super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = M;
2796
- }
2797
- getBaseTargetFromProps(e, n) {
2798
- return e[n];
2799
- }
2800
- readValueFromInstance(e, n) {
2801
- if (bt.has(n)) {
2802
- const s = Pi(n);
2803
- return s && s.default || 0;
2804
- }
2805
- return n = Xi.has(n) ? n : yn(n), e.getAttribute(n);
2806
- }
2807
- scrapeMotionValuesFromProps(e, n, s) {
2808
- return ji(e, n, s);
2809
- }
2810
- build(e, n, s) {
2811
- Fi(e, n, this.isSVGTag, s.transformTemplate, s.style);
2812
- }
2813
- renderInstance(e, n, s, i) {
2814
- dl(e, n, s, i);
2815
- }
2816
- mount(e) {
2817
- this.isSVGTag = Ii(e.tagName), super.mount(e);
2818
- }
2819
- }
2820
- const pl = (t, e) => mn(t) ? new ml(e) : new fl(e, {
2821
- allowProjection: t !== Is
2822
- });
2823
- function pt(t, e, n) {
2824
- const s = t.getProps();
2825
- return pn(s, e, n !== void 0 ? n : s.custom, t);
2826
- }
2827
- const Fe = (t) => Array.isArray(t);
2828
- function gl(t, e, n) {
2829
- t.hasValue(e) ? t.getValue(e).set(n) : t.addValue(e, gt(n));
2830
- }
2831
- function yl(t) {
2832
- return Fe(t) ? t[t.length - 1] || 0 : t;
2833
- }
2834
- function vl(t, e) {
2835
- const n = pt(t, e);
2836
- let { transitionEnd: s = {}, transition: i = {}, ...o } = n || {};
2837
- o = { ...o, ...s };
2838
- for (const r in o) {
2839
- const a = yl(o[r]);
2840
- gl(t, r, a);
2841
- }
2842
- }
2843
- function Tl(t) {
2844
- return !!(k(t) && t.add);
2845
- }
2846
- function Be(t, e) {
2847
- const n = t.getValue("willChange");
2848
- if (Tl(n))
2849
- return n.add(e);
2850
- if (!n && X.WillChange) {
2851
- const s = new X.WillChange("auto");
2852
- t.addValue("willChange", s), s.add(e);
2853
- }
2854
- }
2855
- function qi(t) {
2856
- return t.props[Ni];
2857
- }
2858
- const xl = (t) => t !== null;
2859
- function Pl(t, { repeat: e, repeatType: n = "loop" }, s) {
2860
- const i = t.filter(xl), o = e && n !== "loop" && e % 2 === 1 ? 0 : i.length - 1;
2861
- return i[o];
2862
- }
2863
- const bl = {
2864
- type: "spring",
2865
- stiffness: 500,
2866
- damping: 25,
2867
- restSpeed: 10
2868
- }, Sl = (t) => ({
2869
- type: "spring",
2870
- stiffness: 550,
2871
- damping: t === 0 ? 2 * Math.sqrt(550) : 30,
2872
- restSpeed: 10
2873
- }), wl = {
2874
- type: "keyframes",
2875
- duration: 0.8
2876
- }, Al = {
2877
- type: "keyframes",
2878
- ease: [0.25, 0.1, 0.35, 1],
2879
- duration: 0.3
2880
- }, Vl = (t, { keyframes: e }) => e.length > 2 ? wl : bt.has(t) ? t.startsWith("scale") ? Sl(e[1]) : bl : Al;
2881
- function Dl({ when: t, delay: e, delayChildren: n, staggerChildren: s, staggerDirection: i, repeat: o, repeatType: r, repeatDelay: a, from: l, elapsed: c, ...u }) {
2882
- return !!Object.keys(u).length;
2883
- }
2884
- const vn = (t, e, n, s = {}, i, o) => (r) => {
2885
- const a = on(s, t) || {}, l = a.delay || s.delay || 0;
2886
- let { elapsed: c = 0 } = s;
2887
- c = c - /* @__PURE__ */ _(l);
2888
- const u = {
2889
- keyframes: Array.isArray(n) ? n : [null, n],
2890
- ease: "easeOut",
2891
- velocity: e.getVelocity(),
2892
- ...a,
2893
- delay: -c,
2894
- onUpdate: (f) => {
2895
- e.set(f), a.onUpdate && a.onUpdate(f);
2896
- },
2897
- onComplete: () => {
2898
- r(), a.onComplete && a.onComplete();
2899
- },
2900
- name: t,
2901
- motionValue: e,
2902
- element: o ? void 0 : i
2903
- };
2904
- Dl(a) || Object.assign(u, Vl(t, u)), u.duration && (u.duration = /* @__PURE__ */ _(u.duration)), u.repeatDelay && (u.repeatDelay = /* @__PURE__ */ _(u.repeatDelay)), u.from !== void 0 && (u.keyframes[0] = u.from);
2905
- let h = !1;
2906
- if ((u.type === !1 || u.duration === 0 && !u.repeatDelay) && (Ce(u), u.delay === 0 && (h = !0)), (X.instantAnimations || X.skipAnimations) && (h = !0, Ce(u), u.delay = 0), u.allowFlatten = !a.type && !a.ease, h && !o && e.get() !== void 0) {
2907
- const f = Pl(u.keyframes, a);
2908
- if (f !== void 0) {
2909
- A.update(() => {
2910
- u.onUpdate(f), u.onComplete();
2911
- });
2912
- return;
2913
- }
2914
- }
2915
- return a.isSync ? new sn(u) : new Zo(u);
2916
- };
2917
- function Ml({ protectedKeys: t, needsAnimating: e }, n) {
2918
- const s = t.hasOwnProperty(n) && e[n] !== !0;
2919
- return e[n] = !1, s;
2920
- }
2921
- function Zi(t, e, { delay: n = 0, transitionOverride: s, type: i } = {}) {
2922
- let { transition: o = t.getDefaultTransition(), transitionEnd: r, ...a } = e;
2923
- s && (o = s);
2924
- const l = [], c = i && t.animationState && t.animationState.getState()[i];
2925
- for (const u in a) {
2926
- const h = t.getValue(u, t.latestValues[u] ?? null), f = a[u];
2927
- if (f === void 0 || c && Ml(c, u))
2928
- continue;
2929
- const d = {
2930
- delay: n,
2931
- ...on(o || {}, u)
2932
- }, m = h.get();
2933
- if (m !== void 0 && !h.isAnimating && !Array.isArray(f) && f === m && !d.velocity)
2934
- continue;
2935
- let v = !1;
2936
- if (window.MotionHandoffAnimation) {
2937
- const p = qi(t);
2938
- if (p) {
2939
- const T = window.MotionHandoffAnimation(p, u, A);
2940
- T !== null && (d.startTime = T, v = !0);
2941
- }
2942
- }
2943
- Be(t, u), h.start(vn(u, h, f, t.shouldReduceMotion && vi.has(u) ? { type: !1 } : d, t, v));
2944
- const y = h.animation;
2945
- y && l.push(y);
2946
- }
2947
- return r && Promise.all(l).then(() => {
2948
- A.update(() => {
2949
- r && vl(t, r);
2950
- });
2951
- }), l;
2952
- }
2953
- function Ji(t, e, n, s = 0, i = 1) {
2954
- const o = Array.from(t).sort((c, u) => c.sortNodePosition(u)).indexOf(e), r = t.size, a = (r - 1) * s;
2955
- return typeof n == "function" ? n(o, r) : i === 1 ? o * s : a - o * s;
2956
- }
2957
- function Ie(t, e, n = {}) {
2958
- const s = pt(t, e, n.type === "exit" ? t.presenceContext?.custom : void 0);
2959
- let { transition: i = t.getDefaultTransition() || {} } = s || {};
2960
- n.transitionOverride && (i = n.transitionOverride);
2961
- const o = s ? () => Promise.all(Zi(t, s, n)) : () => Promise.resolve(), r = t.variantChildren && t.variantChildren.size ? (l = 0) => {
2962
- const { delayChildren: c = 0, staggerChildren: u, staggerDirection: h } = i;
2963
- return Cl(t, e, l, c, u, h, n);
2964
- } : () => Promise.resolve(), { when: a } = i;
2965
- if (a) {
2966
- const [l, c] = a === "beforeChildren" ? [o, r] : [r, o];
2967
- return l().then(() => c());
2968
- } else
2969
- return Promise.all([o(), r(n.delay)]);
2970
- }
2971
- function Cl(t, e, n = 0, s = 0, i = 0, o = 1, r) {
2972
- const a = [];
2973
- for (const l of t.variantChildren)
2974
- l.notify("AnimationStart", e), a.push(Ie(l, e, {
2975
- ...r,
2976
- delay: n + (typeof s == "function" ? 0 : s) + Ji(t.variantChildren, l, s, i, o)
2977
- }).then(() => l.notify("AnimationComplete", e)));
2978
- return Promise.all(a);
2979
- }
2980
- function El(t, e, n = {}) {
2981
- t.notify("AnimationStart", e);
2982
- let s;
2983
- if (Array.isArray(e)) {
2984
- const i = e.map((o) => Ie(t, o, n));
2985
- s = Promise.all(i);
2986
- } else if (typeof e == "string")
2987
- s = Ie(t, e, n);
2988
- else {
2989
- const i = typeof e == "function" ? pt(t, e, n.custom) : e;
2990
- s = Promise.all(Zi(t, i, n));
2991
- }
2992
- return s.then(() => {
2993
- t.notify("AnimationComplete", e);
2994
- });
2995
- }
2996
- function Qi(t, e) {
2997
- if (!Array.isArray(e))
2998
- return !1;
2999
- const n = e.length;
3000
- if (n !== t.length)
3001
- return !1;
3002
- for (let s = 0; s < n; s++)
3003
- if (e[s] !== t[s])
3004
- return !1;
3005
- return !0;
3006
- }
3007
- const Rl = hn.length;
3008
- function tr(t) {
3009
- if (!t)
3010
- return;
3011
- if (!t.isControllingVariants) {
3012
- const n = t.parent ? tr(t.parent) || {} : {};
3013
- return t.props.initial !== void 0 && (n.initial = t.props.initial), n;
3014
- }
3015
- const e = {};
3016
- for (let n = 0; n < Rl; n++) {
3017
- const s = hn[n], i = t.props[s];
3018
- (Lt(i) || i === !1) && (e[s] = i);
3019
- }
3020
- return e;
3021
- }
3022
- const Ll = [...cn].reverse(), kl = cn.length;
3023
- function Fl(t) {
3024
- return (e) => Promise.all(e.map(({ animation: n, options: s }) => El(t, n, s)));
3025
- }
3026
- function Bl(t) {
3027
- let e = Fl(t), n = ts(), s = !0;
3028
- const i = (l) => (c, u) => {
3029
- const h = pt(t, u, l === "exit" ? t.presenceContext?.custom : void 0);
3030
- if (h) {
3031
- const { transition: f, transitionEnd: d, ...m } = h;
3032
- c = { ...c, ...m, ...d };
3033
- }
3034
- return c;
3035
- };
3036
- function o(l) {
3037
- e = l(t);
3038
- }
3039
- function r(l) {
3040
- const { props: c } = t, u = tr(t.parent) || {}, h = [], f = /* @__PURE__ */ new Set();
3041
- let d = {}, m = 1 / 0;
3042
- for (let y = 0; y < kl; y++) {
3043
- const p = Ll[y], T = n[p], g = c[p] !== void 0 ? c[p] : u[p], S = Lt(g), P = p === l ? T.isActive : null;
3044
- P === !1 && (m = y);
3045
- let w = g === u[p] && g !== c[p] && S;
3046
- if (w && s && t.manuallyAnimateOnMount && (w = !1), T.protectedKeys = { ...d }, // If it isn't active and hasn't *just* been set as inactive
3047
- !T.isActive && P === null || // If we didn't and don't have any defined prop for this animation type
3048
- !g && !T.prevProp || // Or if the prop doesn't define an animation
3049
- te(g) || typeof g == "boolean")
3050
- continue;
3051
- const E = Il(T.prevProp, g);
3052
- let b = E || // If we're making this variant active, we want to always make it active
3053
- p === l && T.isActive && !w && S || // If we removed a higher-priority variant (i is in reverse order)
3054
- y > m && S, B = !1;
3055
- const j = Array.isArray(g) ? g : [g];
3056
- let at = j.reduce(i(p), {});
3057
- P === !1 && (at = {});
3058
- const { prevResolvedValues: Tn = {} } = T, pr = {
3059
- ...Tn,
3060
- ...at
3061
- }, xn = (R) => {
3062
- b = !0, f.has(R) && (B = !0, f.delete(R)), T.needsAnimating[R] = !0;
3063
- const N = t.getValue(R);
3064
- N && (N.liveStyle = !1);
3065
- };
3066
- for (const R in pr) {
3067
- const N = at[R], tt = Tn[R];
3068
- if (d.hasOwnProperty(R))
3069
- continue;
3070
- let lt = !1;
3071
- Fe(N) && Fe(tt) ? lt = !Qi(N, tt) : lt = N !== tt, lt ? N != null ? xn(R) : f.add(R) : N !== void 0 && f.has(R) ? xn(R) : T.protectedKeys[R] = !0;
3072
- }
3073
- T.prevProp = g, T.prevResolvedValues = at, T.isActive && (d = { ...d, ...at }), s && t.blockInitialAnimation && (b = !1);
3074
- const Pn = w && E;
3075
- b && (!Pn || B) && h.push(...j.map((R) => {
3076
- const N = { type: p };
3077
- if (typeof R == "string" && s && !Pn && t.manuallyAnimateOnMount && t.parent) {
3078
- const { parent: tt } = t, lt = pt(tt, R);
3079
- if (tt.enteringChildren && lt) {
3080
- const { delayChildren: gr } = lt.transition || {};
3081
- N.delay = Ji(tt.enteringChildren, t, gr);
3082
- }
3083
- }
3084
- return {
3085
- animation: R,
3086
- options: N
3087
- };
3088
- }));
3089
- }
3090
- if (f.size) {
3091
- const y = {};
3092
- if (typeof c.initial != "boolean") {
3093
- const p = pt(t, Array.isArray(c.initial) ? c.initial[0] : c.initial);
3094
- p && p.transition && (y.transition = p.transition);
3095
- }
3096
- f.forEach((p) => {
3097
- const T = t.getBaseTarget(p), g = t.getValue(p);
3098
- g && (g.liveStyle = !0), y[p] = T ?? null;
3099
- }), h.push({ animation: y });
3100
- }
3101
- let v = !!h.length;
3102
- return s && (c.initial === !1 || c.initial === c.animate) && !t.manuallyAnimateOnMount && (v = !1), s = !1, v ? e(h) : Promise.resolve();
3103
- }
3104
- function a(l, c) {
3105
- if (n[l].isActive === c)
3106
- return Promise.resolve();
3107
- t.variantChildren?.forEach((h) => h.animationState?.setActive(l, c)), n[l].isActive = c;
3108
- const u = r(l);
3109
- for (const h in n)
3110
- n[h].protectedKeys = {};
3111
- return u;
3112
- }
3113
- return {
3114
- animateChanges: r,
3115
- setActive: a,
3116
- setAnimateFunction: o,
3117
- getState: () => n,
3118
- reset: () => {
3119
- n = ts();
3120
- }
3121
- };
3122
- }
3123
- function Il(t, e) {
3124
- return typeof e == "string" ? e !== t : Array.isArray(e) ? !Qi(e, t) : !1;
3125
- }
3126
- function et(t = !1) {
3127
- return {
3128
- isActive: t,
3129
- protectedKeys: {},
3130
- needsAnimating: {},
3131
- prevResolvedValues: {}
3132
- };
3133
- }
3134
- function ts() {
3135
- return {
3136
- animate: et(!0),
3137
- whileInView: et(),
3138
- whileHover: et(),
3139
- whileTap: et(),
3140
- whileDrag: et(),
3141
- whileFocus: et(),
3142
- exit: et()
3143
- };
3144
- }
3145
- class Q {
3146
- constructor(e) {
3147
- this.isMounted = !1, this.node = e;
3148
- }
3149
- update() {
3150
- }
3151
- }
3152
- class Ol extends Q {
3153
- /**
3154
- * We dynamically generate the AnimationState manager as it contains a reference
3155
- * to the underlying animation library. We only want to load that if we load this,
3156
- * so people can optionally code split it out using the `m` component.
3157
- */
3158
- constructor(e) {
3159
- super(e), e.animationState || (e.animationState = Bl(e));
3160
- }
3161
- updateAnimationControlsSubscription() {
3162
- const { animate: e } = this.node.getProps();
3163
- te(e) && (this.unmountControls = e.subscribe(this.node));
3164
- }
3165
- /**
3166
- * Subscribe any provided AnimationControls to the component's VisualElement
3167
- */
3168
- mount() {
3169
- this.updateAnimationControlsSubscription();
3170
- }
3171
- update() {
3172
- const { animate: e } = this.node.getProps(), { animate: n } = this.node.prevProps || {};
3173
- e !== n && this.updateAnimationControlsSubscription();
3174
- }
3175
- unmount() {
3176
- this.node.animationState.reset(), this.unmountControls?.();
3177
- }
3178
- }
3179
- let jl = 0;
3180
- class Nl extends Q {
3181
- constructor() {
3182
- super(...arguments), this.id = jl++;
3183
- }
3184
- update() {
3185
- if (!this.node.presenceContext)
3186
- return;
3187
- const { isPresent: e, onExitComplete: n } = this.node.presenceContext, { isPresent: s } = this.node.prevPresenceContext || {};
3188
- if (!this.node.animationState || e === s)
3189
- return;
3190
- const i = this.node.animationState.setActive("exit", !e);
3191
- n && !e && i.then(() => {
3192
- n(this.id);
3193
- });
3194
- }
3195
- mount() {
3196
- const { register: e, onExitComplete: n } = this.node.presenceContext || {};
3197
- n && n(this.id), e && (this.unmount = e(this.id));
3198
- }
3199
- unmount() {
3200
- }
3201
- }
3202
- const Ul = {
3203
- animation: {
3204
- Feature: Ol
3205
- },
3206
- exit: {
3207
- Feature: Nl
3208
- }
3209
- };
3210
- function Ft(t, e, n, s = { passive: !0 }) {
3211
- return t.addEventListener(e, n, s), () => t.removeEventListener(e, n);
3212
- }
3213
- function jt(t) {
3214
- return {
3215
- point: {
3216
- x: t.pageX,
3217
- y: t.pageY
3218
- }
3219
- };
3220
- }
3221
- const Kl = (t) => (e) => un(e) && t(e, jt(e));
3222
- function Vt(t, e, n, s) {
3223
- return Ft(t, e, Kl(n), s);
3224
- }
3225
- const er = 1e-4, Wl = 1 - er, $l = 1 + er, nr = 0.01, Gl = 0 - nr, _l = 0 + nr;
3226
- function F(t) {
3227
- return t.max - t.min;
3228
- }
3229
- function Hl(t, e, n) {
3230
- return Math.abs(t - e) <= n;
3231
- }
3232
- function es(t, e, n, s = 0.5) {
3233
- t.origin = s, t.originPoint = D(e.min, e.max, t.origin), t.scale = F(n) / F(e), t.translate = D(n.min, n.max, t.origin) - t.originPoint, (t.scale >= Wl && t.scale <= $l || isNaN(t.scale)) && (t.scale = 1), (t.translate >= Gl && t.translate <= _l || isNaN(t.translate)) && (t.translate = 0);
3234
- }
3235
- function Dt(t, e, n, s) {
3236
- es(t.x, e.x, n.x, s ? s.originX : void 0), es(t.y, e.y, n.y, s ? s.originY : void 0);
3237
- }
3238
- function ns(t, e, n) {
3239
- t.min = n.min + e.min, t.max = t.min + F(e);
3240
- }
3241
- function zl(t, e, n) {
3242
- ns(t.x, e.x, n.x), ns(t.y, e.y, n.y);
3243
- }
3244
- function ss(t, e, n) {
3245
- t.min = e.min - n.min, t.max = t.min + F(e);
3246
- }
3247
- function Mt(t, e, n) {
3248
- ss(t.x, e.x, n.x), ss(t.y, e.y, n.y);
3249
- }
3250
- function K(t) {
3251
- return [t("x"), t("y")];
3252
- }
3253
- const sr = ({ current: t }) => t ? t.ownerDocument.defaultView : null, is = (t, e) => Math.abs(t - e);
3254
- function Yl(t, e) {
3255
- const n = is(t.x, e.x), s = is(t.y, e.y);
3256
- return Math.sqrt(n ** 2 + s ** 2);
3257
- }
3258
- class ir {
3259
- constructor(e, n, { transformPagePoint: s, contextWindow: i = window, dragSnapToOrigin: o = !1, distanceThreshold: r = 3 } = {}) {
3260
- if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => {
3261
- if (!(this.lastMoveEvent && this.lastMoveEventInfo))
3262
- return;
3263
- const f = he(this.lastMoveEventInfo, this.history), d = this.startEvent !== null, m = Yl(f.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
3264
- if (!d && !m)
3265
- return;
3266
- const { point: v } = f, { timestamp: y } = L;
3267
- this.history.push({ ...v, timestamp: y });
3268
- const { onStart: p, onMove: T } = this.handlers;
3269
- d || (p && p(this.lastMoveEvent, f), this.startEvent = this.lastMoveEvent), T && T(this.lastMoveEvent, f);
3270
- }, this.handlePointerMove = (f, d) => {
3271
- this.lastMoveEvent = f, this.lastMoveEventInfo = ce(d, this.transformPagePoint), A.update(this.updatePoint, !0);
3272
- }, this.handlePointerUp = (f, d) => {
3273
- this.end();
3274
- const { onEnd: m, onSessionEnd: v, resumeAnimation: y } = this.handlers;
3275
- if (this.dragSnapToOrigin && y && y(), !(this.lastMoveEvent && this.lastMoveEventInfo))
3276
- return;
3277
- const p = he(f.type === "pointercancel" ? this.lastMoveEventInfo : ce(d, this.transformPagePoint), this.history);
3278
- this.startEvent && m && m(f, p), v && v(f, p);
3279
- }, !un(e))
3280
- return;
3281
- this.dragSnapToOrigin = o, this.handlers = n, this.transformPagePoint = s, this.distanceThreshold = r, this.contextWindow = i || window;
3282
- const a = jt(e), l = ce(a, this.transformPagePoint), { point: c } = l, { timestamp: u } = L;
3283
- this.history = [{ ...c, timestamp: u }];
3284
- const { onSessionStart: h } = n;
3285
- h && h(e, he(l, this.history)), this.removeListeners = Bt(Vt(this.contextWindow, "pointermove", this.handlePointerMove), Vt(this.contextWindow, "pointerup", this.handlePointerUp), Vt(this.contextWindow, "pointercancel", this.handlePointerUp));
3286
- }
3287
- updateHandlers(e) {
3288
- this.handlers = e;
3289
- }
3290
- end() {
3291
- this.removeListeners && this.removeListeners(), Z(this.updatePoint);
3292
- }
3293
- }
3294
- function ce(t, e) {
3295
- return e ? { point: e(t.point) } : t;
3296
- }
3297
- function rs(t, e) {
3298
- return { x: t.x - e.x, y: t.y - e.y };
3299
- }
3300
- function he({ point: t }, e) {
3301
- return {
3302
- point: t,
3303
- delta: rs(t, rr(e)),
3304
- offset: rs(t, Xl(e)),
3305
- velocity: ql(e, 0.1)
3306
- };
3307
- }
3308
- function Xl(t) {
3309
- return t[0];
3310
- }
3311
- function rr(t) {
3312
- return t[t.length - 1];
3313
- }
3314
- function ql(t, e) {
3315
- if (t.length < 2)
3316
- return { x: 0, y: 0 };
3317
- let n = t.length - 1, s = null;
3318
- const i = rr(t);
3319
- for (; n >= 0 && (s = t[n], !(i.timestamp - s.timestamp > /* @__PURE__ */ _(e))); )
3320
- n--;
3321
- if (!s)
3322
- return { x: 0, y: 0 };
3323
- const o = /* @__PURE__ */ W(i.timestamp - s.timestamp);
3324
- if (o === 0)
3325
- return { x: 0, y: 0 };
3326
- const r = {
3327
- x: (i.x - s.x) / o,
3328
- y: (i.y - s.y) / o
3329
- };
3330
- return r.x === 1 / 0 && (r.x = 0), r.y === 1 / 0 && (r.y = 0), r;
3331
- }
3332
- function Zl(t, { min: e, max: n }, s) {
3333
- return e !== void 0 && t < e ? t = s ? D(e, t, s.min) : Math.max(t, e) : n !== void 0 && t > n && (t = s ? D(n, t, s.max) : Math.min(t, n)), t;
3334
- }
3335
- function os(t, e, n) {
3336
- return {
3337
- min: e !== void 0 ? t.min + e : void 0,
3338
- max: n !== void 0 ? t.max + n - (t.max - t.min) : void 0
3339
- };
3340
- }
3341
- function Jl(t, { top: e, left: n, bottom: s, right: i }) {
3342
- return {
3343
- x: os(t.x, n, i),
3344
- y: os(t.y, e, s)
3345
- };
3346
- }
3347
- function as(t, e) {
3348
- let n = e.min - t.min, s = e.max - t.max;
3349
- return e.max - e.min < t.max - t.min && ([n, s] = [s, n]), { min: n, max: s };
3350
- }
3351
- function Ql(t, e) {
3352
- return {
3353
- x: as(t.x, e.x),
3354
- y: as(t.y, e.y)
3355
- };
3356
- }
3357
- function tu(t, e) {
3358
- let n = 0.5;
3359
- const s = F(t), i = F(e);
3360
- return i > s ? n = /* @__PURE__ */ Ct(e.min, e.max - s, t.min) : s > i && (n = /* @__PURE__ */ Ct(t.min, t.max - i, e.min)), z(0, 1, n);
3361
- }
3362
- function eu(t, e) {
3363
- const n = {};
3364
- return e.min !== void 0 && (n.min = e.min - t.min), e.max !== void 0 && (n.max = e.max - t.min), n;
3365
- }
3366
- const Oe = 0.35;
3367
- function nu(t = Oe) {
3368
- return t === !1 ? t = 0 : t === !0 && (t = Oe), {
3369
- x: ls(t, "left", "right"),
3370
- y: ls(t, "top", "bottom")
3371
- };
3372
- }
3373
- function ls(t, e, n) {
3374
- return {
3375
- min: us(t, e),
3376
- max: us(t, n)
3377
- };
3378
- }
3379
- function us(t, e) {
3380
- return typeof t == "number" ? t : t[e] || 0;
3381
- }
3382
- const su = /* @__PURE__ */ new WeakMap();
3383
- class iu {
3384
- constructor(e) {
3385
- this.openDragLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = M(), this.latestPointerEvent = null, this.latestPanInfo = null, this.visualElement = e;
3386
- }
3387
- start(e, { snapToCursor: n = !1, distanceThreshold: s } = {}) {
3388
- const { presenceContext: i } = this.visualElement;
3389
- if (i && i.isPresent === !1)
3390
- return;
3391
- const o = (h) => {
3392
- const { dragSnapToOrigin: f } = this.getProps();
3393
- f ? this.pauseAnimation() : this.stopAnimation(), n && this.snapToCursor(jt(h).point);
3394
- }, r = (h, f) => {
3395
- const { drag: d, dragPropagation: m, onDragStart: v } = this.getProps();
3396
- if (d && !m && (this.openDragLock && this.openDragLock(), this.openDragLock = pa(d), !this.openDragLock))
3397
- return;
3398
- this.latestPointerEvent = h, this.latestPanInfo = f, this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), K((p) => {
3399
- let T = this.getAxisMotionValue(p).get() || 0;
3400
- if (H.test(T)) {
3401
- const { projection: g } = this.visualElement;
3402
- if (g && g.layout) {
3403
- const S = g.layout.layoutBox[p];
3404
- S && (T = F(S) * (parseFloat(T) / 100));
3405
- }
3406
- }
3407
- this.originPoint[p] = T;
3408
- }), v && A.postRender(() => v(h, f)), Be(this.visualElement, "transform");
3409
- const { animationState: y } = this.visualElement;
3410
- y && y.setActive("whileDrag", !0);
3411
- }, a = (h, f) => {
3412
- this.latestPointerEvent = h, this.latestPanInfo = f;
3413
- const { dragPropagation: d, dragDirectionLock: m, onDirectionLock: v, onDrag: y } = this.getProps();
3414
- if (!d && !this.openDragLock)
3415
- return;
3416
- const { offset: p } = f;
3417
- if (m && this.currentDirection === null) {
3418
- this.currentDirection = ru(p), this.currentDirection !== null && v && v(this.currentDirection);
3419
- return;
3420
- }
3421
- this.updateAxis("x", f.point, p), this.updateAxis("y", f.point, p), this.visualElement.render(), y && y(h, f);
3422
- }, l = (h, f) => {
3423
- this.latestPointerEvent = h, this.latestPanInfo = f, this.stop(h, f), this.latestPointerEvent = null, this.latestPanInfo = null;
3424
- }, c = () => K((h) => this.getAnimationState(h) === "paused" && this.getAxisMotionValue(h).animation?.play()), { dragSnapToOrigin: u } = this.getProps();
3425
- this.panSession = new ir(e, {
3426
- onSessionStart: o,
3427
- onStart: r,
3428
- onMove: a,
3429
- onSessionEnd: l,
3430
- resumeAnimation: c
3431
- }, {
3432
- transformPagePoint: this.visualElement.getTransformPagePoint(),
3433
- dragSnapToOrigin: u,
3434
- distanceThreshold: s,
3435
- contextWindow: sr(this.visualElement)
3436
- });
3437
- }
3438
- /**
3439
- * @internal
3440
- */
3441
- stop(e, n) {
3442
- const s = e || this.latestPointerEvent, i = n || this.latestPanInfo, o = this.isDragging;
3443
- if (this.cancel(), !o || !i || !s)
3444
- return;
3445
- const { velocity: r } = i;
3446
- this.startAnimation(r);
3447
- const { onDragEnd: a } = this.getProps();
3448
- a && A.postRender(() => a(s, i));
3449
- }
3450
- /**
3451
- * @internal
3452
- */
3453
- cancel() {
3454
- this.isDragging = !1;
3455
- const { projection: e, animationState: n } = this.visualElement;
3456
- e && (e.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0;
3457
- const { dragPropagation: s } = this.getProps();
3458
- !s && this.openDragLock && (this.openDragLock(), this.openDragLock = null), n && n.setActive("whileDrag", !1);
3459
- }
3460
- updateAxis(e, n, s) {
3461
- const { drag: i } = this.getProps();
3462
- if (!s || !Kt(e, i, this.currentDirection))
3463
- return;
3464
- const o = this.getAxisMotionValue(e);
3465
- let r = this.originPoint[e] + s[e];
3466
- this.constraints && this.constraints[e] && (r = Zl(r, this.constraints[e], this.elastic[e])), o.set(r);
3467
- }
3468
- resolveConstraints() {
3469
- const { dragConstraints: e, dragElastic: n } = this.getProps(), s = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : this.visualElement.projection?.layout, i = this.constraints;
3470
- e && ht(e) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : e && s ? this.constraints = Jl(s.layoutBox, e) : this.constraints = !1, this.elastic = nu(n), i !== this.constraints && s && this.constraints && !this.hasMutatedConstraints && K((o) => {
3471
- this.constraints !== !1 && this.getAxisMotionValue(o) && (this.constraints[o] = eu(s.layoutBox[o], this.constraints[o]));
3472
- });
3473
- }
3474
- resolveRefConstraints() {
3475
- const { dragConstraints: e, onMeasureDragConstraints: n } = this.getProps();
3476
- if (!e || !ht(e))
3477
- return !1;
3478
- const s = e.current;
3479
- Y(s !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.", "drag-constraints-ref");
3480
- const { projection: i } = this.visualElement;
3481
- if (!i || !i.layout)
3482
- return !1;
3483
- const o = ol(s, i.root, this.visualElement.getTransformPagePoint());
3484
- let r = Ql(i.layout.layoutBox, o);
3485
- if (n) {
3486
- const a = n(sl(r));
3487
- this.hasMutatedConstraints = !!a, a && (r = Wi(a));
3488
- }
3489
- return r;
3490
- }
3491
- startAnimation(e) {
3492
- const { drag: n, dragMomentum: s, dragElastic: i, dragTransition: o, dragSnapToOrigin: r, onDragTransitionEnd: a } = this.getProps(), l = this.constraints || {}, c = K((u) => {
3493
- if (!Kt(u, n, this.currentDirection))
3494
- return;
3495
- let h = l && l[u] || {};
3496
- r && (h = { min: 0, max: 0 });
3497
- const f = i ? 200 : 1e6, d = i ? 40 : 1e7, m = {
3498
- type: "inertia",
3499
- velocity: s ? e[u] : 0,
3500
- bounceStiffness: f,
3501
- bounceDamping: d,
3502
- timeConstant: 750,
3503
- restDelta: 1,
3504
- restSpeed: 10,
3505
- ...o,
3506
- ...h
3507
- };
3508
- return this.startAxisValueAnimation(u, m);
3509
- });
3510
- return Promise.all(c).then(a);
3511
- }
3512
- startAxisValueAnimation(e, n) {
3513
- const s = this.getAxisMotionValue(e);
3514
- return Be(this.visualElement, e), s.start(vn(e, s, 0, n, this.visualElement, !1));
3515
- }
3516
- stopAnimation() {
3517
- K((e) => this.getAxisMotionValue(e).stop());
3518
- }
3519
- pauseAnimation() {
3520
- K((e) => this.getAxisMotionValue(e).animation?.pause());
3521
- }
3522
- getAnimationState(e) {
3523
- return this.getAxisMotionValue(e).animation?.state;
3524
- }
3525
- /**
3526
- * Drag works differently depending on which props are provided.
3527
- *
3528
- * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
3529
- * - Otherwise, we apply the delta to the x/y motion values.
3530
- */
3531
- getAxisMotionValue(e) {
3532
- const n = `_drag${e.toUpperCase()}`, s = this.visualElement.getProps(), i = s[n];
3533
- return i || this.visualElement.getValue(e, (s.initial ? s.initial[e] : void 0) || 0);
3534
- }
3535
- snapToCursor(e) {
3536
- K((n) => {
3537
- const { drag: s } = this.getProps();
3538
- if (!Kt(n, s, this.currentDirection))
3539
- return;
3540
- const { projection: i } = this.visualElement, o = this.getAxisMotionValue(n);
3541
- if (i && i.layout) {
3542
- const { min: r, max: a } = i.layout.layoutBox[n];
3543
- o.set(e[n] - D(r, a, 0.5));
3544
- }
3545
- });
3546
- }
3547
- /**
3548
- * When the viewport resizes we want to check if the measured constraints
3549
- * have changed and, if so, reposition the element within those new constraints
3550
- * relative to where it was before the resize.
3551
- */
3552
- scalePositionWithinConstraints() {
3553
- if (!this.visualElement.current)
3554
- return;
3555
- const { drag: e, dragConstraints: n } = this.getProps(), { projection: s } = this.visualElement;
3556
- if (!ht(n) || !s || !this.constraints)
3557
- return;
3558
- this.stopAnimation();
3559
- const i = { x: 0, y: 0 };
3560
- K((r) => {
3561
- const a = this.getAxisMotionValue(r);
3562
- if (a && this.constraints !== !1) {
3563
- const l = a.get();
3564
- i[r] = tu({ min: l, max: l }, this.constraints[r]);
3565
- }
3566
- });
3567
- const { transformTemplate: o } = this.visualElement.getProps();
3568
- this.visualElement.current.style.transform = o ? o({}, "") : "none", s.root && s.root.updateScroll(), s.updateLayout(), this.resolveConstraints(), K((r) => {
3569
- if (!Kt(r, e, null))
3570
- return;
3571
- const a = this.getAxisMotionValue(r), { min: l, max: c } = this.constraints[r];
3572
- a.set(D(l, c, i[r]));
3573
- });
3574
- }
3575
- addListeners() {
3576
- if (!this.visualElement.current)
3577
- return;
3578
- su.set(this.visualElement, this);
3579
- const e = this.visualElement.current, n = Vt(e, "pointerdown", (l) => {
3580
- const { drag: c, dragListener: u = !0 } = this.getProps();
3581
- c && u && this.start(l);
3582
- }), s = () => {
3583
- const { dragConstraints: l } = this.getProps();
3584
- ht(l) && l.current && (this.constraints = this.resolveRefConstraints());
3585
- }, { projection: i } = this.visualElement, o = i.addEventListener("measure", s);
3586
- i && !i.layout && (i.root && i.root.updateScroll(), i.updateLayout()), A.read(s);
3587
- const r = Ft(window, "resize", () => this.scalePositionWithinConstraints()), a = i.addEventListener("didUpdate", (({ delta: l, hasLayoutChanged: c }) => {
3588
- this.isDragging && c && (K((u) => {
3589
- const h = this.getAxisMotionValue(u);
3590
- h && (this.originPoint[u] += l[u].translate, h.set(h.get() + l[u].translate));
3591
- }), this.visualElement.render());
3592
- }));
3593
- return () => {
3594
- r(), n(), o(), a && a();
3595
- };
3596
- }
3597
- getProps() {
3598
- const e = this.visualElement.getProps(), { drag: n = !1, dragDirectionLock: s = !1, dragPropagation: i = !1, dragConstraints: o = !1, dragElastic: r = Oe, dragMomentum: a = !0 } = e;
3599
- return {
3600
- ...e,
3601
- drag: n,
3602
- dragDirectionLock: s,
3603
- dragPropagation: i,
3604
- dragConstraints: o,
3605
- dragElastic: r,
3606
- dragMomentum: a
3607
- };
3608
- }
3609
- }
3610
- function Kt(t, e, n) {
3611
- return (e === !0 || e === t) && (n === null || n === t);
3612
- }
3613
- function ru(t, e = 10) {
3614
- let n = null;
3615
- return Math.abs(t.y) > e ? n = "y" : Math.abs(t.x) > e && (n = "x"), n;
3616
- }
3617
- class ou extends Q {
3618
- constructor(e) {
3619
- super(e), this.removeGroupControls = $, this.removeListeners = $, this.controls = new iu(e);
3620
- }
3621
- mount() {
3622
- const { dragControls: e } = this.node.getProps();
3623
- e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || $;
3624
- }
3625
- unmount() {
3626
- this.removeGroupControls(), this.removeListeners();
3627
- }
3628
- }
3629
- const cs = (t) => (e, n) => {
3630
- t && A.postRender(() => t(e, n));
3631
- };
3632
- class au extends Q {
3633
- constructor() {
3634
- super(...arguments), this.removePointerDownListener = $;
3635
- }
3636
- onPointerDown(e) {
3637
- this.session = new ir(e, this.createPanHandlers(), {
3638
- transformPagePoint: this.node.getTransformPagePoint(),
3639
- contextWindow: sr(this.node)
3640
- });
3641
- }
3642
- createPanHandlers() {
3643
- const { onPanSessionStart: e, onPanStart: n, onPan: s, onPanEnd: i } = this.node.getProps();
3644
- return {
3645
- onSessionStart: cs(e),
3646
- onStart: cs(n),
3647
- onMove: s,
3648
- onEnd: (o, r) => {
3649
- delete this.session, i && A.postRender(() => i(o, r));
3650
- }
3651
- };
3652
- }
3653
- mount() {
3654
- this.removePointerDownListener = Vt(this.node.current, "pointerdown", (e) => this.onPointerDown(e));
3655
- }
3656
- update() {
3657
- this.session && this.session.updateHandlers(this.createPanHandlers());
3658
- }
3659
- unmount() {
3660
- this.removePointerDownListener(), this.session && this.session.end();
3661
- }
3662
- }
3663
- const Ht = {
3664
- /**
3665
- * Global flag as to whether the tree has animated since the last time
3666
- * we resized the window
3667
- */
3668
- hasAnimatedSinceResize: !0,
3669
- /**
3670
- * We set this to true once, on the first update. Any nodes added to the tree beyond that
3671
- * update will be given a `data-projection-id` attribute.
3672
- */
3673
- hasEverUpdated: !1
3674
- };
3675
- function hs(t, e) {
3676
- return e.max === e.min ? 0 : t / (e.max - e.min) * 100;
3677
- }
3678
- const St = {
3679
- correct: (t, e) => {
3680
- if (!e.target)
3681
- return t;
3682
- if (typeof t == "string")
3683
- if (x.test(t))
3684
- t = parseFloat(t);
3685
- else
3686
- return t;
3687
- const n = hs(t, e.target.x), s = hs(t, e.target.y);
3688
- return `${n}% ${s}%`;
3689
- }
3690
- }, lu = {
3691
- correct: (t, { treeScale: e, projectionDelta: n }) => {
3692
- const s = t, i = J.parse(t);
3693
- if (i.length > 5)
3694
- return s;
3695
- const o = J.createTransformer(t), r = typeof i[0] != "number" ? 1 : 0, a = n.x.scale * e.x, l = n.y.scale * e.y;
3696
- i[0 + r] /= a, i[1 + r] /= l;
3697
- const c = D(a, l, 0.5);
3698
- return typeof i[2 + r] == "number" && (i[2 + r] /= c), typeof i[3 + r] == "number" && (i[3 + r] /= c), o(i);
3699
- }
3700
- };
3701
- let fe = !1;
3702
- class uu extends br {
3703
- /**
3704
- * This only mounts projection nodes for components that
3705
- * need measuring, we might want to do it for all components
3706
- * in order to incorporate transforms
3707
- */
3708
- componentDidMount() {
3709
- const { visualElement: e, layoutGroup: n, switchLayoutGroup: s, layoutId: i } = this.props, { projection: o } = e;
3710
- Ra(cu), o && (n.group && n.group.add(o), s && s.register && i && s.register(o), fe && o.root.didUpdate(), o.addEventListener("animationComplete", () => {
3711
- this.safeToRemove();
3712
- }), o.setOptions({
3713
- ...o.options,
3714
- onExitComplete: () => this.safeToRemove()
3715
- })), Ht.hasEverUpdated = !0;
3716
- }
3717
- getSnapshotBeforeUpdate(e) {
3718
- const { layoutDependency: n, visualElement: s, drag: i, isPresent: o } = this.props, { projection: r } = s;
3719
- return r && (r.isPresent = o, fe = !0, i || e.layoutDependency !== n || n === void 0 || e.isPresent !== o ? r.willUpdate() : this.safeToRemove(), e.isPresent !== o && (o ? r.promote() : r.relegate() || A.postRender(() => {
3720
- const a = r.getStack();
3721
- (!a || !a.members.length) && this.safeToRemove();
3722
- }))), null;
3723
- }
3724
- componentDidUpdate() {
3725
- const { projection: e } = this.props.visualElement;
3726
- e && (e.root.didUpdate(), ln.postRender(() => {
3727
- !e.currentAnimation && e.isLead() && this.safeToRemove();
3728
- }));
3729
- }
3730
- componentWillUnmount() {
3731
- const { visualElement: e, layoutGroup: n, switchLayoutGroup: s } = this.props, { projection: i } = e;
3732
- fe = !0, i && (i.scheduleCheckAfterUnmount(), n && n.group && n.group.remove(i), s && s.deregister && s.deregister(i));
3733
- }
3734
- safeToRemove() {
3735
- const { safeToRemove: e } = this.props;
3736
- e && e();
3737
- }
3738
- render() {
3739
- return null;
3740
- }
3741
- }
3742
- function or(t) {
3743
- const [e, n] = wa(), s = I(js);
3744
- return Os(uu, { ...t, layoutGroup: s, switchLayoutGroup: I(Ui), isPresent: e, safeToRemove: n });
3745
- }
3746
- const cu = {
3747
- borderRadius: {
3748
- ...St,
3749
- applyTo: [
3750
- "borderTopLeftRadius",
3751
- "borderTopRightRadius",
3752
- "borderBottomLeftRadius",
3753
- "borderBottomRightRadius"
3754
- ]
3755
- },
3756
- borderTopLeftRadius: St,
3757
- borderTopRightRadius: St,
3758
- borderBottomLeftRadius: St,
3759
- borderBottomRightRadius: St,
3760
- boxShadow: lu
3761
- };
3762
- function hu(t, e, n) {
3763
- const s = k(t) ? t : gt(t);
3764
- return s.start(vn("", s, e, n)), s.animation;
3765
- }
3766
- const fu = (t, e) => t.depth - e.depth;
3767
- class du {
3768
- constructor() {
3769
- this.children = [], this.isDirty = !1;
3770
- }
3771
- add(e) {
3772
- We(this.children, e), this.isDirty = !0;
3773
- }
3774
- remove(e) {
3775
- $e(this.children, e), this.isDirty = !0;
3776
- }
3777
- forEach(e) {
3778
- this.isDirty && this.children.sort(fu), this.isDirty = !1, this.children.forEach(e);
3779
- }
3780
- }
3781
- function mu(t, e) {
3782
- const n = O.now(), s = ({ timestamp: i }) => {
3783
- const o = i - n;
3784
- o >= e && (Z(s), t(o - e));
3785
- };
3786
- return A.setup(s, !0), () => Z(s);
3787
- }
3788
- const ar = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], pu = ar.length, fs = (t) => typeof t == "string" ? parseFloat(t) : t, ds = (t) => typeof t == "number" || x.test(t);
3789
- function gu(t, e, n, s, i, o) {
3790
- i ? (t.opacity = D(0, n.opacity ?? 1, yu(s)), t.opacityExit = D(e.opacity ?? 1, 0, vu(s))) : o && (t.opacity = D(e.opacity ?? 1, n.opacity ?? 1, s));
3791
- for (let r = 0; r < pu; r++) {
3792
- const a = `border${ar[r]}Radius`;
3793
- let l = ms(e, a), c = ms(n, a);
3794
- if (l === void 0 && c === void 0)
3795
- continue;
3796
- l || (l = 0), c || (c = 0), l === 0 || c === 0 || ds(l) === ds(c) ? (t[a] = Math.max(D(fs(l), fs(c), s), 0), (H.test(c) || H.test(l)) && (t[a] += "%")) : t[a] = c;
3797
- }
3798
- (e.rotate || n.rotate) && (t.rotate = D(e.rotate || 0, n.rotate || 0, s));
3799
- }
3800
- function ms(t, e) {
3801
- return t[e] !== void 0 ? t[e] : t.borderRadius;
3802
- }
3803
- const yu = /* @__PURE__ */ lr(0, 0.5, Xs), vu = /* @__PURE__ */ lr(0.5, 0.95, $);
3804
- function lr(t, e, n) {
3805
- return (s) => s < t ? 0 : s > e ? 1 : n(/* @__PURE__ */ Ct(t, e, s));
3806
- }
3807
- function ps(t, e) {
3808
- t.min = e.min, t.max = e.max;
3809
- }
3810
- function U(t, e) {
3811
- ps(t.x, e.x), ps(t.y, e.y);
3812
- }
3813
- function gs(t, e) {
3814
- t.translate = e.translate, t.scale = e.scale, t.originPoint = e.originPoint, t.origin = e.origin;
3815
- }
3816
- function ys(t, e, n, s, i) {
3817
- return t -= e, t = Zt(t, 1 / n, s), i !== void 0 && (t = Zt(t, 1 / i, s)), t;
3818
- }
3819
- function Tu(t, e = 0, n = 1, s = 0.5, i, o = t, r = t) {
3820
- if (H.test(e) && (e = parseFloat(e), e = D(r.min, r.max, e / 100) - r.min), typeof e != "number")
3821
- return;
3822
- let a = D(o.min, o.max, s);
3823
- t === o && (a -= e), t.min = ys(t.min, e, n, a, i), t.max = ys(t.max, e, n, a, i);
3824
- }
3825
- function vs(t, e, [n, s, i], o, r) {
3826
- Tu(t, e[n], e[s], e[i], e.scale, o, r);
3827
- }
3828
- const xu = ["x", "scaleX", "originX"], Pu = ["y", "scaleY", "originY"];
3829
- function Ts(t, e, n, s) {
3830
- vs(t.x, e, xu, n ? n.x : void 0, s ? s.x : void 0), vs(t.y, e, Pu, n ? n.y : void 0, s ? s.y : void 0);
3831
- }
3832
- function xs(t) {
3833
- return t.translate === 0 && t.scale === 1;
3834
- }
3835
- function ur(t) {
3836
- return xs(t.x) && xs(t.y);
3837
- }
3838
- function Ps(t, e) {
3839
- return t.min === e.min && t.max === e.max;
3840
- }
3841
- function bu(t, e) {
3842
- return Ps(t.x, e.x) && Ps(t.y, e.y);
3843
- }
3844
- function bs(t, e) {
3845
- return Math.round(t.min) === Math.round(e.min) && Math.round(t.max) === Math.round(e.max);
3846
- }
3847
- function cr(t, e) {
3848
- return bs(t.x, e.x) && bs(t.y, e.y);
3849
- }
3850
- function Ss(t) {
3851
- return F(t.x) / F(t.y);
3852
- }
3853
- function ws(t, e) {
3854
- return t.translate === e.translate && t.scale === e.scale && t.originPoint === e.originPoint;
3855
- }
3856
- class Su {
3857
- constructor() {
3858
- this.members = [];
3859
- }
3860
- add(e) {
3861
- We(this.members, e), e.scheduleRender();
3862
- }
3863
- remove(e) {
3864
- if ($e(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) {
3865
- const n = this.members[this.members.length - 1];
3866
- n && this.promote(n);
3867
- }
3868
- }
3869
- relegate(e) {
3870
- const n = this.members.findIndex((i) => e === i);
3871
- if (n === 0)
3872
- return !1;
3873
- let s;
3874
- for (let i = n; i >= 0; i--) {
3875
- const o = this.members[i];
3876
- if (o.isPresent !== !1) {
3877
- s = o;
3878
- break;
3879
- }
3880
- }
3881
- return s ? (this.promote(s), !0) : !1;
3882
- }
3883
- promote(e, n) {
3884
- const s = this.lead;
3885
- if (e !== s && (this.prevLead = s, this.lead = e, e.show(), s)) {
3886
- s.instance && s.scheduleRender(), e.scheduleRender(), e.resumeFrom = s, n && (e.resumeFrom.preserveOpacity = !0), s.snapshot && (e.snapshot = s.snapshot, e.snapshot.latestValues = s.animationValues || s.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0);
3887
- const { crossfade: i } = e.options;
3888
- i === !1 && s.hide();
3889
- }
3890
- }
3891
- exitAnimationComplete() {
3892
- this.members.forEach((e) => {
3893
- const { options: n, resumingFrom: s } = e;
3894
- n.onExitComplete && n.onExitComplete(), s && s.options.onExitComplete && s.options.onExitComplete();
3895
- });
3896
- }
3897
- scheduleRender() {
3898
- this.members.forEach((e) => {
3899
- e.instance && e.scheduleRender(!1);
3900
- });
3901
- }
3902
- /**
3903
- * Clear any leads that have been removed this render to prevent them from being
3904
- * used in future animations and to prevent memory leaks
3905
- */
3906
- removeLeadSnapshot() {
3907
- this.lead && this.lead.snapshot && (this.lead.snapshot = void 0);
3908
- }
3909
- }
3910
- function wu(t, e, n) {
3911
- let s = "";
3912
- const i = t.x.translate / e.x, o = t.y.translate / e.y, r = n?.z || 0;
3913
- if ((i || o || r) && (s = `translate3d(${i}px, ${o}px, ${r}px) `), (e.x !== 1 || e.y !== 1) && (s += `scale(${1 / e.x}, ${1 / e.y}) `), n) {
3914
- const { transformPerspective: c, rotate: u, rotateX: h, rotateY: f, skewX: d, skewY: m } = n;
3915
- c && (s = `perspective(${c}px) ${s}`), u && (s += `rotate(${u}deg) `), h && (s += `rotateX(${h}deg) `), f && (s += `rotateY(${f}deg) `), d && (s += `skewX(${d}deg) `), m && (s += `skewY(${m}deg) `);
3916
- }
3917
- const a = t.x.scale * e.x, l = t.y.scale * e.y;
3918
- return (a !== 1 || l !== 1) && (s += `scale(${a}, ${l})`), s || "none";
3919
- }
3920
- const de = ["", "X", "Y", "Z"], Au = 1e3;
3921
- let Vu = 0;
3922
- function me(t, e, n, s) {
3923
- const { latestValues: i } = e;
3924
- i[t] && (n[t] = i[t], e.setStaticValue(t, 0), s && (s[t] = 0));
3925
- }
3926
- function hr(t) {
3927
- if (t.hasCheckedOptimisedAppear = !0, t.root === t)
3928
- return;
3929
- const { visualElement: e } = t.options;
3930
- if (!e)
3931
- return;
3932
- const n = qi(e);
3933
- if (window.MotionHasOptimisedAnimation(n, "transform")) {
3934
- const { layout: i, layoutId: o } = t.options;
3935
- window.MotionCancelOptimisedAnimation(n, "transform", A, !(i || o));
3936
- }
3937
- const { parent: s } = t;
3938
- s && !s.hasCheckedOptimisedAppear && hr(s);
3939
- }
3940
- function fr({ attachResizeListener: t, defaultParent: e, measureScroll: n, checkIsScrollRoot: s, resetTransform: i }) {
3941
- return class {
3942
- constructor(r = {}, a = e?.()) {
3943
- this.id = Vu++, this.animationId = 0, this.animationCommitId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.hasCheckedOptimisedAppear = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.updateScheduled = !1, this.scheduleUpdate = () => this.update(), this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => {
3944
- this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots());
3945
- }, this.updateProjection = () => {
3946
- this.projectionUpdateScheduled = !1, this.nodes.forEach(Cu), this.nodes.forEach(ku), this.nodes.forEach(Fu), this.nodes.forEach(Eu);
3947
- }, this.resolvedRelativeTargetAt = 0, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = r, this.root = a ? a.root || a : this, this.path = a ? [...a.path, a] : [], this.parent = a, this.depth = a ? a.depth + 1 : 0;
3948
- for (let l = 0; l < this.path.length; l++)
3949
- this.path[l].shouldResetTransform = !0;
3950
- this.root === this && (this.nodes = new du());
3951
- }
3952
- addEventListener(r, a) {
3953
- return this.eventHandlers.has(r) || this.eventHandlers.set(r, new _e()), this.eventHandlers.get(r).add(a);
3954
- }
3955
- notifyListeners(r, ...a) {
3956
- const l = this.eventHandlers.get(r);
3957
- l && l.notify(...a);
3958
- }
3959
- hasListeners(r) {
3960
- return this.eventHandlers.has(r);
3961
- }
3962
- /**
3963
- * Lifecycles
3964
- */
3965
- mount(r) {
3966
- if (this.instance)
3967
- return;
3968
- this.isSVG = Di(r) && !Pa(r), this.instance = r;
3969
- const { layoutId: a, layout: l, visualElement: c } = this.options;
3970
- if (c && !c.current && c.mount(r), this.root.nodes.add(this), this.parent && this.parent.children.add(this), this.root.hasTreeAnimated && (l || a) && (this.isLayoutDirty = !0), t) {
3971
- let u, h = 0;
3972
- const f = () => this.root.updateBlockedByResize = !1;
3973
- A.read(() => {
3974
- h = window.innerWidth;
3975
- }), t(r, () => {
3976
- const d = window.innerWidth;
3977
- d !== h && (h = d, this.root.updateBlockedByResize = !0, u && u(), u = mu(f, 250), Ht.hasAnimatedSinceResize && (Ht.hasAnimatedSinceResize = !1, this.nodes.forEach(Ds)));
3978
- });
3979
- }
3980
- a && this.root.registerSharedNode(a, this), this.options.animate !== !1 && c && (a || l) && this.addEventListener("didUpdate", ({ delta: u, hasLayoutChanged: h, hasRelativeLayoutChanged: f, layout: d }) => {
3981
- if (this.isTreeAnimationBlocked()) {
3982
- this.target = void 0, this.relativeTarget = void 0;
3983
- return;
3984
- }
3985
- const m = this.options.transition || c.getDefaultTransition() || Nu, { onLayoutAnimationStart: v, onLayoutAnimationComplete: y } = c.getProps(), p = !this.targetLayout || !cr(this.targetLayout, d), T = !h && f;
3986
- if (this.options.layoutRoot || this.resumeFrom || T || h && (p || !this.currentAnimation)) {
3987
- this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0);
3988
- const g = {
3989
- ...on(m, "layout"),
3990
- onPlay: v,
3991
- onComplete: y
3992
- };
3993
- (c.shouldReduceMotion || this.options.layoutRoot) && (g.delay = 0, g.type = !1), this.startAnimation(g), this.setAnimationOrigin(u, T);
3994
- } else
3995
- h || Ds(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete();
3996
- this.targetLayout = d;
3997
- });
3998
- }
3999
- unmount() {
4000
- this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this);
4001
- const r = this.getStack();
4002
- r && r.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, this.eventHandlers.clear(), Z(this.updateProjection);
4003
- }
4004
- // only on the root
4005
- blockUpdate() {
4006
- this.updateManuallyBlocked = !0;
4007
- }
4008
- unblockUpdate() {
4009
- this.updateManuallyBlocked = !1;
4010
- }
4011
- isUpdateBlocked() {
4012
- return this.updateManuallyBlocked || this.updateBlockedByResize;
4013
- }
4014
- isTreeAnimationBlocked() {
4015
- return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1;
4016
- }
4017
- // Note: currently only running on root node
4018
- startUpdate() {
4019
- this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(Bu), this.animationId++);
4020
- }
4021
- getTransformTemplate() {
4022
- const { visualElement: r } = this.options;
4023
- return r && r.getProps().transformTemplate;
4024
- }
4025
- willUpdate(r = !0) {
4026
- if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) {
4027
- this.options.onExitComplete && this.options.onExitComplete();
4028
- return;
4029
- }
4030
- if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear && hr(this), !this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty)
4031
- return;
4032
- this.isLayoutDirty = !0;
4033
- for (let u = 0; u < this.path.length; u++) {
4034
- const h = this.path[u];
4035
- h.shouldResetTransform = !0, h.updateScroll("snapshot"), h.options.layoutRoot && h.willUpdate(!1);
4036
- }
4037
- const { layoutId: a, layout: l } = this.options;
4038
- if (a === void 0 && !l)
4039
- return;
4040
- const c = this.getTransformTemplate();
4041
- this.prevTransformTemplateValue = c ? c(this.latestValues, "") : void 0, this.updateSnapshot(), r && this.notifyListeners("willUpdate");
4042
- }
4043
- update() {
4044
- if (this.updateScheduled = !1, this.isUpdateBlocked()) {
4045
- this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(As);
4046
- return;
4047
- }
4048
- if (this.animationId <= this.animationCommitId) {
4049
- this.nodes.forEach(Vs);
4050
- return;
4051
- }
4052
- this.animationCommitId = this.animationId, this.isUpdating ? (this.isUpdating = !1, this.nodes.forEach(Lu), this.nodes.forEach(Du), this.nodes.forEach(Mu)) : this.nodes.forEach(Vs), this.clearAllSnapshots();
4053
- const a = O.now();
4054
- L.delta = z(0, 1e3 / 60, a - L.timestamp), L.timestamp = a, L.isProcessing = !0, ne.update.process(L), ne.preRender.process(L), ne.render.process(L), L.isProcessing = !1;
4055
- }
4056
- didUpdate() {
4057
- this.updateScheduled || (this.updateScheduled = !0, ln.read(this.scheduleUpdate));
4058
- }
4059
- clearAllSnapshots() {
4060
- this.nodes.forEach(Ru), this.sharedNodes.forEach(Iu);
4061
- }
4062
- scheduleUpdateProjection() {
4063
- this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, A.preRender(this.updateProjection, !1, !0));
4064
- }
4065
- scheduleCheckAfterUnmount() {
4066
- A.postRender(() => {
4067
- this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed();
4068
- });
4069
- }
4070
- /**
4071
- * Update measurements
4072
- */
4073
- updateSnapshot() {
4074
- this.snapshot || !this.instance || (this.snapshot = this.measure(), this.snapshot && !F(this.snapshot.measuredBox.x) && !F(this.snapshot.measuredBox.y) && (this.snapshot = void 0));
4075
- }
4076
- updateLayout() {
4077
- if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty))
4078
- return;
4079
- if (this.resumeFrom && !this.resumeFrom.instance)
4080
- for (let l = 0; l < this.path.length; l++)
4081
- this.path[l].updateScroll();
4082
- const r = this.layout;
4083
- this.layout = this.measure(!1), this.layoutCorrected = M(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox);
4084
- const { visualElement: a } = this.options;
4085
- a && a.notify("LayoutMeasure", this.layout.layoutBox, r ? r.layoutBox : void 0);
4086
- }
4087
- updateScroll(r = "measure") {
4088
- let a = !!(this.options.layoutScroll && this.instance);
4089
- if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === r && (a = !1), a && this.instance) {
4090
- const l = s(this.instance);
4091
- this.scroll = {
4092
- animationId: this.root.animationId,
4093
- phase: r,
4094
- isRoot: l,
4095
- offset: n(this.instance),
4096
- wasRoot: this.scroll ? this.scroll.isRoot : l
4097
- };
4098
- }
4099
- }
4100
- resetTransform() {
4101
- if (!i)
4102
- return;
4103
- const r = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout, a = this.projectionDelta && !ur(this.projectionDelta), l = this.getTransformTemplate(), c = l ? l(this.latestValues, "") : void 0, u = c !== this.prevTransformTemplateValue;
4104
- r && this.instance && (a || nt(this.latestValues) || u) && (i(this.instance, c), this.shouldResetTransform = !1, this.scheduleRender());
4105
- }
4106
- measure(r = !0) {
4107
- const a = this.measurePageBox();
4108
- let l = this.removeElementScroll(a);
4109
- return r && (l = this.removeTransform(l)), Uu(l), {
4110
- animationId: this.root.animationId,
4111
- measuredBox: a,
4112
- layoutBox: l,
4113
- latestValues: {},
4114
- source: this.id
4115
- };
4116
- }
4117
- measurePageBox() {
4118
- const { visualElement: r } = this.options;
4119
- if (!r)
4120
- return M();
4121
- const a = r.measureViewportBox();
4122
- if (!(this.scroll?.wasRoot || this.path.some(Ku))) {
4123
- const { scroll: c } = this.root;
4124
- c && (ft(a.x, c.offset.x), ft(a.y, c.offset.y));
4125
- }
4126
- return a;
4127
- }
4128
- removeElementScroll(r) {
4129
- const a = M();
4130
- if (U(a, r), this.scroll?.wasRoot)
4131
- return a;
4132
- for (let l = 0; l < this.path.length; l++) {
4133
- const c = this.path[l], { scroll: u, options: h } = c;
4134
- c !== this.root && u && h.layoutScroll && (u.wasRoot && U(a, r), ft(a.x, u.offset.x), ft(a.y, u.offset.y));
4135
- }
4136
- return a;
4137
- }
4138
- applyTransform(r, a = !1) {
4139
- const l = M();
4140
- U(l, r);
4141
- for (let c = 0; c < this.path.length; c++) {
4142
- const u = this.path[c];
4143
- !a && u.options.layoutScroll && u.scroll && u !== u.root && dt(l, {
4144
- x: -u.scroll.offset.x,
4145
- y: -u.scroll.offset.y
4146
- }), nt(u.latestValues) && dt(l, u.latestValues);
4147
- }
4148
- return nt(this.latestValues) && dt(l, this.latestValues), l;
4149
- }
4150
- removeTransform(r) {
4151
- const a = M();
4152
- U(a, r);
4153
- for (let l = 0; l < this.path.length; l++) {
4154
- const c = this.path[l];
4155
- if (!c.instance || !nt(c.latestValues))
4156
- continue;
4157
- Re(c.latestValues) && c.updateSnapshot();
4158
- const u = M(), h = c.measurePageBox();
4159
- U(u, h), Ts(a, c.latestValues, c.snapshot ? c.snapshot.layoutBox : void 0, u);
4160
- }
4161
- return nt(this.latestValues) && Ts(a, this.latestValues), a;
4162
- }
4163
- setTargetDelta(r) {
4164
- this.targetDelta = r, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0;
4165
- }
4166
- setOptions(r) {
4167
- this.options = {
4168
- ...this.options,
4169
- ...r,
4170
- crossfade: r.crossfade !== void 0 ? r.crossfade : !0
4171
- };
4172
- }
4173
- clearMeasurements() {
4174
- this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1;
4175
- }
4176
- forceRelativeParentToResolveTarget() {
4177
- this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== L.timestamp && this.relativeParent.resolveTargetDelta(!0);
4178
- }
4179
- resolveTargetDelta(r = !1) {
4180
- const a = this.getLead();
4181
- this.isProjectionDirty || (this.isProjectionDirty = a.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = a.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = a.isSharedProjectionDirty);
4182
- const l = !!this.resumingFrom || this !== a;
4183
- if (!(r || l && this.isSharedProjectionDirty || this.isProjectionDirty || this.parent?.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize))
4184
- return;
4185
- const { layout: u, layoutId: h } = this.options;
4186
- if (!(!this.layout || !(u || h))) {
4187
- if (this.resolvedRelativeTargetAt = L.timestamp, !this.targetDelta && !this.relativeTarget) {
4188
- const f = this.getClosestProjectingParent();
4189
- f && f.layout && this.animationProgress !== 1 ? (this.relativeParent = f, this.forceRelativeParentToResolveTarget(), this.relativeTarget = M(), this.relativeTargetOrigin = M(), Mt(this.relativeTargetOrigin, this.layout.layoutBox, f.layout.layoutBox), U(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
4190
- }
4191
- if (!(!this.relativeTarget && !this.targetDelta) && (this.target || (this.target = M(), this.targetWithTransforms = M()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), zl(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : U(this.target, this.layout.layoutBox), Gi(this.target, this.targetDelta)) : U(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget)) {
4192
- this.attemptToResolveRelativeTarget = !1;
4193
- const f = this.getClosestProjectingParent();
4194
- f && !!f.resumingFrom == !!this.resumingFrom && !f.options.layoutScroll && f.target && this.animationProgress !== 1 ? (this.relativeParent = f, this.forceRelativeParentToResolveTarget(), this.relativeTarget = M(), this.relativeTargetOrigin = M(), Mt(this.relativeTargetOrigin, this.target, f.target), U(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0;
4195
- }
4196
- }
4197
- }
4198
- getClosestProjectingParent() {
4199
- if (!(!this.parent || Re(this.parent.latestValues) || $i(this.parent.latestValues)))
4200
- return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent();
4201
- }
4202
- isProjecting() {
4203
- return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
4204
- }
4205
- calcProjection() {
4206
- const r = this.getLead(), a = !!this.resumingFrom || this !== r;
4207
- let l = !0;
4208
- if ((this.isProjectionDirty || this.parent?.isProjectionDirty) && (l = !1), a && (this.isSharedProjectionDirty || this.isTransformDirty) && (l = !1), this.resolvedRelativeTargetAt === L.timestamp && (l = !1), l)
4209
- return;
4210
- const { layout: c, layoutId: u } = this.options;
4211
- if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(c || u))
4212
- return;
4213
- U(this.layoutCorrected, this.layout.layoutBox);
4214
- const h = this.treeScale.x, f = this.treeScale.y;
4215
- rl(this.layoutCorrected, this.treeScale, this.path, a), r.layout && !r.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (r.target = r.layout.layoutBox, r.targetWithTransforms = M());
4216
- const { target: d } = r;
4217
- if (!d) {
4218
- this.prevProjectionDelta && (this.createProjectionDeltas(), this.scheduleRender());
4219
- return;
4220
- }
4221
- !this.projectionDelta || !this.prevProjectionDelta ? this.createProjectionDeltas() : (gs(this.prevProjectionDelta.x, this.projectionDelta.x), gs(this.prevProjectionDelta.y, this.projectionDelta.y)), Dt(this.projectionDelta, this.layoutCorrected, d, this.latestValues), (this.treeScale.x !== h || this.treeScale.y !== f || !ws(this.projectionDelta.x, this.prevProjectionDelta.x) || !ws(this.projectionDelta.y, this.prevProjectionDelta.y)) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", d));
4222
- }
4223
- hide() {
4224
- this.isVisible = !1;
4225
- }
4226
- show() {
4227
- this.isVisible = !0;
4228
- }
4229
- scheduleRender(r = !0) {
4230
- if (this.options.visualElement?.scheduleRender(), r) {
4231
- const a = this.getStack();
4232
- a && a.scheduleRender();
4233
- }
4234
- this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0);
4235
- }
4236
- createProjectionDeltas() {
4237
- this.prevProjectionDelta = mt(), this.projectionDelta = mt(), this.projectionDeltaWithTransform = mt();
4238
- }
4239
- setAnimationOrigin(r, a = !1) {
4240
- const l = this.snapshot, c = l ? l.latestValues : {}, u = { ...this.latestValues }, h = mt();
4241
- (!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !a;
4242
- const f = M(), d = l ? l.source : void 0, m = this.layout ? this.layout.source : void 0, v = d !== m, y = this.getStack(), p = !y || y.members.length <= 1, T = !!(v && !p && this.options.crossfade === !0 && !this.path.some(ju));
4243
- this.animationProgress = 0;
4244
- let g;
4245
- this.mixTargetDelta = (S) => {
4246
- const P = S / 1e3;
4247
- Ms(h.x, r.x, P), Ms(h.y, r.y, P), this.setTargetDelta(h), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (Mt(f, this.layout.layoutBox, this.relativeParent.layout.layoutBox), Ou(this.relativeTarget, this.relativeTargetOrigin, f, P), g && bu(this.relativeTarget, g) && (this.isProjectionDirty = !1), g || (g = M()), U(g, this.relativeTarget)), v && (this.animationValues = u, gu(u, c, this.latestValues, P, T, p)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = P;
4248
- }, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
4249
- }
4250
- startAnimation(r) {
4251
- this.notifyListeners("animationStart"), this.currentAnimation?.stop(), this.resumingFrom?.currentAnimation?.stop(), this.pendingAnimation && (Z(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = A.update(() => {
4252
- Ht.hasAnimatedSinceResize = !0, this.motionValue || (this.motionValue = gt(0)), this.currentAnimation = hu(this.motionValue, [0, 1e3], {
4253
- ...r,
4254
- velocity: 0,
4255
- isSync: !0,
4256
- onUpdate: (a) => {
4257
- this.mixTargetDelta(a), r.onUpdate && r.onUpdate(a);
4258
- },
4259
- onStop: () => {
4260
- },
4261
- onComplete: () => {
4262
- r.onComplete && r.onComplete(), this.completeAnimation();
4263
- }
4264
- }), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0;
4265
- });
4266
- }
4267
- completeAnimation() {
4268
- this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0);
4269
- const r = this.getStack();
4270
- r && r.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete");
4271
- }
4272
- finishAnimation() {
4273
- this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(Au), this.currentAnimation.stop()), this.completeAnimation();
4274
- }
4275
- applyTransformsToTarget() {
4276
- const r = this.getLead();
4277
- let { targetWithTransforms: a, target: l, layout: c, latestValues: u } = r;
4278
- if (!(!a || !l || !c)) {
4279
- if (this !== r && this.layout && c && dr(this.options.animationType, this.layout.layoutBox, c.layoutBox)) {
4280
- l = this.target || M();
4281
- const h = F(this.layout.layoutBox.x);
4282
- l.x.min = r.target.x.min, l.x.max = l.x.min + h;
4283
- const f = F(this.layout.layoutBox.y);
4284
- l.y.min = r.target.y.min, l.y.max = l.y.min + f;
4285
- }
4286
- U(a, l), dt(a, u), Dt(this.projectionDeltaWithTransform, this.layoutCorrected, a, u);
4287
- }
4288
- }
4289
- registerSharedNode(r, a) {
4290
- this.sharedNodes.has(r) || this.sharedNodes.set(r, new Su()), this.sharedNodes.get(r).add(a);
4291
- const c = a.options.initialPromotionConfig;
4292
- a.promote({
4293
- transition: c ? c.transition : void 0,
4294
- preserveFollowOpacity: c && c.shouldPreserveFollowOpacity ? c.shouldPreserveFollowOpacity(a) : void 0
4295
- });
4296
- }
4297
- isLead() {
4298
- const r = this.getStack();
4299
- return r ? r.lead === this : !0;
4300
- }
4301
- getLead() {
4302
- const { layoutId: r } = this.options;
4303
- return r ? this.getStack()?.lead || this : this;
4304
- }
4305
- getPrevLead() {
4306
- const { layoutId: r } = this.options;
4307
- return r ? this.getStack()?.prevLead : void 0;
4308
- }
4309
- getStack() {
4310
- const { layoutId: r } = this.options;
4311
- if (r)
4312
- return this.root.sharedNodes.get(r);
4313
- }
4314
- promote({ needsReset: r, transition: a, preserveFollowOpacity: l } = {}) {
4315
- const c = this.getStack();
4316
- c && c.promote(this, l), r && (this.projectionDelta = void 0, this.needsReset = !0), a && this.setOptions({ transition: a });
4317
- }
4318
- relegate() {
4319
- const r = this.getStack();
4320
- return r ? r.relegate(this) : !1;
4321
- }
4322
- resetSkewAndRotation() {
4323
- const { visualElement: r } = this.options;
4324
- if (!r)
4325
- return;
4326
- let a = !1;
4327
- const { latestValues: l } = r;
4328
- if ((l.z || l.rotate || l.rotateX || l.rotateY || l.rotateZ || l.skewX || l.skewY) && (a = !0), !a)
4329
- return;
4330
- const c = {};
4331
- l.z && me("z", r, c, this.animationValues);
4332
- for (let u = 0; u < de.length; u++)
4333
- me(`rotate${de[u]}`, r, c, this.animationValues), me(`skew${de[u]}`, r, c, this.animationValues);
4334
- r.render();
4335
- for (const u in c)
4336
- r.setStaticValue(u, c[u]), this.animationValues && (this.animationValues[u] = c[u]);
4337
- r.scheduleRender();
4338
- }
4339
- applyProjectionStyles(r, a) {
4340
- if (!this.instance || this.isSVG)
4341
- return;
4342
- if (!this.isVisible) {
4343
- r.visibility = "hidden";
4344
- return;
4345
- }
4346
- const l = this.getTransformTemplate();
4347
- if (this.needsReset) {
4348
- this.needsReset = !1, r.visibility = "", r.opacity = "", r.pointerEvents = _t(a?.pointerEvents) || "", r.transform = l ? l(this.latestValues, "") : "none";
4349
- return;
4350
- }
4351
- const c = this.getLead();
4352
- if (!this.projectionDelta || !this.layout || !c.target) {
4353
- this.options.layoutId && (r.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, r.pointerEvents = _t(a?.pointerEvents) || ""), this.hasProjected && !nt(this.latestValues) && (r.transform = l ? l({}, "") : "none", this.hasProjected = !1);
4354
- return;
4355
- }
4356
- r.visibility = "";
4357
- const u = c.animationValues || c.latestValues;
4358
- this.applyTransformsToTarget();
4359
- let h = wu(this.projectionDeltaWithTransform, this.treeScale, u);
4360
- l && (h = l(u, h)), r.transform = h;
4361
- const { x: f, y: d } = this.projectionDelta;
4362
- r.transformOrigin = `${f.origin * 100}% ${d.origin * 100}% 0`, c.animationValues ? r.opacity = c === this ? u.opacity ?? this.latestValues.opacity ?? 1 : this.preserveOpacity ? this.latestValues.opacity : u.opacityExit : r.opacity = c === this ? u.opacity !== void 0 ? u.opacity : "" : u.opacityExit !== void 0 ? u.opacityExit : 0;
4363
- for (const m in kt) {
4364
- if (u[m] === void 0)
4365
- continue;
4366
- const { correct: v, applyTo: y, isCSSVariable: p } = kt[m], T = h === "none" ? u[m] : v(u[m], c);
4367
- if (y) {
4368
- const g = y.length;
4369
- for (let S = 0; S < g; S++)
4370
- r[y[S]] = T;
4371
- } else
4372
- p ? this.options.visualElement.renderState.vars[m] = T : r[m] = T;
4373
- }
4374
- this.options.layoutId && (r.pointerEvents = c === this ? _t(a?.pointerEvents) || "" : "none");
4375
- }
4376
- clearSnapshot() {
4377
- this.resumeFrom = this.snapshot = void 0;
4378
- }
4379
- // Only run on root
4380
- resetTree() {
4381
- this.root.nodes.forEach((r) => r.currentAnimation?.stop()), this.root.nodes.forEach(As), this.root.sharedNodes.clear();
4382
- }
4383
- };
4384
- }
4385
- function Du(t) {
4386
- t.updateLayout();
4387
- }
4388
- function Mu(t) {
4389
- const e = t.resumeFrom?.snapshot || t.snapshot;
4390
- if (t.isLead() && t.layout && e && t.hasListeners("didUpdate")) {
4391
- const { layoutBox: n, measuredBox: s } = t.layout, { animationType: i } = t.options, o = e.source !== t.layout.source;
4392
- i === "size" ? K((u) => {
4393
- const h = o ? e.measuredBox[u] : e.layoutBox[u], f = F(h);
4394
- h.min = n[u].min, h.max = h.min + f;
4395
- }) : dr(i, e.layoutBox, n) && K((u) => {
4396
- const h = o ? e.measuredBox[u] : e.layoutBox[u], f = F(n[u]);
4397
- h.max = h.min + f, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[u].max = t.relativeTarget[u].min + f);
4398
- });
4399
- const r = mt();
4400
- Dt(r, n, e.layoutBox);
4401
- const a = mt();
4402
- o ? Dt(a, t.applyTransform(s, !0), e.measuredBox) : Dt(a, n, e.layoutBox);
4403
- const l = !ur(r);
4404
- let c = !1;
4405
- if (!t.resumeFrom) {
4406
- const u = t.getClosestProjectingParent();
4407
- if (u && !u.resumeFrom) {
4408
- const { snapshot: h, layout: f } = u;
4409
- if (h && f) {
4410
- const d = M();
4411
- Mt(d, e.layoutBox, h.layoutBox);
4412
- const m = M();
4413
- Mt(m, n, f.layoutBox), cr(d, m) || (c = !0), u.options.layoutRoot && (t.relativeTarget = m, t.relativeTargetOrigin = d, t.relativeParent = u);
4414
- }
4415
- }
4416
- }
4417
- t.notifyListeners("didUpdate", {
4418
- layout: n,
4419
- snapshot: e,
4420
- delta: a,
4421
- layoutDelta: r,
4422
- hasLayoutChanged: l,
4423
- hasRelativeLayoutChanged: c
4424
- });
4425
- } else if (t.isLead()) {
4426
- const { onExitComplete: n } = t.options;
4427
- n && n();
4428
- }
4429
- t.options.transition = void 0;
4430
- }
4431
- function Cu(t) {
4432
- t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty));
4433
- }
4434
- function Eu(t) {
4435
- t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1;
4436
- }
4437
- function Ru(t) {
4438
- t.clearSnapshot();
4439
- }
4440
- function As(t) {
4441
- t.clearMeasurements();
4442
- }
4443
- function Vs(t) {
4444
- t.isLayoutDirty = !1;
4445
- }
4446
- function Lu(t) {
4447
- const { visualElement: e } = t.options;
4448
- e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform();
4449
- }
4450
- function Ds(t) {
4451
- t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0;
4452
- }
4453
- function ku(t) {
4454
- t.resolveTargetDelta();
4455
- }
4456
- function Fu(t) {
4457
- t.calcProjection();
4458
- }
4459
- function Bu(t) {
4460
- t.resetSkewAndRotation();
4461
- }
4462
- function Iu(t) {
4463
- t.removeLeadSnapshot();
4464
- }
4465
- function Ms(t, e, n) {
4466
- t.translate = D(e.translate, 0, n), t.scale = D(e.scale, 1, n), t.origin = e.origin, t.originPoint = e.originPoint;
4467
- }
4468
- function Cs(t, e, n, s) {
4469
- t.min = D(e.min, n.min, s), t.max = D(e.max, n.max, s);
4470
- }
4471
- function Ou(t, e, n, s) {
4472
- Cs(t.x, e.x, n.x, s), Cs(t.y, e.y, n.y, s);
4473
- }
4474
- function ju(t) {
4475
- return t.animationValues && t.animationValues.opacityExit !== void 0;
4476
- }
4477
- const Nu = {
4478
- duration: 0.45,
4479
- ease: [0.4, 0, 0.1, 1]
4480
- }, Es = (t) => typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(t), Rs = Es("applewebkit/") && !Es("chrome/") ? Math.round : $;
4481
- function Ls(t) {
4482
- t.min = Rs(t.min), t.max = Rs(t.max);
4483
- }
4484
- function Uu(t) {
4485
- Ls(t.x), Ls(t.y);
4486
- }
4487
- function dr(t, e, n) {
4488
- return t === "position" || t === "preserve-aspect" && !Hl(Ss(e), Ss(n), 0.2);
4489
- }
4490
- function Ku(t) {
4491
- return t !== t.root && t.scroll?.wasRoot;
4492
- }
4493
- const Wu = fr({
4494
- attachResizeListener: (t, e) => Ft(t, "resize", e),
4495
- measureScroll: () => ({
4496
- x: document.documentElement.scrollLeft || document.body.scrollLeft,
4497
- y: document.documentElement.scrollTop || document.body.scrollTop
4498
- }),
4499
- checkIsScrollRoot: () => !0
4500
- }), pe = {
4501
- current: void 0
4502
- }, mr = fr({
4503
- measureScroll: (t) => ({
4504
- x: t.scrollLeft,
4505
- y: t.scrollTop
4506
- }),
4507
- defaultParent: () => {
4508
- if (!pe.current) {
4509
- const t = new Wu({});
4510
- t.mount(window), t.setOptions({ layoutScroll: !0 }), pe.current = t;
4511
- }
4512
- return pe.current;
4513
- },
4514
- resetTransform: (t, e) => {
4515
- t.style.transform = e !== void 0 ? e : "none";
4516
- },
4517
- checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed"
4518
- }), $u = {
4519
- pan: {
4520
- Feature: au
4521
- },
4522
- drag: {
4523
- Feature: ou,
4524
- ProjectionNode: mr,
4525
- MeasureLayout: or
4526
- }
4527
- };
4528
- function ks(t, e, n) {
4529
- const { props: s } = t;
4530
- t.animationState && s.whileHover && t.animationState.setActive("whileHover", n === "Start");
4531
- const i = "onHover" + n, o = s[i];
4532
- o && A.postRender(() => o(e, jt(e)));
4533
- }
4534
- class Gu extends Q {
4535
- mount() {
4536
- const { current: e } = this.node;
4537
- e && (this.unmount = ga(e, (n, s) => (ks(this.node, s, "Start"), (i) => ks(this.node, i, "End"))));
4538
- }
4539
- unmount() {
4540
- }
4541
- }
4542
- class _u extends Q {
4543
- constructor() {
4544
- super(...arguments), this.isActive = !1;
4545
- }
4546
- onFocus() {
4547
- let e = !1;
4548
- try {
4549
- e = this.node.current.matches(":focus-visible");
4550
- } catch {
4551
- e = !0;
4552
- }
4553
- !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0);
4554
- }
4555
- onBlur() {
4556
- !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1);
4557
- }
4558
- mount() {
4559
- this.unmount = Bt(Ft(this.node.current, "focus", () => this.onFocus()), Ft(this.node.current, "blur", () => this.onBlur()));
4560
- }
4561
- unmount() {
4562
- }
4563
- }
4564
- function Fs(t, e, n) {
4565
- const { props: s } = t;
4566
- if (t.current instanceof HTMLButtonElement && t.current.disabled)
4567
- return;
4568
- t.animationState && s.whileTap && t.animationState.setActive("whileTap", n === "Start");
4569
- const i = "onTap" + (n === "End" ? "" : n), o = s[i];
4570
- o && A.postRender(() => o(e, jt(e)));
4571
- }
4572
- class Hu extends Q {
4573
- mount() {
4574
- const { current: e } = this.node;
4575
- e && (this.unmount = xa(e, (n, s) => (Fs(this.node, s, "Start"), (i, { success: o }) => Fs(this.node, i, o ? "End" : "Cancel")), { useGlobalTarget: this.node.props.globalTapTarget }));
4576
- }
4577
- unmount() {
4578
- }
4579
- }
4580
- const je = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), zu = (t) => {
4581
- const e = je.get(t.target);
4582
- e && e(t);
4583
- }, Yu = (t) => {
4584
- t.forEach(zu);
4585
- };
4586
- function Xu({ root: t, ...e }) {
4587
- const n = t || document;
4588
- ge.has(n) || ge.set(n, {});
4589
- const s = ge.get(n), i = JSON.stringify(e);
4590
- return s[i] || (s[i] = new IntersectionObserver(Yu, { root: t, ...e })), s[i];
4591
- }
4592
- function qu(t, e, n) {
4593
- const s = Xu(e);
4594
- return je.set(t, n), s.observe(t), () => {
4595
- je.delete(t), s.unobserve(t);
4596
- };
4597
- }
4598
- const Zu = {
4599
- some: 0,
4600
- all: 1
4601
- };
4602
- class Ju extends Q {
4603
- constructor() {
4604
- super(...arguments), this.hasEnteredView = !1, this.isInView = !1;
4605
- }
4606
- startObserver() {
4607
- this.unmount();
4608
- const { viewport: e = {} } = this.node.getProps(), { root: n, margin: s, amount: i = "some", once: o } = e, r = {
4609
- root: n ? n.current : void 0,
4610
- rootMargin: s,
4611
- threshold: typeof i == "number" ? i : Zu[i]
4612
- }, a = (l) => {
4613
- const { isIntersecting: c } = l;
4614
- if (this.isInView === c || (this.isInView = c, o && !c && this.hasEnteredView))
4615
- return;
4616
- c && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", c);
4617
- const { onViewportEnter: u, onViewportLeave: h } = this.node.getProps(), f = c ? u : h;
4618
- f && f(l);
4619
- };
4620
- return qu(this.node.current, r, a);
4621
- }
4622
- mount() {
4623
- this.startObserver();
4624
- }
4625
- update() {
4626
- if (typeof IntersectionObserver > "u")
4627
- return;
4628
- const { props: e, prevProps: n } = this.node;
4629
- ["amount", "margin", "root"].some(Qu(e, n)) && this.startObserver();
4630
- }
4631
- unmount() {
4632
- }
4633
- }
4634
- function Qu({ viewport: t = {} }, { viewport: e = {} } = {}) {
4635
- return (n) => t[n] !== e[n];
4636
- }
4637
- const tc = {
4638
- inView: {
4639
- Feature: Ju
4640
- },
4641
- tap: {
4642
- Feature: Hu
4643
- },
4644
- focus: {
4645
- Feature: _u
4646
- },
4647
- hover: {
4648
- Feature: Gu
4649
- }
4650
- }, ec = {
4651
- layout: {
4652
- ProjectionNode: mr,
4653
- MeasureLayout: or
4654
- }
4655
- }, nc = {
4656
- ...Ul,
4657
- ...tc,
4658
- ...$u,
4659
- ...ec
4660
- }, ac = /* @__PURE__ */ nl(nc, pl);
4661
- export {
4662
- js as L,
4663
- Mi as M,
4664
- Ke as P,
4665
- wa as a,
4666
- Ar as b,
4667
- fa as i,
4668
- ac as m,
4669
- wr as u
4670
- };