@algorisys/tinyfly 0.99.0 → 0.101.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 (77) hide show
  1. package/README.md +9 -9
  2. package/bin/tinyfly.mjs +7 -3
  3. package/docs/acting.md +10 -6
  4. package/docs/character-appearance.md +71 -7
  5. package/docs/editor-guide.md +38 -3
  6. package/docs/examples.md +1 -1
  7. package/docs/getting-started.md +1 -1
  8. package/docs/gsap-compat.md +1 -1
  9. package/docs/llm-guide.md +34 -9
  10. package/docs/maps.md +2 -2
  11. package/docs/props.md +61 -1
  12. package/docs/scene-3d.md +23 -4
  13. package/docs/teaching.md +1 -1
  14. package/docs/video-rendering.md +154 -0
  15. package/lib/addons/adapters.js +387 -333
  16. package/lib/addons/characters.js +4795 -3752
  17. package/lib/addons/load-scene-oWNsYYC1.js +372 -0
  18. package/lib/addons/scene-3d-webgl.js +1 -1
  19. package/lib/addons/scene-3d.js +323 -277
  20. package/lib/addons/shading-0lPgnXmD.js +96 -0
  21. package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
  22. package/lib/browser/tinyfly.iife.js +14 -14
  23. package/lib/browser/tinyfly.js +7294 -5893
  24. package/lib/browser/tinyfly.umd.js +14 -14
  25. package/lib/engine/tinyfly-engine.js +1389 -1031
  26. package/lib/engine/tinyfly-engine.umd.cjs +2 -2
  27. package/lib/headless/headless.js +39 -0
  28. package/lib/types/adapters/canvas/impossible.d.ts +15 -0
  29. package/lib/types/adapters/canvas/index.d.ts +3 -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/acting/character-script.d.ts +14 -2
  33. package/lib/types/characters/acting/script.d.ts +9 -0
  34. package/lib/types/characters/capabilities.d.ts +2 -0
  35. package/lib/types/characters/character.d.ts +28 -1
  36. package/lib/types/characters/hair-follow.d.ts +12 -6
  37. package/lib/types/characters/hands/held-items.d.ts +6 -2
  38. package/lib/types/characters/head/face.d.ts +23 -1
  39. package/lib/types/characters/index.d.ts +3 -2
  40. package/lib/types/characters/interactions.d.ts +60 -0
  41. package/lib/types/characters/props/families/animals.d.ts +6 -0
  42. package/lib/types/characters/props/families/birds.d.ts +16 -0
  43. package/lib/types/characters/props/families/furniture.d.ts +102 -0
  44. package/lib/types/characters/props/index.d.ts +1 -0
  45. package/lib/types/characters/props/presets.d.ts +15 -2
  46. package/lib/types/characters/props/ride-3d.d.ts +4 -1
  47. package/lib/types/characters/scenery.d.ts +126 -0
  48. package/lib/types/characters/species/human-motion.d.ts +17 -0
  49. package/lib/types/characters/species/human.d.ts +6 -0
  50. package/lib/types/characters/wardrobe/basic-outfit.d.ts +16 -5
  51. package/lib/types/engine/authoring/beat-loop.d.ts +46 -0
  52. package/lib/types/engine/authoring/curve.d.ts +26 -0
  53. package/lib/types/engine/authoring/index.d.ts +3 -0
  54. package/lib/types/engine/authoring/periodic.d.ts +89 -0
  55. package/lib/types/engine/path/goo.d.ts +103 -0
  56. package/lib/types/engine/path/impossible.d.ts +92 -0
  57. package/lib/types/engine/path/index.d.ts +6 -0
  58. package/lib/types/engine/path/similarity.d.ts +48 -0
  59. package/lib/types/headless/index.d.ts +1 -0
  60. package/lib/types/headless/loop-audio.d.ts +21 -0
  61. package/lib/types/headless/node-audio.d.ts +20 -0
  62. package/lib/types/headless/video-scene.d.ts +9 -0
  63. package/lib/types/scene-3d/camera.d.ts +11 -2
  64. package/lib/types/scene-3d/geometry/mesh.d.ts +2 -0
  65. package/lib/types/scene-3d/geometry/primitives.d.ts +7 -0
  66. package/lib/types/scene-3d/impossible-3d.d.ts +29 -0
  67. package/lib/types/scene-3d/index.d.ts +4 -3
  68. package/lib/types/scene-3d/resolve-scene.d.ts +13 -1
  69. package/lib/types/scene-3d/scene-3d-adapter.d.ts +2 -0
  70. package/lib/types/scene-3d/scene-types.d.ts +29 -4
  71. package/lib/types/scene-3d/shading.d.ts +2 -0
  72. package/llms-full.txt +423 -47
  73. package/llms.txt +29 -29
  74. package/package.json +2 -2
  75. package/skills/tinyfly/SKILL.md +20 -6
  76. package/lib/addons/load-scene-CQvcFWGJ.js +0 -331
  77. 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 Ve } from "./dom-adapter-Cphr2HZn.js";
