@snowcone-app/canvas 0.17.1 → 0.17.3

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 (65) hide show
  1. package/dist/{CanvasStateV1-C6i6vU6p.js → CanvasStateV1-BG2hEc3-.js} +3 -3
  2. package/dist/{CanvasStateV1-C6i6vU6p.js.map → CanvasStateV1-BG2hEc3-.js.map} +1 -1
  3. package/dist/EditorCanvasImpl-DQxqdgpq.js +70 -0
  4. package/dist/EditorCanvasImpl-DQxqdgpq.js.map +1 -0
  5. package/dist/EditorContext-CGkfmbgo.js +1178 -0
  6. package/dist/EditorContext-CGkfmbgo.js.map +1 -0
  7. package/dist/{ElementFactory-C05JJkRp.js → ElementFactory-CuHSAPfg.js} +1469 -710
  8. package/dist/ElementFactory-CuHSAPfg.js.map +1 -0
  9. package/dist/{HybridHistoryManager-Bht98XRv.js → FontAnalyzer-CLv7_msL.js} +2104 -2903
  10. package/dist/FontAnalyzer-CLv7_msL.js.map +1 -0
  11. package/dist/{ImportManager-kRYfIX-D.js → ImportManager-C_wBjWaV.js} +147 -147
  12. package/dist/{ImportManager-kRYfIX-D.js.map → ImportManager-C_wBjWaV.js.map} +1 -1
  13. package/dist/SnowconeCanvas-DBbmx9qW.js +1187 -0
  14. package/dist/SnowconeCanvas-DBbmx9qW.js.map +1 -0
  15. package/dist/{UnifiedFontService-BAtqqkU4.js → UnifiedFontService-Dsu5cwfT.js} +141 -141
  16. package/dist/UnifiedFontService-Dsu5cwfT.js.map +1 -0
  17. package/dist/advanced.mjs +10 -10
  18. package/dist/components/editor/RootInternals.d.ts +7 -0
  19. package/dist/components/embed/EmbedRoot.d.ts +23 -0
  20. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  21. package/dist/components/embed/kernel.d.ts +114 -0
  22. package/dist/contexts/BoundLayerGuardContext.d.ts +36 -0
  23. package/dist/core/GroupElement.d.ts +0 -5
  24. package/dist/core/TextElement.d.ts +8 -3
  25. package/dist/core/paint-registry.d.ts +42 -0
  26. package/dist/core/rich-text-layout.d.ts +28 -0
  27. package/dist/{editorErrors-DbIEtCTt.js → editorErrors-BY4Pdg7a.js} +2 -2
  28. package/dist/{editorErrors-DbIEtCTt.js.map → editorErrors-BY4Pdg7a.js.map} +1 -1
  29. package/dist/{embed-B5kewSQY.js → embed--B8ot6Lj.js} +207 -199
  30. package/dist/embed--B8ot6Lj.js.map +1 -0
  31. package/dist/embed.mjs +21 -22
  32. package/dist/embed.mjs.map +1 -1
  33. package/dist/index.mjs +7 -7
  34. package/dist/internals.mjs +93 -93
  35. package/dist/rendering/element-painters.d.ts +16 -0
  36. package/dist/rendering/rich-text-renderer.d.ts +3 -28
  37. package/dist/{template-fields-GOM4MNfq.js → template-fields-Z9x13sjM.js} +32 -33
  38. package/dist/{template-fields-GOM4MNfq.js.map → template-fields-Z9x13sjM.js.map} +1 -1
  39. package/dist/testing.mjs +7 -7
  40. package/dist/transforms/ArchTransform.d.ts +0 -1
  41. package/dist/transforms/AscendTransform.d.ts +0 -1
  42. package/dist/transforms/CircleTransform.d.ts +0 -1
  43. package/dist/transforms/FlagTransform.d.ts +0 -1
  44. package/dist/transforms/LeanTransform.d.ts +0 -1
  45. package/dist/transforms/WaveTransform.d.ts +0 -1
  46. package/dist/{usePieceGuideBundle-CGERAQJl.js → usePieceGuideBundle-C1ipFnZd.js} +2 -2
  47. package/dist/{usePieceGuideBundle-CGERAQJl.js.map → usePieceGuideBundle-C1ipFnZd.js.map} +1 -1
  48. package/dist/{validation-DEd6EOCP.js → validation-C795COGQ.js} +4803 -4791
  49. package/dist/validation-C795COGQ.js.map +1 -0
  50. package/dist/vendor/ui/primitives/kbd.d.ts +1 -1
  51. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/dist/EditorCanvasImpl-C8SsT3C2.js +0 -68
  54. package/dist/EditorCanvasImpl-C8SsT3C2.js.map +0 -1
  55. package/dist/EditorContext-CyanYzo2.js +0 -1131
  56. package/dist/EditorContext-CyanYzo2.js.map +0 -1
  57. package/dist/ElementFactory-C05JJkRp.js.map +0 -1
  58. package/dist/HybridHistoryManager-Bht98XRv.js.map +0 -1
  59. package/dist/SnowconeCanvas-C3eZ9PP8.js +0 -1047
  60. package/dist/SnowconeCanvas-C3eZ9PP8.js.map +0 -1
  61. package/dist/UnifiedFontService-BAtqqkU4.js.map +0 -1
  62. package/dist/editorError-DMENTZ-3.js +0 -19
  63. package/dist/editorError-DMENTZ-3.js.map +0 -1
  64. package/dist/embed-B5kewSQY.js.map +0 -1
  65. package/dist/validation-DEd6EOCP.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { aC as tt, _ as ae, $ as re, a5 as Vt, aP as le, aN as he, aG as Ot, aM as ce, aF as ht, aW as de, aX as Gt, aY as fe, aZ as ge, c as zt, G as ue, I as Qt, P as pe, S as ye, T as be, a_ as me, a$ as Se, b0 as Te, b1 as we, b2 as te, ag as ee, az as ft, ah as ne, b3 as Bt, b4 as ve, V as xe, b5 as Ce, b6 as Yt, b7 as Me, b8 as Re, b9 as Ee, ac as ke, ba as Pe, bb as Ae, bc as Q, A as Xt } from "./HybridHistoryManager-Bht98XRv.js";
