@snowcone-app/canvas 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/ERROR_CONTRACT.md +45 -0
  2. package/dist/{CanvasRenderer-3M-52sAd.js → CanvasRenderer-DnYgiWjt.js} +4 -4
  3. package/dist/{CanvasRenderer-3M-52sAd.js.map → CanvasRenderer-DnYgiWjt.js.map} +1 -1
  4. package/dist/{CanvasStateV1-BQ3cbxt2.js → CanvasStateV1-B51bXTyy.js} +3 -3
  5. package/dist/{CanvasStateV1-BQ3cbxt2.js.map → CanvasStateV1-B51bXTyy.js.map} +1 -1
  6. package/dist/{ContextualToolbars-B2LTNu7r.js → ContextualToolbars-DtlxDatY.js} +6 -6
  7. package/dist/{ContextualToolbars-B2LTNu7r.js.map → ContextualToolbars-DtlxDatY.js.map} +1 -1
  8. package/dist/{EditorCanvasImpl-VJ7kBhXB.js → EditorCanvasImpl-BpudFLkw.js} +8 -8
  9. package/dist/{EditorCanvasImpl-VJ7kBhXB.js.map → EditorCanvasImpl-BpudFLkw.js.map} +1 -1
  10. package/dist/{ExportManager-9_RjQEv0.js → ExportManager-vAuaoF5Q.js} +1212 -1224
  11. package/dist/{ExportManager-9_RjQEv0.js.map → ExportManager-vAuaoF5Q.js.map} +1 -1
  12. package/dist/{FontAnalyzer-Ch1jgTq7.js → FontAnalyzer-D9R2PYsy.js} +5 -1
  13. package/dist/FontAnalyzer-D9R2PYsy.js.map +1 -0
  14. package/dist/{ImagePanel-DY9Ve3X7.js → ImagePanel-kybrF6yT.js} +372 -366
  15. package/dist/{ImagePanel-DY9Ve3X7.js.map → ImagePanel-kybrF6yT.js.map} +1 -1
  16. package/dist/SnowconeCanvas-p9XmnSCK.js +1157 -0
  17. package/dist/SnowconeCanvas-p9XmnSCK.js.map +1 -0
  18. package/dist/advanced.mjs +15 -15
  19. package/dist/api/embed.d.ts +1 -0
  20. package/dist/api/stable.d.ts +1 -0
  21. package/dist/components/embed/SnowconeCanvas.d.ts +18 -2
  22. package/dist/core/ArtboardManager.d.ts +2 -0
  23. package/dist/{custom-icons-D_XezOul.js → custom-icons-Dlfrg3A_.js} +2 -2
  24. package/dist/{custom-icons-D_XezOul.js.map → custom-icons-Dlfrg3A_.js.map} +1 -1
  25. package/dist/{design-builder-BFM94eA9.js → design-builder-C8s1r4MF.js} +20 -19
  26. package/dist/{design-builder-BFM94eA9.js.map → design-builder-C8s1r4MF.js.map} +1 -1
  27. package/dist/{embed-5W-gg9dt.js → embed-DuIOU8mL.js} +10 -10
  28. package/dist/{embed-5W-gg9dt.js.map → embed-DuIOU8mL.js.map} +1 -1
  29. package/dist/embed.mjs +15 -15
  30. package/dist/errors/editorError.d.ts +4 -1
  31. package/dist/{guards-D_mw4DgS.js → guards-B0PNEbK6.js} +2 -2
  32. package/dist/{guards-D_mw4DgS.js.map → guards-B0PNEbK6.js.map} +1 -1
  33. package/dist/index.mjs +9 -9
  34. package/dist/internals.mjs +6 -6
  35. package/dist/{template-fields-CQURvcab.js → template-fields-DCZ9TqxY.js} +19 -19
  36. package/dist/{template-fields-CQURvcab.js.map → template-fields-DCZ9TqxY.js.map} +1 -1
  37. package/dist/testing.mjs +3 -3
  38. package/dist/{useCommands-DSapP-w1.js → useCommands-d5UM6Cnc.js} +7 -7
  39. package/dist/{useCommands-DSapP-w1.js.map → useCommands-d5UM6Cnc.js.map} +1 -1
  40. package/dist/{usePieceGuideBundle-oBykb3X8.js → usePieceGuideBundle-BPVWvChD.js} +2 -2
  41. package/dist/{usePieceGuideBundle-oBykb3X8.js.map → usePieceGuideBundle-BPVWvChD.js.map} +1 -1
  42. package/dist/utils/ExportManager.d.ts +37 -1
  43. package/dist/utils/printFiles.d.ts +23 -0
  44. package/dist/{validation-D6zVSeTh.js → validation-C8qNtk6j.js} +11 -11
  45. package/dist/{validation-D6zVSeTh.js.map → validation-C8qNtk6j.js.map} +1 -1
  46. package/example/package.json +1 -1
  47. package/package.json +2 -2
  48. package/dist/FontAnalyzer-Ch1jgTq7.js.map +0 -1
  49. package/dist/SnowconeCanvas-BzOy46Yw.js +0 -1098
  50. package/dist/SnowconeCanvas-BzOy46Yw.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { c as j, G as Yt, ag as Ve, x as Je, v as Ke, ak as Ee, aS as Vt, ai as Qe, af as x, s as ze, w as Ze, ah as at, aj as Jt, z as te, ax as De, al as xe, aT as J, aU as tr, b as er, aV as Tt, aW as rr, _ as Se, aX as Me, P as nr, S as or, I as At, F as sr, W as ar, f as ir, d as lr, L as cr, C as hr, g as fr, A as ee, $ as dr, a0 as ur, i as gr, t as Ce } from "./FontAnalyzer-Ch1jgTq7.js";
1
+ import { c as j, G as Vt, ag as Je, x as Ke, v as Qe, ak as Ee, aS as Jt, ai as ze, af as D, s as Ze, w as De, ah as at, aj as Kt, z as ee, ax as xe, al as tr, aT as J, aU as er, b as rr, aV as vt, aW as nr, _ as Se, aX as Ce, P as or, S as ar, I as Wt, F as sr, W as ir, f as lr, d as cr, L as hr, C as fr, g as dr, A as re, $ as ur, a0 as gr, i as pr, t as gt } from "./FontAnalyzer-D9R2PYsy.js";
2
2
  let Pe = null;
