@pixodesk/svg-animator-vue 1.0.47 → 1.0.49

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
@@ -56761,7 +56761,7 @@ ${codeFrame}` : message);
56761
56761
  PixodeskSvgCssAnimator: () => PixodeskSvgCssAnimator_default
56762
56762
  });
56763
56763
 
56764
- // ../svg-animator-web/dist/chunk-ZBGGXE5W.js
56764
+ // ../svg-animator-web/dist/chunk-U5Z7OD2T.js
56765
56765
  var __defProp2 = Object.defineProperty;
56766
56766
  var __defProps = Object.defineProperties;
56767
56767
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -57445,13 +57445,14 @@ ${codeFrame}` : message);
57445
57445
  var PX_TRIGGER_DEFAULTS = {
57446
57446
  start: "load",
57447
57447
  offScreen: "pause",
57448
- mouseOut: "continue",
57448
+ mouseOut: "pause",
57449
57449
  visibilityThreshold: 0.5,
57450
57450
  visibilityDebounce: 150,
57451
57451
  finish: "hold"
57452
57452
  };
57453
57453
  var PX_DEFAULT_DURATION_MS = 1e3;
57454
57454
  var PX_DEFAULT_ITERATIONS = 1;
57455
+ var PX_DEFAULT_UNITS_PER_EM = 1e3;
57455
57456
  function resolveTrigger(trigger) {
57456
57457
  var _a22, _b, _c, _d, _e;
57457
57458
  return {
@@ -57714,7 +57715,7 @@ ${codeFrame}` : message);
57714
57715
  fontFamily: px.string(),
57715
57716
  fontStyle: px.string(),
57716
57717
  ascent: px.number(),
57717
- unitsPerEm: px.number(),
57718
+ unitsPerEm: px.number(PX_DEFAULT_UNITS_PER_EM).optional(),
57718
57719
  glyphs: px.record(PxGlyphSchema)
57719
57720
  }));
57720
57721
  var PxDefinitionsSchema = implementsInterface()(px.object({
@@ -57914,7 +57915,7 @@ ${codeFrame}` : message);
57914
57915
  }));
57915
57916
  var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
57916
57917
  var PxTextPathEffectSchema = implementsInterface()(px.object({
57917
- pathData: px.string(),
57918
+ pathData: PxAnimatableStringSchema,
57918
57919
  // `extend` is what an omitted pathOverflow means (glyphs continue along the tangent); the
57919
57920
  // other three are SVG's own initial values for the native <textPath> attributes.
57920
57921
  pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend], PxPathOverflow.extend).optional(),
@@ -59961,11 +59962,11 @@ ${codeFrame}` : message);
59961
59962
  const totalLength = cum[segs.length];
59962
59963
  const start = segs[0].P0, end = segs[segs.length - 1].P3;
59963
59964
  const closed = Math.hypot(end[0] - start[0], end[1] - start[1]) < 1e-3;
59964
- const sampleOn = (dist) => {
59965
+ const sampleOn = (dist22) => {
59965
59966
  let k = 0;
59966
- while (k < segs.length - 1 && dist > cum[k + 1]) k++;
59967
+ while (k < segs.length - 1 && dist22 > cum[k + 1]) k++;
59967
59968
  const seg = segs[k];
59968
- const local = dist - cum[k];
59969
+ const local = dist22 - cum[k];
59969
59970
  const t = seg.len > 0 ? bezier2D_tForDistance(seg.lut, local) : 0;
59970
59971
  const [x, y] = bezier2D_pointAt(seg.P0, seg.P1, seg.P2, seg.P3, t);
59971
59972
  const [dx, dy] = bezier2D_derivativeAt(seg.P0, seg.P1, seg.P2, seg.P3, t);
@@ -59974,17 +59975,17 @@ ${codeFrame}` : message);
59974
59975
  return {
59975
59976
  totalLength,
59976
59977
  closed,
59977
- sampleAtDistance(dist) {
59978
- if (closed && totalLength > 0 && (dist < 0 || dist > totalLength)) {
59979
- return sampleOn((dist % totalLength + totalLength) % totalLength);
59978
+ sampleAtDistance(dist22) {
59979
+ if (closed && totalLength > 0 && (dist22 < 0 || dist22 > totalLength)) {
59980
+ return sampleOn((dist22 % totalLength + totalLength) % totalLength);
59980
59981
  }
59981
- if (!closed && (dist < 0 || dist > totalLength)) {
59982
- const edge = dist < 0 ? 0 : totalLength;
59982
+ if (!closed && (dist22 < 0 || dist22 > totalLength)) {
59983
+ const edge = dist22 < 0 ? 0 : totalLength;
59983
59984
  const p = sampleOn(edge);
59984
- const over = dist - edge;
59985
+ const over = dist22 - edge;
59985
59986
  return { x: p.x + Math.cos(p.angle) * over, y: p.y + Math.sin(p.angle) * over, angle: p.angle };
59986
59987
  }
59987
- return sampleOn(clamp2(dist, 0, totalLength));
59988
+ return sampleOn(clamp2(dist22, 0, totalLength));
59988
59989
  }
59989
59990
  };
59990
59991
  }
@@ -60066,6 +60067,72 @@ ${codeFrame}` : message);
60066
60067
  if (kf.tangentIn !== void 0) out.tangentIn = kf.tangentIn;
60067
60068
  return out;
60068
60069
  }
60070
+ function pathString(v) {
60071
+ if (typeof v === "string") return v;
60072
+ if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
60073
+ return void 0;
60074
+ }
60075
+ function pathTrackOf(raw) {
60076
+ var _a22, _b;
60077
+ const r = readAnimatable(raw);
60078
+ if (r.kind === "absent") return void 0;
60079
+ if (r.kind === "static" || r.keyframes.length < 2) {
60080
+ const d = pathString(r.kind === "static" ? r.value : (_a22 = r.keyframes[0]) == null ? void 0 : _a22.value);
60081
+ if (!d) return void 0;
60082
+ return {
60083
+ animated: false,
60084
+ times: [],
60085
+ dAt: () => d,
60086
+ maxLength: (lengthOf) => lengthOf(d),
60087
+ moveBetween: () => 0
60088
+ };
60089
+ }
60090
+ const kfs = [...r.keyframes].map((kf) => ({ time: Number(kf.time) || 0, d: pathString(kf.value) })).filter((kf) => !!kf.d).sort((a, b) => a.time - b.time);
60091
+ if (kfs.length < 2) return pathTrackOf((_b = kfs[0]) == null ? void 0 : _b.d);
60092
+ const times = kfs.map((kf) => kf.time);
60093
+ const beziers = kfs.map((kf) => parseSvgPathToBezier(kf.d));
60094
+ const at = (t) => {
60095
+ if (t <= times[0]) return beziers[0];
60096
+ for (let i = 1; i < times.length; i++) {
60097
+ if (t <= times[i]) {
60098
+ const span = times[i] - times[i - 1];
60099
+ const f = span > 0 ? (t - times[i - 1]) / span : 1;
60100
+ return interpolateBeziers(beziers[i - 1], beziers[i], f);
60101
+ }
60102
+ }
60103
+ return beziers[beziers.length - 1];
60104
+ };
60105
+ return {
60106
+ animated: true,
60107
+ times,
60108
+ loop: r.loop,
60109
+ dAt: (t) => at(t).map((bz) => bezierToSvgPath(bz)).join(""),
60110
+ maxLength: (lengthOf) => Math.max(...kfs.map((kf) => lengthOf(kf.d))),
60111
+ moveBetween: (t0, t1) => maxPointMove(at(t0), at(t1))
60112
+ };
60113
+ }
60114
+ function maxPointMove(a, b) {
60115
+ var _a22, _b, _c, _d, _e, _f, _g, _h;
60116
+ let max = 0;
60117
+ const n = Math.min(a.length, b.length);
60118
+ for (let p = 0; p < n; p++) {
60119
+ const pa = a[p], pb = b[p];
60120
+ const count = Math.min(pa.v.length, pb.v.length);
60121
+ for (let k = 0; k < count; k++) {
60122
+ max = Math.max(
60123
+ max,
60124
+ dist(pa.v[k], pb.v[k]),
60125
+ dist((_b = (_a22 = pa.i) == null ? void 0 : _a22[k]) != null ? _b : pa.v[k], (_d = (_c = pb.i) == null ? void 0 : _c[k]) != null ? _d : pb.v[k]),
60126
+ dist((_f = (_e = pa.o) == null ? void 0 : _e[k]) != null ? _f : pa.v[k], (_h = (_g = pb.o) == null ? void 0 : _g[k]) != null ? _h : pb.v[k])
60127
+ );
60128
+ }
60129
+ }
60130
+ return max;
60131
+ }
60132
+ function dist(p, q) {
60133
+ var _a22, _b, _c, _d;
60134
+ return Math.hypot(((_a22 = q[0]) != null ? _a22 : 0) - ((_b = p[0]) != null ? _b : 0), ((_c = q[1]) != null ? _c : 0) - ((_d = p[1]) != null ? _d : 0));
60135
+ }
60069
60136
  function deepClonePxNode(value) {
60070
60137
  if (value === null || typeof value !== "object") return value;
60071
60138
  if (Array.isArray(value)) return value.map(deepClonePxNode);
@@ -60187,7 +60254,7 @@ ${codeFrame}` : message);
60187
60254
  }
