@mkbabb/keyframes.js 4.4.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 +36 -221
  2. package/dist/animation-BGyzfzBq.js +947 -0
  3. package/dist/compile-CcSUwM8R.js +276 -0
  4. package/dist/{waapi-D9MHMm_9.js → delegation-DWwr4IXr.js} +116 -32
  5. package/dist/{draw-svg-DYRDxBlL.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-CNM5xkQT.js → ingest-S5hUe20K.js} +62 -56
  16. package/dist/keyframes.d.ts +585 -989
  17. package/dist/keyframes.js +188 -129
  18. package/dist/morph-svg-BToeumw5.js +89 -0
  19. package/dist/{motion-path-J-RSNmRQ.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-5nf2kBkv.js → presets-BG2Fczzq.js} +124 -73
  23. package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
  24. package/dist/{scroll-scene-CXEgM49Q.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 +45 -6
  28. package/dist/animate-CuUJt2Tb.js +0 -26
  29. package/dist/compile-DgNRG6Lo.js +0 -251
  30. package/dist/decay-BvNmFk51.js +0 -25
  31. package/dist/engine-CNHvTgpw.js +0 -1122
  32. package/dist/errors-W8zkvPw4.js +0 -21
  33. package/dist/morph-svg-DRjl9Hfz.js +0 -62
  34. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  35. package/dist/sequence-CF5hazqz.js +0 -198
  36. package/dist/springTimingFunction-CDHZ00JQ.js +0 -63
  37. package/dist/timeline-B7SV3T_E.js +0 -442
  38. package/dist/utils-D7nuAND5.js +0 -97
  39. package/dist/validate-8r6Yo-uc.js +0 -35
@@ -1,1122 +0,0 @@
1
- import { r as e, t } from "./errors-W8zkvPw4.js";
2
- import { a as n, d as r, h as i, l as a } from "./timeline-B7SV3T_E.js";
3
- import { r as o } from "./springTimingFunction-CDHZ00JQ.js";
4
- import { n as s } from "./scheduler-7eIr_q1g.js";
5
- import { a as c, i as l, n as u, r as d, t as f } from "./utils-D7nuAND5.js";
6
- import { n as p, r as m } from "./waapi-D9MHMm_9.js";
7
- import { COLOR_SPACE_RANGES as ee, FunctionValue as h, ValueArray as g, ValueUnit as _, clamp as v, easeInOutCubic as te, extractAnimationOptions as ne, extractFunctions as re, extractKeyframes as ie, extractProperties as ae, extractTimelineOptions as oe, isObject as se, lerp as y, lerpValue as ce, parseCSSStylesheet as b, parseCSSTime as le, parseCSSValue as ue, parseCSSValueUnit as x, scale as S, seekPreviousValue as C, sleep as de, unflattenObject as fe } from "@mkbabb/value.js";
8
- //#region src/animation/resolve-values.ts
9
- var pe = 32, me = () => {
10
- let e = typeof globalThis < "u" && typeof globalThis.CSS?.supports == "function", t = typeof globalThis < "u" && typeof globalThis.matchMedia == "function";
11
- return {
12
- supports: e ? (e) => globalThis.CSS.supports(e) : () => !1,
13
- matchMedia: t ? (e) => globalThis.matchMedia(e) : () => ({ matches: !1 })
14
- };
15
- }, he = (e, t) => ({
16
- functions: e,
17
- env: {
18
- ...me(),
19
- ...t
20
- },
21
- seen: /* @__PURE__ */ new Set(),
22
- depth: 0
23
- }), w = Symbol("kf.resolve.drop"), ge = (e) => {
24
- let t = e.indexOf("(");
25
- if (t <= 0 || !e.trimEnd().endsWith(")")) return;
26
- let n = e.slice(0, t).trim().toLowerCase(), r = e.slice(t + 1, e.lastIndexOf(")")).trim();
27
- if (!(!n || !r)) return {
28
- name: n,
29
- query: r
30
- };
31
- }, _e = (e, t) => {
32
- let n = String(e instanceof _ ? e.value : e).trim();
33
- if (n === "else" || n === "") return !0;
34
- let r = ge(n);
35
- if (!r) return !1;
36
- let { name: i, query: a } = r;
37
- if (i === "supports") return t.env.supports?.(a) ?? !1;
38
- if (i === "media") return t.env.matchMedia?.(a)?.matches ?? !1;
39
- if (i !== "style") return !1;
40
- }, ve = (e) => e instanceof _ && String(e.value).trim() === "", T = (e) => {
41
- if (e === w) return e;
42
- if (e instanceof _ && e.unit === "string") try {
43
- return ue(String(e.value));
44
- } catch {
45
- return e;
46
- }
47
- return e;
48
- }, ye = (e, t) => {
49
- let n = e.values, r = n[0], i = n[1], a = n[2];
50
- if (r === void 0 || i === void 0) return w;
51
- let o = _e(r, t);
52
- return o === void 0 ? e : o ? T(E(i, t)) : a !== void 0 && !ve(a) ? T(E(a, t)) : w;
53
- }, E = (e, t) => {
54
- if (t.depth > pe) return w;
55
- if (e instanceof _ || !(e instanceof h)) return e;
56
- if (e.name === "if") return ye(e, {
57
- ...t,
58
- depth: t.depth + 1
59
- });
60
- if (e.name.startsWith("--") && t.functions.has(e.name)) return e;
61
- let n = [], r = !1;
62
- for (let i of e.values) {
63
- let e = E(i, {
64
- ...t,
65
- depth: t.depth + 1
66
- });
67
- if (e === w) {
68
- r = !0;
69
- continue;
70
- }
71
- e !== i && (r = !0), n.push(e);
72
- }
73
- return r ? new h(e.name, n) : e;
74
- }, D = (e, t) => {
75
- let n = [], r = !1;
76
- for (let i of e) {
77
- let e = E(i, t);
78
- if (e === w) {
79
- r = !0;
80
- continue;
81
- }
82
- e !== i && (r = !0), n.push(e);
83
- }
84
- return n.length === 0 ? w : r ? new g(...n) : e;
85
- }, O = (e) => e instanceof h ? e.name === "if" || e.name === "spring" ? !0 : e.values.some((e) => O(e)) : e instanceof g ? e.some((e) => O(e)) : !1, k = (e, t) => {
86
- let n = {};
87
- for (let r of e.declarations) {
88
- let e = r.value;
89
- if (e instanceof g && O(e)) {
90
- let n = D(e, t);
91
- if (n === w) continue;
92
- e = n;
93
- }
94
- n[r.name] = e;
95
- }
96
- return n;
97
- }, A = (e) => {
98
- let t = [];
99
- for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
100
- return t;
101
- }, j = (e) => {
102
- let t = ie(e);
103
- for (let e of t.values()) if (e.length > 0) return e;
104
- return [];
105
- }, M = (e, t) => {
106
- let n = [], r = (e, t) => {
107
- n.push({
108
- code: e,
109
- message: t.message ?? e,
110
- ...t
111
- });
112
- }, i = typeof e == "string" ? b(e) : e, a = j(i);
113
- typeof e == "string" && a.length === 0 && e.trim() && (i = b(`@keyframes anonymous {\n${e.trim()}\n}`), a = j(i)), typeof e == "string" && a.length === 0 && e.trim() && r("EMPTY_PARSE", {
114
- message: "the input is non-empty but parsed to zero @keyframes rules (no animatable stops) — the resulting animation has no frames",
115
- input: e
116
- });
117
- let o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = re(i), u = he(l, t);
118
- for (let e of a) {
119
- let t = k(e, u);
120
- for (let n of A(e)) {
121
- let r = o.get(n);
122
- o.set(n, {
123
- ...r ?? {},
124
- ...t
125
- }), e.timingFunction != null && s.set(n, e.timingFunction);
126
- let i = e.composition;
127
- i != null && c.set(n, i);
128
- }
129
- }
130
- return {
131
- keyframes: o,
132
- timingFunctions: s,
133
- composition: c,
134
- properties: ae(i),
135
- functions: l,
136
- options: ne(i),
137
- diagnostics: n,
138
- stylesheet: i
139
- };
140
- }, N = [
141
- "normal",
142
- "reverse",
143
- "alternate",
144
- "alternate-reverse"
145
- ], P = [
146
- "none",
147
- "forwards",
148
- "backwards",
149
- "both"
150
- ], F = Object.keys(ee), I = [
151
- "shorter",
152
- "longer",
153
- "increasing",
154
- "decreasing"
155
- ], L = () => {}, R = {
156
- duration: 1e3,
157
- delay: 0,
158
- iterationCount: 1,
159
- direction: "normal",
160
- fillMode: "forwards",
161
- timingFunction: { fn: te },
162
- useWAAPI: !0,
163
- respectReducedMotion: !1,
164
- colorSpace: "oklab"
165
- }, z = {
166
- zIndex: 0,
167
- weight: 1,
168
- blendMode: "replace",
169
- enabled: !0
170
- }, B = (e) => typeof e == "string" ? e : Q(e), V = (e, t, n) => {
171
- let r = B(t), i = e[r];
172
- if (!i) throw Error(`AnimationGroup.${n}: no animation registered for key "${r}". Known keys: ${Object.keys(e).join(", ") || "(none)"}.`);
173
- return i;
174
- }, be = (e, t, r) => {
175
- let i = new n({
176
- ...r,
177
- initial: e
178
- });
179
- return i.target = t, i;
180
- }, xe = (e) => {
181
- let t = /* @__PURE__ */ new Set();
182
- for (let n of e) {
183
- let e = n.layer.properties;
184
- for (let r of n.animation.flatKeys) e && !e.has(r) || t.add(r);
185
- }
186
- return [...t];
187
- }, H = (e, t) => {
188
- let n;
189
- for (let r of e) {
190
- let e = r.animation;
191
- if (e.paused && e.pausedTime !== 0) continue;
192
- let i = e.advanceTo(t);
193
- typeof i != "number" && (n ??= []).push(i);
194
- }
195
- return n && Promise.all(n).then(() => void 0);
196
- }, Se = async (e, t, n) => {
197
- for (let r = 0; r < e.length; r += n) await H(e.slice(r, r + n), t), r + n < e.length && await s();
198
- }, U = (e) => {
199
- let t = !0;
200
- for (let n of e) n.animation.interpFrames(n.animation.t, !0), t &&= n.animation.done;
201
- return t;
202
- }, Ce = (e) => {
203
- for (let t of e) {
204
- let e = t.animation;
205
- e.started = !0, e.t = e.options.duration, e.interpFrames(e.t, !0);
206
- }
207
- }, W = (e, t) => {
208
- for (let n of e) n.animation.paused = t;
209
- }, G = (e) => e instanceof _ && typeof e.value == "number", K = class e {
210
- animations = {};
211
- transform = L;
212
- superKey;
213
- paused = !1;
214
- started = !1;
215
- done = !1;
216
- respectReducedMotion = !1;
217
- static YIELD_BATCH = 32;
218
- singleTarget = !0;
219
- lastTickTime = 0;
220
- playback = new a();
221
- resolvePromise = null;
222
- _playingPromise = null;
223
- _boundFrame;
224
- _entries = [];
225
- _entriesDirty = !0;
226
- _grouped = {};
227
- _groupedKeys = [];
228
- _groupedKeysDirty = !0;
229
- _soaPlans = null;
230
- _compositeBuf = null;
231
- _hasLayerSprings = !1;
232
- constructor(...e) {
233
- this._boundFrame = this._frame.bind(this);
234
- let t = [];
235
- for (let n of e) {
236
- let e, r;
237
- n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform === L && e.frames[0] != null && (this.transform = e.frames[0].transform);
238
- let i = Q(e);
239
- this.animations[i] = {
240
- values: {},
241
- animation: e,
242
- layer: {
243
- ...z,
244
- ...r
245
- }
246
- }, e.managed = !0, t.push(e);
247
- }
248
- this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
249
- }
250
- getEntries() {
251
- return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
252
- }
253
- invalidateEntries() {
254
- this._entriesDirty = !0, this._groupedKeysDirty = !0;
255
- }
256
- setSuperKey(e) {
257
- this.superKey = e;
258
- for (let t of this.getEntries()) t.animation.superKey = e;
259
- return this;
260
- }
261
- setTargets(...e) {
262
- let t = this.getEntries();
263
- for (let n of t) n.animation.setTargets(...e);
264
- return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
265
- }
266
- onStart() {
267
- return this.started = !0, this;
268
- }
269
- onEnd() {
270
- return this;
271
- }
272
- transformFramesGrouped(e) {
273
- let t = this._grouped;
274
- this._groupedKeysDirty && (this._groupedKeys = xe(this.getEntries()), this._groupedKeysDirty = !1, this._soaPlans = null);
275
- let n = this._groupedKeys;
276
- for (let e = 0; e < n.length; e++) t[n[e]] = void 0;
277
- let r = this.getEntries(), i = this._soaPlans !== null, a = 0, o = !0;
278
- for (let e of r) {
279
- let { animation: n, layer: r, values: s } = e;
280
- if (o &&= n.done, !r.enabled) continue;
281
- n.interpFrames(n.t, !1, s);
282
- let c = r.properties;
283
- if (r.blendMode === "replace") {
284
- for (let e in s) {
285
- if (c && !c.has(e)) continue;
286
- let n = s[e];
287
- n !== void 0 && (t[e] = n);
288
- }
289
- continue;
290
- }
291
- if (i) {
292
- let e = this._soaPlans[a++];
293
- this.soaBlendLayer(e), e.boxedKeys.length > 0 && this.boxedBlendArm(r, s, t, c, e.boxedKeys);
294
- } else this.boxedBlendArm(r, s, t, c);
295
- }
296
- i || (this._soaPlans = this.buildSoAPlans(r)), this.done = o;
297
- for (let e = 0; e < n.length; e++) {
298
- let r = n[e];
299
- t[r] === void 0 && delete t[r];
300
- }
301
- if (this.transform === L) for (let e of this.getEntries()) {
302
- let t = e.animation.frames[0];
303
- if (t != null && t.transform != null) {
304
- this.transform = t.transform;
305
- break;
306
- }
307
- }
308
- return this.transform(t, e), t;
309
- }
310
- boxedBlendArm(e, t, n, r, i) {
311
- let a = i ? new Set(i) : void 0;
312
- if (e.blendMode === "add") {
313
- for (let e in t) {
314
- if (a && !a.has(e) || r && !r.has(e)) continue;
315
- let i = t[e];
316
- if (i === void 0) continue;
317
- let o = n[e];
318
- if (Array.isArray(o) && Array.isArray(i)) {
319
- let e = Math.min(o.length, i.length);
320
- for (let t = 0; t < e; t++) G(o[t]) && G(i[t]) ? o[t].value += i[t].value : o[t] = i[t];
321
- } else n[e] = i;
322
- }
323
- return;
324
- }
325
- let o = e.weightSpring?.value ?? e.weight;
326
- for (let e in t) {
327
- if (a && !a.has(e) || r && !r.has(e)) continue;
328
- let i = t[e];
329
- if (i === void 0) continue;
330
- let s = n[e];
331
- if (Array.isArray(s) && Array.isArray(i)) {
332
- let e = Math.min(s.length, i.length);
333
- for (let t = 0; t < e; t++) G(s[t]) && G(i[t]) ? s[t].value = y(s[t].value, i[t].value, o) : s[t] = i[t];
334
- } else n[e] = i;
335
- }
336
- }
337
- soaBlendLayer(e) {
338
- let { carriers: t, incomings: n } = e, r = t.length;
339
- if (r === 0) return;
340
- let i = this._compositeBuf;
341
- for (let e = 0; e < r; e++) i[e] = t[e].value;
342
- if (e.weighted) {
343
- let t = e.layer.weightSpring?.value ?? e.layer.weight;
344
- for (let e = 0; e < r; e++) i[e] = y(i[e], n[e].value, t);
345
- } else for (let e = 0; e < r; e++) i[e] = i[e] + n[e].value;
346
- for (let e = 0; e < r; e++) t[e].value = i[e];
347
- }
348
- buildSoAPlans(e) {
349
- let t = [], n = {}, r = 0;
350
- for (let i of e) {
351
- let { layer: e, values: a } = i;
352
- if (!e.enabled) continue;
353
- let o = e.properties, s = e.blendMode === "weighted";
354
- if (e.blendMode === "replace") {
355
- for (let e in a) {
356
- if (o && !o.has(e)) continue;
357
- let t = a[e];
358
- t !== void 0 && (n[e] = t);
359
- }
360
- continue;
361
- }
362
- let c = [], l = [], u = [];
363
- for (let e in a) {
364
- if (o && !o.has(e)) continue;
365
- let t = a[e];
366
- if (t === void 0) continue;
367
- let r = n[e];
368
- if (Array.isArray(r) && Array.isArray(t)) {
369
- let n = Math.min(r.length, t.length), i = !0;
370
- for (let e = 0; e < n; e++) if (!G(r[e]) || !G(t[e])) {
371
- i = !1;
372
- break;
373
- }
374
- if (i) for (let e = 0; e < n; e++) c.push(r[e]), l.push(t[e]);
375
- else u.push(e);
376
- } else u.push(e), n[e] = t;
377
- }
378
- c.length > r && (r = c.length), t.push({
379
- layer: e,
380
- weighted: s,
381
- carriers: c,
382
- incomings: l,
383
- boxedKeys: u
384
- });
385
- }
386
- return r > 0 && (this._compositeBuf === null || this._compositeBuf.length < r) && (this._compositeBuf = new Float64Array(r)), t;
387
- }
388
- render() {
389
- let e = this.lastTickTime || performance.now();
390
- this.singleTarget ? this.transformFramesGrouped(e) : U(this.getEntries());
391
- }
392
- setChildTime(e, t) {
393
- let n = V(this.animations, e, "setChildTime").animation;
394
- return n.t = t, n.startTime !== void 0 && (n.pausedTime = n.startTime + t), this;
395
- }
396
- advanceTo(t) {
397
- let n = this.lastTickTime === 0 ? 0 : t - this.lastTickTime;
398
- this._hasLayerSprings && this.advanceLayerSprings(n), this.lastTickTime = t, this.started || this.onStart();
399
- let r = this.getEntries(), i = e.YIELD_BATCH, a = r.length <= i ? H(r, t) : Se(r, t, i);
400
- return a ? a.then(() => this._endAdvance()) : this._endAdvance();
401
- }
402
- _endAdvance() {
403
- return this.done && this.onEnd(), this;
404
- }
405
- _frame(e) {
406
- let t = this.advanceTo(e);
407
- return typeof t.then == "function" ? t.then(() => this._renderFrame(e)) : this._renderFrame(e);
408
- }
409
- _renderFrame(e) {
410
- return this.paused ? !1 : (this.singleTarget ? this.transformFramesGrouped(e) : this.done = U(this.getEntries()), this.done ? (this.settle(), this._resolvePlay(), !1) : !0);
411
- }
412
- _resolvePlay() {
413
- let e = this.resolvePromise;
414
- this.resolvePromise = null, e?.();
415
- }
416
- get finished() {
417
- return this._playingPromise ?? Promise.resolve();
418
- }
419
- async play() {
420
- if (this._playingPromise) return this._playingPromise;
421
- let e = r(this.respectReducedMotion, () => this._playReducedMotion(), () => new Promise((e) => {
422
- this.resolvePromise = e, this.playback.loop(this._boundFrame);
423
- }));
424
- return this._playingPromise = e, e.finally(() => {
425
- this._playingPromise = null;
426
- }), e;
427
- }
428
- _playReducedMotion() {
429
- this.onStart();
430
- let e = this.lastTickTime || performance.now();
431
- return this.lastTickTime = e, Ce(this.getEntries()), this.singleTarget && this.transformFramesGrouped(e), this.settle(), Promise.resolve();
432
- }
433
- pause() {
434
- if (!this.started || this.paused) return this;
435
- this.paused = !0;
436
- let e = this.lastTickTime || performance.now();
437
- for (let t of this.getEntries()) {
438
- let n = t.animation;
439
- n.pause(), n.pausedTime === 0 && (n.pausedTime = e);
440
- }
441
- return this.playback.stop(), this.render(), this;
442
- }
443
- resume() {
444
- return !this.started || !this.paused ? this : (this.paused = !1, W(this.getEntries(), !1), this.playback.loop(this._boundFrame), this);
445
- }
446
- toggle() {
447
- return this.paused ? this.resume() : this.pause();
448
- }
449
- settle() {
450
- for (let e of this.getEntries()) e.animation.managed = !1, e.animation.settle();
451
- return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
452
- }
453
- reset() {
454
- for (let e of this.getEntries()) {
455
- let t = e.animation;
456
- t.started && t.frames.length > 0 && t.interpFrames(0, !0);
457
- }
458
- return this.settle();
459
- }
460
- stop() {
461
- return this.playback.stop(), this.reset(), this._resolvePlay(), this;
462
- }
463
- playing() {
464
- return !(!this.started || this.paused);
465
- }
466
- forcePause() {
467
- this.paused = !0, W(this.getEntries(), !0);
468
- }
469
- forcePlay() {
470
- this.paused = !1, W(this.getEntries(), !1);
471
- }
472
- setLayerConfig(e, t) {
473
- let n = V(this.animations, e, "setLayerConfig");
474
- return Object.assign(n.layer, t), this.invalidateEntries(), this;
475
- }
476
- setLayerEnabled(e, t) {
477
- return this.setLayerConfig(e, { enabled: t });
478
- }
479
- getLayerConfig(e) {
480
- return this.animations[B(e)]?.layer;
481
- }
482
- transitionLayer(e, t) {
483
- let r = V(this.animations, e, "transitionLayer").layer;
484
- r.blendMode = "weighted";
485
- let i = r.weightSpring;
486
- return i instanceof n ? i.target = t.weight : r.weightSpring = be(r.weight, t.weight, t.spring), this._hasLayerSprings = !0, this.invalidateEntries(), this;
487
- }
488
- crossfade(e, t, n) {
489
- let r = n?.spring;
490
- return this.transitionLayer(e, {
491
- weight: 0,
492
- ...r ? { spring: r } : {}
493
- }), this.transitionLayer(t, {
494
- weight: 1,
495
- ...r ? { spring: r } : {}
496
- }), this;
497
- }
498
- advanceLayerSprings(e) {
499
- let t = !1;
500
- for (let n of this.getEntries()) {
501
- let r = n.layer.weightSpring;
502
- r !== void 0 && (e > 0 && r.tickDt(e), r.settled ? (n.layer.weight = r.value, delete n.layer.weightSpring) : t = !0);
503
- }
504
- this._hasLayerSprings = t;
505
- }
506
- };
507
- //#endregion
508
- //#region src/animation/engine-composition.ts
509
- function q(e) {
510
- for (let t of e) if (t.composition != null && t.composition !== "replace") return !0;
511
- return !1;
512
- }
513
- function we(e, t) {
514
- e.clear(), t.clear();
515
- }
516
- function Te(e, t) {
517
- let n = e.composition;
518
- if (n == null || n === "replace") return;
519
- let r = e.flatVars;
520
- for (let i in r) {
521
- let a = r[i];
522
- if (!Array.isArray(a) || a.length === 0) continue;
523
- if (!a.every((e) => e instanceof _ && typeof e.value == "number")) {
524
- Oe(i, n, t);
525
- continue;
526
- }
527
- let o = t.compositionBase.get(i);
528
- o === void 0 && (o = Ee(t.target, i, a.length), t.compositionBase.set(i, o));
529
- let s = n === "accumulate" ? t.iteration : 0;
530
- for (let n = 0; n < a.length; n++) {
531
- let r = a[n], c = o[n] ?? 0;
532
- s > 0 ? r.value = c + s * (De(e, i, n, t.compositionBase) - c) + r.value : r.value = c + r.value;
533
- }
534
- }
535
- }
536
- function Ee(e, t, n) {
537
- let r = Array(n).fill(0);
538
- if (e == null || e.style == null) return r;
539
- let i = t.split(".").pop() ?? t, a = e.style.getPropertyValue(i) || e.style[i] || "";
540
- if (!a) return r;
541
- let o = a.match(/-?\d*\.?\d+(?:e[+-]?\d+)?/gi);
542
- if (o == null) return r;
543
- for (let e = 0; e < n && e < o.length; e++) {
544
- let t = Number.parseFloat(o[e]);
545
- Number.isFinite(t) && (r[e] = t);
546
- }
547
- return r;
548
- }
549
- function De(e, t, n, r) {
550
- let i = e.interpVars[t]?.[n]?.stop;
551
- return i instanceof _ && typeof i.value == "number" ? i.value : r.get(t)?.[n] ?? 0;
552
- }
553
- function Oe(e, t, n) {
554
- n.compositionFallbackSeen.has(e) || (n.compositionFallbackSeen.add(e), n.diagnostics.push({
555
- code: "COMPOSITION_FALLBACK",
556
- message: `animation-composition: ${t} on a non-numeric leaf "${e}" has no faithful numeric add — composited as \`replace\` (the lerped value), never a wrong sum`,
557
- property: e
558
- }));
559
- }
560
- //#endregion
561
- //#region src/animation/frame-compiler.ts
562
- var J = (e, n) => {
563
- if (typeof n == "function") return { fn: n };
564
- if (typeof n == "object") {
565
- if (typeof n.fn == "function") return n;
566
- throw new t(e, n, "an Easing must carry a callable `fn`");
567
- }
568
- let r = d(n);
569
- if (!r) throw new t(e, n, "unknown timing function — pass a callable TimingFunction, a typed Easing, a registry name, or a cubic-bezier() literal", "UNKNOWN_TIMING_FN");
570
- let a = i(n);
571
- return a ? {
572
- fn: r,
573
- css: a
574
- } : { fn: r };
575
- }, ke = 1e6, Ae = /^(?:from|to)$/i, je = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, Me = /^(?:entry|exit|cover|contain)(?:\s+\d+(?:\.\d+)?%)?$/i, Ne = "named-selector", Y = "a keyframe selector must be a percentage 0%–100% (e.g. \"0%\", \"50%\"), the keyword 'from'/'to', or a scroll-range named selector (entry/exit/cover/contain, optionally with a range fraction like 'entry 0%')", Pe = class {
576
- _options;
577
- templateFrames = [];
578
- parsedVars = [];
579
- frames = [];
580
- frameId = 0;
581
- constructor(e) {
582
- this._options = e;
583
- }
584
- get options() {
585
- return this._options;
586
- }
587
- addFrame(e, n, r, i, a) {
588
- typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof _ && (e = String(e));
589
- let o = e.trim();
590
- if (o === "") throw new t("start", e, `${Y} — got an empty/blank string`, "EMPTY_PARSE");
591
- let s;
592
- if (Me.test(o)) s = new _(o, void 0, [Ne]);
593
- else {
594
- if (!Ae.test(o) && !(je.test(o) && parseFloat(o) <= 100)) throw new t("start", e, `${Y} — got ${JSON.stringify(e)}`);
595
- s = x(o);
596
- }
597
- let c = {
598
- id: this.frameId,
599
- start: s,
600
- vars: n,
601
- transform: r,
602
- timingFunction: i == null ? this.options.timingFunction : J("timingFunction", i),
603
- composition: a
604
- };
605
- this.templateFrames.push(c), this.frameId += 1;
606
- }
607
- createFrame(e, t) {
608
- let n = this.templateFrames[e], r = this.templateFrames[t], i = {
609
- start: e,
610
- stop: t
611
- }, a = f(n, r, this.options.duration), o = n.transform;
612
- if (o == null) {
613
- let t = C(e, this.templateFrames, (e) => e.transform != null);
614
- o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? L;
615
- }
616
- let s = n.timingFunction;
617
- if (s == null) {
618
- let t = C(e, this.templateFrames, (e) => e.timingFunction != null);
619
- s = (t === void 0 ? void 0 : this.templateFrames[t].timingFunction) ?? this.options.timingFunction;
620
- }
621
- let c = e * ke + t, l = r.composition;
622
- return {
623
- id: c,
624
- ixs: i,
625
- start: n.start,
626
- time: a,
627
- vars: void 0,
628
- flatVars: void 0,
629
- interpVars: {},
630
- allInterpVars: [],
631
- transform: o,
632
- timingFunction: s,
633
- ...l == null ? {} : { composition: l }
634
- };
635
- }
636
- buildVarIndex() {
637
- let e = /* @__PURE__ */ new Map();
638
- for (let t = 0; t < this.parsedVars.length; t++) for (let n of Object.keys(this.parsedVars[t])) {
639
- let r = e.get(n);
640
- r || (r = [], e.set(n, r)), r.push(t);
641
- }
642
- return e;
643
- }
644
- reconcileVars(e, t) {
645
- let n = this.parsedVars[e];
646
- if (n) for (let r of Object.keys(n)) {
647
- let n = t.get(r);
648
- if (!n) continue;
649
- let i = -1;
650
- for (let t of n) if (t > e) {
651
- i = t;
652
- break;
653
- }
654
- if (i === -1) continue;
655
- let [a, o] = [e, i], s = this.frames.findIndex((e) => e.ixs.start === a && e.ixs.stop === o), c = s === -1 ? this.createFrame(a, o) : this.frames[s];
656
- c.interpVars[r] = u(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(c);
657
- }
658
- }
659
- parse(e) {
660
- this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((t) => {
661
- let n = l(t.vars);
662
- return Object.values(n).forEach((t) => {
663
- t.setTargets(e);
664
- }), n;
665
- });
666
- for (let e = 0; e < this.templateFrames.length - 1; e++) this.frames.push(this.createFrame(e, e + 1));
667
- let t = this.buildVarIndex();
668
- this.frames.forEach((e, n) => this.reconcileVars(n, t)), this.frames.sort((e, t) => e.time.start === t.time.start ? e.time.stop - t.time.stop : e.time.start - t.time.start), this.frames = this.frames.filter((e) => e.interpVars != null && Object.keys(e.interpVars).length > 0), this.frames.forEach((e) => this.finalizeFrameVars(e));
669
- }
670
- finalizeFrameVars(e) {
671
- e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = fe(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
672
- }
673
- renormalizeColors() {
674
- for (let e of this.frames) {
675
- for (let t of Object.keys(e.interpVars)) e.interpVars[t] = u(t, e.ixs.start, e.ixs.stop, this.parsedVars, this.options.colorSpace, this.options.hueMethod);
676
- this.finalizeFrameVars(e);
677
- }
678
- }
679
- }, X = (e) => {
680
- try {
681
- let t = le(e);
682
- return Number.isFinite(t) ? t : void 0;
683
- } catch {
684
- return;
685
- }
686
- };
687
- function Fe(e) {
688
- return e == null ? R.timingFunction : J("timingFunction", e);
689
- }
690
- function Ie(t) {
691
- return t == null ? R.iterationCount : t === "infinite" || t === "∞" || t === "Infinity" || t === Infinity ? Infinity : e("iterationCount", t, (e) => {
692
- let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
693
- return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
694
- }, "expected a non-negative count, \"infinite\", or Infinity");
695
- }
696
- function Le(t) {
697
- if (t != null) return e("duration", t, (e) => {
698
- let t = typeof e == "string" ? X(e) : e;
699
- return typeof t == "number" && isFinite(t) && t > 0 ? t : void 0;
700
- }, "expected a positive duration in milliseconds or a CSS time string");
701
- }
702
- function Re(t) {
703
- return t == null ? R.delay : e("delay", t, (e) => {
704
- let t = typeof e == "string" ? X(e) : e;
705
- return typeof t == "number" && isFinite(t) ? t : void 0;
706
- }, "expected a delay in milliseconds or a CSS time string");
707
- }
708
- function ze(e) {
709
- if (e == null) return R.direction;
710
- if (!N.includes(e)) throw new t("direction", e, `expected one of: ${N.join(", ")}`);
711
- return e;
712
- }
713
- function Be(e) {
714
- if (e == null) return R.fillMode;
715
- if (!P.includes(e)) throw new t("fillMode", e, `expected one of: ${P.join(", ")}`);
716
- return e;
717
- }
718
- function Z(e, n) {
719
- if (n == null) return R[e];
720
- if (typeof n != "boolean") throw new t(e, n, "expected a boolean");
721
- return n;
722
- }
723
- function Ve(e) {
724
- if (e == null) return R.colorSpace;
725
- if (!F.includes(e)) throw new t("colorSpace", e, `expected one of: ${F.join(", ")}`);
726
- return e;
727
- }
728
- function He(e) {
729
- if (e != null) {
730
- if (!I.includes(e)) throw new t("hueMethod", e, `expected one of: ${I.join(", ")}`);
731
- return e;
732
- }
733
- }
734
- //#endregion
735
- //#region src/animation/engine-css-metadata.ts
736
- function Ue(e) {
737
- let t = {};
738
- return e.duration != null && (t.duration = e.duration), e.timingFunction != null && (t.timingFunction = e.timingFunction), e.iterationCount !== void 0 && (t.iterationCount = e.iterationCount === null ? Infinity : e.iterationCount), e.direction != null && (t.direction = e.direction), e.delay != null && (t.delay = e.delay), e.fillMode != null && (t.fillMode = e.fillMode), e.composition != null && (t.composite = e.composition), t;
739
- }
740
- function We(e) {
741
- let t = oe(e);
742
- return Object.keys(t).length > 0 ? t : void 0;
743
- }
744
- function Ge(e) {
745
- if (!(typeof CSS > "u" || typeof CSS.registerProperty != "function")) for (let [t, n] of e) {
746
- if (n.syntax == null) continue;
747
- let e = {
748
- name: t,
749
- syntax: n.syntax,
750
- inherits: n.inherits ?? !1
751
- };
752
- n.initialValue != null && (e.initialValue = n.initialValue.toString());
753
- try {
754
- CSS.registerProperty(e);
755
- } catch {}
756
- }
757
- }
758
- //#endregion
759
- //#region src/animation/engine.ts
760
- var Ke = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), qe = 0, $ = class {
761
- id = qe++;
762
- name;
763
- superKey;
764
- targets;
765
- options;
766
- _compiler;
767
- get compiler() {
768
- return this._compiler;
769
- }
770
- playback = new a();
771
- _waAnimations = [];
772
- startTime = void 0;
773
- pausedTime = 0;
774
- t = 0;
775
- iteration = 0;
776
- diagnostics = [];
777
- _compositionBase = /* @__PURE__ */ new Map();
778
- _compositionFallbackSeen = /* @__PURE__ */ new Set();
779
- _hasComposition = !1;
780
- started = !1;
781
- done = !1;
782
- reversed = !1;
783
- paused = !1;
784
- managed = !1;
785
- waapiIneligibleReason = void 0;
786
- unflatten = !0;
787
- resolvePromise = null;
788
- _playingPromise = null;
789
- _boundFrame = this._frame.bind(this);
790
- _interpOut = {};
791
- _stableKeys = [];
792
- _ctorOptions = {};
793
- get flatKeys() {
794
- return this._stableKeys;
795
- }
796
- _defaultTransform = (e) => c(e, this.targets);
797
- usesDefaultRenderer(e) {
798
- return e === this._defaultTransform;
799
- }
800
- dispatchAnimationEvent(e) {
801
- if (!(typeof AnimationEvent > "u")) for (let t of this.targets) typeof t?.dispatchEvent == "function" && t.dispatchEvent(new AnimationEvent(e, {
802
- animationName: this.name ?? "",
803
- elapsedTime: this.t / 1e3
804
- }));
805
- }
806
- constructor(e, t, n, r) {
807
- this.options = {}, this._compiler = new Pe(this.options), this._ctorOptions = e ?? {}, this.setOptions({
808
- ...R,
809
- ...this._ctorOptions
810
- }), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
811
- }
812
- get templateFrames() {
813
- return this.compiler.templateFrames;
814
- }
815
- set templateFrames(e) {
816
- this.compiler.templateFrames = e;
817
- }
818
- get parsedVars() {
819
- return this.compiler.parsedVars;
820
- }
821
- get frames() {
822
- return this.compiler.frames;
823
- }
824
- get frameId() {
825
- return this.compiler.frameId;
826
- }
827
- addFrame(e, t, n, r, i) {
828
- return this.compiler.addFrame(e, t, n, r, i), this;
829
- }
830
- parse() {
831
- return this.compiler.parse(this.targets), this.computeStableKeys(), this.computeHasComposition(), this;
832
- }
833
- computeHasComposition() {
834
- this._hasComposition = q(this.frames), we(this._compositionBase, this._compositionFallbackSeen);
835
- }
836
- adoptCompiled(e) {
837
- return this._compiler = e.compiler, this.options = this.compiler.options, this.unflatten = e.unflatten, this.computeStableKeys(), this.computeHasComposition(), this;
838
- }
839
- computeStableKeys() {
840
- let e = /* @__PURE__ */ new Set();
841
- for (let t of this.frames) for (let n in t.flatVars) e.add(n);
842
- this._stableKeys = [...e];
843
- }
844
- setTimingFunction(e) {
845
- return this.options.timingFunction = Fe(e), this;
846
- }
847
- setIterationCount(e) {
848
- return this.options.iterationCount = Ie(e), this;
849
- }
850
- setDuration(e) {
851
- let t = Le(e);
852
- if (t === void 0) return this;
853
- let n = t / this.options.duration;
854
- for (let e = 0; e < this.frames.length; e++) {
855
- let t = this.frames[e];
856
- t.time.start *= n, t.time.stop *= n;
857
- }
858
- return this.options.duration = t, this;
859
- }
860
- setDelay(e) {
861
- return this.options.delay = Re(e), this;
862
- }
863
- setDirection(e) {
864
- return this.options.direction = ze(e), this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && (this.reversed = !0), this;
865
- }
866
- setFillMode(e) {
867
- return this.options.fillMode = Be(e), this;
868
- }
869
- setUseWAAPI(e) {
870
- return this.options.useWAAPI = Z("useWAAPI", e), this;
871
- }
872
- setRespectReducedMotion(e) {
873
- return this.options.respectReducedMotion = Z("respectReducedMotion", e), this;
874
- }
875
- setColorSpace(e) {
876
- return this.options.colorSpace = Ve(e), this.frames.length > 0 && this.compiler.renormalizeColors(), this;
877
- }
878
- setHueMethod(e) {
879
- let t = He(e);
880
- return t === void 0 ? this : (this.options.hueMethod = t, this.frames.length > 0 && this.compiler.renormalizeColors(), this);
881
- }
882
- setComposite(e) {
883
- return e === void 0 || (this.options.composite = e), this;
884
- }
885
- setOptions(e) {
886
- return this.setTimingFunction(e.timingFunction), this.setDuration(e.duration), this.setIterationCount(e.iterationCount), this.setDelay(e.delay), this.setDirection(e.direction), this.setFillMode(e.fillMode), this.setUseWAAPI(e.useWAAPI), this.setRespectReducedMotion(e.respectReducedMotion), this.setColorSpace(e.colorSpace), this.setHueMethod(e.hueMethod), this.setComposite(e.composite), this;
887
- }
888
- reverse() {
889
- if (this.startTime !== void 0) {
890
- let e = this.t, t = this.options.duration - 2 * e;
891
- this.startTime -= t;
892
- }
893
- return this.reversed = !this.reversed, this;
894
- }
895
- fillForwards() {
896
- this.interpFrames(this.options.duration, !0);
897
- }
898
- fillBackwards() {
899
- this.interpFrames(0, !0);
900
- }
901
- get restPosition() {
902
- return this.options.fillMode === "forwards" || this.options.fillMode === "both" ? "final" : "initial";
903
- }
904
- paintRest() {
905
- this.restPosition === "final" ? this.fillForwards() : this.fillBackwards();
906
- }
907
- at(e, t = !1) {
908
- let n = this.reversed;
909
- this.reversed = !1;
910
- let r = v(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
911
- return this.reversed = n, i;
912
- }
913
- interpFrames(e, t = !1, n) {
914
- e = this.reversed ? this.options.duration - e : e;
915
- let r = this.frames, i = r.length, a = o(r, e, (e) => e.time.start, (e) => e.time.stop);
916
- if (a === -1) return n === void 0 ? {} : (this.clearBuffer(n), n);
917
- let s = a, c = a;
918
- for (let t = a - 1; t >= 0; t--) {
919
- let n = r[t];
920
- if (e < n.time.start || e > n.time.stop) break;
921
- s = t;
922
- }
923
- for (let t = a + 1; t < i; t++) {
924
- let n = r[t];
925
- if (e < n.time.start || e > n.time.stop) break;
926
- c = t;
927
- }
928
- for (let n = s; n <= c; n++) this.processFrame(r[n], e, t);
929
- if (s === c) {
930
- let e = r[a].flatVars;
931
- return n === void 0 ? e : (this.clearBuffer(n), Object.assign(n, e), n);
932
- }
933
- let l = n ?? {};
934
- n !== void 0 && this.clearBuffer(n);
935
- for (let e = s; e <= c; e++) Object.assign(l, r[e].flatVars);
936
- return l;
937
- }
938
- clearBuffer(e) {
939
- let t = this._stableKeys;
940
- for (let n = 0; n < t.length; n++) e[t[n]] = void 0;
941
- }
942
- processFrame(e, t, n) {
943
- let { start: r, stop: i } = e.time, a = r === i ? 1 : S(t, r, i, 0, 1), o = e.timingFunction.fn(a);
944
- for (let t of e.allInterpVars) ce(o, t);
945
- n && this._hasComposition && e.composition != null && this.applyComposition(e), n && e.transform(this.unflatten ? e.vars : e.flatVars, t);
946
- }
947
- applyComposition(e) {
948
- Te(e, {
949
- iteration: this.iteration,
950
- target: this.targets[0],
951
- compositionBase: this._compositionBase,
952
- compositionFallbackSeen: this._compositionFallbackSeen,
953
- diagnostics: this.diagnostics
954
- });
955
- }
956
- onStart() {
957
- if (this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && this.reverse(), (this.options.fillMode === "backwards" || this.options.fillMode === "both") && this.fillBackwards(), this.options.delay > 0) return this.paused = !0, de(this.options.delay).then(() => {
958
- this.paused = !1, this.started = !0;
959
- });
960
- this.started = !0;
961
- }
962
- onEnd() {
963
- this.paintRest(), this.startTime = void 0, this.iteration >= this.options.iterationCount - 1 ? (this.done = !0, this.iteration = 0, this.dispatchAnimationEvent("animationend")) : (this.iteration += 1, this.dispatchAnimationEvent("animationiteration"));
964
- }
965
- advanceTo(e) {
966
- if (this.startTime === void 0) {
967
- let t = this.onStart(), n = () => (this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart"), this._advance(e));
968
- return t ? t.then(n) : n();
969
- }
970
- return this._advance(e);
971
- }
972
- _advance(e) {
973
- if (this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
974
- if (this.pausedTime > 0 && !this.paused) {
975
- let t = e - this.pausedTime;
976
- this.startTime += t, this.pausedTime = 0;
977
- }
978
- return this.t = e - this.startTime, this.t >= this.options.duration && (this.onEnd(), this.t = this.options.duration), this.t;
979
- }
980
- _frame(e) {
981
- if (r(this.options.respectReducedMotion, () => !0, () => !1)) return this._snapToReducedMotion(), !1;
982
- let t = this.advanceTo(e);
983
- return typeof t == "number" ? this._renderFrame(t) : t.then((e) => this._renderFrame(e));
984
- }
985
- _renderFrame(e) {
986
- return this.paused ? !1 : this.done ? (this.settle(), this._resolvePlay(), !1) : (this.interpFrames(e, !0, this._interpOut), !0);
987
- }
988
- _resolvePlay() {
989
- let e = this.resolvePromise;
990
- this.resolvePromise = null, e?.();
991
- }
992
- _playRAF() {
993
- return new Promise((e) => {
994
- this.resolvePromise = e, this.playback.loop(this._boundFrame);
995
- });
996
- }
997
- async _playWAAPI() {
998
- await m(this), this.settle();
999
- }
1000
- _cancelWAAPI() {
1001
- if (this._waAnimations.length !== 0) {
1002
- for (let e of this._waAnimations) try {
1003
- e.cancel();
1004
- } catch {}
1005
- this._waAnimations = [];
1006
- }
1007
- }
1008
- async _playReducedMotion() {
1009
- this.started = !0, this.dispatchAnimationEvent("animationstart"), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle();
1010
- }
1011
- _snapToReducedMotion() {
1012
- this._cancelWAAPI(), this.fillForwards(), this.iteration = 0, this.done = !0, this.dispatchAnimationEvent("animationend"), this.settle(), this._resolvePlay();
1013
- }
1014
- get finished() {
1015
- return this._playingPromise ?? Promise.resolve();
1016
- }
1017
- async play() {
1018
- if (this.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
1019
- if (this._playingPromise) return this._playingPromise;
1020
- let e = r(this.options.respectReducedMotion, () => (this.waapiIneligibleReason = void 0, this._playReducedMotion()), () => {
1021
- if (this.options.useWAAPI) {
1022
- let e = p(this);
1023
- return e.eligible ? (this.waapiIneligibleReason = void 0, this._playWAAPI()) : (this.waapiIneligibleReason = e.reason, this._playRAF());
1024
- }
1025
- return this.waapiIneligibleReason = void 0, this._playRAF();
1026
- });
1027
- return this._playingPromise = e, e.finally(() => {
1028
- this._playingPromise = null;
1029
- }), e;
1030
- }
1031
- pause() {
1032
- return this.started && (this.paused = !0), this;
1033
- }
1034
- resume() {
1035
- if (this.started && this.paused) if (this.paused = !1, this._waAnimations.length > 0) for (let e of this._waAnimations) e.play();
1036
- else this.playback.running || this.playback.loop(this._boundFrame);
1037
- return this;
1038
- }
1039
- toggle() {
1040
- return this.paused ? this.resume() : this.pause();
1041
- }
1042
- stop() {
1043
- this._cancelWAAPI(), this.playback.stop(), this.settle(), this._resolvePlay();
1044
- }
1045
- playing() {
1046
- return !(!this.started || this.paused);
1047
- }
1048
- get effectiveT() {
1049
- return this.reversed ? this.options.duration - this.t : this.t;
1050
- }
1051
- settle() {
1052
- return this.done = !1, this.started = !1, this.paused = !1, this.reversed = !1, this.iteration = 0, this.startTime = void 0, this.pausedTime = 0, this.t = 0, this;
1053
- }
1054
- reset() {
1055
- return this._cancelWAAPI(), this.started && this.frames.length > 0 && this.fillBackwards(), this.settle();
1056
- }
1057
- setTargets(...e) {
1058
- return this.targets = e, this.frames.forEach((e) => {
1059
- Object.values(e.interpVars).forEach((e) => {
1060
- e.forEach(({ start: e, stop: t, value: n }) => {
1061
- e.setTargets(this.targets), t.setTargets(this.targets), n.setTargets(this.targets);
1062
- });
1063
- });
1064
- }), this;
1065
- }
1066
- group(...e) {
1067
- return new K(this, ...e);
1068
- }
1069
- }, Je = class extends $ {
1070
- constructor(e, ...t) {
1071
- super(e, t), this.unflatten = !1;
1072
- }
1073
- resolveTransform(e) {
1074
- return this.unflatten = e != null, e ?? this._defaultTransform;
1075
- }
1076
- fromVars(e, t) {
1077
- t = this.resolveTransform(t);
1078
- for (let n = 0; n < e.length; n++) {
1079
- let r = e[n], i = Math.round(n / (e.length - 1) * 100);
1080
- this.addFrame(i, r, t);
1081
- }
1082
- return this.parse(), this;
1083
- }
1084
- fromKeyframes(e, t) {
1085
- t = this.resolveTransform(t), se(e) && (e = new Map(Object.entries(e)));
1086
- let n = e instanceof Map ? e.entries() : Object.entries(e);
1087
- for (let [e, r] of n) this.addFrame(e, r, t);
1088
- return this.parse(), this;
1089
- }
1090
- propertyRegistry = /* @__PURE__ */ new Map();
1091
- scrollOptions;
1092
- fromString(e, t) {
1093
- t = this.resolveTransform(t);
1094
- let n = M(e);
1095
- this.propertyRegistry = n.properties;
1096
- let r = We(n.stylesheet);
1097
- r === void 0 ? delete this.scrollOptions : this.scrollOptions = r, this.diagnostics = [...n.diagnostics];
1098
- let a = Ue(n.options);
1099
- Object.keys(a).length > 0 && this.setOptions({
1100
- ...a,
1101
- ...this._ctorOptions
1102
- });
1103
- for (let [e, r] of n.keyframes.entries()) {
1104
- let a = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, Ke(t) ? t.clone() : t])), o = n.timingFunctions.get(e), s = o ? d(o) : void 0, c;
1105
- if (s) {
1106
- let e = o ? i(o) : void 0;
1107
- c = e ? {
1108
- fn: s,
1109
- css: e
1110
- } : { fn: s };
1111
- }
1112
- let l = n.composition.get(e);
1113
- this.addFrame(e, a, t, c, l);
1114
- }
1115
- return this.parse(), Ge(this.propertyRegistry), this;
1116
- }
1117
- transform(e) {
1118
- c(e, this.targets);
1119
- }
1120
- };
1121
- //#endregion
1122
- export { $ as Animation, $ as KeyframesAnimation, K as AnimationGroup, Je as CSSKeyframesAnimation, N as DIRECTIONS, P as FILL_MODES, z as defaultLayerConfig, R as defaultOptions, Q as getAnimationId, d as getTimingFunction, M as resolveKeyframes };