@snowcone-app/canvas 0.44.1 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{ContextualToolbars-rCZo-KCm.js → ContextualToolbars-5tHC6s0Y.js} +4 -4
  2. package/dist/{ContextualToolbars-rCZo-KCm.js.map → ContextualToolbars-5tHC6s0Y.js.map} +1 -1
  3. package/dist/{EditorCanvasImpl-VkjeyOGd.js → EditorCanvasImpl-B4VBKRBA.js} +6 -6
  4. package/dist/{EditorCanvasImpl-VkjeyOGd.js.map → EditorCanvasImpl-B4VBKRBA.js.map} +1 -1
  5. package/dist/{ImagePanel-DhOWKvIN.js → ImagePanel-bW3yr6Ac.js} +264 -259
  6. package/dist/{ImagePanel-DhOWKvIN.js.map → ImagePanel-bW3yr6Ac.js.map} +1 -1
  7. package/dist/{SnowconeCanvas-COXpmwkS.js → SnowconeCanvas-crxPwbib.js} +441 -439
  8. package/dist/SnowconeCanvas-crxPwbib.js.map +1 -0
  9. package/dist/advanced.mjs +9 -9
  10. package/dist/components/embed/SnowconeCanvas.d.ts +6 -0
  11. package/dist/components/embed/kernel.d.ts +2 -0
  12. package/dist/{custom-icons-C4bzABm2.js → custom-icons-DQRp8GhF.js} +2 -2
  13. package/dist/{custom-icons-C4bzABm2.js.map → custom-icons-DQRp8GhF.js.map} +1 -1
  14. package/dist/{design-builder-DCHVrEFV.js → design-builder-sH53Og6j.js} +598 -589
  15. package/dist/design-builder-sH53Og6j.js.map +1 -0
  16. package/dist/{embed-CamnTsuT.js → embed-CYWbpvu_.js} +6 -6
  17. package/dist/{embed-CamnTsuT.js.map → embed-CYWbpvu_.js.map} +1 -1
  18. package/dist/embed.mjs +4 -4
  19. package/dist/index.mjs +7 -7
  20. package/dist/{template-fields-CK7Uvvc8.js → template-fields-BaQG0CJY.js} +3 -3
  21. package/dist/{template-fields-CK7Uvvc8.js.map → template-fields-BaQG0CJY.js.map} +1 -1
  22. package/dist/testing.mjs +2 -2
  23. package/dist/{useCommands-BrkGKdXr.js → useCommands-F-b_SwW-.js} +3 -3
  24. package/dist/{useCommands-BrkGKdXr.js.map → useCommands-F-b_SwW-.js.map} +1 -1
  25. package/dist/{validation-jgr2OtXC.js → validation-hn5ZX8Po.js} +9 -8
  26. package/dist/{validation-jgr2OtXC.js.map → validation-hn5ZX8Po.js.map} +1 -1
  27. package/example/package.json +1 -1
  28. package/package.json +3 -3
  29. package/dist/SnowconeCanvas-COXpmwkS.js.map +0 -1
  30. package/dist/design-builder-DCHVrEFV.js.map +0 -1
@@ -1,14 +1,14 @@
1
1
  import { jsx as V } from "react/jsx-runtime";
