@pixodesk/svg-animator-react 1.0.24 → 1.0.27

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.
package/dist/index.umd.js CHANGED
@@ -1815,114 +1815,582 @@ var PixodeskAnimatorReact = (() => {
1815
1815
  return a;
1816
1816
  };
1817
1817
  var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
1818
- function pathStr(path) {
1819
- if (!path.length) return ".";
1820
- let result = "";
1821
- for (const seg of path) {
1822
- if (seg.startsWith("[")) result += seg;
1823
- else result += (result ? "." : "") + seg;
1824
- }
1825
- return result;
1826
- }
1827
- var Base = class {
1828
- _canSanitize(raw) {
1829
- return this.isValid(raw);
1818
+ function bezierToSvgPath(path, forceCurves = false) {
1819
+ var _a, _b, _c, _d;
1820
+ const v = path.v;
1821
+ const i = path.i;
1822
+ const o = path.o;
1823
+ const c = path.c;
1824
+ if (!v.length) return "";
1825
+ const d = [];
1826
+ const len = v.length;
1827
+ d.push("M" + v[0][0] + "," + v[0][1]);
1828
+ for (let idx = 1; idx < len; idx++) {
1829
+ const prevV = v[idx - 1];
1830
+ const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
1831
+ const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
1832
+ const currV = v[idx];
1833
+ const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
1834
+ if (isLine) {
1835
+ d.push("L" + currV[0] + "," + currV[1]);
1836
+ } else {
1837
+ d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
1838
+ }
1830
1839
  }
1831
- optional() {
1832
- return new Optional(this);
1840
+ if (c && len > 0) {
1841
+ const lastV = v[len - 1];
1842
+ const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
1843
+ const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
1844
+ const firstV = v[0];
1845
+ const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
1846
+ if (!isLine) {
1847
+ d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
1848
+ }
1849
+ d.push("z");
1833
1850
  }
1834
- };
1835
- var Optional = class extends Base {
1836
- constructor(inner) {
1837
- super();
1838
- this.inner = inner;
1839
- this._default = void 0;
1851
+ return d.join("");
1852
+ }
1853
+ function interpolateNum(a, b, t) {
1854
+ return a + (b - a) * t;
1855
+ }
1856
+ function interpolateVec(a, b, t) {
1857
+ const res = [];
1858
+ const count = Math.max(a.length, b.length);
1859
+ for (let i = 0; i < count; i++) {
1860
+ res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
1840
1861
  }
1841
- sanitize(raw) {
1842
- if (raw === void 0 || raw === null) return void 0;
1843
- return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
1862
+ return res;
1863
+ }
1864
+ function interpolateColor(a, b, t) {
1865
+ return [
1866
+ interpolateNum(a[0] || 0, b[0] || 0, t),
1867
+ interpolateNum(a[1] || 0, b[1] || 0, t),
1868
+ interpolateNum(a[2] || 0, b[2] || 0, t),
1869
+ interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
1870
+ ];
1871
+ }
1872
+ function interpolateBeziers(paths1, paths2, progress) {
1873
+ const count = Math.max(paths1.length, paths2.length);
1874
+ const res = [];
1875
+ for (let i = 0; i < count; i++) {
1876
+ res.push(interpolateBezier(paths1[i], paths2[i], progress));
1844
1877
  }
1845
- isValid(raw, ctx, path) {
1846
- if (raw === void 0 || raw === null) return true;
1847
- return this.inner.isValid(raw, ctx, path);
1878
+ return res;
1879
+ }
1880
+ function interpolateBezier(path1, path2, progress) {
1881
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1882
+ if (!path1 || !path2) return path1 || path2 || { v: [] };
1883
+ const t = Math.min(Math.max(progress, 0), 1);
1884
+ const len = Math.min(path1.v.length, path2.v.length);
1885
+ const v = [];
1886
+ const i = [];
1887
+ const o = [];
1888
+ for (let idx = 0; idx < len; idx++) {
1889
+ const v1 = path1.v[idx];
1890
+ const v2 = path2.v[idx];
1891
+ v.push(interpolateVec(v1, v2, t));
1892
+ const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
1893
+ const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
1894
+ i.push(interpolateVec(i1, i2, t));
1895
+ const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
1896
+ const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
1897
+ o.push(interpolateVec(o1, o2, t));
1848
1898
  }
1849
- _canSanitize(raw) {
1850
- return raw === void 0 || raw === null || this.inner._canSanitize(raw);
1899
+ return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
1900
+ }
1901
+ function remap(value, inMin, inMax, outMin, outMax) {
1902
+ if (inMax === inMin) return outMin;
1903
+ const t = (value - inMin) / (inMax - inMin);
1904
+ return outMin + t * (outMax - outMin);
1905
+ }
1906
+ function solveCubicBezierX(p1x, p2x, x) {
1907
+ if (x <= 0) return 0;
1908
+ if (x >= 1) return 1;
1909
+ const cx = 3 * p1x;
1910
+ const bx = 3 * (p2x - p1x) - cx;
1911
+ const ax = 1 - cx - bx;
1912
+ function sampleX(t) {
1913
+ return ((ax * t + bx) * t + cx) * t;
1851
1914
  }
1852
- };
1853
- var Str = class extends Base {
1854
- constructor(_default = "") {
1855
- super();
1856
- this._default = _default;
1915
+ function sampleDX(t) {
1916
+ return (3 * ax * t + 2 * bx) * t + cx;
1857
1917
  }
1858
- sanitize(raw) {
1859
- return typeof raw === "string" ? raw : this._default;
1918
+ let t2 = x;
1919
+ let t0 = 0;
1920
+ let t1 = 1;
1921
+ for (let i = 0; i < 8; i++) {
1922
+ const x2 = sampleX(t2) - x;
1923
+ if (Math.abs(x2) < 1e-6) return t2;
1924
+ const d2 = sampleDX(t2);
1925
+ if (Math.abs(d2) < 1e-6) break;
1926
+ t2 -= x2 / d2;
1860
1927
  }
1861
- isValid(raw, ctx, path) {
1862
- if (typeof raw === "string") return true;
1863
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
1864
- return false;
1928
+ t2 = x;
1929
+ while (t0 < t1) {
1930
+ const x2 = sampleX(t2);
1931
+ if (Math.abs(x2 - x) < 1e-6) return t2;
1932
+ if (x > x2) t0 = t2;
1933
+ else t1 = t2;
1934
+ t2 = (t1 + t0) / 2;
1865
1935
  }
1866
- };
1867
- var Num = class extends Base {
1868
- constructor(_default = 0) {
1869
- super();
1870
- this._default = _default;
1936
+ return t2;
1937
+ }
1938
+ function cubicBezier(easing) {
1939
+ const [p1x, p1y, p2x, p2y] = easing;
1940
+ const cy = 3 * p1y;
1941
+ const by = 3 * (p2y - p1y) - cy;
1942
+ const ay = 1 - cy - by;
1943
+ function sampleCurveY(t) {
1944
+ return ((ay * t + by) * t + cy) * t;
1871
1945
  }
1872
- sanitize(raw) {
1873
- return typeof raw === "number" && isFinite(raw) ? raw : this._default;
1946
+ return function(x) {
1947
+ return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
1948
+ };
1949
+ }
1950
+ function lerp2(a, b, t) {
1951
+ return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
1952
+ }
1953
+ function subdivideCubicBezier(p0, p1, p2, p3, t) {
1954
+ const q0 = lerp2(p0, p1, t);
1955
+ const q1 = lerp2(p1, p2, t);
1956
+ const q2 = lerp2(p2, p3, t);
1957
+ const r0 = lerp2(q0, q1, t);
1958
+ const r1 = lerp2(q1, q2, t);
1959
+ const s = lerp2(r0, r1, t);
1960
+ return {
1961
+ left: [p0, q0, r0, s],
1962
+ right: [s, r1, q2, p3]
1963
+ };
1964
+ }
1965
+ function splitEasing(easing, xFraction) {
1966
+ if (!easing) return { left: void 0, right: void 0 };
1967
+ if (xFraction <= 0) return { left: void 0, right: easing };
1968
+ if (xFraction >= 1) return { left: easing, right: void 0 };
1969
+ const [x1, y1, x2, y2] = easing;
1970
+ const t = solveCubicBezierX(x1, x2, xFraction);
1971
+ const p0 = [0, 0];
1972
+ const p1 = [x1, y1];
1973
+ const p2 = [x2, y2];
1974
+ const p3 = [1, 1];
1975
+ const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
1976
+ const sx = left[3][0];
1977
+ const sy = left[3][1];
1978
+ let leftEasing;
1979
+ if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
1980
+ leftEasing = [
1981
+ left[1][0] / sx,
1982
+ left[1][1] / sy,
1983
+ left[2][0] / sx,
1984
+ left[2][1] / sy
1985
+ ];
1874
1986
  }
1875
- isValid(raw, ctx, path) {
1876
- if (typeof raw === "number" && isFinite(raw)) return true;
1877
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
1878
- return false;
1987
+ let rightEasing;
1988
+ const rx = 1 - sx;
1989
+ const ry = 1 - sy;
1990
+ if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
1991
+ rightEasing = [
1992
+ (right[1][0] - sx) / rx,
1993
+ (right[1][1] - sy) / ry,
1994
+ (right[2][0] - sx) / rx,
1995
+ (right[2][1] - sy) / ry
1996
+ ];
1879
1997
  }
1880
- };
1881
- var Bool = class extends Base {
1882
- constructor(_default = false) {
1883
- super();
1884
- this._default = _default;
1998
+ return { left: leftEasing, right: rightEasing };
1999
+ }
2000
+ function reverseEasing(easing) {
2001
+ if (!easing) return void 0;
2002
+ return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
2003
+ }
2004
+ function toRGBA(color) {
2005
+ const r = Math.round(color[0] * 255);
2006
+ const g = Math.round(color[1] * 255);
2007
+ const b = Math.round(color[2] * 255);
2008
+ return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
2009
+ }
2010
+ function parseRgba(s) {
2011
+ var _a;
2012
+ const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
2013
+ if (!inner) throw new Error("Invalid rgb/rgba format");
2014
+ const parts = inner.split(",").map((v) => +v.trim());
2015
+ return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
2016
+ }
2017
+ function parseHex(s) {
2018
+ const hex = s.slice(1);
2019
+ const isShort = hex.length <= 4;
2020
+ const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
2021
+ const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
2022
+ const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
2023
+ const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
2024
+ const result = [
2025
+ parseInt(r, 16) / 255,
2026
+ parseInt(g, 16) / 255,
2027
+ parseInt(b, 16) / 255
2028
+ ];
2029
+ if (a !== null) {
2030
+ result.push(parseInt(a, 16) / 255);
1885
2031
  }
1886
- sanitize(raw) {
1887
- return typeof raw === "boolean" ? raw : this._default;
2032
+ return result;
2033
+ }
2034
+ function parseColor(s) {
2035
+ if (!s) return void 0;
2036
+ if (Array.isArray(s)) return s;
2037
+ if (typeof s !== "string") return void 0;
2038
+ if (s.startsWith("#")) {
2039
+ return parseHex(s);
2040
+ } else if (s.startsWith("rgb")) {
2041
+ return parseRgba(s);
2042
+ } else {
2043
+ console.warn("Unsupported color format: " + s);
1888
2044
  }
1889
- isValid(raw, ctx, path) {
1890
- if (typeof raw === "boolean") return true;
1891
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
1892
- return false;
2045
+ return void 0;
2046
+ }
2047
+ var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
2048
+ var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
2049
+ var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
2050
+ function composeTransformParts(parts, opts) {
2051
+ var _a;
2052
+ if (!parts) return "";
2053
+ const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
2054
+ const segs = [];
2055
+ const t = parts.translate;
2056
+ const o = parts.origin;
2057
+ const r = parts.rotate;
2058
+ const k = parts.skew;
2059
+ const s = parts.scale;
2060
+ const tu = withUnits ? "px" : "";
2061
+ const ru = withUnits ? "deg" : "";
2062
+ if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
2063
+ if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
2064
+ if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
2065
+ if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
2066
+ if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
2067
+ if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
2068
+ return segs.join("");
2069
+ }
2070
+ var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
2071
+ var DEFAULT_DURATION_MS = 1e3;
2072
+ function kebabToCamelCaseWord(kebab) {
2073
+ return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
2074
+ }
2075
+ function isCamelCaseWord(word) {
2076
+ return !word.includes("-") && /[a-z][A-Z]/.test(word);
2077
+ }
2078
+ var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
2079
+ // Transform/positioning
2080
+ "viewBox",
2081
+ "preserveAspectRatio",
2082
+ // Gradient
2083
+ "gradientUnits",
2084
+ "gradientTransform",
2085
+ "spreadMethod",
2086
+ // Pattern
2087
+ "patternUnits",
2088
+ "patternContentUnits",
2089
+ "patternTransform",
2090
+ // Clipping/masking
2091
+ "clipPathUnits",
2092
+ "maskUnits",
2093
+ "maskContentUnits",
2094
+ // Marker (SVG spec keeps these camelCase, like viewBox)
2095
+ "markerUnits",
2096
+ "markerWidth",
2097
+ "markerHeight",
2098
+ "refX",
2099
+ "refY",
2100
+ // Text
2101
+ "textLength",
2102
+ "lengthAdjust",
2103
+ "startOffset",
2104
+ // Filter
2105
+ "filterUnits",
2106
+ "primitiveUnits",
2107
+ "tableValues",
2108
+ // feFuncR/G/B/A transfer table (type="table")
2109
+ "stdDeviation",
2110
+ "baseFrequency",
2111
+ "numOctaves",
2112
+ "surfaceScale",
2113
+ "diffuseConstant",
2114
+ "specularConstant",
2115
+ "specularExponent",
2116
+ "kernelMatrix",
2117
+ "kernelUnitLength",
2118
+ "edgeMode",
2119
+ "preserveAlpha",
2120
+ "targetX",
2121
+ "targetY"
2122
+ // // Animation
2123
+ // 'attributeName',
2124
+ // 'attributeType',
2125
+ // 'calcMode',
2126
+ // 'keyTimes',
2127
+ // 'keySplines',
2128
+ // 'repeatCount',
2129
+ // 'repeatDur'
2130
+ ]);
2131
+ function camelCaseToKebabWordIfNeeded(camel) {
2132
+ return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2133
+ }
2134
+ function clamp(value, min, max) {
2135
+ return Math.max(min, Math.min(value, max));
2136
+ }
2137
+ function bezier2D_pointAt(P0, P1, P2, P3, t) {
2138
+ if (t <= 0) return [P0[0], P0[1]];
2139
+ if (t >= 1) return [P3[0], P3[1]];
2140
+ const u = 1 - t;
2141
+ const u2 = u * u;
2142
+ const u3 = u2 * u;
2143
+ const t2 = t * t;
2144
+ const t3 = t2 * t;
2145
+ const w0 = u3;
2146
+ const w1 = 3 * t * u2;
2147
+ const w2 = 3 * t2 * u;
2148
+ const w3 = t3;
2149
+ return [
2150
+ w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
2151
+ w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
2152
+ ];
2153
+ }
2154
+ var BEZIER_T_NUDGE = 1e-4;
2155
+ function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
2156
+ const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
2157
+ if (result[0] === 0 && result[1] === 0) {
2158
+ const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
2159
+ return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
2160
+ }
2161
+ return result;
2162
+ }
2163
+ function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
2164
+ const u = 1 - t;
2165
+ const a = 3 * u * u;
2166
+ const b = 6 * t * u;
2167
+ const c = 3 * t * t;
2168
+ return [
2169
+ a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
2170
+ a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
2171
+ ];
2172
+ }
2173
+ function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
2174
+ const n = steps + 1;
2175
+ const ts = new Float64Array(n);
2176
+ const ds = new Float64Array(n);
2177
+ let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
2178
+ ts[0] = 0;
2179
+ ds[0] = 0;
2180
+ let cum = 0;
2181
+ for (let i = 1; i < n; i++) {
2182
+ const t = i / steps;
2183
+ const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
2184
+ const dx = cur[0] - prev[0];
2185
+ const dy = cur[1] - prev[1];
2186
+ cum += Math.sqrt(dx * dx + dy * dy);
2187
+ ts[i] = t;
2188
+ ds[i] = cum;
2189
+ prev = cur;
2190
+ }
2191
+ return { ts, ds };
2192
+ }
2193
+ function bezier2D_tForDistance(lut, distance) {
2194
+ const { ts, ds } = lut;
2195
+ const last = ds.length - 1;
2196
+ if (distance <= 0) return ts[0];
2197
+ if (distance >= ds[last]) return ts[last];
2198
+ let lo = 1;
2199
+ let hi = last;
2200
+ while (lo < hi) {
2201
+ const mid = lo + hi >>> 1;
2202
+ if (ds[mid] < distance) lo = mid + 1;
2203
+ else hi = mid;
2204
+ }
2205
+ const dPrev = ds[hi - 1];
2206
+ const dCur = ds[hi];
2207
+ const span = dCur - dPrev;
2208
+ const frac = span > 0 ? (distance - dPrev) / span : 0;
2209
+ return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
2210
+ }
2211
+ function bezier2D_arcAtT(lut, t) {
2212
+ const { ts, ds } = lut;
2213
+ const last = ts.length - 1;
2214
+ if (t <= ts[0]) return ds[0];
2215
+ if (t >= ts[last]) return ds[last];
2216
+ let lo = 1, hi = last;
2217
+ while (lo < hi) {
2218
+ const mid = lo + hi >>> 1;
2219
+ if (ts[mid] < t) lo = mid + 1;
2220
+ else hi = mid;
2221
+ }
2222
+ const tPrev = ts[hi - 1];
2223
+ const span = ts[hi] - tPrev;
2224
+ const frac = span > 0 ? (t - tPrev) / span : 0;
2225
+ return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
2226
+ }
2227
+ function invertEasing(easing) {
2228
+ if (!easing) return (y) => y;
2229
+ const flipped = [easing[1], easing[0], easing[3], easing[2]];
2230
+ return cubicBezier(flipped);
2231
+ }
2232
+ function isScrollTimeline(config) {
2233
+ return (config == null ? void 0 : config.timelineSource) === "scroll";
2234
+ }
2235
+ function scrollTotalDurationMs(config) {
2236
+ const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
2237
+ const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
2238
+ return duration * iterations;
2239
+ }
2240
+ function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
2241
+ const s = subjectSize, vp = scrollportSize;
2242
+ switch (phase) {
2243
+ case "cover":
2244
+ return [0, s + vp];
2245
+ case "entry":
2246
+ return [0, Math.min(s, vp)];
2247
+ case "contain":
2248
+ return [Math.min(s, vp), Math.max(s, vp)];
2249
+ case "exit":
2250
+ return [Math.max(s, vp), s + vp];
2251
+ case "entry-crossing":
2252
+ return [0, s];
2253
+ case "exit-crossing":
2254
+ return [vp, s + vp];
2255
+ }
2256
+ }
2257
+ var DEFAULT_PHASE = "cover";
2258
+ function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
2259
+ var _a;
2260
+ const [u0, u1] = scrollPhaseInterval((_a = point == null ? void 0 : point.phase) != null ? _a : DEFAULT_PHASE, subjectSize, scrollportSize);
2261
+ const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
2262
+ return u0 + fraction * (u1 - u0);
2263
+ }
2264
+ function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
2265
+ const u = scrollportSize - subjectStart;
2266
+ const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
2267
+ const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
2268
+ if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
2269
+ return clamp((u - uStart) / (uEnd - uStart), 0, 1);
2270
+ }
2271
+ function scrollOffsetProgress(offset, maxOffset, range) {
2272
+ var _a, _b;
2273
+ const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
2274
+ const start = typeof ((_a = range == null ? void 0 : range.start) == null ? void 0 : _a.fraction) === "number" ? range.start.fraction : 0;
2275
+ const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
2276
+ if (end <= start) return raw >= end ? 1 : 0;
2277
+ return clamp((raw - start) / (end - start), 0, 1);
2278
+ }
2279
+ function scrollResolveAxis(axis, writingMode) {
2280
+ const a = axis != null ? axis : "block";
2281
+ if (a === "x" || a === "y") return a;
2282
+ const vertical = !!writingMode && writingMode.startsWith("vertical");
2283
+ if (a === "inline") return vertical ? "y" : "x";
2284
+ return vertical ? "x" : "y";
2285
+ }
2286
+ function pathStr(path) {
2287
+ if (!path.length) return ".";
2288
+ let result = "";
2289
+ for (const seg of path) {
2290
+ if (seg.startsWith("[")) result += seg;
2291
+ else result += (result ? "." : "") + seg;
2292
+ }
2293
+ return result;
2294
+ }
2295
+ var Base = class {
2296
+ _canSanitize(raw) {
2297
+ return this.isValid(raw);
2298
+ }
2299
+ optional() {
2300
+ return new Optional(this);
1893
2301
  }
1894
2302
  };
1895
- var Literal = class extends Base {
1896
- constructor(value) {
2303
+ var Optional = class extends Base {
2304
+ constructor(inner) {
1897
2305
  super();
1898
- this.value = value;
1899
- this._default = value;
2306
+ this.inner = inner;
2307
+ this._default = void 0;
1900
2308
  }
1901
2309
  sanitize(raw) {
1902
- return raw === this.value ? this.value : this._default;
2310
+ if (raw === void 0 || raw === null) return void 0;
2311
+ return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
1903
2312
  }
1904
2313
  isValid(raw, ctx, path) {
1905
- if (raw === this.value) return true;
1906
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected " + JSON.stringify(this.value) + ", got " + JSON.stringify(raw));
1907
- return false;
2314
+ if (raw === void 0 || raw === null) return true;
2315
+ return this.inner.isValid(raw, ctx, path);
2316
+ }
2317
+ _canSanitize(raw) {
2318
+ return raw === void 0 || raw === null || this.inner._canSanitize(raw);
1908
2319
  }
1909
2320
  };
1910
- var Enum = class extends Base {
1911
- constructor(values, defaultVal) {
2321
+ var Str = class extends Base {
2322
+ constructor(_default = "") {
1912
2323
  super();
1913
- this.values = values;
1914
- this._default = defaultVal != null ? defaultVal : values[0];
2324
+ this._default = _default;
1915
2325
  }
1916
2326
  sanitize(raw) {
1917
- return this.values.includes(raw) ? raw : this._default;
2327
+ return typeof raw === "string" ? raw : this._default;
1918
2328
  }
1919
2329
  isValid(raw, ctx, path) {
1920
- if (this.values.includes(raw)) return true;
1921
- ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected one of " + this.values.map((v) => JSON.stringify(v)).join(" | ") + ", got " + JSON.stringify(raw));
2330
+ if (typeof raw === "string") return true;
2331
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
1922
2332
  return false;
1923
2333
  }
1924
2334
  };
1925
- var Union = class extends Base {
2335
+ var Num = class extends Base {
2336
+ constructor(_default = 0) {
2337
+ super();
2338
+ this._default = _default;
2339
+ }
2340
+ sanitize(raw) {
2341
+ return typeof raw === "number" && isFinite(raw) ? raw : this._default;
2342
+ }
2343
+ isValid(raw, ctx, path) {
2344
+ if (typeof raw === "number" && isFinite(raw)) return true;
2345
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
2346
+ return false;
2347
+ }
2348
+ };
2349
+ var Bool = class extends Base {
2350
+ constructor(_default = false) {
2351
+ super();
2352
+ this._default = _default;
2353
+ }
2354
+ sanitize(raw) {
2355
+ return typeof raw === "boolean" ? raw : this._default;
2356
+ }
2357
+ isValid(raw, ctx, path) {
2358
+ if (typeof raw === "boolean") return true;
2359
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
2360
+ return false;
2361
+ }
2362
+ };
2363
+ var Literal = class extends Base {
2364
+ constructor(value) {
2365
+ super();
2366
+ this.value = value;
2367
+ this._default = value;
2368
+ }
2369
+ sanitize(raw) {
2370
+ return raw === this.value ? this.value : this._default;
2371
+ }
2372
+ isValid(raw, ctx, path) {
2373
+ if (raw === this.value) return true;
2374
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected " + JSON.stringify(this.value) + ", got " + JSON.stringify(raw));
2375
+ return false;
2376
+ }
2377
+ };
2378
+ var Enum = class extends Base {
2379
+ constructor(values, defaultVal) {
2380
+ super();
2381
+ this.values = values;
2382
+ this._default = defaultVal != null ? defaultVal : values[0];
2383
+ }
2384
+ sanitize(raw) {
2385
+ return this.values.includes(raw) ? raw : this._default;
2386
+ }
2387
+ isValid(raw, ctx, path) {
2388
+ if (this.values.includes(raw)) return true;
2389
+ ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected one of " + this.values.map((v) => JSON.stringify(v)).join(" | ") + ", got " + JSON.stringify(raw));
2390
+ return false;
2391
+ }
2392
+ };
2393
+ var Union = class extends Base {
1926
2394
  constructor(schemas, defaultVal) {
1927
2395
  super();
1928
2396
  this.schemas = schemas;
@@ -2459,6 +2927,22 @@ var PixodeskAnimatorReact = (() => {
2459
2927
  styles: px.record(px.any()).optional(),
2460
2928
  glyphs: px.record(PxGlyphFontSchema).optional()
2461
2929
  }));
2930
+ var PX_SCROLL_PHASES = ["cover", "contain", "entry", "exit", "entry-crossing", "exit-crossing"];
2931
+ var PxScrollRangePointSchema = implementsInterface()(px.object({
2932
+ phase: px.enum(PX_SCROLL_PHASES).optional(),
2933
+ fraction: px.number().optional()
2934
+ }));
2935
+ var PxScrollRangeSchema = px.object({
2936
+ start: PxScrollRangePointSchema.optional(),
2937
+ end: PxScrollRangePointSchema.optional()
2938
+ });
2939
+ var PxScrollSchema = implementsInterface()(px.object({
2940
+ driver: px.enum(["custom", "native"]).optional(),
2941
+ kind: px.enum(["view", "scroll"]).optional(),
2942
+ axis: px.enum(["block", "inline", "x", "y"]).optional(),
2943
+ source: px.enum(["nearest", "root"]).optional(),
2944
+ range: PxScrollRangeSchema.optional()
2945
+ }));
2462
2946
  var PxAnimatorConfigSchema = implementsInterface()(px.object({
2463
2947
  mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.waapi, PxAnimatorMode.frames]).optional(),
2464
2948
  duration: px.number().optional(),
@@ -2474,6 +2958,7 @@ var PixodeskAnimatorReact = (() => {
2474
2958
  definitions: PxDefsSchema.optional(),
2475
2959
  animateById: px.record(PxElementAnimationSchema).optional(),
2476
2960
  timelineSource: px.string().optional(),
2961
+ scroll: PxScrollSchema.optional(),
2477
2962
  debugInstName: px.string().optional()
2478
2963
  }));
2479
2964
  var PxBindingSchema = implementsInterface()(px.object({
@@ -2487,592 +2972,180 @@ var PixodeskAnimatorReact = (() => {
2487
2972
  // Structured static — `{value: …}` (read-accepted transitional spelling, S1).
2488
2973
  // `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
2489
2974
  px.object({ value: px.defined() }),
2490
- // Bare transform parts record — the canonical static `transform` on the wire (T2).
2491
- PxTransformPartsSchema
2492
- ]);
2493
- var PxAnimatableNumberSchema = px.union([
2494
- px.number(),
2495
- px.object({ value: px.number() }),
2496
- PxPropertyAnimationSchema
2497
- ]);
2498
- var PxAnimatableVec2Schema = px.union([
2499
- px.tuple([px.number(), px.number()]),
2500
- px.object({ value: px.tuple([px.number(), px.number()]) }),
2501
- PxPropertyAnimationSchema
2502
- ]);
2503
- var PxAnimatableStringSchema = px.union([
2504
- px.string(),
2505
- px.object({ value: px.string() }),
2506
- PxPropertyAnimationSchema
2507
- ]);
2508
- var PxTransformByEffectSchema = implementsInterface()(px.object({
2509
- translate: PxAnimatableVec2Schema.optional(),
2510
- rotate: PxAnimatableNumberSchema.optional(),
2511
- scale: PxAnimatableVec2Schema.optional(),
2512
- skew: PxAnimatableNumberSchema.optional(),
2513
- origin: PxAnimatableVec2Schema.optional()
2514
- }));
2515
- var PxRepeaterEffectSchema = implementsInterface()(px.object({
2516
- // STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
2517
- // once at expansion time and never sampled — plain number, no `keyframes`.
2518
- copies: px.number().optional(),
2519
- translate: PxAnimatableVec2Schema.optional(),
2520
- rotate: PxAnimatableNumberSchema.optional(),
2521
- skew: PxAnimatableNumberSchema.optional(),
2522
- scale: PxAnimatableVec2Schema.optional(),
2523
- origin: PxAnimatableVec2Schema.optional()
2524
- }));
2525
- var PxMaskedByEffectSchema = implementsInterface()(px.object({
2526
- sourceId: px.string().optional(),
2527
- maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
2528
- maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
2529
- maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
2530
- x: px.number().optional(),
2531
- y: px.number().optional(),
2532
- width: px.number().optional(),
2533
- height: px.number().optional()
2534
- }));
2535
- var PxClipPathEffectSchema = implementsInterface()(px.object({
2536
- d: PxAnimatableStringSchema.optional(),
2537
- animate: PxPropertyAnimationSchema.optional()
2538
- }));
2539
- var PxTrimPathEffectSchema = implementsInterface()(px.object({
2540
- offset: PxAnimatableNumberSchema.optional(),
2541
- range: PxAnimatableVec2Schema.optional(),
2542
- subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
2543
- }));
2544
- var PxRetimeEffectSchema = implementsInterface()(px.object({
2545
- sourceId: px.string().optional(),
2546
- start: px.number().optional(),
2547
- stretch: px.number().optional(),
2548
- timeCrop: px.tuple([px.number(), px.number()]).optional()
2549
- }));
2550
- var PxCloneEffectSchema = implementsInterface()(px.object({
2551
- // Contextual kind — the `type` convention, see `PxNodeBase.type`.
2552
- type: px.enum([PxCloneType.content]).optional(),
2553
- sourceId: px.string().optional(),
2554
- retime: PxRetimeEffectSchema.optional()
2555
- }));
2556
- var PxGradientStopSchema = implementsInterface()(px.object({
2557
- offset: px.number(),
2558
- color: px.string()
2559
- }));
2560
- var PxAnimatableGradientStopsSchema = px.union([
2561
- px.array(PxGradientStopSchema),
2562
- px.object({ value: px.array(PxGradientStopSchema) }),
2563
- PxPropertyAnimationSchema
2564
- ]);
2565
- var PxFillGradientEffectSchema = implementsInterface()(px.object({
2566
- // Contextual kind — the `type` convention, see `PxNodeBase.type`.
2567
- type: px.enum([PxGradientType.linear, PxGradientType.radial]),
2568
- p1: PxAnimatableVec2Schema.optional(),
2569
- p2: PxAnimatableVec2Schema.optional(),
2570
- c: PxAnimatableVec2Schema.optional(),
2571
- r: PxAnimatableNumberSchema.optional(),
2572
- fp: PxAnimatableVec2Schema.optional(),
2573
- stops: PxAnimatableGradientStopsSchema.optional(),
2574
- gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
2575
- spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
2576
- gradientTransform: px.string().optional()
2577
- }));
2578
- var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
2579
- var PxTextPathEffectSchema = implementsInterface()(px.object({
2580
- path: px.string(),
2581
- pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
2582
- lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
2583
- method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
2584
- spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
2585
- startOffset: PxAnimatableNumberSchema.optional(),
2586
- textLength: PxAnimatableNumberSchema.optional()
2587
- }));
2588
- var PxTextEffectSchema = implementsInterface()(px.object({
2589
- useGlyphs: px.boolean().optional()
2590
- }));
2591
- var PxEffectsSchema = implementsInterface()(px.object({
2592
- transformBy: PxTransformByEffectSchema.optional(),
2593
- repeater: PxRepeaterEffectSchema.optional(),
2594
- maskedBy: PxMaskedByEffectSchema.optional(),
2595
- clipPath: PxClipPathEffectSchema.optional(),
2596
- trimPath: PxTrimPathEffectSchema.optional(),
2597
- clone: PxCloneEffectSchema.optional(),
2598
- fillGradient: PxFillGradientEffectSchema.optional(),
2599
- strokeGradient: PxStrokeGradientEffectSchema.optional(),
2600
- textPath: PxTextPathEffectSchema.optional(),
2601
- text: PxTextEffectSchema.optional()
2602
- }));
2603
- function validateNodeEffects(root, opts) {
2604
- const warnings = [];
2605
- const walk = (node, path) => {
2606
- if (node && node.effects) {
2607
- const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
2608
- const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
2609
- if (!ok) {
2610
- for (const err of ctx.errors) warnings.push(err);
2611
- }
2612
- }
2613
- if (node && Array.isArray(node.children)) {
2614
- node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
2615
- }
2616
- };
2617
- walk(root, "root");
2618
- return warnings;
2619
- }
2620
- var PxNodeBase = px.openObject({
2621
- // CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
2622
- // kind of thing is this", discriminated by its CARRIER — here the node TAG
2623
- // (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
2624
- // `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
2625
- // the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
2626
- // would add words that all mean "type" and still need the carrier to read.
2627
- // Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
2628
- // (issues V3), never of distinct key names.
2629
- type: px.string(),
2630
- id: px.string().optional(),
2631
- meta: px.any().optional(),
2632
- // Player-effects bucket emitted by the Editor's lightweight design format.
2633
- // Consumed and removed by `applyPlayerEffects` before any other normalisation
2634
- // (see `createAnimatorImpl`), so downstream code never sees it.
2635
- effects: PxEffectsSchema.optional(),
2636
- // `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
2637
- // string ref / array of refs / inline definition / mixed array; mirrors
2638
- // `animator.animateById` map values and what `processNode` resolves at runtime.
2639
- animate: PxElementAnimationSchema.optional(),
2640
- style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
2641
- }, PxAttrValueSchema);
2642
- var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
2643
- children: px.lazy(() => px.array(PxNodeSchema), []).optional()
2644
- }), PxAttrValueSchema);
2645
- var PxSvgNodeExtra = px.object({
2646
- width: px.number().optional(),
2647
- height: px.number().optional(),
2648
- viewBox: px.string().optional(),
2649
- animator: PxAnimatorConfigSchema.optional()
2650
- });
2651
- var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
2652
- type: px.literal("svg"),
2653
- // override string → literal to require 'svg'
2654
- children: px.array(PxNodeSchema).optional()
2655
- }), PxAttrValueSchema);
2656
- var PxBezierPathSchema = implementsInterface()(px.object({
2657
- v: px.array(px.array(px.number())),
2658
- i: px.array(px.array(px.number())).optional(),
2659
- o: px.array(px.array(px.number())).optional(),
2660
- c: px.boolean().optional()
2661
- }));
2662
- function bezierToSvgPath(path, forceCurves = false) {
2663
- var _a, _b, _c, _d;
2664
- const v = path.v;
2665
- const i = path.i;
2666
- const o = path.o;
2667
- const c = path.c;
2668
- if (!v.length) return "";
2669
- const d = [];
2670
- const len = v.length;
2671
- d.push("M" + v[0][0] + "," + v[0][1]);
2672
- for (let idx = 1; idx < len; idx++) {
2673
- const prevV = v[idx - 1];
2674
- const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
2675
- const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
2676
- const currV = v[idx];
2677
- const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
2678
- if (isLine) {
2679
- d.push("L" + currV[0] + "," + currV[1]);
2680
- } else {
2681
- d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
2682
- }
2683
- }
2684
- if (c && len > 0) {
2685
- const lastV = v[len - 1];
2686
- const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
2687
- const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
2688
- const firstV = v[0];
2689
- const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
2690
- if (!isLine) {
2691
- d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
2692
- }
2693
- d.push("z");
2694
- }
2695
- return d.join("");
2696
- }
2697
- function interpolateNum(a, b, t) {
2698
- return a + (b - a) * t;
2699
- }
2700
- function interpolateVec(a, b, t) {
2701
- const res = [];
2702
- const count = Math.max(a.length, b.length);
2703
- for (let i = 0; i < count; i++) {
2704
- res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
2705
- }
2706
- return res;
2707
- }
2708
- function interpolateColor(a, b, t) {
2709
- return [
2710
- interpolateNum(a[0] || 0, b[0] || 0, t),
2711
- interpolateNum(a[1] || 0, b[1] || 0, t),
2712
- interpolateNum(a[2] || 0, b[2] || 0, t),
2713
- interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
2714
- ];
2715
- }
2716
- function interpolateBeziers(paths1, paths2, progress) {
2717
- const count = Math.max(paths1.length, paths2.length);
2718
- const res = [];
2719
- for (let i = 0; i < count; i++) {
2720
- res.push(interpolateBezier(paths1[i], paths2[i], progress));
2721
- }
2722
- return res;
2723
- }
2724
- function interpolateBezier(path1, path2, progress) {
2725
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2726
- if (!path1 || !path2) return path1 || path2 || { v: [] };
2727
- const t = Math.min(Math.max(progress, 0), 1);
2728
- const len = Math.min(path1.v.length, path2.v.length);
2729
- const v = [];
2730
- const i = [];
2731
- const o = [];
2732
- for (let idx = 0; idx < len; idx++) {
2733
- const v1 = path1.v[idx];
2734
- const v2 = path2.v[idx];
2735
- v.push(interpolateVec(v1, v2, t));
2736
- const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
2737
- const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
2738
- i.push(interpolateVec(i1, i2, t));
2739
- const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
2740
- const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
2741
- o.push(interpolateVec(o1, o2, t));
2742
- }
2743
- return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
2744
- }
2745
- function remap(value, inMin, inMax, outMin, outMax) {
2746
- if (inMax === inMin) return outMin;
2747
- const t = (value - inMin) / (inMax - inMin);
2748
- return outMin + t * (outMax - outMin);
2749
- }
2750
- function solveCubicBezierX(p1x, p2x, x) {
2751
- if (x <= 0) return 0;
2752
- if (x >= 1) return 1;
2753
- const cx = 3 * p1x;
2754
- const bx = 3 * (p2x - p1x) - cx;
2755
- const ax = 1 - cx - bx;
2756
- function sampleX(t) {
2757
- return ((ax * t + bx) * t + cx) * t;
2758
- }
2759
- function sampleDX(t) {
2760
- return (3 * ax * t + 2 * bx) * t + cx;
2761
- }
2762
- let t2 = x;
2763
- let t0 = 0;
2764
- let t1 = 1;
2765
- for (let i = 0; i < 8; i++) {
2766
- const x2 = sampleX(t2) - x;
2767
- if (Math.abs(x2) < 1e-6) return t2;
2768
- const d2 = sampleDX(t2);
2769
- if (Math.abs(d2) < 1e-6) break;
2770
- t2 -= x2 / d2;
2771
- }
2772
- t2 = x;
2773
- while (t0 < t1) {
2774
- const x2 = sampleX(t2);
2775
- if (Math.abs(x2 - x) < 1e-6) return t2;
2776
- if (x > x2) t0 = t2;
2777
- else t1 = t2;
2778
- t2 = (t1 + t0) / 2;
2779
- }
2780
- return t2;
2781
- }
2782
- function cubicBezier(easing) {
2783
- const [p1x, p1y, p2x, p2y] = easing;
2784
- const cy = 3 * p1y;
2785
- const by = 3 * (p2y - p1y) - cy;
2786
- const ay = 1 - cy - by;
2787
- function sampleCurveY(t) {
2788
- return ((ay * t + by) * t + cy) * t;
2789
- }
2790
- return function(x) {
2791
- return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
2792
- };
2793
- }
2794
- function lerp2(a, b, t) {
2795
- return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
2796
- }
2797
- function subdivideCubicBezier(p0, p1, p2, p3, t) {
2798
- const q0 = lerp2(p0, p1, t);
2799
- const q1 = lerp2(p1, p2, t);
2800
- const q2 = lerp2(p2, p3, t);
2801
- const r0 = lerp2(q0, q1, t);
2802
- const r1 = lerp2(q1, q2, t);
2803
- const s = lerp2(r0, r1, t);
2804
- return {
2805
- left: [p0, q0, r0, s],
2806
- right: [s, r1, q2, p3]
2807
- };
2808
- }
2809
- function splitEasing(easing, xFraction) {
2810
- if (!easing) return { left: void 0, right: void 0 };
2811
- if (xFraction <= 0) return { left: void 0, right: easing };
2812
- if (xFraction >= 1) return { left: easing, right: void 0 };
2813
- const [x1, y1, x2, y2] = easing;
2814
- const t = solveCubicBezierX(x1, x2, xFraction);
2815
- const p0 = [0, 0];
2816
- const p1 = [x1, y1];
2817
- const p2 = [x2, y2];
2818
- const p3 = [1, 1];
2819
- const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
2820
- const sx = left[3][0];
2821
- const sy = left[3][1];
2822
- let leftEasing;
2823
- if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
2824
- leftEasing = [
2825
- left[1][0] / sx,
2826
- left[1][1] / sy,
2827
- left[2][0] / sx,
2828
- left[2][1] / sy
2829
- ];
2830
- }
2831
- let rightEasing;
2832
- const rx = 1 - sx;
2833
- const ry = 1 - sy;
2834
- if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
2835
- rightEasing = [
2836
- (right[1][0] - sx) / rx,
2837
- (right[1][1] - sy) / ry,
2838
- (right[2][0] - sx) / rx,
2839
- (right[2][1] - sy) / ry
2840
- ];
2841
- }
2842
- return { left: leftEasing, right: rightEasing };
2843
- }
2844
- function reverseEasing(easing) {
2845
- if (!easing) return void 0;
2846
- return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
2847
- }
2848
- function toRGBA(color) {
2849
- const r = Math.round(color[0] * 255);
2850
- const g = Math.round(color[1] * 255);
2851
- const b = Math.round(color[2] * 255);
2852
- return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
2853
- }
2854
- function parseRgba(s) {
2855
- var _a;
2856
- const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
2857
- if (!inner) throw new Error("Invalid rgb/rgba format");
2858
- const parts = inner.split(",").map((v) => +v.trim());
2859
- return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
2860
- }
2861
- function parseHex(s) {
2862
- const hex = s.slice(1);
2863
- const isShort = hex.length <= 4;
2864
- const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
2865
- const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
2866
- const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
2867
- const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
2868
- const result = [
2869
- parseInt(r, 16) / 255,
2870
- parseInt(g, 16) / 255,
2871
- parseInt(b, 16) / 255
2872
- ];
2873
- if (a !== null) {
2874
- result.push(parseInt(a, 16) / 255);
2875
- }
2876
- return result;
2877
- }
2878
- function parseColor(s) {
2879
- if (!s) return void 0;
2880
- if (Array.isArray(s)) return s;
2881
- if (typeof s !== "string") return void 0;
2882
- if (s.startsWith("#")) {
2883
- return parseHex(s);
2884
- } else if (s.startsWith("rgb")) {
2885
- return parseRgba(s);
2886
- } else {
2887
- console.warn("Unsupported color format: " + s);
2888
- }
2889
- return void 0;
2890
- }
2891
- var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
2892
- var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
2893
- var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
2894
- function composeTransformParts(parts, opts) {
2895
- var _a;
2896
- if (!parts) return "";
2897
- const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
2898
- const segs = [];
2899
- const t = parts.translate;
2900
- const o = parts.origin;
2901
- const r = parts.rotate;
2902
- const k = parts.skew;
2903
- const s = parts.scale;
2904
- const tu = withUnits ? "px" : "";
2905
- const ru = withUnits ? "deg" : "";
2906
- if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
2907
- if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
2908
- if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
2909
- if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
2910
- if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
2911
- if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
2912
- return segs.join("");
2913
- }
2914
- var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
2915
- var DEFAULT_DURATION_MS = 1e3;
2916
- function kebabToCamelCaseWord(kebab) {
2917
- return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
2918
- }
2919
- function isCamelCaseWord(word) {
2920
- return !word.includes("-") && /[a-z][A-Z]/.test(word);
2921
- }
2922
- var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
2923
- // Transform/positioning
2924
- "viewBox",
2925
- "preserveAspectRatio",
2926
- // Gradient
2927
- "gradientUnits",
2928
- "gradientTransform",
2929
- "spreadMethod",
2930
- // Pattern
2931
- "patternUnits",
2932
- "patternContentUnits",
2933
- "patternTransform",
2934
- // Clipping/masking
2935
- "clipPathUnits",
2936
- "maskUnits",
2937
- "maskContentUnits",
2938
- // Marker (SVG spec keeps these camelCase, like viewBox)
2939
- "markerUnits",
2940
- "markerWidth",
2941
- "markerHeight",
2942
- "refX",
2943
- "refY",
2944
- // Text
2945
- "textLength",
2946
- "lengthAdjust",
2947
- "startOffset",
2948
- // Filter
2949
- "filterUnits",
2950
- "primitiveUnits",
2951
- "tableValues",
2952
- // feFuncR/G/B/A transfer table (type="table")
2953
- "stdDeviation",
2954
- "baseFrequency",
2955
- "numOctaves",
2956
- "surfaceScale",
2957
- "diffuseConstant",
2958
- "specularConstant",
2959
- "specularExponent",
2960
- "kernelMatrix",
2961
- "kernelUnitLength",
2962
- "edgeMode",
2963
- "preserveAlpha",
2964
- "targetX",
2965
- "targetY"
2966
- // // Animation
2967
- // 'attributeName',
2968
- // 'attributeType',
2969
- // 'calcMode',
2970
- // 'keyTimes',
2971
- // 'keySplines',
2972
- // 'repeatCount',
2973
- // 'repeatDur'
2974
- ]);
2975
- function camelCaseToKebabWordIfNeeded(camel) {
2976
- return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2977
- }
2978
- function clamp(value, min, max) {
2979
- return Math.max(min, Math.min(value, max));
2980
- }
2981
- function bezier2D_pointAt(P0, P1, P2, P3, t) {
2982
- if (t <= 0) return [P0[0], P0[1]];
2983
- if (t >= 1) return [P3[0], P3[1]];
2984
- const u = 1 - t;
2985
- const u2 = u * u;
2986
- const u3 = u2 * u;
2987
- const t2 = t * t;
2988
- const t3 = t2 * t;
2989
- const w0 = u3;
2990
- const w1 = 3 * t * u2;
2991
- const w2 = 3 * t2 * u;
2992
- const w3 = t3;
2993
- return [
2994
- w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
2995
- w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
2996
- ];
2997
- }
2998
- var BEZIER_T_NUDGE = 1e-4;
2999
- function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
3000
- const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
3001
- if (result[0] === 0 && result[1] === 0) {
3002
- const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
3003
- return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
3004
- }
3005
- return result;
3006
- }
3007
- function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
3008
- const u = 1 - t;
3009
- const a = 3 * u * u;
3010
- const b = 6 * t * u;
3011
- const c = 3 * t * t;
3012
- return [
3013
- a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
3014
- a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
3015
- ];
3016
- }
3017
- function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
3018
- const n = steps + 1;
3019
- const ts = new Float64Array(n);
3020
- const ds = new Float64Array(n);
3021
- let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
3022
- ts[0] = 0;
3023
- ds[0] = 0;
3024
- let cum = 0;
3025
- for (let i = 1; i < n; i++) {
3026
- const t = i / steps;
3027
- const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
3028
- const dx = cur[0] - prev[0];
3029
- const dy = cur[1] - prev[1];
3030
- cum += Math.sqrt(dx * dx + dy * dy);
3031
- ts[i] = t;
3032
- ds[i] = cum;
3033
- prev = cur;
3034
- }
3035
- return { ts, ds };
3036
- }
3037
- function bezier2D_tForDistance(lut, distance) {
3038
- const { ts, ds } = lut;
3039
- const last = ds.length - 1;
3040
- if (distance <= 0) return ts[0];
3041
- if (distance >= ds[last]) return ts[last];
3042
- let lo = 1;
3043
- let hi = last;
3044
- while (lo < hi) {
3045
- const mid = lo + hi >>> 1;
3046
- if (ds[mid] < distance) lo = mid + 1;
3047
- else hi = mid;
3048
- }
3049
- const dPrev = ds[hi - 1];
3050
- const dCur = ds[hi];
3051
- const span = dCur - dPrev;
3052
- const frac = span > 0 ? (distance - dPrev) / span : 0;
3053
- return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
3054
- }
3055
- function bezier2D_arcAtT(lut, t) {
3056
- const { ts, ds } = lut;
3057
- const last = ts.length - 1;
3058
- if (t <= ts[0]) return ds[0];
3059
- if (t >= ts[last]) return ds[last];
3060
- let lo = 1, hi = last;
3061
- while (lo < hi) {
3062
- const mid = lo + hi >>> 1;
3063
- if (ts[mid] < t) lo = mid + 1;
3064
- else hi = mid;
3065
- }
3066
- const tPrev = ts[hi - 1];
3067
- const span = ts[hi] - tPrev;
3068
- const frac = span > 0 ? (t - tPrev) / span : 0;
3069
- return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
3070
- }
3071
- function invertEasing(easing) {
3072
- if (!easing) return (y) => y;
3073
- const flipped = [easing[1], easing[0], easing[3], easing[2]];
3074
- return cubicBezier(flipped);
2975
+ // Bare transform parts record — the canonical static `transform` on the wire (T2).
2976
+ PxTransformPartsSchema
2977
+ ]);
2978
+ var PxAnimatableNumberSchema = px.union([
2979
+ px.number(),
2980
+ px.object({ value: px.number() }),
2981
+ PxPropertyAnimationSchema
2982
+ ]);
2983
+ var PxAnimatableVec2Schema = px.union([
2984
+ px.tuple([px.number(), px.number()]),
2985
+ px.object({ value: px.tuple([px.number(), px.number()]) }),
2986
+ PxPropertyAnimationSchema
2987
+ ]);
2988
+ var PxAnimatableStringSchema = px.union([
2989
+ px.string(),
2990
+ px.object({ value: px.string() }),
2991
+ PxPropertyAnimationSchema
2992
+ ]);
2993
+ var PxTransformByEffectSchema = implementsInterface()(px.object({
2994
+ translate: PxAnimatableVec2Schema.optional(),
2995
+ rotate: PxAnimatableNumberSchema.optional(),
2996
+ scale: PxAnimatableVec2Schema.optional(),
2997
+ skew: PxAnimatableNumberSchema.optional(),
2998
+ origin: PxAnimatableVec2Schema.optional()
2999
+ }));
3000
+ var PxRepeaterEffectSchema = implementsInterface()(px.object({
3001
+ // STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
3002
+ // once at expansion time and never sampled — plain number, no `keyframes`.
3003
+ copies: px.number().optional(),
3004
+ translate: PxAnimatableVec2Schema.optional(),
3005
+ rotate: PxAnimatableNumberSchema.optional(),
3006
+ skew: PxAnimatableNumberSchema.optional(),
3007
+ scale: PxAnimatableVec2Schema.optional(),
3008
+ origin: PxAnimatableVec2Schema.optional()
3009
+ }));
3010
+ var PxMaskedByEffectSchema = implementsInterface()(px.object({
3011
+ sourceId: px.string().optional(),
3012
+ maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
3013
+ maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
3014
+ maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
3015
+ x: px.number().optional(),
3016
+ y: px.number().optional(),
3017
+ width: px.number().optional(),
3018
+ height: px.number().optional()
3019
+ }));
3020
+ var PxClipPathEffectSchema = implementsInterface()(px.object({
3021
+ d: PxAnimatableStringSchema.optional(),
3022
+ animate: PxPropertyAnimationSchema.optional()
3023
+ }));
3024
+ var PxTrimPathEffectSchema = implementsInterface()(px.object({
3025
+ offset: PxAnimatableNumberSchema.optional(),
3026
+ range: PxAnimatableVec2Schema.optional(),
3027
+ subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
3028
+ }));
3029
+ var PxRetimeEffectSchema = implementsInterface()(px.object({
3030
+ sourceId: px.string().optional(),
3031
+ start: px.number().optional(),
3032
+ stretch: px.number().optional(),
3033
+ timeCrop: px.tuple([px.number(), px.number()]).optional()
3034
+ }));
3035
+ var PxCloneEffectSchema = implementsInterface()(px.object({
3036
+ // Contextual kind — the `type` convention, see `PxNodeBase.type`.
3037
+ type: px.enum([PxCloneType.content]).optional(),
3038
+ sourceId: px.string().optional(),
3039
+ retime: PxRetimeEffectSchema.optional()
3040
+ }));
3041
+ var PxGradientStopSchema = implementsInterface()(px.object({
3042
+ offset: px.number(),
3043
+ color: px.string()
3044
+ }));
3045
+ var PxAnimatableGradientStopsSchema = px.union([
3046
+ px.array(PxGradientStopSchema),
3047
+ px.object({ value: px.array(PxGradientStopSchema) }),
3048
+ PxPropertyAnimationSchema
3049
+ ]);
3050
+ var PxFillGradientEffectSchema = implementsInterface()(px.object({
3051
+ // Contextual kind — the `type` convention, see `PxNodeBase.type`.
3052
+ type: px.enum([PxGradientType.linear, PxGradientType.radial]),
3053
+ p1: PxAnimatableVec2Schema.optional(),
3054
+ p2: PxAnimatableVec2Schema.optional(),
3055
+ c: PxAnimatableVec2Schema.optional(),
3056
+ r: PxAnimatableNumberSchema.optional(),
3057
+ fp: PxAnimatableVec2Schema.optional(),
3058
+ stops: PxAnimatableGradientStopsSchema.optional(),
3059
+ gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
3060
+ spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
3061
+ gradientTransform: px.string().optional()
3062
+ }));
3063
+ var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
3064
+ var PxTextPathEffectSchema = implementsInterface()(px.object({
3065
+ path: px.string(),
3066
+ pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
3067
+ lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
3068
+ method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
3069
+ spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
3070
+ startOffset: PxAnimatableNumberSchema.optional(),
3071
+ textLength: PxAnimatableNumberSchema.optional()
3072
+ }));
3073
+ var PxTextEffectSchema = implementsInterface()(px.object({
3074
+ useGlyphs: px.boolean().optional()
3075
+ }));
3076
+ var PxEffectsSchema = implementsInterface()(px.object({
3077
+ transformBy: PxTransformByEffectSchema.optional(),
3078
+ repeater: PxRepeaterEffectSchema.optional(),
3079
+ maskedBy: PxMaskedByEffectSchema.optional(),
3080
+ clipPath: PxClipPathEffectSchema.optional(),
3081
+ trimPath: PxTrimPathEffectSchema.optional(),
3082
+ clone: PxCloneEffectSchema.optional(),
3083
+ fillGradient: PxFillGradientEffectSchema.optional(),
3084
+ strokeGradient: PxStrokeGradientEffectSchema.optional(),
3085
+ textPath: PxTextPathEffectSchema.optional(),
3086
+ text: PxTextEffectSchema.optional()
3087
+ }));
3088
+ function validateNodeEffects(root, opts) {
3089
+ const warnings = [];
3090
+ const walk = (node, path) => {
3091
+ if (node && node.effects) {
3092
+ const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
3093
+ const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
3094
+ if (!ok) {
3095
+ for (const err of ctx.errors) warnings.push(err);
3096
+ }
3097
+ }
3098
+ if (node && Array.isArray(node.children)) {
3099
+ node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
3100
+ }
3101
+ };
3102
+ walk(root, "root");
3103
+ return warnings;
3075
3104
  }
3105
+ var PxNodeBase = px.openObject({
3106
+ // CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
3107
+ // kind of thing is this", discriminated by its CARRIER — here the node TAG
3108
+ // (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
3109
+ // `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
3110
+ // the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
3111
+ // would add words that all mean "type" and still need the carrier to read.
3112
+ // Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
3113
+ // (issues V3), never of distinct key names.
3114
+ type: px.string(),
3115
+ id: px.string().optional(),
3116
+ meta: px.any().optional(),
3117
+ // Player-effects bucket emitted by the Editor's lightweight design format.
3118
+ // Consumed and removed by `applyPlayerEffects` before any other normalisation
3119
+ // (see `createAnimatorImpl`), so downstream code never sees it.
3120
+ effects: PxEffectsSchema.optional(),
3121
+ // `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
3122
+ // string ref / array of refs / inline definition / mixed array; mirrors
3123
+ // `animator.animateById` map values and what `processNode` resolves at runtime.
3124
+ animate: PxElementAnimationSchema.optional(),
3125
+ style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
3126
+ }, PxAttrValueSchema);
3127
+ var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
3128
+ children: px.lazy(() => px.array(PxNodeSchema), []).optional()
3129
+ }), PxAttrValueSchema);
3130
+ var PxSvgNodeExtra = px.object({
3131
+ // `"100%"` and other SVG length strings are legal here — a number-only slot rejected
3132
+ // real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
3133
+ width: px.union([px.number(), px.string()]).optional(),
3134
+ height: px.union([px.number(), px.string()]).optional(),
3135
+ viewBox: px.string().optional(),
3136
+ animator: PxAnimatorConfigSchema.optional()
3137
+ });
3138
+ var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
3139
+ type: px.literal("svg"),
3140
+ // override string → literal to require 'svg'
3141
+ children: px.array(PxNodeSchema).optional()
3142
+ }), PxAttrValueSchema);
3143
+ var PxBezierPathSchema = implementsInterface()(px.object({
3144
+ v: px.array(px.array(px.number())),
3145
+ i: px.array(px.array(px.number())).optional(),
3146
+ o: px.array(px.array(px.number())).optional(),
3147
+ c: px.boolean().optional()
3148
+ }));
3076
3149
  var _idCounter = 0;
