@snowcone-app/canvas 0.29.0 → 0.30.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 (72) hide show
  1. package/ERROR_CONTRACT.md +13 -0
  2. package/dist/{CanvasRenderer-_lFoIoz5.js → CanvasRenderer-BEf0hXeF.js} +4 -4
  3. package/dist/{CanvasRenderer-_lFoIoz5.js.map → CanvasRenderer-BEf0hXeF.js.map} +1 -1
  4. package/dist/{CanvasStateV1-BMxr6xb8.js → CanvasStateV1-BDSyYo4A.js} +868 -843
  5. package/dist/{CanvasStateV1-BMxr6xb8.js.map → CanvasStateV1-BDSyYo4A.js.map} +1 -1
  6. package/dist/ContextualToolbars-C3D_6sep.js +5960 -0
  7. package/dist/ContextualToolbars-C3D_6sep.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-BNz8TPFs.js → EditorCanvasImpl-DXeBz2CX.js} +8 -8
  9. package/dist/{EditorCanvasImpl-BNz8TPFs.js.map → EditorCanvasImpl-DXeBz2CX.js.map} +1 -1
  10. package/dist/{ExportManager-B8Td7uR5.js → ExportManager-DUdis6se.js} +794 -536
  11. package/dist/ExportManager-DUdis6se.js.map +1 -0
  12. package/dist/{FontAnalyzer-D4Sg-P6_.js → FontAnalyzer-DKG5JK0x.js} +823 -808
  13. package/dist/FontAnalyzer-DKG5JK0x.js.map +1 -0
  14. package/dist/{ImagePanel-CN2Bu3hf.js → ImagePanel-CBgGqmVV.js} +53 -53
  15. package/dist/{ImagePanel-CN2Bu3hf.js.map → ImagePanel-CBgGqmVV.js.map} +1 -1
  16. package/dist/SnowconeCanvas-BWPBngvI.js +1192 -0
  17. package/dist/SnowconeCanvas-BWPBngvI.js.map +1 -0
  18. package/dist/{UnifiedFontService-CgYnYTj7.js → UnifiedFontService-Co9tQ59z.js} +869 -826
  19. package/dist/UnifiedFontService-Co9tQ59z.js.map +1 -0
  20. package/dist/advanced.mjs +14 -14
  21. package/dist/api/embed.d.ts +2 -0
  22. package/dist/api/stable.d.ts +2 -0
  23. package/dist/components/CanvasContextMenu.d.ts +15 -0
  24. package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +27 -0
  25. package/dist/components/CanvasEditor.d.ts +8 -0
  26. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  27. package/dist/components/embed/kernel.d.ts +8 -0
  28. package/dist/components/ui/icons.d.ts +2 -0
  29. package/dist/contexts/CanvasServicesContext.d.ts +17 -0
  30. package/dist/contexts/EditorContext.d.ts +7 -0
  31. package/dist/{custom-icons-B5TRC1Ed.js → custom-icons-BIaRovwG.js} +2 -2
  32. package/dist/{custom-icons-B5TRC1Ed.js.map → custom-icons-BIaRovwG.js.map} +1 -1
  33. package/dist/{design-builder-COj0zkxu.js → design-builder-JYLO_Hyi.js} +2 -2
  34. package/dist/{design-builder-COj0zkxu.js.map → design-builder-JYLO_Hyi.js.map} +1 -1
  35. package/dist/{editorErrors-CCvoKj_P.js → editorErrors-WzaNxU1Y.js} +181 -194
  36. package/dist/editorErrors-WzaNxU1Y.js.map +1 -0
  37. package/dist/{embed-BTRtoktw.js → embed-Csez1hui.js} +113 -112
  38. package/dist/{embed-BTRtoktw.js.map → embed-Csez1hui.js.map} +1 -1
  39. package/dist/embed.mjs +51 -45
  40. package/dist/embed.mjs.map +1 -1
  41. package/dist/errors/editorError.d.ts +8 -0
  42. package/dist/{guards-uQtEQJbs.js → guards-BSoX73yg.js} +2 -2
  43. package/dist/{guards-uQtEQJbs.js.map → guards-BSoX73yg.js.map} +1 -1
  44. package/dist/hooks/useKeyboardShortcuts.d.ts +15 -2
  45. package/dist/hooks/useLayers.d.ts +2 -0
  46. package/dist/index.mjs +42 -37
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/internals.mjs +47 -47
  49. package/dist/state/CanvasStateV1.d.ts +31 -3
  50. package/dist/state/index.d.ts +2 -2
  51. package/dist/{template-fields-BLRp84Ny.js → template-fields-DYPW7bVU.js} +40 -40
  52. package/dist/{template-fields-BLRp84Ny.js.map → template-fields-DYPW7bVU.js.map} +1 -1
  53. package/dist/testing.mjs +13 -13
  54. package/dist/{usePieceGuideBundle-CTQszfKA.js → usePieceGuideBundle-CRLY2iQa.js} +2 -2
  55. package/dist/{usePieceGuideBundle-CTQszfKA.js.map → usePieceGuideBundle-CRLY2iQa.js.map} +1 -1
  56. package/dist/utils/custom-fonts.d.ts +99 -0
  57. package/dist/validation-BGEl9rrE.js +8686 -0
  58. package/dist/validation-BGEl9rrE.js.map +1 -0
  59. package/dist/workers/export-protocol.d.ts +13 -0
  60. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  61. package/example/package.json +1 -1
  62. package/package.json +1 -1
  63. package/dist/ContextualToolbars-0jWvnQgp.js +0 -5833
  64. package/dist/ContextualToolbars-0jWvnQgp.js.map +0 -1
  65. package/dist/ExportManager-B8Td7uR5.js.map +0 -1
  66. package/dist/FontAnalyzer-D4Sg-P6_.js.map +0 -1
  67. package/dist/SnowconeCanvas-CR_LdRFP.js +0 -1173
  68. package/dist/SnowconeCanvas-CR_LdRFP.js.map +0 -1
  69. package/dist/UnifiedFontService-CgYnYTj7.js.map +0 -1
  70. package/dist/editorErrors-CCvoKj_P.js.map +0 -1
  71. package/dist/validation-eCebhplp.js +0 -8402
  72. package/dist/validation-eCebhplp.js.map +0 -1
