@spear-ai/spectral 1.9.1 → 1.10.0

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