@mkbabb/keyframes.js 5.1.0 → 5.2.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 (35) hide show
  1. package/README.md +83 -3
  2. package/dist/backward-color-BtbRcnna.js +108 -0
  3. package/dist/compile-BHCTPerD.js +30 -0
  4. package/dist/{delegation-DWwr4IXr.js → delegation-BQYCrP2p.js} +5 -9
  5. package/dist/{draw-svg-GURj9nin.js → draw-svg-CK9Qrly8.js} +13 -25
  6. package/dist/easing-serialize-D4LZCB6i.js +21 -0
  7. package/dist/engine/index.d.ts +422 -156
  8. package/dist/engine/index.js +16 -17
  9. package/dist/engine-CPK_udUQ.js +1172 -0
  10. package/dist/engine-DlpimZtM.js +3 -0
  11. package/dist/entry-D82NKUhP.js +148 -0
  12. package/dist/format-BdIvdLzG.js +114 -0
  13. package/dist/{group-vJcsHKN9.js → group-HM7N4uOE.js} +153 -123
  14. package/dist/handle-D4xrf_ya.js +21 -0
  15. package/dist/{ingest-S5hUe20K.js → ingest-_g6tfk2e.js} +2 -2
  16. package/dist/keyframes.d.ts +702 -178
  17. package/dist/keyframes.js +295 -74
  18. package/dist/morph-svg-KUrH9KnK.js +79 -0
  19. package/dist/motion-path-wM5tPfrY.js +26 -0
  20. package/dist/presets-DeDJYL4G.js +275 -0
  21. package/dist/{scheduler-CUtVnuoU.js → scheduler-CfGIC3GX.js} +1 -1
  22. package/dist/{scroll-CxpYFO4u.js → scroll-BEyCx0b_.js} +165 -58
  23. package/dist/{sequence-C_DCiOIQ.js → sequence-s0bL7Uul.js} +118 -90
  24. package/dist/{validate-DDeGnvSt.js → validate-xFZ_Ld1k.js} +7 -7
  25. package/dist/view-transition-BPJQxUTC.js +305 -0
  26. package/package.json +113 -83
  27. package/dist/animation-BGyzfzBq.js +0 -947
  28. package/dist/compile-CcSUwM8R.js +0 -276
  29. package/dist/engine-DEVgCTUy.js +0 -156
  30. package/dist/engine-DrBtsKaf.js +0 -4
  31. package/dist/format-C-Gi9r7L.js +0 -123
  32. package/dist/grammar-BLucehC4.js +0 -23
  33. package/dist/morph-svg-BToeumw5.js +0 -89
  34. package/dist/motion-path-pQVbamWT.js +0 -35
  35. package/dist/presets-BG2Fczzq.js +0 -275