@@ -1,29 +1,29 @@
1
- function se(r) {
1
+ function oe(r) {
2
2
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
3
3
  }
4
- var Ht = { exports: {} }, O = Ht.exports = {}, X, Y;
5
- function xt() {
4
+ var Ht = { exports: {} }, O = Ht.exports = {}, X, _;
5
+ function St() {
6
6
  throw new Error("setTimeout has not been defined");
7
7
  }
8
- function St() {
8
+ function Ct() {
9
9
  throw new Error("clearTimeout has not been defined");
10
10
  }
11
11
  (function() {
12
12
  try {
13
- typeof setTimeout == "function" ? X = setTimeout : X = xt;
13
+ typeof setTimeout == "function" ? X = setTimeout : X = St;
14
14
  } catch {
15
- X = xt;
15
+ X = St;
16
16
  }
17
17
  try {
18
- typeof clearTimeout == "function" ? Y = clearTimeout : Y = St;
18
+ typeof clearTimeout == "function" ? _ = clearTimeout : _ = Ct;
19
19
  } catch {
20
- Y = St;
20
+ _ = Ct;
21
21
  }
22
22
  })();
23
23
  function Pt(r) {
24
24
  if (X === setTimeout)
25
25
  return setTimeout(r, 0);
26
- if ((X === xt || !X) && setTimeout)
26
+ if ((X === St || !X) && setTimeout)
27
27
  return X = setTimeout, setTimeout(r, 0);
28
28
  try {
29
29
  return X(r, 0);
@@ -35,35 +35,35 @@ function Pt(r) {
35
35
  }
36
36
  }
37
37
  }
38
- function oe(r) {
39
- if (Y === clearTimeout)
38
+ function se(r) {
39
+ if (_ === clearTimeout)
40
40
  return clearTimeout(r);
41
- if ((Y === St || !Y) && clearTimeout)
42
- return Y = clearTimeout, clearTimeout(r);
41
+ if ((_ === Ct || !_) && clearTimeout)
42
+ return _ = clearTimeout, clearTimeout(r);
43
43
  try {
44
- return Y(r);
44
+ return _(r);
45
45
  } catch {
46
46
  try {
47
- return Y.call(null, r);
47
+ return _.call(null, r);
48
48
  } catch {
49
- return Y.call(this, r);
49
+ return _.call(this, r);
50
50
  }
51
51
  }
52
52
  }
53
- var _ = [], K = !1, V, dt = -1;
53
+ var Y = [], K = !1, V, dt = -1;
54
54
  function re() {
55
- !K || !V || (K = !1, V.length ? _ = V.concat(_) : dt = -1, _.length && Lt());
55
+ !K || !V || (K = !1, V.length ? Y = V.concat(Y) : dt = -1, Y.length && Lt());
56
56
  }
57
57
  function Lt() {
58
58
  if (!K) {
59
59
  var r = Pt(re);
60
60
  K = !0;
61
- for (var t = _.length; t; ) {
62
- for (V = _, _ = []; ++dt < t; )
61
+ for (var t = Y.length; t; ) {
62
+ for (V = Y, Y = []; ++dt < t; )
63
63
  V && V[dt].run();
64
- dt = -1, t = _.length;
64
+ dt = -1, t = Y.length;
65
65
  }
66
- V = null, K = !1, oe(r);
66
+ V = null, K = !1, se(r);
67
67
  }
68
68
  }
69
69
  O.nextTick = function(r) {
@@ -71,7 +71,7 @@ O.nextTick = function(r) {
71
71
  if (arguments.length > 1)
72
72
  for (var e = 1; e < arguments.length; e++)
73
73
  t[e - 1] = arguments[e];
74
- _.push(new Wt(r, t)), _.length === 1 && !K && Pt(Lt);
74
+ Y.push(new Wt(r, t)), Y.length === 1 && !K && Pt(Lt);
75
75
  };
76
76
  function Wt(r, t) {
77
77
  this.fun = r, this.array = t;
@@ -112,7 +112,7 @@ O.umask = function() {
112
112
  return 0;
113
113
  };
114
114
  var ne = Ht.exports;
115
- const It = /* @__PURE__ */ se(ne);
115
+ const ft = /* @__PURE__ */ oe(ne);
116
116
  let kt = 1;
117
117
  class nt {
118
118
  constructor(t = {}) {
@@ -192,7 +192,7 @@ class nt {
192
192
  * Returns true if point is near the border (within tolerance)
193
193
  */
194
194
  hitTestBorder(t, e, i = 5) {
195
- const s = t >= this.x - i && t <= this.x + this.width + i, o = e >= this.y - i && e <= this.y + this.height + i, a = Math.abs(t - this.x) <= i && o, n = Math.abs(t - (this.x + this.width)) <= i && o, h = Math.abs(e - this.y) <= i && s, l = Math.abs(e - (this.y + this.height)) <= i && s;
195
+ const o = t >= this.x - i && t <= this.x + this.width + i, s = e >= this.y - i && e <= this.y + this.height + i, a = Math.abs(t - this.x) <= i && s, n = Math.abs(t - (this.x + this.width)) <= i && s, h = Math.abs(e - this.y) <= i && o, l = Math.abs(e - (this.y + this.height)) <= i && o;
196
196
  return a || n || h || l;
197
197
  }
198
198
  /**
@@ -302,11 +302,11 @@ class ti {
302
302
  if (!e)
303
303
  return [];
304
304
  const i = e.getElementIds();
305
- if (i.forEach((s) => {
306
- this.elementToArtboard.delete(s);
305
+ if (i.forEach((o) => {
306
+ this.elementToArtboard.delete(o);
307
307
  }), this.artboards.delete(t), this.activeArtboardId === t) {
308
- const s = Array.from(this.artboards.keys());
309
- this.activeArtboardId = s.length > 0 ? s[0] : null;
308
+ const o = Array.from(this.artboards.keys());
309
+ this.activeArtboardId = o.length > 0 ? o[0] : null;
310
310
  }
311
311
  return i;
312
312
  }
@@ -353,10 +353,10 @@ class ti {
353
353
  const i = this.artboards.get(e);
354
354
  if (!i)
355
355
  return !1;
356
- const s = this.elementToArtboard.get(t);
357
- if (s) {
358
- const o = this.artboards.get(s);
359
- o == null || o.removeElementId(t);
356
+ const o = this.elementToArtboard.get(t);
357
+ if (o) {
358
+ const s = this.artboards.get(o);
359
+ s == null || s.removeElementId(t);
360
360
  }
361
361
  return i.addElementId(t), this.elementToArtboard.set(t, e), !0;
362
362
  }
@@ -396,19 +396,19 @@ class ti {
396
396
  */
397
397
  findArtboardAtPoint(t, e) {
398
398
  const i = Array.from(this.artboards.values()).reverse();
399
- for (const s of i)
400
- if (s.containsPoint(t, e))
401
- return s;
399
+ for (const o of i)
400
+ if (o.containsPoint(t, e))
401
+ return o;
402
402
  return null;
403
403
  }
404
404
  /**
405
405
  * Find artboard border at point (for resize handles)
406
406
  */
407
407
  findArtboardBorderAtPoint(t, e, i = 5) {
408
- const s = Array.from(this.artboards.values()).reverse();
409
- for (const o of s)
410
- if (o.hitTestBorder(t, e, i))
411
- return o;
408
+ const o = Array.from(this.artboards.values()).reverse();
409
+ for (const s of o)
410
+ if (s.hitTestBorder(t, e, i))
411
+ return s;
412
412
  return null;
413
413
  }
414
414
  /**
@@ -449,8 +449,8 @@ class ti {
449
449
  reorderArtboards(t, e) {
450
450
  const i = Array.from(this.artboards.entries());
451
451
  if (t < 0 || t >= i.length || e < 0 || e >= i.length || t === e) return;
452
- const [s] = i.splice(t, 1);
453
- i.splice(e, 0, s), this.artboards = new Map(i);
452
+ const [o] = i.splice(t, 1);
453
+ i.splice(e, 0, o), this.artboards = new Map(i);
454
454
  }
455
455
  /**
456
456
  * Clear all artboards
@@ -473,8 +473,8 @@ class ti {
473
473
  fromJSON(t) {
474
474
  this.clear(), t.artboards.forEach((e) => {
475
475
  const i = nt.fromJSON(e);
476
- this.artboards.set(i.id, i), i.getElementIds().forEach((s) => {
477
- this.elementToArtboard.set(s, i.id);
476
+ this.artboards.set(i.id, i), i.getElementIds().forEach((o) => {
477
+ this.elementToArtboard.set(o, i.id);
478
478
  });
479
479
  }), this.activeArtboardId = t.activeArtboardId;
480
480
  }
@@ -484,11 +484,11 @@ class ti {
484
484
  */
485
485
  validateMappings(t) {
486
486
  const e = new Set(t.map((i) => i.id));
487
- for (const [i, s] of this.elementToArtboard.entries())
487
+ for (const [i, o] of this.elementToArtboard.entries())
488
488
  e.has(i) || this.removeElementFromArtboard(i);
489
489
  for (const i of this.artboards.values()) {
490
- const s = i.getElementIds().filter((o) => e.has(o));
491
- i.clearElementIds(), s.forEach((o) => i.addElementId(o));
490
+ const o = i.getElementIds().filter((s) => e.has(s));
491
+ i.clearElementIds(), o.forEach((s) => i.addElementId(s));
492
492
  }
493
493
  }
494
494
  }
@@ -554,7 +554,7 @@ class Q {
554
554
  * Uses visual bounding box for better user experience
555
555
  */
556
556
  hitTest(t, e) {
557
- const i = this.getVisualBoundingBox(), s = this.getRotationAnchor(), o = I.toRadiansInverse(this.rotation), a = Math.cos(o), n = Math.sin(o), h = t - s.x, l = e - s.y, c = h * a - l * n, g = h * n + l * a, d = s.x + c, f = s.y + g;
557
+ const i = this.getVisualBoundingBox(), o = this.getRotationAnchor(), s = I.toRadiansInverse(this.rotation), a = Math.cos(s), n = Math.sin(s), h = t - o.x, l = e - o.y, c = h * a - l * n, g = h * n + l * a, d = o.x + c, f = o.y + g;
558
558
  return d >= i.x && d <= i.x + i.width && f >= i.y && f <= i.y + i.height;
559
559
  }
560
560
  /**
@@ -665,10 +665,10 @@ class P {
665
665
  * @returns Point in local coordinates
666
666
  */
667
667
  worldToLocal(t, e) {
668
- const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i), a = t - this.element.x, n = e - this.element.y;
668
+ const i = this.element.rotation * Math.PI / 180, o = Math.cos(i), s = Math.sin(i), a = t - this.element.x, n = e - this.element.y;
669
669
  return {
670
- x: a * s - n * o,
671
- y: a * o + n * s
670
+ x: a * o - n * s,
671
+ y: a * s + n * o
672
672
  };
673
673
  }
674
674
  /**
@@ -681,7 +681,7 @@ class P {
681
681
  * @returns Point in world coordinates
682
682
  */
683
683
  localToWorld(t, e) {
684
- const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i), a = t * s - e * o, n = t * o + e * s;
684
+ const i = -this.element.rotation * Math.PI / 180, o = Math.cos(i), s = Math.sin(i), a = t * o - e * s, n = t * s + e * o;
685
685
  return {
686
686
  x: this.element.x + a,
687
687
  y: this.element.y + n
@@ -697,10 +697,10 @@ class P {
697
697
  * @returns Delta in local space
698
698
  */
699
699
  worldDeltaToLocal(t, e) {
700
- const i = this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i);
700
+ const i = this.element.rotation * Math.PI / 180, o = Math.cos(i), s = Math.sin(i);
701
701
  return {
702
- dx: t * s - e * o,
703
- dy: t * o + e * s
702
+ dx: t * o - e * s,
703
+ dy: t * s + e * o
704
704
  };
705
705
  }
706
706
  /**
@@ -712,10 +712,10 @@ class P {
712
712
  * @returns Delta in world space
713
713
  */
714
714
  localDeltaToWorld(t, e) {
715
- const i = -this.element.rotation * Math.PI / 180, s = Math.cos(i), o = Math.sin(i);
715
+ const i = -this.element.rotation * Math.PI / 180, o = Math.cos(i), s = Math.sin(i);
716
716
  return {
717
- dx: t * s - e * o,
718
- dy: t * o + e * s
717
+ dx: t * o - e * s,
718
+ dy: t * s + e * o
719
719
  };
720
720
  }
721
721
  /**
@@ -729,11 +729,11 @@ class P {
729
729
  * @param angleDegrees - Rotation angle in degrees (positive = clockwise in UI)
730
730
  * @returns Rotated point in world space
731
731
  */
732
- static rotatePointAroundAnchor(t, e, i, s, o) {
733
- const a = -o * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - i, c = e - s, g = l * n - c * h, d = l * h + c * n;
732
+ static rotatePointAroundAnchor(t, e, i, o, s) {
733
+ const a = -s * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - i, c = e - o, g = l * n - c * h, d = l * h + c * n;
734
734
  return {
735
735
  x: i + g,
736
- y: s + d
736
+ y: o + d
737
737
  };
738
738
  }
739
739
  /**
@@ -2300,17 +2300,17 @@ function ii(r) {
2300
2300
  const t = r || document.documentElement;
2301
2301
  return getComputedStyle(t).getPropertyValue("--color-spacing-indicator").trim() || "#FF0000";
2302
2302
  }
2303
- function si(r = 0.1, t) {
2303
+ function oi(r = 0.1, t) {
2304
2304
  const e = zt(t);
2305
2305
  if (e.startsWith("oklch("))
2306
2306
  return `${e.slice(0, -1)} / ${r})`;
2307
2307
  if (e.startsWith("#")) {
2308
- const i = e.replace("#", ""), s = parseInt(i.substring(0, 2), 16), o = parseInt(i.substring(2, 4), 16), a = parseInt(i.substring(4, 6), 16);
2309
- return `rgba(${s}, ${o}, ${a}, ${r})`;
2308
+ const i = e.replace("#", ""), o = parseInt(i.substring(0, 2), 16), s = parseInt(i.substring(2, 4), 16), a = parseInt(i.substring(4, 6), 16);
2309
+ return `rgba(${o}, ${s}, ${a}, ${r})`;
2310
2310
  }
2311
2311
  return e;
2312
2312
  }
2313
- function oi(r) {
2313
+ function si(r) {
2314
2314
  if (typeof window > "u" || typeof document > "u")
2315
2315
  return "oklch(0% 0 0 / 0.45)";
2316
2316
  const t = r || document.documentElement;
@@ -2374,7 +2374,7 @@ function fi(r) {
2374
2374
  const t = document.documentElement, e = getComputedStyle(t).getPropertyValue("--foreground").trim();
2375
2375
  return e.startsWith("oklch(") ? `${e.slice(0, -1)} / 0.5)` : e || "oklch(0.2103 0.0059 285.89 / 0.5)";
2376
2376
  }
2377
- const ui = 1, mi = "#ffffff", ge = 20, pi = 6, yi = 24, fe = 16, ue = 36, me = 24, wi = 4, bi = "#FFFFFF", xi = 2, Si = 0.1, Ci = le(), Ti = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96, 128], j = 0, Yt = 1.2, _t = 50, pe = 8, ye = 999, we = /* @__PURE__ */ new Set([
2377
+ const ui = 1, mi = "#ffffff", ge = 20, pi = 6, yi = 24, fe = 16, ue = 36, me = 24, wi = 4, bi = "#FFFFFF", xi = 2, Si = 0.1, Ci = le(), Ti = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48, 64, 72, 96, 128], j = 0, _t = 1.2, Yt = 50, pe = 8, ye = 999, we = /* @__PURE__ */ new Set([
2378
2378
  "Arial",
2379
2379
  "Arial Black",
2380
2380
  "Verdana",
@@ -2400,7 +2400,7 @@ var xe = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INF
2400
2400
  class Se {
2401
2401
  constructor() {
2402
2402
  var t;
2403
- this.level = 0, this.enabled = typeof It < "u" && ((t = It.env) == null ? void 0 : t.NODE_ENV) !== "production";
2403
+ this.level = 0, this.enabled = typeof ft < "u" && ((t = ft.env) == null ? void 0 : t.NODE_ENV) !== "production";
2404
2404
  }
2405
2405
  // Only enabled in development by default
2406
2406
  /**
@@ -2474,14 +2474,14 @@ class Ce {
2474
2474
  this.logger.error(`[${this.scopeName}] ${t}`, ...e);
2475
2475
  }
2476
2476
  }
2477
- const Te = new Se(), mt = (r) => Te.scope(r), ve = mt("ImageLoadEvents"), Ct = /* @__PURE__ */ new Set();
2477
+ const Te = new Se(), pt = (r) => Te.scope(r), ve = pt("ImageLoadEvents"), Tt = /* @__PURE__ */ new Set();
2478
2478
  function vi(r) {
2479
- return Ct.add(r), () => {
2480
- Ct.delete(r);
2479
+ return Tt.add(r), () => {
2480
+ Tt.delete(r);
2481
2481
  };
2482
2482
  }
2483
2483
  function et(r) {
2484
- Ct.forEach((t) => {
2484
+ Tt.forEach((t) => {
2485
2485
  try {
2486
2486
  t(r);
2487
2487
  } catch (e) {
@@ -2513,16 +2513,16 @@ class J {
2513
2513
  return e.refCount++, e.image;
2514
2514
  const i = new Image();
2515
2515
  i.crossOrigin = "anonymous";
2516
- const s = {
2516
+ const o = {
2517
2517
  image: i,
2518
2518
  refCount: 1,
2519
2519
  loaded: !1
2520
2520
  };
2521
2521
  return i.onload = () => {
2522
- s.loaded = !0;
2522
+ o.loaded = !0;
2523
2523
  }, i.onerror = () => {
2524
- s.loaded = !0;
2525
- }, this.cache.set(t, s), (!t.includes(":") || /^https?:\/\/|^data:|^blob:/.test(t)) && (i.src = t), i;
2524
+ o.loaded = !0;
2525
+ }, this.cache.set(t, o), (!t.includes(":") || /^https?:\/\/|^data:|^blob:/.test(t)) && (i.src = t), i;
2526
2526
  }
2527
2527
  /**
2528
2528
  * Release a reference to a cached image.
@@ -2571,20 +2571,20 @@ class J {
2571
2571
  this.cache.clear();
2572
2572
  }
2573
2573
  }
2574
- const it = mt("ImageElement"), Et = 3e4, Ot = 3, Fe = 1e3;
2574
+ const it = pt("ImageElement"), Et = 3e4, Ot = 3, Fe = 1e3;
2575
2575
  function x(r) {
2576
2576
  return r.transformData;
2577
2577
  }
2578
- class pt extends Q {
2578
+ class yt extends Q {
2579
2579
  // Track URL acquired from ImageCache for release on destroy
2580
2580
  constructor(t = {}) {
2581
- var e, i, s, o, a, n, h, l, c, g;
2581
+ var e, i, o, s, a, n, h, l, c, g;
2582
2582
  super(t), this.svgBlobUrl = null, this.loadTimeoutId = null, this.retryAttempt = 0, this.cachedImageUrl = null, this.transformType = "image", this.transformData = {
2583
2583
  type: "image",
2584
2584
  width: ((e = t.transformData) == null ? void 0 : e.width) || 200,
2585
2585
  height: ((i = t.transformData) == null ? void 0 : i.height) || 200,
2586
- cropX: ((s = t.transformData) == null ? void 0 : s.cropX) ?? 0,
2587
- cropY: ((o = t.transformData) == null ? void 0 : o.cropY) ?? 0,
2586
+ cropX: ((o = t.transformData) == null ? void 0 : o.cropX) ?? 0,
2587
+ cropY: ((s = t.transformData) == null ? void 0 : s.cropY) ?? 0,
2588
2588
  cropWidth: ((a = t.transformData) == null ? void 0 : a.cropWidth) ?? 1,
2589
2589
  cropHeight: ((n = t.transformData) == null ? void 0 : n.cropHeight) ?? 1,
2590
2590
  flipHorizontal: ((h = t.transformData) == null ? void 0 : h.flipHorizontal) ?? !1,
@@ -2619,28 +2619,28 @@ class pt extends Q {
2619
2619
  this.clearLoadTimeout(), this.releaseImageCache();
2620
2620
  const i = J.getInstance().acquire(t);
2621
2621
  this.cachedImageUrl = t;
2622
- let s = !1;
2623
- const o = () => {
2624
- s = !0, this.clearLoadTimeout();
2622
+ let o = !1;
2623
+ const s = () => {
2624
+ o = !0, this.clearLoadTimeout();
2625
2625
  };
2626
2626
  if (i.complete && i.naturalWidth > 0) {
2627
- o(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id);
2627
+ s(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id);
2628
2628
  return;
2629
2629
  }
2630
2630
  const a = i.onload, n = i.onerror;
2631
2631
  i.onload = (l) => {
2632
- s || (o(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id), a && a !== i.onload && a(l));
2632
+ o || (s(), this.imageElement = i, this.imageLoaded = !0, this.imageLoadState = "loaded", this.imageLoadError = null, this.imageAspectRatio = i.naturalWidth / i.naturalHeight, this.preserveDimensions || (this.transformData.height = this.transformData.width / this.imageAspectRatio), this.onLoadCallback && this.onLoadCallback(this.clone()), et(this.id), a && a !== i.onload && a(l));
2633
2633
  }, i.onerror = (l) => {
2634
- if (s) return;
2635
- o();
2634
+ if (o) return;
2635
+ s();
2636
2636
  const c = new Error(`Failed to load image: ${t}`);
2637
2637
  this.handleLoadFailure(t, c), n && n !== i.onerror && n(l);
2638
2638
  }, this.loadTimeoutId = setTimeout(() => {
2639
- if (s) return;
2640
- o(), i.src = "";
2639
+ if (o) return;
2640
+ s(), i.src = "";
2641
2641
  const l = new Error(`Image load timed out after ${Et}ms: ${t}`);
2642
2642
  this.handleLoadFailure(t, l);
2643
- }, Et), (!i.src || i.src !== t) && (i.src = t), !s && i.complete && i.naturalWidth > 0 && ((h = i.onload) == null || h.call(i, new Event("load")));
2643
+ }, Et), (!i.src || i.src !== t) && (i.src = t), !o && i.complete && i.naturalWidth > 0 && ((h = i.onload) == null || h.call(i, new Event("load")));
2644
2644
  }
2645
2645
  /**
2646
2646
  * Handle a load failure - either retry with backoff or set error state.
@@ -2689,10 +2689,10 @@ class pt extends Q {
2689
2689
  this.revokeSvgBlobUrl();
2690
2690
  const e = new Image();
2691
2691
  e.crossOrigin = "anonymous", e.onload = () => {
2692
- const s = document.createElement("canvas");
2693
- s.width = e.width * 4, s.height = e.height * 4;
2694
- const o = s.getContext("2d");
2695
- o.scale(4, 4), o.drawImage(e, 0, 0), s.toBlob((a) => {
2692
+ const o = document.createElement("canvas");
2693
+ o.width = e.width * 4, o.height = e.height * 4;
2694
+ const s = o.getContext("2d");
2695
+ s.scale(4, 4), s.drawImage(e, 0, 0), o.toBlob((a) => {
2696
2696
  if (!a) {
2697
2697
  it.error("Failed to convert SVG to blob"), this.imageLoaded = !1;
2698
2698
  return;
@@ -2713,10 +2713,10 @@ class pt extends Q {
2713
2713
  getBoundingBox() {
2714
2714
  if (this.isCropping) {
2715
2715
  const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
2716
- let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
2717
- const o = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
2718
- i *= o, s *= a;
2719
- const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - s * h, c = i * h + s * n, g = this.x + l, d = this.y + c;
2716
+ let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), o = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
2717
+ const s = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
2718
+ i *= s, o *= a;
2719
+ const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - o * h, c = i * h + o * n, g = this.x + l, d = this.y + c;
2720
2720
  return {
2721
2721
  x: g - this.transformData.width / 2,
2722
2722
  y: d - this.transformData.height / 2,
@@ -2754,10 +2754,10 @@ class pt extends Q {
2754
2754
  getRotationAnchor() {
2755
2755
  if (this.isCropping) {
2756
2756
  const t = this.transformData.width * this.transformData.cropWidth, e = this.transformData.height * this.transformData.cropHeight;
2757
- let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), s = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
2758
- const o = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
2759
- i *= o, s *= a;
2760
- const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - s * h, c = i * h + s * n;
2757
+ let i = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + t / 2), o = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + e / 2);
2758
+ const s = this.transformData.flipHorizontal ? -1 : 1, a = this.transformData.flipVertical ? -1 : 1;
2759
+ i *= s, o *= a;
2760
+ const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = i * n - o * h, c = i * h + o * n;
2761
2761
  return {
2762
2762
  x: this.x + l,
2763
2763
  y: this.y + c
@@ -2774,10 +2774,10 @@ class pt extends Q {
2774
2774
  hitTest(t, e) {
2775
2775
  const i = this.worldToLocal(t, e);
2776
2776
  if (this.isCropping) {
2777
- const s = this.transformData.width * this.transformData.cropWidth, o = this.transformData.height * this.transformData.cropHeight, a = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + s / 2), n = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + o / 2), h = this.transformData.width / 2, l = this.transformData.height / 2;
2777
+ const o = this.transformData.width * this.transformData.cropWidth, s = this.transformData.height * this.transformData.cropHeight, a = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + o / 2), n = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + s / 2), h = this.transformData.width / 2, l = this.transformData.height / 2;
2778
2778
  return i.x >= a - h && i.x <= a + h && i.y >= n - l && i.y <= n + l;
2779
2779
  } else {
2780
- const s = this.transformData.width * this.transformData.cropWidth, o = this.transformData.height * this.transformData.cropHeight, a = s / 2, n = o / 2;
2780
+ const o = this.transformData.width * this.transformData.cropWidth, s = this.transformData.height * this.transformData.cropHeight, a = o / 2, n = s / 2;
2781
2781
  return i.x >= -a && i.x <= a && i.y >= -n && i.y <= n;
2782
2782
  }
2783
2783
  }
@@ -2790,8 +2790,8 @@ class pt extends Q {
2790
2790
  return;
2791
2791
  }
2792
2792
  t.save(), this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
2793
- const s = this.transformData.flipHorizontal ? -1 : 1, o = this.transformData.flipVertical ? -1 : 1;
2794
- if (t.scale(s, o), this.isCropping) {
2793
+ const o = this.transformData.flipHorizontal ? -1 : 1, s = this.transformData.flipVertical ? -1 : 1;
2794
+ if (t.scale(o, s), this.isCropping) {
2795
2795
  const a = this.transformData.width * this.transformData.cropWidth, n = this.transformData.height * this.transformData.cropHeight, h = this.transformData.width / 2 - (this.transformData.cropX * this.transformData.width + a / 2), l = this.transformData.height / 2 - (this.transformData.cropY * this.transformData.height + n / 2), c = h - this.transformData.width / 2, g = l - this.transformData.height / 2, d = this.transformData.borderRadius || 0;
2796
2796
  if (d > 0) {
2797
2797
  t.save();
@@ -2852,50 +2852,50 @@ class pt extends Q {
2852
2852
  */
2853
2853
  renderPlaceholder(t) {
2854
2854
  t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
2855
- const e = this.transformData.width * this.transformData.cropWidth, i = this.transformData.height * this.transformData.cropHeight, s = -e / 2, o = -i / 2;
2855
+ const e = this.transformData.width * this.transformData.cropWidth, i = this.transformData.height * this.transformData.cropHeight, o = -e / 2, s = -i / 2;
2856
2856
  let a, n, h;
2857
- this.imageLoadState === "error" ? (a = "#f0e0e0", n = "#993333", h = "Image failed to load") : this.imageLoadState === "retrying" ? (a = "#e0e0e0", n = "#666", h = "Retrying...") : this.imageLoadState === "loading" ? (a = "#e0e0e0", n = "#666", h = "Loading...") : (a = "#e0e0e0", n = "#666", h = this.imageUrl ? "Loading..." : "No image"), t.fillStyle = a, t.fillRect(s, o, e, i), t.fillStyle = n, t.font = "14px system-ui, -apple-system, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText(h, 0, 0), t.restore();
2857
+ this.imageLoadState === "error" ? (a = "#f0e0e0", n = "#993333", h = "Image failed to load") : this.imageLoadState === "retrying" ? (a = "#e0e0e0", n = "#666", h = "Retrying...") : this.imageLoadState === "loading" ? (a = "#e0e0e0", n = "#666", h = "Loading...") : (a = "#e0e0e0", n = "#666", h = this.imageUrl ? "Loading..." : "No image"), t.fillStyle = a, t.fillRect(o, s, e, i), t.fillStyle = n, t.font = "14px system-ui, -apple-system, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText(h, 0, 0), t.restore();
2858
2858
  }
2859
2859
  /**
2860
2860
  * Handle resize - maintain aspect ratio
2861
2861
  * @returns {boolean} true if resize was applied
2862
2862
  */
2863
- resize(t, e, i, s) {
2864
- let o, a;
2865
- this.isCropping ? (o = e / x(s).width, a = i / x(s).height) : (o = e / (s.width ?? 1), a = i / (s.height ?? 1));
2866
- const n = (o + a) / 2;
2863
+ resize(t, e, i, o) {
2864
+ let s, a;
2865
+ this.isCropping ? (s = e / x(o).width, a = i / x(o).height) : (s = e / (o.width ?? 1), a = i / (o.height ?? 1));
2866
+ const n = (s + a) / 2;
2867
2867
  let h = t;
2868
- this.isCropping && (h = this.remapAnchorForFlips(t, s));
2868
+ this.isCropping && (h = this.remapAnchorForFlips(t, o));
2869
2869
  let l = n;
2870
2870
  if (this.isCropping) {
2871
- const B = this.transformData.width / x(s).width;
2871
+ const B = this.transformData.width / x(o).width;
2872
2872
  n < B && (l = this.calculateMinScaleForCropBounds(
2873
2873
  h,
2874
- s,
2874
+ o,
2875
2875
  n,
2876
2876
  B
2877
2877
  ));
2878
2878
  }
2879
- this.transformData.width = x(s).width * l, this.transformData.height = this.transformData.width / this.imageAspectRatio, this.rotation = s.rotation;
2879
+ this.transformData.width = x(o).width * l, this.transformData.height = this.transformData.width / this.imageAspectRatio, this.rotation = o.rotation;
2880
2880
  let c, g;
2881
2881
  if (this.isCropping) {
2882
- const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
2883
- c = s.x - W, g = s.y - z;
2882
+ const B = (x(o).cropX + x(o).cropWidth / 2) * x(o).width - x(o).width / 2, A = (x(o).cropY + x(o).cropHeight / 2) * x(o).height - x(o).height / 2, k = B, R = A, E = P.fromSnapshot(o).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
2883
+ c = o.x - W, g = o.y - z;
2884
2884
  } else {
2885
- const B = (x(s).cropX + x(s).cropWidth / 2) * x(s).width - x(s).width / 2, A = (x(s).cropY + x(s).cropHeight / 2) * x(s).height - x(s).height / 2, k = B, R = A, E = P.fromSnapshot(s).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
2886
- c = s.x - W, g = s.y - z;
2885
+ const B = (x(o).cropX + x(o).cropWidth / 2) * x(o).width - x(o).width / 2, A = (x(o).cropY + x(o).cropHeight / 2) * x(o).height - x(o).height / 2, k = B, R = A, E = P.fromSnapshot(o).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
2886
+ c = o.x - W, g = o.y - z;
2887
2887
  }
2888
2888
  let d, f, u = 0, m = 0;
2889
- h === "top-left" ? (u = x(s).width / 2, m = x(s).height / 2) : h === "top-right" ? (u = -x(s).width / 2, m = x(s).height / 2) : h === "bottom-left" ? (u = x(s).width / 2, m = -x(s).height / 2) : h === "bottom-right" ? (u = -x(s).width / 2, m = -x(s).height / 2) : h === "middle-left" ? (u = x(s).width / 2, m = 0) : h === "middle-right" ? (u = -x(s).width / 2, m = 0) : h === "middle-top" ? (u = 0, m = x(s).height / 2) : h === "middle-bottom" && (u = 0, m = -x(s).height / 2);
2890
- const y = P.fromSnapshot(s).localDeltaToWorld(u, m), w = y.dx, S = y.dy;
2889
+ h === "top-left" ? (u = x(o).width / 2, m = x(o).height / 2) : h === "top-right" ? (u = -x(o).width / 2, m = x(o).height / 2) : h === "bottom-left" ? (u = x(o).width / 2, m = -x(o).height / 2) : h === "bottom-right" ? (u = -x(o).width / 2, m = -x(o).height / 2) : h === "middle-left" ? (u = x(o).width / 2, m = 0) : h === "middle-right" ? (u = -x(o).width / 2, m = 0) : h === "middle-top" ? (u = 0, m = x(o).height / 2) : h === "middle-bottom" && (u = 0, m = -x(o).height / 2);
2890
+ const y = P.fromSnapshot(o).localDeltaToWorld(u, m), w = y.dx, S = y.dy;
2891
2891
  d = c + w, f = g + S;
2892
2892
  let b = 0, T = 0;
2893
2893
  h === "top-left" ? (b = this.transformData.width / 2, T = this.transformData.height / 2) : h === "top-right" ? (b = -this.transformData.width / 2, T = this.transformData.height / 2) : h === "bottom-left" ? (b = this.transformData.width / 2, T = -this.transformData.height / 2) : h === "bottom-right" ? (b = -this.transformData.width / 2, T = -this.transformData.height / 2) : h === "middle-left" ? (b = this.transformData.width / 2, T = 0) : h === "middle-right" ? (b = -this.transformData.width / 2, T = 0) : h === "middle-top" ? (b = 0, T = this.transformData.height / 2) : h === "middle-bottom" && (b = 0, T = -this.transformData.height / 2);
2894
2894
  const M = new P(this).localDeltaToWorld(b, T), F = M.dx, v = M.dy, D = d - F, U = f - v;
2895
2895
  if (this.isCropping) {
2896
- const B = s.x, A = s.y, k = x(s).cropWidth * x(s).width, R = x(s).cropHeight * x(s).height;
2896
+ const B = o.x, A = o.y, k = x(o).cropWidth * x(o).width, R = x(o).cropHeight * x(o).height;
2897
2897
  this.x = B, this.y = A;
2898
- const H = k / this.transformData.width, E = R / this.transformData.height, W = B - D, z = A - U, Dt = new P(this).worldDeltaToLocal(W, z), Zt = Dt.dx, Kt = Dt.dy, Qt = this.transformData.width / 2 + Zt, te = this.transformData.height / 2 + Kt, ee = Qt / this.transformData.width - H / 2, ie = te / this.transformData.height - E / 2;
2898
+ const H = k / this.transformData.width, E = R / this.transformData.height, W = B - D, z = A - U, It = new P(this).worldDeltaToLocal(W, z), Zt = It.dx, Kt = It.dy, Qt = this.transformData.width / 2 + Zt, te = this.transformData.height / 2 + Kt, ee = Qt / this.transformData.width - H / 2, ie = te / this.transformData.height - E / 2;
2899
2899
  this.transformData.cropX = ee, this.transformData.cropY = ie, this.transformData.cropWidth = H, this.transformData.cropHeight = E;
2900
2900
  } else {
2901
2901
  const B = (this.transformData.cropX + this.transformData.cropWidth / 2) * this.transformData.width - this.transformData.width / 2, A = (this.transformData.cropY + this.transformData.cropHeight / 2) * this.transformData.height - this.transformData.height / 2, k = B, R = A, E = new P(this).localDeltaToWorld(k, R), W = E.dx, z = E.dy;
@@ -2955,9 +2955,9 @@ class pt extends Q {
2955
2955
  // bottom-left
2956
2956
  { x: t.x + t.width, y: t.y + t.height }
2957
2957
  // bottom-right
2958
- ].map((o) => ({
2959
- x: this.x + o.x * e - o.y * i,
2960
- y: this.y + o.x * i + o.y * e
2958
+ ].map((s) => ({
2959
+ x: this.x + s.x * e - s.y * i,
2960
+ y: this.y + s.x * i + s.y * e
2961
2961
  }));
2962
2962
  }
2963
2963
  /**
@@ -2965,8 +2965,8 @@ class pt extends Q {
2965
2965
  * Local coordinates are relative to this.x, this.y (the center of the visible area)
2966
2966
  */
2967
2967
  worldToLocal(t, e) {
2968
- const i = t - this.x, s = e - this.y, o = Math.cos(I.toRadiansInverse(this.rotation)), a = Math.sin(I.toRadiansInverse(this.rotation));
2969
- let n = i * o - s * a, h = i * a + s * o;
2968
+ const i = t - this.x, o = e - this.y, s = Math.cos(I.toRadiansInverse(this.rotation)), a = Math.sin(I.toRadiansInverse(this.rotation));
2969
+ let n = i * s - o * a, h = i * a + o * s;
2970
2970
  const l = this.transformData.flipHorizontal ? -1 : 1, c = this.transformData.flipVertical ? -1 : 1;
2971
2971
  return n *= l, h *= c, {
2972
2972
  x: n,
@@ -2979,9 +2979,9 @@ class pt extends Q {
2979
2979
  * Canvas transformations are applied in reverse: scale -> rotate -> translate
2980
2980
  */
2981
2981
  localToWorld(t, e) {
2982
- const i = this.transformData.flipHorizontal ? -1 : 1, s = this.transformData.flipVertical ? -1 : 1;
2983
- let o = t * i, a = e * s;
2984
- const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = o * n - a * h, c = o * h + a * n;
2982
+ const i = this.transformData.flipHorizontal ? -1 : 1, o = this.transformData.flipVertical ? -1 : 1;
2983
+ let s = t * i, a = e * o;
2984
+ const n = Math.cos(I.toRadians(this.rotation)), h = Math.sin(I.toRadians(this.rotation)), l = s * n - a * h, c = s * h + a * n;
2985
2985
  return {
2986
2986
  x: this.x + l,
2987
2987
  y: this.y + c
@@ -2996,29 +2996,29 @@ class pt extends Q {
2996
2996
  */
2997
2997
  hitTestCropHandle(t, e, i = 1) {
2998
2998
  if (!this.isCropping) return null;
2999
- const s = this.getCropBoxBounds();
3000
- if (!s) return null;
3001
- const o = this.worldToLocal(t, e), a = 1 / i, n = fe * a, h = ue * a, l = me * a, c = [
3002
- { x: s.x, y: s.y, anchor: "top-left" },
3003
- { x: s.x + s.width, y: s.y, anchor: "top-right" },
3004
- { x: s.x, y: s.y + s.height, anchor: "bottom-left" },
3005
- { x: s.x + s.width, y: s.y + s.height, anchor: "bottom-right" }
2999
+ const o = this.getCropBoxBounds();
3000
+ if (!o) return null;
3001
+ const s = this.worldToLocal(t, e), a = 1 / i, n = fe * a, h = ue * a, l = me * a, c = [
3002
+ { x: o.x, y: o.y, anchor: "top-left" },
3003
+ { x: o.x + o.width, y: o.y, anchor: "top-right" },
3004
+ { x: o.x, y: o.y + o.height, anchor: "bottom-left" },
3005
+ { x: o.x + o.width, y: o.y + o.height, anchor: "bottom-right" }
3006
3006
  ];
3007
3007
  for (const d of c) {
3008
- const f = o.x - d.x, u = o.y - d.y;
3008
+ const f = s.x - d.x, u = s.y - d.y;
3009
3009
  if (Math.sqrt(f * f + u * u) <= n) {
3010
3010
  const p = this.localToWorld(d.x, d.y);
3011
3011
  return { type: "corner", anchor: d.anchor, worldX: p.x, worldY: p.y };
3012
3012
  }
3013
3013
  }
3014
3014
  const g = [
3015
- { x: s.x + s.width / 2, y: s.y, anchor: "top", orientation: "horizontal" },
3016
- { x: s.x + s.width / 2, y: s.y + s.height, anchor: "bottom", orientation: "horizontal" },
3017
- { x: s.x, y: s.y + s.height / 2, anchor: "left", orientation: "vertical" },
3018
- { x: s.x + s.width, y: s.y + s.height / 2, anchor: "right", orientation: "vertical" }
3015
+ { x: o.x + o.width / 2, y: o.y, anchor: "top", orientation: "horizontal" },
3016
+ { x: o.x + o.width / 2, y: o.y + o.height, anchor: "bottom", orientation: "horizontal" },
3017
+ { x: o.x, y: o.y + o.height / 2, anchor: "left", orientation: "vertical" },
3018
+ { x: o.x + o.width, y: o.y + o.height / 2, anchor: "right", orientation: "vertical" }
3019
3019
  ];
3020
3020
  for (const d of g) {
3021
- const f = o.x - d.x, u = o.y - d.y;
3021
+ const f = s.x - d.x, u = s.y - d.y;
3022
3022
  let m, p;
3023
3023
  if (d.orientation === "horizontal" ? (m = h / 2, p = l / 2) : (m = l / 2, p = h / 2), Math.abs(f) <= m && Math.abs(u) <= p) {
3024
3024
  const y = this.localToWorld(d.x, d.y);
@@ -3035,8 +3035,8 @@ class pt extends Q {
3035
3035
  if (!this.isCropping) return !1;
3036
3036
  const i = this.getCropBoxBounds();
3037
3037
  if (!i) return !1;
3038
- const s = this.worldToLocal(t, e);
3039
- return s.x >= i.x && s.x <= i.x + i.width && s.y >= i.y && s.y <= i.y + i.height;
3038
+ const o = this.worldToLocal(t, e);
3039
+ return o.x >= i.x && o.x <= i.x + i.width && o.y >= i.y && o.y <= i.y + i.height;
3040
3040
  }
3041
3041
  /**
3042
3042
  * Update crop box (normalized 0-1 coordinates)
@@ -3046,46 +3046,46 @@ class pt extends Q {
3046
3046
  * @param {number} cropHeight - Normalized height (0-1)
3047
3047
  * @param {boolean} adjustPosition - Whether to adjust this.x, this.y to keep visual position stable (default: false)
3048
3048
  */
3049
- updateCrop(t, e, i, s, o = !1) {
3050
- let n = Math.max(0.1, Math.min(1, i)), h = Math.max(0.1, Math.min(1, s)), l = Math.max(0, Math.min(1 - n, t)), c = Math.max(0, Math.min(1 - h, e));
3049
+ updateCrop(t, e, i, o, s = !1) {
3050
+ let n = Math.max(0.1, Math.min(1, i)), h = Math.max(0.1, Math.min(1, o)), l = Math.max(0, Math.min(1 - n, t)), c = Math.max(0, Math.min(1 - h, e));
3051
3051
  l + n > 1 && (n = 1 - l), c + h > 1 && (h = 1 - c);
3052
3052
  let g = 0, d = 0;
3053
- if (o) {
3053
+ if (s) {
3054
3054
  const f = this.transformData.cropX * this.transformData.width + this.transformData.cropWidth * this.transformData.width / 2, u = this.transformData.cropY * this.transformData.height + this.transformData.cropHeight * this.transformData.height / 2, m = l * this.transformData.width + n * this.transformData.width / 2, p = c * this.transformData.height + h * this.transformData.height / 2, y = m - f, w = p - u, S = Math.cos(I.toRadians(this.rotation)), b = Math.sin(I.toRadians(this.rotation));
3055
3055
  g = y * S - w * b, d = y * b + w * S;
3056
3056
  }
3057
- this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight = h, o && (this.x += g, this.y += d);
3057
+ this.transformData.cropX = l, this.transformData.cropY = c, this.transformData.cropWidth = n, this.transformData.cropHeight = h, s && (this.x += g, this.y += d);
3058
3058
  }
3059
3059
  /**
3060
3060
  * Get the local position of the corner opposite to the given anchor
3061
3061
  * Corners are relative to frame center
3062
3062
  */
3063
3063
  getOppositeCornerLocalPosition(t, e, i) {
3064
- const s = e / 2, o = i / 2;
3064
+ const o = e / 2, s = i / 2;
3065
3065
  return {
3066
- "top-left": { x: s, y: o },
3066
+ "top-left": { x: o, y: s },
3067
3067
  // Opposite is bottom-right
3068
- "top-right": { x: -s, y: o },
3068
+ "top-right": { x: -o, y: s },
3069
3069
  // Opposite is bottom-left
3070
- "bottom-left": { x: s, y: -o },
3070
+ "bottom-left": { x: o, y: -s },
3071
3071
  // Opposite is top-right
3072
- "bottom-right": { x: -s, y: -o },
3072
+ "bottom-right": { x: -o, y: -s },
3073
3073
  // Opposite is top-left
3074
- top: { x: 0, y: o },
3074
+ top: { x: 0, y: s },
3075
3075
  // Opposite is bottom edge
3076
- bottom: { x: 0, y: -o },
3076
+ bottom: { x: 0, y: -s },
3077
3077
  // Opposite is top edge
3078
- left: { x: s, y: 0 },
3078
+ left: { x: o, y: 0 },
3079
3079
  // Opposite is right edge
3080
- right: { x: -s, y: 0 },
3080
+ right: { x: -o, y: 0 },
3081
3081
  // Opposite is left edge
3082
- "middle-top": { x: 0, y: o },
3082
+ "middle-top": { x: 0, y: s },
3083
3083
  // Opposite is bottom edge
3084
- "middle-bottom": { x: 0, y: -o },
3084
+ "middle-bottom": { x: 0, y: -s },
3085
3085
  // Opposite is top edge
3086
- "middle-left": { x: s, y: 0 },
3086
+ "middle-left": { x: o, y: 0 },
3087
3087
  // Opposite is right edge
3088
- "middle-right": { x: -s, y: 0 }
3088
+ "middle-right": { x: -o, y: 0 }
3089
3089
  // Opposite is left edge
3090
3090
  }[t];
3091
3091
  }
@@ -3094,7 +3094,7 @@ class pt extends Q {
3094
3094
  * In crop mode, this.x/y is the crop center, not the frame center
3095
3095
  */
3096
3096
  calculateFrameCenterFromCropCenter(t) {
3097
- const e = x(t).width * x(t).cropWidth, i = x(t).height * x(t).cropHeight, s = x(t).width / 2 - (x(t).cropX * x(t).width + e / 2), o = x(t).height / 2 - (x(t).cropY * x(t).height + i / 2), n = new P(t).localDeltaToWorld(s, o);
3097
+ const e = x(t).width * x(t).cropWidth, i = x(t).height * x(t).cropHeight, o = x(t).width / 2 - (x(t).cropX * x(t).width + e / 2), s = x(t).height / 2 - (x(t).cropY * x(t).height + i / 2), n = new P(t).localDeltaToWorld(o, s);
3098
3098
  return {
3099
3099
  x: t.x + n.dx,
3100
3100
  y: t.y + n.dy
@@ -3108,10 +3108,10 @@ class pt extends Q {
3108
3108
  t,
3109
3109
  x(e).width,
3110
3110
  x(e).height
3111
- ), s = this.calculateFrameCenterFromCropCenter(e), a = new P(e).localDeltaToWorld(i.x, i.y);
3111
+ ), o = this.calculateFrameCenterFromCropCenter(e), a = new P(e).localDeltaToWorld(i.x, i.y);
3112
3112
  return {
3113
- x: s.x + a.dx,
3114
- y: s.y + a.dy
3113
+ x: o.x + a.dx,
3114
+ y: o.y + a.dy
3115
3115
  };
3116
3116
  }
3117
3117
  /**
@@ -3119,15 +3119,15 @@ class pt extends Q {
3119
3119
  * The opposite corner from the anchor stays fixed in world space
3120
3120
  */
3121
3121
  calculateFrameCenterAfterResize(t, e, i) {
3122
- const s = this.getFixedCornerWorldPosition(e, i), o = x(i).width * t, a = o / this.imageAspectRatio, n = this.getOppositeCornerLocalPosition(e, o, a), l = new P({
3122
+ const o = this.getFixedCornerWorldPosition(e, i), s = x(i).width * t, a = s / this.imageAspectRatio, n = this.getOppositeCornerLocalPosition(e, s, a), l = new P({
3123
3123
  x: 0,
3124
3124
  // Will calculate frame center
3125
3125
  y: 0,
3126
3126
  rotation: i.rotation
3127
3127
  }).localDeltaToWorld(n.x, n.y);
3128
3128
  return {
3129
- x: s.x - l.dx,
3130
- y: s.y - l.dy
3129
+ x: o.x - l.dx,
3130
+ y: o.y - l.dy
3131
3131
  };
3132
3132
  }
3133
3133
  /**
@@ -3136,7 +3136,7 @@ class pt extends Q {
3136
3136
  * would be positioned within the frame after resize.
3137
3137
  */
3138
3138
  calculateCropStateAtScale(t, e, i) {
3139
- const s = x(i).width * t, o = s / this.imageAspectRatio, a = x(i).cropWidth * x(i).width, n = x(i).cropHeight * x(i).height, h = a / s, l = n / o, c = this.calculateFrameCenterAfterResize(t, e, i), g = {
3139
+ const o = x(i).width * t, s = o / this.imageAspectRatio, a = x(i).cropWidth * x(i).width, n = x(i).cropHeight * x(i).height, h = a / o, l = n / s, c = this.calculateFrameCenterAfterResize(t, e, i), g = {
3140
3140
  x: i.x,
3141
3141
  // In crop mode, this.x/y is the crop center
3142
3142
  y: i.y
@@ -3144,7 +3144,7 @@ class pt extends Q {
3144
3144
  x: c.x,
3145
3145
  y: c.y,
3146
3146
  rotation: i.rotation
3147
- }).worldDeltaToLocal(d, f), p = s / 2 + m.dx, y = o / 2 + m.dy, w = p / s - h / 2, S = y / o - l / 2;
3147
+ }).worldDeltaToLocal(d, f), p = o / 2 + m.dx, y = s / 2 + m.dy, w = p / o - h / 2, S = y / s - l / 2;
3148
3148
  return {
3149
3149
  cropX: w,
3150
3150
  cropY: S,
@@ -3156,20 +3156,20 @@ class pt extends Q {
3156
3156
  * Check if a given scale keeps crop within frame bounds
3157
3157
  */
3158
3158
  isScaleValidForCropBounds(t, e, i) {
3159
- const o = this.calculateCropStateAtScale(t, e, i);
3160
- if (o.cropWidth > 1 + 1e-4 || o.cropHeight > 1 + 1e-4)
3159
+ const s = this.calculateCropStateAtScale(t, e, i);
3160
+ if (s.cropWidth > 1 + 1e-4 || s.cropHeight > 1 + 1e-4)
3161
3161
  return !1;
3162
- const a = o.cropX, n = o.cropX + o.cropWidth, h = o.cropY, l = o.cropY + o.cropHeight;
3162
+ const a = s.cropX, n = s.cropX + s.cropWidth, h = s.cropY, l = s.cropY + s.cropHeight;
3163
3163
  return a >= -1e-4 && h >= -1e-4 && n <= 1 + 1e-4 && l <= 1 + 1e-4;
3164
3164
  }
3165
3165
  /**
3166
3166
  * Calculate minimum scale that keeps crop within frame bounds
3167
3167
  * Uses binary search to find the largest scale >= proposedScale that satisfies constraints
3168
3168
  */
3169
- calculateMinScaleForCropBounds(t, e, i, s) {
3169
+ calculateMinScaleForCropBounds(t, e, i, o) {
3170
3170
  if (this.isScaleValidForCropBounds(i, t, e))
3171
3171
  return i;
3172
- let n = i, h = s;
3172
+ let n = i, h = o;
3173
3173
  for (let l = 0; l < 20; l++) {
3174
3174
  const c = (n + h) / 2;
3175
3175
  if (this.isScaleValidForCropBounds(c, t, e) ? h = c : n = c, Math.abs(h - n) < 1e-4)
@@ -3182,15 +3182,15 @@ class pt extends Q {
3182
3182
  */
3183
3183
  remapAnchorForFlips(t, e) {
3184
3184
  let i = t;
3185
- const s = x(e).flipHorizontal, o = x(e).flipVertical;
3186
- return s && (i.includes("left") ? i = i.replace("left", "right") : i.includes("right") && (i = i.replace("right", "left"))), o && (i.includes("top") ? i = i.replace("top", "bottom") : i.includes("bottom") && (i = i.replace("bottom", "top"))), i;
3185
+ const o = x(e).flipHorizontal, s = x(e).flipVertical;
3186
+ return o && (i.includes("left") ? i = i.replace("left", "right") : i.includes("right") && (i = i.replace("right", "left"))), s && (i.includes("top") ? i = i.replace("top", "bottom") : i.includes("bottom") && (i = i.replace("bottom", "top"))), i;
3187
3187
  }
3188
3188
  /**
3189
3189
  * Clone this element
3190
3190
  */
3191
3191
  clone() {
3192
- const t = this.toJSON(), { imageUrl: e, ...i } = t, s = new pt(i);
3193
- return s.imageUrl = this.imageUrl, s.imageElement = this.imageElement, s.imageLoaded = this.imageLoaded, s.imageAspectRatio = this.imageAspectRatio, s.isCropping = this.isCropping, s.onLoadCallback = this.onLoadCallback, s.isSvg = this.isSvg, s.imageLoadState = this.imageLoadState, s.imageLoadError = this.imageLoadError, s.preserveDimensions = this.preserveDimensions, s;
3192
+ const t = this.toJSON(), { imageUrl: e, ...i } = t, o = new yt(i);
3193
+ return o.imageUrl = this.imageUrl, o.imageElement = this.imageElement, o.imageLoaded = this.imageLoaded, o.imageAspectRatio = this.imageAspectRatio, o.isCropping = this.isCropping, o.onLoadCallback = this.onLoadCallback, o.isSvg = this.isSvg, o.imageLoadState = this.imageLoadState, o.imageLoadError = this.imageLoadError, o.preserveDimensions = this.preserveDimensions, o;
3194
3194
  }
3195
3195
  /**
3196
3196
  * Serialize to JSON
@@ -3225,7 +3225,7 @@ class pt extends Q {
3225
3225
  }
3226
3226
  }
3227
3227
  const Nt = /* @__PURE__ */ new Map();
3228
- let Tt = null;
3228
+ let vt = null;
3229
3229
  function Ut(r) {
3230
3230
  return new Error(
3231
3231
  `[paint-registry] no painter registered for ${r}. Element painting requires the rendering engine: import 'src/rendering/element-painters.js' (every paint driver — CanvasRenderer, ExportManager, ElementPreviewRenderer — does this; a direct element.render() call in a test must import it too).`
@@ -3240,11 +3240,11 @@ function gt(r) {
3240
3240
  return t;
3241
3241
  }
3242
3242
  function Ai(r) {
3243
- Tt = r;
3243
+ vt = r;
3244
3244
  }
3245
3245
  function Ae() {
3246
- if (!Tt) throw Ut("group clipping");
3247
- return Tt;
3246
+ if (!vt) throw Ut("group clipping");
3247
+ return vt;
3248
3248
  }
3249
3249
  class L {
3250
3250
  constructor(t = []) {
@@ -3293,31 +3293,31 @@ class L {
3293
3293
  applyStyle(t, e, i) {
3294
3294
  if (t >= e || t < 0 || e > this.getLength())
3295
3295
  return;
3296
- const s = [];
3297
- let o = 0;
3296
+ const o = [];
3297
+ let s = 0;
3298
3298
  for (const a of this.spans) {
3299
- const n = o, h = o + a.text.length;
3299
+ const n = s, h = s + a.text.length;
3300
3300
  if (h <= t) {
3301
- s.push(a), o = h;
3301
+ o.push(a), s = h;
3302
3302
  continue;
3303
3303
  }
3304
3304
  if (n >= e) {
3305
- s.push(a), o = h;
3305
+ o.push(a), s = h;
3306
3306
  continue;
3307
3307
  }
3308
3308
  const l = Math.max(t, n), c = Math.min(e, h);
3309
- l > n && s.push({
3309
+ l > n && o.push({
3310
3310
  text: a.text.substring(0, l - n),
3311
3311
  style: a.style
3312
- }), s.push({
3312
+ }), o.push({
3313
3313
  text: a.text.substring(l - n, c - n),
3314
3314
  style: { ...a.style, ...i }
3315
- }), c < h && s.push({
3315
+ }), c < h && o.push({
3316
3316
  text: a.text.substring(c - n),
3317
3317
  style: a.style
3318
- }), o = h;
3318
+ }), s = h;
3319
3319
  }
3320
- this.spans = s, this.normalize();
3320
+ this.spans = o, this.normalize();
3321
3321
  }
3322
3322
  /**
3323
3323
  * Insert text at a specific position with a given style
@@ -3327,24 +3327,24 @@ class L {
3327
3327
  */
3328
3328
  insert(t, e, i) {
3329
3329
  if (e.length === 0) return;
3330
- const s = [];
3331
- let o = 0;
3330
+ const o = [];
3331
+ let s = 0;
3332
3332
  for (const a of this.spans) {
3333
- const n = o, h = o + a.text.length;
3334
- if (t <= n && s.length === 0 && s.push({ text: e, style: i }), t > n && t <= h) {
3333
+ const n = s, h = s + a.text.length;
3334
+ if (t <= n && o.length === 0 && o.push({ text: e, style: i }), t > n && t <= h) {
3335
3335
  const l = t - n;
3336
- s.push({
3336
+ o.push({
3337
3337
  text: a.text.substring(0, l),
3338
3338
  style: a.style
3339
- }), s.push({ text: e, style: i }), s.push({
3339
+ }), o.push({ text: e, style: i }), o.push({
3340
3340
  text: a.text.substring(l),
3341
3341
  style: a.style
3342
- }), o = h;
3342
+ }), s = h;
3343
3343
  continue;
3344
3344
  }
3345
- s.push(a), o = h;
3345
+ o.push(a), s = h;
3346
3346
  }
3347
- t >= this.getLength() && !s.some((a) => a.text === e) && s.push({ text: e, style: i }), this.spans = s, this.normalize();
3347
+ t >= this.getLength() && !o.some((a) => a.text === e) && o.push({ text: e, style: i }), this.spans = o, this.normalize();
3348
3348
  }
3349
3349
  /**
3350
3350
  * Delete text in a character range
@@ -3355,28 +3355,28 @@ class L {
3355
3355
  const i = this.getLength();
3356
3356
  if (t = Math.max(0, Math.min(t, i)), e = Math.max(0, Math.min(e, i)), t >= e)
3357
3357
  return;
3358
- const s = [];
3359
- let o = 0;
3358
+ const o = [];
3359
+ let s = 0;
3360
3360
  for (const a of this.spans) {
3361
- const n = o, h = o + a.text.length;
3361
+ const n = s, h = s + a.text.length;
3362
3362
  if (h <= t) {
3363
- s.push(a), o = h;
3363
+ o.push(a), s = h;
3364
3364
  continue;
3365
3365
  }
3366
3366
  if (n >= e) {
3367
- s.push(a), o = h;
3367
+ o.push(a), s = h;
3368
3368
  continue;
3369
3369
  }
3370
3370
  const l = Math.max(t, n), c = Math.min(e, h);
3371
- l > n && s.push({
3371
+ l > n && o.push({
3372
3372
  text: a.text.substring(0, l - n),
3373
3373
  style: a.style
3374
- }), c < h && s.push({
3374
+ }), c < h && o.push({
3375
3375
  text: a.text.substring(c - n),
3376
3376
  style: a.style
3377
- }), o = h;
3377
+ }), s = h;
3378
3378
  }
3379
- this.spans = s.length > 0 ? s : [{ text: "", style: {} }], this.normalize();
3379
+ this.spans = o.length > 0 ? o : [{ text: "", style: {} }], this.normalize();
3380
3380
  }
3381
3381
  /**
3382
3382
  * Normalize spans by:
@@ -3393,11 +3393,11 @@ class L {
3393
3393
  const t = [];
3394
3394
  let e = this.spans[0];
3395
3395
  for (let i = 1; i < this.spans.length; i++) {
3396
- const s = this.spans[i];
3397
- this.stylesEqual(e.style, s.style) ? e = {
3398
- text: e.text + s.text,
3396
+ const o = this.spans[i];
3397
+ this.stylesEqual(e.style, o.style) ? e = {
3398
+ text: e.text + o.text,
3399
3399
  style: e.style
3400
- } : (t.push(e), e = s);
3400
+ } : (t.push(e), e = o);
3401
3401
  }
3402
3402
  t.push(e), this.spans = t;
3403
3403
  }
@@ -3484,10 +3484,10 @@ function zi(r) {
3484
3484
  function Xi(r) {
3485
3485
  return r.transformType === "path";
3486
3486
  }
3487
- function Yi(r) {
3487
+ function _i(r) {
3488
3488
  return r.type === "shape";
3489
3489
  }
3490
- function _i(r) {
3490
+ function Yi(r) {
3491
3491
  return r.type === "path";
3492
3492
  }
3493
3493
  function Ni(r) {
@@ -3525,8 +3525,8 @@ class q extends Q {
3525
3525
  * handled by SelectionRenderer and HoverRenderer.
3526
3526
  */
3527
3527
  render(t, e = !1, i = !1) {
3528
- const s = t.globalAlpha;
3529
- this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), gt(this.transformType)(t, this.toJSON()), t.globalAlpha = s;
3528
+ const o = t.globalAlpha;
3529
+ this.opacity !== void 0 && this.opacity !== 1 && (t.globalAlpha = this.opacity), gt(this.transformType)(t, this.toJSON()), t.globalAlpha = o;
3530
3530
  }
3531
3531
  /**
3532
3532
  * Serialize to JSON
@@ -3605,8 +3605,8 @@ class q extends Q {
3605
3605
  * Apply character-level formatting to a text range
3606
3606
  */
3607
3607
  applyFormatting(t, e, i) {
3608
- const s = this.getRichText();
3609
- s.applyStyle(t, e, i), this.text = s.getText();
3608
+ const o = this.getRichText();
3609
+ o.applyStyle(t, e, i), this.text = o.getText();
3610
3610
  }
3611
3611
  /**
3612
3612
  * Update font size
@@ -3622,15 +3622,15 @@ class q extends Q {
3622
3622
  const e = this.color;
3623
3623
  if (this.color = t, this.richText)
3624
3624
  for (let i = 0; i < this.richText.spans.length; i++) {
3625
- const s = this.richText.spans[i];
3626
- (s.style.color === void 0 || s.style.color === e) && (s.style.color = t);
3625
+ const o = this.richText.spans[i];
3626
+ (o.style.color === void 0 || o.style.color === e) && (o.style.color = t);
3627
3627
  }
3628
3628
  }
3629
3629
  /**
3630
3630
  * Handle resize transform
3631
3631
  * Must be implemented by subclasses
3632
3632
  */
3633
- resize(t, e, i, s) {
3633
+ resize(t, e, i, o) {
3634
3634
  throw new Error("resize() must be implemented by subclass");
3635
3635
  }
3636
3636
  /**
@@ -3649,15 +3649,15 @@ class q extends Q {
3649
3649
  function Me(r) {
3650
3650
  return Array.from(r).length;
3651
3651
  }
3652
- function yt(r, t, e) {
3652
+ function wt(r, t, e) {
3653
3653
  return e ? r + e * Me(t) : r;
3654
3654
  }
3655
3655
  function De(r, t, e) {
3656
- const i = Array.from(t), s = [0];
3657
- let o = "";
3656
+ const i = Array.from(t), o = [0];
3657
+ let s = "";
3658
3658
  for (let a = 0; a < i.length; a++)
3659
- o += i[a], s.push(r.measureText(o).width + e * (a + 1));
3660
- return s;
3659
+ s += i[a], o.push(r.measureText(s).width + e * (a + 1));
3660
+ return o;
3661
3661
  }
3662
3662
  function Ie(r, t, e) {
3663
3663
  switch (r.textAlign) {
@@ -3670,26 +3670,26 @@ function Ie(r, t, e) {
3670
3670
  return t;
3671
3671
  }
3672
3672
  }
3673
- function Gt(r, t, e, i, s, o) {
3674
- if (!o || e.length === 0) {
3675
- t[r](e, i, s);
3673
+ function Gt(r, t, e, i, o, s) {
3674
+ if (!s || e.length === 0) {
3675
+ t[r](e, i, o);
3676
3676
  return;
3677
3677
  }
3678
- const a = De(t, e, o), n = a[a.length - 1], h = Ie(t, i, n), l = t.textAlign;
3678
+ const a = De(t, e, s), n = a[a.length - 1], h = Ie(t, i, n), l = t.textAlign;
3679
3679
  t.textAlign = "left";
3680
3680
  const c = Array.from(e);
3681
3681
  for (let g = 0; g < c.length; g++)
3682
- t[r](c[g], h + a[g], s);
3682
+ t[r](c[g], h + a[g], o);
3683
3683
  t.textAlign = l;
3684
3684
  }
3685
- function Vi(r, t, e, i, s) {
3686
- Gt("fillText", r, t, e, i, s);
3685
+ function Vi(r, t, e, i, o) {
3686
+ Gt("fillText", r, t, e, i, o);
3687
3687
  }
3688
- function Ji(r, t, e, i, s) {
3689
- Gt("strokeText", r, t, e, i, s);
3688
+ function Ji(r, t, e, i, o) {
3689
+ Gt("strokeText", r, t, e, i, o);
3690
3690
  }
3691
3691
  let ht = null;
3692
- function wt() {
3692
+ function bt() {
3693
3693
  if (!ht)
3694
3694
  if (typeof document < "u")
3695
3695
  ht = document.createElement("canvas");
@@ -3700,13 +3700,13 @@ function wt() {
3700
3700
  return ht;
3701
3701
  }
3702
3702
  function at(r, t, e = !1, i = !1) {
3703
- const s = [];
3704
- return i && s.push("italic"), e && s.push("bold"), s.push(`${r}px`), s.push(t), s.join(" ");
3703
+ const o = [];
3704
+ return i && o.push("italic"), e && o.push("bold"), o.push(`${r}px`), o.push(t), o.join(" ");
3705
3705
  }
3706
- function Ft(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
3707
- const c = wt().getContext("2d");
3708
- c.font = at(e, i, s, o);
3709
- const g = (h == null ? void 0 : h.letterSpacing) ?? 0, d = (A) => yt(c.measureText(A).width, A, g);
3706
+ function At(r, t, e, i, o = !1, s = !1, a, n = !1, h) {
3707
+ const c = bt().getContext("2d");
3708
+ c.font = at(e, i, o, s);
3709
+ const g = (h == null ? void 0 : h.letterSpacing) ?? 0, d = (A) => wt(c.measureText(A).width, A, g);
3710
3710
  if (r.trim().length === 0)
3711
3711
  return [r];
3712
3712
  if (r.includes(`
@@ -3714,7 +3714,7 @@ function Ft(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
3714
3714
  const A = r.split(`
3715
3715
  `), k = [];
3716
3716
  for (let R = 0; R < A.length; R++) {
3717
- const H = A[R], E = Ft(H, t, e, i, s, o, void 0, n, h);
3717
+ const H = A[R], E = At(H, t, e, i, o, s, void 0, n, h);
3718
3718
  k.push(...E);
3719
3719
  }
3720
3720
  return k;
@@ -3764,25 +3764,25 @@ function Ft(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
3764
3764
  }
3765
3765
  return v;
3766
3766
  }
3767
- function Bt(r, t, e, i = !1, s = !1, o = 0) {
3768
- const n = wt().getContext("2d");
3769
- return n.font = at(t, e, i, s), yt(n.measureText(r).width, r, o);
3767
+ function Bt(r, t, e, i = !1, o = !1, s = 0) {
3768
+ const n = bt().getContext("2d");
3769
+ return n.font = at(t, e, i, o), wt(n.measureText(r).width, r, s);
3770
3770
  }
3771
- function vt(r, t, e = !1, i = !1) {
3772
- const o = wt().getContext("2d");
3773
- o.font = at(r, t, e, i);
3774
- const n = o.measureText("ÁÉÍgjpqy"), h = n.actualBoundingBoxAscent || r * 0.8, l = n.actualBoundingBoxDescent || r * 0.2, c = h + l;
3771
+ function Ft(r, t, e = !1, i = !1) {
3772
+ const s = bt().getContext("2d");
3773
+ s.font = at(r, t, e, i);
3774
+ const n = s.measureText("ÁÉÍgjpqy"), h = n.actualBoundingBoxAscent || r * 0.8, l = n.actualBoundingBoxDescent || r * 0.2, c = h + l;
3775
3775
  return { ascent: h, descent: l, height: c };
3776
3776
  }
3777
- function Rt(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
3778
- const l = (h == null ? void 0 : h.letterSpacing) ?? 0, c = Ft(r, t, e, i, s, o, a, n, h), g = r.includes(`
3777
+ function Rt(r, t, e, i, o = !1, s = !1, a, n = !1, h) {
3778
+ const l = (h == null ? void 0 : h.letterSpacing) ?? 0, c = At(r, t, e, i, o, s, a, n, h), g = r.includes(`
3779
3779
  `), d = c.map((b, T) => ({
3780
3780
  isParagraphStart: !g && T === 0,
3781
3781
  isParagraphEnd: !g && T === c.length - 1
3782
- })), u = wt().getContext("2d");
3783
- u.font = at(e, i, s, o);
3782
+ })), u = bt().getContext("2d");
3783
+ u.font = at(e, i, o, s);
3784
3784
  let m = 0;
3785
- const p = vt(e, i, s, o);
3785
+ const p = Ft(e, i, o, s);
3786
3786
  let y = 0;
3787
3787
  c.forEach((b, T) => {
3788
3788
  const C = d[T].isParagraphStart, M = d[T].isParagraphEnd;
@@ -3796,12 +3796,12 @@ function Rt(r, t, e, i, s = !1, o = !1, a, n = !1, h) {
3796
3796
  D > 0 && (F = F.substring(0, F.length - D));
3797
3797
  }
3798
3798
  if (y++, F.length > 0) {
3799
- const v = yt(u.measureText(F).width, F, l);
3799
+ const v = wt(u.measureText(F).width, F, l);
3800
3800
  m = Math.max(m, v);
3801
3801
  }
3802
3802
  });
3803
3803
  let w;
3804
- const S = (h == null ? void 0 : h.lineHeight) ?? Yt;
3804
+ const S = (h == null ? void 0 : h.lineHeight) ?? _t;
3805
3805
  if (y === 1)
3806
3806
  w = p.height;
3807
3807
  else if (y === 0)
@@ -3828,9 +3828,9 @@ function ke() {
3828
3828
  return lt;
3829
3829
  }
3830
3830
  function Ee(r, t, e) {
3831
- const i = ke(), s = [], o = (p, y) => {
3831
+ const i = ke(), o = [], s = (p, y) => {
3832
3832
  const w = y.fontSize || e.fontSize, S = y.fontFamily || e.fontFamily, b = y.bold !== void 0 ? y.bold : e.bold || !1, T = y.italic !== void 0 ? y.italic : e.italic || !1, C = y.letterSpacing !== void 0 ? y.letterSpacing : e.letterSpacing ?? 0;
3833
- return i.font = at(w, S, b, T), yt(i.measureText(p).width, p, C);
3833
+ return i.font = at(w, S, b, T), wt(i.measureText(p).width, p, C);
3834
3834
  }, a = (p, y) => p.fontSize === y.fontSize && p.fontFamily === y.fontFamily && p.color === y.color && p.bold === y.bold && p.italic === y.italic && p.underline === y.underline && p.strikethrough === y.strikethrough && p.letterSpacing === y.letterSpacing, n = [];
3835
3835
  r.forEach((p) => {
3836
3836
  n.length > 0 && a(n[n.length - 1].style, p.style) ? n[n.length - 1].text += p.text : n.push({ text: p.text, style: p.style });
@@ -3850,7 +3850,7 @@ function Ee(r, t, e) {
3850
3850
  g.length > 0 && c.push({ text: g, startIdx: d, endIdx: h.length - 1 });
3851
3851
  let f = [], u = 0;
3852
3852
  const m = () => {
3853
- f.length > 0 && (s.push(f), f = [], u = 0);
3853
+ f.length > 0 && (o.push(f), f = [], u = 0);
3854
3854
  };
3855
3855
  return c.forEach((p, y) => {
3856
3856
  const w = [];
@@ -3860,7 +3860,7 @@ function Ee(r, t, e) {
3860
3860
  M !== S ? (w.push({ text: b, style: n[S].style }), b = h[C], S = M) : b += h[C];
3861
3861
  }
3862
3862
  b.length > 0 && w.push({ text: b, style: n[S].style });
3863
- const T = w.reduce((C, M) => C + o(M.text, M.style), 0);
3863
+ const T = w.reduce((C, M) => C + s(M.text, M.style), 0);
3864
3864
  if (p.text === " ") {
3865
3865
  if (f.length > 0) {
3866
3866
  const C = f[f.length - 1];
@@ -3874,7 +3874,7 @@ function Ee(r, t, e) {
3874
3874
  const M = Array.from(C.text);
3875
3875
  let F = "";
3876
3876
  for (const v of M) {
3877
- const D = o(v, C.style);
3877
+ const D = s(v, C.style);
3878
3878
  if (u + D > t && u > 0) {
3879
3879
  if (F.length > 0) {
3880
3880
  if (f.length > 0) {
@@ -3903,27 +3903,27 @@ function Ee(r, t, e) {
3903
3903
  } else
3904
3904
  f.push({ ...C });
3905
3905
  }), u += T;
3906
- }), m(), s.length === 0 && s.push([]), s;
3906
+ }), m(), o.length === 0 && o.push([]), o;
3907
3907
  }
3908
3908
  function Oe(r) {
3909
3909
  const t = [];
3910
3910
  let e = [];
3911
3911
  return r.spans.forEach((i) => {
3912
- const s = i.text.split(`
3912
+ const o = i.text.split(`
3913
3913
  `);
3914
- s.forEach((o, a) => {
3915
- o.length > 0 && e.push({ text: o, style: i.style }), a < s.length - 1 && (t.push(e), e = []);
3914
+ o.forEach((s, a) => {
3915
+ s.length > 0 && e.push({ text: s, style: i.style }), a < o.length - 1 && (t.push(e), e = []);
3916
3916
  });
3917
3917
  }), e.length > 0 && t.push(e), t.length === 0 && t.push([]), t;
3918
3918
  }
3919
- function st(r) {
3919
+ function ot(r) {
3920
3920
  return typeof r.width == "number" ? r.width : void 0;
3921
3921
  }
3922
3922
  function $t(r, t) {
3923
3923
  r.width = t;
3924
3924
  }
3925
3925
  function Be(r, t, e) {
3926
- const i = e.transformData, s = st(i), o = s !== void 0 ? s : e.width ?? 0, a = t / o, n = e.fontSize ?? r.fontSize, h = n * a;
3926
+ const i = e.transformData, o = ot(i), s = o !== void 0 ? o : e.width ?? 0, a = t / s, n = e.fontSize ?? r.fontSize, h = n * a;
3927
3927
  let l;
3928
3928
  if (h < 16 ? l = Math.round(h) : l = Math.round(h * 2) / 2, r.setFontSize(l), e.richText && e.richText instanceof L && typeof r.setRichText == "function") {
3929
3929
  const f = e.richText.clone();
@@ -3935,8 +3935,8 @@ function Be(r, t, e) {
3935
3935
  r.setRichText(f);
3936
3936
  }
3937
3937
  const c = r.transformData;
3938
- if (st(c) !== void 0 && s !== void 0) {
3939
- const d = n > 0 ? l / n : a, f = s * d;
3938
+ if (ot(c) !== void 0 && o !== void 0) {
3939
+ const d = n > 0 ? l / n : a, f = o * d;
3940
3940
  $t(c, Math.max(20, Math.ceil(f)));
3941
3941
  }
3942
3942
  }
@@ -3944,23 +3944,23 @@ function Re(r, t, e, i) {
3944
3944
  if (t !== "middle-left" && t !== "middle-right")
3945
3945
  return;
3946
3946
  r.fontSize = i.fontSize ?? r.fontSize;
3947
- const s = r.transformData;
3948
- if (st(s) !== void 0) {
3949
- $t(s, Math.max(_t, e));
3950
- const a = I.toRadiansInverse(r.rotation), n = Math.cos(a), h = Math.sin(a), l = i.transformData, g = st(l) ?? i.width ?? 0, f = (st(s) ?? 0) - g;
3947
+ const o = r.transformData;
3948
+ if (ot(o) !== void 0) {
3949
+ $t(o, Math.max(Yt, e));
3950
+ const a = I.toRadiansInverse(r.rotation), n = Math.cos(a), h = Math.sin(a), l = i.transformData, g = ot(l) ?? i.width ?? 0, f = (ot(o) ?? 0) - g;
3951
3951
  t === "middle-left" ? (r.x = i.x - f / 2 * n, r.y = i.y - f / 2 * h) : t === "middle-right" && (r.x = i.x + f / 2 * n, r.y = i.y + f / 2 * h);
3952
3952
  }
3953
3953
  }
3954
- function Vt(r, t, e, i, s) {
3955
- const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle");
3956
- o ? Be(r, e, s) : a && Re(r, t, e, s);
3954
+ function Vt(r, t, e, i, o) {
3955
+ const s = t.includes("top") || t.includes("bottom"), a = t.includes("middle");
3956
+ s ? Be(r, e, o) : a && Re(r, t, e, o);
3957
3957
  }
3958
3958
  class He extends q {
3959
3959
  // Temporary property used during resize operations only
3960
3960
  constructor(t = {}) {
3961
3961
  super(t), this.transformType = "custom";
3962
3962
  const e = t.transformData, i = (e == null ? void 0 : e.width) !== void 0 ? e.width : Math.max(
3963
- _t,
3963
+ Yt,
3964
3964
  Bt(this.text, this.fontSize, this.fontFamily, this.bold, this.italic, this.letterSpacing ?? 0) + j * 2
3965
3965
  );
3966
3966
  this.transformData = {
@@ -3974,7 +3974,7 @@ class He extends q {
3974
3974
  * Returns the total height based on the tallest font in each line
3975
3975
  */
3976
3976
  calculateRichTextHeight() {
3977
- const t = this.getRichText(), e = this.transformData.width - j * 2, i = Oe(t), s = [];
3977
+ const t = this.getRichText(), e = this.transformData.width - j * 2, i = Oe(t), o = [];
3978
3978
  if (i.forEach((h) => {
3979
3979
  Ee(h, e, {
3980
3980
  fontSize: this.fontSize,
@@ -3983,22 +3983,22 @@ class He extends q {
3983
3983
  italic: this.italic,
3984
3984
  letterSpacing: this.letterSpacing
3985
3985
  }).forEach((c) => {
3986
- s.push(c);
3986
+ o.push(c);
3987
3987
  });
3988
- }), s.length === 0)
3988
+ }), o.length === 0)
3989
3989
  return 0;
3990
- let o = 0, a = 0;
3991
- s.forEach((h) => {
3990
+ let s = 0, a = 0;
3991
+ o.forEach((h) => {
3992
3992
  h.forEach((l) => {
3993
- const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u = vt(c, g, d, f);
3994
- o = Math.max(o, u.height), a = Math.max(a, u.ascent);
3993
+ const c = l.style.fontSize !== void 0 ? l.style.fontSize : this.fontSize, g = l.style.fontFamily !== void 0 ? l.style.fontFamily : this.fontFamily, d = l.style.bold !== void 0 ? l.style.bold : this.bold, f = l.style.italic !== void 0 ? l.style.italic : this.italic, u = Ft(c, g, d, f);
3994
+ s = Math.max(s, u.height), a = Math.max(a, u.ascent);
3995
3995
  });
3996
3996
  });
3997
- const n = this.fontSize * (this.lineHeight ?? Yt);
3998
- if (s.length === 1)
3999
- return o;
3997
+ const n = this.fontSize * (this.lineHeight ?? _t);
3998
+ if (o.length === 1)
3999
+ return s;
4000
4000
  {
4001
- const h = vt(this.fontSize, this.fontFamily, this.bold, this.italic), l = (s.length - 1) * n + h.height, c = Math.max(0, a - h.ascent), g = Math.max(0, o - a - (h.height - h.ascent));
4001
+ const h = Ft(this.fontSize, this.fontFamily, this.bold, this.italic), l = (o.length - 1) * n + h.height, c = Math.max(0, a - h.ascent), g = Math.max(0, s - a - (h.height - h.ascent));
4002
4002
  return l + c + g;
4003
4003
  }
4004
4004
  }
@@ -4085,13 +4085,13 @@ class He extends q {
4085
4085
  */
4086
4086
  render(t, e = !1, i = !1) {
4087
4087
  var n;
4088
- const s = this.opacity ?? 1, o = !!((n = this.stroke) != null && n.enabled);
4089
- if (s < 1 && o) {
4090
- this.renderWithOffscreen(t, s);
4088
+ const o = this.opacity ?? 1, s = !!((n = this.stroke) != null && n.enabled);
4089
+ if (o < 1 && s) {
4090
+ this.renderWithOffscreen(t, o);
4091
4091
  return;
4092
4092
  }
4093
4093
  const a = t.globalAlpha;
4094
- s !== 1 && (t.globalAlpha = s), gt("custom")(t, this.toJSON()), t.globalAlpha = a;
4094
+ o !== 1 && (t.globalAlpha = o), gt("custom")(t, this.toJSON()), t.globalAlpha = a;
4095
4095
  }
4096
4096
  /**
4097
4097
  * Render stroke+fill to an offscreen canvas at full opacity, then composite
@@ -4099,7 +4099,7 @@ class He extends q {
4099
4099
  */
4100
4100
  renderWithOffscreen(t, e) {
4101
4101
  var d;
4102
- const s = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20, o = this.getVisualBoundingBox(), a = Math.ceil(o.width + s * 2), n = Math.ceil(o.height + s * 2), h = document.createElement("canvas");
4102
+ const o = (((d = this.stroke) == null ? void 0 : d.width) || 0) + 20, s = this.getVisualBoundingBox(), a = Math.ceil(s.width + o * 2), n = Math.ceil(s.height + o * 2), h = document.createElement("canvas");
4103
4103
  h.width = a, h.height = n;
4104
4104
  const l = h.getContext("2d");
4105
4105
  if (!l) {
@@ -4107,14 +4107,14 @@ class He extends q {
4107
4107
  t.globalAlpha = e, gt("custom")(t, this.toJSON()), t.globalAlpha = f;
4108
4108
  return;
4109
4109
  }
4110
- const c = o.x + o.width / 2, g = o.y + o.height / 2;
4110
+ const c = s.x + s.width / 2, g = s.y + s.height / 2;
4111
4111
  l.translate(a / 2 - c, n / 2 - g), gt("custom")(l, this.toJSON()), t.save(), t.globalAlpha = e, t.drawImage(h, c - a / 2, g - n / 2), t.restore();
4112
4112
  }
4113
4113
  /**
4114
4114
  * Override getTransformStartData to capture initial line count
4115
4115
  */
4116
4116
  getTransformStartData() {
4117
- const t = super.getTransformStartData(), e = this.transformData.width - j * 2, i = Ft(this.text, e, this.fontSize, this.fontFamily, this.bold, this.italic, void 0, !1, {
4117
+ const t = super.getTransformStartData(), e = this.transformData.width - j * 2, i = At(this.text, e, this.fontSize, this.fontFamily, this.bold, this.italic, void 0, !1, {
4118
4118
  letterSpacing: this.letterSpacing
4119
4119
  });
4120
4120
  return t.lineCount = i.length, t;
@@ -4124,8 +4124,8 @@ class He extends q {
4124
4124
  * Corner handles: uniform scale (fontSize and width both change) - line count locked
4125
4125
  * Side handles: only width changes - text re-wraps naturally
4126
4126
  */
4127
- resize(t, e, i, s) {
4128
- if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0), Vt(this, t, e, i, s), this._lockedLineCount !== void 0 && this._lockedLineCount > 0) {
4127
+ resize(t, e, i, o) {
4128
+ if (t === "top-left" || t === "top-right" || t === "bottom-left" || t === "bottom-right" || (this._lockedLineCount = void 0), Vt(this, t, e, i, o), this._lockedLineCount !== void 0 && this._lockedLineCount > 0) {
4129
4129
  const n = Bt(
4130
4130
  this.text,
4131
4131
  this.fontSize,
@@ -4179,25 +4179,25 @@ class He extends q {
4179
4179
  }
4180
4180
  }
4181
4181
  function Pe(r, t, e, i) {
4182
- const s = I.toRadians(i), o = Math.cos(s), a = Math.sin(s);
4182
+ const o = I.toRadians(i), s = Math.cos(o), a = Math.sin(o);
4183
4183
  let n = 0, h = 0;
4184
4184
  e === "top-left" ? (n = r.width, h = r.height) : e === "top-right" ? (n = 0, h = r.height) : e === "bottom-left" ? (n = r.width, h = 0) : e === "bottom-right" && (n = 0, h = 0);
4185
- const l = r.x + (n * o - h * a), c = r.y + (n * a + h * o);
4185
+ const l = r.x + (n * s - h * a), c = r.y + (n * a + h * s);
4186
4186
  let g = 0, d = 0;
4187
4187
  e === "top-left" ? (g = t.width, d = t.height) : e === "top-right" ? (g = 0, d = t.height) : e === "bottom-left" ? (g = t.width, d = 0) : e === "bottom-right" && (g = 0, d = 0);
4188
- const f = l - (g * o - d * a), u = c - (g * a + d * o);
4188
+ const f = l - (g * s - d * a), u = c - (g * a + d * s);
4189
4189
  return { x: f, y: u };
4190
4190
  }
4191
4191
  function qi(r, t, e, i = 1) {
4192
- const s = r.width / 2, o = r.height + ge / i, a = r.x + s, n = r.y + o, h = I.toRadians(t), l = Math.cos(h), c = Math.sin(h), g = a - e.x, d = n - e.y, f = g * l - d * c, u = g * c + d * l;
4192
+ const o = r.width / 2, s = r.height + ge / i, a = r.x + o, n = r.y + s, h = I.toRadians(t), l = Math.cos(h), c = Math.sin(h), g = a - e.x, d = n - e.y, f = g * l - d * c, u = g * c + d * l;
4193
4193
  return {
4194
4194
  x: e.x + f,
4195
4195
  y: e.y + u
4196
4196
  };
4197
4197
  }
4198
4198
  function ji(r, t, e) {
4199
- const i = I.toRadians(t), s = Math.cos(i), o = Math.sin(i), a = (c, g) => {
4200
- const d = r.x + c, f = r.y + g, u = d - e.x, m = f - e.y, p = u * s - m * o, y = u * o + m * s;
4199
+ const i = I.toRadians(t), o = Math.cos(i), s = Math.sin(i), a = (c, g) => {
4200
+ const d = r.x + c, f = r.y + g, u = d - e.x, m = f - e.y, p = u * o - m * s, y = u * s + m * o;
4201
4201
  return {
4202
4202
  x: e.x + p,
4203
4203
  y: e.y + y
@@ -4232,16 +4232,16 @@ function ji(r, t, e) {
4232
4232
  l("edge", "middle-bottom", n / 2, h)
4233
4233
  ];
4234
4234
  }
4235
- function Zi(r, t, e, i, s) {
4236
- const o = r - e, a = t - i;
4237
- return o * o + a * a <= s * s;
4235
+ function Zi(r, t, e, i, o) {
4236
+ const s = r - e, a = t - i;
4237
+ return s * s + a * a <= o * o;
4238
4238
  }
4239
4239
  function Ki(r, t, e, i) {
4240
- const s = I.toRadiansInverse(i), o = Math.cos(s), a = Math.sin(s), n = r - e.x, h = t - e.y, l = n * o - h * a, c = n * a + h * o;
4240
+ const o = I.toRadiansInverse(i), s = Math.cos(o), a = Math.sin(o), n = r - e.x, h = t - e.y, l = n * s - h * a, c = n * a + h * s;
4241
4241
  return l >= 0 && l <= e.width && c >= 0 && c <= e.height;
4242
4242
  }
4243
- function tt(r, t, e = "Arial", i = !1, s = !1) {
4244
- const a = document.createElement("canvas").getContext("2d"), n = i ? "bold" : "normal", h = s ? "italic" : "normal";
4243
+ function tt(r, t, e = "Arial", i = !1, o = !1) {
4244
+ const a = document.createElement("canvas").getContext("2d"), n = i ? "bold" : "normal", h = o ? "italic" : "normal";
4245
4245
  return a.font = `${h} ${n} ${t}px ${e}`, a.measureText(r).width;
4246
4246
  }
4247
4247
  function Qi(r) {
@@ -4250,17 +4250,17 @@ function Qi(r) {
4250
4250
  y: r.y + r.height / 2
4251
4251
  };
4252
4252
  }
4253
- function ts(r, t, e, i) {
4253
+ function to(r, t, e, i) {
4254
4254
  return Math.atan2(i - t, e - r);
4255
4255
  }
4256
- function es(r, t, e) {
4256
+ function eo(r, t, e) {
4257
4257
  return Math.abs(r - t) <= e;
4258
4258
  }
4259
- function Le(r, t, e, i, s, o = 0, a = "") {
4259
+ function Le(r, t, e, i, o, s = 0, a = "") {
4260
4260
  const n = r - e, h = t - i;
4261
4261
  let l = Math.atan2(h, n) * (180 / Math.PI);
4262
- if (l = (l % 360 + 360) % 360, s === "corner") {
4263
- if (Math.abs(o) < 0.1) {
4262
+ if (l = (l % 360 + 360) % 360, o === "corner") {
4263
+ if (Math.abs(s) < 0.1) {
4264
4264
  if (a === "top-left" || a === "bottom-right")
4265
4265
  return "nwse-resize";
4266
4266
  if (a === "top-right" || a === "bottom-left")
@@ -4279,9 +4279,9 @@ function We(r) {
4279
4279
  const t = r.getTransform();
4280
4280
  return Math.sqrt(t.a * t.a + t.b * t.b);
4281
4281
  }
4282
- function is(r, t, e = []) {
4282
+ function io(r, t, e = []) {
4283
4283
  const i = We(r);
4284
- r.lineWidth = i > 0 ? t / i : t, e.length > 0 && r.setLineDash(i > 0 ? e.map((s) => s / i) : e);
4284
+ r.lineWidth = i > 0 ? t / i : t, e.length > 0 && r.setLineDash(i > 0 ? e.map((o) => o / i) : e);
4285
4285
  }
4286
4286
  class ze extends q {
4287
4287
  constructor(t = {}) {
@@ -4313,11 +4313,11 @@ class ze extends q {
4313
4313
  * For circular text, calculate the arc bounds where text actually appears
4314
4314
  */
4315
4315
  getVisualBoundingBox() {
4316
- const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, s = tt(this.text, e, this.fontFamily, this.bold, this.italic) / t, o = -Math.PI / 2 - s / 2, a = -Math.PI / 2 + s / 2, n = t > e / 2 ? t - e / 2 : t * 0.1, h = t + e / 2;
4316
+ const t = this.transformData.radius * this.transformData.scale, e = this.fontSize * this.transformData.scale, o = tt(this.text, e, this.fontFamily, this.bold, this.italic) / t, s = -Math.PI / 2 - o / 2, a = -Math.PI / 2 + o / 2, n = t > e / 2 ? t - e / 2 : t * 0.1, h = t + e / 2;
4317
4317
  let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0;
4318
4318
  const f = 10;
4319
4319
  for (let u = 0; u <= f; u++) {
4320
- const m = o + (a - o) * (u / f), p = this.x + Math.cos(m) * n, y = this.y + Math.sin(m) * n, w = this.x + Math.cos(m) * h, S = this.y + Math.sin(m) * h;
4320
+ const m = s + (a - s) * (u / f), p = this.x + Math.cos(m) * n, y = this.y + Math.sin(m) * n, w = this.x + Math.cos(m) * h, S = this.y + Math.sin(m) * h;
4321
4321
  l = Math.min(l, p, w), c = Math.max(c, p, w), g = Math.min(g, y, S), d = Math.max(d, y, S);
4322
4322
  }
4323
4323
  return {
@@ -4336,15 +4336,15 @@ class ze extends q {
4336
4336
  * Handle resize
4337
4337
  * For circle, we maintain uniform scale and keep scale on the transform
4338
4338
  */
4339
- resize(t, e, i, s) {
4340
- const o = s.transformData, a = (e + i) / 2, n = (s.width + s.height) / 2, h = a / n, l = o.scale * h, c = Math.max(0.1, Math.min(10, l));
4339
+ resize(t, e, i, o) {
4340
+ const s = o.transformData, a = (e + i) / 2, n = (o.width + o.height) / 2, h = a / n, l = s.scale * h, c = Math.max(0.1, Math.min(10, l));
4341
4341
  this.transformData.scale = c;
4342
4342
  const g = this.getBoundingBox(), d = Pe(
4343
4343
  {
4344
- x: s.x - o.radius * o.scale,
4345
- y: s.y - o.radius * o.scale,
4346
- width: o.radius * 2 * o.scale,
4347
- height: o.radius * 2 * o.scale
4344
+ x: o.x - s.radius * s.scale,
4345
+ y: o.y - s.radius * s.scale,
4346
+ width: s.radius * 2 * s.scale,
4347
+ height: s.radius * 2 * s.scale
4348
4348
  },
4349
4349
  { width: g.width, height: g.height },
4350
4350
  t,
@@ -4433,10 +4433,10 @@ class Xe extends q {
4433
4433
  };
4434
4434
  }
4435
4435
  getVisualBoundingBox() {
4436
- const t = this.text.split(""), e = t.map((u) => tt(u, this.fontSize, this.fontFamily)), i = e.reduce((u, m) => u + m, 0), s = this.transformData.width / 2, o = 0.3, n = this.fontSize / 2;
4436
+ const t = this.text.split(""), e = t.map((u) => tt(u, this.fontSize, this.fontFamily)), i = e.reduce((u, m) => u + m, 0), o = this.transformData.width / 2, s = 0.3, n = this.fontSize / 2;
4437
4437
  let h = 1 / 0, l = -1 / 0, c = 1 / 0, g = -1 / 0, d = -i / 2;
4438
4438
  t.forEach((u, m) => {
4439
- const p = e[m], y = d + p / 2, w = y / s, S = (Math.pow(w, 2) - 1) * this.transformData.archHeight * this.fontSize, b = 2 * w * this.transformData.archHeight;
4439
+ const p = e[m], y = d + p / 2, w = y / o, S = (Math.pow(w, 2) - 1) * this.transformData.archHeight * this.fontSize, b = 2 * w * this.transformData.archHeight;
4440
4440
  [
4441
4441
  { x: -p / 2, y: -n },
4442
4442
  // top-left
@@ -4447,7 +4447,7 @@ class Xe extends q {
4447
4447
  { x: p / 2, y: n }
4448
4448
  // bottom-right
4449
4449
  ].forEach((C) => {
4450
- const M = C.x, F = C.y + b * o * C.x, v = y + M, D = S + F;
4450
+ const M = C.x, F = C.y + b * s * C.x, v = y + M, D = S + F;
4451
4451
  h = Math.min(h, v), l = Math.max(l, v), c = Math.min(c, D), g = Math.max(g, D);
4452
4452
  }), d += p;
4453
4453
  });
@@ -4459,22 +4459,22 @@ class Xe extends q {
4459
4459
  height: g - c
4460
4460
  };
4461
4461
  }
4462
- resize(t, e, i, s) {
4463
- const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
4464
- if (o) {
4465
- const h = e / s.width, l = s.fontSize * h;
4462
+ resize(t, e, i, o) {
4463
+ const s = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = o.transformData;
4464
+ if (s) {
4465
+ const h = e / o.width, l = o.fontSize * h;
4466
4466
  this.setFontSize(l);
4467
4467
  const c = n.width * h;
4468
4468
  this.transformData.width = Math.max(50, c);
4469
4469
  } else if (a && (t === "middle-left" || t === "middle-right")) {
4470
- this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
4471
- const h = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4470
+ this.fontSize = o.fontSize, this.transformData.width = Math.max(50, e);
4471
+ const h = e - o.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4472
4472
  if (t === "middle-left") {
4473
4473
  const d = -h / 2;
4474
- this.x = s.x + d * c, this.y = s.y + d * g;
4474
+ this.x = o.x + d * c, this.y = o.y + d * g;
4475
4475
  } else if (t === "middle-right") {
4476
4476
  const d = h / 2;
4477
- this.x = s.x + d * c, this.y = s.y + d * g;
4477
+ this.x = o.x + d * c, this.y = o.y + d * g;
4478
4478
  }
4479
4479
  }
4480
4480
  }
@@ -4506,7 +4506,7 @@ class Xe extends q {
4506
4506
  };
4507
4507
  }
4508
4508
  }
4509
- const ot = {
4509
+ const st = {
4510
4510
  amplitude: 0.2,
4511
4511
  // 20% - subtle wave effect
4512
4512
  frequency: 1.2,
@@ -4518,9 +4518,9 @@ const ot = {
4518
4518
  frequency: 2,
4519
4519
  // Standard flag frequency
4520
4520
  width: 200
4521
- }, Ye = {
4522
- archHeight: 0.5
4523
4521
  }, _e = {
4522
+ archHeight: 0.5
4523
+ }, Ye = {
4524
4524
  leanAmount: 0
4525
4525
  }, Ne = {
4526
4526
  ascendAngle: -15
@@ -4531,9 +4531,9 @@ class Ue extends q {
4531
4531
  const e = t.transformData;
4532
4532
  this.transformData = {
4533
4533
  type: "wave",
4534
- amplitude: (e == null ? void 0 : e.amplitude) ?? ot.amplitude,
4535
- frequency: (e == null ? void 0 : e.frequency) ?? ot.frequency,
4536
- width: (e == null ? void 0 : e.width) ?? ot.width
4534
+ amplitude: (e == null ? void 0 : e.amplitude) ?? st.amplitude,
4535
+ frequency: (e == null ? void 0 : e.frequency) ?? st.frequency,
4536
+ width: (e == null ? void 0 : e.width) ?? st.width
4537
4537
  };
4538
4538
  }
4539
4539
  getBoundingBox() {
@@ -4546,18 +4546,18 @@ class Ue extends q {
4546
4546
  };
4547
4547
  }
4548
4548
  getVisualBoundingBox() {
4549
- const t = this.text.split(""), e = t.map((d) => tt(d, this.fontSize, this.fontFamily)), i = e.reduce((d, f) => d + f, 0), o = this.fontSize / 2;
4549
+ const t = this.text.split(""), e = t.map((d) => tt(d, this.fontSize, this.fontFamily)), i = e.reduce((d, f) => d + f, 0), s = this.fontSize / 2;
4550
4550
  let a = 1 / 0, n = -1 / 0, h = 1 / 0, l = -1 / 0, c = -i / 2;
4551
4551
  t.forEach((d, f) => {
4552
4552
  const u = e[f], m = c + u / 2, p = m / (this.transformData.width / 2), y = this.transformData.amplitude * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * p), w = this.transformData.amplitude * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * p);
4553
4553
  [
4554
- { x: -u / 2, y: -o },
4554
+ { x: -u / 2, y: -s },
4555
4555
  // top-left
4556
- { x: u / 2, y: -o },
4556
+ { x: u / 2, y: -s },
4557
4557
  // top-right
4558
- { x: -u / 2, y: o },
4558
+ { x: -u / 2, y: s },
4559
4559
  // bottom-left
4560
- { x: u / 2, y: o }
4560
+ { x: u / 2, y: s }
4561
4561
  // bottom-right
4562
4562
  ].forEach((b) => {
4563
4563
  const T = b.x, C = b.y + w * be * b.x, M = m + T, F = y + C;
@@ -4572,8 +4572,8 @@ class Ue extends q {
4572
4572
  height: l - h
4573
4573
  };
4574
4574
  }
4575
- resize(t, e, i, s) {
4576
- Vt(this, t, e, i, s);
4575
+ resize(t, e, i, o) {
4576
+ Vt(this, t, e, i, o);
4577
4577
  }
4578
4578
  getEnabledAnchors() {
4579
4579
  return ["top-left", "top-right", "bottom-left", "bottom-right"];
@@ -4615,7 +4615,7 @@ class Ge extends q {
4615
4615
  };
4616
4616
  }
4617
4617
  getVisualBoundingBox() {
4618
- const t = this.text.split(""), e = t.map((f) => tt(f, this.fontSize, this.fontFamily)), i = e.reduce((f, u) => f + u, 0), s = 0.3, a = this.fontSize / 2;
4618
+ const t = this.text.split(""), e = t.map((f) => tt(f, this.fontSize, this.fontFamily)), i = e.reduce((f, u) => f + u, 0), o = 0.3, a = this.fontSize / 2;
4619
4619
  let n = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0, g = -i / 2;
4620
4620
  t.forEach((f, u) => {
4621
4621
  const m = e[u], p = g + m / 2, y = p / (this.transformData.width / 2), w = Math.abs(y), S = this.transformData.amplitude * w, b = S * this.fontSize * Math.sin(this.transformData.frequency * Math.PI * y), T = S * this.transformData.frequency * Math.PI * Math.cos(this.transformData.frequency * Math.PI * y), C = this.transformData.amplitude * Math.sign(y) * Math.sin(this.transformData.frequency * Math.PI * y), M = T + C;
@@ -4629,7 +4629,7 @@ class Ge extends q {
4629
4629
  { x: m / 2, y: a }
4630
4630
  // bottom-right
4631
4631
  ].forEach((v) => {
4632
- const D = v.x, U = v.y + M * s * v.x, B = p + D, A = b + U;
4632
+ const D = v.x, U = v.y + M * o * v.x, B = p + D, A = b + U;
4633
4633
  n = Math.min(n, B), h = Math.max(h, B), l = Math.min(l, A), c = Math.max(c, A);
4634
4634
  }), g += m;
4635
4635
  });
@@ -4641,22 +4641,22 @@ class Ge extends q {
4641
4641
  height: c - l
4642
4642
  };
4643
4643
  }
4644
- resize(t, e, i, s) {
4645
- const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
4646
- if (o) {
4647
- const h = e / s.width, l = s.fontSize * h;
4644
+ resize(t, e, i, o) {
4645
+ const s = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = o.transformData;
4646
+ if (s) {
4647
+ const h = e / o.width, l = o.fontSize * h;
4648
4648
  this.setFontSize(l);
4649
4649
  const c = n.width * h;
4650
4650
  this.transformData.width = Math.max(50, c);
4651
4651
  } else if (a && (t === "middle-left" || t === "middle-right")) {
4652
- this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
4653
- const h = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4652
+ this.fontSize = o.fontSize, this.transformData.width = Math.max(50, e);
4653
+ const h = e - o.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4654
4654
  if (t === "middle-left") {
4655
4655
  const d = -h / 2;
4656
- this.x = s.x + d * c, this.y = s.y + d * g;
4656
+ this.x = o.x + d * c, this.y = o.y + d * g;
4657
4657
  } else if (t === "middle-right") {
4658
4658
  const d = h / 2;
4659
- this.x = s.x + d * c, this.y = s.y + d * g;
4659
+ this.x = o.x + d * c, this.y = o.y + d * g;
4660
4660
  }
4661
4661
  }
4662
4662
  }
@@ -4710,7 +4710,7 @@ class $e extends q {
4710
4710
  };
4711
4711
  }
4712
4712
  getVisualBoundingBox() {
4713
- const e = tt(this.text, this.fontSize, this.fontFamily), i = this.fontSize * 1.2, s = -this.transformData.leanAmount * Math.PI / 4, o = Math.tan(s), a = [
4713
+ const e = tt(this.text, this.fontSize, this.fontFamily), i = this.fontSize * 1.2, o = -this.transformData.leanAmount * Math.PI / 4, s = Math.tan(o), a = [
4714
4714
  { x: -e / 2, y: -i / 2 },
4715
4715
  // top-left
4716
4716
  { x: e / 2, y: -i / 2 },
@@ -4722,7 +4722,7 @@ class $e extends q {
4722
4722
  ];
4723
4723
  let n = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0;
4724
4724
  a.forEach((d) => {
4725
- const f = d.x + o * d.y, u = d.y;
4725
+ const f = d.x + s * d.y, u = d.y;
4726
4726
  n = Math.min(n, f), h = Math.max(h, f), l = Math.min(l, u), c = Math.max(c, u);
4727
4727
  });
4728
4728
  const g = 2;
@@ -4733,22 +4733,22 @@ class $e extends q {
4733
4733
  height: c - l
4734
4734
  };
4735
4735
  }
4736
- resize(t, e, i, s) {
4737
- const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
4738
- if (o) {
4739
- const h = e / s.width, l = s.fontSize * h;
4736
+ resize(t, e, i, o) {
4737
+ const s = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = o.transformData;
4738
+ if (s) {
4739
+ const h = e / o.width, l = o.fontSize * h;
4740
4740
  this.setFontSize(l);
4741
4741
  const c = n.width * h;
4742
4742
  this.transformData.width = Math.max(50, c);
4743
4743
  } else if (a && (t === "middle-left" || t === "middle-right")) {
4744
- this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
4744
+ this.fontSize = o.fontSize, this.transformData.width = Math.max(50, e);
4745
4745
  const h = e - n.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4746
4746
  if (t === "middle-left") {
4747
4747
  const d = -h / 2;
4748
- this.x = s.x + d * c, this.y = s.y + d * g;
4748
+ this.x = o.x + d * c, this.y = o.y + d * g;
4749
4749
  } else if (t === "middle-right") {
4750
4750
  const d = h / 2;
4751
- this.x = s.x + d * c, this.y = s.y + d * g;
4751
+ this.x = o.x + d * c, this.y = o.y + d * g;
4752
4752
  }
4753
4753
  }
4754
4754
  }
@@ -4791,19 +4791,19 @@ class Ve extends q {
4791
4791
  };
4792
4792
  }
4793
4793
  getBoundingBox() {
4794
- const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width, i = e * Math.tan(t), s = Math.abs(i) + this.fontSize * 1.2, o = i > 0 ? -s : 0;
4794
+ const t = this.transformData.ascendAngle * Math.PI / 180, e = this.transformData.width, i = e * Math.tan(t), o = Math.abs(i) + this.fontSize * 1.2, s = i > 0 ? -o : 0;
4795
4795
  return {
4796
4796
  x: this.x - e / 2,
4797
- y: this.y + o,
4797
+ y: this.y + s,
4798
4798
  width: e,
4799
- height: s
4799
+ height: o
4800
4800
  };
4801
4801
  }
4802
4802
  getVisualBoundingBox() {
4803
- const t = this.text.split(""), e = t.map((m) => tt(m, this.fontSize, this.fontFamily)), i = e.reduce((m, p) => m + p, 0), s = this.transformData.ascendAngle * Math.PI / 180, o = Math.tan(s), a = 1, h = this.fontSize / 2;
4803
+ const t = this.text.split(""), e = t.map((m) => tt(m, this.fontSize, this.fontFamily)), i = e.reduce((m, p) => m + p, 0), o = this.transformData.ascendAngle * Math.PI / 180, s = Math.tan(o), a = 1, h = this.fontSize / 2;
4804
4804
  let l = 1 / 0, c = -1 / 0, g = 1 / 0, d = -1 / 0, f = -i / 2;
4805
4805
  t.forEach((m, p) => {
4806
- const y = e[p], w = f + y / 2, S = w * o;
4806
+ const y = e[p], w = f + y / 2, S = w * s;
4807
4807
  [
4808
4808
  { x: -y / 2, y: -h },
4809
4809
  // top-left
@@ -4814,7 +4814,7 @@ class Ve extends q {
4814
4814
  { x: y / 2, y: h }
4815
4815
  // bottom-right
4816
4816
  ].forEach((T) => {
4817
- const C = T.x, M = T.y + o * a * T.x, F = w + C, v = S + M;
4817
+ const C = T.x, M = T.y + s * a * T.x, F = w + C, v = S + M;
4818
4818
  l = Math.min(l, F), c = Math.max(c, F), g = Math.min(g, v), d = Math.max(d, v);
4819
4819
  }), f += y;
4820
4820
  });
@@ -4826,22 +4826,22 @@ class Ve extends q {
4826
4826
  height: d - g
4827
4827
  };
4828
4828
  }
4829
- resize(t, e, i, s) {
4830
- const o = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = s.transformData;
4831
- if (o) {
4832
- const h = e / s.width, l = s.fontSize * h;
4829
+ resize(t, e, i, o) {
4830
+ const s = t.includes("top") || t.includes("bottom"), a = t.includes("middle"), n = o.transformData;
4831
+ if (s) {
4832
+ const h = e / o.width, l = o.fontSize * h;
4833
4833
  this.setFontSize(l);
4834
4834
  const c = n.width * h;
4835
4835
  this.transformData.width = Math.max(50, c);
4836
4836
  } else if (a && (t === "middle-left" || t === "middle-right")) {
4837
- this.fontSize = s.fontSize, this.transformData.width = Math.max(50, e);
4838
- const h = e - s.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4837
+ this.fontSize = o.fontSize, this.transformData.width = Math.max(50, e);
4838
+ const h = e - o.width, l = this.rotation * Math.PI / 180, c = Math.cos(l), g = Math.sin(l);
4839
4839
  if (t === "middle-left") {
4840
4840
  const d = -h / 2;
4841
- this.x = s.x + d * c, this.y = s.y + d * g;
4841
+ this.x = o.x + d * c, this.y = o.y + d * g;
4842
4842
  } else if (t === "middle-right") {
4843
4843
  const d = h / 2;
4844
- this.x = s.x + d * c, this.y = s.y + d * g;
4844
+ this.x = o.x + d * c, this.y = o.y + d * g;
4845
4845
  }
4846
4846
  }
4847
4847
  }
@@ -4873,16 +4873,16 @@ class Ve extends q {
4873
4873
  };
4874
4874
  }
4875
4875
  }
4876
- class At extends Q {
4876
+ class Mt extends Q {
4877
4877
  constructor(t = {}) {
4878
- var i, s, o, a, n, h, l, c, g, d, f;
4878
+ var i, o, s, a, n, h, l, c, g, d, f;
4879
4879
  super(t), this.transformType = "shape";
4880
4880
  const e = "rectangle";
4881
4881
  this.transformData = {
4882
4882
  type: "shape",
4883
4883
  shapeType: ((i = t.transformData) == null ? void 0 : i.shapeType) || e,
4884
- width: ((s = t.transformData) == null ? void 0 : s.width) || 200,
4885
- height: ((o = t.transformData) == null ? void 0 : o.height) || 200,
4884
+ width: ((o = t.transformData) == null ? void 0 : o.width) || 200,
4885
+ height: ((s = t.transformData) == null ? void 0 : s.height) || 200,
4886
4886
  borderRadius: ((a = t.transformData) == null ? void 0 : a.borderRadius) ?? 3,
4887
4887
  // Default 3% radius (~6px on 200x200 shape, matches hover border)
4888
4888
  radiusX: (n = t.transformData) == null ? void 0 : n.radiusX,
@@ -4925,34 +4925,34 @@ class At extends Q {
4925
4925
  getVisualBoundingBox() {
4926
4926
  const { shapeType: t, width: e, height: i } = this.transformData;
4927
4927
  if (t === "circle") {
4928
- const s = Math.min(e, i) / 2;
4928
+ const o = Math.min(e, i) / 2;
4929
4929
  return {
4930
- x: this.x - s,
4931
- y: this.y - s,
4932
- width: s * 2,
4933
- height: s * 2
4930
+ x: this.x - o,
4931
+ y: this.y - o,
4932
+ width: o * 2,
4933
+ height: o * 2
4934
4934
  };
4935
4935
  }
4936
4936
  if (t === "polygon" || t === "star") {
4937
- const s = Math.min(e, i) / 2;
4938
- let o = 1 / 0, a = 1 / 0, n = -1 / 0, h = -1 / 0;
4937
+ const o = Math.min(e, i) / 2;
4938
+ let s = 1 / 0, a = 1 / 0, n = -1 / 0, h = -1 / 0;
4939
4939
  if (t === "polygon") {
4940
4940
  const l = this.transformData.sides || 5;
4941
4941
  for (let c = 0; c < l; c++) {
4942
- const g = c * 2 * Math.PI / l - Math.PI / 2, d = s * Math.cos(g), f = s * Math.sin(g);
4943
- d < o && (o = d), d > n && (n = d), f < a && (a = f), f > h && (h = f);
4942
+ const g = c * 2 * Math.PI / l - Math.PI / 2, d = o * Math.cos(g), f = o * Math.sin(g);
4943
+ d < s && (s = d), d > n && (n = d), f < a && (a = f), f > h && (h = f);
4944
4944
  }
4945
4945
  } else {
4946
- const l = this.transformData.points || 5, c = s, g = c * (this.transformData.innerRadius ?? 0.4);
4946
+ const l = this.transformData.points || 5, c = o, g = c * (this.transformData.innerRadius ?? 0.4);
4947
4947
  for (let d = 0; d < l * 2; d++) {
4948
4948
  const f = d * Math.PI / l - Math.PI / 2, u = d % 2 === 0 ? c : g, m = u * Math.cos(f), p = u * Math.sin(f);
4949
- m < o && (o = m), m > n && (n = m), p < a && (a = p), p > h && (h = p);
4949
+ m < s && (s = m), m > n && (n = m), p < a && (a = p), p > h && (h = p);
4950
4950
  }
4951
4951
  }
4952
4952
  return {
4953
- x: this.x + o,
4953
+ x: this.x + s,
4954
4954
  y: this.y + a,
4955
- width: n - o,
4955
+ width: n - s,
4956
4956
  height: h - a
4957
4957
  };
4958
4958
  }
@@ -4969,14 +4969,14 @@ class At extends Q {
4969
4969
  */
4970
4970
  render(t, e = !1, i = !1) {
4971
4971
  var n;
4972
- const s = this.opacity ?? 1, o = !!((n = this.stroke) != null && n.enabled);
4973
- if (s < 1 && o) {
4974
- this.renderWithOffscreen(t, s);
4972
+ const o = this.opacity ?? 1, s = !!((n = this.stroke) != null && n.enabled);
4973
+ if (o < 1 && s) {
4974
+ this.renderWithOffscreen(t, o);
4975
4975
  return;
4976
4976
  }
4977
4977
  t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation)), t.fillStyle = this.transformData.fillColor || "#3b82f6";
4978
4978
  const a = this.transformData.fillOpacity ?? 1;
4979
- t.globalAlpha = s * a, this.renderShape(t), t.restore(), o && this.renderStroke(t, s);
4979
+ t.globalAlpha = o * a, this.renderShape(t), t.restore(), s && this.renderStroke(t, o);
4980
4980
  }
4981
4981
  /**
4982
4982
  * Render fill+stroke to a temporary canvas at full opacity, then composite
@@ -4984,7 +4984,7 @@ class At extends Q {
4984
4984
  */
4985
4985
  renderWithOffscreen(t, e) {
4986
4986
  var f;
4987
- const { width: i, height: s } = this.transformData, a = (((f = this.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(i + a * 2), h = Math.ceil(s + a * 2), l = document.createElement("canvas");
4987
+ const { width: i, height: o } = this.transformData, a = (((f = this.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(i + a * 2), h = Math.ceil(o + a * 2), l = document.createElement("canvas");
4988
4988
  l.width = n, l.height = h;
4989
4989
  const c = l.getContext("2d");
4990
4990
  if (!c) {
@@ -5008,55 +5008,55 @@ class At extends Q {
5008
5008
  * Trace the shape path without filling or stroking — used by offscreen render
5009
5009
  */
5010
5010
  traceShapePath(t) {
5011
- const { shapeType: e, width: i, height: s } = this.transformData;
5011
+ const { shapeType: e, width: i, height: o } = this.transformData;
5012
5012
  switch (e) {
5013
5013
  case "rectangle": {
5014
- const o = this.transformData.borderRadius || 0, a = -i / 2, n = -s / 2;
5015
- if (o > 0) {
5016
- const h = Math.min(o / 100 * Math.min(i, s), i / 2, s / 2);
5017
- t.roundRect(a, n, i, s, h);
5014
+ const s = this.transformData.borderRadius || 0, a = -i / 2, n = -o / 2;
5015
+ if (s > 0) {
5016
+ const h = Math.min(s / 100 * Math.min(i, o), i / 2, o / 2);
5017
+ t.roundRect(a, n, i, o, h);
5018
5018
  } else
5019
- t.rect(a, n, i, s);
5019
+ t.rect(a, n, i, o);
5020
5020
  break;
5021
5021
  }
5022
5022
  case "circle": {
5023
- const o = Math.min(i, s) / 2;
5024
- t.arc(0, 0, o, 0, Math.PI * 2);
5023
+ const s = Math.min(i, o) / 2;
5024
+ t.arc(0, 0, s, 0, Math.PI * 2);
5025
5025
  break;
5026
5026
  }
5027
5027
  case "ellipse":
5028
- t.ellipse(0, 0, i / 2, s / 2, 0, 0, Math.PI * 2);
5028
+ t.ellipse(0, 0, i / 2, o / 2, 0, 0, Math.PI * 2);
5029
5029
  break;
5030
5030
  case "triangle": {
5031
- const o = i / 2, a = s / 2;
5032
- t.moveTo(0, -a), t.lineTo(o, a), t.lineTo(-o, a), t.closePath();
5031
+ const s = i / 2, a = o / 2;
5032
+ t.moveTo(0, -a), t.lineTo(s, a), t.lineTo(-s, a), t.closePath();
5033
5033
  break;
5034
5034
  }
5035
5035
  case "polygon": {
5036
- const o = this.transformData.sides || 5, a = Math.min(i, s) / 2;
5037
- for (let n = 0; n < o; n++) {
5038
- const h = n * 2 * Math.PI / o - Math.PI / 2, l = a * Math.cos(h), c = a * Math.sin(h);
5036
+ const s = this.transformData.sides || 5, a = Math.min(i, o) / 2;
5037
+ for (let n = 0; n < s; n++) {
5038
+ const h = n * 2 * Math.PI / s - Math.PI / 2, l = a * Math.cos(h), c = a * Math.sin(h);
5039
5039
  n === 0 ? t.moveTo(l, c) : t.lineTo(l, c);
5040
5040
  }
5041
5041
  t.closePath();
5042
5042
  break;
5043
5043
  }
5044
5044
  case "star": {
5045
- const o = this.transformData.points || 5, a = Math.min(i, s) / 2, n = a * (this.transformData.innerRadius || 0.4);
5046
- for (let h = 0; h < o * 2; h++) {
5047
- const l = h * Math.PI / o - Math.PI / 2, c = h % 2 === 0 ? a : n, g = c * Math.cos(l), d = c * Math.sin(l);
5045
+ const s = this.transformData.points || 5, a = Math.min(i, o) / 2, n = a * (this.transformData.innerRadius || 0.4);
5046
+ for (let h = 0; h < s * 2; h++) {
5047
+ const l = h * Math.PI / s - Math.PI / 2, c = h % 2 === 0 ? a : n, g = c * Math.cos(l), d = c * Math.sin(l);
5048
5048
  h === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
5049
5049
  }
5050
5050
  t.closePath();
5051
5051
  break;
5052
5052
  }
5053
5053
  case "line": {
5054
- const o = i / 2, a = s / 2;
5055
- t.rect(-o, -a, i, s);
5054
+ const s = i / 2, a = o / 2;
5055
+ t.rect(-s, -a, i, o);
5056
5056
  break;
5057
5057
  }
5058
5058
  default:
5059
- t.rect(-i / 2, -s / 2, i, s);
5059
+ t.rect(-i / 2, -o / 2, i, o);
5060
5060
  }
5061
5061
  }
5062
5062
  /**
@@ -5066,32 +5066,32 @@ class At extends Q {
5066
5066
  t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
5067
5067
  const i = this.stroke;
5068
5068
  t.strokeStyle = i.color || "#000000", t.lineWidth = i.width || 2, t.lineCap = i.lineCap || "round", t.lineJoin = i.lineJoin || "round", t.globalAlpha = e * (i.opacity ?? 1), i.dashArray && i.dashArray.length > 0 && t.setLineDash(i.dashArray);
5069
- const { shapeType: s, width: o, height: a } = this.transformData;
5070
- switch (t.beginPath(), s) {
5069
+ const { shapeType: o, width: s, height: a } = this.transformData;
5070
+ switch (t.beginPath(), o) {
5071
5071
  case "rectangle": {
5072
- const n = this.transformData.borderRadius || 0, h = -o / 2, l = -a / 2;
5072
+ const n = this.transformData.borderRadius || 0, h = -s / 2, l = -a / 2;
5073
5073
  if (n > 0) {
5074
- const c = Math.min(n / 100 * Math.min(o, a), o / 2, a / 2);
5075
- t.roundRect(h, l, o, a, c);
5074
+ const c = Math.min(n / 100 * Math.min(s, a), s / 2, a / 2);
5075
+ t.roundRect(h, l, s, a, c);
5076
5076
  } else
5077
- t.rect(h, l, o, a);
5077
+ t.rect(h, l, s, a);
5078
5078
  break;
5079
5079
  }
5080
5080
  case "circle": {
5081
- const n = Math.min(o, a) / 2;
5081
+ const n = Math.min(s, a) / 2;
5082
5082
  t.arc(0, 0, n, 0, Math.PI * 2);
5083
5083
  break;
5084
5084
  }
5085
5085
  case "ellipse":
5086
- t.ellipse(0, 0, o / 2, a / 2, 0, 0, Math.PI * 2);
5086
+ t.ellipse(0, 0, s / 2, a / 2, 0, 0, Math.PI * 2);
5087
5087
  break;
5088
5088
  case "triangle": {
5089
- const n = o / 2, h = a / 2;
5089
+ const n = s / 2, h = a / 2;
5090
5090
  t.moveTo(0, -h), t.lineTo(n, h), t.lineTo(-n, h), t.closePath();
5091
5091
  break;
5092
5092
  }
5093
5093
  case "polygon": {
5094
- const n = this.transformData.sides || 5, h = Math.min(o, a) / 2;
5094
+ const n = this.transformData.sides || 5, h = Math.min(s, a) / 2;
5095
5095
  for (let l = 0; l < n; l++) {
5096
5096
  const c = l * 2 * Math.PI / n - Math.PI / 2, g = h * Math.cos(c), d = h * Math.sin(c);
5097
5097
  l === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
@@ -5100,7 +5100,7 @@ class At extends Q {
5100
5100
  break;
5101
5101
  }
5102
5102
  case "star": {
5103
- const n = this.transformData.points || 5, h = Math.min(o, a) / 2, l = h * (this.transformData.innerRadius || 0.4);
5103
+ const n = this.transformData.points || 5, h = Math.min(s, a) / 2, l = h * (this.transformData.innerRadius || 0.4);
5104
5104
  for (let c = 0; c < n * 2; c++) {
5105
5105
  const g = c * Math.PI / n - Math.PI / 2, d = c % 2 === 0 ? h : l, f = d * Math.cos(g), u = d * Math.sin(g);
5106
5106
  c === 0 ? t.moveTo(f, u) : t.lineTo(f, u);
@@ -5109,12 +5109,12 @@ class At extends Q {
5109
5109
  break;
5110
5110
  }
5111
5111
  case "line": {
5112
- const n = o / 2, h = a / 2;
5113
- t.rect(-n, -h, o, a);
5112
+ const n = s / 2, h = a / 2;
5113
+ t.rect(-n, -h, s, a);
5114
5114
  break;
5115
5115
  }
5116
5116
  default:
5117
- t.rect(-o / 2, -a / 2, o, a);
5117
+ t.rect(-s / 2, -a / 2, s, a);
5118
5118
  }
5119
5119
  t.stroke(), t.restore();
5120
5120
  }
@@ -5122,32 +5122,32 @@ class At extends Q {
5122
5122
  * Render the specific shape based on shapeType
5123
5123
  */
5124
5124
  renderShape(t) {
5125
- const { shapeType: e, width: i, height: s } = this.transformData;
5125
+ const { shapeType: e, width: i, height: o } = this.transformData;
5126
5126
  switch (t.beginPath(), e) {
5127
5127
  case "rectangle":
5128
- this.renderRectangle(t, i, s);
5128
+ this.renderRectangle(t, i, o);
5129
5129
  break;
5130
5130
  case "circle":
5131
- this.renderCircle(t, Math.min(i, s) / 2);
5131
+ this.renderCircle(t, Math.min(i, o) / 2);
5132
5132
  break;
5133
5133
  case "ellipse":
5134
- this.renderEllipse(t, i / 2, s / 2);
5134
+ this.renderEllipse(t, i / 2, o / 2);
5135
5135
  break;
5136
5136
  case "triangle":
5137
- this.renderTriangle(t, i, s);
5137
+ this.renderTriangle(t, i, o);
5138
5138
  break;
5139
5139
  case "polygon":
5140
- this.renderPolygon(t, Math.min(i, s) / 2);
5140
+ this.renderPolygon(t, Math.min(i, o) / 2);
5141
5141
  break;
5142
5142
  case "star":
5143
- this.renderStar(t, Math.min(i, s) / 2);
5143
+ this.renderStar(t, Math.min(i, o) / 2);
5144
5144
  break;
5145
5145
  case "line":
5146
- this.renderLine(t, i, s);
5146
+ this.renderLine(t, i, o);
5147
5147
  return;
5148
5148
  // Line uses stroke, not fill
5149
5149
  default:
5150
- this.renderRectangle(t, i, s);
5150
+ this.renderRectangle(t, i, o);
5151
5151
  }
5152
5152
  t.fill();
5153
5153
  }
@@ -5155,12 +5155,12 @@ class At extends Q {
5155
5155
  * Render a rectangle (with optional border radius)
5156
5156
  */
5157
5157
  renderRectangle(t, e, i) {
5158
- const s = this.transformData.borderRadius || 0, o = -e / 2, a = -i / 2;
5159
- if (s > 0) {
5160
- const n = Math.min(s / 100 * Math.min(e, i), e / 2, i / 2);
5161
- t.roundRect(o, a, e, i, n);
5158
+ const o = this.transformData.borderRadius || 0, s = -e / 2, a = -i / 2;
5159
+ if (o > 0) {
5160
+ const n = Math.min(o / 100 * Math.min(e, i), e / 2, i / 2);
5161
+ t.roundRect(s, a, e, i, n);
5162
5162
  } else
5163
- t.rect(o, a, e, i);
5163
+ t.rect(s, a, e, i);
5164
5164
  }
5165
5165
  /**
5166
5166
  * Render a circle
@@ -5178,16 +5178,16 @@ class At extends Q {
5178
5178
  * Render a triangle (isosceles, pointing up)
5179
5179
  */
5180
5180
  renderTriangle(t, e, i) {
5181
- const s = e / 2, o = i / 2;
5182
- t.moveTo(0, -o), t.lineTo(s, o), t.lineTo(-s, o), t.closePath();
5181
+ const o = e / 2, s = i / 2;
5182
+ t.moveTo(0, -s), t.lineTo(o, s), t.lineTo(-o, s), t.closePath();
5183
5183
  }
5184
5184
  /**
5185
5185
  * Render a regular polygon
5186
5186
  */
5187
5187
  renderPolygon(t, e) {
5188
- const i = Math.max(3, Math.min(20, this.transformData.sides || 5)), s = Math.PI * 2 / i, o = -Math.PI / 2;
5188
+ const i = Math.max(3, Math.min(20, this.transformData.sides || 5)), o = Math.PI * 2 / i, s = -Math.PI / 2;
5189
5189
  for (let a = 0; a <= i; a++) {
5190
- const n = o + s * a, h = Math.cos(n) * e, l = Math.sin(n) * e;
5190
+ const n = s + o * a, h = Math.cos(n) * e, l = Math.sin(n) * e;
5191
5191
  a === 0 ? t.moveTo(h, l) : t.lineTo(h, l);
5192
5192
  }
5193
5193
  t.closePath();
@@ -5196,9 +5196,9 @@ class At extends Q {
5196
5196
  * Render a star
5197
5197
  */
5198
5198
  renderStar(t, e) {
5199
- const i = Math.max(3, Math.min(20, this.transformData.points || 5)), s = Math.max(0.1, Math.min(0.9, this.transformData.innerRadius || 0.4)), o = e * s, a = Math.PI / i, n = -Math.PI / 2;
5199
+ const i = Math.max(3, Math.min(20, this.transformData.points || 5)), o = Math.max(0.1, Math.min(0.9, this.transformData.innerRadius || 0.4)), s = e * o, a = Math.PI / i, n = -Math.PI / 2;
5200
5200
  for (let h = 0; h < i * 2; h++) {
5201
- const l = n + a * h, c = h % 2 === 0 ? e : o, g = Math.cos(l) * c, d = Math.sin(l) * c;
5201
+ const l = n + a * h, c = h % 2 === 0 ? e : s, g = Math.cos(l) * c, d = Math.sin(l) * c;
5202
5202
  h === 0 ? t.moveTo(g, d) : t.lineTo(g, d);
5203
5203
  }
5204
5204
  t.closePath();
@@ -5207,20 +5207,20 @@ class At extends Q {
5207
5207
  * Render a line
5208
5208
  */
5209
5209
  renderLine(t, e, i) {
5210
- const s = e / 2, o = i;
5211
- t.moveTo(-s, 0), t.lineTo(s, 0), t.strokeStyle = this.transformData.fillColor || "#3b82f6", t.lineWidth = o, t.lineCap = "round", t.stroke();
5210
+ const o = e / 2, s = i;
5211
+ t.moveTo(-o, 0), t.lineTo(o, 0), t.strokeStyle = this.transformData.fillColor || "#3b82f6", t.lineWidth = s, t.lineCap = "round", t.stroke();
5212
5212
  }
5213
5213
  /**
5214
5214
  * Handle resize - maintain aspect ratio for circles, free resize for others
5215
5215
  */
5216
- resize(t, e, i, s) {
5217
- const { shapeType: o } = this.transformData;
5218
- if (o === "circle" || o === "polygon" || o === "star") {
5219
- const c = Math.max(e / s.transformData.width, i / s.transformData.height);
5220
- this.transformData.width = s.transformData.width * c, this.transformData.height = s.transformData.height * c;
5221
- } else o === "line" ? (this.transformData.width = e, this.transformData.height = s.transformData.height) : (this.transformData.width = e, this.transformData.height = i);
5222
- this.rotation = s.rotation;
5223
- const a = this.getFixedCorner(t, s), n = this.getOppositeAnchor(t), h = this.getBoundingBox(), l = this.getCornerOffset(n, h);
5216
+ resize(t, e, i, o) {
5217
+ const { shapeType: s } = this.transformData;
5218
+ if (s === "circle" || s === "polygon" || s === "star") {
5219
+ const c = Math.max(e / o.transformData.width, i / o.transformData.height);
5220
+ this.transformData.width = o.transformData.width * c, this.transformData.height = o.transformData.height * c;
5221
+ } else s === "line" ? (this.transformData.width = e, this.transformData.height = o.transformData.height) : (this.transformData.width = e, this.transformData.height = i);
5222
+ this.rotation = o.rotation;
5223
+ const a = this.getFixedCorner(t, o), n = this.getOppositeAnchor(t), h = this.getBoundingBox(), l = this.getCornerOffset(n, h);
5224
5224
  return this.x = a.x - l.x, this.y = a.y - l.y, !0;
5225
5225
  }
5226
5226
  /**
@@ -5252,71 +5252,71 @@ class At extends Q {
5252
5252
  width: e.transformData.width,
5253
5253
  height: e.transformData.height
5254
5254
  };
5255
- let s, o;
5255
+ let o, s;
5256
5256
  switch (t) {
5257
5257
  case "top-left":
5258
- s = i.x + i.width, o = i.y + i.height;
5258
+ o = i.x + i.width, s = i.y + i.height;
5259
5259
  break;
5260
5260
  case "top-right":
5261
- s = i.x, o = i.y + i.height;
5261
+ o = i.x, s = i.y + i.height;
5262
5262
  break;
5263
5263
  case "bottom-left":
5264
- s = i.x + i.width, o = i.y;
5264
+ o = i.x + i.width, s = i.y;
5265
5265
  break;
5266
5266
  case "bottom-right":
5267
- s = i.x, o = i.y;
5267
+ o = i.x, s = i.y;
5268
5268
  break;
5269
5269
  case "middle-left":
5270
- s = i.x + i.width, o = i.y + i.height / 2;
5270
+ o = i.x + i.width, s = i.y + i.height / 2;
5271
5271
  break;
5272
5272
  case "middle-right":
5273
- s = i.x, o = i.y + i.height / 2;
5273
+ o = i.x, s = i.y + i.height / 2;
5274
5274
  break;
5275
5275
  case "middle-top":
5276
- s = i.x + i.width / 2, o = i.y + i.height;
5276
+ o = i.x + i.width / 2, s = i.y + i.height;
5277
5277
  break;
5278
5278
  case "middle-bottom":
5279
- s = i.x + i.width / 2, o = i.y;
5279
+ o = i.x + i.width / 2, s = i.y;
5280
5280
  break;
5281
5281
  default:
5282
- s = i.x + i.width / 2, o = i.y + i.height / 2;
5282
+ o = i.x + i.width / 2, s = i.y + i.height / 2;
5283
5283
  }
5284
- return { x: s, y: o };
5284
+ return { x: o, y: s };
5285
5285
  }
5286
5286
  /**
5287
5287
  * Get the offset of a corner from the center
5288
5288
  */
5289
5289
  getCornerOffset(t, e) {
5290
- let i, s;
5290
+ let i, o;
5291
5291
  switch (t) {
5292
5292
  case "top-left":
5293
- i = -e.width / 2, s = -e.height / 2;
5293
+ i = -e.width / 2, o = -e.height / 2;
5294
5294
  break;
5295
5295
  case "top-right":
5296
- i = e.width / 2, s = -e.height / 2;
5296
+ i = e.width / 2, o = -e.height / 2;
5297
5297
  break;
5298
5298
  case "bottom-left":
5299
- i = -e.width / 2, s = e.height / 2;
5299
+ i = -e.width / 2, o = e.height / 2;
5300
5300
  break;
5301
5301
  case "bottom-right":
5302
- i = e.width / 2, s = e.height / 2;
5302
+ i = e.width / 2, o = e.height / 2;
5303
5303
  break;
5304
5304
  case "middle-left":
5305
- i = -e.width / 2, s = 0;
5305
+ i = -e.width / 2, o = 0;
5306
5306
  break;
5307
5307
  case "middle-right":
5308
- i = e.width / 2, s = 0;
5308
+ i = e.width / 2, o = 0;
5309
5309
  break;
5310
5310
  case "middle-top":
5311
- i = 0, s = -e.height / 2;
5311
+ i = 0, o = -e.height / 2;
5312
5312
  break;
5313
5313
  case "middle-bottom":
5314
- i = 0, s = e.height / 2;
5314
+ i = 0, o = e.height / 2;
5315
5315
  break;
5316
5316
  default:
5317
- i = 0, s = 0;
5317
+ i = 0, o = 0;
5318
5318
  }
5319
- return { x: i, y: s };
5319
+ return { x: i, y: o };
5320
5320
  }
5321
5321
  /**
5322
5322
  * Get enabled anchors - all 8 anchors for most shapes, only corners for circles/polygons
@@ -5338,7 +5338,7 @@ class At extends Q {
5338
5338
  * Clone this element
5339
5339
  */
5340
5340
  clone() {
5341
- return new At(this.toJSON());
5341
+ return new Mt(this.toJSON());
5342
5342
  }
5343
5343
  /**
5344
5344
  * Serialize to JSON
@@ -5360,15 +5360,15 @@ class At extends Q {
5360
5360
  };
5361
5361
  }
5362
5362
  }
5363
- class Mt extends Q {
5363
+ class Dt extends Q {
5364
5364
  constructor(t = {}) {
5365
- var e, i, s, o, a, n, h, l, c, g;
5365
+ var e, i, o, s, a, n, h, l, c, g;
5366
5366
  super(t), this.transformType = "path", this.transformData = {
5367
5367
  type: "path",
5368
5368
  points: ((e = t.transformData) == null ? void 0 : e.points) || [],
5369
5369
  closed: ((i = t.transformData) == null ? void 0 : i.closed) ?? !1,
5370
- width: ((s = t.transformData) == null ? void 0 : s.width) || 200,
5371
- height: ((o = t.transformData) == null ? void 0 : o.height) || 200,
5370
+ width: ((o = t.transformData) == null ? void 0 : o.width) || 200,
5371
+ height: ((s = t.transformData) == null ? void 0 : s.height) || 200,
5372
5372
  fillEnabled: ((a = t.transformData) == null ? void 0 : a.fillEnabled) ?? !1,
5373
5373
  fillColor: ((n = t.transformData) == null ? void 0 : n.fillColor) || Xt(),
5374
5374
  fillOpacity: ((h = t.transformData) == null ? void 0 : h.fillOpacity) ?? 1,
@@ -5416,11 +5416,11 @@ class Mt extends Q {
5416
5416
  * @param p3 End point
5417
5417
  * @param t Parameter from 0 to 1
5418
5418
  */
5419
- bezierPoint(t, e, i, s, o) {
5420
- const a = 1 - o, n = a * a, h = n * a, l = o * o, c = l * o;
5419
+ bezierPoint(t, e, i, o, s) {
5420
+ const a = 1 - s, n = a * a, h = n * a, l = s * s, c = l * s;
5421
5421
  return {
5422
- x: h * t.x + 3 * n * o * e.x + 3 * a * l * i.x + c * s.x,
5423
- y: h * t.y + 3 * n * o * e.y + 3 * a * l * i.y + c * s.y
5422
+ x: h * t.x + 3 * n * s * e.x + 3 * a * l * i.x + c * o.x,
5423
+ y: h * t.y + 3 * n * s * e.y + 3 * a * l * i.y + c * o.y
5424
5424
  };
5425
5425
  }
5426
5426
  /**
@@ -5432,14 +5432,14 @@ class Mt extends Q {
5432
5432
  const { points: t } = this.transformData;
5433
5433
  if (t.length === 0)
5434
5434
  return { x: 0, y: 0, width: 0, height: 0 };
5435
- let e = 1 / 0, i = 1 / 0, s = -1 / 0, o = -1 / 0;
5435
+ let e = 1 / 0, i = 1 / 0, o = -1 / 0, s = -1 / 0;
5436
5436
  for (let d = 0; d < t.length; d++) {
5437
5437
  const f = t[d], u = t[(d + 1) % t.length];
5438
5438
  if (d === t.length - 1 && !this.transformData.closed) {
5439
- e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), o = Math.max(o, f.y);
5439
+ e = Math.min(e, f.x), i = Math.min(i, f.y), o = Math.max(o, f.x), s = Math.max(s, f.y);
5440
5440
  break;
5441
5441
  }
5442
- if (e = Math.min(e, f.x), i = Math.min(i, f.y), s = Math.max(s, f.x), o = Math.max(o, f.y), f.handleOut || u.handleIn) {
5442
+ if (e = Math.min(e, f.x), i = Math.min(i, f.y), o = Math.max(o, f.x), s = Math.max(s, f.y), f.handleOut || u.handleIn) {
5443
5443
  const p = { x: f.x, y: f.y }, y = {
5444
5444
  x: f.x + (((h = f.handleOut) == null ? void 0 : h.x) || 0),
5445
5445
  y: f.y + (((l = f.handleOut) == null ? void 0 : l.y) || 0)
@@ -5449,7 +5449,7 @@ class Mt extends Q {
5449
5449
  }, S = { x: u.x, y: u.y }, b = 20;
5450
5450
  for (let T = 0; T <= b; T++) {
5451
5451
  const C = T / b, M = this.bezierPoint(p, y, w, S, C);
5452
- e = Math.min(e, M.x), i = Math.min(i, M.y), s = Math.max(s, M.x), o = Math.max(o, M.y);
5452
+ e = Math.min(e, M.x), i = Math.min(i, M.y), o = Math.max(o, M.x), s = Math.max(s, M.y);
5453
5453
  }
5454
5454
  }
5455
5455
  }
@@ -5457,8 +5457,8 @@ class Mt extends Q {
5457
5457
  return {
5458
5458
  x: e - n,
5459
5459
  y: i - n,
5460
- width: s - e + a,
5461
- height: o - i + a
5460
+ width: o - e + a,
5461
+ height: s - i + a
5462
5462
  };
5463
5463
  }
5464
5464
  /**
@@ -5472,28 +5472,28 @@ class Mt extends Q {
5472
5472
  * Render the path
5473
5473
  */
5474
5474
  render(t, e = !1, i = !1) {
5475
- const { points: s, closed: o, fillEnabled: a, fillColor: n, fillOpacity: h, strokeEnabled: l, strokeColor: c, strokeWidth: g } = this.transformData;
5476
- if (s.length === 0)
5475
+ const { points: o, closed: s, fillEnabled: a, fillColor: n, fillOpacity: h, strokeEnabled: l, strokeColor: c, strokeWidth: g } = this.transformData;
5476
+ if (o.length === 0)
5477
5477
  return;
5478
5478
  t.save(), t.translate(this.x, this.y), t.rotate(I.toRadians(this.rotation));
5479
5479
  const d = this.calculatePathBounds(), f = d.x + d.width / 2, u = d.y + d.height / 2;
5480
- t.translate(-f, -u), t.beginPath(), this.renderPath(t), a && o && n && (t.fillStyle = n, t.globalAlpha = h ?? 1, t.fill()), l && c && g && (t.strokeStyle = c, t.lineWidth = g, t.lineCap = "round", t.lineJoin = "round", t.globalAlpha = 1, t.stroke()), t.restore();
5480
+ t.translate(-f, -u), t.beginPath(), this.renderPath(t), a && s && n && (t.fillStyle = n, t.globalAlpha = h ?? 1, t.fill()), l && c && g && (t.strokeStyle = c, t.lineWidth = g, t.lineCap = "round", t.lineJoin = "round", t.globalAlpha = 1, t.stroke()), t.restore();
5481
5481
  }
5482
5482
  /**
5483
5483
  * Render the path using Canvas API bezier curves
5484
5484
  */
5485
5485
  renderPath(t) {
5486
- var o, a, n, h;
5486
+ var s, a, n, h;
5487
5487
  const { points: e, closed: i } = this.transformData;
5488
5488
  if (e.length === 0) return;
5489
- const s = e[0];
5490
- t.moveTo(s.x, s.y);
5489
+ const o = e[0];
5490
+ t.moveTo(o.x, o.y);
5491
5491
  for (let l = 0; l < e.length; l++) {
5492
5492
  const c = e[l], g = e[(l + 1) % e.length];
5493
5493
  if (l === e.length - 1 && !i)
5494
5494
  break;
5495
5495
  if (c.handleOut || g.handleIn) {
5496
- const f = c.x + (((o = c.handleOut) == null ? void 0 : o.x) || 0), u = c.y + (((a = c.handleOut) == null ? void 0 : a.y) || 0), m = g.x + (((n = g.handleIn) == null ? void 0 : n.x) || 0), p = g.y + (((h = g.handleIn) == null ? void 0 : h.y) || 0);
5496
+ const f = c.x + (((s = c.handleOut) == null ? void 0 : s.x) || 0), u = c.y + (((a = c.handleOut) == null ? void 0 : a.y) || 0), m = g.x + (((n = g.handleIn) == null ? void 0 : n.x) || 0), p = g.y + (((h = g.handleIn) == null ? void 0 : h.y) || 0);
5497
5497
  t.bezierCurveTo(f, u, m, p, g.x, g.y);
5498
5498
  } else
5499
5499
  t.lineTo(g.x, g.y);
@@ -5503,11 +5503,11 @@ class Mt extends Q {
5503
5503
  /**
5504
5504
  * Handle resize - scale all points relative to center
5505
5505
  */
5506
- resize(t, e, i, s) {
5507
- const o = s.transformData.width, a = s.transformData.height;
5508
- if (o === 0 || a === 0)
5506
+ resize(t, e, i, o) {
5507
+ const s = o.transformData.width, a = o.transformData.height;
5508
+ if (s === 0 || a === 0)
5509
5509
  return !1;
5510
- const n = e / o, h = i / a, l = s.transformData.points;
5510
+ const n = e / s, h = i / a, l = o.transformData.points;
5511
5511
  let c = 1 / 0, g = 1 / 0, d = -1 / 0, f = -1 / 0;
5512
5512
  for (const b of l)
5513
5513
  c = Math.min(c, b.x), g = Math.min(g, b.y), d = Math.max(d, b.x), f = Math.max(f, b.y);
@@ -5518,8 +5518,8 @@ class Mt extends Q {
5518
5518
  y: m + (b.y - m) * h,
5519
5519
  handleIn: b.handleIn ? { x: b.handleIn.x * n, y: b.handleIn.y * h } : void 0,
5520
5520
  handleOut: b.handleOut ? { x: b.handleOut.x * n, y: b.handleOut.y * h } : void 0
5521
- })), this.transformData.width = e, this.transformData.height = i, this.rotation = s.rotation;
5522
- const p = this.getFixedCorner(t, s), y = this.getOppositeAnchor(t), w = this.getBoundingBox(), S = this.getCornerOffset(y, w);
5521
+ })), this.transformData.width = e, this.transformData.height = i, this.rotation = o.rotation;
5522
+ const p = this.getFixedCorner(t, o), y = this.getOppositeAnchor(t), w = this.getBoundingBox(), S = this.getCornerOffset(y, w);
5523
5523
  return this.x = p.x - S.x, this.y = p.y - S.y, !0;
5524
5524
  }
5525
5525
  /**
@@ -5551,71 +5551,71 @@ class Mt extends Q {
5551
5551
  width: e.transformData.width,
5552
5552
  height: e.transformData.height
5553
5553
  };
5554
- let s, o;
5554
+ let o, s;
5555
5555
  switch (t) {
5556
5556
  case "top-left":
5557
- s = i.x + i.width, o = i.y + i.height;
5557
+ o = i.x + i.width, s = i.y + i.height;
5558
5558
  break;
5559
5559
  case "top-right":
5560
- s = i.x, o = i.y + i.height;
5560
+ o = i.x, s = i.y + i.height;
5561
5561
  break;
5562
5562
  case "bottom-left":
5563
- s = i.x + i.width, o = i.y;
5563
+ o = i.x + i.width, s = i.y;
5564
5564
  break;
5565
5565
  case "bottom-right":
5566
- s = i.x, o = i.y;
5566
+ o = i.x, s = i.y;
5567
5567
  break;
5568
5568
  case "middle-left":
5569
- s = i.x + i.width, o = i.y + i.height / 2;
5569
+ o = i.x + i.width, s = i.y + i.height / 2;
5570
5570
  break;
5571
5571
  case "middle-right":
5572
- s = i.x, o = i.y + i.height / 2;
5572
+ o = i.x, s = i.y + i.height / 2;
5573
5573
  break;
5574
5574
  case "middle-top":
5575
- s = i.x + i.width / 2, o = i.y + i.height;
5575
+ o = i.x + i.width / 2, s = i.y + i.height;
5576
5576
  break;
5577
5577
  case "middle-bottom":
5578
- s = i.x + i.width / 2, o = i.y;
5578
+ o = i.x + i.width / 2, s = i.y;
5579
5579
  break;
5580
5580
  default:
5581
- s = i.x + i.width / 2, o = i.y + i.height / 2;
5581
+ o = i.x + i.width / 2, s = i.y + i.height / 2;
5582
5582
  }
5583
- return { x: s, y: o };
5583
+ return { x: o, y: s };
5584
5584
  }
5585
5585
  /**
5586
5586
  * Get the offset of a corner from the center
5587
5587
  */
5588
5588
  getCornerOffset(t, e) {
5589
- let i, s;
5589
+ let i, o;
5590
5590
  switch (t) {
5591
5591
  case "top-left":
5592
- i = -e.width / 2, s = -e.height / 2;
5592
+ i = -e.width / 2, o = -e.height / 2;
5593
5593
  break;
5594
5594
  case "top-right":
5595
- i = e.width / 2, s = -e.height / 2;
5595
+ i = e.width / 2, o = -e.height / 2;
5596
5596
  break;
5597
5597
  case "bottom-left":
5598
- i = -e.width / 2, s = e.height / 2;
5598
+ i = -e.width / 2, o = e.height / 2;
5599
5599
  break;
5600
5600
  case "bottom-right":
5601
- i = e.width / 2, s = e.height / 2;
5601
+ i = e.width / 2, o = e.height / 2;
5602
5602
  break;
5603
5603
  case "middle-left":
5604
- i = -e.width / 2, s = 0;
5604
+ i = -e.width / 2, o = 0;
5605
5605
  break;
5606
5606
  case "middle-right":
5607
- i = e.width / 2, s = 0;
5607
+ i = e.width / 2, o = 0;
5608
5608
  break;
5609
5609
  case "middle-top":
5610
- i = 0, s = -e.height / 2;
5610
+ i = 0, o = -e.height / 2;
5611
5611
  break;
5612
5612
  case "middle-bottom":
5613
- i = 0, s = e.height / 2;
5613
+ i = 0, o = e.height / 2;
5614
5614
  break;
5615
5615
  default:
5616
- i = 0, s = 0;
5616
+ i = 0, o = 0;
5617
5617
  }
5618
- return { x: i, y: s };
5618
+ return { x: i, y: o };
5619
5619
  }
5620
5620
  /**
5621
5621
  * Get enabled anchors - all 8 anchors for free resize
@@ -5636,7 +5636,7 @@ class Mt extends Q {
5636
5636
  * Clone this element
5637
5637
  */
5638
5638
  clone() {
5639
- return new Mt(this.toJSON());
5639
+ return new Dt(this.toJSON());
5640
5640
  }
5641
5641
  /**
5642
5642
  * Serialize to JSON
@@ -5679,7 +5679,7 @@ const Je = {
5679
5679
  {
5680
5680
  key: "archHeight",
5681
5681
  label: "Arch Height",
5682
- defaultInternalValue: Ye.archHeight,
5682
+ defaultInternalValue: _e.archHeight,
5683
5683
  // Slider 0-100 maps to internal -1 to 1
5684
5684
  toSlider: (r) => (r + 1) / 2 * 100,
5685
5685
  fromSlider: (r) => r / 100 * 2 - 1,
@@ -5690,7 +5690,7 @@ const Je = {
5690
5690
  {
5691
5691
  key: "amplitude",
5692
5692
  label: "Wave Amplitude",
5693
- defaultInternalValue: ot.amplitude,
5693
+ defaultInternalValue: st.amplitude,
5694
5694
  // Slider 0-100 maps to internal -0.5 to 0.5 (-50% to +50%)
5695
5695
  toSlider: (r) => (r + 0.5) * 100,
5696
5696
  fromSlider: (r) => r / 100 - 0.5,
@@ -5699,7 +5699,7 @@ const Je = {
5699
5699
  {
5700
5700
  key: "frequency",
5701
5701
  label: "Wave Frequency",
5702
- defaultInternalValue: ot.frequency,
5702
+ defaultInternalValue: st.frequency,
5703
5703
  step: 5,
5704
5704
  // 5% steps for smoother control
5705
5705
  // Slider 0-100 maps to internal 1 to 5
@@ -5732,7 +5732,7 @@ const Je = {
5732
5732
  {
5733
5733
  key: "leanAmount",
5734
5734
  label: "Lean Amount",
5735
- defaultInternalValue: _e.leanAmount,
5735
+ defaultInternalValue: Ye.leanAmount,
5736
5736
  // Slider 0-100 maps to internal -0.5 to 0.5
5737
5737
  // Display as -100% to 100%
5738
5738
  toSlider: (r) => (r + 0.5) * 100,
@@ -5831,42 +5831,42 @@ const Je = {
5831
5831
  { id: "ascend", label: "ASCEND", Component: Ve },
5832
5832
  { id: "wave", label: "WAVE", Component: Ue },
5833
5833
  { id: "flag", label: "FLAG", Component: Ge },
5834
- { id: "shape", label: "SHAPE", Component: At },
5835
- { id: "path", label: "PATH", Component: Mt },
5836
- { id: "image", label: "IMAGE", Component: pt },
5834
+ { id: "shape", label: "SHAPE", Component: Mt },
5835
+ { id: "path", label: "PATH", Component: Dt },
5836
+ { id: "image", label: "IMAGE", Component: yt },
5837
5837
  // Use a getter to break circular dependency: GroupElement imports getTransformById
5838
5838
  // from this module, so GroupElement may be in the TDZ during module evaluation.
5839
5839
  // The getter defers access until runtime when both modules are fully initialized.
5840
5840
  { id: "group", label: "GROUP", get Component() {
5841
- return ut;
5841
+ return mt;
5842
5842
  } }
5843
- ], qt = new Set(Jt.map((r) => r.id)), ft = /* @__PURE__ */ new Map();
5844
- function ss(r, t) {
5843
+ ], qt = new Set(Jt.map((r) => r.id)), ut = /* @__PURE__ */ new Map();
5844
+ function oo(r, t) {
5845
5845
  if (qt.has(r))
5846
5846
  throw new Error(
5847
5847
  `Cannot register transform type "${r}": conflicts with built-in type`
5848
5848
  );
5849
- if (ft.has(r))
5849
+ if (ut.has(r))
5850
5850
  throw new Error(
5851
5851
  `Cannot register transform type "${r}": already registered as a custom type`
5852
5852
  );
5853
- ft.set(r, t);
5853
+ ut.set(r, t);
5854
5854
  }
5855
- function os(r) {
5855
+ function so(r) {
5856
5856
  if (qt.has(r))
5857
5857
  throw new Error(
5858
5858
  `Cannot unregister transform type "${r}": built-in types cannot be removed`
5859
5859
  );
5860
- return ft.delete(r);
5860
+ return ut.delete(r);
5861
5861
  }
5862
5862
  function qe(r) {
5863
5863
  const t = Jt.find((e) => e.id === r);
5864
- return t || ft.get(r);
5864
+ return t || ut.get(r);
5865
5865
  }
5866
- function rs(r) {
5866
+ function ro(r) {
5867
5867
  return Je[r] || [];
5868
5868
  }
5869
- class ut extends Q {
5869
+ class mt extends Q {
5870
5870
  constructor(t = {}) {
5871
5871
  super(t), this.isGroup = !0, this._baseBBoxWidth = 0, this._baseBBoxHeight = 0, this._rotationCenterX = 0, this._rotationCenterY = 0, this.transformType = "group";
5872
5872
  const e = t.children || [];
@@ -5893,17 +5893,17 @@ class ut extends Q {
5893
5893
  getBoundingBox() {
5894
5894
  if (this.children.length === 0)
5895
5895
  return { x: this.x - 50, y: this.y - 50, width: 100, height: 100 };
5896
- let t = 1 / 0, e = 1 / 0, i = -1 / 0, s = -1 / 0;
5897
- return this.children.forEach((o) => {
5898
- const a = o.getVisualBoundingBox();
5899
- this._getRotatedCorners(o, a).forEach((h) => {
5900
- t = Math.min(t, h.x), e = Math.min(e, h.y), i = Math.max(i, h.x), s = Math.max(s, h.y);
5896
+ let t = 1 / 0, e = 1 / 0, i = -1 / 0, o = -1 / 0;
5897
+ return this.children.forEach((s) => {
5898
+ const a = s.getVisualBoundingBox();
5899
+ this._getRotatedCorners(s, a).forEach((h) => {
5900
+ t = Math.min(t, h.x), e = Math.min(e, h.y), i = Math.max(i, h.x), o = Math.max(o, h.y);
5901
5901
  });
5902
5902
  }), {
5903
5903
  x: t,
5904
5904
  y: e,
5905
5905
  width: i - t,
5906
- height: s - e
5906
+ height: o - e
5907
5907
  };
5908
5908
  }
5909
5909
  /**
@@ -5927,7 +5927,7 @@ class ut extends Q {
5927
5927
  * Get the four corners of an element's bounding box in world space
5928
5928
  */
5929
5929
  _getRotatedCorners(t, e) {
5930
- const i = new P(t), s = e.x + e.width / 2, o = e.y + e.height / 2, a = s - t.x, n = o - t.y;
5930
+ const i = new P(t), o = e.x + e.width / 2, s = e.y + e.height / 2, a = o - t.x, n = s - t.y;
5931
5931
  return [
5932
5932
  { localX: a - e.width / 2, localY: n - e.height / 2 },
5933
5933
  { localX: a + e.width / 2, localY: n - e.height / 2 },
@@ -5967,8 +5967,8 @@ class ut extends Q {
5967
5967
  * Elements with isClipping=true clip all elements below them in the group
5968
5968
  */
5969
5969
  render(t, e = !1, i = !1) {
5970
- const s = this.children.filter((a) => a.visible !== !1);
5971
- s.some((a) => a.isClipping) ? Ae()(t, s) : s.forEach((a) => {
5970
+ const o = this.children.filter((a) => a.visible !== !1);
5971
+ o.some((a) => a.isClipping) ? Ae()(t, o) : o.forEach((a) => {
5972
5972
  a.render(t, !1);
5973
5973
  }), e ? this._renderGroupOutline(t, 1) : i && this._renderGroupOutline(t, 0.3);
5974
5974
  }
@@ -5979,8 +5979,8 @@ class ut extends Q {
5979
5979
  _renderGroupOutline(t, e = 1) {
5980
5980
  const i = this.getOrientedBoundingBox();
5981
5981
  t.save(), t.globalAlpha = e, t.strokeStyle = zt(), t.lineWidth = 2, t.setLineDash([5, 5]);
5982
- const s = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
5983
- this.rotation !== 0 && (t.translate(s, o), t.rotate(-this.rotation * Math.PI / 180), t.translate(-s, -o)), t.strokeRect(i.x, i.y, i.width, i.height), t.setLineDash([]), t.restore();
5982
+ const o = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
5983
+ this.rotation !== 0 && (t.translate(o, s), t.rotate(-this.rotation * Math.PI / 180), t.translate(-o, -s)), t.strokeRect(i.x, i.y, i.width, i.height), t.setLineDash([]), t.restore();
5984
5984
  }
5985
5985
  /**
5986
5986
  * Get oriented bounding box (uses cached base dimensions for stability during rotation)
@@ -5997,13 +5997,13 @@ class ut extends Q {
5997
5997
  if (this._baseBBoxWidth > 0 && this._baseBBoxHeight > 0)
5998
5998
  t = this._baseBBoxWidth, e = this._baseBBoxHeight;
5999
5999
  else {
6000
- const o = this.getBoundingBox();
6001
- t = o.width, e = o.height, this._baseBBoxWidth = t, this._baseBBoxHeight = e;
6000
+ const s = this.getBoundingBox();
6001
+ t = s.width, e = s.height, this._baseBBoxWidth = t, this._baseBBoxHeight = e;
6002
6002
  }
6003
- const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
6003
+ const i = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
6004
6004
  return {
6005
6005
  x: i - t / 2,
6006
- y: s - e / 2,
6006
+ y: o - e / 2,
6007
6007
  width: t,
6008
6008
  height: e
6009
6009
  };
@@ -6022,52 +6022,52 @@ class ut extends Q {
6022
6022
  setRotation(t) {
6023
6023
  const e = t - this.rotation;
6024
6024
  this.rotation = t;
6025
- const i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
6026
- this.children.forEach((o) => {
6027
- const a = P.rotatePointAroundAnchor(o.x, o.y, i, s, e);
6028
- o.x = a.x, o.y = a.y, o.setRotation(o.rotation + e);
6029
- }), this.x = i, this.y = s;
6025
+ const i = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
6026
+ this.children.forEach((s) => {
6027
+ const a = P.rotatePointAroundAnchor(s.x, s.y, i, o, e);
6028
+ s.x = a.x, s.y = a.y, s.setRotation(s.rotation + e);
6029
+ }), this.x = i, this.y = o;
6030
6030
  }
6031
6031
  /**
6032
6032
  * Resize the group (scales all children proportionally)
6033
6033
  * Uses the same fixed-corner approach as multi-selection resize
6034
6034
  */
6035
- resize(t, e, i, s) {
6036
- if (!s.childrenStartData || !s.width || !s.height)
6035
+ resize(t, e, i, o) {
6036
+ if (!o.childrenStartData || !o.width || !o.height)
6037
6037
  return;
6038
- const o = e / s.width, a = i / s.height, n = (o + a) / 2;
6038
+ const s = e / o.width, a = i / o.height, n = (s + a) / 2;
6039
6039
  let h, l;
6040
6040
  switch (t) {
6041
6041
  case "top-left":
6042
- h = s.width / 2, l = s.height / 2;
6042
+ h = o.width / 2, l = o.height / 2;
6043
6043
  break;
6044
6044
  case "top-right":
6045
- h = -s.width / 2, l = s.height / 2;
6045
+ h = -o.width / 2, l = o.height / 2;
6046
6046
  break;
6047
6047
  case "bottom-left":
6048
- h = s.width / 2, l = -s.height / 2;
6048
+ h = o.width / 2, l = -o.height / 2;
6049
6049
  break;
6050
6050
  case "bottom-right":
6051
- h = -s.width / 2, l = -s.height / 2;
6051
+ h = -o.width / 2, l = -o.height / 2;
6052
6052
  break;
6053
6053
  default:
6054
6054
  h = 0, l = 0;
6055
6055
  }
6056
- const c = -s.rotation * Math.PI / 180, g = Math.cos(c), d = Math.sin(c), f = s.x + (h * g - l * d), u = s.y + (h * d + l * g);
6056
+ const c = -o.rotation * Math.PI / 180, g = Math.cos(c), d = Math.sin(c), f = o.x + (h * g - l * d), u = o.y + (h * d + l * g);
6057
6057
  this.children.forEach((y, w) => {
6058
- const S = s.childrenStartData[w], b = S.x - f, T = S.y - u, C = f + b * n, M = u + T * n;
6059
- if (y.x = C, y.y = M, y instanceof pt) {
6058
+ const S = o.childrenStartData[w], b = S.x - f, T = S.y - u, C = f + b * n, M = u + T * n;
6059
+ if (y.x = C, y.y = M, y instanceof yt) {
6060
6060
  const F = S.transformData, v = F.width * n, D = F.height * n;
6061
6061
  y.transformData.width = v, y.transformData.height = D;
6062
- } else if (y instanceof ut) {
6062
+ } else if (y instanceof mt) {
6063
6063
  const F = (S.width ?? 0) * n, v = (S.height ?? 0) * n;
6064
6064
  y.resize(t, F, v, S);
6065
6065
  } else {
6066
6066
  const F = (S.width ?? 0) * n, v = (S.height ?? 0) * n;
6067
6067
  y.resize(t, F, v, S);
6068
6068
  }
6069
- }), this._baseBBoxWidth = s.width * n, this._baseBBoxHeight = s.height * n;
6070
- const m = s.x - f, p = s.y - u;
6069
+ }), this._baseBBoxWidth = o.width * n, this._baseBBoxHeight = o.height * n;
6070
+ const m = o.x - f, p = o.y - u;
6071
6071
  this.x = f + m * n, this.y = u + p * n, this._rotationCenterX = this.x, this._rotationCenterY = this.y;
6072
6072
  }
6073
6073
  /**
@@ -6075,16 +6075,16 @@ class ut extends Q {
6075
6075
  * Use cached base dimensions instead of axis-aligned bbox for consistency with visual border
6076
6076
  */
6077
6077
  getTransformStartData() {
6078
- const t = this._baseBBoxWidth > 0 ? this._baseBBoxWidth : this.getBoundingBox().width, e = this._baseBBoxHeight > 0 ? this._baseBBoxHeight : this.getBoundingBox().height, i = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
6078
+ const t = this._baseBBoxWidth > 0 ? this._baseBBoxWidth : this.getBoundingBox().width, e = this._baseBBoxHeight > 0 ? this._baseBBoxHeight : this.getBoundingBox().height, i = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
6079
6079
  return {
6080
6080
  id: this.id,
6081
6081
  x: i,
6082
- y: s,
6082
+ y: o,
6083
6083
  width: t,
6084
6084
  height: e,
6085
6085
  rotation: this.rotation,
6086
6086
  transformData: this.transformData,
6087
- childrenStartData: this.children.map((o) => o.getTransformStartData())
6087
+ childrenStartData: this.children.map((s) => s.getTransformStartData())
6088
6088
  };
6089
6089
  }
6090
6090
  /**
@@ -6092,10 +6092,10 @@ class ut extends Q {
6092
6092
  * This allows clicking anywhere within the selection border to drag the group
6093
6093
  */
6094
6094
  hitTest(t, e) {
6095
- const i = this.getOrientedBoundingBox(), s = this._rotationCenterX || this.x, o = this._rotationCenterY || this.y;
6095
+ const i = this.getOrientedBoundingBox(), o = this._rotationCenterX || this.x, s = this._rotationCenterY || this.y;
6096
6096
  if (this.rotation === 0)
6097
6097
  return t >= i.x && t <= i.x + i.width && e >= i.y && e <= i.y + i.height;
6098
- const a = this.rotation * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - s, c = e - o, g = s + (l * n - c * h), d = o + (l * h + c * n);
6098
+ const a = this.rotation * Math.PI / 180, n = Math.cos(a), h = Math.sin(a), l = t - o, c = e - s, g = o + (l * n - c * h), d = s + (l * h + c * n);
6099
6099
  return g >= i.x && g <= i.x + i.width && d >= i.y && d <= i.y + i.height;
6100
6100
  }
6101
6101
  /**
@@ -6121,7 +6121,7 @@ class ut extends Q {
6121
6121
  * Clone the group (deep copy with children)
6122
6122
  */
6123
6123
  clone() {
6124
- const t = this.children.map((i) => i.clone()), e = new ut({
6124
+ const t = this.children.map((i) => i.clone()), e = new mt({
6125
6125
  id: this.id,
6126
6126
  x: this.x,
6127
6127
  y: this.y,
@@ -6162,9 +6162,9 @@ class ut extends Q {
6162
6162
  */
6163
6163
  hitTestChild(t, e) {
6164
6164
  for (let i = this.children.length - 1; i >= 0; i--) {
6165
- const s = this.children[i];
6166
- if (s.hitTest(t, e))
6167
- return s;
6165
+ const o = this.children[i];
6166
+ if (o.hitTest(t, e))
6167
+ return o;
6168
6168
  }
6169
6169
  return null;
6170
6170
  }
@@ -6209,8 +6209,8 @@ class Z {
6209
6209
  getAllByName(t) {
6210
6210
  const e = [];
6211
6211
  for (const i of this.order) {
6212
- const s = this.byId.get(i);
6213
- s && s.name === t && e.push(s);
6212
+ const o = this.byId.get(i);
6213
+ o && o.name === t && e.push(o);
6214
6214
  }
6215
6215
  return e;
6216
6216
  }
@@ -6231,8 +6231,8 @@ class Z {
6231
6231
  const i = this.clone();
6232
6232
  if (t !== e.id) {
6233
6233
  i.byId.delete(t);
6234
- const s = i.order.indexOf(t);
6235
- s !== -1 && (i.order[s] = e.id);
6234
+ const o = i.order.indexOf(t);
6235
+ o !== -1 && (i.order[o] = e.id);
6236
6236
  }
6237
6237
  return i.byId.set(e.id, e), i;
6238
6238
  }
@@ -6245,8 +6245,8 @@ class Z {
6245
6245
  insertAfter(t, e) {
6246
6246
  const i = this.clone();
6247
6247
  i.byId.set(t.id, t);
6248
- const s = i.order.indexOf(e);
6249
- return s !== -1 ? i.order.splice(s + 1, 0, t.id) : i.order.push(t.id), i;
6248
+ const o = i.order.indexOf(e);
6249
+ return o !== -1 ? i.order.splice(o + 1, 0, t.id) : i.order.push(t.id), i;
6250
6250
  }
6251
6251
  /** Remove an element by ID. */
6252
6252
  remove(t) {
@@ -6257,7 +6257,7 @@ class Z {
6257
6257
  /** Reorder element to a new index in the render order. */
6258
6258
  reorder(t, e) {
6259
6259
  const i = this.clone();
6260
- return i.order = i.order.filter((s) => s !== t), i.order.splice(e, 0, t), i;
6260
+ return i.order = i.order.filter((o) => o !== t), i.order.splice(e, 0, t), i;
6261
6261
  }
6262
6262
  /**
6263
6263
  * Apply a batch update: replace elements whose IDs match.
@@ -6311,6 +6311,18 @@ class Z {
6311
6311
  return t.byId = new Map(this.byId), t.order = [...this.order], t;
6312
6312
  }
6313
6313
  }
6314
+ class no extends Error {
6315
+ constructor(t, e, i = {}) {
6316
+ super(`[Editor] ${t}: ${e}`), this.name = "EditorError", this.code = t, this.data = { code: t, ...i };
6317
+ }
6318
+ }
6319
+ function ao(r) {
6320
+ return r instanceof Error && r.name === "EditorError" && "code" in r;
6321
+ }
6322
+ function ho() {
6323
+ var r;
6324
+ return typeof ft < "u" && ((r = ft.env) == null ? void 0 : r.NODE_ENV) !== "production";
6325
+ }
6314
6326
  class $ {
6315
6327
  /**
6316
6328
  * Execute the command
@@ -6325,9 +6337,9 @@ class $ {
6325
6337
  throw new Error("Command.undo() must be implemented");
6326
6338
  }
6327
6339
  }
6328
- class ns extends $ {
6329
- constructor(t, e, i, s) {
6330
- super(), this.elementId = t, this.oldElement = e ? e.clone() : null, this.newElement = i ? i.clone() : null, this.onUpdate = s;
6340
+ class lo extends $ {
6341
+ constructor(t, e, i, o) {
6342
+ super(), this.elementId = t, this.oldElement = e ? e.clone() : null, this.newElement = i ? i.clone() : null, this.onUpdate = o;
6331
6343
  }
6332
6344
  execute() {
6333
6345
  this.newElement && this.onUpdate(this.newElement);
@@ -6336,7 +6348,7 @@ class ns extends $ {
6336
6348
  this.oldElement && this.onUpdate(this.oldElement);
6337
6349
  }
6338
6350
  }
6339
- class as extends $ {
6351
+ class co extends $ {
6340
6352
  constructor(t, e, i) {
6341
6353
  super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
6342
6354
  }
@@ -6347,7 +6359,7 @@ class as extends $ {
6347
6359
  this.onRemove(this.element.id);
6348
6360
  }
6349
6361
  }
6350
- class hs extends $ {
6362
+ class go extends $ {
6351
6363
  constructor(t, e, i) {
6352
6364
  super(), this.element = t.clone(), this.onAdd = e, this.onRemove = i;
6353
6365
  }
@@ -6435,7 +6447,7 @@ class ct {
6435
6447
  };
6436
6448
  }
6437
6449
  }
6438
- class ls extends $ {
6450
+ class fo extends $ {
6439
6451
  constructor(t, e) {
6440
6452
  super(), this.artboard = t.clone(), this.artboardManager = e;
6441
6453
  }
@@ -6455,7 +6467,7 @@ class ls extends $ {
6455
6467
  this.artboardManager.deleteArtboard(this.artboard.id);
6456
6468
  }
6457
6469
  }
6458
- class cs extends $ {
6470
+ class uo extends $ {
6459
6471
  constructor(t, e) {
6460
6472
  super(), this.artboard = t.clone(), this.artboardManager = e, this.elementsOnArtboard = t.getElementIds();
6461
6473
  }
@@ -6478,9 +6490,9 @@ class cs extends $ {
6478
6490
  });
6479
6491
  }
6480
6492
  }
6481
- class ds extends $ {
6482
- constructor(t, e, i, s) {
6483
- super(), this.artboardId = t, this.oldProperties = { ...e }, this.newProperties = { ...i }, this.artboardManager = s;
6493
+ class mo extends $ {
6494
+ constructor(t, e, i, o) {
6495
+ super(), this.artboardId = t, this.oldProperties = { ...e }, this.newProperties = { ...i }, this.artboardManager = o;
6484
6496
  }
6485
6497
  execute() {
6486
6498
  this.artboardManager.updateArtboard(this.artboardId, this.newProperties);
@@ -6489,9 +6501,9 @@ class ds extends $ {
6489
6501
  this.artboardManager.updateArtboard(this.artboardId, this.oldProperties);
6490
6502
  }
6491
6503
  }
6492
- class gs extends $ {
6493
- constructor(t, e, i, s, o) {
6494
- super(), this.draggedId = t, this.targetId = e, this.position = i, this.oldOrder = [...s], this.onReorder = o, this.newOrder = this.calculateNewOrder();
6504
+ class po extends $ {
6505
+ constructor(t, e, i, o, s) {
6506
+ super(), this.draggedId = t, this.targetId = e, this.position = i, this.oldOrder = [...o], this.onReorder = s, this.newOrder = this.calculateNewOrder();
6495
6507
  }
6496
6508
  calculateNewOrder() {
6497
6509
  const t = [...this.oldOrder], e = t.indexOf(this.draggedId);
@@ -6499,8 +6511,8 @@ class gs extends $ {
6499
6511
  t.splice(e, 1);
6500
6512
  const i = t.indexOf(this.targetId);
6501
6513
  if (i === -1) return t;
6502
- const s = this.position === "before" ? i : i + 1;
6503
- return t.splice(s, 0, this.draggedId), t;
6514
+ const o = this.position === "before" ? i : i + 1;
6515
+ return t.splice(o, 0, this.draggedId), t;
6504
6516
  }
6505
6517
  execute() {
6506
6518
  this.onReorder(this.newOrder);
@@ -6509,8 +6521,8 @@ class gs extends $ {
6509
6521
  this.onReorder(this.oldOrder);
6510
6522
  }
6511
6523
  }
6512
- const Ze = mt("HybridHistoryManager");
6513
- class fs {
6524
+ const Ze = pt("HybridHistoryManager");
6525
+ class yo {
6514
6526
  constructor(t, e = 50) {
6515
6527
  this.commandExecutedCallbacks = [], this.globalHistory = new ct(e), this.artboardHistories = /* @__PURE__ */ new Map(), this.lastOperation = null, this.artboardManager = t, this.maxHistorySize = e;
6516
6528
  }
@@ -6528,11 +6540,11 @@ class fs {
6528
6540
  * Notify all callbacks that a command was executed
6529
6541
  */
6530
6542
  notifyCommandExecuted(t, e, i) {
6531
- for (const s of this.commandExecutedCallbacks)
6543
+ for (const o of this.commandExecutedCallbacks)
6532
6544
  try {
6533
- s(t, e, i);
6534
- } catch (o) {
6535
- Ze.error("Error in command executed callback:", o);
6545
+ o(t, e, i);
6546
+ } catch (s) {
6547
+ Ze.error("Error in command executed callback:", s);
6536
6548
  }
6537
6549
  }
6538
6550
  /**
@@ -6571,8 +6583,8 @@ class fs {
6571
6583
  artboardId: t,
6572
6584
  timestamp: Date.now()
6573
6585
  };
6574
- const s = i.history[i.currentIndex];
6575
- this.notifyCommandExecuted(s, "artboard", t);
6586
+ const o = i.history[i.currentIndex];
6587
+ this.notifyCommandExecuted(o, "artboard", t);
6576
6588
  }
6577
6589
  /**
6578
6590
  * Execute a command on a specific artboard
@@ -6738,12 +6750,12 @@ class fs {
6738
6750
  */
6739
6751
  getState() {
6740
6752
  const t = this.globalHistory.getState(), e = /* @__PURE__ */ new Map();
6741
- return this.artboardHistories.forEach((i, s) => {
6742
- const o = i.getState();
6743
- e.set(s, {
6744
- canUndo: o.canUndo,
6745
- canRedo: o.canRedo,
6746
- historySize: o.historySize
6753
+ return this.artboardHistories.forEach((i, o) => {
6754
+ const s = i.getState();
6755
+ e.set(o, {
6756
+ canUndo: s.canUndo,
6757
+ canRedo: s.canRedo,
6758
+ historySize: s.historySize
6747
6759
  });
6748
6760
  }), {
6749
6761
  global: {
@@ -6804,10 +6816,10 @@ class fs {
6804
6816
  return this.canRedoGlobal() ? "Redo artboard operation" : "Nothing to redo";
6805
6817
  }
6806
6818
  }
6807
- const G = mt("FontAnalyzer");
6808
- let bt = null;
6819
+ const G = pt("FontAnalyzer");
6820
+ let xt = null;
6809
6821
  async function Ke() {
6810
- return bt || (bt = await import("./browser-module-DFvKXBUE.js")), bt;
6822
+ return xt || (xt = await import("./browser-module-DFvKXBUE.js")), xt;
6811
6823
  }
6812
6824
  class Qe {
6813
6825
  constructor() {
@@ -6821,8 +6833,8 @@ class Qe {
6821
6833
  evictOldestFont() {
6822
6834
  if (this.fontCache.size <= this.MAX_CACHE_SIZE) return;
6823
6835
  let t = null, e = Date.now();
6824
- this.fontCache.forEach((i, s) => {
6825
- i.timestamp < e && (e = i.timestamp, t = s);
6836
+ this.fontCache.forEach((i, o) => {
6837
+ i.timestamp < e && (e = i.timestamp, t = o);
6826
6838
  }), t && this.fontCache.delete(t);
6827
6839
  }
6828
6840
  /**
@@ -6842,7 +6854,7 @@ class Qe {
6842
6854
  */
6843
6855
  async extractFontFileUrl(t, e = 400) {
6844
6856
  try {
6845
- const i = this.getGoogleFontUrl(t, e), o = await (await fetch(i)).text(), a = /@font-face\s*{([^}]*)}/g, n = Array.from(o.matchAll(a));
6857
+ const i = this.getGoogleFontUrl(t, e), s = await (await fetch(i)).text(), a = /@font-face\s*{([^}]*)}/g, n = Array.from(s.matchAll(a));
6846
6858
  if (n.length === 0)
6847
6859
  return G.warn("No @font-face found in CSS"), null;
6848
6860
  let h = null, l = -1;
@@ -6867,24 +6879,24 @@ class Qe {
6867
6879
  const i = `${t}-${e}`;
6868
6880
  if (this.failedFonts.has(i))
6869
6881
  return null;
6870
- const s = this.fontCache.get(i);
6871
- if (s && Date.now() - s.timestamp < this.CACHE_DURATION)
6872
- return s.timestamp = Date.now(), s.font;
6882
+ const o = this.fontCache.get(i);
6883
+ if (o && Date.now() - o.timestamp < this.CACHE_DURATION)
6884
+ return o.timestamp = Date.now(), o.font;
6873
6885
  try {
6874
- const o = await this.extractFontFileUrl(t, e);
6875
- if (!o)
6886
+ const s = await this.extractFontFileUrl(t, e);
6887
+ if (!s)
6876
6888
  return this.failedFonts.add(i), null;
6877
- const a = await fetch(o);
6889
+ const a = await fetch(s);
6878
6890
  if (!a.ok)
6879
6891
  return G.error(`Font fetch failed: ${a.status} ${a.statusText}`), this.failedFonts.add(i), null;
6880
6892
  const n = await a.arrayBuffer(), h = new Uint8Array(n), c = (await Ke()).create(h), g = "fonts" in c ? c.fonts[0] : c;
6881
6893
  return this.fontCache.set(i, {
6882
6894
  font: g,
6883
- url: o,
6895
+ url: s,
6884
6896
  timestamp: Date.now()
6885
6897
  }), this.evictOldestFont(), g;
6886
- } catch (o) {
6887
- return G.error(`Error loading font ${t}:`, o), this.failedFonts.add(i), null;
6898
+ } catch (s) {
6899
+ return G.error(`Error loading font ${t}:`, s), this.failedFonts.add(i), null;
6888
6900
  }
6889
6901
  }
6890
6902
  /**
@@ -6892,8 +6904,8 @@ class Qe {
6892
6904
  * Returns null if font is not cached - font should be pre-loaded before rendering
6893
6905
  */
6894
6906
  getFontSync(t, e = 400) {
6895
- const i = `${t}-${e}`, s = this.fontCache.get(i);
6896
- return s && Date.now() - s.timestamp < this.CACHE_DURATION ? (s.timestamp = Date.now(), s.font) : null;
6907
+ const i = `${t}-${e}`, o = this.fontCache.get(i);
6908
+ return o && Date.now() - o.timestamp < this.CACHE_DURATION ? (o.timestamp = Date.now(), o.font) : null;
6897
6909
  }
6898
6910
  /**
6899
6911
  * Clear font cache (useful for debugging or forcing reload)
@@ -6913,13 +6925,13 @@ class Qe {
6913
6925
  var n, h;
6914
6926
  if (this.isSystemFont(t))
6915
6927
  return [];
6916
- const s = await this.loadFont(t, e);
6917
- if (!s)
6928
+ const o = await this.loadFont(t, e);
6929
+ if (!o)
6918
6930
  return [];
6919
- const o = [], a = Math.min(s.numGlyphs, i);
6931
+ const s = [], a = Math.min(o.numGlyphs, i);
6920
6932
  for (let l = 0; l < a; l++)
6921
6933
  try {
6922
- const c = s.getGlyph(l);
6934
+ const c = o.getGlyph(l);
6923
6935
  if (!c || !c.name || c.name === ".notdef" || c.name.startsWith(".null"))
6924
6936
  continue;
6925
6937
  const g = c.codePoints || [];
@@ -6944,42 +6956,42 @@ class Qe {
6944
6956
  const m = c.name.toLowerCase();
6945
6957
  if (m.includes("swash") || m.includes("cswh") ? u = "swash" : c.name.match(/\.(alt|ss\d+|cv\d+|salt|ornament)/) || c.name.match(/_\d+$/) ? u = "stylistic" : m.match(/liga|dlig/) && (u = "ligature"), u === "default")
6946
6958
  continue;
6947
- d && d.length > 0 && o.push({
6959
+ d && d.length > 0 && s.push({
6948
6960
  glyphIndex: c.id,
6949
6961
  unicode: d,
6950
6962
  name: f,
6951
6963
  category: u,
6952
- previewDataUrl: this.generateGlyphPreview(s, c.id, 80)
6964
+ previewDataUrl: this.generateGlyphPreview(o, c.id, 80)
6953
6965
  });
6954
6966
  } catch {
6955
6967
  }
6956
- return o;
6968
+ return s;
6957
6969
  }
6958
6970
  /**
6959
6971
  * Get glyph alternates for a specific character
6960
6972
  */
6961
6973
  async getGlyphAlternates(t, e, i = 400) {
6962
6974
  var l, c, g, d;
6963
- const s = await this.loadFont(t, i);
6964
- if (!s)
6975
+ const o = await this.loadFont(t, i);
6976
+ if (!o)
6965
6977
  return [];
6966
- const o = [], a = e.codePointAt(0);
6978
+ const s = [], a = e.codePointAt(0);
6967
6979
  if (a === void 0)
6968
6980
  return [];
6969
- const n = s.glyphForCodePoint(a);
6970
- n && o.push({
6981
+ const n = o.glyphForCodePoint(a);
6982
+ n && s.push({
6971
6983
  glyphIndex: n.id,
6972
6984
  unicode: e,
6973
6985
  name: n.name || "Default",
6974
6986
  category: "default",
6975
- previewDataUrl: this.generateGlyphPreview(s, n.id, 80)
6987
+ previewDataUrl: this.generateGlyphPreview(o, n.id, 80)
6976
6988
  });
6977
6989
  const h = n == null ? void 0 : n.name;
6978
6990
  if (h) {
6979
6991
  let f = 0;
6980
- for (let u = 0; u < s.numGlyphs; u++)
6992
+ for (let u = 0; u < o.numGlyphs; u++)
6981
6993
  try {
6982
- const m = s.getGlyph(u);
6994
+ const m = o.getGlyph(u);
6983
6995
  if (!m || !m.name) continue;
6984
6996
  if ([
6985
6997
  new RegExp(`^${h}\\.(swash|alt|ss\\d+|salt|ornament)`, "i"),
@@ -6997,19 +7009,19 @@ class Qe {
6997
7009
  const S = (c = m.name.match(/\.ss(\d+)/)) == null ? void 0 : c[1];
6998
7010
  w = `${e} Stylistic Set ${S}`;
6999
7011
  }
7000
- o.push({
7012
+ s.push({
7001
7013
  glyphIndex: m.id,
7002
7014
  unicode: e,
7003
7015
  name: w,
7004
7016
  category: "stylistic",
7005
- previewDataUrl: this.generateGlyphPreview(s, m.id, 80)
7017
+ previewDataUrl: this.generateGlyphPreview(o, m.id, 80)
7006
7018
  });
7007
7019
  }
7008
7020
  } catch {
7009
7021
  }
7010
7022
  }
7011
- if (s.GSUB) {
7012
- const f = s.GSUB;
7023
+ if (o.GSUB) {
7024
+ const f = o.GSUB;
7013
7025
  if (f.featureList)
7014
7026
  for (const u of f.featureList) {
7015
7027
  const m = u.tag;
@@ -7023,12 +7035,12 @@ class Qe {
7023
7035
  if (!S) continue;
7024
7036
  if (this.getCoverageIndex(S, n.id) !== -1) {
7025
7037
  const T = this.getSubstituteGlyph(w, n.id);
7026
- T !== null && o.push({
7038
+ T !== null && s.push({
7027
7039
  glyphIndex: T,
7028
7040
  unicode: e,
7029
7041
  name: `${e} (${m})`,
7030
7042
  category: this.categorizeFeature(m),
7031
- previewDataUrl: this.generateGlyphPreview(s, T, 80)
7043
+ previewDataUrl: this.generateGlyphPreview(o, T, 80)
7032
7044
  });
7033
7045
  }
7034
7046
  }
@@ -7041,12 +7053,12 @@ class Qe {
7041
7053
  const C = T.alternateSets[b];
7042
7054
  if (C)
7043
7055
  for (const M of C)
7044
- o.push({
7056
+ s.push({
7045
7057
  glyphIndex: M,
7046
7058
  unicode: e,
7047
7059
  name: `${e} (${m} alt)`,
7048
7060
  category: this.categorizeFeature(m),
7049
- previewDataUrl: this.generateGlyphPreview(s, M, 80)
7061
+ previewDataUrl: this.generateGlyphPreview(o, M, 80)
7050
7062
  });
7051
7063
  }
7052
7064
  }
@@ -7054,7 +7066,7 @@ class Qe {
7054
7066
  }
7055
7067
  }
7056
7068
  }
7057
- return o;
7069
+ return s;
7058
7070
  }
7059
7071
  /**
7060
7072
  * Get available OpenType features for a font
@@ -7064,38 +7076,38 @@ class Qe {
7064
7076
  if (!i)
7065
7077
  return G.warn(`Font ${t} failed to load`), [];
7066
7078
  try {
7067
- const s = [];
7079
+ const o = [];
7068
7080
  if (i.GSUB && i.GSUB.featureList) {
7069
- const o = /* @__PURE__ */ new Set();
7081
+ const s = /* @__PURE__ */ new Set();
7070
7082
  for (const a of i.GSUB.featureList)
7071
- a.tag && o.add(a.tag);
7072
- s.push(...Array.from(o));
7083
+ a.tag && s.add(a.tag);
7084
+ o.push(...Array.from(s));
7073
7085
  }
7074
7086
  if (i.GPOS && i.GPOS.featureList) {
7075
- const o = /* @__PURE__ */ new Set();
7087
+ const s = /* @__PURE__ */ new Set();
7076
7088
  for (const a of i.GPOS.featureList)
7077
- a.tag && o.add(a.tag);
7078
- s.push(...Array.from(o));
7089
+ a.tag && s.add(a.tag);
7090
+ o.push(...Array.from(s));
7079
7091
  }
7080
- return s;
7081
- } catch (s) {
7082
- return G.error(`Error getting features for ${t}:`, s), [];
7092
+ return o;
7093
+ } catch (o) {
7094
+ return G.error(`Error getting features for ${t}:`, o), [];
7083
7095
  }
7084
7096
  }
7085
7097
  /**
7086
7098
  * Generate a preview image for a glyph
7087
7099
  */
7088
7100
  generateGlyphPreview(t, e, i = 80) {
7089
- const s = document.createElement("canvas");
7090
- s.width = i, s.height = i;
7091
- const o = s.getContext("2d");
7092
- if (!o)
7101
+ const o = document.createElement("canvas");
7102
+ o.width = i, o.height = i;
7103
+ const s = o.getContext("2d");
7104
+ if (!s)
7093
7105
  return "";
7094
7106
  try {
7095
7107
  const a = t.getGlyph(e);
7096
7108
  if (!a)
7097
7109
  return "";
7098
- o.clearRect(0, 0, i, i);
7110
+ s.clearRect(0, 0, i, i);
7099
7111
  const n = a.bbox;
7100
7112
  if (!n)
7101
7113
  return "";
@@ -7106,7 +7118,7 @@ class Qe {
7106
7118
  if (!p)
7107
7119
  return "";
7108
7120
  const y = new Path2D(p);
7109
- return o.save(), o.translate(u, m), o.scale(g, -g), o.translate(-d, -f), o.fillStyle = "#000000", o.fill(y), o.restore(), s.toDataURL("image/png");
7121
+ return s.save(), s.translate(u, m), s.scale(g, -g), s.translate(-d, -f), s.fillStyle = "#000000", s.fill(y), s.restore(), o.toDataURL("image/png");
7110
7122
  } catch (a) {
7111
7123
  return G.error("Error generating glyph preview:", a), "";
7112
7124
  }
@@ -7169,10 +7181,10 @@ class Qe {
7169
7181
  return t.glyphs.indexOf(e);
7170
7182
  if (t.format === 2 && t.ranges) {
7171
7183
  const i = t.ranges;
7172
- for (let s = 0; s < i.length; s++) {
7173
- const o = i[s];
7174
- if (e >= o.start && e <= o.end)
7175
- return o.index + (e - o.start);
7184
+ for (let o = 0; o < i.length; o++) {
7185
+ const s = i[o];
7186
+ if (e >= s.start && e <= s.end)
7187
+ return s.index + (e - s.start);
7176
7188
  }
7177
7189
  }
7178
7190
  return -1;
@@ -7185,9 +7197,9 @@ class Qe {
7185
7197
  if (t.substFormat === 1 && typeof t.deltaGlyphId == "number")
7186
7198
  return e + t.deltaGlyphId;
7187
7199
  if (t.substFormat === 2 && t.substitute) {
7188
- const i = this.getCoverageIndex(t.coverage, e), s = t.substitute;
7189
- if (i !== -1 && s[i] !== void 0)
7190
- return s[i];
7200
+ const i = this.getCoverageIndex(t.coverage, e), o = t.substitute;
7201
+ if (i !== -1 && o[i] !== void 0)
7202
+ return o[i];
7191
7203
  }
7192
7204
  return null;
7193
7205
  }
@@ -7198,9 +7210,9 @@ class Qe {
7198
7210
  const i = await this.loadFont(t, e);
7199
7211
  if (!i)
7200
7212
  return 0;
7201
- let s = 0;
7202
- const o = Math.min(i.numGlyphs, 1500);
7203
- for (let a = 0; a < o; a++)
7213
+ let o = 0;
7214
+ const s = Math.min(i.numGlyphs, 1500);
7215
+ for (let a = 0; a < s; a++)
7204
7216
  try {
7205
7217
  const n = i.getGlyph(a);
7206
7218
  if (!n || !n.name || n.name === ".notdef" || n.name.startsWith(".null"))
@@ -7213,10 +7225,10 @@ class Qe {
7213
7225
  }
7214
7226
  let c = "default";
7215
7227
  const g = n.name.toLowerCase();
7216
- g.includes("swash") || g.includes("cswh") ? c = "swash" : n.name.match(/\.(alt|ss\d+|cv\d+|salt|ornament)/) || n.name.match(/_\d+$/) ? c = "stylistic" : g.match(/liga|dlig/) && (c = "ligature"), c !== "default" && l && l.length > 0 && s++;
7228
+ g.includes("swash") || g.includes("cswh") ? c = "swash" : n.name.match(/\.(alt|ss\d+|cv\d+|salt|ornament)/) || n.name.match(/_\d+$/) ? c = "stylistic" : g.match(/liga|dlig/) && (c = "ligature"), c !== "default" && l && l.length > 0 && o++;
7217
7229
  } catch {
7218
7230
  }
7219
- return s;
7231
+ return o;
7220
7232
  }
7221
7233
  /**
7222
7234
  * Get cache statistics
@@ -7228,104 +7240,107 @@ class Qe {
7228
7240
  };
7229
7241
  }
7230
7242
  }
7231
- const us = new Qe();
7243
+ const wo = new Qe();
7232
7244
  export {
7233
- Te as $,
7245
+ qi as $,
7234
7246
  nt as A,
7235
7247
  Q as B,
7236
- he as C,
7237
- Xe as D,
7238
- ti as E,
7248
+ wo as C,
7249
+ ho as D,
7250
+ no as E,
7239
7251
  Ti as F,
7240
- ut as G,
7241
- Ve as H,
7242
- pt as I,
7243
- ze as J,
7244
- He as K,
7245
- Z as L,
7246
- Ge as M,
7247
- fs as N,
7248
- $e as O,
7249
- Mt as P,
7250
- xe as Q,
7252
+ mt as G,
7253
+ he as H,
7254
+ yt as I,
7255
+ Xe as J,
7256
+ ti as K,
7257
+ Ve as L,
7258
+ ze as M,
7259
+ He as N,
7260
+ Z as O,
7261
+ Dt as P,
7262
+ Ge as Q,
7251
7263
  L as R,
7252
- At as S,
7264
+ Mt as S,
7253
7265
  q as T,
7254
- ns as U,
7255
- Pe as V,
7256
- Ue as W,
7257
- ji as X,
7258
- qi as Y,
7259
- Zi as Z,
7260
- Ki as _,
7266
+ lo as U,
7267
+ yo as V,
7268
+ $e as W,
7269
+ xe as X,
7270
+ Ue as Y,
7271
+ Pe as Z,
7272
+ ji as _,
7261
7273
  Ui as a,
7262
- _e as a$,
7263
- Oe as a0,
7264
- Ee as a1,
7265
- at as a2,
7266
- Bt as a3,
7267
- vt as a4,
7268
- Rt as a5,
7269
- Yt as a6,
7270
- Ji as a7,
7271
- j as a8,
7272
- yt as a9,
7273
- is as aA,
7274
- ge as aB,
7275
- si as aC,
7276
- ci as aD,
7277
- ts as aE,
7278
- fe as aF,
7279
- Qi as aG,
7280
- Le as aH,
7281
- es as aI,
7282
- wi as aJ,
7283
- hi as aK,
7284
- li as aL,
7285
- ai as aM,
7286
- de as aN,
7287
- ni as aO,
7288
- ri as aP,
7289
- ii as aQ,
7290
- xi as aR,
7291
- bi as aS,
7292
- oi as aT,
7293
- pi as aU,
7294
- yi as aV,
7295
- ui as aW,
7296
- ei as aX,
7297
- Jt as aY,
7298
- rs as aZ,
7299
- Ci as a_,
7300
- Vi as aa,
7301
- be as ab,
7302
- Fi as ac,
7303
- Ai as ad,
7304
- J as ae,
7305
- as as af,
7306
- hs as ag,
7307
- ls as ah,
7308
- cs as ai,
7309
- ds as aj,
7310
- gs as ak,
7311
- pe as al,
7312
- ye as am,
7313
- mi as an,
7314
- Ye as ao,
7315
- ot as ap,
7316
- vi as aq,
7317
- Ft as ar,
7318
- Xt as as,
7319
- di as at,
7320
- zt as au,
7321
- gi as av,
7322
- fi as aw,
7323
- I as ax,
7324
- P as ay,
7325
- Si as az,
7274
+ Jt as a$,
7275
+ Zi as a0,
7276
+ Ki as a1,
7277
+ Te as a2,
7278
+ Oe as a3,
7279
+ Ee as a4,
7280
+ at as a5,
7281
+ Bt as a6,
7282
+ Ft as a7,
7283
+ Rt as a8,
7284
+ _t as a9,
7285
+ I as aA,
7286
+ P as aB,
7287
+ Si as aC,
7288
+ io as aD,
7289
+ ge as aE,
7290
+ oi as aF,
7291
+ ci as aG,
7292
+ to as aH,
7293
+ fe as aI,
7294
+ Qi as aJ,
7295
+ Le as aK,
7296
+ eo as aL,
7297
+ wi as aM,
7298
+ hi as aN,
7299
+ li as aO,
7300
+ ai as aP,
7301
+ de as aQ,
7302
+ ni as aR,
7303
+ ri as aS,
7304
+ ii as aT,
7305
+ xi as aU,
7306
+ bi as aV,
7307
+ si as aW,
7308
+ pi as aX,
7309
+ yi as aY,
7310
+ ui as aZ,
7311
+ ei as a_,
7312
+ Ji as aa,
7313
+ j as ab,
7314
+ wt as ac,
7315
+ Vi as ad,
7316
+ be as ae,
7317
+ Fi as af,
7318
+ Ai as ag,
7319
+ J as ah,
7320
+ co as ai,
7321
+ go as aj,
7322
+ fo as ak,
7323
+ uo as al,
7324
+ mo as am,
7325
+ po as an,
7326
+ pe as ao,
7327
+ ye as ap,
7328
+ mi as aq,
7329
+ _e as ar,
7330
+ st as as,
7331
+ vi as at,
7332
+ At as au,
7333
+ Xt as av,
7334
+ di as aw,
7335
+ zt as ax,
7336
+ gi as ay,
7337
+ fi as az,
7326
7338
  Ni as b,
7327
- rt as b0,
7328
- mt as c,
7339
+ ro as b0,
7340
+ Ci as b1,
7341
+ Ye as b2,
7342
+ rt as b3,
7343
+ pt as c,
7329
7344
  Li as d,
7330
7345
  Di as e,
7331
7346
  Pi as f,
@@ -7340,14 +7355,14 @@ export {
7340
7355
  Oi as o,
7341
7356
  Gi as p,
7342
7357
  Xi as q,
7343
- ss as r,
7344
- _i as s,
7358
+ oo as r,
7359
+ Yi as s,
7345
7360
  zi as t,
7346
- os as u,
7347
- Yi as v,
7361
+ so as u,
7362
+ _i as v,
7348
7363
  Ri as w,
7349
7364
  ki as x,
7350
- It as y,
7351
- us as z
7365
+ ao as y,
7366
+ ft as z
7352
7367
  };
7353
- //# sourceMappingURL=FontAnalyzer-D4Sg-P6_.js.map
7368
+ //# sourceMappingURL=FontAnalyzer-DKG5JK0x.js.map