2
- import { T as Ht, l as Ie, e as Et, m as Nt, n as Be, o as He, f as Kt } from "./ElementFactory-C05JJkRp.js";
1
+ import { ap as tt, V as ae, X as re, Y as Vt, aC as le, aA as he, at as Ot, az as ce, as as ht, aJ as de, aK as Yt, aL as fe, aM as ge, c as zt, G as ue, I as Qt, P as pe, S as ye, T as be, aN as me, aO as Se, aP as Te, aQ as we, a3 as te, $ as ee, a5 as ft, a0 as ne, a1 as Bt, a4 as ve, a7 as xe, aR as Gt, aS as Ce, aT as Re, aU as Me, aV as Ee, aW as ke, aX as Q, A as Xt } from "./FontAnalyzer-CLv7_msL.js";
2
+ import { T as Ht, a as Pe, t as Ae, J as Ie, y as Et, K as Nt, L as Be, N as He, C as Kt } from "./ElementFactory-CuHSAPfg.js";
3
3
  const ot = {
4
4
  // Canvas-specific
5
5
  canvas: {
@@ -188,17 +188,17 @@ class Ve {
188
188
  if (i && t.transformType === "image") {
189
189
  const V = e.anchor ?? "", A = V === "top-left" || V === "top-right" || V === "bottom-left" || V === "bottom-right", $ = V.startsWith("crop-");
190
190
  if (A && !$) {
191
- const j = (H = i.activeSnaps) == null ? void 0 : H.x, J = (L = i.activeSnaps) == null ? void 0 : L.y;
192
- if (!!j || !!J) {
193
- const E = [j, J].find(
191
+ const j = (H = i.activeSnaps) == null ? void 0 : H.x, Z = (L = i.activeSnaps) == null ? void 0 : L.y;
192
+ if (!!j || !!Z) {
193
+ const E = [j, Z].find(
194
194
  (I) => typeof I == "object" && I !== null && "frozenWidth" in I
195
195
  );
196
196
  if (E) {
197
197
  const I = t, _ = s.transformData, B = E.frozenWidth ?? ((D = I.transformData) == null ? void 0 : D.width) ?? u, F = I.imageAspectRatio || (_ != null && _.width && (_ != null && _.height) ? _.width / _.height : null);
198
- let G = E.frozenHeight;
199
- G == null && (F && F !== 0 ? G = B / F : (O = I.transformData) != null && O.height ? G = I.transformData.height : G = p);
200
- const at = u !== 0 ? B / u : 1, gt = p !== 0 ? G / p : 1;
201
- b = c * at, g = d * gt, f = B, y = G, w = !0;
198
+ let Y = E.frozenHeight;
199
+ Y == null && (F && F !== 0 ? Y = B / F : (O = I.transformData) != null && O.height ? Y = I.transformData.height : Y = p);
200
+ const at = u !== 0 ? B / u : 1, gt = p !== 0 ? Y / p : 1;
201
+ b = c * at, g = d * gt, f = B, y = Y, w = !0;
202
202
  }
203
203
  }
204
204
  }
@@ -209,7 +209,7 @@ class Ve {
209
209
  const V = s.width ?? 1, A = s.height ?? 1, $ = Math.sqrt(f / V * (y / A)), j = Math.max(1, Math.round(s.strokeWidth * $ * 10) / 10);
210
210
  m.stroke = { ...m.stroke, width: j };
211
211
  }
212
- const M = w || C === !1, k = e.anchor.includes("top") || e.anchor.includes("bottom"), v = "isCropping" in m && m.isCropping, P = "isGroup" in m && m.isGroup;
212
+ const R = w || C === !1, k = e.anchor.includes("top") || e.anchor.includes("bottom"), v = "isCropping" in m && m.isCropping, P = "isGroup" in m && m.isGroup;
213
213
  if (k && !v && !P) {
214
214
  const V = t.getRotationAnchor(), A = this._calculateFixedCornerOffset({
215
215
  element: t,
@@ -221,7 +221,7 @@ class Ve {
221
221
  }
222
222
  return {
223
223
  element: m,
224
- isFrozen: M,
224
+ isFrozen: R,
225
225
  // For snap system to detect break-free: dimensions before freeze was applied
226
226
  unfrozenDimensions: w ? { width: S, height: T } : void 0
227
227
  };
@@ -237,7 +237,7 @@ class Ve {
237
237
  handle: o,
238
238
  rotationAnchor: n
239
239
  }) {
240
- const s = new Ot(t), { cos: i, sin: a } = s.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(o.anchor, r.width, r.height), u = d.x, p = d.y, b = r.x - h.x, g = r.y - h.y, f = b + u, y = g + p, S = f * i - y * a, T = f * a + y * i, w = h.x + S, m = h.y + T, C = this._getFixedLocalCoords(o.anchor, l.width, l.height), R = C.x, M = C.y, k = l.x - c.x, v = l.y - c.y, P = k + R, H = v + M, L = P * i - H * a, D = P * a + H * i, O = c.x + L, W = c.y + D;
240
+ const s = new Ot(t), { cos: i, sin: a } = s.getRenderingCosSin(), r = t.getVisualBoundingBox(), l = e.getVisualBoundingBox(), h = n, c = e.getRotationAnchor(), d = this._getFixedLocalCoords(o.anchor, r.width, r.height), u = d.x, p = d.y, b = r.x - h.x, g = r.y - h.y, f = b + u, y = g + p, S = f * i - y * a, T = f * a + y * i, w = h.x + S, m = h.y + T, C = this._getFixedLocalCoords(o.anchor, l.width, l.height), M = C.x, R = C.y, k = l.x - c.x, v = l.y - c.y, P = k + M, H = v + R, L = P * i - H * a, D = P * a + H * i, O = c.x + L, W = c.y + D;
241
241
  return {
242
242
  x: w - O,
243
243
  y: m - W
@@ -348,8 +348,8 @@ class Oe {
348
348
  return this.runHooks("afterPositionUpdate", o).position;
349
349
  }
350
350
  }
351
- const Ze = new Oe();
352
- class Je {
351
+ const Je = new Oe();
352
+ class Ze {
353
353
  constructor(t = null) {
354
354
  this.state = "IDLE", this.context = {
355
355
  mode: null,
@@ -1001,20 +1001,20 @@ class Qe {
1001
1001
  for (const m of T) {
1002
1002
  const C = this._anchorMetadata.get(m.id);
1003
1003
  if (!C) continue;
1004
- const R = C.point, M = C.anchorKey, k = Math.abs(S.x - R.x);
1004
+ const M = C.point, R = C.anchorKey, k = Math.abs(S.x - M.x);
1005
1005
  if (k < this.snapThreshold) {
1006
1006
  const v = {
1007
- snapTo: R.x,
1007
+ snapTo: M.x,
1008
1008
  offset: S.x - t.x,
1009
1009
  // How far anchor is from element position
1010
1010
  distance: k,
1011
1011
  guide: {
1012
1012
  type: "vertical",
1013
- x: R.x,
1014
- y1: Math.min(S.y, R.y) - 50,
1015
- y2: Math.max(S.y, R.y) + 50,
1013
+ x: M.x,
1014
+ y1: Math.min(S.y, M.y) - 50,
1015
+ y2: Math.max(S.y, M.y) + 50,
1016
1016
  movingKey: y,
1017
- otherKey: M
1017
+ otherKey: R
1018
1018
  }
1019
1019
  };
1020
1020
  c.push(v), k < l && (l = k, a = v);
@@ -1024,19 +1024,19 @@ class Qe {
1024
1024
  for (const m of w) {
1025
1025
  const C = this._anchorMetadata.get(m.id);
1026
1026
  if (!C) continue;
1027
- const R = C.point, M = C.anchorKey, k = Math.abs(S.y - R.y);
1027
+ const M = C.point, R = C.anchorKey, k = Math.abs(S.y - M.y);
1028
1028
  if (k < this.snapThreshold) {
1029
1029
  const v = {
1030
- snapTo: R.y,
1030
+ snapTo: M.y,
1031
1031
  offset: S.y - t.y,
1032
1032
  distance: k,
1033
1033
  guide: {
1034
1034
  type: "horizontal",
1035
- y: R.y,
1036
- x1: Math.min(S.x, R.x) - 50,
1037
- x2: Math.max(S.x, R.x) + 50,
1035
+ y: M.y,
1036
+ x1: Math.min(S.x, M.x) - 50,
1037
+ x2: Math.max(S.x, M.x) + 50,
1038
1038
  movingKey: y,
1039
- otherKey: M
1039
+ otherKey: R
1040
1040
  }
1041
1041
  };
1042
1042
  d.push(v), k < h && (h = k, r = v);
@@ -1440,7 +1440,7 @@ class Qe {
1440
1440
  * @returns {object} Modified resize result with adjusted element
1441
1441
  */
1442
1442
  snapDimensions(t, e, o = null) {
1443
- var m, C, R, M, k;
1443
+ var m, C, M, R, k;
1444
1444
  if (!this.enabled || !e)
1445
1445
  return this.clearGuides(), t;
1446
1446
  const { element: n } = t, s = t.handle;
@@ -1487,13 +1487,13 @@ class Qe {
1487
1487
  const E = this.activeSnaps.x || this.activeSnaps.y;
1488
1488
  let I = L, _ = D;
1489
1489
  E && (I = E.frozenWidth ?? I, _ = E.frozenHeight ?? _);
1490
- const B = lt(n), F = mt(n), G = v.imageAspectRatio || (B && F ? B / F : null);
1491
- G && G !== 0 && (_ = I / G), vt(v, I), kt(v, _), E && (E.frozenWidth = I, E.frozenHeight = _);
1490
+ const B = lt(n), F = mt(n), Y = v.imageAspectRatio || (B && F ? B / F : null);
1491
+ Y && Y !== 0 && (_ = I / Y), vt(v, I), kt(v, _), E && (E.frozenWidth = I, E.frozenHeight = _);
1492
1492
  }
1493
1493
  } else
1494
- (((R = this.activeSnaps.y) == null ? void 0 : R.isPositionBasedSnap) || !1) && (lt(v) !== void 0 ? vt(v, L) : v.width !== void 0 && (v.width = L));
1495
- const $ = s && (s.anchor === "middle-left" || s.anchor === "middle-right"), j = s && (s.anchor === "middle-top" || s.anchor === "middle-bottom"), J = ((M = this.activeSnaps.x) == null ? void 0 : M.isPositionBasedSnap) || !1, X = ((k = this.activeSnaps.y) == null ? void 0 : k.isPositionBasedSnap) || !1;
1496
- return (g === 0 || J) && !$ && !j && !W && (v.x = O.x), (f === 0 || X) && !j && !$ && !W && (v.y = O.y), {
1494
+ (((M = this.activeSnaps.y) == null ? void 0 : M.isPositionBasedSnap) || !1) && (lt(v) !== void 0 ? vt(v, L) : v.width !== void 0 && (v.width = L));
1495
+ const $ = s && (s.anchor === "middle-left" || s.anchor === "middle-right"), j = s && (s.anchor === "middle-top" || s.anchor === "middle-bottom"), Z = ((R = this.activeSnaps.x) == null ? void 0 : R.isPositionBasedSnap) || !1, X = ((k = this.activeSnaps.y) == null ? void 0 : k.isPositionBasedSnap) || !1;
1496
+ return (g === 0 || Z) && !$ && !j && !W && (v.x = O.x), (f === 0 || X) && !j && !$ && !W && (v.y = O.y), {
1497
1497
  ...t,
1498
1498
  element: v,
1499
1499
  snapAdjustment: { dx: g, dy: f },
@@ -1550,7 +1550,7 @@ class tn {
1550
1550
  snapToSpacing(t, e, o) {
1551
1551
  if (!this.enabled || !o)
1552
1552
  return t;
1553
- const n = Gt, s = o.filter((g) => g.id !== e.id);
1553
+ const n = Yt, s = o.filter((g) => g.id !== e.id);
1554
1554
  if (s.length === 0)
1555
1555
  return t;
1556
1556
  const i = e.clone();
@@ -1738,8 +1738,8 @@ class tn {
1738
1738
  isAltHover: !0
1739
1739
  }), a++);
1740
1740
  let S = 0, T = !1, w = 0, m = 0, C = 0;
1741
- const M = 30 * (r % 2 === 0 ? 1 : -1);
1742
- h.y >= n.y + n.height ? (S = h.y - (n.y + n.height), S >= this.minDistance && (T = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + M, m = n.y + n.height, C = h.y)) : n.y >= h.y + h.height && (S = n.y - (h.y + h.height), S >= this.minDistance && (T = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + M, m = h.y + h.height, C = n.y)), T && (o.push({
1741
+ const R = 30 * (r % 2 === 0 ? 1 : -1);
1742
+ h.y >= n.y + n.height ? (S = h.y - (n.y + n.height), S >= this.minDistance && (T = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + R, m = n.y + n.height, C = h.y)) : n.y >= h.y + h.height && (S = n.y - (h.y + h.height), S >= this.minDistance && (T = !0, w = (n.x + n.width / 2 + h.x + h.width / 2) / 2 + R, m = h.y + h.height, C = n.y)), T && (o.push({
1743
1743
  type: "vertical",
1744
1744
  distance: Math.round(S),
1745
1745
  x: w,
@@ -1847,7 +1847,7 @@ class tn {
1847
1847
  * Check if spacing would snap to a pattern
1848
1848
  */
1849
1849
  checkIfWouldSnap(t, e, o, n) {
1850
- const s = Gt;
1850
+ const s = Yt;
1851
1851
  if (o === "top" || o === "bottom") {
1852
1852
  const i = n.filter((a) => {
1853
1853
  const r = a.getVisualBoundingBox();
@@ -1947,7 +1947,7 @@ class tn {
1947
1947
  }
1948
1948
  }
1949
1949
  }
1950
- const Lt = zt("ArtboardRenderer"), Ge = {
1950
+ const Lt = zt("ArtboardRenderer"), Ye = {
1951
1951
  showLabel: !0,
1952
1952
  showBorder: !0,
1953
1953
  borderColor: "",
@@ -1967,7 +1967,7 @@ const Lt = zt("ArtboardRenderer"), Ge = {
1967
1967
  };
1968
1968
  class oe {
1969
1969
  constructor(t = {}) {
1970
- this.options = { ...Ge, ...t };
1970
+ this.options = { ...Ye, ...t };
1971
1971
  }
1972
1972
  /**
1973
1973
  * Render an artboard
@@ -2161,7 +2161,7 @@ class oe {
2161
2161
  function en(x) {
2162
2162
  return x instanceof be;
2163
2163
  }
2164
- function Ye(x) {
2164
+ function Ge(x) {
2165
2165
  return x instanceof Qt;
2166
2166
  }
2167
2167
  function Dt(x) {
@@ -2390,10 +2390,10 @@ class _t {
2390
2390
  bold: i,
2391
2391
  italic: a
2392
2392
  });
2393
- C.forEach((R, M) => {
2394
- f.push(R), y.push({
2395
- isParagraphStart: M === 0,
2396
- isParagraphEnd: M === C.length - 1
2393
+ C.forEach((M, R) => {
2394
+ f.push(M), y.push({
2395
+ isParagraphStart: R === 0,
2396
+ isParagraphEnd: R === C.length - 1
2397
2397
  });
2398
2398
  });
2399
2399
  } else
@@ -2407,56 +2407,56 @@ class _t {
2407
2407
  const T = -S / 2;
2408
2408
  f.forEach((w, m) => {
2409
2409
  var W, V;
2410
- const C = y[m].isParagraphStart, R = y[m].isParagraphEnd;
2411
- let M = 0;
2410
+ const C = y[m].isParagraphStart, M = y[m].isParagraphEnd;
2411
+ let R = 0;
2412
2412
  const k = w.map((A) => A.text).join(""), v = ((W = k.match(/^ +/)) == null ? void 0 : W[0].length) || 0, P = ((V = k.match(/ +$/)) == null ? void 0 : V[0].length) || 0;
2413
2413
  let H = 0;
2414
2414
  w.forEach((A) => {
2415
- const $ = A.style.fontSize !== void 0 ? A.style.fontSize : n, j = A.style.fontFamily !== void 0 ? A.style.fontFamily : s, J = A.style.bold !== void 0 ? A.style.bold : i, X = A.style.italic !== void 0 ? A.style.italic : a;
2415
+ const $ = A.style.fontSize !== void 0 ? A.style.fontSize : n, j = A.style.fontFamily !== void 0 ? A.style.fontFamily : s, Z = A.style.bold !== void 0 ? A.style.bold : i, X = A.style.italic !== void 0 ? A.style.italic : a;
2416
2416
  let E = A.text;
2417
2417
  const I = H, _ = H + A.text.length;
2418
2418
  if (!C && v > 0 && I < v) {
2419
2419
  const B = Math.min(v - I, A.text.length);
2420
2420
  E = E.substring(B);
2421
2421
  }
2422
- if (!R && P > 0) {
2422
+ if (!M && P > 0) {
2423
2423
  const B = k.length - P;
2424
2424
  if (_ > B) {
2425
- const F = !C && I < v ? Math.min(v - I, A.text.length) : 0, G = Math.max(0, B - I - F);
2426
- E = E.substring(0, G);
2425
+ const F = !C && I < v ? Math.min(v - I, A.text.length) : 0, Y = Math.max(0, B - I - F);
2426
+ E = E.substring(0, Y);
2427
2427
  }
2428
2428
  }
2429
- E.length > 0 && (t.save(), t.font = Bt($, j, J, X), M += t.measureText(E).width, t.restore()), H += A.text.length;
2429
+ E.length > 0 && (t.save(), t.font = Bt($, j, Z, X), R += t.measureText(E).width, t.restore()), H += A.text.length;
2430
2430
  });
2431
2431
  const L = e.transformType === "custom" && e.transformData ? e.transformData.width - ft * 2 : void 0;
2432
2432
  let D;
2433
- r === "center" ? D = -M / 2 : r === "right" ? D = L !== void 0 ? L / 2 - M : -M : D = L !== void 0 ? -L / 2 : 0;
2433
+ r === "center" ? D = -R / 2 : r === "right" ? D = L !== void 0 ? L / 2 - R : -R : D = L !== void 0 ? -L / 2 : 0;
2434
2434
  const O = T + l.ascent + m * h;
2435
2435
  H = 0, w.forEach((A) => {
2436
2436
  const $ = A.style.fontSize !== void 0 ? A.style.fontSize : n, j = A.style.fontFamily !== void 0 ? A.style.fontFamily : s;
2437
2437
  A.style.color !== void 0 ? A.style.color : e.color;
2438
- const J = A.style.bold !== void 0 ? A.style.bold : i, X = A.style.italic !== void 0 ? A.style.italic : a;
2438
+ const Z = A.style.bold !== void 0 ? A.style.bold : i, X = A.style.italic !== void 0 ? A.style.italic : a;
2439
2439
  let E = A.text;
2440
2440
  const I = H, _ = H + A.text.length;
2441
2441
  if (!C && v > 0 && I < v) {
2442
2442
  const B = Math.min(v - I, A.text.length);
2443
2443
  E = E.substring(B);
2444
2444
  }
2445
- if (!R && P > 0) {
2445
+ if (!M && P > 0) {
2446
2446
  const B = k.length - P;
2447
2447
  if (_ > B) {
2448
- const F = !C && I < v ? Math.min(v - I, A.text.length) : 0, G = Math.max(0, B - I - F);
2449
- E = E.substring(0, G);
2448
+ const F = !C && I < v ? Math.min(v - I, A.text.length) : 0, Y = Math.max(0, B - I - F);
2449
+ E = E.substring(0, Y);
2450
2450
  }
2451
2451
  }
2452
- H += A.text.length, E.length > 0 && (p.font = Bt($, j, J, X), p.textAlign = "left", p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.strokeText(E, D, O), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(E, D, O), p.fillText(E, D, O), D += p.measureText(E).width);
2452
+ H += A.text.length, E.length > 0 && (p.font = Bt($, j, Z, X), p.textAlign = "left", p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.strokeText(E, D, O), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(E, D, O), p.fillText(E, D, O), D += p.measureText(E).width);
2453
2453
  });
2454
2454
  });
2455
2455
  } else {
2456
2456
  t.font = Bt(n, s, i, a), p.font = t.font, p.textAlign = r;
2457
2457
  let g, f;
2458
2458
  if (e.transformType === "custom" && e.transformData) {
2459
- const C = e.transformData.width - ft * 2, { lines: R } = ve(
2459
+ const C = e.transformData.width - ft * 2, { lines: M } = ve(
2460
2460
  e.text,
2461
2461
  C,
2462
2462
  n,
@@ -2466,22 +2466,22 @@ class _t {
2466
2466
  void 0,
2467
2467
  !0
2468
2468
  );
2469
- g = R;
2469
+ g = M;
2470
2470
  } else {
2471
2471
  g = e.text.split(`
2472
2472
  `);
2473
2473
  const C = e.text.includes(`
2474
2474
  `);
2475
- g = xe(g, C);
2475
+ g = Pe(g, C);
2476
2476
  }
2477
2477
  g.length === 0 ? f = 0 : g.length === 1 ? f = l.height : f = (g.length - 1) * h + l.height;
2478
2478
  const y = -f / 2, S = e.text.includes(`
2479
2479
  `), T = e.transformType === "custom" && e.transformData ? e.transformData.width : 0, w = -T / 2;
2480
2480
  let m = w + ft;
2481
- r === "center" ? m = w + T / 2 : r === "right" && (m = w + T - ft), g.forEach((C, R) => {
2482
- const M = y + l.ascent + R * h, k = S || R === 0, v = S || R === g.length - 1;
2481
+ r === "center" ? m = w + T / 2 : r === "right" && (m = w + T - ft), g.forEach((C, M) => {
2482
+ const R = y + l.ascent + M * h, k = S || M === 0, v = S || M === g.length - 1;
2483
2483
  let P = C;
2484
- k || (P = P.replace(/^ +/, "")), v || (P = P.replace(/ +$/, "")), p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.lineJoin = "round", p.strokeText(P, m, M), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(P, m, M), p.fillText(P, m, M);
2484
+ k || (P = P.replace(/^ +/, "")), v || (P = P.replace(/ +$/, "")), p.globalCompositeOperation = "source-over", p.strokeStyle = t.strokeStyle, p.globalAlpha = Math.min(t.globalAlpha * 1.6, 0.8), p.lineWidth = (d + c) * 2, p.lineJoin = "round", p.strokeText(P, m, R), p.globalCompositeOperation = "destination-out", p.globalAlpha = 1, p.lineWidth = d * 2, p.strokeText(P, m, R), p.fillText(P, m, R);
2485
2485
  });
2486
2486
  }
2487
2487
  t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(u, 0, 0), t.restore();
@@ -2564,7 +2564,7 @@ class _t {
2564
2564
  let a = -o.reduce((r, l) => r + l, 0) / 2;
2565
2565
  return e.forEach((r, l) => {
2566
2566
  const h = o[l], c = a + h / 2, d = c / (n.width / 2), u = n.amplitude * t.fontSize * Math.sin(n.frequency * Math.PI * d), p = n.amplitude * n.frequency * Math.PI * Math.cos(n.frequency * Math.PI * d);
2567
- s.push({ x: c, y: u, angle: 0, skewY: p * Ce }), a += h;
2567
+ s.push({ x: c, y: u, angle: 0, skewY: p * xe }), a += h;
2568
2568
  }), s;
2569
2569
  }
2570
2570
  /**
@@ -2626,7 +2626,7 @@ class xt {
2626
2626
  */
2627
2627
  static renderSpacingIndicatorsLayer(t, e = []) {
2628
2628
  e.length !== 0 && (t.save(), t.setLineDash([]), e.forEach((o) => {
2629
- const n = Yt(t.canvas);
2629
+ const n = Gt(t.canvas);
2630
2630
  if (t.strokeStyle = n, t.fillStyle = n, t.lineWidth = ot.canvas.spacingIndicatorWidth, t.beginPath(), o.type === "horizontal") {
2631
2631
  const s = o.x1 ?? 0, i = o.x2 ?? 0, a = o.y ?? 0;
2632
2632
  t.moveTo(s, a), t.lineTo(i, a), t.stroke();
@@ -2651,7 +2651,7 @@ class xt {
2651
2651
  const s = `${n}`;
2652
2652
  t.font = `600 ${ot.canvas.spacingLabelFontSize}px ${ot.canvas.spacingLabelFontFamily}`;
2653
2653
  const a = t.measureText(s).width, r = ot.canvas.spacingLabelFontSize, l = 4, h = a + l * 2, c = r + l * 2;
2654
- t.fillStyle = Yt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, o - c / 2, h, c, Me), t.fill(), t.fillStyle = Re, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, e, o);
2654
+ t.fillStyle = Gt(t.canvas), t.beginPath(), t.roundRect(e - h / 2, o - c / 2, h, c, Ce), t.fill(), t.fillStyle = Re, t.textAlign = "center", t.textBaseline = "middle", t.fillText(s, e, o);
2655
2655
  }
2656
2656
  }
2657
2657
  class Wt {
@@ -2668,7 +2668,7 @@ class Wt {
2668
2668
  }
2669
2669
  const g = s.fontSize || 24, f = s.fontFamily || "Arial", y = s.bold || !1, S = s.italic || !1, T = s.underline || !1, w = s.strikethrough || !1, m = s.textAlign || "center";
2670
2670
  t.save(), t.translate(s.x, s.y), t.rotate(-s.rotation * Math.PI / 180);
2671
- const C = te(g, f, y, S), R = C.height, M = g * 1.2;
2671
+ const C = te(g, f, y, S), M = C.height, R = g * 1.2;
2672
2672
  let k, v, P;
2673
2673
  if (h && s.transformType === "custom" && s.transformData.width) {
2674
2674
  const X = s.transformData.width - ft * 2;
@@ -2700,32 +2700,32 @@ class Wt {
2700
2700
  // Each line is its own paragraph
2701
2701
  isParagraphEnd: !0
2702
2702
  }));
2703
- const H = k.length > 1 ? C.height + (k.length - 1) * M : C.height;
2704
- let L = -H / 2, D = 0, O = L, W = R;
2703
+ const H = k.length > 1 ? C.height + (k.length - 1) * R : C.height;
2704
+ let L = -H / 2, D = 0, O = L, W = M;
2705
2705
  const V = [];
2706
2706
  let A = 0;
2707
2707
  k.forEach((X, E) => {
2708
- var F, G;
2708
+ var F, Y;
2709
2709
  const I = v[E].isParagraphStart, _ = v[E].isParagraphEnd, B = [];
2710
2710
  X.forEach((at) => {
2711
2711
  Array.from(at.text).forEach((ct) => {
2712
- let Y = g, it = f, et = y, q = S;
2712
+ let G = g, it = f, et = y, q = S;
2713
2713
  if (h && A < l.length) {
2714
- const Z = h.getStyleAt(A);
2715
- Y = Z.fontSize || g, it = Z.fontFamily || f, et = Z.bold !== void 0 ? Z.bold : y, q = Z.italic !== void 0 ? Z.italic : S;
2714
+ const J = h.getStyleAt(A);
2715
+ G = J.fontSize || g, it = J.fontFamily || f, et = J.bold !== void 0 ? J.bold : y, q = J.italic !== void 0 ? J.italic : S;
2716
2716
  }
2717
2717
  t.save();
2718
2718
  const nt = et ? "bold" : "normal", z = q ? "italic" : "normal";
2719
- t.font = `${z} ${nt} ${Y}px "${it}", Arial, sans-serif`;
2719
+ t.font = `${z} ${nt} ${G}px "${it}", Arial, sans-serif`;
2720
2720
  const U = t.measureText(ct).width;
2721
- t.restore(), B.push({ char: ct, width: U, fontSize: Y, index: A }), A++;
2721
+ t.restore(), B.push({ char: ct, width: U, fontSize: G, index: A }), A++;
2722
2722
  });
2723
2723
  });
2724
2724
  {
2725
- const at = E === 0, gt = E === k.length - 1, ct = B.map((z) => z.char).join(""), Y = ((F = ct.match(/^ +/)) == null ? void 0 : F[0].length) || 0, it = ((G = ct.match(/ +$/)) == null ? void 0 : G[0].length) || 0;
2725
+ const at = E === 0, gt = E === k.length - 1, ct = B.map((z) => z.char).join(""), G = ((F = ct.match(/^ +/)) == null ? void 0 : F[0].length) || 0, it = ((Y = ct.match(/ +$/)) == null ? void 0 : Y[0].length) || 0;
2726
2726
  let et = 0;
2727
2727
  for (let z = 0; z < B.length; z++)
2728
- !at && z < Y || !gt && z >= B.length - it || (et += B[z].width);
2728
+ !at && z < G || !gt && z >= B.length - it || (et += B[z].width);
2729
2729
  let q;
2730
2730
  m === "center" ? q = -et / 2 : m === "right" ? q = P !== void 0 ? P / 2 - et : -et : q = P !== void 0 ? -P / 2 : 0;
2731
2731
  let nt = q;
@@ -2743,72 +2743,72 @@ class Wt {
2743
2743
  const z = B[0].index, U = B[B.length - 1].index, dt = E < k.length - 1 && U + 1 === A ? U : U + 1;
2744
2744
  if (i >= z && i <= dt)
2745
2745
  if (i === z)
2746
- D = q, O = L, W = R;
2746
+ D = q, O = L, W = M;
2747
2747
  else {
2748
2748
  let pt = 0;
2749
2749
  for (let st = 0; st < B.length && B[st].index < i; st++) {
2750
- const rt = B[st], Mt = rt.char === " ";
2750
+ const rt = B[st], Rt = rt.char === " ";
2751
2751
  let yt = !0;
2752
- if (Mt) {
2753
- const Rt = st < Y, N = st >= B.length - it, Tt = !I && Y > 0, wt = !_ && it > 0;
2754
- yt = !(Rt && Tt || N && wt);
2752
+ if (Rt) {
2753
+ const Mt = st < G, N = st >= B.length - it, Tt = !I && G > 0, wt = !_ && it > 0;
2754
+ yt = !(Mt && Tt || N && wt);
2755
2755
  }
2756
2756
  yt && (pt += rt.width);
2757
2757
  }
2758
- D = q + pt, O = L, W = R;
2758
+ D = q + pt, O = L, W = M;
2759
2759
  }
2760
2760
  }
2761
- E < k.length - 1 && (L += M);
2761
+ E < k.length - 1 && (L += R);
2762
2762
  }
2763
2763
  });
2764
2764
  const $ = a !== r;
2765
- let j = null, J = null;
2765
+ let j = null, Z = null;
2766
2766
  if ($) {
2767
2767
  const X = Math.min(a, r), E = Math.max(a, r);
2768
- t.save(), t.fillStyle = Ee(t.canvas);
2768
+ t.save(), t.fillStyle = Me(t.canvas);
2769
2769
  let I = 0, _ = -H / 2;
2770
2770
  if (k.forEach((B, F) => {
2771
2771
  var it, et;
2772
- const G = v[F].isParagraphStart, at = v[F].isParagraphEnd, gt = F === 0, ct = F === k.length - 1, Y = [];
2772
+ const Y = v[F].isParagraphStart, at = v[F].isParagraphEnd, gt = F === 0, ct = F === k.length - 1, G = [];
2773
2773
  if (B.forEach((q) => {
2774
2774
  Array.from(q.text).forEach((nt) => {
2775
- const z = q.style || {}, U = z.fontSize !== void 0 ? z.fontSize : g, Z = z.fontFamily !== void 0 ? z.fontFamily : f, ut = z.bold !== void 0 ? z.bold : y, dt = z.italic !== void 0 ? z.italic : S;
2775
+ const z = q.style || {}, U = z.fontSize !== void 0 ? z.fontSize : g, J = z.fontFamily !== void 0 ? z.fontFamily : f, ut = z.bold !== void 0 ? z.bold : y, dt = z.italic !== void 0 ? z.italic : S;
2776
2776
  t.save();
2777
2777
  const pt = ut ? "bold" : "normal", st = dt ? "italic" : "normal";
2778
- t.font = `${st} ${pt} ${U}px "${Z}", Arial, sans-serif`;
2778
+ t.font = `${st} ${pt} ${U}px "${J}", Arial, sans-serif`;
2779
2779
  const rt = t.measureText(nt).width;
2780
- t.restore(), Y.push({ char: nt, index: I, width: rt, style: z }), I++;
2780
+ t.restore(), G.push({ char: nt, index: I, width: rt, style: z }), I++;
2781
2781
  });
2782
- }), Y.length > 0) {
2783
- const q = Y[0].index, nt = Y[Y.length - 1].index;
2782
+ }), G.length > 0) {
2783
+ const q = G[0].index, nt = G[G.length - 1].index;
2784
2784
  if (E > q && X <= nt) {
2785
2785
  t.save();
2786
- const z = Y.map((N) => N.char).join(""), U = ((it = z.match(/^ +/)) == null ? void 0 : it[0].length) || 0, Z = ((et = z.match(/ +$/)) == null ? void 0 : et[0].length) || 0;
2786
+ const z = G.map((N) => N.char).join(""), U = ((it = z.match(/^ +/)) == null ? void 0 : it[0].length) || 0, J = ((et = z.match(/ +$/)) == null ? void 0 : et[0].length) || 0;
2787
2787
  let ut = 0;
2788
- for (let N = 0; N < Y.length; N++)
2789
- !gt && N < U || !ct && N >= Y.length - Z || (ut += Y[N].width);
2788
+ for (let N = 0; N < G.length; N++)
2789
+ !gt && N < U || !ct && N >= G.length - J || (ut += G[N].width);
2790
2790
  let dt = 0;
2791
2791
  m === "center" ? dt = -ut / 2 : m === "right" && (dt = -ut);
2792
2792
  const pt = Math.max(X, q), st = Math.min(E, nt + 1);
2793
2793
  let rt = 0;
2794
- for (let N = 0; N < Y.length && Y[N].index < pt; N++) {
2795
- const Tt = Y[N], wt = N < U, Pt = N >= Y.length - Z, At = !G && U > 0, It = !at && Z > 0;
2794
+ for (let N = 0; N < G.length && G[N].index < pt; N++) {
2795
+ const Tt = G[N], wt = N < U, Pt = N >= G.length - J, At = !Y && U > 0, It = !at && J > 0;
2796
2796
  !(wt && At || Pt && It) && (rt += Tt.width);
2797
2797
  }
2798
- let Mt = 0;
2799
- for (let N = 0; N < Y.length && Y[N].index < st; N++) {
2800
- const Tt = Y[N], wt = N < U, Pt = N >= Y.length - Z, At = !G && U > 0, It = !at && Z > 0;
2801
- !(wt && At || Pt && It) && (Mt += Tt.width);
2798
+ let Rt = 0;
2799
+ for (let N = 0; N < G.length && G[N].index < st; N++) {
2800
+ const Tt = G[N], wt = N < U, Pt = N >= G.length - J, At = !Y && U > 0, It = !at && J > 0;
2801
+ !(wt && At || Pt && It) && (Rt += Tt.width);
2802
2802
  }
2803
- const yt = dt + rt, Rt = Mt - rt;
2804
- t.fillRect(yt, _, Rt, R), j === null && (j = { x: yt, y: _ }), J = { x: yt + Rt, y: _ + R }, t.restore();
2803
+ const yt = dt + rt, Mt = Rt - rt;
2804
+ t.fillRect(yt, _, Mt, M), j === null && (j = { x: yt, y: _ }), Z = { x: yt + Mt, y: _ + M }, t.restore();
2805
2805
  }
2806
2806
  }
2807
- F < k.length - 1 && (_ += M);
2807
+ F < k.length - 1 && (_ += R);
2808
2808
  }), t.restore(), h) {
2809
2809
  t.save();
2810
2810
  const B = s.transformType === "custom" ? s.transformData : null, F = B != null && B.width ? B.width - ft * 2 : void 0;
2811
- ke(t, h, {
2811
+ Ae(t, h, {
2812
2812
  fontSize: g,
2813
2813
  fontFamily: f,
2814
2814
  color: s.color || "#000000",
@@ -2820,20 +2820,20 @@ class Wt {
2820
2820
  }, F), t.restore();
2821
2821
  }
2822
2822
  }
2823
- if ($ && d && j && J) {
2824
- const X = j, E = J, I = 6 / p, _ = 2 / p;
2823
+ if ($ && d && j && Z) {
2824
+ const X = j, E = Z, I = 6 / p, _ = 2 / p;
2825
2825
  t.save();
2826
2826
  const B = tt();
2827
2827
  t.fillStyle = B, t.strokeStyle = B, t.lineWidth = _, t.lineCap = "round";
2828
- const F = { x: X.x, y: X.y - I }, G = { x: E.x, y: E.y + I };
2829
- t.beginPath(), t.moveTo(X.x, X.y), t.lineTo(X.x, X.y + R), t.stroke(), t.beginPath(), t.arc(F.x, F.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.strokeStyle = B, t.lineWidth = _, t.beginPath(), t.moveTo(E.x, E.y - R), t.lineTo(E.x, E.y), t.stroke(), t.beginPath(), t.arc(G.x, G.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.restore(), u && (u.current = {
2828
+ const F = { x: X.x, y: X.y - I }, Y = { x: E.x, y: E.y + I };
2829
+ t.beginPath(), t.moveTo(X.x, X.y), t.lineTo(X.x, X.y + M), t.stroke(), t.beginPath(), t.arc(F.x, F.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.strokeStyle = B, t.lineWidth = _, t.beginPath(), t.moveTo(E.x, E.y - M), t.lineTo(E.x, E.y), t.stroke(), t.beginPath(), t.arc(Y.x, Y.y, I, 0, Math.PI * 2), t.fill(), t.strokeStyle = "white", t.lineWidth = 2 / p, t.stroke(), t.restore(), u && (u.current = {
2830
2830
  start: {
2831
2831
  center: F,
2832
2832
  textEdge: X
2833
2833
  // Original selection edge (top-left of selection on first line)
2834
2834
  },
2835
2835
  end: {
2836
- center: G,
2836
+ center: Y,
2837
2837
  textEdge: E
2838
2838
  // Original selection edge (bottom-right of selection on last line)
2839
2839
  }
@@ -2892,7 +2892,7 @@ class Wt {
2892
2892
  if (!(e instanceof Qt) || !e.isCropping) return;
2893
2893
  const s = e, i = s.getCropBoxBounds();
2894
2894
  if (!i) return;
2895
- const a = 4 / n, r = 2 / n, l = Pe / n, h = Ae / n, c = 1 / n;
2895
+ const a = 4 / n, r = 2 / n, l = Ee / n, h = ke / n, c = 1 / n;
2896
2896
  t.save(), t.translate(e.x * n, e.y * n), t.rotate(ht.toRadians(e.rotation));
2897
2897
  const d = s.transformData.flipHorizontal ? -1 : 1, u = s.transformData.flipVertical ? -1 : 1;
2898
2898
  t.scale(d * n, u * n);
@@ -2905,10 +2905,10 @@ class Wt {
2905
2905
  t.fillStyle = "rgba(0, 0, 0, 0.5)", i.y > T.y && t.fillRect(T.x, T.y, T.width, i.y - T.y);
2906
2906
  const w = i.y + i.height, m = T.y + T.height;
2907
2907
  w < m && t.fillRect(T.x, w, T.width, m - w), i.x > T.x && t.fillRect(T.x, i.y, i.x - T.x, i.height);
2908
- const C = i.x + i.width, R = T.x + T.width;
2909
- C < R && t.fillRect(C, i.y, R - C, i.height), t.strokeStyle = ot.canvas.selectionColor, t.lineWidth = r, t.strokeRect(i.x, i.y, i.width, i.height), t.strokeStyle = "rgba(255, 255, 255, 0.5)", t.lineWidth = c;
2910
- const M = i.width / 3;
2911
- t.beginPath(), t.moveTo(i.x + M, i.y), t.lineTo(i.x + M, i.y + i.height), t.moveTo(i.x + 2 * M, i.y), t.lineTo(i.x + 2 * M, i.y + i.height), t.stroke();
2908
+ const C = i.x + i.width, M = T.x + T.width;
2909
+ C < M && t.fillRect(C, i.y, M - C, i.height), t.strokeStyle = ot.canvas.selectionColor, t.lineWidth = r, t.strokeRect(i.x, i.y, i.width, i.height), t.strokeStyle = "rgba(255, 255, 255, 0.5)", t.lineWidth = c;
2910
+ const R = i.width / 3;
2911
+ t.beginPath(), t.moveTo(i.x + R, i.y), t.lineTo(i.x + R, i.y + i.height), t.moveTo(i.x + 2 * R, i.y), t.lineTo(i.x + 2 * R, i.y + i.height), t.stroke();
2912
2912
  const k = i.height / 3;
2913
2913
  if (t.beginPath(), t.moveTo(i.x, i.y + k), t.lineTo(i.x + i.width, i.y + k), t.moveTo(i.x, i.y + 2 * k), t.lineTo(i.x + i.width, i.y + 2 * k), t.stroke(), [
2914
2914
  { x: i.x, y: i.y },
@@ -3050,12 +3050,12 @@ const Xe = zt("CanvasRenderer"), K = class K {
3050
3050
  const w = new Path2D();
3051
3051
  w.rect(g, f, y - g, S - f);
3052
3052
  for (const m of T.pieces) {
3053
- const C = new Path2D(m.d), R = m.rotation ?? 0, M = new DOMMatrix();
3054
- if (M.translateSelf(o.x + m.x, o.y + m.y), R !== 0) {
3055
- const k = (m.baseWidth ?? 0) / 2, v = (m.baseHeight ?? 0) / 2, P = R === 90 || R === 270, H = P ? m.baseHeight ?? 0 : m.baseWidth ?? 0, L = P ? m.baseWidth ?? 0 : m.baseHeight ?? 0;
3056
- M.translateSelf(H / 2, L / 2), M.rotateSelf(R), M.translateSelf(-k, -v);
3053
+ const C = new Path2D(m.d), M = m.rotation ?? 0, R = new DOMMatrix();
3054
+ if (R.translateSelf(o.x + m.x, o.y + m.y), M !== 0) {
3055
+ const k = (m.baseWidth ?? 0) / 2, v = (m.baseHeight ?? 0) / 2, P = M === 90 || M === 270, H = P ? m.baseHeight ?? 0 : m.baseWidth ?? 0, L = P ? m.baseWidth ?? 0 : m.baseHeight ?? 0;
3056
+ R.translateSelf(H / 2, L / 2), R.rotateSelf(M), R.translateSelf(-k, -v);
3057
3057
  }
3058
- w.addPath(C, M);
3058
+ w.addPath(C, R);
3059
3059
  }
3060
3060
  t.clip(w, "evenodd");
3061
3061
  } else
@@ -3078,8 +3078,8 @@ const Xe = zt("CanvasRenderer"), K = class K {
3078
3078
  b.clear(), e.forEach((f, y) => {
3079
3079
  var S, T, w;
3080
3080
  if (f.blendMode === "knockout" || f.blendMode === "clip") {
3081
- const m = u[y], C = f.blendMode === "knockout" ? "destination-out" : "destination-in", R = ((S = m.knockoutParts) == null ? void 0 : S.scope) || "group", M = u.findIndex((H) => H.id === m.id), k = ((T = m.knockoutParts) == null ? void 0 : T.fill) || ((w = m.knockoutParts) == null ? void 0 : w.stroke), v = R === "artboard" && M !== -1 ? u.slice(0, M) : [];
3082
- k && (R === "artboard" || v.length > 0) && (v.forEach((H) => H.id && b.add(H.id)), Ie(
3081
+ const m = u[y], C = f.blendMode === "knockout" ? "destination-out" : "destination-in", M = ((S = m.knockoutParts) == null ? void 0 : S.scope) || "group", R = u.findIndex((H) => H.id === m.id), k = ((T = m.knockoutParts) == null ? void 0 : T.fill) || ((w = m.knockoutParts) == null ? void 0 : w.stroke), v = M === "artboard" && R !== -1 ? u.slice(0, R) : [];
3082
+ k && (M === "artboard" || v.length > 0) && (v.forEach((H) => H.id && b.add(H.id)), Ie(
3083
3083
  t,
3084
3084
  m,
3085
3085
  u,
@@ -3103,9 +3103,9 @@ const Xe = zt("CanvasRenderer"), K = class K {
3103
3103
  u,
3104
3104
  r
3105
3105
  ) : e.forEach((f) => {
3106
- var R, M;
3106
+ var M, R;
3107
3107
  if (b.has(f.id) || f.visible === !1) return;
3108
- const y = f.id === o, S = (n == null ? void 0 : n.type) === "element" && ((R = n == null ? void 0 : n.data) == null ? void 0 : R.id) === f.id, T = c && d && Dt(f) && f.id === o, w = y && !T, m = u[e.indexOf(f)], C = ((M = m == null ? void 0 : m.distressEffect) == null ? void 0 : M.enabled) && m.distressEffect.style === "custom" && m.distressEffect.textureUrl;
3108
+ const y = f.id === o, S = (n == null ? void 0 : n.type) === "element" && ((M = n == null ? void 0 : n.data) == null ? void 0 : M.id) === f.id, T = c && d && Dt(f) && f.id === o, w = y && !T, m = u[e.indexOf(f)], C = ((R = m == null ? void 0 : m.distressEffect) == null ? void 0 : R.enabled) && m.distressEffect.style === "custom" && m.distressEffect.textureUrl;
3109
3109
  if (m && m.masks && m.masks.length > 0)
3110
3110
  Et(t, m, (k) => {
3111
3111
  const v = (P) => {
@@ -3153,28 +3153,28 @@ const Xe = zt("CanvasRenderer"), K = class K {
3153
3153
  if (!y.mask)
3154
3154
  y.content.forEach((S, T) => {
3155
3155
  var k;
3156
- const w = S.id === n, m = (s == null ? void 0 : s.type) === "element" && ((k = s == null ? void 0 : s.data) == null ? void 0 : k.id) === S.id, C = i && a && Dt(S) && S.id === n, R = w && !C, M = y.contentConfigs[T];
3157
- M && M.masks && M.masks.length > 0 ? Et(t, M, (v) => {
3158
- l && (v.save(), v.globalAlpha = Q), S.render(v, R, m), l && v.restore();
3159
- }) : (l && (t.save(), t.globalAlpha = Q), S.render(t, R, m), l && t.restore());
3156
+ const w = S.id === n, m = (s == null ? void 0 : s.type) === "element" && ((k = s == null ? void 0 : s.data) == null ? void 0 : k.id) === S.id, C = i && a && Dt(S) && S.id === n, M = w && !C, R = y.contentConfigs[T];
3157
+ R && R.masks && R.masks.length > 0 ? Et(t, R, (v) => {
3158
+ l && (v.save(), v.globalAlpha = Q), S.render(v, M, m), l && v.restore();
3159
+ }) : (l && (t.save(), t.globalAlpha = Q), S.render(t, M, m), l && t.restore());
3160
3160
  });
3161
3161
  else {
3162
3162
  const S = this._getContentCanvas(c, d), T = S.getContext("2d");
3163
3163
  if (!T) continue;
3164
- T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(u), y.content.forEach((M, k) => {
3164
+ T.setTransform(1, 0, 0, 1, 0, 0), T.clearRect(0, 0, c, d), T.globalCompositeOperation = "source-over", T.setTransform(u), y.content.forEach((R, k) => {
3165
3165
  var O;
3166
- const v = M.id === n, P = (s == null ? void 0 : s.type) === "element" && ((O = s == null ? void 0 : s.data) == null ? void 0 : O.id) === M.id, H = i && a && Dt(M) && M.id === n, L = v && !H, D = y.contentConfigs[k];
3166
+ const v = R.id === n, P = (s == null ? void 0 : s.type) === "element" && ((O = s == null ? void 0 : s.data) == null ? void 0 : O.id) === R.id, H = i && a && Dt(R) && R.id === n, L = v && !H, D = y.contentConfigs[k];
3167
3167
  D && D.masks && D.masks.length > 0 ? Et(T, D, (W) => {
3168
- l && (W.save(), W.globalAlpha = Q), M.render(W, L, P), l && W.restore();
3169
- }) : (l && (T.save(), T.globalAlpha = Q), M.render(T, L, P), l && T.restore());
3168
+ l && (W.save(), W.globalAlpha = Q), R.render(W, L, P), l && W.restore();
3169
+ }) : (l && (T.save(), T.globalAlpha = Q), R.render(T, L, P), l && T.restore());
3170
3170
  });
3171
3171
  const w = this._getMaskCanvas(c, d), m = w.getContext("2d");
3172
3172
  if (!m) continue;
3173
3173
  m.setTransform(1, 0, 0, 1, 0, 0), m.clearRect(0, 0, c, d), m.globalCompositeOperation = "source-over", m.setTransform(u);
3174
- const C = y.mask.id === n, R = (s == null ? void 0 : s.type) === "element" && ((f = s == null ? void 0 : s.data) == null ? void 0 : f.id) === y.mask.id;
3175
- y.maskConfig && y.maskConfig.masks && y.maskConfig.masks.length > 0 ? Et(m, y.maskConfig, (M) => {
3176
- l && (M.save(), M.globalAlpha = Q), y.mask.render(M, C, R), l && M.restore();
3177
- }) : (l && (m.save(), m.globalAlpha = Q), y.mask.render(m, C, R), l && m.restore()), T.globalCompositeOperation = "destination-in", T.setTransform(1, 0, 0, 1, 0, 0), T.drawImage(w, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(S, 0, 0), t.restore();
3174
+ const C = y.mask.id === n, M = (s == null ? void 0 : s.type) === "element" && ((f = s == null ? void 0 : s.data) == null ? void 0 : f.id) === y.mask.id;
3175
+ y.maskConfig && y.maskConfig.masks && y.maskConfig.masks.length > 0 ? Et(m, y.maskConfig, (R) => {
3176
+ l && (R.save(), R.globalAlpha = Q), y.mask.render(R, C, M), l && R.restore();
3177
+ }) : (l && (m.save(), m.globalAlpha = Q), y.mask.render(m, C, M), l && m.restore()), T.globalCompositeOperation = "destination-in", T.setTransform(1, 0, 0, 1, 0, 0), T.drawImage(w, 0, 0), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(S, 0, 0), t.restore();
3178
3178
  }
3179
3179
  }
3180
3180
  // =========================================================================
@@ -3294,8 +3294,8 @@ const Xe = zt("CanvasRenderer"), K = class K {
3294
3294
  g
3295
3295
  ), f != null && f.enabled && c && Be(t, f, c, h), y != null && y.enabled && c && He(t, y, c, h), i && S && n && Wt.renderEditModeLayer(t, n, S, u), u !== 1) {
3296
3296
  t.save();
3297
- const C = t.getTransform().a / u, R = p.x * u * C, M = p.y * u * C;
3298
- t.setTransform(C, 0, 0, C, R, M);
3297
+ const C = t.getTransform().a / u, M = p.x * u * C, R = p.y * u * C;
3298
+ t.setTransform(C, 0, 0, C, M, R);
3299
3299
  }
3300
3300
  const T = r.map((m) => ({
3301
3301
  ...m,
@@ -3353,7 +3353,7 @@ const Xe = zt("CanvasRenderer"), K = class K {
3353
3353
  const S = t.getTransform().a / b, T = g.x * b * S, w = g.y * b * S;
3354
3354
  t.setTransform(S, 0, 0, S, T, w);
3355
3355
  }
3356
- if (e && Ye(e) && e.isCropping)
3356
+ if (e && Ge(e) && e.isCropping)
3357
3357
  o && Wt.renderCropBoxLayer(t, e, o, b);
3358
3358
  else if (!l && n && St.renderSelectionLayer(t, e, n, b), o && n && St.renderPositionSizeInfo(t, e, o, n, b), !l && o && n && St.renderHandlesLayer(
3359
3359
  t,
@@ -3378,7 +3378,7 @@ const Xe = zt("CanvasRenderer"), K = class K {
3378
3378
  };
3379
3379
  K._contentCanvas = null, K._contentCanvasSize = { width: 0, height: 0 }, K._maskCanvas = null, K._maskCanvasSize = { width: 0, height: 0 }, K._cachedElementsRef = null, K._cachedElementConfigs = null, K._cachedElementMap = null, K._knockoutRenderedIds = /* @__PURE__ */ new Set(), K.onRenderError = null;
3380
3380
  let qt = K;
3381
- const Zt = zt("ImportManager"), Ft = class Ft {
3381
+ const Jt = zt("ImportManager"), Ft = class Ft {
3382
3382
  /**
3383
3383
  * Import workspace from JSON file
3384
3384
  */
@@ -3406,7 +3406,7 @@ const Zt = zt("ImportManager"), Ft = class Ft {
3406
3406
  try {
3407
3407
  return Kt.createFromJSON(l);
3408
3408
  } catch (h) {
3409
- return Zt.error("Failed to create element:", l, h), null;
3409
+ return Jt.error("Failed to create element:", l, h), null;
3410
3410
  }
3411
3411
  }).filter((l) => l !== null);
3412
3412
  n.push(a), s.push(...r);
@@ -3441,7 +3441,7 @@ const Zt = zt("ImportManager"), Ft = class Ft {
3441
3441
  try {
3442
3442
  return Kt.createFromJSON(r);
3443
3443
  } catch (l) {
3444
- return Zt.error("Failed to create element:", r, l), null;
3444
+ return Jt.error("Failed to create element:", r, l), null;
3445
3445
  }
3446
3446
  }).filter((r) => r !== null);
3447
3447
  return a.forEach((r) => {
@@ -3593,25 +3593,25 @@ const Zt = zt("ImportManager"), Ft = class Ft {
3593
3593
  }
3594
3594
  };
3595
3595
  Ft.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
3596
- let Jt = Ft;
3596
+ let Zt = Ft;
3597
3597
  export {
3598
3598
  Qe as A,
3599
3599
  qt as C,
3600
- Jt as I,
3600
+ Zt as I,
3601
3601
  Oe as R,
3602
3602
  tn as S,
3603
3603
  qe as T,
3604
- Ye as a,
3604
+ Ge as a,
3605
3605
  sn as b,
3606
3606
  nn as c,
3607
3607
  en as d,
3608
3608
  oe as e,
3609
- Je as f,
3609
+ Ze as f,
3610
3610
  $t as g,
3611
3611
  je as h,
3612
3612
  Dt as i,
3613
3613
  $e as j,
3614
- Ze as k,
3614
+ Je as k,
3615
3615
  Ue as r
3616
3616
  };
3617
- //# sourceMappingURL=ImportManager-kRYfIX-D.js.map
3617
+ //# sourceMappingURL=ImportManager-C_wBjWaV.js.map