3
+ import { C as qe, I as Ze, a as je, b as Je, c as Qe, d as Ke, e as et, f as tt } 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, mat4 as v } from "@algorisys/tinyfly";
5
+ import { p as fe, s as de } from "./sketch-CYPUbk3Q.js";
6
+ import { c as ot, a as st, b as nt } from "./sketch-CYPUbk3Q.js";
7
+ function ue(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 pe(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
+ A(`${a}-${l}-x`, l, "x", m, 0, i, o),
21
+ A(`${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(A(`${a}-${l}-sx`, l, "scaleX", p, 1, i, o)), u !== 1 && r.push(A(`${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 _e(s, e, t = {}) {
30
+ const i = ue(s);
31
+ return e(), pe(i, s, t);
32
32
  }
33
- function T(n, e, t, i, o, s, a) {
34
- return Q({
35
- id: n,
33
+ function A(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 x(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;
83
+ function me(s, e, t, i, o = 0) {
84
+ const n = Math.max(0, Math.min(o, t / 2, i / 2));
85
+ if (n === 0) return x(`M${s},${e} H${s + t} V${e + i} H${s} Z`);
86
+ const a = s + t, r = e + i;
87
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`
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 = fe(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 k(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 $e(s) {
122
+ return typeof s == "object" && s !== null && "type" in s;
123
123
  }
124
- class R {
124
+ class I {
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 (I.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 = I.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 = k(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 ? de(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, me(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, x(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,158 @@ 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 ye(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 $(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 Y(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 = $(n, e, t, o, !0), n = $(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 Ye(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 = k(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 = ye(c.getImageData(0, 0, a, r).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, o) * 0.02) / n, m = Y(h, a, r, f), d = Y(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 Oe(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 = be(e, i, o, n, a);
672
+ r ? (s.globalCompositeOperation = "lighter", X(s, c, t.color)) : ve(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, we(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 we(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 be(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 X(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 ve(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 ? k(s, Math.ceil(c) + 1 - f, Math.ceil(h) + 1 - m) : null, p = d?.getContext("2d");
720
+ if (!d || !p) {
721
+ X(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", X(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 Te(s, e, t) {
727
+ return le(s, e - t);
728
+ }
729
+ function Be(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 = Te(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 Le(s, e = {}) {
745
+ const t = s.canvas, i = t.width, o = t.height;
746
+ if (!(i > 0 && o > 0)) return;
747
+ const n = k(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 Fe(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, T = f.next(), M = 0.6 + f.next() * 0.8, z = ((T + d * m) % 1 + 1) % 1, b = a + z * l, S = b + c * M, P = Math.cos(w), g = Math.sin(w), R = s.createLinearGradient(i + P * b, o + g * b, i + P * S, o + g * S);
764
+ R.addColorStop(0, "rgba(0,0,0,0)"), R.addColorStop(0.5, e.color ?? "#ffffff"), R.addColorStop(1, "rgba(0,0,0,0)"), s.strokeStyle = R, 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 + P * b, o + g * b), s.lineTo(i + P * Math.min(S, r + c), o + g * Math.min(S, r + c)), s.stroke();
765
+ }
766
+ s.restore();
767
+ }
768
+ function De(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
+ const E = "http://www.w3.org/2000/svg", Me = /* @__PURE__ */ new Set([
727
776
  "fill",
728
777
  "stroke",
729
778
  "d",
@@ -743,7 +792,7 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
743
792
  "height",
744
793
  "viewBox",
745
794
  "preserveAspectRatio"
746
- ]), X = {
795
+ ]), O = {
747
796
  strokeWidth: "stroke-width",
748
797
  strokeLinecap: "stroke-linecap",
749
798
  strokeLinejoin: "stroke-linejoin",
@@ -754,7 +803,7 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
754
803
  strokeOpacity: "stroke-opacity",
755
804
  borderRadius: "rx"
756
805
  // Map CSS borderRadius to SVG rx
757
- }, fe = /* @__PURE__ */ new Set([
806
+ }, Se = /* @__PURE__ */ new Set([
758
807
  "x",
759
808
  // Position x treated as translateX
760
809
  "y",
@@ -775,8 +824,8 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
775
824
  "motionPathX",
776
825
  "motionPathY",
777
826
  "motionPathRotate"
778
- ]), ue = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
779
- class Ae {
827
+ ]), Pe = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
828
+ class Ge {
780
829
  targets = /* @__PURE__ */ new Map();
781
830
  /**
782
831
  * Register an SVG element as an animation target.
@@ -817,25 +866,25 @@ class Ae {
817
866
  applyProperties(e, t) {
818
867
  const i = {};
819
868
  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));
869
+ const n = {}, a = {}, r = {};
870
+ let l = !1;
871
+ for (const [c, h] of t)
872
+ c !== "drawOn" && (Se.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) : Pe.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
873
  if (Object.keys(i).length > 0 || o) {
825
- const l = this.buildCssTransformString(i, o);
826
- e.style.transform = l, J(e);
874
+ const c = this.buildCssTransformString(i, o);
875
+ e.style.transform = c, oe(e);
827
876
  }
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}%`;
877
+ if (Object.keys(n).length > 0) {
878
+ const c = e.style;
879
+ c.transformBox = "fill-box", c.transformOrigin = `${n.originX ?? 50}% ${n.originY ?? 50}%`;
831
880
  }
832
881
  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}%)`;
882
+ const c = a.clipTop ?? 0, h = a.clipRight ?? 0, f = a.clipBottom ?? 0, m = a.clipLeft ?? 0;
883
+ e.style.clipPath = `inset(${c}% ${h}% ${f}% ${m}%)`;
835
884
  }
836
- if (c) {
837
- const l = B(r);
838
- l && (e.style.filter = l);
885
+ if (l) {
886
+ const c = W(r);
887
+ c && (e.style.filter = c);
839
888
  }
840
889
  }
841
890
  /**
@@ -844,14 +893,14 @@ class Ae {
844
893
  buildCssTransformString(e, t = null) {
845
894
  const i = [];
846
895
  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)`);
896
+ const o = e.motionPathX ?? e.x ?? e.translateX, n = e.motionPathY ?? e.y ?? e.translateY;
897
+ 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
898
  const a = e.motionPathRotate ?? e.rotate ?? e.rotateZ;
850
899
  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
900
  i.push(`scale(${e.scale})`);
852
901
  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})`);
902
+ const r = e.scaleX ?? 1, l = e.scaleY ?? 1;
903
+ i.push(`scale(${r}, ${l})`);
855
904
  }
856
905
  return e.skewX !== void 0 && i.push(`skewX(${e.skewX}deg)`), e.skewY !== void 0 && i.push(`skewY(${e.skewY}deg)`), i.join(" ");
857
906
  }
@@ -866,27 +915,27 @@ class Ae {
866
915
  applyShine(e, t) {
867
916
  const i = e.ownerSVGElement, o = e.ownerDocument;
868
917
  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;
918
+ const n = e;
919
+ n.dataset.shineBase || (n.dataset.shineBase = e.getAttribute("fill") || "#000000");
920
+ const a = n.dataset.shineBase;
872
921
  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);
922
+ r || (r = o.createElementNS(E, "defs"), i.insertBefore(r, i.firstChild));
923
+ let l = n.dataset.shineGrad, c = l ? r.querySelector(`#${l}`) : null;
924
+ 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);
925
+ for (const h of H(t, a)) {
926
+ const f = o.createElementNS(E, "stop");
927
+ f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), c.appendChild(f);
879
928
  }
880
- e.setAttribute("fill", `url(#${c})`);
929
+ e.setAttribute("fill", `url(#${l})`);
881
930
  }
882
931
  applyAttribute(e, t, i) {
883
932
  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);
933
+ O[t] ? o = O[t] : Me.has(t) && (o = t);
934
+ const n = Array.isArray(i) ? i.join(" ") : String(i);
935
+ e.setAttribute(o, n);
887
936
  }
888
937
  }