60188
60255
  function extendedPathForBrowser(pathD, opts) {
60189
60256
  var _a22;
60190
- if (opts.pathOverflow === "clip") return { d: pathD, startShift: 0 };
60257
+ if (opts.pathOverflow === PxPathOverflow.clip) return { d: pathD, startShift: 0 };
60191
60258
  const sampler = createPathSampler(pathD);
60192
60259
  if (!sampler || sampler.closed || sampler.totalLength <= 0) return { d: pathD, startShift: 0 };
60193
60260
  const L = sampler.totalLength;
@@ -60214,20 +60281,30 @@ ${codeFrame}` : message);
60214
60281
  return { d, startShift: startExt };
60215
60282
  }
60216
60283
  function applyTextPathEffect(node, fx, ctx) {
60217
- var _a22;
60218
- if (!fx || typeof fx.pathData !== "string" || !fx.pathData) return node;
60284
+ var _a22, _b, _c, _d;
60285
+ if (!fx) return node;
60286
+ const read = readAnimatable(fx.pathData);
60287
+ if (read.kind === "absent") return node;
60288
+ const isAnimated = read.kind === "animated";
60289
+ const baseD = pathString(isAnimated ? (_b = read.base) != null ? _b : (_a22 = read.keyframes[0]) == null ? void 0 : _a22.value : read.value);
60290
+ if (!baseD) return node;
60219
60291
  const pathId = genId(ctx, "tpath");
60220
- const { d, startShift } = extendedPathForBrowser(fx.pathData, {
60221
- pathOverflow: fx.pathOverflow,
60292
+ const { d, startShift } = extendedPathForBrowser(baseD, {
60293
+ pathOverflow: isAnimated ? PxPathOverflow.clip : fx.pathOverflow,
60222
60294
  startOffset: fx.startOffset,
60223
60295
  textLength: fx.textLength,
60224
60296
  advance: estimateTextAdvance(node)
60225
60297
  });
60226
- ctx.defs.push({ type: "path", id: pathId, d });
60298
+ const pathDef = { type: "path", id: pathId, d };
60299
+ if (isAnimated) {
60300
+ writeAnimatableChannel(pathDef, "d", read);
60301
+ pathDef.d = (_c = pathString(pathDef.d)) != null ? _c : d;
60302
+ }
60303
+ ctx.defs.push(pathDef);
60227
60304
  const textPath = {
60228
60305
  type: "textPath",
60229
60306
  href: "#" + pathId,
60230
- children: (_a22 = node.children) != null ? _a22 : []
60307
+ children: (_d = node.children) != null ? _d : []
60231
60308
  };
60232
60309
  if (fx.lengthAdjust !== void 0) textPath.lengthAdjust = fx.lengthAdjust;
60233
60310
  if (fx.method !== void 0) textPath.method = fx.method;
@@ -60404,6 +60481,9 @@ ${codeFrame}` : message);
60404
60481
  if (!gf) warnings == null ? void 0 : warnings.push('textGlyphs: no glyphs for font "' + ((_a22 = s.fontFamily) != null ? _a22 : "") + '"');