3077
3150
  function generateUniqueId() {
3078
3151
  const timestamp = Date.now().toString(36);
@@ -3673,7 +3746,7 @@ var PixodeskAnimatorReact = (() => {
3673
3746
  if (newAnimate) cloned.animate = newAnimate;
3674
3747
  return cloned;
3675
3748
  }
3676
- var LOOP_JUMP_SHIFT_MS = 10;
3749
+ var LOOP_JUMP_SHIFT_MS = 1;
3677
3750
  function deepEqualValue(a, b) {
3678
3751
  if (a === b) return true;
3679
3752
  if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
@@ -3922,6 +3995,8 @@ var PixodeskAnimatorReact = (() => {
3922
3995
  const looped = [];
3923
3996
  const separateBoundary = loop.extend !== PxLoopExtend.before;
3924
3997
  const originalTerminalKf = keyframes[keyframes.length - 1];
3998
+ let terminalEasingOverride;
3999
+ let hasTerminalEasingOverride = false;
3925
4000
  function appendRep(repStart, isReversed, partial) {
3926
4001
  var _a2;
3927
4002
  let entries;
@@ -3962,7 +4037,16 @@ var PixodeskAnimatorReact = (() => {
3962
4037
  const prevKf = looped.length > 0 ? looped[looped.length - 1] : originalTerminalKf;
3963
4038
  const isBoundary = separateBoundary && i === 0 && prevKf !== void 0 && Math.abs(((_a2 = prevKf.t) != null ? _a2 : 0) - (repStart + entry.relT * segDuration)) < 1e-9;
3964
4039
  if (isBoundary) {
3965
- if (deepEqualValue(prevKf.v, entry.v)) continue;
4040
+ if (deepEqualValue(prevKf.v, entry.v)) {
4041
+ if (looped.length > 0) {
4042
+ prevKf.e = entry.e;
4043
+ prevKf.tangentOut = entry.tangentOut;
4044
+ } else {
4045
+ terminalEasingOverride = entry.e;
4046
+ hasTerminalEasingOverride = true;
4047
+ }
4048
+ continue;
4049
+ }
3966
4050
  if (looped.length > 0) {
3967
4051
  delete prevKf.tangentIn;
3968
4052
  delete prevKf.tangentOut;
@@ -4043,6 +4127,11 @@ var PixodeskAnimatorReact = (() => {
4043
4127
  if (loop.extend === PxLoopExtend.before) {
4044
4128
  return [...looped, ...keyframes];
4045
4129
  } else {
4130
+ if (hasTerminalEasingOverride && keyframes.length > 0) {
4131
+ const head = keyframes.slice(0, -1);
4132
+ const tail = __spreadProps2(__spreadValues2({}, keyframes[keyframes.length - 1]), { e: terminalEasingOverride });
4133
+ return [...head, tail, ...looped];
4134
+ }
4046
4135
  return [...keyframes, ...looped];
4047
4136
  }
4048
4137
  }
@@ -4159,6 +4248,9 @@ var PixodeskAnimatorReact = (() => {
4159
4248
  function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimatorEngine.waapi) {
4160
4249
  const normalized = {};
4161
4250
  for (const [propName, propAnim] of Object.entries(animDef)) {
4251
+ if (propName === "transform" && propAnim.alongPathMode === "offsetPath" && animDef["offsetDistance"] !== void 0) {
4252
+ continue;
4253
+ }
4162
4254
  const normalizedKfs = normalizeKeyframes(propName, propAnim, duration, defs);
4163
4255
  if (normalizedKfs.length > 0) {
4164
4256
  const out = { kfs: normalizedKfs };
@@ -6838,9 +6930,138 @@ var PixodeskAnimatorReact = (() => {
6838
6930
  applyAllRetimeEffects(node, ctx);
6839
6931
  return node;
6840
6932
  }
6933
+ var kfTime = (kf) => {
6934
+ var _a, _b;
6935
+ return (_b = (_a = kf.t) != null ? _a : kf.time) != null ? _b : 0;
6936
+ };
6937
+ var kfValue = (kf) => {
6938
+ var _a;
6939
+ return (_a = kf.v) != null ? _a : kf.value;
6940
+ };
6941
+ var kfEasing = (kf) => {
6942
+ var _a;
6943
+ return (_a = kf.e) != null ? _a : kf.easing;
6944
+ };
6945
+ var kfTangentIn = (kf) => {
6946
+ var _a;
6947
+ return (_a = kf.tangentIn) != null ? _a : kf.ti;
6948
+ };
6949
+ var kfTangentOut = (kf) => {
6950
+ var _a;
6951
+ return (_a = kf.tangentOut) != null ? _a : kf.to;
6952
+ };
6953
+ function cubicAt(p0, c1, c2, p1, t) {
6954
+ const u = 1 - t;
6955
+ const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
6956
+ return [
6957
+ a * p0[0] + b * c1[0] + c * c2[0] + d * p1[0],
6958
+ a * p0[1] + b * c1[1] + c * c2[1] + d * p1[1]
6959
+ ];
6960
+ }
6961
+ function cubicLength(p0, c1, c2, p1, steps = 64) {
6962
+ let len = 0;
6963
+ let prev = p0;
6964
+ for (let i = 1; i <= steps; i++) {
6965
+ const pt = cubicAt(p0, c1, c2, p1, i / steps);
6966
+ len += Math.hypot(pt[0] - prev[0], pt[1] - prev[1]);
6967
+ prev = pt;
6968
+ }
6969
+ return len;
6970
+ }
6971
+ var fmt2 = (n) => {
6972
+ const r = Math.round(n * 1e4) / 1e4;
6973
+ return Object.is(r, -0) ? "0" : String(r);
6974
+ };
6975
+ function buildOffsetPath(propAnim) {
6976
+ var _a, _b, _c, _d;
6977
+ if (propAnim.alongPathMode !== "offsetPath") return void 0;
6978
+ const kfs = (_a = propAnim.keyframes) != null ? _a : propAnim.kfs;
6979
+ if (!kfs || kfs.length < 2) return void 0;
6980
+ const first = kfValue(kfs[0]);
6981
+ const anchor = (first == null ? void 0 : first.origin) && first.origin.length >= 2 ? [first.origin[0], first.origin[1]] : [0, 0];
6982
+ const points = [];
6983
+ for (const kf of kfs) {
6984
+ const v = kfValue(kf);
6985
+ const tr = v == null ? void 0 : v.translate;
6986
+ if (!tr || tr.length < 2) return void 0;
6987
+ const parts = Object.keys(v);
6988
+ if (parts.some((p) => p !== "translate" && p !== "origin")) return void 0;
6989
+ const o = (_b = v == null ? void 0 : v.origin) != null ? _b : [0, 0];
6990
+ if (o[0] !== anchor[0] || o[1] !== anchor[1]) return void 0;
6991
+ points.push([tr[0] + anchor[0], tr[1] + anchor[1]]);
6992
+ }
6993
+ if (!kfs.some((kf) => kfTangentIn(kf) || kfTangentOut(kf))) return void 0;
6994
+ let d = "M" + fmt2(points[0][0]) + "," + fmt2(points[0][1]);
6995
+ const segLens = [];
6996
+ for (let i = 0; i < points.length - 1; i++) {
6997
+ const p0 = points[i], p1 = points[i + 1];
6998
+ const to = (_c = kfTangentOut(kfs[i])) != null ? _c : [0, 0];
6999
+ const ti = (_d = kfTangentIn(kfs[i + 1])) != null ? _d : [0, 0];
7000
+ const c1 = [p0[0] + to[0], p0[1] + to[1]];
7001
+ const c2 = [p1[0] + ti[0], p1[1] + ti[1]];
7002
+ d += "C" + fmt2(c1[0]) + "," + fmt2(c1[1]) + "," + fmt2(c2[0]) + "," + fmt2(c2[1]) + "," + fmt2(p1[0]) + "," + fmt2(p1[1]);
7003
+ segLens.push(cubicLength(p0, c1, c2, p1));
7004
+ }
7005
+ const total = segLens.reduce((a, b) => a + b, 0);
7006
+ if (!(total > 0)) return void 0;
7007
+ const distanceKfs = [];
7008
+ let cum = 0;
7009
+ for (let i = 0; i < kfs.length; i++) {
7010
+ if (i > 0) cum += segLens[i - 1];
7011
+ const out = { t: kfTime(kfs[i]), v: cum / total };
7012
+ const e = kfEasing(kfs[i]);
7013
+ if (e !== void 0) out.e = e;
7014
+ distanceKfs.push(out);
7015
+ }
7016
+ return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor };
7017
+ }
7018
+ function materialiseOffsetPathsInTree(root) {
7019
+ const walk = (node) => {
7020
+ var _a;
7021
+ let out = node;
7022
+ const anim = node.animate;
7023
+ const transform = anim == null ? void 0 : anim["transform"];
7024
+ if (transform) {
7025
+ const built = buildOffsetPath(transform);
7026
+ if (built) {
7027
+ const newAnimate = __spreadValues2({}, anim);
7028
+ delete newAnimate["transform"];
7029
+ const distance = { keyframes: built.distanceKfs };
7030
+ if (transform.loop !== void 0) distance.loop = transform.loop;
7031
+ newAnimate["offsetDistance"] = distance;
7032
+ const staticTr = node.transform;
7033
+ let newTransform = staticTr;
7034
+ if (staticTr && typeof staticTr === "object") {
7035
+ const t = __spreadValues2({}, staticTr);
7036
+ delete t["translate"];
7037
+ delete t["origin"];
7038
+ newTransform = Object.keys(t).length ? t : void 0;
7039
+ }
7040
+ out = __spreadProps2(__spreadValues2({}, node), {
7041
+ animate: newAnimate,
7042
+ style: __spreadProps2(__spreadValues2({}, node.style), {
7043
+ offsetPath: "path('" + built.pathStr + "')",
7044
+ offsetAnchor: fmt2(built.anchor[0]) + "px " + fmt2(built.anchor[1]) + "px",
7045
+ offsetRotate: built.autoOrient ? "auto" : "0deg",
7046
+ offsetDistance: "0%"
7047
+ })
7048
+ });
7049
+ if (newTransform !== void 0) out.transform = newTransform;
7050
+ else delete out.transform;
7051
+ }
7052
+ }
7053
+ if ((_a = out.children) == null ? void 0 : _a.length) {
7054
+ const children = out.children.map(walk);
7055
+ if (children.some((c, i) => c !== out.children[i])) out = __spreadProps2(__spreadValues2({}, out), { children });
7056
+ }
7057
+ return out;
7058
+ };
7059
+ return walk(root);
7060
+ }
6841
7061
  function materialiseAllInTree(doc, engine, opts) {
6842
7062
  var _a, _b;
6843
7063
  let root = applyPlayerEffects(doc).root;
7064
+ root = materialiseOffsetPathsInTree(root);
6844
7065
  const duration = (_b = (_a = getAnimatorConfig(root)) == null ? void 0 : _a.duration) != null ? _b : DEFAULT_DURATION_MS;
6845
7066
  root = materialiseInternalLoopsInTree(root, duration);
6846
7067
  if (engine === PxAnimatorEngine.waapi) {
@@ -7280,7 +7501,13 @@ var PixodeskAnimatorReact = (() => {
7280
7501
  const api = __spreadProps(__spreadValues({}, basicApi), {
7281
7502
  "getRootElement": () => rootElement || null
7282
7503
  });
7283
- if (config.trigger) setupAnimationTriggers(api, config.trigger);
7504
+ if (config.trigger) {
7505
+ if (isScrollTimeline(config)) {
7506
+ console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
7507
+ } else {
7508
+ setupAnimationTriggers(api, config.trigger);
7509
+ }
7510
+ }
7284
7511
  return api;
7285
7512
  }
7286
7513
  function createDomAdapter(rootElement) {
@@ -7336,6 +7563,8 @@ var PixodeskAnimatorReact = (() => {
7336
7563
  } else if (propName === "d") {
7337
7564
  const paths = value && typeof value === "object" && Array.isArray(value.paths) ? value.paths : [];
7338
7565
  cssValue = 'path("' + paths.map((bz) => bezierToSvgPath(bz, true)).join("") + '")';
7566
+ } else if (PCT_BASED_ATTR_NAMES.has(propName) && typeof value === "number") {
7567
+ cssValue = value * 100 + "%";
7339
7568
  } else {
7340
7569
  cssValue = "" + value;
7341
7570
  }
@@ -7404,7 +7633,7 @@ var PixodeskAnimatorReact = (() => {
7404
7633
  }
7405
7634
  return result;
7406
7635
  }
7407
- function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs) {
7636
+ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
7408
7637
  var _a;
7409
7638
  const config = getAnimatorConfig(doc) || {};
7410
7639
  if (!rootElement) {
@@ -7463,7 +7692,12 @@ var PixodeskAnimatorReact = (() => {
7463
7692
  if (keyframes.length > 0) {
7464
7693
  try {
7465
7694
  const effect = new KeyframeEffect(element, keyframes, effectOptions);
7466
- const anim = new Animation(effect, document.timeline);
7695
+ const anim = new Animation(effect, scrollTimeline ? scrollTimeline.timeline : document.timeline);
7696
+ if (scrollTimeline) {
7697
+ const a = anim;
7698
+ if (scrollTimeline.rangeStart) a.rangeStart = scrollTimeline.rangeStart;
7699
+ if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
7700
+ }
7467
7701
  if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
7468
7702
  var _a2;
7469
7703
  if (finishNotified) return;
@@ -7557,10 +7791,133 @@ var PixodeskAnimatorReact = (() => {
7557
7791
  }
7558
7792
  };
7559
7793
  if (config.trigger) {
7560
- setupAnimationTriggers(api, config.trigger);
7794
+ if (config.timelineSource === "scroll") {
7795
+ console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
7796
+ } else {
7797
+ setupAnimationTriggers(api, config.trigger);
7798
+ }
7799
+ }
7800
+ if (scrollTimeline) {
7801
+ animations.forEach((a) => a.play());
7561
7802
  }
7562
7803
  return api;
7563
7804
  }
7805
+ function nativeRangeOffset(point, defaultFraction, view) {
7806
+ var _a, _b, _c;
7807
+ const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
7808
+ const pct = (_b = (_a = globalThis.CSS) == null ? void 0 : _a.percent) == null ? void 0 : _b.call(_a, fraction * 100);
7809
+ if (pct === void 0) return void 0;
7810
+ return view ? { rangeName: (_c = point == null ? void 0 : point.phase) != null ? _c : "cover", offset: pct } : { offset: pct };
7811
+ }
7812
+ function createNativeScrollTimeline(subject, config) {
7813
+ var _a, _b, _c, _d;
7814
+ if (!config || !isScrollTimeline(config)) return null;
7815
+ const scroll = config.scroll || {};
7816
+ const kind = (_a = scroll.kind) != null ? _a : "view";
7817
+ const g = globalThis;
7818
+ const view = kind === "view";
7819
+ const Ctor = view ? g.ViewTimeline : g.ScrollTimeline;
7820
+ if (typeof Ctor !== "function") return null;
7821
+ const axis = (_b = scroll.axis) != null ? _b : "block";
7822
+ let timeline;
7823
+ try {
7824
+ if (view) {
7825
+ timeline = new Ctor({ subject, axis });
7826
+ } else {
7827
+ const source = scroll.source === "root" ? documentScroller() : findNearestScroller(subject, "y") || findNearestScroller(subject, "x") || documentScroller();
7828
+ timeline = new Ctor({ source, axis });
7829
+ }
7830
+ } catch (e) {
7831
+ console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the custom driver", e);
7832
+ return null;
7833
+ }
7834
+ return {
7835
+ timeline,
7836
+ rangeStart: nativeRangeOffset((_c = scroll.range) == null ? void 0 : _c.start, 0, view),
7837
+ rangeEnd: nativeRangeOffset((_d = scroll.range) == null ? void 0 : _d.end, 1, view)
7838
+ };
7839
+ }
7840
+ function findNearestScroller(el, axis) {
7841
+ for (let p = el.parentElement; p; p = p.parentElement) {
7842
+ const style = getComputedStyle(p);
7843
+ const overflow = axis === "y" ? style.overflowY : style.overflowX;
7844
+ if (overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "overlay") {
7845
+ return p;
7846
+ }
7847
+ }
7848
+ return null;
7849
+ }
7850
+ function documentScroller() {
7851
+ return document.scrollingElement || document.documentElement;
7852
+ }
7853
+ function createScrollDriver(subject, config, onProgress) {
7854
+ var _a;
7855
+ if (!config || !isScrollTimeline(config)) return null;
7856
+ const scroll = config.scroll || {};
7857
+ const kind = (_a = scroll.kind) != null ? _a : "view";
7858
+ const nearest = findNearestScroller(subject, "y") || findNearestScroller(subject, "x");
7859
+ const scroller = kind === "scroll" && scroll.source === "root" ? documentScroller() : nearest || documentScroller();
7860
+ const isRootScroller = scroller === documentScroller();
7861
+ const axis = scrollResolveAxis(scroll.axis, getComputedStyle(scroller).writingMode);
7862
+ const compute = () => {
7863
+ if (kind === "scroll") {
7864
+ const offset = axis === "y" ? scroller.scrollTop : scroller.scrollLeft;
7865
+ const maxOffset = axis === "y" ? scroller.scrollHeight - scroller.clientHeight : scroller.scrollWidth - scroller.clientWidth;
7866
+ return scrollOffsetProgress(offset, maxOffset, scroll.range);
7867
+ }
7868
+ const subjectRect = subject.getBoundingClientRect();
7869
+ let portStart, portSize;
7870
+ if (isRootScroller) {
7871
+ portStart = 0;
7872
+ portSize = axis === "y" ? document.documentElement.clientHeight : document.documentElement.clientWidth;
7873
+ } else {
7874
+ const portRect = scroller.getBoundingClientRect();
7875
+ portStart = axis === "y" ? portRect.top : portRect.left;
7876
+ portSize = axis === "y" ? scroller.clientHeight : scroller.clientWidth;
7877
+ }
7878
+ const subjectStart = (axis === "y" ? subjectRect.top : subjectRect.left) - portStart;
7879
+ const subjectSize = axis === "y" ? subjectRect.height : subjectRect.width;
7880
+ return scrollViewProgress(subjectStart, subjectSize, portSize, scroll.range);
7881
+ };
7882
+ let rafId = null;
7883
+ let destroyed = false;
7884
+ const tick = () => {
7885
+ rafId = null;
7886
+ if (destroyed) return;
7887
+ onProgress(compute());
7888
+ };
7889
+ const schedule = () => {
7890
+ if (destroyed || rafId !== null) return;
7891
+ rafId = requestAnimationFrame(tick);
7892
+ };
7893
+ const scrollTarget = isRootScroller ? window : scroller;
7894
+ scrollTarget.addEventListener("scroll", schedule, { passive: true });
7895
+ window.addEventListener("resize", schedule, { passive: true });
7896
+ let resizeObserver;
7897
+ if (typeof ResizeObserver !== "undefined") {
7898
+ resizeObserver = new ResizeObserver(schedule);
7899
+ resizeObserver.observe(subject);
7900
+ if (!isRootScroller) resizeObserver.observe(scroller);
7901
+ }
7902
+ const driver = {
7903
+ destroy: () => {
7904
+ if (destroyed) return;
7905
+ destroyed = true;
7906
+ scrollTarget.removeEventListener("scroll", schedule);
7907
+ window.removeEventListener("resize", schedule);
7908
+ resizeObserver == null ? void 0 : resizeObserver.disconnect();
7909
+ if (rafId !== null) {
7910
+ cancelAnimationFrame(rafId);
7911
+ rafId = null;
7912
+ }
7913
+ },
7914
+ refresh: () => {
7915
+ if (!destroyed) onProgress(compute());
7916
+ }
7917
+ };
7918
+ driver.refresh();
7919
+ return driver;
7920
+ }
7564
7921
  function finaliseAnimator(animatorConfig, callbacks, make) {
7565
7922
  let apiRef;
7566
7923
  let effectiveCallbacks = callbacks;
@@ -7582,6 +7939,44 @@ var PixodeskAnimatorReact = (() => {
7582
7939
  }
7583
7940
  function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
7584
7941
  const animatorConfig = getAnimatorConfig(doc) || {};
7942
+ if (isScrollTimeline(animatorConfig)) {
7943
+ return finaliseAnimator(animatorConfig, callbacks, (cb) => {
7944
+ var _a, _b;
7945
+ if (animatorConfig.mode !== PxAnimatorMode.frames && ((_a = animatorConfig.scroll) == null ? void 0 : _a.driver) === "native" && rootElement) {
7946
+ const native = createNativeScrollTimeline(rootElement, animatorConfig);
7947
+ if (native) {
7948
+ const api2 = createWebApiAnimator(
7949
+ doc,
7950
+ cb,
7951
+ rootElement,
7952
+ animatorConfig.mode === PxAnimatorMode.waapi,
7953
+ native
7954
+ );
7955
+ if (api2) return api2;
7956
+ }
7957
+ }
7958
+ const api = (animatorConfig.mode !== PxAnimatorMode.frames ? createWebApiAnimator(doc, cb, rootElement, animatorConfig.mode === PxAnimatorMode.waapi) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
7959
+ const subject = ((_b = api.getRootElement) == null ? void 0 : _b.call(api)) || rootElement;
7960
+ if (subject) {
7961
+ const totalMs = scrollTotalDurationMs(animatorConfig);
7962
+ const driver = createScrollDriver(
7963
+ subject,
7964
+ animatorConfig,
7965
+ (progress) => api.setCurrentTime(progress * totalMs)
7966
+ );
7967
+ if (driver) {
7968
+ const destroy = api.destroy.bind(api);
7969
+ api.destroy = () => {
7970
+ driver.destroy();
7971
+ destroy();
7972
+ };
7973
+ }
7974
+ } else {
7975
+ console.warn("scroll timeline: no root element to observe \u2014 animation will stay at frame 0");
7976
+ }
7977
+ return api;
7978
+ });
7979
+ }
7585
7980
  return finaliseAnimator(animatorConfig, callbacks, (cb) => {
7586
7981
  if (animatorConfig.mode === PxAnimatorMode.frames) {
7587
7982
  return createFrameLoopAnimator(doc, adapter, cb, rootElement);