@snowcone-app/canvas 0.40.22 → 0.40.24

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 (50) hide show
  1. package/dist/{CanvasRenderer-BmLEU_Zb.js → CanvasRenderer-JcBrIZ6I.js} +454 -452
  2. package/dist/{CanvasRenderer-BmLEU_Zb.js.map → CanvasRenderer-JcBrIZ6I.js.map} +1 -1
  3. package/dist/{CanvasStateV1-DnpfA376.js → CanvasStateV1-BJ5-75NN.js} +3 -3
  4. package/dist/{CanvasStateV1-DnpfA376.js.map → CanvasStateV1-BJ5-75NN.js.map} +1 -1
  5. package/dist/{ContextualToolbars-DSJykxdc.js → ContextualToolbars-wmbHxn5a.js} +2058 -1991
  6. package/dist/{ContextualToolbars-DSJykxdc.js.map → ContextualToolbars-wmbHxn5a.js.map} +1 -1
  7. package/dist/{EditorCanvasImpl-t5MD0lMB.js → EditorCanvasImpl-CI_mLBGt.js} +8 -8
  8. package/dist/{EditorCanvasImpl-t5MD0lMB.js.map → EditorCanvasImpl-CI_mLBGt.js.map} +1 -1
  9. package/dist/{ExportManager-CnUTZrbv.js → ExportManager-CHlByUYV.js} +856 -839
  10. package/dist/ExportManager-CHlByUYV.js.map +1 -0
  11. package/dist/{FontAnalyzer-Bjtl4XTH.js → FontAnalyzer-Bj2KrX80.js} +1592 -1530
  12. package/dist/FontAnalyzer-Bj2KrX80.js.map +1 -0
  13. package/dist/{ImagePanel-AWQgzuXz.js → ImagePanel-0ZwDDaCy.js} +6 -6
  14. package/dist/{ImagePanel-AWQgzuXz.js.map → ImagePanel-0ZwDDaCy.js.map} +1 -1
  15. package/dist/{SnowconeCanvas-BWv3Sd5P.js → SnowconeCanvas-0w0-l9tm.js} +10 -10
  16. package/dist/{SnowconeCanvas-BWv3Sd5P.js.map → SnowconeCanvas-0w0-l9tm.js.map} +1 -1
  17. package/dist/advanced.mjs +39 -39
  18. package/dist/components/toolbars/SecondaryPanels.d.ts +3 -0
  19. package/dist/core/ImageElement.d.ts +20 -0
  20. package/dist/core/TextMetrics.d.ts +14 -2
  21. package/dist/core/masked-crop.d.ts +57 -0
  22. package/dist/{custom-icons-Bn8_I4kt.js → custom-icons-up58ZbC9.js} +2 -2
  23. package/dist/{custom-icons-Bn8_I4kt.js.map → custom-icons-up58ZbC9.js.map} +1 -1
  24. package/dist/{design-builder-B3v5OAQo.js → design-builder-DUEwCUmA.js} +396 -396
  25. package/dist/{design-builder-B3v5OAQo.js.map → design-builder-DUEwCUmA.js.map} +1 -1
  26. package/dist/{embed-D6-jVZMw.js → embed-VKMR6QO1.js} +10 -10
  27. package/dist/{embed-D6-jVZMw.js.map → embed-VKMR6QO1.js.map} +1 -1
  28. package/dist/embed.mjs +7 -7
  29. package/dist/{export-worker.bundle.string-DXciOLDt.js → export-worker.bundle.string-C6Zm9Wt-.js} +146 -27
  30. package/dist/{export-worker.bundle.string-DXciOLDt.js.map → export-worker.bundle.string-C6Zm9Wt-.js.map} +1 -1
  31. package/dist/{guards-B_Q3pewr.js → guards-CQeF53PN.js} +2 -2
  32. package/dist/{guards-B_Q3pewr.js.map → guards-CQeF53PN.js.map} +1 -1
  33. package/dist/index.mjs +9 -9
  34. package/dist/internals.mjs +6 -6
  35. package/dist/rendering/MaskRenderer.d.ts +13 -0
  36. package/dist/{template-fields-B4sJfQjP.js → template-fields-tobyHoMe.js} +5 -5
  37. package/dist/{template-fields-B4sJfQjP.js.map → template-fields-tobyHoMe.js.map} +1 -1
  38. package/dist/testing.mjs +3 -3
  39. package/dist/types/index.d.ts +10 -0
  40. package/dist/{useCommands-CZHeVauL.js → useCommands-Cm3mDB-l.js} +225 -225
  41. package/dist/{useCommands-CZHeVauL.js.map → useCommands-Cm3mDB-l.js.map} +1 -1
  42. package/dist/{usePieceGuideBundle-DsCv7HKy.js → usePieceGuideBundle-BTnUn33k.js} +2 -2
  43. package/dist/{usePieceGuideBundle-DsCv7HKy.js.map → usePieceGuideBundle-BTnUn33k.js.map} +1 -1
  44. package/dist/{validation-D9catdeB.js → validation-D4zxugNJ.js} +11 -11
  45. package/dist/{validation-D9catdeB.js.map → validation-D4zxugNJ.js.map} +1 -1
  46. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  47. package/example/package.json +1 -1
  48. package/package.json +3 -3
  49. package/dist/ExportManager-CnUTZrbv.js.map +0 -1
  50. package/dist/FontAnalyzer-Bjtl4XTH.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { k as re, l as le, _ as nt, m as Ot, $ as he, a0 as ce, a1 as Yt, a2 as de, a3 as gt, a4 as fe, a5 as Gt, a6 as ge, a7 as ue, c as Qt, a8 as pe, a9 as ye, aa as be, ab as Se, v as te, s as ee, ac as pt, w as ne, ad as Lt, ae as Xt, af as Pt, ag as Nt, ah as me, ai as Te, aj as Kt, ak as we, al as ve, am as Me, I as xe, an as Re, ao as Ce, ap as tt } from "./FontAnalyzer-Bjtl4XTH.js";
2
- import { T as Wt, b as ke, v as Pe, L as Ae, M as Dt, A as At, N as Ee, O as He, P as Ie, Q as $t } from "./ExportManager-CnUTZrbv.js";
3
- import { a as _t, i as Be } from "./guards-B_Q3pewr.js";
1
+ import { k as le, l as he, a1 as nt, m as Ot, a2 as ce, a3 as de, a4 as Yt, a5 as fe, a6 as gt, a7 as ge, a8 as Gt, a9 as ue, aa as pe, c as te, ab as ye, ac as be, ad as Se, ae as me, v as ee, s as ne, af as pt, w as se, ag as Lt, ah as Xt, ai as Pt, aj as Nt, ak as Te, al as we, am as Kt, an as ve, ao as Me, ap as xe, I as Re, aq as Ce, ar as ke, as as tt } from "./FontAnalyzer-Bj2KrX80.js";
2
+ import { T as Wt, b as Pe, v as Ae, L as Ee, M as Dt, A as At, N as He, O as Ie, P as Be, Q as $t } from "./ExportManager-CHlByUYV.js";
3
+ import { a as _t, i as jt } from "./guards-CQeF53PN.js";
4
4
  const ct = {
5
5
  // Canvas-specific
6
6
  canvas: {
@@ -15,30 +15,30 @@ const ct = {
15
15
  spacingLabelFontSize: 11,
16
16
  spacingLabelFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
17
17
  }
18
- }, Le = 2, Ct = 6, We = 16, De = 5, _e = 5, se = 0.5;
19
- function jt(v) {
18
+ }, Le = 2, Ct = 6, We = 16, De = 5, _e = 5, oe = 0.5;
19
+ function qt(v) {
20
20
  return Le / v;
21
21
  }
22
- function Qe(v) {
22
+ function tn(v) {
23
23
  return Ct / v;
24
24
  }
25
25
  function ze(v) {
26
26
  return We / v;
27
27
  }
28
- function tn(v) {
28
+ function en(v) {
29
29
  return [De / v, _e / v];
30
30
  }
31
31
  function Ve(v, t, e, s) {
32
32
  v.save();
33
- const n = se / s;
33
+ const n = oe / s;
34
34
  v.translate(t, e), v.scale(n, n), v.strokeStyle = "#000", v.lineWidth = 1.5, v.lineCap = "round", v.lineJoin = "round", v.translate(-12, -12), v.beginPath(), v.moveTo(21, 12), v.arc(12, 12, 9, 0, -Math.PI / 2, !0), v.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), v.stroke(), v.beginPath(), v.moveTo(3, 3), v.lineTo(3, 8), v.lineTo(8, 8), v.stroke(), v.beginPath(), v.moveTo(3, 12), v.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), v.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), v.stroke(), v.beginPath(), v.moveTo(16, 16), v.lineTo(21, 16), v.lineTo(21, 21), v.stroke(), v.restore();
35
35
  }
