@mkbabb/keyframes.js 5.0.0 → 5.1.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 (39) hide show
  1. package/README.md +31 -216
  2. package/dist/animation-BGyzfzBq.js +947 -0
  3. package/dist/compile-CcSUwM8R.js +276 -0
  4. package/dist/{waapi-D0ssxKy1.js → delegation-DWwr4IXr.js} +115 -93
  5. package/dist/{draw-svg-Dat9mHgi.js → draw-svg-GURj9nin.js} +17 -13
  6. package/dist/easing-registry-DHV2-5gA.js +27 -0
  7. package/dist/easing-registry-y1p9McFy.js +2 -0
  8. package/dist/engine/index.d.ts +2873 -0
  9. package/dist/engine/index.js +17 -0
  10. package/dist/engine-DEVgCTUy.js +156 -0
  11. package/dist/engine-DrBtsKaf.js +4 -0
  12. package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
  13. package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
  14. package/dist/group-vJcsHKN9.js +360 -0
  15. package/dist/{ingest-CU-kdYcM.js → ingest-S5hUe20K.js} +62 -56
  16. package/dist/keyframes.d.ts +475 -942
  17. package/dist/keyframes.js +196 -137
  18. package/dist/morph-svg-BToeumw5.js +89 -0
  19. package/dist/{motion-path-C0OHqcA3.js → motion-path-pQVbamWT.js} +16 -12
  20. package/dist/parse-flatten-DRMHFytp.js +2 -0
  21. package/dist/parse-flatten-ZZUSEQEL.js +63 -0
  22. package/dist/{animations-CZxf0rep.js → presets-BG2Fczzq.js} +124 -73
  23. package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
  24. package/dist/{scroll-scene-DQxhxn9I.js → scroll-CxpYFO4u.js} +50 -46
  25. package/dist/sequence-C_DCiOIQ.js +708 -0
  26. package/dist/validate-DDeGnvSt.js +39 -0
  27. package/package.json +12 -3
  28. package/dist/animate-CTWr6K7j.js +0 -26
  29. package/dist/compile-YRJRdpKF.js +0 -251
  30. package/dist/decay-BvNmFk51.js +0 -25
  31. package/dist/engine-DQcb7CLW.js +0 -1349
  32. package/dist/errors-W8zkvPw4.js +0 -21
  33. package/dist/morph-svg-83uyYxoW.js +0 -84
  34. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  35. package/dist/sequence-cBr7thU8.js +0 -198
  36. package/dist/springTimingFunction-D26gPkAy.js +0 -63
  37. package/dist/timeline-vY3eD3Ax.js +0 -430
  38. package/dist/utils-BPRImVl5.js +0 -100
  39. package/dist/validate-B1pE-Y_T.js +0 -35
