@algorisys/tinyfly 0.100.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +6 -6
  2. package/bin/tinyfly.mjs +16 -6
  3. package/docs/character-appearance.md +26 -0
  4. package/docs/editor-guide.md +1 -1
  5. package/docs/examples.md +1 -1
  6. package/docs/getting-started.md +1 -1
  7. package/docs/gsap-compat.md +1 -1
  8. package/docs/llm-guide.md +22 -4
  9. package/docs/maps.md +2 -2
  10. package/docs/scene-3d.md +140 -9
  11. package/docs/teaching.md +1 -1
  12. package/docs/video-rendering.md +198 -1
  13. package/lib/addons/adapters.js +431 -332
  14. package/lib/addons/characters.js +3889 -3773
  15. package/lib/addons/load-scene-oWNsYYC1.js +372 -0
  16. package/lib/addons/scene-3d-webgl.js +31 -31
  17. package/lib/addons/scene-3d.js +669 -314
  18. package/lib/addons/shading-0lPgnXmD.js +96 -0
  19. package/lib/browser/tinyfly-scene-3d-webgl.iife.js +2 -2
  20. package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
  21. package/lib/browser/tinyfly.iife.js +15 -15
  22. package/lib/browser/tinyfly.js +6232 -5723
  23. package/lib/browser/tinyfly.umd.js +15 -15
  24. package/lib/engine/tinyfly-engine.js +1563 -1170
  25. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  26. package/lib/headless/headless.js +189 -6
  27. package/lib/types/adapters/canvas/framing.d.ts +27 -0
  28. package/lib/types/adapters/canvas/impossible.d.ts +15 -0
  29. package/lib/types/adapters/canvas/index.d.ts +4 -0
  30. package/lib/types/adapters/canvas/nested-zoom.d.ts +40 -0
  31. package/lib/types/adapters/canvas/zoom-blur.d.ts +49 -0
  32. package/lib/types/characters/character-script-3d.d.ts +21 -1
  33. package/lib/types/characters/character.d.ts +23 -3
  34. package/lib/types/characters/head/face.d.ts +19 -2
  35. package/lib/types/characters/index.d.ts +2 -1
  36. package/lib/types/characters/staging-3d.d.ts +56 -0
  37. package/lib/types/engine/authoring/beat-loop.d.ts +46 -0
  38. package/lib/types/engine/authoring/curve.d.ts +26 -0
  39. package/lib/types/engine/authoring/framing.d.ts +48 -0
  40. package/lib/types/engine/authoring/index.d.ts +4 -0
  41. package/lib/types/engine/authoring/periodic.d.ts +89 -0
  42. package/lib/types/engine/path/goo.d.ts +103 -0
  43. package/lib/types/engine/path/impossible.d.ts +92 -0
  44. package/lib/types/engine/path/index.d.ts +6 -0
  45. package/lib/types/engine/path/similarity.d.ts +48 -0
  46. package/lib/types/headless/audio-mix.d.ts +40 -0
  47. package/lib/types/headless/ffmpeg-args.d.ts +2 -0
  48. package/lib/types/headless/frame-renderer.d.ts +7 -1
  49. package/lib/types/headless/index.d.ts +2 -0
  50. package/lib/types/headless/loop-audio.d.ts +21 -0
  51. package/lib/types/headless/node-audio.d.ts +39 -0
  52. package/lib/types/headless/node-video.d.ts +2 -0
  53. package/lib/types/headless/video-scene.d.ts +21 -0
  54. package/lib/types/scene-3d/camera.d.ts +11 -2
  55. package/lib/types/scene-3d/geometry/mesh.d.ts +2 -0
  56. package/lib/types/scene-3d/geometry/primitives.d.ts +7 -0
  57. package/lib/types/scene-3d/impossible-3d.d.ts +29 -0
  58. package/lib/types/scene-3d/index.d.ts +7 -3
  59. package/lib/types/scene-3d/lighting.d.ts +58 -0
  60. package/lib/types/scene-3d/resolve-scene.d.ts +18 -2
  61. package/lib/types/scene-3d/scene-3d-adapter.d.ts +4 -0
  62. package/lib/types/scene-3d/scene-types.d.ts +43 -6
  63. package/lib/types/scene-3d/shading.d.ts +2 -0
  64. package/lib/types/scene-3d/shots.d.ts +162 -0
  65. package/lib/types/scene-3d/software-renderer.d.ts +40 -0
  66. package/llms-full.txt +395 -23
  67. package/llms.txt +29 -29
  68. package/package.json +1 -1
  69. package/skills/tinyfly/SKILL.md +11 -1
  70. package/lib/addons/load-scene-CQvcFWGJ.js +0 -331
  71. package/lib/addons/shading-o5T_v9DT.js +0 -89
