@snowcone-app/canvas 0.1.10 → 0.1.13

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