@snowcone-app/canvas 0.43.8 → 0.44.1

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 (67) hide show
  1. package/dist/{CanvasRenderer-DIug_mjX.js → CanvasRenderer-B8BADU_r.js} +876 -830
  2. package/dist/CanvasRenderer-B8BADU_r.js.map +1 -0
  3. package/dist/{CanvasStateV1-BWd358xJ.js → CanvasStateV1-BlDWgOzV.js} +3 -3
  4. package/dist/{CanvasStateV1-BWd358xJ.js.map → CanvasStateV1-BlDWgOzV.js.map} +1 -1
  5. package/dist/ContextualToolbars-rCZo-KCm.js +6808 -0
  6. package/dist/ContextualToolbars-rCZo-KCm.js.map +1 -0
  7. package/dist/EditorCanvasImpl-VkjeyOGd.js +144 -0
  8. package/dist/EditorCanvasImpl-VkjeyOGd.js.map +1 -0
  9. package/dist/{ExportManager-BDH9jW4Q.js → ExportManager-xRsXgyNo.js} +2 -2
  10. package/dist/{ExportManager-BDH9jW4Q.js.map → ExportManager-xRsXgyNo.js.map} +1 -1
  11. package/dist/{FontAnalyzer-CyhywbAM.js → FontAnalyzer-Ds3Wdba7.js} +239 -236
  12. package/dist/FontAnalyzer-Ds3Wdba7.js.map +1 -0
  13. package/dist/{ImagePanel-CIGpLY3B.js → ImagePanel-DhOWKvIN.js} +6 -6
  14. package/dist/{ImagePanel-CIGpLY3B.js.map → ImagePanel-DhOWKvIN.js.map} +1 -1
  15. package/dist/{SnowconeCanvas-DE0A9UwD.js → SnowconeCanvas-COXpmwkS.js} +481 -466
  16. package/dist/SnowconeCanvas-COXpmwkS.js.map +1 -0
  17. package/dist/adjust-CDVzlVBY.js +145 -0
  18. package/dist/adjust-CDVzlVBY.js.map +1 -0
  19. package/dist/advanced.mjs +15 -15
  20. package/dist/api/stable.d.ts +2 -0
  21. package/dist/components/ImageToolbar.d.ts +3 -0
  22. package/dist/components/ShapeToolbar.d.ts +2 -0
  23. package/dist/components/TextToolbar.d.ts +2 -1
  24. package/dist/components/embed/SnowconeCanvas.d.ts +8 -0
  25. package/dist/components/toolbars/SecondaryPanels.d.ts +24 -0
  26. package/dist/components/toolbars/index.d.ts +2 -2
  27. package/dist/core/ArtboardElement.d.ts +2 -0
  28. package/dist/core/CanvasRenderer.d.ts +3 -1
  29. package/dist/{custom-icons-sT5sNRcG.js → custom-icons-C4bzABm2.js} +2 -2
  30. package/dist/{custom-icons-sT5sNRcG.js.map → custom-icons-C4bzABm2.js.map} +1 -1
  31. package/dist/{design-builder-CwfefZJC.js → design-builder-DCHVrEFV.js} +315 -314
  32. package/dist/design-builder-DCHVrEFV.js.map +1 -0
  33. package/dist/{embed-rRSCS25g.js → embed-CamnTsuT.js} +10 -10
  34. package/dist/{embed-rRSCS25g.js.map → embed-CamnTsuT.js.map} +1 -1
  35. package/dist/embed.mjs +19 -19
  36. package/dist/engrave/EngraveSync.d.ts +5 -0
  37. package/dist/engrave/adjust.d.ts +36 -0
  38. package/dist/engrave/makeEngraved.d.ts +23 -0
  39. package/dist/engrave/types.d.ts +33 -0
  40. package/dist/{guards-Dvw7Qch0.js → guards-DwYEoqcn.js} +2 -2
  41. package/dist/{guards-Dvw7Qch0.js.map → guards-DwYEoqcn.js.map} +1 -1
  42. package/dist/index.mjs +57 -54
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/internals.mjs +6 -6
  45. package/dist/rendering/EngraveViewRenderer.d.ts +15 -0
  46. package/dist/services/AutoExportManager.d.ts +13 -0
  47. package/dist/{template-fields-DF1ijCl9.js → template-fields-CK7Uvvc8.js} +5 -5
  48. package/dist/{template-fields-DF1ijCl9.js.map → template-fields-CK7Uvvc8.js.map} +1 -1
  49. package/dist/testing.mjs +3 -3
  50. package/dist/types/index.d.ts +5 -0
  51. package/dist/{useCommands-wwGeWCn6.js → useCommands-BrkGKdXr.js} +7 -7
  52. package/dist/{useCommands-wwGeWCn6.js.map → useCommands-BrkGKdXr.js.map} +1 -1
  53. package/dist/{usePieceGuideBundle-BWQINIJR.js → usePieceGuideBundle-BWdobHQE.js} +2 -2
  54. package/dist/{usePieceGuideBundle-BWQINIJR.js.map → usePieceGuideBundle-BWdobHQE.js.map} +1 -1
  55. package/dist/{validation-CXC34UhU.js → validation-jgr2OtXC.js} +2136 -2113
  56. package/dist/validation-jgr2OtXC.js.map +1 -0
  57. package/example/package.json +1 -1
  58. package/package.json +3 -3
  59. package/dist/CanvasRenderer-DIug_mjX.js.map +0 -1
  60. package/dist/ContextualToolbars-CspkC1T3.js +0 -6604
  61. package/dist/ContextualToolbars-CspkC1T3.js.map +0 -1
  62. package/dist/EditorCanvasImpl-Cn2fdo6a.js +0 -144
  63. package/dist/EditorCanvasImpl-Cn2fdo6a.js.map +0 -1
  64. package/dist/FontAnalyzer-CyhywbAM.js.map +0 -1
  65. package/dist/SnowconeCanvas-DE0A9UwD.js.map +0 -1
  66. package/dist/design-builder-CwfefZJC.js.map +0 -1
  67. package/dist/validation-CXC34UhU.js.map +0 -1
@@ -1,16 +1,16 @@
1
- import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-CyhywbAM.js";
2
- import { jsx as v, Fragment as Je, jsxs as _ } from "react/jsx-runtime";
3
- import Qe, { useMemo as Re, useRef as N, useEffect as S, Component as Ye, useState as oe, useCallback as V, useImperativeHandle as Ze, forwardRef as Ce } from "react";
4
- import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-CXC34UhU.js";
5
- import { ImagePanel as ft } from "./ImagePanel-CIGpLY3B.js";
6
- import { C as mt, a as gt } from "./ContextualToolbars-CspkC1T3.js";
7
- import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-wwGeWCn6.js";
8
- import { C as yt, D as xt } from "./template-fields-DF1ijCl9.js";
9
- import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-CwfefZJC.js";
1
+ import { p as ee, c as te, u as ze, t as ae, I as Ge, v as Ue, x as Ve, y as Xe } from "./FontAnalyzer-Ds3Wdba7.js";
2
+ import { jsx as y, Fragment as Je, jsxs as _ } from "react/jsx-runtime";
3
+ import Qe, { useMemo as Re, useRef as N, useEffect as F, Component as Ye, useState as oe, useCallback as V, useImperativeHandle as Ze, forwardRef as Ce } from "react";
4
+ import { a as qe, b as _e, c as et, G as tt, d as rt, Z as nt, g as at, e as ot, D as st, r as it, v as ct, S as lt, K as dt, f as ut } from "./validation-jgr2OtXC.js";
5
+ import { ImagePanel as ft } from "./ImagePanel-DhOWKvIN.js";
6
+ import { C as mt, a as gt } from "./ContextualToolbars-rCZo-KCm.js";
7
+ import { n as ht, o as pt, E as bt, C as vt, b as he, k as Et } from "./useCommands-BrkGKdXr.js";
8
+ import { C as yt, D as xt } from "./template-fields-CK7Uvvc8.js";
9
+ import { E as wt, b as se, i as It, l as At, j as Ie } from "./design-builder-DCHVrEFV.js";
10
10
  import { T as Ae } from "./ThemeContext-Rjz25x9X.js";
11
11
  import { c as St } from "./placement-tSiIVhrL.js";
12
- import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-BDH9jW4Q.js";
13
- import { C as fe } from "./CanvasRenderer-DIug_mjX.js";
12
+ import { a as kt, G as ce, E as Me, H as Ft } from "./ExportManager-xRsXgyNo.js";
13
+ import { C as fe } from "./CanvasRenderer-B8BADU_r.js";
14
14
  const pe = te("KitLayout"), ne = "canvas", me = 320;
15
15
  let Se = !1;
16
16
  function Rt() {
@@ -36,10 +36,10 @@ function Ct({ children: r }) {
36
36
  ...pt((a) => pe.error("[kit section]", a))
37
37
  };
38
38
  }
39
- return /* @__PURE__ */ v(bt.Provider, { value: n.current, children: r });
39
+ return /* @__PURE__ */ y(bt.Provider, { value: n.current, children: r });
40
40
  }