2
- import { useContext as G, useSyncExternalStore as Se, useCallback as h, createContext as Q, useRef as gt, useState as E, useEffect as $t, useMemo as q } from "react";
3
- import { H as Re, t as ot, U as Ie, B as Te, G as qt, R as Ce, D as Fe, J as ve, K as Pe, M as Ne, c as Qt, z as Oe, N as ze, O as Ue, I as Vt, Q as He, e as ke, E as Yt, q as De, S as Le, V as Xt, X as Ve, Y as Gt, Z as _e, _ as $e, $ as Be, a0 as Me, a1 as We, i as Ye } from "./FontAnalyzer-Ds3Wdba7.js";
4
- import { g as te, a as ee } from "./placement-tSiIVhrL.js";
5
- const oe = Q(null), Xe = () => () => {
6
- }, Kt = () => 0;
7
- function Uo() {
8
- const e = G(oe), t = Se(
9
- e ? e.subscribe : Xe,
10
- e ? e.getVersion : Kt,
11
- e ? e.getVersion : Kt
2
+ import { useContext as G, useSyncExternalStore as Re, useCallback as h, createContext as q, useRef as At, useState as S, useEffect as Bt, useMemo as J } from "react";
3
+ import { H as Ie, t as et, U as Te, B as Ce, G as Qt, R as Fe, D as ve, J as Pe, K as Ne, M as Oe, c as te, z as ze, N as Ue, O as He, I as _t, Q as ke, e as De, E as Xt, q as Le, S as Ve, V as Gt, X as _e, Y as Kt, Z as $e, _ as Be, $ as Me, a0 as We, a1 as Ye, i as Xe } from "./FontAnalyzer-Ds3Wdba7.js";
4
+ import { g as ee, a as oe } from "./placement-tSiIVhrL.js";
5
+ const ne = q(null), Ge = () => () => {
6
+ }, Zt = () => 0;
7
+ function Ho() {
8
+ const e = G(ne), t = Re(
9
+ e ? e.subscribe : Ge,
10
+ e ? e.getVersion : Zt,
11
+ e ? e.getVersion : Zt
12
12
  );
13
13
  return h(
14
14
  (o) => !!(e && o && e.getBoundLayer(o)),
@@ -17,152 +17,152 @@ function Uo() {
17
17
  [e, t]
18
18
  );
19
19
  }
20
- const wt = Qt("useCommandHistory");
21
- function Ge(e, t, o, n) {
22
- const i = gt(new Re(o)), r = G(oe), a = h(
23
- (l, p) => {
24
- const w = l == null ? void 0 : l.name;
25
- if (!r || !w) return;
26
- const A = r.getBoundLayer(w);
20
+ const bt = te("useCommandHistory");
21
+ function Ke(e, t, o, n) {
22
+ const i = At(new Ie(o)), r = G(ne), a = h(
23
+ (u, g) => {
24
+ const b = u == null ? void 0 : u.name;
25
+ if (!r || !b) return;
26
+ const A = r.getBoundLayer(b);
27
27
  if (A)
28
- throw new ot(
28
+ throw new et(
29
29
  "E_BOUND_LAYER_MUTATION",
30
- `cannot ${p} layer "${w}" — a mounted <${A.part} layer={design.layer("${w}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
31
- { layer: w, part: A.part, operation: p, docSlug: "embed-mode" }
30
+ `cannot ${g} layer "${b}" — a mounted <${A.part} layer={design.layer("${b}")}> is bound to it. Unmount that field first, or keep the layer and set its text through the field / its binding instead.`,
31
+ { layer: b, part: A.part, operation: g, docSlug: "embed-mode" }
32
32
  );
33
33
  },
34
34
  [r]
35
- ), [s, c] = E({
35
+ ), [s, c] = S({
36
36
  canUndo: !1,
37
37
  canRedo: !1,
38
38
  // Per-artboard state for the active artboard
39
39
  canUndoActiveArtboard: !1,
40
40
  canRedoActiveArtboard: !1
41
41
  }), d = h(() => {
42
- const l = i.current, p = o.getActiveArtboardId();
42
+ const u = i.current, g = o.getActiveArtboardId();
43
43
  c({
44
- canUndo: l.canUndo(),
45
- canRedo: l.canRedo(),
44
+ canUndo: u.canUndo(),
45
+ canRedo: u.canRedo(),
46
46
  // Per-artboard state - only check active artboard's history
47
- canUndoActiveArtboard: p ? l.canUndoArtboard(p) : !1,
48
- canRedoActiveArtboard: p ? l.canRedoArtboard(p) : !1
47
+ canUndoActiveArtboard: g ? u.canUndoArtboard(g) : !1,
48
+ canRedoActiveArtboard: g ? u.canRedoArtboard(g) : !1
49
49
  });
50
- }, [o]), S = h(
51
- (l, p) => {
52
- l && l.name !== p.name && a(l, "rename");
53
- const w = new Ie(
54
- p.id,
55
- l || null,
56
- p,
57
- (C) => {
58
- t((Y) => Y.map((z) => z.id === C.id ? C : z));
50
+ }, [o]), R = h(
51
+ (u, g) => {
52
+ u && u.name !== g.name && a(u, "rename");
53
+ const b = new Te(
54
+ g.id,
55
+ u || null,
56
+ g,
57
+ (F) => {
58
+ t((Y) => Y.map((z) => z.id === F.id ? F : z));
59
59
  }
60
- ), A = o.getArtboardIdForElement(p.id);
60
+ ), A = o.getArtboardIdForElement(g.id);
61
61
  if (A)
62
- i.current.executeOnArtboard(A, w);
62
+ i.current.executeOnArtboard(A, b);
63
63
  else {
64
- const C = o.getActiveArtboardId();
65
- C && i.current.executeOnArtboard(C, w);
64
+ const F = o.getActiveArtboardId();
65
+ F && i.current.executeOnArtboard(F, b);
66
66
  }
67
67
  d();
68
68
  },
69
69
  [t, o, d, a]
70
70
  ), N = h(
71
- (l, p, w, A) => {
72
- const C = p || o.getActiveArtboardId();
73
- if (!C) {
74
- wt.warn("No active artboard to add element to");
71
+ (u, g, b, A) => {
72
+ const F = g || o.getActiveArtboardId();
73
+ if (!F) {
74
+ bt.warn("No active artboard to add element to");
75
75
  return;
76
76
  }
77
- const Y = new Te(
78
- l,
77
+ const Y = new Ce(
78
+ u,
79
79
  (z) => {
80
- const $ = z;
80
+ const _ = z;
81
81
  t((U) => {
82
82
  if (A) {
83
83
  const L = U.findIndex((P) => P.id === A);
84
84
  if (L !== -1) {
85
85
  const P = [...U];
86
- return P.splice(L, 0, $), P;
86
+ return P.splice(L, 0, _), P;
87
87
  }
88
88
  }
89
- if (w) {
90
- const L = U.findIndex((P) => P.id === w);
89
+ if (b) {
90
+ const L = U.findIndex((P) => P.id === b);
91
91
  if (L !== -1) {
92
92
  const P = [...U];
93
- return P.splice(L + 1, 0, $), P;
93
+ return P.splice(L + 1, 0, _), P;
94
94
  }
95
95
  for (let P = 0; P < U.length; P++) {
96
96
  const K = U[P];
97
- if (K instanceof qt && K.children) {
98
- const rt = K.children.findIndex((Z) => Z.id === w);
99
- if (rt !== -1) {
97
+ if (K instanceof Qt && K.children) {
98
+ const nt = K.children.findIndex((Z) => Z.id === b);
99
+ if (nt !== -1) {
100
100
  const Z = K.clone();
101
- Z.children.splice(rt + 1, 0, $);
102
- const j = [...U];
103
- return j[P] = Z, j;
101
+ Z.children.splice(nt + 1, 0, _);
102
+ const $ = [...U];
103
+ return $[P] = Z, $;
104
104
  }
105
105
  }
106
106
  }
107
107
  }
108
- return [...U, $];
109
- }), o.addElementToArtboard(z.id, C);
108
+ return [...U, _];
109
+ }), o.addElementToArtboard(z.id, F);
110
110
  },
111
111
  (z) => {
112
- t(($) => $.filter((U) => U.id !== z)), o.removeElementFromArtboard(z);
112
+ t((_) => _.filter((U) => U.id !== z)), o.removeElementFromArtboard(z);
113
113
  }
114
114
  );
115
- i.current.executeOnArtboard(C, Y), d();
115
+ i.current.executeOnArtboard(F, Y), d();
116
116
  },
117
117
  [t, o, d]
118
118
  ), k = h(
119
- (l) => {
120
- a(l, "delete");
121
- const p = o.getArtboardIdForElement(l.id);
122
- if (!p) {
123
- wt.warn("Element not found in any artboard");
119
+ (u) => {
120
+ a(u, "delete");
121
+ const g = o.getArtboardIdForElement(u.id);
122
+ if (!g) {
123
+ bt.warn("Element not found in any artboard");
124
124
  return;
125
125
  }
126
- const w = new Ce(
127
- l,
126
+ const b = new Fe(
127
+ u,
128
128
  (A) => {
129
- t((C) => [...C, A]), o.addElementToArtboard(A.id, p);
129
+ t((F) => [...F, A]), o.addElementToArtboard(A.id, g);
130
130
  },
131
131
  (A) => {
132
- t((C) => C.filter((Y) => Y.id !== A)), o.removeElementFromArtboard(A);
132
+ t((F) => F.filter((Y) => Y.id !== A)), o.removeElementFromArtboard(A);
133
133
  }
134
134
  );
135
- i.current.executeOnArtboard(p, w), d();
135
+ i.current.executeOnArtboard(g, b), d();
136
136
  },
137
137
  [t, o, d, a]
138
- ), y = h(
139
- (l) => {
140
- const p = new Fe(l, o);
141
- i.current.executeGlobal(p), d(), n == null || n();
138
+ ), x = h(
139
+ (u) => {
140
+ const g = new ve(u, o);
141
+ i.current.executeGlobal(g), d(), n == null || n();
142
142
  },
143
143
  [o, d, n]
144
144
  ), D = h(
145
- (l) => {
146
- const p = new ve(l, o);
147
- i.current.executeGlobal(p), d(), n == null || n();
145
+ (u) => {
146
+ const g = new Pe(u, o);
147
+ i.current.executeGlobal(g), d(), n == null || n();
148
148
  },
149
149
  [o, d, n]
150
- ), f = h(
151
- (l, p, w) => {
152
- const A = new Pe(l, p, w, o);
150
+ ), p = h(
151
+ (u, g, b) => {
152
+ const A = new Ne(u, g, b, o);
153
153
  i.current.executeGlobal(A), d(), n == null || n();
154
154
  },
155
155
  [o, d, n]
156
156
  ), m = h(
157
- (l) => {
158
- if (l.length === 0)
157
+ (u) => {
158
+ if (u.length === 0)
159
159
  return;
160
- const p = o.getActiveArtboardId();
161
- if (!p) {
162
- wt.warn("No active artboard for batch execution");
160
+ const g = o.getActiveArtboardId();
161
+ if (!g) {
162
+ bt.warn("No active artboard for batch execution");
163
163
  return;
164
164
  }
165
- const w = l.map((A) => new class extends Object {
165
+ const b = u.map((A) => new class extends Object {
166
166
  execute() {
167
167
  A.execute();
168
168
  }
@@ -170,68 +170,68 @@ function Ge(e, t, o, n) {
170
170
  A.undo();
171
171
  }
172
172
  }());
173
- i.current.executeBatchOnArtboard(p, w), d();
173
+ i.current.executeBatchOnArtboard(g, b), d();
174
174
  },
175
175
  [o, d]
176
- ), x = h(() => {
176
+ ), w = h(() => {
177
177
  i.current.undo() && (d(), n == null || n());
178
- }, [d, n]), I = h(() => {
179
- i.current.redo() && (d(), n == null || n());
180
178
  }, [d, n]), T = h(() => {
181
- const l = o.getActiveArtboardId();
182
- l && i.current.undoArtboard(l) && (d(), n == null || n());
183
- }, [o, d, n]), R = h(() => {
184
- const l = o.getActiveArtboardId();
185
- l && i.current.redoArtboard(l) && (d(), n == null || n());
179
+ i.current.redo() && (d(), n == null || n());
180
+ }, [d, n]), C = h(() => {
181
+ const u = o.getActiveArtboardId();
182
+ u && i.current.undoArtboard(u) && (d(), n == null || n());
183
+ }, [o, d, n]), I = h(() => {
184
+ const u = o.getActiveArtboardId();
185
+ u && i.current.redoArtboard(u) && (d(), n == null || n());
186
186
  }, [o, d, n]), M = h(() => {
187
187
  i.current.clear(), d();
188
- }, [d]), nt = h(
189
- (l) => {
190
- i.current.clearArtboardHistory(l), d();
188
+ }, [d]), ot = h(
189
+ (u) => {
190
+ i.current.clearArtboardHistory(u), d();
191
191
  },
192
192
  [d]
193
- ), _ = gt(null);
194
- $t(() => {
195
- const l = o.getActiveArtboardId();
196
- l !== _.current && (_.current = l, d());
193
+ ), ht = At(null);
194
+ Bt(() => {
195
+ const u = o.getActiveArtboardId();
196
+ u !== ht.current && (ht.current = u, d());
197
197
  });
198
198
  const W = h(
199
- (l, p, w) => {
200
- const A = e.map((z) => z.id), C = o.getArtboardIdForElement(l);
201
- if (!C) {
202
- wt.warn("Element not found in any artboard");
199
+ (u, g, b) => {
200
+ const A = e.map((z) => z.id), F = o.getArtboardIdForElement(u);
201
+ if (!F) {
202
+ bt.warn("Element not found in any artboard");
203
203
  return;
204
204
  }
205
- const Y = new Ne(l, p, w, A, (z) => {
206
- t(($) => {
207
- const U = new Map($.map((L) => [L.id, L]));
205
+ const Y = new Oe(u, g, b, A, (z) => {
206
+ t((_) => {
207
+ const U = new Map(_.map((L) => [L.id, L]));
208
208
  return z.map((L) => U.get(L)).filter(Boolean);
209
209
  });
210
210
  });
211
- i.current.executeOnArtboard(C, Y), d();
211
+ i.current.executeOnArtboard(F, Y), d();
212
212
  },
213
213
  [e, t, o, d]
214
214
  );
215
215
  return {
216
216
  // Element operations
217
- executeElementUpdate: S,
217
+ executeElementUpdate: R,
218
218
  executeAddElement: N,
219
219
  executeRemoveElement: k,
220
220
  executeReorderElement: W,
221
221
  // Batch operations
222
222
  executeCommandBatch: m,
223
223
  // Artboard operations
224
- executeCreateArtboard: y,
224
+ executeCreateArtboard: x,
225
225
  executeDeleteArtboard: D,
226
- executeUpdateArtboard: f,
226
+ executeUpdateArtboard: p,
227
227
  // Undo/redo (smart - considers last operation and active artboard)
228
- undo: x,
229
- redo: I,
228
+ undo: w,
229
+ redo: T,
230
230
  // Undo/redo for active artboard only (element operations)
231
- undoActiveArtboard: T,
232
- redoActiveArtboard: R,
231
+ undoActiveArtboard: C,
232
+ redoActiveArtboard: I,
233
233
  clearHistory: M,
234
- clearArtboardHistory: nt,
234
+ clearArtboardHistory: ot,
235
235
  // State (smart - considers last operation)
236
236
  canUndo: s.canUndo,
237
237
  canRedo: s.canRedo,
@@ -244,57 +244,57 @@ function Ge(e, t, o, n) {
244
244
  function dt(e) {
245
245
  return e && "fontSize" in e && "color" in e && "fontFamily" in e;
246
246
  }
247
- function Ke(e, t) {
248
- const [o, n] = E(32), [i, r] = E("#333333"), [a, s] = E("Arial"), [c, d] = E("center");
249
- $t(() => {
247
+ function Ze(e, t) {
248
+ const [o, n] = S(32), [i, r] = S("#333333"), [a, s] = S("Arial"), [c, d] = S("center");
249
+ Bt(() => {
250
250
  if (e && dt(e)) {
251
- const f = e.transformType === "circle" && "getEffectiveFontSize" in e ? Math.round(e.getEffectiveFontSize()) : Math.round(e.fontSize), m = e.color, x = e.fontFamily, I = e.textAlign;
252
- n((T) => T !== f ? f : T), r((T) => T !== m ? m : T), s((T) => T !== x ? x : T), d((T) => T !== I ? I : T);
251
+ const p = e.transformType === "circle" && "getEffectiveFontSize" in e ? Math.round(e.getEffectiveFontSize()) : Math.round(e.fontSize), m = e.color, w = e.fontFamily, T = e.textAlign;
252
+ n((C) => C !== p ? p : C), r((C) => C !== m ? m : C), s((C) => C !== w ? w : C), d((C) => C !== T ? T : C);
253
253
  }
254
254
  }, [e]);
255
- const S = h(
256
- (f) => {
255
+ const R = h(
256
+ (p) => {
257
257
  if (!e || !dt(e)) return;
258
- const m = Math.max(ze, Math.min(Ue, o + f));
258
+ const m = Math.max(Ue, Math.min(He, o + p));
259
259
  n(m);
260
- const x = e.clone();
261
- x.transformType === "circle" && "setEffectiveFontSize" in x ? x.setEffectiveFontSize(m) : x.setFontSize(m), t(x);
260
+ const w = e.clone();
261
+ w.transformType === "circle" && "setEffectiveFontSize" in w ? w.setEffectiveFontSize(m) : w.setFontSize(m), t(w);
262
262
  },
263
263
  [e, o, t]
264
264
  ), N = h(
265
- (f) => {
265
+ (p) => {
266
266
  if (!e || !dt(e)) return;
267
- n(f);
267
+ n(p);
268
268
  const m = e.clone();
269
- m.transformType === "circle" && "setEffectiveFontSize" in m ? m.setEffectiveFontSize(f) : m.setFontSize(f), t(m);
269
+ m.transformType === "circle" && "setEffectiveFontSize" in m ? m.setEffectiveFontSize(p) : m.setFontSize(p), t(m);
270
270
  },
271
271
  [e, t]
272
272
  ), k = h(
273
- (f) => {
273
+ (p) => {
274
274
  if (!e || !dt(e)) return;
275
- r(f);
275
+ r(p);
276
276
  const m = e.clone();
277
- if (m.color = f, m.richText)
278
- for (const x of m.richText.spans)
279
- x.style.color = void 0;
277
+ if (m.color = p, m.richText)
278
+ for (const w of m.richText.spans)
279
+ w.style.color = void 0;
280
280
  t(m);
281
281
  },
282
282
  [e, t]
283
- ), y = h(
284
- (f) => {
283
+ ), x = h(
284
+ (p) => {
285
285
  if (!e || !dt(e)) return;
286
286
  const m = e.fontFamily;
287
- m !== f && Oe.clearCache(m), s(f);
288
- const x = e.clone();
289
- x.fontFamily = f, t(x);
287
+ m !== p && ze.clearCache(m), s(p);
288
+ const w = e.clone();
289
+ w.fontFamily = p, t(w);
290
290
  },
291
291
  [e, t]
292
292
  ), D = h(
293
- (f) => {
293
+ (p) => {
294
294
  if (!e || !dt(e)) return;
295
- d(f);
295
+ d(p);
296
296
  const m = e.clone();
297
- m.textAlign = f, t(m);
297
+ m.textAlign = p, t(m);
298
298
  },
299
299
  [e, t]
300
300
  );
@@ -310,22 +310,22 @@ function Ke(e, t) {
310
310
  setFontFamily: s,
311
311
  setTextAlign: d,
312
312
  // Update functions (update element + UI)
313
- updateFontSize: S,
313
+ updateFontSize: R,
314
314
  setFontSizeValue: N,
315
315
  updateFontColor: k,
316
- updateFontFamily: y,
316
+ updateFontFamily: x,
317
317
  updateTextAlign: D
318
318
  };
319
319
  }
320
- const ne = "data-preserve-selection";
321
- function Ze(e) {
320
+ const re = "data-preserve-selection";
321
+ function je(e) {
322
322
  if (!(e instanceof Element))
323
323
  return !1;
324
324
  let t = e;
325
325
  const o = [];
326
326
  for (; t; ) {
327
327
  const n = t.id ? `#${t.id}` : "", i = t.className ? `.${String(t.className).split(" ").slice(0, 2).join(".")}` : "";
328
- if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(ne))
328
+ if (o.push(`${t.tagName.toLowerCase()}${n}${i}`), t.hasAttribute(re))
329
329
  return !0;
330
330
  const r = t.getAttribute("role");
331
331
  if (r === "dialog" || r === "alertdialog" || r === "menu" || r === "listbox")
@@ -337,18 +337,18 @@ function Ze(e) {
337
337
  }
338
338
  return !1;
339
339
  }
340
- const Ho = {
341
- [ne]: ""
340
+ const ko = {
341
+ [re]: ""
342
342
  };
343
- function je(e) {
344
- const t = re(e);
343
+ function Je(e) {
344
+ const t = ie(e);
345
345
  return t !== null && t < 0.5;
346
346
  }
347
- function ko(e) {
348
- const t = re(e);
347
+ function Do(e) {
348
+ const t = ie(e);
349
349
  return t !== null && t >= 0.5;
350
350
  }
351
- function re(e) {
351
+ function ie(e) {
352
352
  const t = e.trim();
353
353
  if (t.startsWith("#")) {
354
354
  const n = t.slice(1);
@@ -358,29 +358,29 @@ function re(e) {
358
358
  else if (n.length === 6)
359
359
  i = parseInt(n.slice(0, 2), 16), r = parseInt(n.slice(2, 4), 16), a = parseInt(n.slice(4, 6), 16);
360
360
  else return null;
361
- return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null : Zt(i, r, a);
361
+ return Number.isNaN(i) || Number.isNaN(r) || Number.isNaN(a) ? null : jt(i, r, a);
362
362
  }
363
363
  const o = t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
364
- return o ? Zt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
364
+ return o ? jt(Number(o[1]), Number(o[2]), Number(o[3])) : null;
365
365
  }
366
- function Zt(e, t, o) {
366
+ function jt(e, t, o) {
367
367
  const n = (i) => {
368
368
  const r = i / 255;
369
369
  return r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
370
370
  };
371
371
  return 0.2126 * n(e) + 0.7152 * n(t) + 0.0722 * n(o);
372
372
  }
373
- const Je = "#333333", qe = "#f4f4f5";
374
- function Qe(e) {
375
- return e && je(e) ? qe : Je;
373
+ const qe = "#333333", Qe = "#f4f4f5";
374
+ function to(e) {
375
+ return e && Je(e) ? Qe : qe;
376
376
  }
377
- const to = {
377
+ const eo = {
378
378
  timeout: 3e4,
379
379
  retries: 1,
380
380
  retryDelay: 1e3,
381
381
  validateUrl: !0
382
382
  };
383
- function eo(e) {
383
+ function oo(e) {
384
384
  try {
385
385
  const t = new URL(e);
386
386
  return ["http:", "https:", "data:", "blob:"].includes(t.protocol);
@@ -388,9 +388,9 @@ function eo(e) {
388
388
  return !1;
389
389
  }
390
390
  }
391
- async function ie(e, t = {}) {
392
- const o = { ...to, ...t };
393
- if (o.validateUrl && !eo(e))
391
+ async function se(e, t = {}) {
392
+ const o = { ...eo, ...t };
393
+ if (o.validateUrl && !oo(e))
394
394
  return {
395
395
  success: !1,
396
396
  error: new Error(`Invalid image URL: ${e}`)
@@ -398,16 +398,16 @@ async function ie(e, t = {}) {
398
398
  let n;
399
399
  for (let i = 0; i <= o.retries; i++)
400
400
  try {
401
- return await oo(e, o.timeout);
401
+ return await no(e, o.timeout);
402
402
  } catch (r) {
403
- n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await no(o.retryDelay);
403
+ n = r instanceof Error ? r : new Error(String(r)), i < o.retries && await ro(o.retryDelay);
404
404
  }
405
405
  return {
406
406
  success: !1,
407
407
  error: n || new Error("Failed to load image after retries")
408
408
  };
409
409
  }
410
- function oo(e, t) {
410
+ function no(e, t) {
411
411
  return new Promise((o) => {
412
412
  const n = new Image();
413
413
  n.crossOrigin = "anonymous";
@@ -417,13 +417,13 @@ function oo(e, t) {
417
417
  }, s = () => {
418
418
  if (r) return;
419
419
  r = !0, a();
420
- const d = n.naturalWidth || n.width, S = n.naturalHeight || n.height;
420
+ const d = n.naturalWidth || n.width, R = n.naturalHeight || n.height;
421
421
  o({
422
422
  success: !0,
423
423
  element: n,
424
424
  width: d,
425
- height: S,
426
- aspectRatio: S > 0 ? d / S : 1
425
+ height: R,
426
+ aspectRatio: R > 0 ? d / R : 1
427
427
  });
428
428
  }, c = (d) => {
429
429
  r || (r = !0, a(), o({
@@ -438,9 +438,9 @@ function oo(e, t) {
438
438
  }, t), n.src = e;
439
439
  });
440
440
  }
441
- async function Do(e, t, o = {}, n = {}) {
442
- var k, y, D, f, m, x, I;
443
- const i = await ie(e, n);
441
+ async function Lo(e, t, o = {}, n = {}) {
442
+ var k, x, D, p, m, w, T;
443
+ const i = await se(e, n);
444
444
  if (!i.success || !i.width || !i.height)
445
445
  return {
446
446
  success: !1,
@@ -450,7 +450,7 @@ async function Do(e, t, o = {}, n = {}) {
450
450
  width: t.artboard.width,
451
451
  height: t.artboard.height,
452
452
  scale: t.scale,
453
- align: te(t.alignment),
453
+ align: ee(t.alignment),
454
454
  offsetX: t.offsetX,
455
455
  offsetY: t.offsetY,
456
456
  scaleMode: t.scaleMode,
@@ -458,16 +458,16 @@ async function Do(e, t, o = {}, n = {}) {
458
458
  marginRight: t.marginRight,
459
459
  marginBottom: t.marginBottom,
460
460
  marginLeft: t.marginLeft
461
- }, a = ee(
461
+ }, a = oe(
462
462
  { width: i.width, height: i.height },
463
463
  r
464
- ), s = t.artboard.x + a.x, c = t.artboard.y + a.y, d = s + a.width / 2, S = c + a.height / 2;
464
+ ), s = t.artboard.x + a.x, c = t.artboard.y + a.y, d = s + a.width / 2, R = c + a.height / 2;
465
465
  return {
466
466
  success: !0,
467
- element: new Vt({
467
+ element: new _t({
468
468
  ...o,
469
469
  x: d,
470
- y: S,
470
+ y: R,
471
471
  imageUrl: e,
472
472
  imageAspectRatio: i.aspectRatio,
473
473
  preserveDimensions: !0,
@@ -477,26 +477,26 @@ async function Do(e, t, o = {}, n = {}) {
477
477
  width: a.width,
478
478
  height: a.height,
479
479
  cropX: ((k = o.transformData) == null ? void 0 : k.cropX) ?? 0,
480
- cropY: ((y = o.transformData) == null ? void 0 : y.cropY) ?? 0,
480
+ cropY: ((x = o.transformData) == null ? void 0 : x.cropY) ?? 0,
481
481
  cropWidth: ((D = o.transformData) == null ? void 0 : D.cropWidth) ?? 1,
482
- cropHeight: ((f = o.transformData) == null ? void 0 : f.cropHeight) ?? 1,
482
+ cropHeight: ((p = o.transformData) == null ? void 0 : p.cropHeight) ?? 1,
483
483
  flipHorizontal: ((m = o.transformData) == null ? void 0 : m.flipHorizontal) ?? !1,
484
- flipVertical: ((x = o.transformData) == null ? void 0 : x.flipVertical) ?? !1,
485
- borderRadius: ((I = o.transformData) == null ? void 0 : I.borderRadius) ?? 0
484
+ flipVertical: ((w = o.transformData) == null ? void 0 : w.flipVertical) ?? !1,
485
+ borderRadius: ((T = o.transformData) == null ? void 0 : T.borderRadius) ?? 0
486
486
  }
487
487
  }),
488
488
  placement: {
489
489
  artworkSize: { width: i.width, height: i.height },
490
490
  finalSize: { width: a.width, height: a.height },
491
- position: { x: d, y: S },
491
+ position: { x: d, y: R },
492
492
  scale: a.scale
493
493
  }
494
494
  };
495
495
  }
496
- function no(e) {
496
+ function ro(e) {
497
497
  return new Promise((t) => setTimeout(t, e));
498
498
  }
499
- function Lo(e) {
499
+ function Vo(e) {
500
500
  if (e != null && e.scaleMode)
501
501
  return {
502
502
  scaleMode: e.scaleMode,
@@ -507,21 +507,21 @@ function Lo(e) {
507
507
  align: e.fitAlign
508
508
  };
509
509
  }
510
- function se(e) {
510
+ function ae(e) {
511
511
  var t;
512
512
  return ((t = e == null ? void 0 : e.imageFit) == null ? void 0 : t.scaleMode) === "contain";
513
513
  }
514
- function ro(e, t) {
515
- if (!se(e)) return null;
514
+ function io(e, t) {
515
+ if (!ae(e)) return null;
516
516
  if (!(t.width > 0) || !(t.height > 0))
517
517
  throw new Error(
518
518
  `E_NEW_IMAGE_SIZE: a new picture of ${t.width}x${t.height} cannot be placed on a ${e.width}x${e.height} area; pass the picture's natural size (loadImageFromURL).`
519
519
  );
520
- const o = e.imageFit, n = ee(t, {
520
+ const o = e.imageFit, n = oe(t, {
521
521
  width: e.width,
522
522
  height: e.height,
523
523
  scaleMode: "contain",
524
- align: te(o.align),
524
+ align: ee(o.align),
525
525
  marginTop: o.marginTop,
526
526
  marginRight: o.marginRight,
527
527
  marginBottom: o.marginBottom,
@@ -534,71 +534,71 @@ function ro(e, t) {
534
534
  height: n.height
535
535
  };
536
536
  }
537
- async function io(e, t) {
538
- if (!se(e)) return null;
539
- const o = await ie(t, { validateUrl: !1 });
540
- return !o.success || !o.width || !o.height ? null : ro(e, { width: o.width, height: o.height });
537
+ async function so(e, t) {
538
+ if (!ae(e)) return null;
539
+ const o = await se(t, { validateUrl: !1 });
540
+ return !o.success || !o.width || !o.height ? null : io(e, { width: o.width, height: o.height });
541
541
  }
542
- const ae = Q(null), so = 0.1, ao = 4, jt = 0.25, co = ({
542
+ const ce = q(null), ao = 0.1, co = 4, Jt = 0.25, lo = ({
543
543
  children: e,
544
544
  artboardManager: t,
545
545
  canvasRef: o,
546
546
  viewPadding: n = 0.9
547
547
  }) => {
548
- const [i, r] = E(1), [a, s] = E({ x: 0, y: 0 }), [c, d] = E(!1), [S, N] = E(1), k = h(() => {
548
+ const [i, r] = S(1), [a, s] = S({ x: 0, y: 0 }), [c, d] = S(!1), [R, N] = S(1), k = h(() => {
549
549
  N(1), s({ x: 0, y: 0 });
550
- }, []), y = h(() => {
551
- r((I) => Math.min(I + jt, ao));
550
+ }, []), x = h(() => {
551
+ r((T) => Math.min(T + Jt, co));
552
552
  }, []), D = h(() => {
553
- r((I) => Math.max(I - jt, so));
554
- }, []), f = h(() => {
555
- const I = t.getActiveArtboard();
556
- if (!I || !o.current) return;
557
- let T = o.current.parentElement, R = 0, M = 0;
558
- for (; T && (R = T.clientWidth, M = T.clientHeight, !(R > 0 && M > 0)); )
559
- T = T.parentElement;
560
- if (!R || !M) return;
561
- const nt = Math.min(
562
- R * n / I.width,
563
- M * n / I.height,
553
+ r((T) => Math.max(T - Jt, ao));
554
+ }, []), p = h(() => {
555
+ const T = t.getActiveArtboard();
556
+ if (!T || !o.current) return;
557
+ let C = o.current.parentElement, I = 0, M = 0;
558
+ for (; C && (I = C.clientWidth, M = C.clientHeight, !(I > 0 && M > 0)); )
559
+ C = C.parentElement;
560
+ if (!I || !M) return;
561
+ const ot = Math.min(
562
+ I * n / T.width,
563
+ M * n / T.height,
564
564
  1
565
565
  // Never zoom in beyond 100%
566
566
  );
567
- r(nt), s({ x: 0, y: 0 });
567
+ r(ot), s({ x: 0, y: 0 });
568
568
  }, [t, o, n]), m = h(() => {
569
569
  r(1), s({ x: 0, y: 0 });
570
- }, []), x = q(
570
+ }, []), w = J(
571
571
  () => ({
572
572
  zoom: i,
573
573
  panOffset: a,
574
574
  isPanning: c,
575
- zoomIn: y,
575
+ zoomIn: x,
576
576
  zoomOut: D,
577
- zoomToFit: f,
577
+ zoomToFit: p,
578
578
  resetView: m,
579
579
  setZoom: r,
580
580
  setPanOffset: s,
581
581
  setIsPanning: d,
582
- userZoom: S,
582
+ userZoom: R,
583
583
  setUserZoom: N,
584
584
  resetUserView: k
585
585
  }),
586
- [i, a, c, y, D, f, m, S, k]
586
+ [i, a, c, x, D, p, m, R, k]
587
587
  );
588
- return /* @__PURE__ */ V(ae.Provider, { value: x, children: e });
588
+ return /* @__PURE__ */ V(ce.Provider, { value: w, children: e });
589
589
  };
590
- function lo() {
591
- const e = G(ae);
590
+ function uo() {
591
+ const e = G(ce);
592
592
  if (!e)
593
593
  throw new Error("useViewportContext must be used within a ViewportProvider (or EditorProvider)");
594
594
  return e;
595
595
  }
596
- const ce = Q(null), uo = ({ children: e }) => {
597
- const [t, o] = E(null), [n, i] = E([]), [r, a] = E(null), [s, c] = E(null), [d, S] = E(!1), N = h((D) => {
596
+ const de = q(null), ho = ({ children: e }) => {
597
+ const [t, o] = S(null), [n, i] = S([]), [r, a] = S(null), [s, c] = S(null), [d, R] = S(!1), N = h((D) => {
598
598
  o(D);
599
599
  }, []), k = h((D) => {
600
600
  a(D);
601
- }, []), y = q(
601
+ }, []), x = J(
602
602
  () => ({
603
603
  selectedId: t,
604
604
  multiSelection: n,
@@ -608,7 +608,7 @@ const ce = Q(null), uo = ({ children: e }) => {
608
608
  setSelectedId: o,
609
609
  setMultiSelection: i,
610
610
  setHoveredElementId: c,
611
- setHideHandles: S,
611
+ setHideHandles: R,
612
612
  handleSelectionChange: N,
613
613
  handleActiveChildChange: k
614
614
  }),
@@ -622,16 +622,16 @@ const ce = Q(null), uo = ({ children: e }) => {
622
622
  k
623
623
  ]
624
624
  );
625
- return /* @__PURE__ */ V(ce.Provider, { value: y, children: e });
625
+ return /* @__PURE__ */ V(de.Provider, { value: x, children: e });
626
626
  };
627
- function ho() {
628
- const e = G(ce);
627
+ function mo() {
628
+ const e = G(de);
629
629
  if (!e)
630
630
  throw new Error("useSelectionContext must be used within a SelectionProvider (or EditorProvider)");
631
631
  return e;
632
632
  }
633
- const de = Q(null), mo = ({ children: e, value: t }) => {
634
- const o = q(
633
+ const le = q(null), fo = ({ children: e, value: t }) => {
634
+ const o = J(
635
635
  () => ({
636
636
  undo: t.undo,
637
637
  redo: t.redo,
@@ -653,16 +653,16 @@ const de = Q(null), mo = ({ children: e, value: t }) => {
653
653
  t.canRedoActiveArtboard
654
654
  ]
655
655
  );
656
- return /* @__PURE__ */ V(de.Provider, { value: o, children: e });
656
+ return /* @__PURE__ */ V(le.Provider, { value: o, children: e });
657
657
  };
658
- function Vo() {
659
- const e = G(de);
658
+ function _o() {
659
+ const e = G(le);
660
660
  if (!e)
661
661
  throw new Error("useHistoryContext must be used within a HistoryProvider (or EditorProvider)");
662
662
  return e;
663
663
  }
664
- const le = Q(null), fo = ({ children: e }) => {
665
- const [t, o] = E(null), [n, i] = E(!1), [r, a] = E(0), [s, c] = E(!1), [d, S] = E(!1), N = q(
664
+ const ue = q(null), po = ({ children: e }) => {
665
+ const [t, o] = S(null), [n, i] = S(!1), [r, a] = S(0), [s, c] = S(!1), [d, R] = S(!1), N = J(
666
666
  () => ({
667
667
  expandedPanelType: t,
668
668
  setExpandedPanelType: o,
@@ -673,20 +673,20 @@ const le = Q(null), fo = ({ children: e }) => {
673
673
  isCanvasReady: s,
674
674
  setCanvasReady: c,
675
675
  isRotating: d,
676
- setIsRotating: S
676
+ setIsRotating: R
677
677
  }),
678
678
  [t, n, r, s, d]
679
679
  );
680
- return /* @__PURE__ */ V(le.Provider, { value: N, children: e });
680
+ return /* @__PURE__ */ V(ue.Provider, { value: N, children: e });
681
681
  };
682
- function po() {
683
- const e = G(le);
682
+ function go() {
683
+ const e = G(ue);
684
684
  if (!e)
685
685
  throw new Error("useToolStateContext must be used within a ToolStateProvider (or EditorProvider)");
686
686
  return e;
687
687
  }
688
- const ue = Q(null), go = ({ children: e, value: t }) => {
689
- const o = q(
688
+ const he = q(null), Ao = ({ children: e, value: t }) => {
689
+ const o = J(
690
690
  () => ({
691
691
  elements: t.elements,
692
692
  elementStore: t.elementStore,
@@ -740,16 +740,16 @@ const ue = Q(null), go = ({ children: e, value: t }) => {
740
740
  t.canvasEditorRef
741
741
  ]
742
742
  );
743
- return /* @__PURE__ */ V(ue.Provider, { value: o, children: e });
743
+ return /* @__PURE__ */ V(he.Provider, { value: o, children: e });
744
744
  };
745
- function _o() {
746
- const e = G(ue);
745
+ function $o() {
746
+ const e = G(he);
747
747
  if (!e)
748
748
  throw new Error("useElementsContext must be used within an ElementsProvider (or EditorProvider)");
749
749
  return e;
750
750
  }
751
- const he = Q(null), Ao = ({ children: e, value: t }) => {
752
- const o = q(
751
+ const me = q(null), yo = ({ children: e, value: t }) => {
752
+ const o = J(
753
753
  () => ({
754
754
  executeElementUpdate: t.executeElementUpdate,
755
755
  executeAddElement: t.executeAddElement,
@@ -789,120 +789,129 @@ const he = Q(null), Ao = ({ children: e, value: t }) => {
789
789
  t.historyManager
790
790
  ]
791
791
  );
792
- return /* @__PURE__ */ V(he.Provider, { value: o, children: e });
792
+ return /* @__PURE__ */ V(me.Provider, { value: o, children: e });
793
793
  };
794
- function $o() {
795
- const e = G(he);
794
+ function Bo() {
795
+ const e = G(me);
796
796
  if (!e)
797
797
  throw new Error("useCommandContext must be used within a CommandProvider (or EditorProvider)");
798
798
  return e;
799
799
  }
800
- const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
801
- const e = G(fe);
800
+ const xo = te("EditorContext"), fe = q(null), pe = q(null), Mo = () => {
801
+ const e = G(pe);
802
802
  if (!e)
803
803
  throw new Error("useEditorHandles must be used within EditorProvider");
804
804
  return e;
805
- }, xo = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
806
- const i = gt(null), r = q(() => ({ get: () => i.current }), []), a = lo(), s = ho(), c = po(), [d, S] = E(
805
+ }, wo = ({ children: e, artboardManager: t, canvasRef: o, canvasEditorRef: n }) => {
806
+ const i = At(null), r = J(() => ({ get: () => i.current }), []), a = uo(), s = mo(), c = go(), [d, R] = S(
807
807
  () => t.getAllArtboards()
808
- ), [N, k] = E(0), [y, D] = E(
809
- () => new Yt()
810
- ), f = q(() => y.toArray(), [y]), m = h((u) => {
811
- D((g) => {
812
- const b = g.toArray(), F = typeof u == "function" ? u(b) : u;
813
- return F === b ? g : Yt.fromArray(F);
808
+ ), [N, k] = S(0), [x, D] = S(
809
+ () => new Xt()
810
+ ), p = J(() => x.toArray(), [x]), m = h((l) => {
811
+ D((f) => {
812
+ const y = f.toArray(), E = typeof l == "function" ? l(y) : l;
813
+ return E === y ? f : Xt.fromArray(E);
814
814
  });
815
- }, []), x = h(
816
- (u) => y.get(u),
817
- [y]
818
- ), [I, T] = E([]), R = s.selectedId ? y.get(s.selectedId) : void 0, M = h(() => {
819
- S([...t.getAllArtboards()]), k((u) => u + 1);
815
+ }, []), w = h(
816
+ (l) => x.get(l),
817
+ [x]
818
+ ), [T, C] = S([]), I = s.selectedId ? x.get(s.selectedId) : void 0, M = h(() => {
819
+ R([...t.getAllArtboards()]), k((l) => l + 1);
820
820
  }, [t]), {
821
- historyManager: nt,
822
- executeElementUpdate: _,
821
+ historyManager: ot,
822
+ executeElementUpdate: ht,
823
823
  executeAddElement: W,
824
- executeRemoveElement: l,
825
- executeReorderElement: p,
826
- executeCommandBatch: w,
824
+ executeRemoveElement: u,
825
+ executeReorderElement: g,
826
+ executeCommandBatch: b,
827
827
  executeCreateArtboard: A,
828
- executeDeleteArtboard: C,
828
+ executeDeleteArtboard: F,
829
829
  executeUpdateArtboard: Y,
830
830
  undo: z,
831
- redo: $,
831
+ redo: _,
832
832
  canUndo: U,
833
833
  canRedo: L,
834
834
  undoActiveArtboard: P,
835
835
  redoActiveArtboard: K,
836
- canUndoActiveArtboard: rt,
836
+ canUndoActiveArtboard: nt,
837
837
  canRedoActiveArtboard: Z
838
- } = Ge(
839
- f,
838
+ } = Ke(
839
+ p,
840
840
  m,
841
841
  t,
842
842
  M
843
- ), j = h(
844
- (u) => {
845
- const g = y.get(u.id);
846
- _(g, u);
843
+ ), $ = h(
844
+ (l, f) => {
845
+ if (f && t.isPlaceholder(f.id)) {
846
+ const y = l == null ? void 0 : l.text, E = f.text;
847
+ typeof E == "string" && y !== E && t.unmarkPlaceholder(f.id);
848
+ }
849
+ return ht(l, f);
847
850
  },
848
- [y, _]
849
- ), xe = h(
850
- (u) => {
851
- if (!R || !(R instanceof qt))
851
+ [t, ht]
852
+ ), it = h(
853
+ (l) => {
854
+ const f = x.get(l.id);
855
+ $(f, l);
856
+ },
857
+ [x, $]
858
+ ), we = h(
859
+ (l) => {
860
+ if (!I || !(I instanceof Qt))
852
861
  return;
853
- const g = R.clone(), b = g.children.findIndex(
854
- (F) => F.id === u.id
862
+ const f = I.clone(), y = f.children.findIndex(
863
+ (E) => E.id === l.id
855
864
  );
856
- b >= 0 && (g.children[b] = u, j(g));
865
+ y >= 0 && (f.children[y] = l, it(f));
857
866
  },
858
- [R, j]
859
- ), we = s.activeChildElement || R, be = s.activeChildElement ? xe : j, {
860
- fontSize: Et,
861
- fontColor: St,
862
- fontFamily: Rt,
863
- textAlign: It,
864
- updateFontSize: Tt,
865
- setFontSizeValue: Ct,
866
- updateFontColor: Ft,
867
- updateFontFamily: vt,
868
- updateTextAlign: Pt
869
- } = Ke(we, be), At = h(
870
- async (u) => {
871
- var Mt;
872
- const g = u.type, b = u, F = t.getActiveArtboardId();
873
- if (!F)
874
- throw new ot(
867
+ [I, it]
868
+ ), be = s.activeChildElement || I, Ee = s.activeChildElement ? we : it, {
869
+ fontSize: St,
870
+ fontColor: Rt,
871
+ fontFamily: It,
872
+ textAlign: Tt,
873
+ updateFontSize: Ct,
874
+ setFontSizeValue: Ft,
875
+ updateFontColor: vt,
876
+ updateFontFamily: Pt,
877
+ updateTextAlign: Nt
878
+ } = Ze(be, Ee), yt = h(
879
+ async (l) => {
880
+ var Wt;
881
+ const f = l.type, y = l, E = t.getActiveArtboardId();
882
+ if (!E)
883
+ throw new et(
875
884
  "E_NO_ACTIVE_ARTBOARD",
876
- `addElement({ type: "${g}" }) needs an active artboard and none exists. <Editor.Root> seeds one automatically; with a raw EditorProvider create one first (executeCreateArtboard) or select one (artboardManager.setActiveArtboard).`,
877
- { type: g, docSlug: "embed-mode" }
885
+ `addElement({ type: "${f}" }) needs an active artboard and none exists. <Editor.Root> seeds one automatically; with a raw EditorProvider create one first (executeCreateArtboard) or select one (artboardManager.setActiveArtboard).`,
886
+ { type: f, docSlug: "embed-mode" }
878
887
  );
879
- const v = `element-${Date.now()}`, O = t.getActiveArtboard(), ht = O ? O.x + O.width / 2 : window.innerWidth / 2, st = O ? O.y + O.height / 2 : window.innerHeight / 2, J = ((Mt = n.current) == null ? void 0 : Mt.getZoom()) || a.zoom || 1;
880
- if (g === "image") {
881
- const ft = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", et = 200 / J, B = b == null ? void 0 : b.src, pt = B ? await io(O, B) : null;
882
- if (pt) {
883
- const H = new Vt({
888
+ const v = `element-${Date.now()}`, O = t.getActiveArtboard(), mt = O ? O.x + O.width / 2 : window.innerWidth / 2, st = O ? O.y + O.height / 2 : window.innerHeight / 2, j = ((Wt = n.current) == null ? void 0 : Wt.getZoom()) || a.zoom || 1;
889
+ if (f === "image") {
890
+ const pt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==", tt = 200 / j, B = y == null ? void 0 : y.src, gt = B ? await so(O, B) : null;
891
+ if (gt) {
892
+ const H = new _t({
884
893
  id: v,
885
- name: u.name,
886
- x: pt.x,
887
- y: pt.y,
894
+ name: l.name,
895
+ x: gt.x,
896
+ y: gt.y,
888
897
  imageUrl: "",
889
898
  preserveDimensions: !0,
890
- transformData: { type: "image", width: pt.width, height: pt.height }
899
+ transformData: { type: "image", width: gt.width, height: gt.height }
891
900
  });
892
- return H.imageUrl = B, H.onLoadCallback = (xt) => _(H, xt), W(H, F), s.setSelectedId(H.id), H.loadImage(B), { id: H.id, name: u.name ?? "" };
901
+ return H.imageUrl = B, H.onLoadCallback = (wt) => $(H, wt), W(H, E), s.setSelectedId(H.id), H.loadImage(B), { id: H.id, name: l.name ?? "" };
893
902
  }
894
- const X = new Vt({
903
+ const X = new _t({
895
904
  id: v,
896
- name: u.name,
897
- x: ht,
905
+ name: l.name,
906
+ x: mt,
898
907
  y: st,
899
908
  // Defer loading `src` until after the element is in the store so a
900
909
  // synchronously-cached image can't fire onLoadCallback too early.
901
- imageUrl: B ? "" : ft,
910
+ imageUrl: B ? "" : pt,
902
911
  transformData: {
903
912
  type: "image",
904
- width: et,
905
- height: et,
913
+ width: tt,
914
+ height: tt,
906
915
  cropX: 0,
907
916
  cropY: 0,
908
917
  cropWidth: 1,
@@ -913,130 +922,130 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
913
922
  }
914
923
  });
915
924
  return B && (X.imageLoaded = !1, X.imageElement = null, X.isCropping = !1, X.imageUrl = B, X.preserveDimensions = !1, X.onLoadCallback = (H) => {
916
- const xt = H.transformData.width, Wt = H.transformData.height, Dt = Math.min(et / xt, et / Wt, 1);
917
- Dt < 1 && (H.transformData.width = xt * Dt, H.transformData.height = Wt * Dt), H.transformData.cropX = 0, H.transformData.cropY = 0, H.transformData.cropWidth = 1, H.transformData.cropHeight = 1, _(X, H);
918
- }), W(X, F), s.setSelectedId(X.id), B && X.loadImage(B), { id: X.id, name: u.name ?? "" };
925
+ const wt = H.transformData.width, Yt = H.transformData.height, Lt = Math.min(tt / wt, tt / Yt, 1);
926
+ Lt < 1 && (H.transformData.width = wt * Lt, H.transformData.height = Yt * Lt), H.transformData.cropX = 0, H.transformData.cropY = 0, H.transformData.cropWidth = 1, H.transformData.cropHeight = 1, $(X, H);
927
+ }), W(X, E), s.setSelectedId(X.id), B && X.loadImage(B), { id: X.id, name: l.name ?? "" };
919
928
  }
920
- let tt;
929
+ let Q;
921
930
  const ct = {
922
931
  text: "custom",
923
932
  circle: "circle",
924
933
  wave: "wave",
925
934
  arch: "arch",
926
935
  shape: "shape"
927
- }[g] || "custom", Ht = De(ct);
928
- if (!Ht || !Ht.Component)
929
- throw new Error(`[EditorContext] no transform registered for element type "${g}"`);
930
- const mt = t.getActiveArtboard(), Ee = mt ? Math.min(mt.width, mt.height) * 0.1 : 80, kt = mt ? mt.width * 0.5 : 300;
931
- if (g === "shape") {
932
- const ft = (b == null ? void 0 : b.shapeType) ?? "rectangle";
933
- let et = 200 / J, B = 200 / J;
934
- ft === "ellipse" ? (et = 150 / J, B = 250 / J) : ft === "line" && (et = 300 / J, B = 8 / J), tt = new Le({
936
+ }[f] || "custom", kt = Le(ct);
937
+ if (!kt || !kt.Component)
938
+ throw new Error(`[EditorContext] no transform registered for element type "${f}"`);
939
+ const ft = t.getActiveArtboard(), Se = ft ? Math.min(ft.width, ft.height) * 0.1 : 80, Dt = ft ? ft.width * 0.5 : 300;
940
+ if (f === "shape") {
941
+ const pt = (y == null ? void 0 : y.shapeType) ?? "rectangle";
942
+ let tt = 200 / j, B = 200 / j;
943
+ pt === "ellipse" ? (tt = 150 / j, B = 250 / j) : pt === "line" && (tt = 300 / j, B = 8 / j), Q = new Ve({
935
944
  id: v,
936
- name: u.name,
937
- x: ht,
945
+ name: l.name,
946
+ x: mt,
938
947
  y: st,
939
948
  transformData: {
940
949
  type: "shape",
941
- shapeType: ft,
942
- width: et,
950
+ shapeType: pt,
951
+ width: tt,
943
952
  height: B,
944
953
  // an engraved area has one ink: black, which the laser cuts
945
- fillColor: O != null && O.engrave ? Xt : "#3b82f6",
954
+ fillColor: O != null && O.engrave ? Gt : "#3b82f6",
946
955
  fillOpacity: 1
947
956
  }
948
957
  });
949
958
  } else
950
- tt = new Ht.Component({
959
+ Q = new kt.Component({
951
960
  id: v,
952
- name: u.name,
961
+ name: l.name,
953
962
  text: "New Text",
954
- x: ht,
963
+ x: mt,
955
964
  y: st,
956
- fontSize: Ee,
965
+ fontSize: Se,
957
966
  fontFamily: "Poppins",
958
- color: O != null && O.engrave ? Xt : Qe(O == null ? void 0 : O.backgroundColor),
967
+ color: O != null && O.engrave ? Gt : to(O == null ? void 0 : O.backgroundColor),
959
968
  transformData: ct === "arch" ? {
960
969
  type: "arch",
961
- width: kt,
962
- archHeight: Ve.archHeight
970
+ width: Dt,
971
+ archHeight: _e.archHeight
963
972
  } : ct === "wave" ? {
964
973
  type: "wave",
965
- width: kt,
966
- amplitude: Gt.amplitude,
967
- frequency: Gt.frequency
974
+ width: Dt,
975
+ amplitude: Kt.amplitude,
976
+ frequency: Kt.frequency
968
977
  } : ct === "circle" ? {
969
978
  type: "circle",
970
- radius: kt / 2
979
+ radius: Dt / 2
971
980
  } : void 0
972
981
  });
973
- return t.addElementToArtboard(v, F), W(
974
- tt,
975
- F,
982
+ return t.addElementToArtboard(v, E), W(
983
+ Q,
984
+ E,
976
985
  s.selectedId || void 0
977
- ), s.setSelectedId(v), { id: v, name: u.name ?? "" };
986
+ ), s.setSelectedId(v), { id: v, name: l.name ?? "" };
978
987
  },
979
- [t, W, _, s, a.zoom, n]
980
- ), Nt = h(
981
- async (u, g) => {
982
- await At({ ...g, type: u });
988
+ [t, W, $, s, a.zoom, n]
989
+ ), Ot = h(
990
+ async (l, f) => {
991
+ await yt({ ...f, type: l });
983
992
  },
984
- [At]
985
- ), Ot = h(() => {
986
- const u = [];
993
+ [yt]
994
+ ), zt = h(() => {
995
+ const l = [];
987
996
  if (s.multiSelection.length > 0) {
988
- const g = f.filter(
989
- (b) => s.multiSelection.includes(b.id)
997
+ const f = p.filter(
998
+ (y) => s.multiSelection.includes(y.id)
990
999
  );
991
- u.push(...g);
992
- } else R && u.push(R);
993
- if (u.length > 0) {
994
- const g = u.map((b) => b.clone());
995
- T(g);
1000
+ l.push(...f);
1001
+ } else I && l.push(I);
1002
+ if (l.length > 0) {
1003
+ const f = l.map((y) => y.clone());
1004
+ C(f);
996
1005
  }
997
- }, [R, s.multiSelection, f]), zt = h(() => {
998
- if (I.length === 0) return;
999
- const u = [], g = 30, b = 30;
1000
- I.forEach((F) => {
1001
- const v = y.get(F.id), O = v ? v.x : F.x, ht = v ? v.y : F.y, st = F.toJSON();
1006
+ }, [I, s.multiSelection, p]), Ut = h(() => {
1007
+ if (T.length === 0) return;
1008
+ const l = [], f = 30, y = 30;
1009
+ T.forEach((E) => {
1010
+ const v = x.get(E.id), O = v ? v.x : E.x, mt = v ? v.y : E.y, st = E.toJSON();
1002
1011
  delete st.id;
1003
- const J = F.constructor, tt = new J(st);
1004
- tt.x = O + g, tt.y = ht + b;
1012
+ const j = E.constructor, Q = new j(st);
1013
+ Q.x = O + f, Q.y = mt + y;
1005
1014
  let at = null;
1006
1015
  if (v && (at = t.getArtboardIdForElement(
1007
1016
  v.id
1008
1017
  )), at || (at = t.getActiveArtboardId()), !at) {
1009
- yo.warn("[handlePasteElements] No artboard found for pasting");
1018
+ xo.warn("[handlePasteElements] No artboard found for pasting");
1010
1019
  return;
1011
1020
  }
1012
1021
  const ct = v ? v.id : void 0;
1013
- W(tt, at, ct), u.push(tt.id);
1014
- }), u.length === 1 ? s.handleSelectionChange(u[0]) : u.length > 1 && s.setMultiSelection(u);
1022
+ W(Q, at, ct), l.push(Q.id);
1023
+ }), l.length === 1 ? s.handleSelectionChange(l[0]) : l.length > 1 && s.setMultiSelection(l);
1015
1024
  }, [
1016
- I,
1017
- y,
1025
+ T,
1026
+ x,
1018
1027
  t,
1019
1028
  W,
1020
1029
  s
1021
- ]), yt = h(() => {
1022
- if (c.expandedPanelType === "crop" && (R == null ? void 0 : R.transformType) === "image") {
1023
- const u = R;
1024
- if (u.isCropping) {
1025
- const g = u.clone();
1026
- g.exitCropMode(), _(u, g);
1030
+ ]), xt = h(() => {
1031
+ if (c.expandedPanelType === "crop" && (I == null ? void 0 : I.transformType) === "image") {
1032
+ const l = I;
1033
+ if (l.isCropping) {
1034
+ const f = l.clone();
1035
+ f.exitCropMode(), $(l, f);
1027
1036
  }
1028
1037
  }
1029
1038
  c.setExpandedPanelType(null);
1030
1039
  }, [
1031
1040
  c.expandedPanelType,
1032
1041
  c.setExpandedPanelType,
1033
- R,
1034
- _
1042
+ I,
1043
+ $
1035
1044
  ]);
1036
- $t(() => {
1037
- const u = (g) => {
1038
- const b = g.target;
1039
- if (b.tagName === "CANVAS" || Ze(b))
1045
+ Bt(() => {
1046
+ const l = (f) => {
1047
+ const y = f.target;
1048
+ if (y.tagName === "CANVAS" || je(y))
1040
1049
  return;
1041
1050
  const v = document.activeElement;
1042
1051
  if (v != null && v.hasAttribute("data-preserve-selection")) {
@@ -1044,21 +1053,21 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1044
1053
  return;
1045
1054
  }
1046
1055
  if (c.expandedPanelType !== null) {
1047
- yt();
1056
+ xt();
1048
1057
  return;
1049
1058
  }
1050
1059
  s.selectedId !== null && s.setSelectedId(null), s.multiSelection.length > 0 && s.setMultiSelection([]);
1051
1060
  };
1052
- return document.addEventListener("pointerdown", u), () => document.removeEventListener("pointerdown", u);
1053
- }, [c.expandedPanelType, yt, s]);
1054
- const Ut = h(
1055
- (u, g, b) => {
1056
- t.clear(), u.forEach((F) => {
1057
- t.createArtboard(F.toJSON());
1058
- }), b && t.setActiveArtboard(b), S([...t.getAllArtboards()]), k((F) => F + 1), m(g), s.setSelectedId(null);
1061
+ return document.addEventListener("pointerdown", l), () => document.removeEventListener("pointerdown", l);
1062
+ }, [c.expandedPanelType, xt, s]);
1063
+ const Ht = h(
1064
+ (l, f, y) => {
1065
+ t.clear(), l.forEach((E) => {
1066
+ t.createArtboard(E.toJSON());
1067
+ }), y && t.setActiveArtboard(y), R([...t.getAllArtboards()]), k((E) => E + 1), m(f), s.setSelectedId(null);
1059
1068
  },
1060
1069
  [t, s, m]
1061
- ), Bt = q(() => ({
1070
+ ), Mt = J(() => ({
1062
1071
  // From ViewportContext
1063
1072
  zoom: a.zoom,
1064
1073
  panOffset: a.panOffset,
@@ -1094,15 +1103,15 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1094
1103
  isRotating: c.isRotating,
1095
1104
  setIsRotating: c.setIsRotating,
1096
1105
  // Cross-context handler
1097
- clearExpandedPanel: yt,
1106
+ clearExpandedPanel: xt,
1098
1107
  // Core state (element/artboard domain)
1099
1108
  artboardManager: t,
1100
1109
  artboards: d,
1101
- elements: f,
1102
- elementStore: y,
1103
- getElementById: x,
1110
+ elements: p,
1111
+ elementStore: x,
1112
+ getElementById: w,
1104
1113
  // Derived state (cross-context)
1105
- selectedElement: R,
1114
+ selectedElement: I,
1106
1115
  // Refs
1107
1116
  canvasRef: o,
1108
1117
  canvasEditorRef: n,
@@ -1112,41 +1121,41 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1112
1121
  artboardVersion: N,
1113
1122
  // Handlers
1114
1123
  refreshArtboards: M,
1115
- handleElementUpdate: j,
1116
- addElement: At,
1117
- handleAddElement: Nt,
1118
- handleLoadWorkspace: Ut,
1119
- handleCopyElements: Ot,
1120
- handlePasteElements: zt,
1121
- hasClipboardContent: I.length > 0,
1124
+ handleElementUpdate: it,
1125
+ addElement: yt,
1126
+ handleAddElement: Ot,
1127
+ handleLoadWorkspace: Ht,
1128
+ handleCopyElements: zt,
1129
+ handlePasteElements: Ut,
1130
+ hasClipboardContent: T.length > 0,
1122
1131
  // Command history (undo/redo actions + execute functions)
1123
- historyManager: nt,
1124
- executeElementUpdate: _,
1132
+ historyManager: ot,
1133
+ executeElementUpdate: $,
1125
1134
  executeAddElement: W,
1126
- executeRemoveElement: l,
1127
- executeReorderElement: p,
1128
- executeCommandBatch: w,
1135
+ executeRemoveElement: u,
1136
+ executeReorderElement: g,
1137
+ executeCommandBatch: b,
1129
1138
  executeCreateArtboard: A,
1130
- executeDeleteArtboard: C,
1139
+ executeDeleteArtboard: F,
1131
1140
  executeUpdateArtboard: Y,
1132
1141
  undo: z,
1133
- redo: $,
1142
+ redo: _,
1134
1143
  canUndo: U,
1135
1144
  canRedo: L,
1136
1145
  undoActiveArtboard: P,
1137
1146
  redoActiveArtboard: K,
1138
- canUndoActiveArtboard: rt,
1147
+ canUndoActiveArtboard: nt,
1139
1148
  canRedoActiveArtboard: Z,
1140
1149
  // Element properties
1141
- fontSize: Et,
1142
- fontColor: St,
1143
- fontFamily: Rt,
1144
- textAlign: It,
1145
- updateFontSize: Tt,
1146
- setFontSizeValue: Ct,
1147
- updateFontColor: Ft,
1148
- updateFontFamily: vt,
1149
- updateTextAlign: Pt
1150
+ fontSize: St,
1151
+ fontColor: Rt,
1152
+ fontFamily: It,
1153
+ textAlign: Tt,
1154
+ updateFontSize: Ct,
1155
+ setFontSizeValue: Ft,
1156
+ updateFontColor: vt,
1157
+ updateFontFamily: Pt,
1158
+ updateTextAlign: Nt
1150
1159
  }), [
1151
1160
  // Viewport
1152
1161
  a.zoom,
@@ -1182,46 +1191,45 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1182
1191
  c.setCanvasReady,
1183
1192
  c.isRotating,
1184
1193
  c.setIsRotating,
1185
- yt,
1194
+ xt,
1186
1195
  // Element/artboard domain
1187
1196
  t,
1188
1197
  d,
1189
- f,
1190
- y,
1198
+ p,
1191
1199
  x,
1192
- R,
1200
+ w,
1201
+ I,
1193
1202
  o,
1194
1203
  n,
1195
1204
  m,
1196
1205
  N,
1197
1206
  M,
1198
- j,
1199
- At,
1200
- Nt,
1201
- Ut,
1207
+ it,
1208
+ yt,
1202
1209
  Ot,
1210
+ Ht,
1203
1211
  zt,
1204
- I,
1212
+ Ut,
1213
+ T,
1205
1214
  // Command history
1206
- nt,
1207
- _,
1215
+ ot,
1216
+ $,
1208
1217
  W,
1209
- l,
1210
- p,
1211
- w,
1218
+ u,
1219
+ g,
1220
+ b,
1212
1221
  A,
1213
- C,
1222
+ F,
1214
1223
  Y,
1215
1224
  z,
1216
- $,
1225
+ _,
1217
1226
  U,
1218
1227
  L,
1219
1228
  P,
1220
1229
  K,
1221
- rt,
1230
+ nt,
1222
1231
  Z,
1223
1232
  // Element properties
1224
- Et,
1225
1233
  St,
1226
1234
  Rt,
1227
1235
  It,
@@ -1229,103 +1237,104 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1229
1237
  Ct,
1230
1238
  Ft,
1231
1239
  vt,
1232
- Pt
1240
+ Pt,
1241
+ Nt
1233
1242
  ]);
1234
- return i.current = Bt, /* @__PURE__ */ V(fe.Provider, { value: r, children: /* @__PURE__ */ V(
1235
- mo,
1243
+ return i.current = Mt, /* @__PURE__ */ V(pe.Provider, { value: r, children: /* @__PURE__ */ V(
1244
+ fo,
1236
1245
  {
1237
1246
  value: {
1238
1247
  undo: z,
1239
- redo: $,
1248
+ redo: _,
1240
1249
  canUndo: U,
1241
1250
  canRedo: L,
1242
1251
  undoActiveArtboard: P,
1243
1252
  redoActiveArtboard: K,
1244
- canUndoActiveArtboard: rt,
1253
+ canUndoActiveArtboard: nt,
1245
1254
  canRedoActiveArtboard: Z
1246
1255
  },
1247
1256
  children: /* @__PURE__ */ V(
1248
- go,
1257
+ Ao,
1249
1258
  {
1250
1259
  value: {
1251
- elements: f,
1252
- elementStore: y,
1260
+ elements: p,
1261
+ elementStore: x,
1253
1262
  artboards: d,
1254
1263
  artboardManager: t,
1255
1264
  artboardVersion: N,
1256
1265
  setElements: m,
1257
1266
  refreshArtboards: M,
1258
- getElementById: x,
1259
- handleAddElement: Nt,
1260
- handleElementUpdate: j,
1261
- handleLoadWorkspace: Ut,
1262
- handleCopyElements: Ot,
1263
- handlePasteElements: zt,
1264
- fontSize: Et,
1265
- fontColor: St,
1266
- fontFamily: Rt,
1267
- textAlign: It,
1268
- updateFontSize: Tt,
1269
- setFontSizeValue: Ct,
1270
- updateFontColor: Ft,
1271
- updateFontFamily: vt,
1272
- updateTextAlign: Pt,
1267
+ getElementById: w,
1268
+ handleAddElement: Ot,
1269
+ handleElementUpdate: it,
1270
+ handleLoadWorkspace: Ht,
1271
+ handleCopyElements: zt,
1272
+ handlePasteElements: Ut,
1273
+ fontSize: St,
1274
+ fontColor: Rt,
1275
+ fontFamily: It,
1276
+ textAlign: Tt,
1277
+ updateFontSize: Ct,
1278
+ setFontSizeValue: Ft,
1279
+ updateFontColor: vt,
1280
+ updateFontFamily: Pt,
1281
+ updateTextAlign: Nt,
1273
1282
  canvasRef: o,
1274
1283
  canvasEditorRef: n
1275
1284
  },
1276
1285
  children: /* @__PURE__ */ V(
1277
- Ao,
1286
+ yo,
1278
1287
  {
1279
1288
  value: {
1280
- executeElementUpdate: _,
1289
+ executeElementUpdate: $,
1281
1290
  executeAddElement: W,
1282
- executeRemoveElement: l,
1283
- executeReorderElement: p,
1284
- executeCommandBatch: w,
1291
+ executeRemoveElement: u,
1292
+ executeReorderElement: g,
1293
+ executeCommandBatch: b,
1285
1294
  executeCreateArtboard: A,
1286
- executeDeleteArtboard: C,
1295
+ executeDeleteArtboard: F,
1287
1296
  executeUpdateArtboard: Y,
1288
1297
  undo: z,
1289
- redo: $,
1298
+ redo: _,
1290
1299
  canUndo: U,
1291
1300
  canRedo: L,
1292
1301
  undoActiveArtboard: P,
1293
1302
  redoActiveArtboard: K,
1294
- canUndoActiveArtboard: rt,
1303
+ canUndoActiveArtboard: nt,
1295
1304
  canRedoActiveArtboard: Z,
1296
- historyManager: nt
1305
+ historyManager: ot
1297
1306
  },
1298
- children: /* @__PURE__ */ V(me.Provider, { value: Bt, children: e })
1307
+ children: /* @__PURE__ */ V(fe.Provider, { value: Mt, children: e })
1299
1308
  }
1300
1309
  )
1301
1310
  }
1302
1311
  )
1303
1312
  }
1304
1313
  ) });
1305
- }, Mo = ({
1314
+ }, Wo = ({
1306
1315
  children: e,
1307
1316
  initialArtboardConfig: t = {},
1308
1317
  viewPadding: o = 0.9
1309
1318
  }) => {
1310
- const [n] = E(() => {
1311
- const a = new ke(), s = {
1319
+ const [n] = S(() => {
1320
+ const a = new De(), s = {
1312
1321
  name: t.name || "Artboard 1",
1313
1322
  x: t.x ?? 0,
1314
1323
  y: t.y ?? 0,
1315
1324
  width: t.width ?? 1e3,
1316
1325
  height: t.height ?? 1e3,
1317
- backgroundColor: t.backgroundColor || He
1326
+ backgroundColor: t.backgroundColor || ke
1318
1327
  };
1319
1328
  return a.createArtboard(s), a;
1320
- }), i = gt(null), r = gt(null);
1329
+ }), i = At(null), r = At(null);
1321
1330
  return /* @__PURE__ */ V(
1322
- co,
1331
+ lo,
1323
1332
  {
1324
1333
  artboardManager: n,
1325
1334
  canvasRef: i,
1326
1335
  viewPadding: o,
1327
- children: /* @__PURE__ */ V(uo, { children: /* @__PURE__ */ V(fo, { children: /* @__PURE__ */ V(
1328
- xo,
1336
+ children: /* @__PURE__ */ V(ho, { children: /* @__PURE__ */ V(po, { children: /* @__PURE__ */ V(
1337
+ wo,
1329
1338
  {
1330
1339
  artboardManager: n,
1331
1340
  canvasRef: i,
@@ -1335,24 +1344,24 @@ const yo = Qt("EditorContext"), me = Q(null), fe = Q(null), Bo = () => {
1335
1344
  ) }) })
1336
1345
  }
1337
1346
  );
1338
- }, Wo = () => {
1339
- const e = G(me);
1347
+ }, Yo = () => {
1348
+ const e = G(fe);
1340
1349
  if (!e)
1341
1350
  throw new Error("useEditor must be used within EditorProvider");
1342
1351
  return e;
1343
1352
  }, ut = [];
1344
- function Yo(e) {
1345
- $e() && ut.push(e);
1353
+ function Xo(e) {
1354
+ Be() && ut.push(e);
1346
1355
  }
1347
- function Xo() {
1356
+ function Go() {
1348
1357
  return [...ut];
1349
1358
  }
1350
- function Go() {
1359
+ function Ko() {
1351
1360
  ut.length = 0;
1352
1361
  }
1353
- function Ko() {
1362
+ function Zo() {
1354
1363
  if (ut.length === 0) return;
1355
- const e = ut.map((t) => _e(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
1364
+ const e = ut.map((t) => $e(t) ? `${t.code}: ${t.message}` : `${t.name}: ${t.message}`).join(`
1356
1365
  - `);
1357
1366
  throw ut.length = 0, new Error(
1358
1367
  `expectNoEditorErrors: ${e.includes(`
@@ -1361,36 +1370,36 @@ function Ko() {
1361
1370
  A contained error renders an error card in prod — this composition is broken even if the test rendered "successfully".`
1362
1371
  );
1363
1372
  }
1364
- const wo = 1;
1365
- function it(e) {
1373
+ const bo = 1;
1374
+ function rt(e) {
1366
1375
  return typeof e == "number" && Number.isFinite(e) ? Math.round(e * 100) / 100 : e;
1367
1376
  }
1368
- function pe(e) {
1377
+ function ge(e) {
1369
1378
  return {
1370
1379
  ...e,
1371
- ...e.x !== void 0 && { x: it(e.x) },
1372
- ...e.y !== void 0 && { y: it(e.y) },
1373
- ...e.width !== void 0 && { width: it(e.width) },
1374
- ...e.height !== void 0 && { height: it(e.height) },
1375
- ...e.rotation !== void 0 && { rotation: it(e.rotation) }
1380
+ ...e.x !== void 0 && { x: rt(e.x) },
1381
+ ...e.y !== void 0 && { y: rt(e.y) },
1382
+ ...e.width !== void 0 && { width: rt(e.width) },
1383
+ ...e.height !== void 0 && { height: rt(e.height) },
1384
+ ...e.rotation !== void 0 && { rotation: rt(e.rotation) }
1376
1385
  };
1377
1386
  }
1378
- function bo(e) {
1387
+ function Eo(e) {
1379
1388
  var n, i;
1380
1389
  const t = (n = e.artboards) != null && n.length ? e.artboards : [{ name: "Front", width: 800, height: 800 }], o = t.map(() => []);
1381
1390
  for (const r of e.elements || []) {
1382
1391
  const a = r == null ? void 0 : r.artboard, s = typeof a == "string" ? t.findIndex((c) => (c.name || "Front") === a) : -1;
1383
- (r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(ge(r));
1392
+ (r == null ? void 0 : r.visible) !== !1 && o[s >= 0 ? s : 0].push(Ae(r));
1384
1393
  }
1385
1394
  return {
1386
- schemaVersion: wo,
1395
+ schemaVersion: bo,
1387
1396
  artboards: t.map((r, a) => ({
1388
1397
  id: `artboard-${a + 1}`,
1389
1398
  name: r.name || "Front",
1390
1399
  x: 0,
1391
1400
  y: 0,
1392
- width: it(r.width || 800),
1393
- height: it(r.height || 800),
1401
+ width: rt(r.width || 800),
1402
+ height: rt(r.height || 800),
1394
1403
  backgroundColor: r.backgroundColor || "transparent",
1395
1404
  // Pass the artboard's flag through — the server worker only paints the
1396
1405
  // background when this is true. Hardcoding `false` here silently dropped
@@ -1407,19 +1416,19 @@ function bo(e) {
1407
1416
  ...(i = e.customFonts) != null && i.length ? { customFonts: e.customFonts } : {}
1408
1417
  };
1409
1418
  }
1410
- function ge(e) {
1419
+ function Ae(e) {
1411
1420
  const t = e.type || e.transformType;
1412
1421
  if (t === "image")
1413
- return Eo(e);
1422
+ return So(e);
1414
1423
  const { artboard: o, ...n } = e;
1415
- return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(ge)), pe({
1424
+ return t === "group" && Array.isArray(e.children) && (n.children = e.children.filter((i) => i && i.visible !== !1).map(Ae)), ge({
1416
1425
  ...n,
1417
1426
  type: t
1418
1427
  });
1419
1428
  }
1420
- function Eo(e) {
1429
+ function So(e) {
1421
1430
  var d;
1422
- const t = e.transformData || {}, o = Be(e), n = Me(t, o), i = t.width || 0, r = t.height || 0, a = i * n.cropWidth, s = r * n.cropHeight, c = {
1431
+ const t = e.transformData || {}, o = Me(e), n = We(t, o), i = t.width || 0, r = t.height || 0, a = i * n.cropWidth, s = r * n.cropHeight, c = {
1423
1432
  id: e.id,
1424
1433
  type: "image",
1425
1434
  x: e.x || 0,
@@ -1430,44 +1439,44 @@ function Eo(e) {
1430
1439
  imageUrl: e.imageUrl,
1431
1440
  imageAspectRatio: e.imageAspectRatio
1432
1441
  };
1433
- return We(n) || (c.cropX = n.cropX, c.cropY = n.cropY, c.cropWidth = n.cropWidth, c.cropHeight = n.cropHeight, c.needsCropPixelConversion = !0), t.flipHorizontal && (c.flipHorizontal = t.flipHorizontal), t.flipVertical && (c.flipVertical = t.flipVertical), t.borderRadius && (c.borderRadius = t.borderRadius), e.shadow && (c.shadow = e.shadow), Ye(t.adjustments) || (c.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (c.opacity = e.opacity), e.distressEffect && (c.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (c.masks = e.masks), e.blendMode && (c.blendMode = e.blendMode), e.knockoutParts && (c.knockoutParts = e.knockoutParts), e.stroke && (c.stroke = e.stroke), pe(c);
1442
+ return Ye(n) || (c.cropX = n.cropX, c.cropY = n.cropY, c.cropWidth = n.cropWidth, c.cropHeight = n.cropHeight, c.needsCropPixelConversion = !0), t.flipHorizontal && (c.flipHorizontal = t.flipHorizontal), t.flipVertical && (c.flipVertical = t.flipVertical), t.borderRadius && (c.borderRadius = t.borderRadius), e.shadow && (c.shadow = e.shadow), Xe(t.adjustments) || (c.adjustments = { ...t.adjustments }), e.opacity !== void 0 && (c.opacity = e.opacity), e.distressEffect && (c.distressEffect = e.distressEffect), ((d = e.masks) == null ? void 0 : d.length) > 0 && (c.masks = e.masks), e.blendMode && (c.blendMode = e.blendMode), e.knockoutParts && (c.knockoutParts = e.knockoutParts), e.stroke && (c.stroke = e.stroke), ge(c);
1434
1443
  }
1435
- const Jt = "center", Ae = Symbol.for("snowcone.canvas.layerToken");
1436
- function Zo(e) {
1437
- return typeof e == "object" && e !== null && e[Ae] === !0 && typeof e.name == "string" && (e.kind === "text" || e.kind === "image");
1444
+ const qt = "center", ye = Symbol.for("snowcone.canvas.layerToken");
1445
+ function jo(e) {
1446
+ return typeof e == "object" && e !== null && e[ye] === !0 && typeof e.name == "string" && (e.kind === "text" || e.kind === "image");
1438
1447
  }
1439
- function So(e, t) {
1440
- return Object.freeze({ kind: e, name: t, [Ae]: !0 });
1448
+ function Ro(e, t) {
1449
+ return Object.freeze({ kind: e, name: t, [ye]: !0 });
1441
1450
  }
1442
- const ye = Symbol.for("snowcone.canvas.colorToken");
1443
- function Ro(e) {
1444
- return typeof e == "object" && e !== null && e[ye] === !0 && typeof e.name == "string" && typeof e.value == "string";
1451
+ const xe = Symbol.for("snowcone.canvas.colorToken");
1452
+ function Io(e) {
1453
+ return typeof e == "object" && e !== null && e[xe] === !0 && typeof e.name == "string" && typeof e.value == "string";
1445
1454
  }
1446
- function Io(e, t) {
1447
- return Object.freeze({ name: e, value: t, [ye]: !0 });
1455
+ function To(e, t) {
1456
+ return Object.freeze({ name: e, value: t, [xe]: !0 });
1448
1457
  }
1449
- function To(e) {
1458
+ function Co(e) {
1450
1459
  let t = e.trim().toUpperCase();
1451
1460
  return /^#[0-9A-F]{3}$/.test(t) && (t = "#" + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), /^#[0-9A-F]{6}$/.test(t) ? t : null;
1452
1461
  }
1453
- function bt(e) {
1454
- return Ro(e) ? e.value : e;
1462
+ function Et(e) {
1463
+ return Io(e) ? e.value : e;
1455
1464
  }
1456
- function _t(e) {
1465
+ function $t(e) {
1457
1466
  const t = e.transformType;
1458
1467
  return t === "image" ? "image" : t === "shape" || t === "group" || t === "path" ? null : "text";
1459
1468
  }
1460
- function Co(e) {
1469
+ function Fo(e) {
1461
1470
  return e === "top-left" || e === "left" || e === "bottom-left" ? "left" : e === "top-right" || e === "right" || e === "bottom-right" ? "right" : "center";
1462
1471
  }
1463
- function Fo(e) {
1472
+ function vo(e) {
1464
1473
  return e === "top-left" || e === "top" || e === "top-right" ? "top" : e === "bottom-left" || e === "bottom" || e === "bottom-right" ? "bottom" : "middle";
1465
1474
  }
1466
- function Lt(e, t, o, n, i, r) {
1467
- const a = Co(e), s = Fo(e), c = a === "left" ? t / 2 + r : a === "right" ? n - t / 2 - r : n / 2, d = s === "top" ? o / 2 + r : s === "bottom" ? i - o / 2 - r : i / 2;
1475
+ function Vt(e, t, o, n, i, r) {
1476
+ const a = Fo(e), s = vo(e), c = a === "left" ? t / 2 + r : a === "right" ? n - t / 2 - r : n / 2, d = s === "top" ? o / 2 + r : s === "bottom" ? i - o / 2 - r : i / 2;
1468
1477
  return { x: c, y: d };
1469
1478
  }
1470
- function vo(e, t, o) {
1479
+ function Po(e, t, o) {
1471
1480
  const n = t / o;
1472
1481
  if (e >= n) {
1473
1482
  const a = o * e, s = t / a;
@@ -1495,16 +1504,16 @@ class lt {
1495
1504
  if (this.els = [], this.colorRoles = /* @__PURE__ */ new Map(), this.idCounter = 0, !(t.width > 0) || !(t.height > 0))
1496
1505
  throw new Error("design(): artboard width and height must be positive numbers");
1497
1506
  for (const [o, n] of Object.entries(t.colors ?? {})) {
1498
- const i = To(n);
1507
+ const i = Co(n);
1499
1508
  if (i === null)
1500
- throw new ot(
1509
+ throw new et(
1501
1510
  "E_COLOR_ROLE_INVALID",
1502
1511
  `color role "${o}" is ${JSON.stringify(n)} — roles must be #RGB/#RRGGBB hex (useColorBinding matches by normalized hex value; other syntaxes can't bind).`,
1503
1512
  { roleName: o, value: n, docSlug: "embed-mode" }
1504
1513
  );
1505
1514
  const r = [...this.colorRoles.entries()].find(([, a]) => a === i);
1506
1515
  if (r)
1507
- throw new ot(
1516
+ throw new et(
1508
1517
  "E_COLOR_ROLE_COLLISION",
1509
1518
  `color roles "${r[0]}" and "${o}" both normalize to ${i}. useColorBinding matches elements by VALUE, so colliding roles would repaint each other's elements — give every role a distinct hex.`,
1510
1519
  { roles: [r[0], o], value: i, docSlug: "embed-mode" }
@@ -1515,7 +1524,7 @@ class lt {
1515
1524
  name: t.name || "Front",
1516
1525
  width: t.width,
1517
1526
  height: t.height,
1518
- backgroundColor: bt(t.backgroundColor),
1527
+ backgroundColor: Et(t.backgroundColor),
1519
1528
  role: t.role
1520
1529
  }, this.activeName = this.current.name;
1521
1530
  }
@@ -1598,7 +1607,7 @@ class lt {
1598
1607
  if (!(o.width > 0) || !(o.height > 0))
1599
1608
  throw new Error("design().artboard(): width and height must be positive numbers");
1600
1609
  if (this.allArtboards || (this.allArtboards = [lt.snapshotArtboard(this.current)]), this.allArtboards.some((n) => n.name === t))
1601
- throw new ot(
1610
+ throw new et(
1602
1611
  "E_DUPLICATE_ARTBOARD",
1603
1612
  `the design already has an artboard "${t}" — artboard names are placement labels and must be unique. Existing: ${JSON.stringify(this.allArtboards.map((n) => n.name))}.`,
1604
1613
  { artboardName: t, validNames: this.allArtboards.map((n) => n.name), docSlug: "embed-mode" }
@@ -1609,7 +1618,7 @@ class lt {
1609
1618
  name: t,
1610
1619
  width: o.width,
1611
1620
  height: o.height,
1612
- backgroundColor: bt(o.backgroundColor),
1621
+ backgroundColor: Et(o.backgroundColor),
1613
1622
  role: o.role
1614
1623
  }, this.allArtboards.push(lt.snapshotArtboard(this.current)), this;
1615
1624
  }
@@ -1617,7 +1626,7 @@ class lt {
1617
1626
  const { width: n, height: i } = this.current;
1618
1627
  let r;
1619
1628
  if (o.aspectRatio && o.aspectRatio > 0) {
1620
- const s = vo(o.aspectRatio, n, i);
1629
+ const s = Po(o.aspectRatio, n, i);
1621
1630
  r = {
1622
1631
  type: "image",
1623
1632
  width: s.width,
@@ -1658,7 +1667,7 @@ class lt {
1658
1667
  return this.els.unshift(a), this;
1659
1668
  }
1660
1669
  image(t, o = {}) {
1661
- const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } = Lt(o.anchor ?? Jt, r, a, n, i, o.padding ?? 0), d = {
1670
+ const { width: n, height: i } = this.current, r = o.width ?? Math.round(n / 3), a = o.height ?? (o.aspectRatio ? Math.round(r / o.aspectRatio) : r), { x: s, y: c } = Vt(o.anchor ?? qt, r, a, n, i, o.padding ?? 0), d = {
1662
1671
  id: this.nextId("img"),
1663
1672
  transformType: "image",
1664
1673
  x: s,
@@ -1684,7 +1693,7 @@ class lt {
1684
1693
  return this.els.push(d), this;
1685
1694
  }
1686
1695
  text(t, o = {}) {
1687
- const { width: n, height: i } = this.current, r = o.fontSize ?? Math.round(this.current.height / 12), { x: a, y: s } = Lt(o.anchor ?? "top", 0, r, n, i, o.padding ?? Math.round(i / 20)), c = {
1696
+ const { width: n, height: i } = this.current, r = o.fontSize ?? Math.round(this.current.height / 12), { x: a, y: s } = Vt(o.anchor ?? "top", 0, r, n, i, o.padding ?? Math.round(i / 20)), c = {
1688
1697
  id: this.nextId("text"),
1689
1698
  transformType: "custom",
1690
1699
  x: a,
@@ -1693,7 +1702,7 @@ class lt {
1693
1702
  text: t,
1694
1703
  fontSize: r,
1695
1704
  fontFamily: o.fontFamily ?? "Anton",
1696
- color: bt(o.color) ?? "#ffffff",
1705
+ color: Et(o.color) ?? "#ffffff",
1697
1706
  textAlign: o.textAlign ?? "center",
1698
1707
  bold: o.bold ?? !1,
1699
1708
  italic: o.italic ?? !1,
@@ -1719,20 +1728,20 @@ class lt {
1719
1728
  const o = this.els.find((i) => i.name === t);
1720
1729
  if (!o) {
1721
1730
  const i = this.layerNamesOfKind("text"), r = this.layerNamesOfKind("image");
1722
- throw new ot(
1731
+ throw new et(
1723
1732
  "E_LAYER_NOT_FOUND",
1724
1733
  `no layer "${t}" in this design. Text layers: ${JSON.stringify(i)}; image layers: ${JSON.stringify(r)}. Fix the name, or add the layer first — e.g. design(…).text('…', { name: '${t}' }).`,
1725
1734
  { layerName: t, validNames: [...i, ...r], textNames: i, imageNames: r, docSlug: "embed-mode" }
1726
1735
  );
1727
1736
  }
1728
- const n = _t(o);
1737
+ const n = $t(o);
1729
1738
  if (!n)
1730
- throw new ot(
1739
+ throw new et(
1731
1740
  "E_LAYER_WRONG_KIND",
1732
1741
  `layer "${t}" is a ${o.transformType} element — only text and image layers are bindable. Bindable layers: ${JSON.stringify([...this.layerNamesOfKind("text"), ...this.layerNamesOfKind("image")])}.`,
1733
1742
  { layerName: t, actualType: o.transformType, docSlug: "embed-mode" }
1734
1743
  );
1735
- return So(n, t);
1744
+ return Ro(n, t);
1736
1745
  }
1737
1746
  /**
1738
1747
  * Mint a {@link ColorToken} for a declared color role. Compile time: `name`
@@ -1750,25 +1759,25 @@ class lt {
1750
1759
  color(t) {
1751
1760
  const o = this.colorRoles.get(t);
1752
1761
  if (o === void 0)
1753
- throw new ot(
1762
+ throw new et(
1754
1763
  "E_COLOR_ROLE_NOT_FOUND",
1755
1764
  `no color role "${t}" in this design. Declared roles: ${JSON.stringify([...this.colorRoles.keys()])}. Declare roles up front — design({ …, colors: { ${t}: '#FF2D8A' } }).`,
1756
1765
  { roleName: t, validNames: [...this.colorRoles.keys()], docSlug: "embed-mode" }
1757
1766
  );
1758
- return Io(t, o);
1767
+ return To(t, o);
1759
1768
  }
1760
1769
  /** Names of bindable layers of one kind, in stack order. @internal */
1761
1770
  layerNamesOfKind(t) {
1762
- return this.els.filter((o) => _t(o) === t).map((o) => o.name).filter((o) => !!o);
1771
+ return this.els.filter((o) => $t(o) === t).map((o) => o.name).filter((o) => !!o);
1763
1772
  }
1764
1773
  /** An anchored vector shape. */
1765
1774
  shape(t, o = {}) {
1766
- const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } = Lt(o.anchor ?? Jt, a, s, n, i, o.padding ?? 0), S = {
1775
+ const { width: n, height: i } = this.current, r = o.size ?? Math.round(n / 6), a = typeof r == "number" ? r : r.width, s = typeof r == "number" ? r : r.height, { x: c, y: d } = Vt(o.anchor ?? qt, a, s, n, i, o.padding ?? 0), R = {
1767
1776
  type: "shape",
1768
1777
  shapeType: t,
1769
1778
  width: a,
1770
1779
  height: s,
1771
- fillColor: bt(o.fill) ?? "#000000",
1780
+ fillColor: Et(o.fill) ?? "#000000",
1772
1781
  fillOpacity: o.opacity ?? 1,
1773
1782
  ...o.points !== void 0 ? { points: o.points } : {},
1774
1783
  ...o.sides !== void 0 ? { sides: o.sides } : {}
@@ -1778,7 +1787,7 @@ class lt {
1778
1787
  x: c,
1779
1788
  y: d,
1780
1789
  rotation: o.rotation ?? 0,
1781
- transformData: S,
1790
+ transformData: R,
1782
1791
  ...o.name ? { name: o.name } : {}
1783
1792
  };
1784
1793
  return this.els.push(N), this;
@@ -1815,47 +1824,47 @@ class lt {
1815
1824
  /** Server-render payload for `RenderSession.renderState(placement, …)`.
1816
1825
  * Equivalent to `serializeStateForServer(design.toJSON())`. */
1817
1826
  toServerRequest() {
1818
- return bo(this.toJSON());
1827
+ return Eo(this.toJSON());
1819
1828
  }
1820
1829
  }
1821
- function jo(e) {
1830
+ function Jo(e) {
1822
1831
  return new lt(e);
1823
1832
  }
1824
- function Jo(e) {
1825
- return _t(e);
1833
+ function qo(e) {
1834
+ return $t(e);
1826
1835
  }
1827
1836
  export {
1828
- ko as A,
1829
- oe as B,
1830
- wo as C,
1837
+ Do as A,
1838
+ ne as B,
1839
+ bo as C,
1831
1840
  lt as D,
1832
- Mo as E,
1833
- ne as P,
1834
- $o as a,
1835
- Wo as b,
1836
- ho as c,
1837
- se as d,
1838
- lo as e,
1839
- jo as f,
1840
- Ko as g,
1841
- Xo as h,
1842
- Lo as i,
1843
- Do as j,
1844
- Jo as k,
1845
- ie as l,
1846
- Zo as m,
1847
- Ro as n,
1848
- Ho as o,
1849
- io as p,
1850
- Ze as q,
1851
- Go as r,
1852
- bo as s,
1853
- Vo as t,
1854
- _o as u,
1855
- po as v,
1856
- Yo as w,
1857
- Uo as x,
1858
- Bo as y,
1859
- je as z
1841
+ Wo as E,
1842
+ re as P,
1843
+ Bo as a,
1844
+ Yo as b,
1845
+ mo as c,
1846
+ ae as d,
1847
+ uo as e,
1848
+ Jo as f,
1849
+ Zo as g,
1850
+ Go as h,
1851
+ Vo as i,
1852
+ Lo as j,
1853
+ qo as k,
1854
+ se as l,
1855
+ jo as m,
1856
+ Io as n,
1857
+ ko as o,
1858
+ so as p,
1859
+ je as q,
1860
+ Ko as r,
1861
+ Eo as s,
1862
+ _o as t,
1863
+ $o as u,
1864
+ go as v,
1865
+ Xo as w,
1866
+ Ho as x,
1867
+ Mo as y,
1868
+ Je as z
1860
1869
  };
1861
- //# sourceMappingURL=design-builder-DCHVrEFV.js.map
1870
+ //# sourceMappingURL=design-builder-sH53Og6j.js.map