@snowcone-app/canvas 0.30.0 → 0.31.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 (69) hide show
  1. package/STYLING_CONTRACT.md +2 -2
  2. package/dist/{CanvasRenderer-BEf0hXeF.js → CanvasRenderer-hpJ05JGO.js} +4 -4
  3. package/dist/{CanvasRenderer-BEf0hXeF.js.map → CanvasRenderer-hpJ05JGO.js.map} +1 -1
  4. package/dist/{CanvasStateV1-BDSyYo4A.js → CanvasStateV1-jLOibojY.js} +11 -4
  5. package/dist/{CanvasStateV1-BDSyYo4A.js.map → CanvasStateV1-jLOibojY.js.map} +1 -1
  6. package/dist/{ContextualToolbars-C3D_6sep.js → ContextualToolbars-DRbuUE7W.js} +2086 -1985
  7. package/dist/ContextualToolbars-DRbuUE7W.js.map +1 -0
  8. package/dist/{EditorCanvasImpl-DXeBz2CX.js → EditorCanvasImpl-P2GHPNA3.js} +19 -20
  9. package/dist/{EditorCanvasImpl-DXeBz2CX.js.map → EditorCanvasImpl-P2GHPNA3.js.map} +1 -1
  10. package/dist/{ExportManager-DUdis6se.js → ExportManager-Bkzzyxgw.js} +400 -261
  11. package/dist/ExportManager-Bkzzyxgw.js.map +1 -0
  12. package/dist/{FontAnalyzer-DKG5JK0x.js → FontAnalyzer-BYhwxDhe.js} +1084 -1034
  13. package/dist/FontAnalyzer-BYhwxDhe.js.map +1 -0
  14. package/dist/{ImagePanel-CBgGqmVV.js → ImagePanel-CEr0_FYy.js} +49 -49
  15. package/dist/{ImagePanel-CBgGqmVV.js.map → ImagePanel-CEr0_FYy.js.map} +1 -1
  16. package/dist/{SnowconeCanvas-BWPBngvI.js → SnowconeCanvas-Fa0isFpO.js} +27 -27
  17. package/dist/{SnowconeCanvas-BWPBngvI.js.map → SnowconeCanvas-Fa0isFpO.js.map} +1 -1
  18. package/dist/advanced.mjs +14 -14
  19. package/dist/components/ImageToolbar.d.ts +4 -0
  20. package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +2 -0
  21. package/dist/components/toolbars/SecondaryPanels.d.ts +17 -1
  22. package/dist/components/toolbars/index.d.ts +2 -2
  23. package/dist/components/ui/SliderRow.d.ts +6 -0
  24. package/dist/components/ui/toolbar-button.d.ts +2 -2
  25. package/dist/core/image-adjustments.d.ts +32 -0
  26. package/dist/{custom-icons-BIaRovwG.js → custom-icons-Co4rcW0S.js} +7 -7
  27. package/dist/{custom-icons-BIaRovwG.js.map → custom-icons-Co4rcW0S.js.map} +1 -1
  28. package/dist/design-builder-CBG2hKc8.js +1672 -0
  29. package/dist/design-builder-CBG2hKc8.js.map +1 -0
  30. package/dist/{embed-Csez1hui.js → embed-D4TIzO7g.js} +110 -111
  31. package/dist/{embed-Csez1hui.js.map → embed-D4TIzO7g.js.map} +1 -1
  32. package/dist/embed.mjs +53 -54
  33. package/dist/embed.mjs.map +1 -1
  34. package/dist/{guards-BSoX73yg.js → guards-DgZuwVgu.js} +2 -2
  35. package/dist/{guards-BSoX73yg.js.map → guards-DgZuwVgu.js.map} +1 -1
  36. package/dist/hooks/elementPatch.d.ts +7 -2
  37. package/dist/index.mjs +41 -41
  38. package/dist/internals.mjs +196 -127
  39. package/dist/internals.mjs.map +1 -1
  40. package/dist/rendering/element-painters.d.ts +0 -13
  41. package/dist/rendering/element-serializer.d.ts +3 -1
  42. package/dist/rendering/image-adjustments.d.ts +24 -0
  43. package/dist/rendering/renderer-types.d.ts +8 -1
  44. package/dist/state/CanvasStateV1.d.ts +5 -0
  45. package/dist/template-fields-CvFcr5zy.js +505 -0
  46. package/dist/template-fields-CvFcr5zy.js.map +1 -0
  47. package/dist/testing.mjs +40 -41
  48. package/dist/testing.mjs.map +1 -1
  49. package/dist/types/index.d.ts +21 -0
  50. package/dist/{UnifiedFontService-Co9tQ59z.js → useCommands-bPXY9rCh.js} +2344 -2103
  51. package/dist/useCommands-bPXY9rCh.js.map +1 -0
  52. package/dist/{usePieceGuideBundle-CRLY2iQa.js → usePieceGuideBundle-Bj98nPk0.js} +2 -2
  53. package/dist/{usePieceGuideBundle-CRLY2iQa.js.map → usePieceGuideBundle-Bj98nPk0.js.map} +1 -1
  54. package/dist/utils/featureApplied.d.ts +2 -0
  55. package/dist/{validation-BGEl9rrE.js → validation-CsTlSvJJ.js} +465 -465
  56. package/dist/{validation-BGEl9rrE.js.map → validation-CsTlSvJJ.js.map} +1 -1
  57. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  58. package/example/package.json +1 -1
  59. package/package.json +1 -1
  60. package/dist/ContextualToolbars-C3D_6sep.js.map +0 -1
  61. package/dist/ExportManager-DUdis6se.js.map +0 -1
  62. package/dist/FontAnalyzer-DKG5JK0x.js.map +0 -1
  63. package/dist/UnifiedFontService-Co9tQ59z.js.map +0 -1
  64. package/dist/design-builder-JYLO_Hyi.js +0 -470
  65. package/dist/design-builder-JYLO_Hyi.js.map +0 -1
  66. package/dist/editorErrors-WzaNxU1Y.js +0 -1206
  67. package/dist/editorErrors-WzaNxU1Y.js.map +0 -1
  68. package/dist/template-fields-DYPW7bVU.js +0 -716
  69. package/dist/template-fields-DYPW7bVU.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { c as U, G as xe, a5 as ze, a6 as Ge, a7 as He, a8 as ve, a9 as Gn, aa as Ve, ab as Q, a3 as je, a4 as qe, ac as on, ad as Hn, C as Jn, R as Xe, ae as Ye, af as q, ag as Ke, ah as wn, P as Je, S as Ze, I as An, Q as Qe, Y as nt, L as et, J as tt, W as at, M as rt, N as st, A as Zn, E as we } from "./FontAnalyzer-DKG5JK0x.js";
1
+ import { c as U, G as xe, a9 as ze, aa as Ge, ab as He, ac as ve, ad as Gn, ae as Ve, af as Q, a7 as je, a8 as qe, ag as on, ah as Hn, C as Jn, R as Xe, ai as Ye, aj as q, ak as Ke, al as wn, P as Je, S as Ze, I as An, Y as Qe, a0 as nt, Q as et, N as tt, _ as at, V as rt, W as st, A as Zn, K as it, E as we } from "./FontAnalyzer-BYhwxDhe.js";
2
2
  let Se = null;