@@ -0,0 +1,708 @@
1
+ import { clamp as e, lerpArray as t, scale as n } from "@mkbabb/value.js/math";
2
+ //#region src/animation/internal/errors.ts
3
+ var r = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), i = class extends Error {
4
+ option;
5
+ value;
6
+ code;
7
+ constructor(e, t, n, i) {
8
+ super(`Invalid value for animation option "${e}": ${r(t)} — ${n}`), this.name = "AnimationOptionError", this.option = e, this.value = t, i !== void 0 && (this.code = i);
9
+ }
10
+ }, a = class extends Error {
11
+ easingName;
12
+ constructor(e) {
13
+ super(`Unknown easing name ${r(e)} — not a value.js registry entry or cubic-bezier() literal. Pass a callable TimingFunction (or a typed Easing), or resolve the name first via \`await resolveEasing(name)\`.`), this.name = "UnknownEasingError", this.easingName = e;
14
+ }
15
+ };
16
+ function o(e, t, n, r) {
17
+ let a = n(t);
18
+ if (a === void 0) throw new i(e, t, r);
19
+ return a;
20
+ }
21
+ //#endregion
22
+ //#region src/animation/easing.ts
23
+ var s = (e) => typeof e == "function" ? { fn: e } : e, c = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, l = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, u = (e) => {
24
+ let t = e.trim();
25
+ if (c.test(t) || l.test(t)) return t;
26
+ };
27
+ async function d(e) {
28
+ let t;
29
+ try {
30
+ t = await import("./easing-registry-y1p9McFy.js");
31
+ } catch (t) {
32
+ throw Error(`keyframes: the easing-registry chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
33
+ }
34
+ let n = t.getTimingFunction(e);
35
+ if (!n) throw new a(e);
36
+ let r = { fn: n }, i = u(e);
37
+ return i && (r.css = i), r;
38
+ }
39
+ //#endregion
40
+ //#region src/animation/internal/binarySearch.ts
41
+ function f(e, t, n, r) {
42
+ let i = 0, a = e.length - 1;
43
+ for (; i <= a;) {
44
+ let o = i + a >> 1, s = e[o];
45
+ if (t < n(s)) a = o - 1;
46
+ else if (t > r(s)) i = o + 1;
47
+ else return o;
48
+ }
49
+ return -1;
50
+ }
51
+ //#endregion
52
+ //#region src/animation/internal/leaves.ts
53
+ var p = 1e3 / 60;
54
+ function m(e) {
55
+ if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
56
+ let t = p, n = Date.now();
57
+ return setTimeout(() => {
58
+ let r = Date.now(), i = r - n;
59
+ n = r, t = Math.max(0, p - i), e(r);
60
+ }, t);
61
+ }
62
+ function h(e) {
63
+ if (e != null) {
64
+ if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
65
+ clearTimeout(e);
66
+ }
67
+ }
68
+ //#endregion
69
+ //#region src/animation/internal/reduced-motion.ts
70
+ var g = "(prefers-reduced-motion: reduce)", _ = null, v;
71
+ function y() {
72
+ let e = typeof window > "u" ? void 0 : window.matchMedia;
73
+ return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
74
+ }
75
+ function b() {
76
+ return y()?.matches ?? !1;
77
+ }
78
+ function x(e) {
79
+ return e === !1 || e === void 0 || !b() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
80
+ }
81
+ function S(e, t, n) {
82
+ return !e && e !== 0 || !b() ? n() : e === !0 || e === 0 ? t() : n();
83
+ }
84
+ //#endregion
85
+ //#region src/animation/physics/playback.ts
86
+ var C = class {
87
+ _rafId = null;
88
+ _startTime = void 0;
89
+ _lastFrameT = 0;
90
+ _resolve = null;
91
+ _gen = 0;
92
+ get running() {
93
+ return this._rafId !== null;
94
+ }
95
+ _run(e) {
96
+ let t = ++this._gen, n = (e) => {
97
+ t === this._gen && (e ? this._rafId = m(r) : this._cleanup());
98
+ }, r = (t) => {
99
+ let r = e(t);
100
+ r && typeof r.then == "function" ? r.then(n) : n(r);
101
+ };
102
+ this._rafId = m(r);
103
+ }
104
+ play = (t, n, r) => {
105
+ if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
106
+ return this.stop(), S(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
107
+ this._resolve = r, this._startTime = void 0, this._run((r) => {
108
+ this._startTime === void 0 && (this._startTime = r);
109
+ let i = e((r - this._startTime) / t, 0, 1);
110
+ return n(i), i < 1;
111
+ });
112
+ }));
113
+ };
114
+ drive = (e, t) => {
115
+ this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
116
+ let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
117
+ return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
118
+ }));
119
+ };
120
+ loop = (e) => {
121
+ this.stop(), this._run(e);
122
+ };
123
+ stop = () => {
124
+ this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
125
+ };
126
+ _cleanup() {
127
+ this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
128
+ let e = this._resolve;
129
+ this._resolve = null, e?.();
130
+ }
131
+ }, w = {
132
+ damping: .1,
133
+ snapThreshold: .001,
134
+ targetEpsilon: 0,
135
+ initial: 0,
136
+ clamp: !0,
137
+ respectReducedMotion: !1
138
+ }, T = class {
139
+ options;
140
+ targetValue;
141
+ currentValue;
142
+ isSettled;
143
+ _playback = new C();
144
+ _onFrame = void 0;
145
+ constructor(e) {
146
+ this.options = {
147
+ ...w,
148
+ ...e
149
+ }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
150
+ }
151
+ get target() {
152
+ return this.targetValue;
153
+ }
154
+ get current() {
155
+ return this.currentValue;
156
+ }
157
+ get settled() {
158
+ return this.isSettled;
159
+ }
160
+ setTarget(t) {
161
+ this.options.clamp && (t = e(t, 0, 1));
162
+ let n = Math.abs(t - this.targetValue);
163
+ n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
164
+ this.isSettled = !1, this._onFrame && this._startLoop();
165
+ }));
166
+ }
167
+ _snapSettled() {
168
+ this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
169
+ }
170
+ tickDt(t) {
171
+ if (this.isSettled) return this.currentValue;
172
+ let n = 1 - Math.exp(-this.options.damping * t / 16.667);
173
+ return this.currentValue += (this.targetValue - this.currentValue) * n, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = e(this.currentValue, 0, 1)), this.currentValue;
174
+ }
175
+ snap() {
176
+ this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
177
+ }
178
+ reset(e) {
179
+ let t = e ?? 0;
180
+ this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
181
+ }
182
+ play(e) {
183
+ this._onFrame = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
184
+ if (this.isSettled) {
185
+ e?.(this.currentValue);
186
+ return;
187
+ }
188
+ this._startLoop();
189
+ });
190
+ }
191
+ stop() {
192
+ this._onFrame = void 0, this._playback.stop();
193
+ }
194
+ _startLoop() {
195
+ this._playback.drive(this, () => this._onFrame?.(this.currentValue));
196
+ }
197
+ }, E = {
198
+ response: .5,
199
+ dampingFraction: .86,
200
+ initial: 0,
201
+ initialVelocity: 0,
202
+ settleThreshold: .001,
203
+ velocitySettleThreshold: .001,
204
+ respectReducedMotion: !1
205
+ };
206
+ //#endregion
207
+ //#region src/animation/physics/spring/duration.ts
208
+ function D(t) {
209
+ let { visualDuration: n, duration: r, bounce: i = 0, ...a } = t, o = n ?? r ?? .5, s = 1 - e(i, -1, 1);
210
+ return {
211
+ ...a,
212
+ response: o,
213
+ dampingFraction: s
214
+ };
215
+ }
216
+ //#endregion
217
+ //#region src/animation/physics/spring/vector.ts
218
+ var O = new Float64Array(), k = class {
219
+ vecOrigin = null;
220
+ vecOriginVel = null;
221
+ vecTarget = null;
222
+ vecCurrent = null;
223
+ vecVelocity = null;
224
+ vecElapsed = 0;
225
+ setTargets(e) {
226
+ let t = e.length;
227
+ if (this.vecTarget === null) this.vecOrigin = new Float64Array(t), this.vecOriginVel = new Float64Array(t), this.vecTarget = new Float64Array(t), this.vecCurrent = new Float64Array(t), this.vecVelocity = new Float64Array(t);
228
+ else if (this.vecTarget.length !== t) throw RangeError(`setTargets length ${t} does not match the armed lane count ${this.vecTarget.length}; the lane buffers are stable references — construct a new SpringProgress for a new arity.`);
229
+ this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
230
+ }
231
+ get values() {
232
+ return this.vecCurrent ?? O;
233
+ }
234
+ get velocities() {
235
+ return this.vecVelocity ?? O;
236
+ }
237
+ get armed() {
238
+ return this.vecTarget !== null;
239
+ }
240
+ tick(e, t, n, r) {
241
+ if (this.vecTarget === null || e <= 0) return this.values;
242
+ this.vecElapsed += e / 1e3;
243
+ let i = this.vecElapsed, a = t, o = n, s = r, c = this.vecOrigin, l = this.vecOriginVel, u = this.vecTarget, d = this.vecCurrent, f = this.vecVelocity, p = o < 1 ? Math.exp(-o * a * i) : 0, m = o < 1 ? Math.cos(s * i) : 0, h = o < 1 ? Math.sin(s * i) : 0, g = o === 1 ? Math.exp(-a * i) : 0, _ = 0, v = 0, y = 0, b = 0;
244
+ if (o > 1) {
245
+ let e = a * Math.sqrt(o * o - 1);
246
+ _ = -o * a + e, v = -o * a - e, y = Math.exp(_ * i), b = Math.exp(v * i);
247
+ }
248
+ for (let e = 0; e < d.length; e++) {
249
+ let t = c[e] - u[e], n = l[e], r, x;
250
+ if (o < 1) {
251
+ let e = t, i = (n + o * a * t) / s;
252
+ r = p * (e * m + i * h), x = p * ((i * s - e * o * a) * m - (e * s + i * o * a) * h);
253
+ } else if (o === 1) {
254
+ let e = t, o = n + a * t;
255
+ r = g * (e + o * i), x = g * (o - a * (e + o * i));
256
+ } else {
257
+ let e = (n - v * t) / (_ - v), i = t - e;
258
+ r = e * y + i * b, x = e * _ * y + i * v * b;
259
+ }
260
+ d[e] = u[e] + r, f[e] = x;
261
+ }
262
+ return d;
263
+ }
264
+ };
265
+ //#endregion
266
+ //#region src/animation/physics/spring/solver.ts
267
+ function A(e, t, n, r, i, a) {
268
+ let o = n, s = r;
269
+ if (s < 1) {
270
+ let n = i, r = Math.exp(-s * o * a), c = e, l = (t + s * o * e) / n, u = Math.cos(n * a), d = Math.sin(n * a);
271
+ return {
272
+ x: r * (c * u + l * d),
273
+ v: r * ((l * n - c * s * o) * u - (c * n + l * s * o) * d)
274
+ };
275
+ }
276
+ if (s === 1) {
277
+ let n = Math.exp(-o * a), r = e, i = t + o * e;
278
+ return {
279
+ x: n * (r + i * a),
280
+ v: n * (i - o * (r + i * a))
281
+ };
282
+ }
283
+ let c = o * Math.sqrt(s * s - 1), l = -s * o + c, u = -s * o - c, d = (t - u * e) / (l - u), f = e - d, p = Math.exp(l * a), m = Math.exp(u * a);
284
+ return {
285
+ x: d * p + f * m,
286
+ v: d * l * p + f * u * m
287
+ };
288
+ }
289
+ //#endregion
290
+ //#region src/animation/physics/spring/progress.ts
291
+ var j = class e {
292
+ options;
293
+ targetValue;
294
+ currentValue;
295
+ currentVelocity;
296
+ isSettled;
297
+ elapsed;
298
+ originValue;
299
+ originVelocity;
300
+ amplitudeScale = 1;
301
+ omega;
302
+ zeta;
303
+ omegaD;
304
+ subscribers = /* @__PURE__ */ new Set();
305
+ disposed = !1;
306
+ vectorLanes = null;
307
+ _playback = new C();
308
+ _onFrame = void 0;
309
+ constructor(e) {
310
+ this.options = {
311
+ ...E,
312
+ ...e
313
+ }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.amplitudeScale = x(this.options.respectReducedMotion), this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
314
+ }
315
+ static fromDuration(t) {
316
+ return new e(D(t ?? {}));
317
+ }
318
+ get target() {
319
+ return this.targetValue;
320
+ }
321
+ get value() {
322
+ return this.currentValue;
323
+ }
324
+ get velocity() {
325
+ return this.currentVelocity;
326
+ }
327
+ get settled() {
328
+ return this.isSettled;
329
+ }
330
+ set target(e) {
331
+ e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
332
+ }
333
+ reseatTarget(e) {
334
+ this.targetValue = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
335
+ this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = x(this.options.respectReducedMotion), this._onFrame && this._startLoop();
336
+ });
337
+ }
338
+ _snapSettled() {
339
+ this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
340
+ }
341
+ tickDt(e) {
342
+ return this._stepSeconds(e / 1e3);
343
+ }
344
+ _stepSeconds(e) {
345
+ return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
346
+ }
347
+ tickToTime(e) {
348
+ return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
349
+ }
350
+ evaluateAt(e) {
351
+ let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, { x: a, v: o } = A(r, i, this.omega, this.zeta, this.omegaD, e);
352
+ this.currentValue = n + a, this.currentVelocity = o;
353
+ }
354
+ checkSettled() {
355
+ let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
356
+ n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
357
+ }
358
+ snap() {
359
+ this._snapSettled();
360
+ }
361
+ reset(e, t) {
362
+ let n = e ?? 0, r = t ?? 0;
363
+ this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = x(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
364
+ }
365
+ setTargets(e) {
366
+ (this.vectorLanes ??= new k()).setTargets(e);
367
+ }
368
+ get values() {
369
+ return this.vectorLanes?.values ?? O;
370
+ }
371
+ get velocities() {
372
+ return this.vectorLanes?.velocities ?? O;
373
+ }
374
+ tickVector(e) {
375
+ return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : this.vectorLanes.tick(e, this.omega, this.zeta, this.omegaD);
376
+ }
377
+ subscribe(e) {
378
+ return this.subscribers.add(e), () => {
379
+ this.subscribers.delete(e);
380
+ };
381
+ }
382
+ emit() {
383
+ if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
384
+ }
385
+ dispose() {
386
+ this.disposed = !0, this._playback.stop(), this.subscribers.clear();
387
+ }
388
+ play(e) {
389
+ this.disposed || (this._onFrame = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
390
+ if (this.isSettled) {
391
+ e?.(this.currentValue, this.currentVelocity);
392
+ return;
393
+ }
394
+ this._startLoop();
395
+ }));
396
+ }
397
+ stop() {
398
+ this._onFrame = void 0, this._playback.stop();
399
+ }
400
+ _startLoop() {
401
+ this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
402
+ }
403
+ };
404
+ //#endregion
405
+ //#region src/animation/physics/spring/sample.ts
406
+ function M(e) {
407
+ let t = new j({
408
+ response: e.response,
409
+ dampingFraction: e.dampingFraction,
410
+ initial: 0,
411
+ settleThreshold: e.settleThreshold,
412
+ velocitySettleThreshold: e.settleThreshold
413
+ });
414
+ t.target = 1;
415
+ let n = [];
416
+ for (let r = 1; r <= e.sampleCount; r++) t._stepSeconds(e.dt), n.push(t.settled ? 1 : t.value);
417
+ return t.dispose(), n;
418
+ }
419
+ //#endregion
420
+ //#region src/animation/physics/spring/linear-stops.ts
421
+ function N(e) {
422
+ let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = M({
423
+ response: e.response,
424
+ dampingFraction: e.dampingFraction,
425
+ sampleCount: t,
426
+ settleThreshold: n,
427
+ dt: r / (t + 1)
428
+ }), a = ["0"];
429
+ for (let e = 1; e <= t; e++) {
430
+ let n = e / (t + 1) * 100, r = i[e - 1];
431
+ a.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
432
+ }
433
+ return a.push("1"), `linear(${a.join(", ")})`;
434
+ }
435
+ //#endregion
436
+ //#region src/animation/physics/spring/timing-function.ts
437
+ function P(e) {
438
+ let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = M({
439
+ response: e.response,
440
+ dampingFraction: e.dampingFraction,
441
+ sampleCount: t,
442
+ settleThreshold: n,
443
+ dt: r / t
444
+ }), a = new Float64Array(t + 1);
445
+ a[0] = 0;
446
+ for (let e = 1; e <= t; e++) a[e] = i[e - 1];
447
+ a[t] = 1;
448
+ let o = (e) => {
449
+ if (e <= 0) return 0;
450
+ if (e >= 1) return 1;
451
+ let n = e * t, r = Math.floor(n), i = n - r, o = a[r];
452
+ return o + (a[r + 1] - o) * i;
453
+ }, s = {
454
+ response: e.response,
455
+ dampingFraction: e.dampingFraction
456
+ };
457
+ return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (s.maxDuration = e.maxDuration), {
458
+ fn: o,
459
+ css: N(s)
460
+ };
461
+ }
462
+ //#endregion
463
+ //#region src/animation/orchestration/timeline/native.ts
464
+ function F(e) {
465
+ if (typeof window > "u") return null;
466
+ if (e.kind === "scroll") {
467
+ if (globalThis.ScrollTimeline === void 0) return null;
468
+ let t = {};
469
+ return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
470
+ }
471
+ if (globalThis.ViewTimeline === void 0) return null;
472
+ let t = { subject: e.subject };
473
+ return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
474
+ }
475
+ //#endregion
476
+ //#region src/animation/physics/decay.ts
477
+ var I = 5;
478
+ function L(e) {
479
+ let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? I;
480
+ if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
481
+ let i = t + n / r;
482
+ return (e) => {
483
+ if (e <= 0) return {
484
+ value: t,
485
+ velocity: n
486
+ };
487
+ let a = Math.exp(-r * e);
488
+ return {
489
+ value: i - n / r * a,
490
+ velocity: n * a
491
+ };
492
+ };
493
+ }
494
+ function R(e) {
495
+ let t = e.friction ?? I;
496
+ if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
497
+ return (e.initial ?? 0) + e.velocity / t;
498
+ }
499
+ //#endregion
500
+ //#region src/animation/orchestration/sequence/transport.ts
501
+ function z(t, n) {
502
+ for (let { animation: r, at: i } of t) {
503
+ let t = e(n - i, 0, r.options.duration);
504
+ r.interpFrames(t, !0);
505
+ }
506
+ }
507
+ function B(e, t, n, r) {
508
+ e.fire(t, n, r);
509
+ }
510
+ function V(e, t, n) {
511
+ if (e === void 0) return t;
512
+ if (typeof e == "number") return e;
513
+ let r = /^([+-])=(\d*\.?\d+)$/.exec(e);
514
+ if (r) return t + (r[1] === "+" ? 1 : -1) * Number.parseFloat(r[2]);
515
+ let i = n.get(e);
516
+ if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
517
+ return i;
518
+ }
519
+ function H(t, n, r, i) {
520
+ if (n <= 0) return 0;
521
+ let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
522
+ return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
523
+ }
524
+ function U(e, t, n) {
525
+ return n && (t - 1) % 2 == 1 ? 0 : e;
526
+ }
527
+ function W(e, t, n) {
528
+ return e === 1 && t === 1 && !n;
529
+ }
530
+ function G(e, t, n) {
531
+ return n === 0 ? e : e - t / n;
532
+ }
533
+ function K() {
534
+ return typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
535
+ }
536
+ async function q(e, t) {
537
+ e._playOrigin === void 0 && (e._playOrigin = G(t, e._time, e._rate)), e._lastClock = t;
538
+ let n = (t - e._playOrigin) * e._rate, r = e.duration * e._repeatCount, i = e._rate >= 0 ? n >= r : n <= 0, a = i ? e._rate >= 0 ? U(e.duration, e._repeatCount, e._yoyoOn) : 0 : H(n, e.duration, e._repeatCount, e._yoyoOn);
539
+ if (e._time = a, W(e._rate, e._repeatCount, e._yoyoOn)) for (let { animation: t, at: n } of e.entries) a >= n && a - n < t.options.duration && await t.advanceTo(a);
540
+ if (B(e.events, e.entries, e.labels, a), z(e.entries, a), i) {
541
+ J(e);
542
+ let t = e._resolvePlay;
543
+ return e._resolvePlay = null, t?.(), !1;
544
+ }
545
+ return !0;
546
+ }
547
+ function J(e) {
548
+ for (let { animation: t } of e.entries) t.managed = !1, t.started = !1, t.startTime = void 0;
549
+ e._playOrigin = void 0, e._lastClock = void 0, e._paused = !1;
550
+ }
551
+ function Y(e, t) {
552
+ if (!t) return;
553
+ let n = e._lastClock;
554
+ if (n === void 0) {
555
+ e._playOrigin = void 0;
556
+ return;
557
+ }
558
+ e._playOrigin = G(n, e._time, e._rate);
559
+ }
560
+ //#endregion
561
+ //#region src/animation/orchestration/sequence/events.ts
562
+ var X = class {
563
+ subscribers = new Map([
564
+ ["segment:enter", /* @__PURE__ */ new Set()],
565
+ ["segment:leave", /* @__PURE__ */ new Set()],
566
+ ["label", /* @__PURE__ */ new Set()]
567
+ ]);
568
+ _activeSegments = /* @__PURE__ */ new Set();
569
+ _prevPhase = void 0;
570
+ subscribe(e, t) {
571
+ let n = this.subscribers.get(e);
572
+ return n.add(t), () => n.delete(t);
573
+ }
574
+ fire(e, t, n) {
575
+ let r = this.subscribers.get("segment:enter"), i = this.subscribers.get("segment:leave"), a = this.subscribers.get("label");
576
+ if (r.size === 0 && i.size === 0 && a.size === 0) {
577
+ this._prevPhase = n;
578
+ return;
579
+ }
580
+ let o = this._prevPhase;
581
+ if (r.size > 0 || i.size > 0) for (let t of e) {
582
+ let e = n >= t.at && n < t.at + t.animation.options.duration, a = this._activeSegments.has(t);
583
+ if (e && !a) {
584
+ this._activeSegments.add(t);
585
+ for (let e of r) e(t.animation, n);
586
+ } else if (!e && a) {
587
+ this._activeSegments.delete(t);
588
+ for (let e of i) e(t.animation, n);
589
+ }
590
+ }
591
+ if (a.size > 0 && o !== void 0 && o !== n) {
592
+ let e = Math.min(o, n), r = Math.max(o, n);
593
+ for (let [i, o] of t) if (o > e && o <= r) for (let e of a) e(i, n);
594
+ }
595
+ this._prevPhase = n;
596
+ }
597
+ }, Z = class {
598
+ entries = [];
599
+ labels = /* @__PURE__ */ new Map();
600
+ events = new X();
601
+ cursor = 0;
602
+ _time = 0;
603
+ respectReducedMotion;
604
+ playback = new C();
605
+ _boundFrame;
606
+ _resolvePlay = null;
607
+ _playOrigin = void 0;
608
+ _playingPromise = null;
609
+ _rate = 1;
610
+ _repeatCount = 1;
611
+ _yoyoOn = !1;
612
+ _paused = !1;
613
+ _lastClock = void 0;
614
+ constructor(e) {
615
+ this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
616
+ }
617
+ get duration() {
618
+ let e = 0;
619
+ for (let t of this.entries) {
620
+ let n = t.at + t.animation.options.duration;
621
+ n > e && (e = n);
622
+ }
623
+ return e;
624
+ }
625
+ get time() {
626
+ return this._time;
627
+ }
628
+ get progress() {
629
+ return this.duration === 0 ? 0 : this._time / this.duration;
630
+ }
631
+ set progress(t) {
632
+ this.seek(e(t, 0, 1) * this.duration);
633
+ }
634
+ get rate() {
635
+ return this._rate;
636
+ }
637
+ label(e, t) {
638
+ return this.labels.set(e, V(t, this.cursor, this.labels)), this;
639
+ }
640
+ on(e, t) {
641
+ return this.events.subscribe(e, t);
642
+ }
643
+ add(e, t) {
644
+ let n = V(t, this.cursor, this.labels);
645
+ return this.entries.push({
646
+ animation: e,
647
+ at: n
648
+ }), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this;
649
+ }
650
+ seek(e) {
651
+ return this._time = e, B(this.events, this.entries, this.labels, e), z(this.entries, e), this;
652
+ }
653
+ setTargets(...e) {
654
+ for (let { animation: t } of this.entries) t.setTargets(...e);
655
+ return this;
656
+ }
657
+ get finished() {
658
+ return this._playingPromise ?? Promise.resolve();
659
+ }
660
+ play() {
661
+ if (this._playingPromise) return this._playingPromise;
662
+ if (this.respectReducedMotion && K()) return this.seek(this.duration), Promise.resolve();
663
+ for (let { animation: e, at: t } of this.entries) e.startTime = t, e.started = !0, e.managed = !0;
664
+ this._time = 0, this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0;
665
+ let e = new Promise((e) => {
666
+ this._resolvePlay = e, this.playback.loop(this._boundFrame);
667
+ });
668
+ return this._playingPromise = e, e.finally(() => {
669
+ this._playingPromise = null;
670
+ }), e;
671
+ }
672
+ async _frame(e) {
673
+ return q(this, e);
674
+ }
675
+ _reanchor() {
676
+ Y(this, this._playingPromise != null);
677
+ }
678
+ _settle() {
679
+ J(this);
680
+ }
681
+ stop() {
682
+ this.playback.stop(), this._settle();
683
+ let e = this._resolvePlay;
684
+ return this._resolvePlay = null, e?.(), this;
685
+ }
686
+ pause() {
687
+ return !this._playingPromise || this._paused ? this : (this._paused = !0, this.playback.stop(), this._playOrigin = void 0, this);
688
+ }
689
+ resume() {
690
+ return !this._playingPromise || !this._paused ? this : (this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0, this.playback.loop(this._boundFrame), this);
691
+ }
692
+ timeScale(e) {
693
+ if (!Number.isFinite(e)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${e}.`);
694
+ return this._rate = e, this._reanchor(), this;
695
+ }
696
+ reverse() {
697
+ return this._rate = -this._rate, this._reanchor(), this;
698
+ }
699
+ repeat(e) {
700
+ if (e !== Infinity && (!Number.isInteger(e) || e < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${e}.`);
701
+ return this._repeatCount = e, this;
702
+ }
703
+ yoyo(e = !0) {
704
+ return this._yoyoOn = e, this;
705
+ }
706
+ };
707
+ //#endregion
708
+ export { d as _, P as a, a as b, T as c, S as d, e as f, u as g, f as h, F as i, C as l, n as m, L as n, N as o, t as p, R as r, j as s, Z as t, x as u, s as v, o as x, i as y };