@pixodesk/svg-animator-web 1.0.39 → 1.0.40

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.
@@ -55,579 +55,93 @@ var PixodeskAnimator = (() => {
55
55
  setupAnimationTriggers: () => setupAnimationTriggers
56
56
  });
57
57
 
58
- // ../svg-animator-core/src/util/PxAnimatorUtil.ts
59
- function bezierToSvgPath(path, forceCurves = false) {
60
- var _a, _b, _c, _d;
61
- const v = path.v;
62
- const i = path.i;
63
- const o = path.o;
64
- const c = path.c;
65
- if (!v.length) return "";
66
- const d = [];
67
- const len = v.length;
68
- d.push("M" + v[0][0] + "," + v[0][1]);
69
- for (let idx = 1; idx < len; idx++) {
70
- const prevV = v[idx - 1];
71
- const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
72
- const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
73
- const currV = v[idx];
74
- const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
75
- if (isLine) {
76
- d.push("L" + currV[0] + "," + currV[1]);
77
- } else {
78
- d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
79
- }
80
- }
81
- if (c && len > 0) {
82
- const lastV = v[len - 1];
83
- const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
84
- const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
85
- const firstV = v[0];
86
- const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
87
- if (!isLine) {
88
- d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
89
- }
90
- d.push("z");
58
+ // ../svg-animator-core/src/schema/PxSchema.ts
59
+ var PX_UNKNOWN_KEY_ERROR = "unexpected extra key";
60
+ function pathStr(path) {
61
+ if (!path.length) return ".";
62
+ let result = "";
63
+ for (const seg of path) {
64
+ if (seg.startsWith("[")) result += seg;
65
+ else result += (result ? "." : "") + seg;
91
66
  }
92
- return d.join("");
93
- }
94
- function interpolateNum(a, b, t) {
95
- return a + (b - a) * t;
67
+ return result;
96
68
  }
97
- function interpolateVec(a, b, t) {
98
- const res = [];
99
- const count = Math.max(a.length, b.length);
100
- for (let i = 0; i < count; i++) {
101
- res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
69
+ var Base = class {
70
+ _canSanitize(raw) {
71
+ return this.isValid(raw);
102
72
  }
103
- return res;
104
- }
105
- function interpolateColor(a, b, t) {
106
- return [
107
- interpolateNum(a[0] || 0, b[0] || 0, t),
108
- interpolateNum(a[1] || 0, b[1] || 0, t),
109
- interpolateNum(a[2] || 0, b[2] || 0, t),
110
- interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
111
- ];
112
- }
113
- function interpolateBeziers(paths1, paths2, progress) {
114
- const count = Math.max(paths1.length, paths2.length);
115
- const res = [];
116
- for (let i = 0; i < count; i++) {
117
- res.push(interpolateBezier(paths1[i], paths2[i], progress));
73
+ optional() {
74
+ return new Optional(this);
118
75
  }
119
- return res;
120
- }
121
- function interpolateBezier(path1, path2, progress) {
122
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
123
- if (!path1 || !path2) return path1 || path2 || { v: [] };
124
- const t = Math.min(Math.max(progress, 0), 1);
125
- const len = Math.min(path1.v.length, path2.v.length);
126
- const v = [];
127
- const i = [];
128
- const o = [];
129
- for (let idx = 0; idx < len; idx++) {
130
- const v1 = path1.v[idx];
131
- const v2 = path2.v[idx];
132
- v.push(interpolateVec(v1, v2, t));
133
- const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
134
- const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
135
- i.push(interpolateVec(i1, i2, t));
136
- const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
137
- const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
138
- o.push(interpolateVec(o1, o2, t));
76
+ };
77
+ var Optional = class extends Base {
78
+ constructor(inner) {
79
+ super();
80
+ this.inner = inner;
81
+ this._default = void 0;
139
82
  }
140
- return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
141
- }
142
- function remap(value, inMin, inMax, outMin, outMax) {
143
- if (inMax === inMin) return outMin;
144
- const t = (value - inMin) / (inMax - inMin);
145
- return outMin + t * (outMax - outMin);
146
- }
147
- function solveCubicBezierX(p1x, p2x, x) {
148
- if (x <= 0) return 0;
149
- if (x >= 1) return 1;
150
- const cx = 3 * p1x;
151
- const bx = 3 * (p2x - p1x) - cx;
152
- const ax = 1 - cx - bx;
153
- function sampleX(t) {
154
- return ((ax * t + bx) * t + cx) * t;
83
+ sanitize(raw) {
84
+ if (raw === void 0 || raw === null) return void 0;
85
+ return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
155
86
  }
156
- function sampleDX(t) {
157
- return (3 * ax * t + 2 * bx) * t + cx;
87
+ isValid(raw, ctx, path) {
88
+ if (raw === void 0 || raw === null) return true;
89
+ return this.inner.isValid(raw, ctx, path);
158
90
  }
159
- let t2 = x;
160
- let t0 = 0;
161
- let t1 = 1;
162
- for (let i = 0; i < 8; i++) {
163
- const x2 = sampleX(t2) - x;
164
- if (Math.abs(x2) < 1e-6) return t2;
165
- const d2 = sampleDX(t2);
166
- if (Math.abs(d2) < 1e-6) break;
167
- t2 -= x2 / d2;
91
+ _canSanitize(raw) {
92
+ return raw === void 0 || raw === null || this.inner._canSanitize(raw);
168
93
  }
169
- t2 = x;
170
- while (t0 < t1) {
171
- const x2 = sampleX(t2);
172
- if (Math.abs(x2 - x) < 1e-6) return t2;
173
- if (x > x2) t0 = t2;
174
- else t1 = t2;
175
- t2 = (t1 + t0) / 2;
94
+ };
95
+ var Str = class extends Base {
96
+ constructor(_default = "") {
97
+ super();
98
+ this._default = _default;
176
99
  }
177
- return t2;
178
- }
179
- function cubicBezier(easing) {
180
- const [p1x, p1y, p2x, p2y] = easing;
181
- const cy = 3 * p1y;
182
- const by = 3 * (p2y - p1y) - cy;
183
- const ay = 1 - cy - by;
184
- function sampleCurveY(t) {
185
- return ((ay * t + by) * t + cy) * t;
100
+ sanitize(raw) {
101
+ return typeof raw === "string" ? raw : this._default;
186
102
  }
187
- return function(x) {
188
- return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
189
- };
190
- }
191
- function lerp2(a, b, t) {
192
- return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
193
- }
194
- function subdivideCubicBezier(p0, p1, p2, p3, t) {
195
- const q0 = lerp2(p0, p1, t);
196
- const q1 = lerp2(p1, p2, t);
197
- const q2 = lerp2(p2, p3, t);
198
- const r0 = lerp2(q0, q1, t);
199
- const r1 = lerp2(q1, q2, t);
200
- const s = lerp2(r0, r1, t);
201
- return {
202
- left: [p0, q0, r0, s],
203
- right: [s, r1, q2, p3]
204
- };
205
- }
206
- function splitEasing(easing, xFraction) {
207
- if (!easing) return { left: void 0, right: void 0 };
208
- if (xFraction <= 0) return { left: void 0, right: easing };
209
- if (xFraction >= 1) return { left: easing, right: void 0 };
210
- const [x1, y1, x2, y2] = easing;
211
- const t = solveCubicBezierX(x1, x2, xFraction);
212
- const p0 = [0, 0];
213
- const p1 = [x1, y1];
214
- const p2 = [x2, y2];
215
- const p3 = [1, 1];
216
- const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
217
- const sx = left[3][0];
218
- const sy = left[3][1];
219
- let leftEasing;
220
- if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
221
- leftEasing = [
222
- left[1][0] / sx,
223
- left[1][1] / sy,
224
- left[2][0] / sx,
225
- left[2][1] / sy
226
- ];
103
+ isValid(raw, ctx, path) {
104
+ if (typeof raw === "string") return true;
105
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
106
+ return false;
227
107
  }
228
- let rightEasing;
229
- const rx = 1 - sx;
230
- const ry = 1 - sy;
231
- if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
232
- rightEasing = [
233
- (right[1][0] - sx) / rx,
234
- (right[1][1] - sy) / ry,
235
- (right[2][0] - sx) / rx,
236
- (right[2][1] - sy) / ry
237
- ];
108
+ };
109
+ var Num = class extends Base {
110
+ constructor(_default = 0) {
111
+ super();
112
+ this._default = _default;
238
113
  }
239
- return { left: leftEasing, right: rightEasing };
240
- }
241
- function reverseEasing(easing) {
242
- if (!easing) return void 0;
243
- return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
244
- }
245
- function toRGBA(color) {
246
- const r = Math.round(color[0] * 255);
247
- const g = Math.round(color[1] * 255);
248
- const b = Math.round(color[2] * 255);
249
- return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
250
- }
251
- function parseRgba(s) {
252
- var _a;
253
- const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
254
- if (!inner) throw new Error("Invalid rgb/rgba format");
255
- const parts = inner.split(",").map((v) => +v.trim());
256
- return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
257
- }
258
- function parseHex(s) {
259
- const hex = s.slice(1);
260
- const isShort = hex.length <= 4;
261
- const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
262
- const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
263
- const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
264
- const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
265
- const result = [
266
- parseInt(r, 16) / 255,
267
- parseInt(g, 16) / 255,
268
- parseInt(b, 16) / 255
269
- ];
270
- if (a !== null) {
271
- result.push(parseInt(a, 16) / 255);
114
+ sanitize(raw) {
115
+ return typeof raw === "number" && isFinite(raw) ? raw : this._default;
272
116
  }
273
- return result;
274
- }
275
- function parseColor(s) {
276
- if (!s) return void 0;
277
- if (Array.isArray(s)) return s;
278
- if (typeof s !== "string") return void 0;
279
- if (s.startsWith("#")) {
280
- return parseHex(s);
281
- } else if (s.startsWith("rgb")) {
282
- return parseRgba(s);
283
- } else {
284
- console.warn("Unsupported color format: " + s);
117
+ isValid(raw, ctx, path) {
118
+ if (typeof raw === "number" && isFinite(raw)) return true;
119
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
120
+ return false;
285
121
  }
286
- return void 0;
287
- }
288
- var COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
289
- var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
290
- var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
291
- function composeTransformParts(parts, opts) {
292
- var _a;
293
- if (!parts) return "";
294
- const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
295
- const segs = [];
296
- const t = parts.translate;
297
- const o = parts.origin;
298
- const r = parts.rotate;
299
- const k = parts.skew;
300
- const s = parts.scale;
301
- const tu = withUnits ? "px" : "";
302
- const ru = withUnits ? "deg" : "";
303
- if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
304
- if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
305
- if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
306
- if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
307
- if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
308
- if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
309
- return segs.join("");
310
- }
311
- function parseTransformParts(str) {
312
- var _a, _b;
313
- if (!str || typeof str !== "string") return void 0;
314
- const out = {};
315
- const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
316
- const order = ["translate", "rotate", "skewX", "scale"];
317
- let lastIdx = -1;
318
- let m;
319
- while ((m = re.exec(str)) !== null) {
320
- const fn = m[1];
321
- const idx = order.indexOf(fn);
322
- if (idx < 0 || idx <= lastIdx) return void 0;
323
- lastIdx = idx;
324
- const nums = m[2].split(/[\s,]+/).filter(Boolean).map(Number);
325
- if (nums.some((n) => Number.isNaN(n))) return void 0;
326
- if (fn === "translate") {
327
- if (nums.length < 1 || nums.length > 2) return void 0;
328
- out.translate = [nums[0], (_a = nums[1]) != null ? _a : 0];
329
- } else if (fn === "rotate") {
330
- if (nums.length !== 1) return void 0;
331
- out.rotate = nums[0];
332
- } else if (fn === "skewX") {
333
- if (nums.length !== 1) return void 0;
334
- out.skew = nums[0];
335
- } else {
336
- if (nums.length < 1 || nums.length > 2) return void 0;
337
- out.scale = [nums[0], (_b = nums[1]) != null ? _b : nums[0]];
338
- }
122
+ };
123
+ var Bool = class extends Base {
124
+ constructor(_default = false) {
125
+ super();
126
+ this._default = _default;
339
127
  }
340
- if (str.replace(/([a-zA-Z]+)\s*\(([^)]*)\)/g, "").replace(/[\s,]/g, "").length) return void 0;
341
- return Object.keys(out).length ? out : void 0;
342
- }
343
- var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
344
- var DEFAULT_DURATION_MS = 1e3;
345
- function kebabToCamelCaseWord(kebab) {
346
- return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
347
- }
348
- function isCamelCaseWord(word) {
349
- return !word.includes("-") && /[a-z][A-Z]/.test(word);
350
- }
351
- var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
352
- // Transform/positioning
353
- "viewBox",
354
- "preserveAspectRatio",
355
- // Gradient
356
- "gradientUnits",
357
- "gradientTransform",
358
- "spreadMethod",
359
- // Pattern
360
- "patternUnits",
361
- "patternContentUnits",
362
- "patternTransform",
363
- // Clipping/masking
364
- "clipPathUnits",
365
- "maskUnits",
366
- "maskContentUnits",
367
- // Marker (SVG spec keeps these camelCase, like viewBox)
368
- "markerUnits",
369
- "markerWidth",
370
- "markerHeight",
371
- "refX",
372
- "refY",
373
- // Text
374
- "textLength",
375
- "lengthAdjust",
376
- "startOffset",
377
- // Filter
378
- "filterUnits",
379
- "primitiveUnits",
380
- "tableValues",
381
- // feFuncR/G/B/A transfer table (type="table")
382
- "stdDeviation",
383
- "baseFrequency",
384
- "numOctaves",
385
- "surfaceScale",
386
- "diffuseConstant",
387
- "specularConstant",
388
- "specularExponent",
389
- "kernelMatrix",
390
- "kernelUnitLength",
391
- "edgeMode",
392
- "preserveAlpha",
393
- "targetX",
394
- "targetY"
395
- // // Animation
396
- // 'attributeName',
397
- // 'attributeType',
398
- // 'calcMode',
399
- // 'keyTimes',
400
- // 'keySplines',
401
- // 'repeatCount',
402
- // 'repeatDur'
403
- ]);
404
- function camelCaseToKebabWordIfNeeded(camel) {
405
- return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
406
- }
407
- function clamp(value, min, max) {
408
- return Math.max(min, Math.min(value, max));
409
- }
410
- function bezier2D_pointAt(P0, P1, P2, P3, t) {
411
- if (t <= 0) return [P0[0], P0[1]];
412
- if (t >= 1) return [P3[0], P3[1]];
413
- const u = 1 - t;
414
- const u2 = u * u;
415
- const u3 = u2 * u;
416
- const t2 = t * t;
417
- const t3 = t2 * t;
418
- const w0 = u3;
419
- const w1 = 3 * t * u2;
420
- const w2 = 3 * t2 * u;
421
- const w3 = t3;
422
- return [
423
- w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
424
- w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
425
- ];
426
- }
427
- var BEZIER_T_NUDGE = 1e-4;
428
- function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
429
- const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
430
- if (result[0] === 0 && result[1] === 0) {
431
- const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
432
- return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
128
+ sanitize(raw) {
129
+ return typeof raw === "boolean" ? raw : this._default;
433
130
  }
434
- return result;
435
- }
436
- function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
437
- const u = 1 - t;
438
- const a = 3 * u * u;
439
- const b = 6 * t * u;
440
- const c = 3 * t * t;
441
- return [
442
- a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
443
- a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
444
- ];
445
- }
446
- function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
447
- const n = steps + 1;
448
- const ts = new Float64Array(n);
449
- const ds = new Float64Array(n);
450
- let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
451
- ts[0] = 0;
452
- ds[0] = 0;
453
- let cum = 0;
454
- for (let i = 1; i < n; i++) {
455
- const t = i / steps;
456
- const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
457
- const dx = cur[0] - prev[0];
458
- const dy = cur[1] - prev[1];
459
- cum += Math.sqrt(dx * dx + dy * dy);
460
- ts[i] = t;
461
- ds[i] = cum;
462
- prev = cur;
131
+ isValid(raw, ctx, path) {
132
+ if (typeof raw === "boolean") return true;
133
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
134
+ return false;
463
135
  }
464
- return { ts, ds };
465
- }
466
- function bezier2D_arcAtT(lut, t) {
467
- const { ts, ds } = lut;
468
- const last = ts.length - 1;
469
- if (t <= ts[0]) return ds[0];
470
- if (t >= ts[last]) return ds[last];
471
- let lo = 1, hi = last;
472
- while (lo < hi) {
473
- const mid = lo + hi >>> 1;
474
- if (ts[mid] < t) lo = mid + 1;
475
- else hi = mid;
136
+ };
137
+ var Literal = class extends Base {
138
+ constructor(value) {
139
+ super();
140
+ this.value = value;
141
+ this._default = value;
476
142
  }
477
- const tPrev = ts[hi - 1];
478
- const span = ts[hi] - tPrev;
479
- const frac = span > 0 ? (t - tPrev) / span : 0;
480
- return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
481
- }
482
- function invertEasing(easing) {
483
- if (!easing) return (y) => y;
484
- const flipped = [easing[1], easing[0], easing[3], easing[2]];
485
- return cubicBezier(flipped);
486
- }
487
-
488
- // ../svg-animator-core/src/playback/PxScrollMath.ts
489
- function isScrollTimeline(config) {
490
- return (config == null ? void 0 : config.timelineSource) === "scroll";
491
- }
492
- function scrollTotalDurationMs(config) {
493
- const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
494
- const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
495
- return duration * iterations;
496
- }
497
- function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
498
- const s = subjectSize, vp = scrollportSize;
499
- switch (phase) {
500
- case "cover":
501
- return [0, s + vp];
502
- case "entry":
503
- return [0, Math.min(s, vp)];
504
- case "contain":
505
- return [Math.min(s, vp), Math.max(s, vp)];
506
- case "exit":
507
- return [Math.max(s, vp), s + vp];
508
- case "entry-crossing":
509
- return [0, s];
510
- case "exit-crossing":
511
- return [vp, s + vp];
512
- }
513
- }
514
- var DEFAULT_PHASE = "cover";
515
- function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
516
- var _a;
517
- const [u0, u1] = scrollPhaseInterval((_a = point == null ? void 0 : point.phase) != null ? _a : DEFAULT_PHASE, subjectSize, scrollportSize);
518
- const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
519
- return u0 + fraction * (u1 - u0);
520
- }
521
- function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
522
- const u = scrollportSize - subjectStart;
523
- const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
524
- const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
525
- if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
526
- return clamp((u - uStart) / (uEnd - uStart), 0, 1);
527
- }
528
- function scrollOffsetProgress(offset, maxOffset, range) {
529
- var _a, _b;
530
- const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
531
- const start = typeof ((_a = range == null ? void 0 : range.start) == null ? void 0 : _a.fraction) === "number" ? range.start.fraction : 0;
532
- const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
533
- if (end <= start) return raw >= end ? 1 : 0;
534
- return clamp((raw - start) / (end - start), 0, 1);
535
- }
536
- function scrollResolveAxis(axis, writingMode) {
537
- const a = axis != null ? axis : "block";
538
- if (a === "x" || a === "y") return a;
539
- const vertical = !!writingMode && writingMode.startsWith("vertical");
540
- if (a === "inline") return vertical ? "y" : "x";
541
- return vertical ? "x" : "y";
542
- }
543
-
544
- // ../svg-animator-core/src/schema/PxSchema.ts
545
- var PX_UNKNOWN_KEY_ERROR = "unexpected extra key";
546
- function pathStr(path) {
547
- if (!path.length) return ".";
548
- let result = "";
549
- for (const seg of path) {
550
- if (seg.startsWith("[")) result += seg;
551
- else result += (result ? "." : "") + seg;
552
- }
553
- return result;
554
- }
555
- var Base = class {
556
- _canSanitize(raw) {
557
- return this.isValid(raw);
558
- }
559
- optional() {
560
- return new Optional(this);
561
- }
562
- };
563
- var Optional = class extends Base {
564
- constructor(inner) {
565
- super();
566
- this.inner = inner;
567
- this._default = void 0;
568
- }
569
- sanitize(raw) {
570
- if (raw === void 0 || raw === null) return void 0;
571
- return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
572
- }
573
- isValid(raw, ctx, path) {
574
- if (raw === void 0 || raw === null) return true;
575
- return this.inner.isValid(raw, ctx, path);
576
- }
577
- _canSanitize(raw) {
578
- return raw === void 0 || raw === null || this.inner._canSanitize(raw);
579
- }
580
- };
581
- var Str = class extends Base {
582
- constructor(_default = "") {
583
- super();
584
- this._default = _default;
585
- }
586
- sanitize(raw) {
587
- return typeof raw === "string" ? raw : this._default;
588
- }
589
- isValid(raw, ctx, path) {
590
- if (typeof raw === "string") return true;
591
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
592
- return false;
593
- }
594
- };
595
- var Num = class extends Base {
596
- constructor(_default = 0) {
597
- super();
598
- this._default = _default;
599
- }
600
- sanitize(raw) {
601
- return typeof raw === "number" && isFinite(raw) ? raw : this._default;
602
- }
603
- isValid(raw, ctx, path) {
604
- if (typeof raw === "number" && isFinite(raw)) return true;
605
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
606
- return false;
607
- }
608
- };
609
- var Bool = class extends Base {
610
- constructor(_default = false) {
611
- super();
612
- this._default = _default;
613
- }
614
- sanitize(raw) {
615
- return typeof raw === "boolean" ? raw : this._default;
616
- }
617
- isValid(raw, ctx, path) {
618
- if (typeof raw === "boolean") return true;
619
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
620
- return false;
621
- }
622
- };
623
- var Literal = class extends Base {
624
- constructor(value) {
625
- super();
626
- this.value = value;
627
- this._default = value;
628
- }
629
- sanitize(raw) {
630
- return raw === this.value ? this.value : this._default;
143
+ sanitize(raw) {
144
+ return raw === this.value ? this.value : this._default;
631
145
  }
632
146
  isValid(raw, ctx, path) {
633
147
  if (raw === this.value) return true;
@@ -1280,9 +794,7 @@ var PixodeskAnimator = (() => {
1280
794
  function getBindings(doc) {
1281
795
  var _a;
1282
796
  if (!doc) return void 0;
1283
- const animateById = (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.animateById;
1284
- if (!animateById) return void 0;
1285
- return Object.entries(animateById).map(([id, anim]) => ({ id: id.startsWith("#") ? id.slice(1) : id, animate: anim }));
797
+ return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.bindings;
1286
798
  }
1287
799
 
1288
800
  // ../svg-animator-core/src/format/PxAnimatorTypes.ts
@@ -1387,9 +899,6 @@ var PixodeskAnimator = (() => {
1387
899
  var PxDefsSchema = implementsInterface()(px.object({
1388
900
  easings: px.record(px.tuple([px.number(), px.number(), px.number(), px.number()])).optional(),
1389
901
  animations: px.record(PxAnimationDefinitionSchema).optional(),
1390
- // Review §2.6: the schema now matches the declared type — a style preset is a flat
1391
- // record of string|number attribute values, nothing nested.
1392
- styles: px.record(px.record(px.union([px.string(), px.number()]))).optional(),
1393
902
  fonts: px.record(PxGlyphFontSchema).optional()
1394
903
  }));
1395
904
  var PxScrollRangePointSchema = implementsInterface()(px.object({
@@ -1470,22 +979,22 @@ var PixodeskAnimator = (() => {
1470
979
  PxScrollTimelineSchema,
1471
980
  PxViewTimelineSchema
1472
981
  ]);
982
+ var PxBindingSchema = implementsInterface()(px.object({
983
+ target: px.string(),
984
+ animateWith: px.array(px.string())
985
+ }));
1473
986
  var PxAnimatorConfigSchema = implementsInterface()(px.object({
1474
987
  // (`mode`, `duration` and `frameRate` live INSIDE `timeline` on the wire — §2.8; they exist
1475
988
  // at this level only on the runtime view, like the rest of the playback dynamics.)
1476
989
  // THE spelling of "what advances progress" — clock / scroll / view (review §2.1).
1477
990
  timeline: PxTimelineSchema.optional(),
1478
991
  definitions: PxDefsSchema.optional(),
1479
- animateById: px.record(PxElementAnimationSchema).optional(),
992
+ bindings: px.array(PxBindingSchema).optional(),
1480
993
  debugGlobalName: px.string().optional(),
1481
994
  // Declared HERE because this is a closed object: an undeclared key would be stripped by
1482
995
  // `sanitize` and flagged by strict validation on our own files.
1483
996
  version: px.string().optional()
1484
997
  }));
1485
- var PxBindingSchema = implementsInterface()(px.object({
1486
- id: px.string(),
1487
- animate: PxElementAnimationSchema
1488
- }));
1489
998
  var PxAttrValueSchema = px.union([
1490
999
  px.string(),
1491
1000
  px.number(),
@@ -1567,98 +1076,528 @@ var PixodeskAnimator = (() => {
1567
1076
  px.object({ value: px.array(PxGradientStopSchema) }),
1568
1077
  PxPropertyAnimationSchema
1569
1078
  ]);
1570
- var PxFillGradientEffectSchema = implementsInterface()(px.object({
1571
- // Contextual kind — the `type` convention, see `PxNodeBase.type`.
1572
- type: px.enum([PxGradientType.linear, PxGradientType.radial]),
1573
- start: PxAnimatableVec2Schema.optional(),
1574
- end: PxAnimatableVec2Schema.optional(),
1575
- center: PxAnimatableVec2Schema.optional(),
1576
- radius: PxAnimatableNumberSchema.optional(),
1577
- focal: PxAnimatableVec2Schema.optional(),
1578
- stops: PxAnimatableGradientStopsSchema.optional(),
1579
- gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
1580
- spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
1581
- gradientTransform: px.string().optional()
1582
- }));
1583
- var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
1584
- var PxTextPathEffectSchema = implementsInterface()(px.object({
1585
- pathData: px.string(),
1586
- pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
1587
- lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
1588
- method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
1589
- spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
1590
- startOffset: PxAnimatableNumberSchema.optional(),
1591
- textLength: PxAnimatableNumberSchema.optional()
1592
- }));
1593
- var PxTextEffectSchema = implementsInterface()(px.object({
1594
- useGlyphs: px.boolean().optional()
1595
- }));
1596
- var PxEffectsSchema = implementsInterface()(px.object({
1597
- transformBy: PxTransformByEffectSchema.optional(),
1598
- repeater: PxRepeaterEffectSchema.optional(),
1599
- maskedBy: PxMaskedByEffectSchema.optional(),
1600
- clipPath: PxClipPathEffectSchema.optional(),
1601
- strokeTrim: PxStrokeTrimEffectSchema.optional(),
1602
- clone: PxCloneEffectSchema.optional(),
1603
- fillGradient: PxFillGradientEffectSchema.optional(),
1604
- strokeGradient: PxStrokeGradientEffectSchema.optional(),
1605
- textPath: PxTextPathEffectSchema.optional(),
1606
- text: PxTextEffectSchema.optional()
1607
- }));
1608
- var PxNodeBase = px.openObject({
1609
- // CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
1610
- // kind of thing is this", discriminated by its CARRIER — here the node TAG
1611
- // (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
1612
- // `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
1613
- // the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
1614
- // would add words that all mean "type" and still need the carrier to read.
1615
- // Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
1616
- // (issues V3), never of distinct key names.
1617
- type: px.string(),
1618
- // The escape hatch for elements that carry a REAL `type` attribute — `<feTurbulence
1619
- // type="fractalNoise">`, `<feFuncR type="table">`, `<feColorMatrix type="saturate">`.
1620
- // `type` is taken by the tag name, so the attribute travels here and the renderer puts
1621
- // it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
1622
- // documented — because a wire key that is not in a schema is invisible to the
1623
- // minifier's reserve list and gets renamed (MINIFICATION-BOUNDARY-PLAN.md §1.1).
1624
- domType: px.string().optional(),
1625
- // Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
1626
- // and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
1627
- textContent: px.string().optional(),
1628
- id: px.string().optional(),
1629
- meta: px.any().optional(),
1630
- // Player-effects bucket emitted by the Editor's lightweight design format.
1631
- // Consumed and removed by `applyPlayerEffects` before any other normalization
1632
- // (see `createAnimatorImpl`), so downstream code never sees it.
1633
- effects: PxEffectsSchema.optional(),
1634
- // `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
1635
- // string ref / array of refs / inline definition / mixed array; mirrors
1636
- // `animator.animateById` map values and what `processNode` resolves at runtime.
1637
- animate: PxElementAnimationSchema.optional(),
1638
- style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
1639
- }, PxAttrValueSchema);
1640
- var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBase._shape), {
1641
- children: px.lazy(() => px.array(PxNodeSchema), []).optional()
1642
- }), PxAttrValueSchema);
1643
- var PxSvgNodeExtra = px.object({
1644
- // `"100%"` and other SVG length strings are legal here — a number-only slot rejected
1645
- // real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
1646
- width: px.union([px.number(), px.string()]).optional(),
1647
- height: px.union([px.number(), px.string()]).optional(),
1648
- viewBox: px.string().optional(),
1649
- animator: PxAnimatorConfigSchema.optional()
1650
- });
1651
- var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
1652
- type: px.literal("svg"),
1653
- // override string → literal to require 'svg'
1654
- children: px.array(PxNodeSchema).optional()
1655
- }), PxAttrValueSchema);
1656
- var PxBezierPathSchema = implementsInterface()(px.object({
1657
- v: px.array(px.array(px.number())),
1658
- i: px.array(px.array(px.number())).optional(),
1659
- o: px.array(px.array(px.number())).optional(),
1660
- c: px.boolean().optional()
1661
- }));
1079
+ var PxFillGradientEffectSchema = implementsInterface()(px.object({
1080
+ // Contextual kind — the `type` convention, see `PxNodeBase.type`.
1081
+ type: px.enum([PxGradientType.linear, PxGradientType.radial]),
1082
+ start: PxAnimatableVec2Schema.optional(),
1083
+ end: PxAnimatableVec2Schema.optional(),
1084
+ center: PxAnimatableVec2Schema.optional(),
1085
+ radius: PxAnimatableNumberSchema.optional(),
1086
+ focal: PxAnimatableVec2Schema.optional(),
1087
+ stops: PxAnimatableGradientStopsSchema.optional(),
1088
+ gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
1089
+ spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
1090
+ gradientTransform: px.string().optional()
1091
+ }));
1092
+ var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
1093
+ var PxTextPathEffectSchema = implementsInterface()(px.object({
1094
+ pathData: px.string(),
1095
+ pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
1096
+ lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
1097
+ method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
1098
+ spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
1099
+ startOffset: PxAnimatableNumberSchema.optional(),
1100
+ textLength: PxAnimatableNumberSchema.optional()
1101
+ }));
1102
+ var PxTextEffectSchema = implementsInterface()(px.object({
1103
+ useGlyphs: px.boolean().optional()
1104
+ }));
1105
+ var PxEffectsSchema = implementsInterface()(px.object({
1106
+ transformBy: PxTransformByEffectSchema.optional(),
1107
+ repeater: PxRepeaterEffectSchema.optional(),
1108
+ maskedBy: PxMaskedByEffectSchema.optional(),
1109
+ clipPath: PxClipPathEffectSchema.optional(),
1110
+ strokeTrim: PxStrokeTrimEffectSchema.optional(),
1111
+ clone: PxCloneEffectSchema.optional(),
1112
+ fillGradient: PxFillGradientEffectSchema.optional(),
1113
+ strokeGradient: PxStrokeGradientEffectSchema.optional(),
1114
+ textPath: PxTextPathEffectSchema.optional(),
1115
+ text: PxTextEffectSchema.optional()
1116
+ }));
1117
+ var PxNodeBase = px.openObject({
1118
+ // CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
1119
+ // kind of thing is this", discriminated by its CARRIER — here the node TAG
1120
+ // (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
1121
+ // `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
1122
+ // the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
1123
+ // would add words that all mean "type" and still need the carrier to read.
1124
+ // Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
1125
+ // (issues V3), never of distinct key names.
1126
+ type: px.string(),
1127
+ // The escape hatch for elements that carry a REAL `type` attribute — `<feTurbulence
1128
+ // type="fractalNoise">`, `<feFuncR type="table">`, `<feColorMatrix type="saturate">`.
1129
+ // `type` is taken by the tag name, so the attribute travels here and the renderer puts
1130
+ // it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
1131
+ // documented — because a wire key that is not in a schema is invisible to the
1132
+ // minifier's reserve list and gets renamed (MINIFICATION-BOUNDARY-PLAN.md §1.1).
1133
+ domType: px.string().optional(),
1134
+ // Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
1135
+ // and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
1136
+ textContent: px.string().optional(),
1137
+ id: px.string().optional(),
1138
+ meta: px.any().optional(),
1139
+ // Player-effects bucket emitted by the Editor's lightweight design format.
1140
+ // Consumed and removed by `applyPlayerEffects` before any other normalization
1141
+ // (see `createAnimatorImpl`), so downstream code never sees it.
1142
+ effects: PxEffectsSchema.optional(),
1143
+ // `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
1144
+ // string ref / array of refs / inline definition / mixed array; mirrors
1145
+ // `node.animate` values and what `processNode` resolves at runtime.
1146
+ animate: PxElementAnimationSchema.optional(),
1147
+ style: px.record(px.union([px.string(), px.number()])).optional()
1148
+ }, PxAttrValueSchema);
1149
+ var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBase._shape), {
1150
+ children: px.lazy(() => px.array(PxNodeSchema), []).optional()
1151
+ }), PxAttrValueSchema);
1152
+ var PxSvgNodeExtra = px.object({
1153
+ // `"100%"` and other SVG length strings are legal here — a number-only slot rejected
1154
+ // real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
1155
+ width: px.union([px.number(), px.string()]).optional(),
1156
+ height: px.union([px.number(), px.string()]).optional(),
1157
+ viewBox: px.string().optional(),
1158
+ animator: PxAnimatorConfigSchema.optional()
1159
+ });
1160
+ var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
1161
+ type: px.literal("svg"),
1162
+ // override string → literal to require 'svg'
1163
+ children: px.array(PxNodeSchema).optional()
1164
+ }), PxAttrValueSchema);
1165
+ var PxBezierPathSchema = implementsInterface()(px.object({
1166
+ v: px.array(px.array(px.number())),
1167
+ i: px.array(px.array(px.number())).optional(),
1168
+ o: px.array(px.array(px.number())).optional(),
1169
+ c: px.boolean().optional()
1170
+ }));
1171
+
1172
+ // ../svg-animator-core/src/util/PxAnimatorUtil.ts
1173
+ function bezierToSvgPath(path, forceCurves = false) {
1174
+ var _a, _b, _c, _d;
1175
+ const v = path.v;
1176
+ const i = path.i;
1177
+ const o = path.o;
1178
+ const c = path.c;
1179
+ if (!v.length) return "";
1180
+ const d = [];
1181
+ const len = v.length;
1182
+ d.push("M" + v[0][0] + "," + v[0][1]);
1183
+ for (let idx = 1; idx < len; idx++) {
1184
+ const prevV = v[idx - 1];
1185
+ const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
1186
+ const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
1187
+ const currV = v[idx];
1188
+ const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
1189
+ if (isLine) {
1190
+ d.push("L" + currV[0] + "," + currV[1]);
1191
+ } else {
1192
+ d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
1193
+ }
1194
+ }
1195
+ if (c && len > 0) {
1196
+ const lastV = v[len - 1];
1197
+ const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
1198
+ const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
1199
+ const firstV = v[0];
1200
+ const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
1201
+ if (!isLine) {
1202
+ d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
1203
+ }
1204
+ d.push("z");
1205
+ }
1206
+ return d.join("");
1207
+ }
1208
+ function interpolateNum(a, b, t) {
1209
+ return a + (b - a) * t;
1210
+ }
1211
+ function interpolateVec(a, b, t) {
1212
+ const res = [];
1213
+ const count = Math.max(a.length, b.length);
1214
+ for (let i = 0; i < count; i++) {
1215
+ res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
1216
+ }
1217
+ return res;
1218
+ }
1219
+ function interpolateColor(a, b, t) {
1220
+ return [
1221
+ interpolateNum(a[0] || 0, b[0] || 0, t),
1222
+ interpolateNum(a[1] || 0, b[1] || 0, t),
1223
+ interpolateNum(a[2] || 0, b[2] || 0, t),
1224
+ interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
1225
+ ];
1226
+ }
1227
+ function interpolateBeziers(paths1, paths2, progress) {
1228
+ const count = Math.max(paths1.length, paths2.length);
1229
+ const res = [];
1230
+ for (let i = 0; i < count; i++) {
1231
+ res.push(interpolateBezier(paths1[i], paths2[i], progress));
1232
+ }
1233
+ return res;
1234
+ }
1235
+ function interpolateBezier(path1, path2, progress) {
1236
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1237
+ if (!path1 || !path2) return path1 || path2 || { v: [] };
1238
+ const t = Math.min(Math.max(progress, 0), 1);
1239
+ const len = Math.min(path1.v.length, path2.v.length);
1240
+ const v = [];
1241
+ const i = [];
1242
+ const o = [];
1243
+ for (let idx = 0; idx < len; idx++) {
1244
+ const v1 = path1.v[idx];
1245
+ const v2 = path2.v[idx];
1246
+ v.push(interpolateVec(v1, v2, t));
1247
+ const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
1248
+ const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
1249
+ i.push(interpolateVec(i1, i2, t));
1250
+ const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
1251
+ const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
1252
+ o.push(interpolateVec(o1, o2, t));
1253
+ }
1254
+ return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
1255
+ }
1256
+ function remap(value, inMin, inMax, outMin, outMax) {
1257
+ if (inMax === inMin) return outMin;
1258
+ const t = (value - inMin) / (inMax - inMin);
1259
+ return outMin + t * (outMax - outMin);
1260
+ }
1261
+ function solveCubicBezierX(p1x, p2x, x) {
1262
+ if (x <= 0) return 0;
1263
+ if (x >= 1) return 1;
1264
+ const cx = 3 * p1x;
1265
+ const bx = 3 * (p2x - p1x) - cx;
1266
+ const ax = 1 - cx - bx;
1267
+ function sampleX(t) {
1268
+ return ((ax * t + bx) * t + cx) * t;
1269
+ }
1270
+ function sampleDX(t) {
1271
+ return (3 * ax * t + 2 * bx) * t + cx;
1272
+ }
1273
+ let t2 = x;
1274
+ let t0 = 0;
1275
+ let t1 = 1;
1276
+ for (let i = 0; i < 8; i++) {
1277
+ const x2 = sampleX(t2) - x;
1278
+ if (Math.abs(x2) < 1e-6) return t2;
1279
+ const d2 = sampleDX(t2);
1280
+ if (Math.abs(d2) < 1e-6) break;
1281
+ t2 -= x2 / d2;
1282
+ }
1283
+ t2 = x;
1284
+ while (t0 < t1) {
1285
+ const x2 = sampleX(t2);
1286
+ if (Math.abs(x2 - x) < 1e-6) return t2;
1287
+ if (x > x2) t0 = t2;
1288
+ else t1 = t2;
1289
+ t2 = (t1 + t0) / 2;
1290
+ }
1291
+ return t2;
1292
+ }
1293
+ function cubicBezier(easing) {
1294
+ const [p1x, p1y, p2x, p2y] = easing;
1295
+ const cy = 3 * p1y;
1296
+ const by = 3 * (p2y - p1y) - cy;
1297
+ const ay = 1 - cy - by;
1298
+ function sampleCurveY(t) {
1299
+ return ((ay * t + by) * t + cy) * t;
1300
+ }
1301
+ return function(x) {
1302
+ return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
1303
+ };
1304
+ }
1305
+ function lerp2(a, b, t) {
1306
+ return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
1307
+ }
1308
+ function subdivideCubicBezier(p0, p1, p2, p3, t) {
1309
+ const q0 = lerp2(p0, p1, t);
1310
+ const q1 = lerp2(p1, p2, t);
1311
+ const q2 = lerp2(p2, p3, t);
1312
+ const r0 = lerp2(q0, q1, t);
1313
+ const r1 = lerp2(q1, q2, t);
1314
+ const s = lerp2(r0, r1, t);
1315
+ return {
1316
+ left: [p0, q0, r0, s],
1317
+ right: [s, r1, q2, p3]
1318
+ };
1319
+ }
1320
+ function splitEasing(easing, xFraction) {
1321
+ if (!easing) return { left: void 0, right: void 0 };
1322
+ if (xFraction <= 0) return { left: void 0, right: easing };
1323
+ if (xFraction >= 1) return { left: easing, right: void 0 };
1324
+ const [x1, y1, x2, y2] = easing;
1325
+ const t = solveCubicBezierX(x1, x2, xFraction);
1326
+ const p0 = [0, 0];
1327
+ const p1 = [x1, y1];
1328
+ const p2 = [x2, y2];
1329
+ const p3 = [1, 1];
1330
+ const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
1331
+ const sx = left[3][0];
1332
+ const sy = left[3][1];
1333
+ let leftEasing;
1334
+ if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
1335
+ leftEasing = [
1336
+ left[1][0] / sx,
1337
+ left[1][1] / sy,
1338
+ left[2][0] / sx,
1339
+ left[2][1] / sy
1340
+ ];
1341
+ }
1342
+ let rightEasing;
1343
+ const rx = 1 - sx;
1344
+ const ry = 1 - sy;
1345
+ if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
1346
+ rightEasing = [
1347
+ (right[1][0] - sx) / rx,
1348
+ (right[1][1] - sy) / ry,
1349
+ (right[2][0] - sx) / rx,
1350
+ (right[2][1] - sy) / ry
1351
+ ];
1352
+ }
1353
+ return { left: leftEasing, right: rightEasing };
1354
+ }
1355
+ function reverseEasing(easing) {
1356
+ if (!easing) return void 0;
1357
+ return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
1358
+ }
1359
+ function toRGBA(color) {
1360
+ const r = Math.round(color[0] * 255);
1361
+ const g = Math.round(color[1] * 255);
1362
+ const b = Math.round(color[2] * 255);
1363
+ return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
1364
+ }
1365
+ function parseRgba(s) {
1366
+ var _a;
1367
+ const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
1368
+ if (!inner) throw new Error("Invalid rgb/rgba format");
1369
+ const parts = inner.split(",").map((v) => +v.trim());
1370
+ return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
1371
+ }
1372
+ function parseHex(s) {
1373
+ const hex = s.slice(1);
1374
+ const isShort = hex.length <= 4;
1375
+ const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
1376
+ const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
1377
+ const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
1378
+ const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
1379
+ const result = [
1380
+ parseInt(r, 16) / 255,
1381
+ parseInt(g, 16) / 255,
1382
+ parseInt(b, 16) / 255
1383
+ ];
1384
+ if (a !== null) {
1385
+ result.push(parseInt(a, 16) / 255);
1386
+ }
1387
+ return result;
1388
+ }
1389
+ function parseColor(s) {
1390
+ if (!s) return void 0;
1391
+ if (Array.isArray(s)) return s;
1392
+ if (typeof s !== "string") return void 0;
1393
+ if (s.startsWith("#")) {
1394
+ return parseHex(s);
1395
+ } else if (s.startsWith("rgb")) {
1396
+ return parseRgba(s);
1397
+ } else {
1398
+ console.warn("Unsupported color format: " + s);
1399
+ }
1400
+ return void 0;
1401
+ }
1402
+ var COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
1403
+ var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
1404
+ var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1405
+ function composeTransformParts(parts, opts) {
1406
+ var _a;
1407
+ if (!parts) return "";
1408
+ const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
1409
+ const segs = [];
1410
+ const t = parts.translate;
1411
+ const o = parts.origin;
1412
+ const r = parts.rotate;
1413
+ const k = parts.skew;
1414
+ const s = parts.scale;
1415
+ const tu = withUnits ? "px" : "";
1416
+ const ru = withUnits ? "deg" : "";
1417
+ if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
1418
+ if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
1419
+ if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
1420
+ if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
1421
+ if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
1422
+ if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
1423
+ return segs.join("");
1424
+ }
1425
+ function parseTransformParts(str) {
1426
+ var _a, _b;
1427
+ if (!str || typeof str !== "string") return void 0;
1428
+ const out = {};
1429
+ const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
1430
+ const order = ["translate", "rotate", "skewX", "scale"];
1431
+ let lastIdx = -1;
1432
+ let m;
1433
+ while ((m = re.exec(str)) !== null) {
1434
+ const fn = m[1];
1435
+ const idx = order.indexOf(fn);
1436
+ if (idx < 0 || idx <= lastIdx) return void 0;
1437
+ lastIdx = idx;
1438
+ const nums = m[2].split(/[\s,]+/).filter(Boolean).map(Number);
1439
+ if (nums.some((n) => Number.isNaN(n))) return void 0;
1440
+ if (fn === "translate") {
1441
+ if (nums.length < 1 || nums.length > 2) return void 0;
1442
+ out.translate = [nums[0], (_a = nums[1]) != null ? _a : 0];
1443
+ } else if (fn === "rotate") {
1444
+ if (nums.length !== 1) return void 0;
1445
+ out.rotate = nums[0];
1446
+ } else if (fn === "skewX") {
1447
+ if (nums.length !== 1) return void 0;
1448
+ out.skew = nums[0];
1449
+ } else {
1450
+ if (nums.length < 1 || nums.length > 2) return void 0;
1451
+ out.scale = [nums[0], (_b = nums[1]) != null ? _b : nums[0]];
1452
+ }
1453
+ }
1454
+ if (str.replace(/([a-zA-Z]+)\s*\(([^)]*)\)/g, "").replace(/[\s,]/g, "").length) return void 0;
1455
+ return Object.keys(out).length ? out : void 0;
1456
+ }
1457
+ var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1458
+ var DEFAULT_DURATION_MS = 1e3;
1459
+ function kebabToCamelCaseWord(kebab) {
1460
+ return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
1461
+ }
1462
+ function isCamelCaseWord(word) {
1463
+ return !word.includes("-") && /[a-z][A-Z]/.test(word);
1464
+ }
1465
+ var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
1466
+ // Transform/positioning
1467
+ "viewBox",
1468
+ "preserveAspectRatio",
1469
+ // Gradient
1470
+ "gradientUnits",
1471
+ "gradientTransform",
1472
+ "spreadMethod",
1473
+ // Pattern
1474
+ "patternUnits",
1475
+ "patternContentUnits",
1476
+ "patternTransform",
1477
+ // Clipping/masking
1478
+ "clipPathUnits",
1479
+ "maskUnits",
1480
+ "maskContentUnits",
1481
+ // Marker (SVG spec keeps these camelCase, like viewBox)
1482
+ "markerUnits",
1483
+ "markerWidth",
1484
+ "markerHeight",
1485
+ "refX",
1486
+ "refY",
1487
+ // Text
1488
+ "textLength",
1489
+ "lengthAdjust",
1490
+ "startOffset",
1491
+ // Filter
1492
+ "filterUnits",
1493
+ "primitiveUnits",
1494
+ "tableValues",
1495
+ // feFuncR/G/B/A transfer table (type="table")
1496
+ "stdDeviation",
1497
+ "baseFrequency",
1498
+ "numOctaves",
1499
+ "surfaceScale",
1500
+ "diffuseConstant",
1501
+ "specularConstant",
1502
+ "specularExponent",
1503
+ "kernelMatrix",
1504
+ "kernelUnitLength",
1505
+ "edgeMode",
1506
+ "preserveAlpha",
1507
+ "targetX",
1508
+ "targetY"
1509
+ // // Animation
1510
+ // 'attributeName',
1511
+ // 'attributeType',
1512
+ // 'calcMode',
1513
+ // 'keyTimes',
1514
+ // 'keySplines',
1515
+ // 'repeatCount',
1516
+ // 'repeatDur'
1517
+ ]);
1518
+ function camelCaseToKebabWordIfNeeded(camel) {
1519
+ return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1520
+ }
1521
+ function clamp(value, min, max) {
1522
+ return Math.max(min, Math.min(value, max));
1523
+ }
1524
+ function bezier2D_pointAt(P0, P1, P2, P3, t) {
1525
+ if (t <= 0) return [P0[0], P0[1]];
1526
+ if (t >= 1) return [P3[0], P3[1]];
1527
+ const u = 1 - t;
1528
+ const u2 = u * u;
1529
+ const u3 = u2 * u;
1530
+ const t2 = t * t;
1531
+ const t3 = t2 * t;
1532
+ const w0 = u3;
1533
+ const w1 = 3 * t * u2;
1534
+ const w2 = 3 * t2 * u;
1535
+ const w3 = t3;
1536
+ return [
1537
+ w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
1538
+ w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
1539
+ ];
1540
+ }
1541
+ var BEZIER_T_NUDGE = 1e-4;
1542
+ function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
1543
+ const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
1544
+ if (result[0] === 0 && result[1] === 0) {
1545
+ const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
1546
+ return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
1547
+ }
1548
+ return result;
1549
+ }
1550
+ function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
1551
+ const u = 1 - t;
1552
+ const a = 3 * u * u;
1553
+ const b = 6 * t * u;
1554
+ const c = 3 * t * t;
1555
+ return [
1556
+ a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
1557
+ a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
1558
+ ];
1559
+ }
1560
+ function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
1561
+ const n = steps + 1;
1562
+ const ts = new Float64Array(n);
1563
+ const ds = new Float64Array(n);
1564
+ let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
1565
+ ts[0] = 0;
1566
+ ds[0] = 0;
1567
+ let cum = 0;
1568
+ for (let i = 1; i < n; i++) {
1569
+ const t = i / steps;
1570
+ const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
1571
+ const dx = cur[0] - prev[0];
1572
+ const dy = cur[1] - prev[1];
1573
+ cum += Math.sqrt(dx * dx + dy * dy);
1574
+ ts[i] = t;
1575
+ ds[i] = cum;
1576
+ prev = cur;
1577
+ }
1578
+ return { ts, ds };
1579
+ }
1580
+ function bezier2D_arcAtT(lut, t) {
1581
+ const { ts, ds } = lut;
1582
+ const last = ts.length - 1;
1583
+ if (t <= ts[0]) return ds[0];
1584
+ if (t >= ts[last]) return ds[last];
1585
+ let lo = 1, hi = last;
1586
+ while (lo < hi) {
1587
+ const mid = lo + hi >>> 1;
1588
+ if (ts[mid] < t) lo = mid + 1;
1589
+ else hi = mid;
1590
+ }
1591
+ const tPrev = ts[hi - 1];
1592
+ const span = ts[hi] - tPrev;
1593
+ const frac = span > 0 ? (t - tPrev) / span : 0;
1594
+ return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
1595
+ }
1596
+ function invertEasing(easing) {
1597
+ if (!easing) return (y) => y;
1598
+ const flipped = [easing[1], easing[0], easing[3], easing[2]];
1599
+ return cubicBezier(flipped);
1600
+ }
1662
1601
 
1663
1602
  // ../svg-animator-core/src/materialize/PxMotionPath.ts
1664
1603
  function getKfTranslate(kf) {
@@ -2499,9 +2438,7 @@ var PixodeskAnimator = (() => {
2499
2438
  const defs = getDefs(doc);
2500
2439
  const duration = animatorConfig.duration || 1e3;
2501
2440
  const bindings = [];
2502
- const processAnimation = (id, animate, staticTransform) => {
2503
- if (!animate) return null;
2504
- const animDefs = resolveElementAnimation(animate, defs);
2441
+ const processAnimation = (id, animDefs, staticTransform) => {
2505
2442
  if (animDefs.length === 0) return null;
2506
2443
  const merged = mergeStaticTransformIntoAnimDef(mergeAnimationDefinitions(animDefs), staticTransform);
2507
2444
  const normalizedAnim = normalizeAnimationDefinition(merged, duration, defs, engine);
@@ -2514,7 +2451,9 @@ var PixodeskAnimator = (() => {
2514
2451
  const docBindings = getBindings(doc);
2515
2452
  if (docBindings) {
2516
2453
  for (const binding of docBindings) {
2517
- const normalized = processAnimation(binding.id, binding.animate);
2454
+ const id = binding.target.startsWith("#") ? binding.target.slice(1) : binding.target;
2455
+ const animDefs = binding.animateWith.map((name) => resolveAnimation(name, defs)).filter((d) => !!d);
2456
+ const normalized = processAnimation(id, animDefs);
2518
2457
  if (normalized) bindings.push(normalized);
2519
2458
  }
2520
2459
  }
@@ -2523,7 +2462,7 @@ var PixodeskAnimator = (() => {
2523
2462
  if (inlineAnim && Object.keys(inlineAnim).length > 0) {
2524
2463
  const nodeId = node.id || generateElementId();
2525
2464
  node.id = nodeId;
2526
- const normalized = processAnimation(nodeId, inlineAnim, node.transform);
2465
+ const normalized = processAnimation(nodeId, resolveElementAnimation(inlineAnim, defs), node.transform);
2527
2466
  if (normalized) bindings.push(normalized);
2528
2467
  }
2529
2468
  if (node.children) {
@@ -3013,10 +2952,6 @@ var PixodeskAnimator = (() => {
3013
2952
  function asError(error) {
3014
2953
  return typeof error === "string" ? new Error(error) : error;
3015
2954
  }
3016
- function isSilenced(silent, kind) {
3017
- if (!silent) return false;
3018
- return silent === true || silent.includes(kind);
3019
- }
3020
2955
  function createDiagnostics(config, prefix) {
3021
2956
  const tag = prefix ? prefix + " " : "";
3022
2957
  return {
@@ -3025,26 +2960,84 @@ var PixodeskAnimator = (() => {
3025
2960
  config.onWarn({ kind, message, detail });
3026
2961
  return;
3027
2962
  }
3028
- if (isSilenced(config == null ? void 0 : config.silent, kind)) return;
2963
+ if (config == null ? void 0 : config.muteWarn) return;
3029
2964
  const line = tag + kind + ": " + message;
3030
2965
  if (detail === void 0) console.warn(line);
3031
2966
  else console.warn(line, detail);
3032
2967
  },
3033
- error: (kind, error) => {
2968
+ error: (kind, error, detail) => {
3034
2969
  const err = asError(error);
3035
2970
  if (config == null ? void 0 : config.onError) {
3036
- config.onError({ kind, message: err.message, error: err });
2971
+ config.onError({ kind, message: err.message, error: err, detail });
3037
2972
  return;
3038
2973
  }
3039
- if (isSilenced(config == null ? void 0 : config.silent, kind)) return;
3040
- console.error(tag + kind + ": " + err.message);
2974
+ if (config == null ? void 0 : config.muteError) return;
2975
+ const line = tag + kind + ": " + err.message;
2976
+ if (detail === void 0) console.error(line);
2977
+ else console.error(line, detail);
3041
2978
  }
3042
2979
  };
3043
2980
  }
3044
2981
 
2982
+ // ../svg-animator-core/src/playback/PxScrollMath.ts
2983
+ function isScrollTimeline(config) {
2984
+ return (config == null ? void 0 : config.timelineSource) === "scroll";
2985
+ }
2986
+ function scrollTotalDurationMs(config) {
2987
+ const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
2988
+ const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
2989
+ return duration * iterations;
2990
+ }
2991
+ function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
2992
+ const s = subjectSize, vp = scrollportSize;
2993
+ switch (phase) {
2994
+ case "cover":
2995
+ return [0, s + vp];
2996
+ case "entry":
2997
+ return [0, Math.min(s, vp)];
2998
+ case "contain":
2999
+ return [Math.min(s, vp), Math.max(s, vp)];
3000
+ case "exit":
3001
+ return [Math.max(s, vp), s + vp];
3002
+ case "entry-crossing":
3003
+ return [0, s];
3004
+ case "exit-crossing":
3005
+ return [vp, s + vp];
3006
+ }
3007
+ }
3008
+ var DEFAULT_PHASE = "cover";
3009
+ function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
3010
+ var _a;
3011
+ const [u0, u1] = scrollPhaseInterval((_a = point == null ? void 0 : point.phase) != null ? _a : DEFAULT_PHASE, subjectSize, scrollportSize);
3012
+ const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
3013
+ return u0 + fraction * (u1 - u0);
3014
+ }
3015
+ function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
3016
+ const u = scrollportSize - subjectStart;
3017
+ const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
3018
+ const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
3019
+ if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
3020
+ return clamp((u - uStart) / (uEnd - uStart), 0, 1);
3021
+ }
3022
+ function scrollOffsetProgress(offset, maxOffset, range) {
3023
+ var _a, _b;
3024
+ const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
3025
+ const start = typeof ((_a = range == null ? void 0 : range.start) == null ? void 0 : _a.fraction) === "number" ? range.start.fraction : 0;
3026
+ const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
3027
+ if (end <= start) return raw >= end ? 1 : 0;
3028
+ return clamp((raw - start) / (end - start), 0, 1);
3029
+ }
3030
+ function scrollResolveAxis(axis, writingMode) {
3031
+ const a = axis != null ? axis : "block";
3032
+ if (a === "x" || a === "y") return a;
3033
+ const vertical = !!writingMode && writingMode.startsWith("vertical");
3034
+ if (a === "inline") return vertical ? "y" : "x";
3035
+ return vertical ? "x" : "y";
3036
+ }
3037
+
3045
3038
  // src/shared/PxAnimatorCallbacks.ts
3046
3039
  function toEngineCallbacks(inline) {
3047
- const { onPlay, onPause, onCancel, onFinish, onRemove, onStop, onWarn, onError, silent } = inline != null ? inline : {};
3040
+ const { onPlay, onPause, onCancel, onFinish, onRemove, onStop, onWarn, onError, muteWarn, muteError } = inline != null ? inline : {};
3048
3041
  const withStop = (own) => own || onStop ? () => {
3049
3042
  own == null ? void 0 : own();
3050
3043
  onStop == null ? void 0 : onStop();
@@ -3057,9 +3050,38 @@ var PixodeskAnimator = (() => {
3057
3050
  onRemove: withStop(onRemove),
3058
3051
  onWarn,
3059
3052
  onError,
3060
- silent
3053
+ muteWarn,
3054
+ muteError
3055
+ };
3056
+ }
3057
+ function createInertAnimator() {
3058
+ return {
3059
+ isReady: () => false,
3060
+ getRootElement: () => null,
3061
+ isPlaying: () => false,
3062
+ play: () => {
3063
+ },
3064
+ pause: () => {
3065
+ },
3066
+ cancel: () => {
3067
+ },
3068
+ finish: () => {
3069
+ },
3070
+ setPlaybackRate: () => {
3071
+ },
3072
+ getCurrentTime: () => null,
3073
+ setCurrentTime: () => {
3074
+ },
3075
+ getCurrentProgress: () => null,
3076
+ setCurrentProgress: () => {
3077
+ },
3078
+ destroy: () => {
3079
+ }
3061
3080
  };
3062
3081
  }
3082
+ function asThrownError(e) {
3083
+ return e instanceof Error ? e : new Error(String(e));
3084
+ }
3063
3085
 
3064
3086
  // src/triggers/PxAnimatorTriggers.ts
3065
3087
  function setupAnimationTriggers(api, config, diag) {
@@ -3876,8 +3898,18 @@ var PixodeskAnimator = (() => {
3876
3898
  if (!(options == null ? void 0 : options.doc)) throw new Error("createAnimator: `doc` is required");
3877
3899
  return options.doc;
3878
3900
  }
3901
+ function buildOrReport(options, build) {
3902
+ try {
3903
+ return build();
3904
+ } catch (e) {
3905
+ const err = asThrownError(e);
3906
+ createDiagnostics(options, "[PxAnimator]").error(PxDiagnosticKind.internal, "createAnimator: could not build the player \u2014 " + err.message, err);
3907
+ return createInertAnimator();
3908
+ }
3909
+ }
3879
3910
  function createPrerenderedAnimator(options) {
3880
- return bindWithEngineChoice(requireDoc(options), options.adapter, toEngineCallbacks(options), null);
3911
+ const doc = requireDoc(options);
3912
+ return buildOrReport(options, () => bindWithEngineChoice(doc, void 0, toEngineCallbacks(options), null));
3881
3913
  }
3882
3914
 
3883
3915
  // src/shared/PxAnimatorKeys.ts