@snowcone-app/canvas 0.1.9 → 0.1.12

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 (55) hide show
  1. package/dist/{CanvasStateV1-D5GzvmnY.cjs → CanvasStateV1-C4hC1MCe.cjs} +5 -5
  2. package/dist/{CanvasStateV1-D5GzvmnY.cjs.map → CanvasStateV1-C4hC1MCe.cjs.map} +1 -1
  3. package/dist/{CanvasStateV1-ejb4d_LM.js → CanvasStateV1-CJU_xYW5.js} +3 -3
  4. package/dist/{CanvasStateV1-ejb4d_LM.js.map → CanvasStateV1-CJU_xYW5.js.map} +1 -1
  5. package/dist/{HybridHistoryManager-BV6XV0nD.js → HybridHistoryManager-jBBnVim8.js} +54 -54
  6. package/dist/{HybridHistoryManager-BV6XV0nD.js.map → HybridHistoryManager-jBBnVim8.js.map} +1 -1
  7. package/dist/{ElementFactory-uJTXU-nP.js → ImportManager-Oqu2yB54.js} +916 -697
  8. package/dist/ImportManager-Oqu2yB54.js.map +1 -0
  9. package/dist/{ElementFactory-B7UOaJSD.cjs → ImportManager-W1eWhfyM.cjs} +5 -5
  10. package/dist/ImportManager-W1eWhfyM.cjs.map +1 -0
  11. package/dist/ThemeContext-BMNQKl1c.cjs +2 -0
  12. package/dist/{ThemeContext-4mJ_y0Me.cjs.map → ThemeContext-BMNQKl1c.cjs.map} +1 -1
  13. package/dist/ThemeContext-wj-wSO7J.js +1158 -0
  14. package/dist/{ThemeContext-H0Z-MqqR.js.map → ThemeContext-wj-wSO7J.js.map} +1 -1
  15. package/dist/advanced.js +5 -32
  16. package/dist/advanced.js.map +1 -1
  17. package/dist/advanced.mjs +593 -15081
  18. package/dist/advanced.mjs.map +1 -1
  19. package/dist/components/embed/KitLayout.d.ts +22 -0
  20. package/dist/components/embed/UndoRedoControls.d.ts +3 -0
  21. package/dist/compose-Dqh2f8tS.js +22222 -0
  22. package/dist/compose-Dqh2f8tS.js.map +1 -0
  23. package/dist/compose-HDJp4Z_d.cjs +60 -0
  24. package/dist/compose-HDJp4Z_d.cjs.map +1 -0
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +589 -508
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/internals.js +1 -1
  30. package/dist/internals.js.map +1 -1
  31. package/dist/internals.mjs +101 -102
  32. package/dist/internals.mjs.map +1 -1
  33. package/dist/style.css.d.ts +4 -0
  34. package/dist/testing.js +1 -1
  35. package/dist/testing.mjs +11 -11
  36. package/package.json +9 -5
  37. package/dist/ElementFactory-B7UOaJSD.cjs.map +0 -1
  38. package/dist/ElementFactory-uJTXU-nP.js.map +0 -1
  39. package/dist/ImportManager-BYwuK6n4.cjs +0 -2
  40. package/dist/ImportManager-BYwuK6n4.cjs.map +0 -1
  41. package/dist/ImportManager-CxiaRg1N.js +0 -222
  42. package/dist/ImportManager-CxiaRg1N.js.map +0 -1
  43. package/dist/ThemeContext-4mJ_y0Me.cjs +0 -2
  44. package/dist/ThemeContext-H0Z-MqqR.js +0 -1077
  45. package/dist/components/stories/utils/MockEditorProvider.d.ts +0 -32
  46. package/dist/components/stories/utils/QACanvasCard.d.ts +0 -41
  47. package/dist/components/stories/utils/VisualQACard.d.ts +0 -24
  48. package/dist/components/stories/utils/element-factories.d.ts +0 -188
  49. package/dist/components/stories/utils/spec-to-elements.d.ts +0 -74
  50. package/dist/components/stories/utils/themeDecorator.d.ts +0 -45
  51. package/dist/components/stories/utils/unified-test-cases.d.ts +0 -27
  52. package/dist/compose-Bo108juW.cjs +0 -33
  53. package/dist/compose-Bo108juW.cjs.map +0 -1
  54. package/dist/compose-DQ1FZS3O.js +0 -7690
  55. package/dist/compose-DQ1FZS3O.js.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,13 +1,147 @@