889
- const de = `
938
+ const ge = `
890
939
  attribute vec2 a_position;
891
940
  attribute vec2 a_texCoord;
892
941
  uniform mat4 u_matrix;
@@ -896,7 +945,7 @@ void main() {
896
945
  gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
897
946
  v_texCoord = a_texCoord;
898
947
  }
899
- `, pe = `
948
+ `, Re = `
900
949
  precision mediump float;
901
950
  uniform vec4 u_color;
902
951
  uniform sampler2D u_texture;
@@ -907,7 +956,7 @@ void main() {
907
956
  vec4 color = u_useTexture ? texture2D(u_texture, v_texCoord) : u_color;
908
957
  gl_FragColor = vec4(color.rgb, color.a * u_opacity);
909
958
  }
910
- `, me = /* @__PURE__ */ new Set([
959
+ `, Ae = /* @__PURE__ */ new Set([
911
960
  "x",
912
961
  "y",
913
962
  "width",
@@ -928,7 +977,7 @@ void main() {
928
977
  "motionPathY",
929
978
  "motionPathRotate"
930
979
  ]);
931
- class ge {
980
+ class We {
932
981
  gl;
933
982
  program;
934
983
  positionBuffer;
@@ -939,7 +988,7 @@ class ge {
939
988
  basePositions = /* @__PURE__ */ new Map();
940
989
  locations;
941
990
  constructor(e) {
942
- this.gl = e, this.program = be(e, de, pe), this.locations = {
991
+ this.gl = e, this.program = Ee(e, ge, Re), this.locations = {
943
992
  position: e.getAttribLocation(this.program, "a_position"),
944
993
  texCoord: e.getAttribLocation(this.program, "a_texCoord"),
945
994
  matrix: e.getUniformLocation(this.program, "u_matrix"),
@@ -947,7 +996,7 @@ class ge {
947
996
  texture: e.getUniformLocation(this.program, "u_texture"),
948
997
  useTexture: e.getUniformLocation(this.program, "u_useTexture"),
949
998
  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]);
999
+ }, 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
1000
  }
952
1001
  registerTarget(e, t) {
953
1002
  this.targets.set(e, t), this.basePositions.set(e, { x: t.x, y: t.y });
@@ -968,9 +1017,9 @@ class ge {
968
1017
  for (const [t, i] of e.values) {
969
1018
  const o = this.targets.get(t);
970
1019
  if (!o) continue;
971
- const s = this.basePositions.get(t) ?? { x: 0, y: 0 };
1020
+ const n = this.basePositions.get(t) ?? { x: 0, y: 0 };
972
1021
  for (const [a, r] of i)
973
- this.applyProperty(o, s, a, r);
1022
+ this.applyProperty(o, n, a, r);
974
1023
  }
975
1024
  }
976
1025
  applyProperty(e, t, i, o) {
@@ -987,7 +1036,7 @@ class ge {
987
1036
  e.rotate = o;
988
1037
  return;
989
1038
  }
990
- if (me.has(i)) {
1039
+ if (Ae.has(i)) {
991
1040
  e[i] = o;
992
1041
  return;
993
1042
  }
@@ -997,61 +1046,61 @@ class ge {
997
1046
  /** Draw every registered target. */
998
1047
  render() {
999
1048
  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);
1049
+ 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);
1050
+ for (const [o, n] of this.targets)
1051
+ this.drawTarget(o, n, t, i);
1003
1052
  }
1004
1053
  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);
1054
+ const n = this.gl;
1055
+ if (t.backfaceVisibility === "hidden" && G(V(t))) return;
1056
+ const a = ke(t, i, o);
1057
+ if (n.uniformMatrix4fv(this.locations.matrix, !1, a), n.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
1058
+ n.bindTexture(n.TEXTURE_2D, this.textureFor(e, t.texture)), n.uniform1i(this.locations.useTexture, 1), n.uniform1i(this.locations.texture, 0);
1010
1059
  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);
1060
+ n.uniform1i(this.locations.useTexture, 0);
1061
+ const [r, l, c] = Ce(t.fill ?? "#ffffff");
1062
+ n.uniform4f(this.locations.color, r, l, c, 1);
1014
1063
  }
1015
- s.drawArrays(s.TRIANGLES, 0, 6);
1064
+ n.drawArrays(n.TRIANGLES, 0, 6);
1016
1065
  }
1017
1066
  textureFor(e, t) {
1018
1067
  const i = this.textures.get(e);
1019
1068
  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;
1069
+ const o = this.gl, n = o.createTexture();
1070
+ 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
1071
  }
1023
1072
  /** Release GL resources. */
1024
1073
  destroy() {
1025
1074
  this.clearTargets(), this.gl.deleteProgram(this.program), this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteBuffer(this.texCoordBuffer);
1026
1075
  }
1027
1076
  }
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;
1077
+ function Ne(s, e, t) {
1078
+ 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, T = 2 / e, M = -2 / t;
1030
1079
  return new Float32Array([
1031
- m * v,
1032
- u * P,
1080
+ m * T,
1081
+ d * M,
1033
1082
  0,
1034
- p * v,
1035
- d * P,
1083
+ p * T,
1084
+ u * M,
1036
1085
  0,
1037
- y * v - 1,
1038
- w * P + 1,
1086
+ y * T - 1,
1087
+ w * M + 1,
1039
1088
  1
1040
1089
  ]);
1041
1090
  }
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]))
1091
+ function V(s) {
1092
+ const e = (s.originX ?? 50) / 100, t = (s.originY ?? 50) / 100, i = { x: s.x, y: s.y }, o = v.multiply(
1093
+ v.translation([s.x, s.y, 0]),
1094
+ v.multiply(v.scaling([s.width, s.height, 1]), v.translation([-e, -t, 0]))
1046
1095
  );
1047
- return b.multiply(Y(n, { x: 0, y: 0 }, i), o);
1096
+ return v.multiply(D(s, { x: 0, y: 0 }, i), o);
1048
1097
  }