@@ -1,113 +1,113 @@
1
- import { h as N, e as Y, i as O, a as U, b as W, p as H, t as V, g as z, c as B, q, F as j, s as Z, d as J } from "./dom-adapter-Cphr2HZn.js";
2
- import { D as Xe } from "./dom-adapter-Cphr2HZn.js";
3
- import { C as _e, I as $e, a as Ye, b as Oe, c as Be, d as Le, e as Fe, f as De } from "./target-properties-BtN9skb-.js";
4
- import { createTrack as Q, parsePath as L, ribbon as K, ribbonHeadCap as ee, mat4 as b } from "@algorisys/tinyfly";
5
- import { p as te, s as ie } from "./sketch-CYPUbk3Q.js";
6
- import { c as Ne, a as Ue, b as We } from "./sketch-CYPUbk3Q.js";
7
- function oe(n) {
1
+ import { h as q, e as D, i as G, a as Z, b as j, p as J, t as Q, g as K, c as W, q as ee, F as te, s as ie, d as oe } from "./dom-adapter-Cphr2HZn.js";
2
+ import { D as Je } from "./dom-adapter-Cphr2HZn.js";
3
+ import { C as Ke, I as et, a as tt, b as it, c as ot, d as st, e as nt, f as rt } from "./target-properties-BtN9skb-.js";
4
+ import { createTrack as se, parsePath as N, ribbon as ne, ribbonHeadCap as re, similarityMatrix as ae, powSimilarity as le, createRandom as ce, hashSeed as he, frameRect as fe, safeAreas as de, mat4 as T } from "@algorisys/tinyfly";
5
+ import { p as ue, s as pe } from "./sketch-CYPUbk3Q.js";
6
+ import { c as lt, a as ct, b as ht } from "./sketch-CYPUbk3Q.js";
7
+ function me(s) {
8
8
  const e = /* @__PURE__ */ new Map();
9
- for (const { name: t, element: i } of n)
10
- e.set(t, F(i));
9
+ for (const { name: t, element: i } of s)
10
+ e.set(t, U(i));
11
11
  return { measurements: e };
12
12
  }
13
- function se(n, e, t = {}) {
14
- const i = t.duration ?? 600, o = t.easing ?? "ease-out", s = t.scale !== !1, a = t.idPrefix ?? "flip", r = [];
15
- for (const { name: c, element: l } of e) {
16
- const h = n.measurements.get(c);
13
+ function ye(s, e, t = {}) {
14
+ const i = t.duration ?? 600, o = t.easing ?? "ease-out", n = t.scale !== !1, a = t.idPrefix ?? "flip", r = [];
15
+ for (const { name: l, element: c } of e) {
16
+ const h = s.measurements.get(l);
17
17
  if (!h) continue;
18
- const f = F(l), m = h.left + h.width / 2 - (f.left + f.width / 2), u = h.top + h.height / 2 - (f.top + f.height / 2);
19
- if ((m !== 0 || u !== 0) && r.push(
20
- T(`${a}-${c}-x`, c, "x", m, 0, i, o),
21
- T(`${a}-${c}-y`, c, "y", u, 0, i, o)
22
- ), s && f.width > 0 && f.height > 0) {
23
- const p = h.width / f.width, d = h.height / f.height;
24
- p !== 1 && r.push(T(`${a}-${c}-sx`, c, "scaleX", p, 1, i, o)), d !== 1 && r.push(T(`${a}-${c}-sy`, c, "scaleY", d, 1, i, o));
18
+ const f = U(c), m = h.left + h.width / 2 - (f.left + f.width / 2), d = h.top + h.height / 2 - (f.top + f.height / 2);
19
+ if ((m !== 0 || d !== 0) && r.push(
20
+ k(`${a}-${l}-x`, l, "x", m, 0, i, o),
21
+ k(`${a}-${l}-y`, l, "y", d, 0, i, o)
22
+ ), n && f.width > 0 && f.height > 0) {
23
+ const p = h.width / f.width, u = h.height / f.height;
24
+ p !== 1 && r.push(k(`${a}-${l}-sx`, l, "scaleX", p, 1, i, o)), u !== 1 && r.push(k(`${a}-${l}-sy`, l, "scaleY", u, 1, i, o));
25
25
  }
26
26
  }
27
27
  return r;
28
28
  }
29
- function Me(n, e, t = {}) {
30
- const i = oe(n);
31
- return e(), se(i, n, t);
29
+ function Oe(s, e, t = {}) {
30
+ const i = me(s);
31
+ return e(), ye(i, s, t);
32
32
  }
33
- function T(n, e, t, i, o, s, a) {
34
- return Q({
35
- id: n,
33
+ function k(s, e, t, i, o, n, a) {
34
+ return se({
35
+ id: s,
36
36
  target: e,
37
37
  property: t,
38
38
  keyframes: [
39
39
  { time: 0, value: i },
40
- { time: s, value: o, easing: a }
40
+ { time: n, value: o, easing: a }
41
41
  ]
42
42
  });
43
43
  }
44
- function F(n) {
45
- const e = n;
44
+ function U(s) {
45
+ const e = s;
46
46
  if (typeof e.getBoundingClientRect != "function")
47
47
  return { left: 0, top: 0, width: 0, height: 0 };
48
48
  const t = e.getBoundingClientRect();
49
49
  return { left: t.left, top: t.top, width: t.width, height: t.height };
50
50
  }
51
- function D(n, e, t = {}) {
52
- const i = t.highlight ?? "#ffffff", o = t.halfWidth ?? 0.12, s = -0.2 + n * 1.4, a = [{ offset: 0, color: e }], r = [
53
- { offset: s - o, color: e },
54
- { offset: s, color: i },
55
- { offset: s + o, color: e }
51
+ function H(s, e, t = {}) {
52
+ const i = t.highlight ?? "#ffffff", o = t.halfWidth ?? 0.12, n = -0.2 + s * 1.4, a = [{ offset: 0, color: e }], r = [
53
+ { offset: n - o, color: e },
54
+ { offset: n, color: i },
55
+ { offset: n + o, color: e }
56
56
  ];
57
- for (const c of r)
58
- c.offset > 0 && c.offset < 1 && a.push(c);
59
- return a.push({ offset: 1, color: e }), a.sort((c, l) => c.offset - l.offset), a;
57
+ for (const l of r)
58
+ l.offset > 0 && l.offset < 1 && a.push(l);
59
+ return a.push({ offset: 1, color: e }), a.sort((l, c) => l.offset - c.offset), a;
60
60
  }
61
- const k = 12;
62
- function x(n) {
61
+ const $ = 12;
62
+ function I(s) {
63
63
  const e = [];
64
64
  let t, i = -1;
65
- for (const o of L(n).segments) {
65
+ for (const o of N(s).segments) {
66
66
  if (o.type === "L") {
67
67
  (!t || i !== o.subpath) && (t = { kind: "line", points: [{ x: o.startX, y: o.startY }], length: 0 }, i = o.subpath, e.push(t)), t.points.push({ x: o.endX, y: o.endY }), t.length += o.length;
68
68
  continue;
69
69
  }
70
70
  t = void 0;
71
- const [s, a, r, c, l, h] = o.points, f = [];
72
- for (let m = 0; m <= k; m++) {
73
- const u = m / k, p = 1 - u;
71
+ const [n, a, r, l, c, h] = o.points, f = [];
72
+ for (let m = 0; m <= $; m++) {
73
+ const d = m / $, p = 1 - d;
74
74
  f.push({
75
- x: p * p * p * o.startX + 3 * p * p * u * s + 3 * p * u * u * r + u * u * u * l,
76
- y: p * p * p * o.startY + 3 * p * p * u * a + 3 * p * u * u * c + u * u * u * h
75
+ x: p * p * p * o.startX + 3 * p * p * d * n + 3 * p * d * d * r + d * d * d * c,
76
+ y: p * p * p * o.startY + 3 * p * p * d * a + 3 * p * d * d * l + d * d * d * h
77
77
  });
78
78
  }
79
79
  e.push({ kind: "curve", points: f, length: o.length });
80
80
  }
81
81
  return e;
82
82
  }
83
- function ne(n, e, t, i, o = 0) {
84
- const s = Math.max(0, Math.min(o, t / 2, i / 2));
85
- if (s === 0) return x(`M${n},${e} H${n + t} V${e + i} H${n} Z`);
86
- const a = n + t, r = e + i;
87
- return x(
88
- `M${n + s},${e} H${a - s} A${s},${s} 0 0 1 ${a},${e + s} V${r - s} A${s},${s} 0 0 1 ${a - s},${r} H${n + s} A${s},${s} 0 0 1 ${n},${r - s} V${e + s} A${s},${s} 0 0 1 ${n + s},${e} Z`
83
+ function we(s, e, t, i, o = 0) {
84
+ const n = Math.max(0, Math.min(o, t / 2, i / 2));
85
+ if (n === 0) return I(`M${s},${e} H${s + t} V${e + i} H${s} Z`);
86
+ const a = s + t, r = e + i;
87
+ return I(
88
+ `M${s + n},${e} H${a - n} A${n},${n} 0 0 1 ${a},${e + n} V${r - n} A${n},${n} 0 0 1 ${a - n},${r} H${s + n} A${n},${n} 0 0 1 ${s},${r - n} V${e + n} A${n},${n} 0 0 1 ${s + n},${e} Z`
89
89
  );
90
90
  }
91
- function M(n, e, t, i) {
92
- const s = e.reduce((r, c) => r + c.length, 0) * Math.min(1, Math.max(0, t));
91
+ function C(s, e, t, i) {
92
+ const n = e.reduce((r, l) => r + l.length, 0) * Math.min(1, Math.max(0, t));
93
93
  let a = 0;
94
- i || n.beginPath();
94
+ i || s.beginPath();
95
95
  for (const r of e) {
96
- const c = r.length === 0 ? s >= a ? 1 : 0 : Math.min(1, Math.max(0, (s - a) / r.length));
96
+ const l = r.length === 0 ? n >= a ? 1 : 0 : Math.min(1, Math.max(0, (n - a) / r.length));
97
97
  if (a += r.length, i) {
98
- r.kind === "curve" ? i.curve(r.points, c) : i.line(r.points, c);
98
+ r.kind === "curve" ? i.curve(r.points, l) : i.line(r.points, l);
99
99
  continue;
100
100
  }
101
- if (c <= 0) continue;
102
- const l = te(r.points, c);
103
- n.moveTo(l[0].x, l[0].y);
104
- for (const h of l.slice(1)) n.lineTo(h.x, h.y);
101
+ if (l <= 0) continue;
102
+ const c = ue(r.points, l);
103
+ s.moveTo(c[0].x, c[0].y);
104
+ for (const h of c.slice(1)) s.lineTo(h.x, h.y);
105
105
  }
106
- i || n.stroke();
106
+ i || s.stroke();
107
107
  }
108
- function g(n, e, t) {
108
+ function S(s, e, t) {
109
109
  if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
110
- const i = n.canvas;
110
+ const i = s.canvas;
111
111
  if (i?.ownerDocument) {
112
112
  const o = i.ownerDocument.createElement("canvas");
113
113
  return o.width = e, o.height = t, o;
@@ -118,10 +118,10 @@ function g(n, e, t) {
118
118
  return null;
119
119
  }
120
120
  }
121
- function Se(n) {
122
- return typeof n == "object" && n !== null && "type" in n;
121
+ function xe(s) {
122
+ return typeof s == "object" && s !== null && "type" in s;
123
123
  }
124
- class R {
124
+ class X {
125
125
  targets = /* @__PURE__ */ new Map();
126
126
  targetOrder = [];
127
127
  // Store animation offsets separately - these are applied via ctx.translate() during rendering
@@ -184,17 +184,17 @@ class R {
184
184
  for (const [t, i] of e.values) {
185
185
  const o = this.targets.get(t);
186
186
  if (!o) continue;
187
- const s = this.aliases.get(t) ?? t, a = this.animationOffsets.get(s) ?? { x: 0, y: 0 };
188
- for (const [r, c] of i)
189
- if (R.OFFSET_PROPERTIES.has(r) && typeof c == "number")
190
- r === "x" || r === "motionPathX" ? a.x = c : (r === "y" || r === "motionPathY") && (a.y = c);
187
+ const n = this.aliases.get(t) ?? t, a = this.animationOffsets.get(n) ?? { x: 0, y: 0 };
188
+ for (const [r, l] of i)
189
+ if (X.OFFSET_PROPERTIES.has(r) && typeof l == "number")
190
+ r === "x" || r === "motionPathX" ? a.x = l : (r === "y" || r === "motionPathY") && (a.y = l);
191
191
  else if (o.type === "custom" && o.props && (r in o.props || o.acceptsProp?.(r)))
192
- o.props[r] = c;
192
+ o.props[r] = l;
193
193
  else {
194
- const l = R.PROPERTY_MAP[r] ?? r;
195
- o[l] = c;
194
+ const c = X.PROPERTY_MAP[r] ?? r;
195
+ o[c] = l;
196
196
  }
197
- this.animationOffsets.set(s, a);
197
+ this.animationOffsets.set(n, a);
198
198
  }
199
199
  }
200
200
  /**
@@ -219,24 +219,24 @@ class R {
219
219
  * Render a single target.
220
220
  */
221
221
  renderTarget(e, t, i) {
222
- if (e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity), N(t)) {
223
- const s = Y(t, i, { x: this.getPivotX(t), y: this.getPivotY(t) });
224
- if (t.backfaceVisibility === "hidden" && O(s)) {
222
+ if (e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity), q(t)) {
223
+ const n = D(t, i, { x: this.getPivotX(t), y: this.getPivotY(t) });
224
+ if (t.backfaceVisibility === "hidden" && G(n)) {
225
225
  e.restore();
226
226
  return;
227
227
  }
228
- U(s) ? (e.transform(...W(s)), this.drawContent(e, t)) : this.drawInPerspective(e, t, s), e.restore();
228
+ Z(n) ? (e.transform(...j(n)), this.drawContent(e, t)) : this.drawInPerspective(e, t, n), e.restore();
229
229
  return;
230
230
  }
231
231
  if ((i.x !== 0 || i.y !== 0) && e.translate(i.x, i.y), t.rotate !== void 0 || t.rotateX !== void 0 || t.rotateY !== void 0 || t.scale !== void 0 || t.scaleX !== void 0 || t.scaleY !== void 0 || t.skewX !== void 0 || t.skewY !== void 0) {
232
- const s = this.getPivotX(t), a = this.getPivotY(t);
233
- e.translate(s, a), t.rotate !== void 0 && e.rotate(t.rotate * Math.PI / 180);
234
- let r = t.scaleX ?? 1, c = t.scaleY ?? 1;
235
- if (t.rotateX !== void 0 && (c *= Math.cos(t.rotateX * Math.PI / 180)), t.rotateY !== void 0 && (r *= Math.cos(t.rotateY * Math.PI / 180)), t.scale !== void 0 ? e.scale(t.scale, t.scale) : (r !== 1 || c !== 1) && e.scale(r, c), t.skewX !== void 0 || t.skewY !== void 0) {
236
- const l = (t.skewX ?? 0) * Math.PI / 180, h = (t.skewY ?? 0) * Math.PI / 180;
237
- e.transform(1, Math.tan(h), Math.tan(l), 1, 0, 0);
232
+ const n = this.getPivotX(t), a = this.getPivotY(t);
233
+ e.translate(n, a), t.rotate !== void 0 && e.rotate(t.rotate * Math.PI / 180);
234
+ let r = t.scaleX ?? 1, l = t.scaleY ?? 1;
235
+ if (t.rotateX !== void 0 && (l *= Math.cos(t.rotateX * Math.PI / 180)), t.rotateY !== void 0 && (r *= Math.cos(t.rotateY * Math.PI / 180)), t.scale !== void 0 ? e.scale(t.scale, t.scale) : (r !== 1 || l !== 1) && e.scale(r, l), t.skewX !== void 0 || t.skewY !== void 0) {
236
+ const c = (t.skewX ?? 0) * Math.PI / 180, h = (t.skewY ?? 0) * Math.PI / 180;
237
+ e.transform(1, Math.tan(h), Math.tan(c), 1, 0, 0);
238
238
  }
239
- e.translate(-s, -a);
239
+ e.translate(-n, -a);
240
240
  }
241
241
  this.drawContent(e, t), e.restore();
242
242
  }
@@ -246,20 +246,20 @@ class R {
246
246
  * there. The triangles overlap by a pixel so no anti-aliased seam shows.
247
247
  */
248
248
  drawInPerspective(e, t, i) {
249
- const s = e.globalAlpha < 1 ? this.perspectiveLayer(e) : null;
250
- if (s) {
251
- s.ctx.setTransform(e.getTransform()), this.drawMesh(s.ctx, t, i), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(s.canvas, 0, 0), e.restore();
249
+ const n = e.globalAlpha < 1 ? this.perspectiveLayer(e) : null;
250
+ if (n) {
251
+ n.ctx.setTransform(e.getTransform()), this.drawMesh(n.ctx, t, i), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(n.canvas, 0, 0), e.restore();
252
252
  return;
253
253
  }
254
254
  this.drawMesh(e, t, i);
255
255
  }
256
256
  drawMesh(e, t, i) {
257
257
  const o = this.contentBounds(e, t);
258
- for (const s of H(i, o)) {
259
- const a = V(s.source, s.target);
258
+ for (const n of J(i, o)) {
259
+ const a = Q(n.source, n.target);
260
260
  if (!a) continue;
261
- const [r, c, l] = z(s.target, 1);
262
- e.save(), e.beginPath(), e.moveTo(r.x, r.y), e.lineTo(c.x, c.y), e.lineTo(l.x, l.y), e.closePath(), e.clip(), e.transform(...a), this.drawContent(e, t), e.restore();
261
+ const [r, l, c] = K(n.target, 1);
262
+ e.save(), e.beginPath(), e.moveTo(r.x, r.y), e.lineTo(l.x, l.y), e.lineTo(c.x, c.y), e.closePath(), e.clip(), e.transform(...a), this.drawContent(e, t), e.restore();
263
263
  }
264
264
  }
265
265
  /** A cleared offscreen canvas the size of `ctx`'s, reused frame to frame; null where none can be made. */
@@ -267,8 +267,8 @@ class R {
267
267
  const t = e.canvas?.width ?? 0, i = e.canvas?.height ?? 0;
268
268
  if (!(t > 0 && i > 0)) return null;
269
269
  if (!this.layer || this.layer.width !== t || this.layer.height !== i) {
270
- const s = g(e, t, i), a = s?.getContext("2d");
271
- if (this.layer = s && a ? { canvas: s, ctx: a, width: t, height: i } : null, !this.layer) return null;
270
+ const n = S(e, t, i), a = n?.getContext("2d");
271
+ if (this.layer = n && a ? { canvas: n, ctx: a, width: t, height: i } : null, !this.layer) return null;
272
272
  }
273
273
  const o = this.layer.ctx;
274
274
  return o.setTransform(1, 0, 0, 1, 0, 0), o.globalAlpha = 1, o.clearRect(0, 0, t, i), this.layer;
@@ -281,22 +281,22 @@ class R {
281
281
  contentBounds(e, t) {
282
282
  let i = this.getTargetBounds(t);
283
283
  if (t.type === "text") {
284
- const s = t.fontSize ?? 16;
285
- e.save(), e.font = `${t.fontWeight ?? 400} ${s}px ${t.fontFamily ?? "sans-serif"}`;
284
+ const n = t.fontSize ?? 16;
285
+ e.save(), e.font = `${t.fontWeight ?? 400} ${n}px ${t.fontFamily ?? "sans-serif"}`;
286
286
  const a = e.measureText(t.text).width;
287
287
  e.restore();
288
- const r = t.textAlign ?? "left", c = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, l = (t.textBaseline ?? "top") === "top" ? t.y : t.y - s;
289
- i = { x: c, y: l, width: a, height: s * 1.4 };
288
+ const r = t.textAlign ?? "left", l = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, c = (t.textBaseline ?? "top") === "top" ? t.y : t.y - n;
289
+ i = { x: l, y: c, width: a, height: n * 1.4 };
290
290
  } else if (t.type === "path") {
291
- const s = [], a = [];
292
- for (const r of L(t.d).segments) {
293
- s.push(r.startX, r.endX), a.push(r.startY, r.endY);
294
- for (let c = 0; c + 1 < r.points.length; c += 2)
295
- s.push(r.points[c]), a.push(r.points[c + 1]);
291
+ const n = [], a = [];
292
+ for (const r of N(t.d).segments) {
293
+ n.push(r.startX, r.endX), a.push(r.startY, r.endY);
294
+ for (let l = 0; l + 1 < r.points.length; l += 2)
295
+ n.push(r.points[l]), a.push(r.points[l + 1]);
296
296
  }
297
- if (s.length > 0) {
298
- const r = Math.min(...s), c = Math.min(...a);
299
- i = { x: t.x + r, y: t.y + c, width: Math.max(...s) - r, height: Math.max(...a) - c };
297
+ if (n.length > 0) {
298
+ const r = Math.min(...n), l = Math.min(...a);
299
+ i = { x: t.x + r, y: t.y + l, width: Math.max(...n) - r, height: Math.max(...a) - l };
300
300
  }
301
301
  }
302
302
  const o = (t.lineWidth ?? 1) + 2 + 3 * Math.max(t.blur ?? 0, t.glow ?? 0, t.shadowBlur ?? 0) + Math.max(Math.abs(t.shadowX ?? 0), Math.abs(t.shadowY ?? 0));
@@ -308,10 +308,10 @@ class R {
308
308
  */
309
309
  drawContent(e, t) {
310
310
  t.fillStyle && (e.fillStyle = this.resolveFillStyle(e, t)), t.strokeStyle && (e.strokeStyle = t.strokeStyle), t.lineWidth !== void 0 && (e.lineWidth = t.lineWidth);
311
- const i = B(t);
311
+ const i = W(t);
312
312
  if (i && (e.filter = i), t.clipTop !== void 0 || t.clipRight !== void 0 || t.clipBottom !== void 0 || t.clipLeft !== void 0) {
313
- const o = this.getTargetBounds(t), s = o.x + (t.clipLeft ?? 0) / 100 * o.width, a = o.x + o.width - (t.clipRight ?? 0) / 100 * o.width, r = o.y + (t.clipTop ?? 0) / 100 * o.height, c = o.y + o.height - (t.clipBottom ?? 0) / 100 * o.height;
314
- e.beginPath(), e.rect(s, r, Math.max(0, a - s), Math.max(0, c - r)), e.clip();
313
+ const o = this.getTargetBounds(t), n = o.x + (t.clipLeft ?? 0) / 100 * o.width, a = o.x + o.width - (t.clipRight ?? 0) / 100 * o.width, r = o.y + (t.clipTop ?? 0) / 100 * o.height, l = o.y + o.height - (t.clipBottom ?? 0) / 100 * o.height;
314
+ e.beginPath(), e.rect(n, r, Math.max(0, a - n), Math.max(0, l - r)), e.clip();
315
315
  }
316
316
  switch (t.type) {
317
317
  case "rect":
@@ -351,18 +351,18 @@ class R {
351
351
  * Create a canvas linear gradient from a LinearGradient definition.
352
352
  */
353
353
  createLinearGradient(e, t, i) {
354
- const o = (t.angle - 90) * (Math.PI / 180), s = i.x + i.width / 2, a = i.y + i.height / 2, r = Math.max(i.width, i.height), c = s - Math.cos(o) * r / 2, l = a - Math.sin(o) * r / 2, h = s + Math.cos(o) * r / 2, f = a + Math.sin(o) * r / 2, m = e.createLinearGradient(c, l, h, f);
355
- for (const u of t.stops)
356
- m.addColorStop(u.offset, u.color);
354
+ const o = (t.angle - 90) * (Math.PI / 180), n = i.x + i.width / 2, a = i.y + i.height / 2, r = Math.max(i.width, i.height), l = n - Math.cos(o) * r / 2, c = a - Math.sin(o) * r / 2, h = n + Math.cos(o) * r / 2, f = a + Math.sin(o) * r / 2, m = e.createLinearGradient(l, c, h, f);
355
+ for (const d of t.stops)
356
+ m.addColorStop(d.offset, d.color);
357
357
  return m;
358
358
  }
359
359
  /**
360
360
  * Create a canvas radial gradient from a RadialGradient definition.
361
361
  */
362
362
  createRadialGradient(e, t, i) {
363
- const o = i.x + i.width * t.centerX, s = i.y + i.height * t.centerY, a = Math.max(i.width, i.height) * t.radius, r = e.createRadialGradient(o, s, 0, o, s, a);
364
- for (const c of t.stops)
365
- r.addColorStop(c.offset, c.color);
363
+ const o = i.x + i.width * t.centerX, n = i.y + i.height * t.centerY, a = Math.max(i.width, i.height) * t.radius, r = e.createRadialGradient(o, n, 0, o, n, a);
364
+ for (const l of t.stops)
365
+ r.addColorStop(l.offset, l.color);
366
366
  return r;
367
367
  }
368
368
  /**
@@ -403,24 +403,24 @@ class R {
403
403
  * then the outline up to `drawOn`, in pencil strokes when sketched.
404
404
  */
405
405
  renderOutlined(e, t, i, o) {
406
- const s = Math.min(1, Math.max(0, t.drawOn ?? 1));
407
- if (i && t.fillStyle && s >= 1 && i(), !t.strokeStyle || s <= 0) return;
408
- const a = t.sketch ? ie(e, t.sketch, this.time) : void 0;
409
- a && (e.lineCap = t.lineCap ?? "round", e.lineJoin = t.lineJoin ?? "round"), o(s, a);
406
+ const n = Math.min(1, Math.max(0, t.drawOn ?? 1));
407
+ if (i && t.fillStyle && n >= 1 && i(), !t.strokeStyle || n <= 0) return;
408
+ const a = t.sketch ? pe(e, t.sketch, this.time) : void 0;
409
+ a && (e.lineCap = t.lineCap ?? "round", e.lineJoin = t.lineJoin ?? "round"), o(n, a);
410
410
  }
411
411
  /**
412
412
  * Render a rectangle.
413
413
  */
414
414
  renderRect(e, t) {
415
415
  if (this.drawsOutline(t)) {
416
- const { x: i, y: o, width: s, height: a } = t;
416
+ const { x: i, y: o, width: n, height: a } = t;
417
417
  return this.renderOutlined(
418
418
  e,
419
419
  t,
420
420
  () => {
421
- e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, i, o, s, a, t.borderRadius) : e.rect(i, o, s, a), e.fill();
421
+ e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, i, o, n, a, t.borderRadius) : e.rect(i, o, n, a), e.fill();
422
422
  },
423
- (r, c) => M(e, ne(i, o, s, a, t.borderRadius), r, c)
423
+ (r, l) => C(e, we(i, o, n, a, t.borderRadius), r, l)
424
424
  );
425
425
  }
426
426
  e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, t.x, t.y, t.width, t.height, t.borderRadius) : e.rect(t.x, t.y, t.width, t.height), t.fillStyle && e.fill(), t.strokeStyle && e.stroke(), e.closePath();
@@ -428,25 +428,25 @@ class R {
428
428
  /**
429
429
  * Draw a rounded rectangle path.
430
430
  */
431
- roundRect(e, t, i, o, s, a) {
432
- const r = Math.min(a, o / 2, s / 2);
433
- e.moveTo(t + r, i), e.lineTo(t + o - r, i), e.arcTo(t + o, i, t + o, i + r, r), e.lineTo(t + o, i + s - r), e.arcTo(t + o, i + s, t + o - r, i + s, r), e.lineTo(t + r, i + s), e.arcTo(t, i + s, t, i + s - r, r), e.lineTo(t, i + r), e.arcTo(t, i, t + r, i, r);
431
+ roundRect(e, t, i, o, n, a) {
432
+ const r = Math.min(a, o / 2, n / 2);
433
+ e.moveTo(t + r, i), e.lineTo(t + o - r, i), e.arcTo(t + o, i, t + o, i + r, r), e.lineTo(t + o, i + n - r), e.arcTo(t + o, i + n, t + o - r, i + n, r), e.lineTo(t + r, i + n), e.arcTo(t, i + n, t, i + n - r, r), e.lineTo(t, i + r), e.arcTo(t, i, t + r, i, r);
434
434
  }
435
435
  /**
436
436
  * Render a circle.
437
437
  */
438
438
  renderCircle(e, t) {
439
439
  if (this.drawsOutline(t)) {
440
- const { x: i, y: o, radius: s } = t;
440
+ const { x: i, y: o, radius: n } = t;
441
441
  return this.renderOutlined(
442
442
  e,
443
443
  t,
444
444
  () => {
445
- e.beginPath(), e.arc(i, o, s, 0, Math.PI * 2), e.fill();
445
+ e.beginPath(), e.arc(i, o, n, 0, Math.PI * 2), e.fill();
446
446
  },
447
447
  (a, r) => {
448
- if (r) return r.circle(i, o, s, a);
449
- e.beginPath(), e.arc(i, o, s, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * a), e.stroke();
448
+ if (r) return r.circle(i, o, n, a);
449
+ e.beginPath(), e.arc(i, o, n, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * a), e.stroke();
450
450
  }
451
451
  );
452
452
  }
@@ -456,13 +456,13 @@ class R {
456
456
  * Render text.
457
457
  */
458
458
  renderText(e, t) {
459
- const i = t.fontSize ?? 16, o = t.fontFamily ?? "sans-serif", s = t.fontWeight ?? 400;
460
- if (e.font = `${s} ${i}px ${o}`, e.textAlign = t.textAlign ?? "left", e.textBaseline = t.textBaseline ?? "top", t.fillStyle) {
459
+ const i = t.fontSize ?? 16, o = t.fontFamily ?? "sans-serif", n = t.fontWeight ?? 400;
460
+ if (e.font = `${n} ${i}px ${o}`, e.textAlign = t.textAlign ?? "left", e.textBaseline = t.textBaseline ?? "top", t.fillStyle) {
461
461
  if (t.shine !== void 0 && typeof t.fillStyle == "string") {
462
- const a = e.measureText(t.text).width, r = t.textAlign ?? "left", c = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, l = e.createLinearGradient(c, t.y, c + a, t.y);
463
- for (const h of D(t.shine, t.fillStyle))
464
- l.addColorStop(h.offset, h.color);
465
- e.fillStyle = l;
462
+ const a = e.measureText(t.text).width, r = t.textAlign ?? "left", l = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, c = e.createLinearGradient(l, t.y, l + a, t.y);
463
+ for (const h of H(t.shine, t.fillStyle))
464
+ c.addColorStop(h.offset, h.color);
465
+ e.fillStyle = c;
466
466
  }
467
467
  e.fillText(t.text, t.x, t.y);
468
468
  }
@@ -481,7 +481,7 @@ class R {
481
481
  e,
482
482
  t,
483
483
  void 0,
484
- (s, a) => M(e, [{ kind: "line", points: i, length: o }], s, a)
484
+ (n, a) => C(e, [{ kind: "line", points: i, length: o }], n, a)
485
485
  );
486
486
  }
487
487
  e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(t.x2, t.y2), t.strokeStyle && e.stroke(), e.closePath();
@@ -497,7 +497,7 @@ class R {
497
497
  e,
498
498
  t,
499
499
  () => e.fill(i),
500
- (o, s) => M(e, x(t.d), o, s)
500
+ (o, n) => C(e, I(t.d), o, n)
501
501
  );
502
502
  t.fillStyle && e.fill(i), t.strokeStyle && e.stroke(i);
503
503
  }
@@ -507,13 +507,13 @@ class R {
507
507
  renderImage(e, t) {
508
508
  if (!t.image) return;
509
509
  t.opacity !== void 0 && (e.globalAlpha = t.opacity);
510
- const { x: i, y: o, width: s, height: a } = t, r = t.objectFit ?? "fill", c = t.borderRadius ?? 0, l = t.image, h = l.naturalWidth || l.videoWidth || l.width || s, f = l.naturalHeight || l.videoHeight || l.height || a;
511
- let m = i, u = o, p = s, d = a;
510
+ const { x: i, y: o, width: n, height: a } = t, r = t.objectFit ?? "fill", l = t.borderRadius ?? 0, c = t.image, h = c.naturalWidth || c.videoWidth || c.width || n, f = c.naturalHeight || c.videoHeight || c.height || a;
511
+ let m = i, d = o, p = n, u = a;
512
512
  if (r !== "fill" && h > 0 && f > 0) {
513
- const y = r === "cover" ? Math.max(s / h, a / f) : Math.min(s / h, a / f);
514
- p = h * y, d = f * y, m = i + (s - p) / 2, u = o + (a - d) / 2;
513
+ const y = r === "cover" ? Math.max(n / h, a / f) : Math.min(n / h, a / f);
514
+ p = h * y, u = f * y, m = i + (n - p) / 2, d = o + (a - u) / 2;
515
515
  }
516
- e.save(), e.beginPath(), c > 0 && typeof e.roundRect == "function" ? e.roundRect(i, o, s, a, c) : e.rect(i, o, s, a), e.clip(), e.drawImage(t.image, m, u, p, d), e.restore();
516
+ e.save(), e.beginPath(), l > 0 && typeof e.roundRect == "function" ? e.roundRect(i, o, n, a, l) : e.rect(i, o, n, a), e.clip(), e.drawImage(t.image, m, d, p, u), e.restore();
517
517
  }
518
518
  /**
519
519
  * Render a custom target by calling its draw function in local coordinates.
@@ -621,109 +621,200 @@ class R {
621
621
  });
622
622
  }
623
623
  }
624
- function re(n, e) {
625
- const t = n.length / 4, i = new Float32Array(t * 3), o = Math.min(0.999, Math.max(0, e));
626
- for (let s = 0; s < t; s++) {
627
- const a = n[s * 4] / 255, r = n[s * 4 + 1] / 255, c = n[s * 4 + 2] / 255, l = n[s * 4 + 3] / 255, h = Math.max(a, r, c);
624
+ function be(s, e) {
625
+ const t = s.length / 4, i = new Float32Array(t * 3), o = Math.min(0.999, Math.max(0, e));
626
+ for (let n = 0; n < t; n++) {
627
+ const a = s[n * 4] / 255, r = s[n * 4 + 1] / 255, l = s[n * 4 + 2] / 255, c = s[n * 4 + 3] / 255, h = Math.max(a, r, l);
628
628
  if (h <= o) continue;
629
- const f = (h - o) / (1 - o) * l / h;
630
- i[s * 3] = a * f, i[s * 3 + 1] = r * f, i[s * 3 + 2] = c * f;
629
+ const f = (h - o) / (1 - o) * c / h;
630
+ i[n * 3] = a * f, i[n * 3 + 1] = r * f, i[n * 3 + 2] = l * f;
631
631
  }
632
632
  return i;
633
633
  }
634
- function E(n, e, t, i, o) {
635
- const s = new Float32Array(n.length), a = o ? t : e, r = o ? e : t, c = (h, f) => (o ? h * e + f : f * e + h) * 3, l = i * 2 + 1;
634
+ function Y(s, e, t, i, o) {
635
+ const n = new Float32Array(s.length), a = o ? t : e, r = o ? e : t, l = (h, f) => (o ? h * e + f : f * e + h) * 3, c = i * 2 + 1;
636
636
  for (let h = 0; h < a; h++)
637
637
  for (let f = 0; f < 3; f++) {
638
638
  let m = 0;
639
- for (let u = -i; u <= i; u++) m += n[c(h, Math.min(r - 1, Math.max(0, u))) + f];
640
- for (let u = 0; u < r; u++) {
641
- s[c(h, u) + f] = m / l;
642
- const p = n[c(h, Math.max(0, u - i)) + f], d = n[c(h, Math.min(r - 1, u + i + 1)) + f];
643
- m += d - p;
639
+ for (let d = -i; d <= i; d++) m += s[l(h, Math.min(r - 1, Math.max(0, d))) + f];
640
+ for (let d = 0; d < r; d++) {
641
+ n[l(h, d) + f] = m / c;
642
+ const p = s[l(h, Math.max(0, d - i)) + f], u = s[l(h, Math.min(r - 1, d + i + 1)) + f];
643
+ m += u - p;
644
644
  }
645
645
  }
646
- return s;
646
+ return n;
647
647
  }
648
- function C(n, e, t, i) {
648
+ function O(s, e, t, i) {
649
649
  const o = Math.max(1, Math.round(i / Math.sqrt(3)));
650
- let s = n;
650
+ let n = s;
651
651
  for (let a = 0; a < 3; a++)
652
- s = E(s, e, t, o, !0), s = E(s, e, t, o, !1);
653
- return s;
652
+ n = Y(n, e, t, o, !0), n = Y(n, e, t, o, !1);
653
+ return n;
654
654
  }
655
- function xe(n, e = {}) {
656
- const t = n.canvas, i = t.width, o = t.height;
655
+ function Be(s, e = {}) {
656
+ const t = s.canvas, i = t.width, o = t.height;
657
657
  if (!(i > 0 && o > 0)) return;
658
- const s = Math.max(1, Math.round(e.downsample ?? 4)), a = Math.max(1, Math.ceil(i / s)), r = Math.max(1, Math.ceil(o / s)), c = g(n, a, r), l = c?.getContext("2d");
659
- if (!c || !l) return;
660
- l.imageSmoothingEnabled = !0, l.drawImage(n.canvas, 0, 0, a, r);
661
- const h = re(l.getImageData(0, 0, a, r).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, o) * 0.02) / s, m = C(h, a, r, f), u = C(h, a, r, f * 3), p = e.halo ?? 0.6, d = l.createImageData(a, r);
658
+ const n = Math.max(1, Math.round(e.downsample ?? 4)), a = Math.max(1, Math.ceil(i / n)), r = Math.max(1, Math.ceil(o / n)), l = S(s, a, r), c = l?.getContext("2d");
659
+ if (!l || !c) return;
660
+ c.imageSmoothingEnabled = !0, c.drawImage(s.canvas, 0, 0, a, r);
661
+ const h = be(c.getImageData(0, 0, a, r).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, o) * 0.02) / n, m = O(h, a, r, f), d = O(h, a, r, f * 3), p = e.halo ?? 0.6, u = c.createImageData(a, r);
662
662
  for (let y = 0; y < a * r; y++) {
663
- for (let w = 0; w < 3; w++) d.data[y * 4 + w] = Math.round(Math.min(1, m[y * 3 + w] + u[y * 3 + w] * p) * 255);
664
- d.data[y * 4 + 3] = 255;
663
+ for (let w = 0; w < 3; w++) u.data[y * 4 + w] = Math.round(Math.min(1, m[y * 3 + w] + d[y * 3 + w] * p) * 255);
664
+ u.data[y * 4 + 3] = 255;
665
665
  }
666
- l.putImageData(d, 0, 0), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalCompositeOperation = "lighter", n.globalAlpha = Math.max(0, e.strength ?? 0.9), n.imageSmoothingEnabled = !0, n.drawImage(c, 0, 0, i, o), n.restore();
666
+ c.putImageData(u, 0, 0), s.save(), s.setTransform(1, 0, 0, 1, 0, 0), s.globalCompositeOperation = "lighter", s.globalAlpha = Math.max(0, e.strength ?? 0.9), s.imageSmoothingEnabled = !0, s.drawImage(l, 0, 0, i, o), s.restore();
667
667
  }
668
- function Re(n, e, t) {
669
- const i = t.width ?? 6, o = t.taper ?? 1, s = t.fade ?? 1, a = t.opacity ?? 1, r = t.blend === "add";
670
- if (n.save(), e.length >= 2) {
671
- const l = le(e, i, o, s, a);
672
- r ? (n.globalCompositeOperation = "lighter", A(n, l, t.color)) : ce(n, l, t.color);
673
- }
674
- const c = e[e.length - 1];
675
- if (t.head && c && t.head.radius > 0) {
676
- r && (n.globalCompositeOperation = "lighter");
677
- const l = t.head.color ?? t.color, h = n.createRadialGradient(c.at.x, c.at.y, 0, c.at.x, c.at.y, t.head.radius);
678
- h.addColorStop(0, l), h.addColorStop(0.35, l), h.addColorStop(1, ae(n, l)), n.globalAlpha = a, n.fillStyle = h, n.beginPath(), n.arc(c.at.x, c.at.y, t.head.radius, 0, Math.PI * 2), n.fill();
679
- }
680
- n.restore();
668
+ function Le(s, e, t) {
669
+ const i = t.width ?? 6, o = t.taper ?? 1, n = t.fade ?? 1, a = t.opacity ?? 1, r = t.blend === "add";
670
+ if (s.save(), e.length >= 2) {
671
+ const c = ve(e, i, o, n, a);
672
+ r ? (s.globalCompositeOperation = "lighter", _(s, c, t.color)) : Me(s, c, t.color);
673
+ }
674
+ const l = e[e.length - 1];
675
+ if (t.head && l && t.head.radius > 0) {
676
+ r && (s.globalCompositeOperation = "lighter");
677
+ const c = t.head.color ?? t.color, h = s.createRadialGradient(l.at.x, l.at.y, 0, l.at.x, l.at.y, t.head.radius);
678
+ h.addColorStop(0, c), h.addColorStop(0.35, c), h.addColorStop(1, Te(s, c)), s.globalAlpha = a, s.fillStyle = h, s.beginPath(), s.arc(l.at.x, l.at.y, t.head.radius, 0, Math.PI * 2), s.fill();
679
+ }
680
+ s.restore();
681
681
  }
682
- function ae(n, e) {
683
- n.fillStyle = e;
684
- const t = String(n.fillStyle), i = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);
682
+ function Te(s, e) {
683
+ s.fillStyle = e;
684
+ const t = String(s.fillStyle), i = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(t);
685
685
  if (i) return `rgba(${parseInt(i[1], 16)}, ${parseInt(i[2], 16)}, ${parseInt(i[3], 16)}, 0)`;
686
686
  const o = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(t);
687
687
  return o ? `rgba(${o[1]}, ${o[2]}, ${o[3]}, 0)` : "rgba(0, 0, 0, 0)";
688
688
  }
689
- function le(n, e, t, i, o) {
690
- const s = n.map((l) => ({ x: l.at.x, y: l.at.y, width: e * (1 - t * l.age) })), a = K(s), r = ee(s) ?? void 0, c = [];
691
- for (let l = 0; l + 1 < n.length; l++) {
692
- const h = (n[l].age + n[l + 1].age) / 2, f = o * (1 - i * h);
689
+ function ve(s, e, t, i, o) {
690
+ const n = s.map((c) => ({ x: c.at.x, y: c.at.y, width: e * (1 - t * c.age) })), a = ne(n), r = re(n) ?? void 0, l = [];
691
+ for (let c = 0; c + 1 < s.length; c++) {
692
+ const h = (s[c].age + s[c + 1].age) / 2, f = o * (1 - i * h);
693
693
  if (f <= 0) continue;
694
- const m = l + 2 === n.length;
695
- c.push({ corners: [a.left[l], a.left[l + 1], a.right[l + 1], a.right[l]], alpha: f, ...m && r && { cap: r } });
694
+ const m = c + 2 === s.length;
695
+ l.push({ corners: [a.left[c], a.left[c + 1], a.right[c + 1], a.right[c]], alpha: f, ...m && r && { cap: r } });
696
696
  }
697
- return c;
697
+ return l;
698
698
  }
699
- function A(n, e, t) {
700
- n.fillStyle = t;
699
+ function _(s, e, t) {
700
+ s.fillStyle = t;
701
701
  for (const i of e) {
702
- const [o, s, a, r] = i.corners;
703
- n.globalAlpha = Math.min(1, i.alpha), n.beginPath(), n.moveTo(o.x, o.y), n.lineTo(s.x, s.y), i.cap && n.arc(i.cap.x, i.cap.y, i.cap.radius, i.cap.start, i.cap.start - Math.PI, !0), n.lineTo(a.x, a.y), n.lineTo(r.x, r.y), n.closePath(), n.fill();
702
+ const [o, n, a, r] = i.corners;
703
+ s.globalAlpha = Math.min(1, i.alpha), s.beginPath(), s.moveTo(o.x, o.y), s.lineTo(n.x, n.y), i.cap && s.arc(i.cap.x, i.cap.y, i.cap.radius, i.cap.start, i.cap.start - Math.PI, !0), s.lineTo(a.x, a.y), s.lineTo(r.x, r.y), s.closePath(), s.fill();
704
704
  }
705
705
  }
706
- function ce(n, e, t) {
707
- const i = typeof n.getTransform == "function" ? n.getTransform() : null, o = (d) => i ? { x: i.a * d.x + i.c * d.y + i.e, y: i.b * d.x + i.d * d.y + i.f } : d, s = i ? Math.sqrt(Math.abs(i.a * i.d - i.b * i.c)) : 1, a = e.map((d) => ({
708
- ...d,
709
- corners: d.corners.map(o),
710
- ...d.cap && { cap: { ...d.cap, ...o(d.cap), radius: d.cap.radius * s, start: d.cap.start + (i ? Math.atan2(i.b, i.a) : 0) } }
706
+ function Me(s, e, t) {
707
+ const i = typeof s.getTransform == "function" ? s.getTransform() : null, o = (u) => i ? { x: i.a * u.x + i.c * u.y + i.e, y: i.b * u.x + i.d * u.y + i.f } : u, n = i ? Math.sqrt(Math.abs(i.a * i.d - i.b * i.c)) : 1, a = e.map((u) => ({
708
+ ...u,
709
+ corners: u.corners.map(o),
710
+ ...u.cap && { cap: { ...u.cap, ...o(u.cap), radius: u.cap.radius * n, start: u.cap.start + (i ? Math.atan2(i.b, i.a) : 0) } }
711
711
  }));
712
- let r = 1 / 0, c = 1 / 0, l = -1 / 0, h = -1 / 0;
713
- for (const d of a) {
714
- const y = d.cap ? [{ x: d.cap.x - d.cap.radius, y: d.cap.y - d.cap.radius }, { x: d.cap.x + d.cap.radius, y: d.cap.y + d.cap.radius }] : [];
715
- for (const w of [...d.corners, ...y])
716
- r = Math.min(r, w.x), c = Math.min(c, w.y), l = Math.max(l, w.x), h = Math.max(h, w.y);
717
- }
718
- if (!(l > r && h > c)) return;
719
- const f = Math.floor(r) - 1, m = Math.floor(c) - 1, u = i ? g(n, Math.ceil(l) + 1 - f, Math.ceil(h) + 1 - m) : null, p = u?.getContext("2d");
720
- if (!u || !p) {
721
- A(n, e, t);
712
+ let r = 1 / 0, l = 1 / 0, c = -1 / 0, h = -1 / 0;
713
+ for (const u of a) {
714
+ const y = u.cap ? [{ x: u.cap.x - u.cap.radius, y: u.cap.y - u.cap.radius }, { x: u.cap.x + u.cap.radius, y: u.cap.y + u.cap.radius }] : [];
715
+ for (const w of [...u.corners, ...y])
716
+ r = Math.min(r, w.x), l = Math.min(l, w.y), c = Math.max(c, w.x), h = Math.max(h, w.y);
717
+ }
718
+ if (!(c > r && h > l)) return;
719
+ const f = Math.floor(r) - 1, m = Math.floor(l) - 1, d = i ? S(s, Math.ceil(c) + 1 - f, Math.ceil(h) + 1 - m) : null, p = d?.getContext("2d");
720
+ if (!d || !p) {
721
+ _(s, e, t);
722
722
  return;
723
723
  }
724
- p.translate(-f, -m), p.globalCompositeOperation = "lighter", A(p, a, t), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalAlpha = 1, n.drawImage(u, f, m), n.restore();
724
+ p.translate(-f, -m), p.globalCompositeOperation = "lighter", _(p, a, t), s.save(), s.setTransform(1, 0, 0, 1, 0, 0), s.globalAlpha = 1, s.drawImage(d, f, m), s.restore();
725
725
  }
726
- const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
726
+ function Se(s, e, t) {
727
+ return le(s, e - t);
728
+ }
729
+ function Fe(s, e) {
730
+ const [t, i] = e.levels ?? [-4, 24], o = e.minSize ?? 1, n = [];
731
+ for (let l = Math.ceil(t); l <= Math.floor(i); l++) {
732
+ const c = Se(e.step, l, e.phase);
733
+ c.scale * e.extent < o || n.push({ level: l, scale: c.scale, transform: c });
734
+ }
735
+ n.sort((l, c) => c.scale - l.scale);
736
+ let a = 0;
737
+ if (e.coversAbove !== void 0)
738
+ for (let l = 0; l < n.length; l++) n[l].scale >= e.coversAbove && (a = l);
739
+ const r = [];
740
+ for (const { level: l, scale: c, transform: h } of n.slice(a))
741
+ s.save(), s.transform(...ae(h)), e.draw(s, l, c), s.restore(), r.push(l);
742
+ return r;
743
+ }
744
+ function De(s, e = {}) {
745
+ const t = s.canvas, i = t.width, o = t.height;
746
+ if (!(i > 0 && o > 0)) return;
747
+ const n = S(s, i, o), a = n?.getContext("2d");
748
+ if (!n || !a) return;
749
+ a.drawImage(s.canvas, 0, 0);
750
+ const r = Math.max(1, Math.round(e.samples ?? 8)), l = e.strength ?? 0.08, c = e.centre?.x ?? i / 2, h = e.centre?.y ?? o / 2, f = e.blend === "add", m = Math.min(1, Math.max(0, e.amount ?? 1));
751
+ s.save(), s.setTransform(1, 0, 0, 1, 0, 0), s.imageSmoothingEnabled = !0, f && (s.globalCompositeOperation = "lighter");
752
+ for (let d = 1; d <= r; d++) {
753
+ const p = 1 + l * d / r;
754
+ s.globalAlpha = m * (f ? 0.9 / r : 1 / (d + 1)), s.drawImage(n, c - c * p, h - h * p, i * p, o * p);
755
+ }
756
+ s.restore();
757
+ }
758
+ function Ge(s, e = {}) {
759
+ const t = s.canvas, i = e.centre?.x ?? t.width / 2, o = e.centre?.y ?? t.height / 2, n = Math.hypot(t.width, t.height) / 2, a = e.inner ?? n * 0.15, r = e.outer ?? n * 1.1, l = Math.max(1, r - a), c = (e.length ?? 0.35) * l, h = Math.max(1, Math.round(e.count ?? 28)), f = ce(typeof e.seed == "string" ? he(e.seed) : e.seed ?? 1), m = e.phase ?? 0, d = e.direction === "in" ? -1 : 1;
760
+ s.save(), s.strokeStyle = e.color ?? "#ffffff", s.lineCap = "round", e.blend === "add" && (s.globalCompositeOperation = "lighter");
761
+ const p = e.width ?? 3, u = e.opacity ?? 0.8;
762
+ for (let y = 0; y < h; y++) {
763
+ const w = (y + f.next() * 0.6) / h * Math.PI * 2, v = f.next(), M = 0.6 + f.next() * 0.8, z = ((v + d * m) % 1 + 1) % 1, b = a + z * l, P = b + c * M, g = Math.cos(w), R = Math.sin(w), A = s.createLinearGradient(i + g * b, o + R * b, i + g * P, o + R * P);
764
+ A.addColorStop(0, "rgba(0,0,0,0)"), A.addColorStop(0.5, e.color ?? "#ffffff"), A.addColorStop(1, "rgba(0,0,0,0)"), s.strokeStyle = A, s.globalAlpha = u * Math.min(1, (b - a) / l + 0.3), s.lineWidth = p * (0.4 + 0.6 * (b - a) / l), s.beginPath(), s.moveTo(i + g * b, o + R * b), s.lineTo(i + g * Math.min(P, r + c), o + R * Math.min(P, r + c)), s.stroke();
765
+ }
766
+ s.restore();
767
+ }
768
+ function We(s, e, t = {}) {
769
+ const i = { top: t.top ?? "#f3f4f6", left: t.left ?? "#9ca3af", right: t.right ?? "#4b5563" };
770
+ s.save(), s.lineJoin = "round";
771
+ for (const o of e)
772
+ s.beginPath(), o.points.forEach((n, a) => a === 0 ? s.moveTo(n.x, n.y) : s.lineTo(n.x, n.y)), s.closePath(), s.fillStyle = t.fill?.(o) ?? i[o.side], s.fill(), t.outline && (s.strokeStyle = t.outline, s.lineWidth = t.lineWidth ?? 2, s.stroke());
773
+ s.restore();
774
+ }
775
+ function Ne(s, e, t, i = "#000000") {
776
+ const o = fe(e, t);
777
+ return s.save(), s.fillStyle = i, o.y > 0 && (s.fillRect(0, 0, e.width, o.y), s.fillRect(0, o.y + o.height, e.width, e.height - o.y - o.height)), o.x > 0 && (s.fillRect(0, 0, o.x, e.height), s.fillRect(o.x + o.width, 0, e.width - o.x - o.width, e.height)), s.restore(), o;
778
+ }
779
+ function Ue(s, e, t = {}) {
780
+ const i = de(e, t);
781
+ s.save(), s.strokeStyle = t.color ?? "rgba(255, 255, 255, 0.6)", s.lineWidth = 1, s.setLineDash([6, 4]);
782
+ for (const o of [i.action, i.title]) s.strokeRect(o.x + 0.5, o.y + 0.5, o.width - 1, o.height - 1);
783
+ s.restore();
784
+ }
785
+ function He(s, e, t) {
786
+ const { width: i, height: o, draw: n } = t, a = Math.min(1, Math.max(0, e.progress));
787
+ if (e.kind === "dipToBlack") {
788
+ n(s, a < 0.5 ? e.from.camera : e.to.camera), s.save(), s.globalAlpha = 1 - Math.abs(a * 2 - 1), s.fillStyle = e.color, s.fillRect(0, 0, i, o), s.restore();
789
+ return;
790
+ }
791
+ n(s, e.from.camera);
792
+ const r = S(s, i, o), l = r?.getContext("2d");
793
+ if (!r || !l) {
794
+ a >= 0.5 && n(s, e.to.camera);
795
+ return;
796
+ }
797
+ if (n(l, e.to.camera), s.save(), e.kind === "crossfade")
798
+ s.globalAlpha = a;
799
+ else {
800
+ switch (s.beginPath(), e.direction) {
801
+ case "right":
802
+ s.rect(i * (1 - a), 0, i * a, o);
803
+ break;
804
+ case "up":
805
+ s.rect(0, o * (1 - a), i, o * a);
806
+ break;
807
+ case "down":
808
+ s.rect(0, 0, i, o * a);
809
+ break;
810
+ default:
811
+ s.rect(0, 0, i * a, o);
812
+ }
813
+ s.clip();
814
+ }
815
+ s.drawImage(r, 0, 0), s.restore();
816
+ }
817
+ const E = "http://www.w3.org/2000/svg", Pe = /* @__PURE__ */ new Set([
727
818
  "fill",
728
819
  "stroke",
729
820
  "d",
@@ -743,7 +834,7 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
743
834
  "height",
744
835
  "viewBox",
745
836
  "preserveAspectRatio"
746
- ]), X = {
837
+ ]), x = {
747
838
  strokeWidth: "stroke-width",
748
839
  strokeLinecap: "stroke-linecap",
749
840
  strokeLinejoin: "stroke-linejoin",
@@ -754,7 +845,7 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
754
845
  strokeOpacity: "stroke-opacity",
755
846
  borderRadius: "rx"
756
847
  // Map CSS borderRadius to SVG rx
757
- }, fe = /* @__PURE__ */ new Set([
848
+ }, ge = /* @__PURE__ */ new Set([
758
849
  "x",
759
850
  // Position x treated as translateX
760
851
  "y",
@@ -775,8 +866,8 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
775
866
  "motionPathX",
776
867
  "motionPathY",
777
868
  "motionPathRotate"
778
- ]), ue = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
779
- class Ae {
869
+ ]), Re = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
870
+ class Ve {
780
871
  targets = /* @__PURE__ */ new Map();
781
872
  /**
782
873
  * Register an SVG element as an animation target.
@@ -817,25 +908,25 @@ class Ae {
817
908
  applyProperties(e, t) {
818
909
  const i = {};
819
910
  let o = null;
820
- const s = {}, a = {}, r = {};
821
- let c = !1;
822
- for (const [l, h] of t)
823
- l !== "drawOn" && (fe.has(l) ? i[l] = h : l === "quaternion" ? o = q(h) : l === "originX" || l === "originY" ? typeof h == "number" && (s[l] = h) : l === "perspective" ? typeof h == "number" && (i.perspective = h) : ue.has(l) ? typeof h == "number" && (a[l] = h) : j.has(l) ? (r[l] = h, c = !0) : l === "text" ? typeof h == "string" && Z(e, h) : l === "shine" ? typeof h == "number" && this.applyShine(e, h) : l === "opacity" ? (e.setAttribute("fill-opacity", String(h)), e.setAttribute("stroke-opacity", String(h))) : this.applyAttribute(e, l, h));
911
+ const n = {}, a = {}, r = {};
912
+ let l = !1;
913
+ for (const [c, h] of t)
914
+ c !== "drawOn" && (ge.has(c) ? i[c] = h : c === "quaternion" ? o = ee(h) : c === "originX" || c === "originY" ? typeof h == "number" && (n[c] = h) : c === "perspective" ? typeof h == "number" && (i.perspective = h) : Re.has(c) ? typeof h == "number" && (a[c] = h) : te.has(c) ? (r[c] = h, l = !0) : c === "text" ? typeof h == "string" && ie(e, h) : c === "shine" ? typeof h == "number" && this.applyShine(e, h) : c === "opacity" ? (e.setAttribute("fill-opacity", String(h)), e.setAttribute("stroke-opacity", String(h))) : this.applyAttribute(e, c, h));
824
915
  if (Object.keys(i).length > 0 || o) {
825
- const l = this.buildCssTransformString(i, o);
826
- e.style.transform = l, J(e);
916
+ const c = this.buildCssTransformString(i, o);
917
+ e.style.transform = c, oe(e);
827
918
  }
828
- if (Object.keys(s).length > 0) {
829
- const l = e.style;
830
- l.transformBox = "fill-box", l.transformOrigin = `${s.originX ?? 50}% ${s.originY ?? 50}%`;
919
+ if (Object.keys(n).length > 0) {
920
+ const c = e.style;
921
+ c.transformBox = "fill-box", c.transformOrigin = `${n.originX ?? 50}% ${n.originY ?? 50}%`;
831
922
  }
832
923
  if (Object.keys(a).length > 0) {
833
- const l = a.clipTop ?? 0, h = a.clipRight ?? 0, f = a.clipBottom ?? 0, m = a.clipLeft ?? 0;
834
- e.style.clipPath = `inset(${l}% ${h}% ${f}% ${m}%)`;
924
+ const c = a.clipTop ?? 0, h = a.clipRight ?? 0, f = a.clipBottom ?? 0, m = a.clipLeft ?? 0;
925
+ e.style.clipPath = `inset(${c}% ${h}% ${f}% ${m}%)`;
835
926
  }
836
- if (c) {
837
- const l = B(r);
838
- l && (e.style.filter = l);
927
+ if (l) {
928
+ const c = W(r);
929
+ c && (e.style.filter = c);
839
930
  }
840
931
  }
841
932
  /**
@@ -844,14 +935,14 @@ class Ae {
844
935
  buildCssTransformString(e, t = null) {
845
936
  const i = [];
846
937
  e.perspective !== void 0 && e.perspective > 0 && i.push(`perspective(${e.perspective}px)`);
847
- const o = e.motionPathX ?? e.x ?? e.translateX, s = e.motionPathY ?? e.y ?? e.translateY;
848
- e.z !== void 0 ? i.push(`translate3d(${o ?? 0}px, ${s ?? 0}px, ${e.z}px)`) : (o !== void 0 || s !== void 0) && i.push(`translate(${o ?? 0}px, ${s ?? 0}px)`);
938
+ const o = e.motionPathX ?? e.x ?? e.translateX, n = e.motionPathY ?? e.y ?? e.translateY;
939
+ e.z !== void 0 ? i.push(`translate3d(${o ?? 0}px, ${n ?? 0}px, ${e.z}px)`) : (o !== void 0 || n !== void 0) && i.push(`translate(${o ?? 0}px, ${n ?? 0}px)`);
849
940
  const a = e.motionPathRotate ?? e.rotate ?? e.rotateZ;
850
941
  if (a !== void 0 && i.push(`rotate(${a}deg)`), e.rotateX !== void 0 && i.push(`rotateX(${e.rotateX}deg)`), e.rotateY !== void 0 && i.push(`rotateY(${e.rotateY}deg)`), t && i.push(t), e.scale !== void 0)
851
942
  i.push(`scale(${e.scale})`);
852
943
  else if (e.scaleX !== void 0 || e.scaleY !== void 0) {
853
- const r = e.scaleX ?? 1, c = e.scaleY ?? 1;
854
- i.push(`scale(${r}, ${c})`);
944
+ const r = e.scaleX ?? 1, l = e.scaleY ?? 1;
945
+ i.push(`scale(${r}, ${l})`);
855
946
  }
856
947
  return e.skewX !== void 0 && i.push(`skewX(${e.skewX}deg)`), e.skewY !== void 0 && i.push(`skewY(${e.skewY}deg)`), i.join(" ");
857
948
  }
@@ -866,27 +957,27 @@ class Ae {
866
957
  applyShine(e, t) {
867
958
  const i = e.ownerSVGElement, o = e.ownerDocument;
868
959
  if (!i || !o) return;
869
- const s = e;
870
- s.dataset.shineBase || (s.dataset.shineBase = e.getAttribute("fill") || "#000000");
871
- const a = s.dataset.shineBase;
960
+ const n = e;
961
+ n.dataset.shineBase || (n.dataset.shineBase = e.getAttribute("fill") || "#000000");
962
+ const a = n.dataset.shineBase;
872
963
  let r = i.querySelector("defs");
873
- r || (r = o.createElementNS(S, "defs"), i.insertBefore(r, i.firstChild));
874
- let c = s.dataset.shineGrad, l = c ? r.querySelector(`#${c}`) : null;
875
- for (l || (c = `tinyfly-shine-${Math.random().toString(36).slice(2, 9)}`, s.dataset.shineGrad = c, l = o.createElementNS(S, "linearGradient"), l.setAttribute("id", c), r.appendChild(l)); l.firstChild; ) l.removeChild(l.firstChild);
876
- for (const h of D(t, a)) {
877
- const f = o.createElementNS(S, "stop");
878
- f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), l.appendChild(f);
964
+ r || (r = o.createElementNS(E, "defs"), i.insertBefore(r, i.firstChild));
965
+ let l = n.dataset.shineGrad, c = l ? r.querySelector(`#${l}`) : null;
966
+ for (c || (l = `tinyfly-shine-${Math.random().toString(36).slice(2, 9)}`, n.dataset.shineGrad = l, c = o.createElementNS(E, "linearGradient"), c.setAttribute("id", l), r.appendChild(c)); c.firstChild; ) c.removeChild(c.firstChild);
967
+ for (const h of H(t, a)) {
968
+ const f = o.createElementNS(E, "stop");
969
+ f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), c.appendChild(f);
879
970
  }
880
- e.setAttribute("fill", `url(#${c})`);
971
+ e.setAttribute("fill", `url(#${l})`);
881
972
  }
882
973
  applyAttribute(e, t, i) {
883
974
  let o = t;
884
- X[t] ? o = X[t] : he.has(t) && (o = t);
885
- const s = Array.isArray(i) ? i.join(" ") : String(i);
886
- e.setAttribute(o, s);
975
+ x[t] ? o = x[t] : Pe.has(t) && (o = t);
976
+ const n = Array.isArray(i) ? i.join(" ") : String(i);
977
+ e.setAttribute(o, n);
887
978
  }
888
979
  }
889
- const de = `
980
+ const Ae = `
890
981
  attribute vec2 a_position;
891
982
  attribute vec2 a_texCoord;
892
983
  uniform mat4 u_matrix;
@@ -896,7 +987,7 @@ void main() {
896
987
  gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
897
988
  v_texCoord = a_texCoord;
898
989
  }
899
- `, pe = `
990
+ `, ke = `
900
991
  precision mediump float;
901
992
  uniform vec4 u_color;
902
993
  uniform sampler2D u_texture;
@@ -907,7 +998,7 @@ void main() {
907
998
  vec4 color = u_useTexture ? texture2D(u_texture, v_texCoord) : u_color;
908
999
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
909
1000
  }
910
- `, me = /* @__PURE__ */ new Set([
1001
+ `, Ce = /* @__PURE__ */ new Set([
911
1002
  "x",
912
1003
  "y",
913
1004
  "width",
@@ -928,7 +1019,7 @@ void main() {
928
1019
  "motionPathY",
929
1020
  "motionPathRotate"
930
1021
  ]);
931
- class ge {
1022
+ class ze {
932
1023
  gl;
933
1024
  program;
934
1025
  positionBuffer;
@@ -939,7 +1030,7 @@ class ge {
939
1030
  basePositions = /* @__PURE__ */ new Map();
940
1031
  locations;
941
1032
  constructor(e) {
942
- this.gl = e, this.program = be(e, de, pe), this.locations = {
1033
+ this.gl = e, this.program = Xe(e, Ae, ke), this.locations = {
943
1034
  position: e.getAttribLocation(this.program, "a_position"),
944
1035
  texCoord: e.getAttribLocation(this.program, "a_texCoord"),
945
1036
  matrix: e.getUniformLocation(this.program, "u_matrix"),
@@ -947,7 +1038,7 @@ class ge {
947
1038
  texture: e.getUniformLocation(this.program, "u_texture"),
948
1039
  useTexture: e.getUniformLocation(this.program, "u_useTexture"),
949
1040
  opacity: e.getUniformLocation(this.program, "u_opacity")
950
- }, this.positionBuffer = _(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), this.texCoordBuffer = _(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]);
1041
+ }, this.positionBuffer = L(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), this.texCoordBuffer = L(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]);
951
1042
  }
952
1043
  registerTarget(e, t) {
953
1044
  this.targets.set(e, t), this.basePositions.set(e, { x: t.x, y: t.y });
@@ -968,9 +1059,9 @@ class ge {
968
1059
  for (const [t, i] of e.values) {
969
1060
  const o = this.targets.get(t);
970
1061
  if (!o) continue;
971
- const s = this.basePositions.get(t) ?? { x: 0, y: 0 };
1062
+ const n = this.basePositions.get(t) ?? { x: 0, y: 0 };
972
1063
  for (const [a, r] of i)
973
- this.applyProperty(o, s, a, r);
1064
+ this.applyProperty(o, n, a, r);
974
1065
  }
975
1066
  }
976
1067
  applyProperty(e, t, i, o) {
@@ -987,7 +1078,7 @@ class ge {
987
1078
  e.rotate = o;
988
1079
  return;
989
1080
  }
990
- if (me.has(i)) {
1081
+ if (Ce.has(i)) {
991
1082
  e[i] = o;
992
1083
  return;
993
1084
  }
@@ -997,61 +1088,61 @@ class ge {
997
1088
  /** Draw every registered target. */
998
1089
  render() {
999
1090
  const e = this.gl, { width: t, height: i } = e.canvas;
1000
- e.viewport(0, 0, t, i), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.enable(e.BLEND), e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA), e.useProgram(this.program), $(e, this.positionBuffer, this.locations.position), $(e, this.texCoordBuffer, this.locations.texCoord);
1001
- for (const [o, s] of this.targets)
1002
- this.drawTarget(o, s, t, i);
1091
+ e.viewport(0, 0, t, i), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.enable(e.BLEND), e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA), e.useProgram(this.program), F(e, this.positionBuffer, this.locations.position), F(e, this.texCoordBuffer, this.locations.texCoord);
1092
+ for (const [o, n] of this.targets)
1093
+ this.drawTarget(o, n, t, i);
1003
1094
  }
1004
1095
  drawTarget(e, t, i, o) {
1005
- const s = this.gl;
1006
- if (t.backfaceVisibility === "hidden" && O(G(t))) return;
1007
- const a = ye(t, i, o);
1008
- if (s.uniformMatrix4fv(this.locations.matrix, !1, a), s.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
1009
- s.bindTexture(s.TEXTURE_2D, this.textureFor(e, t.texture)), s.uniform1i(this.locations.useTexture, 1), s.uniform1i(this.locations.texture, 0);
1096
+ const n = this.gl;
1097
+ if (t.backfaceVisibility === "hidden" && G(V(t))) return;
1098
+ const a = Ee(t, i, o);
1099
+ if (n.uniformMatrix4fv(this.locations.matrix, !1, a), n.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
1100
+ n.bindTexture(n.TEXTURE_2D, this.textureFor(e, t.texture)), n.uniform1i(this.locations.useTexture, 1), n.uniform1i(this.locations.texture, 0);
1010
1101
  else {
1011
- s.uniform1i(this.locations.useTexture, 0);
1012
- const [r, c, l] = we(t.fill ?? "#ffffff");
1013
- s.uniform4f(this.locations.color, r, c, l, 1);
1102
+ n.uniform1i(this.locations.useTexture, 0);
1103
+ const [r, l, c] = Ie(t.fill ?? "#ffffff");
1104
+ n.uniform4f(this.locations.color, r, l, c, 1);
1014
1105
  }
1015
- s.drawArrays(s.TRIANGLES, 0, 6);
1106
+ n.drawArrays(n.TRIANGLES, 0, 6);
1016
1107
  }
1017
1108
  textureFor(e, t) {
1018
1109
  const i = this.textures.get(e);
1019
1110
  if (i) return i;
1020
- const o = this.gl, s = o.createTexture();
1021
- return o.bindTexture(o.TEXTURE_2D, s), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_WRAP_S, o.CLAMP_TO_EDGE), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_WRAP_T, o.CLAMP_TO_EDGE), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MIN_FILTER, o.LINEAR), o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, t), this.textures.set(e, s), s;
1111
+ const o = this.gl, n = o.createTexture();
1112
+ return o.bindTexture(o.TEXTURE_2D, n), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_WRAP_S, o.CLAMP_TO_EDGE), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_WRAP_T, o.CLAMP_TO_EDGE), o.texParameteri(o.TEXTURE_2D, o.TEXTURE_MIN_FILTER, o.LINEAR), o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, t), this.textures.set(e, n), n;
1022
1113
  }
1023
1114
  /** Release GL resources. */
1024
1115
  destroy() {
1025
1116
  this.clearTargets(), this.gl.deleteProgram(this.program), this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteBuffer(this.texCoordBuffer);
1026
1117
  }
1027
1118
  }
1028
- function ke(n, e, t) {
1029
- const i = (n.scale ?? n.scaleX ?? 1) * n.width, o = (n.scale ?? n.scaleY ?? 1) * n.height, s = (n.originX ?? 50) / 100, a = (n.originY ?? 50) / 100, r = (n.rotate ?? 0) * Math.PI / 180, c = Math.cos(r), l = Math.sin(r), h = -s, f = -a, m = c * i, u = l * i, p = -l * o, d = c * o, y = n.x + m * h + p * f, w = n.y + u * h + d * f, v = 2 / e, P = -2 / t;
1119
+ function qe(s, e, t) {
1120
+ const i = (s.scale ?? s.scaleX ?? 1) * s.width, o = (s.scale ?? s.scaleY ?? 1) * s.height, n = (s.originX ?? 50) / 100, a = (s.originY ?? 50) / 100, r = (s.rotate ?? 0) * Math.PI / 180, l = Math.cos(r), c = Math.sin(r), h = -n, f = -a, m = l * i, d = c * i, p = -c * o, u = l * o, y = s.x + m * h + p * f, w = s.y + d * h + u * f, v = 2 / e, M = -2 / t;
1030
1121
  return new Float32Array([
1031
1122
  m * v,
1032
- u * P,
1123
+ d * M,
1033
1124
  0,
1034
1125
  p * v,
1035
- d * P,
1126
+ u * M,
1036
1127
  0,
1037
1128
  y * v - 1,
1038
- w * P + 1,
1129
+ w * M + 1,
1039
1130
  1
1040
1131
  ]);
1041
1132
  }
1042
- function G(n) {
1043
- const e = (n.originX ?? 50) / 100, t = (n.originY ?? 50) / 100, i = { x: n.x, y: n.y }, o = b.multiply(
1044
- b.translation([n.x, n.y, 0]),
1045
- b.multiply(b.scaling([n.width, n.height, 1]), b.translation([-e, -t, 0]))
1133
+ function V(s) {
1134
+ const e = (s.originX ?? 50) / 100, t = (s.originY ?? 50) / 100, i = { x: s.x, y: s.y }, o = T.multiply(
1135
+ T.translation([s.x, s.y, 0]),
1136
+ T.multiply(T.scaling([s.width, s.height, 1]), T.translation([-e, -t, 0]))
1046
1137
  );
1047
- return b.multiply(Y(n, { x: 0, y: 0 }, i), o);
1138
+ return T.multiply(D(s, { x: 0, y: 0 }, i), o);
1048
1139
  }
1049
- function ye(n, e, t) {
1140
+ function Ee(s, e, t) {
1050
1141
  const i = [2 / e, 0, 0, 0, 0, -2 / t, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1];
1051
- return new Float32Array(b.multiply(i, G(n)));
1142
+ return new Float32Array(T.multiply(i, V(s)));
1052
1143
  }
1053
- function we(n) {
1054
- const e = n.trim().replace("#", "");
1144
+ function Ie(s) {
1145
+ const e = s.trim().replace("#", "");
1055
1146
  return e.length === 3 ? [
1056
1147
  Number.parseInt(e[0] + e[0], 16) / 255,
1057
1148
  Number.parseInt(e[1] + e[1], 16) / 255,
@@ -1062,61 +1153,69 @@ function we(n) {
1062
1153
  Number.parseInt(e.slice(4, 6), 16) / 255
1063
1154
  ] : [1, 1, 1];
1064
1155
  }
1065
- function be(n, e, t) {
1066
- const i = n.createProgram();
1156
+ function Xe(s, e, t) {
1157
+ const i = s.createProgram();
1067
1158
  if (!i) throw new Error("WebGLAdapter: could not create a program");
1068
- if (n.attachShader(i, I(n, n.VERTEX_SHADER, e)), n.attachShader(i, I(n, n.FRAGMENT_SHADER, t)), n.linkProgram(i), !n.getProgramParameter(i, n.LINK_STATUS))
1069
- throw new Error(`WebGLAdapter: program link failed — ${n.getProgramInfoLog(i)}`);
1159
+ if (s.attachShader(i, B(s, s.VERTEX_SHADER, e)), s.attachShader(i, B(s, s.FRAGMENT_SHADER, t)), s.linkProgram(i), !s.getProgramParameter(i, s.LINK_STATUS))
1160
+ throw new Error(`WebGLAdapter: program link failed — ${s.getProgramInfoLog(i)}`);
1070
1161
  return i;
1071
1162
  }
1072
- function I(n, e, t) {
1073
- const i = n.createShader(e);
1163
+ function B(s, e, t) {
1164
+ const i = s.createShader(e);
1074
1165
  if (!i) throw new Error("WebGLAdapter: could not create a shader");
1075
- if (n.shaderSource(i, t), n.compileShader(i), !n.getShaderParameter(i, n.COMPILE_STATUS))
1076
- throw new Error(`WebGLAdapter: shader compile failed — ${n.getShaderInfoLog(i)}`);
1166
+ if (s.shaderSource(i, t), s.compileShader(i), !s.getShaderParameter(i, s.COMPILE_STATUS))
1167
+ throw new Error(`WebGLAdapter: shader compile failed — ${s.getShaderInfoLog(i)}`);
1077
1168
  return i;
1078
1169
  }
1079
- function _(n, e) {
1080
- const t = n.createBuffer();
1170
+ function L(s, e) {
1171
+ const t = s.createBuffer();
1081
1172
  if (!t) throw new Error("WebGLAdapter: could not create a buffer");
1082
- return n.bindBuffer(n.ARRAY_BUFFER, t), n.bufferData(n.ARRAY_BUFFER, new Float32Array(e), n.STATIC_DRAW), t;
1173
+ return s.bindBuffer(s.ARRAY_BUFFER, t), s.bufferData(s.ARRAY_BUFFER, new Float32Array(e), s.STATIC_DRAW), t;
1083
1174
  }
1084
- function $(n, e, t) {
1085
- t < 0 || (n.bindBuffer(n.ARRAY_BUFFER, e), n.enableVertexAttribArray(t), n.vertexAttribPointer(t, 2, n.FLOAT, !1, 0, 0));
1175
+ function F(s, e, t) {
1176
+ t < 0 || (s.bindBuffer(s.ARRAY_BUFFER, e), s.enableVertexAttribArray(t), s.vertexAttribPointer(t, 2, s.FLOAT, !1, 0, 0));
1086
1177
  }
1087
1178
  export {
1088
- _e as CANVAS_PROPERTIES,
1089
- R as CanvasAdapter,
1090
- Xe as DOMAdapter,
1091
- $e as IDENTITY_CAMERA,
1092
- Ae as SVGAdapter,
1093
- ge as WebGLAdapter,
1094
- Ye as animatableProperties,
1095
- xe as applyBloom,
1096
- Oe as applyCamera,
1097
- Ne as boilFrame,
1098
- C as boxBlur,
1099
- re as brightPass,
1100
- se as buildFlipTracks,
1101
- Be as cameraFromValues,
1102
- Le as cameraPoint,
1103
- g as canvasLike,
1104
- Fe as checkTracks,
1105
- De as describeTarget,
1106
- M as drawOutline,
1107
- Re as drawTrail,
1108
- Me as flip,
1109
- Se as isGradient,
1110
- we as parseColor,
1111
- te as partialPath,
1112
- Ue as pathLength,
1113
- x as pathOutline,
1114
- We as pointAlong,
1115
- ke as quadMatrix,
1116
- ye as quadMatrix3d,
1117
- oe as recordFlipState,
1118
- ne as rectOutline,
1119
- Z as setTextContent,
1120
- ie as sketchPen,
1121
- le as trailQuads
1179
+ Ke as CANVAS_PROPERTIES,
1180
+ X as CanvasAdapter,
1181
+ Je as DOMAdapter,
1182
+ et as IDENTITY_CAMERA,
1183
+ Ve as SVGAdapter,
1184
+ ze as WebGLAdapter,
1185
+ tt as animatableProperties,
1186
+ Be as applyBloom,
1187
+ it as applyCamera,
1188
+ De as applyZoomBlur,
1189
+ lt as boilFrame,
1190
+ O as boxBlur,
1191
+ be as brightPass,
1192
+ ye as buildFlipTracks,
1193
+ ot as cameraFromValues,
1194
+ st as cameraPoint,
1195
+ S as canvasLike,
1196
+ nt as checkTracks,
1197
+ rt as describeTarget,
1198
+ Ge as drawDiveLines,
1199
+ We as drawIsometricFaces,
1200
+ Ne as drawLetterbox,
1201
+ C as drawOutline,
1202
+ Ue as drawSafeAreas,
1203
+ Le as drawTrail,
1204
+ He as drawTransition,
1205
+ Oe as flip,
1206
+ xe as isGradient,
1207
+ Fe as nestedZoom,
1208
+ Se as nestedZoomTransform,
1209
+ Ie as parseColor,
1210
+ ue as partialPath,
1211
+ ct as pathLength,
1212
+ I as pathOutline,
1213
+ ht as pointAlong,
1214
+ qe as quadMatrix,
1215
+ Ee as quadMatrix3d,
1216
+ me as recordFlipState,
1217
+ we as rectOutline,
1218
+ ie as setTextContent,
1219
+ pe as sketchPen,
1220
+ ve as trailQuads
1122
1221
  };