41
41
  function le({ ids: r }) {
42
- return !r || r.length === 0 ? null : /* @__PURE__ */ v(Ct, { children: r.map((n) => {
42
+ return !r || r.length === 0 ? null : /* @__PURE__ */ y(Ct, { children: r.map((n) => {
43
43
  var t;
44
44
  if (n === ne) return null;
45
45
  const e = at(n);
@@ -48,51 +48,51 @@ function le({ ids: r }) {
48
48
  `Kit layout references unknown section "${n}" — skipping. Register it with registerSection("${n}", { ... }).`
49
49
  ), null;
50
50
  const a = e.component;
51
- return /* @__PURE__ */ v(a, {}, n);
51
+ return /* @__PURE__ */ y(a, {}, n);
52
52
  }) });
53
53
  }
54
54
  function Mt({ kit: r, canvas: n }) {
55
- var b, d, E, y;
55
+ var v, c, w, A;
56
56
  Rt();
57
- const e = r.layout.slots, a = !!((b = e.topbar) != null && b.some((x) => x !== ne)), t = !!((d = e.left) != null && d.some((x) => x !== ne)), o = !!((E = e.right) != null && E.some((x) => x !== ne)), l = !!((y = e.bottombar) != null && y.some((x) => x !== ne)), u = Re(
58
- () => !a && !t && !o && !l,
59
- [a, t, o, l]
60
- ), s = N(null), f = a || t || o || l, h = N(!1);
61
- return S(() => {
62
- var i;
63
- if (typeof ee > "u" || ((i = ee.env) == null ? void 0 : i.NODE_ENV) !== "development" || !f) return;
64
- const x = s.current;
65
- if (!x || typeof ResizeObserver > "u") return;
66
- const $ = (g) => {
67
- g > 0 && g < me && !h.current ? (h.current = !0, pe.warn(
68
- `Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(g)}px wide — below the ~${me}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
69
- )) : g >= me && (h.current = !1);
57
+ const e = r.layout.slots, a = !!((v = e.topbar) != null && v.some((S) => S !== ne)), t = !!((c = e.left) != null && c.some((S) => S !== ne)), o = !!((w = e.right) != null && w.some((S) => S !== ne)), i = !!((A = e.bottombar) != null && A.some((S) => S !== ne)), l = Re(
58
+ () => !a && !t && !o && !i,
59
+ [a, t, o, i]
60
+ ), s = N(null), m = a || t || o || i, h = N(!1);
61
+ return F(() => {
62
+ var u;
63
+ if (typeof ee > "u" || ((u = ee.env) == null ? void 0 : u.NODE_ENV) !== "development" || !m) return;
64
+ const S = s.current;
65
+ if (!S || typeof ResizeObserver > "u") return;
66
+ const $ = (x) => {
67
+ x > 0 && x < me && !h.current ? (h.current = !0, pe.warn(
68
+ `Kit "${r.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(x)}px wide — below the ~${me}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
69
+ )) : x >= me && (h.current = !1);
70
70
  };
71
- $(x.getBoundingClientRect().width);
72
- const M = new ResizeObserver((g) => {
73
- for (const w of g) $(w.contentRect.width);
71
+ $(S.getBoundingClientRect().width);
72
+ const T = new ResizeObserver((x) => {
73
+ for (const d of x) $(d.contentRect.width);
74
74
  });
75
- return M.observe(x), () => M.disconnect();
76
- }, [f, r.name]), u ? /* @__PURE__ */ v(Je, { children: n }) : /* @__PURE__ */ _("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
77
- a && /* @__PURE__ */ v(
75
+ return T.observe(S), () => T.disconnect();
76
+ }, [m, r.name]), l ? /* @__PURE__ */ y(Je, { children: n }) : /* @__PURE__ */ _("div", { ref: s, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
77
+ a && /* @__PURE__ */ y(
78
78
  "div",
79
79
  {
80
80
  className: "sc-kit-topbar sc-toolbar",
81
81
  style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
82
- children: /* @__PURE__ */ v(le, { ids: e.topbar })
82
+ children: /* @__PURE__ */ y(le, { ids: e.topbar })
83
83
  }
84
84
  ),
85
85
  /* @__PURE__ */ _("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
86
- t && /* @__PURE__ */ v("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(le, { ids: e.left }) }),
87
- /* @__PURE__ */ v("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: n }),
88
- o && /* @__PURE__ */ v("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(le, { ids: e.right }) })
86
+ t && /* @__PURE__ */ y("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.left }) }),
87
+ /* @__PURE__ */ y("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: n }),
88
+ o && /* @__PURE__ */ y("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ y(le, { ids: e.right }) })
89
89
  ] }),
90
- l && /* @__PURE__ */ v(
90
+ i && /* @__PURE__ */ y(
91
91
  "div",
92
92
  {
93
93
  className: "sc-kit-bottombar sc-toolbar",
94
94
  style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
95
- children: /* @__PURE__ */ v(le, { ids: e.bottombar })
95
+ children: /* @__PURE__ */ y(le, { ids: e.bottombar })
96
96
  }
97
97
  )
98
98
  ] });
@@ -140,8 +140,8 @@ class Nt extends Ye {
140
140
  fontFamily: "system-ui, sans-serif"
141
141
  },
142
142
  children: [
143
- /* @__PURE__ */ v("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
144
- /* @__PURE__ */ v(
143
+ /* @__PURE__ */ y("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
144
+ /* @__PURE__ */ y(
145
145
  "pre",
146
146
  {
147
147
  style: {
@@ -156,7 +156,7 @@ class Nt extends Ye {
156
156
  children: this.state.error.message
157
157
  }
158
158
  ),
159
- /* @__PURE__ */ v(
159
+ /* @__PURE__ */ y(
160
160
  "button",
161
161
  {
162
162
  onClick: this.resetError,
@@ -185,83 +185,85 @@ function Lt({
185
185
  viewPadding: a,
186
186
  children: t
187
187
  }) {
188
- const o = n ? /* @__PURE__ */ v(Ae, { defaultTheme: "light", passive: r, children: t }) : /* @__PURE__ */ v(Ae, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ v(wt, { viewPadding: a, children: t }) });
189
- return e ? /* @__PURE__ */ v(vt, { services: e, children: o }) : o;
188
+ const o = n ? /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: t }) : /* @__PURE__ */ y(Ae, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ y(wt, { viewPadding: a, children: t }) });
189
+ return e ? /* @__PURE__ */ y(vt, { services: e, children: o }) : o;
190
190
  }
191
191
  const Pt = te("useAutoExport");
192
192
  function $t(r) {
193
- const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled: l, isCanvasReady: u = !1 } = r, s = N(null), f = N(!1), h = N({
193
+ const { config: n, historyManager: e, artboards: a, elements: t, onExport: o, onExportScheduled: i, isCanvasReady: l = !1 } = r, s = N(null), m = N(!1), h = N({
194
194
  totalExports: 0,
195
195
  skippedExports: 0,
196
196
  lastExportTime: null,
197
- avgExportInterval: 0
198
- }), [b, d] = oe(h.current), E = N(o);
199
- E.current = o, S(() => {
200
- const i = new ot({
197
+ avgExportInterval: 0,
198
+ failedExports: 0,
199
+ lastExportError: null
200
+ }), [v, c] = oe(h.current), w = N(o);
201
+ w.current = o, F(() => {
202
+ const u = new ot({
201
203
  ...st,
202
204
  ...n
203
205
  });
204
- return i.onExport(async () => {
206
+ return u.onExport(async () => {
205
207
  try {
206
- await E.current(), h.current = i.getStats();
207
- } catch (g) {
208
- Pt.error("[useAutoExport] Export failed:", g);
208
+ await w.current(), h.current = u.getStats();
209
+ } catch (x) {
210
+ Pt.error("[useAutoExport] Export failed:", x);
209
211
  }
210
- }), s.current = i, () => {
211
- i.destroy();
212
+ }), s.current = u, () => {
213
+ u.destroy();
212
214
  };
213
- }, []), S(() => {
214
- u && f.current && s.current && (f.current = !1, s.current.forceExport());
215
- }, [u]), S(() => {
215
+ }, []), F(() => {
216
+ l && m.current && s.current && (m.current = !1, s.current.forceExport());
217
+ }, [l]), F(() => {
216
218
  s.current && n && s.current.updateConfig(n);
217
- }, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]), S(() => {
218
- s.current && l && s.current.onExportScheduled(l);
219
- }, [l]), S(() => {
219
+ }, [n == null ? void 0 : n.enabled, n == null ? void 0 : n.debounceMs, n == null ? void 0 : n.maxWaitMs]), F(() => {
220
+ s.current && i && s.current.onExportScheduled(i);
221
+ }, [i]), F(() => {
220
222
  if (!e || !s.current)
221
223
  return;
222
- const i = e.onCommandExecuted(() => {
224
+ const u = e.onCommandExecuted(() => {
223
225
  if (s.current) {
224
- if (!u) {
225
- f.current = !0;
226
+ if (!l) {
227
+ m.current = !0;
226
228
  return;
227
229
  }
228
230
  s.current.scheduleExport();
229
231
  }
230
232
  });
231
233
  return () => {
232
- i();
234
+ u();
233
235
  };
234
- }, [e, u]), S(() => {
236
+ }, [e, l]), F(() => {
235
237
  if (s.current) {
236
- if (!u) {
237
- f.current = !0;
238
+ if (!l) {
239
+ m.current = !0;
238
240
  return;
239
241
  }
240
242
  s.current.scheduleExport();
241
243
  }
242
- }, [t, a, u]), S(() => ze((g) => {
243
- if (!s.current || !u) return;
244
- t.some((I) => I.id === g) && s.current.scheduleExport();
245
- }), [t, u]);
246
- const y = V((i) => {
247
- s.current && s.current.updateConfig(i);
248
- }, []), x = V(async () => {
249
- s.current && (await s.current.forceExport(), h.current = s.current.getStats(), d(h.current));
244
+ }, [t, a, l]), F(() => ze((x) => {
245
+ if (!s.current || !l) return;
246
+ t.some((p) => p.id === x) && s.current.scheduleExport();
247
+ }), [t, l]);
248
+ const A = V((u) => {
249
+ s.current && s.current.updateConfig(u);
250
+ }, []), S = V(async () => {
251
+ s.current && (await s.current.forceExport(), h.current = s.current.getStats(), c(h.current));
250
252
  }, []), $ = V(() => {
251
- s.current && (s.current.resetStats(), h.current = s.current.getStats(), d(h.current));
252
- }, []), M = V(() => {
253
+ s.current && (s.current.resetStats(), h.current = s.current.getStats(), c(h.current));
254
+ }, []), T = V(() => {
253
255
  s.current && s.current.resetChangeDetection();
254
256
  }, []);
255
257
  return {
256
- stats: b,
257
- updateConfig: y,
258
- forceExport: x,
258
+ stats: v,
259
+ updateConfig: A,
260
+ forceExport: S,
259
261
  resetStats: $,
260
- resetChangeDetection: M
262
+ resetChangeDetection: T
261
263
  };
262
264
  }
263
265
  const Te = te("useContentReady");
264
- function Dt(r) {
266
+ function Ot(r) {
265
267
  var e;
266
268
  const n = /* @__PURE__ */ new Set();
267
269
  for (const a of r)
@@ -275,7 +277,7 @@ function Dt(r) {
275
277
  }
276
278
  return Array.from(n);
277
279
  }
278
- async function Ot(r) {
280
+ async function Dt(r) {
279
281
  if (r.length === 0 || typeof document > "u" || !document.fonts) return;
280
282
  const n = [];
281
283
  for (const e of r) {
@@ -291,23 +293,23 @@ function Bt() {
291
293
  return new Promise((r) => requestAnimationFrame(() => r()));
292
294
  }
293
295
  function Wt(r) {
294
- const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o, l] = oe(!1), u = N(!1);
295
- return S(() => {
296
- if (o || !n || a && !t || a && e.length === 0 || u.current) return;
297
- u.current = !0;
296
+ const { isCanvasReady: n, elements: e, hasInitialElements: a, initialElementsLoaded: t } = r, [o, i] = oe(!1), l = N(!1);
297
+ return F(() => {
298
+ if (o || !n || a && !t || a && e.length === 0 || l.current) return;
299
+ l.current = !0;
298
300
  let s = !1;
299
301
  return (async () => {
300
302
  try {
301
- const f = Dt(e);
302
- if (f.length > 0 && (await Ot(f), s) || (await Bt(), s)) return;
303
- l(!0);
304
- } catch (f) {
305
- Te.error("Error during content readiness check:", f), s || l(!0);
303
+ const m = Ot(e);
304
+ if (m.length > 0 && (await Dt(m), s) || (await Bt(), s)) return;
305
+ i(!0);
306
+ } catch (m) {
307
+ Te.error("Error during content readiness check:", m), s || i(!0);
306
308
  } finally {
307
- u.current = !1;
309
+ l.current = !1;
308
310
  }
309
311
  })(), () => {
310
- s = !0, u.current = !1;
312
+ s = !0, l.current = !1;
311
313
  };
312
314
  }, [n, e, a, t, o]), o;
313
315
  }
@@ -328,7 +330,7 @@ function Ht(r, n) {
328
330
  }), r;
329
331
  }
330
332
  function Kt(r, n, e) {
331
- const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t), l = n.left + r.left * n.width, u = (r.width ?? 0) * n.width, s = r.align === "center" ? l + u / 2 : r.align === "right" ? l + u - o.advance / 2 : l + o.advance / 2, f = n.top + r.baseline * n.height;
333
+ const a = r.fontSize * n.height, t = (r.letterSpacing ?? 0) * n.height, o = e(r.text, a, r.fontFamily, t), i = n.left + r.left * n.width, l = (r.width ?? 0) * n.width, s = r.align === "center" ? i + l / 2 : r.align === "right" ? i + l - o.advance / 2 : i + o.advance / 2, m = n.top + r.baseline * n.height;
332
334
  return {
333
335
  transformType: "custom",
334
336
  name: r.name ?? r.text,
@@ -340,7 +342,7 @@ function Kt(r, n, e) {
340
342
  ...t !== 0 ? { letterSpacing: t } : {},
341
343
  ...r.stroke ? { stroke: { enabled: !0, color: r.stroke.color, width: r.stroke.width * n.height, lineJoin: "round", lineCap: "round" } } : {},
342
344
  x: s,
343
- y: f - o.ascent + (o.ascent + o.descent) / 2,
345
+ y: m - o.ascent + (o.ascent + o.descent) / 2,
344
346
  rotation: 0,
345
347
  // Room past the measured advance: the editor wraps a line at its box, and measures spaced letters a little
346
348
  // wider when it wraps than when it measures (a spaced "BRIDE SQUAD" broke onto two lines at its exact width).
@@ -360,22 +362,22 @@ function Ne(r) {
360
362
  async function zt(r, n, e) {
361
363
  const a = Date.now();
362
364
  for (; ; ) {
363
- const t = Ne(n.filter((l) => l.visible !== !1)).filter((l) => !l.imageElement || !l.imageLoaded);
365
+ const t = Ne(n.filter((i) => i.visible !== !1)).filter((i) => !i.imageElement || !i.imageLoaded);
364
366
  if (t.length === 0) return;
365
- const o = t.filter((l) => l.imageLoadState === "error");
367
+ const o = t.filter((i) => i.imageLoadState === "error");
366
368
  if (o.length > 0 || Date.now() - a > e) {
367
- const l = (o.length > 0 ? o : t).map((u) => u.id);
369
+ const i = (o.length > 0 ? o : t).map((l) => l.id);
368
370
  throw new ae(
369
371
  "E_PRINT_FILE_FAILED",
370
- `the print file of "${r.name}" needs every picture on it, and ${l.join(", ")} ${o.length > 0 ? "failed to load" : `has not loaded after ${e} ms`}: remove or re-add that picture, then ask again.`,
371
- { artboard: r.name, elements: l, state: o.length > 0 ? "error" : "loading" }
372
+ `the print file of "${r.name}" needs every picture on it, and ${i.join(", ")} ${o.length > 0 ? "failed to load" : `has not loaded after ${e} ms`}: remove or re-add that picture, then ask again.`,
373
+ { artboard: r.name, elements: i, state: o.length > 0 ? "error" : "loading" }
372
374
  );
373
375
  }
374
- await new Promise((l) => setTimeout(l, 100));
376
+ await new Promise((i) => setTimeout(i, 100));
375
377
  }
376
378
  }
377
379
  async function Gt(r, n, e = {}, a = {}) {
378
- var l, u;
380
+ var i, l;
379
381
  const t = r.map((s) => s.name);
380
382
  for (const s of Object.keys(e.regions ?? {}))
381
383
  if (!t.includes(s))
@@ -385,13 +387,13 @@ async function Gt(r, n, e = {}, a = {}) {
385
387
  });
386
388
  const o = {};
387
389
  for (const s of r) {
388
- const f = n(s);
389
- await zt(s, f, a.imageWaitMs ?? jt);
390
- const h = (l = e.regions) == null ? void 0 : l[s.name], b = h ? h.map((d) => ({ key: d.id, region: d })) : [{ key: s.name }];
391
- for (const { key: d, region: E } of b) {
392
- if (d in o)
393
- throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${d}": region ids and artboard names must all differ.`, { key: d });
394
- o[d] = await kt.exportPrintFile(s, f, { scale: ((u = e.scale) == null ? void 0 : u[d]) ?? 1, region: E });
390
+ const m = n(s);
391
+ await zt(s, m, a.imageWaitMs ?? jt);
392
+ const h = (i = e.regions) == null ? void 0 : i[s.name], v = h ? h.map((c) => ({ key: c.id, region: c })) : [{ key: s.name }];
393
+ for (const { key: c, region: w } of v) {
394
+ if (c in o)
395
+ throw new ae("E_PRINT_FILE_FAILED", `two print files are keyed "${c}": region ids and artboard names must all differ.`, { key: c });
396
+ o[c] = await kt.exportPrintFile(s, m, { scale: ((l = e.scale) == null ? void 0 : l[c]) ?? 1, region: w });
395
397
  }
396
398
  }
397
399
  return o;
@@ -403,7 +405,7 @@ function ge(r, n, e, a) {
403
405
  const t = r * e, o = n * e;
404
406
  if (Math.max(t, o) <= a)
405
407
  return e;
406
- const u = Math.max(r, n), s = a / u;
408
+ const l = Math.max(r, n), s = a / l;
407
409
  return Math.min(s, e);
408
410
  }
409
411
  function Ut(r) {
@@ -413,7 +415,7 @@ function Ut(r) {
413
415
  var o;
414
416
  Q.error(`[${t.category}] ${t.message}`, t.originalError), (o = n.current) == null || o.call(n, t);
415
417
  }, []);
416
- S(() => (fe.onRenderError = e, () => {
418
+ F(() => (fe.onRenderError = e, () => {
417
419
  fe.onRenderError === e && (fe.onRenderError = null);
418
420
  }), [e]);
419
421
  const a = V((t) => {
@@ -433,151 +435,164 @@ function Vt(r) {
433
435
  height: a,
434
436
  pieceGuides: t,
435
437
  controlledActiveArtboard: o,
436
- onArtboardChange: l,
437
- resetDocumentOnMount: u
438
+ onArtboardChange: i,
439
+ resetDocumentOnMount: l
438
440
  } = r, {
439
441
  setElements: s,
440
- setSelectedId: f,
442
+ setSelectedId: m,
441
443
  setMultiSelection: h,
442
- artboardManager: b,
443
- refreshArtboards: d
444
- } = se(), { createArtboard: E, selectArtboard: y, artboards: x } = he(), $ = N(!1), M = N(!1);
445
- S(() => {
444
+ artboardManager: v,
445
+ refreshArtboards: c
446
+ } = se(), { createArtboard: w, selectArtboard: A, artboards: S } = he(), $ = N(!1), T = N(!1);
447
+ F(() => {
446
448
  if ($.current) return;
447
449
  $.current = !0;
448
- const i = n || [{ name: "Design", width: e, height: a }], g = t ? "transparent" : void 0, w = (c) => c.exportBackground ?? (!!c.backgroundColor && c.backgroundColor !== "transparent"), I = () => {
449
- for (const c of b.getAllArtboards())
450
- c.imageFit = It(i.find((m) => m.name === c.name));
450
+ const d = n || [{ name: "Design", width: e, height: a }], p = t ? "transparent" : void 0, b = (E) => E.exportBackground ?? (!!E.backgroundColor && E.backgroundColor !== "transparent"), g = () => {
451
+ for (const E of v.getAllArtboards()) {
452
+ const f = d.find((I) => I.name === E.name);
453
+ E.imageFit = It(f), E.engrave = f != null && f.engrave ? { ...f.engrave } : void 0;
454
+ }
451
455
  };
452
- if (u) {
453
- b.clear(), s([]), f(null), h([]);
454
- for (const m of i)
455
- b.createArtboard({
456
- name: m.name,
457
- width: m.width,
458
- height: m.height,
459
- backgroundColor: m.backgroundColor ?? g,
460
- exportBackground: w(m),
461
- clipShape: m.clipShape,
462
- role: m.role
456
+ if (l) {
457
+ v.clear(), s([]), m(null), h([]);
458
+ for (const f of d)
459
+ v.createArtboard({
460
+ name: f.name,
461
+ width: f.width,
462
+ height: f.height,
463
+ backgroundColor: f.backgroundColor ?? p,
464
+ exportBackground: b(f),
465
+ clipShape: f.clipShape,
466
+ role: f.role
463
467
  });
464
- const c = b.getAllArtboards();
465
- c.length > 0 && !o && b.setActiveArtboard(c[0].id), I(), d();
468
+ const E = v.getAllArtboards();
469
+ E.length > 0 && !o && v.setActiveArtboard(E[0].id), g(), c();
466
470
  return;
467
471
  }
468
- const p = b.getAllArtboards();
469
- if (p.length > 0) {
470
- const c = i[0], m = p[0];
471
- m.name = c.name, m.width = c.width, m.height = c.height, m.clipShape = c.clipShape, m.exportBackground = w(c), m.role = c.role, c.backgroundColor ? m.backgroundColor = c.backgroundColor : g && (m.backgroundColor = g);
472
- for (let A = 1; A < i.length; A++)
473
- E(i[A].width, i[A].height, {
474
- name: i[A].name,
475
- backgroundColor: i[A].backgroundColor ?? g,
476
- exportBackground: w(i[A]),
477
- clipShape: i[A].clipShape,
478
- role: i[A].role
472
+ const k = v.getAllArtboards();
473
+ if (k.length > 0) {
474
+ const E = d[0], f = k[0];
475
+ f.name = E.name, f.width = E.width, f.height = E.height, f.clipShape = E.clipShape, f.exportBackground = b(E), f.role = E.role, E.backgroundColor ? f.backgroundColor = E.backgroundColor : p && (f.backgroundColor = p);
476
+ for (let I = 1; I < d.length; I++)
477
+ w(d[I].width, d[I].height, {
478
+ name: d[I].name,
479
+ backgroundColor: d[I].backgroundColor ?? p,
480
+ exportBackground: b(d[I]),
481
+ clipShape: d[I].clipShape,
482
+ role: d[I].role
479
483
  });
480
- !o && i.length > 1 && b.setActiveArtboard(m.id);
484
+ !o && d.length > 1 && v.setActiveArtboard(f.id);
481
485
  }
482
- I(), d();
483
- }, []), S(() => {
486
+ g(), c();
487
+ }, []);
488
+ const u = JSON.stringify((n ?? []).map((d) => [d.name, d.engrave ?? null])), x = N(u);
489
+ F(() => {
490
+ if (x.current !== u) {
491
+ x.current = u;
492
+ for (const d of v.getAllArtboards()) {
493
+ const p = (n ?? []).find((b) => b.name === d.name);
494
+ d.engrave = p != null && p.engrave ? { ...p.engrave } : void 0;
495
+ }
496
+ c();
497
+ }
498
+ }, [u]), F(() => {
484
499
  if (!o) {
485
- M.current = !0;
500
+ T.current = !0;
486
501
  return;
487
502
  }
488
- const i = x.find((g) => g.name === o);
489
- if (i) {
490
- const g = b.getActiveArtboard();
491
- (g == null ? void 0 : g.name) !== o && y(i.id), M.current = !0;
503
+ const d = S.find((p) => p.name === o);
504
+ if (d) {
505
+ const p = v.getActiveArtboard();
506
+ (p == null ? void 0 : p.name) !== o && A(d.id), T.current = !0;
492
507
  }
493
- }, [o, x]), S(() => {
494
- if (!l || !M.current) return;
495
- const i = b.getActiveArtboard();
496
- i && l(i.name);
497
- }, [b.getActiveArtboardId()]);
508
+ }, [o, S]), F(() => {
509
+ if (!i || !T.current) return;
510
+ const d = v.getActiveArtboard();
511
+ d && i(d.name);
512
+ }, [v.getActiveArtboardId()]);
498
513
  }
499
514
  function Xt(r) {
500
- const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(), l = N(!1), [u, s] = oe(!1), f = N(!0);
501
- return S(() => (f.current = !0, () => {
502
- f.current = !1;
503
- }), []), S(() => {
504
- if (!(!n || n.length === 0) && !l.current) {
505
- l.current = !0, s(!0);
515
+ const { initialElements: n, emitError: e, customFonts: a } = r, { setElements: t, artboardManager: o } = se(), i = N(!1), [l, s] = oe(!1), m = N(!0);
516
+ return F(() => (m.current = !0, () => {
517
+ m.current = !1;
518
+ }), []), F(() => {
519
+ if (!(!n || n.length === 0) && !i.current) {
520
+ i.current = !0, s(!0);
506
521
  try {
507
522
  a && a.length > 0 && ce.register(a);
508
- const h = Me.createManyFromJSON(n), b = o.getAllArtboards();
509
- if (b.length > 0) {
510
- const E = new Map(b.map((y) => [y.name, y]));
511
- h.forEach((y, x) => {
512
- var i;
513
- const $ = (i = n[x]) == null ? void 0 : i.artboard, M = $ && E.get($) || b[0];
514
- o.addElementToArtboard(y.id, M.id);
523
+ const h = Me.createManyFromJSON(n), v = o.getAllArtboards();
524
+ if (v.length > 0) {
525
+ const w = new Map(v.map((A) => [A.name, A]));
526
+ h.forEach((A, S) => {
527
+ var u;
528
+ const $ = (u = n[S]) == null ? void 0 : u.artboard, T = $ && w.get($) || v[0];
529
+ o.addElementToArtboard(A.id, T.id);
515
530
  });
516
531
  }
517
532
  t(h);
518
- const d = /* @__PURE__ */ new Set();
519
- for (const E of h) {
520
- const y = E.fontFamily;
521
- typeof y == "string" && y.trim().length > 0 && d.add(y);
533
+ const c = /* @__PURE__ */ new Set();
534
+ for (const w of h) {
535
+ const A = w.fontFamily;
536
+ typeof A == "string" && A.trim().length > 0 && c.add(A);
522
537
  }
523
- if (d.size > 0 && typeof document < "u") {
524
- const E = document.fonts ?? null, y = Array.from(d).filter(
525
- (i) => ce.has(i)
526
- ), x = Ft(
527
- ce.forFamilies(y),
538
+ if (c.size > 0 && typeof document < "u") {
539
+ const w = document.fonts ?? null, A = Array.from(c).filter(
540
+ (u) => ce.has(u)
541
+ ), S = Ft(
542
+ ce.forFamilies(A),
528
543
  {
529
- onLoadError: (i) => {
530
- f.current && e({
544
+ onLoadError: (u) => {
545
+ m.current && e({
531
546
  category: "import",
532
- message: i.message,
533
- originalError: i,
547
+ message: u.message,
548
+ originalError: u,
534
549
  recoverable: !0
535
550
  });
536
551
  }
537
552
  }
538
- ), M = Array.from(d).filter(
539
- (i) => !ce.has(i)
540
- ).map((i) => {
541
- const g = `font-${i.replace(/\s+/g, "-").toLowerCase()}`;
542
- let w = document.getElementById(g);
543
- return w || (w = document.createElement("link"), w.id = g, w.rel = "stylesheet", w.href = `https://fonts.googleapis.com/css2?family=${i.replace(
553
+ ), T = Array.from(c).filter(
554
+ (u) => !ce.has(u)
555
+ ).map((u) => {
556
+ const x = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
557
+ let d = document.getElementById(x);
558
+ return d || (d = document.createElement("link"), d.id = x, d.rel = "stylesheet", d.href = `https://fonts.googleapis.com/css2?family=${u.replace(
544
559
  /\s+/g,
545
560
  "+"
546
- )}:wght@400;700&display=swap`, document.head.appendChild(w)), new Promise((I) => {
547
- if (w.sheet) {
548
- I(i);
561
+ )}:wght@400;700&display=swap`, document.head.appendChild(d)), new Promise((p) => {
562
+ if (d.sheet) {
563
+ p(u);
549
564
  return;
550
565
  }
551
- const p = () => I(i);
552
- w.addEventListener("load", p, { once: !0 }), w.addEventListener("error", p, { once: !0 }), setTimeout(p, 4e3);
566
+ const b = () => p(u);
567
+ d.addEventListener("load", b, { once: !0 }), d.addEventListener("error", b, { once: !0 }), setTimeout(b, 4e3);
553
568
  });
554
569
  });
555
- Promise.all([Promise.all(M), x]).then(([i]) => {
556
- if (!(!f.current || !E))
570
+ Promise.all([Promise.all(T), S]).then(([u]) => {
571
+ if (!(!m.current || !w))
557
572
  return Promise.all(
558
- i.flatMap((g) => [
559
- E.load(`400 16px "${g}"`).catch(() => {
573
+ u.flatMap((x) => [
574
+ w.load(`400 16px "${x}"`).catch(() => {
560
575
  }),
561
- E.load(`700 16px "${g}"`).catch(() => {
576
+ w.load(`700 16px "${x}"`).catch(() => {
562
577
  })
563
578
  ])
564
579
  );
565
580
  }).then(() => {
566
- f.current && t((i) => i.slice());
581
+ m.current && t((u) => u.slice());
567
582
  });
568
583
  }
569
584
  } catch (h) {
570
585
  Q.error("Failed to load initial elements:", h);
571
- const b = h instanceof Error ? h : new Error(String(h));
586
+ const v = h instanceof Error ? h : new Error(String(h));
572
587
  e({
573
588
  category: "import",
574
- message: `Failed to load initial elements: ${b.message}`,
575
- originalError: b,
589
+ message: `Failed to load initial elements: ${v.message}`,
590
+ originalError: v,
576
591
  recoverable: !0
577
592
  });
578
593
  }
579
594
  }
580
- }, [n, o, t, e, a]), { initialElementsLoadedState: u };
595
+ }, [n, o, t, e, a]), { initialElementsLoadedState: l };
581
596
  }
582
597
  function Jt(r) {
583
598
  const {
@@ -586,151 +601,151 @@ function Jt(r) {
586
601
  initialImageAlignment: a,
587
602
  initialImageScale: t,
588
603
  initialImageScaleMode: o,
589
- initialImageRole: l,
590
- artboardConfigs: u,
604
+ initialImageRole: i,
605
+ artboardConfigs: l,
591
606
  onImageLoad: s,
592
- onImageError: f,
607
+ onImageError: m,
593
608
  emitError: h
594
- } = r, { elements: b, setElements: d, artboardManager: E } = se(), [y, x] = oe("idle"), [$, M] = oe(null), i = N(void 0);
595
- return S(() => {
596
- if (!n || i.current === n) return;
597
- if (b.length > 0) {
598
- i.current = n;
609
+ } = r, { elements: v, setElements: c, artboardManager: w } = se(), [A, S] = oe("idle"), [$, T] = oe(null), u = N(void 0);
610
+ return F(() => {
611
+ if (!n || u.current === n) return;
612
+ if (v.length > 0) {
613
+ u.current = n;
599
614
  return;
600
615
  }
601
- i.current = n, (async () => {
602
- x("loading"), M(null);
616
+ u.current = n, (async () => {
617
+ S("loading"), T(null);
603
618
  try {
604
- const w = E.getAllArtboards();
605
- if (w.length === 0)
619
+ const d = w.getAllArtboards();
620
+ if (d.length === 0)
606
621
  throw new Error("No artboards available");
607
- const I = [];
608
- for (const p of w) {
609
- const c = u == null ? void 0 : u.find((T) => T.name === p.name), m = (c == null ? void 0 : c.scaleMode) || o, A = (c == null ? void 0 : c.imageRegions) ?? [];
610
- if (A.length > 0) {
611
- const T = await At(n);
612
- if (!T.success || !T.width || !T.height) {
613
- Q.error("Failed to load image for artboard:", p.name, T.error);
622
+ const p = [];
623
+ for (const b of d) {
624
+ const g = l == null ? void 0 : l.find((I) => I.name === b.name), k = (g == null ? void 0 : g.scaleMode) || o, E = (g == null ? void 0 : g.imageRegions) ?? [];
625
+ if (E.length > 0) {
626
+ const I = await At(n);
627
+ if (!I.success || !I.width || !I.height) {
628
+ Q.error("Failed to load image for artboard:", b.name, I.error);
614
629
  continue;
615
630
  }
616
- for (const W of A) {
617
- const L = St(T.width / T.height, W), H = await Ie(
631
+ for (const W of E) {
632
+ const L = St(I.width / I.height, W), H = await Ie(
618
633
  n,
619
634
  {
620
- artboard: { width: L.width, height: L.height, x: p.x + L.centerX - L.width / 2, y: p.y + L.centerY - L.height / 2 },
635
+ artboard: { width: L.width, height: L.height, x: b.x + L.centerX - L.width / 2, y: b.y + L.centerY - L.height / 2 },
621
636
  alignment: "center",
622
637
  scale: 1,
623
638
  scaleMode: "cover"
624
639
  },
625
640
  { transformData: { type: "image", width: L.width, height: L.height, cropX: L.cropX, cropY: L.cropY, cropWidth: L.cropWidth, cropHeight: L.cropHeight } }
626
641
  );
627
- H.success && H.element ? (E.addElementToArtboard(H.element.id, p.id), I.push(H.element)) : Q.error("Failed to load image for a panel of artboard:", p.name, H.error);
642
+ H.success && H.element ? (w.addElementToArtboard(H.element.id, b.id), p.push(H.element)) : Q.error("Failed to load image for a panel of artboard:", b.name, H.error);
628
643
  }
629
644
  continue;
630
645
  }
631
- const k = await Ie(
646
+ const f = await Ie(
632
647
  n,
633
648
  {
634
649
  artboard: {
635
- width: p.width,
636
- height: p.height,
637
- x: p.x,
638
- y: p.y
650
+ width: b.width,
651
+ height: b.height,
652
+ x: b.x,
653
+ y: b.y
639
654
  },
640
- alignment: (c == null ? void 0 : c.fitAlign) || a,
655
+ alignment: (g == null ? void 0 : g.fitAlign) || a,
641
656
  scale: t,
642
- scaleMode: m,
643
- marginTop: c == null ? void 0 : c.fitMarginTop,
644
- marginRight: c == null ? void 0 : c.fitMarginRight,
645
- marginBottom: c == null ? void 0 : c.fitMarginBottom,
646
- marginLeft: c == null ? void 0 : c.fitMarginLeft
657
+ scaleMode: k,
658
+ marginTop: g == null ? void 0 : g.fitMarginTop,
659
+ marginRight: g == null ? void 0 : g.fitMarginRight,
660
+ marginBottom: g == null ? void 0 : g.fitMarginBottom,
661
+ marginLeft: g == null ? void 0 : g.fitMarginLeft
647
662
  }
648
663
  );
649
- k.success && k.element ? (E.addElementToArtboard(k.element.id, p.id), I.push(k.element)) : Q.error("Failed to load image for artboard:", p.name, k.error);
664
+ f.success && f.element ? (w.addElementToArtboard(f.element.id, b.id), p.push(f.element)) : Q.error("Failed to load image for artboard:", b.name, f.error);
650
665
  }
651
- if (e.length > 0 && I.length > 0) {
652
- const p = await Zt(Array.from(new Set(e.map((m) => m.fontFamily))));
653
- for (const m of p)
666
+ if (e.length > 0 && p.length > 0) {
667
+ const b = await Zt(Array.from(new Set(e.map((k) => k.fontFamily))));
668
+ for (const k of b)
654
669
  h({
655
670
  category: "import",
656
- message: `E_FONT_LOAD_FAILED: the font "${m}" for initialImageText could not be loaded; its words are drawn in a fallback font until it loads.`,
671
+ message: `E_FONT_LOAD_FAILED: the font "${k}" for initialImageText could not be loaded; its words are drawn in a fallback font until it loads.`,
657
672
  recoverable: !0
658
673
  });
659
- const c = (m, A, k, T) => {
660
- const W = Ue(A, k);
661
- return { advance: Ve(m, A, k, !1, !1, T), ascent: W.ascent, descent: W.descent };
674
+ const g = (k, E, f, I) => {
675
+ const W = Ue(E, f);
676
+ return { advance: Ve(k, E, f, !1, !1, I), ascent: W.ascent, descent: W.descent };
662
677
  };
663
- for (const m of I.slice()) {
664
- const A = E.getArtboardForElement(m.id), k = m.transformData, T = (k == null ? void 0 : k.width) ?? 0, W = (k == null ? void 0 : k.height) ?? 0;
665
- if (!A || !(T > 0) || !(W > 0)) continue;
666
- const L = { left: m.x - T / 2, top: m.y - W / 2, width: T, height: W };
678
+ for (const k of p.slice()) {
679
+ const E = w.getArtboardForElement(k.id), f = k.transformData, I = (f == null ? void 0 : f.width) ?? 0, W = (f == null ? void 0 : f.height) ?? 0;
680
+ if (!E || !(I > 0) || !(W > 0)) continue;
681
+ const L = { left: k.x - I / 2, top: k.y - W / 2, width: I, height: W };
667
682
  for (const H of e) {
668
- const Y = Me.createFromJSON(Kt(H, L, c));
669
- E.addElementToArtboard(Y.id, A.id), I.push(Y);
683
+ const Y = Me.createFromJSON(Kt(H, L, g));
684
+ w.addElementToArtboard(Y.id, E.id), p.push(Y);
670
685
  }
671
686
  }
672
687
  }
673
- if (I.length > 0)
674
- l === "placeholder" && E.markPlaceholders(I.map((p) => p.id)), d((p) => [...p, ...I]), x("success"), s == null || s(n);
688
+ if (p.length > 0)
689
+ i === "placeholder" && w.markPlaceholders(p.map((b) => b.id)), c((b) => [...b, ...p]), S("success"), s == null || s(n);
675
690
  else {
676
- const p = new Error("Failed to load image into any artboard");
677
- x("error"), M(p), f == null || f(n, p), h({
691
+ const b = new Error("Failed to load image into any artboard");
692
+ S("error"), T(b), m == null || m(n, b), h({
678
693
  category: "image",
679
- message: p.message,
680
- originalError: p,
694
+ message: b.message,
695
+ originalError: b,
681
696
  recoverable: !0
682
697
  });
683
698
  }
684
- } catch (w) {
685
- const I = w instanceof Error ? w : new Error(String(w));
686
- x("error"), M(I), f == null || f(n, I), h({
699
+ } catch (d) {
700
+ const p = d instanceof Error ? d : new Error(String(d));
701
+ S("error"), T(p), m == null || m(n, p), h({
687
702
  category: "image",
688
- message: I.message,
689
- originalError: I,
703
+ message: p.message,
704
+ originalError: p,
690
705
  recoverable: !0
691
706
  });
692
707
  }
693
708
  })();
694
- }, [n, e, a, t, o, l]), { imageLoadingState: y, imageError: $ };
709
+ }, [n, e, a, t, o, i]), { imageLoadingState: A, imageError: $ };
695
710
  }
696
711
  function Qt(r) {
697
- const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards: l } = he(), u = N(e);
698
- u.current = e, S(() => {
699
- var f;
700
- (f = u.current) == null || f.call(u, t);
712
+ const { onChange: n, onSelectionChange: e } = r, { elements: a, selectedId: t, artboardManager: o } = se(), { artboards: i } = he(), l = N(e);
713
+ l.current = e, F(() => {
714
+ var m;
715
+ (m = l.current) == null || m.call(l, t);
701
716
  }, [t]);
702
717
  const s = N(n);
703
- s.current = n, S(() => {
704
- const f = s.current;
705
- if (!f) return;
706
- const h = o.getActiveArtboard(), b = {
718
+ s.current = n, F(() => {
719
+ const m = s.current;
720
+ if (!m) return;
721
+ const h = o.getActiveArtboard(), v = {
707
722
  // Stamp each element with the NAME of the artboard it lives on (the
708
723
  // manager is the membership source of truth). Without this the public
709
724
  // state is flat and a multi-placement design cannot round-trip: restore
710
725
  // collapses everything onto the first artboard, and per-placement render
711
726
  // states can't be derived from onChange. Pinned by
712
727
  // SnowconeCanvas.artboard-membership.test.tsx.
713
- elements: a.map((d) => {
714
- const E = d.toJSON(), y = o.getArtboardForElement(d.id);
715
- return y ? { ...E, artboard: y.name } : E;
728
+ elements: a.map((c) => {
729
+ const w = c.toJSON(), A = o.getArtboardForElement(c.id);
730
+ return A ? { ...w, artboard: A.name } : w;
716
731
  }),
717
- artboards: l.map((d) => ({
718
- name: d.name,
719
- width: d.width,
720
- height: d.height,
721
- clipShape: d.clipShape,
722
- backgroundColor: d.backgroundColor,
732
+ artboards: i.map((c) => ({
733
+ name: c.name,
734
+ width: c.width,
735
+ height: c.height,
736
+ clipShape: c.clipShape,
737
+ backgroundColor: c.backgroundColor,
723
738
  // Carried so serializeStateForServer / saved states keep an
724
739
  // explicitly-set background renderable (mockup matches editor).
725
- exportBackground: d.exportBackground,
740
+ exportBackground: c.exportBackground,
726
741
  // Pacing role for multi-page templates (ADR-0086) — emitted only when
727
742
  // set so non-template states stay byte-identical.
728
- ...d.role ? { role: d.role } : {}
743
+ ...c.role ? { role: c.role } : {}
729
744
  })),
730
745
  activeArtboard: (h == null ? void 0 : h.name) || "Design"
731
746
  };
732
- f(b);
733
- }, [a, l]);
747
+ m(v);
748
+ }, [a, i]);
734
749
  }
735
750
  function Yt(r, n) {
736
751
  const {
@@ -738,163 +753,163 @@ function Yt(r, n) {
738
753
  autoExportConfig: a,
739
754
  autoExportFormat: t,
740
755
  autoExportAll: o,
741
- exportScale: l,
742
- maxExportSize: u,
756
+ exportScale: i,
757
+ maxExportSize: l,
743
758
  exportImageFormat: s,
744
- exportImageQuality: f,
759
+ exportImageQuality: m,
745
760
  onExport: h,
746
- onExportScheduled: b,
747
- onExportStatus: d,
748
- onExportReady: E,
749
- onReady: y,
750
- hasInitialElements: x,
761
+ onExportScheduled: v,
762
+ onExportStatus: c,
763
+ onExportReady: w,
764
+ onReady: A,
765
+ hasInitialElements: S,
751
766
  initialElementsLoaded: $,
752
- emitError: M
767
+ emitError: T
753
768
  } = r, {
754
- elements: i,
755
- artboardManager: g,
756
- historyManager: w,
757
- isCanvasReady: I,
758
- setCanvasReady: p
759
- } = se(), { artboards: c } = he(), { exportArtboard: m, exportAllArtboards: A, exportArtboardAsBlob: k, exportAllArtboardsAsBlobs: T } = Et(), W = N(0), L = N(0), H = N(i);
760
- H.current = i, Ze(n, () => ({
761
- exportArtboards: async (D = {}) => {
762
- const P = D.format || t, B = D.scale || l, K = D.all ?? !1;
769
+ elements: u,
770
+ artboardManager: x,
771
+ historyManager: d,
772
+ isCanvasReady: p,
773
+ setCanvasReady: b
774
+ } = se(), { artboards: g } = he(), { exportArtboard: k, exportAllArtboards: E, exportArtboardAsBlob: f, exportAllArtboardsAsBlobs: I } = Et(), W = N(0), L = N(0), H = N(u);
775
+ H.current = u, Ze(n, () => ({
776
+ exportArtboards: async (O = {}) => {
777
+ const P = O.format || t, B = O.scale || i, K = O.all ?? !1;
763
778
  let j = B;
764
- if (u > 0 && isFinite(u))
765
- for (const C of c) {
766
- const R = ge(C.width, C.height, B, u);
767
- j = Math.min(j, R);
779
+ if (l > 0 && isFinite(l))
780
+ for (const M of g) {
781
+ const C = ge(M.width, M.height, B, l);
782
+ j = Math.min(j, C);
768
783
  }
769
- const F = { scale: j, format: s, quality: f };
784
+ const R = { scale: j, format: s, quality: m };
770
785
  if (K) {
771
- const C = P === "blob" ? await T(F) : await A(F), R = {};
772
- for (const [O, X] of Object.entries(C)) {
773
- const z = c.find((J) => J.id === O);
774
- z && (R[z.name] = X);
786
+ const M = P === "blob" ? await I(R) : await E(R), C = {};
787
+ for (const [D, X] of Object.entries(M)) {
788
+ const z = g.find((J) => J.id === D);
789
+ z && (C[z.name] = X);
775
790
  }
776
- return R;
791
+ return C;
777
792
  } else {
778
- const C = g.getActiveArtboard();
779
- if (!C)
793
+ const M = x.getActiveArtboard();
794
+ if (!M)
780
795
  throw new Error("[SnowconeCanvas] No active artboard found");
781
796
  if (P === "blob") {
782
- const R = await k(C.id, F);
783
- return { [C.name]: R };
797
+ const C = await f(M.id, R);
798
+ return { [M.name]: C };
784
799
  } else {
785
- const R = await m(C.id, F);
786
- return { [C.name]: R };
800
+ const C = await k(M.id, R);
801
+ return { [M.name]: C };
787
802
  }
788
803
  }
789
804
  },
790
805
  // Print files: every artboard (or its regions), lossless PNG, full size, original picture pixels, one at a time.
791
806
  // Never the auto-export's format / maxExportSize: those keep the live preview light, a print file is the product.
792
- exportPrintFiles: (D = {}) => Gt(
793
- c,
807
+ exportPrintFiles: (O = {}) => Gt(
808
+ g,
794
809
  (P) => {
795
- const B = new Set(g.getElementsOnArtboard(P.id));
810
+ const B = new Set(x.getElementsOnArtboard(P.id));
796
811
  return H.current.filter((K) => B.has(K.id));
797
812
  },
798
- D
813
+ O
799
814
  )
800
- }), [m, A, k, T, t, l, u, s, f, g, c]), S(() => {
801
- E && E(async () => {
802
- const P = g.getActiveArtboard();
815
+ }), [k, E, f, I, t, i, l, s, m, x, g]), F(() => {
816
+ w && w(async () => {
817
+ const P = x.getActiveArtboard();
803
818
  if (!P)
804
819
  throw new Error("[SnowconeCanvas] No active artboard found");
805
820
  const B = ge(
806
821
  P.width,
807
822
  P.height,
808
- l,
809
- u
810
- ), K = t === "blob" ? await k(P.id, { scale: B }) : await m(P.id, { scale: B });
823
+ i,
824
+ l
825
+ ), K = t === "blob" ? await f(P.id, { scale: B }) : await k(P.id, { scale: B });
811
826
  return { [P.name]: K };
812
827
  });
813
- }, [E, m, k, g, t, l, u]);
828
+ }, [w, k, f, x, t, i, l]);
814
829
  const Y = V(async () => {
815
- if (!h && !d) return;
816
- const D = ++L.current, P = Date.now();
817
- let B = l;
818
- if (u > 0 && isFinite(u))
819
- for (const F of c) {
820
- const C = ge(F.width, F.height, l, u);
821
- B = Math.min(B, C);
830
+ if (!h && !c) return;
831
+ const O = ++L.current, P = Date.now();
832
+ let B = i;
833
+ if (l > 0 && isFinite(l))
834
+ for (const R of g) {
835
+ const M = ge(R.width, R.height, i, l);
836
+ B = Math.min(B, M);
822
837
  }
823
- const K = g.getActiveArtboard(), j = (K == null ? void 0 : K.id) ?? "unknown";
824
- d == null || d({ status: "rendering", artboardId: j }), W.current = P;
838
+ const K = x.getActiveArtboard(), j = (K == null ? void 0 : K.id) ?? "unknown";
839
+ c == null || c({ status: "rendering", artboardId: j }), W.current = P;
825
840
  try {
826
- let F;
827
- const C = {
841
+ let R;
842
+ const M = {
828
843
  format: s,
829
844
  scale: B,
830
- quality: f
845
+ quality: m
831
846
  };
832
847
  if (t === "blob")
833
848
  if (o) {
834
- const R = await T(C);
835
- F = {};
836
- for (const [O, X] of Object.entries(R)) {
837
- const z = c.find((J) => J.id === O);
838
- z && (F[z.name] = X);
849
+ const C = await I(M);
850
+ R = {};
851
+ for (const [D, X] of Object.entries(C)) {
852
+ const z = g.find((J) => J.id === D);
853
+ z && (R[z.name] = X);
839
854
  }
840
855
  } else {
841
- const R = g.getActiveArtboard();
842
- if (!R) return;
843
- const O = await k(R.id, C);
844
- F = { [R.name]: O };
856
+ const C = x.getActiveArtboard();
857
+ if (!C) return;
858
+ const D = await f(C.id, M);
859
+ R = { [C.name]: D };
845
860
  }
846
861
  else if (o) {
847
- const R = await A(C);
848
- F = {};
849
- for (const [O, X] of Object.entries(R)) {
850
- const z = c.find((J) => J.id === O);
851
- z && (F[z.name] = X);
862
+ const C = await E(M);
863
+ R = {};
864
+ for (const [D, X] of Object.entries(C)) {
865
+ const z = g.find((J) => J.id === D);
866
+ z && (R[z.name] = X);
852
867
  }
853
868
  } else {
854
- const R = g.getActiveArtboard();
855
- if (!R) return;
856
- const O = await m(R.id, C);
857
- F = { [R.name]: O };
869
+ const C = x.getActiveArtboard();
870
+ if (!C) return;
871
+ const D = await k(C.id, M);
872
+ R = { [C.name]: D };
858
873
  }
859
- h == null || h(F), d == null || d({ status: "complete", artboardId: j, result: F });
860
- } catch (F) {
861
- const C = F instanceof Error ? F.message : String(F);
862
- if (C.includes("Canvas ref not available"))
874
+ h == null || h(R), c == null || c({ status: "complete", artboardId: j, result: R });
875
+ } catch (R) {
876
+ const M = R instanceof Error ? R.message : String(R);
877
+ if (M.includes("Canvas ref not available"))
863
878
  return;
864
- const R = Date.now() - P;
865
- Q.error("Export failed (export #" + D + "):", {
866
- duration: `${R}ms`,
867
- error: C
879
+ const C = Date.now() - P;
880
+ Q.error("Export failed (export #" + O + "):", {
881
+ duration: `${C}ms`,
882
+ error: M
868
883
  });
869
- const O = F instanceof Error ? F : new Error(C);
870
- d == null || d({ status: "error", artboardId: j, error: O }), M({
884
+ const D = R instanceof Error ? R : new Error(M);
885
+ c == null || c({ status: "error", artboardId: j, error: D }), T({
871
886
  category: "export",
872
- message: O.message,
873
- originalError: O,
887
+ message: D.message,
888
+ originalError: D,
874
889
  artboardId: j,
875
890
  recoverable: !0
876
891
  });
877
892
  }
878
- }, [h, d, o, t, l, u, s, f, m, A, k, T, c, g, i, a, M]);
879
- S(() => {
893
+ }, [h, c, o, t, i, l, s, m, k, E, f, I, g, x, u, a, T]);
894
+ F(() => {
880
895
  e !== void 0 && e > 0 && Q.warn(
881
896
  "autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
882
897
  );
883
898
  }, []);
884
899
  const de = V(() => {
885
- if (b == null || b(), d) {
886
- const D = g.getActiveArtboard();
887
- d({ status: "scheduled", artboardId: (D == null ? void 0 : D.id) ?? "unknown" });
900
+ if (v == null || v(), c) {
901
+ const O = x.getActiveArtboard();
902
+ c({ status: "scheduled", artboardId: (O == null ? void 0 : O.id) ?? "unknown" });
888
903
  }
889
- }, [b, d, g]), re = Wt({
890
- isCanvasReady: I,
891
- elements: i,
892
- hasInitialElements: x,
904
+ }, [v, c, x]), re = Wt({
905
+ isCanvasReady: p,
906
+ elements: u,
907
+ hasInitialElements: S,
893
908
  initialElementsLoaded: $
894
909
  }), ie = N(!1);
895
- S(() => {
896
- re && !ie.current && (ie.current = !0, y == null || y());
897
- }, [re, y]), $t({
910
+ F(() => {
911
+ re && !ie.current && (ie.current = !0, A == null || A());
912
+ }, [re, A]), $t({
898
913
  config: a ? {
899
914
  enabled: a.enabled ?? !0,
900
915
  debounceMs: a.debounceMs ?? 100,
@@ -903,23 +918,23 @@ function Yt(r, n) {
903
918
  enabled: !1
904
919
  // Only use smart export if autoExportConfig is provided
905
920
  },
906
- historyManager: w,
907
- artboards: c,
908
- elements: i,
921
+ historyManager: d,
922
+ artboards: g,
923
+ elements: u,
909
924
  onExport: Y,
910
925
  onExportScheduled: de,
911
926
  isCanvasReady: re
912
927
  // Gate exports until content is fully ready (fonts loaded, elements deserialized)
913
- }), S(() => {
914
- if (c.length > 0 && !I) {
915
- const D = requestAnimationFrame(() => {
916
- p(!0);
928
+ }), F(() => {
929
+ if (g.length > 0 && !p) {
930
+ const O = requestAnimationFrame(() => {
931
+ b(!0);
917
932
  });
918
- return () => cancelAnimationFrame(D);
933
+ return () => cancelAnimationFrame(O);
919
934
  }
920
- }, [c.length, I, p]), S(() => () => {
921
- p(!1);
922
- }, [p]);
935
+ }, [g.length, p, b]), F(() => () => {
936
+ b(!1);
937
+ }, [b]);
923
938
  }
924
939
  async function Zt(r) {
925
940
  if (typeof document > "u" || r.length === 0) return [];
@@ -949,66 +964,66 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
949
964
  imageConfig: a,
950
965
  layoutConfig: t,
951
966
  kit: o,
952
- artboards: l,
953
- activeArtboard: u,
967
+ artboards: i,
968
+ activeArtboard: l,
954
969
  onArtboardChange: s,
955
- initialElements: f,
970
+ initialElements: m,
956
971
  customFonts: h,
957
- onChange: b,
958
- onSelectionChange: d,
959
- autoExportInterval: E,
960
- onExport: y,
961
- onExportScheduled: x,
972
+ onChange: v,
973
+ onSelectionChange: c,
974
+ autoExportInterval: w,
975
+ onExport: A,
976
+ onExportScheduled: S,
962
977
  onExportStatus: $,
963
- onExportReady: M,
964
- onImageLoad: i,
965
- onImageError: g,
966
- onImageLoadError: w,
967
- onError: I,
968
- onReady: p,
969
- className: c,
970
- style: m,
971
- enableShortcuts: A,
972
- overlay: k,
973
- resetDocumentOnMount: T
974
- } = r, W = E, L = r.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), H = r.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", Y = r.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, de = r.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, re = r.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, ie = r.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", D = r.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, P = r.initialImage ?? (a == null ? void 0 : a.src), B = r.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", K = r.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, j = r.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", F = r.initialImageRole ?? (a == null ? void 0 : a.role) ?? "design", C = Qe.useMemo(() => Ht(r.initialImageText, P), [r.initialImageText, P]), R = r.width ?? (t == null ? void 0 : t.width) ?? 1200, O = r.height ?? (t == null ? void 0 : t.height) ?? 1200, X = r.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = r.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, J = r.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Pe = r.maxHeight ?? (t == null ? void 0 : t.maxHeight), $e = r.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, De = r.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, be = r.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), ve = r.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), Oe = r.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), Ee = r.pieceGuides, Be = r.pieceFocus, We = A ?? !0, Z = Re(() => it(o ?? "pro-studio"), [o]);
975
- S(() => {
978
+ onExportReady: T,
979
+ onImageLoad: u,
980
+ onImageError: x,
981
+ onImageLoadError: d,
982
+ onError: p,
983
+ onReady: b,
984
+ className: g,
985
+ style: k,
986
+ enableShortcuts: E,
987
+ overlay: f,
988
+ resetDocumentOnMount: I
989
+ } = r, W = w, L = r.autoExportConfig ?? (e == null ? void 0 : e.autoExportConfig), H = r.autoExportFormat ?? (e == null ? void 0 : e.format) ?? "dataUrl", Y = r.autoExportAll ?? (e == null ? void 0 : e.exportAll) ?? !1, de = r.exportScale ?? (e == null ? void 0 : e.scale) ?? 2, re = r.maxExportSize ?? (e == null ? void 0 : e.maxSize) ?? 4e3, ie = r.exportImageFormat ?? (e == null ? void 0 : e.imageFormat) ?? "png", O = r.exportImageQuality ?? (e == null ? void 0 : e.imageQuality) ?? 0.92, P = r.initialImage ?? (a == null ? void 0 : a.src), B = r.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", K = r.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, j = r.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", R = r.initialImageRole ?? (a == null ? void 0 : a.role) ?? "design", M = Qe.useMemo(() => Ht(r.initialImageText, P), [r.initialImageText, P]), C = r.width ?? (t == null ? void 0 : t.width) ?? 1200, D = r.height ?? (t == null ? void 0 : t.height) ?? 1200, X = r.viewPadding ?? (t == null ? void 0 : t.viewPadding) ?? 0.9, z = r.artboardBorderRadius ?? (t == null ? void 0 : t.artboardBorderRadius) ?? 0, J = r.fixedMargin ?? (t == null ? void 0 : t.fixedMargin), Pe = r.maxHeight ?? (t == null ? void 0 : t.maxHeight), $e = r.showRotationHandle ?? (t == null ? void 0 : t.showRotationHandle) ?? !0, Oe = r.hideCanvas ?? (t == null ? void 0 : t.hideCanvas) ?? !1, be = r.canvasWrapperClassName ?? (t == null ? void 0 : t.canvasWrapperClassName), ve = r.canvasWrapperStyle ?? (t == null ? void 0 : t.canvasWrapperStyle), De = r.canvasCutouts ?? (t == null ? void 0 : t.canvasCutouts), Ee = r.pieceGuides, Be = r.pieceFocus, We = E ?? !0, Z = Re(() => it(o ?? "pro-studio"), [o]);
990
+ F(() => {
976
991
  var U;
977
992
  if (typeof ee < "u" && ((U = ee.env) == null ? void 0 : U.NODE_ENV) === "development" && Z) {
978
993
  const G = ct(Z);
979
994
  G.valid || Fe.warn("Kit validation warnings:", G.errors), G.warnings.length > 0 && Fe.warn("Kit validation warnings:", G.warnings);
980
995
  }
981
- }, [Z]), S(() => {
982
- if (w)
983
- return Xe(w);
984
- }, [w]);
985
- const { emitError: ue, handleBoundaryError: He } = Ut(I);
996
+ }, [Z]), F(() => {
997
+ if (d)
998
+ return Xe(d);
999
+ }, [d]);
1000
+ const { emitError: ue, handleBoundaryError: He } = Ut(p);
986
1001
  Vt({
987
- artboardConfigs: l,
988
- width: R,
989
- height: O,
1002
+ artboardConfigs: i,
1003
+ width: C,
1004
+ height: D,
990
1005
  pieceGuides: Ee,
991
- controlledActiveArtboard: u,
1006
+ controlledActiveArtboard: l,
992
1007
  onArtboardChange: s,
993
- resetDocumentOnMount: T
1008
+ resetDocumentOnMount: I
994
1009
  });
995
1010
  const { initialElementsLoadedState: Ke } = Xt({
996
- initialElements: f,
1011
+ initialElements: m,
997
1012
  customFonts: h,
998
1013
  emitError: ue
999
1014
  }), { imageLoadingState: ye, imageError: xe } = Jt({
1000
1015
  initialImage: P,
1001
- initialImageText: C,
1016
+ initialImageText: M,
1002
1017
  initialImageAlignment: B,
1003
1018
  initialImageScale: K,
1004
1019
  initialImageScaleMode: j,
1005
- initialImageRole: F,
1006
- artboardConfigs: l,
1007
- onImageLoad: i,
1008
- onImageError: g,
1020
+ initialImageRole: R,
1021
+ artboardConfigs: i,
1022
+ onImageLoad: u,
1023
+ onImageError: x,
1009
1024
  emitError: ue
1010
1025
  });
1011
- if (Qt({ onChange: b, onSelectionChange: d }), Yt(
1026
+ if (Qt({ onChange: v, onSelectionChange: c }), Yt(
1012
1027
  {
1013
1028
  autoExportInterval: W,
1014
1029
  autoExportConfig: L,
@@ -1017,39 +1032,39 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1017
1032
  exportScale: de,
1018
1033
  maxExportSize: re,
1019
1034
  exportImageFormat: ie,
1020
- exportImageQuality: D,
1021
- onExport: y,
1022
- onExportScheduled: x,
1035
+ exportImageQuality: O,
1036
+ onExport: A,
1037
+ onExportScheduled: S,
1023
1038
  onExportStatus: $,
1024
- onExportReady: M,
1025
- onReady: p,
1026
- hasInitialElements: !!f && f.length > 0,
1039
+ onExportReady: T,
1040
+ onReady: b,
1041
+ hasInitialElements: !!m && m.length > 0,
1027
1042
  initialElementsLoaded: Ke,
1028
1043
  emitError: ue
1029
1044
  },
1030
1045
  n
1031
1046
  ), ye === "loading")
1032
- return /* @__PURE__ */ v(
1047
+ return /* @__PURE__ */ y(
1033
1048
  "div",
1034
1049
  {
1035
- className: c,
1050
+ className: g,
1036
1051
  style: {
1037
- ...m,
1052
+ ...k,
1038
1053
  display: "flex",
1039
1054
  alignItems: "center",
1040
1055
  justifyContent: "center",
1041
1056
  backgroundColor: "var(--surface, #f5f5f5)"
1042
1057
  },
1043
- children: /* @__PURE__ */ v(lt, { size: 48 })
1058
+ children: /* @__PURE__ */ y(lt, { size: 48 })
1044
1059
  }
1045
1060
  );
1046
1061
  if (ye === "error" && xe)
1047
- return /* @__PURE__ */ v(
1062
+ return /* @__PURE__ */ y(
1048
1063
  "div",
1049
1064
  {
1050
- className: c,
1065
+ className: g,
1051
1066
  style: {
1052
- ...m,
1067
+ ...k,
1053
1068
  display: "flex",
1054
1069
  alignItems: "center",
1055
1070
  justifyContent: "center",
@@ -1058,15 +1073,15 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1058
1073
  padding: "1rem"
1059
1074
  },
1060
1075
  children: /* @__PURE__ */ _("div", { className: "sc:text-center", children: [
1061
- /* @__PURE__ */ v("div", { className: "sc:font-medium", children: "Failed to load image" }),
1062
- /* @__PURE__ */ v("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: xe.message })
1076
+ /* @__PURE__ */ y("div", { className: "sc:font-medium", children: "Failed to load image" }),
1077
+ /* @__PURE__ */ y("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: xe.message })
1063
1078
  ] })
1064
1079
  }
1065
1080
  );
1066
1081
  const je = Object.entries(((we = Z.layout) == null ? void 0 : we.slots) ?? {}).every(
1067
1082
  ([U, G]) => U === "canvas" || !G || G.length === 0
1068
1083
  ) ? { "--color-canvas-bg": "transparent" } : void 0;
1069
- return /* @__PURE__ */ v(dt, { kit: Z, children: /* @__PURE__ */ v("div", { className: `sc-root ${c || ""}`, style: { ...je, ...m, position: "relative" }, children: /* @__PURE__ */ _(
1084
+ return /* @__PURE__ */ y(dt, { kit: Z, children: /* @__PURE__ */ y("div", { className: `sc-root ${g || ""}`, style: { ...je, ...k, position: "relative" }, children: /* @__PURE__ */ _(
1070
1085
  Nt,
1071
1086
  {
1072
1087
  onError: He,
@@ -1086,9 +1101,9 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1086
1101
  textAlign: "center"
1087
1102
  },
1088
1103
  children: [
1089
- /* @__PURE__ */ v("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
1090
- /* @__PURE__ */ v("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: U.message }),
1091
- /* @__PURE__ */ v(
1104
+ /* @__PURE__ */ y("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
1105
+ /* @__PURE__ */ y("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: U.message }),
1106
+ /* @__PURE__ */ y(
1092
1107
  "button",
1093
1108
  {
1094
1109
  onClick: G,
@@ -1109,8 +1124,8 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1109
1124
  }
1110
1125
  ),
1111
1126
  children: [
1112
- !De && /* @__PURE__ */ (() => {
1113
- const U = /* @__PURE__ */ v(
1127
+ !Oe && /* @__PURE__ */ (() => {
1128
+ const U = /* @__PURE__ */ y(
1114
1129
  ut,
1115
1130
  {
1116
1131
  style: { width: "100%" },
@@ -1120,30 +1135,30 @@ const Fe = te("SnowconeCanvas"), Le = Ce((r, n) => {
1120
1135
  maxHeight: Pe,
1121
1136
  showRotationHandle: $e,
1122
1137
  enableShortcuts: We,
1123
- canvasCutouts: Oe,
1138
+ canvasCutouts: De,
1124
1139
  pieceGuides: Ee,
1125
1140
  pieceFocus: Be
1126
1141
  }
1127
1142
  );
1128
- return /* @__PURE__ */ v(Mt, { kit: Z, canvas: be || ve ? /* @__PURE__ */ v("div", { className: be, style: ve, children: U }) : U });
1143
+ return /* @__PURE__ */ y(Mt, { kit: Z, canvas: be || ve ? /* @__PURE__ */ y("div", { className: be, style: ve, children: U }) : U });
1129
1144
  })(),
1130
- k
1145
+ f
1131
1146
  ]
1132
1147
  }
1133
1148
  ) }) });
1134
1149
  });
1135
1150
  Le.displayName = "SnowconeCanvasInner";
1136
1151
  const qt = Ce((r, n) => {
1137
- var l;
1138
- const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((l = r.layoutConfig) == null ? void 0 : l.viewPadding);
1139
- return /* @__PURE__ */ v(
1152
+ var i;
1153
+ const { inheritTheme: e, externalProvider: a, services: t } = r, o = r.viewPadding ?? ((i = r.layoutConfig) == null ? void 0 : i.viewPadding);
1154
+ return /* @__PURE__ */ y(
1140
1155
  Lt,
1141
1156
  {
1142
1157
  inheritTheme: e,
1143
1158
  externalProvider: a,
1144
1159
  services: t,
1145
1160
  viewPadding: o,
1146
- children: /* @__PURE__ */ v(Le, { ref: n, ...r })
1161
+ children: /* @__PURE__ */ y(Le, { ref: n, ...r })
1147
1162
  }
1148
1163
  );
1149
1164
  });
@@ -1154,4 +1169,4 @@ export {
1154
1169
  Wt as a,
1155
1170
  $t as u
1156
1171
  };
1157
- //# sourceMappingURL=SnowconeCanvas-DE0A9UwD.js.map
1172
+ //# sourceMappingURL=SnowconeCanvas-COXpmwkS.js.map