1049
- function ye(n, e, t) {
1098
+ function ke(s, e, t) {
1050
1099
  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)));
1100
+ return new Float32Array(v.multiply(i, V(s)));
1052
1101
  }
1053
- function we(n) {
1054
- const e = n.trim().replace("#", "");
1102
+ function Ce(s) {
1103
+ const e = s.trim().replace("#", "");
1055
1104
  return e.length === 3 ? [
1056
1105
  Number.parseInt(e[0] + e[0], 16) / 255,
1057
1106
  Number.parseInt(e[1] + e[1], 16) / 255,
@@ -1062,61 +1111,66 @@ function we(n) {
1062
1111
  Number.parseInt(e.slice(4, 6), 16) / 255
1063
1112
  ] : [1, 1, 1];
1064
1113
  }
1065
- function be(n, e, t) {
1066
- const i = n.createProgram();
1114
+ function Ee(s, e, t) {
1115
+ const i = s.createProgram();
1067
1116
  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)}`);
1117
+ 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))
1118
+ throw new Error(`WebGLAdapter: program link failed — ${s.getProgramInfoLog(i)}`);
1070
1119
  return i;
1071
1120
  }
1072
- function I(n, e, t) {
1073
- const i = n.createShader(e);
1121
+ function B(s, e, t) {
1122
+ const i = s.createShader(e);
1074
1123
  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)}`);
1124
+ if (s.shaderSource(i, t), s.compileShader(i), !s.getShaderParameter(i, s.COMPILE_STATUS))
1125
+ throw new Error(`WebGLAdapter: shader compile failed — ${s.getShaderInfoLog(i)}`);
1077
1126
  return i;
1078
1127
  }