@@ -1,947 +0,0 @@
1
- import { d as e, g as t, h as n, l as r, x as i, y as a } from "./sequence-C_DCiOIQ.js";
2
- import { n as o, r as s, t as c } from "./parse-flatten-ZZUSEQEL.js";
3
- import { i as l, n as u, r as ee } from "./delegation-DWwr4IXr.js";
4
- import { t as te } from "./easing-registry-DHV2-5gA.js";
5
- import { COLOR_SPACE_RANGES as ne, FunctionValue as d, ValueArray as f, ValueUnit as p, clamp as re, coerceToSyntax as ie, easeInOutCubic as ae, lerpArray as oe, lerpValue as m, parseCSSTime as se, parseCSSValue as h, parseCSSValueUnit as ce, scale as le, seekPreviousValue as g, sleep as ue, unflattenObject as de } from "@mkbabb/value.js";
6
- //#region src/animation/constants.ts
7
- var _ = [
8
- "normal",
9
- "reverse",
10
- "alternate",
11
- "alternate-reverse"
12
- ], v = [
13
- "none",
14
- "forwards",
15
- "backwards",
16
- "both"
17
- ], y = Object.keys(ne), fe = [
18
- "shorter",
19
- "longer",
20
- "increasing",
21
- "decreasing"
22
- ], b = () => {}, x = {
23
- duration: 1e3,
24
- delay: 0,
25
- iterationCount: 1,
26
- direction: "normal",
27
- fillMode: "forwards",
28
- timingFunction: { fn: ae },
29
- useWAAPI: !0,
30
- respectReducedMotion: !1,
31
- colorSpace: "oklab"
32
- }, pe = {
33
- zIndex: 0,
34
- weight: 1,
35
- blendMode: "replace",
36
- enabled: !0
37
- }, S = null, me = (e) => {
38
- S = e;
39
- }, he = () => {
40
- if (S === null) throw Error("AnimationGroup factory not registered — the group/ zone must be loaded (it is, transitively, via loadAnimationEngine()) before KeyframesAnimation.group() is called.");
41
- return S;
42
- }, ge = 1e6, _e = /^(?:from|to)$/i, ve = /^(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?%$/, ye = /^(?:entry|exit|cover|contain)(?:\s+\d+(?:\.\d+)?%)?$/i, C = "named-selector", be = /^(entry|exit|cover|contain)(?:\s+(\d+(?:\.\d+)?)%)?$/i, xe = (e) => {
43
- let t = be.exec(e.trim());
44
- if (t === null) throw new a("start", e, "not a conforming scroll-range named selector (entry/exit/cover/contain, optionally with a range fraction like 'entry 50%')", "NAMED_SELECTOR_NO_TIMELINE");
45
- let n = l[t[1].toLowerCase()], r = t[2];
46
- if (r === void 0) return n.start;
47
- let i = Number.parseFloat(r) / 100;
48
- return n.start + i * (n.end - n.start);
49
- }, w = "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%')", Se = (e) => typeof e.start.value == "number" && typeof e.stop.value == "number" && e.computed !== !0 && e.value.unit !== "color" && e._colorPlan == null, Ce = (e) => {
50
- let t = [], n = [];
51
- for (let r of e) Se(r) ? t.push(r) : n.push(r);
52
- let r = t.length, i = new Float64Array(r), a = new Float64Array(r);
53
- for (let e = 0; e < r; e++) i[e] = t[e].start.value, a[e] = t[e].stop.value;
54
- return {
55
- numeric: t,
56
- from: i,
57
- to: a,
58
- out: new Float64Array(r),
59
- boxed: n
60
- };
61
- }, T = (e, n) => {
62
- if (typeof n == "function") return { fn: n };
63
- if (typeof n == "object") {
64
- if (typeof n.fn == "function") return n;
65
- throw new a(e, n, "an Easing must carry a callable `fn`");
66
- }
67
- let r = te(n);
68
- if (!r) throw new a(e, n, "unknown timing function — pass a callable TimingFunction, a typed Easing, a registry name, or a cubic-bezier() literal", "UNKNOWN_TIMING_FN");
69
- let i = t(n);
70
- return i ? {
71
- fn: r,
72
- css: i
73
- } : { fn: r };
74
- };
75
- //#endregion
76
- //#region src/animation/compile/frame-compiler.ts
77
- function we(e, t, n) {
78
- let [r, i] = [e.start, t.start];
79
- return {
80
- start: r.value * n / 100,
81
- stop: i.value * n / 100
82
- };
83
- }
84
- var Te = class {
85
- _options;
86
- templateFrames = [];
87
- parsedVars = [];
88
- frames = [];
89
- frameId = 0;
90
- constructor(e) {
91
- this._options = e;
92
- }
93
- get options() {
94
- return this._options;
95
- }
96
- addFrame(e, t, n, r, i) {
97
- typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof p && (e = String(e));
98
- let o = e.trim();
99
- if (o === "") throw new a("start", e, `${w} — got an empty/blank string`, "EMPTY_PARSE");
100
- let s;
101
- if (ye.test(o)) s = new p(o, void 0, [C]);
102
- else {
103
- if (!_e.test(o) && !(ve.test(o) && parseFloat(o) <= 100)) throw new a("start", e, `${w} — got ${JSON.stringify(e)}`);
104
- s = ce(o);
105
- }
106
- let c = {
107
- id: this.frameId,
108
- start: s,
109
- vars: t,
110
- transform: n,
111
- timingFunction: r == null ? this.options.timingFunction : T("timingFunction", r),
112
- composition: i
113
- };
114
- this.templateFrames.push(c), this.frameId += 1;
115
- }
116
- createFrame(e, t) {
117
- let n = this.templateFrames[e], r = this.templateFrames[t], i = {
118
- start: e,
119
- stop: t
120
- }, a = we(n, r, this.options.duration), o = n.transform;
121
- if (o == null) {
122
- let t = g(e, this.templateFrames, (e) => e.transform != null);
123
- o = (t === void 0 ? void 0 : this.templateFrames[t].transform) ?? b;
124
- }
125
- let s = n.timingFunction;
126
- if (s == null) {
127
- let t = g(e, this.templateFrames, (e) => e.timingFunction != null);
128
- s = (t === void 0 ? void 0 : this.templateFrames[t].timingFunction) ?? this.options.timingFunction;
129
- }
130
- let c = e * ge + t, l = r.composition;
131
- return {
132
- id: c,
133
- ixs: i,
134
- start: n.start,
135
- time: a,
136
- vars: void 0,
137
- flatVars: void 0,
138
- interpVars: {},
139
- allInterpVars: [],
140
- transform: o,
141
- timingFunction: s,
142
- ...l == null ? {} : { composition: l }
143
- };
144
- }
145
- buildVarIndex() {
146
- let e = /* @__PURE__ */ new Map();
147
- for (let t = 0; t < this.parsedVars.length; t++) for (let n of Object.keys(this.parsedVars[t])) {
148
- let r = e.get(n);
149
- r || (r = [], e.set(n, r)), r.push(t);
150
- }
151
- return e;
152
- }
153
- reconcileVars(e, t) {
154
- let n = this.parsedVars[e];
155
- if (n) for (let r of Object.keys(n)) {
156
- let n = t.get(r);
157
- if (!n) continue;
158
- let i = -1;
159
- for (let t of n) if (t > e) {
160
- i = t;
161
- break;
162
- }
163
- if (i === -1) continue;
164
- let [a, o] = [e, i], s = this.frames.findIndex((e) => e.ixs.start === a && e.ixs.stop === o), l = s === -1 ? this.createFrame(a, o) : this.frames[s];
165
- l.interpVars[r] = c(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(l);
166
- }
167
- }
168
- parse(e) {
169
- this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((t) => {
170
- let n = o(t.vars);
171
- return Object.values(n).forEach((t) => {
172
- t.setTargets(e);
173
- }), n;
174
- });
175
- for (let e = 0; e < this.templateFrames.length - 1; e++) this.frames.push(this.createFrame(e, e + 1));
176
- let t = this.buildVarIndex();
177
- 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));
178
- }
179
- finalizeFrameVars(e) {
180
- e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = de(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat(), e._numericPlan = Ce(e.allInterpVars);
181
- }
182
- renormalizeColors() {
183
- for (let e of this.frames) {
184
- for (let t of Object.keys(e.interpVars)) e.interpVars[t] = c(t, e.ixs.start, e.ixs.stop, this.parsedVars, this.options.colorSpace, this.options.hueMethod);
185
- this.finalizeFrameVars(e);
186
- }
187
- }
188
- }, Ee = class {
189
- resolvePromise = null;
190
- _playingPromise = null;
191
- _waAnimations = [];
192
- _boundFrame;
193
- _interpOut = {};
194
- constructor(e) {
195
- this._boundFrame = e;
196
- }
197
- };
198
- function De(e, t) {
199
- if (!(typeof AnimationEvent > "u")) for (let n of e.targets) typeof n?.dispatchEvent == "function" && n.dispatchEvent(new AnimationEvent(t, {
200
- animationName: e.name ?? "",
201
- elapsedTime: e.t / 1e3
202
- }));
203
- }
204
- function Oe(e, t) {
205
- return e === "reverse" || e === "alternate-reverse" && t % 2 == 0 || e === "alternate" && t % 2 == 1;
206
- }
207
- function ke(e) {
208
- if (e.reversed = !1, Oe(e.options.direction, e.iteration) && e.reverse(), (e.options.fillMode === "backwards" || e.options.fillMode === "both") && e.fillBackwards(), e.options.delay > 0) return e.paused = !0, ue(e.options.delay).then(() => {
209
- e.paused = !1, e.started = !0;
210
- });
211
- e.started = !0;
212
- }
213
- function Ae(e) {
214
- e.paintRest(), e.startTime = void 0, e.iteration >= e.options.iterationCount - 1 ? (e.done = !0, e.iteration = 0, e.dispatchAnimationEvent("animationend")) : (e.iteration += 1, e.dispatchAnimationEvent("animationiteration"));
215
- }
216
- function je(e, t) {
217
- if (e.startTime === void 0) {
218
- let n = ke(e), r = () => (e.startTime = t + e.options.delay, e.dispatchAnimationEvent("animationstart"), Me(e, t));
219
- return n ? n.then(r) : r();
220
- }
221
- return Me(e, t);
222
- }
223
- function Me(e, t) {
224
- if (e.paused && e.pausedTime === 0) return e.pausedTime = t, e.t;
225
- if (e.pausedTime > 0 && !e.paused) {
226
- let n = t - e.pausedTime;
227
- e.startTime += n, e.pausedTime = 0;
228
- }
229
- return e.t = t - e.startTime, e.t >= e.options.duration && (Ae(e), e.t = e.options.duration), e.t;
230
- }
231
- function Ne(t, n) {
232
- if (e(t.options.respectReducedMotion, () => !0, () => !1)) return Ie(t), !1;
233
- let r = t.advanceTo(n);
234
- return typeof r == "number" ? E(t, r) : r.then((e) => E(t, e));
235
- }
236
- function E(e, t) {
237
- return e.paused ? !1 : e.done ? (A(e), D(e), !1) : (e.interpFrames(t, !0, e._playback._interpOut), !0);
238
- }
239
- function D(e) {
240
- let t = e._playback.resolvePromise;
241
- e._playback.resolvePromise = null, t?.();
242
- }
243
- function O(e) {
244
- return new Promise((t) => {
245
- e._playback.resolvePromise = t, e.playback.loop(e._playback._boundFrame);
246
- });
247
- }
248
- async function Pe(e) {
249
- await u(e), A(e);
250
- }
251
- function k(e) {
252
- let t = e._playback._waAnimations;
253
- if (t.length !== 0) {
254
- for (let e of t) try {
255
- e.cancel();
256
- } catch {}
257
- e._playback._waAnimations = [];
258
- }
259
- }
260
- async function Fe(e) {
261
- e.started = !0, e.dispatchAnimationEvent("animationstart"), e.fillForwards(), e.iteration = 0, e.done = !0, e.dispatchAnimationEvent("animationend"), A(e);
262
- }
263
- function Ie(e) {
264
- k(e), e.fillForwards(), e.iteration = 0, e.done = !0, e.dispatchAnimationEvent("animationend"), A(e), D(e);
265
- }
266
- async function Le(t) {
267
- if (t.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
268
- if (t.assertNoUnresolvedNamedSelector(), t._playback._playingPromise) return t._playback._playingPromise;
269
- let n = e(t.options.respectReducedMotion, () => (t.waapiIneligibleReason = void 0, Fe(t)), () => {
270
- if (t.options.useWAAPI) {
271
- let e = ee(t);
272
- return e.eligible ? (t.waapiIneligibleReason = void 0, Pe(t)) : (t.waapiIneligibleReason = e.reason, O(t));
273
- }
274
- return t.waapiIneligibleReason = void 0, O(t);
275
- });
276
- return t._playback._playingPromise = n, n.finally(() => {
277
- t._playback._playingPromise = null;
278
- }), n;
279
- }
280
- function Re(e) {
281
- e.started && (e.paused = !0);
282
- }
283
- function ze(e) {
284
- if (e.started && e.paused) if (e.paused = !1, e._playback._waAnimations.length > 0) for (let t of e._playback._waAnimations) t.play();
285
- else e.playback.running || e.playback.loop(e._playback._boundFrame);
286
- }
287
- function Be(e) {
288
- k(e), e.playback.stop(), A(e), D(e);
289
- }
290
- function Ve(e) {
291
- return !(!e.started || e.paused);
292
- }
293
- function He(e) {
294
- return e.reversed ? e.options.duration - e.t : e.t;
295
- }
296
- function A(e) {
297
- e.done = !1, e.started = !1, e.paused = !1, e.reversed = !1, e.iteration = 0, e.startTime = void 0, e.pausedTime = 0, e.t = 0;
298
- }
299
- function Ue(e) {
300
- k(e), e.started && e.frames.length > 0 && e.fillBackwards(), A(e);
301
- }
302
- //#endregion
303
- //#region src/animation/engine/composition.ts
304
- function We(e) {
305
- for (let t of e) if (t.composition != null && t.composition !== "replace") return !0;
306
- return !1;
307
- }
308
- function Ge(e, t) {
309
- e.clear(), t.clear();
310
- }
311
- function Ke(e, t) {
312
- let n = e.composition;
313
- if (n == null || n === "replace") return;
314
- let r = e.flatVars;
315
- for (let i in r) {
316
- let a = r[i];
317
- if (!Array.isArray(a) || a.length === 0) continue;
318
- if (!a.every((e) => e instanceof p && typeof e.value == "number")) {
319
- Ye(i, n, t);
320
- continue;
321
- }
322
- let o = t.compositionBase.get(i);
323
- o === void 0 && (o = qe(t.target, i, a.length), t.compositionBase.set(i, o));
324
- let s = n === "accumulate" ? t.iteration : 0;
325
- for (let n = 0; n < a.length; n++) {
326
- let r = a[n], c = o[n] ?? 0;
327
- s > 0 ? r.value = c + s * (Je(e, i, n, t.compositionBase) - c) + r.value : r.value = c + r.value;
328
- }
329
- }
330
- }
331
- function qe(e, t, n) {
332
- let r = Array(n).fill(0);
333
- if (e == null || e.style == null) return r;
334
- let i = t.split(".").pop() ?? t, a = e.style.getPropertyValue(i) || e.style[i] || "";
335
- if (!a) return r;
336
- let o = a.match(/-?\d*\.?\d+(?:e[+-]?\d+)?/gi);
337
- if (o == null) return r;
338
- for (let e = 0; e < n && e < o.length; e++) {
339
- let t = Number.parseFloat(o[e]);
340
- Number.isFinite(t) && (r[e] = t);
341
- }
342
- return r;
343
- }
344
- function Je(e, t, n, r) {
345
- let i = e.interpVars[t]?.[n]?.stop;
346
- return i instanceof p && typeof i.value == "number" ? i.value : r.get(t)?.[n] ?? 0;
347
- }
348
- function Ye(e, t, n) {
349
- n.compositionFallbackSeen.has(e) || (n.compositionFallbackSeen.add(e), n.diagnostics.push({
350
- code: "COMPOSITION_FALLBACK",
351
- 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`,
352
- property: e
353
- }));
354
- }
355
- //#endregion
356
- //#region src/animation/engine/interpolate.ts
357
- function j(e) {
358
- return e.options.fillMode === "forwards" || e.options.fillMode === "both" ? "final" : "initial";
359
- }
360
- function Xe(e) {
361
- j(e) === "final" ? N(e, e.options.duration, !0) : N(e, 0, !0);
362
- }
363
- function M(e) {
364
- let t = e.compiler.templateFrames.find((e) => e.start.superType?.includes(C));
365
- if (t != null) {
366
- let e = String(t.start.value);
367
- throw new a("start", e, `named scroll-range selector ("${e}") requires a ScrollTimeline or ManualTimeline — call bindTimeline(timeline) before play() to resolve the named phase to a numeric position`, "NAMED_SELECTOR_NO_TIMELINE");
368
- }
369
- }
370
- function Ze(e, t, n = !1) {
371
- M(e);
372
- let r = e.reversed;
373
- e.reversed = !1;
374
- let i = N(e, re(t, 0, 1) * e.options.duration, n);
375
- return e.reversed = r, i;
376
- }
377
- function N(e, t, r = !1, i) {
378
- t = e.reversed ? e.options.duration - t : t;
379
- let a = e.frames, o = a.length, s = n(a, t, (e) => e.time.start, (e) => e.time.stop);
380
- if (s === -1) return i === void 0 ? {} : (P(e, i), i);
381
- let c = s, l = s;
382
- for (let e = s - 1; e >= 0; e--) {
383
- let n = a[e];
384
- if (t < n.time.start || t > n.time.stop) break;
385
- c = e;
386
- }
387
- for (let e = s + 1; e < o; e++) {
388
- let n = a[e];
389
- if (t < n.time.start || t > n.time.stop) break;
390
- l = e;
391
- }
392
- for (let n = c; n <= l; n++) Qe(e, a[n], t, r);
393
- if (c === l) {
394
- let t = a[s].flatVars;
395
- return i === void 0 ? t : (P(e, i), Object.assign(i, t), i);
396
- }
397
- let u = i ?? {};
398
- i !== void 0 && P(e, i);
399
- for (let e = c; e <= l; e++) Object.assign(u, a[e].flatVars);
400
- return u;
401
- }
402
- function P(e, t) {
403
- let n = e._stableKeys;
404
- for (let e = 0; e < n.length; e++) t[n[e]] = void 0;
405
- }
406
- function Qe(e, t, n, r) {
407
- let { start: i, stop: a } = t.time, o = i === a ? 1 : le(n, i, a, 0, 1), s = t.timingFunction.fn(o), c = t._numericPlan;
408
- if (c !== void 0 && c.numeric.length > 0) {
409
- let { numeric: e, from: t, to: n, out: r } = c;
410
- oe(t, n, s, r);
411
- for (let t = 0; t < e.length; t++) e[t].value.value = r[t];
412
- for (let e of c.boxed) m(s, e);
413
- } else for (let e of t.allInterpVars) m(s, e);
414
- r && e._hasComposition && t.composition != null && $e(e, t), r && t.transform(e.unflatten ? t.vars : t.flatVars, n);
415
- }
416
- function $e(e, t) {
417
- Ke(t, {
418
- iteration: e.iteration,
419
- target: e.targets[0],
420
- compositionBase: e._compositionBase,
421
- compositionFallbackSeen: e._compositionFallbackSeen,
422
- diagnostics: e.diagnostics
423
- });
424
- }
425
- //#endregion
426
- //#region src/animation/engine/options.ts
427
- var F = (e) => {
428
- try {
429
- let t = se(e);
430
- return Number.isFinite(t) ? t : void 0;
431
- } catch {
432
- return;
433
- }
434
- };
435
- function et(e) {
436
- return e == null ? x.timingFunction : T("timingFunction", e);
437
- }
438
- function tt(e) {
439
- return e == null ? x.iterationCount : e === "infinite" || e === "∞" || e === "Infinity" || e === Infinity ? Infinity : i("iterationCount", e, (e) => {
440
- let t = typeof e == "string" ? Number.parseFloat(e.trim()) : e;
441
- return typeof t == "number" && !Number.isNaN(t) && t >= 0 ? t : void 0;
442
- }, "expected a non-negative count, \"infinite\", or Infinity");
443
- }
444
- function nt(e) {
445
- if (e != null) return i("duration", e, (e) => {
446
- let t = typeof e == "string" ? F(e) : e;
447
- return typeof t == "number" && isFinite(t) && t > 0 ? t : void 0;
448
- }, "expected a positive duration in milliseconds or a CSS time string");
449
- }
450
- function rt(e) {
451
- return e == null ? x.delay : i("delay", e, (e) => {
452
- let t = typeof e == "string" ? F(e) : e;
453
- return typeof t == "number" && isFinite(t) ? t : void 0;
454
- }, "expected a delay in milliseconds or a CSS time string");
455
- }
456
- function it(e) {
457
- if (e == null) return x.direction;
458
- if (!_.includes(e)) throw new a("direction", e, `expected one of: ${_.join(", ")}`);
459
- return e;
460
- }
461
- function at(e) {
462
- if (e == null) return x.fillMode;
463
- if (!v.includes(e)) throw new a("fillMode", e, `expected one of: ${v.join(", ")}`);
464
- return e;
465
- }
466
- function I(e, t) {
467
- if (t == null) return x[e];
468
- if (typeof t != "boolean") throw new a(e, t, "expected a boolean");
469
- return t;
470
- }
471
- function ot(e) {
472
- if (e == null) return x.colorSpace;
473
- if (!y.includes(e)) throw new a("colorSpace", e, `expected one of: ${y.join(", ")}`);
474
- return e;
475
- }
476
- function st(e) {
477
- if (e != null) {
478
- if (!fe.includes(e)) throw new a("hueMethod", e, `expected one of: ${fe.join(", ")}`);
479
- return e;
480
- }
481
- }
482
- //#endregion
483
- //#region src/animation/engine/option-setters.ts
484
- function L(e, t) {
485
- e.options.timingFunction = et(t);
486
- }
487
- function R(e, t) {
488
- e.options.iterationCount = tt(t);
489
- }
490
- function z(e, t) {
491
- let n = nt(t);
492
- if (n === void 0) return;
493
- let r = n / e.options.duration;
494
- for (let t = 0; t < e.frames.length; t++) {
495
- let n = e.frames[t];
496
- n.time.start *= r, n.time.stop *= r;
497
- }
498
- e.options.duration = n;
499
- }
500
- function B(e, t) {
501
- e.options.delay = rt(t);
502
- }
503
- function V(e, t) {
504
- e.options.direction = it(t), e.reversed = Oe(e.options.direction, e.iteration);
505
- }
506
- function ct(e, t) {
507
- e.options.fillMode = at(t);
508
- }
509
- function H(e, t) {
510
- e.options.useWAAPI = I("useWAAPI", t);
511
- }
512
- function U(e, t) {
513
- e.options.respectReducedMotion = I("respectReducedMotion", t);
514
- }
515
- function W(e, t) {
516
- e.options.colorSpace = ot(t), e.frames.length > 0 && e.compiler.renormalizeColors();
517
- }
518
- function G(e, t) {
519
- let n = st(t);
520
- n !== void 0 && (e.options.hueMethod = n, e.frames.length > 0 && e.compiler.renormalizeColors());
521
- }
522
- function K(e, t) {
523
- t !== void 0 && (e.options.composite = t);
524
- }
525
- function lt(e, t) {
526
- L(e, t.timingFunction), z(e, t.duration), R(e, t.iterationCount), B(e, t.delay), V(e, t.direction), ct(e, t.fillMode), H(e, t.useWAAPI), U(e, t.respectReducedMotion), W(e, t.colorSpace), G(e, t.hueMethod), K(e, t.composite);
527
- }
528
- //#endregion
529
- //#region src/animation/engine/compile-bridge.ts
530
- function ut(e) {
531
- e.compiler.parse(e.targets), J(e), q(e);
532
- }
533
- function q(e) {
534
- e._hasComposition = We(e.frames), Ge(e._compositionBase, e._compositionFallbackSeen);
535
- }
536
- function J(e) {
537
- let t = /* @__PURE__ */ new Set();
538
- for (let n of e.frames) for (let e in n.flatVars) t.add(e);
539
- e._stableKeys = [...t];
540
- }
541
- function dt(e, t) {
542
- e._setCompiler(t.compiler), e.options = e.compiler.options, e.unflatten = t.unflatten, J(e), q(e);
543
- }
544
- //#endregion
545
- //#region src/animation/resolve/env.ts
546
- var ft = () => {
547
- let e = typeof globalThis < "u" && typeof globalThis.CSS?.supports == "function", t = typeof globalThis < "u" && typeof globalThis.matchMedia == "function";
548
- return {
549
- supports: e ? (e) => globalThis.CSS.supports(e) : () => !1,
550
- matchMedia: t ? (e) => globalThis.matchMedia(e) : () => ({ matches: !1 })
551
- };
552
- }, pt = (e, t, n) => {
553
- let r = {
554
- functions: e,
555
- env: {
556
- ...ft(),
557
- ...t
558
- },
559
- seen: /* @__PURE__ */ new Set(),
560
- depth: 0
561
- };
562
- return n !== void 0 && (r.diagnostics = n), r;
563
- }, Y = Symbol("kf.resolve.drop"), mt = "1.2.0", ht = (e) => {
564
- let t = e.name.trim(), n = t.search(/\s/), r = n === -1 ? t : t.slice(0, n), i = n === -1 ? "" : t.slice(n).trim(), a = i.startsWith("<") && i.endsWith(">") ? i : void 0, o = e.type !== void 0 && !(e.type.startsWith("<") && e.type.endsWith(">")) ? e.type : void 0;
565
- return {
566
- ident: r,
567
- syntax: a,
568
- defaultValue: e.defaultValue ?? o
569
- };
570
- }, gt = (e, t, n) => {
571
- if (t.syntax === void 0) return e;
572
- let r = ie(String(e), t.syntax);
573
- if (r !== null) return r;
574
- if (t.defaultValue === void 0) return Y;
575
- try {
576
- return h(t.defaultValue);
577
- } catch (e) {
578
- return n?.push({
579
- code: "CUSTOM_FN_ARG_DROP",
580
- property: t.ident,
581
- message: `--fn() arg coercion: default for ${t.ident} failed to parse (value.js ≤${mt} bug — ${String(e)})`
582
- }), Y;
583
- }
584
- }, _t = (e, t) => !(e instanceof p) || e.unit !== "var" ? !1 : String(e.value).split(",", 1)[0]?.trim() === t, X = (e, t) => {
585
- if (e instanceof p) {
586
- if (e.unit === "var") {
587
- for (let [n, r] of t) if (_t(e, n)) return r.clone();
588
- }
589
- return e;
590
- }
591
- let n = e.values.map((e) => X(e, t));
592
- return new d(e.name, n);
593
- }, vt = (e, t, n) => {
594
- if (t.seen.has(e.name)) return Y;
595
- let r = t.functions.get(e.name);
596
- if (r === void 0 || r.result === void 0) return Y;
597
- let i = (r.parameters ?? []).map(ht), a = e.values;
598
- if (a.length > i.length) return Y;
599
- let o = /* @__PURE__ */ new Map();
600
- for (let e = 0; e < i.length; e++) {
601
- let n = i[e], r = a[e], s;
602
- if (r === void 0) {
603
- if (n.defaultValue === void 0) return Y;
604
- try {
605
- s = h(n.defaultValue);
606
- } catch (e) {
607
- return t.diagnostics?.push({
608
- code: "CUSTOM_FN_ARG_DROP",
609
- property: n.ident,
610
- message: `--fn() missing-positional default for ${n.ident} failed to parse (value.js ≤${mt} bug — ${String(e)})`
611
- }), Y;
612
- }
613
- } else s = gt(r, n, t.diagnostics);
614
- if (s === Y) return Y;
615
- o.set(n.ident, s);
616
- }
617
- let s = r.result.clone().map((e) => X(e, o));
618
- t.seen.add(e.name);
619
- let c = [];
620
- for (let e of s) {
621
- let r = n(e, {
622
- ...t,
623
- depth: t.depth + 1
624
- });
625
- r !== Y && c.push(r);
626
- }
627
- return t.seen.delete(e.name), c.length === 0 ? Y : c[0];
628
- }, yt = (e) => {
629
- let t = e.indexOf("(");
630
- if (t <= 0 || !e.trimEnd().endsWith(")")) return;
631
- let n = e.slice(0, t).trim().toLowerCase(), r = e.slice(t + 1, e.lastIndexOf(")")).trim();
632
- if (!(!n || !r)) return {
633
- name: n,
634
- query: r
635
- };
636
- }, bt = (e, t) => {
637
- let n = String(e instanceof p ? e.value : e).trim();
638
- if (n === "else" || n === "") return !0;
639
- let r = yt(n);
640
- if (!r) return !1;
641
- let { name: i, query: a } = r;
642
- return i === "supports" ? t.env.supports?.(a) ?? !1 : i === "media" ? t.env.matchMedia?.(a)?.matches ?? !1 : i === "style" ? t.env.customProps === void 0 ? void 0 : xt(a, t.env.customProps) : !1;
643
- }, xt = (e, t) => {
644
- let n = e.indexOf(":");
645
- if (n === -1) {
646
- let n = e.trim();
647
- return n === "" ? !1 : t(n) !== void 0;
648
- }
649
- let r = e.slice(0, n).trim(), i = e.slice(n + 1).trim();
650
- if (r === "") return !1;
651
- let a = t(r);
652
- if (a === void 0) return !1;
653
- let o = (e) => e.trim().replace(/\s+/g, " ");
654
- return o(a) === o(i);
655
- }, St = (e) => e instanceof p && String(e.value).trim() === "", Ct = (e) => {
656
- if (e === Y) return e;
657
- if (e instanceof p && e.unit === "string") try {
658
- return h(String(e.value));
659
- } catch {
660
- return e;
661
- }
662
- return e;
663
- }, wt = (e, t, n) => {
664
- let r = e.values, i = r[0], a = r[1], o = r[2];
665
- if (i === void 0 || a === void 0) return Y;
666
- let s = bt(i, t);
667
- return s === void 0 ? e : s ? Ct(n(a, t)) : o !== void 0 && !St(o) ? Ct(n(o, t)) : Y;
668
- }, Tt = (e) => {
669
- if (e.name !== "if") return !1;
670
- let t = e.values[0];
671
- return t === void 0 ? !1 : yt(String(t instanceof p ? t.value : t).trim())?.name === "style";
672
- }, Et = 32, Z = (e, t) => {
673
- if (t.depth > Et) return Y;
674
- if (e instanceof p || !(e instanceof d)) return e;
675
- if (e.name === "if") return wt(e, {
676
- ...t,
677
- depth: t.depth + 1
678
- }, Z);
679
- if (e.name === "sibling-index") {
680
- let n = t.env.siblingIndex;
681
- return n === void 0 ? e : new p(n(), "");
682
- }
683
- if (e.name === "sibling-count") {
684
- let n = t.env.siblingCount;
685
- return n === void 0 ? e : new p(n(), "");
686
- }
687
- if (e.name.startsWith("--") && t.functions.has(e.name)) return vt(e, t, Z);
688
- let n = [], r = !1;
689
- for (let i of e.values) {
690
- let e = Z(i, {
691
- ...t,
692
- depth: t.depth + 1
693
- });
694
- if (e === Y) {
695
- r = !0;
696
- continue;
697
- }
698
- e !== i && (r = !0), n.push(e);
699
- }
700
- return r ? new d(e.name, n) : e;
701
- }, Dt = (e, t) => {
702
- let n = [], r = !1;
703
- for (let i of e) {
704
- let e = Z(i, t);
705
- if (e === Y) {
706
- r = !0;
707
- continue;
708
- }
709
- e !== i && (r = !0), n.push(e);
710
- }
711
- return n.length === 0 ? Y : r ? new f(...n) : e;
712
- }, Q = (e) => e instanceof d ? e.name === "if" || e.name === "spring" || e.name === "sibling-index" || e.name === "sibling-count" || e.name.startsWith("--") ? !0 : e.values.some((e) => Q(e)) : e instanceof f ? e.some((e) => Q(e)) : !1, $ = (e) => e instanceof d ? e.name === "sibling-index" || e.name === "sibling-count" || Tt(e) ? !0 : e.values.some((e) => $(e)) : e instanceof f ? e.some((e) => $(e)) : !1;
713
- //#endregion
714
- //#region src/animation/engine/element-resolve.ts
715
- function Ot(e) {
716
- let t = e.compiler.templateFrames, n = !1;
717
- for (let e of t) {
718
- let t = e.vars;
719
- for (let e in t) if ($(t[e])) {
720
- n = !0;
721
- break;
722
- }
723
- if (n) break;
724
- }
725
- if (!n) return !1;
726
- let r = kt(e);
727
- if (r === void 0) return !1;
728
- let i = pt(/* @__PURE__ */ new Map(), r), a = !1;
729
- for (let e of t) {
730
- let t = e.vars;
731
- for (let e in t) {
732
- let n = t[e];
733
- if (!(n instanceof f) || !$(n)) continue;
734
- let r = Dt(n, i);
735
- if (r === Y) {
736
- delete t[e], a = !0;
737
- continue;
738
- }
739
- r !== n && (t[e] = r, a = !0);
740
- }
741
- }
742
- return a ? (e.parse(), !0) : !1;
743
- }
744
- function kt(e) {
745
- let t = e.targets[0];
746
- if (t == null) return;
747
- let n = { customProps: (e) => {
748
- let n = "";
749
- return t instanceof Element && typeof getComputedStyle == "function" && (n = getComputedStyle(t).getPropertyValue(e).trim()), n === "" && (n = t.style.getPropertyValue(e).trim()), n === "" ? void 0 : n;
750
- } }, r = t.parentElement;
751
- return r != null && (n.siblingIndex = () => Array.prototype.indexOf.call(r.children, t) + 1, n.siblingCount = () => r.children.length), n;
752
- }
753
- //#endregion
754
- //#region src/animation/internal/animation-id.ts
755
- var At = (e) => typeof e == "string" ? e : e.name ?? String(e.id), jt = 0, Mt = class {
756
- id = jt++;
757
- name;
758
- superKey;
759
- targets;
760
- options;
761
- _compiler;
762
- get compiler() {
763
- return this._compiler;
764
- }
765
- playback = new r();
766
- _playback;
767
- startTime = void 0;
768
- pausedTime = 0;
769
- t = 0;
770
- iteration = 0;
771
- diagnostics = [];
772
- _compositionBase = /* @__PURE__ */ new Map();
773
- _compositionFallbackSeen = /* @__PURE__ */ new Set();
774
- _hasComposition = !1;
775
- started = !1;
776
- done = !1;
777
- reversed = !1;
778
- paused = !1;
779
- managed = !1;
780
- waapiIneligibleReason = void 0;
781
- unflatten = !0;
782
- _stableKeys = [];
783
- _ctorOptions = {};
784
- get flatKeys() {
785
- return this._stableKeys;
786
- }
787
- _defaultTransform = (e) => s(e, this.targets);
788
- usesDefaultRenderer(e) {
789
- return e === this._defaultTransform;
790
- }
791
- dispatchAnimationEvent(e) {
792
- De(this, e);
793
- }
794
- constructor(e, t, n, r) {
795
- this.options = {}, this._compiler = new Te(this.options), this._playback = new Ee(this._frame.bind(this)), this._ctorOptions = e ?? {}, this.setOptions({
796
- ...x,
797
- ...this._ctorOptions
798
- }), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
799
- }
800
- get templateFrames() {
801
- return this.compiler.templateFrames;
802
- }
803
- set templateFrames(e) {
804
- this.compiler.templateFrames = e;
805
- }
806
- get parsedVars() {
807
- return this.compiler.parsedVars;
808
- }
809
- get frames() {
810
- return this.compiler.frames;
811
- }
812
- get frameId() {
813
- return this.compiler.frameId;
814
- }
815
- addFrame(e, t, n, r, i) {
816
- return this.compiler.addFrame(e, t, n, r, i), this;
817
- }
818
- parse() {
819
- return ut(this), this;
820
- }
821
- adoptCompiled(e) {
822
- return dt(this, e), this;
823
- }
824
- _setCompiler(e) {
825
- this._compiler = e;
826
- }
827
- setTimingFunction(e) {
828
- return L(this, e), this;
829
- }
830
- setIterationCount(e) {
831
- return R(this, e), this;
832
- }
833
- setDuration(e) {
834
- return z(this, e), this;
835
- }
836
- setDelay(e) {
837
- return B(this, e), this;
838
- }
839
- setDirection(e) {
840
- return V(this, e), this;
841
- }
842
- setFillMode(e) {
843
- return ct(this, e), this;
844
- }
845
- setUseWAAPI(e) {
846
- return H(this, e), this;
847
- }
848
- setRespectReducedMotion(e) {
849
- return U(this, e), this;
850
- }
851
- setColorSpace(e) {
852
- return W(this, e), this;
853
- }
854
- setHueMethod(e) {
855
- return G(this, e), this;
856
- }
857
- setComposite(e) {
858
- return K(this, e), this;
859
- }
860
- setOptions(e) {
861
- return lt(this, e), this;
862
- }
863
- reverse() {
864
- if (this.startTime !== void 0) {
865
- let e = this.t, t = this.options.duration - 2 * e;
866
- this.startTime -= t;
867
- }
868
- return this.reversed = !this.reversed, this;
869
- }
870
- fillForwards() {
871
- this.interpFrames(this.options.duration, !0);
872
- }
873
- fillBackwards() {
874
- this.interpFrames(0, !0);
875
- }
876
- get restPosition() {
877
- return j(this);
878
- }
879
- paintRest() {
880
- Xe(this);
881
- }
882
- assertNoUnresolvedNamedSelector() {
883
- M(this);
884
- }
885
- at(e, t = !1) {
886
- return Ze(this, e, t);
887
- }
888
- interpFrames(e, t = !1, n) {
889
- return N(this, e, t, n);
890
- }
891
- onStart() {
892
- return ke(this);
893
- }
894
- onEnd() {
895
- Ae(this);
896
- }
897
- advanceTo(e) {
898
- return je(this, e);
899
- }
900
- _frame(e) {
901
- return Ne(this, e);
902
- }
903
- get finished() {
904
- return this._playback._playingPromise ?? Promise.resolve();
905
- }
906
- async play() {
907
- return Le(this);
908
- }
909
- pause() {
910
- return Re(this), this;
911
- }
912
- resume() {
913
- return ze(this), this;
914
- }
915
- toggle() {
916
- return this.paused ? this.resume() : this.pause();
917
- }
918
- stop() {
919
- Be(this);
920
- }
921
- playing() {
922
- return Ve(this);
923
- }
924
- get effectiveT() {
925
- return He(this);
926
- }
927
- settle() {
928
- return A(this), this;
929
- }
930
- reset() {
931
- return Ue(this), this;
932
- }
933
- setTargets(...e) {
934
- return this.targets = e, Ot(this) || this.frames.forEach((e) => {
935
- Object.values(e.interpVars).forEach((e) => {
936
- e.forEach(({ start: e, stop: t, value: n }) => {
937
- e.setTargets(this.targets), t.setTargets(this.targets), n.setTargets(this.targets);
938
- });
939
- });
940
- }), this;
941
- }
942
- group(...e) {
943
- return he()(this, ...e);
944
- }
945
- };
946
- //#endregion
947
- export { Y as a, T as c, me as d, _ as f, x as g, pe as h, Dt as i, C as l, b as m, At as n, pt as o, v as p, Q as r, Te as s, Mt as t, xe as u };