60405
60482
  return gf;
60406
60483
  }
60484
+ function unitsPerEmOf(gf) {
60485
+ return (gf == null ? void 0 : gf.unitsPerEm) || PX_DEFAULT_UNITS_PER_EM;
60486
+ }
60407
60487
  function soleFontOf(glyphs) {
60408
60488
  const names = Object.keys(glyphs);
60409
60489
  return names.length === 1 ? glyphs[names[0]] : void 0;
@@ -60433,7 +60513,7 @@ ${codeFrame}` : message);
60433
60513
  const renderChars = (content, s) => {
60434
60514
  var _a3;
60435
60515
  const gf = glyphFontFor(s, glyphs, soleFont, warnings);
60436
- const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
60516
+ const upm = unitsPerEmOf(gf);
60437
60517
  const scale = s.fontSize / upm;
60438
60518
  const ascentEm = (_a3 = gf == null ? void 0 : gf.ascent) != null ? _a3 : 0.9 * upm;
60439
60519
  const paint = paintOf(s);
@@ -60495,8 +60575,9 @@ ${codeFrame}` : message);
60495
60575
  if (content && !((_a22 = el.children) == null ? void 0 : _a22.length)) {
60496
60576
  const gf = glyphFontFor(s, glyphs, soleFont, warnings);
60497
60577
  if (gf) {
60498
- const scale = s.fontSize / gf.unitsPerEm;
60499
- const ascentEm = (_b = gf.ascent) != null ? _b : 0.9 * gf.unitsPerEm;
60578
+ const upm = unitsPerEmOf(gf);
60579
+ const scale = s.fontSize / upm;
60580
+ const ascentEm = (_b = gf.ascent) != null ? _b : 0.9 * upm;
60500
60581
  const paint = paintOf(s);
60501
60582
  for (let i = 0; i < content.length; i++) {
60502
60583
  const ch = content.charAt(i);
@@ -60506,7 +60587,7 @@ ${codeFrame}` : message);
60506
60587
  cells.push({ glyphD: g.pathData, widthEm: g.width, scale, paint, midBase: adv + glyphAdv / 2 });
60507
60588
  adv += glyphAdv;
60508
60589
  } else if (/\S/.test(ch)) {
60509
- const wEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM * gf.unitsPerEm;
60590
+ const wEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM * upm;
60510
60591
  const boxAdv = wEm * scale;
60511
60592
  cells.push({ glyphD: missingGlyphBoxEm(wEm, ascentEm), widthEm: wEm, scale, paint, isMissing: true, midBase: adv + boxAdv / 2 });
60512
60593
  adv += boxAdv;
@@ -60522,8 +60603,8 @@ ${codeFrame}` : message);
60522
60603
  walk(node, rootStyleOf(node));
60523
60604
  return { cells, width: adv };
60524
60605
  }
60525
- function alongAffine(sampler, dist, scale, widthEm, perp = 0) {
60526
- const { x, y, angle } = sampler.sampleAtDistance(dist);
60606
+ function alongAffine(sampler, dist22, scale, widthEm, perp = 0) {
60607
+ const { x, y, angle } = sampler.sampleAtDistance(dist22);
60527
60608
  const cos = Math.cos(angle), sin = Math.sin(angle), hw = widthEm / 2;
60528
60609
  return [scale * cos, scale * sin, -scale * sin, scale * cos, x - scale * cos * hw - perp * sin, y - scale * sin * hw + perp * cos];
60529
60610
  }
@@ -60535,9 +60616,12 @@ ${codeFrame}` : message);
60535
60616
  };
60536
60617
  }
60537
60618
  function materializeGlyphTextAlongPath(node, pathD, startOffset, opts, textLength, pathOverflow) {
60619
+ var _a22;
60538
60620
  const { glyphs, create = jsonElementFactory, warnings } = opts;
60539
- const sampler = pathD ? createPathSampler(pathD) : null;
60540
- if (!sampler) {
60621
+ const pathTrack = pathTrackOf(pathD);
60622
+ const samplerAt = pathTrack ? pathSamplers(pathTrack) : null;
60623
+ const sampler = (_a22 = samplerAt == null ? void 0 : samplerAt(0)) != null ? _a22 : null;
60624
+ if (!pathTrack || !samplerAt || !sampler) {
60541
60625
  warnings == null ? void 0 : warnings.push("textGlyphs: unparsable along-path geometry");
60542
60626
  return null;
60543
60627
  }
@@ -60549,11 +60633,11 @@ ${codeFrame}` : message);
60549
60633
  const tlTrack = numTrackOf(textLength);
60550
60634
  const kOf = (tl) => tl > 0 && width > 0 ? tl / width : 1;
60551
60635
  const isClip = pathOverflow === "clip" && !sampler.closed;
60552
- if (soTrack.animated || tlTrack.animated) {
60553
- const times = mergeTrackTimes(soTrack.times, tlTrack.times);
60636
+ if (soTrack.animated || tlTrack.animated || pathTrack.animated) {
60637
+ const times = mergeTrackTimes(mergeTrackTimes(pathTrack.times, soTrack.times), tlTrack.times);
60554
60638
  const distOf = (c, t) => alongOffset + soTrack.at(t) + kOf(tlTrack.at(t)) * c.midBase;
60555
- const loop = soTrack.animated ? soTrack.loop : tlTrack.loop;
60556
- return toGroup(node, buildAnimatedAlongPath(cells, sampler, distOf, times, loop, create, isClip, perp), create);
60639
+ const loop = pathTrack.animated && pathTrack.loop !== void 0 ? pathTrack.loop : soTrack.animated ? soTrack.loop : tlTrack.loop;
60640
+ return toGroup(node, buildAnimatedAlongPath(cells, samplerAt, pathTrack, distOf, times, loop, create, isClip, perp), create);
60557
60641
  }
60558
60642
  const k = kOf(tlTrack.at(0));
60559
60643
  const base = alongOffset + soTrack.at(0);
@@ -60608,15 +60692,39 @@ ${codeFrame}` : message);
60608
60692
  const f = __pow(10, n);
60609
60693
  return Math.round(v * f) / f;
60610
60694
  }
60611
- function buildAnimatedAlongPath(cells, sampler, distOf, times, loop, create, isClip, perp = 0) {
60612
- const step = Math.max(sampler.totalLength / ALONG_PATH_MAX_STEPS, 0.5);
60613
- const onPath = (dist) => dist >= 0 && dist <= sampler.totalLength;
60695
+ function pathSamplers(track) {
60696
+ if (!track.animated) {
60697
+ const one = createPathSampler(track.dAt(0));
60698
+ return () => one;
60699
+ }
60700
+ const byTime = /* @__PURE__ */ new Map();
60701
+ return (t) => {
60702
+ let s = byTime.get(t);
60703
+ if (s === void 0) {
60704
+ s = createPathSampler(track.dAt(t));
60705
+ byTime.set(t, s);
60706
+ }
60707
+ return s;
60708
+ };
60709
+ }
60710
+ function buildAnimatedAlongPath(cells, samplerAt, track, distOf, times, loop, create, isClip, perp = 0) {
60711
+ var _a22;
60712
+ const first = samplerAt((_a22 = times[0]) != null ? _a22 : 0);
60713
+ if (!first) return [];
60714
+ const at = (t) => {
60715
+ var _a3;
60716
+ return (_a3 = samplerAt(t)) != null ? _a3 : first;
60717
+ };
60718
+ const maxLength = track.animated ? Math.max(...track.times.map((t) => at(t).totalLength)) : first.totalLength;
60719
+ const step = Math.max(maxLength / ALONG_PATH_MAX_STEPS, 0.5);
60720
+ const onPath = (dist22, t) => dist22 >= 0 && dist22 <= at(t).totalLength;
60721
+ const moved = times.map((t, k) => k ? track.moveBetween(times[k - 1], t) : 0);
60614
60722
  const out = [];
60615
60723
  for (const c of cells) {
60616
60724
  const centered = [c.scale, 0, 0, c.scale, -c.scale * (c.widthEm / 2), 0];
60617
60725
  const d = transformPathData(c.glyphD, centered);
60618
- const sampleKf = (dist, time) => {
60619
- const { x, y, angle } = sampler.sampleAtDistance(dist);
60726
+ const sampleKf = (dist22, time) => {
60727
+ const { x, y, angle } = at(time).sampleAtDistance(dist22);
60620
60728
  const cos = Math.cos(angle), sin = Math.sin(angle);
60621
60729
  return {
60622
60730
  time,
@@ -60634,15 +60742,15 @@ ${codeFrame}` : message);
60634
60742
  };