3
- function it(e) {
3
+ function ot(e) {
4
4
  Se = e;
5
5
  }
6
- function Da() {
6
+ function Oa() {
7
7
  return Se;
8
8
  }
9
- const ot = U("TextureManager"), ln = class ln {
9
+ const ct = U("TextureManager"), ln = class ln {
10
10
  /**
11
11
  * Load a texture by ID or URL
12
12
  */
@@ -20,7 +20,7 @@ const ot = U("TextureManager"), ln = class ln {
20
20
  s.crossOrigin = "anonymous", s.onload = () => {
21
21
  this.cache.set(n, s), this.cache.set(t, s), this.loading.delete(n), this.loading.delete(t), r(s);
22
22
  }, s.onerror = () => {
23
- ot.error("Failed to load texture:", t), this.loading.delete(n), this.loading.delete(t), o(new Error(`Failed to load texture: ${t}`));
23
+ ct.error("Failed to load texture:", t), this.loading.delete(n), this.loading.delete(t), o(new Error(`Failed to load texture: ${t}`));
24
24
  }, s.src = t;
25
25
  });
26
26
  return this.loading.set(n, a), t !== n && this.loading.set(t, a), a;
@@ -97,28 +97,28 @@ ln.cache = /* @__PURE__ */ new Map(), ln.loading = /* @__PURE__ */ new Map(), ln
97
97
  }
98
98
  ];
99
99
  let Z = ln;
100
- const ct = U("ElementPreviewRenderer"), lt = {
100
+ const lt = U("ElementPreviewRenderer"), dt = {
101
101
  width: 40,
102
102
  height: 40,
103
103
  padding: 4,
104
104
  backgroundColor: "transparent"
105
105
  };
106
- function dt(e, n = {}) {
106
+ function ft(e, n = {}) {
107
107
  jn();
108
- const t = { ...lt, ...n }, a = document.createElement("canvas");
108
+ const t = { ...dt, ...n }, a = document.createElement("canvas");
109
109
  a.width = t.width, a.height = t.height;
110
110
  const r = a.getContext("2d");
111
111
  if (!r)
112
112
  return "";
113
113
  t.backgroundColor !== "transparent" && (r.fillStyle = t.backgroundColor, r.fillRect(0, 0, t.width, t.height)), r.save();
114
114
  try {
115
- e instanceof xe ? ut(r, e, t) : ft(r, e, t);
115
+ e instanceof xe ? pt(r, e, t) : ut(r, e, t);
116
116
  } catch (o) {
117
- ct.warn("Failed to generate preview:", o);
117
+ lt.warn("Failed to generate preview:", o);
118
118
  }
119
119
  return r.restore(), a.toDataURL("image/png");
120
120
  }
121
- function ft(e, n, t) {
121
+ function ut(e, n, t) {
122
122
  var f;
123
123
  const a = ((f = n.getBoundingBox) == null ? void 0 : f.call(n)) || { x: 0, y: 0, width: 100, height: 100 }, r = a.width, o = a.height;
124
124
  if (r === 0 || o === 0) {
@@ -138,7 +138,7 @@ function Qn(e, n, t) {
138
138
  const a = n.transformType || "Element";
139
139
  e.fillText(a, t.width / 2, t.height / 2);
140
140
  }
141
- function ut(e, n, t) {
141
+ function pt(e, n, t) {
142
142
  const a = t.width - t.padding * 2, r = t.height - t.padding * 2, o = t.padding, s = t.padding;
143
143
  e.fillStyle = "#888888", e.strokeStyle = "#666666", e.lineWidth = 1;
144
144
  const c = r * 0.7, i = s + r * 0.3, l = a * 0.4, d = r * 0.2;
@@ -162,7 +162,7 @@ function Ma(e, n, t) {
162
162
  e.beginPath(), e.moveTo(-d / 2, 0), e.lineTo(d / 2, 0), e.moveTo(-d / 2, -r), e.lineTo(d / 2, -r), e.moveTo(-d / 2, r * 0.2), e.lineTo(d / 2, r * 0.2);
163
163
  }
164
164
  }
165
- function pt(e, n) {
165
+ function ht(e, n) {
166
166
  if (!n.transformData) return;
167
167
  const { borderRadius: t = 0 } = n.transformData, a = n.transformData.width ?? 100, r = n.transformData.height ?? 100;
168
168
  if (e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180), e.beginPath(), t > 0) {
@@ -171,16 +171,16 @@ function pt(e, n) {
171
171
  } else
172
172
  e.rect(-a / 2, -r / 2, a, r);
173
173
  }
174
- function Oa(e, n, t, a) {
174
+ function Ra(e, n, t, a) {
175
175
  e.beginPath(), e.arc(n, t, a, 0, Math.PI * 2), e.closePath();
176
176
  }
177
- function Ra(e, n, t, a, r) {
177
+ function Ba(e, n, t, a, r) {
178
178
  e.beginPath(), e.rect(n, t, a, r), e.closePath();
179
179
  }
180
180
  function Ce(e, n) {
181
181
  e.strokeStyle = n.color, e.lineWidth = n.width, e.lineCap = n.lineCap || "butt", e.lineJoin = n.lineJoin || "miter", n.miterLimit !== void 0 && (e.miterLimit = n.miterLimit), n.dashArray && n.dashArray.length > 0 ? e.setLineDash(n.dashArray) : e.setLineDash([]), n.opacity !== void 0 && (e.globalAlpha = n.opacity);
182
182
  }
183
- function ht(e, n) {
183
+ function bt(e, n) {
184
184
  if (typeof OffscreenCanvas < "u")
185
185
  return new OffscreenCanvas(e, n);
186
186
  const t = document.createElement("canvas");
@@ -194,21 +194,21 @@ function ke(e, n, t) {
194
194
  const o = (t == null ? void 0 : t.isKnockout) === !0, s = n.stroke.opacity ?? 1;
195
195
  if (!o && s < 1)
196
196
  try {
197
- bt(e, n, a, t, s);
197
+ gt(e, n, a, t, s);
198
198
  } catch {
199
199
  cn(e, n, a, t, !1);
200
200
  }
201
201
  else
202
202
  cn(e, n, a, t, o);
203
203
  }
204
- function bt(e, n, t, a, r) {
204
+ function gt(e, n, t, a, r) {
205
205
  var k, _;
206
206
  const o = t.text || "", s = t.fontSize || 24, c = n.stroke.width, i = n.stroke.feather || 0, l = n.transformType === "custom" && ((k = n.transformData) == null ? void 0 : k.width), d = l ? ((_ = n.transformData) == null ? void 0 : _.width) ?? 200 : 0, u = l ? d + c * 2 + i * 2 + 40 : s * o.length * 0.7 + c * 2 + i * 2 + 40, p = s * 3 + c * 2 + i * 2 + 40, f = e.getTransform(), $ = Math.max(Math.abs(f.a), Math.abs(f.d), 1), h = Math.ceil(u * $ / 2) * 2, b = Math.ceil(p * $ / 2) * 2;
207
207
  if (h <= 0 || b <= 0) {
208
208
  cn(e, n, t, a, !1);
209
209
  return;
210
210
  }
211
- const v = ht(h, b), y = v.getContext("2d");
211
+ const v = bt(h, b), y = v.getContext("2d");
212
212
  if (!y) {
213
213
  cn(e, n, t, a, !1);
214
214
  return;
@@ -272,17 +272,17 @@ function cn(e, n, t, a, r) {
272
272
  }
273
273
  e.restore();
274
274
  }
275
- function gt(e, n, t) {
275
+ function mt(e, n, t) {
276
276
  var r;
277
277
  if (!((r = n.stroke) != null && r.enabled) || !n.transformData) return;
278
278
  const a = (t == null ? void 0 : t.isKnockout) === !0;
279
- e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1, n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit)) : Ce(e, n.stroke), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), pt(e, n), e.stroke(), e.restore();
279
+ e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1, n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit)) : Ce(e, n.stroke), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), ht(e, n), e.stroke(), e.restore();
280
280
  }
281
- function Ba(e, n, t) {
281
+ function La(e, n, t) {
282
282
  n.enabled && (e.save(), Ce(e, n), n.feather && n.feather > 0 && "filter" in e && (e.filter = `blur(${n.feather}px)`), e.beginPath(), t(), e.stroke(), e.restore());
283
283
  }
284
284
  const ne = U("GlyphRenderer");
285
- function mt(e, n, t, a, r, o, s, c = {}) {
285
+ function yt(e, n, t, a, r, o, s, c = {}) {
286
286
  try {
287
287
  const i = [];
288
288
  Object.entries(s).forEach(([b, v]) => {
@@ -332,7 +332,7 @@ function mt(e, n, t, a, r, o, s, c = {}) {
332
332
  ne.error("Error rendering with fontkit:", i), e.fillStyle = c.color || "#000000", e.textAlign = c.align || "left", e.fillText(t, a, r);
333
333
  }
334
334
  }
335
- function yt(e, n, t, a, r, o, s, c = {}) {
335
+ function $t(e, n, t, a, r, o, s, c = {}) {
336
336
  const l = ((b) => {
337
337
  for (const v of b) {
338
338
  const y = v.codePointAt(0);
@@ -385,7 +385,7 @@ function yt(e, n, t, a, r, o, s, c = {}) {
385
385
  }
386
386
  }), e.restore();
387
387
  }
388
- function $t(e, n, t, a, r) {
388
+ function xt(e, n, t, a, r) {
389
389
  e.fillStyle = t.color;
390
390
  const o = t.textAlign || "center", s = (h) => h.letterSpacing !== void 0 ? h.letterSpacing : t.letterSpacing ?? 0, c = je(n);
391
391
  let i, l;
@@ -409,8 +409,8 @@ function $t(e, n, t, a, r) {
409
409
  h.forEach((S) => {
410
410
  const P = S.style.fontSize !== void 0 ? S.style.fontSize : t.fontSize, I = S.style.fontFamily !== void 0 ? S.style.fontFamily : t.fontFamily, F = S.style.bold !== void 0 ? S.style.bold : t.bold || !1, D = S.style.italic !== void 0 ? S.style.italic : t.italic || !1;
411
411
  e.font = B(P, I, F, D);
412
- const M = on(e.measureText(S.text).width, S.text, s(S.style));
413
- v.push(M);
412
+ const O = on(e.measureText(S.text).width, S.text, s(S.style));
413
+ v.push(O);
414
414
  const L = fn(P, I, F, D);
415
415
  y = Math.max(y, L.height), x = Math.max(x, L.ascent);
416
416
  });
@@ -418,22 +418,22 @@ function $t(e, n, t, a, r) {
418
418
  let A = 0, E = 0;
419
419
  h.forEach((S) => {
420
420
  const P = S.style.fontSize !== void 0 ? S.style.fontSize : t.fontSize, I = S.style.fontFamily !== void 0 ? S.style.fontFamily : t.fontFamily, F = S.style.bold !== void 0 ? S.style.bold : t.bold || !1, D = S.style.italic !== void 0 ? S.style.italic : t.italic || !1;
421
- let M = S.text;
421
+ let O = S.text;
422
422
  const L = E, kn = E + S.text.length;
423
423
  if (!m && _ > 0 && L < _) {
424
424
  const R = Math.min(_ - L, S.text.length);
425
- M = M.substring(R);
425
+ O = O.substring(R);
426
426
  }
427
427
  if (!g && w > 0) {
428
428
  const R = C.length - w;
429
429
  if (kn > R) {
430
430
  const H = !m && _ > 0 && L < _ ? Math.min(_ - L, S.text.length) : 0, Tn = Math.max(0, R - L - H);
431
- M = M.substring(0, Tn);
431
+ O = O.substring(0, Tn);
432
432
  }
433
433
  }
434
- E += S.text.length, M.length > 0 && (e.save(), e.font = B(P, I, F, D), A += on(
435
- e.measureText(M).width,
436
- M,
434
+ E += S.text.length, O.length > 0 && (e.save(), e.font = B(P, I, F, D), A += on(
435
+ e.measureText(O).width,
436
+ O,
437
437
  s(S.style)
438
438
  ), e.restore());
439
439
  }), d.push({
@@ -459,7 +459,7 @@ function $t(e, n, t, a, r) {
459
459
  const C = $ + u.ascent + b * p, T = v.map((S) => S.text).join(""), k = T.match(/^ +/), _ = T.match(/ +$/), w = k ? k[0].length : 0, A = _ ? _[0].length : 0;
460
460
  let E = 0;
461
461
  v.forEach((S) => {
462
- const P = S.style.fontSize !== void 0 ? S.style.fontSize : t.fontSize, I = S.style.fontFamily !== void 0 ? S.style.fontFamily : t.fontFamily, F = S.style.color !== void 0 ? S.style.color : t.color, D = S.style.bold !== void 0 ? S.style.bold : t.bold || !1, M = S.style.italic !== void 0 ? S.style.italic : t.italic || !1, L = S.style.underline !== void 0 ? S.style.underline : t.underline || !1, kn = S.style.strikethrough !== void 0 ? S.style.strikethrough : t.strikethrough || !1;
462
+ const P = S.style.fontSize !== void 0 ? S.style.fontSize : t.fontSize, I = S.style.fontFamily !== void 0 ? S.style.fontFamily : t.fontFamily, F = S.style.color !== void 0 ? S.style.color : t.color, D = S.style.bold !== void 0 ? S.style.bold : t.bold || !1, O = S.style.italic !== void 0 ? S.style.italic : t.italic || !1, L = S.style.underline !== void 0 ? S.style.underline : t.underline || !1, kn = S.style.strikethrough !== void 0 ? S.style.strikethrough : t.strikethrough || !1;
463
463
  let R = S.text, H = E, Tn = E + S.text.length;
464
464
  if (!x && w > 0 && H < w) {
465
465
  const V = Math.min(w - H, S.text.length);
@@ -474,7 +474,7 @@ function $t(e, n, t, a, r) {
474
474
  }
475
475
  if (E += S.text.length, R.length > 0) {
476
476
  const V = s(S.style);
477
- e.font = B(P, I, D, M), e.fillStyle = F, e.textBaseline = "alphabetic", e.textAlign = "left", Hn(e, R, g, C, V);
477
+ e.font = B(P, I, D, O), e.fillStyle = F, e.textBaseline = "alphabetic", e.textAlign = "left", Hn(e, R, g, C, V);
478
478
  const an = on(e.measureText(R).width, R, V);
479
479
  if (L) {
480
480
  const j = C + P * 0.1;
@@ -515,7 +515,7 @@ function fn(e, n, t = !1, a = !1) {
515
515
  const s = r.measureText("ÁÉÍgjpqy"), c = s.actualBoundingBoxAscent || e * 0.8, i = s.actualBoundingBoxDescent || e * 0.2, l = c + i;
516
516
  return { ascent: c, descent: i, height: l };
517
517
  }
518
- function La(e, n) {
518
+ function Na(e, n) {
519
519
  const t = e.map((r, o) => ({
520
520
  isParagraphStart: !n && o === 0,
521
521
  isParagraphEnd: !n && o === e.length - 1
@@ -528,13 +528,13 @@ function La(e, n) {
528
528
  return s || (i = i.replace(/^ +/, "")), c || (i = i.replace(/ +$/, "")), i;
529
529
  }).filter((r) => r.length > 0);
530
530
  }
531
- function xt(e, n) {
531
+ function vt(e, n) {
532
532
  const t = n.fontSize, a = n.fontFamily, r = n.bold || !1, o = n.italic || !1, s = n.textAlign || "center", c = n.text;
533
533
  e.font = B(t, a, r, o), e.textAlign = s, e.textBaseline = "alphabetic", e.fillStyle = n.color;
534
534
  const i = fn(t, a, r, o), u = -i.height / 2 + i.ascent;
535
535
  Hn(e, c, 0, u, n.letterSpacing);
536
536
  }
537
- function vt(e, n, t, a, r = !1, o = !1, s) {
537
+ function wt(e, n, t, a, r = !1, o = !1, s) {
538
538
  const c = Vn();
539
539
  if (c.font = B(t, a, r, o), e.trim().length === 0)
540
540
  return [e];
@@ -543,7 +543,7 @@ function vt(e, n, t, a, r = !1, o = !1, s) {
543
543
  const k = e.split(`
544
544
  `), _ = [];
545
545
  for (let w = 0; w < k.length; w++) {
546
- const A = k[w], E = vt(A, n, t, a, r, o);
546
+ const A = k[w], E = wt(A, n, t, a, r, o);
547
547
  _.push(...E);
548
548
  }
549
549
  return _;
@@ -571,7 +571,7 @@ function vt(e, n, t, a, r = !1, o = !1, s) {
571
571
  }
572
572
  return m.push(g), m.length > 0 && (m[0] = d + m[0], m[m.length - 1] = m[m.length - 1] + u), m;
573
573
  }
574
- function Na(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1, p = !1, f = !1, $, h) {
574
+ function Ua(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1, p = !1, f = !1, $, h) {
575
575
  e.font = B(r, o, d, u), e.textBaseline = "alphabetic", e.textAlign = s;
576
576
  const b = (w) => {
577
577
  for (const A of w) {
@@ -599,32 +599,32 @@ function Na(e, n, t, a, r, o, s = "left", c = 0, i = 0, l = 1.2, d = !1, u = !1,
599
599
  charIndex: F.charIndex - _
600
600
  // Adjust to line-relative index
601
601
  })) : [];
602
- if (C && (v || I.length > 0 || m) ? I.length > 0 || b(w) ? yt(e, C, w, E, S, r, I, {
602
+ if (C && (v || I.length > 0 || m) ? I.length > 0 || b(w) ? $t(e, C, w, E, S, r, I, {
603
603
  color: e.fillStyle,
604
604
  align: s === "start" || s === "end" ? "left" : s
605
- }) : $ && mt(e, C, w, E, S, r, $, {
605
+ }) : $ && yt(e, C, w, E, S, r, $, {
606
606
  color: e.fillStyle,
607
607
  align: s === "start" || s === "end" ? "left" : s
608
608
  }) : e.fillText(w, E, S), _ += P + 1, p) {
609
609
  const F = ee(w, r, o, d, u);
610
610
  let D = E;
611
611
  s === "center" ? D = E - F / 2 : s === "right" && (D = E - F);
612
- const M = S + r * 0.1;
613
- e.beginPath(), e.moveTo(D, M), e.lineTo(D + F, M), e.lineWidth = Math.max(1, r * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
612
+ const O = S + r * 0.1;
613
+ e.beginPath(), e.moveTo(D, O), e.lineTo(D + F, O), e.lineWidth = Math.max(1, r * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
614
614
  }
615
615
  if (f) {
616
616
  const F = ee(w, r, o, d, u);
617
617
  let D = E;
618
618
  s === "center" ? D = E - F / 2 : s === "right" && (D = E - F);
619
- const M = S - r * 0.25;
620
- e.beginPath(), e.moveTo(D, M), e.lineTo(D + F, M), e.lineWidth = Math.max(1, r * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
619
+ const O = S - r * 0.25;
620
+ e.beginPath(), e.moveTo(D, O), e.lineTo(D + F, O), e.lineWidth = Math.max(1, r * 0.05), e.strokeStyle = e.fillStyle, e.stroke();
621
621
  }
622
622
  });
623
623
  }
624
624
  function In(e, n) {
625
- wt(e, n);
625
+ St(e, n);
626
626
  }
627
- function wt(e, n) {
627
+ function St(e, n) {
628
628
  var r;
629
629
  (r = n.stroke) != null && r.enabled && ke(e, n), e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180);
630
630
  const t = n.transformData, a = ((t == null ? void 0 : t.width) ?? 100) - Q * 2;
@@ -632,7 +632,7 @@ function wt(e, n) {
632
632
  const o = Xe.fromJSON(n.richText);
633
633
  e.save(), e.translate(0, 0);
634
634
  const s = n._lockedLineCount;
635
- $t(
635
+ xt(
636
636
  e,
637
637
  o,
638
638
  {
@@ -699,17 +699,17 @@ function wt(e, n) {
699
699
  }
700
700
  e.restore();
701
701
  }
702
- function Ua(e, n) {
702
+ function Wa(e, n) {
703
703
  var s;
704
704
  const t = n.opacity ?? 1, a = !!((s = n.stroke) != null && s.enabled), r = n.type === "custom";
705
705
  if (t < 1 && a && r) {
706
- St(e, n, t);
706
+ Ct(e, n, t);
707
707
  return;
708
708
  }
709
709
  const o = e.globalAlpha;
710
710
  t !== 1 && (e.globalAlpha = t), Fn(e, n), e.globalAlpha = o;
711
711
  }
712
- function St(e, n, t) {
712
+ function Ct(e, n, t) {
713
713
  var b;
714
714
  const a = n.transformData, r = n.fontSize || 24, o = ((b = n.stroke) == null ? void 0 : b.width) || 0, s = ((a == null ? void 0 : a.width) ?? r * n.text.length * 0.7) + o * 2 + 40, c = r * 3 + o * 2 + 40, i = e.getTransform(), l = Math.max(Math.abs(i.a), Math.abs(i.d), 1), d = Math.ceil(s * l), u = Math.ceil(c * l);
715
715
  let p;
@@ -757,7 +757,7 @@ function Fn(e, n) {
757
757
  Pn.warn(`[canvas-renderer] Unsupported transform type: ${n.type}`), In(e, n);
758
758
  }
759
759
  }
760
- function Ct(e, n) {
760
+ function kt(e, n) {
761
761
  if (typeof OffscreenCanvas < "u")
762
762
  return new OffscreenCanvas(e, n);
763
763
  const t = document.createElement("canvas");
@@ -782,7 +782,7 @@ function tn(e, n, t) {
782
782
  t(e, n);
783
783
  return;
784
784
  }
785
- const _ = Ct(T, k), w = _.getContext("2d");
785
+ const _ = kt(T, k), w = _.getContext("2d");
786
786
  if (!w) {
787
787
  t(e, n);
788
788
  return;
@@ -803,17 +803,17 @@ function tn(e, n, t) {
803
803
  }
804
804
  const D = a.opacity;
805
805
  a.opacity = 1, t(w, n), a.opacity = D;
806
- const M = a.enabled;
807
- a.enabled = !1, t(e, n), a.enabled = M, e.save(), e.resetTransform(), e.globalAlpha = r, e.drawImage(
806
+ const O = a.enabled;
807
+ a.enabled = !1, t(e, n), a.enabled = O, e.save(), e.resetTransform(), e.globalAlpha = r, e.drawImage(
808
808
  _,
809
809
  I,
810
810
  F
811
811
  ), e.restore();
812
812
  }
813
813
  function Te(e, n) {
814
- tn(e, n, kt);
814
+ tn(e, n, Tt);
815
815
  }
816
- function kt(e, n) {
816
+ function Tt(e, n) {
817
817
  const t = n.transformData;
818
818
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.scale(t.scale, t.scale);
819
819
  const a = n.bold ? "bold" : "normal", r = n.italic ? "italic" : "normal";
@@ -835,9 +835,9 @@ function kt(e, n) {
835
835
  e.restore();
836
836
  }
837
837
  function _e(e, n) {
838
- tn(e, n, Tt);
838
+ tn(e, n, _t);
839
839
  }
840
- function Tt(e, n) {
840
+ function _t(e, n) {
841
841
  const t = n.transformData;
842
842
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = B(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
843
843
  const a = n.text.split("");
@@ -848,9 +848,9 @@ function Tt(e, n) {
848
848
  }), e.restore();
849
849
  }
850
850
  function Ee(e, n) {
851
- tn(e, n, _t);
851
+ tn(e, n, Et);
852
852
  }
853
- function _t(e, n) {
853
+ function Et(e, n) {
854
854
  const t = n.transformData;
855
855
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = B(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
856
856
  const a = n.text.split(""), r = a.reduce((c, i) => c + e.measureText(i).width, 0), o = t.width / 2;
@@ -861,9 +861,9 @@ function _t(e, n) {
861
861
  }), e.restore();
862
862
  }
863
863
  function Ae(e, n) {
864
- tn(e, n, Et);
864
+ tn(e, n, At);
865
865
  }
866
- function Et(e, n) {
866
+ function At(e, n) {
867
867
  const t = n.transformData;
868
868
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = B(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
869
869
  const a = n.text.split(""), r = a.reduce((c, i) => c + e.measureText(i).width, 0), o = t.ascendAngle * Math.PI / 180;
@@ -874,9 +874,9 @@ function Et(e, n) {
874
874
  }), e.restore();
875
875
  }
876
876
  function Pe(e, n) {
877
- tn(e, n, At);
877
+ tn(e, n, Pt);
878
878
  }
879
- function At(e, n) {
879
+ function Pt(e, n) {
880
880
  var r;
881
881
  const t = n.transformData;
882
882
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180);
@@ -884,9 +884,9 @@ function At(e, n) {
884
884
  e.transform(1, 0, Math.tan(a), 1, 0, 0), e.font = B(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle", (r = n.stroke) != null && r.enabled && (e.save(), e.strokeStyle = n.stroke.color, e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "round", e.lineJoin = n.stroke.lineJoin || "round", n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity), e.strokeText(n.text, 0, 0), e.restore()), e.fillText(n.text, 0, 0), e.restore();
885
885
  }
886
886
  function Ie(e, n) {
887
- tn(e, n, Pt);
887
+ tn(e, n, It);
888
888
  }
889
- function Pt(e, n) {
889
+ function It(e, n) {
890
890
  const t = n.transformData;
891
891
  e.save(), e.translate(n.x, n.y), e.rotate(-n.rotation * Math.PI / 180), e.font = B(n.fontSize, n.fontFamily, n.bold, n.italic), e.fillStyle = n.color, e.textAlign = "center", e.textBaseline = "middle";
892
892
  const a = n.text.split("");
@@ -899,7 +899,7 @@ function Pt(e, n) {
899
899
  function Y(e) {
900
900
  return (n, t) => e(n, t);
901
901
  }
902
- function It(e, n) {
902
+ function Ft(e, n) {
903
903
  e.save();
904
904
  const t = e.canvas, a = t.width, r = t.height, o = e.getTransform(), s = [];
905
905
  let c = [];
@@ -934,8 +934,8 @@ function jn() {
934
934
  te || (te = !0, q("arch", Y(Ee)), q("ascend", Y(Ae)), q("circle", Y(Te)), q("flag", Y(Ie)), q("lean", Y(Pe)), q("wave", Y(_e)), q(
935
935
  "custom",
936
936
  (e, n) => In(e, n)
937
- ), Ke(It), it(
938
- (e, n) => dt(e, n)
937
+ ), Ke(Ft), ot(
938
+ (e, n) => ft(e, n)
939
939
  ), globalThis.__scElementPaintersInstalled = !0);
940
940
  }
941
941
  jn();
@@ -943,7 +943,7 @@ function qn(e, n, t = {}) {
943
943
  const a = t.mode || "both";
944
944
  switch (e.save(), e.translate(n.x || 0, n.y || 0), e.rotate(-(n.rotation || 0) * Math.PI / 180), n.transformType) {
945
945
  case "image":
946
- Dt(e, n, a, t);
946
+ Ot(e, n, a, t);
947
947
  break;
948
948
  case "shape":
949
949
  Mt(e, n, a, t);
@@ -951,15 +951,15 @@ function qn(e, n, t = {}) {
951
951
  case "group":
952
952
  break;
953
953
  default:
954
- Ft(e, n, a, t);
954
+ Dt(e, n, a, t);
955
955
  break;
956
956
  }
957
957
  e.restore();
958
958
  }
959
- function Ft(e, n, t, a) {
959
+ function Dt(e, n, t, a) {
960
960
  var s;
961
961
  const r = n, o = r.text || "";
962
- o && ((t === "stroke" || t === "both") && ((s = n.stroke) != null && s.enabled) && (e.save(), ke(e, n, { ...a.renderingContext, positionApplied: !0 }), e.restore()), (t === "fill" || t === "both") && (e.save(), xt(e, {
962
+ o && ((t === "stroke" || t === "both") && ((s = n.stroke) != null && s.enabled) && (e.save(), ke(e, n, { ...a.renderingContext, positionApplied: !0 }), e.restore()), (t === "fill" || t === "both") && (e.save(), vt(e, {
963
963
  text: o,
964
964
  fontSize: r.fontSize || 24,
965
965
  fontFamily: r.fontFamily || "Arial",
@@ -970,12 +970,12 @@ function Ft(e, n, t, a) {
970
970
  letterSpacing: r.letterSpacing
971
971
  }), e.restore()));
972
972
  }
973
- function Dt(e, n, t, a) {
973
+ function Ot(e, n, t, a) {
974
974
  var o;
975
975
  if (!n.transformData) return;
976
976
  const r = n.transformData;
977
977
  if (t === "fill" || t === "both")
978
- if (Nt(e, n), a.loadedImage) {
978
+ if (Ut(e, n), a.loadedImage) {
979
979
  e.save(), e.clip();
980
980
  const s = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
981
981
  e.scale(s, c);
@@ -983,13 +983,13 @@ function Dt(e, n, t, a) {
983
983
  e.drawImage(a.loadedImage, -i / 2, -l / 2, i, l), e.restore();
984
984
  } else
985
985
  e.fillStyle = "#cccccc", e.fill();
986
- (t === "stroke" || t === "both") && ((o = n.stroke) != null && o.enabled) && (e.save(), gt(e, n, a.renderingContext), e.restore());
986
+ (t === "stroke" || t === "both") && ((o = n.stroke) != null && o.enabled) && (e.save(), mt(e, n, a.renderingContext), e.restore());
987
987
  }
988
988
  function Mt(e, n, t, a) {
989
989
  var s, c;
990
990
  if (!n.transformData) return;
991
991
  const r = n.transformData, o = ((s = a.renderingContext) == null ? void 0 : s.isKnockout) === !0;
992
- e.beginPath(), Fe(e, r), (t === "fill" || t === "both") && (e.fillStyle = o ? "#000000" : r.fillColor || "#3b82f6", e.globalAlpha = o ? 1 : r.fillOpacity ?? 1, e.fill()), (t === "stroke" || t === "both") && ((c = n.stroke) != null && c.enabled) && (e.save(), Lt(e, n, a.renderingContext), e.restore());
992
+ e.beginPath(), Fe(e, r), (t === "fill" || t === "both") && (e.fillStyle = o ? "#000000" : r.fillColor || "#3b82f6", e.globalAlpha = o ? 1 : r.fillOpacity ?? 1, e.fill()), (t === "stroke" || t === "both") && ((c = n.stroke) != null && c.enabled) && (e.save(), Nt(e, n, a.renderingContext), e.restore());
993
993
  }
994
994
  function Fe(e, n) {
995
995
  const { shapeType: t } = n, a = n.width ?? 100, r = n.height ?? 100;
@@ -998,13 +998,13 @@ function Fe(e, n) {
998
998
  ae(e, n, a, r);
999
999
  break;
1000
1000
  case "circle":
1001
- Ot(e, Math.min(a, r) / 2);
1001
+ Rt(e, Math.min(a, r) / 2);
1002
1002
  break;
1003
1003
  case "ellipse":
1004
- Rt(e, a / 2, r / 2);
1004
+ Bt(e, a / 2, r / 2);
1005
1005
  break;
1006
1006
  case "star":
1007
- Bt(e, n, Math.min(a, r) / 2);
1007
+ Lt(e, n, Math.min(a, r) / 2);
1008
1008
  break;
1009
1009
  default:
1010
1010
  ae(e, n, a, r);
@@ -1018,13 +1018,13 @@ function ae(e, n, t, a) {
1018
1018
  } else
1019
1019
  e.rect(o, s, t, a);
1020
1020
  }
1021
- function Ot(e, n) {
1021
+ function Rt(e, n) {
1022
1022
  e.arc(0, 0, n, 0, Math.PI * 2);
1023
1023
  }
1024
- function Rt(e, n, t) {
1024
+ function Bt(e, n, t) {
1025
1025
  e.ellipse(0, 0, n, t, 0, 0, Math.PI * 2);
1026
1026
  }
1027
- function Bt(e, n, t) {
1027
+ function Lt(e, n, t) {
1028
1028
  const a = Math.max(3, Math.min(20, n.points || 5)), r = Math.max(0.1, Math.min(0.9, n.innerRadius || 0.4)), o = t * r, s = Math.PI / a, c = -Math.PI / 2;
1029
1029
  for (let i = 0; i < a * 2; i++) {
1030
1030
  const l = c + s * i, d = i % 2 === 0 ? t : o, u = Math.cos(l) * d, p = Math.sin(l) * d;
@@ -1032,13 +1032,13 @@ function Bt(e, n, t) {
1032
1032
  }
1033
1033
  e.closePath();
1034
1034
  }
1035
- function Lt(e, n, t) {
1035
+ function Nt(e, n, t) {
1036
1036
  var r;
1037
1037
  if (!((r = n.stroke) != null && r.enabled) || !n.transformData) return;
1038
1038
  const a = (t == null ? void 0 : t.isKnockout) === !0;
1039
1039
  e.save(), a ? (e.strokeStyle = "#000000", e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", e.globalAlpha = 1) : (e.strokeStyle = n.stroke.color, e.lineWidth = n.stroke.width, e.lineCap = n.stroke.lineCap || "butt", e.lineJoin = n.stroke.lineJoin || "miter", n.stroke.opacity !== void 0 && (e.globalAlpha = n.stroke.opacity)), n.stroke.miterLimit !== void 0 && (e.miterLimit = n.stroke.miterLimit), n.stroke.dashArray && n.stroke.dashArray.length > 0 && e.setLineDash(n.stroke.dashArray), !a && n.stroke.feather && n.stroke.feather > 0 && "filter" in e && (e.filter = `blur(${n.stroke.feather}px)`), e.beginPath(), Fe(e, n.transformData), e.stroke(), e.restore();
1040
1040
  }
1041
- function Nt(e, n) {
1041
+ function Ut(e, n) {
1042
1042
  if (!n.transformData) return;
1043
1043
  const { borderRadius: t } = n.transformData, a = n.transformData.width ?? 100, r = n.transformData.height ?? 100, o = -a / 2, s = -r / 2;
1044
1044
  if (e.beginPath(), t && t > 0) {
@@ -1056,21 +1056,21 @@ function Dn(e, n, t, a, r, o, s = "destination-out") {
1056
1056
  }
1057
1057
  const i = e.getTransform();
1058
1058
  e.save();
1059
- const l = n.knockoutParts.scope || "group", d = Ut(n, l, t);
1059
+ const l = n.knockoutParts.scope || "group", d = Wt(n, l, t);
1060
1060
  if (d.length === 0 && l === "artboard") {
1061
- zt(e, n, a), e.restore();
1061
+ Gt(e, n, a), e.restore();
1062
1062
  return;
1063
1063
  }
1064
1064
  if (d.length === 0) {
1065
1065
  a(e, n), e.restore();
1066
1066
  return;
1067
1067
  }
1068
- const u = e.canvas, f = e.getTransform().a, $ = Gt(u.width, u.height), h = $.getContext("2d");
1068
+ const u = e.canvas, f = e.getTransform().a, $ = Ht(u.width, u.height), h = $.getContext("2d");
1069
1069
  if (!h) return;
1070
1070
  h.scale(f, f), r && o && (h.fillStyle = r, h.fillRect(o.x, o.y, o.width, o.height));
1071
1071
  for (const m of d)
1072
1072
  a(h, m);
1073
- n.knockoutParts.fill && !n.knockoutParts.stroke && ((x = n.stroke) != null && x.enabled) && (h.save(), On(h, n), h.restore()), h.save(), h.globalCompositeOperation = s, n.knockoutParts.fill && Mn(h, n), n.knockoutParts.stroke && On(h, n), h.restore(), n.knockoutParts.fill || (h.save(), Mn(h, n), h.restore());
1073
+ n.knockoutParts.fill && !n.knockoutParts.stroke && ((x = n.stroke) != null && x.enabled) && (h.save(), Mn(h, n), h.restore()), h.save(), h.globalCompositeOperation = s, n.knockoutParts.fill && On(h, n), n.knockoutParts.stroke && Mn(h, n), h.restore(), n.knockoutParts.fill || (h.save(), On(h, n), h.restore());
1074
1074
  const b = u.width / f, v = u.height / f;
1075
1075
  e.drawImage($, 0, 0, b, v), e.restore();
1076
1076
  const y = e.getTransform();
@@ -1083,18 +1083,18 @@ function Dn(e, n, t, a, r, o, s = "destination-out") {
1083
1083
  i.f
1084
1084
  );
1085
1085
  }
1086
- function Wa(e, n, t, a, r, o) {
1086
+ function za(e, n, t, a, r, o) {
1087
1087
  Dn(e, n, t, a, r, o, "destination-out");
1088
1088
  }
1089
- function Ut(e, n, t) {
1090
- return n === "artboard" ? De(e, t) : Wt(e, t);
1089
+ function Wt(e, n, t) {
1090
+ return n === "artboard" ? De(e, t) : zt(e, t);
1091
1091
  }
1092
1092
  function De(e, n) {
1093
1093
  const t = n.findIndex((a) => a.id === e.id);
1094
1094
  return t === -1 ? [] : n.slice(0, t);
1095
1095
  }
1096
- function Wt(e, n) {
1097
- const t = Me(e, n);
1096
+ function zt(e, n) {
1097
+ const t = Oe(e, n);
1098
1098
  if (!t)
1099
1099
  return De(e, n);
1100
1100
  if (t.transformType !== "group" || !t.children)
@@ -1102,40 +1102,40 @@ function Wt(e, n) {
1102
1102
  const a = t.children.findIndex((r) => r.id === e.id);
1103
1103
  return a === -1 ? [] : t.children.slice(0, a);
1104
1104
  }
1105
- function Me(e, n) {
1105
+ function Oe(e, n) {
1106
1106
  for (const t of n)
1107
1107
  if (t.transformType === "group" && t.children) {
1108
1108
  if (t.children.some((r) => r.id === e.id))
1109
1109
  return t;
1110
- const a = Me(e, t.children);
1110
+ const a = Oe(e, t.children);
1111
1111
  if (a)
1112
1112
  return a;
1113
1113
  }
1114
1114
  return null;
1115
1115
  }
1116
- function Mn(e, n, t) {
1116
+ function On(e, n, t) {
1117
1117
  qn(e, n, {
1118
1118
  mode: "fill",
1119
1119
  renderingContext: { isKnockout: !0 }
1120
1120
  });
1121
1121
  }
1122
- function On(e, n) {
1122
+ function Mn(e, n) {
1123
1123
  var t;
1124
1124
  (t = n.stroke) != null && t.enabled && qn(e, n, {
1125
1125
  mode: "stroke",
1126
1126
  renderingContext: { isKnockout: !0 }
1127
1127
  });
1128
1128
  }
1129
- function zt(e, n, t) {
1129
+ function Gt(e, n, t) {
1130
1130
  var r;
1131
1131
  const a = n.knockoutParts;
1132
1132
  if (!a) {
1133
1133
  t(e, n);
1134
1134
  return;
1135
1135
  }
1136
- a.fill || (e.save(), Mn(e, n), e.restore()), !a.stroke && ((r = n.stroke) != null && r.enabled) && (e.save(), On(e, n), e.restore());
1136
+ a.fill || (e.save(), On(e, n), e.restore()), !a.stroke && ((r = n.stroke) != null && r.enabled) && (e.save(), Mn(e, n), e.restore());
1137
1137
  }
1138
- function Gt(e, n) {
1138
+ function Ht(e, n) {
1139
1139
  if (typeof OffscreenCanvas < "u")
1140
1140
  return new OffscreenCanvas(e, n);
1141
1141
  if (typeof document < "u") {
@@ -1155,10 +1155,10 @@ function re(e, n, t, a, r = 0) {
1155
1155
  };
1156
1156
  }
1157
1157
  const rn = 64, _n = 512;
1158
- function Ht(e, n) {
1158
+ function Vt(e, n) {
1159
1159
  e.beginPath(), e.arc(n / 2, n / 2, n * 0.45, 0, Math.PI * 2), e.fill();
1160
1160
  }
1161
- function Vt(e, n) {
1161
+ function jt(e, n) {
1162
1162
  const t = n / 2, a = n / 2, r = n * 0.45, o = r * 0.4, s = 5;
1163
1163
  e.beginPath();
1164
1164
  for (let c = 0; c < s * 2; c++) {
@@ -1167,15 +1167,15 @@ function Vt(e, n) {
1167
1167
  }
1168
1168
  e.closePath(), e.fill();
1169
1169
  }
1170
- function jt(e, n) {
1170
+ function qt(e, n) {
1171
1171
  const t = n / 2, a = n * 0.42;
1172
1172
  e.beginPath(), e.moveTo(t, n * 0.82), e.bezierCurveTo(t - a * 1.1, n * 0.6, t - a * 1.3, n * 0.2, t, n * 0.35), e.bezierCurveTo(t + a * 1.3, n * 0.2, t + a * 1.1, n * 0.6, t, n * 0.82), e.closePath(), e.fill();
1173
1173
  }
1174
- function qt(e, n) {
1174
+ function Xt(e, n) {
1175
1175
  const t = n / 2, a = n / 2, r = n * 0.4, o = n * 0.48;
1176
1176
  e.beginPath(), e.moveTo(t, a - o), e.lineTo(t + r, a), e.lineTo(t, a + o), e.lineTo(t - r, a), e.closePath(), e.fill();
1177
1177
  }
1178
- function Xt(e, n) {
1178
+ function Yt(e, n) {
1179
1179
  const t = n / 2, a = n / 2, r = n * 0.44;
1180
1180
  e.beginPath();
1181
1181
  for (let o = 0; o < 6; o++) {
@@ -1184,11 +1184,11 @@ function Xt(e, n) {
1184
1184
  }
1185
1185
  e.closePath(), e.fill();
1186
1186
  }
1187
- function Yt(e, n) {
1187
+ function Kt(e, n) {
1188
1188
  const t = n / 2, a = n * 0.4, r = n * 0.12;
1189
1189
  e.beginPath(), e.moveTo(t, r), e.lineTo(t + a, n * 0.25), e.lineTo(t + a, n * 0.55), e.quadraticCurveTo(t + a * 0.3, n * 0.8, t, n * 0.9), e.quadraticCurveTo(t - a * 0.3, n * 0.8, t - a, n * 0.55), e.lineTo(t - a, n * 0.25), e.closePath(), e.fill();
1190
1190
  }
1191
- function Kt(e, n) {
1191
+ function Jt(e, n) {
1192
1192
  const t = n / 2, a = n / 2;
1193
1193
  let r = 42;
1194
1194
  const o = () => (r = (r * 16807 + 0) % 2147483647, r / 2147483647);
@@ -1198,7 +1198,7 @@ function Kt(e, n) {
1198
1198
  e.beginPath(), e.arc(t + Math.cos(c) * i, a + Math.sin(c) * i, l, 0, Math.PI * 2), e.fill();
1199
1199
  }
1200
1200
  }
1201
- function Jt(e, n) {
1201
+ function Zt(e, n) {
1202
1202
  let t = 123;
1203
1203
  const a = () => (t = (t * 16807 + 0) % 2147483647, t / 2147483647), r = n * 0.08, o = 40;
1204
1204
  e.beginPath(), e.moveTo(r, r);
@@ -1220,7 +1220,7 @@ function Jt(e, n) {
1220
1220
  }
1221
1221
  e.closePath(), e.fill();
1222
1222
  }
1223
- function Zt(e, n) {
1223
+ function Qt(e, n) {
1224
1224
  let t = 77;
1225
1225
  const a = () => (t = (t * 16807 + 0) % 2147483647, t / 2147483647), r = n * 0.25, o = n * 0.75, s = n * 0.1;
1226
1226
  e.beginPath(), e.moveTo(s, r + a() * n * 0.05);
@@ -1234,23 +1234,23 @@ function Zt(e, n) {
1234
1234
  }
1235
1235
  e.closePath(), e.fill();
1236
1236
  }
1237
- function Qt(e, n) {
1237
+ function na(e, n) {
1238
1238
  const t = n / 2, a = n * 0.55;
1239
1239
  e.beginPath(), e.arc(t, a, n * 0.2, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t - n * 0.18, a + n * 0.02, n * 0.15, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t + n * 0.18, a + n * 0.02, n * 0.16, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t - n * 0.06, a - n * 0.14, n * 0.14, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(t + n * 0.1, a - n * 0.12, n * 0.12, 0, Math.PI * 2), e.fill();
1240
1240
  }
1241
- const na = [
1241
+ const ea = [
1242
1242
  // Geometric
1243
- { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: Ht },
1244
- { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: Vt },
1245
- { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: jt },
1246
- { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: qt },
1247
- { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: Xt },
1248
- { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: Yt },
1243
+ { id: "circle", name: "Circle", description: "Perfect circle", imageUrl: "builtin-mask:circle", thumbnailUrl: "", category: "geometric", draw: Vt },
1244
+ { id: "star", name: "Star", description: "5-pointed star", imageUrl: "builtin-mask:star", thumbnailUrl: "", category: "geometric", draw: jt },
1245
+ { id: "heart", name: "Heart", description: "Heart shape", imageUrl: "builtin-mask:heart", thumbnailUrl: "", category: "geometric", draw: qt },
1246
+ { id: "diamond", name: "Diamond", description: "Diamond/rhombus", imageUrl: "builtin-mask:diamond", thumbnailUrl: "", category: "geometric", draw: Xt },
1247
+ { id: "hexagon", name: "Hexagon", description: "Regular hexagon", imageUrl: "builtin-mask:hexagon", thumbnailUrl: "", category: "geometric", draw: Yt },
1248
+ { id: "shield", name: "Shield", description: "Shield/crest shape", imageUrl: "builtin-mask:shield", thumbnailUrl: "", category: "geometric", draw: Kt },
1249
1249
  // Organic
1250
- { id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: Kt },
1251
- { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: Jt },
1252
- { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: Zt },
1253
- { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: Qt }
1250
+ { id: "splatter", name: "Splatter", description: "Ink splatter", imageUrl: "builtin-mask:splatter", thumbnailUrl: "", category: "organic", draw: Jt },
1251
+ { id: "torn-edge", name: "Torn Edge", description: "Rough torn paper edge", imageUrl: "builtin-mask:torn-edge", thumbnailUrl: "", category: "organic", draw: Zt },
1252
+ { id: "paint-stroke", name: "Paint Stroke", description: "Horizontal brush stroke", imageUrl: "builtin-mask:paint-stroke", thumbnailUrl: "", category: "organic", draw: Qt },
1253
+ { id: "cloud", name: "Cloud", description: "Soft cloud shape", imageUrl: "builtin-mask:cloud", thumbnailUrl: "", category: "organic", draw: na }
1254
1254
  ];
1255
1255
  let se = !1;
1256
1256
  function ie(e, n) {
@@ -1258,11 +1258,11 @@ function ie(e, n) {
1258
1258
  const t = document.createElement("canvas");
1259
1259
  return t.width = e, t.height = n, t;
1260
1260
  }
1261
- function ea() {
1261
+ function ta() {
1262
1262
  if (typeof document > "u" || se) return;
1263
1263
  se = !0;
1264
1264
  const e = wn.getInstance();
1265
- for (const n of na) {
1265
+ for (const n of ea) {
1266
1266
  const t = ie(_n, _n);
1267
1267
  if (!t) continue;
1268
1268
  const a = t.getContext("2d");
@@ -1277,14 +1277,14 @@ function ea() {
1277
1277
  }
1278
1278
  }
1279
1279
  }
1280
- const ta = U("MaskRenderer"), Rn = /* @__PURE__ */ new Map(), aa = /* @__PURE__ */ new Map();
1281
- function za(e) {
1280
+ const aa = U("MaskRenderer"), Rn = /* @__PURE__ */ new Map(), ra = /* @__PURE__ */ new Map();
1281
+ function Ga(e) {
1282
1282
  const n = [];
1283
1283
  Rn.forEach((t, a) => {
1284
1284
  a.startsWith(e) && n.push(a);
1285
1285
  }), n.forEach((t) => Rn.delete(t));
1286
1286
  }
1287
- function Ga() {
1287
+ function Ha() {
1288
1288
  Rn.clear();
1289
1289
  }
1290
1290
  function oe(e, n, t) {
@@ -1294,38 +1294,38 @@ function oe(e, n, t) {
1294
1294
  }
1295
1295
  const a = e.canvas, r = gn(a.width, a.height), o = r.getContext("2d");
1296
1296
  if (!o) {
1297
- ta.error("[renderWithMasks] Failed to get offscreen context");
1297
+ aa.error("[renderWithMasks] Failed to get offscreen context");
1298
1298
  return;
1299
1299
  }
1300
1300
  const s = e.getTransform();
1301
1301
  o.setTransform(s), t(o);
1302
1302
  for (const c of n.masks)
1303
- ra(o, c, n);
1303
+ sa(o, c, n);
1304
1304
  e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(r, 0, 0), e.restore();
1305
1305
  }
1306
- function ra(e, n, t) {
1306
+ function sa(e, n, t) {
1307
1307
  switch (n.type) {
1308
1308
  case "clip":
1309
- sa(e, n, t);
1309
+ ia(e, n, t);
1310
1310
  break;
1311
1311
  case "alpha":
1312
- ia(e, n, t);
1312
+ oa(e, n, t);
1313
1313
  break;
1314
1314
  case "luma":
1315
- oa(e, n, t);
1315
+ ca(e, n, t);
1316
1316
  break;
1317
1317
  case "distress":
1318
- ca(e, n, t);
1318
+ la(e, n, t);
1319
1319
  break;
1320
1320
  }
1321
1321
  }
1322
- function sa(e, n, t) {
1323
- e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), e.restore();
1324
- }
1325
1322
  function ia(e, n, t) {
1326
- e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), n.feather && n.feather > 0 && Oe(e, n.feather), e.restore();
1323
+ e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), e.restore();
1327
1324
  }
1328
1325
  function oa(e, n, t) {
1326
+ e.save(), e.globalCompositeOperation = n.inverted ? "destination-out" : "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), n.feather && n.feather > 0 && Me(e, n.feather), e.restore();
1327
+ }
1328
+ function ca(e, n, t) {
1329
1329
  const a = gn(e.canvas.width, e.canvas.height), r = a.getContext("2d");
1330
1330
  if (!r) return;
1331
1331
  Sn(r, n.maskElement, t);
@@ -1336,8 +1336,8 @@ function oa(e, n, t) {
1336
1336
  }
1337
1337
  r.putImageData(o, 0, 0), e.save(), e.globalCompositeOperation = "destination-in", n.opacity !== void 0 && (e.globalAlpha = n.opacity), e.drawImage(a, 0, 0), e.restore();
1338
1338
  }
1339
- function ca(e, n, t) {
1340
- e.save(), e.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), n.feather && n.feather > 0 && Oe(e, n.feather), e.restore();
1339
+ function la(e, n, t) {
1340
+ e.save(), e.globalCompositeOperation = n.inverted ? "destination-in" : "destination-out", n.opacity !== void 0 && (e.globalAlpha = n.opacity), Sn(e, n.maskElement, t), n.feather && n.feather > 0 && Me(e, n.feather), e.restore();
1341
1341
  }
1342
1342
  function Sn(e, n, t) {
1343
1343
  const a = t.x || 0, r = t.y || 0, o = n.x || 0, s = n.y || 0, c = {
@@ -1357,11 +1357,11 @@ function Sn(e, n, t) {
1357
1357
  const m = n;
1358
1358
  if (m.imageUrl)
1359
1359
  if (typeof document < "u") {
1360
- m.imageUrl.startsWith("builtin-mask:") && ea();
1360
+ m.imageUrl.startsWith("builtin-mask:") && ta();
1361
1361
  const g = wn.getInstance(), C = g.acquire(m.imageUrl);
1362
1362
  C.complete && C.naturalWidth > 0 && ($ = C), g.release(m.imageUrl);
1363
1363
  } else
1364
- h = aa.get(m.imageUrl);
1364
+ h = ra.get(m.imageUrl);
1365
1365
  }
1366
1366
  const b = c.transformData, v = (f == null ? void 0 : f.width) || 0, y = (f == null ? void 0 : f.height) || 0, x = v > 0 && y > 0 && u > 0 && p > 0 && Math.abs(v / y - u / p) > 1e-3;
1367
1367
  if (h) {
@@ -1391,7 +1391,7 @@ function Sn(e, n, t) {
1391
1391
  } else
1392
1392
  qn(e, c, { mode: "both", loadedImage: $ });
1393
1393
  }
1394
- function Oe(e, n) {
1394
+ function Me(e, n) {
1395
1395
  "filter" in e && (e.filter = `blur(${n}px)`);
1396
1396
  }
1397
1397
  function gn(e, n) {
@@ -1403,7 +1403,7 @@ function gn(e, n) {
1403
1403
  }
1404
1404
  throw new Error("No canvas context available");
1405
1405
  }
1406
- function la(e, n, t, a) {
1406
+ function da(e, n, t, a) {
1407
1407
  if (!n.enabled || !n.imageUrl || n.opacity <= 0) return;
1408
1408
  const r = wn.getInstance(), o = r.acquire(n.imageUrl);
1409
1409
  if (!o.complete || o.naturalWidth === 0) {
@@ -1447,7 +1447,7 @@ function la(e, n, t, a) {
1447
1447
  y.globalCompositeOperation = x, y.globalAlpha = n.opacity / 100, y.drawImage(o, 0, 0, h, b);
1448
1448
  y.globalCompositeOperation = "source-over", y.globalAlpha = 1, e.save(), e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(u, p, f, $), a && (e.fillStyle = a, e.fillRect(u, p, f, $)), e.drawImage(v, u, p), e.restore(), r.release(n.imageUrl);
1449
1449
  }
1450
- class da {
1450
+ class fa {
1451
1451
  constructor(n = Math.random()) {
1452
1452
  this.perm = [];
1453
1453
  for (let a = 0; a < 256; a++)
@@ -1486,7 +1486,7 @@ class da {
1486
1486
  }
1487
1487
  }
1488
1488
  function En(e, n, t, a = Date.now()) {
1489
- const s = Cn(e, n).getContext("2d").createImageData(e, n), c = s.data, i = new da(a), l = 0.02, d = 1 - t / 100;
1489
+ const s = Cn(e, n).getContext("2d").createImageData(e, n), c = s.data, i = new fa(a), l = 0.02, d = 1 - t / 100;
1490
1490
  for (let u = 0; u < n; u++)
1491
1491
  for (let p = 0; p < e; p++) {
1492
1492
  const f = (u * e + p) * 4;
@@ -1499,7 +1499,7 @@ function En(e, n, t, a = Date.now()) {
1499
1499
  }
1500
1500
  return s;
1501
1501
  }
1502
- function fa(e, n, t, a = Date.now()) {
1502
+ function ua(e, n, t, a = Date.now()) {
1503
1503
  const o = Cn(e, n).getContext("2d");
1504
1504
  o.clearRect(0, 0, e, n), o.strokeStyle = "#000000", o.lineWidth = 1 + t / 50, o.lineCap = "round";
1505
1505
  const s = Xn(a), c = Math.floor(t / 100 * 30 + 5);
@@ -1530,7 +1530,7 @@ function bn(e, n, t, a = Date.now()) {
1530
1530
  }
1531
1531
  return s;
1532
1532
  }
1533
- function ua(e, n, t, a = Date.now()) {
1533
+ function pa(e, n, t, a = Date.now()) {
1534
1534
  const o = Cn(e, n).getContext("2d");
1535
1535
  o.fillStyle = "#000000";
1536
1536
  const s = Xn(a), c = 4 + t / 100 * 6, i = c * 2;
@@ -1562,13 +1562,13 @@ function Ln(e) {
1562
1562
  n[t] = 255, n[t + 1] = 255, n[t + 2] = 255;
1563
1563
  return e;
1564
1564
  }
1565
- function pa(e, n) {
1565
+ function ha(e, n) {
1566
1566
  const t = e.data, a = n.data;
1567
1567
  for (let r = 0; r < t.length; r += 4)
1568
1568
  t[r] = 255, t[r + 1] = 255, t[r + 2] = 255, t[r + 3] = Math.min(255, t[r + 3] + a[r + 3]);
1569
1569
  return e;
1570
1570
  }
1571
- const ha = [
1571
+ const ba = [
1572
1572
  {
1573
1573
  id: "grunge-heavy",
1574
1574
  name: "Heavy Grunge",
@@ -1609,7 +1609,7 @@ const ha = [
1609
1609
  description: "Noise + splatter combined",
1610
1610
  generate: (e, n) => {
1611
1611
  const t = En(e, n, 45, N + 4), a = bn(e, n, 35, N + 5);
1612
- return pa(Ln(t), Ln(a));
1612
+ return ha(Ln(t), Ln(a));
1613
1613
  }
1614
1614
  },
1615
1615
  {
@@ -1618,7 +1618,7 @@ const ha = [
1618
1618
  textureUrl: "builtin:scratches",
1619
1619
  thumbnailUrl: "",
1620
1620
  description: "Branching crack lines",
1621
- generate: (e, n) => fa(e, n, 55, N + 6)
1621
+ generate: (e, n) => ua(e, n, 55, N + 6)
1622
1622
  },
1623
1623
  {
1624
1624
  id: "halftone",
@@ -1626,7 +1626,7 @@ const ha = [
1626
1626
  textureUrl: "builtin:halftone",
1627
1627
  thumbnailUrl: "",
1628
1628
  description: "Dot grid pattern",
1629
- generate: (e, n) => ua(e, n, 55, N + 7)
1629
+ generate: (e, n) => pa(e, n, 55, N + 7)
1630
1630
  },
1631
1631
  {
1632
1632
  id: "spray",
@@ -1638,7 +1638,7 @@ const ha = [
1638
1638
  }
1639
1639
  ];
1640
1640
  let ce = !1;
1641
- function ba(e, n) {
1641
+ function ga(e, n) {
1642
1642
  if (typeof OffscreenCanvas < "u")
1643
1643
  return new OffscreenCanvas(e, n);
1644
1644
  const t = document.createElement("canvas");
@@ -1649,7 +1649,7 @@ function le(e, n) {
1649
1649
  const t = document.createElement("canvas");
1650
1650
  return t.width = e, t.height = n, t;
1651
1651
  }
1652
- function ga(e) {
1652
+ function ma(e) {
1653
1653
  const n = le(e.width, e.height);
1654
1654
  if (!n) return "";
1655
1655
  const t = n.getContext("2d");
@@ -1667,14 +1667,14 @@ function ga(e) {
1667
1667
  }
1668
1668
  return r.putImageData(o, 0, 0), a.toDataURL("image/png");
1669
1669
  }
1670
- function ma() {
1670
+ function ya() {
1671
1671
  if (!ce) {
1672
1672
  ce = !0;
1673
- for (const e of ha) {
1673
+ for (const e of ba) {
1674
1674
  const n = e.generate(K, K);
1675
1675
  Ln(n);
1676
- const t = ba(K, K), a = t.getContext("2d");
1677
- a && (a.putImageData(n, 0, 0), ya(e.textureUrl, t, K, K)), typeof document < "u" && (e.thumbnailUrl = ga(n));
1676
+ const t = ga(K, K), a = t.getContext("2d");
1677
+ a && (a.putImageData(n, 0, 0), $a(e.textureUrl, t, K, K)), typeof document < "u" && (e.thumbnailUrl = ma(n));
1678
1678
  }
1679
1679
  }
1680
1680
  }
@@ -1705,13 +1705,13 @@ function Re(e) {
1705
1705
  const n = G.get(e);
1706
1706
  if (n) return n;
1707
1707
  if (e.startsWith("builtin:")) {
1708
- ma();
1708
+ ya();
1709
1709
  const t = G.get(e);
1710
1710
  return t || null;
1711
1711
  }
1712
1712
  return z.has(e) || (z.add(e), Be(e)), null;
1713
1713
  }
1714
- function Ha(e) {
1714
+ function Va(e) {
1715
1715
  return G.has(e) ? Promise.resolve() : new Promise((n) => {
1716
1716
  if (G.has(e)) {
1717
1717
  n();
@@ -1721,7 +1721,7 @@ function Ha(e) {
1721
1721
  t.push(n), mn.set(e, t), z.has(e) || (z.add(e), Be(e));
1722
1722
  });
1723
1723
  }
1724
- function ya(e, n, t, a) {
1724
+ function $a(e, n, t, a) {
1725
1725
  G.has(e) || (G.set(e, { alphaMask: n, width: t, height: a }), sn(e));
1726
1726
  }
1727
1727
  function sn(e) {
@@ -1751,7 +1751,7 @@ function Le(e, n) {
1751
1751
  const t = document.createElement("canvas");
1752
1752
  return t.width = e, t.height = n, t;
1753
1753
  }
1754
- function $a(e, n, t, a) {
1754
+ function xa(e, n, t, a) {
1755
1755
  if (!n.enabled || !n.textureUrl || n.intensity <= 0) return;
1756
1756
  const r = Re(n.textureUrl);
1757
1757
  if (!r) return;
@@ -2300,11 +2300,11 @@ const he = U("ImportManager"), Kn = class Kn {
2300
2300
  Kn.SUPPORTED_VERSIONS = ["1.0.0", "2.0.0"];
2301
2301
  let be = Kn;
2302
2302
  const ge = U("element-serializer"), Ne = 4e3, un = /* @__PURE__ */ new Set();
2303
- function xa(e, n) {
2304
- const t = n ? va(n) : "no-src";
2303
+ function va(e, n) {
2304
+ const t = n ? wa(n) : "no-src";
2305
2305
  return `${e}:${t}`;
2306
2306
  }
2307
- function va(e) {
2307
+ function wa(e) {
2308
2308
  let n = 0;
2309
2309
  for (let t = 0; t < e.length; t++) {
2310
2310
  const a = e.charCodeAt(t);
@@ -2319,13 +2319,13 @@ function Ue(e) {
2319
2319
  for (const n of un)
2320
2320
  n.startsWith(`${e}:`) && un.delete(n);
2321
2321
  }
2322
- function wa(e) {
2322
+ function Sa(e) {
2323
2323
  un.add(e);
2324
2324
  }
2325
- function Sa(e) {
2325
+ function Ca(e) {
2326
2326
  return un.has(e);
2327
2327
  }
2328
- async function Ca(e, n = Ne) {
2328
+ async function ka(e, n = Ne) {
2329
2329
  const { naturalWidth: t, naturalHeight: a } = e;
2330
2330
  if (t <= n && a <= n)
2331
2331
  return createImageBitmap(e);
@@ -2337,16 +2337,16 @@ async function Ca(e, n = Ne) {
2337
2337
  });
2338
2338
  }
2339
2339
  let $n = null, xn = null;
2340
- function ka(e, n) {
2340
+ function Ta(e, n) {
2341
2341
  $n = e, xn = n;
2342
2342
  }
2343
- function Ta() {
2343
+ function _a() {
2344
2344
  $n = null, xn = null;
2345
2345
  }
2346
- function Va() {
2346
+ function ja() {
2347
2347
  Nn(), $n && $n();
2348
2348
  }
2349
- function ja(e) {
2349
+ function qa(e) {
2350
2350
  Ue(e), xn && xn(e);
2351
2351
  }
2352
2352
  function Un(e, n) {
@@ -2397,10 +2397,10 @@ async function ye(e, n, t = Ne) {
2397
2397
  }
2398
2398
  if (i instanceof An && i.imageElement)
2399
2399
  try {
2400
- const d = xa(i.id, i.imageUrl);
2401
- if (!Sa(d)) {
2402
- const x = await Ca(i.imageElement, t);
2403
- o.push({ cacheKey: d, bitmap: x }), wa(d);
2400
+ const d = va(i.id, i.imageUrl);
2401
+ if (!Ca(d)) {
2402
+ const x = await ka(i.imageElement, t);
2403
+ o.push({ cacheKey: d, bitmap: x }), Sa(d);
2404
2404
  }
2405
2405
  const p = i.transformData || {}, f = l.masks && l.masks.length > 0, $ = f ? p.width : p.width * (p.cropWidth ?? 1), h = f ? p.height : p.height * (p.cropHeight ?? 1), b = {
2406
2406
  id: i.id,
@@ -2417,7 +2417,7 @@ async function ye(e, n, t = Ne) {
2417
2417
  let g = 1;
2418
2418
  (x > t || m > t) && (g = t / Math.max(x, m)), b.cropX = p.cropX * x * g, b.cropY = p.cropY * m * g, b.cropWidth = p.cropWidth * x * g, b.cropHeight = p.cropHeight * m * g;
2419
2419
  }
2420
- p.flipHorizontal && (b.flipHorizontal = p.flipHorizontal), p.flipVertical && (b.flipVertical = p.flipVertical), p.borderRadius && (b.borderRadius = p.borderRadius), i.opacity !== void 0 && (b.opacity = i.opacity);
2420
+ p.flipHorizontal && (b.flipHorizontal = p.flipHorizontal), p.flipVertical && (b.flipVertical = p.flipVertical), p.borderRadius && (b.borderRadius = p.borderRadius), it(p.adjustments) || (b.adjustments = { ...p.adjustments }), i.opacity !== void 0 && (b.opacity = i.opacity);
2421
2421
  const y = b;
2422
2422
  i.distressEffect && (y.distressEffect = { ...i.distressEffect }), l.masks && l.masks.length > 0 && (y.masks = me(l.masks)), l.blendMode && (y.blendMode = l.blendMode), l.knockoutParts && (y.knockoutParts = l.knockoutParts), "getVisualBoundingBox" in i && typeof i.getVisualBoundingBox == "function" ? y._boundingBox = i.getVisualBoundingBox() : "getBoundingBox" in i && typeof i.getBoundingBox == "function" && (y._boundingBox = i.getBoundingBox()), r.push(y);
2423
2423
  } catch (d) {
@@ -2454,7 +2454,7 @@ async function ye(e, n, t = Ne) {
2454
2454
  newBitmaps: o
2455
2455
  };
2456
2456
  }
2457
- const _a = `"use strict";
2457
+ const Ea = `"use strict";
2458
2458
  (() => {
2459
2459
  var __create = Object.create;
2460
2460
  var __defProp = Object.defineProperty;
@@ -22778,8 +22778,8 @@ const _a = `"use strict";
22778
22778
  }
22779
22779
  };
22780
22780
  var ScopedLogger = class {
22781
- constructor(logger4, scopeName) {
22782
- this.logger = logger4;
22781
+ constructor(logger5, scopeName) {
22782
+ this.logger = logger5;
22783
22783
  this.scopeName = scopeName;
22784
22784
  }
22785
22785
  debug(message, ...args) {
@@ -24026,6 +24026,141 @@ const _a = `"use strict";
24026
24026
  }
24027
24027
  }
24028
24028
 
24029
+ // src/core/image-adjustments.ts
24030
+ var NEUTRAL_ADJUSTMENTS = Object.freeze({
24031
+ brightness: 1,
24032
+ contrast: 1,
24033
+ saturation: 1
24034
+ });
24035
+ var EPSILON = 1e-3;
24036
+ function isNeutralAdjustments(adjustments) {
24037
+ if (!adjustments) return true;
24038
+ return Math.abs(adjustments.brightness - 1) < EPSILON && Math.abs(adjustments.contrast - 1) < EPSILON && Math.abs(adjustments.saturation - 1) < EPSILON;
24039
+ }
24040
+ function adjustmentsCacheKey(adjustments) {
24041
+ if (isNeutralAdjustments(adjustments)) return "neutral";
24042
+ const a = adjustments;
24043
+ return \`b\${a.brightness}c\${a.contrast}s\${a.saturation}\`;
24044
+ }
24045
+ var adjustedImageSourceProvider = null;
24046
+ function registerAdjustedImageSourceProvider(provider) {
24047
+ adjustedImageSourceProvider = provider;
24048
+ }
24049
+
24050
+ // src/rendering/image-adjustments.ts
24051
+ var logger3 = createLogger("image-adjustments");
24052
+ var EPSILON2 = 1e-3;
24053
+ function applyAdjustmentsToPixels(data, adjustments) {
24054
+ const { brightness, contrast, saturation } = adjustments;
24055
+ const slope = brightness * contrast;
24056
+ const intercept = 127.5 * (1 - contrast);
24057
+ const applyLut = Math.abs(slope - 1) > EPSILON2 || Math.abs(intercept) > EPSILON2;
24058
+ const lut = new Uint8ClampedArray(256);
24059
+ if (applyLut) {
24060
+ for (let v = 0; v < 256; v++) lut[v] = v * slope + intercept;
24061
+ }
24062
+ const applySaturation = Math.abs(saturation - 1) > EPSILON2;
24063
+ const s = saturation;
24064
+ const rr = 0.213 + 0.787 * s;
24065
+ const rg = 0.715 - 0.715 * s;
24066
+ const rb = 0.072 - 0.072 * s;
24067
+ const gr = 0.213 - 0.213 * s;
24068
+ const gg = 0.715 + 0.285 * s;
24069
+ const gb = 0.072 - 0.072 * s;
24070
+ const br = 0.213 - 0.213 * s;
24071
+ const bg = 0.715 - 0.715 * s;
24072
+ const bb = 0.072 + 0.928 * s;
24073
+ for (let i = 0; i < data.length; i += 4) {
24074
+ let r = data[i];
24075
+ let g = data[i + 1];
24076
+ let b = data[i + 2];
24077
+ if (applyLut) {
24078
+ r = lut[r];
24079
+ g = lut[g];
24080
+ b = lut[b];
24081
+ }
24082
+ if (applySaturation) {
24083
+ const r2 = rr * r + rg * g + rb * b;
24084
+ const g2 = gr * r + gg * g + gb * b;
24085
+ const b2 = br * r + bg * g + bb * b;
24086
+ r = r2;
24087
+ g = g2;
24088
+ b = b2;
24089
+ }
24090
+ data[i] = r;
24091
+ data[i + 1] = g;
24092
+ data[i + 2] = b;
24093
+ }
24094
+ }
24095
+ var adjustedSourceCache = /* @__PURE__ */ new WeakMap();
24096
+ var MAX_VARIANTS_PER_SOURCE = 4;
24097
+ function sourcePixelWidth(source) {
24098
+ const natural = source.naturalWidth;
24099
+ return typeof natural === "number" && natural > 0 ? natural : source.width;
24100
+ }
24101
+ function sourcePixelHeight(source) {
24102
+ const natural = source.naturalHeight;
24103
+ return typeof natural === "number" && natural > 0 ? natural : source.height;
24104
+ }
24105
+ function createCanvas(width, height) {
24106
+ if (typeof OffscreenCanvas !== "undefined") {
24107
+ return new OffscreenCanvas(width, height);
24108
+ }
24109
+ if (typeof document !== "undefined") {
24110
+ const canvas = document.createElement("canvas");
24111
+ canvas.width = width;
24112
+ canvas.height = height;
24113
+ return canvas;
24114
+ }
24115
+ throw new Error("image-adjustments: no canvas implementation available (no OffscreenCanvas, no DOM)");
24116
+ }
24117
+ function renderAdjustedSource(source, adjustments) {
24118
+ const width = sourcePixelWidth(source);
24119
+ const height = sourcePixelHeight(source);
24120
+ if (width <= 0 || height <= 0) {
24121
+ throw new Error("image-adjustments: source has no pixels (width/height is 0)");
24122
+ }
24123
+ const canvas = createCanvas(width, height);
24124
+ const ctx = canvas.getContext("2d");
24125
+ if (!ctx) {
24126
+ throw new Error("image-adjustments: could not acquire a 2d context");
24127
+ }
24128
+ ctx.drawImage(source, 0, 0, width, height);
24129
+ const imageData = ctx.getImageData(0, 0, width, height);
24130
+ applyAdjustmentsToPixels(imageData.data, adjustments);
24131
+ ctx.putImageData(imageData, 0, 0);
24132
+ return canvas;
24133
+ }
24134
+ function getAdjustedImageSource(source, adjustments) {
24135
+ if (isNeutralAdjustments(adjustments)) return source;
24136
+ const key = adjustmentsCacheKey(adjustments);
24137
+ let variants = adjustedSourceCache.get(source);
24138
+ const cached = variants?.get(key);
24139
+ if (cached) {
24140
+ variants.delete(key);
24141
+ variants.set(key, cached);
24142
+ return cached;
24143
+ }
24144
+ let result;
24145
+ try {
24146
+ result = renderAdjustedSource(source, adjustments);
24147
+ } catch (error) {
24148
+ logger3.error("adjustment pixel pass failed \\u2014 rendering UNADJUSTED source:", error);
24149
+ result = source;
24150
+ }
24151
+ if (!variants) {
24152
+ variants = /* @__PURE__ */ new Map();
24153
+ adjustedSourceCache.set(source, variants);
24154
+ }
24155
+ variants.set(key, result);
24156
+ while (variants.size > MAX_VARIANTS_PER_SOURCE) {
24157
+ const oldest = variants.keys().next().value;
24158
+ variants.delete(oldest);
24159
+ }
24160
+ return result;
24161
+ }
24162
+ registerAdjustedImageSourceProvider(getAdjustedImageSource);
24163
+
24029
24164
  // src/rendering/image-renderer.ts
24030
24165
  function resolveServerCrop(el, bitmap) {
24031
24166
  if (!el.needsCropPixelConversion || el.cropWidth === void 0) return el;
@@ -24039,6 +24174,10 @@ const _a = `"use strict";
24039
24174
  };
24040
24175
  }
24041
24176
  function renderImageElement(ctx, elementData, imageBitmap) {
24177
+ const source = getAdjustedImageSource(
24178
+ imageBitmap,
24179
+ elementData.adjustments
24180
+ );
24042
24181
  ctx.save();
24043
24182
  ctx.translate(elementData.x, elementData.y);
24044
24183
  if (elementData.rotation) {
@@ -24079,7 +24218,7 @@ const _a = `"use strict";
24079
24218
  }
24080
24219
  if (elementData.cropX !== void 0 && elementData.cropWidth !== void 0) {
24081
24220
  ctx.drawImage(
24082
- imageBitmap,
24221
+ source,
24083
24222
  elementData.cropX,
24084
24223
  elementData.cropY || 0,
24085
24224
  elementData.cropWidth,
@@ -24090,7 +24229,7 @@ const _a = `"use strict";
24090
24229
  elementData.height
24091
24230
  );
24092
24231
  } else {
24093
- ctx.drawImage(imageBitmap, -elementData.width / 2, -elementData.height / 2, elementData.width, elementData.height);
24232
+ ctx.drawImage(source, -elementData.width / 2, -elementData.height / 2, elementData.width, elementData.height);
24094
24233
  }
24095
24234
  ctx.restore();
24096
24235
  if (elementData.stroke?.enabled) {
@@ -24695,7 +24834,7 @@ const _a = `"use strict";
24695
24834
  }
24696
24835
  };
24697
24836
  function generateWornEffect(width, height, intensity, seed = Date.now()) {
24698
- const canvas = createCanvas(width, height);
24837
+ const canvas = createCanvas2(width, height);
24699
24838
  const ctx = canvas.getContext("2d");
24700
24839
  const imageData = ctx.createImageData(width, height);
24701
24840
  const data = imageData.data;
@@ -24724,7 +24863,7 @@ const _a = `"use strict";
24724
24863
  return imageData;
24725
24864
  }
24726
24865
  function generateCrackedEffect(width, height, intensity, seed = Date.now()) {
24727
- const canvas = createCanvas(width, height);
24866
+ const canvas = createCanvas2(width, height);
24728
24867
  const ctx = canvas.getContext("2d");
24729
24868
  ctx.clearRect(0, 0, width, height);
24730
24869
  ctx.strokeStyle = "#000000";
@@ -24757,7 +24896,7 @@ const _a = `"use strict";
24757
24896
  }
24758
24897
  }
24759
24898
  function generateGrungeEffect(width, height, intensity, seed = Date.now()) {
24760
- const canvas = createCanvas(width, height);
24899
+ const canvas = createCanvas2(width, height);
24761
24900
  const ctx = canvas.getContext("2d");
24762
24901
  const imageData = ctx.createImageData(width, height);
24763
24902
  const data = imageData.data;
@@ -24777,7 +24916,7 @@ const _a = `"use strict";
24777
24916
  return imageData;
24778
24917
  }
24779
24918
  function generateRetroEffect(width, height, intensity, seed = Date.now()) {
24780
- const canvas = createCanvas(width, height);
24919
+ const canvas = createCanvas2(width, height);
24781
24920
  const ctx = canvas.getContext("2d");
24782
24921
  ctx.fillStyle = "#000000";
24783
24922
  const random = seededRandom(seed);
@@ -24795,7 +24934,7 @@ const _a = `"use strict";
24795
24934
  }
24796
24935
  return ctx.getImageData(0, 0, width, height);
24797
24936
  }
24798
- function createCanvas(width, height) {
24937
+ function createCanvas2(width, height) {
24799
24938
  if (typeof OffscreenCanvas !== "undefined") {
24800
24939
  return new OffscreenCanvas(width, height);
24801
24940
  } else if (typeof document !== "undefined") {
@@ -24909,7 +25048,7 @@ const _a = `"use strict";
24909
25048
  }
24910
25049
  ];
24911
25050
  var initialized = false;
24912
- function createCanvas2(width, height) {
25051
+ function createCanvas3(width, height) {
24913
25052
  if (typeof OffscreenCanvas !== "undefined") {
24914
25053
  return new OffscreenCanvas(width, height);
24915
25054
  }
@@ -24955,7 +25094,7 @@ const _a = `"use strict";
24955
25094
  for (const preset of DISTRESS_TEXTURE_PRESETS) {
24956
25095
  const imageData = preset.generate(TEX_SIZE, TEX_SIZE);
24957
25096
  toAlphaMask(imageData);
24958
- const maskCanvas = createCanvas2(TEX_SIZE, TEX_SIZE);
25097
+ const maskCanvas = createCanvas3(TEX_SIZE, TEX_SIZE);
24959
25098
  const maskCtx = maskCanvas.getContext("2d");
24960
25099
  if (maskCtx) {
24961
25100
  maskCtx.putImageData(imageData, 0, 0);
@@ -24971,7 +25110,7 @@ const _a = `"use strict";
24971
25110
  var loadingUrls = /* @__PURE__ */ new Set();
24972
25111
  var cache = /* @__PURE__ */ new Map();
24973
25112
  var pendingCallbacks = /* @__PURE__ */ new Map();
24974
- function createCanvas3(width, height) {
25113
+ function createCanvas4(width, height) {
24975
25114
  if (typeof OffscreenCanvas !== "undefined") {
24976
25115
  return new OffscreenCanvas(width, height);
24977
25116
  }
@@ -24985,7 +25124,7 @@ const _a = `"use strict";
24985
25124
  }
24986
25125
  function convertToAlphaMask(source) {
24987
25126
  const { width, height } = source;
24988
- const tempCanvas = createCanvas3(width, height);
25127
+ const tempCanvas = createCanvas4(width, height);
24989
25128
  const tempCtx = getContext(tempCanvas);
24990
25129
  if (!tempCtx) throw new Error("Failed to get 2d context for temp canvas");
24991
25130
  tempCtx.drawImage(source, 0, 0);
@@ -25002,7 +25141,7 @@ const _a = `"use strict";
25002
25141
  data[i + 2] = 255;
25003
25142
  data[i + 3] = alpha;
25004
25143
  }
25005
- const maskCanvas = createCanvas3(width, height);
25144
+ const maskCanvas = createCanvas4(width, height);
25006
25145
  const maskCtx = getContext(maskCanvas);
25007
25146
  if (!maskCtx) throw new Error("Failed to get 2d context for mask canvas");
25008
25147
  maskCtx.putImageData(imageData, 0, 0);
@@ -25576,7 +25715,7 @@ const _a = `"use strict";
25576
25715
  }
25577
25716
 
25578
25717
  // src/rendering/MaskRenderer.ts
25579
- var logger3 = createLogger("MaskRenderer");
25718
+ var logger4 = createLogger("MaskRenderer");
25580
25719
  var workerMaskBitmaps = /* @__PURE__ */ new Map();
25581
25720
  function registerMaskBitmap(imageUrl, bitmap) {
25582
25721
  workerMaskBitmaps.set(imageUrl, bitmap);
@@ -25593,7 +25732,7 @@ const _a = `"use strict";
25593
25732
  const offscreen = createOffscreenCanvas5(canvas.width, canvas.height);
25594
25733
  const offCtx = offscreen.getContext("2d");
25595
25734
  if (!offCtx) {
25596
- logger3.error("[renderWithMasks] Failed to get offscreen context");
25735
+ logger4.error("[renderWithMasks] Failed to get offscreen context");
25597
25736
  return;
25598
25737
  }
25599
25738
  const transform = ctx.getTransform();
@@ -26530,7 +26669,7 @@ const _a = `"use strict";
26530
26669
  };
26531
26670
  })();
26532
26671
  `;
26533
- async function Ea(e, n, t = fetch) {
26672
+ async function Aa(e, n, t = fetch) {
26534
26673
  try {
26535
26674
  const a = await t(n.fontFileUrl, { mode: "cors" });
26536
26675
  if (!a.ok) return null;
@@ -26546,7 +26685,7 @@ function X(e) {
26546
26685
  function Yn(e) {
26547
26686
  return `${X(e.family)}|${e.weight ?? 400}|${e.style ?? "normal"}`;
26548
26687
  }
26549
- class Aa {
26688
+ class Pa {
26550
26689
  constructor() {
26551
26690
  this.fonts = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.snapshot = [], this.list = () => this.snapshot, this.subscribe = (n) => (this.listeners.add(n), () => {
26552
26691
  this.listeners.delete(n);
@@ -26592,13 +26731,13 @@ class Aa {
26592
26731
  for (const n of this.listeners) n();
26593
26732
  }
26594
26733
  }
26595
- const Wn = new Aa();
26596
- function Pa(e) {
26734
+ const Wn = new Pa();
26735
+ function Ia(e) {
26597
26736
  Wn.register(e);
26598
26737
  }
26599
26738
  const We = /* @__PURE__ */ new Set();
26600
- async function Ia(e, n = {}) {
26601
- const t = await Ea(
26739
+ async function Fa(e, n = {}) {
26740
+ const t = await Aa(
26602
26741
  e.family,
26603
26742
  {
26604
26743
  fontFileUrl: e.url,
@@ -26623,14 +26762,14 @@ async function Ia(e, n = {}) {
26623
26762
  const a = n.fonts ?? (typeof document < "u" ? document.fonts : void 0);
26624
26763
  return a == null || a.add(t), We.add(Yn(e)), t;
26625
26764
  }
26626
- async function qa(e, n = {}) {
26627
- Pa(e);
26765
+ async function Xa(e, n = {}) {
26766
+ Ia(e);
26628
26767
  const { onLoadError: t, ...a } = n;
26629
26768
  await Promise.all(
26630
26769
  e.map(async (r) => {
26631
26770
  if (!We.has(Yn(r)))
26632
26771
  try {
26633
- await Ia(r, a);
26772
+ await Fa(r, a);
26634
26773
  } catch (o) {
26635
26774
  if (t && o instanceof we) {
26636
26775
  t(o, r);
@@ -26641,7 +26780,7 @@ async function qa(e, n = {}) {
26641
26780
  })
26642
26781
  );
26643
26782
  }
26644
- const O = U("WorkerExport");
26783
+ const M = U("WorkerExport");
26645
26784
  class pn {
26646
26785
  constructor() {
26647
26786
  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.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;
@@ -26669,7 +26808,7 @@ class pn {
26669
26808
  try {
26670
26809
  t(n);
26671
26810
  } catch (a) {
26672
- O.error("Error in progress listener:", a);
26811
+ M.error("Error in progress listener:", a);
26673
26812
  }
26674
26813
  }
26675
26814
  /**
@@ -26729,9 +26868,9 @@ class pn {
26729
26868
  */
26730
26869
  static supportsWorkerExport() {
26731
26870
  try {
26732
- return typeof OffscreenCanvas > "u" ? (O.warn("OffscreenCanvas not supported"), !1) : typeof Worker > "u" ? (O.warn("Web Workers not supported"), !1) : new OffscreenCanvas(1, 1).getContext("2d") ? !0 : (O.warn("OffscreenCanvas 2D context not supported"), !1);
26871
+ return typeof OffscreenCanvas > "u" ? (M.warn("OffscreenCanvas not supported"), !1) : typeof Worker > "u" ? (M.warn("Web Workers not supported"), !1) : new OffscreenCanvas(1, 1).getContext("2d") ? !0 : (M.warn("OffscreenCanvas 2D context not supported"), !1);
26733
26872
  } catch (n) {
26734
- return O.warn("Feature detection failed:", n), !1;
26873
+ return M.warn("Feature detection failed:", n), !1;
26735
26874
  }
26736
26875
  }
26737
26876
  /**
@@ -26746,28 +26885,28 @@ class pn {
26746
26885
  try {
26747
26886
  let a;
26748
26887
  try {
26749
- const s = new Blob([_a], { type: "application/javascript" });
26888
+ const s = new Blob([Ea], { type: "application/javascript" });
26750
26889
  a = URL.createObjectURL(s), this.workerBlobUrl = a;
26751
26890
  } catch (s) {
26752
- O.error("Failed to create worker blob:", s), t(new Error(`Worker creation failed: ${s instanceof Error ? s.message : String(s)}`));
26891
+ M.error("Failed to create worker blob:", s), t(new Error(`Worker creation failed: ${s instanceof Error ? s.message : String(s)}`));
26753
26892
  return;
26754
26893
  }
26755
26894
  this.worker = new Worker(a, { type: "classic" }), this.worker.onmessage = (s) => {
26756
26895
  this.handleWorkerMessage(s.data);
26757
26896
  }, this.worker.onerror = (s) => {
26758
- O.error("Worker error:", s), this.handleWorkerError(s);
26897
+ M.error("Worker error:", s), this.handleWorkerError(s);
26759
26898
  };
26760
26899
  const r = setTimeout(() => {
26761
26900
  t(new Error("Worker initialization timeout"));
26762
26901
  }, 15e3), o = (s) => {
26763
- s.data.type === "ready" && (clearTimeout(r), this.isReady = !0, ka(
26902
+ s.data.type === "ready" && (clearTimeout(r), this.isReady = !0, Ta(
26764
26903
  () => this.clearWorkerBitmapCache(),
26765
26904
  (c) => this.clearWorkerBitmap(c)
26766
26905
  ), n());
26767
26906
  };
26768
26907
  this.worker.addEventListener("message", o, { once: !0 });
26769
26908
  } catch (a) {
26770
- O.error("Failed to create worker:", a), t(a);
26909
+ M.error("Failed to create worker:", a), t(a);
26771
26910
  }
26772
26911
  }), this.readyPromise;
26773
26912
  }
@@ -26776,8 +26915,8 @@ class pn {
26776
26915
  */
26777
26916
  async restartWorker() {
26778
26917
  const n = Date.now();
26779
- if (n - this.lastCrashTime > this.CRASH_RESET_TIMEOUT && (this.workerCrashCount = 0), this.workerCrashCount++, this.lastCrashTime = n, O.warn(`Worker crashed (${this.workerCrashCount}/${this.MAX_CRASHES_BEFORE_FALLBACK})`), this.workerCrashCount >= this.MAX_CRASHES_BEFORE_FALLBACK)
26780
- throw O.error("Worker crashed too many times, giving up"), new Error("Worker has crashed too many times. Please refresh the page or use main thread export.");
26918
+ if (n - this.lastCrashTime > this.CRASH_RESET_TIMEOUT && (this.workerCrashCount = 0), this.workerCrashCount++, this.lastCrashTime = n, M.warn(`Worker crashed (${this.workerCrashCount}/${this.MAX_CRASHES_BEFORE_FALLBACK})`), this.workerCrashCount >= this.MAX_CRASHES_BEFORE_FALLBACK)
26919
+ throw M.error("Worker crashed too many times, giving up"), new Error("Worker has crashed too many times. Please refresh the page or use main thread export.");
26781
26920
  this.worker && (this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null));
26782
26921
  const t = Math.min(1e3 * Math.pow(2, this.workerCrashCount - 1), 5e3);
26783
26922
  await new Promise((a) => setTimeout(a, t)), await this.initialize();
@@ -26958,7 +27097,7 @@ class pn {
26958
27097
  case "ready":
26959
27098
  break;
26960
27099
  default:
26961
- O.warn("Unknown message type:", n);
27100
+ M.warn("Unknown message type:", n);
26962
27101
  }
26963
27102
  }
26964
27103
  /**
@@ -26966,14 +27105,14 @@ class pn {
26966
27105
  */
26967
27106
  handleExportComplete(n) {
26968
27107
  const t = this.pendingRequests.get(n.requestId);
26969
- t && t.returnFormat === "dataUrl" ? (t.resolve(n), this.pendingRequests.delete(n.requestId)) : t ? (O.warn("Received dataUrl response for blob request:", n.requestId), t.reject(new Error("Received dataUrl response when expecting blob")), this.pendingRequests.delete(n.requestId)) : O.warn("Received response for unknown request:", n.requestId);
27108
+ t && t.returnFormat === "dataUrl" ? (t.resolve(n), this.pendingRequests.delete(n.requestId)) : t ? (M.warn("Received dataUrl response for blob request:", n.requestId), t.reject(new Error("Received dataUrl response when expecting blob")), this.pendingRequests.delete(n.requestId)) : M.warn("Received response for unknown request:", n.requestId);
26970
27109
  }
26971
27110
  /**
26972
27111
  * Handle successful blob export completion
26973
27112
  */
26974
27113
  handleBlobExportComplete(n) {
26975
27114
  const t = this.pendingRequests.get(n.requestId);
26976
- t && t.returnFormat === "blob" ? (t.resolve(n), this.pendingRequests.delete(n.requestId)) : t ? (O.warn("Received blob response for dataUrl request:", n.requestId), t.reject(new Error("Received blob response when expecting dataUrl")), this.pendingRequests.delete(n.requestId)) : O.warn("Received blob response for unknown request:", n.requestId);
27115
+ t && t.returnFormat === "blob" ? (t.resolve(n), this.pendingRequests.delete(n.requestId)) : t ? (M.warn("Received blob response for dataUrl request:", n.requestId), t.reject(new Error("Received blob response when expecting dataUrl")), this.pendingRequests.delete(n.requestId)) : M.warn("Received blob response for unknown request:", n.requestId);
26977
27116
  }
26978
27117
  /**
26979
27118
  * Handle export error
@@ -26984,13 +27123,13 @@ class pn {
26984
27123
  const a = new Error(n.error);
26985
27124
  n.stack && (a.stack = n.stack), t.reject(a), this.pendingRequests.delete(n.requestId);
26986
27125
  } else
26987
- O.warn("Received error for unknown request:", n.requestId);
27126
+ M.warn("Received error for unknown request:", n.requestId);
26988
27127
  }
26989
27128
  /**
26990
27129
  * Handle worker errors
26991
27130
  */
26992
27131
  async handleWorkerError(n) {
26993
- O.error("Worker error:", n);
27132
+ M.error("Worker error:", n);
26994
27133
  const t = Array.from(this.pendingRequests.values());
26995
27134
  for (const [a, r] of this.pendingRequests.entries())
26996
27135
  this.pendingRequests.delete(a);
@@ -26998,7 +27137,7 @@ class pn {
26998
27137
  try {
26999
27138
  await this.restartWorker();
27000
27139
  } catch (a) {
27001
- O.error("Failed to restart worker:", a);
27140
+ M.error("Failed to restart worker:", a);
27002
27141
  for (const r of t)
27003
27142
  r.reject(new Error(`Worker crashed and could not be restarted: ${n.message}`));
27004
27143
  for (; this.requestQueue.length > 0; )
@@ -27014,7 +27153,7 @@ class pn {
27014
27153
  t.reject(new Error("Worker terminated")), this.pendingRequests.delete(n);
27015
27154
  for (; this.requestQueue.length > 0; )
27016
27155
  this.requestQueue.shift().reject(new Error("Worker terminated"));
27017
- this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, Nn(), Ta(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
27156
+ this.worker.terminate(), this.worker = null, this.isReady = !1, this.readyPromise = null, Nn(), _a(), this.workerBlobUrl && (URL.revokeObjectURL(this.workerBlobUrl), this.workerBlobUrl = null);
27018
27157
  }
27019
27158
  }
27020
27159
  /**
@@ -27030,10 +27169,10 @@ class pn {
27030
27169
  }
27031
27170
  }
27032
27171
  let nn = null;
27033
- function Xa() {
27172
+ function Ya() {
27034
27173
  return nn || (nn = new pn()), nn;
27035
27174
  }
27036
- function Ya() {
27175
+ function Ka() {
27037
27176
  nn && (nn.terminate(), nn = null);
27038
27177
  }
27039
27178
  jn();
@@ -27350,12 +27489,12 @@ const dn = class dn {
27350
27489
  } else
27351
27490
  T.render(f, !1);
27352
27491
  }
27353
- }), (g = n.distressTexture) != null && g.enabled && $a(f, n.distressTexture, {
27492
+ }), (g = n.distressTexture) != null && g.enabled && xa(f, n.distressTexture, {
27354
27493
  x: n.x,
27355
27494
  y: n.y,
27356
27495
  width: n.width,
27357
27496
  height: n.height
27358
- }), (C = n.imageMask) != null && C.enabled && la(f, n.imageMask, {
27497
+ }), (C = n.imageMask) != null && C.enabled && da(f, n.imageMask, {
27359
27498
  x: n.x,
27360
27499
  y: n.y,
27361
27500
  width: n.width,
@@ -27596,62 +27735,62 @@ const dn = class dn {
27596
27735
  };
27597
27736
  dn.CURRENT_VERSION = "2.0.0", dn.workerManager = null, dn.workerInitPromise = null;
27598
27737
  let vn = dn;
27599
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
27738
+ const Ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
27600
27739
  __proto__: null,
27601
27740
  ExportManager: vn,
27602
27741
  default: vn
27603
27742
  }, Symbol.toStringTag, { value: "Module" }));
27604
27743
  export {
27605
- xt as A,
27744
+ vt as A,
27606
27745
  ke as B,
27607
- Wa as C,
27746
+ za as C,
27608
27747
  Ne as D,
27609
27748
  vn as E,
27610
27749
  oe as F,
27611
- Ya as G,
27750
+ Ka as G,
27612
27751
  Ue as H,
27613
27752
  be as I,
27614
- vt as J,
27753
+ wt as J,
27615
27754
  yn as K,
27616
- ma as L,
27617
- ha as M,
27618
- Ha as N,
27755
+ ya as L,
27756
+ ba as M,
27757
+ Va as N,
27619
27758
  Dn as O,
27620
27759
  pe as P,
27621
- $a as Q,
27622
- la as R,
27760
+ xa as Q,
27761
+ da as R,
27623
27762
  jn as S,
27624
27763
  Z as T,
27625
- ea as U,
27626
- na as V,
27764
+ ta as U,
27765
+ ea as V,
27627
27766
  pn as W,
27628
- dt as X,
27629
- Ka as Y,
27630
- gt as a,
27631
- La as b,
27767
+ ft as X,
27768
+ Ja as Y,
27769
+ mt as a,
27770
+ Na as b,
27632
27771
  Wn as c,
27633
27772
  Ce as d,
27634
- qa as e,
27773
+ Xa as e,
27635
27774
  B as f,
27636
- Da as g,
27637
- Va as h,
27638
- Ga as i,
27775
+ Oa as g,
27776
+ ja as h,
27777
+ Ha as i,
27639
27778
  Nn as j,
27640
- Oa as k,
27641
- Ia as l,
27642
- pt as m,
27643
- Ra as n,
27779
+ Ra as k,
27780
+ Fa as l,
27781
+ ht as m,
27782
+ Ba as n,
27644
27783
  Ma as o,
27645
27784
  fn as p,
27646
- Xa as q,
27647
- Pa as r,
27648
- za as s,
27785
+ Ya as q,
27786
+ Ia as r,
27787
+ Ga as s,
27649
27788
  ee as t,
27650
- ja as u,
27789
+ qa as u,
27651
27790
  In as v,
27652
- Na as w,
27653
- Ba as x,
27654
- $t as y,
27655
- Ua as z
27791
+ Ua as w,
27792
+ La as x,
27793
+ xt as y,
27794
+ Wa as z
27656
27795
  };
27657
- //# sourceMappingURL=ExportManager-DUdis6se.js.map
27796
+ //# sourceMappingURL=ExportManager-Bkzzyxgw.js.map