1079
- function _(n, e) {
1080
- const t = n.createBuffer();
1128
+ function L(s, e) {
1129
+ const t = s.createBuffer();
1081
1130
  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;
1131
+ return s.bindBuffer(s.ARRAY_BUFFER, t), s.bufferData(s.ARRAY_BUFFER, new Float32Array(e), s.STATIC_DRAW), t;
1083
1132
  }
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));
1133
+ function F(s, e, t) {
1134
+ t < 0 || (s.bindBuffer(s.ARRAY_BUFFER, e), s.enableVertexAttribArray(t), s.vertexAttribPointer(t, 2, s.FLOAT, !1, 0, 0));
1086
1135
  }
1087
1136
  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,
1137
+ qe as CANVAS_PROPERTIES,
1138
+ I as CanvasAdapter,
1139
+ Ve as DOMAdapter,
1140
+ Ze as IDENTITY_CAMERA,
1141
+ Ge as SVGAdapter,
1142
+ We as WebGLAdapter,
1143
+ je as animatableProperties,
1144
+ Ye as applyBloom,
1145
+ Je as applyCamera,
1146
+ Le as applyZoomBlur,
1147
+ ot as boilFrame,
1148
+ Y as boxBlur,
1149
+ ye as brightPass,
1150
+ pe as buildFlipTracks,
1151
+ Qe as cameraFromValues,
1152
+ Ke as cameraPoint,
1153
+ k as canvasLike,
1154
+ et as checkTracks,
1155
+ tt as describeTarget,
1156
+ Fe as drawDiveLines,
1157
+ De as drawIsometricFaces,
1158
+ C as drawOutline,
1159
+ Oe as drawTrail,
1160
+ _e as flip,
1161
+ $e as isGradient,
1162
+ Be as nestedZoom,
1163
+ Te as nestedZoomTransform,
1164
+ Ce as parseColor,
1165
+ fe as partialPath,
1166
+ st as pathLength,
1113
1167
  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
1168
+ nt as pointAlong,
1169
+ Ne as quadMatrix,
1170
+ ke as quadMatrix3d,
1171
+ ue as recordFlipState,
1172
+ me as rectOutline,
1173
+ ie as setTextContent,
1174
+ de as sketchPen,
1175
+ be as trailQuads
1122
1176
  };