60635
60743
  const kfs = [];
60636
60744
  const opKfs = [];
60637
- const pushKf = (dist, time) => {
60638
- kfs.push(sampleKf(dist, time));
60639
- if (isClip) opKfs.push({ time, value: onPath(dist) ? 1 : 0 });
60745
+ const pushKf = (dist22, time) => {
60746
+ kfs.push(sampleKf(dist22, time));
60747
+ if (isClip) opKfs.push({ time, value: onPath(dist22, time) ? 1 : 0 });
60640
60748
  };
60641
60749
  pushKf(distOf(c, times[0]), times[0]);
60642
60750
  for (let k = 1; k < times.length; k++) {
60643
60751
  const t0 = times[k - 1], t1 = times[k];
60644
60752
  const d0 = distOf(c, t0), d1 = distOf(c, t1);
60645
- const n = Math.min(ALONG_PATH_MAX_STEPS_PER_SEGMENT, Math.max(1, Math.ceil(Math.abs(d1 - d0) / step)));
60753
+ const n = Math.min(ALONG_PATH_MAX_STEPS_PER_SEGMENT, Math.max(1, Math.ceil(Math.abs(d1 - d0) / step), Math.ceil(moved[k] / step)));
60646
60754
  for (let s = 1; s <= n; s++) {
60647
60755
  const f = s / n;
60648
60756
  const t = t0 + f * (t1 - t0);
@@ -61195,11 +61303,6 @@ ${codeFrame}` : message);
61195
61303
  node.clipPath = "url(#" + clipId + ")";
61196
61304
  return node;
61197
61305
  }
61198
- function pathString(v) {
61199
- if (typeof v === "string") return v;
61200
- if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
61201
- return void 0;
61202
- }
61203
61306
  function applyMaskedByEffect(node, fx, transformBy, ctx) {
61204
61307
  if (!fx) return node;
61205
61308
  const sourceId = stripHash(fx.source);
@@ -62182,8 +62285,7 @@ ${codeFrame}` : message);
62182
62285
  let consumedByGlyphs = false;
62183
62286
  if (text == null ? void 0 : text.useGlyphs) {
62184
62287
  if (textPath) {
62185
- const pathD = typeof textPath.pathData === "string" ? textPath.pathData : void 0;
62186
- const glyphed = applyTextGlyphsAlongPath(n, ctx, pathD, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
62288
+ const glyphed = applyTextGlyphsAlongPath(n, ctx, textPath.pathData, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
62187
62289
  if (glyphed) {
62188
62290
  n = glyphed;
62189
62291
  consumedByGlyphs = true;
@@ -64401,7 +64503,7 @@ ${codeFrame}` : message);
64401
64503
  return proxy;
64402
64504
  }
64403
64505
 
64404
- // ../svg-animator-core/dist/chunk-37OFJ3RX.js
64506
+ // ../svg-animator-core/dist/chunk-NDANRP4J.js
64405
64507
  var __defProp3 = Object.defineProperty;
64406
64508
  var __defProps3 = Object.defineProperties;
64407
64509
  var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
@@ -65060,13 +65162,14 @@ ${codeFrame}` : message);
65060
65162
  var PX_TRIGGER_DEFAULTS2 = {
65061
65163
  start: "load",
65062
65164
  offScreen: "pause",
65063
- mouseOut: "continue",
65165
+ mouseOut: "pause",
65064
65166
  visibilityThreshold: 0.5,
65065
65167
  visibilityDebounce: 150,
65066
65168
  finish: "hold"
65067
65169
  };
65068
65170
  var PX_DEFAULT_DURATION_MS2 = 1e3;
65069
65171
  var PX_DEFAULT_ITERATIONS2 = 1;
65172
+ var PX_DEFAULT_UNITS_PER_EM2 = 1e3;
65070
65173
  var PxControlMode = {
65071
65174
  /** No control props — the document's trigger decides, and nothing is taken over. */
65072
65175
  static: "static",
@@ -65344,7 +65447,7 @@ ${codeFrame}` : message);
65344
65447
  fontFamily: px2.string(),
65345
65448
  fontStyle: px2.string(),
65346
65449
  ascent: px2.number(),
65347
- unitsPerEm: px2.number(),
65450
+ unitsPerEm: px2.number(PX_DEFAULT_UNITS_PER_EM2).optional(),
65348
65451
  glyphs: px2.record(PxGlyphSchema2)
65349
65452
  }));
65350
65453
  var PxDefinitionsSchema2 = implementsInterface2()(px2.object({
@@ -65544,7 +65647,7 @@ ${codeFrame}` : message);
65544
65647
  }));
65545
65648
  var PxStrokeGradientEffectSchema2 = PxFillGradientEffectSchema2;
65546
65649
  var PxTextPathEffectSchema2 = implementsInterface2()(px2.object({
65547
- pathData: px2.string(),
65650
+ pathData: PxAnimatableStringSchema2,
65548
65651
  // `extend` is what an omitted pathOverflow means (glyphs continue along the tangent); the
65549
65652
  // other three are SVG's own initial values for the native <textPath> attributes.
65550
65653
  pathOverflow: px2.enum([PxPathOverflow2.clip, PxPathOverflow2.extend], PxPathOverflow2.extend).optional(),
@@ -67503,11 +67606,11 @@ ${codeFrame}` : message);
67503
67606
  const totalLength = cum[segs.length];
67504
67607
  const start = segs[0].P0, end = segs[segs.length - 1].P3;
67505
67608
  const closed = Math.hypot(end[0] - start[0], end[1] - start[1]) < 1e-3;
67506
- const sampleOn = (dist) => {
67609
+ const sampleOn = (dist22) => {
67507
67610
  let k = 0;
67508
- while (k < segs.length - 1 && dist > cum[k + 1]) k++;
67611
+ while (k < segs.length - 1 && dist22 > cum[k + 1]) k++;
67509
67612
  const seg = segs[k];
67510
- const local = dist - cum[k];
67613
+ const local = dist22 - cum[k];
67511
67614
  const t = seg.len > 0 ? bezier2D_tForDistance2(seg.lut, local) : 0;
67512
67615
  const [x, y] = bezier2D_pointAt2(seg.P0, seg.P1, seg.P2, seg.P3, t);
67513
67616
  const [dx, dy] = bezier2D_derivativeAt2(seg.P0, seg.P1, seg.P2, seg.P3, t);
@@ -67516,17 +67619,17 @@ ${codeFrame}` : message);
67516
67619
  return {
67517
67620
  totalLength,
67518
67621
  closed,
67519
- sampleAtDistance(dist) {
67520
- if (closed && totalLength > 0 && (dist < 0 || dist > totalLength)) {
67521
- return sampleOn((dist % totalLength + totalLength) % totalLength);
67622
+ sampleAtDistance(dist22) {
67623
+ if (closed && totalLength > 0 && (dist22 < 0 || dist22 > totalLength)) {
67624
+ return sampleOn((dist22 % totalLength + totalLength) % totalLength);
67522
67625
  }
67523
- if (!closed && (dist < 0 || dist > totalLength)) {
67524
- const edge = dist < 0 ? 0 : totalLength;
67626
+ if (!closed && (dist22 < 0 || dist22 > totalLength)) {
67627
+ const edge = dist22 < 0 ? 0 : totalLength;
67525
67628
  const p = sampleOn(edge);
67526
- const over = dist - edge;
67629
+ const over = dist22 - edge;
67527
67630
  return { x: p.x + Math.cos(p.angle) * over, y: p.y + Math.sin(p.angle) * over, angle: p.angle };
67528
67631
  }
67529
- return sampleOn(clamp22(dist, 0, totalLength));
67632
+ return sampleOn(clamp22(dist22, 0, totalLength));
67530
67633
  }
67531
67634
  };
67532
67635
  }
@@ -67608,6 +67711,72 @@ ${codeFrame}` : message);
67608
67711
  if (kf.tangentIn !== void 0) out.tangentIn = kf.tangentIn;
67609
67712
  return out;
67610
67713
  }
67714
+ function pathString2(v) {
67715
+ if (typeof v === "string") return v;
67716
+ if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
67717
+ return void 0;
67718
+ }
67719
+ function pathTrackOf2(raw) {
67720
+ var _a22, _b;
67721
+ const r = readAnimatable2(raw);
67722
+ if (r.kind === "absent") return void 0;
67723
+ if (r.kind === "static" || r.keyframes.length < 2) {
67724
+ const d = pathString2(r.kind === "static" ? r.value : (_a22 = r.keyframes[0]) == null ? void 0 : _a22.value);
67725
+ if (!d) return void 0;
67726
+ return {
67727
+ animated: false,
67728
+ times: [],
67729
+ dAt: () => d,
67730
+ maxLength: (lengthOf) => lengthOf(d),
67731
+ moveBetween: () => 0
67732
+ };
67733
+ }
67734
+ const kfs = [...r.keyframes].map((kf) => ({ time: Number(kf.time) || 0, d: pathString2(kf.value) })).filter((kf) => !!kf.d).sort((a, b) => a.time - b.time);
67735
+ if (kfs.length < 2) return pathTrackOf2((_b = kfs[0]) == null ? void 0 : _b.d);
67736
+ const times = kfs.map((kf) => kf.time);
67737
+ const beziers = kfs.map((kf) => parseSvgPathToBezier2(kf.d));
67738
+ const at = (t) => {
67739
+ if (t <= times[0]) return beziers[0];
67740
+ for (let i = 1; i < times.length; i++) {
67741
+ if (t <= times[i]) {
67742
+ const span = times[i] - times[i - 1];
67743
+ const f = span > 0 ? (t - times[i - 1]) / span : 1;
67744
+ return interpolateBeziers2(beziers[i - 1], beziers[i], f);
67745
+ }
67746
+ }
67747
+ return beziers[beziers.length - 1];
67748
+ };
67749
+ return {
67750
+ animated: true,
67751
+ times,
67752
+ loop: r.loop,
67753
+ dAt: (t) => at(t).map((bz) => bezierToSvgPath2(bz)).join(""),
67754
+ maxLength: (lengthOf) => Math.max(...kfs.map((kf) => lengthOf(kf.d))),
67755
+ moveBetween: (t0, t1) => maxPointMove2(at(t0), at(t1))
67756
+ };
67757
+ }
67758
+ function maxPointMove2(a, b) {
67759
+ var _a22, _b, _c, _d, _e, _f, _g, _h;
67760
+ let max = 0;
67761
+ const n = Math.min(a.length, b.length);
67762
+ for (let p = 0; p < n; p++) {
67763
+ const pa = a[p], pb = b[p];
67764
+ const count = Math.min(pa.v.length, pb.v.length);
67765
+ for (let k = 0; k < count; k++) {
67766
+ max = Math.max(
67767
+ max,
67768
+ dist2(pa.v[k], pb.v[k]),
67769
+ dist2((_b = (_a22 = pa.i) == null ? void 0 : _a22[k]) != null ? _b : pa.v[k], (_d = (_c = pb.i) == null ? void 0 : _c[k]) != null ? _d : pb.v[k]),
67770
+ dist2((_f = (_e = pa.o) == null ? void 0 : _e[k]) != null ? _f : pa.v[k], (_h = (_g = pb.o) == null ? void 0 : _g[k]) != null ? _h : pb.v[k])
67771
+ );
67772
+ }
67773
+ }
67774
+ return max;
67775
+ }
67776
+ function dist2(p, q) {
67777
+ var _a22, _b, _c, _d;
67778
+ return Math.hypot(((_a22 = q[0]) != null ? _a22 : 0) - ((_b = p[0]) != null ? _b : 0), ((_c = q[1]) != null ? _c : 0) - ((_d = p[1]) != null ? _d : 0));
67779
+ }
67611
67780
  function deepClonePxNode2(value) {
67612
67781
  if (value === null || typeof value !== "object") return value;
67613
67782
  if (Array.isArray(value)) return value.map(deepClonePxNode2);
@@ -67729,7 +67898,7 @@ ${codeFrame}` : message);
67729
67898
  }
67730
67899
  function extendedPathForBrowser2(pathD, opts) {
67731
67900
  var _a22;
67732
- if (opts.pathOverflow === "clip") return { d: pathD, startShift: 0 };
67901
+ if (opts.pathOverflow === PxPathOverflow2.clip) return { d: pathD, startShift: 0 };
67733
67902
  const sampler = createPathSampler2(pathD);
67734
67903
  if (!sampler || sampler.closed || sampler.totalLength <= 0) return { d: pathD, startShift: 0 };
67735
67904
  const L = sampler.totalLength;
@@ -67756,20 +67925,30 @@ ${codeFrame}` : message);
67756
67925
  return { d, startShift: startExt };
67757
67926
  }
67758
67927
  function applyTextPathEffect2(node, fx, ctx) {
67759
- var _a22;
67760
- if (!fx || typeof fx.pathData !== "string" || !fx.pathData) return node;
67928
+ var _a22, _b, _c, _d;
67929
+ if (!fx) return node;
67930
+ const read = readAnimatable2(fx.pathData);
67931
+ if (read.kind === "absent") return node;
67932
+ const isAnimated = read.kind === "animated";
67933
+ const baseD = pathString2(isAnimated ? (_b = read.base) != null ? _b : (_a22 = read.keyframes[0]) == null ? void 0 : _a22.value : read.value);
67934
+ if (!baseD) return node;
67761
67935
  const pathId = genId2(ctx, "tpath");
67762
- const { d, startShift } = extendedPathForBrowser2(fx.pathData, {
67763
- pathOverflow: fx.pathOverflow,
67936
+ const { d, startShift } = extendedPathForBrowser2(baseD, {
67937
+ pathOverflow: isAnimated ? PxPathOverflow2.clip : fx.pathOverflow,
67764
67938
  startOffset: fx.startOffset,
67765
67939
  textLength: fx.textLength,
67766
67940
  advance: estimateTextAdvance2(node)
67767
67941
  });
67768
- ctx.defs.push({ type: "path", id: pathId, d });
67942
+ const pathDef = { type: "path", id: pathId, d };
67943
+ if (isAnimated) {
67944
+ writeAnimatableChannel2(pathDef, "d", read);
67945
+ pathDef.d = (_c = pathString2(pathDef.d)) != null ? _c : d;
67946
+ }
67947
+ ctx.defs.push(pathDef);
67769
67948
  const textPath = {
67770
67949
  type: "textPath",
67771
67950
  href: "#" + pathId,
67772
- children: (_a22 = node.children) != null ? _a22 : []
67951
+ children: (_d = node.children) != null ? _d : []
67773
67952
  };
67774
67953
  if (fx.lengthAdjust !== void 0) textPath.lengthAdjust = fx.lengthAdjust;
67775
67954
  if (fx.method !== void 0) textPath.method = fx.method;
@@ -67946,6 +68125,9 @@ ${codeFrame}` : message);
67946
68125
  if (!gf) warnings == null ? void 0 : warnings.push('textGlyphs: no glyphs for font "' + ((_a22 = s.fontFamily) != null ? _a22 : "") + '"');
67947
68126
  return gf;
67948
68127
  }
68128
+ function unitsPerEmOf2(gf) {
68129
+ return (gf == null ? void 0 : gf.unitsPerEm) || PX_DEFAULT_UNITS_PER_EM2;
68130
+ }
67949
68131
  function soleFontOf2(glyphs) {
67950
68132
  const names = Object.keys(glyphs);
67951
68133
  return names.length === 1 ? glyphs[names[0]] : void 0;
@@ -67975,7 +68157,7 @@ ${codeFrame}` : message);
67975
68157
  const renderChars = (content, s) => {
67976
68158
  var _a3;
67977
68159
  const gf = glyphFontFor2(s, glyphs, soleFont, warnings);
67978
- const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
68160
+ const upm = unitsPerEmOf2(gf);
67979
68161
  const scale = s.fontSize / upm;
67980
68162
  const ascentEm = (_a3 = gf == null ? void 0 : gf.ascent) != null ? _a3 : 0.9 * upm;
67981
68163
  const paint = paintOf2(s);
@@ -68037,8 +68219,9 @@ ${codeFrame}` : message);
68037
68219
  if (content && !((_a22 = el.children) == null ? void 0 : _a22.length)) {
68038
68220
  const gf = glyphFontFor2(s, glyphs, soleFont, warnings);
68039
68221
  if (gf) {
68040
- const scale = s.fontSize / gf.unitsPerEm;
68041
- const ascentEm = (_b = gf.ascent) != null ? _b : 0.9 * gf.unitsPerEm;
68222
+ const upm = unitsPerEmOf2(gf);
68223
+ const scale = s.fontSize / upm;
68224
+ const ascentEm = (_b = gf.ascent) != null ? _b : 0.9 * upm;
68042
68225
  const paint = paintOf2(s);
68043
68226
  for (let i = 0; i < content.length; i++) {
68044
68227
  const ch = content.charAt(i);
@@ -68048,7 +68231,7 @@ ${codeFrame}` : message);
68048
68231
  cells.push({ glyphD: g.pathData, widthEm: g.width, scale, paint, midBase: adv + glyphAdv / 2 });
68049
68232
  adv += glyphAdv;
68050
68233
  } else if (/\S/.test(ch)) {
68051
- const wEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM2 * gf.unitsPerEm;
68234
+ const wEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM2 * upm;
68052
68235
  const boxAdv = wEm * scale;
68053
68236
  cells.push({ glyphD: missingGlyphBoxEm2(wEm, ascentEm), widthEm: wEm, scale, paint, isMissing: true, midBase: adv + boxAdv / 2 });
68054
68237
  adv += boxAdv;
@@ -68064,8 +68247,8 @@ ${codeFrame}` : message);
68064
68247
  walk(node, rootStyleOf2(node));
68065
68248
  return { cells, width: adv };
68066
68249
  }
68067
- function alongAffine2(sampler, dist, scale, widthEm, perp = 0) {
68068
- const { x, y, angle } = sampler.sampleAtDistance(dist);
68250
+ function alongAffine2(sampler, dist22, scale, widthEm, perp = 0) {
68251
+ const { x, y, angle } = sampler.sampleAtDistance(dist22);
68069
68252
  const cos = Math.cos(angle), sin = Math.sin(angle), hw = widthEm / 2;
68070
68253
  return [scale * cos, scale * sin, -scale * sin, scale * cos, x - scale * cos * hw - perp * sin, y - scale * sin * hw + perp * cos];
68071
68254
  }
@@ -68077,9 +68260,12 @@ ${codeFrame}` : message);
68077
68260
  };
68078
68261
  }
68079
68262
  function materializeGlyphTextAlongPath2(node, pathD, startOffset, opts, textLength, pathOverflow) {
68263
+ var _a22;
68080
68264
  const { glyphs, create = jsonElementFactory2, warnings } = opts;
68081
- const sampler = pathD ? createPathSampler2(pathD) : null;
68082
- if (!sampler) {
68265
+ const pathTrack = pathTrackOf2(pathD);
68266
+ const samplerAt = pathTrack ? pathSamplers2(pathTrack) : null;
68267
+ const sampler = (_a22 = samplerAt == null ? void 0 : samplerAt(0)) != null ? _a22 : null;
68268
+ if (!pathTrack || !samplerAt || !sampler) {
68083
68269
  warnings == null ? void 0 : warnings.push("textGlyphs: unparsable along-path geometry");
68084
68270
  return null;
68085
68271
  }
@@ -68091,11 +68277,11 @@ ${codeFrame}` : message);
68091
68277
  const tlTrack = numTrackOf2(textLength);
68092
68278
  const kOf = (tl) => tl > 0 && width > 0 ? tl / width : 1;
68093
68279
  const isClip = pathOverflow === "clip" && !sampler.closed;
68094
- if (soTrack.animated || tlTrack.animated) {
68095
- const times = mergeTrackTimes2(soTrack.times, tlTrack.times);
68280
+ if (soTrack.animated || tlTrack.animated || pathTrack.animated) {
68281
+ const times = mergeTrackTimes2(mergeTrackTimes2(pathTrack.times, soTrack.times), tlTrack.times);
68096
68282
  const distOf = (c, t) => alongOffset + soTrack.at(t) + kOf(tlTrack.at(t)) * c.midBase;
68097
- const loop = soTrack.animated ? soTrack.loop : tlTrack.loop;
68098
- return toGroup2(node, buildAnimatedAlongPath2(cells, sampler, distOf, times, loop, create, isClip, perp), create);
68283
+ const loop = pathTrack.animated && pathTrack.loop !== void 0 ? pathTrack.loop : soTrack.animated ? soTrack.loop : tlTrack.loop;
68284
+ return toGroup2(node, buildAnimatedAlongPath2(cells, samplerAt, pathTrack, distOf, times, loop, create, isClip, perp), create);
68099
68285
  }
68100
68286
  const k = kOf(tlTrack.at(0));
68101
68287
  const base = alongOffset + soTrack.at(0);
@@ -68150,15 +68336,39 @@ ${codeFrame}` : message);
68150
68336
  const f = __pow2(10, n);
68151
68337
  return Math.round(v * f) / f;
68152
68338
  }
68153
- function buildAnimatedAlongPath2(cells, sampler, distOf, times, loop, create, isClip, perp = 0) {
68154
- const step = Math.max(sampler.totalLength / ALONG_PATH_MAX_STEPS2, 0.5);
68155
- const onPath = (dist) => dist >= 0 && dist <= sampler.totalLength;
68339
+ function pathSamplers2(track) {
68340
+ if (!track.animated) {
68341
+ const one = createPathSampler2(track.dAt(0));
68342
+ return () => one;
68343
+ }
68344
+ const byTime = /* @__PURE__ */ new Map();
68345
+ return (t) => {
68346
+ let s = byTime.get(t);
68347
+ if (s === void 0) {
68348
+ s = createPathSampler2(track.dAt(t));
68349
+ byTime.set(t, s);
68350
+ }
68351
+ return s;
68352
+ };
68353
+ }
68354
+ function buildAnimatedAlongPath2(cells, samplerAt, track, distOf, times, loop, create, isClip, perp = 0) {
68355
+ var _a22;
68356
+ const first = samplerAt((_a22 = times[0]) != null ? _a22 : 0);
68357
+ if (!first) return [];
68358
+ const at = (t) => {
68359
+ var _a3;
68360
+ return (_a3 = samplerAt(t)) != null ? _a3 : first;
68361
+ };
68362
+ const maxLength = track.animated ? Math.max(...track.times.map((t) => at(t).totalLength)) : first.totalLength;
68363
+ const step = Math.max(maxLength / ALONG_PATH_MAX_STEPS2, 0.5);
68364
+ const onPath = (dist22, t) => dist22 >= 0 && dist22 <= at(t).totalLength;
68365
+ const moved = times.map((t, k) => k ? track.moveBetween(times[k - 1], t) : 0);
68156
68366
  const out = [];
68157
68367
  for (const c of cells) {
68158
68368
  const centered = [c.scale, 0, 0, c.scale, -c.scale * (c.widthEm / 2), 0];
68159
68369
  const d = transformPathData2(c.glyphD, centered);
68160
- const sampleKf = (dist, time) => {
68161
- const { x, y, angle } = sampler.sampleAtDistance(dist);
68370
+ const sampleKf = (dist22, time) => {
68371
+ const { x, y, angle } = at(time).sampleAtDistance(dist22);
68162
68372
  const cos = Math.cos(angle), sin = Math.sin(angle);
68163
68373
  return {
68164
68374
  time,
@@ -68176,15 +68386,15 @@ ${codeFrame}` : message);
68176
68386
  };
68177
68387
  const kfs = [];
68178
68388
  const opKfs = [];
68179
- const pushKf = (dist, time) => {
68180
- kfs.push(sampleKf(dist, time));
68181
- if (isClip) opKfs.push({ time, value: onPath(dist) ? 1 : 0 });
68389
+ const pushKf = (dist22, time) => {
68390
+ kfs.push(sampleKf(dist22, time));
68391
+ if (isClip) opKfs.push({ time, value: onPath(dist22, time) ? 1 : 0 });
68182
68392
  };
68183
68393
  pushKf(distOf(c, times[0]), times[0]);
68184
68394
  for (let k = 1; k < times.length; k++) {
68185
68395
  const t0 = times[k - 1], t1 = times[k];
68186
68396
  const d0 = distOf(c, t0), d1 = distOf(c, t1);
68187
- const n = Math.min(ALONG_PATH_MAX_STEPS_PER_SEGMENT2, Math.max(1, Math.ceil(Math.abs(d1 - d0) / step)));
68397
+ const n = Math.min(ALONG_PATH_MAX_STEPS_PER_SEGMENT2, Math.max(1, Math.ceil(Math.abs(d1 - d0) / step), Math.ceil(moved[k] / step)));
68188
68398
  for (let s = 1; s <= n; s++) {
68189
68399
  const f = s / n;
68190
68400
  const t = t0 + f * (t1 - t0);
@@ -68737,11 +68947,6 @@ ${codeFrame}` : message);
68737
68947
  node.clipPath = "url(#" + clipId + ")";
68738
68948
  return node;
68739
68949
  }
68740
- function pathString2(v) {
68741
- if (typeof v === "string") return v;
68742
- if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
68743
- return void 0;
68744
- }
68745
68950
  function applyMaskedByEffect2(node, fx, transformBy, ctx) {
68746
68951
  if (!fx) return node;
68747
68952
  const sourceId = stripHash3(fx.source);
@@ -69724,8 +69929,7 @@ ${codeFrame}` : message);
69724
69929
  let consumedByGlyphs = false;
69725
69930
  if (text == null ? void 0 : text.useGlyphs) {
69726
69931
  if (textPath) {
69727
- const pathD = typeof textPath.pathData === "string" ? textPath.pathData : void 0;
69728
- const glyphed = applyTextGlyphsAlongPath2(n, ctx, pathD, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
69932
+ const glyphed = applyTextGlyphsAlongPath2(n, ctx, textPath.pathData, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
69729
69933
  if (glyphed) {
69730
69934
  n = glyphed;
69731
69935
  consumedByGlyphs = true;