36
- function en(v, t, e, s = 1, n = "#3b82f6", o = !1) {
36
+ function nn(v, t, e, s = 1, n = "#3b82f6", o = !1) {
37
37
  const i = ze(s);
38
- v.save(), v.fillStyle = "#fff", v.strokeStyle = n, v.lineWidth = o ? jt(s) * 1.25 : jt(s), v.beginPath(), v.arc(t, e, i, 0, Math.PI * 2), v.fill(), v.stroke(), Ve(v, t, e, s), v.restore();
38
+ v.save(), v.fillStyle = "#fff", v.strokeStyle = n, v.lineWidth = o ? qt(s) * 1.25 : qt(s), v.beginPath(), v.arc(t, e, i, 0, Math.PI * 2), v.fill(), v.stroke(), Ve(v, t, e, s), v.restore();
39
39
  }
40
- const qt = Ct * 2;
41
- class nn {
40
+ const Ut = Ct * 2;
41
+ class sn {
42
42
  constructor() {
43
43
  this.resizeHandles = [], this.rotationHandle = null, this.elementRotation = 0, this.rotationAnchor = { x: 0, y: 0 };
44
44
  }
@@ -55,8 +55,8 @@ class nn {
55
55
  y: n.y - a,
56
56
  width: n.width + a * 2,
57
57
  height: n.height + a * 2
58
- }, l = re(r, t.rotation, o), h = Math.abs(t.rotation % 360) > 0.1;
59
- this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle = le(
58
+ }, l = le(r, t.rotation, o), h = Math.abs(t.rotation % 360) > 0.1;
59
+ this.resizeHandles = l.filter((c) => !(!i.includes(c.anchor) || h && c.anchor.includes("middle"))), this.rotationHandle = he(
60
60
  r,
61
61
  t.rotation,
62
62
  o,
@@ -71,8 +71,8 @@ class nn {
71
71
  this.resizeHandles.forEach((c) => {
72
72
  if (a && r && c.anchor !== r.anchor)
73
73
  return;
74
- const d = !!(i && i.anchor === c.anchor), f = !!(a && r && r.anchor === c.anchor);
75
- this.renderResizeHandle(t, c, d, f, l);
74
+ const d = !!(i && i.anchor === c.anchor), g = !!(a && r && r.anchor === c.anchor);
75
+ this.renderResizeHandle(t, c, d, g, l);
76
76
  }), h && e && this.rotationHandle && !n && !a && this.renderRotationHandle(t, this.rotationHandle, o, l), h && e && this.rotationHandle && n && this.renderRotationTooltip(t, this.rotationHandle, s, l);
77
77
  }
78
78
  /**
@@ -85,8 +85,8 @@ class nn {
85
85
  if (e.anchor.includes("middle")) {
86
86
  const l = e.anchor === "middle-top" || e.anchor === "middle-bottom";
87
87
  t.translate(i, a), t.rotate(-this.elementRotation * Math.PI / 180), l && t.rotate(Math.PI / 2), t.translate(-i, -a);
88
- const h = qt * 0.6, c = qt * 1.4, d = h / 2, f = i - h / 2, b = a - c / 2;
89
- t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.roundRect(f, b, h, c, d), t.fill(), t.stroke();
88
+ const h = Ut * 0.6, c = Ut * 1.4, d = h / 2, g = i - h / 2, b = a - c / 2;
89
+ t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.roundRect(g, b, h, c, d), t.fill(), t.stroke();
90
90
  } else
91
91
  t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s || n ? 2.5 : 2, t.beginPath(), t.arc(i, a, Ct, 0, Math.PI * 2), t.fill(), t.stroke();
92
92
  t.restore();
@@ -99,7 +99,7 @@ class nn {
99
99
  t.save();
100
100
  const o = e.x * n, i = e.y * n, a = Ct * 2.67;
101
101
  t.fillStyle = "#fff", t.strokeStyle = nt(t.canvas), t.lineWidth = s ? 2.5 : 2, t.beginPath(), t.arc(o, i, a, 0, Math.PI * 2), t.fill(), t.stroke();
102
- const r = se;
102
+ const r = oe;
103
103
  t.translate(o, i), t.scale(r, r), t.strokeStyle = "#000", t.lineWidth = 1.5, t.lineCap = "round", t.lineJoin = "round", t.translate(-12, -12), t.beginPath(), t.moveTo(21, 12), t.arc(12, 12, 9, 0, -Math.PI / 2, !0), t.bezierCurveTo(3.5, 4.5, 4, 6, 3, 8), t.stroke(), t.beginPath(), t.moveTo(3, 3), t.lineTo(3, 8), t.lineTo(8, 8), t.stroke(), t.beginPath(), t.moveTo(3, 12), t.arc(12, 12, 9, Math.PI, Math.PI / 2, !0), t.bezierCurveTo(20.5, 19.5, 20, 18, 21, 16), t.stroke(), t.beginPath(), t.moveTo(16, 16), t.lineTo(21, 16), t.lineTo(21, 21), t.stroke(), t.restore();
104
104
  }
105
105
  /**
@@ -115,7 +115,7 @@ class nn {
115
115
  * @param zoom - Current zoom level (radius scales inversely with zoom)
116
116
  */
117
117
  hitTestResize(t, e, s = 1) {
118
- const n = ce / s;
118
+ const n = de / s;
119
119
  for (const o of this.resizeHandles)
120
120
  if (Ot(t, e, o.x, o.y, n))
121
121
  return o;
@@ -143,7 +143,7 @@ class nn {
143
143
  */
144
144
  getCursor(t, e) {
145
145
  const s = t.anchor.includes("middle") ? "edge" : "corner";
146
- return he(
146
+ return ce(
147
147
  t.x,
148
148
  t.y,
149
149
  this.rotationAnchor.x,
@@ -193,21 +193,21 @@ class Ne {
193
193
  snapSystem: i,
194
194
  modifiers: a
195
195
  }) {
196
- var F, D, N, j, H;
197
- const l = new Yt(t).worldDeltaToLocal(s, n), h = l.dx, c = l.dy, d = o.visualWidth ?? o.width ?? 0, f = o.visualHeight ?? o.height ?? 0, b = o.width ?? 0, u = o.height ?? 0;
198
- let p = d, g = f;
199
- e.anchor.includes("right") ? p = d + h : e.anchor.includes("left") && (p = d - h), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? g = f + c : e.anchor.includes("top") && (g = f - c));
196
+ var _, G, V, j, H;
197
+ const l = new Yt(t).worldDeltaToLocal(s, n), h = l.dx, c = l.dy, d = o.visualWidth ?? o.width ?? 0, g = o.visualHeight ?? o.height ?? 0, b = o.width ?? 0, u = o.height ?? 0;
198
+ let p = d, f = g;
199
+ e.anchor.includes("right") ? p = d + h : e.anchor.includes("left") && (p = d - h), e.anchor !== "middle-left" && e.anchor !== "middle-right" && (e.anchor.includes("bottom") ? f = g + c : e.anchor.includes("top") && (f = g - c));
200
200
  const y = (a == null ? void 0 : a.shift) === !0;
201
201
  let S = null;
202
202
  if (y) {
203
203
  const z = Xe({
204
204
  anchor: e.anchor,
205
205
  startVisualWidth: d,
206
- startVisualHeight: f,
206
+ startVisualHeight: g,
207
207
  newVisualWidth: p,
208
- newVisualHeight: g
208
+ newVisualHeight: f
209
209
  });
210
- S = z.scale, p = z.newVisualWidth, g = z.newVisualHeight;
210
+ S = z.scale, p = z.newVisualWidth, f = z.newVisualHeight;
211
211
  }
212
212
  let m, w;
213
213
  if (S !== null)
@@ -216,28 +216,28 @@ class Ne {
216
216
  const z = p - d;
217
217
  m = b + z, w = u;
218
218
  } else if (e.anchor === "middle-top" || e.anchor === "middle-bottom") {
219
- const z = g - f;
219
+ const z = f - g;
220
220
  m = b, w = u + z;
221
221
  } else {
222
- const z = p / d, K = g / f;
222
+ const z = p / d, K = f / g;
223
223
  m = b * z, w = u * K;
224
224
  }
225
- const T = p, R = g;
225
+ const T = p, R = f;
226
226
  let C = !1;
227
227
  if (i && t.transformType === "image") {
228
228
  const z = e.anchor ?? "", K = z === "top-left" || z === "top-right" || z === "bottom-left" || z === "bottom-right", Q = z.startsWith("crop-");
229
229
  if (K && !Q) {
230
- const L = (F = i.activeSnaps) == null ? void 0 : F.x, A = (D = i.activeSnaps) == null ? void 0 : D.y;
231
- if (!!L || !!A) {
232
- const G = [L, A].find(
233
- (E) => typeof E == "object" && E !== null && "frozenWidth" in E
230
+ const L = (_ = i.activeSnaps) == null ? void 0 : _.x, P = (G = i.activeSnaps) == null ? void 0 : G.y;
231
+ if (!!L || !!P) {
232
+ const X = [L, P].find(
233
+ (A) => typeof A == "object" && A !== null && "frozenWidth" in A
234
234
  );
235
- if (G) {
236
- const E = t, _ = o.transformData, U = G.frozenWidth ?? ((N = E.transformData) == null ? void 0 : N.width) ?? b, ot = E.imageAspectRatio || (_ != null && _.width && (_ != null && _.height) ? _.width / _.height : null);
237
- let et = G.frozenHeight;
238
- et == null && (ot && ot !== 0 ? et = U / ot : (j = E.transformData) != null && j.height ? et = E.transformData.height : et = u);
235
+ if (X) {
236
+ const A = t, D = o.transformData, U = X.frozenWidth ?? ((V = A.transformData) == null ? void 0 : V.width) ?? b, ot = A.imageAspectRatio || (D != null && D.width && (D != null && D.height) ? D.width / D.height : null);
237
+ let et = X.frozenHeight;
238
+ et == null && (ot && ot !== 0 ? et = U / ot : (j = A.transformData) != null && j.height ? et = A.transformData.height : et = u);
239
239
  const lt = b !== 0 ? U / b : 1, Y = u !== 0 ? et / u : 1;
240
- p = d * lt, g = f * Y, m = U, w = et, C = !0;
240
+ p = d * lt, f = g * Y, m = U, w = et, C = !0;
241
241
  }
242
242
  }
243
243
  }
@@ -248,8 +248,8 @@ class Ne {
248
248
  const z = o.width ?? 1, K = o.height ?? 1, Q = Math.sqrt(m / z * (w / K)), L = Math.max(1, Math.round(o.strokeWidth * Q * 10) / 10);
249
249
  x.stroke = { ...x.stroke, width: L };
250
250
  }
251
- const P = C || I === !1, k = e.anchor.includes("top") || e.anchor.includes("bottom"), B = "isCropping" in x && x.isCropping, W = "isGroup" in x && x.isGroup;
252
- if (k && !B && !W) {
251
+ const k = C || I === !1, E = e.anchor.includes("top") || e.anchor.includes("bottom"), B = "isCropping" in x && x.isCropping, W = "isGroup" in x && x.isGroup;
252
+ if (E && !B && !W) {
253
253
  const z = t.getRotationAnchor(), K = this._calculateFixedCornerOffset({
254
254
  element: t,
255
255
  updatedElement: x,
@@ -260,7 +260,7 @@ class Ne {
260
260
  }
261
261
  return {
262
262
  element: x,
263
- isFrozen: P,
263
+ isFrozen: k,
264
264
  // For snap system to detect break-free: dimensions before freeze was applied
265
265
  unfrozenDimensions: C ? { width: T, height: R } : void 0
266
266
  };
@@ -276,10 +276,10 @@ class Ne {
276
276
  handle: s,
277
277
  rotationAnchor: n
278
278
  }) {
279
- const o = new Yt(t), { cos: i, sin: a } = o.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(s.anchor, r.width, r.height), f = d.x, b = d.y, u = r.x - h.x, p = r.y - h.y, g = u + f, y = p + b, S = g * i - y * a, m = g * a + y * i, w = h.x + S, T = h.y + m, R = this._getFixedLocalCoords(s.anchor, l.width, l.height), C = R.x, x = R.y, I = l.x - c.x, M = l.y - c.y, P = I + C, k = M + x, B = P * i - k * a, W = P * a + k * i, F = c.x + B, D = c.y + W;
279
+ const o = new Yt(t), { cos: i, sin: a } = o.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(s.anchor, r.width, r.height), g = d.x, b = d.y, u = r.x - h.x, p = r.y - h.y, f = u + g, y = p + b, S = f * i - y * a, m = f * a + y * i, w = h.x + S, T = h.y + m, R = this._getFixedLocalCoords(s.anchor, l.width, l.height), C = R.x, x = R.y, I = l.x - c.x, M = l.y - c.y, k = I + C, E = M + x, B = k * i - E * a, W = k * a + E * i, _ = c.x + B, G = c.y + W;
280
280
  return {
281
- x: w - F,
282
- y: T - D
281
+ x: w - _,
282
+ y: T - G
283
283
  };
284
284
  }
285
285
  /**
@@ -388,8 +388,8 @@ class Ke {
388
388
  return this.runHooks("afterPositionUpdate", s).position;
389
389
  }
390
390
  }
391
- const sn = new Ke();
392
- class on {
391
+ const on = new Ke();
392
+ class an {
393
393
  constructor(t = null) {
394
394
  this.state = "IDLE", this.context = {
395
395
  mode: null,
@@ -487,8 +487,8 @@ class on {
487
487
  const o = t - this.context.startX, i = e - this.context.startY, { dx: a, dy: r, lockedAxis: l } = Ye(o, i, n), h = this.context.startData;
488
488
  let c = h.x + a, d = h.y + r;
489
489
  if (this.snapHandler && this.snapHandler.snapPosition && this.context.element) {
490
- const f = this.snapHandler.snapPosition({ x: c, y: d }, this.context.element, s);
491
- c = f.x, d = f.y;
490
+ const g = this.snapHandler.snapPosition({ x: c, y: d }, this.context.element, s);
491
+ c = g.x, d = g.y;
492
492
  }
493
493
  return l === "x" ? c = h.x : l === "y" && (d = h.y), { x: c, y: d };
494
494
  }
@@ -600,7 +600,7 @@ class on {
600
600
  updateRotate(t, e, s, n, o) {
601
601
  if (this.state !== "ROTATING")
602
602
  throw new Error("Cannot update rotate: not in ROTATING state");
603
- const i = this.context.startData, r = (de(s, n, t, e) - i.startAngle) * 180 / Math.PI;
603
+ const i = this.context.startData, r = (fe(s, n, t, e) - i.startAngle) * 180 / Math.PI;
604
604
  let l = i.currentRotation - r;
605
605
  return l = (l % 360 + 360) % 360, l > 180 && (l -= 360), o != null && o.shift ? Ge(l) : this.snapHandler && this.snapHandler.snapRotation && this.context.element ? this.snapHandler.snapRotation(l, this.context.element) : l;
606
606
  }
@@ -824,7 +824,7 @@ class mt {
824
824
  return Math.abs(n.x - s.x) > o || Math.abs(n.y - s.y) > o;
825
825
  }
826
826
  }
827
- class Ut {
827
+ class Zt {
828
828
  constructor(t) {
829
829
  this.cellSize = t, this.cells = /* @__PURE__ */ new Map(), this.idIndex = /* @__PURE__ */ new Map();
830
830
  }
@@ -866,9 +866,9 @@ class Ut {
866
866
  const o = [], i = Math.floor((t - s) / this.cellSize), a = Math.floor((t + s) / this.cellSize), r = Math.floor((e - s) / this.cellSize), l = Math.floor((e + s) / this.cellSize);
867
867
  for (let h = i; h <= a; h++)
868
868
  for (let c = r; c <= l; c++) {
869
- const d = `${h},${c}`, f = this.cells.get(d);
870
- if (f)
871
- for (const b of f) {
869
+ const d = `${h},${c}`, g = this.cells.get(d);
870
+ if (g)
871
+ for (const b of g) {
872
872
  if (n !== void 0 && b.id === n) continue;
873
873
  const u = b.x - t, p = b.y - e;
874
874
  u * u + p * p <= s * s && o.push(b);
@@ -938,14 +938,14 @@ function Et(v, t) {
938
938
  const e = v.transformData;
939
939
  return e && "height" in e ? (e.height = t, !0) : !1;
940
940
  }
941
- class an {
941
+ class rn {
942
942
  constructor(t = {}) {
943
943
  this._extraSnapRects = [], this.snapThreshold = t.snapThreshold || ct.canvas.snapThreshold, this.enabled = t.enabled !== !1, this.showGuides = t.showGuides !== !1, this.guides = [], this.activeSnaps = {
944
944
  x: null,
945
945
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
946
946
  y: null
947
947
  // { snapTo: number, anchorKey: string, frozenFontSize: number, frozenWidth: number, frozenPosition: {x, y}, isPositionBasedSnap: boolean }
948
- }, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new Ut(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
948
+ }, this.stickyThreshold = t.stickyThreshold || 15, this._spatialGrid = new Zt(Math.max(this.snapThreshold * 2, 16)), this._anchorMetadata = /* @__PURE__ */ new Map();
949
949
  }
950
950
  /**
951
951
  * Enable or disable snapping
@@ -957,7 +957,7 @@ class an {
957
957
  * Set snap threshold in pixels
958
958
  */
959
959
  setSnapThreshold(t) {
960
- this.snapThreshold = t, this._spatialGrid = new Ut(Math.max(t * 2, 16));
960
+ this.snapThreshold = t, this._spatialGrid = new Zt(Math.max(t * 2, 16));
961
961
  }
962
962
  /**
963
963
  * Get current snap guides for rendering
@@ -1048,7 +1048,7 @@ class an {
1048
1048
  const o = mt.getSnapAnchors(n), i = s.filter((y) => y.id !== e.id);
1049
1049
  this._populateSpatialGrid(i);
1050
1050
  let a = null, r = null, l = 1 / 0, h = 1 / 0;
1051
- const c = [], d = [], f = [];
1051
+ const c = [], d = [], g = [];
1052
1052
  for (const [y, S] of Object.entries(o)) {
1053
1053
  const m = this._spatialGrid.queryNearAxis("x", S.x, this.snapThreshold);
1054
1054
  for (const T of m) {
@@ -1098,20 +1098,20 @@ class an {
1098
1098
  }
1099
1099
  let b = t.x, u = t.y;
1100
1100
  a && (b = a.snapTo - a.offset), r && (u = r.snapTo - r.offset);
1101
- const p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
1101
+ const p = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1102
1102
  for (const y of c) {
1103
1103
  const S = p.get(y.snapTo);
1104
1104
  (!S || y.distance < S.distance) && p.set(y.snapTo, y);
1105
1105
  }
1106
1106
  for (const y of d) {
1107
- const S = g.get(y.snapTo);
1108
- (!S || y.distance < S.distance) && g.set(y.snapTo, y);
1107
+ const S = f.get(y.snapTo);
1108
+ (!S || y.distance < S.distance) && f.set(y.snapTo, y);
1109
1109
  }
1110
1110
  for (const y of p.values())
1111
- f.push(y.guide);
1112
- for (const y of g.values())
1113
- f.push(y.guide);
1114
- return this.guides = f, { x: b, y: u };
1111
+ g.push(y.guide);
1112
+ for (const y of f.values())
1113
+ g.push(y.guide);
1114
+ return this.guides = g, { x: b, y: u };
1115
1115
  }
1116
1116
  /**
1117
1117
  * Calculate what the frozen font size should be at the snap point
@@ -1162,7 +1162,7 @@ class an {
1162
1162
  for (const h of l) {
1163
1163
  const c = this._anchorMetadata.get(h.id);
1164
1164
  if (!c || !i.has(c.anchorKey)) continue;
1165
- const d = c.point, f = c.anchorKey, b = Math.abs(r.x - d.x);
1165
+ const d = c.point, g = c.anchorKey, b = Math.abs(r.x - d.x);
1166
1166
  b < this.snapThreshold && o.push({
1167
1167
  distance: b,
1168
1168
  snapTo: d.x,
@@ -1173,7 +1173,7 @@ class an {
1173
1173
  y1: Math.min(r.y, d.y) - 50,
1174
1174
  y2: Math.max(r.y, d.y) + 50,
1175
1175
  movingKey: a,
1176
- otherKey: f
1176
+ otherKey: g
1177
1177
  }
1178
1178
  });
1179
1179
  }
@@ -1194,7 +1194,7 @@ class an {
1194
1194
  for (const h of l) {
1195
1195
  const c = this._anchorMetadata.get(h.id);
1196
1196
  if (!c || !i.has(c.anchorKey)) continue;
1197
- const d = c.point, f = c.anchorKey, b = Math.abs(r.y - d.y);
1197
+ const d = c.point, g = c.anchorKey, b = Math.abs(r.y - d.y);
1198
1198
  b < this.snapThreshold && o.push({
1199
1199
  distance: b,
1200
1200
  snapTo: d.y,
@@ -1205,7 +1205,7 @@ class an {
1205
1205
  x1: Math.min(r.x, d.x) - 50,
1206
1206
  x2: Math.max(r.x, d.x) + 50,
1207
1207
  movingKey: a,
1208
- otherKey: f
1208
+ otherKey: g
1209
1209
  }
1210
1210
  });
1211
1211
  }
@@ -1329,8 +1329,8 @@ class an {
1329
1329
  if (r) {
1330
1330
  const c = e[r.anchorKey];
1331
1331
  if (c) {
1332
- const d = t === "x" ? c.x : c.y, f = Math.abs(d - r.snapTo), b = this._getAdjustedStickyThreshold(t, n);
1333
- if (f < b) {
1332
+ const d = t === "x" ? c.x : c.y, g = Math.abs(d - r.snapTo), b = this._getAdjustedStickyThreshold(t, n);
1333
+ if (g < b) {
1334
1334
  if (l = r.snapTo - d, !(t === "y" && r.isPositionBasedSnap)) {
1335
1335
  const p = this._calculateFrozenFontSizeAtSnap(
1336
1336
  n,
@@ -1346,7 +1346,7 @@ class an {
1346
1346
  const u = r;
1347
1347
  if (this.activeSnaps[t] = null, s.length > 0 && s[0].distance < this.snapThreshold) {
1348
1348
  h = s[0], l = h.snapTo - h.currentValue;
1349
- const p = u && u.anchorKey === h.guide.movingKey && Math.abs(u.snapTo - h.snapTo) < 1, g = p ? u.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1349
+ const p = u && u.anchorKey === h.guide.movingKey && Math.abs(u.snapTo - h.snapTo) < 1, f = p ? u.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1350
1350
  n,
1351
1351
  t === "x" ? l : 0,
1352
1352
  t === "y" ? l : 0,
@@ -1368,7 +1368,7 @@ class an {
1368
1368
  this.activeSnaps[t] = {
1369
1369
  snapTo: h.snapTo,
1370
1370
  anchorKey: h.guide.movingKey,
1371
- frozenFontSize: g,
1371
+ frozenFontSize: f,
1372
1372
  frozenWidth: m.frozenWidth,
1373
1373
  frozenHeight: m.frozenHeight,
1374
1374
  frozenPosition: S,
@@ -1380,7 +1380,7 @@ class an {
1380
1380
  this.activeSnaps[t] = null;
1381
1381
  } else if (s.length > 0 && s[0].distance < this.snapThreshold) {
1382
1382
  h = s[0], l = h.snapTo - h.currentValue;
1383
- const c = this.activeSnaps[t], d = c && c.anchorKey === h.guide.movingKey && Math.abs(c.snapTo - h.snapTo) < 1, f = d ? c.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1383
+ const c = this.activeSnaps[t], d = c && c.anchorKey === h.guide.movingKey && Math.abs(c.snapTo - h.snapTo) < 1, g = d ? c.frozenFontSize : this._calculateFrozenFontSizeAtSnap(
1384
1384
  n,
1385
1385
  t === "x" ? l : 0,
1386
1386
  t === "y" ? l : 0,
@@ -1402,7 +1402,7 @@ class an {
1402
1402
  this.activeSnaps[t] = {
1403
1403
  snapTo: h.snapTo,
1404
1404
  anchorKey: h.guide.movingKey,
1405
- frozenFontSize: f,
1405
+ frozenFontSize: g,
1406
1406
  frozenWidth: p.frozenWidth,
1407
1407
  frozenHeight: p.frozenHeight,
1408
1408
  frozenPosition: u,
@@ -1502,8 +1502,8 @@ class an {
1502
1502
  if (a && r && t.isFrozen && t.unfrozenDimensions) {
1503
1503
  const M = n.clone();
1504
1504
  if (M.transformData) {
1505
- const P = n.getVisualBoundingBox(), k = P.width, B = P.height, W = (s == null ? void 0 : s.width) ?? n.width ?? 0, F = (s == null ? void 0 : s.height) ?? n.height ?? 0, D = (s == null ? void 0 : s.visualWidth) ?? k, N = (s == null ? void 0 : s.visualHeight) ?? B, j = t.unfrozenDimensions.width / D, H = t.unfrozenDimensions.height / N;
1506
- xt(M, W * j), Et(M, F * H);
1505
+ const k = n.getVisualBoundingBox(), E = k.width, B = k.height, W = (s == null ? void 0 : s.width) ?? n.width ?? 0, _ = (s == null ? void 0 : s.height) ?? n.height ?? 0, G = (s == null ? void 0 : s.visualWidth) ?? E, V = (s == null ? void 0 : s.visualHeight) ?? B, j = t.unfrozenDimensions.width / G, H = t.unfrozenDimensions.height / V;
1506
+ xt(M, W * j), Et(M, _ * H);
1507
1507
  }
1508
1508
  i = mt.getSnapAnchors(M);
1509
1509
  } else
@@ -1512,44 +1512,44 @@ class an {
1512
1512
  if (l.length === 0)
1513
1513
  return this.clearGuides(), t;
1514
1514
  this._populateSpatialGrid(l);
1515
- const h = this._getSnapKeysForHandle(o), c = this._getTargetSnapKeys(), d = this._findXSnaps(i, l, h, c), f = this._findYSnaps(i, l, h, c);
1516
- this._prioritizeSnaps(d, o, "x"), this._prioritizeSnaps(f, o, "y");
1517
- const b = this._processStickySnap("x", i, d, n, o, s, l), u = this._processStickySnap("y", i, f, n, o, s, l), p = b.snapDelta, g = u.snapDelta, y = b.bestSnap, S = u.bestSnap, m = [];
1515
+ const h = this._getSnapKeysForHandle(o), c = this._getTargetSnapKeys(), d = this._findXSnaps(i, l, h, c), g = this._findYSnaps(i, l, h, c);
1516
+ this._prioritizeSnaps(d, o, "x"), this._prioritizeSnaps(g, o, "y");
1517
+ const b = this._processStickySnap("x", i, d, n, o, s, l), u = this._processStickySnap("y", i, g, n, o, s, l), p = b.snapDelta, f = u.snapDelta, y = b.bestSnap, S = u.bestSnap, m = [];
1518
1518
  y && m.push(y.guide), S && m.push(S.guide), this.guides = m, m.length > 0;
1519
1519
  const w = o && (o.anchor === "top-left" || o.anchor === "top-right" || o.anchor === "bottom-left" || o.anchor === "bottom-right");
1520
- if (a && w && (p !== 0 || g !== 0))
1520
+ if (a && w && (p !== 0 || f !== 0))
1521
1521
  return t;
1522
- if (p !== 0 || g !== 0) {
1523
- const M = n.clone(), P = this.activeSnaps.x || this.activeSnaps.y, k = (P == null ? void 0 : P.frozenFontSize) ?? n.fontSize ?? 0, B = (P == null ? void 0 : P.frozenWidth) ?? ft(n) ?? n.width ?? 0, W = (P == null ? void 0 : P.frozenHeight) ?? Tt(n) ?? n.height ?? 0, F = (P == null ? void 0 : P.frozenPosition) ?? { x: n.x, y: n.y }, D = M.isCropping && !String(o.anchor).startsWith("crop-");
1524
- if (!D)
1522
+ if (p !== 0 || f !== 0) {
1523
+ const M = n.clone(), k = this.activeSnaps.x || this.activeSnaps.y, E = (k == null ? void 0 : k.frozenFontSize) ?? n.fontSize ?? 0, B = (k == null ? void 0 : k.frozenWidth) ?? ft(n) ?? n.width ?? 0, W = (k == null ? void 0 : k.frozenHeight) ?? Tt(n) ?? n.height ?? 0, _ = (k == null ? void 0 : k.frozenPosition) ?? { x: n.x, y: n.y }, G = M.isCropping && !String(o.anchor).startsWith("crop-");
1524
+ if (!G)
1525
1525
  if (o && o.anchor) {
1526
1526
  if (p !== 0) {
1527
- const L = (T = this.activeSnaps.x) == null ? void 0 : T.anchorKey, A = L == null ? void 0 : L.toLowerCase();
1528
- A && A.includes("right") ? this._adjustElementForRightResize(M, p, o) : A && A.includes("left") ? this._adjustElementForLeftResize(M, p, o) : M.x += p;
1527
+ const L = (T = this.activeSnaps.x) == null ? void 0 : T.anchorKey, P = L == null ? void 0 : L.toLowerCase();
1528
+ P && P.includes("right") ? this._adjustElementForRightResize(M, p, o) : P && P.includes("left") ? this._adjustElementForLeftResize(M, p, o) : M.x += p;
1529
1529
  }
1530
- if (g !== 0) {
1531
- const L = (R = this.activeSnaps.y) == null ? void 0 : R.anchorKey, A = L == null ? void 0 : L.toLowerCase();
1532
- A && A.includes("bottom") ? this._adjustElementForBottomResize(M, g, o) : A && A.includes("top") ? this._adjustElementForTopResize(M, g, o) : M.y += g;
1530
+ if (f !== 0) {
1531
+ const L = (R = this.activeSnaps.y) == null ? void 0 : R.anchorKey, P = L == null ? void 0 : L.toLowerCase();
1532
+ P && P.includes("bottom") ? this._adjustElementForBottomResize(M, f, o) : P && P.includes("top") ? this._adjustElementForTopResize(M, f, o) : M.y += f;
1533
1533
  }
1534
1534
  } else
1535
- M.x += p, M.y += g;
1536
- M.fontSize !== void 0 && (M.fontSize = k);
1537
- const N = M.transformType === "image", j = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
1538
- if (N && j) {
1535
+ M.x += p, M.y += f;
1536
+ M.fontSize !== void 0 && (M.fontSize = E);
1537
+ const V = M.transformType === "image", j = this.activeSnaps.x !== null || this.activeSnaps.y !== null;
1538
+ if (V && j) {
1539
1539
  if (ft(M) !== void 0) {
1540
1540
  const L = this.activeSnaps.x || this.activeSnaps.y;
1541
- let A = B, O = W;
1542
- L && (A = L.frozenWidth ?? A, O = L.frozenHeight ?? O);
1543
- const G = ft(n), E = Tt(n), _ = M.imageAspectRatio || (G && E ? G / E : null);
1544
- _ && _ !== 0 && (O = A / _), xt(M, A), Et(M, O), L && (L.frozenWidth = A, L.frozenHeight = O);
1541
+ let P = B, O = W;
1542
+ L && (P = L.frozenWidth ?? P, O = L.frozenHeight ?? O);
1543
+ const X = ft(n), A = Tt(n), D = M.imageAspectRatio || (X && A ? X / A : null);
1544
+ D && D !== 0 && (O = P / D), xt(M, P), Et(M, O), L && (L.frozenWidth = P, L.frozenHeight = O);
1545
1545
  }
1546
1546
  } else
1547
1547
  (((C = this.activeSnaps.y) == null ? void 0 : C.isPositionBasedSnap) || !1) && (ft(M) !== void 0 ? xt(M, B) : M.width !== void 0 && (M.width = B));
1548
1548
  const H = o && (o.anchor === "middle-left" || o.anchor === "middle-right"), z = o && (o.anchor === "middle-top" || o.anchor === "middle-bottom"), K = ((x = this.activeSnaps.x) == null ? void 0 : x.isPositionBasedSnap) || !1, Q = ((I = this.activeSnaps.y) == null ? void 0 : I.isPositionBasedSnap) || !1;
1549
- return (p === 0 || K) && !H && !z && !D && (M.x = F.x), (g === 0 || Q) && !z && !H && !D && (M.y = F.y), {
1549
+ return (p === 0 || K) && !H && !z && !G && (M.x = _.x), (f === 0 || Q) && !z && !H && !G && (M.y = _.y), {
1550
1550
  ...t,
1551
1551
  element: M,
1552
- snapAdjustment: { dx: p, dy: g },
1552
+ snapAdjustment: { dx: p, dy: f },
1553
1553
  // Flag to indicate we're in sticky snap mode (used to freeze font size)
1554
1554
  isInStickySnap: !0
1555
1555
  };
@@ -1563,12 +1563,12 @@ class an {
1563
1563
  if (!this.enabled) return t;
1564
1564
  const n = [0, 45, 90, 135, 180, 225, 270, 315, 360], o = 5;
1565
1565
  for (const i of n)
1566
- if (fe(t, i, o))
1566
+ if (ge(t, i, o))
1567
1567
  return i;
1568
1568
  return t;
1569
1569
  }
1570
1570
  }
1571
- class rn {
1571
+ class ln {
1572
1572
  constructor(t = {}) {
1573
1573
  this.lastSnapTarget = null, this.detectionThreshold = t.detectionThreshold || 100, this.minDistance = t.minDistance || 10, this.enabled = t.enabled !== !1, this.showLabels = t.showLabels !== !1, this.indicators = [];
1574
1574
  }
@@ -1609,19 +1609,19 @@ class rn {
1609
1609
  const i = e.clone();
1610
1610
  i.x = t.x, i.y = t.y;
1611
1611
  const a = i.getVisualBoundingBox(), r = a.x - t.x, l = a.y - t.y;
1612
- let h = t.x, c = t.y, d = !1, f = !1;
1612
+ let h = t.x, c = t.y, d = !1, g = !1;
1613
1613
  const b = o.filter((p) => {
1614
- const g = p.getVisualBoundingBox();
1615
- return !(a.x + a.width < g.x || a.x > g.x + g.width);
1614
+ const f = p.getVisualBoundingBox();
1615
+ return !(a.x + a.width < f.x || a.x > f.x + f.width);
1616
1616
  });
1617
- if (b.sort((p, g) => {
1618
- const y = p.getVisualBoundingBox(), S = g.getVisualBoundingBox();
1617
+ if (b.sort((p, f) => {
1618
+ const y = p.getVisualBoundingBox(), S = f.getVisualBoundingBox();
1619
1619
  return y.y - S.y;
1620
1620
  }), b.length >= 1) {
1621
- let p = null, g = null;
1621
+ let p = null, f = null;
1622
1622
  for (const m of b) {
1623
1623
  const w = m.getVisualBoundingBox();
1624
- w.y + w.height <= a.y ? (!p || w.y > p.getVisualBoundingBox().y) && (p = m) : w.y >= a.y + a.height && (!g || w.y < g.getVisualBoundingBox().y) && (g = m);
1624
+ w.y + w.height <= a.y ? (!p || w.y > p.getVisualBoundingBox().y) && (p = m) : w.y >= a.y + a.height && (!f || w.y < f.getVisualBoundingBox().y) && (f = m);
1625
1625
  }
1626
1626
  const y = [];
1627
1627
  for (let m = 0; m < b.length - 1; m++) {
@@ -1637,8 +1637,8 @@ class rn {
1637
1637
  break;
1638
1638
  }
1639
1639
  }
1640
- if (!S && g) {
1641
- const w = g.getVisualBoundingBox().y - (a.y + a.height);
1640
+ if (!S && f) {
1641
+ const w = f.getVisualBoundingBox().y - (a.y + a.height);
1642
1642
  for (const T of y)
1643
1643
  if (Math.abs(w - T) <= n) {
1644
1644
  S = T;
@@ -1648,26 +1648,26 @@ class rn {
1648
1648
  if (S !== null && S > 0) {
1649
1649
  if (p) {
1650
1650
  const m = p.getVisualBoundingBox(), w = a.y - (m.y + m.height);
1651
- Math.abs(w - S) <= n && (c = m.y + m.height + S - l, f = !0);
1651
+ Math.abs(w - S) <= n && (c = m.y + m.height + S - l, g = !0);
1652
1652
  }
1653
- if (!f && g) {
1654
- const m = g.getVisualBoundingBox(), w = m.y - (a.y + a.height);
1655
- Math.abs(w - S) <= n && (c = m.y - a.height - S - l, f = !0);
1653
+ if (!g && f) {
1654
+ const m = f.getVisualBoundingBox(), w = m.y - (a.y + a.height);
1655
+ Math.abs(w - S) <= n && (c = m.y - a.height - S - l, g = !0);
1656
1656
  }
1657
1657
  }
1658
1658
  }
1659
1659
  const u = o.filter((p) => {
1660
- const g = p.getVisualBoundingBox();
1661
- return !(a.y + a.height < g.y || a.y > g.y + g.height);
1660
+ const f = p.getVisualBoundingBox();
1661
+ return !(a.y + a.height < f.y || a.y > f.y + f.height);
1662
1662
  });
1663
- if (u.sort((p, g) => {
1664
- const y = p.getVisualBoundingBox(), S = g.getVisualBoundingBox();
1663
+ if (u.sort((p, f) => {
1664
+ const y = p.getVisualBoundingBox(), S = f.getVisualBoundingBox();
1665
1665
  return y.x - S.x;
1666
1666
  }), u.length >= 1) {
1667
- let p = null, g = null;
1667
+ let p = null, f = null;
1668
1668
  for (const m of u) {
1669
1669
  const w = m.getVisualBoundingBox();
1670
- w.x + w.width <= a.x ? (!p || w.x > p.getVisualBoundingBox().x) && (p = m) : w.x >= a.x + a.width && (!g || w.x < g.getVisualBoundingBox().x) && (g = m);
1670
+ w.x + w.width <= a.x ? (!p || w.x > p.getVisualBoundingBox().x) && (p = m) : w.x >= a.x + a.width && (!f || w.x < f.getVisualBoundingBox().x) && (f = m);
1671
1671
  }
1672
1672
  const y = [];
1673
1673
  for (let m = 0; m < u.length - 1; m++) {
@@ -1683,8 +1683,8 @@ class rn {
1683
1683
  break;
1684
1684
  }
1685
1685
  }
1686
- if (!S && g) {
1687
- const w = g.getVisualBoundingBox().x - (a.x + a.width);
1686
+ if (!S && f) {
1687
+ const w = f.getVisualBoundingBox().x - (a.x + a.width);
1688
1688
  for (const T of y)
1689
1689
  if (Math.abs(w - T) <= n) {
1690
1690
  S = T;
@@ -1696,13 +1696,13 @@ class rn {
1696
1696
  const m = p.getVisualBoundingBox(), w = a.x - (m.x + m.width);
1697
1697
  Math.abs(w - S) <= n && (h = m.x + m.width + S - r, d = !0);
1698
1698
  }
1699
- if (!d && g) {
1700
- const m = g.getVisualBoundingBox(), w = m.x - (a.x + a.width);
1699
+ if (!d && f) {
1700
+ const m = f.getVisualBoundingBox(), w = m.x - (a.x + a.width);
1701
1701
  Math.abs(w - S) <= n && (h = m.x - a.width - S - r, d = !0);
1702
1702
  }
1703
1703
  }
1704
1704
  }
1705
- return this.lastSnapTarget = d || f ? { x: h, y: c } : null, { x: h, y: c };
1705
+ return this.lastSnapTarget = d || g ? { x: h, y: c } : null, { x: h, y: c };
1706
1706
  }
1707
1707
  /**
1708
1708
  * Detect spacing between a moving element and other elements
@@ -1718,8 +1718,8 @@ class rn {
1718
1718
  return this.clearIndicators(), [];
1719
1719
  const o = t.getVisualBoundingBox(), i = [], a = [], r = [], l = [];
1720
1720
  for (const c of n) {
1721
- const d = c.getVisualBoundingBox(), f = o.x - (d.x + d.width), b = d.x - (o.x + o.width), u = o.y - (d.y + d.height), p = d.y - (o.y + o.height), g = !(o.y + o.height < d.y || o.y > d.y + d.height), y = !(o.x + o.width < d.x || o.x > d.x + d.width);
1722
- f >= this.minDistance && f < this.detectionThreshold && g && i.push({ element: c, distance: f }), b >= this.minDistance && b < this.detectionThreshold && g && a.push({ element: c, distance: b }), u >= this.minDistance && u < this.detectionThreshold && y && r.push({ element: c, distance: u }), p >= this.minDistance && p < this.detectionThreshold && y && l.push({ element: c, distance: p });
1721
+ const d = c.getVisualBoundingBox(), g = o.x - (d.x + d.width), b = d.x - (o.x + o.width), u = o.y - (d.y + d.height), p = d.y - (o.y + o.height), f = !(o.y + o.height < d.y || o.y > d.y + d.height), y = !(o.x + o.width < d.x || o.x > d.x + d.width);
1722
+ g >= this.minDistance && g < this.detectionThreshold && f && i.push({ element: c, distance: g }), b >= this.minDistance && b < this.detectionThreshold && f && a.push({ element: c, distance: b }), u >= this.minDistance && u < this.detectionThreshold && y && r.push({ element: c, distance: u }), p >= this.minDistance && p < this.detectionThreshold && y && l.push({ element: c, distance: p });
1723
1723
  }
1724
1724
  i.sort((c, d) => c.distance - d.distance), a.sort((c, d) => c.distance - d.distance), r.sort((c, d) => c.distance - d.distance), l.sort((c, d) => c.distance - d.distance);
1725
1725
  const h = [];
@@ -1778,9 +1778,9 @@ class rn {
1778
1778
  // bottom
1779
1779
  ) > i)
1780
1780
  continue;
1781
- let d = 0, f = !1, b = 0, u = 0, p = 0;
1781
+ let d = 0, g = !1, b = 0, u = 0, p = 0;
1782
1782
  const y = -30 * (a % 2 === 0 ? 1 : -1);
1783
- h.x >= n.x + n.width ? (d = h.x - (n.x + n.width), d >= this.minDistance && (f = !0, b = n.x + n.width, u = h.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)) : n.x >= h.x + h.width && (d = n.x - (h.x + h.width), d >= this.minDistance && (f = !0, b = h.x + h.width, u = n.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)), f && (s.push({
1783
+ h.x >= n.x + n.width ? (d = h.x - (n.x + n.width), d >= this.minDistance && (g = !0, b = n.x + n.width, u = h.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)) : n.x >= h.x + h.width && (d = n.x - (h.x + h.width), d >= this.minDistance && (g = !0, b = h.x + h.width, u = n.x, p = (n.y + n.height / 2 + h.y + h.height / 2) / 2 + y)), g && (s.push({
1784
1784
  type: "horizontal",
1785
1785
  distance: Math.round(d),
1786
1786
  x1: b,
@@ -1812,84 +1812,84 @@ class rn {
1812
1812
  detectConsistentSpacing(t, e, s, n, o) {
1813
1813
  const i = [], r = s[0], l = r.distance, h = r.element.getVisualBoundingBox(), c = this.checkIfWouldSnap(e, l, n, o);
1814
1814
  if (this.addIndicatorForDirection(i, e, h, l, n, c), n === "left" || n === "right") {
1815
- const d = o.filter((f) => {
1816
- if (f.id === t.id) return !1;
1817
- const b = f.getVisualBoundingBox();
1815
+ const d = o.filter((g) => {
1816
+ if (g.id === t.id) return !1;
1817
+ const b = g.getVisualBoundingBox();
1818
1818
  return !(e.y + e.height < b.y || e.y > b.y + b.height);
1819
1819
  });
1820
- if (d.sort((f, b) => {
1821
- const u = f.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1820
+ if (d.sort((g, b) => {
1821
+ const u = g.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1822
1822
  return u.x - p.x;
1823
1823
  }), n === "left")
1824
- for (let f = 0; f < d.length - 1; f++) {
1825
- const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.x - (p.x + p.width);
1824
+ for (let g = 0; g < d.length - 1; g++) {
1825
+ const b = d[g], u = d[g + 1], p = b.getVisualBoundingBox(), f = u.getVisualBoundingBox(), y = f.x - (p.x + p.width);
1826
1826
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1827
- const S = Math.max(p.y, g.y), m = Math.min(p.y + p.height, g.y + g.height), w = (S + m) / 2;
1827
+ const S = Math.max(p.y, f.y), m = Math.min(p.y + p.height, f.y + f.height), w = (S + m) / 2;
1828
1828
  i.push({
1829
1829
  type: "horizontal",
1830
1830
  distance: Math.round(y),
1831
1831
  x1: p.x + p.width,
1832
- x2: g.x,
1832
+ x2: f.x,
1833
1833
  y: w,
1834
- labelX: (p.x + p.width + g.x) / 2,
1834
+ labelX: (p.x + p.width + f.x) / 2,
1835
1835
  labelY: w
1836
1836
  });
1837
1837
  }
1838
1838
  }
1839
1839
  else
1840
- for (let f = 0; f < d.length - 1; f++) {
1841
- const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.x - (p.x + p.width);
1840
+ for (let g = 0; g < d.length - 1; g++) {
1841
+ const b = d[g], u = d[g + 1], p = b.getVisualBoundingBox(), f = u.getVisualBoundingBox(), y = f.x - (p.x + p.width);
1842
1842
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1843
- const S = Math.max(p.y, g.y), m = Math.min(p.y + p.height, g.y + g.height), w = (S + m) / 2;
1843
+ const S = Math.max(p.y, f.y), m = Math.min(p.y + p.height, f.y + f.height), w = (S + m) / 2;
1844
1844
  i.push({
1845
1845
  type: "horizontal",
1846
1846
  distance: Math.round(y),
1847
1847
  x1: p.x + p.width,
1848
- x2: g.x,
1848
+ x2: f.x,
1849
1849
  y: w,
1850
- labelX: (p.x + p.width + g.x) / 2,
1850
+ labelX: (p.x + p.width + f.x) / 2,
1851
1851
  labelY: w
1852
1852
  });
1853
1853
  }
1854
1854
  }
1855
1855
  } else {
1856
- const d = o.filter((f) => {
1857
- if (f.id === t.id) return !1;
1858
- const b = f.getVisualBoundingBox();
1856
+ const d = o.filter((g) => {
1857
+ if (g.id === t.id) return !1;
1858
+ const b = g.getVisualBoundingBox();
1859
1859
  return !(e.x + e.width < b.x || e.x > b.x + b.width);
1860
1860
  });
1861
- if (d.sort((f, b) => {
1862
- const u = f.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1861
+ if (d.sort((g, b) => {
1862
+ const u = g.getVisualBoundingBox(), p = b.getVisualBoundingBox();
1863
1863
  return u.y - p.y;
1864
1864
  }), n === "top")
1865
- for (let f = 0; f < d.length - 1; f++) {
1866
- const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.y - (p.y + p.height);
1865
+ for (let g = 0; g < d.length - 1; g++) {
1866
+ const b = d[g], u = d[g + 1], p = b.getVisualBoundingBox(), f = u.getVisualBoundingBox(), y = f.y - (p.y + p.height);
1867
1867
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1868
- const S = Math.max(p.x, g.x), m = Math.min(p.x + p.width, g.x + g.width), w = (S + m) / 2;
1868
+ const S = Math.max(p.x, f.x), m = Math.min(p.x + p.width, f.x + f.width), w = (S + m) / 2;
1869
1869
  i.push({
1870
1870
  type: "vertical",
1871
1871
  distance: Math.round(y),
1872
1872
  x: w,
1873
1873
  y1: p.y + p.height,
1874
- y2: g.y,
1874
+ y2: f.y,
1875
1875
  labelX: w,
1876
- labelY: (p.y + p.height + g.y) / 2
1876
+ labelY: (p.y + p.height + f.y) / 2
1877
1877
  });
1878
1878
  }
1879
1879
  }
1880
1880
  else
1881
- for (let f = 0; f < d.length - 1; f++) {
1882
- const b = d[f], u = d[f + 1], p = b.getVisualBoundingBox(), g = u.getVisualBoundingBox(), y = g.y - (p.y + p.height);
1881
+ for (let g = 0; g < d.length - 1; g++) {
1882
+ const b = d[g], u = d[g + 1], p = b.getVisualBoundingBox(), f = u.getVisualBoundingBox(), y = f.y - (p.y + p.height);
1883
1883
  if (Math.abs(y - l) <= 16 && y >= this.minDistance) {
1884
- const S = Math.max(p.x, g.x), m = Math.min(p.x + p.width, g.x + g.width), w = (S + m) / 2;
1884
+ const S = Math.max(p.x, f.x), m = Math.min(p.x + p.width, f.x + f.width), w = (S + m) / 2;
1885
1885
  i.push({
1886
1886
  type: "vertical",
1887
1887
  distance: Math.round(y),
1888
1888
  x: w,
1889
1889
  y1: p.y + p.height,
1890
- y2: g.y,
1890
+ y2: f.y,
1891
1891
  labelX: w,
1892
- labelY: (p.y + p.height + g.y) / 2
1892
+ labelY: (p.y + p.height + f.y) / 2
1893
1893
  });
1894
1894
  }
1895
1895
  }
@@ -2000,7 +2000,7 @@ class rn {
2000
2000
  }
2001
2001
  }
2002
2002
  }
2003
- const zt = Qt("ArtboardRenderer"), $e = {
2003
+ const zt = te("ArtboardRenderer"), $e = {
2004
2004
  showLabel: !0,
2005
2005
  showBorder: !0,
2006
2006
  borderColor: "",
@@ -2018,7 +2018,7 @@ const zt = Qt("ArtboardRenderer"), $e = {
2018
2018
  borderRadius: 0
2019
2019
  // Default to no border radius (sharp corners)
2020
2020
  };
2021
- class oe {
2021
+ class ie {
2022
2022
  constructor(t = {}) {
2023
2023
  this.options = { ...$e, ...t };
2024
2024
  }
@@ -2066,7 +2066,7 @@ class oe {
2066
2066
  * Render artboard border (respects clipShape and borderRadius option)
2067
2067
  */
2068
2068
  renderBorder(t, e, s) {
2069
- const { x: n, y: o, width: i, height: a, clipShape: r } = e, l = this.options.borderColor || ge(), h = this.options.selectedBorderColor || nt();
2069
+ const { x: n, y: o, width: i, height: a, clipShape: r } = e, l = this.options.borderColor || ue(), h = this.options.selectedBorderColor || nt();
2070
2070
  if (t.strokeStyle = s ? h : l, t.lineWidth = s ? this.options.selectedBorderWidth : this.options.borderWidth, t.beginPath(), !r || r === "rectangle")
2071
2071
  if (this.options.borderRadius > 0) {
2072
2072
  const c = Math.min(this.options.borderRadius, Math.min(i, a) / 2);
@@ -2074,8 +2074,8 @@ class oe {
2074
2074
  } else
2075
2075
  t.rect(n, o, i, a);
2076
2076
  else if (r === "circle") {
2077
- const c = n + i / 2, d = o + a / 2, f = Math.min(i, a) / 2;
2078
- t.arc(c, d, f, 0, Math.PI * 2);
2077
+ const c = n + i / 2, d = o + a / 2, g = Math.min(i, a) / 2;
2078
+ t.arc(c, d, g, 0, Math.PI * 2);
2079
2079
  } else if (typeof r == "object" && r.type === "rounded") {
2080
2080
  const c = Math.min(r.radius, Math.min(i, a) / 2);
2081
2081
  this.roundedRect(t, n, o, i, a, c);
@@ -2095,7 +2095,7 @@ class oe {
2095
2095
  renderLabel(t, e, s) {
2096
2096
  const n = this.options.labelFontSize, o = this.options.labelPadding, i = `${e.name} (${Math.round(e.width)} × ${Math.round(e.height)})`, a = e.x, r = e.y - o;
2097
2097
  t.font = `${n}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;
2098
- const l = this.options.selectedBorderColor || nt(), h = this.options.labelColor || ue();
2098
+ const l = this.options.selectedBorderColor || nt(), h = this.options.labelColor || pe();
2099
2099
  t.fillStyle = s ? l : h, t.textAlign = "left", t.textBaseline = "bottom", t.fillText(i, a, r);
2100
2100
  }
2101
2101
  /**
@@ -2198,7 +2198,7 @@ class oe {
2198
2198
  * Use this when exporting to ensure preview background is never included
2199
2199
  */
2200
2200
  static createForExport(t = {}) {
2201
- return new oe({
2201
+ return new ie({
2202
2202
  ...t,
2203
2203
  showPreviewBackground: !1
2204
2204
  // CRITICAL: Never show preview in exports
@@ -2220,27 +2220,27 @@ function je(v) {
2220
2220
  const e = t * Math.PI / 180;
2221
2221
  return [Math.cos(e), Math.sin(e)];
2222
2222
  }
2223
- function Zt(v, t, e) {
2223
+ function Jt(v, t, e) {
2224
2224
  const [s, n] = je(e);
2225
2225
  return { width: Math.abs(v * s) + Math.abs(t * n), height: Math.abs(v * n) + Math.abs(t * s) };
2226
2226
  }
2227
- function ie(v) {
2227
+ function ae(v) {
2228
2228
  if (v.naturalWidth && v.naturalHeight) return { width: v.naturalWidth, height: v.naturalHeight };
2229
2229
  const t = ((v.rotation ?? 0) % 360 + 360) % 360;
2230
2230
  if (t % 90 !== 0)
2231
2231
  throw new Error(`E_PIECE_NATURAL_DIMS: piece "${v.id ?? "?"}" is turned ${t}° but carries no naturalWidth/naturalHeight — the displayed box of a non-right angle doesn't determine them. Send them with the piece (the /piece-guides endpoint does)`);
2232
2232
  return t === 90 || t === 270 ? { width: v.height, height: v.width } : { width: v.width, height: v.height };
2233
2233
  }
2234
- function ln(v) {
2234
+ function hn(v) {
2235
2235
  const t = ((v.rotation ?? 0) % 360 + 360) % 360;
2236
2236
  if (!t) return "";
2237
- const e = ie(v);
2237
+ const e = ae(v);
2238
2238
  return `translate(${v.width / 2} ${v.height / 2}) rotate(${t}) translate(${-e.width / 2} ${-e.height / 2})`;
2239
2239
  }
2240
- function hn(v, t) {
2240
+ function cn(v, t) {
2241
2241
  const e = ((t.rotation ?? 0) % 360 + 360) % 360;
2242
2242
  if (!e) return;
2243
- const s = ie(t);
2243
+ const s = ae(t);
2244
2244
  v.translate(t.width / 2, t.height / 2), v.rotate(e * Math.PI / 180), v.translate(-s.width / 2, -s.height / 2);
2245
2245
  }
2246
2246
  class wt {
@@ -2268,21 +2268,21 @@ class wt {
2268
2268
  const i = e.getVisualBoundingBox(), a = Math.round(i.width), r = Math.round(i.height), l = `${a} × ${r}`, h = s.rotationHandle, c = h.x * o, d = h.y * o - 20;
2269
2269
  t.save(), t.font = "10px system-ui, -apple-system, sans-serif";
2270
2270
  const b = t.measureText(l).width + 12, u = 18;
2271
- t.shadowColor = pe(t.canvas), t.shadowBlur = 4, t.shadowOffsetY = 1, t.fillStyle = ye(t.canvas), t.beginPath(), t.roundRect(
2271
+ t.shadowColor = ye(t.canvas), t.shadowBlur = 4, t.shadowOffsetY = 1, t.fillStyle = be(t.canvas), t.beginPath(), t.roundRect(
2272
2272
  c - b / 2,
2273
2273
  d - u / 2,
2274
2274
  b,
2275
2275
  u,
2276
2276
  3
2277
2277
  // Smaller border radius
2278
- ), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle = be(t.canvas), t.textAlign = "center", t.textBaseline = "middle", t.fillText(l, c, d + 0.5), t.restore();
2278
+ ), t.fill(), t.shadowColor = "transparent", t.shadowBlur = 0, t.shadowOffsetY = 0, t.fillStyle = Se(t.canvas), t.textAlign = "center", t.textBaseline = "middle", t.fillText(l, c, d + 0.5), t.restore();
2279
2279
  }
2280
2280
  /**
2281
2281
  * Render transform handles layer
2282
2282
  */
2283
2283
  static renderHandlesLayer(t, e, s, n, o, i, a, r = 1, l = !0) {
2284
2284
  if (!e || e.visible === !1 || a.getMode() === "drag") return;
2285
- const c = i.type === "rotation-handle", d = i.type === "resize-handle" ? i.data : null, f = a.getMode() === "resize", b = f ? a.getActiveHandle() : null;
2285
+ const c = i.type === "rotation-handle", d = i.type === "resize-handle" ? i.data : null, g = a.getMode() === "resize", b = g ? a.getActiveHandle() : null;
2286
2286
  s.render(
2287
2287
  t,
2288
2288
  l,
@@ -2290,7 +2290,7 @@ class wt {
2290
2290
  o,
2291
2291
  c,
2292
2292
  d,
2293
- f,
2293
+ g,
2294
2294
  b,
2295
2295
  r,
2296
2296
  !0
@@ -2313,7 +2313,7 @@ class Ft {
2313
2313
  const c = performance.now() - e.startTime;
2314
2314
  h = Math.min(c / r, 1) * l;
2315
2315
  }
2316
- t.strokeStyle = Se(t.canvas), t.globalAlpha = h, t.lineWidth = 3, this.renderElementOutline(t, a, o, i), t.restore();
2316
+ t.strokeStyle = me(t.canvas), t.globalAlpha = h, t.lineWidth = 3, this.renderElementOutline(t, a, o, i), t.restore();
2317
2317
  }
2318
2318
  /**
2319
2319
  * Render outline for a specific element type
@@ -2330,12 +2330,12 @@ class Ft {
2330
2330
  const n = e.transformData, o = n.width * s, i = n.height * s, a = 2, l = a + a / 2;
2331
2331
  switch (t.save(), t.translate(e.x * s, e.y * s), t.beginPath(), n.shapeType) {
2332
2332
  case "rectangle": {
2333
- const h = n.borderRadius || 0, c = -(o + l * 2) / 2, d = -(i + l * 2) / 2, f = o + l * 2, b = i + l * 2;
2333
+ const h = n.borderRadius || 0, c = -(o + l * 2) / 2, d = -(i + l * 2) / 2, g = o + l * 2, b = i + l * 2;
2334
2334
  if (h > 0) {
2335
- const u = Math.min(h / 100 * Math.min(f, b), f / 2, b / 2);
2336
- t.roundRect(c, d, f, b, u);
2335
+ const u = Math.min(h / 100 * Math.min(g, b), g / 2, b / 2);
2336
+ t.roundRect(c, d, g, b, u);
2337
2337
  } else
2338
- t.rect(c, d, f, b);
2338
+ t.rect(c, d, g, b);
2339
2339
  break;
2340
2340
  }
2341
2341
  case "circle": {
@@ -2356,11 +2356,11 @@ class Ft {
2356
2356
  // bottom-right
2357
2357
  { x: -h, y: c }
2358
2358
  // bottom-left
2359
- ], f = d.map((u, p) => {
2360
- const g = d[(p + 1) % 3], y = g.x - u.x, S = g.y - u.y, m = Math.sqrt(y * y + S * S);
2359
+ ], g = d.map((u, p) => {
2360
+ const f = d[(p + 1) % 3], y = f.x - u.x, S = f.y - u.y, m = Math.sqrt(y * y + S * S);
2361
2361
  return { x: S / m, y: -y / m };
2362
2362
  }), b = d.map((u, p) => {
2363
- const g = f[(p + 2) % 3], y = f[p], S = g.x + y.x, m = g.y + y.y, w = Math.sqrt(S * S + m * m), T = (S * g.x + m * g.y) / w, R = l / T;
2363
+ const f = g[(p + 2) % 3], y = g[p], S = f.x + y.x, m = f.y + y.y, w = Math.sqrt(S * S + m * m), T = (S * f.x + m * f.y) / w, R = l / T;
2364
2364
  return {
2365
2365
  x: u.x + S / w * R,
2366
2366
  y: u.y + m / w * R
@@ -2370,10 +2370,10 @@ class Ft {
2370
2370
  break;
2371
2371
  }
2372
2372
  case "star": {
2373
- const h = n.points ?? 5, c = n.innerRadius ?? 0.4, d = Math.min(o, i) / 2 + l, f = d * c;
2373
+ const h = n.points ?? 5, c = n.innerRadius ?? 0.4, d = Math.min(o, i) / 2 + l, g = d * c;
2374
2374
  for (let b = 0; b < h * 2; b++) {
2375
- const u = b * Math.PI / h - Math.PI / 2, p = b % 2 === 0 ? d : f, g = p * Math.cos(u), y = p * Math.sin(u);
2376
- b === 0 ? t.moveTo(g, y) : t.lineTo(g, y);
2375
+ const u = b * Math.PI / h - Math.PI / 2, p = b % 2 === 0 ? d : g, f = p * Math.cos(u), y = p * Math.sin(u);
2376
+ b === 0 ? t.moveTo(f, y) : t.lineTo(f, y);
2377
2377
  }
2378
2378
  t.closePath();
2379
2379
  break;
@@ -2381,7 +2381,7 @@ class Ft {
2381
2381
  case "polygon": {
2382
2382
  const h = n.sides ?? 5, c = Math.min(o, i) / 2 + l;
2383
2383
  for (let d = 0; d < h; d++) {
2384
- const f = d * 2 * Math.PI / h - Math.PI / 2, b = c * Math.cos(f), u = c * Math.sin(f);
2384
+ const g = d * 2 * Math.PI / h - Math.PI / 2, b = c * Math.cos(g), u = c * Math.sin(g);
2385
2385
  d === 0 ? t.moveTo(b, u) : t.lineTo(b, u);
2386
2386
  }
2387
2387
  t.closePath();
@@ -2403,12 +2403,12 @@ class Ft {
2403
2403
  var u;
2404
2404
  const n = e.getVisualBoundingBox(), o = n.width * s, i = n.height * s, a = ((u = e.transformData) == null ? void 0 : u.borderRadius) || 0, r = 2, h = r + r / 2;
2405
2405
  t.save(), t.translate(e.x * s, e.y * s);
2406
- const c = -(o + h * 2) / 2, d = -(i + h * 2) / 2, f = o + h * 2, b = i + h * 2;
2406
+ const c = -(o + h * 2) / 2, d = -(i + h * 2) / 2, g = o + h * 2, b = i + h * 2;
2407
2407
  if (t.beginPath(), a > 0) {
2408
- const p = Math.min(a / 100 * Math.min(f, b), f / 2, b / 2);
2409
- t.roundRect(c, d, f, b, p);
2408
+ const p = Math.min(a / 100 * Math.min(g, b), g / 2, b / 2);
2409
+ t.roundRect(c, d, g, b, p);
2410
2410
  } else
2411
- t.rect(c, d, f, b);
2411
+ t.rect(c, d, g, b);
2412
2412
  t.stroke(), t.restore();
2413
2413
  }
2414
2414
  /**
@@ -2441,7 +2441,7 @@ class Ft {
2441
2441
  */
2442
2442
  static renderHoverRingEffect(t, e, s) {
2443
2443
  t.save(), t.translate(e.x * s, e.y * s), s !== 1 && t.scale(s, s);
2444
- const n = e.fontSize, o = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l = te(n, o, i, a), h = n * (e.lineHeight ?? 1.2), c = e.letterSpacing ?? 0, d = 4 / s, f = 4 / s, b = document.createElement("canvas");
2444
+ const n = e.fontSize, o = e.fontFamily, i = e.bold || !1, a = e.italic || !1, r = e.textAlign || "center", l = ee(n, o, i, a), h = n * (e.lineHeight ?? 1.2), c = e.letterSpacing ?? 0, d = 4 / s, g = 4 / s, b = document.createElement("canvas");
2445
2445
  b.width = t.canvas.width, b.height = t.canvas.height;
2446
2446
  const u = b.getContext("2d");
2447
2447
  if (!u) {
@@ -2451,10 +2451,10 @@ class Ft {
2451
2451
  u.setTransform(t.getTransform()), u.textBaseline = "alphabetic", u.lineJoin = "round";
2452
2452
  const p = e.getRichText ? e.getRichText() : null;
2453
2453
  if (p) {
2454
- const g = ee(p), y = [], S = [];
2455
- g.forEach((T) => {
2454
+ const f = ne(p), y = [], S = [];
2455
+ f.forEach((T) => {
2456
2456
  if (e.transformType === "custom" && e.transformData) {
2457
- const R = e.transformData.width - pt * 2, C = ne(T, R, {
2457
+ const R = e.transformData.width - pt * 2, C = se(T, R, {
2458
2458
  fontSize: n,
2459
2459
  fontFamily: o,
2460
2460
  bold: i,
@@ -2477,64 +2477,64 @@ class Ft {
2477
2477
  y.length === 0 ? m = 0 : y.length === 1 ? m = l.height : m = (y.length - 1) * h + l.height;
2478
2478
  const w = -m / 2;
2479
2479
  y.forEach((T, R) => {
2480
- var N, j;
2480
+ var V, j;
2481
2481
  const C = S[R].isParagraphStart, x = S[R].isParagraphEnd;
2482
2482
  let I = 0;
2483
- const M = T.map((H) => H.text).join(""), P = ((N = M.match(/^ +/)) == null ? void 0 : N[0].length) || 0, k = ((j = M.match(/ +$/)) == null ? void 0 : j[0].length) || 0;
2483
+ const M = T.map((H) => H.text).join(""), k = ((V = M.match(/^ +/)) == null ? void 0 : V[0].length) || 0, E = ((j = M.match(/ +$/)) == null ? void 0 : j[0].length) || 0;
2484
2484
  let B = 0;
2485
2485
  T.forEach((H) => {
2486
2486
  const z = H.style.fontSize !== void 0 ? H.style.fontSize : n, K = H.style.fontFamily !== void 0 ? H.style.fontFamily : o, Q = H.style.bold !== void 0 ? H.style.bold : i, L = H.style.italic !== void 0 ? H.style.italic : a;
2487
- let A = H.text;
2488
- const O = B, G = B + H.text.length;
2489
- if (!C && P > 0 && O < P) {
2490
- const E = Math.min(P - O, H.text.length);
2491
- A = A.substring(E);
2487
+ let P = H.text;
2488
+ const O = B, X = B + H.text.length;
2489
+ if (!C && k > 0 && O < k) {
2490
+ const A = Math.min(k - O, H.text.length);
2491
+ P = P.substring(A);
2492
2492
  }
2493
- if (!x && k > 0) {
2494
- const E = M.length - k;
2495
- if (G > E) {
2496
- const _ = !C && O < P ? Math.min(P - O, H.text.length) : 0, U = Math.max(0, E - O - _);
2497
- A = A.substring(0, U);
2493
+ if (!x && E > 0) {
2494
+ const A = M.length - E;
2495
+ if (X > A) {
2496
+ const D = !C && O < k ? Math.min(k - O, H.text.length) : 0, U = Math.max(0, A - O - D);
2497
+ P = P.substring(0, U);
2498
2498
  }
2499
2499
  }
2500
- if (A.length > 0) {
2501
- const E = H.style.letterSpacing !== void 0 ? H.style.letterSpacing : c;
2502
- t.save(), t.font = Lt(z, K, Q, L), I += Xt(t.measureText(A).width, A, E), t.restore();
2500
+ if (P.length > 0) {
2501
+ const A = H.style.letterSpacing !== void 0 ? H.style.letterSpacing : c;
2502
+ t.save(), t.font = Lt(z, K, Q, L), I += Xt(t.measureText(P).width, P, A), t.restore();
2503
2503
  }
2504
2504
  B += H.text.length;
2505
2505
  });
2506
2506
  const W = e.transformType === "custom" && e.transformData ? e.transformData.width - pt * 2 : void 0;
2507
- let F;
2508
- r === "center" ? F = -I / 2 : r === "right" ? F = W !== void 0 ? W / 2 - I : -I : F = W !== void 0 ? -W / 2 : 0;
2509
- const D = w + l.ascent + R * h;
2507
+ let _;
2508
+ r === "center" ? _ = -I / 2 : r === "right" ? _ = W !== void 0 ? W / 2 - I : -I : _ = W !== void 0 ? -W / 2 : 0;
2509
+ const G = w + l.ascent + R * h;
2510
2510
  B = 0, T.forEach((H) => {
2511
2511
  const z = H.style.fontSize !== void 0 ? H.style.fontSize : n, K = H.style.fontFamily !== void 0 ? H.style.fontFamily : o;
2512
2512
  H.style.color !== void 0 ? H.style.color : e.color;
2513
2513
  const Q = H.style.bold !== void 0 ? H.style.bold : i, L = H.style.italic !== void 0 ? H.style.italic : a;
2514
- let A = H.text;
2515
- const O = B, G = B + H.text.length;
2516
- if (!C && P > 0 && O < P) {
2517
- const E = Math.min(P - O, H.text.length);
2518
- A = A.substring(E);
2514
+ let P = H.text;
2515
+ const O = B, X = B + H.text.length;
2516
+ if (!C && k > 0 && O < k) {
2517
+ const A = Math.min(k - O, H.text.length);
2518
+ P = P.substring(A);
2519
2519
  }
2520
- if (!x && k > 0) {
2521
- const E = M.length - k;
2522
- if (G > E) {
2523
- const _ = !C && O < P ? Math.min(P - O, H.text.length) : 0, U = Math.max(0, E - O - _);
2524
- A = A.substring(0, U);
2520
+ if (!x && E > 0) {
2521
+ const A = M.length - E;
2522
+ if (X > A) {
2523
+ const D = !C && O < k ? Math.min(k - O, H.text.length) : 0, U = Math.max(0, A - O - D);
2524
+ P = P.substring(0, U);
2525
2525
  }
2526
2526
  }
2527
- if (B += H.text.length, A.length > 0) {
2528
- const E = H.style.letterSpacing !== void 0 ? H.style.letterSpacing : c;
2529
- u.font = Lt(z, K, Q, L), u.textAlign = "left", u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (f + d) * 2, Pt(u, A, F, D, E), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = f * 2, Pt(u, A, F, D, E), Nt(u, A, F, D, E), F += Xt(u.measureText(A).width, A, E);
2527
+ if (B += H.text.length, P.length > 0) {
2528
+ const A = H.style.letterSpacing !== void 0 ? H.style.letterSpacing : c;
2529
+ u.font = Lt(z, K, Q, L), u.textAlign = "left", u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (g + d) * 2, Pt(u, P, _, G, A), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = g * 2, Pt(u, P, _, G, A), Nt(u, P, _, G, A), _ += Xt(u.measureText(P).width, P, A);
2530
2530
  }
2531
2531
  });
2532
2532
  });
2533
2533
  } else {
2534
2534
  t.font = Lt(n, o, i, a), u.font = t.font, u.textAlign = r;
2535
- let g, y;
2535
+ let f, y;
2536
2536
  if (e.transformType === "custom" && e.transformData) {
2537
- const C = e.transformData.width - pt * 2, { lines: x } = me(
2537
+ const C = e.transformData.width - pt * 2, { lines: x } = Te(
2538
2538
  e.text,
2539
2539
  C,
2540
2540
  n,
@@ -2545,22 +2545,22 @@ class Ft {
2545
2545
  !0,
2546
2546
  { letterSpacing: c, lineHeight: e.lineHeight }
2547
2547
  );
2548
- g = x;
2548
+ f = x;
2549
2549
  } else {
2550
- g = e.text.split(`
2550
+ f = e.text.split(`
2551
2551
  `);
2552
2552
  const C = e.text.includes(`
2553
2553
  `);
2554
- g = ke(g, C);
2554
+ f = Pe(f, C);
2555
2555
  }
2556
- g.length === 0 ? y = 0 : g.length === 1 ? y = l.height : y = (g.length - 1) * h + l.height;
2556
+ f.length === 0 ? y = 0 : f.length === 1 ? y = l.height : y = (f.length - 1) * h + l.height;
2557
2557
  const S = -y / 2, m = e.text.includes(`
2558
2558
  `), w = e.transformType === "custom" && e.transformData ? e.transformData.width : 0, T = -w / 2;
2559
2559
  let R = T + pt;
2560
- r === "center" ? R = T + w / 2 : r === "right" && (R = T + w - pt), g.forEach((C, x) => {
2561
- const I = S + l.ascent + x * h, M = m || x === 0, P = m || x === g.length - 1;
2562
- let k = C;
2563
- M || (k = k.replace(/^ +/, "")), P || (k = k.replace(/ +$/, "")), u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (f + d) * 2, u.lineJoin = "round", Pt(u, k, R, I, c), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = f * 2, Pt(u, k, R, I, c), Nt(u, k, R, I, c);
2560
+ r === "center" ? R = T + w / 2 : r === "right" && (R = T + w - pt), f.forEach((C, x) => {
2561
+ const I = S + l.ascent + x * h, M = m || x === 0, k = m || x === f.length - 1;
2562
+ let E = C;
2563
+ M || (E = E.replace(/^ +/, "")), k || (E = E.replace(/ +$/, "")), u.globalCompositeOperation = "source-over", u.strokeStyle = t.strokeStyle, u.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), u.lineWidth = (g + d) * 2, u.lineJoin = "round", Pt(u, E, R, I, c), u.globalCompositeOperation = "destination-out", u.globalAlpha = 1, u.lineWidth = g * 2, Pt(u, E, R, I, c), Nt(u, E, R, I, c);
2564
2564
  });
2565
2565
  }
2566
2566
  t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(b, 0, 0), t.restore();
@@ -2597,13 +2597,13 @@ class Ft {
2597
2597
  t.transform(1, 0, Math.tan(y), 1, 0, 0), t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round", t.strokeText(i.text, 0, 0), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, t.strokeText(i.text, 0, 0), t.fillText(i.text, 0, 0);
2598
2598
  return;
2599
2599
  }
2600
- const f = i.text.split(""), b = f.map((g) => t.measureText(g).width), u = this.calculateCharPositions(e, f, b), p = (g) => {
2601
- t.translate(g.x, g.y), g.angle && t.rotate(g.angle), g.skewY && t.transform(1, g.skewY, 0, 1, 0, 0);
2600
+ const g = i.text.split(""), b = g.map((f) => t.measureText(f).width), u = this.calculateCharPositions(e, g, b), p = (f) => {
2601
+ t.translate(f.x, f.y), f.angle && t.rotate(f.angle), f.skewY && t.transform(1, f.skewY, 0, 1, 0, 0);
2602
2602
  };
2603
- t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round", u.forEach((g, y) => {
2604
- t.save(), p(g), t.strokeText(f[y], 0, 0), t.restore();
2605
- }), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, u.forEach((g, y) => {
2606
- t.save(), p(g), t.strokeText(f[y], 0, 0), t.fillText(f[y], 0, 0), t.restore();
2603
+ t.globalCompositeOperation = "source-over", t.strokeStyle = o, t.globalAlpha = 0.8, t.lineWidth = (n + s) * 2, t.lineJoin = "round", u.forEach((f, y) => {
2604
+ t.save(), p(f), t.strokeText(g[y], 0, 0), t.restore();
2605
+ }), t.globalCompositeOperation = "destination-out", t.globalAlpha = 1, t.lineWidth = n * 2, u.forEach((f, y) => {
2606
+ t.save(), p(f), t.strokeText(g[y], 0, 0), t.fillText(g[y], 0, 0), t.restore();
2607
2607
  });
2608
2608
  }
2609
2609
  /**
@@ -2623,14 +2623,14 @@ class Ft {
2623
2623
  if (t.reverse) {
2624
2624
  let a = Math.PI / 2 + o / (2 * i);
2625
2625
  e.forEach((r, l) => {
2626
- const c = s[l] / i, d = Math.cos(a - c / 2) * i, f = Math.sin(a - c / 2) * i, b = a - c / 2 - Math.PI / 2;
2627
- n.push({ x: d, y: f, angle: b }), a -= c;
2626
+ const c = s[l] / i, d = Math.cos(a - c / 2) * i, g = Math.sin(a - c / 2) * i, b = a - c / 2 - Math.PI / 2;
2627
+ n.push({ x: d, y: g, angle: b }), a -= c;
2628
2628
  });
2629
2629
  } else {
2630
2630
  let a = -Math.PI / 2 - o / (2 * i);
2631
2631
  e.forEach((r, l) => {
2632
- const c = s[l] / i, d = Math.cos(a + c / 2) * i, f = Math.sin(a + c / 2) * i, b = a + c / 2 + Math.PI / 2;
2633
- n.push({ x: d, y: f, angle: b }), a += c;
2632
+ const c = s[l] / i, d = Math.cos(a + c / 2) * i, g = Math.sin(a + c / 2) * i, b = a + c / 2 + Math.PI / 2;
2633
+ n.push({ x: d, y: g, angle: b }), a += c;
2634
2634
  });
2635
2635
  }
2636
2636
  return n;
@@ -2642,8 +2642,8 @@ class Ft {
2642
2642
  const o = [];
2643
2643
  let a = -s.reduce((r, l) => r + l, 0) / 2;
2644
2644
  return e.forEach((r, l) => {
2645
- const h = s[l], c = a + h / 2, d = c / (n.width / 2), f = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * d), b = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d);
2646
- o.push({ x: c, y: f, angle: 0, skewY: b * Te }), a += h;
2645
+ const h = s[l], c = a + h / 2, d = c / (n.width / 2), g = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * d), b = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d);
2646
+ o.push({ x: c, y: g, angle: 0, skewY: b * we }), a += h;
2647
2647
  }), o;
2648
2648
  }
2649
2649
  /**
@@ -2653,7 +2653,7 @@ class Ft {
2653
2653
  const o = [], i = s.reduce((l, h) => l + h, 0), a = n.width / 2;
2654
2654
  let r = -i / 2;
2655
2655
  return e.forEach((l, h) => {
2656
- const c = s[h], d = r + c / 2, f = d / a, b = (Math.pow(f, 2) - 1) * n.archHeight * t.fontSize, u = 2 * f * n.archHeight;
2656
+ const c = s[h], d = r + c / 2, g = d / a, b = (Math.pow(g, 2) - 1) * n.archHeight * t.fontSize, u = 2 * g * n.archHeight;
2657
2657
  o.push({ x: d, y: b, angle: 0, skewY: u * 0.3 }), r += c;
2658
2658
  }), o;
2659
2659
  }
@@ -2675,8 +2675,8 @@ class Ft {
2675
2675
  const o = [], i = s.reduce((h, c) => h + c, 0), a = n.ascendAngle * Math.PI / 180, r = Math.tan(a);
2676
2676
  let l = -i / 2;
2677
2677
  return e.forEach((h, c) => {
2678
- const d = s[c], f = l + d / 2, b = f * r;
2679
- o.push({ x: f, y: b, angle: 0, skewY: r * 1 }), l += d;
2678
+ const d = s[c], g = l + d / 2, b = g * r;
2679
+ o.push({ x: g, y: b, angle: 0, skewY: r * 1 }), l += d;
2680
2680
  }), o;
2681
2681
  }
2682
2682
  /**
@@ -2686,7 +2686,7 @@ class Ft {
2686
2686
  const o = [];
2687
2687
  let a = -s.reduce((r, l) => r + l, 0) / 2;
2688
2688
  return e.forEach((r, l) => {
2689
- const h = s[l], c = a + h / 2, d = c / (n.width / 2), f = Math.abs(d), b = n.amplitude * f, u = b * t.fontSize * Math.sin(n.frequency * Math.PI * d), p = b * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d), g = n.amplitude * Math.sign(d) * Math.sin(n.frequency * Math.PI * d), y = p + g;
2689
+ const h = s[l], c = a + h / 2, d = c / (n.width / 2), g = Math.abs(d), b = n.amplitude * g, u = b * t.fontSize * Math.sin(n.frequency * Math.PI * d), p = b * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d), f = n.amplitude * Math.sign(d) * Math.sin(n.frequency * Math.PI * d), y = p + f;
2690
2690
  o.push({ x: c, y: u, angle: 0, skewY: y * 0.3 }), a += h;
2691
2691
  }), o;
2692
2692
  }
@@ -2730,7 +2730,7 @@ class Rt {
2730
2730
  const o = `${n}`;
2731
2731
  t.font = `600 ${ct.canvas.spacingLabelFontSize}px ${ct.canvas.spacingLabelFontFamily}`;
2732
2732
  const a = t.measureText(o).width, r = ct.canvas.spacingLabelFontSize, l = 4, h = a + l * 2, c = r + l * 2;
2733
- t.fillStyle = Kt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, s - c / 2, h, c, we), t.fill(), t.fillStyle = ve, t.textAlign = "center", t.textBaseline = "middle", t.fillText(o, e, s);
2733
+ t.fillStyle = Kt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, s - c / 2, h, c, ve), t.fill(), t.fillStyle = Me, t.textAlign = "center", t.textBaseline = "middle", t.fillText(o, e, s);
2734
2734
  }
2735
2735
  }
2736
2736
  class Vt {
@@ -2740,77 +2740,77 @@ class Vt {
2740
2740
  */
2741
2741
  static renderEditModeLayer(t, e, s, n) {
2742
2742
  if (!e || e.transformType === "image" || e.transformType === "group") return;
2743
- const o = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice: d, selectionHandlePositionsRef: f } = s, b = n || 1, u = o.transformType;
2743
+ const o = e, { cursorPosition: i, selectionStart: a, selectionEnd: r, editText: l, editRichText: h, cursorOpacity: c, isTouchDevice: d, selectionHandlePositionsRef: g } = s, b = n || 1, u = o.transformType;
2744
2744
  if (u === "circle" || u === "wave" || u === "arch" || u === "lean" || u === "ascend" || u === "flag") {
2745
2745
  this.renderTransformEditModeLayer(t, o, s, b);
2746
2746
  return;
2747
2747
  }
2748
- const p = o.fontSize || 24, g = o.fontFamily || "Arial", y = o.bold || !1, S = o.italic || !1, m = o.underline || !1, w = o.strikethrough || !1, T = o.textAlign || "center", R = o.letterSpacing ?? 0;
2748
+ const p = o.fontSize || 24, f = o.fontFamily || "Arial", y = o.bold || !1, S = o.italic || !1, m = o.underline || !1, w = o.strikethrough || !1, T = o.textAlign || "center", R = o.letterSpacing ?? 0;
2749
2749
  t.save(), t.translate(o.x, o.y), t.rotate(-o.rotation * Math.PI / 180);
2750
- const C = te(p, g, y, S), x = C.height, I = p * (o.lineHeight ?? 1.2);
2751
- let M, P, k;
2750
+ const C = ee(p, f, y, S), x = C.height, I = p * (o.lineHeight ?? 1.2);
2751
+ let M, k, E;
2752
2752
  if (h && o.transformType === "custom" && o.transformData.width) {
2753
2753
  const L = o.transformData.width - pt * 2;
2754
- k = L;
2755
- const A = ee(h);
2756
- M = [], P = [], A.forEach((O) => {
2757
- const G = ne(O, L, {
2754
+ E = L;
2755
+ const P = ne(h);
2756
+ M = [], k = [], P.forEach((O) => {
2757
+ const X = se(O, L, {
2758
2758
  fontSize: o.fontSize,
2759
2759
  fontFamily: o.fontFamily,
2760
2760
  bold: o.bold,
2761
2761
  italic: o.italic,
2762
2762
  letterSpacing: o.letterSpacing
2763
2763
  });
2764
- G.forEach((E, _) => {
2765
- M.push(E), P.push({
2766
- isParagraphStart: _ === 0,
2767
- isParagraphEnd: _ === G.length - 1
2764
+ X.forEach((A, D) => {
2765
+ M.push(A), k.push({
2766
+ isParagraphStart: D === 0,
2767
+ isParagraphEnd: D === X.length - 1
2768
2768
  });
2769
2769
  });
2770
2770
  });
2771
2771
  } else
2772
2772
  M = l.split(`
2773
- `).map((A) => [
2773
+ `).map((P) => [
2774
2774
  {
2775
- text: A,
2776
- style: { fontSize: p, fontFamily: g, bold: y, italic: S }
2775
+ text: P,
2776
+ style: { fontSize: p, fontFamily: f, bold: y, italic: S }
2777
2777
  }
2778
- ]), P = M.map(() => ({
2778
+ ]), k = M.map(() => ({
2779
2779
  isParagraphStart: !0,
2780
2780
  // Each line is its own paragraph
2781
2781
  isParagraphEnd: !0
2782
2782
  }));
2783
2783
  const B = M.length > 1 ? C.height + (M.length - 1) * I : C.height;
2784
- let W = -B / 2, F = 0, D = W, N = x;
2784
+ let W = -B / 2, _ = 0, G = W, V = x;
2785
2785
  const j = [];
2786
2786
  let H = 0;
2787
- M.forEach((L, A) => {
2788
- var _, U;
2789
- const O = P[A].isParagraphStart, G = P[A].isParagraphEnd, E = [];
2787
+ M.forEach((L, P) => {
2788
+ var D, U;
2789
+ const O = k[P].isParagraphStart, X = k[P].isParagraphEnd, A = [];
2790
2790
  L.forEach((ot) => {
2791
2791
  Array.from(ot.text).forEach((lt) => {
2792
- let Y = p, ht = g, it = y, Z = S, st = R;
2792
+ let Y = p, ht = f, it = y, Z = S, st = R;
2793
2793
  if (h && H < l.length) {
2794
2794
  const J = h.getStyleAt(H);
2795
- Y = J.fontSize || p, ht = J.fontFamily || g, it = J.bold !== void 0 ? J.bold : y, Z = J.italic !== void 0 ? J.italic : S, st = J.letterSpacing !== void 0 ? J.letterSpacing : R;
2795
+ Y = J.fontSize || p, ht = J.fontFamily || f, it = J.bold !== void 0 ? J.bold : y, Z = J.italic !== void 0 ? J.italic : S, st = J.letterSpacing !== void 0 ? J.letterSpacing : R;
2796
2796
  }
2797
2797
  t.save();
2798
- const V = it ? "bold" : "normal", q = Z ? "italic" : "normal";
2799
- t.font = `${q} ${V} ${Y}px "${ht}", Arial, sans-serif`;
2798
+ const F = it ? "bold" : "normal", q = Z ? "italic" : "normal";
2799
+ t.font = `${q} ${F} ${Y}px "${ht}", Arial, sans-serif`;
2800
2800
  const at = t.measureText(lt).width + st;
2801
- t.restore(), E.push({ char: lt, width: at, fontSize: Y, index: H }), H++;
2801
+ t.restore(), A.push({ char: lt, width: at, fontSize: Y, index: H }), H++;
2802
2802
  });
2803
2803
  });
2804
2804
  {
2805
- const ot = A === 0, et = A === M.length - 1, lt = E.map((V) => V.char).join(""), Y = ((_ = lt.match(/^ +/)) == null ? void 0 : _[0].length) || 0, ht = ((U = lt.match(/ +$/)) == null ? void 0 : U[0].length) || 0;
2805
+ const ot = P === 0, et = P === M.length - 1, lt = A.map((F) => F.char).join(""), Y = ((D = lt.match(/^ +/)) == null ? void 0 : D[0].length) || 0, ht = ((U = lt.match(/ +$/)) == null ? void 0 : U[0].length) || 0;
2806
2806
  let it = 0;
2807
- for (let V = 0; V < E.length; V++)
2808
- !ot && V < Y || !et && V >= E.length - ht || (it += E[V].width);
2807
+ for (let F = 0; F < A.length; F++)
2808
+ !ot && F < Y || !et && F >= A.length - ht || (it += A[F].width);
2809
2809
  let Z;
2810
- T === "center" ? Z = -it / 2 : T === "right" ? Z = k !== void 0 ? k / 2 - it : -it : Z = k !== void 0 ? -k / 2 : 0;
2810
+ T === "center" ? Z = -it / 2 : T === "right" ? Z = E !== void 0 ? E / 2 - it : -it : Z = E !== void 0 ? -E / 2 : 0;
2811
2811
  let st = Z;
2812
- for (let V = 0; V < E.length; V++) {
2813
- const q = E[V];
2812
+ for (let F = 0; F < A.length; F++) {
2813
+ const q = A[F];
2814
2814
  j[q.index] = {
2815
2815
  x: st,
2816
2816
  y: W,
@@ -2819,78 +2819,78 @@ class Vt {
2819
2819
  height: q.fontSize
2820
2820
  }, st += q.width;
2821
2821
  }
2822
- if (E.length > 0) {
2823
- const V = E[0].index, q = E[E.length - 1].index, ut = A < M.length - 1 && q + 1 === H ? q : q + 1;
2824
- if (i >= V && i <= ut)
2825
- if (i === V)
2826
- F = Z, D = W, N = x;
2822
+ if (A.length > 0) {
2823
+ const F = A[0].index, q = A[A.length - 1].index, ut = P < M.length - 1 && q + 1 === H ? q : q + 1;
2824
+ if (i >= F && i <= ut)
2825
+ if (i === F)
2826
+ _ = Z, G = W, V = x;
2827
2827
  else {
2828
2828
  let yt = 0;
2829
- for (let rt = 0; rt < E.length && E[rt].index < i; rt++) {
2830
- const dt = E[rt], bt = dt.char === " ";
2829
+ for (let rt = 0; rt < A.length && A[rt].index < i; rt++) {
2830
+ const dt = A[rt], bt = dt.char === " ";
2831
2831
  let St = !0;
2832
2832
  if (bt) {
2833
- const kt = rt < Y, X = rt >= E.length - ht, vt = !O && Y > 0, Mt = !G && ht > 0;
2834
- St = !(kt && vt || X && Mt);
2833
+ const kt = rt < Y, N = rt >= A.length - ht, vt = !O && Y > 0, Mt = !X && ht > 0;
2834
+ St = !(kt && vt || N && Mt);
2835
2835
  }
2836
2836
  St && (yt += dt.width);
2837
2837
  }
2838
- F = Z + yt, D = W, N = x;
2838
+ _ = Z + yt, G = W, V = x;
2839
2839
  }
2840
2840
  }
2841
- A < M.length - 1 && (W += I);
2841
+ P < M.length - 1 && (W += I);
2842
2842
  }
2843
2843
  });
2844
2844
  const z = a !== r;
2845
2845
  let K = null, Q = null;
2846
2846
  if (z) {
2847
- const L = Math.min(a, r), A = Math.max(a, r);
2848
- t.save(), t.fillStyle = Me(t.canvas);
2849
- let O = 0, G = -B / 2;
2850
- if (M.forEach((E, _) => {
2847
+ const L = Math.min(a, r), P = Math.max(a, r);
2848
+ t.save(), t.fillStyle = xe(t.canvas);
2849
+ let O = 0, X = -B / 2;
2850
+ if (M.forEach((A, D) => {
2851
2851
  var ht, it;
2852
- const U = P[_].isParagraphStart, ot = P[_].isParagraphEnd, et = _ === 0, lt = _ === M.length - 1, Y = [];
2853
- if (E.forEach((Z) => {
2852
+ const U = k[D].isParagraphStart, ot = k[D].isParagraphEnd, et = D === 0, lt = D === M.length - 1, Y = [];
2853
+ if (A.forEach((Z) => {
2854
2854
  Array.from(Z.text).forEach((st) => {
2855
- const V = Z.style || {}, q = V.fontSize !== void 0 ? V.fontSize : p, at = V.fontFamily !== void 0 ? V.fontFamily : g, J = V.bold !== void 0 ? V.bold : y, ut = V.italic !== void 0 ? V.italic : S, yt = V.letterSpacing !== void 0 ? V.letterSpacing : R;
2855
+ const F = Z.style || {}, q = F.fontSize !== void 0 ? F.fontSize : p, at = F.fontFamily !== void 0 ? F.fontFamily : f, J = F.bold !== void 0 ? F.bold : y, ut = F.italic !== void 0 ? F.italic : S, yt = F.letterSpacing !== void 0 ? F.letterSpacing : R;
2856
2856
  t.save();
2857
2857
  const rt = J ? "bold" : "normal", dt = ut ? "italic" : "normal";
2858
2858
  t.font = `${dt} ${rt} ${q}px "${at}", Arial, sans-serif`;
2859
2859
  const bt = t.measureText(st).width + yt;
2860
- t.restore(), Y.push({ char: st, index: O, width: bt, style: V }), O++;
2860
+ t.restore(), Y.push({ char: st, index: O, width: bt, style: F }), O++;
2861
2861
  });
2862
2862
  }), Y.length > 0) {
2863
2863
  const Z = Y[0].index, st = Y[Y.length - 1].index;
2864
- if (A > Z && L <= st) {
2864
+ if (P > Z && L <= st) {
2865
2865
  t.save();
2866
- const V = Y.map((X) => X.char).join(""), q = ((ht = V.match(/^ +/)) == null ? void 0 : ht[0].length) || 0, at = ((it = V.match(/ +$/)) == null ? void 0 : it[0].length) || 0;
2866
+ const F = Y.map((N) => N.char).join(""), q = ((ht = F.match(/^ +/)) == null ? void 0 : ht[0].length) || 0, at = ((it = F.match(/ +$/)) == null ? void 0 : it[0].length) || 0;
2867
2867
  let J = 0;
2868
- for (let X = 0; X < Y.length; X++)
2869
- !et && X < q || !lt && X >= Y.length - at || (J += Y[X].width);
2868
+ for (let N = 0; N < Y.length; N++)
2869
+ !et && N < q || !lt && N >= Y.length - at || (J += Y[N].width);
2870
2870
  let ut = 0;
2871
2871
  T === "center" ? ut = -J / 2 : T === "right" && (ut = -J);
2872
- const yt = Math.max(L, Z), rt = Math.min(A, st + 1);
2872
+ const yt = Math.max(L, Z), rt = Math.min(P, st + 1);
2873
2873
  let dt = 0;
2874
- for (let X = 0; X < Y.length && Y[X].index < yt; X++) {
2875
- const vt = Y[X], Mt = X < q, Ht = X >= Y.length - at, It = !U && q > 0, Bt = !ot && at > 0;
2874
+ for (let N = 0; N < Y.length && Y[N].index < yt; N++) {
2875
+ const vt = Y[N], Mt = N < q, Ht = N >= Y.length - at, It = !U && q > 0, Bt = !ot && at > 0;
2876
2876
  !(Mt && It || Ht && Bt) && (dt += vt.width);
2877
2877
  }
2878
2878
  let bt = 0;
2879
- for (let X = 0; X < Y.length && Y[X].index < rt; X++) {
2880
- const vt = Y[X], Mt = X < q, Ht = X >= Y.length - at, It = !U && q > 0, Bt = !ot && at > 0;
2879
+ for (let N = 0; N < Y.length && Y[N].index < rt; N++) {
2880
+ const vt = Y[N], Mt = N < q, Ht = N >= Y.length - at, It = !U && q > 0, Bt = !ot && at > 0;
2881
2881
  !(Mt && It || Ht && Bt) && (bt += vt.width);
2882
2882
  }
2883
2883
  const St = ut + dt, kt = bt - dt;
2884
- t.fillRect(St, G, kt, x), K === null && (K = { x: St, y: G }), Q = { x: St + kt, y: G + x }, t.restore();
2884
+ t.fillRect(St, X, kt, x), K === null && (K = { x: St, y: X }), Q = { x: St + kt, y: X + x }, t.restore();
2885
2885
  }
2886
2886
  }
2887
- _ < M.length - 1 && (G += I);
2887
+ D < M.length - 1 && (X += I);
2888
2888
  }), t.restore(), h) {
2889
2889
  t.save();
2890
- const E = o.transformType === "custom" ? o.transformData : null, _ = E != null && E.width ? E.width - pt * 2 : void 0;
2891
- Pe(t, h, {
2890
+ const A = o.transformType === "custom" ? o.transformData : null, D = A != null && A.width ? A.width - pt * 2 : void 0;
2891
+ Ae(t, h, {
2892
2892
  fontSize: p,
2893
- fontFamily: g,
2893
+ fontFamily: f,
2894
2894
  color: o.color || "#000000",
2895
2895
  bold: y,
2896
2896
  italic: S,
@@ -2899,29 +2899,29 @@ class Vt {
2899
2899
  textAlign: T,
2900
2900
  letterSpacing: o.letterSpacing,
2901
2901
  lineHeight: o.lineHeight
2902
- }, _), t.restore();
2902
+ }, D), t.restore();
2903
2903
  }
2904
2904
  }
2905
2905
  if (z && d && K && Q) {
2906
- const L = K, A = Q, O = 6 / b, G = 2 / b;
2906
+ const L = K, P = Q, O = 6 / b, X = 2 / b;
2907
2907
  t.save();
2908
- const E = nt(t.canvas);
2909
- t.fillStyle = E, t.strokeStyle = E, t.lineWidth = G, t.lineCap = "round";
2910
- const _ = { x: L.x, y: L.y - O }, U = { x: A.x, y: A.y + O };
2911
- t.beginPath(), t.moveTo(L.x, L.y), t.lineTo(L.x, L.y + x), t.stroke(), t.beginPath(), t.arc(_.x, _.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.strokeStyle = E, t.lineWidth = G, t.beginPath(), t.moveTo(A.x, A.y - x), t.lineTo(A.x, A.y), t.stroke(), t.beginPath(), t.arc(U.x, U.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.restore(), f && (f.current = {
2908
+ const A = nt(t.canvas);
2909
+ t.fillStyle = A, t.strokeStyle = A, t.lineWidth = X, t.lineCap = "round";
2910
+ const D = { x: L.x, y: L.y - O }, U = { x: P.x, y: P.y + O };
2911
+ t.beginPath(), t.moveTo(L.x, L.y), t.lineTo(L.x, L.y + x), t.stroke(), t.beginPath(), t.arc(D.x, D.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.strokeStyle = A, t.lineWidth = X, t.beginPath(), t.moveTo(P.x, P.y - x), t.lineTo(P.x, P.y), t.stroke(), t.beginPath(), t.arc(U.x, U.y, O, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / b, t.stroke(), t.restore(), g && (g.current = {
2912
2912
  start: {
2913
- center: _,
2913
+ center: D,
2914
2914
  textEdge: L
2915
2915
  // Original selection edge (top-left of selection on first line)
2916
2916
  },
2917
2917
  end: {
2918
2918
  center: U,
2919
- textEdge: A
2919
+ textEdge: P
2920
2920
  // Original selection edge (bottom-right of selection on last line)
2921
2921
  }
2922
2922
  });
2923
- } else f && (f.current = { start: null, end: null });
2924
- !z && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = nt(t.canvas), t.lineWidth = 3 / b, t.lineCap = "round", t.beginPath(), t.moveTo(F, D), t.lineTo(F, D + N), t.stroke(), t.restore()), t.restore();
2923
+ } else g && (g.current = { start: null, end: null });
2924
+ !z && c > 0 && (t.save(), t.globalAlpha = c, t.strokeStyle = nt(t.canvas), t.lineWidth = 3 / b, t.lineCap = "round", t.beginPath(), t.moveTo(_, G), t.lineTo(_, G + V), t.stroke(), t.restore()), t.restore();
2925
2925
  }
2926
2926
  /**
2927
2927
  * Render edit mode features for transformed text (circle, wave, arch, etc.)
@@ -2932,8 +2932,8 @@ class Vt {
2932
2932
  t.save(), t.translate(e.x, e.y), t.rotate(-e.rotation * Math.PI / 180);
2933
2933
  const c = l ? "bold" : "normal", d = h ? "italic" : "normal";
2934
2934
  t.font = `${d} ${c} ${a}px ${r}`;
2935
- const f = Array.from(e.text), b = f.map((p) => t.measureText(p).width), u = Ft.calculateCharPositions(e, f, b);
2936
- if (o >= 0 && o <= f.length && i > 0) {
2935
+ const g = Array.from(e.text), b = g.map((p) => t.measureText(p).width), u = Ft.calculateCharPositions(e, g, b);
2936
+ if (o >= 0 && o <= g.length && i > 0) {
2937
2937
  let p;
2938
2938
  if (o === 0)
2939
2939
  if (u.length > 0) {
@@ -2961,8 +2961,8 @@ class Vt {
2961
2961
  };
2962
2962
  }
2963
2963
  t.save(), t.translate(p.x, p.y), t.rotate(p.angle), t.globalAlpha = i, t.strokeStyle = nt(t.canvas), t.lineWidth = 2 / n;
2964
- const g = a * 1.2;
2965
- t.beginPath(), t.moveTo(0, -g / 2), t.lineTo(0, g / 2), t.stroke(), t.restore();
2964
+ const f = a * 1.2;
2965
+ t.beginPath(), t.moveTo(0, -f / 2), t.lineTo(0, f / 2), t.stroke(), t.restore();
2966
2966
  }
2967
2967
  t.restore();
2968
2968
  }
@@ -2971,16 +2971,16 @@ class Vt {
2971
2971
  * Shows both image resize handles and crop handles
2972
2972
  */
2973
2973
  static renderCropBoxLayer(t, e, s, n = 1) {
2974
- if (!(e instanceof xe) || !e.isCropping) return;
2974
+ if (!(e instanceof Re) || !e.isCropping) return;
2975
2975
  const o = e, i = o.getCropBoxBounds();
2976
2976
  if (!i) return;
2977
- const a = 4 / n, r = 2 / n, l = Re / n, h = Ce / n, c = 1 / n;
2977
+ const a = 4 / n, r = 2 / n, l = Ce / n, h = ke / n, c = 1 / n;
2978
2978
  t.save(), t.translate(e.x * n, e.y * n), t.rotate(gt.toRadians(e.rotation));
2979
- const d = o.transformData.flipHorizontal ? -1 : 1, f = o.transformData.flipVertical ? -1 : 1;
2980
- t.scale(d * n, f * n);
2981
- const b = o.transformData.width * o.transformData.cropWidth, u = o.transformData.height * o.transformData.cropHeight, p = o.transformData.width / 2 - (o.transformData.cropX * o.transformData.width + b / 2), g = o.transformData.height / 2 - (o.transformData.cropY * o.transformData.height + u / 2), y = o.transformData.width / 2, S = o.transformData.height / 2, m = {
2979
+ const d = o.transformData.flipHorizontal ? -1 : 1, g = o.transformData.flipVertical ? -1 : 1;
2980
+ t.scale(d * n, g * n);
2981
+ const b = o.transformData.width * o.transformData.cropWidth, u = o.transformData.height * o.transformData.cropHeight, p = o.transformData.width / 2 - (o.transformData.cropX * o.transformData.width + b / 2), f = o.transformData.height / 2 - (o.transformData.cropY * o.transformData.height + u / 2), y = o.transformData.width / 2, S = o.transformData.height / 2, m = {
2982
2982
  x: p - y,
2983
- y: g - S,
2983
+ y: f - S,
2984
2984
  width: o.transformData.width,
2985
2985
  height: o.transformData.height
2986
2986
  };
@@ -2992,7 +2992,9 @@ class Vt {
2992
2992
  const x = i.width / 3;
2993
2993
  t.beginPath(), t.moveTo(i.x + x, i.y), t.lineTo(i.x + x, i.y + i.height), t.moveTo(i.x + 2 * x, i.y), t.lineTo(i.x + 2 * x, i.y + i.height), t.stroke();
2994
2994
  const I = i.height / 3;
2995
- if (t.beginPath(), t.moveTo(i.x, i.y + I), t.lineTo(i.x + i.width, i.y + I), t.moveTo(i.x, i.y + 2 * I), t.lineTo(i.x + i.width, i.y + 2 * I), t.stroke(), [
2995
+ t.beginPath(), t.moveTo(i.x, i.y + I), t.lineTo(i.x + i.width, i.y + I), t.moveTo(i.x, i.y + 2 * I), t.lineTo(i.x + i.width, i.y + 2 * I), t.stroke();
2996
+ const M = o.isFrameLockedInCrop();
2997
+ if ((M ? [] : [
2996
2998
  { x: i.x, y: i.y },
2997
2999
  // top-left
2998
3000
  { x: i.x + i.width, y: i.y },
@@ -3001,9 +3003,9 @@ class Vt {
3001
3003
  // bottom-right
3002
3004
  { x: i.x, y: i.y + i.height }
3003
3005
  // bottom-left
3004
- ].forEach((k) => {
3005
- t.beginPath(), t.arc(k.x, k.y, l + 1 / n, 0, Math.PI * 2), t.fillStyle = "#bbb", t.fill(), t.beginPath(), t.arc(k.x, k.y, l, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill();
3006
- }), [
3006
+ ]).forEach((B) => {
3007
+ t.beginPath(), t.arc(B.x, B.y, l + 1 / n, 0, Math.PI * 2), t.fillStyle = "#bbb", t.fill(), t.beginPath(), t.arc(B.x, B.y, l, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill();
3008
+ }), (M ? [] : [
3007
3009
  { x: i.x + i.width / 2, y: i.y, orientation: "horizontal" },
3008
3010
  // top
3009
3011
  { x: i.x + i.width / 2, y: i.y + i.height, orientation: "horizontal" },
@@ -3012,32 +3014,32 @@ class Vt {
3012
3014
  // left
3013
3015
  { x: i.x + i.width, y: i.y + i.height / 2, orientation: "vertical" }
3014
3016
  // right
3015
- ].forEach((k) => {
3016
- let B, W;
3017
- k.orientation === "horizontal" ? (B = h, W = a) : (B = a, W = h);
3018
- const F = k.x - B / 2, D = k.y - W / 2;
3019
- t.fillStyle = "#fff", t.fillRect(F, D, B, W), t.strokeStyle = "#bbb", t.lineWidth = c, t.strokeRect(F, D, B, W);
3017
+ ]).forEach((B) => {
3018
+ let W, _;
3019
+ B.orientation === "horizontal" ? (W = h, _ = a) : (W = a, _ = h);
3020
+ const G = B.x - W / 2, V = B.y - _ / 2;
3021
+ t.fillStyle = "#fff", t.fillRect(G, V, W, _), t.strokeStyle = "#bbb", t.lineWidth = c, t.strokeRect(G, V, W, _);
3020
3022
  }), t.restore(), s && s.resizeHandles) {
3021
- const k = s.resizeHandles.filter(
3022
- (D) => D.anchor === "top-left" || D.anchor === "top-right" || D.anchor === "bottom-left" || D.anchor === "bottom-right"
3023
- ), B = o.getCropBoxWorldCorners(), W = 6, F = 20;
3024
- k.forEach((D) => {
3025
- let N = !1;
3026
- if (B)
3027
- for (const j of B) {
3028
- const H = D.x - j.x, z = D.y - j.y;
3029
- if (Math.sqrt(H * H + z * z) < F) {
3030
- N = !0;
3023
+ const B = s.resizeHandles.filter(
3024
+ (V) => V.anchor === "top-left" || V.anchor === "top-right" || V.anchor === "bottom-left" || V.anchor === "bottom-right"
3025
+ ), W = o.getCropBoxWorldCorners(), _ = 6, G = 20;
3026
+ B.forEach((V) => {
3027
+ let j = !1;
3028
+ if (W)
3029
+ for (const H of W) {
3030
+ const z = V.x - H.x, K = V.y - H.y;
3031
+ if (Math.sqrt(z * z + K * K) < G) {
3032
+ j = !0;
3031
3033
  break;
3032
3034
  }
3033
3035
  }
3034
- N || (t.save(), t.globalAlpha = 1, t.beginPath(), t.arc(D.x * n, D.y * n, W, 0, 2 * Math.PI), t.fillStyle = "#fff", t.fill(), t.strokeStyle = nt(t.canvas), t.lineWidth = 2, t.stroke(), t.restore());
3036
+ j || (t.save(), t.globalAlpha = 1, t.beginPath(), t.arc(V.x * n, V.y * n, _, 0, 2 * Math.PI), t.fillStyle = "#fff", t.fill(), t.strokeStyle = nt(t.canvas), t.lineWidth = 2, t.stroke(), t.restore());
3035
3037
  });
3036
3038
  }
3037
3039
  }
3038
3040
  }
3039
- Ie();
3040
- const qe = Qt("CanvasRenderer"), $ = class $ {
3041
+ Be();
3042
+ const qe = te("CanvasRenderer"), Ue = 0.35, $ = class $ {
3041
3043
  /**
3042
3044
  * Get a pooled offscreen canvas for clipping content, only recreating
3043
3045
  * when dimensions change. Eliminates per-frame canvas allocation.
@@ -3107,12 +3109,12 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3107
3109
  try {
3108
3110
  const l = new Path2D();
3109
3111
  for (const h of a.pieces) {
3110
- const c = new Path2D(h.d), d = h.rotation ?? 0, f = new DOMMatrix();
3111
- if (f.translateSelf(h.x, h.y), d !== 0) {
3112
- const b = (h.baseWidth ?? 0) / 2, u = (h.baseHeight ?? 0) / 2, { width: p, height: g } = Zt(h.baseWidth ?? 0, h.baseHeight ?? 0, d);
3113
- f.translateSelf(p / 2, g / 2), f.rotateSelf(d), f.translateSelf(-b, -u);
3112
+ const c = new Path2D(h.d), d = h.rotation ?? 0, g = new DOMMatrix();
3113
+ if (g.translateSelf(h.x, h.y), d !== 0) {
3114
+ const b = (h.baseWidth ?? 0) / 2, u = (h.baseHeight ?? 0) / 2, { width: p, height: f } = Jt(h.baseWidth ?? 0, h.baseHeight ?? 0, d);
3115
+ g.translateSelf(p / 2, f / 2), g.rotateSelf(d), g.translateSelf(-b, -u);
3114
3116
  }
3115
- l.addPath(c, f);
3117
+ l.addPath(c, g);
3116
3118
  }
3117
3119
  t.translate(s, n), t.clip(l), t.translate(-s, -n);
3118
3120
  return;
@@ -3128,21 +3130,21 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3128
3130
  static renderElementWithOverflowDimming(t, e, s, n, o, i) {
3129
3131
  const a = t.getTransform(), r = s.borderRadius || 0;
3130
3132
  t.save(), t.globalAlpha = 0.3 * (i ? tt : 1), t.filter = "blur(4px)", t.beginPath();
3131
- const h = t.getTransform().inverse(), c = t.canvas.width, d = t.canvas.height, f = new DOMPoint(0, 0).matrixTransform(h), b = new DOMPoint(c, d).matrixTransform(h), u = Math.max(b.x - f.x, b.y - f.y), p = f.x - u, g = f.y - u, y = b.x + u, S = b.y + u, m = typeof s.clipShape == "object" && s.clipShape !== null && s.clipShape.type === "composite-path" ? s.clipShape : null;
3133
+ const h = t.getTransform().inverse(), c = t.canvas.width, d = t.canvas.height, g = new DOMPoint(0, 0).matrixTransform(h), b = new DOMPoint(c, d).matrixTransform(h), u = Math.max(b.x - g.x, b.y - g.y), p = g.x - u, f = g.y - u, y = b.x + u, S = b.y + u, m = typeof s.clipShape == "object" && s.clipShape !== null && s.clipShape.type === "composite-path" ? s.clipShape : null;
3132
3134
  if (m) {
3133
3135
  const w = new Path2D();
3134
- w.rect(p, g, y - p, S - g);
3136
+ w.rect(p, f, y - p, S - f);
3135
3137
  for (const T of m.pieces) {
3136
3138
  const R = new Path2D(T.d), C = T.rotation ?? 0, x = new DOMMatrix();
3137
3139
  if (x.translateSelf(s.x + T.x, s.y + T.y), C !== 0) {
3138
- const I = (T.baseWidth ?? 0) / 2, M = (T.baseHeight ?? 0) / 2, { width: P, height: k } = Zt(T.baseWidth ?? 0, T.baseHeight ?? 0, C);
3139
- x.translateSelf(P / 2, k / 2), x.rotateSelf(C), x.translateSelf(-I, -M);
3140
+ const I = (T.baseWidth ?? 0) / 2, M = (T.baseHeight ?? 0) / 2, { width: k, height: E } = Jt(T.baseWidth ?? 0, T.baseHeight ?? 0, C);
3141
+ x.translateSelf(k / 2, E / 2), x.rotateSelf(C), x.translateSelf(-I, -M);
3140
3142
  }
3141
3143
  w.addPath(R, x);
3142
3144
  }
3143
3145
  t.clip(w, "evenodd");
3144
3146
  } else
3145
- t.rect(p, g, y - p, S - g), r > 0 ? t.roundRect(s.x, s.y, s.width, s.height, r) : t.rect(s.x, s.y, s.width, s.height), t.clip("evenodd");
3147
+ t.rect(p, f, y - p, S - f), r > 0 ? t.roundRect(s.x, s.y, s.width, s.height, r) : t.rect(s.x, s.y, s.width, s.height), t.clip("evenodd");
3146
3148
  e.render(t, !1, !1), t.restore(), t.save(), this.applyArtboardClipPath(t, s), i && (t.globalAlpha = tt), e.render(t, n, o), t.restore(), t.setTransform(a);
3147
3149
  }
3148
3150
  /**
@@ -3156,26 +3158,26 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3156
3158
  */
3157
3159
  static renderElementsLayer(t, e, s, n, o, i, a, r = !0, l = !1, h = !1) {
3158
3160
  const c = o != null && o.getMode() === "drag", d = o == null ? void 0 : o._activeChildContext;
3159
- e !== $._cachedElementsRef && ($._cachedElementConfigs = e.map((g) => g.toJSON()), $._cachedElementMap = new Map(e.map((g) => [g.id, g])), $._cachedElementsRef = e);
3160
- const f = $._cachedElementConfigs, b = $._cachedElementMap, u = $._knockoutRenderedIds;
3161
- u.clear(), e.forEach((g, y) => {
3161
+ e !== $._cachedElementsRef && ($._cachedElementConfigs = e.map((f) => f.toJSON()), $._cachedElementMap = new Map(e.map((f) => [f.id, f])), $._cachedElementsRef = e);
3162
+ const g = $._cachedElementConfigs, b = $._cachedElementMap, u = $._knockoutRenderedIds;
3163
+ u.clear(), e.forEach((f, y) => {
3162
3164
  var S, m, w;
3163
- if (g.blendMode === "knockout" || g.blendMode === "clip") {
3164
- const T = f[y], R = g.blendMode === "knockout" ? "destination-out" : "destination-in", C = ((S = T.knockoutParts) == null ? void 0 : S.scope) || "group", x = f.findIndex((k) => k.id === T.id), I = ((m = T.knockoutParts) == null ? void 0 : m.fill) || ((w = T.knockoutParts) == null ? void 0 : w.stroke), M = C === "artboard" && x !== -1 ? f.slice(0, x) : [];
3165
- I && (C === "artboard" || M.length > 0) && (M.forEach((k) => k.id && u.add(k.id)), Ae(
3165
+ if (f.blendMode === "knockout" || f.blendMode === "clip") {
3166
+ const T = g[y], R = f.blendMode === "knockout" ? "destination-out" : "destination-in", C = ((S = T.knockoutParts) == null ? void 0 : S.scope) || "group", x = g.findIndex((E) => E.id === T.id), I = ((m = T.knockoutParts) == null ? void 0 : m.fill) || ((w = T.knockoutParts) == null ? void 0 : w.stroke), M = C === "artboard" && x !== -1 ? g.slice(0, x) : [];
3167
+ I && (C === "artboard" || M.length > 0) && (M.forEach((E) => E.id && u.add(E.id)), Ee(
3166
3168
  t,
3167
3169
  T,
3168
- f,
3169
- (k, B) => {
3170
+ g,
3171
+ (E, B) => {
3170
3172
  const W = B.id && b.get(B.id);
3171
- W && this.renderElement(k, W, r);
3173
+ W && this.renderElement(E, W, r);
3172
3174
  },
3173
3175
  i,
3174
3176
  a,
3175
3177
  R
3176
- ), u.add(g.id));
3178
+ ), u.add(f.id));
3177
3179
  }
3178
- }), e.some((g) => !u.has(g.id) && g.isClipping) ? this._renderWithClipping(
3180
+ }), e.some((f) => !u.has(f.id) && f.isClipping) ? this._renderWithClipping(
3179
3181
  t,
3180
3182
  e,
3181
3183
  u,
@@ -3183,29 +3185,29 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3183
3185
  n,
3184
3186
  c,
3185
3187
  d,
3186
- f,
3188
+ g,
3187
3189
  r
3188
- ) : e.forEach((g) => {
3190
+ ) : e.forEach((f) => {
3189
3191
  var x, I;
3190
- if (u.has(g.id) || g.visible === !1) return;
3191
- const y = g.id === s, S = (n == null ? void 0 : n.type) === "element" && ((x = n == null ? void 0 : n.data) == null ? void 0 : x.id) === g.id, m = c && d && _t(g) && g.id === s, w = y && !m, T = f[e.indexOf(g)], R = ((I = T == null ? void 0 : T.distressEffect) == null ? void 0 : I.enabled) && T.distressEffect.style === "custom" && T.distressEffect.textureUrl, C = (M) => {
3192
+ if (u.has(f.id) || f.visible === !1) return;
3193
+ const y = f.id === s, S = (n == null ? void 0 : n.type) === "element" && ((x = n == null ? void 0 : n.data) == null ? void 0 : x.id) === f.id, m = c && d && _t(f) && f.id === s, w = y && !m, T = g[e.indexOf(f)], R = ((I = T == null ? void 0 : T.distressEffect) == null ? void 0 : I.enabled) && T.distressEffect.style === "custom" && T.distressEffect.textureUrl, C = (M) => {
3192
3194
  if (T && T.masks && T.masks.length > 0)
3193
- At(M, T, (P) => {
3194
- const k = (B) => {
3195
- r && (B.save(), B.globalAlpha = tt), this.safeRender(B, g, w, S), r && B.restore();
3195
+ jt(f) && f.isCropping && (M.save(), M.globalAlpha *= Ue, this.safeRender(M, f, w, S), M.restore()), At(M, T, (k) => {
3196
+ const E = (B) => {
3197
+ r && (B.save(), B.globalAlpha = tt), this.safeRender(B, f, w, S), r && B.restore();
3196
3198
  };
3197
3199
  if (R) {
3198
- const B = g.getVisualBoundingBox();
3199
- $t(P, T.distressEffect, B, k);
3200
+ const B = f.getVisualBoundingBox();
3201
+ $t(k, T.distressEffect, B, E);
3200
3202
  } else
3201
- k(P);
3203
+ E(k);
3202
3204
  });
3203
3205
  else if (R) {
3204
- const P = g.getVisualBoundingBox();
3205
- $t(M, T.distressEffect, P, (k) => {
3206
- r && (k.save(), k.globalAlpha = tt), this.safeRender(k, g, w, S), r && k.restore();
3206
+ const k = f.getVisualBoundingBox();
3207
+ $t(M, T.distressEffect, k, (E) => {
3208
+ r && (E.save(), E.globalAlpha = tt), this.safeRender(E, f, w, S), r && E.restore();
3207
3209
  });
3208
- } else l && !h && a && w ? this.renderElementWithOverflowDimming(M, g, a, w, S, r) : l && a ? (M.save(), this.applyArtboardClipPath(M, a), r && (M.globalAlpha = tt), this.safeRender(M, g, w, S), M.restore()) : (r && (M.save(), M.globalAlpha = tt), this.safeRender(M, g, w, S), r && M.restore());
3210
+ } else l && !h && a && w ? this.renderElementWithOverflowDimming(M, f, a, w, S, r) : l && a ? (M.save(), this.applyArtboardClipPath(M, a), r && (M.globalAlpha = tt), this.safeRender(M, f, w, S), M.restore()) : (r && (M.save(), M.globalAlpha = tt), this.safeRender(M, f, w, S), r && M.restore());
3209
3211
  };
3210
3212
  Dt(
3211
3213
  t,
@@ -3219,8 +3221,8 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3219
3221
  * Elements with isClipping=true clip all elements below them
3220
3222
  */
3221
3223
  static _renderWithClipping(t, e, s, n, o, i, a, r, l = !0) {
3222
- var g;
3223
- const h = t.canvas, c = h.width, d = h.height, f = t.getTransform(), b = [];
3224
+ var f;
3225
+ const h = t.canvas, c = h.width, d = h.height, g = t.getTransform(), b = [];
3224
3226
  let u = [], p = [];
3225
3227
  for (let y = 0; y < e.length; y++) {
3226
3228
  const S = e[y], m = r[y];
@@ -3244,29 +3246,29 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3244
3246
  var I;
3245
3247
  const w = S.id === n, T = (o == null ? void 0 : o.type) === "element" && ((I = o == null ? void 0 : o.data) == null ? void 0 : I.id) === S.id, R = i && a && _t(S) && S.id === n, C = w && !R, x = y.contentConfigs[m];
3246
3248
  Dt(t, x, (M) => {
3247
- const P = M;
3248
- x && x.masks && x.masks.length > 0 ? At(P, x, (k) => {
3249
- l && (k.save(), k.globalAlpha = tt), S.render(k, C, T), l && k.restore();
3250
- }) : (l && (P.save(), P.globalAlpha = tt), S.render(P, C, T), l && P.restore());
3249
+ const k = M;
3250
+ x && x.masks && x.masks.length > 0 ? At(k, x, (E) => {
3251
+ l && (E.save(), E.globalAlpha = tt), S.render(E, C, T), l && E.restore();
3252
+ }) : (l && (k.save(), k.globalAlpha = tt), S.render(k, C, T), l && k.restore());
3251
3253
  });
3252
3254
  });
3253
3255
  else {
3254
3256
  const S = this._getContentCanvas(c, d), m = S.getContext("2d");
3255
3257
  if (!m) continue;
3256
- m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c, d), m.globalCompositeOperation = "source-over", m.setTransform(f), y.content.forEach((x, I) => {
3257
- var F;
3258
- const M = x.id === n, P = (o == null ? void 0 : o.type) === "element" && ((F = o == null ? void 0 : o.data) == null ? void 0 : F.id) === x.id, k = i && a && _t(x) && x.id === n, B = M && !k, W = y.contentConfigs[I];
3259
- Dt(m, W, (D) => {
3260
- const N = D;
3261
- W && W.masks && W.masks.length > 0 ? At(N, W, (j) => {
3262
- l && (j.save(), j.globalAlpha = tt), x.render(j, B, P), l && j.restore();
3263
- }) : (l && (N.save(), N.globalAlpha = tt), x.render(N, B, P), l && N.restore());
3258
+ m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c, d), m.globalCompositeOperation = "source-over", m.setTransform(g), y.content.forEach((x, I) => {
3259
+ var _;
3260
+ const M = x.id === n, k = (o == null ? void 0 : o.type) === "element" && ((_ = o == null ? void 0 : o.data) == null ? void 0 : _.id) === x.id, E = i && a && _t(x) && x.id === n, B = M && !E, W = y.contentConfigs[I];
3261
+ Dt(m, W, (G) => {
3262
+ const V = G;
3263
+ W && W.masks && W.masks.length > 0 ? At(V, W, (j) => {
3264
+ l && (j.save(), j.globalAlpha = tt), x.render(j, B, k), l && j.restore();
3265
+ }) : (l && (V.save(), V.globalAlpha = tt), x.render(V, B, k), l && V.restore());
3264
3266
  });
3265
3267
  });
3266
3268
  const w = this._getMaskCanvas(c, d), T = w.getContext("2d");
3267
3269
  if (!T) continue;
3268
- T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(f);
3269
- const R = y.mask.id === n, C = (o == null ? void 0 : o.type) === "element" && ((g = o == null ? void 0 : o.data) == null ? void 0 : g.id) === y.mask.id;
3270
+ T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(g);
3271
+ const R = y.mask.id === n, C = (o == null ? void 0 : o.type) === "element" && ((f = o == null ? void 0 : o.data) == null ? void 0 : f.id) === y.mask.id;
3270
3272
  y.maskConfig && y.maskConfig.masks && y.maskConfig.masks.length > 0 ? At(T, y.maskConfig, (x) => {
3271
3273
  l && (x.save(), x.globalAlpha = tt), y.mask.render(x, R, C), l && x.restore();
3272
3274
  }) : (l && (T.save(), T.globalAlpha = tt), y.mask.render(T, R, C), l && T.restore()), m.globalCompositeOperation = "destination-in", m.setTransform(1, 0, 0, 1, 0, 0), m.drawImage(w, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(S, 0, 0), t.restore();
@@ -3368,11 +3370,11 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3368
3370
  artboardBackgroundColor: h,
3369
3371
  artboard: c,
3370
3372
  isPreview: d = !0,
3371
- zoom: f = 1,
3373
+ zoom: g = 1,
3372
3374
  paddingOffset: b = { x: 0, y: 0 },
3373
3375
  showOverflowDimmed: u = !1,
3374
3376
  suppressOverflowDim: p = !1,
3375
- distressTexture: g,
3377
+ distressTexture: f,
3376
3378
  imageMask: y,
3377
3379
  editModeData: S
3378
3380
  }) {
@@ -3387,31 +3389,31 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3387
3389
  d,
3388
3390
  u,
3389
3391
  p
3390
- ), g != null && g.enabled && c && Ee(t, g, c, h), y != null && y.enabled && c && He(t, y, c, h), i && S && n && Vt.renderEditModeLayer(t, n, S, f), f !== 1) {
3392
+ ), f != null && f.enabled && c && He(t, f, c, h), y != null && y.enabled && c && Ie(t, y, c, h), i && S && n && Vt.renderEditModeLayer(t, n, S, g), g !== 1) {
3391
3393
  t.save();
3392
- const R = t.getTransform().a / f, C = b.x * f * R, x = b.y * f * R;
3394
+ const R = t.getTransform().a / g, C = b.x * g * R, x = b.y * g * R;
3393
3395
  t.setTransform(R, 0, 0, R, C, x);
3394
3396
  }
3395
3397
  const m = r.map((T) => ({
3396
3398
  ...T,
3397
- x: T.x !== void 0 ? T.x * f : void 0,
3398
- y: T.y !== void 0 ? T.y * f : void 0,
3399
- x1: T.x1 !== void 0 ? T.x1 * f : void 0,
3400
- y1: T.y1 !== void 0 ? T.y1 * f : void 0,
3401
- x2: T.x2 !== void 0 ? T.x2 * f : void 0,
3402
- y2: T.y2 !== void 0 ? T.y2 * f : void 0
3399
+ x: T.x !== void 0 ? T.x * g : void 0,
3400
+ y: T.y !== void 0 ? T.y * g : void 0,
3401
+ x1: T.x1 !== void 0 ? T.x1 * g : void 0,
3402
+ y1: T.y1 !== void 0 ? T.y1 * g : void 0,
3403
+ x2: T.x2 !== void 0 ? T.x2 * g : void 0,
3404
+ y2: T.y2 !== void 0 ? T.y2 * g : void 0
3403
3405
  })), w = l.map((T) => ({
3404
3406
  ...T,
3405
- x: T.x !== void 0 ? T.x * f : void 0,
3406
- y: T.y !== void 0 ? T.y * f : void 0,
3407
- x1: T.x1 !== void 0 ? T.x1 * f : void 0,
3408
- y1: T.y1 !== void 0 ? T.y1 * f : void 0,
3409
- x2: T.x2 !== void 0 ? T.x2 * f : void 0,
3410
- y2: T.y2 !== void 0 ? T.y2 * f : void 0,
3411
- labelX: T.labelX * f,
3412
- labelY: T.labelY * f
3407
+ x: T.x !== void 0 ? T.x * g : void 0,
3408
+ y: T.y !== void 0 ? T.y * g : void 0,
3409
+ x1: T.x1 !== void 0 ? T.x1 * g : void 0,
3410
+ y1: T.y1 !== void 0 ? T.y1 * g : void 0,
3411
+ x2: T.x2 !== void 0 ? T.x2 * g : void 0,
3412
+ y2: T.y2 !== void 0 ? T.y2 * g : void 0,
3413
+ labelX: T.labelX * g,
3414
+ labelY: T.labelY * g
3413
3415
  }));
3414
- Rt.renderSnapGuidesLayer(t, m), Rt.renderSpacingIndicatorsLayer(t, w), f !== 1 && t.restore();
3416
+ Rt.renderSnapGuidesLayer(t, m), Rt.renderSpacingIndicatorsLayer(t, w), g !== 1 && t.restore();
3415
3417
  }
3416
3418
  /**
3417
3419
  * Single-selection interaction chrome: bbox, handles, position/size
@@ -3438,7 +3440,7 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3438
3440
  isEditing: h,
3439
3441
  isAltKeyPressed: c = !1,
3440
3442
  artboardBackgroundColor: d,
3441
- hoverClipArtboard: f,
3443
+ hoverClipArtboard: g,
3442
3444
  showRotationHandle: b = !0,
3443
3445
  zoom: u = 1,
3444
3446
  paddingOffset: p = { x: 0, y: 0 }
@@ -3448,7 +3450,7 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3448
3450
  const S = t.getTransform().a / u, m = p.x * u * S, w = p.y * u * S;
3449
3451
  t.setTransform(S, 0, 0, S, m, w);
3450
3452
  }
3451
- if (e && Be(e) && e.isCropping)
3453
+ if (e && jt(e) && e.isCropping)
3452
3454
  s && Vt.renderCropBoxLayer(t, e, s, u);
3453
3455
  else if (!l && n && wt.renderSelectionLayer(t, e, n, u), s && n && wt.renderPositionSizeInfo(t, e, s, n, u), !l && s && n && wt.renderHandlesLayer(
3454
3456
  t,
@@ -3461,34 +3463,34 @@ const qe = Qt("CanvasRenderer"), $ = class $ {
3461
3463
  u,
3462
3464
  b
3463
3465
  ), !h) {
3464
- if (f) {
3466
+ if (g) {
3465
3467
  t.save();
3466
- const y = f, S = y.x * u, m = y.y * u, w = y.width * u, T = y.height * u, R = (y.borderRadius ?? 0) * u;
3468
+ const y = g, S = y.x * u, m = y.y * u, w = y.width * u, T = y.height * u, R = (y.borderRadius ?? 0) * u;
3467
3469
  t.beginPath(), R > 0 ? t.roundRect(S, m, w, T, R) : t.rect(S, m, w, T), t.clip();
3468
3470
  }
3469
- Ft.renderHoverLayer(t, a, r, c, u, d), f && t.restore();
3471
+ Ft.renderHoverLayer(t, a, r, c, u, d), g && t.restore();
3470
3472
  }
3471
3473
  u !== 1 && t.restore();
3472
3474
  }
3473
3475
  };
3474
3476
  $._contentCanvas = null, $._contentCanvasSize = { width: 0, height: 0 }, $._maskCanvas = null, $._maskCanvasSize = { width: 0, height: 0 }, $._cachedElementsRef = null, $._cachedElementConfigs = null, $._cachedElementMap = null, $._knockoutRenderedIds = /* @__PURE__ */ new Set(), $.onRenderError = null;
3475
- let Jt = $;
3477
+ let Qt = $;
3476
3478
  export {
3477
- an as A,
3478
- Jt as C,
3479
- on as I,
3479
+ rn as A,
3480
+ Qt as C,
3481
+ an as I,
3480
3482
  Ke as R,
3481
- rn as S,
3482
- nn as T,
3483
- oe as a,
3484
- hn as b,
3485
- tn as c,
3486
- Qe as d,
3483
+ ln as S,
3484
+ sn as T,
3485
+ ie as a,
3486
+ cn as b,
3487
+ en as c,
3488
+ tn as d,
3487
3489
  Ye as e,
3488
- sn as f,
3489
- jt as g,
3490
- ie as n,
3491
- ln as p,
3492
- en as r
3490
+ on as f,
3491
+ qt as g,
3492
+ ae as n,
3493
+ hn as p,
3494
+ nn as r
3493
3495
  };
3494
- //# sourceMappingURL=CanvasRenderer-BmLEU_Zb.js.map
3496
+ //# sourceMappingURL=CanvasRenderer-JcBrIZ6I.js.map