1
- import { A as ft, D as mt, r as ht, v as gt, u as pt, a as bt, S as vt, K as xt, C as Oe, e as wt } from "./compose-DQ1FZS3O.js";
2
- import { b as br, c as vr, E as xr, M as wr, P as Er, d as yr, f as Ar, g as Sr } from "./compose-DQ1FZS3O.js";
3
- import { c as _, s as Et, I as Ke, p as yt, T as At } from "./HybridHistoryManager-BV6XV0nD.js";
4
- import { jsxs as de, jsx as C } from "react/jsx-runtime";
5
- import { Component as St, useRef as T, useState as q, useEffect as R, useCallback as N, forwardRef as je, useMemo as ye, useImperativeHandle as Rt } from "react";
6
- import { u as ue, T as Xe, E as It, a as Ae, b as Ge, c as kt } from "./ThemeContext-H0Z-MqqR.js";
7
- import { C as we, E as Ct } from "./ElementFactory-uJTXU-nP.js";
8
- import { d as Ir, m as kr, s as Cr, v as Mr } from "./CanvasStateV1-ejb4d_LM.js";
9
- const Mt = _("ErrorBoundary");
10
- class Tt extends St {
1
+ import { T as We, i as Be, r as yt, a as Ue, g as wt, L as Et, E as At, b as St, I as kt, G as Rt, A as It, C as Ct, Z as Mt, M as ze, c as Tt, d as Dt, D as Ft, e as Pt, v as Nt, u as Ht, f as Lt, S as Wt, K as Bt, h as Ut, j as zt } from "./compose-Dqh2f8tS.js";
2
+ import { k as zr, l as $r, m as Or, n as Yr, P as Xr, o as Vr, p as Kr, q as jr } from "./compose-Dqh2f8tS.js";
3
+ import { c as q, p as Xe, s as $t, I as Ve, T as Ot } from "./HybridHistoryManager-jBBnVim8.js";
4
+ import { jsxs as j, jsx as v, Fragment as Ke } from "react/jsx-runtime";
5
+ import { useCallback as W, useMemo as me, Component as Yt, useRef as D, useState as re, useEffect as I, forwardRef as je, useImperativeHandle as Xt } from "react";
6
+ import { u as he, T as $e, E as Vt, a as Se, b as Ge, c as Kt } from "./ThemeContext-wj-wSO7J.js";
7
+ import { C as Ee, E as jt } from "./ImportManager-Oqu2yB54.js";
8
+ import { d as Zr, m as Qr, s as qr, v as Jr } from "./CanvasStateV1-CJU_xYW5.js";
9
+ const Oe = q("useCommands");
10
+ function Gt() {
11
+ const t = he(), {
12
+ undo: e,
13
+ redo: r,
14
+ canUndo: a,
15
+ canRedo: n,
16
+ executeElementUpdate: c,
17
+ executeAddElement: o,
18
+ executeRemoveElement: i,
19
+ executeReorderElement: l,
20
+ executeCommandBatch: m,
21
+ executeCreateArtboard: A,
22
+ executeDeleteArtboard: M,
23
+ executeUpdateArtboard: w
24
+ } = t, S = W(() => {
25
+ Oe.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
26
+ }, []), T = W((E) => {
27
+ Oe.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
28
+ }, []);
29
+ return {
30
+ // Undo/Redo
31
+ undo: e,
32
+ redo: r,
33
+ canUndo: a,
34
+ canRedo: n,
35
+ // History management
36
+ clearHistory: S,
37
+ clearArtboardHistory: T,
38
+ // Command execution
39
+ executeElementUpdate: c,
40
+ executeAddElement: o,
41
+ executeRemoveElement: i,
42
+ executeReorderElement: l,
43
+ executeCreateArtboard: A,
44
+ executeDeleteArtboard: M,
45
+ executeUpdateArtboard: w,
46
+ // Batch execution
47
+ executeCommandBatch: m
48
+ };
49
+ }
50
+ const Zt = () => {
51
+ const { undo: t, redo: e, canUndo: r, canRedo: a } = Gt();
52
+ return /* @__PURE__ */ j("div", { className: "sc-undo-redo", style: { display: "inline-flex", gap: 4 }, children: [
53
+ /* @__PURE__ */ v(
54
+ We,
55
+ {
56
+ icon: Be.undo,
57
+ onClick: t,
58
+ disabled: !r,
59
+ tooltip: "Undo",
60
+ "aria-label": "Undo"
61
+ }
62
+ ),
63
+ /* @__PURE__ */ v(
64
+ We,
65
+ {
66
+ icon: Be.redo,
67
+ onClick: e,
68
+ disabled: !a,
69
+ tooltip: "Redo",
70
+ "aria-label": "Redo"
71
+ }
72
+ )
73
+ ] });
74
+ }, Qt = q("KitLayout"), te = "canvas";
75
+ let Ye = !1;
76
+ function qt() {
77
+ Ye || (Ye = !0, yt({
78
+ LayersPanel: Et,
79
+ EffectsPanel: At,
80
+ ExportPanel: St,
81
+ ImagePanel: kt,
82
+ GlyphPanel: Rt,
83
+ ArtboardTabs: It,
84
+ ContextualToolbars: Ct,
85
+ ZoomControls: Mt,
86
+ MenuButton: ze,
87
+ CropPanel: Tt
88
+ }), Ue("add-element-menu", {
89
+ component: ze,
90
+ label: "Add Element",
91
+ icon: "gravity-ui:plus",
92
+ position: "topbar"
93
+ }), Ue("undo-redo-controls", {
94
+ component: Zt,
95
+ label: "Undo / Redo",
96
+ icon: "lucide:undo-2",
97
+ position: "topbar"
98
+ }));
99
+ }
100
+ function fe({ ids: t }) {
101
+ return !t || t.length === 0 ? null : /* @__PURE__ */ v(Ke, { children: t.map((e) => {
102
+ if (e === te) return null;
103
+ const r = wt(e);
104
+ if (!r)
105
+ return Xe.env.NODE_ENV === "development" && Qt.warn(
106
+ `Kit layout references unknown section "${e}" — skipping. Register it with registerSection("${e}", { ... }).`
107
+ ), null;
108
+ const a = r.component;
109
+ return /* @__PURE__ */ v(a, {}, e);
110
+ }) });
111
+ }
112
+ function Jt({ kit: t, canvas: e }) {
113
+ var l, m, A, M;
114
+ qt();
115
+ const r = t.layout.slots, a = !!((l = r.topbar) != null && l.some((w) => w !== te)), n = !!((m = r.left) != null && m.some((w) => w !== te)), c = !!((A = r.right) != null && A.some((w) => w !== te)), o = !!((M = r.bottombar) != null && M.some((w) => w !== te));
116
+ return me(
117
+ () => !a && !n && !c && !o,
118
+ [a, n, c, o]
119
+ ) ? /* @__PURE__ */ v(Ke, { children: e }) : /* @__PURE__ */ j("div", { className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
120
+ a && /* @__PURE__ */ v(
121
+ "div",
122
+ {
123
+ className: "sc-kit-topbar toolbar",
124
+ style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap", flexShrink: 0 },
125
+ children: /* @__PURE__ */ v(fe, { ids: r.topbar })
126
+ }
127
+ ),
128
+ /* @__PURE__ */ j("div", { className: "sc-kit-body", style: { display: "flex", flex: 1, minHeight: 0 }, children: [
129
+ n && /* @__PURE__ */ v("div", { className: "sc-kit-left", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(fe, { ids: r.left }) }),
130
+ /* @__PURE__ */ v("div", { className: "sc-kit-canvas", style: { flex: 1, minWidth: 0, position: "relative" }, children: e }),
131
+ c && /* @__PURE__ */ v("div", { className: "sc-kit-right", style: { flexShrink: 0, overflow: "auto" }, children: /* @__PURE__ */ v(fe, { ids: r.right }) })
132
+ ] }),
133
+ o && /* @__PURE__ */ v(
134
+ "div",
135
+ {
136
+ className: "sc-kit-bottombar toolbar",
137
+ style: { display: "flex", alignItems: "center", gap: 8, flexShrink: 0 },
138
+ children: /* @__PURE__ */ v(fe, { ids: r.bottombar })
139
+ }
140
+ )
141
+ ] });
142
+ }
143
+ const _t = q("ErrorBoundary");
144
+ class er extends Yt {
11
145
  constructor(e) {
12
146
  super(e), this.resetError = () => {
13
147
  this.setState({
@@ -26,7 +160,7 @@ class Tt extends St {
26
160
  };
27
161
  }
28
162
  componentDidCatch(e, r) {
29
- if (Mt.error("Caught error:", e, r), this.props.onError && this.props.onError(e, r), this.props.onCanvasError) {
163
+ if (_t.error("Caught error:", e, r), this.props.onError && this.props.onError(e, r), this.props.onCanvasError) {
30
164
  const a = {
31
165
  category: "unknown",
32
166
  message: e.message,
@@ -37,7 +171,7 @@ class Tt extends St {
37
171
  }
38
172
  }
39
173
  render() {
40
- return this.state.hasError && this.state.error ? this.props.renderError ? this.props.renderError(this.state.error, this.resetError) : this.props.fallback ? typeof this.props.fallback == "function" ? this.props.fallback(this.state.error, this.resetError) : this.props.fallback : /* @__PURE__ */ de(
174
+ return this.state.hasError && this.state.error ? this.props.renderError ? this.props.renderError(this.state.error, this.resetError) : this.props.fallback ? typeof this.props.fallback == "function" ? this.props.fallback(this.state.error, this.resetError) : this.props.fallback : /* @__PURE__ */ j(
41
175
  "div",
42
176
  {
43
177
  style: {
@@ -49,8 +183,8 @@ class Tt extends St {
49
183
  fontFamily: "system-ui, sans-serif"
50
184
  },
51
185
  children: [
52
- /* @__PURE__ */ C("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
53
- /* @__PURE__ */ C(
186
+ /* @__PURE__ */ v("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
187
+ /* @__PURE__ */ v(
54
188
  "pre",
55
189
  {
56
190
  style: {
@@ -65,7 +199,7 @@ class Tt extends St {
65
199
  children: this.state.error.message
66
200
  }
67
201
  ),
68
- /* @__PURE__ */ C(
202
+ /* @__PURE__ */ v(
69
203
  "button",
70
204
  {
71
205
  onClick: this.resetError,
@@ -87,80 +221,80 @@ class Tt extends St {
87
221
  ) : this.props.children;
88
222
  }
89
223
  }
90
- const Dt = _("useAutoExport");
91
- function Ft(t) {
92
- const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = T(null), p = T(!1), A = T({
224
+ const tr = q("useAutoExport");
225
+ function rr(t) {
226
+ const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = D(null), m = D(!1), A = D({
93
227
  totalExports: 0,
94
228
  skippedExports: 0,
95
229
  lastExportTime: null,
96
230
  avgExportInterval: 0
97
- }), [P, I] = q(A.current), E = T(c);
98
- E.current = c, R(() => {
99
- const m = new ft({
100
- ...mt,
231
+ }), [M, w] = re(A.current), S = D(c);
232
+ S.current = c, I(() => {
233
+ const h = new Dt({
234
+ ...Ft,
101
235
  ...e
102
236
  });
103
- return m.onExport(async () => {
237
+ return h.onExport(async () => {
104
238
  try {
105
- await E.current(), A.current = m.getStats();
106
- } catch (S) {
107
- Dt.error("[useAutoExport] Export failed:", S);
239
+ await S.current(), A.current = h.getStats();
240
+ } catch (R) {
241
+ tr.error("[useAutoExport] Export failed:", R);
108
242
  }
109
- }), l.current = m, () => {
110
- m.destroy();
243
+ }), l.current = h, () => {
244
+ h.destroy();
111
245
  };
112
- }, []), R(() => {
113
- i && p.current && l.current && (p.current = !1, l.current.forceExport());
114
- }, [i]), R(() => {
246
+ }, []), I(() => {
247
+ i && m.current && l.current && (m.current = !1, l.current.forceExport());
248
+ }, [i]), I(() => {
115
249
  l.current && e && l.current.updateConfig(e);
116
- }, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]), R(() => {
250
+ }, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]), I(() => {
117
251
  l.current && o && l.current.onExportScheduled(o);
118
- }, [o]), R(() => {
252
+ }, [o]), I(() => {
119
253
  if (!r || !l.current)
120
254
  return;
121
- const m = r.onCommandExecuted(() => {
255
+ const h = r.onCommandExecuted(() => {
122
256
  if (l.current) {
123
257
  if (!i) {
124
- p.current = !0;
258
+ m.current = !0;
125
259
  return;
126
260
  }
127
261
  l.current.scheduleExport();
128
262
  }
129
263
  });
130
264
  return () => {
131
- m();
265
+ h();
132
266
  };
133
- }, [r, i]), R(() => {
267
+ }, [r, i]), I(() => {
134
268
  if (l.current) {
135
269
  if (!i) {
136
- p.current = !0;
270
+ m.current = !0;
137
271
  return;
138
272
  }
139
273
  l.current.scheduleExport();
140
274
  }
141
- }, [n, a, i]), R(() => Et((S) => {
275
+ }, [n, a, i]), I(() => $t((R) => {
142
276
  if (!l.current || !i) return;
143
- n.some((W) => W.id === S) && l.current.scheduleExport();
277
+ n.some((L) => L.id === R) && l.current.scheduleExport();
144
278
  }), [n, i]);
145
- const M = N((m) => {
146
- l.current && l.current.updateConfig(m);
147
- }, []), w = N(async () => {
148
- l.current && (await l.current.forceExport(), A.current = l.current.getStats(), I(A.current));
149
- }, []), H = N(() => {
150
- l.current && (l.current.resetStats(), A.current = l.current.getStats(), I(A.current));
151
- }, []), y = N(() => {
279
+ const T = W((h) => {
280
+ l.current && l.current.updateConfig(h);
281
+ }, []), E = W(async () => {
282
+ l.current && (await l.current.forceExport(), A.current = l.current.getStats(), w(A.current));
283
+ }, []), N = W(() => {
284
+ l.current && (l.current.resetStats(), A.current = l.current.getStats(), w(A.current));
285
+ }, []), k = W(() => {
152
286
  l.current && l.current.resetChangeDetection();
153
287
  }, []);
154
288
  return {
155
- stats: P,
156
- updateConfig: M,
157
- forceExport: w,
158
- resetStats: H,
159
- resetChangeDetection: y
289
+ stats: M,
290
+ updateConfig: T,
291
+ forceExport: E,
292
+ resetStats: N,
293
+ resetChangeDetection: k
160
294
  };
161
295
  }
162
- const Qe = _("useContentReady");
163
- function Pt(t) {
296
+ const Ze = q("useContentReady");
297
+ function nr(t) {
164
298
  var r;
165
299
  const e = /* @__PURE__ */ new Set();
166
300
  for (const a of t)
@@ -174,7 +308,7 @@ function Pt(t) {
174
308
  }
175
309
  return Array.from(e);
176
310
  }
177
- async function Ht(t) {
311
+ async function ar(t) {
178
312
  if (t.length === 0 || typeof document > "u" || !document.fonts) return;
179
313
  const e = [];
180
314
  for (const r of t) {
@@ -184,24 +318,24 @@ async function Ht(t) {
184
318
  await Promise.all(e), document.fonts.ready && await Promise.race([
185
319
  document.fonts.ready,
186
320
  new Promise((r) => setTimeout(r, 250))
187
- ]), Qe.debug(`Awaited ${e.length} font(s)`);
321
+ ]), Ze.debug(`Awaited ${e.length} font(s)`);
188
322
  }
189
- function Lt() {
323
+ function or() {
190
324
  return new Promise((t) => requestAnimationFrame(() => t()));
191
325
  }
192
- function Wt(t) {
193
- const { isCanvasReady: e, elements: r, hasInitialElements: a, initialElementsLoaded: n } = t, [c, o] = q(!1), i = T(!1);
194
- return R(() => {
326
+ function sr(t) {
327
+ const { isCanvasReady: e, elements: r, hasInitialElements: a, initialElementsLoaded: n } = t, [c, o] = re(!1), i = D(!1);
328
+ return I(() => {
195
329
  if (c || !e || a && !n || a && r.length === 0 || i.current) return;
196
330
  i.current = !0;
197
331
  let l = !1;
198
332
  return (async () => {
199
333
  try {
200
- const p = Pt(r);
201
- if (p.length > 0 && (await Ht(p), l) || (await Lt(), l)) return;
334
+ const m = nr(r);
335
+ if (m.length > 0 && (await ar(m), l) || (await or(), l)) return;
202
336
  o(!0);
203
- } catch (p) {
204
- Qe.error("Error during content readiness check:", p), l || o(!0);
337
+ } catch (m) {
338
+ Ze.error("Error during content readiness check:", m), l || o(!0);
205
339
  } finally {
206
340
  i.current = !1;
207
341
  }
@@ -210,7 +344,7 @@ function Wt(t) {
210
344
  };
211
345
  }, [e, r, a, n, c]), c;
212
346
  }
213
- const Nt = {
347
+ const ir = {
214
348
  // Vertical alignments (map to top/center/bottom center)
215
349
  "far-top": "t",
216
350
  top: "t",
@@ -233,75 +367,75 @@ const Nt = {
233
367
  b: "b",
234
368
  br: "br"
235
369
  };
236
- function Bt(t) {
237
- return t && Nt[t] || "c";
370
+ function cr(t) {
371
+ return t && ir[t] || "c";
238
372
  }
239
- function Ut(t, e) {
240
- const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, p = i / t.width, A = l / t.height, P = r === "contain" ? Math.min(p, A) : Math.max(p, A), I = e.scale || 1, E = P * I, M = t.width * E, w = t.height * E, H = e.align || "c";
241
- let y = 0, m = 0;
242
- const S = M - i, v = w - l;
243
- switch (H) {
373
+ function lr(t, e) {
374
+ const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, m = i / t.width, A = l / t.height, M = r === "contain" ? Math.min(m, A) : Math.max(m, A), w = e.scale || 1, S = M * w, T = t.width * S, E = t.height * S, N = e.align || "c";
375
+ let k = 0, h = 0;
376
+ const R = T - i, x = E - l;
377
+ switch (N) {
244
378
  // Top row
245
379
  case "tl":
246
- y = 0, m = 0;
380
+ k = 0, h = 0;
247
381
  break;
248
382
  case "t":
249
- y = -S / 2, m = 0;
383
+ k = -R / 2, h = 0;
250
384
  break;
251
385
  case "tr":
252
- y = -S, m = 0;
386
+ k = -R, h = 0;
253
387
  break;
254
388
  // Middle row
255
389
  case "l":
256
- y = 0, m = -v / 2;
390
+ k = 0, h = -x / 2;
257
391
  break;
258
392
  case "c":
259
393
  // Center (default)
260
394
  default:
261
- y = -S / 2, m = -v / 2;
395
+ k = -R / 2, h = -x / 2;
262
396
  break;
263
397
  case "r":
264
- y = -S, m = -v / 2;
398
+ k = -R, h = -x / 2;
265
399
  break;
266
400
  // Bottom row
267
401
  case "bl":
268
- y = 0, m = -v;
402
+ k = 0, h = -x;
269
403
  break;
270
404
  case "b":
271
- y = -S / 2, m = -v;
405
+ k = -R / 2, h = -x;
272
406
  break;
273
407
  case "br":
274
- y = -S, m = -v;
408
+ k = -R, h = -x;
275
409
  break;
276
410
  }
277
- y += o, m += a;
278
- const W = e.offsetX || 0, D = e.offsetY || 0, $ = S, ee = v;
279
- return y += W * $, m += D * ee, y = Math.round(y), m = Math.round(m), {
411
+ k += o, h += a;
412
+ const L = e.offsetX || 0, F = e.offsetY || 0, O = R, ne = x;
413
+ return k += L * O, h += F * ne, k = Math.round(k), h = Math.round(h), {
280
414
  // Final scale to apply to artwork
281
- scale: E,
415
+ scale: S,
282
416
  // Final artwork dimensions after scaling
283
- width: Math.round(M),
284
- height: Math.round(w),
417
+ width: Math.round(T),
418
+ height: Math.round(E),
285
419
  // Position to draw artwork (relative to artboard origin)
286
- x: y,
287
- y: m,
420
+ x: k,
421
+ y: h,
288
422
  // Debug info
289
423
  debug: {
290
- coverScale: P,
291
- userScale: I,
292
- overflow: { x: S, y: v },
293
- alignment: H,
294
- appliedOffset: { x: W * $, y: D * ee }
424
+ coverScale: M,
425
+ userScale: w,
426
+ overflow: { x: R, y: x },
427
+ alignment: N,
428
+ appliedOffset: { x: L * O, y: F * ne }
295
429
  }
296
430
  };
297
431
  }
298
- const zt = {
432
+ const dr = {
299
433
  timeout: 3e4,
300
434
  retries: 1,
301
435
  retryDelay: 1e3,
302
436
  validateUrl: !0
303
437
  };
304
- function Yt(t) {
438
+ function ur(t) {
305
439
  try {
306
440
  const e = new URL(t);
307
441
  return ["http:", "https:", "data:", "blob:"].includes(e.protocol);
@@ -309,9 +443,9 @@ function Yt(t) {
309
443
  return !1;
310
444
  }
311
445
  }
312
- async function $t(t, e = {}) {
313
- const r = { ...zt, ...e };
314
- if (r.validateUrl && !Yt(t))
446
+ async function fr(t, e = {}) {
447
+ const r = { ...dr, ...e };
448
+ if (r.validateUrl && !ur(t))
315
449
  return {
316
450
  success: !1,
317
451
  error: new Error(`Invalid image URL: ${t}`)
@@ -319,16 +453,16 @@ async function $t(t, e = {}) {
319
453
  let a;
320
454
  for (let n = 0; n <= r.retries; n++)
321
455
  try {
322
- return await Ot(t, r.timeout);
456
+ return await mr(t, r.timeout);
323
457
  } catch (c) {
324
- a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await Vt(r.retryDelay);
458
+ a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await gr(r.retryDelay);
325
459
  }
326
460
  return {
327
461
  success: !1,
328
462
  error: a || new Error("Failed to load image after retries")
329
463
  };
330
464
  }
331
- function Ot(t, e) {
465
+ function mr(t, e) {
332
466
  return new Promise((r) => {
333
467
  const a = new Image();
334
468
  a.crossOrigin = "anonymous";
@@ -338,18 +472,18 @@ function Ot(t, e) {
338
472
  }, i = () => {
339
473
  if (c) return;
340
474
  c = !0, o();
341
- const p = a.naturalWidth || a.width, A = a.naturalHeight || a.height;
475
+ const m = a.naturalWidth || a.width, A = a.naturalHeight || a.height;
342
476
  r({
343
477
  success: !0,
344
478
  element: a,
345
- width: p,
479
+ width: m,
346
480
  height: A,
347
- aspectRatio: A > 0 ? p / A : 1
481
+ aspectRatio: A > 0 ? m / A : 1
348
482
  });
349
- }, l = (p) => {
483
+ }, l = (m) => {
350
484
  c || (c = !0, o(), r({
351
485
  success: !1,
352
- error: new Error(p)
486
+ error: new Error(m)
353
487
  }));
354
488
  };
355
489
  a.onload = i, a.onerror = () => {
@@ -359,9 +493,9 @@ function Ot(t, e) {
359
493
  }, e), a.src = t;
360
494
  });
361
495
  }
362
- async function Xt(t, e, r = {}, a = {}) {
363
- var I, E, M, w, H, y, m;
364
- const n = await $t(t, a);
496
+ async function hr(t, e, r = {}, a = {}) {
497
+ var w, S, T, E, N, k, h;
498
+ const n = await fr(t, a);
365
499
  if (!n.success || !n.width || !n.height)
366
500
  return {
367
501
  success: !1,
@@ -371,7 +505,7 @@ async function Xt(t, e, r = {}, a = {}) {
371
505
  width: e.artboard.width,
372
506
  height: e.artboard.height,
373
507
  scale: e.scale,
374
- align: Bt(e.alignment),
508
+ align: cr(e.alignment),
375
509
  offsetX: e.offsetX,
376
510
  offsetY: e.offsetY,
377
511
  scaleMode: e.scaleMode,
@@ -379,15 +513,15 @@ async function Xt(t, e, r = {}, a = {}) {
379
513
  marginRight: e.marginRight,
380
514
  marginBottom: e.marginBottom,
381
515
  marginLeft: e.marginLeft
382
- }, o = Ut(
516
+ }, o = lr(
383
517
  { width: n.width, height: n.height },
384
518
  c
385
- ), i = e.artboard.x + o.x, l = e.artboard.y + o.y, p = i + o.width / 2, A = l + o.height / 2;
519
+ ), i = e.artboard.x + o.x, l = e.artboard.y + o.y, m = i + o.width / 2, A = l + o.height / 2;
386
520
  return {
387
521
  success: !0,
388
- element: new Ke({
522
+ element: new Ve({
389
523
  ...r,
390
- x: p,
524
+ x: m,
391
525
  y: A,
392
526
  imageUrl: t,
393
527
  imageAspectRatio: n.aspectRatio,
@@ -397,28 +531,28 @@ async function Xt(t, e, r = {}, a = {}) {
397
531
  type: "image",
398
532
  width: o.width,
399
533
  height: o.height,
400
- cropX: ((I = r.transformData) == null ? void 0 : I.cropX) ?? 0,
401
- cropY: ((E = r.transformData) == null ? void 0 : E.cropY) ?? 0,
402
- cropWidth: ((M = r.transformData) == null ? void 0 : M.cropWidth) ?? 1,
403
- cropHeight: ((w = r.transformData) == null ? void 0 : w.cropHeight) ?? 1,
404
- flipHorizontal: ((H = r.transformData) == null ? void 0 : H.flipHorizontal) ?? !1,
405
- flipVertical: ((y = r.transformData) == null ? void 0 : y.flipVertical) ?? !1,
406
- borderRadius: ((m = r.transformData) == null ? void 0 : m.borderRadius) ?? 0
534
+ cropX: ((w = r.transformData) == null ? void 0 : w.cropX) ?? 0,
535
+ cropY: ((S = r.transformData) == null ? void 0 : S.cropY) ?? 0,
536
+ cropWidth: ((T = r.transformData) == null ? void 0 : T.cropWidth) ?? 1,
537
+ cropHeight: ((E = r.transformData) == null ? void 0 : E.cropHeight) ?? 1,
538
+ flipHorizontal: ((N = r.transformData) == null ? void 0 : N.flipHorizontal) ?? !1,
539
+ flipVertical: ((k = r.transformData) == null ? void 0 : k.flipVertical) ?? !1,
540
+ borderRadius: ((h = r.transformData) == null ? void 0 : h.borderRadius) ?? 0
407
541
  }
408
542
  }),
409
543
  placement: {
410
544
  artworkSize: { width: n.width, height: n.height },
411
545
  finalSize: { width: o.width, height: o.height },
412
- position: { x: p, y: A },
546
+ position: { x: m, y: A },
413
547
  scale: o.scale
414
548
  }
415
549
  };
416
550
  }
417
- function Vt(t) {
551
+ function gr(t) {
418
552
  return new Promise((e) => setTimeout(e, t));
419
553
  }
420
- const K = _("SnowconeCanvas");
421
- function Ee(t, e, r, a) {
554
+ const K = q("SnowconeCanvas");
555
+ function Ae(t, e, r, a) {
422
556
  if (a <= 0 || !isFinite(a))
423
557
  return r;
424
558
  const n = t * r, c = e * r;
@@ -427,7 +561,7 @@ function Ee(t, e, r, a) {
427
561
  const i = Math.max(t, e), l = a / i;
428
562
  return Math.min(l, r);
429
563
  }
430
- const Je = je((t, e) => {
564
+ const Qe = je((t, e) => {
431
565
  const {
432
566
  exportConfig: r,
433
567
  imageConfig: a,
@@ -436,152 +570,152 @@ const Je = je((t, e) => {
436
570
  artboards: o,
437
571
  activeArtboard: i,
438
572
  onArtboardChange: l,
439
- initialElements: p,
573
+ initialElements: m,
440
574
  onChange: A,
441
- onSelectionChange: P,
442
- autoExportInterval: I,
443
- onExport: E,
444
- onExportScheduled: M,
445
- onExportStatus: w,
446
- onExportReady: H,
447
- onImageLoad: y,
448
- onImageError: m,
449
- onError: S,
450
- onReady: v,
451
- className: W,
452
- style: D,
453
- enableShortcuts: $,
454
- overlay: ee
455
- } = t, Se = I, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), j = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", fe = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, X = t.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, U = t.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, te = t.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", re = t.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, z = t.initialImage ?? (a == null ? void 0 : a.src), Re = t.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", Ie = t.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, ke = t.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", Ze = t.width ?? (n == null ? void 0 : n.width) ?? 1200, qe = t.height ?? (n == null ? void 0 : n.height) ?? 1200, Ce = t.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, Me = t.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, Te = t.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), De = t.maxHeight ?? (n == null ? void 0 : n.maxHeight), Fe = t.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, _e = t.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Pe = t.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), He = t.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Le = t.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), me = t.pieceGuides, We = t.pieceFocus, Ne = $ ?? !0, ne = ye(() => ht(c ?? "pro-studio"), [c]);
456
- R(() => {
457
- if (yt.env.NODE_ENV === "development" && ne) {
458
- const s = gt(ne);
575
+ onSelectionChange: M,
576
+ autoExportInterval: w,
577
+ onExport: S,
578
+ onExportScheduled: T,
579
+ onExportStatus: E,
580
+ onExportReady: N,
581
+ onImageLoad: k,
582
+ onImageError: h,
583
+ onError: R,
584
+ onReady: x,
585
+ className: L,
586
+ style: F,
587
+ enableShortcuts: O,
588
+ overlay: ne
589
+ } = t, ke = w, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), G = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", ge = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, X = t.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, U = t.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, ae = t.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", oe = t.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, z = t.initialImage ?? (a == null ? void 0 : a.src), Re = t.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", Ie = t.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, Ce = t.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", qe = t.width ?? (n == null ? void 0 : n.width) ?? 1200, Je = t.height ?? (n == null ? void 0 : n.height) ?? 1200, _e = t.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, et = t.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, tt = t.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), rt = t.maxHeight ?? (n == null ? void 0 : n.maxHeight), nt = t.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, at = t.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Me = t.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), Te = t.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), ot = t.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), De = t.pieceGuides, st = t.pieceFocus, it = O ?? !0, _ = me(() => Pt(c ?? "pro-studio"), [c]);
590
+ I(() => {
591
+ if (Xe.env.NODE_ENV === "development" && _) {
592
+ const s = Nt(_);
459
593
  s.valid || K.warn("Kit validation warnings:", s.errors), s.warnings.length > 0 && K.warn("Kit validation warnings:", s.warnings);
460
594
  }
461
- }, [ne]);
462
- const ae = T(S);
463
- ae.current = S;
464
- const B = N((s) => {
595
+ }, [_]);
596
+ const se = D(R);
597
+ se.current = R;
598
+ const B = W((s) => {
465
599
  var d;
466
- K.error(`[${s.category}] ${s.message}`, s.originalError), (d = ae.current) == null || d.call(ae, s);
600
+ K.error(`[${s.category}] ${s.message}`, s.originalError), (d = se.current) == null || d.call(se, s);
467
601
  }, []);
468
- R(() => (we.onRenderError = B, () => {
469
- we.onRenderError === B && (we.onRenderError = null);
602
+ I(() => (Ee.onRenderError = B, () => {
603
+ Ee.onRenderError === B && (Ee.onRenderError = null);
470
604
  }), [B]);
471
605
  const {
472
606
  elements: V,
473
- setElements: oe,
474
- selectedId: Be,
475
- artboardManager: k,
476
- refreshArtboards: et,
477
- historyManager: tt,
478
- isCanvasReady: he,
479
- setCanvasReady: se
480
- } = ue(), { createArtboard: rt, selectArtboard: nt, artboards: L } = pt(), { exportArtboard: G, exportAllArtboards: ie, exportArtboardAsBlob: Q, exportAllArtboardsAsBlobs: ce } = bt();
481
- Rt(e, () => ({
607
+ setElements: ie,
608
+ selectedId: Fe,
609
+ artboardManager: C,
610
+ refreshArtboards: ct,
611
+ historyManager: lt,
612
+ isCanvasReady: pe,
613
+ setCanvasReady: ce
614
+ } = he(), { createArtboard: dt, selectArtboard: ut, artboards: H } = Ht(), { exportArtboard: Z, exportAllArtboards: le, exportArtboardAsBlob: Q, exportAllArtboardsAsBlobs: de } = Lt();
615
+ Xt(e, () => ({
482
616
  exportArtboards: async (s = {}) => {
483
- const d = s.format || j, h = s.scale || X, g = s.all ?? !1;
484
- let f = h;
617
+ const d = s.format || G, g = s.scale || X, p = s.all ?? !1;
618
+ let f = g;
485
619
  if (U > 0 && isFinite(U))
486
- for (const x of L) {
487
- const b = Ee(x.width, x.height, h, U);
620
+ for (const y of H) {
621
+ const b = Ae(y.width, y.height, g, U);
488
622
  f = Math.min(f, b);
489
623
  }
490
- const u = { scale: f, format: te, quality: re };
491
- if (g) {
492
- const x = d === "blob" ? await ce(u) : await ie(u), b = {};
493
- for (const [F, Y] of Object.entries(x)) {
494
- const O = L.find((Z) => Z.id === F);
495
- O && (b[O.name] = Y);
624
+ const u = { scale: f, format: ae, quality: oe };
625
+ if (p) {
626
+ const y = d === "blob" ? await de(u) : await le(u), b = {};
627
+ for (const [P, $] of Object.entries(y)) {
628
+ const Y = H.find((ee) => ee.id === P);
629
+ Y && (b[Y.name] = $);
496
630
  }
497
631
  return b;
498
632
  } else {
499
- const x = k.getActiveArtboard();
500
- if (!x)
633
+ const y = C.getActiveArtboard();
634
+ if (!y)
501
635
  throw new Error("[SnowconeCanvas] No active artboard found");
502
636
  if (d === "blob") {
503
- const b = await Q(x.id, u);
504
- return { [x.name]: b };
637
+ const b = await Q(y.id, u);
638
+ return { [y.name]: b };
505
639
  } else {
506
- const b = await G(x.id, u);
507
- return { [x.name]: b };
640
+ const b = await Z(y.id, u);
641
+ return { [y.name]: b };
508
642
  }
509
643
  }
510
644
  }
511
- }), [G, ie, Q, ce, j, X, U, te, re, k, L]), R(() => {
512
- H && H(async () => {
513
- const d = k.getActiveArtboard();
645
+ }), [Z, le, Q, de, G, X, U, ae, oe, C, H]), I(() => {
646
+ N && N(async () => {
647
+ const d = C.getActiveArtboard();
514
648
  if (!d)
515
649
  throw new Error("[SnowconeCanvas] No active artboard found");
516
- const h = Ee(
650
+ const g = Ae(
517
651
  d.width,
518
652
  d.height,
519
653
  X,
520
654
  U
521
- ), g = j === "blob" ? await Q(d.id, { scale: h }) : await G(d.id, { scale: h });
522
- return { [d.name]: g };
655
+ ), p = G === "blob" ? await Q(d.id, { scale: g }) : await Z(d.id, { scale: g });
656
+ return { [d.name]: p };
523
657
  });
524
- }, [H, G, Q, k, j, X, U]);
525
- const [Ue, le] = q("idle"), [ze, ge] = q(null), pe = T(void 0), be = T(!1), Ye = T(!1), [at, ot] = q(!1), st = T(0), it = T(0), ve = T(!1);
526
- R(() => {
527
- if (be.current) return;
528
- be.current = !0;
529
- const s = o || [{ name: "Design", width: Ze, height: qe }], d = k.getAllArtboards();
658
+ }, [N, Z, Q, C, G, X, U]);
659
+ const [Pe, ue] = re("idle"), [Ne, be] = re(null), ve = D(void 0), xe = D(!1), He = D(!1), [ft, mt] = re(!1), ht = D(0), gt = D(0), ye = D(!1);
660
+ I(() => {
661
+ if (xe.current) return;
662
+ xe.current = !0;
663
+ const s = o || [{ name: "Design", width: qe, height: Je }], d = C.getAllArtboards();
530
664
  if (d.length > 0) {
531
- const h = s[0], g = d[0], f = me ? "transparent" : void 0;
532
- g.name = h.name, g.width = h.width, g.height = h.height, g.clipShape = h.clipShape, h.backgroundColor ? g.backgroundColor = h.backgroundColor : f && (g.backgroundColor = f);
665
+ const g = s[0], p = d[0], f = De ? "transparent" : void 0;
666
+ p.name = g.name, p.width = g.width, p.height = g.height, p.clipShape = g.clipShape, g.backgroundColor ? p.backgroundColor = g.backgroundColor : f && (p.backgroundColor = f);
533
667
  for (let u = 1; u < s.length; u++)
534
- rt(s[u].width, s[u].height, {
668
+ dt(s[u].width, s[u].height, {
535
669
  name: s[u].name,
536
670
  backgroundColor: s[u].backgroundColor ?? f,
537
671
  clipShape: s[u].clipShape
538
672
  });
539
673
  }
540
- et();
541
- }, []), R(() => {
542
- if (!(!p || p.length === 0) && !Ye.current && be.current) {
543
- Ye.current = !0, ot(!0);
674
+ ct();
675
+ }, []), I(() => {
676
+ if (!(!m || m.length === 0) && !He.current && xe.current) {
677
+ He.current = !0, mt(!0);
544
678
  try {
545
- const s = Ct.createManyFromJSON(p), d = k.getAllArtboards();
679
+ const s = jt.createManyFromJSON(m), d = C.getAllArtboards();
546
680
  if (d.length > 0) {
547
- const g = d[0];
681
+ const p = d[0];
548
682
  for (const f of s)
549
- k.addElementToArtboard(f.id, g.id);
683
+ C.addElementToArtboard(f.id, p.id);
550
684
  }
551
- oe(s);
552
- const h = /* @__PURE__ */ new Set();
553
- for (const g of s) {
554
- const f = g.fontFamily;
555
- typeof f == "string" && f.trim().length > 0 && h.add(f);
685
+ ie(s);
686
+ const g = /* @__PURE__ */ new Set();
687
+ for (const p of s) {
688
+ const f = p.fontFamily;
689
+ typeof f == "string" && f.trim().length > 0 && g.add(f);
556
690
  }
557
- if (h.size > 0 && typeof document < "u") {
558
- const g = document.fonts ?? null, f = Array.from(h).map((u) => {
559
- const x = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
560
- let b = document.getElementById(x);
561
- return b || (b = document.createElement("link"), b.id = x, b.rel = "stylesheet", b.href = `https://fonts.googleapis.com/css2?family=${u.replace(
691
+ if (g.size > 0 && typeof document < "u") {
692
+ const p = document.fonts ?? null, f = Array.from(g).map((u) => {
693
+ const y = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
694
+ let b = document.getElementById(y);
695
+ return b || (b = document.createElement("link"), b.id = y, b.rel = "stylesheet", b.href = `https://fonts.googleapis.com/css2?family=${u.replace(
562
696
  /\s+/g,
563
697
  "+"
564
- )}:wght@400;700&display=swap`, document.head.appendChild(b)), new Promise((F) => {
698
+ )}:wght@400;700&display=swap`, document.head.appendChild(b)), new Promise((P) => {
565
699
  if (b.sheet) {
566
- F(u);
700
+ P(u);
567
701
  return;
568
702
  }
569
- const Y = () => F(u);
570
- b.addEventListener("load", Y, { once: !0 }), b.addEventListener("error", Y, { once: !0 }), setTimeout(Y, 4e3);
703
+ const $ = () => P(u);
704
+ b.addEventListener("load", $, { once: !0 }), b.addEventListener("error", $, { once: !0 }), setTimeout($, 4e3);
571
705
  });
572
706
  });
573
707
  Promise.all(f).then((u) => {
574
- if (g)
708
+ if (p)
575
709
  return Promise.all(
576
- u.flatMap((x) => [
577
- g.load(`400 16px "${x}"`).catch(() => {
710
+ u.flatMap((y) => [
711
+ p.load(`400 16px "${y}"`).catch(() => {
578
712
  }),
579
- g.load(`700 16px "${x}"`).catch(() => {
713
+ p.load(`700 16px "${y}"`).catch(() => {
580
714
  })
581
715
  ])
582
716
  );
583
717
  }).then(() => {
584
- oe((u) => u.slice());
718
+ ie((u) => u.slice());
585
719
  });
586
720
  }
587
721
  } catch (s) {
@@ -595,38 +729,38 @@ const Je = je((t, e) => {
595
729
  });
596
730
  }
597
731
  }
598
- }, [p, k, oe, B]), R(() => {
732
+ }, [m, C, ie, B]), I(() => {
599
733
  if (!i) {
600
- ve.current = !0;
734
+ ye.current = !0;
601
735
  return;
602
736
  }
603
- const s = L.find((d) => d.name === i);
737
+ const s = H.find((d) => d.name === i);
604
738
  if (s) {
605
- const d = k.getActiveArtboard();
606
- (d == null ? void 0 : d.name) !== i && nt(s.id), ve.current = !0;
739
+ const d = C.getActiveArtboard();
740
+ (d == null ? void 0 : d.name) !== i && ut(s.id), ye.current = !0;
607
741
  }
608
- }, [i, L]), R(() => {
609
- if (!z || pe.current === z) return;
742
+ }, [i, H]), I(() => {
743
+ if (!z || ve.current === z) return;
610
744
  if (V.length > 0) {
611
- pe.current = z;
745
+ ve.current = z;
612
746
  return;
613
747
  }
614
- pe.current = z, (async () => {
615
- le("loading"), ge(null);
748
+ ve.current = z, (async () => {
749
+ ue("loading"), be(null);
616
750
  try {
617
- const d = k.getAllArtboards();
751
+ const d = C.getAllArtboards();
618
752
  if (d.length === 0)
619
753
  throw new Error("No artboards available");
620
- const h = [];
621
- for (const g of d) {
622
- const f = o == null ? void 0 : o.find((b) => b.name === g.name), u = (f == null ? void 0 : f.scaleMode) || ke, x = await Xt(
754
+ const g = [];
755
+ for (const p of d) {
756
+ const f = o == null ? void 0 : o.find((b) => b.name === p.name), u = (f == null ? void 0 : f.scaleMode) || Ce, y = await hr(
623
757
  z,
624
758
  {
625
759
  artboard: {
626
- width: g.width,
627
- height: g.height,
628
- x: g.x,
629
- y: g.y
760
+ width: p.width,
761
+ height: p.height,
762
+ x: p.x,
763
+ y: p.y
630
764
  },
631
765
  alignment: (f == null ? void 0 : f.fitAlign) || Re,
632
766
  scale: Ie,
@@ -637,135 +771,135 @@ const Je = je((t, e) => {
637
771
  marginLeft: f == null ? void 0 : f.fitMarginLeft
638
772
  }
639
773
  );
640
- x.success && x.element ? (k.addElementToArtboard(x.element.id, g.id), h.push(x.element)) : K.error("Failed to load image for artboard:", g.name, x.error);
774
+ y.success && y.element ? (C.addElementToArtboard(y.element.id, p.id), g.push(y.element)) : K.error("Failed to load image for artboard:", p.name, y.error);
641
775
  }
642
- if (h.length > 0)
643
- oe((g) => [...g, ...h]), le("success"), y == null || y(z);
776
+ if (g.length > 0)
777
+ ie((p) => [...p, ...g]), ue("success"), k == null || k(z);
644
778
  else {
645
- const g = new Error("Failed to load image into any artboard");
646
- le("error"), ge(g), m == null || m(z, g), B({
779
+ const p = new Error("Failed to load image into any artboard");
780
+ ue("error"), be(p), h == null || h(z, p), B({
647
781
  category: "image",
648
- message: g.message,
649
- originalError: g,
782
+ message: p.message,
783
+ originalError: p,
650
784
  recoverable: !0
651
785
  });
652
786
  }
653
787
  } catch (d) {
654
- const h = d instanceof Error ? d : new Error(String(d));
655
- le("error"), ge(h), m == null || m(z, h), B({
788
+ const g = d instanceof Error ? d : new Error(String(d));
789
+ ue("error"), be(g), h == null || h(z, g), B({
656
790
  category: "image",
657
- message: h.message,
658
- originalError: h,
791
+ message: g.message,
792
+ originalError: g,
659
793
  recoverable: !0
660
794
  });
661
795
  }
662
796
  })();
663
- }, [z, Re, Ie, ke]), R(() => {
664
- P == null || P(Be);
665
- }, [Be, P]), R(() => {
797
+ }, [z, Re, Ie, Ce]), I(() => {
798
+ M == null || M(Fe);
799
+ }, [Fe, M]), I(() => {
666
800
  if (!A) return;
667
- const s = k.getActiveArtboard(), d = {
668
- elements: V.map((h) => h.toJSON()),
669
- artboards: L.map((h) => ({
670
- name: h.name,
671
- width: h.width,
672
- height: h.height,
673
- clipShape: h.clipShape,
674
- backgroundColor: h.backgroundColor
801
+ const s = C.getActiveArtboard(), d = {
802
+ elements: V.map((g) => g.toJSON()),
803
+ artboards: H.map((g) => ({
804
+ name: g.name,
805
+ width: g.width,
806
+ height: g.height,
807
+ clipShape: g.clipShape,
808
+ backgroundColor: g.backgroundColor
675
809
  })),
676
810
  activeArtboard: (s == null ? void 0 : s.name) || "Design"
677
811
  };
678
812
  A(d);
679
- }, [V, L, A]), R(() => {
680
- if (!l || !ve.current) return;
681
- const s = k.getActiveArtboard();
813
+ }, [V, H, A]), I(() => {
814
+ if (!l || !ye.current) return;
815
+ const s = C.getActiveArtboard();
682
816
  s && l(s.name);
683
- }, [k.getActiveArtboardId()]);
684
- const ct = N(async () => {
685
- if (!E && !w) return;
686
- const s = ++it.current, d = Date.now();
687
- let h = X;
817
+ }, [C.getActiveArtboardId()]);
818
+ const pt = W(async () => {
819
+ if (!S && !E) return;
820
+ const s = ++gt.current, d = Date.now();
821
+ let g = X;
688
822
  if (U > 0 && isFinite(U))
689
- for (const u of L) {
690
- const x = Ee(u.width, u.height, X, U);
691
- h = Math.min(h, x);
823
+ for (const u of H) {
824
+ const y = Ae(u.width, u.height, X, U);
825
+ g = Math.min(g, y);
692
826
  }
693
- const g = k.getActiveArtboard(), f = (g == null ? void 0 : g.id) ?? "unknown";
694
- w == null || w({ status: "rendering", artboardId: f }), st.current = d;
827
+ const p = C.getActiveArtboard(), f = (p == null ? void 0 : p.id) ?? "unknown";
828
+ E == null || E({ status: "rendering", artboardId: f }), ht.current = d;
695
829
  try {
696
830
  let u;
697
- const x = {
698
- format: te,
699
- scale: h,
700
- quality: re
831
+ const y = {
832
+ format: ae,
833
+ scale: g,
834
+ quality: oe
701
835
  };
702
- if (j === "blob")
703
- if (fe) {
704
- const b = await ce(x);
836
+ if (G === "blob")
837
+ if (ge) {
838
+ const b = await de(y);
705
839
  u = {};
706
- for (const [F, Y] of Object.entries(b)) {
707
- const O = L.find((Z) => Z.id === F);
708
- O && (u[O.name] = Y);
840
+ for (const [P, $] of Object.entries(b)) {
841
+ const Y = H.find((ee) => ee.id === P);
842
+ Y && (u[Y.name] = $);
709
843
  }
710
844
  } else {
711
- const b = k.getActiveArtboard();
845
+ const b = C.getActiveArtboard();
712
846
  if (!b) return;
713
- const F = await Q(b.id, x);
714
- u = { [b.name]: F };
847
+ const P = await Q(b.id, y);
848
+ u = { [b.name]: P };
715
849
  }
716
- else if (fe) {
717
- const b = await ie(x);
850
+ else if (ge) {
851
+ const b = await le(y);
718
852
  u = {};
719
- for (const [F, Y] of Object.entries(b)) {
720
- const O = L.find((Z) => Z.id === F);
721
- O && (u[O.name] = Y);
853
+ for (const [P, $] of Object.entries(b)) {
854
+ const Y = H.find((ee) => ee.id === P);
855
+ Y && (u[Y.name] = $);
722
856
  }
723
857
  } else {
724
- const b = k.getActiveArtboard();
858
+ const b = C.getActiveArtboard();
725
859
  if (!b) return;
726
- const F = await G(b.id, x);
727
- u = { [b.name]: F };
860
+ const P = await Z(b.id, y);
861
+ u = { [b.name]: P };
728
862
  }
729
- E == null || E(u), w == null || w({ status: "complete", artboardId: f, result: u });
863
+ S == null || S(u), E == null || E({ status: "complete", artboardId: f, result: u });
730
864
  } catch (u) {
731
- const x = u instanceof Error ? u.message : String(u);
732
- if (x.includes("Canvas ref not available"))
865
+ const y = u instanceof Error ? u.message : String(u);
866
+ if (y.includes("Canvas ref not available"))
733
867
  return;
734
868
  const b = Date.now() - d;
735
869
  K.error("Export failed (export #" + s + "):", {
736
870
  duration: `${b}ms`,
737
- error: x
871
+ error: y
738
872
  });
739
- const F = u instanceof Error ? u : new Error(x);
740
- w == null || w({ status: "error", artboardId: f, error: F }), B({
873
+ const P = u instanceof Error ? u : new Error(y);
874
+ E == null || E({ status: "error", artboardId: f, error: P }), B({
741
875
  category: "export",
742
- message: F.message,
743
- originalError: F,
876
+ message: P.message,
877
+ originalError: P,
744
878
  artboardId: f,
745
879
  recoverable: !0
746
880
  });
747
881
  }
748
- }, [E, w, fe, j, X, U, te, re, G, ie, Q, ce, L, k, V, J, B]);
749
- R(() => {
750
- Se !== void 0 && Se > 0 && K.warn(
882
+ }, [S, E, ge, G, X, U, ae, oe, Z, le, Q, de, H, C, V, J, B]);
883
+ I(() => {
884
+ ke !== void 0 && ke > 0 && K.warn(
751
885
  "autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
752
886
  );
753
- }, []), R(() => {
887
+ }, []), I(() => {
754
888
  }, [V]);
755
- const lt = N(() => {
756
- if (M == null || M(), w) {
757
- const s = k.getActiveArtboard();
758
- w({ status: "scheduled", artboardId: (s == null ? void 0 : s.id) ?? "unknown" });
889
+ const bt = W(() => {
890
+ if (T == null || T(), E) {
891
+ const s = C.getActiveArtboard();
892
+ E({ status: "scheduled", artboardId: (s == null ? void 0 : s.id) ?? "unknown" });
759
893
  }
760
- }, [M, w, k]), dt = !!p && p.length > 0, xe = Wt({
761
- isCanvasReady: he,
894
+ }, [T, E, C]), vt = !!m && m.length > 0, we = sr({
895
+ isCanvasReady: pe,
762
896
  elements: V,
763
- hasInitialElements: dt,
764
- initialElementsLoaded: at
765
- }), $e = T(!1);
766
- R(() => {
767
- xe && !$e.current && ($e.current = !0, v == null || v());
768
- }, [xe, v]), Ft({
897
+ hasInitialElements: vt,
898
+ initialElementsLoaded: ft
899
+ }), Le = D(!1);
900
+ I(() => {
901
+ we && !Le.current && (Le.current = !0, x == null || x());
902
+ }, [we, x]), rr({
769
903
  config: J ? {
770
904
  enabled: J.enabled ?? !0,
771
905
  debounceMs: J.debounceMs ?? 100,
@@ -774,24 +908,24 @@ const Je = je((t, e) => {
774
908
  enabled: !1
775
909
  // Only use smart export if autoExportConfig is provided
776
910
  },
777
- historyManager: tt,
778
- artboards: L,
911
+ historyManager: lt,
912
+ artboards: H,
779
913
  elements: V,
780
- onExport: ct,
781
- onExportScheduled: lt,
782
- isCanvasReady: xe
914
+ onExport: pt,
915
+ onExportScheduled: bt,
916
+ isCanvasReady: we
783
917
  // Gate exports until content is fully ready (fonts loaded, elements deserialized)
784
- }), R(() => {
785
- if (L.length > 0 && !he) {
918
+ }), I(() => {
919
+ if (H.length > 0 && !pe) {
786
920
  const s = requestAnimationFrame(() => {
787
- se(!0);
921
+ ce(!0);
788
922
  });
789
923
  return () => cancelAnimationFrame(s);
790
924
  }
791
- }, [L.length, he, se]), R(() => () => {
792
- se(!1);
793
- }, [se]);
794
- const ut = N((s) => {
925
+ }, [H.length, pe, ce]), I(() => () => {
926
+ ce(!1);
927
+ }, [ce]);
928
+ const xt = W((s) => {
795
929
  B({
796
930
  category: "unknown",
797
931
  message: s.message,
@@ -799,25 +933,25 @@ const Je = je((t, e) => {
799
933
  recoverable: !1
800
934
  });
801
935
  }, [B]);
802
- return Ue === "loading" ? /* @__PURE__ */ C(
936
+ return Pe === "loading" ? /* @__PURE__ */ v(
803
937
  "div",
804
938
  {
805
- className: W,
939
+ className: L,
806
940
  style: {
807
- ...D,
941
+ ...F,
808
942
  display: "flex",
809
943
  alignItems: "center",
810
944
  justifyContent: "center",
811
945
  backgroundColor: "var(--surface, #f5f5f5)"
812
946
  },
813
- children: /* @__PURE__ */ C(vt, { size: 48 })
947
+ children: /* @__PURE__ */ v(Wt, { size: 48 })
814
948
  }
815
- ) : Ue === "error" && ze ? /* @__PURE__ */ C(
949
+ ) : Pe === "error" && Ne ? /* @__PURE__ */ v(
816
950
  "div",
817
951
  {
818
- className: W,
952
+ className: L,
819
953
  style: {
820
- ...D,
954
+ ...F,
821
955
  display: "flex",
822
956
  alignItems: "center",
823
957
  justifyContent: "center",
@@ -825,16 +959,16 @@ const Je = je((t, e) => {
825
959
  color: "var(--danger, #dc2626)",
826
960
  padding: "1rem"
827
961
  },
828
- children: /* @__PURE__ */ de("div", { className: "text-center", children: [
829
- /* @__PURE__ */ C("div", { className: "font-medium", children: "Failed to load image" }),
830
- /* @__PURE__ */ C("div", { className: "text-sm mt-1 opacity-70", children: ze.message })
962
+ children: /* @__PURE__ */ j("div", { className: "text-center", children: [
963
+ /* @__PURE__ */ v("div", { className: "font-medium", children: "Failed to load image" }),
964
+ /* @__PURE__ */ v("div", { className: "text-sm mt-1 opacity-70", children: Ne.message })
831
965
  ] })
832
966
  }
833
- ) : /* @__PURE__ */ C(xt, { kit: ne, children: /* @__PURE__ */ C("div", { className: `app-modern ${W || ""}`, style: { ...D, position: "relative" }, children: /* @__PURE__ */ de(
834
- Tt,
967
+ ) : /* @__PURE__ */ v(Bt, { kit: _, children: /* @__PURE__ */ v("div", { className: `app-modern ${L || ""}`, style: { ...F, position: "relative" }, children: /* @__PURE__ */ j(
968
+ er,
835
969
  {
836
- onError: ut,
837
- fallback: (s, d) => /* @__PURE__ */ de(
970
+ onError: xt,
971
+ fallback: (s, d) => /* @__PURE__ */ j(
838
972
  "div",
839
973
  {
840
974
  style: {
@@ -850,9 +984,9 @@ const Je = je((t, e) => {
850
984
  textAlign: "center"
851
985
  },
852
986
  children: [
853
- /* @__PURE__ */ C("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
854
- /* @__PURE__ */ C("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: s.message }),
855
- /* @__PURE__ */ C(
987
+ /* @__PURE__ */ v("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
988
+ /* @__PURE__ */ v("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: s.message }),
989
+ /* @__PURE__ */ v(
856
990
  "button",
857
991
  {
858
992
  onClick: d,
@@ -873,100 +1007,48 @@ const Je = je((t, e) => {
873
1007
  }
874
1008
  ),
875
1009
  children: [
876
- !_e && (Pe || He ? /* @__PURE__ */ C("div", { className: Pe, style: He, children: /* @__PURE__ */ C(
877
- Oe,
878
- {
879
- style: { width: "100%" },
880
- fitPadding: Ce,
881
- artboardBorderRadius: Me,
882
- fixedMargin: Te,
883
- maxHeight: De,
884
- showRotationHandle: Fe,
885
- enableShortcuts: Ne,
886
- canvasCutouts: Le,
887
- pieceGuides: me,
888
- pieceFocus: We
889
- }
890
- ) }) : /* @__PURE__ */ C(
891
- Oe,
892
- {
893
- style: { width: "100%" },
894
- fitPadding: Ce,
895
- artboardBorderRadius: Me,
896
- fixedMargin: Te,
897
- maxHeight: De,
898
- showRotationHandle: Fe,
899
- enableShortcuts: Ne,
900
- canvasCutouts: Le,
901
- pieceGuides: me,
902
- pieceFocus: We
903
- }
904
- )),
905
- ee
1010
+ !at && /* @__PURE__ */ (() => {
1011
+ const s = /* @__PURE__ */ v(
1012
+ Ut,
1013
+ {
1014
+ style: { width: "100%" },
1015
+ fitPadding: _e,
1016
+ artboardBorderRadius: et,
1017
+ fixedMargin: tt,
1018
+ maxHeight: rt,
1019
+ showRotationHandle: nt,
1020
+ enableShortcuts: it,
1021
+ canvasCutouts: ot,
1022
+ pieceGuides: De,
1023
+ pieceFocus: st
1024
+ }
1025
+ );
1026
+ return /* @__PURE__ */ v(Jt, { kit: _, canvas: Me || Te ? /* @__PURE__ */ v("div", { className: Me, style: Te, children: s }) : s });
1027
+ })(),
1028
+ ne
906
1029
  ]
907
1030
  }
908
1031
  ) }) });
909
1032
  });
910
- Je.displayName = "SnowconeCanvasInner";
911
- const Kt = je((t, e) => {
1033
+ Qe.displayName = "SnowconeCanvasInner";
1034
+ const pr = je((t, e) => {
912
1035
  var o;
913
- const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */ C(Je, { ref: e, ...t });
914
- return a ? /* @__PURE__ */ C(Xe, { defaultTheme: "light", passive: r, children: c }) : /* @__PURE__ */ C(Xe, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ C(It, { viewPadding: n, children: c }) });
1036
+ const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */ v(Qe, { ref: e, ...t });
1037
+ return a ? /* @__PURE__ */ v($e, { defaultTheme: "light", passive: r, children: c }) : /* @__PURE__ */ v($e, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ v(Vt, { viewPadding: n, children: c }) });
915
1038
  });
916
- Kt.displayName = "SnowconeCanvas";
917
- const Ve = _("useCommands");
918
- function ir() {
919
- const t = ue(), {
920
- undo: e,
921
- redo: r,
922
- canUndo: a,
923
- canRedo: n,
924
- executeElementUpdate: c,
925
- executeAddElement: o,
926
- executeRemoveElement: i,
927
- executeReorderElement: l,
928
- executeCommandBatch: p,
929
- executeCreateArtboard: A,
930
- executeDeleteArtboard: P,
931
- executeUpdateArtboard: I
932
- } = t, E = N(() => {
933
- Ve.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
934
- }, []), M = N((w) => {
935
- Ve.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
936
- }, []);
937
- return {
938
- // Undo/Redo
939
- undo: e,
940
- redo: r,
941
- canUndo: a,
942
- canRedo: n,
943
- // History management
944
- clearHistory: E,
945
- clearArtboardHistory: M,
946
- // Command execution
947
- executeElementUpdate: c,
948
- executeAddElement: o,
949
- executeRemoveElement: i,
950
- executeReorderElement: l,
951
- executeCreateArtboard: A,
952
- executeDeleteArtboard: P,
953
- executeUpdateArtboard: I,
954
- // Batch execution
955
- executeCommandBatch: p
956
- };
957
- }
958
- function cr() {
959
- const { selectedElement: t } = ue();
1039
+ pr.displayName = "SnowconeCanvas";
1040
+ function Dr() {
1041
+ const { selectedElement: t } = he();
960
1042
  return t ?? null;
961
1043
  }
962
- function lr() {
963
- const { isCanvasReady: t } = ue();
1044
+ function Fr() {
1045
+ const { isCanvasReady: t } = he();
964
1046
  return t;
965
1047
  }
966
- const jt = () => {
967
- }, Gt = [];
968
- function dr(t) {
969
- const { elementStore: e } = Ae(), { executeElementUpdate: r } = Ge(), a = ye(() => e.getAllByName(t).filter((o) => o instanceof At), [e, t]), n = N(
1048
+ const br = () => {
1049
+ }, vr = [];
1050
+ function Pr(t) {
1051
+ const { elementStore: e } = Se(), { executeElementUpdate: r } = Ge(), a = me(() => e.getAllByName(t).filter((o) => o instanceof Ot), [e, t]), n = W(
970
1052
  (c) => {
971
1053
  for (const o of a) {
972
1054
  const i = o.clone();
@@ -975,7 +1057,7 @@ function dr(t) {
975
1057
  },
976
1058
  [a, r]
977
1059
  );
978
- return a.length === 0 ? { text: "", setText: jt, element: null, elements: Gt, isConnected: !1 } : {
1060
+ return a.length === 0 ? { text: "", setText: br, element: null, elements: vr, isConnected: !1 } : {
979
1061
  text: a[0].getText(),
980
1062
  setText: n,
981
1063
  element: a[0],
@@ -983,9 +1065,9 @@ function dr(t) {
983
1065
  isConnected: !0
984
1066
  };
985
1067
  }
986
- const Qt = () => {
987
- }, Jt = [];
988
- function Zt(t, e, r) {
1068
+ const xr = () => {
1069
+ }, yr = [];
1070
+ function wr(t, e, r) {
989
1071
  const a = t / e;
990
1072
  if (r >= a) {
991
1073
  const n = e, c = n * r, o = t / c;
@@ -1009,64 +1091,63 @@ function Zt(t, e, r) {
1009
1091
  };
1010
1092
  }
1011
1093
  }
1012
- function ur(t, e) {
1013
- const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } = Ae(), { executeElementUpdate: c } = Ge(), o = ye(() => a.getAllByName(t).filter((E) => E instanceof Ke), [a, t]), i = T(/* @__PURE__ */ new Map());
1014
- for (const I of o)
1015
- if (!i.current.has(I.id)) {
1016
- const E = I.transformData;
1017
- i.current.set(I.id, {
1018
- width: E.width * E.cropWidth,
1019
- height: E.height * E.cropHeight
1094
+ function Nr(t, e) {
1095
+ const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } = Se(), { executeElementUpdate: c } = Ge(), o = me(() => a.getAllByName(t).filter((S) => S instanceof Ve), [a, t]), i = D(/* @__PURE__ */ new Map());
1096
+ for (const w of o)
1097
+ if (!i.current.has(w.id)) {
1098
+ const S = w.transformData;
1099
+ i.current.set(w.id, {
1100
+ width: S.width * S.cropWidth,
1101
+ height: S.height * S.cropHeight
1020
1102
  });
1021
1103
  }
1022
- const l = T(o);
1104
+ const l = D(o);
1023
1105
  l.current = o;
1024
- const p = T(c);
1025
- p.current = c;
1026
- const A = T(n);
1106
+ const m = D(c);
1107
+ m.current = c;
1108
+ const A = D(n);
1027
1109
  A.current = n;
1028
- const P = N(
1029
- (I) => {
1030
- const E = l.current, M = p.current;
1031
- A.current;
1032
- for (const w of E) {
1033
- const H = i.current.get(w.id);
1034
- if (!H) continue;
1035
- const { width: y, height: m } = H, S = w.clone();
1036
- S.imageLoaded = !1, S.imageElement = null, S.isCropping = !1, S.imageUrl = I, r === "cover" ? (S.preserveDimensions = !0, S.onLoadCallback = (v) => {
1037
- const W = v.imageAspectRatio || 1, D = Zt(y, m, W);
1038
- v.transformData.width = D.width, v.transformData.height = D.height, v.transformData.cropX = D.cropX, v.transformData.cropY = D.cropY, v.transformData.cropWidth = D.cropWidth, v.transformData.cropHeight = D.cropHeight, M(w, v);
1039
- }) : (S.preserveDimensions = !1, S.onLoadCallback = (v) => {
1040
- const W = v.transformData.width, D = v.transformData.height, $ = Math.min(y / W, m / D, 1);
1041
- $ < 1 && (v.transformData.width = W * $, v.transformData.height = D * $), v.transformData.cropX = 0, v.transformData.cropY = 0, v.transformData.cropWidth = 1, v.transformData.cropHeight = 1, M(w, v);
1042
- }), S.loadImage(I);
1110
+ const M = W(
1111
+ (w) => {
1112
+ const S = l.current, T = m.current;
1113
+ for (const E of S) {
1114
+ const N = i.current.get(E.id);
1115
+ if (!N) continue;
1116
+ const { width: k, height: h } = N, R = E.clone();
1117
+ R.imageLoaded = !1, R.imageElement = null, R.isCropping = !1, R.imageUrl = w, r === "cover" ? (R.preserveDimensions = !0, R.onLoadCallback = (x) => {
1118
+ const L = x.imageAspectRatio || 1, F = wr(k, h, L);
1119
+ x.transformData.width = F.width, x.transformData.height = F.height, x.transformData.cropX = F.cropX, x.transformData.cropY = F.cropY, x.transformData.cropWidth = F.cropWidth, x.transformData.cropHeight = F.cropHeight, T(E, x);
1120
+ }) : (R.preserveDimensions = !1, R.onLoadCallback = (x) => {
1121
+ const L = x.transformData.width, F = x.transformData.height, O = Math.min(k / L, h / F, 1);
1122
+ O < 1 && (x.transformData.width = L * O, x.transformData.height = F * O), x.transformData.cropX = 0, x.transformData.cropY = 0, x.transformData.cropWidth = 1, x.transformData.cropHeight = 1, T(E, x);
1123
+ }), R.loadImage(w);
1043
1124
  }
1044
1125
  },
1045
1126
  [r]
1046
1127
  // Stable deps only — imageElements/executeElementUpdate/setElements accessed via refs
1047
1128
  );
1048
- return o.length === 0 ? { imageUrl: "", setImageUrl: Qt, element: null, elements: Jt, isConnected: !1 } : {
1129
+ return o.length === 0 ? { imageUrl: "", setImageUrl: xr, element: null, elements: yr, isConnected: !1 } : {
1049
1130
  imageUrl: o[0].imageUrl,
1050
- setImageUrl: P,
1131
+ setImageUrl: M,
1051
1132
  element: o[0],
1052
1133
  elements: o,
1053
1134
  isConnected: !0
1054
1135
  };
1055
1136
  }
1056
- function fr(t) {
1057
- const { elementStore: e } = Ae();
1137
+ function Hr(t) {
1138
+ const { elementStore: e } = Se();
1058
1139
  return t ? e.getByName(t) ?? null : null;
1059
1140
  }
1060
- function mr() {
1061
- const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } = kt();
1141
+ function Lr() {
1142
+ const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } = Kt();
1062
1143
  return { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i };
1063
1144
  }
1064
- const qt = 1;
1065
- function hr(t) {
1145
+ const Er = 1;
1146
+ function Wr(t) {
1066
1147
  var a;
1067
- const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(_t);
1148
+ const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(Ar);
1068
1149
  return {
1069
- schemaVersion: qt,
1150
+ schemaVersion: Er,
1070
1151
  artboards: [{
1071
1152
  id: "artboard-1",
1072
1153
  name: e.name || "Front",
@@ -1082,15 +1163,15 @@ function hr(t) {
1082
1163
  }]
1083
1164
  };
1084
1165
  }
1085
- function _t(t) {
1166
+ function Ar(t) {
1086
1167
  const e = t.type || t.transformType;
1087
- return e === "image" ? er(t) : {
1168
+ return e === "image" ? Sr(t) : {
1088
1169
  ...t,
1089
1170
  type: e
1090
1171
  };
1091
1172
  }
1092
- function er(t) {
1093
- var p;
1173
+ function Sr(t) {
1174
+ var m;
1094
1175
  const e = t.transformData || {}, r = t.masks && t.masks.length > 0, a = e.width || 0, n = e.height || 0, c = r ? a : a * (e.cropWidth ?? 1), o = r ? n : n * (e.cropHeight ?? 1), i = {
1095
1176
  id: t.id,
1096
1177
  type: "image",
@@ -1102,40 +1183,40 @@ function er(t) {
1102
1183
  imageUrl: t.imageUrl,
1103
1184
  imageAspectRatio: t.imageAspectRatio
1104
1185
  };
1105
- return !r && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (i.cropX = e.cropX, i.cropY = e.cropY, i.cropWidth = e.cropWidth, i.cropHeight = e.cropHeight, i.needsCropPixelConversion = !0), e.flipHorizontal && (i.flipHorizontal = e.flipHorizontal), e.flipVertical && (i.flipVertical = e.flipVertical), e.borderRadius && (i.borderRadius = e.borderRadius), t.opacity !== void 0 && (i.opacity = t.opacity), t.distressEffect && (i.distressEffect = t.distressEffect), ((p = t.masks) == null ? void 0 : p.length) > 0 && (i.masks = t.masks), t.blendMode && (i.blendMode = t.blendMode), t.knockoutParts && (i.knockoutParts = t.knockoutParts), t.stroke && (i.stroke = t.stroke), i;
1186
+ return !r && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (i.cropX = e.cropX, i.cropY = e.cropY, i.cropWidth = e.cropWidth, i.cropHeight = e.cropHeight, i.needsCropPixelConversion = !0), e.flipHorizontal && (i.flipHorizontal = e.flipHorizontal), e.flipVertical && (i.flipVertical = e.flipVertical), e.borderRadius && (i.borderRadius = e.borderRadius), t.opacity !== void 0 && (i.opacity = t.opacity), t.distressEffect && (i.distressEffect = t.distressEffect), ((m = t.masks) == null ? void 0 : m.length) > 0 && (i.masks = t.masks), t.blendMode && (i.blendMode = t.blendMode), t.knockoutParts && (i.knockoutParts = t.knockoutParts), t.stroke && (i.stroke = t.stroke), i;
1106
1187
  }
1107
- wt();
1188
+ zt();
1108
1189
  export {
1109
- br as ALL_CAPABILITIES,
1110
- qt as CANVAS_STATE_SCHEMA_VERSION,
1111
- vr as COMPACT_CUSTOMIZER,
1112
- xr as EMBED_ONLY,
1113
- Tt as ErrorBoundary,
1114
- wr as MINIMAL_CAPABILITIES,
1115
- Er as PRO_STUDIO,
1116
- Kt as SnowconeCanvas,
1117
- yr as createKit,
1118
- Kt as default,
1119
- Ir as deserializeState,
1120
- Ar as extendKit,
1121
- kr as migrateState,
1122
- ht as resolveKit,
1123
- Cr as serializeState,
1124
- hr as serializeStateForServer,
1125
- pt as useArtboards,
1126
- Ft as useAutoExport,
1127
- lr as useCanvasReady,
1128
- ir as useCommands,
1129
- Wt as useContentReady,
1130
- ue as useEditor,
1131
- fr as useElementByName,
1132
- bt as useExport,
1133
- ur as useImageBinding,
1134
- Sr as useLayers,
1135
- cr as useSelectedElement,
1136
- dr as useTextBinding,
1137
- mr as useViewport,
1138
- gt as validateKit,
1139
- Mr as validateState
1190
+ zr as ALL_CAPABILITIES,
1191
+ Er as CANVAS_STATE_SCHEMA_VERSION,
1192
+ $r as COMPACT_CUSTOMIZER,
1193
+ Or as EMBED_ONLY,
1194
+ er as ErrorBoundary,
1195
+ Yr as MINIMAL_CAPABILITIES,
1196
+ Xr as PRO_STUDIO,
1197
+ pr as SnowconeCanvas,
1198
+ Vr as createKit,
1199
+ pr as default,
1200
+ Zr as deserializeState,
1201
+ Kr as extendKit,
1202
+ Qr as migrateState,
1203
+ Pt as resolveKit,
1204
+ qr as serializeState,
1205
+ Wr as serializeStateForServer,
1206
+ Ht as useArtboards,
1207
+ rr as useAutoExport,
1208
+ Fr as useCanvasReady,
1209
+ Gt as useCommands,
1210
+ sr as useContentReady,
1211
+ he as useEditor,
1212
+ Hr as useElementByName,
1213
+ Lt as useExport,
1214
+ Nr as useImageBinding,
1215
+ jr as useLayers,
1216
+ Dr as useSelectedElement,
1217
+ Pr as useTextBinding,
1218
+ Lr as useViewport,
1219
+ Nt as validateKit,
1220
+ Jr as validateState
1140
1221
  };
1141
1222
  //# sourceMappingURL=index.mjs.map