3
- function pr(e) {
3
+ function mr(e) {
4
4
  Pe = e;
5
5
  }
6
- function Jn() {
6
+ function zn() {
7
7
  return Pe;
8
8
  }
9
- const mr = j("TextureManager"), lt = class lt {
9
+ const yr = j("TextureManager"), it = class it {
10
10
  /**
11
11
  * Load a texture by ID or URL
12
12
  */
@@ -16,12 +16,12 @@ const mr = j("TextureManager"), lt = class lt {
16
16
  if (this.loading.has(t))
17
17
  return this.loading.get(t);
18
18
  const r = this.resolveTextureUrl(t), n = new Promise((o, i) => {
19
- const s = new Image();
20
- s.crossOrigin = "anonymous", s.onload = () => {
21
- this.cache.set(t, s), this.cache.set(r, s), this.loading.delete(t), this.loading.delete(r), o(s);
22
- }, s.onerror = () => {
23
- mr.error("Failed to load texture:", r), this.loading.delete(t), this.loading.delete(r), i(new Error(`Failed to load texture: ${r}`));
24
- }, s.src = r;
19
+ const a = new Image();
20
+ a.crossOrigin = "anonymous", a.onload = () => {
21
+ this.cache.set(t, a), this.cache.set(r, a), this.loading.delete(t), this.loading.delete(r), o(a);
22
+ }, a.onerror = () => {
23
+ yr.error("Failed to load texture:", r), this.loading.delete(t), this.loading.delete(r), i(new Error(`Failed to load texture: ${r}`));
24
+ }, a.src = r;
25
25
  });
26
26
  return this.loading.set(t, n), r !== t && this.loading.set(r, n), n;
27
27
  }
@@ -86,7 +86,7 @@ const mr = j("TextureManager"), lt = class lt {
86
86
  return (r == null ? void 0 : r.presetColor) || "#ffffff";
87
87
  }
88
88
  };
89
- lt.cache = /* @__PURE__ */ new Map(), lt.loading = /* @__PURE__ */ new Map(), lt.TEXTURES = [
89
+ it.cache = /* @__PURE__ */ new Map(), it.loading = /* @__PURE__ */ new Map(), it.TEXTURES = [
90
90
  {
91
91
  id: "glass-frame",
92
92
  name: "Glass Frame",
@@ -96,85 +96,85 @@ lt.cache = /* @__PURE__ */ new Map(), lt.loading = /* @__PURE__ */ new Map(), lt
96
96
  // Light gray
97
97
  }
98
98
  ];
99
- let D = lt;
100
- const yr = j("ElementPreviewRenderer"), wr = {
99
+ let pt = it;
100
+ const wr = j("ElementPreviewRenderer"), br = {
101
101
  width: 40,
102
102
  height: 40,
103
103
  padding: 4,
104
104
  backgroundColor: "transparent"
105
105
  };
106
106
  function kr(e, t = {}) {
107
- Qt();
108
- const r = { ...wr, ...t }, n = document.createElement("canvas");
107
+ zt();
108
+ const r = { ...br, ...t }, n = document.createElement("canvas");
109
109
  n.width = r.width, n.height = r.height;
110
110
  const o = n.getContext("2d");
111
111
  if (!o)
112
112
  return "";
113
113
  r.backgroundColor !== "transparent" && (o.fillStyle = r.backgroundColor, o.fillRect(0, 0, r.width, r.height)), o.save();
114
114
  try {
115
- e instanceof Yt ? Tr(o, e, r) : br(o, e, r);
115
+ e instanceof Vt ? vr(o, e, r) : Tr(o, e, r);
116
116
  } catch (i) {
117
- yr.warn("Failed to generate preview:", i);
117
+ wr.warn("Failed to generate preview:", i);
118
118
  }
119
119
  return o.restore(), n.toDataURL("image/png");
120
120
  }
121
- function br(e, t, r) {
121
+ function Tr(e, t, r) {
122
122
  var d;
123
123
  const n = ((d = t.getBoundingBox) == null ? void 0 : d.call(t)) || { x: 0, y: 0, width: 100, height: 100 }, o = n.width, i = n.height;
124
124
  if (o === 0 || i === 0) {
125
- re(e, t, r);
125
+ ne(e, t, r);
126
126
  return;
127
127
  }
128
- const s = r.width - r.padding * 2, l = r.height - r.padding * 2, a = Math.min(
129
- s / o,
128
+ const a = r.width - r.padding * 2, l = r.height - r.padding * 2, s = Math.min(
129
+ a / o,
130
130
  l / i,
131
131
  1
132
132
  // Don't scale up, only down
133
- ), c = o * a, h = i * a, f = r.padding + (s - c) / 2, u = r.padding + (l - h) / 2;
134
- e.save(), e.translate(f - n.x * a, u - n.y * a), e.scale(a, a), typeof t.render == "function" ? t.render(e, !1, !1) : re(e, t, r), e.restore();
133
+ ), c = o * s, h = i * s, f = r.padding + (a - c) / 2, u = r.padding + (l - h) / 2;
134
+ e.save(), e.translate(f - n.x * s, u - n.y * s), e.scale(s, s), typeof t.render == "function" ? t.render(e, !1, !1) : ne(e, t, r), e.restore();
135
135
  }
136
- function re(e, t, r) {
136
+ function ne(e, t, r) {
137
137
  e.fillStyle = "#888888", e.font = "10px Arial", e.textAlign = "center", e.textBaseline = "middle";
138
138
  const n = t.transformType || "Element";
139
139
  e.fillText(n, r.width / 2, r.height / 2);
140
140
  }
141
- function Tr(e, t, r) {
142
- const n = r.width - r.padding * 2, o = r.height - r.padding * 2, i = r.padding, s = r.padding;
141
+ function vr(e, t, r) {
142
+ const n = r.width - r.padding * 2, o = r.height - r.padding * 2, i = r.padding, a = r.padding;
143
143
  e.fillStyle = "#888888", e.strokeStyle = "#666666", e.lineWidth = 1;
144
- const l = o * 0.7, a = s + o * 0.3, c = n * 0.4, h = o * 0.2;
145
- e.fillRect(i, a, n, l), e.fillRect(i, a - h, c, h), t.children && t.children.length > 0 && (e.fillStyle = "#FFFFFF", e.font = "bold 10px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText(
144
+ const l = o * 0.7, s = a + o * 0.3, c = n * 0.4, h = o * 0.2;
145
+ e.fillRect(i, s, n, l), e.fillRect(i, s - h, c, h), t.children && t.children.length > 0 && (e.fillStyle = "#FFFFFF", e.font = "bold 10px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText(
146
146
  t.children.length.toString(),
147
147
  i + n / 2,
148
- a + l / 2
148
+ s + l / 2
149
149
  ));
150
150
  }
151
- function Kn(e, t, r) {
151
+ function Zn(e, t, r) {
152
152
  var c;
153
153
  e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180);
154
- const n = t, o = n.fontSize || 24, i = n.fontFamily || "Arial", s = n.bold || !1, l = n.italic || !1;
155
- e.font = Ve(o, i, s, l);
156
- const a = n.text || "";
154
+ const n = t, o = n.fontSize || 24, i = n.fontFamily || "Arial", a = n.bold || !1, l = n.italic || !1;
155
+ e.font = Je(o, i, a, l);
156
+ const s = n.text || "";
157
157
  if (t.transformType === "custom") {
158
- const f = ((c = t.transformData) == null ? void 0 : c.width) || 200, u = Je(a, o, i, s, l), d = Math.min(u, f), m = o * 1.2;
159
- e.rect(-d / 2, -m / 2, d, m);
158
+ const f = ((c = t.transformData) == null ? void 0 : c.width) || 200, u = Ke(s, o, i, a, l), d = Math.min(u, f), p = o * 1.2;
159
+ e.rect(-d / 2, -p / 2, d, p);
160
160
  } else {
161
- const h = e.measureText(a).width;
161
+ const h = e.measureText(s).width;
162
162
  e.beginPath(), e.moveTo(-h / 2, 0), e.lineTo(h / 2, 0), e.moveTo(-h / 2, -o), e.lineTo(h / 2, -o), e.moveTo(-h / 2, o * 0.2), e.lineTo(h / 2, o * 0.2);
163
163
  }
164
164
  }
165
- function vr(e, t) {
165
+ function Mr(e, t) {
166
166
  if (!t.transformData) return;
167
167
  const { borderRadius: r = 0 } = t.transformData, n = t.transformData.width ?? 100, o = t.transformData.height ?? 100;
168
168
  if (e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180), e.beginPath(), r > 0) {
169
- const i = Math.min(n, o) / 2, s = Math.min(r, i), l = -n / 2, a = -o / 2;
170
- e.moveTo(l + s, a), e.lineTo(l + n - s, a), e.arcTo(l + n, a, l + n, a + s, s), e.lineTo(l + n, a + o - s), e.arcTo(l + n, a + o, l + n - s, a + o, s), e.lineTo(l + s, a + o), e.arcTo(l, a + o, l, a + o - s, s), e.lineTo(l, a + s), e.arcTo(l, a, l + s, a, s), e.closePath();
169
+ const i = Math.min(n, o) / 2, a = Math.min(r, i), l = -n / 2, s = -o / 2;
170
+ e.moveTo(l + a, s), e.lineTo(l + n - a, s), e.arcTo(l + n, s, l + n, s + a, a), e.lineTo(l + n, s + o - a), e.arcTo(l + n, s + o, l + n - a, s + o, a), e.lineTo(l + a, s + o), e.arcTo(l, s + o, l, s + o - a, a), e.lineTo(l, s + a), e.arcTo(l, s, l + a, s, a), e.closePath();
171
171
  } else
172
172
  e.rect(-n / 2, -o / 2, n, o);
173
173
  }
174
- function Qn(e, t, r, n) {
174
+ function Dn(e, t, r, n) {
175
175
  e.beginPath(), e.arc(t, r, n, 0, Math.PI * 2), e.closePath();
176
176
  }
177
- function zn(e, t, r, n, o) {
177
+ function xn(e, t, r, n, o) {
178
178
  e.beginPath(), e.rect(t, r, n, o), e.closePath();
179
179
  }
180
180
  function Ie(e, t) {
@@ -187,335 +187,335 @@ function Er(e, t) {
187
187
  return r.width = e, r.height = t, r;
188
188
  }
189
189
  function Ae(e, t, r) {
190
- var a;
191
- if (!((a = t.stroke) != null && a.enabled)) return;
190
+ var s;
191
+ if (!((s = t.stroke) != null && s.enabled)) return;
192
192
  const n = t;
193
193
  if (!(n.text || "")) return;
194
- const i = (r == null ? void 0 : r.isKnockout) === !0, s = t.stroke.opacity ?? 1;
195
- if (!i && s < 1)
194
+ const i = (r == null ? void 0 : r.isKnockout) === !0, a = t.stroke.opacity ?? 1;
195
+ if (!i && a < 1)
196
196
  try {
197
- Sr(e, t, n, r, s);
197
+ Sr(e, t, n, r, a);
198
198
  } catch {
199
- it(e, t, n, r, !1);
199
+ st(e, t, n, r, !1);
200
200
  }
201
201
  else
202
- it(e, t, n, r, i);
202
+ st(e, t, n, r, i);
203
203
  }
204
204
  function Sr(e, t, r, n, o) {
205
- var S, P;
206
- const i = r.text || "", s = r.fontSize || 24, l = t.stroke.width, a = t.stroke.feather || 0, c = t.transformType === "custom" && ((S = t.transformData) == null ? void 0 : S.width), h = c ? ((P = t.transformData) == null ? void 0 : P.width) ?? 200 : 0, f = c ? h + l * 2 + a * 2 + 40 : s * i.length * 0.7 + l * 2 + a * 2 + 40, u = s * 3 + l * 2 + a * 2 + 40, d = e.getTransform(), m = Math.max(Math.abs(d.a), Math.abs(d.d), 1), g = Math.ceil(f * m / 2) * 2, k = Math.ceil(u * m / 2) * 2;
207
- if (g <= 0 || k <= 0) {
208
- it(e, t, r, n, !1);
205
+ var P, I;
206
+ const i = r.text || "", a = r.fontSize || 24, l = t.stroke.width, s = t.stroke.feather || 0, c = t.transformType === "custom" && ((P = t.transformData) == null ? void 0 : P.width), h = c ? ((I = t.transformData) == null ? void 0 : I.width) ?? 200 : 0, f = c ? h + l * 2 + s * 2 + 40 : a * i.length * 0.7 + l * 2 + s * 2 + 40, u = a * 3 + l * 2 + s * 2 + 40, d = e.getTransform(), p = Math.max(Math.abs(d.a), Math.abs(d.d), 1), m = Math.ceil(f * p / 2) * 2, w = Math.ceil(u * p / 2) * 2;
207
+ if (m <= 0 || w <= 0) {
208
+ st(e, t, r, n, !1);
209
209
  return;
210
210
  }
211
- const T = Er(g, k), w = T.getContext("2d");
212
- if (!w) {
213
- it(e, t, r, n, !1);
211
+ const k = Er(m, w), b = k.getContext("2d");
212
+ if (!b) {
213
+ st(e, t, r, n, !1);
214
214
  return;
215
215
  }
216
- const b = t.x || 0, p = t.y || 0, y = d.a * b + d.c * p + d.e, C = d.b * b + d.d * p + d.f;
217
- w.setTransform(
216
+ const T = t.x || 0, g = t.y || 0, y = d.a * T + d.c * g + d.e, S = d.b * T + d.d * g + d.f;
217
+ b.setTransform(
218
218
  d.a,
219
219
  d.b,
220
220
  d.c,
221
221
  d.d,
222
- g / 2 - y + d.e,
223
- k / 2 - C + d.f
222
+ m / 2 - y + d.e,
223
+ w / 2 - S + d.f
224
224
  );
225
- const M = t.stroke.opacity;
226
- t.stroke.opacity = 1, it(w, t, r, n, !1), t.stroke.opacity = M, e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(
227
- T,
228
- Math.round(y - g / 2),
229
- Math.round(C - k / 2)
225
+ const C = t.stroke.opacity;
226
+ t.stroke.opacity = 1, st(b, t, r, n, !1), t.stroke.opacity = C, e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(
227
+ k,
228
+ Math.round(y - m / 2),
229
+ Math.round(S - w / 2)
230
230
  ), e.restore();
231
231
  }
232
- function it(e, t, r, n, o) {
232
+ function st(e, t, r, n, o) {
233
233
  var d;
234
234
  const i = r.text || "";
235
235
  e.save(), n != null && n.positionApplied || (e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180));
236
- const s = r.fontSize || 24, l = r.fontFamily || "Arial", a = r.bold || !1, c = r.italic || !1, h = r.textAlign || "center";
237
- e.font = `${c ? "italic " : ""}${a ? "bold " : ""}${s}px ${l}`, e.textAlign = h, e.textBaseline = "alphabetic", o ? (e.strokeStyle = "#000000", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "round", e.lineJoin = t.stroke.lineJoin || "round", t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), !o && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`);
238
- const f = Ke(s, l, a, c);
236
+ const a = r.fontSize || 24, l = r.fontFamily || "Arial", s = r.bold || !1, c = r.italic || !1, h = r.textAlign || "center";
237
+ e.font = `${c ? "italic " : ""}${s ? "bold " : ""}${a}px ${l}`, e.textAlign = h, e.textBaseline = "alphabetic", o ? (e.strokeStyle = "#000000", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "round", e.lineJoin = t.stroke.lineJoin || "round", t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), !o && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`);
238
+ const f = Qe(a, l, s, c);
239
239
  if (t.transformType === "custom" && ((d = t.transformData) == null ? void 0 : d.width)) {
240
- const m = t.transformData, g = (m == null ? void 0 : m.width) ?? 200, k = g - x * 2, T = r.letterSpacing ?? 0, { lines: w, height: b } = Ee(
240
+ const p = t.transformData, m = (p == null ? void 0 : p.width) ?? 200, w = m - D * 2, k = r.letterSpacing ?? 0, { lines: b, height: T } = Ee(
241
241
  i,
242
- k,
243
- s,
244
- l,
242
+ w,
245
243
  a,
244
+ l,
245
+ s,
246
246
  c,
247
247
  void 0,
248
248
  // No locked line count for stroke
249
249
  !0,
250
250
  // strict: wrap exactly at maxWidth
251
- { letterSpacing: T, lineHeight: r.lineHeight }
252
- ), p = -g / 2, y = -b / 2, C = s * (r.lineHeight ?? Vt);
253
- w.forEach((M, S) => {
254
- const P = S === 0, v = S === w.length - 1;
255
- let A = M;
256
- if (!P) {
257
- const R = M.match(/^ +/), W = R ? R[0].length : 0;
258
- W > 0 && (A = A.substring(W));
251
+ { letterSpacing: k, lineHeight: r.lineHeight }
252
+ ), g = -m / 2, y = -T / 2, S = a * (r.lineHeight ?? Jt);
253
+ b.forEach((C, P) => {
254
+ const I = P === 0, M = P === b.length - 1;
255
+ let A = C;
256
+ if (!I) {
257
+ const R = C.match(/^ +/), U = R ? R[0].length : 0;
258
+ U > 0 && (A = A.substring(U));
259
259
  }
260
- if (!v) {
261
- const R = A.match(/ +$/), W = R ? R[0].length : 0;
262
- W > 0 && (A = A.substring(0, A.length - W));
260
+ if (!M) {
261
+ const R = A.match(/ +$/), U = R ? R[0].length : 0;
262
+ U > 0 && (A = A.substring(0, A.length - U));
263
263
  }
264
- let I = p + x;
265
- h === "center" ? I = p + g / 2 : h === "right" && (I = p + g - x);
266
- const E = y + f.ascent + S * C;
267
- Qe(e, A, I, E, T);
264
+ let E = g + D;
265
+ h === "center" ? E = g + m / 2 : h === "right" && (E = g + m - D);
266
+ const v = y + f.ascent + P * S;
267
+ ze(e, A, E, v, k);
268
268
  });
269
269
  } else {
270
- const k = -f.height / 2 + f.ascent;
271
- e.strokeText(i, 0, k);
270
+ const w = -f.height / 2 + f.ascent;
271
+ e.strokeText(i, 0, w);
272
272
  }
273
273
  e.restore();
274
274
  }
275
- function Mr(e, t, r) {
275
+ function Cr(e, t, r) {
276
276
  var o;
277
277
  if (!((o = t.stroke) != null && o.enabled) || !t.transformData) return;
278
278
  const n = (r == null ? void 0 : r.isKnockout) === !0;
279
- e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1, t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit)) : Ie(e, t.stroke), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), vr(e, t), e.stroke(), e.restore();
279
+ e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1, t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit)) : Ie(e, t.stroke), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), Mr(e, t), e.stroke(), e.restore();
280
280
  }
281
- function Zn(e, t, r) {
281
+ function to(e, t, r) {
282
282
  t.enabled && (e.save(), Ie(e, t), t.feather && t.feather > 0 && "filter" in e && (e.filter = `blur(${t.feather}px)`), e.beginPath(), r(), e.stroke(), e.restore());
283
283
  }
284
- const ne = j("GlyphRenderer");
285
- function Cr(e, t, r, n, o, i, s, l = {}) {
284
+ const oe = j("GlyphRenderer");
285
+ function Pr(e, t, r, n, o, i, a, l = {}) {
286
286
  try {
287
- const a = [];
288
- Object.entries(s).forEach(([k, T]) => {
289
- T && a.push(k);
287
+ const s = [];
288
+ Object.entries(a).forEach(([w, k]) => {
289
+ k && s.push(w);
290
290
  });
291
291
  const c = [];
292
- t.GSUB && t.GSUB.featureList && t.GSUB.featureList.forEach((k) => {
293
- c.push(k.tag);
292
+ t.GSUB && t.GSUB.featureList && t.GSUB.featureList.forEach((w) => {
293
+ c.push(w.tag);
294
294
  });
295
295
  const h = {};
296
- h.ccmp = !0, h.locl = !0, h.kern = !0, a.forEach((k) => {
297
- h[k] = !0;
296
+ h.ccmp = !0, h.locl = !0, h.kern = !0, s.forEach((w) => {
297
+ h[w] = !0;
298
298
  }), h.calt && (h.liga = !0, h.init = !0, h.fina = !0);
299
299
  const f = t.layout(r, h, "latn"), u = i / t.unitsPerEm;
300
300
  let d = 0;
301
- f.glyphs.forEach((k) => {
302
- d += k.advanceWidth * u;
301
+ f.glyphs.forEach((w) => {
302
+ d += w.advanceWidth * u;
303
303
  });
304
- let m = n;
305
- l.align === "center" ? m = n - d / 2 : l.align === "right" && (m = n - d), e.save(), e.fillStyle = l.color || "#000000";
306
- let g = m;
307
- f.glyphs.forEach((k, T) => {
308
- const w = f.positions[T];
309
- let b = null;
304
+ let p = n;
305
+ l.align === "center" ? p = n - d / 2 : l.align === "right" && (p = n - d), e.save(), e.fillStyle = l.color || "#000000";
306
+ let m = p;
307
+ f.glyphs.forEach((w, k) => {
308
+ const b = f.positions[k];
309
+ let T = null;
310
310
  try {
311
- if (k.path && typeof k.path.toPath == "function")
312
- b = k.path.toPath();
313
- else if (k.path && typeof k.path.toSVG == "function") {
314
- const p = k.path.toSVG();
315
- if (p && /^[MmLlHhVvCcSsQqTtAaZz]/.test(p))
316
- b = p;
311
+ if (w.path && typeof w.path.toPath == "function")
312
+ T = w.path.toPath();
313
+ else if (w.path && typeof w.path.toSVG == "function") {
314
+ const g = w.path.toSVG();
315
+ if (g && /^[MmLlHhVvCcSsQqTtAaZz]/.test(g))
316
+ T = g;
317
317
  else {
318
- const y = p == null ? void 0 : p.match(/\bd=["']([^"']+)["']/);
319
- b = y ? y[1] : null;
318
+ const y = g == null ? void 0 : g.match(/\bd=["']([^"']+)["']/);
319
+ T = y ? y[1] : null;
320
320
  }
321
321
  }
322
- } catch (p) {
323
- ne.warn("Error getting path for glyph:", k.name, p);
322
+ } catch (g) {
323
+ oe.warn("Error getting path for glyph:", w.name, g);
324
324
  }
325
- if (b) {
326
- const p = new Path2D(b);
327
- e.save(), e.translate(g + w.xOffset * u, o + w.yOffset * u), e.scale(u, -u), e.fill(p), e.restore();
325
+ if (T) {
326
+ const g = new Path2D(T);
327
+ e.save(), e.translate(m + b.xOffset * u, o + b.yOffset * u), e.scale(u, -u), e.fill(g), e.restore();
328
328
  }
329
- g += k.advanceWidth * u;
329
+ m += w.advanceWidth * u;
330
330
  }), e.restore();
331
- } catch (a) {
332
- ne.error("Error rendering with fontkit:", a), e.fillStyle = l.color || "#000000", e.textAlign = l.align || "left", e.fillText(r, n, o);
331
+ } catch (s) {
332
+ oe.error("Error rendering with fontkit:", s), e.fillStyle = l.color || "#000000", e.textAlign = l.align || "left", e.fillText(r, n, o);
333
333
  }
334
334
  }
335
- function Pr(e, t, r, n, o, i, s, l = {}) {
336
- const c = ((k) => {
337
- for (const T of k) {
338
- const w = T.codePointAt(0);
339
- if (w && w >= 983040 && w <= 1048573) return !0;
335
+ function Ir(e, t, r, n, o, i, a, l = {}) {
336
+ const c = ((w) => {
337
+ for (const k of w) {
338
+ const b = k.codePointAt(0);
339
+ if (b && b >= 983040 && b <= 1048573) return !0;
340
340
  }
341
341
  return !1;
342
342
  })(r);
343
- if ((!s || s.length === 0) && !c) {
343
+ if ((!a || a.length === 0) && !c) {
344
344
  e.fillStyle = l.color || "#000000", e.textAlign = l.align || "left", e.fillText(r, n, o);
345
345
  return;
346
346
  }
347
347
  const h = /* @__PURE__ */ new Map();
348
- s && s.forEach((k) => {
349
- h.set(k.charIndex, k.glyphIndex);
348
+ a && a.forEach((w) => {
349
+ h.set(w.charIndex, w.glyphIndex);
350
350
  });
351
351
  const f = i / t.unitsPerEm, u = Array.from(r);
352
352
  let d = 0;
353
- u.forEach((k, T) => {
354
- const w = k.codePointAt(0) || 0;
355
- let b;
356
- if (w >= 983040 && w <= 1048573)
357
- b = w - 983040;
358
- else if (b = h.get(T), b === void 0) {
359
- const y = t.glyphForCodePoint(w);
360
- b = y ? y.id : 0;
353
+ u.forEach((w, k) => {
354
+ const b = w.codePointAt(0) || 0;
355
+ let T;
356
+ if (b >= 983040 && b <= 1048573)
357
+ T = b - 983040;
358
+ else if (T = h.get(k), T === void 0) {
359
+ const y = t.glyphForCodePoint(b);
360
+ T = y ? y.id : 0;
361
361
  }
362
- const p = t.getGlyph(b);
363
- p && (d += p.advanceWidth * f);
362
+ const g = t.getGlyph(T);
363
+ g && (d += g.advanceWidth * f);
364
364
  });
365
- let m = n;
366
- l.align === "center" ? m = n - d / 2 : l.align === "right" && (m = n - d), e.save(), e.fillStyle = l.color || "#000000";
367
- let g = m;
368
- u.forEach((k, T) => {
369
- const w = k.codePointAt(0) || 0;
370
- let b;
371
- if (w >= 983040 && w <= 1048573)
372
- b = w - 983040;
373
- else if (b = h.get(T), b === void 0) {
374
- const y = t.glyphForCodePoint(w);
375
- b = y ? y.id : 0;
365
+ let p = n;
366
+ l.align === "center" ? p = n - d / 2 : l.align === "right" && (p = n - d), e.save(), e.fillStyle = l.color || "#000000";
367
+ let m = p;
368
+ u.forEach((w, k) => {
369
+ const b = w.codePointAt(0) || 0;
370
+ let T;
371
+ if (b >= 983040 && b <= 1048573)
372
+ T = b - 983040;
373
+ else if (T = h.get(k), T === void 0) {
374
+ const y = t.glyphForCodePoint(b);
375
+ T = y ? y.id : 0;
376
376
  }
377
- const p = t.getGlyph(b);
378
- if (p) {
379
- const y = p.path.toSVG();
377
+ const g = t.getGlyph(T);
378
+ if (g) {
379
+ const y = g.path.toSVG();
380
380
  if (y) {
381
- const C = new Path2D(y);
382
- e.save(), e.translate(g, o), e.scale(f, -f), e.fill(C), e.restore();
381
+ const S = new Path2D(y);
382
+ e.save(), e.translate(m, o), e.scale(f, -f), e.fill(S), e.restore();
383
383
  }
384
- g += p.advanceWidth * f;
384
+ m += g.advanceWidth * f;
385
385
  }
386
386
  }), e.restore();
387
387
  }
388
- function Ir(e, t, r, n, o) {
388
+ function Ar(e, t, r, n, o) {
389
389
  e.fillStyle = r.color;
390
- const i = r.textAlign || "center", s = (g) => g.letterSpacing !== void 0 ? g.letterSpacing : r.letterSpacing ?? 0, l = ze(t);
391
- let a, c;
392
- n !== void 0 && n > 0 && !o ? (a = [], c = [], l.forEach((g) => {
393
- const k = Ze(g, n, r);
394
- k.forEach((T, w) => {
395
- a.push(T), c.push({
396
- isParagraphStart: w === 0,
397
- isParagraphEnd: w === k.length - 1
390
+ const i = r.textAlign || "center", a = (m) => m.letterSpacing !== void 0 ? m.letterSpacing : r.letterSpacing ?? 0, l = Ze(t);
391
+ let s, c;
392
+ n !== void 0 && n > 0 && !o ? (s = [], c = [], l.forEach((m) => {
393
+ const w = De(m, n, r);
394
+ w.forEach((k, b) => {
395
+ s.push(k), c.push({
396
+ isParagraphStart: b === 0,
397
+ isParagraphEnd: b === w.length - 1
398
398
  });
399
399
  });
400
- })) : (a = l, c = l.map(() => ({
400
+ })) : (s = l, c = l.map(() => ({
401
401
  isParagraphStart: !0,
402
402
  isParagraphEnd: !0
403
403
  })));
404
404
  const h = [];
405
- a.forEach((g, k) => {
406
- const T = [];
407
- let w = 0, b = 0;
408
- const p = c[k].isParagraphStart, y = c[k].isParagraphEnd;
409
- g.forEach((E) => {
410
- const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, U = E.style.italic !== void 0 ? E.style.italic : r.italic || !1;
411
- e.font = q(R, W, F, U);
412
- const B = at(e.measureText(E.text).width, E.text, s(E.style));
413
- T.push(B);
414
- const $ = ht(R, W, F, U);
415
- w = Math.max(w, $.height), b = Math.max(b, $.ascent);
405
+ s.forEach((m, w) => {
406
+ const k = [];
407
+ let b = 0, T = 0;
408
+ const g = c[w].isParagraphStart, y = c[w].isParagraphEnd;
409
+ m.forEach((v) => {
410
+ const R = v.style.fontSize !== void 0 ? v.style.fontSize : r.fontSize, U = v.style.fontFamily !== void 0 ? v.style.fontFamily : r.fontFamily, W = v.style.bold !== void 0 ? v.style.bold : r.bold || !1, F = v.style.italic !== void 0 ? v.style.italic : r.italic || !1;
411
+ e.font = q(R, U, W, F);
412
+ const B = at(e.measureText(v.text).width, v.text, a(v.style));
413
+ k.push(B);
414
+ const $ = ct(R, U, W, F);
415
+ b = Math.max(b, $.height), T = Math.max(T, $.ascent);
416
416
  });
417
- const C = g.map((E) => E.text).join(""), M = C.match(/^ +/), S = C.match(/ +$/), P = M ? M[0].length : 0, v = S ? S[0].length : 0;
418
- let A = 0, I = 0;
419
- g.forEach((E) => {
420
- const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, U = E.style.italic !== void 0 ? E.style.italic : r.italic || !1;
421
- let B = E.text;
422
- const $ = I, St = I + E.text.length;
423
- if (!p && P > 0 && $ < P) {
424
- const L = Math.min(P - $, E.text.length);
417
+ const S = m.map((v) => v.text).join(""), C = S.match(/^ +/), P = S.match(/ +$/), I = C ? C[0].length : 0, M = P ? P[0].length : 0;
418
+ let A = 0, E = 0;
419
+ m.forEach((v) => {
420
+ const R = v.style.fontSize !== void 0 ? v.style.fontSize : r.fontSize, U = v.style.fontFamily !== void 0 ? v.style.fontFamily : r.fontFamily, W = v.style.bold !== void 0 ? v.style.bold : r.bold || !1, F = v.style.italic !== void 0 ? v.style.italic : r.italic || !1;
421
+ let B = v.text;
422
+ const $ = E, St = E + v.text.length;
423
+ if (!g && I > 0 && $ < I) {
424
+ const L = Math.min(I - $, v.text.length);
425
425
  B = B.substring(L);
426
426
  }
427
- if (!y && v > 0) {
428
- const L = C.length - v;
427
+ if (!y && M > 0) {
428
+ const L = S.length - M;
429
429
  if (St > L) {
430
- const G = !p && P > 0 && $ < P ? Math.min(P - $, E.text.length) : 0, Mt = Math.max(0, L - $ - G);
431
- B = B.substring(0, Mt);
430
+ const G = !g && I > 0 && $ < I ? Math.min(I - $, v.text.length) : 0, Ct = Math.max(0, L - $ - G);
431
+ B = B.substring(0, Ct);
432
432
  }
433
433
  }
434
- I += E.text.length, B.length > 0 && (e.save(), e.font = q(R, W, F, U), A += at(
434
+ E += v.text.length, B.length > 0 && (e.save(), e.font = q(R, U, W, F), A += at(
435
435
  e.measureText(B).width,
436
436
  B,
437
- s(E.style)
437
+ a(v.style)
438
438
  ), e.restore());
439
439
  }), h.push({
440
- spans: g,
440
+ spans: m,
441
441
  width: A,
442
442
  // Use adjusted width for alignment (may be 0 for empty lines)
443
- height: w,
444
- ascent: b,
445
- spanWidths: T,
446
- isParagraphStart: p,
443
+ height: b,
444
+ ascent: T,
445
+ spanWidths: k,
446
+ isParagraphStart: g,
447
447
  // Store metadata with line
448
448
  isParagraphEnd: y
449
449
  });
450
450
  });
451
- const f = ht(r.fontSize, r.fontFamily, r.bold, r.italic), u = r.fontSize * (r.lineHeight ?? Vt);
451
+ const f = ct(r.fontSize, r.fontFamily, r.bold, r.italic), u = r.fontSize * (r.lineHeight ?? Jt);
452
452
  let d;
453
453
  h.length === 0 ? d = 0 : h.length === 1 ? d = f.height : d = (h.length - 1) * u + f.height;
454
- const m = -d / 2;
455
- h.forEach((g, k) => {
456
- const { spans: T, width: w, isParagraphStart: b, isParagraphEnd: p } = g;
454
+ const p = -d / 2;
455
+ h.forEach((m, w) => {
456
+ const { spans: k, width: b, isParagraphStart: T, isParagraphEnd: g } = m;
457
457
  let y;
458
- i === "center" ? y = -w / 2 : i === "right" ? y = n !== void 0 ? n / 2 - w : -w : y = n !== void 0 ? -n / 2 : 0;
459
- const C = m + f.ascent + k * u, M = T.map((E) => E.text).join(""), S = M.match(/^ +/), P = M.match(/ +$/), v = S ? S[0].length : 0, A = P ? P[0].length : 0;
460
- let I = 0;
461
- T.forEach((E) => {
462
- const R = E.style.fontSize !== void 0 ? E.style.fontSize : r.fontSize, W = E.style.fontFamily !== void 0 ? E.style.fontFamily : r.fontFamily, F = E.style.color !== void 0 ? E.style.color : r.color, U = E.style.bold !== void 0 ? E.style.bold : r.bold || !1, B = E.style.italic !== void 0 ? E.style.italic : r.italic || !1, $ = E.style.underline !== void 0 ? E.style.underline : r.underline || !1, St = E.style.strikethrough !== void 0 ? E.style.strikethrough : r.strikethrough || !1;
463
- let L = E.text, G = I, Mt = I + E.text.length;
464
- if (!b && v > 0 && G < v) {
465
- const Y = Math.min(v - G, E.text.length);
458
+ i === "center" ? y = -b / 2 : i === "right" ? y = n !== void 0 ? n / 2 - b : -b : y = n !== void 0 ? -n / 2 : 0;
459
+ const S = p + f.ascent + w * u, C = k.map((v) => v.text).join(""), P = C.match(/^ +/), I = C.match(/ +$/), M = P ? P[0].length : 0, A = I ? I[0].length : 0;
460
+ let E = 0;
461
+ k.forEach((v) => {
462
+ const R = v.style.fontSize !== void 0 ? v.style.fontSize : r.fontSize, U = v.style.fontFamily !== void 0 ? v.style.fontFamily : r.fontFamily, W = v.style.color !== void 0 ? v.style.color : r.color, F = v.style.bold !== void 0 ? v.style.bold : r.bold || !1, B = v.style.italic !== void 0 ? v.style.italic : r.italic || !1, $ = v.style.underline !== void 0 ? v.style.underline : r.underline || !1, St = v.style.strikethrough !== void 0 ? v.style.strikethrough : r.strikethrough || !1;
463
+ let L = v.text, G = E, Ct = E + v.text.length;
464
+ if (!T && M > 0 && G < M) {
465
+ const Y = Math.min(M - G, v.text.length);
466
466
  L = L.substring(Y);
467
467
  }
468
- if (!p && A > 0) {
469
- const Y = M.length - A;
470
- if (Mt > Y) {
471
- const nt = !b && v > 0 && G < v ? Math.min(v - G, E.text.length) : 0, V = Math.max(0, Y - G - nt);
468
+ if (!g && A > 0) {
469
+ const Y = C.length - A;
470
+ if (Ct > Y) {
471
+ const rt = !T && M > 0 && G < M ? Math.min(M - G, v.text.length) : 0, V = Math.max(0, Y - G - rt);
472
472
  L = L.substring(0, V);
473
473
  }
474
474
  }
475
- if (I += E.text.length, L.length > 0) {
476
- const Y = s(E.style);
477
- e.font = q(R, W, U, B), e.fillStyle = F, e.textBaseline = "alphabetic", e.textAlign = "left", Jt(e, L, y, C, Y);
478
- const nt = at(e.measureText(L).width, L, Y);
475
+ if (E += v.text.length, L.length > 0) {
476
+ const Y = a(v.style);
477
+ e.font = q(R, U, F, B), e.fillStyle = W, e.textBaseline = "alphabetic", e.textAlign = "left", Kt(e, L, y, S, Y);
478
+ const rt = at(e.measureText(L).width, L, Y);
479
479
  if ($) {
480
- const V = C + R * 0.1;
481
- e.beginPath(), e.moveTo(y, V), e.lineTo(y + nt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = F, e.stroke();
480
+ const V = S + R * 0.1;
481
+ e.beginPath(), e.moveTo(y, V), e.lineTo(y + rt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = W, e.stroke();
482
482
  }
483
483
  if (St) {
484
- const V = C - R * 0.25;
485
- e.beginPath(), e.moveTo(y, V), e.lineTo(y + nt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = F, e.stroke();
484
+ const V = S - R * 0.25;
485
+ e.beginPath(), e.moveTo(y, V), e.lineTo(y + rt, V), e.lineWidth = Math.max(1, R * 0.05), e.strokeStyle = W, e.stroke();
486
486
  }
487
- y += nt;
487
+ y += rt;
488
488
  }
489
489
  });
490
490
  });
491
491
  }
492
- const Rt = j("canvas-renderer");
493
- let ut = null;
494
- function Kt() {
495
- if (!ut)
492
+ const Ft = j("canvas-renderer");
493
+ let dt = null;
494
+ function Qt() {
495
+ if (!dt)
496
496
  if (typeof OffscreenCanvas < "u")
497
- ut = new OffscreenCanvas(1, 1).getContext("2d");
497
+ dt = new OffscreenCanvas(1, 1).getContext("2d");
498
498
  else if (typeof document < "u")
499
- ut = document.createElement("canvas").getContext("2d");
499
+ dt = document.createElement("canvas").getContext("2d");
500
500
  else
501
501
  throw new Error("No canvas context available");
502
- return ut;
502
+ return dt;
503
503
  }
504
504
  function q(e, t, r = !1, n = !1) {
505
505
  const o = [];
506
506
  return n && o.push("italic"), r && o.push("bold"), o.push(`${e}px`), o.push(t), o.join(" ");
507
507
  }
508
- function oe(e, t, r, n = !1, o = !1, i = 0) {
509
- const s = Kt();
510
- return s.font = q(t, r, n, o), at(s.measureText(e).width, e, i);
508
+ function ae(e, t, r, n = !1, o = !1, i = 0) {
509
+ const a = Qt();
510
+ return a.font = q(t, r, n, o), at(a.measureText(e).width, e, i);
511
511
  }
512
- function ht(e, t, r = !1, n = !1) {
513
- const o = Kt();
512
+ function ct(e, t, r = !1, n = !1) {
513
+ const o = Qt();
514
514
  o.font = q(e, t, r, n);
515
- const s = o.measureText("ÁÉÍgjpqy"), l = s.actualBoundingBoxAscent || e * 0.8, a = s.actualBoundingBoxDescent || e * 0.2, c = l + a;
516
- return { ascent: l, descent: a, height: c };
515
+ const a = o.measureText("ÁÉÍgjpqy"), l = a.actualBoundingBoxAscent || e * 0.8, s = a.actualBoundingBoxDescent || e * 0.2, c = l + s;
516
+ return { ascent: l, descent: s, height: c };
517
517
  }
518
- function Dn(e, t) {
518
+ function eo(e, t) {
519
519
  const r = e.map((o, i) => ({
520
520
  isParagraphStart: !t && i === 0,
521
521
  isParagraphEnd: !t && i === e.length - 1
@@ -523,116 +523,116 @@ function Dn(e, t) {
523
523
  return e.map((o, i) => {
524
524
  if (o.trim().length === 0)
525
525
  return "";
526
- const s = r[i].isParagraphStart, l = r[i].isParagraphEnd;
527
- let a = o;
528
- return s || (a = a.replace(/^ +/, "")), l || (a = a.replace(/ +$/, "")), a;
526
+ const a = r[i].isParagraphStart, l = r[i].isParagraphEnd;
527
+ let s = o;
528
+ return a || (s = s.replace(/^ +/, "")), l || (s = s.replace(/ +$/, "")), s;
529
529
  }).filter((o) => o.length > 0);
530
530
  }
531
- function Ar(e, t) {
532
- const r = t.fontSize, n = t.fontFamily, o = t.bold || !1, i = t.italic || !1, s = t.textAlign || "center", l = t.text;
533
- e.font = q(r, n, o, i), e.textAlign = s, e.textBaseline = "alphabetic", e.fillStyle = t.color;
534
- const a = ht(r, n, o, i), f = -a.height / 2 + a.ascent;
535
- Jt(e, l, 0, f, t.letterSpacing);
531
+ function Rr(e, t) {
532
+ const r = t.fontSize, n = t.fontFamily, o = t.bold || !1, i = t.italic || !1, a = t.textAlign || "center", l = t.text;
533
+ e.font = q(r, n, o, i), e.textAlign = a, e.textBaseline = "alphabetic", e.fillStyle = t.color;
534
+ const s = ct(r, n, o, i), f = -s.height / 2 + s.ascent;
535
+ Kt(e, l, 0, f, t.letterSpacing);
536
536
  }
537
- function Rr(e, t, r, n, o = !1, i = !1, s) {
538
- const l = Kt();
537
+ function Wr(e, t, r, n, o = !1, i = !1, a) {
538
+ const l = Qt();
539
539
  if (l.font = q(r, n, o, i), e.trim().length === 0)
540
540
  return [e];
541
541
  if (e.includes(`
542
542
  `)) {
543
- const S = e.split(`
544
- `), P = [];
545
- for (let v = 0; v < S.length; v++) {
546
- const A = S[v], I = Rr(A, t, r, n, o, i);
547
- P.push(...I);
543
+ const P = e.split(`
544
+ `), I = [];
545
+ for (let M = 0; M < P.length; M++) {
546
+ const A = P[M], E = Wr(A, t, r, n, o, i);
547
+ I.push(...E);
548
548
  }
549
- return P;
549
+ return I;
550
550
  }
551
- const a = e.match(/^\s*/), c = e.match(/\s*$/), h = a ? a[0] : "", f = c ? c[0] : "", d = e.substring(h.length, e.length - f.length).split(" ");
552
- if (s !== void 0 && s > 0) {
553
- if (s === 1)
551
+ const s = e.match(/^\s*/), c = e.match(/\s*$/), h = s ? s[0] : "", f = c ? c[0] : "", d = e.substring(h.length, e.length - f.length).split(" ");
552
+ if (a !== void 0 && a > 0) {
553
+ if (a === 1)
554
554
  return [h + d.join(" ") + f];
555
- const S = [], P = Math.ceil(d.length / s);
556
- for (let v = 0; v < d.length; v += P) {
557
- const I = d.slice(v, v + P).join(" ");
558
- v === 0 && v + P >= d.length ? S.push(h + I + f) : v === 0 ? S.push(h + I) : v + P >= d.length ? S.push(I + f) : S.push(I);
555
+ const P = [], I = Math.ceil(d.length / a);
556
+ for (let M = 0; M < d.length; M += I) {
557
+ const E = d.slice(M, M + I).join(" ");
558
+ M === 0 && M + I >= d.length ? P.push(h + E + f) : M === 0 ? P.push(h + E) : M + I >= d.length ? P.push(E + f) : P.push(E);
559
559
  }
560
- return S;
560
+ return P;
561
561
  }
562
- const m = d.join(" "), g = h + m + f, k = l.measureText(g).width, T = t < 200, b = Math.max(20, t * (T ? 0.08 : 0.05));
563
- if (k <= t + b)
564
- return [g];
565
- const p = [];
562
+ const p = d.join(" "), m = h + p + f, w = l.measureText(m).width, k = t < 200, T = Math.max(20, t * (k ? 0.08 : 0.05));
563
+ if (w <= t + T)
564
+ return [m];
565
+ const g = [];
566
566
  let y = d[0];
567
- const M = Math.max(15, t * (T ? 0.05 : 0.03));
568
- for (let S = 1; S < d.length; S++) {
569
- const P = d[S], v = y + " " + P;
570
- l.measureText(v).width > t + M ? (p.push(y), y = P) : y = v;
571
- }
572
- return p.push(y), p.length > 0 && (p[0] = h + p[0], p[p.length - 1] = p[p.length - 1] + f), p;
573
- }
574
- function xn(e, t, r, n, o, i, s = "left", l = 0, a = 0, c = 1.2, h = !1, f = !1, u = !1, d = !1, m, g) {
575
- e.font = q(o, i, h, f), e.textBaseline = "alphabetic", e.textAlign = s;
576
- const k = (v) => {
577
- for (const A of v) {
578
- const I = A.codePointAt(0);
579
- if (I && I >= 983040 && I <= 1048573)
567
+ const C = Math.max(15, t * (k ? 0.05 : 0.03));
568
+ for (let P = 1; P < d.length; P++) {
569
+ const I = d[P], M = y + " " + I;
570
+ l.measureText(M).width > t + C ? (g.push(y), y = I) : y = M;
571
+ }
572
+ return g.push(y), g.length > 0 && (g[0] = h + g[0], g[g.length - 1] = g[g.length - 1] + f), g;
573
+ }
574
+ function ro(e, t, r, n, o, i, a = "left", l = 0, s = 0, c = 1.2, h = !1, f = !1, u = !1, d = !1, p, m) {
575
+ e.font = q(o, i, h, f), e.textBaseline = "alphabetic", e.textAlign = a;
576
+ const w = (M) => {
577
+ for (const A of M) {
578
+ const E = A.codePointAt(0);
579
+ if (E && E >= 983040 && E <= 1048573)
580
580
  return !0;
581
581
  }
582
582
  return !1;
583
- }, T = m && Object.values(m).some((v) => v), w = g && g.length > 0, b = t.join(" "), p = k(b), y = T || w || p, C = y ? te.getFontSync(i, h ? 700 : 400) : null;
584
- y && !C && (Rt.warn(
585
- `[renderMultilineText] Font ${i} not loaded for fontkit rendering. Text may not render correctly. Has PUA: ${p}, Text: "${b}"`
586
- ), te.loadFont(i, h ? 700 : 400).catch((v) => {
587
- Rt.error("[renderMultilineText] Error loading font:", v);
583
+ }, k = p && Object.values(p).some((M) => M), b = m && m.length > 0, T = t.join(" "), g = w(T), y = k || b || g, S = y ? ee.getFontSync(i, h ? 700 : 400) : null;
584
+ y && !S && (Ft.warn(
585
+ `[renderMultilineText] Font ${i} not loaded for fontkit rendering. Text may not render correctly. Has PUA: ${g}, Text: "${T}"`
586
+ ), ee.loadFont(i, h ? 700 : 400).catch((M) => {
587
+ Ft.error("[renderMultilineText] Error loading font:", M);
588
588
  }));
589
- const M = ht(o, i, h, f), S = o * c;
590
- let P = 0;
591
- t.forEach((v, A) => {
592
- let I = r + a;
593
- s === "center" ? I = r + l / 2 : s === "right" && (I = r + l - a);
594
- const E = n + M.ascent + A * S, R = Array.from(v).length, W = w ? g.filter((F) => {
595
- const U = F.charIndex - P;
596
- return U >= 0 && U < R;
597
- }).map((F) => ({
598
- ...F,
599
- charIndex: F.charIndex - P
589
+ const C = ct(o, i, h, f), P = o * c;
590
+ let I = 0;
591
+ t.forEach((M, A) => {
592
+ let E = r + s;
593
+ a === "center" ? E = r + l / 2 : a === "right" && (E = r + l - s);
594
+ const v = n + C.ascent + A * P, R = Array.from(M).length, U = b ? m.filter((W) => {
595
+ const F = W.charIndex - I;
596
+ return F >= 0 && F < R;
597
+ }).map((W) => ({
598
+ ...W,
599
+ charIndex: W.charIndex - I
600
600
  // Adjust to line-relative index
601
601
  })) : [];
602
- if (C && (T || W.length > 0 || p) ? W.length > 0 || k(v) ? Pr(e, C, v, I, E, o, W, {
602
+ if (S && (k || U.length > 0 || g) ? U.length > 0 || w(M) ? Ir(e, S, M, E, v, o, U, {
603
603
  color: e.fillStyle,
604
- align: s === "start" || s === "end" ? "left" : s
605
- }) : m && Cr(e, C, v, I, E, o, m, {
604
+ align: a === "start" || a === "end" ? "left" : a
605
+ }) : p && Pr(e, S, M, E, v, o, p, {
606
606
  color: e.fillStyle,
607
- align: s === "start" || s === "end" ? "left" : s
608
- }) : e.fillText(v, I, E), P += R + 1, u) {
609
- const F = oe(v, o, i, h, f);
610
- let U = I;
611
- s === "center" ? U = I - F / 2 : s === "right" && (U = I - F);
612
- const B = E + o * 0.1;
613
- e.beginPath(), e.moveTo(U, B), e.lineTo(U + F, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
607
+ align: a === "start" || a === "end" ? "left" : a
608
+ }) : e.fillText(M, E, v), I += R + 1, u) {
609
+ const W = ae(M, o, i, h, f);
610
+ let F = E;
611
+ a === "center" ? F = E - W / 2 : a === "right" && (F = E - W);
612
+ const B = v + o * 0.1;
613
+ e.beginPath(), e.moveTo(F, B), e.lineTo(F + W, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
614
614
  }
615
615
  if (d) {
616
- const F = oe(v, o, i, h, f);
617
- let U = I;
618
- s === "center" ? U = I - F / 2 : s === "right" && (U = I - F);
619
- const B = E - o * 0.25;
620
- e.beginPath(), e.moveTo(U, B), e.lineTo(U + F, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
616
+ const W = ae(M, o, i, h, f);
617
+ let F = E;
618
+ a === "center" ? F = E - W / 2 : a === "right" && (F = E - W);
619
+ const B = v - o * 0.25;
620
+ e.beginPath(), e.moveTo(F, B), e.lineTo(F + W, B), e.lineWidth = Math.max(1, o * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
621
621
  }
622
622
  });
623
623
  }
624
- function Wt(e, t) {
625
- Wr(e, t);
624
+ function Ut(e, t) {
625
+ Fr(e, t);
626
626
  }
627
- function Wr(e, t) {
627
+ function Fr(e, t) {
628
628
  var o;
629
629
  (o = t.stroke) != null && o.enabled && Ae(e, t), e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180);
630
- const r = t.transformData, n = ((r == null ? void 0 : r.width) ?? 100) - x * 2;
630
+ const r = t.transformData, n = ((r == null ? void 0 : r.width) ?? 100) - D * 2;
631
631
  if (t.richText) {
632
- const i = De.fromJSON(t.richText);
632
+ const i = xe.fromJSON(t.richText);
633
633
  e.save(), e.translate(0, 0);
634
- const s = t._lockedLineCount;
635
- Ir(
634
+ const a = t._lockedLineCount;
635
+ Ar(
636
636
  e,
637
637
  i,
638
638
  {
@@ -648,11 +648,11 @@ function Wr(e, t) {
648
648
  lineHeight: t.lineHeight
649
649
  },
650
650
  n,
651
- s
651
+ a
652
652
  ), e.restore();
653
653
  } else if (t.text) {
654
654
  e.fillStyle = t.color;
655
- const i = t._lockedLineCount, s = t.letterSpacing ?? 0, { lines: l, height: a } = Ee(
655
+ const i = t._lockedLineCount, a = t.letterSpacing ?? 0, { lines: l, height: s } = Ee(
656
656
  t.text,
657
657
  n,
658
658
  t.fontSize,
@@ -662,78 +662,78 @@ function Wr(e, t) {
662
662
  i,
663
663
  !0,
664
664
  // strict: true
665
- { letterSpacing: s, lineHeight: t.lineHeight }
666
- ), c = ht(
665
+ { letterSpacing: a, lineHeight: t.lineHeight }
666
+ ), c = ct(
667
667
  t.fontSize,
668
668
  t.fontFamily,
669
669
  t.bold,
670
670
  t.italic
671
- ), h = -((r == null ? void 0 : r.width) ?? 100) / 2, f = -a / 2, u = t.fontSize * (t.lineHeight ?? Vt);
672
- e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = t.textAlign, l.forEach((d, m) => {
673
- const g = m === 0, k = m === l.length - 1;
674
- let T = d;
675
- if (!g) {
676
- const p = d.match(/^ +/), y = p ? p[0].length : 0;
677
- y > 0 && (T = T.substring(y));
671
+ ), h = -((r == null ? void 0 : r.width) ?? 100) / 2, f = -s / 2, u = t.fontSize * (t.lineHeight ?? Jt);
672
+ e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = t.textAlign, l.forEach((d, p) => {
673
+ const m = p === 0, w = p === l.length - 1;
674
+ let k = d;
675
+ if (!m) {
676
+ const g = d.match(/^ +/), y = g ? g[0].length : 0;
677
+ y > 0 && (k = k.substring(y));
678
678
  }
679
- if (!k) {
680
- const p = T.match(/ +$/), y = p ? p[0].length : 0;
681
- y > 0 && (T = T.substring(0, T.length - y));
679
+ if (!w) {
680
+ const g = k.match(/ +$/), y = g ? g[0].length : 0;
681
+ y > 0 && (k = k.substring(0, k.length - y));
682
682
  }
683
- let w = h + x;
684
- t.textAlign === "center" ? w = h + ((r == null ? void 0 : r.width) ?? 100) / 2 : t.textAlign === "right" && (w = h + ((r == null ? void 0 : r.width) ?? 100) - x);
685
- const b = f + c.ascent + m * u;
686
- if (Jt(e, T, w, b, s), T.length > 0) {
687
- const p = at(e.measureText(T).width, T, s);
688
- let y = w;
689
- if (t.textAlign === "center" ? y -= p / 2 : t.textAlign === "right" && (y -= p), t.underline) {
690
- const C = b + t.fontSize * 0.1;
691
- e.fillRect(y, C, p, Math.max(1, t.fontSize * 0.05));
683
+ let b = h + D;
684
+ t.textAlign === "center" ? b = h + ((r == null ? void 0 : r.width) ?? 100) / 2 : t.textAlign === "right" && (b = h + ((r == null ? void 0 : r.width) ?? 100) - D);
685
+ const T = f + c.ascent + p * u;
686
+ if (Kt(e, k, b, T, a), k.length > 0) {
687
+ const g = at(e.measureText(k).width, k, a);
688
+ let y = b;
689
+ if (t.textAlign === "center" ? y -= g / 2 : t.textAlign === "right" && (y -= g), t.underline) {
690
+ const S = T + t.fontSize * 0.1;
691
+ e.fillRect(y, S, g, Math.max(1, t.fontSize * 0.05));
692
692
  }
693
693
  if (t.strikethrough) {
694
- const C = b - c.ascent * 0.4;
695
- e.fillRect(y, C, p, Math.max(1, t.fontSize * 0.05));
694
+ const S = T - c.ascent * 0.4;
695
+ e.fillRect(y, S, g, Math.max(1, t.fontSize * 0.05));
696
696
  }
697
697
  }
698
698
  });
699
699
  }
700
700
  e.restore();
701
701
  }
702
- function to(e, t) {
703
- var s;
704
- const r = t.opacity ?? 1, n = !!((s = t.stroke) != null && s.enabled), o = t.type === "custom";
702
+ function no(e, t) {
703
+ var a;
704
+ const r = t.opacity ?? 1, n = !!((a = t.stroke) != null && a.enabled), o = t.type === "custom";
705
705
  if (r < 1 && n && o) {
706
- Fr(e, t, r);
706
+ Ur(e, t, r);
707
707
  return;
708
708
  }
709
709
  const i = e.globalAlpha;
710
- r !== 1 && (e.globalAlpha = r), Ft(e, t), e.globalAlpha = i;
710
+ r !== 1 && (e.globalAlpha = r), Bt(e, t), e.globalAlpha = i;
711
711
  }
712
- function Fr(e, t, r) {
713
- var k;
714
- const n = t.transformData, o = t.fontSize || 24, i = ((k = t.stroke) == null ? void 0 : k.width) || 0, s = ((n == null ? void 0 : n.width) ?? o * t.text.length * 0.7) + i * 2 + 40, l = o * 3 + i * 2 + 40, a = e.getTransform(), c = Math.max(Math.abs(a.a), Math.abs(a.d), 1), h = Math.ceil(s * c), f = Math.ceil(l * c);
712
+ function Ur(e, t, r) {
713
+ var w;
714
+ const n = t.transformData, o = t.fontSize || 24, i = ((w = t.stroke) == null ? void 0 : w.width) || 0, a = ((n == null ? void 0 : n.width) ?? o * t.text.length * 0.7) + i * 2 + 40, l = o * 3 + i * 2 + 40, s = e.getTransform(), c = Math.max(Math.abs(s.a), Math.abs(s.d), 1), h = Math.ceil(a * c), f = Math.ceil(l * c);
715
715
  let u;
716
716
  typeof OffscreenCanvas < "u" ? u = new OffscreenCanvas(h, f) : (u = document.createElement("canvas"), u.width = h, u.height = f);
717
717
  const d = u.getContext("2d");
718
718
  if (!d) {
719
- const T = e.globalAlpha;
720
- e.globalAlpha = r, Ft(e, t), e.globalAlpha = T;
719
+ const k = e.globalAlpha;
720
+ e.globalAlpha = r, Bt(e, t), e.globalAlpha = k;
721
721
  return;
722
722
  }
723
- const m = a.a * t.x + a.e, g = a.d * t.y + a.f;
723
+ const p = s.a * t.x + s.e, m = s.d * t.y + s.f;
724
724
  d.setTransform(
725
- a.a,
726
- a.b,
727
- a.c,
728
- a.d,
729
- a.e - m + h / 2,
730
- a.f - g + f / 2
731
- ), Ft(d, t), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = r, e.drawImage(u, m - h / 2, g - f / 2), e.restore();
725
+ s.a,
726
+ s.b,
727
+ s.c,
728
+ s.d,
729
+ s.e - p + h / 2,
730
+ s.f - m + f / 2
731
+ ), Bt(d, t), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.globalAlpha = r, e.drawImage(u, p - h / 2, m - f / 2), e.restore();
732
732
  }
733
- function Ft(e, t) {
733
+ function Bt(e, t) {
734
734
  switch (t.type) {
735
735
  case "custom":
736
- Wt(e, t);
736
+ Ut(e, t);
737
737
  break;
738
738
  case "circle":
739
739
  Re(e, t);
@@ -754,16 +754,16 @@ function Ft(e, t) {
754
754
  Oe(e, t);
755
755
  break;
756
756
  default:
757
- Rt.warn(`[canvas-renderer] Unsupported transform type: ${t.type}`), Wt(e, t);
757
+ Ft.warn(`[canvas-renderer] Unsupported transform type: ${t.type}`), Ut(e, t);
758
758
  }
759
759
  }
760
- function Ur(e, t) {
760
+ function Br(e, t) {
761
761
  if (typeof OffscreenCanvas < "u")
762
762
  return new OffscreenCanvas(e, t);
763
763
  const r = document.createElement("canvas");
764
764
  return r.width = e, r.height = t, r;
765
765
  }
766
- function et(e, t, r) {
766
+ function tt(e, t, r) {
767
767
  if (r != null && r.enabled)
768
768
  if (e.strokeStyle = r.color, e.lineWidth = r.width, e.lineCap = r.lineCap || "round", e.lineJoin = r.lineJoin || "round", r.miterLimit !== void 0 && (e.miterLimit = r.miterLimit), r.opacity !== void 0) {
769
769
  const n = e.globalAlpha;
@@ -771,112 +771,112 @@ function et(e, t, r) {
771
771
  } else
772
772
  e.strokeText(t, 0, 0);
773
773
  }
774
- function rt(e, t, r) {
775
- const n = t.stroke, o = (n == null ? void 0 : n.opacity) ?? 1, i = e.globalAlpha, s = (n == null ? void 0 : n.enabled) && o < 1, l = (n == null ? void 0 : n.enabled) && i < 1;
776
- if (!(s || l)) {
774
+ function et(e, t, r) {
775
+ const n = t.stroke, o = (n == null ? void 0 : n.opacity) ?? 1, i = e.globalAlpha, a = (n == null ? void 0 : n.enabled) && o < 1, l = (n == null ? void 0 : n.enabled) && i < 1;
776
+ if (!(a || l)) {
777
777
  r(e, t);
778
778
  return;
779
779
  }
780
- const c = t.fontSize || 24, h = n.width || 0, f = t.transformData, u = c * t.text.length * 0.7, d = f.width ?? (f.radius ? f.radius * 2 : 0), m = Math.max(d, u), g = (n.feather || 0) * 2, k = h * 4 + g + c + 40, T = m + k, w = f.archHeight ? Math.abs(f.archHeight) * c * 2 : 0, b = f.radius ? f.radius : 0, p = c * 3 + k + w + b, y = e.getTransform(), C = Math.max(Math.abs(y.a), Math.abs(y.d), 1), M = Math.ceil(T * C / 2) * 2, S = Math.ceil(p * C / 2) * 2;
781
- if (M <= 0 || S <= 0) {
780
+ const c = t.fontSize || 24, h = n.width || 0, f = t.transformData, u = c * t.text.length * 0.7, d = f.width ?? (f.radius ? f.radius * 2 : 0), p = Math.max(d, u), m = (n.feather || 0) * 2, w = h * 4 + m + c + 40, k = p + w, b = f.archHeight ? Math.abs(f.archHeight) * c * 2 : 0, T = f.radius ? f.radius : 0, g = c * 3 + w + b + T, y = e.getTransform(), S = Math.max(Math.abs(y.a), Math.abs(y.d), 1), C = Math.ceil(k * S / 2) * 2, P = Math.ceil(g * S / 2) * 2;
781
+ if (C <= 0 || P <= 0) {
782
782
  r(e, t);
783
783
  return;
784
784
  }
785
- const P = Ur(M, S), v = P.getContext("2d");
786
- if (!v) {
785
+ const I = Br(C, P), M = I.getContext("2d");
786
+ if (!M) {
787
787
  r(e, t);
788
788
  return;
789
789
  }
790
- const A = t.x || 0, I = t.y || 0, E = y.a * A + y.c * I + y.e, R = y.b * A + y.d * I + y.f, W = Math.round(E - M / 2), F = Math.round(R - S / 2);
791
- if (v.setTransform(
790
+ const A = t.x || 0, E = t.y || 0, v = y.a * A + y.c * E + y.e, R = y.b * A + y.d * E + y.f, U = Math.round(v - C / 2), W = Math.round(R - P / 2);
791
+ if (M.setTransform(
792
792
  y.a,
793
793
  y.b,
794
794
  y.c,
795
795
  y.d,
796
- M / 2 - E + y.e,
797
- S / 2 - R + y.f
796
+ C / 2 - v + y.e,
797
+ P / 2 - R + y.f
798
798
  ), l) {
799
- v.globalAlpha = 1;
799
+ M.globalAlpha = 1;
800
800
  const $ = n.opacity;
801
- s && (n.opacity = 1), r(v, t), s && (n.opacity = $), e.save(), e.resetTransform(), e.globalAlpha = i, e.drawImage(P, W, F), e.restore();
801
+ a && (n.opacity = 1), r(M, t), a && (n.opacity = $), e.save(), e.resetTransform(), e.globalAlpha = i, e.drawImage(I, U, W), e.restore();
802
802
  return;
803
803
  }
804
- const U = n.opacity;
805
- n.opacity = 1, r(v, t), n.opacity = U;
804
+ const F = n.opacity;
805
+ n.opacity = 1, r(M, t), n.opacity = F;
806
806
  const B = n.enabled;
807
807
  n.enabled = !1, r(e, t), n.enabled = B, e.save(), e.resetTransform(), e.globalAlpha = o, e.drawImage(
808
- P,
809
- W,
810
- F
808
+ I,
809
+ U,
810
+ W
811
811
  ), e.restore();
812
812
  }
813
813
  function Re(e, t) {
814
- rt(e, t, Br);
814
+ et(e, t, Or);
815
815
  }
816
- function Br(e, t) {
816
+ function Or(e, t) {
817
817
  const r = t.transformData;
818
818
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.scale(r.scale, r.scale);
819
819
  const n = t.bold ? "bold" : "normal", o = t.italic ? "italic" : "normal";
820
820
  e.font = `${o} ${n} ${t.fontSize}px ${t.fontFamily}`, e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
821
- const i = t.text.split(""), s = i.map((a) => e.measureText(a).width), l = s.reduce((a, c) => a + c, 0);
821
+ const i = t.text.split(""), a = i.map((s) => e.measureText(s).width), l = a.reduce((s, c) => s + c, 0);
822
822
  if (r.reverse) {
823
- let a = Math.PI / 2 + l / (2 * r.radius);
823
+ let s = Math.PI / 2 + l / (2 * r.radius);
824
824
  i.forEach((c, h) => {
825
- const u = s[h] / r.radius, d = Math.cos(a - u / 2) * r.radius, m = Math.sin(a - u / 2) * r.radius;
826
- e.save(), e.translate(d, m), e.rotate(a - u / 2 - Math.PI / 2), et(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), a -= u;
825
+ const u = a[h] / r.radius, d = Math.cos(s - u / 2) * r.radius, p = Math.sin(s - u / 2) * r.radius;
826
+ e.save(), e.translate(d, p), e.rotate(s - u / 2 - Math.PI / 2), tt(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), s -= u;
827
827
  });
828
828
  } else {
829
- let a = -Math.PI / 2 - l / (2 * r.radius);
829
+ let s = -Math.PI / 2 - l / (2 * r.radius);
830
830
  i.forEach((c, h) => {
831
- const u = s[h] / r.radius, d = Math.cos(a + u / 2) * r.radius, m = Math.sin(a + u / 2) * r.radius;
832
- e.save(), e.translate(d, m), e.rotate(a + u / 2 + Math.PI / 2), et(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), a += u;
831
+ const u = a[h] / r.radius, d = Math.cos(s + u / 2) * r.radius, p = Math.sin(s + u / 2) * r.radius;
832
+ e.save(), e.translate(d, p), e.rotate(s + u / 2 + Math.PI / 2), tt(e, c, t.stroke), e.fillText(c, 0, 0), e.restore(), s += u;
833
833
  });
834
834
  }
835
835
  e.restore();
836
836
  }
837
837
  function We(e, t) {
838
- rt(e, t, Or);
838
+ et(e, t, Lr);
839
839
  }
840
- function Or(e, t) {
840
+ function Lr(e, t) {
841
841
  const r = t.transformData;
842
842
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
843
843
  const n = t.text.split("");
844
- let i = -n.reduce((s, l) => s + e.measureText(l).width, 0) / 2;
845
- n.forEach((s) => {
846
- const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = r.amplitude * t.fontSize * Math.sin(r.frequency * Math.PI * c), f = r.amplitude * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c);
847
- e.save(), e.translate(a, h), e.transform(1, f * xe, 0, 1, 0, 0), et(e, s, t.stroke), e.fillText(s, 0, 0), e.restore(), i += l;
844
+ let i = -n.reduce((a, l) => a + e.measureText(l).width, 0) / 2;
845
+ n.forEach((a) => {
846
+ const l = e.measureText(a).width, s = i + l / 2, c = s / (r.width / 2), h = r.amplitude * t.fontSize * Math.sin(r.frequency * Math.PI * c), f = r.amplitude * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c);
847
+ e.save(), e.translate(s, h), e.transform(1, f * tr, 0, 1, 0, 0), tt(e, a, t.stroke), e.fillText(a, 0, 0), e.restore(), i += l;
848
848
  }), e.restore();
849
849
  }
850
850
  function Fe(e, t) {
851
- rt(e, t, Lr);
851
+ et(e, t, qr);
852
852
  }
853
- function Lr(e, t) {
853
+ function qr(e, t) {
854
854
  const r = t.transformData;
855
855
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
856
- const n = t.text.split(""), o = n.reduce((l, a) => l + e.measureText(a).width, 0), i = r.width / 2;
857
- let s = -o / 2;
856
+ const n = t.text.split(""), o = n.reduce((l, s) => l + e.measureText(s).width, 0), i = r.width / 2;
857
+ let a = -o / 2;
858
858
  n.forEach((l) => {
859
- const a = e.measureText(l).width, c = s + a / 2, h = c / i, f = (Math.pow(h, 2) - 1) * r.archHeight * t.fontSize, u = 2 * h * r.archHeight;
860
- e.save(), e.translate(c, f), e.transform(1, u * 0.3, 0, 1, 0, 0), et(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), s += a;
859
+ const s = e.measureText(l).width, c = a + s / 2, h = c / i, f = (Math.pow(h, 2) - 1) * r.archHeight * t.fontSize, u = 2 * h * r.archHeight;
860
+ e.save(), e.translate(c, f), e.transform(1, u * 0.3, 0, 1, 0, 0), tt(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), a += s;
861
861
  }), e.restore();
862
862
  }
863
863
  function Ue(e, t) {
864
- rt(e, t, qr);
864
+ et(e, t, $r);
865
865
  }
866
- function qr(e, t) {
866
+ function $r(e, t) {
867
867
  const r = t.transformData;
868
868
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
869
- const n = t.text.split(""), o = n.reduce((l, a) => l + e.measureText(a).width, 0), i = r.ascendAngle * Math.PI / 180;
870
- let s = -o / 2;
869
+ const n = t.text.split(""), o = n.reduce((l, s) => l + e.measureText(s).width, 0), i = r.ascendAngle * Math.PI / 180;
870
+ let a = -o / 2;
871
871
  n.forEach((l) => {
872
- const a = e.measureText(l).width, c = s + a / 2, h = c * Math.tan(i), f = Math.tan(i);
873
- e.save(), e.translate(c, h), e.transform(1, f * 1, 0, 1, 0, 0), et(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), s += a;
872
+ const s = e.measureText(l).width, c = a + s / 2, h = c * Math.tan(i), f = Math.tan(i);
873
+ e.save(), e.translate(c, h), e.transform(1, f * 1, 0, 1, 0, 0), tt(e, l, t.stroke), e.fillText(l, 0, 0), e.restore(), a += s;
874
874
  }), e.restore();
875
875
  }
876
876
  function Be(e, t) {
877
- rt(e, t, $r);
877
+ et(e, t, Hr);
878
878
  }
879
- function $r(e, t) {
879
+ function Hr(e, t) {
880
880
  var o;
881
881
  const r = t.transformData;
882
882
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180);
@@ -884,45 +884,45 @@ function $r(e, t) {
884
884
  e.transform(1, 0, Math.tan(n), 1, 0, 0), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle", (o = t.stroke) != null && o.enabled && (e.save(), e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "round", e.lineJoin = t.stroke.lineJoin || "round", t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity), e.strokeText(t.text, 0, 0), e.restore()), e.fillText(t.text, 0, 0), e.restore();
885
885
  }
886
886
  function Oe(e, t) {
887
- rt(e, t, Hr);
887
+ et(e, t, jr);
888
888
  }
889
- function Hr(e, t) {
889
+ function jr(e, t) {
890
890
  const r = t.transformData;
891
891
  e.save(), e.translate(t.x, t.y), e.rotate(-t.rotation * Math.PI / 180), e.font = q(t.fontSize, t.fontFamily, t.bold, t.italic), e.fillStyle = t.color, e.textAlign = "center", e.textBaseline = "middle";
892
892
  const n = t.text.split("");
893
- let i = -n.reduce((s, l) => s + e.measureText(l).width, 0) / 2;
894
- n.forEach((s) => {
895
- const l = e.measureText(s).width, a = i + l / 2, c = a / (r.width / 2), h = Math.abs(c), f = r.amplitude * h, u = f * t.fontSize * Math.sin(r.frequency * Math.PI * c), d = f * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c), m = r.amplitude * Math.sign(c) * Math.sin(r.frequency * Math.PI * c), g = d + m;
896
- e.save(), e.translate(a, u), e.transform(1, g * 0.3, 0, 1, 0, 0), et(e, s, t.stroke), e.fillText(s, 0, 0), e.restore(), i += l;
893
+ let i = -n.reduce((a, l) => a + e.measureText(l).width, 0) / 2;
894
+ n.forEach((a) => {
895
+ const l = e.measureText(a).width, s = i + l / 2, c = s / (r.width / 2), h = Math.abs(c), f = r.amplitude * h, u = f * t.fontSize * Math.sin(r.frequency * Math.PI * c), d = f * r.frequency * Math.PI * Math.cos(r.frequency * Math.PI * c), p = r.amplitude * Math.sign(c) * Math.sin(r.frequency * Math.PI * c), m = d + p;
896
+ e.save(), e.translate(s, u), e.transform(1, m * 0.3, 0, 1, 0, 0), tt(e, a, t.stroke), e.fillText(a, 0, 0), e.restore(), i += l;
897
897
  }), e.restore();
898
898
  }
899
899
  function Q(e) {
900
900
  return (t, r) => e(t, r);
901
901
  }
902
- function jr(e, t) {
902
+ function _r(e, t) {
903
903
  e.save();
904
- const r = e.canvas, n = r.width, o = r.height, i = e.getTransform(), s = [];
904
+ const r = e.canvas, n = r.width, o = r.height, i = e.getTransform(), a = [];
905
905
  let l = [];
906
- for (const a of t)
907
- a.isClipping ? l.length > 0 ? (s.push({ content: l, mask: a }), l = []) : s.push({ content: [a] }) : l.push(a);
908
- l.length > 0 && s.push({ content: l });
909
- for (const a of s)
910
- if (!a.mask)
911
- a.content.forEach((c) => c.render(e, !1, !1));
906
+ for (const s of t)
907
+ s.isClipping ? l.length > 0 ? (a.push({ content: l, mask: s }), l = []) : a.push({ content: [s] }) : l.push(s);
908
+ l.length > 0 && a.push({ content: l });
909
+ for (const s of a)
910
+ if (!s.mask)
911
+ s.content.forEach((c) => c.render(e, !1, !1));
912
912
  else {
913
913
  const c = document.createElement("canvas");
914
914
  c.width = n, c.height = o;
915
915
  const h = c.getContext("2d");
916
916
  if (!h) continue;
917
- h.setTransform(i), a.content.forEach((d) => {
917
+ h.setTransform(i), s.content.forEach((d) => {
918
918
  d.render(h, !1, !1);
919
919
  });
920
920
  const f = document.createElement("canvas");
921
921
  f.width = n, f.height = o;
922
922
  const u = f.getContext("2d");
923
923
  if (!u) continue;
924
- if (u.setTransform(i), a.mask.render(u, !1, !1), a.mask.transformType !== "image" && a.mask.transformType !== "shape") {
925
- const d = a.mask.getBoundingBox();
924
+ if (u.setTransform(i), s.mask.render(u, !1, !1), s.mask.transformType !== "image" && s.mask.transformType !== "shape") {
925
+ const d = s.mask.getBoundingBox();
926
926
  u.save(), u.fillStyle = "#FFFFFF", u.fillRect(d.x, d.y, d.width, d.height), u.restore();
927
927
  }
928
928
  h.globalCompositeOperation = "destination-in", h.setTransform(1, 0, 0, 1, 0, 0), h.drawImage(f, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(c, 0, 0), e.setTransform(i);
@@ -930,36 +930,36 @@ function jr(e, t) {
930
930
  e.restore();
931
931
  }
932
932
  var se = !1;
933
- function Qt() {
933
+ function zt() {
934
934
  se || (se = !0, J("arch", Q(Fe)), J("ascend", Q(Ue)), J("circle", Q(Re)), J("flag", Q(Oe)), J("lean", Q(Be)), J("wave", Q(We)), J(
935
935
  "custom",
936
- (e, t) => Wt(e, t)
937
- ), tr(jr), pr(
936
+ (e, t) => Ut(e, t)
937
+ ), er(_r), mr(
938
938
  (e, t) => kr(e, t)
939
939
  ), globalThis.__scElementPaintersInstalled = !0);
940
940
  }
941
- Qt();
942
- function zt(e, t, r = {}) {
941
+ zt();
942
+ function Zt(e, t, r = {}) {
943
943
  const n = r.mode || "both";
944
944
  switch (e.save(), e.translate(t.x || 0, t.y || 0), e.rotate(-(t.rotation || 0) * Math.PI / 180), t.transformType) {
945
945
  case "image":
946
- Nr(e, t, n, r);
946
+ Xr(e, t, n, r);
947
947
  break;
948
948
  case "shape":
949
- Xr(e, t, n, r);
949
+ Gr(e, t, n, r);
950
950
  break;
951
951
  case "group":
952
952
  break;
953
953
  default:
954
- _r(e, t, n, r);
954
+ Nr(e, t, n, r);
955
955
  break;
956
956
  }
957
957
  e.restore();
958
958
  }
959
- function _r(e, t, r, n) {
960
- var s;
959
+ function Nr(e, t, r, n) {
960
+ var a;
961
961
  const o = t, i = o.text || "";
962
- i && ((r === "stroke" || r === "both") && ((s = t.stroke) != null && s.enabled) && (e.save(), Ae(e, t, { ...n.renderingContext, positionApplied: !0 }), e.restore()), (r === "fill" || r === "both") && (e.save(), Ar(e, {
962
+ i && ((r === "stroke" || r === "both") && ((a = t.stroke) != null && a.enabled) && (e.save(), Ae(e, t, { ...n.renderingContext, positionApplied: !0 }), e.restore()), (r === "fill" || r === "both") && (e.save(), Rr(e, {
963
963
  text: i,
964
964
  fontSize: o.fontSize || 24,
965
965
  fontFamily: o.fontFamily || "Arial",
@@ -970,172 +970,172 @@ function _r(e, t, r, n) {
970
970
  letterSpacing: o.letterSpacing
971
971
  }), e.restore()));
972
972
  }
973
- function Nr(e, t, r, n) {
973
+ function Xr(e, t, r, n) {
974
974
  var i;
975
975
  if (!t.transformData) return;
976
976
  const o = t.transformData;
977
977
  if (r === "fill" || r === "both")
978
- if (Kr(e, t), n.loadedImage) {
978
+ if (Qr(e, t), n.loadedImage) {
979
979
  e.save(), e.clip();
980
- const s = o.flipHorizontal ? -1 : 1, l = o.flipVertical ? -1 : 1;
981
- e.scale(s, l);
982
- const a = o.width ?? 100, c = o.height ?? 100;
983
- e.drawImage(n.loadedImage, -a / 2, -c / 2, a, c), e.restore();
980
+ const a = o.flipHorizontal ? -1 : 1, l = o.flipVertical ? -1 : 1;
981
+ e.scale(a, l);
982
+ const s = o.width ?? 100, c = o.height ?? 100;
983
+ e.drawImage(n.loadedImage, -s / 2, -c / 2, s, c), e.restore();
984
984
  } else
985
985
  e.fillStyle = "#cccccc", e.fill();
986
- (r === "stroke" || r === "both") && ((i = t.stroke) != null && i.enabled) && (e.save(), Mr(e, t, n.renderingContext), e.restore());
986
+ (r === "stroke" || r === "both") && ((i = t.stroke) != null && i.enabled) && (e.save(), Cr(e, t, n.renderingContext), e.restore());
987
987
  }
988
- function Xr(e, t, r, n) {
989
- var s, l;
988
+ function Gr(e, t, r, n) {
989
+ var a, l;
990
990
  if (!t.transformData) return;
991
- const o = t.transformData, i = ((s = n.renderingContext) == null ? void 0 : s.isKnockout) === !0;
992
- e.beginPath(), Le(e, o), (r === "fill" || r === "both") && (e.fillStyle = i ? "#000000" : er(e, o), e.globalAlpha = i ? 1 : o.fillOpacity ?? 1, e.fill()), (r === "stroke" || r === "both") && ((l = t.stroke) != null && l.enabled) && (e.save(), Jr(e, t, n.renderingContext), e.restore());
991
+ const o = t.transformData, i = ((a = n.renderingContext) == null ? void 0 : a.isKnockout) === !0;
992
+ e.beginPath(), Le(e, o), (r === "fill" || r === "both") && (e.fillStyle = i ? "#000000" : rr(e, o), e.globalAlpha = i ? 1 : o.fillOpacity ?? 1, e.fill()), (r === "stroke" || r === "both") && ((l = t.stroke) != null && l.enabled) && (e.save(), Kr(e, t, n.renderingContext), e.restore());
993
993
  }
994
994
  function Le(e, t) {
995
995
  const { shapeType: r } = t, n = t.width ?? 100, o = t.height ?? 100;
996
996
  switch (r) {
997
997
  case "rectangle":
998
- ae(e, t, n, o);
998
+ ie(e, t, n, o);
999
999
  break;
1000
1000
  case "circle":
1001
- Gr(e, Math.min(n, o) / 2);
1001
+ Yr(e, Math.min(n, o) / 2);
1002
1002
  break;
1003
1003
  case "ellipse":
1004
- Yr(e, n / 2, o / 2);
1004
+ Vr(e, n / 2, o / 2);
1005
1005
  break;
1006
1006
  case "star":
1007
- Vr(e, t, Math.min(n, o) / 2);
1007
+ Jr(e, t, Math.min(n, o) / 2);
1008
1008
  break;
1009
1009
  default:
1010
- ae(e, t, n, o);
1010
+ ie(e, t, n, o);
1011
1011
  }
1012
1012
  }
1013
- function ae(e, t, r, n) {
1014
- const o = t.borderRadius || 0, i = -r / 2, s = -n / 2;
1013
+ function ie(e, t, r, n) {
1014
+ const o = t.borderRadius || 0, i = -r / 2, a = -n / 2;
1015
1015
  if (o > 0) {
1016
1016
  const l = Math.min(o / 100 * Math.min(r, n), r / 2, n / 2);
1017
- e.roundRect(i, s, r, n, l);
1017
+ e.roundRect(i, a, r, n, l);
1018
1018
  } else
1019
- e.rect(i, s, r, n);
1019
+ e.rect(i, a, r, n);
1020
1020
  }
1021
- function Gr(e, t) {
1021
+ function Yr(e, t) {
1022
1022
  e.arc(0, 0, t, 0, Math.PI * 2);
1023
1023
  }
1024
- function Yr(e, t, r) {
1024
+ function Vr(e, t, r) {
1025
1025
  e.ellipse(0, 0, t, r, 0, 0, Math.PI * 2);
1026
1026
  }
1027
- function Vr(e, t, r) {
1028
- const n = Math.max(3, Math.min(20, t.points || 5)), o = Math.max(0.1, Math.min(0.9, t.innerRadius || 0.4)), i = r * o, s = Math.PI / n, l = -Math.PI / 2;
1029
- for (let a = 0; a < n * 2; a++) {
1030
- const c = l + s * a, h = a % 2 === 0 ? r : i, f = Math.cos(c) * h, u = Math.sin(c) * h;
1031
- a === 0 ? e.moveTo(f, u) : e.lineTo(f, u);
1027
+ function Jr(e, t, r) {
1028
+ const n = Math.max(3, Math.min(20, t.points || 5)), o = Math.max(0.1, Math.min(0.9, t.innerRadius || 0.4)), i = r * o, a = Math.PI / n, l = -Math.PI / 2;
1029
+ for (let s = 0; s < n * 2; s++) {
1030
+ const c = l + a * s, h = s % 2 === 0 ? r : i, f = Math.cos(c) * h, u = Math.sin(c) * h;
1031
+ s === 0 ? e.moveTo(f, u) : e.lineTo(f, u);
1032
1032
  }
1033
1033
  e.closePath();
1034
1034
  }
1035
- function Jr(e, t, r) {
1035
+ function Kr(e, t, r) {
1036
1036
  var o;
1037
1037
  if (!((o = t.stroke) != null && o.enabled) || !t.transformData) return;
1038
1038
  const n = (r == null ? void 0 : r.isKnockout) === !0;
1039
1039
  e.save(), n ? (e.strokeStyle = "#000000", e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = t.stroke.color, e.lineWidth = t.stroke.width, e.lineCap = t.stroke.lineCap || "butt", e.lineJoin = t.stroke.lineJoin || "miter", t.stroke.opacity !== void 0 && (e.globalAlpha = t.stroke.opacity)), t.stroke.miterLimit !== void 0 && (e.miterLimit = t.stroke.miterLimit), t.stroke.dashArray && t.stroke.dashArray.length > 0 && e.setLineDash(t.stroke.dashArray), !n && t.stroke.feather && t.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${t.stroke.feather}px)`), e.beginPath(), Le(e, t.transformData), e.stroke(), e.restore();
1040
1040
  }
1041
- function Kr(e, t) {
1041
+ function Qr(e, t) {
1042
1042
  if (!t.transformData) return;
1043
- const { borderRadius: r } = t.transformData, n = t.transformData.width ?? 100, o = t.transformData.height ?? 100, i = -n / 2, s = -o / 2;
1043
+ const { borderRadius: r } = t.transformData, n = t.transformData.width ?? 100, o = t.transformData.height ?? 100, i = -n / 2, a = -o / 2;
1044
1044
  if (e.beginPath(), r && r > 0) {
1045
1045
  const l = Math.min(r / 100 * Math.min(n, o), n / 2, o / 2);
1046
- e.roundRect(i, s, n, o, l);
1046
+ e.roundRect(i, a, n, o, l);
1047
1047
  } else
1048
- e.rect(i, s, n, o);
1048
+ e.rect(i, a, n, o);
1049
1049
  }
1050
- function Ut(e, t, r, n, o, i, s = "destination-out") {
1051
- var b;
1050
+ function qe(e, t, r, n, o, i, a = "destination-out") {
1051
+ var T;
1052
1052
  if (!t.knockoutParts) return;
1053
1053
  if (!(t.knockoutParts.fill || t.knockoutParts.stroke)) {
1054
1054
  n(e, t);
1055
1055
  return;
1056
1056
  }
1057
- const a = e.getTransform();
1057
+ const s = e.getTransform();
1058
1058
  e.save();
1059
- const c = t.knockoutParts.scope || "group", h = Qr(t, c, r);
1059
+ const c = t.knockoutParts.scope || "group", h = zr(t, c, r);
1060
1060
  if (h.length === 0 && c === "artboard") {
1061
- Zr(e, t, n), e.restore();
1061
+ Dr(e, t, n), e.restore();
1062
1062
  return;
1063
1063
  }
1064
1064
  if (h.length === 0) {
1065
1065
  n(e, t), e.restore();
1066
1066
  return;
1067
1067
  }
1068
- const f = e.canvas, d = e.getTransform().a, m = Dr(f.width, f.height), g = m.getContext("2d");
1069
- if (!g) return;
1070
- g.scale(d, d), o && i && (g.fillStyle = o, g.fillRect(i.x, i.y, i.width, i.height));
1071
- for (const p of h)
1072
- n(g, p);
1073
- t.knockoutParts.fill && !t.knockoutParts.stroke && ((b = t.stroke) != null && b.enabled) && (g.save(), Ot(g, t), g.restore()), g.save(), g.globalCompositeOperation = s, t.knockoutParts.fill && Bt(g, t), t.knockoutParts.stroke && Ot(g, t), g.restore(), t.knockoutParts.fill || (g.save(), Bt(g, t), g.restore());
1074
- const k = f.width / d, T = f.height / d;
1075
- e.drawImage(m, 0, 0, k, T), e.restore();
1076
- const w = e.getTransform();
1077
- (Math.abs(w.a - a.a) > 1e-3 || Math.abs(w.d - a.d) > 1e-3 || Math.abs(w.e - a.e) > 1e-3 || Math.abs(w.f - a.f) > 1e-3) && e.setTransform(
1078
- a.a,
1079
- a.b,
1080
- a.c,
1081
- a.d,
1082
- a.e,
1083
- a.f
1068
+ const f = e.canvas, d = e.getTransform().a, p = xr(f.width, f.height), m = p.getContext("2d");
1069
+ if (!m) return;
1070
+ m.scale(d, d), o && i && (m.fillStyle = o, m.fillRect(i.x, i.y, i.width, i.height));
1071
+ for (const g of h)
1072
+ n(m, g);
1073
+ t.knockoutParts.fill && !t.knockoutParts.stroke && ((T = t.stroke) != null && T.enabled) && (m.save(), Lt(m, t), m.restore()), m.save(), m.globalCompositeOperation = a, t.knockoutParts.fill && Ot(m, t), t.knockoutParts.stroke && Lt(m, t), m.restore(), t.knockoutParts.fill || (m.save(), Ot(m, t), m.restore());
1074
+ const w = f.width / d, k = f.height / d;
1075
+ e.drawImage(p, 0, 0, w, k), e.restore();
1076
+ const b = e.getTransform();
1077
+ (Math.abs(b.a - s.a) > 1e-3 || Math.abs(b.d - s.d) > 1e-3 || Math.abs(b.e - s.e) > 1e-3 || Math.abs(b.f - s.f) > 1e-3) && e.setTransform(
1078
+ s.a,
1079
+ s.b,
1080
+ s.c,
1081
+ s.d,
1082
+ s.e,
1083
+ s.f
1084
1084
  );
1085
1085
  }
1086
- function eo(e, t, r, n, o, i) {
1087
- Ut(e, t, r, n, o, i, "destination-out");
1086
+ function oo(e, t, r, n, o, i) {
1087
+ qe(e, t, r, n, o, i, "destination-out");
1088
1088
  }
1089
- function Qr(e, t, r) {
1090
- return t === "artboard" ? qe(e, r) : zr(e, r);
1089
+ function zr(e, t, r) {
1090
+ return t === "artboard" ? $e(e, r) : Zr(e, r);
1091
1091
  }
1092
- function qe(e, t) {
1092
+ function $e(e, t) {
1093
1093
  const r = t.findIndex((n) => n.id === e.id);
1094
1094
  return r === -1 ? [] : t.slice(0, r);
1095
1095
  }
1096
- function zr(e, t) {
1097
- const r = $e(e, t);
1096
+ function Zr(e, t) {
1097
+ const r = He(e, t);
1098
1098
  if (!r)
1099
- return qe(e, t);
1099
+ return $e(e, t);
1100
1100
  if (r.transformType !== "group" || !r.children)
1101
1101
  return [];
1102
1102
  const n = r.children.findIndex((o) => o.id === e.id);
1103
1103
  return n === -1 ? [] : r.children.slice(0, n);
1104
1104
  }
1105
- function $e(e, t) {
1105
+ function He(e, t) {
1106
1106
  for (const r of t)
1107
1107
  if (r.transformType === "group" && r.children) {
1108
1108
  if (r.children.some((o) => o.id === e.id))
1109
1109
  return r;
1110
- const n = $e(e, r.children);
1110
+ const n = He(e, r.children);
1111
1111
  if (n)
1112
1112
  return n;
1113
1113
  }
1114
1114
  return null;
1115
1115
  }
1116
- function Bt(e, t, r) {
1117
- zt(e, t, {
1116
+ function Ot(e, t, r) {
1117
+ Zt(e, t, {
1118
1118
  mode: "fill",
1119
1119
  renderingContext: { isKnockout: !0 }
1120
1120
  });
1121
1121
  }
1122
- function Ot(e, t) {
1122
+ function Lt(e, t) {
1123
1123
  var r;
1124
- (r = t.stroke) != null && r.enabled && zt(e, t, {
1124
+ (r = t.stroke) != null && r.enabled && Zt(e, t, {
1125
1125
  mode: "stroke",
1126
1126
  renderingContext: { isKnockout: !0 }
1127
1127
  });
1128
1128
  }
1129
- function Zr(e, t, r) {
1129
+ function Dr(e, t, r) {
1130
1130
  var o;
1131
1131
  const n = t.knockoutParts;
1132
1132
  if (!n) {
1133
1133
  r(e, t);
1134
1134
  return;
1135
1135
  }
1136
- n.fill || (e.save(), Bt(e, t), e.restore()), !n.stroke && ((o = t.stroke) != null && o.enabled) && (e.save(), Ot(e, t), e.restore());
1136
+ n.fill || (e.save(), Ot(e, t), e.restore()), !n.stroke && ((o = t.stroke) != null && o.enabled) && (e.save(), Lt(e, t), e.restore());
1137
1137
  }
1138
- function Dr(e, t) {
1138
+ function xr(e, t) {
1139
1139
  if (typeof OffscreenCanvas < "u")
1140
1140
  return new OffscreenCanvas(e, t);
1141
1141
  if (typeof document < "u") {
@@ -1144,47 +1144,47 @@ function Dr(e, t) {
1144
1144
  }
1145
1145
  throw new Error("No canvas context available");
1146
1146
  }
1147
- function ie(e, t, r, n, o = 0) {
1147
+ function le(e, t, r, n, o = 0) {
1148
1148
  if (r <= 0 || n <= 0 || e <= 0 || t <= 0)
1149
1149
  return { width: e + o, height: t + o };
1150
- const i = r / n, s = e / t;
1151
- let l, a;
1152
- return s > i ? (a = t, l = t * i) : (l = e, a = e / i), {
1150
+ const i = r / n, a = e / t;
1151
+ let l, s;
1152
+ return a > i ? (s = t, l = t * i) : (l = e, s = e / i), {
1153
1153
  width: l + o,
1154
- height: a + o
1154
+ height: s + o
1155
1155
  };
1156
1156
  }
1157
- const ot = 64, Ct = 512;
1158
- function xr(e, t) {
1157
+ const nt = 64, Pt = 512;
1158
+ function tn(e, t) {
1159
1159
  e.beginPath(), e.arc(t / 2, t / 2, t * 0.45, 0, Math.PI * 2), e.fill();
1160
1160
  }
1161
- function tn(e, t) {
1162
- const r = t / 2, n = t / 2, o = t * 0.45, i = o * 0.4, s = 5;
1161
+ function en(e, t) {
1162
+ const r = t / 2, n = t / 2, o = t * 0.45, i = o * 0.4, a = 5;
1163
1163
  e.beginPath();
1164
- for (let l = 0; l < s * 2; l++) {
1165
- const a = -Math.PI / 2 + Math.PI / s * l, c = l % 2 === 0 ? o : i, h = r + Math.cos(a) * c, f = n + Math.sin(a) * c;
1164
+ for (let l = 0; l < a * 2; l++) {
1165
+ const s = -Math.PI / 2 + Math.PI / a * l, c = l % 2 === 0 ? o : i, h = r + Math.cos(s) * c, f = n + Math.sin(s) * c;
1166
1166
  l === 0 ? e.moveTo(h, f) : e.lineTo(h, f);
1167
1167
  }
1168
1168
  e.closePath(), e.fill();
1169
1169
  }
1170
- function en(e, t) {
1170
+ function rn(e, t) {
1171
1171
  const r = t / 2, n = t * 0.42;
1172
1172
  e.beginPath(), e.moveTo(r, t * 0.82), e.bezierCurveTo(r - n * 1.1, t * 0.6, r - n * 1.3, t * 0.2, r, t * 0.35), e.bezierCurveTo(r + n * 1.3, t * 0.2, r + n * 1.1, t * 0.6, r, t * 0.82), e.closePath(), e.fill();
1173
1173
  }
1174
- function rn(e, t) {
1174
+ function nn(e, t) {
1175
1175
  const r = t / 2, n = t / 2, o = t * 0.4, i = t * 0.48;
1176
1176
  e.beginPath(), e.moveTo(r, n - i), e.lineTo(r + o, n), e.lineTo(r, n + i), e.lineTo(r - o, n), e.closePath(), e.fill();
1177
1177
  }
1178
- function nn(e, t) {
1178
+ function on(e, t) {
1179
1179
  const r = t / 2, n = t / 2, o = t * 0.44;
1180
1180
  e.beginPath();
1181
1181
  for (let i = 0; i < 6; i++) {
1182
- const s = -Math.PI / 2 + Math.PI / 3 * i, l = r + Math.cos(s) * o, a = n + Math.sin(s) * o;
1183
- i === 0 ? e.moveTo(l, a) : e.lineTo(l, a);
1182
+ const a = -Math.PI / 2 + Math.PI / 3 * i, l = r + Math.cos(a) * o, s = n + Math.sin(a) * o;
1183
+ i === 0 ? e.moveTo(l, s) : e.lineTo(l, s);
1184
1184
  }
1185
1185
  e.closePath(), e.fill();
1186
1186
  }
1187
- function on(e, t) {
1187
+ function an(e, t) {
1188
1188
  const r = t / 2, n = t * 0.4, o = t * 0.12;
1189
1189
  e.beginPath(), e.moveTo(r, o), e.lineTo(r + n, t * 0.25), e.lineTo(r + n, t * 0.55), e.quadraticCurveTo(r + n * 0.3, t * 0.8, r, t * 0.9), e.quadraticCurveTo(r - n * 0.3, t * 0.8, r - n, t * 0.55), e.lineTo(r - n, t * 0.25), e.closePath(), e.fill();
1190
1190
  }
@@ -1193,215 +1193,215 @@ function sn(e, t) {
1193
1193
  let o = 42;
1194
1194
  const i = () => (o = (o * 16807 + 0) % 2147483647, o / 2147483647);
1195
1195
  e.beginPath(), e.arc(r, n, t * 0.28, 0, Math.PI * 2), e.fill();
1196
- for (let s = 0; s < 30; s++) {
1197
- const l = i() * Math.PI * 2, a = t * 0.15 + i() * t * 0.3, c = t * 0.02 + i() * t * 0.06;
1198
- e.beginPath(), e.arc(r + Math.cos(l) * a, n + Math.sin(l) * a, c, 0, Math.PI * 2), e.fill();
1196
+ for (let a = 0; a < 30; a++) {
1197
+ const l = i() * Math.PI * 2, s = t * 0.15 + i() * t * 0.3, c = t * 0.02 + i() * t * 0.06;
1198
+ e.beginPath(), e.arc(r + Math.cos(l) * s, n + Math.sin(l) * s, c, 0, Math.PI * 2), e.fill();
1199
1199
  }
1200
1200
  }
1201
- function an(e, t) {
1201
+ function ln(e, t) {
1202
1202
  let r = 123;
1203
1203
  const n = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), o = t * 0.08, i = 40;
1204
1204
  e.beginPath(), e.moveTo(o, o);
1205
- for (let s = 1; s <= i; s++) {
1206
- const l = o + (t - 2 * o) * (s / i), a = o + (n() - 0.5) * t * 0.08;
1207
- e.lineTo(l, a);
1205
+ for (let a = 1; a <= i; a++) {
1206
+ const l = o + (t - 2 * o) * (a / i), s = o + (n() - 0.5) * t * 0.08;
1207
+ e.lineTo(l, s);
1208
1208
  }
1209
- for (let s = 1; s <= i; s++) {
1210
- const l = t - o + (n() - 0.5) * t * 0.08, a = o + (t - 2 * o) * (s / i);
1211
- e.lineTo(l, a);
1209
+ for (let a = 1; a <= i; a++) {
1210
+ const l = t - o + (n() - 0.5) * t * 0.08, s = o + (t - 2 * o) * (a / i);
1211
+ e.lineTo(l, s);
1212
1212
  }
1213
- for (let s = i; s >= 0; s--) {
1214
- const l = o + (t - 2 * o) * (s / i), a = t - o + (n() - 0.5) * t * 0.08;
1215
- e.lineTo(l, a);
1213
+ for (let a = i; a >= 0; a--) {
1214
+ const l = o + (t - 2 * o) * (a / i), s = t - o + (n() - 0.5) * t * 0.08;
1215
+ e.lineTo(l, s);
1216
1216
  }
1217
- for (let s = i; s >= 0; s--) {
1218
- const l = o + (n() - 0.5) * t * 0.08, a = o + (t - 2 * o) * (s / i);
1219
- e.lineTo(l, a);
1217
+ for (let a = i; a >= 0; a--) {
1218
+ const l = o + (n() - 0.5) * t * 0.08, s = o + (t - 2 * o) * (a / i);
1219
+ e.lineTo(l, s);
1220
1220
  }
1221
1221
  e.closePath(), e.fill();
1222
1222
  }
1223
- function ln(e, t) {
1223
+ function cn(e, t) {
1224
1224
  let r = 77;
1225
- const n = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), o = t * 0.25, i = t * 0.75, s = t * 0.1;
1226
- e.beginPath(), e.moveTo(s, o + n() * t * 0.05);
1225
+ const n = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647), o = t * 0.25, i = t * 0.75, a = t * 0.1;
1226
+ e.beginPath(), e.moveTo(a, o + n() * t * 0.05);
1227
1227
  for (let l = 1; l <= 10; l++) {
1228
- const a = s + (t - 2 * s) * (l / 10), c = o + (n() - 0.5) * t * 0.1;
1229
- e.lineTo(a, c);
1228
+ const s = a + (t - 2 * a) * (l / 10), c = o + (n() - 0.5) * t * 0.1;
1229
+ e.lineTo(s, c);
1230
1230
  }
1231
1231
  for (let l = 10; l >= 0; l--) {
1232
- const a = s + (t - 2 * s) * (l / 10), c = i + (n() - 0.5) * t * 0.1;
1233
- e.lineTo(a, c);
1232
+ const s = a + (t - 2 * a) * (l / 10), c = i + (n() - 0.5) * t * 0.1;
1233
+ e.lineTo(s, c);
1234
1234
  }
1235
1235
  e.closePath(), e.fill();
1236
1236
  }
1237
- function cn(e, t) {
1237
+ function hn(e, t) {
1238
1238
  const r = t / 2, n = t * 0.55;
1239
1239
  e.beginPath(), e.arc(r, n, t * 0.2, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r - t * 0.18, n + t * 0.02, t * 0.15, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r + t * 0.18, n + t * 0.02, t * 0.16, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r - t * 0.06, n - t * 0.14, t * 0.14, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(r + t * 0.1, n - t * 0.12, t * 0.12, 0, Math.PI * 2), e.fill();
1240
1240
  }
1241
- const hn = [
1241
+ const fn = [
1242
1242
  // Geometric
1243
- { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: xr },
1244
- { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: tn },
1245
- { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: en },
1246
- { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: rn },
1247
- { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: nn },
1248
- { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: on },
1243
+ { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: tn },
1244
+ { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: en },
1245
+ { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: rn },
1246
+ { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: nn },
1247
+ { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: on },
1248
+ { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: an },
1249
1249
  // Organic
1250
1250
  { id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: sn },
1251
- { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: an },
1252
- { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: ln },
1253
- { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: cn }
1251
+ { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: ln },
1252
+ { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: cn },
1253
+ { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: hn }
1254
1254
  ];
1255
- let le = !1;
1256
- function ce(e, t) {
1255
+ let ce = !1;
1256
+ function he(e, t) {
1257
1257
  if (typeof document > "u") return null;
1258
1258
  const r = document.createElement("canvas");
1259
1259
  return r.width = e, r.height = t, r;
1260
1260
  }
1261
- function fn() {
1262
- if (typeof document > "u" || le) return;
1263
- le = !0;
1264
- const e = Tt.getInstance();
1265
- for (const t of hn) {
1266
- const r = ce(Ct, Ct);
1261
+ function dn() {
1262
+ if (typeof document > "u" || ce) return;
1263
+ ce = !0;
1264
+ const e = vt.getInstance();
1265
+ for (const t of fn) {
1266
+ const r = he(Pt, Pt);
1267
1267
  if (!r) continue;
1268
1268
  const n = r.getContext("2d");
1269
1269
  if (!n) continue;
1270
- n.fillStyle = "white", t.draw(n, Ct);
1270
+ n.fillStyle = "white", t.draw(n, Pt);
1271
1271
  const o = r.toDataURL("image/png"), i = e.acquire(t.imageUrl);
1272
1272
  i.crossOrigin = "anonymous", i.src = o;
1273
- const s = ce(ot, ot);
1274
- if (s) {
1275
- const l = s.getContext("2d");
1276
- l && (l.fillStyle = "#1a1a2e", l.fillRect(0, 0, ot, ot), l.fillStyle = "white", t.draw(l, ot), t.thumbnailUrl = s.toDataURL("image/png"));
1273
+ const a = he(nt, nt);
1274
+ if (a) {
1275
+ const l = a.getContext("2d");
1276
+ l && (l.fillStyle = "#1a1a2e", l.fillRect(0, 0, nt, nt), l.fillStyle = "white", t.draw(l, nt), t.thumbnailUrl = a.toDataURL("image/png"));
1277
1277
  }
1278
1278
  }
1279
1279
  }
1280
- const dn = j("MaskRenderer"), Lt = /* @__PURE__ */ new Map(), un = /* @__PURE__ */ new Map();
1281
- function ro(e) {
1280
+ const un = j("MaskRenderer"), qt = /* @__PURE__ */ new Map(), gn = /* @__PURE__ */ new Map();
1281
+ function ao(e) {
1282
1282
  const t = [];
1283
- Lt.forEach((r, n) => {
1283
+ qt.forEach((r, n) => {
1284
1284
  n.startsWith(e) && t.push(n);
1285
- }), t.forEach((r) => Lt.delete(r));
1285
+ }), t.forEach((r) => qt.delete(r));
1286
1286
  }
1287
- function no() {
1288
- Lt.clear();
1287
+ function so() {
1288
+ qt.clear();
1289
1289
  }
1290
- function he(e, t, r) {
1290
+ function fe(e, t, r) {
1291
1291
  if (!t.masks || t.masks.length === 0) {
1292
1292
  r(e);
1293
1293
  return;
1294
1294
  }
1295
- const n = e.canvas, o = pt(n.width, n.height), i = o.getContext("2d");
1295
+ const n = e.canvas, o = mt(n.width, n.height), i = o.getContext("2d");
1296
1296
  if (!i) {
1297
- dn.error("[renderWithMasks] Failed to get offscreen context");
1297
+ un.error("[renderWithMasks] Failed to get offscreen context");
1298
1298
  return;
1299
1299
  }
1300
- const s = e.getTransform();
1301
- i.setTransform(s), r(i);
1300
+ const a = e.getTransform();
1301
+ i.setTransform(a), r(i);
1302
1302
  for (const l of t.masks)
1303
- gn(i, l, t);
1303
+ pn(i, l, t);
1304
1304
  e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(o, 0, 0), e.restore();
1305
1305
  }
1306
- function gn(e, t, r) {
1306
+ function pn(e, t, r) {
1307
1307
  switch (t.type) {
1308
1308
  case "clip":
1309
- pn(e, t, r);
1309
+ mn(e, t, r);
1310
1310
  break;
1311
1311
  case "alpha":
1312
- mn(e, t, r);
1312
+ yn(e, t, r);
1313
1313
  break;
1314
1314
  case "luma":
1315
- yn(e, t, r);
1315
+ wn(e, t, r);
1316
1316
  break;
1317
1317
  case "distress":
1318
- wn(e, t, r);
1318
+ bn(e, t, r);
1319
1319
  break;
1320
1320
  }
1321
1321
  }
1322
- function pn(e, t, r) {
1323
- e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), e.restore();
1324
- }
1325
1322
  function mn(e, t, r) {
1326
- e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 && He(e, t.feather), e.restore();
1323
+ e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), Mt(e, t.maskElement, r), e.restore();
1327
1324
  }
1328
1325
  function yn(e, t, r) {
1329
- const n = pt(e.canvas.width, e.canvas.height), o = n.getContext("2d");
1326
+ e.save(), e.globalCompositeOperation = t.inverted ? "destination-out" : "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), Mt(e, t.maskElement, r), t.feather && t.feather > 0 && je(e, t.feather), e.restore();
1327
+ }
1328
+ function wn(e, t, r) {
1329
+ const n = mt(e.canvas.width, e.canvas.height), o = n.getContext("2d");
1330
1330
  if (!o) return;
1331
- vt(o, t.maskElement, r);
1332
- const i = o.getImageData(0, 0, n.width, n.height), s = i.data;
1333
- for (let l = 0; l < s.length; l += 4) {
1334
- const a = s[l], c = s[l + 1], h = s[l + 2], f = 0.299 * a + 0.587 * c + 0.114 * h;
1335
- s[l + 3] = t.inverted ? 255 - f : f;
1331
+ Mt(o, t.maskElement, r);
1332
+ const i = o.getImageData(0, 0, n.width, n.height), a = i.data;
1333
+ for (let l = 0; l < a.length; l += 4) {
1334
+ const s = a[l], c = a[l + 1], h = a[l + 2], f = 0.299 * s + 0.587 * c + 0.114 * h;
1335
+ a[l + 3] = t.inverted ? 255 - f : f;
1336
1336
  }
1337
1337
  o.putImageData(i, 0, 0), e.save(), e.globalCompositeOperation = "destination-in", t.opacity !== void 0 && (e.globalAlpha = t.opacity), e.drawImage(n, 0, 0), e.restore();
1338
1338
  }
1339
- function wn(e, t, r) {
1340
- e.save(), e.globalCompositeOperation = t.inverted ? "destination-in" : "destination-out", t.opacity !== void 0 && (e.globalAlpha = t.opacity), vt(e, t.maskElement, r), t.feather && t.feather > 0 && He(e, t.feather), e.restore();
1339
+ function bn(e, t, r) {
1340
+ e.save(), e.globalCompositeOperation = t.inverted ? "destination-in" : "destination-out", t.opacity !== void 0 && (e.globalAlpha = t.opacity), Mt(e, t.maskElement, r), t.feather && t.feather > 0 && je(e, t.feather), e.restore();
1341
1341
  }
1342
1342
  function kn(e) {
1343
- const t = e.transformData, r = e, n = t && t.type === "image" ? rr(t, Se(e)) : null;
1343
+ const t = e.transformData, r = e, n = t && t.type === "image" ? nr(t, Se(e)) : null;
1344
1344
  return {
1345
1345
  width: (n == null ? void 0 : n.width) || (t == null ? void 0 : t.width) || r.width || 0,
1346
1346
  height: (n == null ? void 0 : n.height) || (t == null ? void 0 : t.height) || r.height || 0
1347
1347
  };
1348
1348
  }
1349
- function vt(e, t, r) {
1350
- const n = r.x || 0, o = r.y || 0, i = t.x || 0, s = t.y || 0, l = {
1349
+ function Mt(e, t, r) {
1350
+ const n = r.x || 0, o = r.y || 0, i = t.x || 0, a = t.y || 0, l = {
1351
1351
  ...t,
1352
1352
  x: n + i,
1353
- y: o + s,
1353
+ y: o + a,
1354
1354
  // Inherit parent rotation so mask rotates with the element
1355
1355
  rotation: (t.rotation || 0) + (r.rotation || 0)
1356
- }, a = 4, { width: c, height: h } = kn(r), f = t.transformData;
1356
+ }, s = 4, { width: c, height: h } = kn(r), f = t.transformData;
1357
1357
  c && h && f && (l.transformData = {
1358
1358
  ...f,
1359
- width: c + a,
1360
- height: h + a
1359
+ width: c + s,
1360
+ height: h + s
1361
1361
  });
1362
1362
  let u, d;
1363
1363
  if (t.transformType === "image") {
1364
- const w = t;
1365
- if (w.imageUrl)
1364
+ const b = t;
1365
+ if (b.imageUrl)
1366
1366
  if (typeof document < "u") {
1367
- w.imageUrl.startsWith("builtin-mask:") && fn();
1368
- const b = Tt.getInstance(), p = b.acquire(w.imageUrl);
1369
- p.complete && p.naturalWidth > 0 && (u = p), b.release(w.imageUrl);
1367
+ b.imageUrl.startsWith("builtin-mask:") && dn();
1368
+ const T = vt.getInstance(), g = T.acquire(b.imageUrl);
1369
+ g.complete && g.naturalWidth > 0 && (u = g), T.release(b.imageUrl);
1370
1370
  } else
1371
- d = un.get(w.imageUrl);
1371
+ d = gn.get(b.imageUrl);
1372
1372
  }
1373
- const m = l.transformData, g = (f == null ? void 0 : f.width) || 0, k = (f == null ? void 0 : f.height) || 0, T = g > 0 && k > 0 && c > 0 && h > 0 && Math.abs(g / k - c / h) > 1e-3;
1373
+ const p = l.transformData, m = (f == null ? void 0 : f.width) || 0, w = (f == null ? void 0 : f.height) || 0, k = m > 0 && w > 0 && c > 0 && h > 0 && Math.abs(m / w - c / h) > 1e-3;
1374
1374
  if (d) {
1375
1375
  e.save();
1376
- const w = (m == null ? void 0 : m.width) || d.width, b = (m == null ? void 0 : m.height) || d.height;
1377
- if (e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), T) {
1378
- const p = ie(
1379
- w,
1376
+ const b = (p == null ? void 0 : p.width) || d.width, T = (p == null ? void 0 : p.height) || d.height;
1377
+ if (e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), k) {
1378
+ const g = le(
1380
1379
  b,
1381
- g,
1382
- k,
1380
+ T,
1381
+ m,
1382
+ w,
1383
1383
  0
1384
1384
  );
1385
- e.drawImage(d, -p.width / 2, -p.height / 2, p.width, p.height);
1385
+ e.drawImage(d, -g.width / 2, -g.height / 2, g.width, g.height);
1386
1386
  } else
1387
- e.drawImage(d, -w / 2, -b / 2, w, b);
1387
+ e.drawImage(d, -b / 2, -T / 2, b, T);
1388
1388
  e.restore();
1389
- } else if (T && u) {
1390
- const w = (m == null ? void 0 : m.width) || c, b = (m == null ? void 0 : m.height) || h, p = ie(
1391
- w,
1389
+ } else if (k && u) {
1390
+ const b = (p == null ? void 0 : p.width) || c, T = (p == null ? void 0 : p.height) || h, g = le(
1392
1391
  b,
1393
- g,
1394
- k,
1392
+ T,
1393
+ m,
1394
+ w,
1395
1395
  0
1396
1396
  );
1397
- e.save(), e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), e.drawImage(u, -p.width / 2, -p.height / 2, p.width, p.height), e.restore();
1397
+ e.save(), e.translate(l.x || 0, l.y || 0), e.rotate(-(l.rotation || 0) * Math.PI / 180), e.drawImage(u, -g.width / 2, -g.height / 2, g.width, g.height), e.restore();
1398
1398
  } else
1399
- zt(e, l, { mode: "both", loadedImage: u });
1399
+ Zt(e, l, { mode: "both", loadedImage: u });
1400
1400
  }
1401
- function He(e, t) {
1401
+ function je(e, t) {
1402
1402
  "filter" in e && (e.filter = `blur(${t}px)`);
1403
1403
  }
1404
- function pt(e, t) {
1404
+ function mt(e, t) {
1405
1405
  if (typeof OffscreenCanvas < "u")
1406
1406
  return new OffscreenCanvas(e, t);
1407
1407
  if (typeof document < "u") {
@@ -1410,75 +1410,75 @@ function pt(e, t) {
1410
1410
  }
1411
1411
  throw new Error("No canvas context available");
1412
1412
  }
1413
- function bn(e, t, r, n) {
1413
+ function Tn(e, t, r, n) {
1414
1414
  if (!t.enabled || !t.imageUrl || t.opacity <= 0) return;
1415
- const o = Tt.getInstance(), i = o.acquire(t.imageUrl);
1415
+ const o = vt.getInstance(), i = o.acquire(t.imageUrl);
1416
1416
  if (!i.complete || i.naturalWidth === 0) {
1417
1417
  o.release(t.imageUrl);
1418
1418
  return;
1419
1419
  }
1420
- const { x: s, y: l, width: a, height: c } = r, h = e.getTransform(), f = h.a * s + h.e, u = h.d * l + h.f, d = h.a * a, m = h.d * c, g = Math.ceil(d), k = Math.ceil(m);
1421
- if (g <= 0 || k <= 0) {
1420
+ const { x: a, y: l, width: s, height: c } = r, h = e.getTransform(), f = h.a * a + h.e, u = h.d * l + h.f, d = h.a * s, p = h.d * c, m = Math.ceil(d), w = Math.ceil(p);
1421
+ if (m <= 0 || w <= 0) {
1422
1422
  o.release(t.imageUrl);
1423
1423
  return;
1424
1424
  }
1425
- const T = pt(g, k), w = T.getContext("2d");
1426
- if (!w) {
1425
+ const k = mt(m, w), b = k.getContext("2d");
1426
+ if (!b) {
1427
1427
  o.release(t.imageUrl);
1428
1428
  return;
1429
1429
  }
1430
- w.drawImage(
1430
+ b.drawImage(
1431
1431
  e.canvas,
1432
1432
  f,
1433
1433
  u,
1434
1434
  d,
1435
- m,
1435
+ p,
1436
1436
  0,
1437
1437
  0,
1438
- g,
1439
- k
1438
+ m,
1439
+ w
1440
1440
  );
1441
- let b;
1442
- if (t.maskType === "luma" ? b = "destination-in" : b = t.inverted ? "destination-out" : "destination-in", t.maskType === "luma") {
1443
- const p = pt(g, k), y = p.getContext("2d");
1441
+ let T;
1442
+ if (t.maskType === "luma" ? T = "destination-in" : T = t.inverted ? "destination-out" : "destination-in", t.maskType === "luma") {
1443
+ const g = mt(m, w), y = g.getContext("2d");
1444
1444
  if (y) {
1445
- y.drawImage(i, 0, 0, g, k);
1446
- const C = y.getImageData(0, 0, g, k), M = C.data;
1447
- for (let S = 0; S < M.length; S += 4) {
1448
- const P = 0.299 * M[S] + 0.587 * M[S + 1] + 0.114 * M[S + 2];
1449
- M[S + 3] = t.inverted ? 255 - P : P;
1445
+ y.drawImage(i, 0, 0, m, w);
1446
+ const S = y.getImageData(0, 0, m, w), C = S.data;
1447
+ for (let P = 0; P < C.length; P += 4) {
1448
+ const I = 0.299 * C[P] + 0.587 * C[P + 1] + 0.114 * C[P + 2];
1449
+ C[P + 3] = t.inverted ? 255 - I : I;
1450
1450
  }
1451
- y.putImageData(C, 0, 0), w.globalCompositeOperation = "destination-in", w.globalAlpha = t.opacity / 100, w.drawImage(p, 0, 0);
1451
+ y.putImageData(S, 0, 0), b.globalCompositeOperation = "destination-in", b.globalAlpha = t.opacity / 100, b.drawImage(g, 0, 0);
1452
1452
  }
1453
1453
  } else
1454
- w.globalCompositeOperation = b, w.globalAlpha = t.opacity / 100, w.drawImage(i, 0, 0, g, k);
1455
- w.globalCompositeOperation = "source-over", w.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(f, u, d, m), n && (e.fillStyle = n, e.fillRect(f, u, d, m)), e.drawImage(T, f, u), e.restore(), o.release(t.imageUrl);
1454
+ b.globalCompositeOperation = T, b.globalAlpha = t.opacity / 100, b.drawImage(i, 0, 0, m, w);
1455
+ b.globalCompositeOperation = "source-over", b.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(f, u, d, p), n && (e.fillStyle = n, e.fillRect(f, u, d, p)), e.drawImage(k, f, u), e.restore(), o.release(t.imageUrl);
1456
1456
  }
1457
- function Tn(e) {
1457
+ function vn(e) {
1458
1458
  var t;
1459
- return e ? ((t = e.shadow) == null ? void 0 : t.enabled) === !0 || Me(e.blendMode) : !1;
1459
+ return e ? ((t = e.shadow) == null ? void 0 : t.enabled) === !0 || Ce(e.blendMode) : !1;
1460
1460
  }
1461
- function fe(e, t, r) {
1461
+ function Mn(e, t, r) {
1462
1462
  var c;
1463
- if (!Tn(t)) {
1463
+ if (!vn(t)) {
1464
1464
  r(e);
1465
1465
  return;
1466
1466
  }
1467
- const n = (c = t.shadow) != null && c.enabled ? t.shadow : void 0, o = Me(t.blendMode) ? t.blendMode : void 0, i = e.canvas, s = e.getTransform(), l = En(i.width, i.height), a = l.getContext("2d");
1468
- if (!a)
1467
+ const n = (c = t.shadow) != null && c.enabled ? t.shadow : void 0, o = Ce(t.blendMode) ? t.blendMode : void 0, i = e.canvas, a = e.getTransform(), l = Sn(i.width, i.height), s = l.getContext("2d");
1468
+ if (!s)
1469
1469
  throw new Error(
1470
1470
  "[canvas] renderWithLayerEffects: could not acquire a 2D context for the layer-effects raster"
1471
1471
  );
1472
- if (a.setTransform(s), r(a), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), o && (e.globalCompositeOperation = o), n) {
1473
- const h = Math.hypot(s.a, s.b) || 1, f = i.width + 1;
1474
- e.save(), e.globalAlpha = e.globalAlpha * vn(n.opacity ?? 1), e.shadowColor = n.color, e.shadowBlur = n.blur * h, e.shadowOffsetX = n.offsetX * h + f, e.shadowOffsetY = n.offsetY * h, e.drawImage(l, -f, 0), e.restore();
1472
+ if (s.setTransform(a), r(s), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), o && (e.globalCompositeOperation = o), n) {
1473
+ const h = Math.hypot(a.a, a.b) || 1, f = i.width + 1;
1474
+ e.save(), e.globalAlpha = e.globalAlpha * En(n.opacity ?? 1), e.shadowColor = n.color, e.shadowBlur = n.blur * h, e.shadowOffsetX = n.offsetX * h + f, e.shadowOffsetY = n.offsetY * h, e.drawImage(l, -f, 0), e.restore();
1475
1475
  }
1476
1476
  e.drawImage(l, 0, 0), e.restore();
1477
1477
  }
1478
- function vn(e) {
1478
+ function En(e) {
1479
1479
  return Math.min(1, Math.max(0, e));
1480
1480
  }
1481
- function En(e, t) {
1481
+ function Sn(e, t) {
1482
1482
  if (typeof OffscreenCanvas < "u")
1483
1483
  return new OffscreenCanvas(e, t);
1484
1484
  if (typeof document < "u") {
@@ -1487,7 +1487,7 @@ function En(e, t) {
1487
1487
  }
1488
1488
  throw new Error("No canvas context available");
1489
1489
  }
1490
- class Sn {
1490
+ class Cn {
1491
1491
  constructor(t = Math.random()) {
1492
1492
  this.perm = [];
1493
1493
  for (let n = 0; n < 256; n++)
@@ -1511,73 +1511,73 @@ class Sn {
1511
1511
  return r + t * (n - r);
1512
1512
  }
1513
1513
  grad(t, r, n) {
1514
- const o = t & 15, i = o < 8 ? r : n, s = o < 4 ? n : o === 12 || o === 14 ? r : 0;
1515
- return ((o & 1) === 0 ? i : -i) + ((o & 2) === 0 ? s : -s);
1514
+ const o = t & 15, i = o < 8 ? r : n, a = o < 4 ? n : o === 12 || o === 14 ? r : 0;
1515
+ return ((o & 1) === 0 ? i : -i) + ((o & 2) === 0 ? a : -a);
1516
1516
  }
1517
1517
  noise(t, r) {
1518
1518
  const n = Math.floor(t) & 255, o = Math.floor(r) & 255;
1519
1519
  t -= Math.floor(t), r -= Math.floor(r);
1520
- const i = this.fade(t), s = this.fade(r), l = this.perm[n] + o, a = this.perm[n + 1] + o;
1520
+ const i = this.fade(t), a = this.fade(r), l = this.perm[n] + o, s = this.perm[n + 1] + o;
1521
1521
  return this.lerp(
1522
- s,
1523
- this.lerp(i, this.grad(this.perm[l], t, r), this.grad(this.perm[a], t - 1, r)),
1524
- this.lerp(i, this.grad(this.perm[l + 1], t, r - 1), this.grad(this.perm[a + 1], t - 1, r - 1))
1522
+ a,
1523
+ this.lerp(i, this.grad(this.perm[l], t, r), this.grad(this.perm[s], t - 1, r)),
1524
+ this.lerp(i, this.grad(this.perm[l + 1], t, r - 1), this.grad(this.perm[s + 1], t - 1, r - 1))
1525
1525
  );
1526
1526
  }
1527
1527
  }
1528
- function Pt(e, t, r, n = Date.now()) {
1529
- const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a = new Sn(n), c = 0.02, h = 1 - r / 100;
1528
+ function It(e, t, r, n = Date.now()) {
1529
+ const a = Et(e, t).getContext("2d").createImageData(e, t), l = a.data, s = new Cn(n), c = 0.02, h = 1 - r / 100;
1530
1530
  for (let f = 0; f < t; f++)
1531
1531
  for (let u = 0; u < e; u++) {
1532
1532
  const d = (f * e + u) * 4;
1533
- let m = 0;
1534
- m += a.noise(u * c, f * c) * 0.5, m += a.noise(u * c * 2, f * c * 2) * 0.25, m += a.noise(u * c * 4, f * c * 4) * 0.125, m = (m + 1) / 2;
1535
- const g = Math.min(u / e, (e - u) / e) * 2, k = Math.min(f / t, (t - f) / t) * 2, T = Math.min(g, k);
1536
- m *= 0.7 + T * 0.3;
1537
- const w = m > h ? 255 : 0;
1538
- l[d] = 255, l[d + 1] = 255, l[d + 2] = 255, l[d + 3] = w;
1533
+ let p = 0;
1534
+ p += s.noise(u * c, f * c) * 0.5, p += s.noise(u * c * 2, f * c * 2) * 0.25, p += s.noise(u * c * 4, f * c * 4) * 0.125, p = (p + 1) / 2;
1535
+ const m = Math.min(u / e, (e - u) / e) * 2, w = Math.min(f / t, (t - f) / t) * 2, k = Math.min(m, w);
1536
+ p *= 0.7 + k * 0.3;
1537
+ const b = p > h ? 255 : 0;
1538
+ l[d] = 255, l[d + 1] = 255, l[d + 2] = 255, l[d + 3] = b;
1539
1539
  }
1540
- return s;
1540
+ return a;
1541
1541
  }
1542
- function Mn(e, t, r, n = Date.now()) {
1542
+ function Pn(e, t, r, n = Date.now()) {
1543
1543
  const i = Et(e, t).getContext("2d");
1544
1544
  i.clearRect(0, 0, e, t), i.strokeStyle = "#000000", i.lineWidth = 1 + r / 50, i.lineCap = "round";
1545
- const s = Zt(n), l = Math.floor(r / 100 * 30 + 5);
1546
- for (let a = 0; a < l; a++) {
1547
- const c = s() * e, h = s() * t;
1548
- qt(i, c, h, s() * Math.PI * 2, 50 + s() * 100, s, 0);
1545
+ const a = Dt(n), l = Math.floor(r / 100 * 30 + 5);
1546
+ for (let s = 0; s < l; s++) {
1547
+ const c = a() * e, h = a() * t;
1548
+ $t(i, c, h, a() * Math.PI * 2, 50 + a() * 100, a, 0);
1549
1549
  }
1550
1550
  return i.getImageData(0, 0, e, t);
1551
1551
  }
1552
- function qt(e, t, r, n, o, i, s) {
1553
- if (s > 3 || o < 10) return;
1554
- const l = t + Math.cos(n) * o, a = r + Math.sin(n) * o;
1555
- if (e.beginPath(), e.moveTo(t, r), e.lineTo(l, a), e.stroke(), i() > 0.5) {
1552
+ function $t(e, t, r, n, o, i, a) {
1553
+ if (a > 3 || o < 10) return;
1554
+ const l = t + Math.cos(n) * o, s = r + Math.sin(n) * o;
1555
+ if (e.beginPath(), e.moveTo(t, r), e.lineTo(l, s), e.stroke(), i() > 0.5) {
1556
1556
  const c = n + (i() - 0.5) * Math.PI / 2;
1557
- qt(e, l, a, c, o * 0.6, i, s + 1);
1557
+ $t(e, l, s, c, o * 0.6, i, a + 1);
1558
1558
  }
1559
1559
  if (i() > 0.7) {
1560
1560
  const c = n - (i() - 0.5) * Math.PI / 2;
1561
- qt(e, l, a, c, o * 0.6, i, s + 1);
1561
+ $t(e, l, s, c, o * 0.6, i, a + 1);
1562
1562
  }
1563
1563
  }
1564
- function gt(e, t, r, n = Date.now()) {
1565
- const s = Et(e, t).getContext("2d").createImageData(e, t), l = s.data, a = Zt(n), c = r / 100 * 0.5;
1564
+ function ut(e, t, r, n = Date.now()) {
1565
+ const a = Et(e, t).getContext("2d").createImageData(e, t), l = a.data, s = Dt(n), c = r / 100 * 0.5;
1566
1566
  for (let h = 0; h < t; h++)
1567
1567
  for (let f = 0; f < e; f++) {
1568
- const u = (h * e + f) * 4, m = a() < c ? 255 : 0;
1569
- l[u] = 0, l[u + 1] = 0, l[u + 2] = 0, l[u + 3] = m;
1568
+ const u = (h * e + f) * 4, p = s() < c ? 255 : 0;
1569
+ l[u] = 0, l[u + 1] = 0, l[u + 2] = 0, l[u + 3] = p;
1570
1570
  }
1571
- return s;
1571
+ return a;
1572
1572
  }
1573
- function Cn(e, t, r, n = Date.now()) {
1573
+ function In(e, t, r, n = Date.now()) {
1574
1574
  const i = Et(e, t).getContext("2d");
1575
1575
  i.fillStyle = "#000000";
1576
- const s = Zt(n), l = 4 + r / 100 * 6, a = l * 2;
1577
- for (let c = 0; c < t; c += a)
1578
- for (let h = 0; h < e; h += a)
1579
- if (s() < r / 100) {
1580
- const f = l * (0.5 + s() * 0.5);
1576
+ const a = Dt(n), l = 4 + r / 100 * 6, s = l * 2;
1577
+ for (let c = 0; c < t; c += s)
1578
+ for (let h = 0; h < e; h += s)
1579
+ if (a() < r / 100) {
1580
+ const f = l * (0.5 + a() * 0.5);
1581
1581
  i.beginPath(), i.arc(h, c, f / 2, 0, Math.PI * 2), i.fill();
1582
1582
  }
1583
1583
  return i.getImageData(0, 0, e, t);
@@ -1591,31 +1591,31 @@ function Et(e, t) {
1591
1591
  }
1592
1592
  throw new Error("No canvas context available");
1593
1593
  }
1594
- function Zt(e) {
1594
+ function Dt(e) {
1595
1595
  let t = Math.sin(e++) * 1e4;
1596
1596
  return () => (t = Math.sin(e++) * 1e4, t - Math.floor(t));
1597
1597
  }
1598
1598
  const H = 42, z = 512, Z = 64;
1599
- function $t(e) {
1599
+ function Ht(e) {
1600
1600
  const t = e.data;
1601
1601
  for (let r = 0; r < t.length; r += 4)
1602
1602
  t[r] = 255, t[r + 1] = 255, t[r + 2] = 255;
1603
1603
  return e;
1604
1604
  }
1605
- function Pn(e, t) {
1605
+ function An(e, t) {
1606
1606
  const r = e.data, n = t.data;
1607
1607
  for (let o = 0; o < r.length; o += 4)
1608
1608
  r[o] = 255, r[o + 1] = 255, r[o + 2] = 255, r[o + 3] = Math.min(255, r[o + 3] + n[o + 3]);
1609
1609
  return e;
1610
1610
  }
1611
- const In = [
1611
+ const Rn = [
1612
1612
  {
1613
1613
  id: "grunge-heavy",
1614
1614
  name: "Heavy Grunge",
1615
1615
  textureUrl: "builtin:grunge-heavy",
1616
1616
  thumbnailUrl: "",
1617
1617
  description: "Dense random splatters",
1618
- generate: (e, t) => gt(e, t, 80, H)
1618
+ generate: (e, t) => ut(e, t, 80, H)
1619
1619
  },
1620
1620
  {
1621
1621
  id: "grunge-fine",
@@ -1623,7 +1623,7 @@ const In = [
1623
1623
  textureUrl: "builtin:grunge-fine",
1624
1624
  thumbnailUrl: "",
1625
1625
  description: "Sparse fine grain",
1626
- generate: (e, t) => gt(e, t, 25, H + 1)
1626
+ generate: (e, t) => ut(e, t, 25, H + 1)
1627
1627
  },
1628
1628
  {
1629
1629
  id: "concrete",
@@ -1631,7 +1631,7 @@ const In = [
1631
1631
  textureUrl: "builtin:concrete",
1632
1632
  thumbnailUrl: "",
1633
1633
  description: "Rough surface via Perlin noise",
1634
- generate: (e, t) => Pt(e, t, 55, H + 2)
1634
+ generate: (e, t) => It(e, t, 55, H + 2)
1635
1635
  },
1636
1636
  {
1637
1637
  id: "paper",
@@ -1639,7 +1639,7 @@ const In = [
1639
1639
  textureUrl: "builtin:paper",
1640
1640
  thumbnailUrl: "",
1641
1641
  description: "Subtle aging",
1642
- generate: (e, t) => Pt(e, t, 20, H + 3)
1642
+ generate: (e, t) => It(e, t, 20, H + 3)
1643
1643
  },
1644
1644
  {
1645
1645
  id: "rust",
@@ -1648,8 +1648,8 @@ const In = [
1648
1648
  thumbnailUrl: "",
1649
1649
  description: "Noise + splatter combined",
1650
1650
  generate: (e, t) => {
1651
- const r = Pt(e, t, 45, H + 4), n = gt(e, t, 35, H + 5);
1652
- return Pn($t(r), $t(n));
1651
+ const r = It(e, t, 45, H + 4), n = ut(e, t, 35, H + 5);
1652
+ return An(Ht(r), Ht(n));
1653
1653
  }
1654
1654
  },
1655
1655
  {
@@ -1658,7 +1658,7 @@ const In = [
1658
1658
  textureUrl: "builtin:scratches",
1659
1659
  thumbnailUrl: "",
1660
1660
  description: "Branching crack lines",
1661
- generate: (e, t) => Mn(e, t, 55, H + 6)
1661
+ generate: (e, t) => Pn(e, t, 55, H + 6)
1662
1662
  },
1663
1663
  {
1664
1664
  id: "halftone",
@@ -1666,7 +1666,7 @@ const In = [
1666
1666
  textureUrl: "builtin:halftone",
1667
1667
  thumbnailUrl: "",
1668
1668
  description: "Dot grid pattern",
1669
- generate: (e, t) => Cn(e, t, 55, H + 7)
1669
+ generate: (e, t) => In(e, t, 55, H + 7)
1670
1670
  },
1671
1671
  {
1672
1672
  id: "spray",
@@ -1674,11 +1674,11 @@ const In = [
1674
1674
  textureUrl: "builtin:spray",
1675
1675
  thumbnailUrl: "",
1676
1676
  description: "Medium random splatter",
1677
- generate: (e, t) => gt(e, t, 55, H + 8)
1677
+ generate: (e, t) => ut(e, t, 55, H + 8)
1678
1678
  }
1679
1679
  ];
1680
1680
  let de = !1;
1681
- function An(e, t) {
1681
+ function Wn(e, t) {
1682
1682
  if (typeof OffscreenCanvas < "u")
1683
1683
  return new OffscreenCanvas(e, t);
1684
1684
  const r = document.createElement("canvas");
@@ -1689,7 +1689,7 @@ function ue(e, t) {
1689
1689
  const r = document.createElement("canvas");
1690
1690
  return r.width = e, r.height = t, r;
1691
1691
  }
1692
- function Rn(e) {
1692
+ function Fn(e) {
1693
1693
  const t = ue(e.width, e.height);
1694
1694
  if (!t) return "";
1695
1695
  const r = t.getContext("2d");
@@ -1700,25 +1700,25 @@ function Rn(e) {
1700
1700
  const o = n.getContext("2d");
1701
1701
  if (!o) return "";
1702
1702
  o.drawImage(t, 0, 0, e.width, e.height, 0, 0, Z, Z);
1703
- const i = o.getImageData(0, 0, Z, Z), s = i.data;
1704
- for (let l = 0; l < s.length; l += 4) {
1705
- const a = s[l + 3], c = 255 - Math.round(a / 255 * 195);
1706
- s[l] = c, s[l + 1] = c, s[l + 2] = c, s[l + 3] = 255;
1703
+ const i = o.getImageData(0, 0, Z, Z), a = i.data;
1704
+ for (let l = 0; l < a.length; l += 4) {
1705
+ const s = a[l + 3], c = 255 - Math.round(s / 255 * 195);
1706
+ a[l] = c, a[l + 1] = c, a[l + 2] = c, a[l + 3] = 255;
1707
1707
  }
1708
1708
  return o.putImageData(i, 0, 0), n.toDataURL("image/png");
1709
1709
  }
1710
- function Wn() {
1710
+ function Un() {
1711
1711
  if (!de) {
1712
1712
  de = !0;
1713
- for (const e of In) {
1713
+ for (const e of Rn) {
1714
1714
  const t = e.generate(z, z);
1715
- $t(t);
1716
- const r = An(z, z), n = r.getContext("2d");
1717
- n && (n.putImageData(t, 0, 0), Fn(e.textureUrl, r, z, z)), typeof document < "u" && (e.thumbnailUrl = Rn(t));
1715
+ Ht(t);
1716
+ const r = Wn(z, z), n = r.getContext("2d");
1717
+ n && (n.putImageData(t, 0, 0), Bn(e.textureUrl, r, z, z)), typeof document < "u" && (e.thumbnailUrl = Fn(t));
1718
1718
  }
1719
1719
  }
1720
1720
  }
1721
- const N = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Map(), mt = /* @__PURE__ */ new Map();
1721
+ const N = /* @__PURE__ */ new Set(), X = /* @__PURE__ */ new Map(), yt = /* @__PURE__ */ new Map();
1722
1722
  function ge(e, t) {
1723
1723
  if (typeof OffscreenCanvas < "u")
1724
1724
  return new OffscreenCanvas(e, t);
@@ -1732,74 +1732,74 @@ function me(e) {
1732
1732
  const { width: t, height: r } = e, n = ge(t, r), o = pe(n);
1733
1733
  if (!o) throw new Error("Failed to get 2d context for temp canvas");
1734
1734
  o.drawImage(e, 0, 0);
1735
- const i = o.getImageData(0, 0, t, r), s = i.data;
1736
- for (let c = 0; c < s.length; c += 4) {
1737
- const h = s[c], f = s[c + 1], u = s[c + 2], m = 255 - (0.299 * h + 0.587 * f + 0.114 * u);
1738
- s[c] = 255, s[c + 1] = 255, s[c + 2] = 255, s[c + 3] = m;
1735
+ const i = o.getImageData(0, 0, t, r), a = i.data;
1736
+ for (let c = 0; c < a.length; c += 4) {
1737
+ const h = a[c], f = a[c + 1], u = a[c + 2], p = 255 - (0.299 * h + 0.587 * f + 0.114 * u);
1738
+ a[c] = 255, a[c + 1] = 255, a[c + 2] = 255, a[c + 3] = p;
1739
1739
  }
1740
- const l = ge(t, r), a = pe(l);
1741
- if (!a) throw new Error("Failed to get 2d context for mask canvas");
1742
- return a.putImageData(i, 0, 0), { alphaMask: l, width: t, height: r };
1740
+ const l = ge(t, r), s = pe(l);
1741
+ if (!s) throw new Error("Failed to get 2d context for mask canvas");
1742
+ return s.putImageData(i, 0, 0), { alphaMask: l, width: t, height: r };
1743
1743
  }
1744
- function je(e) {
1744
+ function _e(e) {
1745
1745
  const t = X.get(e);
1746
1746
  if (t) return t;
1747
1747
  if (e.startsWith("builtin:")) {
1748
- Wn();
1748
+ Un();
1749
1749
  const r = X.get(e);
1750
1750
  return r || null;
1751
1751
  }
1752
- return N.has(e) || (N.add(e), _e(e)), null;
1752
+ return N.has(e) || (N.add(e), Ne(e)), null;
1753
1753
  }
1754
- function oo(e) {
1754
+ function io(e) {
1755
1755
  return X.has(e) ? Promise.resolve() : new Promise((t) => {
1756
1756
  if (X.has(e)) {
1757
1757
  t();
1758
1758
  return;
1759
1759
  }
1760
- const r = mt.get(e) || [];
1761
- r.push(t), mt.set(e, r), N.has(e) || (N.add(e), _e(e));
1760
+ const r = yt.get(e) || [];
1761
+ r.push(t), yt.set(e, r), N.has(e) || (N.add(e), Ne(e));
1762
1762
  });
1763
1763
  }
1764
- function Fn(e, t, r, n) {
1765
- X.has(e) || (X.set(e, { alphaMask: t, width: r, height: n }), st(e));
1764
+ function Bn(e, t, r, n) {
1765
+ X.has(e) || (X.set(e, { alphaMask: t, width: r, height: n }), ot(e));
1766
1766
  }
1767
- function st(e) {
1768
- const t = mt.get(e);
1769
- t && (t.forEach((r) => r()), mt.delete(e));
1767
+ function ot(e) {
1768
+ const t = yt.get(e);
1769
+ t && (t.forEach((r) => r()), yt.delete(e));
1770
1770
  }
1771
- function _e(e) {
1771
+ function Ne(e) {
1772
1772
  if (typeof document < "u") {
1773
1773
  const t = new Image();
1774
1774
  t.crossOrigin = "anonymous", t.onload = () => {
1775
1775
  const r = me(t);
1776
- X.set(e, r), N.delete(e), st(e);
1776
+ X.set(e, r), N.delete(e), ot(e);
1777
1777
  }, t.onerror = () => {
1778
- N.delete(e), st(e);
1778
+ N.delete(e), ot(e);
1779
1779
  }, t.src = e;
1780
1780
  } else
1781
1781
  fetch(e).then((t) => t.blob()).then((t) => createImageBitmap(t)).then((t) => {
1782
1782
  const r = me(t);
1783
- X.set(e, r), N.delete(e), st(e);
1783
+ X.set(e, r), N.delete(e), ot(e);
1784
1784
  }).catch(() => {
1785
- N.delete(e), st(e);
1785
+ N.delete(e), ot(e);
1786
1786
  });
1787
1787
  }
1788
- function Ne(e, t) {
1788
+ function Xe(e, t) {
1789
1789
  if (typeof OffscreenCanvas < "u")
1790
1790
  return new OffscreenCanvas(e, t);
1791
1791
  const r = document.createElement("canvas");
1792
1792
  return r.width = e, r.height = t, r;
1793
1793
  }
1794
- function Un(e, t, r, n) {
1794
+ function On(e, t, r, n) {
1795
1795
  if (!t.enabled || !t.textureUrl || t.intensity <= 0) return;
1796
- const o = je(t.textureUrl);
1796
+ const o = _e(t.textureUrl);
1797
1797
  if (!o) return;
1798
- const { x: i, y: s, width: l, height: a } = r, c = e.getTransform(), h = c.a * i + c.e, f = c.d * s + c.f, u = c.a * l, d = c.d * a, m = Math.ceil(u), g = Math.ceil(d);
1799
- if (m <= 0 || g <= 0) return;
1800
- const k = Ne(m, g), T = k.getContext("2d");
1801
- if (!T) return;
1802
- T.drawImage(
1798
+ const { x: i, y: a, width: l, height: s } = r, c = e.getTransform(), h = c.a * i + c.e, f = c.d * a + c.f, u = c.a * l, d = c.d * s, p = Math.ceil(u), m = Math.ceil(d);
1799
+ if (p <= 0 || m <= 0) return;
1800
+ const w = Xe(p, m), k = w.getContext("2d");
1801
+ if (!k) return;
1802
+ k.drawImage(
1803
1803
  e.canvas,
1804
1804
  h,
1805
1805
  f,
@@ -1807,70 +1807,70 @@ function Un(e, t, r, n) {
1807
1807
  d,
1808
1808
  0,
1809
1809
  0,
1810
- m,
1811
- g
1810
+ p,
1811
+ m
1812
1812
  );
1813
- const w = o.alphaMask.getContext("2d");
1814
- if (w) {
1815
- const b = t.intensity / 100, p = w.getImageData(0, 0, o.width, o.height).data, y = o.width, C = o.height, M = T.getImageData(0, 0, m, g), S = M.data;
1816
- for (let P = 0; P < g; P++) {
1817
- const v = Math.floor(P / g * C);
1818
- for (let A = 0; A < m; A++) {
1819
- const I = Math.floor(A / m * y), E = p[(v * y + I) * 4 + 3] / 255, R = (P * m + A) * 4;
1820
- S[R + 3] = Math.round(S[R + 3] * (1 - E * b));
1813
+ const b = o.alphaMask.getContext("2d");
1814
+ if (b) {
1815
+ const T = t.intensity / 100, g = b.getImageData(0, 0, o.width, o.height).data, y = o.width, S = o.height, C = k.getImageData(0, 0, p, m), P = C.data;
1816
+ for (let I = 0; I < m; I++) {
1817
+ const M = Math.floor(I / m * S);
1818
+ for (let A = 0; A < p; A++) {
1819
+ const E = Math.floor(A / p * y), v = g[(M * y + E) * 4 + 3] / 255, R = (I * p + A) * 4;
1820
+ P[R + 3] = Math.round(P[R + 3] * (1 - v * T));
1821
1821
  }
1822
1822
  }
1823
- T.putImageData(M, 0, 0);
1823
+ k.putImageData(C, 0, 0);
1824
1824
  } else
1825
- T.globalCompositeOperation = "destination-out", T.globalAlpha = t.intensity / 100, T.drawImage(o.alphaMask, 0, 0, m, g), T.globalCompositeOperation = "source-over";
1826
- T.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(h, f, u, d), n && (e.fillStyle = n, e.fillRect(h, f, u, d)), e.drawImage(k, h, f), e.restore();
1825
+ k.globalCompositeOperation = "destination-out", k.globalAlpha = t.intensity / 100, k.drawImage(o.alphaMask, 0, 0, p, m), k.globalCompositeOperation = "source-over";
1826
+ k.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(h, f, u, d), n && (e.fillStyle = n, e.fillRect(h, f, u, d)), e.drawImage(w, h, f), e.restore();
1827
1827
  }
1828
1828
  function ye(e, t, r, n) {
1829
1829
  if (!t.enabled || t.style !== "custom" || !t.textureUrl) return;
1830
- const o = je(t.textureUrl);
1830
+ const o = _e(t.textureUrl);
1831
1831
  if (!o) {
1832
1832
  n(e);
1833
1833
  return;
1834
1834
  }
1835
- const i = t.textureOpacity ?? t.intensity / 100, s = e.getTransform(), l = Math.sqrt(r.width ** 2 + r.height ** 2), a = (l - r.width) / 2, c = (l - r.height) / 2, h = 20, f = a + h, u = c + h, d = {
1835
+ const i = t.textureOpacity ?? t.intensity / 100, a = e.getTransform(), l = Math.sqrt(r.width ** 2 + r.height ** 2), s = (l - r.width) / 2, c = (l - r.height) / 2, h = 20, f = s + h, u = c + h, d = {
1836
1836
  x: r.x - f,
1837
1837
  y: r.y - u,
1838
1838
  width: r.width + f * 2,
1839
1839
  height: r.height + u * 2
1840
- }, m = s.a * d.x + s.e, g = s.d * d.y + s.f, k = s.a * d.width, T = s.d * d.height, w = Math.ceil(k), b = Math.ceil(T);
1841
- if (w <= 0 || b <= 0) {
1840
+ }, p = a.a * d.x + a.e, m = a.d * d.y + a.f, w = a.a * d.width, k = a.d * d.height, b = Math.ceil(w), T = Math.ceil(k);
1841
+ if (b <= 0 || T <= 0) {
1842
1842
  n(e);
1843
1843
  return;
1844
1844
  }
1845
- const p = Ne(w, b), y = p.getContext("2d");
1845
+ const g = Xe(b, T), y = g.getContext("2d");
1846
1846
  if (!y) {
1847
1847
  n(e);
1848
1848
  return;
1849
1849
  }
1850
1850
  y.setTransform(
1851
- s.a,
1852
- s.b,
1853
- s.c,
1854
- s.d,
1855
- s.e - m,
1856
- s.f - g
1851
+ a.a,
1852
+ a.b,
1853
+ a.c,
1854
+ a.d,
1855
+ a.e - p,
1856
+ a.f - m
1857
1857
  ), n(y), y.setTransform(1, 0, 0, 1, 0, 0);
1858
- const C = o.alphaMask.getContext("2d");
1859
- if (C) {
1860
- const M = C.getImageData(0, 0, o.width, o.height).data, S = o.width, P = o.height, v = y.getImageData(0, 0, w, b), A = v.data;
1861
- for (let I = 0; I < b; I++) {
1862
- const E = Math.floor(I / b * P);
1863
- for (let R = 0; R < w; R++) {
1864
- const W = Math.floor(R / w * S), F = M[(E * S + W) * 4 + 3] / 255, U = (I * w + R) * 4;
1865
- A[U + 3] = Math.round(A[U + 3] * (1 - F * i));
1858
+ const S = o.alphaMask.getContext("2d");
1859
+ if (S) {
1860
+ const C = S.getImageData(0, 0, o.width, o.height).data, P = o.width, I = o.height, M = y.getImageData(0, 0, b, T), A = M.data;
1861
+ for (let E = 0; E < T; E++) {
1862
+ const v = Math.floor(E / T * I);
1863
+ for (let R = 0; R < b; R++) {
1864
+ const U = Math.floor(R / b * P), W = C[(v * P + U) * 4 + 3] / 255, F = (E * b + R) * 4;
1865
+ A[F + 3] = Math.round(A[F + 3] * (1 - W * i));
1866
1866
  }
1867
1867
  }
1868
- y.putImageData(v, 0, 0);
1868
+ y.putImageData(M, 0, 0);
1869
1869
  } else
1870
- y.globalCompositeOperation = "destination-out", y.globalAlpha = i, y.drawImage(o.alphaMask, 0, 0, w, b), y.globalCompositeOperation = "source-over", y.globalAlpha = 1;
1871
- e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(p, m, g), e.restore();
1870
+ y.globalCompositeOperation = "destination-out", y.globalAlpha = i, y.drawImage(o.alphaMask, 0, 0, b, T), y.globalCompositeOperation = "source-over", y.globalAlpha = 1;
1871
+ e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(g, p, m), e.restore();
1872
1872
  }
1873
- class yt {
1873
+ class wt {
1874
1874
  /**
1875
1875
  * Create an element instance from a JSON configuration
1876
1876
  * TypeScript ensures all transform types are handled
@@ -1883,33 +1883,33 @@ class yt {
1883
1883
  const { transformType: r } = t;
1884
1884
  switch (r) {
1885
1885
  case "custom":
1886
- return new fr(t);
1886
+ return new dr(t);
1887
1887
  case "distort":
1888
1888
  throw new Error("DistortTransform is not yet implemented");
1889
1889
  case "circle":
1890
- return new hr(t);
1890
+ return new fr(t);
1891
1891
  case "lean":
1892
- return new cr(t);
1892
+ return new hr(t);
1893
1893
  case "arch":
1894
- return new lr(t);
1894
+ return new cr(t);
1895
1895
  case "ascend":
1896
- return new ir(t);
1896
+ return new lr(t);
1897
1897
  case "wave":
1898
- return new ar(t);
1898
+ return new ir(t);
1899
1899
  case "flag":
1900
1900
  return new sr(t);
1901
1901
  case "image":
1902
- return new At(t);
1902
+ return new Wt(t);
1903
1903
  case "group": {
1904
1904
  const o = (t.children || []).map(
1905
- (a) => yt.createFromJSON(a)
1906
- ), { children: i, ...s } = t, l = new Yt(s);
1907
- return o.forEach((a) => l.addChild(a)), l;
1905
+ (s) => wt.createFromJSON(s)
1906
+ ), { children: i, ...a } = t, l = new Vt(a);
1907
+ return o.forEach((s) => l.addChild(s)), l;
1908
1908
  }
1909
1909
  case "shape":
1910
- return new or(t);
1910
+ return new ar(t);
1911
1911
  case "path":
1912
- return new nr(t);
1912
+ return new or(t);
1913
1913
  default:
1914
1914
  const n = r;
1915
1915
  throw new Error(`Unknown transform type: ${n}`);
@@ -2123,7 +2123,7 @@ class yt {
2123
2123
  return this.createFromJSON(r);
2124
2124
  }
2125
2125
  }
2126
- const we = j("ImportManager"), xt = class xt {
2126
+ const we = j("ImportManager"), te = class te {
2127
2127
  /**
2128
2128
  * Import workspace from JSON file
2129
2129
  */
@@ -2137,24 +2137,24 @@ const we = j("ImportManager"), xt = class xt {
2137
2137
  if (n.metadata.version === "1.0.0")
2138
2138
  return this.migrateV1Document(n);
2139
2139
  const o = [], i = [];
2140
- return n.artboards.forEach((s) => {
2141
- const l = ee.fromJSON({
2142
- id: s.id,
2143
- name: s.name,
2144
- x: s.x,
2145
- y: s.y,
2146
- width: s.width,
2147
- height: s.height,
2148
- backgroundColor: s.backgroundColor,
2149
- elementIds: s.elements.map((c) => c.id || "")
2150
- }), a = s.elements.map((c) => {
2140
+ return n.artboards.forEach((a) => {
2141
+ const l = re.fromJSON({
2142
+ id: a.id,
2143
+ name: a.name,
2144
+ x: a.x,
2145
+ y: a.y,
2146
+ width: a.width,
2147
+ height: a.height,
2148
+ backgroundColor: a.backgroundColor,
2149
+ elementIds: a.elements.map((c) => c.id || "")
2150
+ }), s = a.elements.map((c) => {
2151
2151
  try {
2152
- return yt.createFromJSON(c);
2152
+ return wt.createFromJSON(c);
2153
2153
  } catch (h) {
2154
2154
  return we.error("Failed to create element:", c, h), null;
2155
2155
  }
2156
2156
  }).filter((c) => c !== null);
2157
- o.push(l), i.push(...a);
2157
+ o.push(l), i.push(...s);
2158
2158
  }), await this.preloadAllImages(i), {
2159
2159
  success: !0,
2160
2160
  artboards: o,
@@ -2174,7 +2174,7 @@ const we = j("ImportManager"), xt = class xt {
2174
2174
  static async migrateV1Document(t) {
2175
2175
  var r, n, o;
2176
2176
  try {
2177
- const i = t.elements || [], s = new ee({
2177
+ const i = t.elements || [], a = new re({
2178
2178
  id: "artboard-migrated",
2179
2179
  name: "Artboard 1",
2180
2180
  x: 0,
@@ -2182,20 +2182,20 @@ const we = j("ImportManager"), xt = class xt {
2182
2182
  width: ((r = t.canvas) == null ? void 0 : r.width) || 1920,
2183
2183
  height: ((n = t.canvas) == null ? void 0 : n.height) || 1080,
2184
2184
  backgroundColor: ((o = t.canvas) == null ? void 0 : o.backgroundColor) || "#ffffff"
2185
- }), l = i.map((a) => {
2185
+ }), l = i.map((s) => {
2186
2186
  try {
2187
- return yt.createFromJSON(a);
2187
+ return wt.createFromJSON(s);
2188
2188
  } catch (c) {
2189
- return we.error("Failed to create element:", a, c), null;
2189
+ return we.error("Failed to create element:", s, c), null;
2190
2190
  }
2191
- }).filter((a) => a !== null);
2192
- return l.forEach((a) => {
2193
- s.addElementId(a.id);
2191
+ }).filter((s) => s !== null);
2192
+ return l.forEach((s) => {
2193
+ a.addElementId(s.id);
2194
2194
  }), await this.preloadAllImages(l), {
2195
2195
  success: !0,
2196
- artboards: [s],
2196
+ artboards: [a],
2197
2197
  elements: l,
2198
- activeArtboardId: s.id
2198
+ activeArtboardId: a.id
2199
2199
  };
2200
2200
  } catch (i) {
2201
2201
  return {
@@ -2252,8 +2252,8 @@ const we = j("ImportManager"), xt = class xt {
2252
2252
  return new Promise((r, n) => {
2253
2253
  const o = new FileReader();
2254
2254
  o.onload = (i) => {
2255
- var s;
2256
- return r((s = i.target) == null ? void 0 : s.result);
2255
+ var a;
2256
+ return r((a = i.target) == null ? void 0 : a.result);
2257
2257
  }, o.onerror = () => n(new Error("Failed to read file")), o.readAsText(t);
2258
2258
  });
2259
2259
  }
@@ -2264,8 +2264,8 @@ const we = j("ImportManager"), xt = class xt {
2264
2264
  return new Promise((r, n) => {
2265
2265
  const o = new FileReader();
2266
2266
  o.onload = (i) => {
2267
- var s;
2268
- return r((s = i.target) == null ? void 0 : s.result);
2267
+ var a;
2268
+ return r((a = i.target) == null ? void 0 : a.result);
2269
2269
  }, o.onerror = () => n(new Error("Failed to read file")), o.readAsDataURL(t);
2270
2270
  });
2271
2271
  }
@@ -2285,15 +2285,15 @@ const we = j("ImportManager"), xt = class xt {
2285
2285
  */
2286
2286
  static validateImportedData(t, r) {
2287
2287
  const n = [], o = /* @__PURE__ */ new Set();
2288
- t.forEach((s) => {
2289
- o.has(s.id) && n.push(`Duplicate artboard ID: ${s.id}`), o.add(s.id);
2288
+ t.forEach((a) => {
2289
+ o.has(a.id) && n.push(`Duplicate artboard ID: ${a.id}`), o.add(a.id);
2290
2290
  });
2291
2291
  const i = /* @__PURE__ */ new Set();
2292
- return r.forEach((s) => {
2293
- i.has(s.id) && n.push(`Duplicate element ID: ${s.id}`), i.add(s.id);
2294
- }), t.forEach((s) => {
2295
- s.getElementIds().forEach((l) => {
2296
- i.has(l) || n.push(`Artboard "${s.name}" references missing element: ${l}`);
2292
+ return r.forEach((a) => {
2293
+ i.has(a.id) && n.push(`Duplicate element ID: ${a.id}`), i.add(a.id);
2294
+ }), t.forEach((a) => {
2295
+ a.getElementIds().forEach((l) => {
2296
+ i.has(l) || n.push(`Artboard "${a.name}" references missing element: ${l}`);
2297
2297
  });
2298
2298
  }), {
2299
2299
  valid: n.length === 0,
@@ -2318,33 +2318,33 @@ const we = j("ImportManager"), xt = class xt {
2318
2318
  */
2319
2319
  static async preloadAllImages(t) {
2320
2320
  const r = [], n = (i) => {
2321
- i.transformType === "image" ? r.push(i) : i.transformType === "group" && "children" in i && i.children.forEach((s) => n(s));
2321
+ i.transformType === "image" ? r.push(i) : i.transformType === "group" && "children" in i && i.children.forEach((a) => n(a));
2322
2322
  };
2323
2323
  t.forEach(n);
2324
- const o = r.map((i) => new Promise((s) => {
2324
+ const o = r.map((i) => new Promise((a) => {
2325
2325
  if (i.imageLoaded)
2326
- s();
2326
+ a();
2327
2327
  else if (i.imageElement) {
2328
- const l = i.imageElement, a = () => {
2329
- l.removeEventListener("load", a), l.removeEventListener("error", c), s();
2328
+ const l = i.imageElement, s = () => {
2329
+ l.removeEventListener("load", s), l.removeEventListener("error", c), a();
2330
2330
  }, c = () => {
2331
- l.removeEventListener("load", a), l.removeEventListener("error", c), s();
2331
+ l.removeEventListener("load", s), l.removeEventListener("error", c), a();
2332
2332
  };
2333
- l.addEventListener("load", a), l.addEventListener("error", c);
2333
+ l.addEventListener("load", s), l.addEventListener("error", c);
2334
2334
  } else
2335
- s();
2335
+ a();
2336
2336
  }));
2337
2337
  await Promise.all(o);
2338
2338
  }
2339
2339
  };
2340
- xt.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
2341
- let ke = xt;
2342
- const be = j("element-serializer"), Xe = 4e3, ft = /* @__PURE__ */ new Set();
2343
- function Bn(e, t) {
2344
- const r = t ? On(t) : "no-src";
2340
+ te.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
2341
+ let be = te;
2342
+ const ke = j("element-serializer"), Ge = 4e3, ht = /* @__PURE__ */ new Set();
2343
+ function Ln(e, t) {
2344
+ const r = t ? qn(t) : "no-src";
2345
2345
  return `${e}:${r}`;
2346
2346
  }
2347
- function On(e) {
2347
+ function qn(e) {
2348
2348
  let t = 0;
2349
2349
  for (let r = 0; r < e.length; r++) {
2350
2350
  const n = e.charCodeAt(r);
@@ -2352,44 +2352,44 @@ function On(e) {
2352
2352
  }
2353
2353
  return t.toString(36);
2354
2354
  }
2355
- function Ht() {
2356
- ft.clear();
2355
+ function jt() {
2356
+ ht.clear();
2357
2357
  }
2358
- function Ge(e) {
2359
- for (const t of ft)
2360
- t.startsWith(`${e}:`) && ft.delete(t);
2358
+ function Ye(e) {
2359
+ for (const t of ht)
2360
+ t.startsWith(`${e}:`) && ht.delete(t);
2361
2361
  }
2362
- function Ln(e) {
2363
- ft.add(e);
2362
+ function $n(e) {
2363
+ ht.add(e);
2364
2364
  }
2365
- function qn(e) {
2366
- return ft.has(e);
2365
+ function Hn(e) {
2366
+ return ht.has(e);
2367
2367
  }
2368
- async function $n(e, t = Xe) {
2368
+ async function jn(e, t = Ge) {
2369
2369
  const { naturalWidth: r, naturalHeight: n } = e;
2370
2370
  if (r <= t && n <= t)
2371
2371
  return createImageBitmap(e);
2372
- const o = t / Math.max(r, n), i = Math.round(r * o), s = Math.round(n * o);
2372
+ const o = t / Math.max(r, n), i = Math.round(r * o), a = Math.round(n * o);
2373
2373
  return createImageBitmap(e, {
2374
2374
  resizeWidth: i,
2375
- resizeHeight: s,
2375
+ resizeHeight: a,
2376
2376
  resizeQuality: "high"
2377
2377
  });
2378
2378
  }
2379
- let wt = null, kt = null;
2380
- function Hn(e, t) {
2381
- wt = e, kt = t;
2379
+ let bt = null, kt = null;
2380
+ function _n(e, t) {
2381
+ bt = e, kt = t;
2382
2382
  }
2383
- function jn() {
2384
- wt = null, kt = null;
2383
+ function Nn() {
2384
+ bt = null, kt = null;
2385
2385
  }
2386
- function so() {
2387
- Ht(), wt && wt();
2386
+ function lo() {
2387
+ jt(), bt && bt();
2388
2388
  }
2389
- function ao(e) {
2390
- Ge(e), kt && kt(e);
2389
+ function co(e) {
2390
+ Ye(e), kt && kt(e);
2391
2391
  }
2392
- function jt(e, t) {
2392
+ function _t(e, t) {
2393
2393
  const r = e;
2394
2394
  if (typeof r.fontFamily == "string" && t.add(r.fontFamily), r.richText && typeof r.richText == "object") {
2395
2395
  const n = r.richText;
@@ -2397,21 +2397,21 @@ function jt(e, t) {
2397
2397
  for (const o of n.spans) {
2398
2398
  const i = o;
2399
2399
  if (i.style && typeof i.style == "object") {
2400
- const s = i.style;
2401
- typeof s.fontFamily == "string" && t.add(s.fontFamily);
2400
+ const a = i.style;
2401
+ typeof a.fontFamily == "string" && t.add(a.fontFamily);
2402
2402
  }
2403
2403
  }
2404
2404
  }
2405
2405
  if (r.children && Array.isArray(r.children))
2406
2406
  for (const n of r.children)
2407
- jt(n, t);
2407
+ _t(n, t);
2408
2408
  if (e.masks && Array.isArray(e.masks))
2409
2409
  for (const n of e.masks)
2410
- n.maskElement && jt(n.maskElement, t);
2410
+ n.maskElement && _t(n.maskElement, t);
2411
2411
  }
2412
2412
  function Te(e) {
2413
2413
  if (typeof document > "u") return e;
2414
- const t = Tt.getInstance();
2414
+ const t = vt.getInstance();
2415
2415
  return e.map((r) => {
2416
2416
  if (!(r != null && r.maskElement) || r.maskElement.transformType !== "image") return r;
2417
2417
  const n = r.maskElement.imageUrl;
@@ -2427,42 +2427,42 @@ function Te(e) {
2427
2427
  } : r;
2428
2428
  });
2429
2429
  }
2430
- async function _t(e, t, r = Xe) {
2431
- const n = t.filter((a) => e.hasElementId(a.id)), o = [], i = [], s = /* @__PURE__ */ new Set();
2432
- for (const a of n) {
2433
- if (a.visible === !1) continue;
2434
- const c = a.toJSON();
2435
- if (jt(c, s), a instanceof At && !a.imageElement) {
2436
- be.warn(`[element-serializer] Skipping image ${a.id}: image not loaded (state: ${a.imageLoadState})`);
2430
+ async function Nt(e, t, r = Ge) {
2431
+ const n = t.filter((s) => e.hasElementId(s.id)), o = [], i = [], a = /* @__PURE__ */ new Set();
2432
+ for (const s of n) {
2433
+ if (s.visible === !1) continue;
2434
+ const c = s.toJSON();
2435
+ if (_t(c, a), s instanceof Wt && !s.imageElement) {
2436
+ ke.warn(`[element-serializer] Skipping image ${s.id}: image not loaded (state: ${s.imageLoadState})`);
2437
2437
  continue;
2438
2438
  }
2439
- if (a instanceof At && a.imageElement)
2439
+ if (s instanceof Wt && s.imageElement)
2440
2440
  try {
2441
- const h = Bn(a.id, a.imageUrl);
2442
- if (!qn(h)) {
2443
- const p = await $n(a.imageElement, r);
2444
- i.push({ cacheKey: h, bitmap: p }), Ln(h);
2441
+ const h = Ln(s.id, s.imageUrl);
2442
+ if (!Hn(h)) {
2443
+ const g = await jn(s.imageElement, r);
2444
+ i.push({ cacheKey: h, bitmap: g }), $n(h);
2445
2445
  }
2446
- const u = a.transformData || {}, d = Se(c), m = dr(u, d), g = u.width * m.cropWidth, k = u.height * m.cropHeight, T = {
2447
- id: a.id,
2446
+ const u = s.transformData || {}, d = Se(c), p = ur(u, d), m = u.width * p.cropWidth, w = u.height * p.cropHeight, k = {
2447
+ id: s.id,
2448
2448
  type: "image",
2449
- x: a.x,
2450
- y: a.y,
2451
- width: g,
2452
- height: k,
2453
- rotation: a.rotation || 0,
2449
+ x: s.x,
2450
+ y: s.y,
2451
+ width: m,
2452
+ height: w,
2453
+ rotation: s.rotation || 0,
2454
2454
  bitmapCacheKey: h
2455
2455
  };
2456
- if (!ur(m)) {
2457
- const p = a.imageElement.naturalWidth, y = a.imageElement.naturalHeight;
2458
- let C = 1;
2459
- (p > r || y > r) && (C = r / Math.max(p, y)), T.cropX = m.cropX * p * C, T.cropY = m.cropY * y * C, T.cropWidth = m.cropWidth * p * C, T.cropHeight = m.cropHeight * y * C;
2456
+ if (!gr(p)) {
2457
+ const g = s.imageElement.naturalWidth, y = s.imageElement.naturalHeight;
2458
+ let S = 1;
2459
+ (g > r || y > r) && (S = r / Math.max(g, y)), k.cropX = p.cropX * g * S, k.cropY = p.cropY * y * S, k.cropWidth = p.cropWidth * g * S, k.cropHeight = p.cropHeight * y * S;
2460
2460
  }
2461
- u.flipHorizontal && (T.flipHorizontal = u.flipHorizontal), u.flipVertical && (T.flipVertical = u.flipVertical), u.borderRadius && (T.borderRadius = u.borderRadius), gr(u.adjustments) || (T.adjustments = { ...u.adjustments }), a.opacity !== void 0 && (T.opacity = a.opacity);
2462
- const b = T;
2463
- a.distressEffect && (b.distressEffect = { ...a.distressEffect }), c.masks && c.masks.length > 0 && (b.masks = Te(c.masks)), c.blendMode && (b.blendMode = c.blendMode), c.knockoutParts && (b.knockoutParts = c.knockoutParts), c.shadow && (b.shadow = { ...c.shadow }), "getVisualBoundingBox" in a && typeof a.getVisualBoundingBox == "function" ? b._boundingBox = a.getVisualBoundingBox() : "getBoundingBox" in a && typeof a.getBoundingBox == "function" && (b._boundingBox = a.getBoundingBox()), o.push(b);
2461
+ u.flipHorizontal && (k.flipHorizontal = u.flipHorizontal), u.flipVertical && (k.flipVertical = u.flipVertical), u.borderRadius && (k.borderRadius = u.borderRadius), pr(u.adjustments) || (k.adjustments = { ...u.adjustments }), s.opacity !== void 0 && (k.opacity = s.opacity);
2462
+ const T = k;
2463
+ s.distressEffect && (T.distressEffect = { ...s.distressEffect }), c.masks && c.masks.length > 0 && (T.masks = Te(c.masks)), c.blendMode && (T.blendMode = c.blendMode), c.knockoutParts && (T.knockoutParts = c.knockoutParts), c.shadow && (T.shadow = { ...c.shadow }), "getVisualBoundingBox" in s && typeof s.getVisualBoundingBox == "function" ? T._boundingBox = s.getVisualBoundingBox() : "getBoundingBox" in s && typeof s.getBoundingBox == "function" && (T._boundingBox = s.getBoundingBox()), o.push(T);
2464
2464
  } catch (h) {
2465
- be.error(`[element-serializer] Failed to create ImageBitmap for ${c.id}:`, h);
2465
+ ke.error(`[element-serializer] Failed to create ImageBitmap for ${c.id}:`, h);
2466
2466
  }
2467
2467
  else {
2468
2468
  const h = {
@@ -2470,19 +2470,19 @@ async function _t(e, t, r = Xe) {
2470
2470
  type: c.transformType
2471
2471
  // Map transformType to type for worker compatibility
2472
2472
  };
2473
- if (a instanceof Yt) {
2474
- const f = await _t(
2473
+ if (s instanceof Vt) {
2474
+ const f = await Nt(
2475
2475
  { ...e, hasElementId: () => !0 },
2476
- a.children,
2476
+ s.children,
2477
2477
  r
2478
2478
  );
2479
2479
  h.children = f.data.elements, i.push(...f.newBitmaps);
2480
- for (const u of f.data.fonts) s.add(u);
2480
+ for (const u of f.data.fonts) a.add(u);
2481
2481
  }
2482
- h.masks && Array.isArray(h.masks) && h.masks.length > 0 && (h.masks = Te(h.masks)), "getVisualBoundingBox" in a && typeof a.getVisualBoundingBox == "function" ? h._boundingBox = a.getVisualBoundingBox() : "getBoundingBox" in a && typeof a.getBoundingBox == "function" && (h._boundingBox = a.getBoundingBox()), o.push(h);
2482
+ h.masks && Array.isArray(h.masks) && h.masks.length > 0 && (h.masks = Te(h.masks)), "getVisualBoundingBox" in s && typeof s.getVisualBoundingBox == "function" ? h._boundingBox = s.getVisualBoundingBox() : "getBoundingBox" in s && typeof s.getBoundingBox == "function" && (h._boundingBox = s.getBoundingBox()), o.push(h);
2483
2483
  }
2484
2484
  }
2485
- const l = Array.from(s);
2485
+ const l = Array.from(a);
2486
2486
  return {
2487
2487
  data: {
2488
2488
  version: "1.0.0",
@@ -2504,7 +2504,7 @@ async function _t(e, t, r = Xe) {
2504
2504
  newBitmaps: i
2505
2505
  };
2506
2506
  }
2507
- async function _n(e, t, r = fetch) {
2507
+ async function Xn(e, t, r = fetch) {
2508
2508
  try {
2509
2509
  const n = await r(t.fontFileUrl, { mode: "cors" });
2510
2510
  if (!n.ok) return null;
@@ -2517,10 +2517,10 @@ async function _n(e, t, r = fetch) {
2517
2517
  function K(e) {
2518
2518
  return e.trim().toLowerCase();
2519
2519
  }
2520
- function Dt(e) {
2520
+ function xt(e) {
2521
2521
  return `${K(e.family)}|${e.weight ?? 400}|${e.style ?? "normal"}`;
2522
2522
  }
2523
- class Nn {
2523
+ class Gn {
2524
2524
  constructor() {
2525
2525
  this.fonts = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.snapshot = [], this.list = () => this.snapshot, this.subscribe = (t) => (this.listeners.add(t), () => {
2526
2526
  this.listeners.delete(t);
@@ -2533,7 +2533,7 @@ class Nn {
2533
2533
  register(t) {
2534
2534
  let r = !1;
2535
2535
  for (const n of t) {
2536
- const o = Dt(n), i = this.fonts.get(o);
2536
+ const o = xt(n), i = this.fonts.get(o);
2537
2537
  i && i.url === n.url && i.family === n.family || (this.fonts.set(o, { ...n }), r = !0);
2538
2538
  }
2539
2539
  if (r) {
@@ -2566,13 +2566,13 @@ class Nn {
2566
2566
  for (const t of this.listeners) t();
2567
2567
  }
2568
2568
  }
2569
- const Nt = new Nn();
2570
- function Xn(e) {
2571
- Nt.register(e);
2569
+ const Xt = new Gn();
2570
+ function Yn(e) {
2571
+ Xt.register(e);
2572
2572
  }
2573
- const Ye = /* @__PURE__ */ new Set();
2574
- async function Gn(e, t = {}) {
2575
- const r = await _n(
2573
+ const Ve = /* @__PURE__ */ new Set();
2574
+ async function Vn(e, t = {}) {
2575
+ const r = await Xn(
2576
2576
  e.family,
2577
2577
  {
2578
2578
  fontFileUrl: e.url,
@@ -2584,7 +2584,7 @@ async function Gn(e, t = {}) {
2584
2584
  t.fetchImpl ?? fetch
2585
2585
  );
2586
2586
  if (!r)
2587
- throw new Ce(
2587
+ throw new gt(
2588
2588
  "E_FONT_LOAD_FAILED",
2589
2589
  `Custom font "${e.family}" failed to load from ${e.url}. The URL must serve the font binary over a plain cross-origin GET (CORS). Verify the URL is reachable and sends Access-Control-Allow-Origin, then re-register the font. Custom fonts never fall back silently — the design would render with the wrong typeface.`,
2590
2590
  {
@@ -2595,18 +2595,18 @@ async function Gn(e, t = {}) {
2595
2595
  }
2596
2596
  );
2597
2597
  const n = t.fonts ?? (typeof document < "u" ? document.fonts : void 0);
2598
- return n == null || n.add(r), Ye.add(Dt(e)), r;
2598
+ return n == null || n.add(r), Ve.add(xt(e)), r;
2599
2599
  }
2600
- async function io(e, t = {}) {
2601
- Xn(e);
2600
+ async function ho(e, t = {}) {
2601
+ Yn(e);
2602
2602
  const { onLoadError: r, ...n } = t;
2603
2603
  await Promise.all(
2604
2604
  e.map(async (o) => {
2605
- if (!Ye.has(Dt(o)))
2605
+ if (!Ve.has(xt(o)))
2606
2606
  try {
2607
- await Gn(o, n);
2607
+ await Vn(o, n);
2608
2608
  } catch (i) {
2609
- if (r && i instanceof Ce) {
2609
+ if (r && i instanceof gt) {
2610
2610
  r(i, o);
2611
2611
  return;
2612
2612
  }
@@ -2616,13 +2616,13 @@ async function io(e, t = {}) {
2616
2616
  );
2617
2617
  }
2618
2618
  const O = j("WorkerExport");
2619
- let Xt = null, It = null;
2620
- function Yn() {
2621
- return It ?? (It = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-C6Zm9Wt-.js")).then((e) => Xt = e.default).catch((e) => {
2622
- throw It = null, e;
2623
- })), It;
2619
+ let Gt = null, At = null;
2620
+ function Jn() {
2621
+ return At ?? (At = (typeof window > "u" ? Promise.reject(new Error("The export worker runs in a browser page only (no window here).")) : import("./export-worker.bundle.string-C6Zm9Wt-.js")).then((e) => Gt = e.default).catch((e) => {
2622
+ throw At = null, e;
2623
+ })), At;
2624
2624
  }
2625
- class dt {
2625
+ class ft {
2626
2626
  constructor() {
2627
2627
  this.worker = null, this.workerBlobUrl = null, this.pendingRequests = /* @__PURE__ */ new Map(), this.requestQueue = [], this.blobRequestQueue = [], this.isProcessingQueue = !1, this.isReady = !1, this.readyPromise = null, this.initGeneration = 0, this.requestIdCounter = 0, this.workerCrashCount = 0, this.MAX_CRASHES_BEFORE_FALLBACK = 3, this.lastCrashTime = 0, this.CRASH_RESET_TIMEOUT = 6e4, this.progressListeners = /* @__PURE__ */ new Set(), this.idleTimeout = null, this.IDLE_TIMEOUT_MS = 3e4;
2628
2628
  }
@@ -2684,7 +2684,7 @@ class dt {
2684
2684
  * Call this when exiting editor mode to free memory.
2685
2685
  */
2686
2686
  clearWorkerBitmapCache() {
2687
- if (Ht(), this.worker && this.isReady) {
2687
+ if (jt(), this.worker && this.isReady) {
2688
2688
  const t = {
2689
2689
  type: "clear-all-bitmaps"
2690
2690
  };
@@ -2696,7 +2696,7 @@ class dt {
2696
2696
  * Call this when an element is removed or its image source changes.
2697
2697
  */
2698
2698
  clearWorkerBitmap(t) {
2699
- if (Ge(t), this.worker && this.isReady) {
2699
+ if (Ye(t), this.worker && this.isReady) {
2700
2700
  const r = {
2701
2701
  type: "clear-bitmap",
2702
2702
  elementId: t
@@ -2722,11 +2722,11 @@ class dt {
2722
2722
  return this.readyPromise || Promise.resolve();
2723
2723
  if (this.readyPromise)
2724
2724
  return this.readyPromise;
2725
- if (!dt.supportsWorkerExport())
2725
+ if (!ft.supportsWorkerExport())
2726
2726
  throw new Error("Browser does not support OffscreenCanvas or Web Workers");
2727
- if (Xt !== null)
2728
- return this.readyPromise = this.startWorker(Xt), this.readyPromise;
2729
- const t = this.initGeneration, r = Yn().then((n) => {
2727
+ if (Gt !== null)
2728
+ return this.readyPromise = this.startWorker(Gt), this.readyPromise;
2729
+ const t = this.initGeneration, r = Jn().then((n) => {
2730
2730
  if (t !== this.initGeneration)
2731
2731
  throw new Error("Worker terminated");
2732
2732
  return this.startWorker(n);
@@ -2754,13 +2754,13 @@ class dt {
2754
2754
  };
2755
2755
  const i = setTimeout(() => {
2756
2756
  n(new Error("Worker initialization timeout"));
2757
- }, 15e3), s = (l) => {
2758
- l.data.type === "ready" && (clearTimeout(i), this.isReady = !0, Hn(
2757
+ }, 15e3), a = (l) => {
2758
+ l.data.type === "ready" && (clearTimeout(i), this.isReady = !0, _n(
2759
2759
  () => this.clearWorkerBitmapCache(),
2760
- (a) => this.clearWorkerBitmap(a)
2760
+ (s) => this.clearWorkerBitmap(s)
2761
2761
  ), r());
2762
2762
  };
2763
- this.worker.addEventListener("message", s, { once: !0 });
2763
+ this.worker.addEventListener("message", a, { once: !0 });
2764
2764
  } catch (o) {
2765
2765
  O.error("Failed to create worker:", o), n(o);
2766
2766
  }
@@ -2832,8 +2832,8 @@ class dt {
2832
2832
  const { artboard: r, elements: n, config: o } = t;
2833
2833
  if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
2834
2834
  throw new Error("Worker is not initialized");
2835
- const i = `export-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await _t(r, n);
2836
- a.length > 0 && this.registerBitmapsWithWorker(a);
2835
+ const i = `export-${++this.requestIdCounter}-${Date.now()}`, a = performance.now(), { data: l, newBitmaps: s } = await Nt(r, n);
2836
+ s.length > 0 && this.registerBitmapsWithWorker(s);
2837
2837
  const c = {
2838
2838
  type: "export",
2839
2839
  requestId: i,
@@ -2843,23 +2843,23 @@ class dt {
2843
2843
  // Custom (brand) fonts among the used families — the worker loads
2844
2844
  // these from their hosted URL instead of Google Fonts (deterministic
2845
2845
  // shadowing; see utils/custom-fonts.ts).
2846
- customFonts: Nt.forFamilies(l.fonts ?? []),
2846
+ customFonts: Xt.forFamilies(l.fonts ?? []),
2847
2847
  scale: o.scale || 1,
2848
2848
  format: o.format || "png",
2849
2849
  quality: o.quality || 0.95
2850
- }, h = new Promise((m, g) => {
2850
+ }, h = new Promise((p, m) => {
2851
2851
  this.pendingRequests.set(i, {
2852
2852
  requestId: i,
2853
- resolve: m,
2854
- reject: g,
2855
- startTime: s,
2853
+ resolve: p,
2854
+ reject: m,
2855
+ startTime: a,
2856
2856
  returnFormat: "dataUrl"
2857
2857
  }), setTimeout(() => {
2858
- this.pendingRequests.has(i) && (this.pendingRequests.delete(i), g(new Error("Export request timeout")));
2858
+ this.pendingRequests.has(i) && (this.pendingRequests.delete(i), m(new Error("Export request timeout")));
2859
2859
  }, 3e4);
2860
2860
  });
2861
2861
  this.worker.postMessage(c);
2862
- const f = await h, d = performance.now() - s;
2862
+ const f = await h, d = performance.now() - a;
2863
2863
  return {
2864
2864
  dataUrl: f.dataUrl,
2865
2865
  artboardId: f.artboardId,
@@ -2893,8 +2893,8 @@ class dt {
2893
2893
  const { artboard: r, elements: n, config: o } = t;
2894
2894
  if ((!this.worker || !this.isReady) && await this.initialize(), !this.worker)
2895
2895
  throw new Error("Worker is not initialized");
2896
- const i = `export-blob-${++this.requestIdCounter}-${Date.now()}`, s = performance.now(), { data: l, newBitmaps: a } = await _t(r, n);
2897
- a.length > 0 && this.registerBitmapsWithWorker(a);
2896
+ const i = `export-blob-${++this.requestIdCounter}-${Date.now()}`, a = performance.now(), { data: l, newBitmaps: s } = await Nt(r, n);
2897
+ s.length > 0 && this.registerBitmapsWithWorker(s);
2898
2898
  const c = {
2899
2899
  type: "export",
2900
2900
  requestId: i,
@@ -2902,24 +2902,24 @@ class dt {
2902
2902
  elements: l.elements,
2903
2903
  fonts: l.fonts,
2904
2904
  // Same custom-font threading as the dataUrl path above.
2905
- customFonts: Nt.forFamilies(l.fonts ?? []),
2905
+ customFonts: Xt.forFamilies(l.fonts ?? []),
2906
2906
  scale: o.scale || 1,
2907
2907
  format: o.format || "png",
2908
2908
  quality: o.quality || 0.95,
2909
2909
  returnFormat: "blob"
2910
- }, h = new Promise((g, k) => {
2910
+ }, h = new Promise((m, w) => {
2911
2911
  this.pendingRequests.set(i, {
2912
2912
  requestId: i,
2913
- resolve: g,
2914
- reject: k,
2915
- startTime: s,
2913
+ resolve: m,
2914
+ reject: w,
2915
+ startTime: a,
2916
2916
  returnFormat: "blob"
2917
2917
  }), setTimeout(() => {
2918
- this.pendingRequests.has(i) && (this.pendingRequests.delete(i), k(new Error("Export request timeout")));
2918
+ this.pendingRequests.has(i) && (this.pendingRequests.delete(i), w(new Error("Export request timeout")));
2919
2919
  }, 3e4);
2920
2920
  });
2921
2921
  this.worker.postMessage(c);
2922
- const f = await h, d = performance.now() - s;
2922
+ const f = await h, d = performance.now() - a;
2923
2923
  return {
2924
2924
  blob: new Blob([f.blobData], { type: f.mimeType }),
2925
2925
  artboardId: f.artboardId,
@@ -3009,7 +3009,7 @@ class dt {
3009
3009
  r.reject(new Error("Worker terminated")), this.pendingRequests.delete(t);
3010
3010
  for (; this.requestQueue.length > 0; )
3011
3011
  this.requestQueue.shift().reject(new Error("Worker terminated"));
3012
- this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, Ht(), jn(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
3012
+ this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, jt(), Nn(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
3013
3013
  }
3014
3014
  }
3015
3015
  /**
@@ -3024,32 +3024,35 @@ class dt {
3024
3024
  };
3025
3025
  }
3026
3026
  }
3027
- let tt = null;
3028
- function lo() {
3029
- return tt || (tt = new dt()), tt;
3027
+ let x = null;
3028
+ function fo() {
3029
+ return x || (x = new ft()), x;
3030
3030
  }
3031
- function co() {
3032
- tt && (tt.terminate(), tt = null);
3031
+ function uo() {
3032
+ x && (x.terminate(), x = null);
3033
3033
  }
3034
- Qt();
3035
- const _ = j("Export");
3036
- function Gt(e, t) {
3034
+ zt();
3035
+ const _ = j("Export"), ve = (e) => e === "jpg" || e === "jpeg" ? "image/jpeg" : e === "webp" ? "image/webp" : "image/png", Me = (e, t, r) => new Promise((n) => e.toBlob((o) => n(o), t, r));
3036
+ function Rt(e) {
3037
+ e.width = 0, e.height = 0;
3038
+ }
3039
+ function Yt(e, t) {
3037
3040
  var r;
3038
3041
  if (!(!e || typeof e != "object")) {
3039
3042
  if (typeof e.fontFamily == "string" && e.fontFamily.trim() && t.add(e.fontFamily), e.richText && Array.isArray(e.richText.spans))
3040
3043
  for (const n of e.richText.spans)
3041
3044
  (r = n == null ? void 0 : n.style) != null && r.fontFamily && typeof n.style.fontFamily == "string" && t.add(n.style.fontFamily);
3042
3045
  if (Array.isArray(e.children))
3043
- for (const n of e.children) Gt(n, t);
3046
+ for (const n of e.children) Yt(n, t);
3044
3047
  if (Array.isArray(e.masks))
3045
3048
  for (const n of e.masks)
3046
- n != null && n.maskElement && Gt(n.maskElement, t);
3049
+ n != null && n.maskElement && Yt(n.maskElement, t);
3047
3050
  }
3048
3051
  }
3049
- async function ve(e) {
3052
+ async function Kn(e) {
3050
3053
  if (typeof document > "u" || !document.fonts) return;
3051
3054
  const t = /* @__PURE__ */ new Set();
3052
- for (const n of e) Gt(n, t);
3055
+ for (const n of e) Yt(n, t);
3053
3056
  if (t.size === 0) return;
3054
3057
  const r = [];
3055
3058
  for (const n of t)
@@ -3057,12 +3060,12 @@ async function ve(e) {
3057
3060
  }));
3058
3061
  await Promise.all(r), document.fonts.ready && await document.fonts.ready;
3059
3062
  }
3060
- const ct = class ct {
3063
+ const lt = class lt {
3061
3064
  /**
3062
3065
  * Check if worker export is supported in this browser
3063
3066
  */
3064
3067
  static supportsWorkerExport() {
3065
- return dt.supportsWorkerExport();
3068
+ return ft.supportsWorkerExport();
3066
3069
  }
3067
3070
  /**
3068
3071
  * Get or initialize the worker manager
@@ -3070,7 +3073,7 @@ const ct = class ct {
3070
3073
  static async getWorkerManager() {
3071
3074
  return this.supportsWorkerExport() ? this.workerManager ? this.workerManager : this.workerInitPromise ? (await this.workerInitPromise, this.workerManager) : (this.workerInitPromise = (async () => {
3072
3075
  try {
3073
- this.workerManager = new dt(), await this.workerManager.initialize();
3076
+ this.workerManager = new ft(), await this.workerManager.initialize();
3074
3077
  } catch (t) {
3075
3078
  _.error("Failed to initialize worker:", t), this.workerManager = null;
3076
3079
  }
@@ -3106,7 +3109,7 @@ const ct = class ct {
3106
3109
  };
3107
3110
  }),
3108
3111
  activeArtboardId: n.getActiveArtboardId()
3109
- }, s = JSON.stringify(i, null, 2), l = new Blob([s], { type: "application/json" }), a = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0], c = o || `canvas-${a}.json`;
3112
+ }, a = JSON.stringify(i, null, 2), l = new Blob([a], { type: "application/json" }), s = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0], c = o || `canvas-${s}.json`;
3110
3113
  this.downloadBlob(l, c);
3111
3114
  }
3112
3115
  /**
@@ -3116,21 +3119,21 @@ const ct = class ct {
3116
3119
  static async exportArtboardToImage(t, r, n, o = {}) {
3117
3120
  const {
3118
3121
  format: i = "png",
3119
- quality: s = 0.95,
3122
+ quality: a = 0.95,
3120
3123
  scale: l = 1,
3121
- transparentBackground: a = !1,
3124
+ transparentBackground: s = !1,
3122
3125
  backgroundColor: c = t.backgroundColor,
3123
3126
  filename: h,
3124
3127
  forceMainThread: f = !1
3125
3128
  } = o, u = await this.exportArtboardToDataURL(t, r, n, {
3126
3129
  format: i,
3127
- quality: s,
3130
+ quality: a,
3128
3131
  scale: l,
3129
- transparentBackground: a,
3132
+ transparentBackground: s,
3130
3133
  backgroundColor: c,
3131
3134
  forceMainThread: f
3132
- }), d = await this.dataUrlToBlob(u), m = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0], g = h || `${t.name}-${m}.${i}`;
3133
- this.downloadBlob(d, g);
3135
+ }), d = await this.dataUrlToBlob(u), p = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").split("T")[0], m = h || `${t.name}-${p}.${i}`;
3136
+ this.downloadBlob(d, m);
3134
3137
  }
3135
3138
  /**
3136
3139
  * Export artboard to data URL (for preview/testing)
@@ -3139,9 +3142,9 @@ const ct = class ct {
3139
3142
  static async exportArtboardToDataURL(t, r, n, o = {}) {
3140
3143
  const {
3141
3144
  format: i = "png",
3142
- quality: s = 0.95,
3145
+ quality: a = 0.95,
3143
3146
  scale: l = 1,
3144
- transparentBackground: a = !1,
3147
+ transparentBackground: s = !1,
3145
3148
  backgroundColor: c = t.backgroundColor,
3146
3149
  forceMainThread: h = !1
3147
3150
  } = o;
@@ -3149,11 +3152,11 @@ const ct = class ct {
3149
3152
  try {
3150
3153
  const f = await this.getWorkerManager();
3151
3154
  if (f) {
3152
- const u = new Set(t.getElementIds()), d = r.filter((g) => u.has(g.id));
3155
+ const u = new Set(t.getElementIds()), d = r.filter((m) => u.has(m.id));
3153
3156
  return (await f.exportArtboardToDataURL(t, d, {
3154
3157
  scale: l,
3155
3158
  format: i === "jpg" ? "jpeg" : i,
3156
- quality: s
3159
+ quality: a
3157
3160
  })).dataUrl;
3158
3161
  }
3159
3162
  } catch (f) {
@@ -3161,9 +3164,9 @@ const ct = class ct {
3161
3164
  }
3162
3165
  return this.mainThreadExportToDataURL(t, r, n, {
3163
3166
  format: i,
3164
- quality: s,
3167
+ quality: a,
3165
3168
  scale: l,
3166
- transparentBackground: a,
3169
+ transparentBackground: s,
3167
3170
  backgroundColor: c
3168
3171
  });
3169
3172
  }
@@ -3175,9 +3178,9 @@ const ct = class ct {
3175
3178
  static async exportArtboardToBlob(t, r, n, o = {}) {
3176
3179
  const {
3177
3180
  format: i = "png",
3178
- quality: s = 0.95,
3181
+ quality: a = 0.95,
3179
3182
  scale: l = 1,
3180
- transparentBackground: a = !1,
3183
+ transparentBackground: s = !1,
3181
3184
  backgroundColor: c = t.backgroundColor,
3182
3185
  forceMainThread: h = !1
3183
3186
  } = o;
@@ -3185,11 +3188,11 @@ const ct = class ct {
3185
3188
  try {
3186
3189
  const f = await this.getWorkerManager();
3187
3190
  if (f) {
3188
- const u = new Set(t.getElementIds()), d = r.filter((g) => u.has(g.id));
3191
+ const u = new Set(t.getElementIds()), d = r.filter((m) => u.has(m.id));
3189
3192
  return (await f.exportArtboardToBlob(t, d, {
3190
3193
  scale: l,
3191
3194
  format: i === "jpg" ? "jpeg" : i,
3192
- quality: s
3195
+ quality: a
3193
3196
  })).blob;
3194
3197
  }
3195
3198
  } catch (f) {
@@ -3197,9 +3200,9 @@ const ct = class ct {
3197
3200
  }
3198
3201
  return this.mainThreadExportToBlob(t, r, n, {
3199
3202
  format: i,
3200
- quality: s,
3203
+ quality: a,
3201
3204
  scale: l,
3202
- transparentBackground: a,
3205
+ transparentBackground: s,
3203
3206
  backgroundColor: c
3204
3207
  });
3205
3208
  }
@@ -3210,67 +3213,14 @@ const ct = class ct {
3210
3213
  * worker), so font readiness matters here even when no fallback occurred.
3211
3214
  */
3212
3215
  static async mainThreadExportToBlob(t, r, n, o = {}) {
3213
- const {
3214
- format: i = "png",
3215
- quality: s = 0.95,
3216
- scale: l = 1,
3217
- transparentBackground: a = !1,
3218
- backgroundColor: c = t.backgroundColor
3219
- } = o;
3220
- await ve(r);
3221
- const h = document.createElement("canvas"), f = t.width * l, u = t.height * l;
3222
- h.width = f, h.height = u;
3223
- const d = h.getContext("2d");
3224
- if (d.scale(l, l), !a && t.exportBackground) {
3225
- if (d.save(), this.applyExportBackgroundClipPath(d, t), t.backgroundType === "texture" && t.backgroundTexture) {
3226
- const p = D.getTexturePresetColor(t.backgroundTexture);
3227
- d.fillStyle = p, d.fillRect(0, 0, t.width, t.height);
3228
- const y = D.getTexture(t.backgroundTexture);
3229
- y && y.complete && d.drawImage(y, 0, 0, t.width, t.height);
3230
- } else
3231
- d.fillStyle = c || t.backgroundColor, d.fillRect(0, 0, t.width, t.height);
3232
- d.restore();
3216
+ const { format: i = "png", quality: a = 0.95 } = o, l = await this.renderOnMainThread(t, r, o);
3217
+ try {
3218
+ const s = await Me(l, ve(i), a);
3219
+ if (!s) throw new Error("Failed to create blob from canvas");
3220
+ return s;
3221
+ } finally {
3222
+ Rt(l);
3233
3223
  }
3234
- d.save(), d.translate(-t.x, -t.y), this.applyExportClipPath(d, t);
3235
- const m = new Set(t.getElementIds()), g = r.filter((p) => m.has(p.id)), k = /* @__PURE__ */ new Map();
3236
- g.forEach((p) => k.set(p.id, p));
3237
- const T = (p, y) => {
3238
- if (!y.id) return;
3239
- const C = k.get(y.id);
3240
- C && C.render(p, !1);
3241
- }, w = g.map((p) => p.toJSON()), b = /* @__PURE__ */ new Set();
3242
- return g.forEach((p, y) => {
3243
- var C;
3244
- if (p.blendMode === "knockout" || p.blendMode === "clip") {
3245
- const M = w[y], S = p.blendMode === "knockout" ? "destination-out" : "destination-in", P = ((C = M.knockoutParts) == null ? void 0 : C.scope) || "group", v = w.findIndex((A) => A.id === M.id);
3246
- if (v !== -1 && P === "artboard")
3247
- for (let A = 0; A < v; A++) {
3248
- const I = w[A].id;
3249
- I && b.add(I);
3250
- }
3251
- Ut(
3252
- d,
3253
- M,
3254
- w,
3255
- T,
3256
- a || !t.exportBackground ? void 0 : c,
3257
- t,
3258
- S
3259
- ), b.add(p.id);
3260
- }
3261
- }), g.forEach((p, y) => {
3262
- b.has(p.id) || fe(d, w[y], (C) => {
3263
- p.render(C, !1);
3264
- });
3265
- }), d.restore(), new Promise((p, y) => {
3266
- h.toBlob(
3267
- (C) => {
3268
- C ? p(C) : y(new Error("Failed to create blob from canvas"));
3269
- },
3270
- i === "jpg" || i === "jpeg" ? "image/jpeg" : i === "webp" ? "image/webp" : "image/png",
3271
- s
3272
- );
3273
- });
3274
3224
  }
3275
3225
  /**
3276
3226
  * Main thread export to data URL (fallback/legacy method).
@@ -3279,110 +3229,148 @@ const ct = class ct {
3279
3229
  * worker), so font readiness matters here even when no fallback occurred.
3280
3230
  */
3281
3231
  static async mainThreadExportToDataURL(t, r, n, o = {}) {
3282
- var y, C;
3232
+ const { format: i = "png", quality: a = 0.95 } = o, l = await this.renderOnMainThread(t, r, o);
3233
+ try {
3234
+ return l.toDataURL(ve(i), a);
3235
+ } finally {
3236
+ Rt(l);
3237
+ }
3238
+ }
3239
+ /**
3240
+ * One artboard's PRINT file: a lossless PNG of the artboard (or of `region`, a rect of it in artboard units) at
3241
+ * `scale` pixels per artboard unit, painted from every image's ORIGINAL pixels (the worker's 4,000 px bitmap cap,
3242
+ * `DEFAULT_MAX_BITMAP_DIMENSION`, keeps the live preview light; a print needs what the shopper uploaded).
3243
+ *
3244
+ * Painted on the main thread (the worker would cache an uncapped copy of every picture), one canvas, released as
3245
+ * soon as it is encoded: the caller asks for files one at a time, so a phone holds one print canvas at most.
3246
+ * Throws `E_PRINT_FILE_FAILED` (typed, with the size asked for) when the device could not hold or encode it.
3247
+ */
3248
+ static async exportPrintFile(t, r, n) {
3249
+ const { scale: o, region: i } = n;
3250
+ if (!(o > 0) || !Number.isFinite(o))
3251
+ throw new gt("E_PRINT_FILE_FAILED", `scale must be a finite number above 0 (got ${o}).`, { artboard: t.name, scale: o });
3252
+ const a = await this.renderOnMainThread(t, r, { scale: o, transparentBackground: !0 }, i), l = a.width, s = a.height;
3253
+ try {
3254
+ const c = await Me(a, "image/png");
3255
+ if (!c || c.size === 0)
3256
+ throw new gt(
3257
+ "E_PRINT_FILE_FAILED",
3258
+ `the device could not make the ${l} x ${s} px print file of "${t.name}"${i ? ` (region ${i.id})` : ""}: its canvas was refused. Ask for a smaller scale for this device.`,
3259
+ { artboard: t.name, region: i == null ? void 0 : i.id, width: l, height: s, scale: o }
3260
+ );
3261
+ return { blob: c, width: l, height: s, scale: o };
3262
+ } finally {
3263
+ Rt(a);
3264
+ }
3265
+ }
3266
+ /**
3267
+ * Paint an artboard (or a rect of it) on a detached main-thread canvas: background, compositing (knockout / clip),
3268
+ * every visible element with its masks / distress / layer effects, then the artboard's distress texture and image
3269
+ * mask. The one main-thread painter: the blob, data URL and print exports all use it (the blob path used to skip
3270
+ * masks, distress and the artboard effects the data URL path drew). A hidden layer is not part of the design and is
3271
+ * never painted (as the worker serializer drops it).
3272
+ */
3273
+ static async renderOnMainThread(t, r, n, o) {
3274
+ var b, T;
3283
3275
  const {
3284
- format: i = "png",
3285
- quality: s = 0.95,
3286
- scale: l = 1,
3276
+ scale: i = 1,
3287
3277
  transparentBackground: a = !1,
3288
- backgroundColor: c = t.backgroundColor
3289
- } = o;
3290
- await ve(r);
3291
- const h = document.createElement("canvas"), f = t.width * l, u = t.height * l;
3292
- h.width = f, h.height = u;
3293
- const d = h.getContext("2d");
3294
- if (d.scale(l, l), !a && t.exportBackground) {
3295
- if (d.save(), this.applyExportBackgroundClipPath(d, t), t.backgroundType === "texture" && t.backgroundTexture) {
3296
- const M = D.getTexturePresetColor(t.backgroundTexture);
3297
- d.fillStyle = M, d.fillRect(0, 0, t.width, t.height);
3298
- const S = D.getTexture(t.backgroundTexture);
3299
- S && S.complete ? d.drawImage(S, 0, 0, t.width, t.height) : _.warn("Texture not loaded for export:", t.backgroundTexture);
3278
+ backgroundColor: l = t.backgroundColor
3279
+ } = n, s = r.filter((g) => g.visible !== !1);
3280
+ await Kn(s);
3281
+ const c = o ?? { x: 0, y: 0, width: t.width, height: t.height }, h = document.createElement("canvas");
3282
+ h.width = Math.max(1, Math.round(c.width * i)), h.height = Math.max(1, Math.round(c.height * i));
3283
+ const f = h.getContext("2d");
3284
+ if (f.scale(i, i), (c.x !== 0 || c.y !== 0) && f.translate(-c.x, -c.y), !a && t.exportBackground) {
3285
+ if (f.save(), this.applyExportBackgroundClipPath(f, t), t.backgroundType === "texture" && t.backgroundTexture) {
3286
+ const g = pt.getTexturePresetColor(t.backgroundTexture);
3287
+ f.fillStyle = g, f.fillRect(0, 0, t.width, t.height);
3288
+ const y = pt.getTexture(t.backgroundTexture);
3289
+ y && y.complete ? f.drawImage(y, 0, 0, t.width, t.height) : _.warn("Texture not loaded for export:", t.backgroundTexture);
3300
3290
  } else
3301
- d.fillStyle = c, d.fillRect(0, 0, t.width, t.height);
3302
- d.restore();
3291
+ f.fillStyle = l || t.backgroundColor, f.fillRect(0, 0, t.width, t.height);
3292
+ f.restore();
3303
3293
  }
3304
- d.save(), d.translate(-t.x, -t.y), this.applyExportClipPath(d, t);
3305
- const m = new Set(t.getElementIds()), g = r.filter((M) => m.has(M.id)), k = /* @__PURE__ */ new Map();
3306
- g.forEach((M) => k.set(M.id, M));
3307
- const T = (M, S) => {
3308
- if (!S.id) return;
3309
- const P = k.get(S.id);
3310
- P ? P.render(M, !1) : _.warn("Element not found in map:", S.id);
3311
- }, w = g.map((M) => M.toJSON()), b = /* @__PURE__ */ new Set();
3312
- g.forEach((M, S) => {
3313
- var P;
3314
- if (M.blendMode === "knockout" || M.blendMode === "clip") {
3315
- const v = w[S], A = M.blendMode === "knockout" ? "destination-out" : "destination-in", I = ((P = v.knockoutParts) == null ? void 0 : P.scope) || "group", E = w.findIndex((R) => R.id === v.id);
3316
- if (E !== -1 && I === "artboard")
3317
- for (let R = 0; R < E; R++) {
3318
- const W = w[R].id;
3319
- W && b.add(W);
3294
+ f.save(), f.translate(-t.x, -t.y), this.applyExportClipPath(f, t);
3295
+ const u = new Set(t.getElementIds()), d = s.filter((g) => u.has(g.id)), p = /* @__PURE__ */ new Map();
3296
+ d.forEach((g) => p.set(g.id, g));
3297
+ const m = (g, y) => {
3298
+ if (!y.id) return;
3299
+ const S = p.get(y.id);
3300
+ S ? S.render(g, !1) : _.warn("Element not found in map:", y.id);
3301
+ }, w = d.map((g) => g.toJSON()), k = /* @__PURE__ */ new Set();
3302
+ return d.forEach((g, y) => {
3303
+ var S;
3304
+ if (g.blendMode === "knockout" || g.blendMode === "clip") {
3305
+ const C = w[y], P = g.blendMode === "knockout" ? "destination-out" : "destination-in", I = ((S = C.knockoutParts) == null ? void 0 : S.scope) || "group", M = w.findIndex((A) => A.id === C.id);
3306
+ if (M !== -1 && I === "artboard")
3307
+ for (let A = 0; A < M; A++) {
3308
+ const E = w[A].id;
3309
+ E && k.add(E);
3320
3310
  }
3321
- Ut(
3322
- d,
3323
- v,
3311
+ qe(
3312
+ f,
3313
+ C,
3324
3314
  w,
3325
- T,
3326
- a || !t.exportBackground ? void 0 : c,
3315
+ m,
3316
+ a || !t.exportBackground ? void 0 : l,
3327
3317
  t,
3328
- A
3329
- ), b.add(M.id);
3318
+ P
3319
+ ), k.add(g.id);
3330
3320
  }
3331
- }), g.forEach((M, S) => {
3332
- var P;
3333
- if (!b.has(M.id)) {
3334
- const v = w[S], A = ((P = v == null ? void 0 : v.distressEffect) == null ? void 0 : P.enabled) && v.distressEffect.style === "custom" && v.distressEffect.textureUrl, I = (v == null ? void 0 : v.masks) && v.masks.length > 0, E = (R) => {
3335
- M.render(R, !1);
3321
+ }), d.forEach((g, y) => {
3322
+ var S;
3323
+ if (!k.has(g.id)) {
3324
+ const C = w[y], P = ((S = C == null ? void 0 : C.distressEffect) == null ? void 0 : S.enabled) && C.distressEffect.style === "custom" && C.distressEffect.textureUrl, I = (C == null ? void 0 : C.masks) && C.masks.length > 0, M = (A) => {
3325
+ g.render(A, !1);
3336
3326
  };
3337
- fe(d, v, (R) => {
3338
- if (I && A)
3339
- he(R, v, (W) => {
3340
- const F = M.getVisualBoundingBox();
3341
- ye(W, v.distressEffect, F, E);
3327
+ Mn(f, C, (A) => {
3328
+ if (I && P)
3329
+ fe(A, C, (E) => {
3330
+ const v = g.getVisualBoundingBox();
3331
+ ye(E, C.distressEffect, v, M);
3342
3332
  });
3343
3333
  else if (I)
3344
- he(R, v, E);
3345
- else if (A) {
3346
- const W = M.getVisualBoundingBox();
3347
- ye(R, v.distressEffect, W, E);
3334
+ fe(A, C, M);
3335
+ else if (P) {
3336
+ const E = g.getVisualBoundingBox();
3337
+ ye(A, C.distressEffect, E, M);
3348
3338
  } else
3349
- M.render(R, !1);
3339
+ g.render(A, !1);
3350
3340
  });
3351
3341
  }
3352
- }), (y = t.distressTexture) != null && y.enabled && Un(d, t.distressTexture, {
3342
+ }), (b = t.distressTexture) != null && b.enabled && On(f, t.distressTexture, {
3353
3343
  x: t.x,
3354
3344
  y: t.y,
3355
3345
  width: t.width,
3356
3346
  height: t.height
3357
- }), (C = t.imageMask) != null && C.enabled && bn(d, t.imageMask, {
3347
+ }), (T = t.imageMask) != null && T.enabled && Tn(f, t.imageMask, {
3358
3348
  x: t.x,
3359
3349
  y: t.y,
3360
3350
  width: t.width,
3361
3351
  height: t.height
3362
- }), d.restore();
3363
- const p = i === "png" ? "image/png" : i === "webp" ? "image/webp" : "image/jpeg";
3364
- return h.toDataURL(p, s);
3352
+ }), f.restore(), h;
3365
3353
  }
3366
3354
  /**
3367
3355
  * Apply clip path for export background (uses 0,0 as origin since background is drawn before translate)
3368
3356
  */
3369
3357
  static applyExportBackgroundClipPath(t, r) {
3370
- const { width: n, height: o, clipShape: i } = r, s = 0, l = 0;
3358
+ const { width: n, height: o, clipShape: i } = r, a = 0, l = 0;
3371
3359
  if (t.beginPath(), !i || i === "rectangle")
3372
- t.rect(s, l, n, o);
3360
+ t.rect(a, l, n, o);
3373
3361
  else if (i === "circle") {
3374
- const a = s + n / 2, c = l + o / 2, h = Math.min(n, o) / 2;
3375
- t.arc(a, c, h, 0, Math.PI * 2);
3362
+ const s = a + n / 2, c = l + o / 2, h = Math.min(n, o) / 2;
3363
+ t.arc(s, c, h, 0, Math.PI * 2);
3376
3364
  } else if (typeof i == "object" && i.type === "rounded") {
3377
- const a = Math.min(i.radius, Math.min(n, o) / 2);
3378
- typeof t.roundRect == "function" ? t.roundRect(s, l, n, o, a) : (t.moveTo(s + a, l), t.lineTo(s + n - a, l), t.arcTo(s + n, l, s + n, l + a, a), t.lineTo(s + n, l + o - a), t.arcTo(s + n, l + o, s + n - a, l + o, a), t.lineTo(s + a, l + o), t.arcTo(s, l + o, s, l + o - a, a), t.lineTo(s, l + a), t.arcTo(s, l, s + a, l, a));
3365
+ const s = Math.min(i.radius, Math.min(n, o) / 2);
3366
+ typeof t.roundRect == "function" ? t.roundRect(a, l, n, o, s) : (t.moveTo(a + s, l), t.lineTo(a + n - s, l), t.arcTo(a + n, l, a + n, l + s, s), t.lineTo(a + n, l + o - s), t.arcTo(a + n, l + o, a + n - s, l + o, s), t.lineTo(a + s, l + o), t.arcTo(a, l + o, a, l + o - s, s), t.lineTo(a, l + s), t.arcTo(a, l, a + s, l, s));
3379
3367
  } else if (typeof i == "object" && i.type === "path")
3380
3368
  try {
3381
- const a = new Path2D(i.d);
3382
- t.clip(a);
3369
+ const s = new Path2D(i.d);
3370
+ t.clip(s);
3383
3371
  return;
3384
- } catch (a) {
3385
- _.warn("Invalid SVG path, falling back to rectangle:", a), t.rect(s, l, n, o);
3372
+ } catch (s) {
3373
+ _.warn("Invalid SVG path, falling back to rectangle:", s), t.rect(a, l, n, o);
3386
3374
  }
3387
3375
  t.clip();
3388
3376
  }
@@ -3391,22 +3379,22 @@ const ct = class ct {
3391
3379
  * This creates the clip region for the given artboard during export
3392
3380
  */
3393
3381
  static applyExportClipPath(t, r) {
3394
- const { x: n, y: o, width: i, height: s, clipShape: l } = r;
3382
+ const { x: n, y: o, width: i, height: a, clipShape: l } = r;
3395
3383
  if (t.beginPath(), !l || l === "rectangle")
3396
- t.rect(n, o, i, s);
3384
+ t.rect(n, o, i, a);
3397
3385
  else if (l === "circle") {
3398
- const a = n + i / 2, c = o + s / 2, h = Math.min(i, s) / 2;
3399
- t.arc(a, c, h, 0, Math.PI * 2);
3386
+ const s = n + i / 2, c = o + a / 2, h = Math.min(i, a) / 2;
3387
+ t.arc(s, c, h, 0, Math.PI * 2);
3400
3388
  } else if (typeof l == "object" && l.type === "rounded") {
3401
- const a = Math.min(l.radius, Math.min(i, s) / 2);
3402
- typeof t.roundRect == "function" ? t.roundRect(n, o, i, s, a) : (t.moveTo(n + a, o), t.lineTo(n + i - a, o), t.arcTo(n + i, o, n + i, o + a, a), t.lineTo(n + i, o + s - a), t.arcTo(n + i, o + s, n + i - a, o + s, a), t.lineTo(n + a, o + s), t.arcTo(n, o + s, n, o + s - a, a), t.lineTo(n, o + a), t.arcTo(n, o, n + a, o, a));
3389
+ const s = Math.min(l.radius, Math.min(i, a) / 2);
3390
+ typeof t.roundRect == "function" ? t.roundRect(n, o, i, a, s) : (t.moveTo(n + s, o), t.lineTo(n + i - s, o), t.arcTo(n + i, o, n + i, o + s, s), t.lineTo(n + i, o + a - s), t.arcTo(n + i, o + a, n + i - s, o + a, s), t.lineTo(n + s, o + a), t.arcTo(n, o + a, n, o + a - s, s), t.lineTo(n, o + s), t.arcTo(n, o, n + s, o, s));
3403
3391
  } else if (typeof l == "object" && l.type === "path")
3404
3392
  try {
3405
- const a = new Path2D(l.d);
3406
- t.translate(n, o), t.clip(a), t.translate(-n, -o);
3393
+ const s = new Path2D(l.d);
3394
+ t.translate(n, o), t.clip(s), t.translate(-n, -o);
3407
3395
  return;
3408
- } catch (a) {
3409
- _.warn("Invalid SVG path, falling back to rectangle:", a), t.rect(n, o, i, s);
3396
+ } catch (s) {
3397
+ _.warn("Invalid SVG path, falling back to rectangle:", s), t.rect(n, o, i, a);
3410
3398
  }
3411
3399
  t.clip();
3412
3400
  }
@@ -3415,9 +3403,9 @@ const ct = class ct {
3415
3403
  */
3416
3404
  static async exportAllArtboardsToImages(t, r, n, o = {}) {
3417
3405
  const i = t.map(
3418
- (s) => this.exportArtboardToImage(s, r, n, {
3406
+ (a) => this.exportArtboardToImage(a, r, n, {
3419
3407
  ...o,
3420
- filename: o.filename ? `${o.filename}-${s.name}.${o.format || "png"}` : void 0
3408
+ filename: o.filename ? `${o.filename}-${a.name}.${o.format || "png"}` : void 0
3421
3409
  })
3422
3410
  );
3423
3411
  await Promise.all(i);
@@ -3439,11 +3427,11 @@ const ct = class ct {
3439
3427
  * Get export summary (for UI display)
3440
3428
  */
3441
3429
  static getExportSummary(t, r) {
3442
- const n = t.length, o = r.length, l = n * 200 + o * 500, a = Math.ceil(l / 1024);
3430
+ const n = t.length, o = r.length, l = n * 200 + o * 500, s = Math.ceil(l / 1024);
3443
3431
  return {
3444
3432
  artboardCount: n,
3445
3433
  totalElementCount: o,
3446
- estimatedFileSize: a < 1024 ? `${a} KB` : `${(a / 1024).toFixed(1)} MB`
3434
+ estimatedFileSize: s < 1024 ? `${s} KB` : `${(s / 1024).toFixed(1)} MB`
3447
3435
  };
3448
3436
  }
3449
3437
  /**
@@ -3451,14 +3439,14 @@ const ct = class ct {
3451
3439
  * Returns timing data for both methods
3452
3440
  */
3453
3441
  static async benchmarkExport(t, r, n, o = {}) {
3454
- const i = performance.now(), s = await this.exportArtboardToDataURL(t, r, n, {
3442
+ const i = performance.now(), a = await this.exportArtboardToDataURL(t, r, n, {
3455
3443
  ...o,
3456
3444
  forceMainThread: !0
3457
- }), l = performance.now() - i, a = {
3445
+ }), l = performance.now() - i, s = {
3458
3446
  workerSupported: this.supportsWorkerExport(),
3459
3447
  mainThread: {
3460
3448
  time: l,
3461
- dataUrl: s
3449
+ dataUrl: a
3462
3450
  },
3463
3451
  recommendation: ""
3464
3452
  };
@@ -3466,28 +3454,28 @@ const ct = class ct {
3466
3454
  try {
3467
3455
  const c = performance.now(), h = await this.getWorkerManager();
3468
3456
  if (h) {
3469
- const f = new Set(t.getElementIds()), u = r.filter((k) => f.has(k.id)), d = await h.exportArtboardToDataURL(t, u, {
3457
+ const f = new Set(t.getElementIds()), u = r.filter((w) => f.has(w.id)), d = await h.exportArtboardToDataURL(t, u, {
3470
3458
  scale: o.scale || 1,
3471
3459
  format: (o.format === "jpg" ? "jpeg" : o.format) || "png",
3472
3460
  quality: o.quality || 0.95
3473
- }), m = performance.now() - c, g = l / m;
3461
+ }), p = performance.now() - c, m = l / p;
3474
3462
  return {
3475
- ...a,
3463
+ ...s,
3476
3464
  worker: {
3477
- time: m,
3465
+ time: p,
3478
3466
  dataUrl: d.dataUrl,
3479
3467
  mainThreadBlockTime: d.mainThreadBlockTime
3480
3468
  },
3481
- speedup: g,
3482
- recommendation: g > 1.2 ? `Worker export is ${g.toFixed(2)}x faster - recommended for continuous export` : g < 0.8 ? `Main thread export is ${(1 / g).toFixed(2)}x faster - worker overhead not worth it for single exports` : "Performance is similar, but worker keeps UI responsive during export"
3469
+ speedup: m,
3470
+ recommendation: m > 1.2 ? `Worker export is ${m.toFixed(2)}x faster - recommended for continuous export` : m < 0.8 ? `Main thread export is ${(1 / m).toFixed(2)}x faster - worker overhead not worth it for single exports` : "Performance is similar, but worker keeps UI responsive during export"
3483
3471
  };
3484
3472
  }
3485
3473
  } catch (c) {
3486
- _.error("Worker benchmark failed:", c), a.recommendation = "Worker export not available - using main thread export";
3474
+ _.error("Worker benchmark failed:", c), s.recommendation = "Worker export not available - using main thread export";
3487
3475
  }
3488
3476
  else
3489
- a.recommendation = "Worker export not supported in this browser - using main thread export";
3490
- return a;
3477
+ s.recommendation = "Worker export not supported in this browser - using main thread export";
3478
+ return s;
3491
3479
  }
3492
3480
  /**
3493
3481
  * Performance benchmark: Test continuous exports to measure UI impact
@@ -3497,31 +3485,31 @@ const ct = class ct {
3497
3485
  const {
3498
3486
  duration: i = 5e3,
3499
3487
  // 5 seconds
3500
- interval: s = 500,
3488
+ interval: a = 500,
3501
3489
  // Every 500ms
3502
3490
  useWorker: l = this.supportsWorkerExport()
3503
- } = o, a = [];
3491
+ } = o, s = [];
3504
3492
  let c = 0, h = !0;
3505
3493
  for (setTimeout(() => {
3506
3494
  h = !1;
3507
3495
  }, i); h; ) {
3508
- const w = performance.now();
3496
+ const b = performance.now();
3509
3497
  await this.exportArtboardToDataURL(t, r, n, {
3510
3498
  forceMainThread: !l
3511
3499
  });
3512
- const b = performance.now() - w;
3513
- a.push(b), l || (c += b), await new Promise((p) => setTimeout(p, Math.max(0, s - b)));
3500
+ const T = performance.now() - b;
3501
+ s.push(T), l || (c += T), await new Promise((g) => setTimeout(g, Math.max(0, a - T)));
3514
3502
  }
3515
- const f = a.length, u = a.reduce((w, b) => w + b, 0) / f, d = Math.min(...a), m = Math.max(...a), g = f / i * 1e3, k = c / i * 100, T = k > 20 ? `Main thread blocked ${k.toFixed(1)}% of the time - STRONGLY recommend worker export` : k > 10 ? `Main thread blocked ${k.toFixed(1)}% of the time - consider worker export` : `Main thread blocked ${k.toFixed(1)}% of the time - performance is acceptable`;
3503
+ const f = s.length, u = s.reduce((b, T) => b + T, 0) / f, d = Math.min(...s), p = Math.max(...s), m = f / i * 1e3, w = c / i * 100, k = w > 20 ? `Main thread blocked ${w.toFixed(1)}% of the time - STRONGLY recommend worker export` : w > 10 ? `Main thread blocked ${w.toFixed(1)}% of the time - consider worker export` : `Main thread blocked ${w.toFixed(1)}% of the time - performance is acceptable`;
3516
3504
  return {
3517
3505
  totalExports: f,
3518
3506
  duration: i,
3519
3507
  averageTime: u,
3520
3508
  minTime: d,
3521
- maxTime: m,
3509
+ maxTime: p,
3522
3510
  totalMainThreadBlockTime: c,
3523
- exportsPerSecond: g,
3524
- recommendation: T
3511
+ exportsPerSecond: m,
3512
+ recommendation: k
3525
3513
  };
3526
3514
  }
3527
3515
  /**
@@ -3593,66 +3581,66 @@ const ct = class ct {
3593
3581
  return "previewBackgroundColor" in r && delete r.previewBackgroundColor, r;
3594
3582
  }
3595
3583
  };
3596
- ct.CURRENT_VERSION = "2.0.0", ct.workerManager = null, ct.workerInitPromise = null;
3597
- let bt = ct;
3598
- const ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3584
+ lt.CURRENT_VERSION = "2.0.0", lt.workerManager = null, lt.workerInitPromise = null;
3585
+ let Tt = lt;
3586
+ const go = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3599
3587
  __proto__: null,
3600
- ExportManager: bt,
3601
- default: bt
3588
+ ExportManager: Tt,
3589
+ default: Tt
3602
3590
  }, Symbol.toStringTag, { value: "Module" }));
3603
3591
  export {
3604
- he as A,
3605
- co as B,
3606
- Ge as C,
3607
- Xe as D,
3608
- yt as E,
3609
- Rr as F,
3610
- Nt as G,
3611
- io as H,
3612
- ke as I,
3613
- Gn as J,
3614
- Xn as K,
3615
- Ut as L,
3616
- fe as M,
3617
- Un as N,
3618
- bn as O,
3619
- Qt as P,
3592
+ fe as A,
3593
+ uo as B,
3594
+ Ye as C,
3595
+ Ge as D,
3596
+ wt as E,
3597
+ Wr as F,
3598
+ Xt as G,
3599
+ ho as H,
3600
+ be as I,
3601
+ Vn as J,
3602
+ Yn as K,
3603
+ qe as L,
3604
+ Mn as M,
3605
+ On as N,
3606
+ Tn as O,
3607
+ zt as P,
3620
3608
  ye as Q,
3621
- Jn as R,
3622
- Wn as S,
3623
- D as T,
3624
- In as U,
3625
- oo as V,
3626
- dt as W,
3627
- fn as X,
3628
- hn as Y,
3609
+ zn as R,
3610
+ Un as S,
3611
+ pt as T,
3612
+ Rn as U,
3613
+ io as V,
3614
+ ft as W,
3615
+ dn as X,
3616
+ fn as Y,
3629
3617
  kr as Z,
3630
- ho as _,
3631
- bt as a,
3632
- Dn as b,
3618
+ go as _,
3619
+ Tt as a,
3620
+ eo as b,
3633
3621
  Ie as c,
3634
3622
  q as d,
3635
- so as e,
3636
- no as f,
3637
- Ht as g,
3638
- Qn as h,
3639
- vr as i,
3640
- zn as j,
3641
- Kn as k,
3642
- ht as l,
3643
- lo as m,
3644
- ro as n,
3645
- Yn as o,
3646
- oe as p,
3647
- ao as q,
3648
- Mr as r,
3649
- Wt as s,
3650
- xn as t,
3651
- Zn as u,
3652
- Ir as v,
3653
- to as w,
3654
- Ar as x,
3623
+ lo as e,
3624
+ so as f,
3625
+ jt as g,
3626
+ Dn as h,
3627
+ Mr as i,
3628
+ xn as j,
3629
+ Zn as k,
3630
+ ct as l,
3631
+ fo as m,
3632
+ ao as n,
3633
+ Jn as o,
3634
+ ae as p,
3635
+ co as q,
3636
+ Cr as r,
3637
+ Ut as s,
3638
+ ro as t,
3639
+ to as u,
3640
+ Ar as v,
3641
+ no as w,
3642
+ Rr as x,
3655
3643
  Ae as y,
3656
- eo as z
3644
+ oo as z
3657
3645
  };
3658
- //# sourceMappingURL=ExportManager-9_RjQEv0.js.map
3646
+ //# sourceMappingURL=ExportManager-vAuaoF5Q.js.map