@snowcone-app/canvas 0.17.2 → 0.17.3

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.
@@ -1,20 +1,20 @@
1
- import { y as V, c as G, al as Pe, I as De } from "./FontAnalyzer-CLv7_msL.js";
2
- import { jsxs as X, jsx as E, Fragment as Ae } from "react/jsx-runtime";
3
- import { useMemo as ke, useRef as F, useEffect as C, Component as We, useState as Z, useCallback as H, useImperativeHandle as $e, forwardRef as Re } from "react";
4
- import { ag as be, ah as ve, a6 as He, L as Ue, t as ze, u as Ke, I as Oe, G as Xe, h as Ye, o as je, a1 as Ve, J as Ee, p as Ge, a7 as xe, a3 as Qe, i as Je, q as qe, r as Ze, v as _e, U as et, z as tt, l as rt } from "./validation-C795COGQ.js";
5
- import { a as nt } from "./template-fields-Z9x13sjM.js";
6
- import { E as at, u as ee } from "./EditorContext-CGkfmbgo.js";
7
- import { T as ye } from "./ThemeContext-Rjz25x9X.js";
8
- import { C as ot, u as ue, f as st } from "./UnifiedFontService-Dsu5cwfT.js";
1
+ import { y as G, c as Q, al as We, I as $e } from "./FontAnalyzer-CLv7_msL.js";
2
+ import { jsxs as X, jsx as E, Fragment as ke } from "react/jsx-runtime";
3
+ import { useMemo as Ie, useRef as F, useEffect as C, Component as He, useState as Z, useCallback as z, useImperativeHandle as Ue, forwardRef as Re } from "react";
4
+ import { ag as ve, ah as Ee, a6 as ze, L as Oe, t as Ke, u as Xe, I as je, G as Ye, h as Ve, o as Ge, a1 as Qe, J as xe, p as Je, a7 as ye, a3 as qe, i as Ze, q as _e, r as et, v as tt, U as rt, z as nt, l as at } from "./validation-C795COGQ.js";
5
+ import { a as ot } from "./template-fields-Z9x13sjM.js";
6
+ import { E as st, u as ee } from "./EditorContext-CGkfmbgo.js";
7
+ import { T as we } from "./ThemeContext-Rjz25x9X.js";
8
+ import { C as it, u as ue, f as ct } from "./UnifiedFontService-Dsu5cwfT.js";
9
9
  import { C as ce } from "./ImportManager-C_wBjWaV.js";
10
- import { C as it } from "./ElementFactory-CuHSAPfg.js";
11
- const ct = () => {
12
- const { undo: n, redo: e, canUndo: t, canRedo: a } = nt();
10
+ import { C as lt } from "./ElementFactory-CuHSAPfg.js";
11
+ const dt = () => {
12
+ const { undo: n, redo: e, canUndo: t, canRedo: a } = ot();
13
13
  return /* @__PURE__ */ X("div", { className: "sc-undo-redo", style: { display: "inline-flex", gap: 4 }, children: [
14
14
  /* @__PURE__ */ E(
15
- be,
15
+ ve,
16
16
  {
17
- icon: ve.undo,
17
+ icon: Ee.undo,
18
18
  onClick: n,
19
19
  disabled: !t,
20
20
  tooltip: "Undo",
@@ -22,9 +22,9 @@ const ct = () => {
22
22
  }
23
23
  ),
24
24
  /* @__PURE__ */ E(
25
- be,
25
+ ve,
26
26
  {
27
- icon: ve.redo,
27
+ icon: Ee.redo,
28
28
  onClick: e,
29
29
  disabled: !a,
30
30
  tooltip: "Redo",
@@ -32,59 +32,59 @@ const ct = () => {
32
32
  }
33
33
  )
34
34
  ] });
35
- }, Ie = G("KitLayout"), q = "canvas", le = 320;
36
- let we = !1;
37
- function lt() {
38
- we || (we = !0, He({
39
- LayersPanel: Ue,
40
- EffectsPanel: ze,
41
- ExportPanel: Ke,
42
- ImagePanel: Oe,
43
- GlyphPanel: Xe,
44
- ArtboardTabs: Ye,
45
- ContextualToolbars: je,
46
- ZoomControls: Ve,
47
- MenuButton: Ee,
48
- CropPanel: Ge
49
- }), xe("add-element-menu", {
50
- component: Ee,
35
+ }, Ce = Q("KitLayout"), q = "canvas", le = 320;
36
+ let Se = !1;
37
+ function ut() {
38
+ Se || (Se = !0, ze({
39
+ LayersPanel: Oe,
40
+ EffectsPanel: Ke,
41
+ ExportPanel: Xe,
42
+ ImagePanel: je,
43
+ GlyphPanel: Ye,
44
+ ArtboardTabs: Ve,
45
+ ContextualToolbars: Ge,
46
+ ZoomControls: Qe,
47
+ MenuButton: xe,
48
+ CropPanel: Je
49
+ }), ye("add-element-menu", {
50
+ component: xe,
51
51
  label: "Add Element",
52
52
  icon: "gravity-ui:plus",
53
53
  position: "topbar"
54
- }), xe("undo-redo-controls", {
55
- component: ct,
54
+ }), ye("undo-redo-controls", {
55
+ component: dt,
56
56
  label: "Undo / Redo",
57
57
  icon: "lucide:undo-2",
58
58
  position: "topbar"
59
59
  }));
60
60
  }
61
61
  function re({ ids: n }) {
62
- return !n || n.length === 0 ? null : /* @__PURE__ */ E(Ae, { children: n.map((e) => {
62
+ return !n || n.length === 0 ? null : /* @__PURE__ */ E(ke, { children: n.map((e) => {
63
63
  var r;
64
64
  if (e === q) return null;
65
- const t = Qe(e);
65
+ const t = qe(e);
66
66
  if (!t)
67
- return typeof V < "u" && ((r = V.env) == null ? void 0 : r.NODE_ENV) === "development" && Ie.warn(
67
+ return typeof G < "u" && ((r = G.env) == null ? void 0 : r.NODE_ENV) === "development" && Ce.warn(
68
68
  `Kit layout references unknown section "${e}" — skipping. Register it with registerSection("${e}", { ... }).`
69
69
  ), null;
70
70
  const a = t.component;
71
71
  return /* @__PURE__ */ E(a, {}, e);
72
72
  }) });
73
73
  }
74
- function dt({ kit: n, canvas: e }) {
74
+ function ft({ kit: n, canvas: e }) {
75
75
  var p, l, g, w;
76
- lt();
77
- const t = n.layout.slots, a = !!((p = t.topbar) != null && p.some((m) => m !== q)), r = !!((l = t.left) != null && l.some((m) => m !== q)), s = !!((g = t.right) != null && g.some((m) => m !== q)), c = !!((w = t.bottombar) != null && w.some((m) => m !== q)), d = ke(
76
+ ut();
77
+ const t = n.layout.slots, a = !!((p = t.topbar) != null && p.some((m) => m !== q)), r = !!((l = t.left) != null && l.some((m) => m !== q)), s = !!((g = t.right) != null && g.some((m) => m !== q)), c = !!((w = t.bottombar) != null && w.some((m) => m !== q)), d = Ie(
78
78
  () => !a && !r && !s && !c,
79
79
  [a, r, s, c]
80
80
  ), o = F(null), f = a || r || s || c, h = F(!1);
81
81
  return C(() => {
82
82
  var i;
83
- if (typeof V > "u" || ((i = V.env) == null ? void 0 : i.NODE_ENV) !== "development" || !f) return;
83
+ if (typeof G > "u" || ((i = G.env) == null ? void 0 : i.NODE_ENV) !== "development" || !f) return;
84
84
  const m = o.current;
85
85
  if (!m || typeof ResizeObserver > "u") return;
86
86
  const A = (u) => {
87
- u > 0 && u < le && !h.current ? (h.current = !0, Ie.warn(
87
+ u > 0 && u < le && !h.current ? (h.current = !0, Ce.warn(
88
88
  `Kit "${n.name}" declares chrome (toolbar / panels) but its container is only ${Math.round(u)}px wide — below the ~${le}px needed to render it, so the toolbar / panels are suppressed and the editor looks like a bare canvas. Give the editor more container width, or pass kit="embed-only" if a chrome-less canvas is intended.`
89
89
  )) : u >= le && (h.current = !1);
90
90
  };
@@ -93,7 +93,7 @@ function dt({ kit: n, canvas: e }) {
93
93
  for (const x of u) A(x.contentRect.width);
94
94
  });
95
95
  return v.observe(m), () => v.disconnect();
96
- }, [f, n.name]), d ? /* @__PURE__ */ E(Ae, { children: e }) : /* @__PURE__ */ X("div", { ref: o, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
96
+ }, [f, n.name]), d ? /* @__PURE__ */ E(ke, { children: e }) : /* @__PURE__ */ X("div", { ref: o, className: "sc-kit-layout", style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0 }, children: [
97
97
  a && /* @__PURE__ */ E(
98
98
  "div",
99
99
  {
@@ -117,8 +117,8 @@ function dt({ kit: n, canvas: e }) {
117
117
  )
118
118
  ] });
119
119
  }
120
- const ut = G("ErrorBoundary");
121
- class ft extends We {
120
+ const mt = Q("ErrorBoundary");
121
+ class ht extends He {
122
122
  constructor(e) {
123
123
  super(e), this.resetError = () => {
124
124
  this.setState({
@@ -137,7 +137,7 @@ class ft extends We {
137
137
  };
138
138
  }
139
139
  componentDidCatch(e, t) {
140
- if (ut.error("Caught error:", e, t), this.props.onError && this.props.onError(e, t), this.props.onCanvasError) {
140
+ if (mt.error("Caught error:", e, t), this.props.onError && this.props.onError(e, t), this.props.onCanvasError) {
141
141
  const a = {
142
142
  category: "unknown",
143
143
  message: e.message,
@@ -198,18 +198,18 @@ class ft extends We {
198
198
  ) : this.props.children;
199
199
  }
200
200
  }
201
- function mt({
201
+ function gt({
202
202
  inheritTheme: n,
203
203
  externalProvider: e,
204
204
  services: t,
205
205
  viewPadding: a,
206
206
  children: r
207
207
  }) {
208
- const s = e ? /* @__PURE__ */ E(ye, { defaultTheme: "light", passive: n, children: r }) : /* @__PURE__ */ E(ye, { defaultTheme: "light", passive: n, children: /* @__PURE__ */ E(at, { viewPadding: a, children: r }) });
209
- return t ? /* @__PURE__ */ E(ot, { services: t, children: s }) : s;
208
+ const s = e ? /* @__PURE__ */ E(we, { defaultTheme: "light", passive: n, children: r }) : /* @__PURE__ */ E(we, { defaultTheme: "light", passive: n, children: /* @__PURE__ */ E(st, { viewPadding: a, children: r }) });
209
+ return t ? /* @__PURE__ */ E(it, { services: t, children: s }) : s;
210
210
  }
211
- const ht = G("useAutoExport");
212
- function gt(n) {
211
+ const pt = Q("useAutoExport");
212
+ function bt(n) {
213
213
  const { config: e, historyManager: t, artboards: a, elements: r, onExport: s, onExportScheduled: c, isCanvasReady: d = !1 } = n, o = F(null), f = F(!1), h = F({
214
214
  totalExports: 0,
215
215
  skippedExports: 0,
@@ -217,15 +217,15 @@ function gt(n) {
217
217
  avgExportInterval: 0
218
218
  }), [p, l] = Z(h.current), g = F(s);
219
219
  g.current = s, C(() => {
220
- const i = new Je({
221
- ...qe,
220
+ const i = new Ze({
221
+ ..._e,
222
222
  ...e
223
223
  });
224
224
  return i.onExport(async () => {
225
225
  try {
226
226
  await g.current(), h.current = i.getStats();
227
227
  } catch (u) {
228
- ht.error("[useAutoExport] Export failed:", u);
228
+ pt.error("[useAutoExport] Export failed:", u);
229
229
  }
230
230
  }), o.current = i, () => {
231
231
  i.destroy();
@@ -259,17 +259,17 @@ function gt(n) {
259
259
  }
260
260
  o.current.scheduleExport();
261
261
  }
262
- }, [r, a, d]), C(() => Pe((u) => {
262
+ }, [r, a, d]), C(() => We((u) => {
263
263
  if (!o.current || !d) return;
264
264
  r.some((y) => y.id === u) && o.current.scheduleExport();
265
265
  }), [r, d]);
266
- const w = H((i) => {
266
+ const w = z((i) => {
267
267
  o.current && o.current.updateConfig(i);
268
- }, []), m = H(async () => {
268
+ }, []), m = z(async () => {
269
269
  o.current && (await o.current.forceExport(), h.current = o.current.getStats(), l(h.current));
270
- }, []), A = H(() => {
270
+ }, []), A = z(() => {
271
271
  o.current && (o.current.resetStats(), h.current = o.current.getStats(), l(h.current));
272
- }, []), v = H(() => {
272
+ }, []), v = z(() => {
273
273
  o.current && o.current.resetChangeDetection();
274
274
  }, []);
275
275
  return {
@@ -280,8 +280,8 @@ function gt(n) {
280
280
  resetChangeDetection: v
281
281
  };
282
282
  }
283
- const Ce = G("useContentReady");
284
- function pt(n) {
283
+ const Me = Q("useContentReady");
284
+ function vt(n) {
285
285
  var t;
286
286
  const e = /* @__PURE__ */ new Set();
287
287
  for (const a of n)
@@ -295,7 +295,7 @@ function pt(n) {
295
295
  }
296
296
  return Array.from(e);
297
297
  }
298
- async function bt(n) {
298
+ async function Et(n) {
299
299
  if (n.length === 0 || typeof document > "u" || !document.fonts) return;
300
300
  const e = [];
301
301
  for (const t of n) {
@@ -305,12 +305,12 @@ async function bt(n) {
305
305
  await Promise.all(e), document.fonts.ready && await Promise.race([
306
306
  document.fonts.ready,
307
307
  new Promise((t) => setTimeout(t, 250))
308
- ]), Ce.debug(`Awaited ${e.length} font(s)`);
308
+ ]), Me.debug(`Awaited ${e.length} font(s)`);
309
309
  }
310
- function vt() {
310
+ function xt() {
311
311
  return new Promise((n) => requestAnimationFrame(() => n()));
312
312
  }
313
- function Et(n) {
313
+ function yt(n) {
314
314
  const { isCanvasReady: e, elements: t, hasInitialElements: a, initialElementsLoaded: r } = n, [s, c] = Z(!1), d = F(!1);
315
315
  return C(() => {
316
316
  if (s || !e || a && !r || a && t.length === 0 || d.current) return;
@@ -318,11 +318,11 @@ function Et(n) {
318
318
  let o = !1;
319
319
  return (async () => {
320
320
  try {
321
- const f = pt(t);
322
- if (f.length > 0 && (await bt(f), o) || (await vt(), o)) return;
321
+ const f = vt(t);
322
+ if (f.length > 0 && (await Et(f), o) || (await xt(), o)) return;
323
323
  c(!0);
324
324
  } catch (f) {
325
- Ce.error("Error during content readiness check:", f), o || c(!0);
325
+ Me.error("Error during content readiness check:", f), o || c(!0);
326
326
  } finally {
327
327
  d.current = !1;
328
328
  }
@@ -331,7 +331,7 @@ function Et(n) {
331
331
  };
332
332
  }, [e, t, a, r, s]), s;
333
333
  }
334
- const xt = {
334
+ const wt = {
335
335
  // Vertical alignments (map to top/center/bottom center)
336
336
  "far-top": "t",
337
337
  top: "t",
@@ -354,10 +354,10 @@ const xt = {
354
354
  b: "b",
355
355
  br: "br"
356
356
  };
357
- function yt(n) {
358
- return n && xt[n] || "c";
357
+ function St(n) {
358
+ return n && wt[n] || "c";
359
359
  }
360
- function wt(n, e) {
360
+ function At(n, e) {
361
361
  const t = e.scaleMode || "cover", a = (t === "contain" ? e.marginTop : 0) || 0, r = (t === "contain" ? e.marginRight : 0) || 0, s = (t === "contain" ? e.marginBottom : 0) || 0, c = (t === "contain" ? e.marginLeft : 0) || 0, d = e.width - c - r, o = e.height - a - s, f = d / n.width, h = o / n.height, p = t === "contain" ? Math.min(f, h) : Math.max(f, h), l = e.scale || 1, g = p * l, w = n.width * g, m = n.height * g, A = e.align || "c";
362
362
  let v = 0, i = 0;
363
363
  const u = w - d, x = m - o;
@@ -416,13 +416,13 @@ function wt(n, e) {
416
416
  }
417
417
  };
418
418
  }
419
- const St = {
419
+ const kt = {
420
420
  timeout: 3e4,
421
421
  retries: 1,
422
422
  retryDelay: 1e3,
423
423
  validateUrl: !0
424
424
  };
425
- function At(n) {
425
+ function It(n) {
426
426
  try {
427
427
  const e = new URL(n);
428
428
  return ["http:", "https:", "data:", "blob:"].includes(e.protocol);
@@ -430,9 +430,9 @@ function At(n) {
430
430
  return !1;
431
431
  }
432
432
  }
433
- async function kt(n, e = {}) {
434
- const t = { ...St, ...e };
435
- if (t.validateUrl && !At(n))
433
+ async function Rt(n, e = {}) {
434
+ const t = { ...kt, ...e };
435
+ if (t.validateUrl && !It(n))
436
436
  return {
437
437
  success: !1,
438
438
  error: new Error(`Invalid image URL: ${n}`)
@@ -440,16 +440,16 @@ async function kt(n, e = {}) {
440
440
  let a;
441
441
  for (let r = 0; r <= t.retries; r++)
442
442
  try {
443
- return await Rt(n, t.timeout);
443
+ return await Ct(n, t.timeout);
444
444
  } catch (s) {
445
- a = s instanceof Error ? s : new Error(String(s)), r < t.retries && await Ct(t.retryDelay);
445
+ a = s instanceof Error ? s : new Error(String(s)), r < t.retries && await Ft(t.retryDelay);
446
446
  }
447
447
  return {
448
448
  success: !1,
449
449
  error: a || new Error("Failed to load image after retries")
450
450
  };
451
451
  }
452
- function Rt(n, e) {
452
+ function Ct(n, e) {
453
453
  return new Promise((t) => {
454
454
  const a = new Image();
455
455
  a.crossOrigin = "anonymous";
@@ -480,9 +480,9 @@ function Rt(n, e) {
480
480
  }, e), a.src = n;
481
481
  });
482
482
  }
483
- async function It(n, e, t = {}, a = {}) {
483
+ async function Mt(n, e, t = {}, a = {}) {
484
484
  var l, g, w, m, A, v, i;
485
- const r = await kt(n, a);
485
+ const r = await Rt(n, a);
486
486
  if (!r.success || !r.width || !r.height)
487
487
  return {
488
488
  success: !1,
@@ -492,7 +492,7 @@ async function It(n, e, t = {}, a = {}) {
492
492
  width: e.artboard.width,
493
493
  height: e.artboard.height,
494
494
  scale: e.scale,
495
- align: yt(e.alignment),
495
+ align: St(e.alignment),
496
496
  offsetX: e.offsetX,
497
497
  offsetY: e.offsetY,
498
498
  scaleMode: e.scaleMode,
@@ -500,13 +500,13 @@ async function It(n, e, t = {}, a = {}) {
500
500
  marginRight: e.marginRight,
501
501
  marginBottom: e.marginBottom,
502
502
  marginLeft: e.marginLeft
503
- }, c = wt(
503
+ }, c = At(
504
504
  { width: r.width, height: r.height },
505
505
  s
506
506
  ), d = e.artboard.x + c.x, o = e.artboard.y + c.y, f = d + c.width / 2, h = o + c.height / 2;
507
507
  return {
508
508
  success: !0,
509
- element: new De({
509
+ element: new $e({
510
510
  ...t,
511
511
  x: f,
512
512
  y: h,
@@ -535,10 +535,10 @@ async function It(n, e, t = {}, a = {}) {
535
535
  }
536
536
  };
537
537
  }
538
- function Ct(n) {
538
+ function Ft(n) {
539
539
  return new Promise((e) => setTimeout(e, n));
540
540
  }
541
- const _ = G("SnowconeCanvas");
541
+ const _ = Q("SnowconeCanvas");
542
542
  function de(n, e, t, a) {
543
543
  if (a <= 0 || !isFinite(a))
544
544
  return t;
@@ -548,17 +548,17 @@ function de(n, e, t, a) {
548
548
  const d = Math.max(n, e), o = a / d;
549
549
  return Math.min(o, t);
550
550
  }
551
- function Mt(n) {
551
+ function Nt(n) {
552
552
  const e = F(n);
553
553
  e.current = n;
554
- const t = H((r) => {
554
+ const t = z((r) => {
555
555
  var s;
556
556
  _.error(`[${r.category}] ${r.message}`, r.originalError), (s = e.current) == null || s.call(e, r);
557
557
  }, []);
558
558
  C(() => (ce.onRenderError = t, () => {
559
559
  ce.onRenderError === t && (ce.onRenderError = null);
560
560
  }), [t]);
561
- const a = H((r) => {
561
+ const a = z((r) => {
562
562
  t({
563
563
  category: "unknown",
564
564
  message: r.message,
@@ -568,7 +568,7 @@ function Mt(n) {
568
568
  }, [t]);
569
569
  return { emitError: t, handleBoundaryError: a };
570
570
  }
571
- function Ft(n) {
571
+ function Tt(n) {
572
572
  const {
573
573
  artboardConfigs: e,
574
574
  width: t,
@@ -633,13 +633,13 @@ function Ft(n) {
633
633
  i && c(i.name);
634
634
  }, [p.getActiveArtboardId()]);
635
635
  }
636
- function Nt(n) {
636
+ function Lt(n) {
637
637
  const { initialElements: e, emitError: t } = n, { setElements: a, artboardManager: r } = ee(), s = F(!1), [c, d] = Z(!1);
638
638
  return C(() => {
639
639
  if (!(!e || e.length === 0) && !s.current) {
640
640
  s.current = !0, d(!0);
641
641
  try {
642
- const o = it.createManyFromJSON(e), f = r.getAllArtboards();
642
+ const o = lt.createManyFromJSON(e), f = r.getAllArtboards();
643
643
  if (f.length > 0) {
644
644
  const p = new Map(f.map((l) => [l.name, l]));
645
645
  o.forEach((l, g) => {
@@ -697,7 +697,7 @@ function Nt(n) {
697
697
  }
698
698
  }, [e, r, a, t]), { initialElementsLoadedState: c };
699
699
  }
700
- function Tt(n) {
700
+ function Bt(n) {
701
701
  const {
702
702
  initialImage: e,
703
703
  initialImageAlignment: t,
@@ -722,7 +722,7 @@ function Tt(n) {
722
722
  throw new Error("No artboards available");
723
723
  const u = [];
724
724
  for (const x of i) {
725
- const y = s == null ? void 0 : s.find((M) => M.name === x.name), S = (y == null ? void 0 : y.scaleMode) || r, b = await It(
725
+ const y = s == null ? void 0 : s.find((M) => M.name === x.name), S = (y == null ? void 0 : y.scaleMode) || r, b = await Mt(
726
726
  e,
727
727
  {
728
728
  artboard: {
@@ -765,7 +765,7 @@ function Tt(n) {
765
765
  })();
766
766
  }, [e, t, a, r]), { imageLoadingState: l, imageError: w };
767
767
  }
768
- function Lt(n) {
768
+ function Pt(n) {
769
769
  const { onChange: e, onSelectionChange: t } = n, { elements: a, selectedId: r, artboardManager: s } = ee(), { artboards: c } = ue(), d = F(t);
770
770
  d.current = t, C(() => {
771
771
  var f;
@@ -801,7 +801,7 @@ function Lt(n) {
801
801
  f(p);
802
802
  }, [a, c]);
803
803
  }
804
- function Bt(n, e) {
804
+ function Dt(n, e) {
805
805
  const {
806
806
  autoExportInterval: t,
807
807
  autoExportConfig: a,
@@ -825,38 +825,38 @@ function Bt(n, e) {
825
825
  historyManager: x,
826
826
  isCanvasReady: y,
827
827
  setCanvasReady: S
828
- } = ee(), { artboards: b } = ue(), { exportArtboard: M, exportAllArtboards: Y, exportArtboardAsBlob: $, exportAllArtboardsAsBlobs: j } = st(), ne = F(0), ae = F(0);
829
- $e(e, () => ({
828
+ } = ee(), { artboards: b } = ue(), { exportArtboard: M, exportAllArtboards: j, exportArtboardAsBlob: U, exportAllArtboardsAsBlobs: Y } = ct(), ne = F(0), ae = F(0);
829
+ Ue(e, () => ({
830
830
  exportArtboards: async (T = {}) => {
831
- const L = T.format || r, B = T.scale || c, W = T.all ?? !1;
831
+ const L = T.format || r, B = T.scale || c, $ = T.all ?? !1;
832
832
  let P = B;
833
833
  if (d > 0 && isFinite(d))
834
- for (const I of b) {
835
- const R = de(I.width, I.height, B, d);
836
- P = Math.min(P, R);
834
+ for (const R of b) {
835
+ const I = de(R.width, R.height, B, d);
836
+ P = Math.min(P, I);
837
837
  }
838
838
  const k = { scale: P, format: o, quality: f };
839
- if (W) {
840
- const I = L === "blob" ? await j(k) : await Y(k), R = {};
841
- for (const [N, U] of Object.entries(I)) {
842
- const D = b.find((z) => z.id === N);
843
- D && (R[D.name] = U);
839
+ if ($) {
840
+ const R = L === "blob" ? await Y(k) : await j(k), I = {};
841
+ for (const [N, O] of Object.entries(R)) {
842
+ const D = b.find((K) => K.id === N);
843
+ D && (I[D.name] = O);
844
844
  }
845
- return R;
845
+ return I;
846
846
  } else {
847
- const I = u.getActiveArtboard();
848
- if (!I)
847
+ const R = u.getActiveArtboard();
848
+ if (!R)
849
849
  throw new Error("[SnowconeCanvas] No active artboard found");
850
850
  if (L === "blob") {
851
- const R = await $(I.id, k);
852
- return { [I.name]: R };
851
+ const I = await U(R.id, k);
852
+ return { [R.name]: I };
853
853
  } else {
854
- const R = await M(I.id, k);
855
- return { [I.name]: R };
854
+ const I = await M(R.id, k);
855
+ return { [R.name]: I };
856
856
  }
857
857
  }
858
858
  }
859
- }), [M, Y, $, j, r, c, d, o, f, u, b]), C(() => {
859
+ }), [M, j, U, Y, r, c, d, o, f, u, b]), C(() => {
860
860
  g && g(async () => {
861
861
  const L = u.getActiveArtboard();
862
862
  if (!L)
@@ -866,66 +866,66 @@ function Bt(n, e) {
866
866
  L.height,
867
867
  c,
868
868
  d
869
- ), W = r === "blob" ? await $(L.id, { scale: B }) : await M(L.id, { scale: B });
870
- return { [L.name]: W };
869
+ ), $ = r === "blob" ? await U(L.id, { scale: B }) : await M(L.id, { scale: B });
870
+ return { [L.name]: $ };
871
871
  });
872
- }, [g, M, $, u, r, c, d]);
873
- const oe = H(async () => {
872
+ }, [g, M, U, u, r, c, d]);
873
+ const oe = z(async () => {
874
874
  if (!h && !l) return;
875
875
  const T = ++ae.current, L = Date.now();
876
876
  let B = c;
877
877
  if (d > 0 && isFinite(d))
878
878
  for (const k of b) {
879
- const I = de(k.width, k.height, c, d);
880
- B = Math.min(B, I);
879
+ const R = de(k.width, k.height, c, d);
880
+ B = Math.min(B, R);
881
881
  }
882
- const W = u.getActiveArtboard(), P = (W == null ? void 0 : W.id) ?? "unknown";
882
+ const $ = u.getActiveArtboard(), P = ($ == null ? void 0 : $.id) ?? "unknown";
883
883
  l == null || l({ status: "rendering", artboardId: P }), ne.current = L;
884
884
  try {
885
885
  let k;
886
- const I = {
886
+ const R = {
887
887
  format: o,
888
888
  scale: B,
889
889
  quality: f
890
890
  };
891
891
  if (r === "blob")
892
892
  if (s) {
893
- const R = await j(I);
893
+ const I = await Y(R);
894
894
  k = {};
895
- for (const [N, U] of Object.entries(R)) {
896
- const D = b.find((z) => z.id === N);
897
- D && (k[D.name] = U);
895
+ for (const [N, O] of Object.entries(I)) {
896
+ const D = b.find((K) => K.id === N);
897
+ D && (k[D.name] = O);
898
898
  }
899
899
  } else {
900
- const R = u.getActiveArtboard();
901
- if (!R) return;
902
- const N = await $(R.id, I);
903
- k = { [R.name]: N };
900
+ const I = u.getActiveArtboard();
901
+ if (!I) return;
902
+ const N = await U(I.id, R);
903
+ k = { [I.name]: N };
904
904
  }
905
905
  else if (s) {
906
- const R = await Y(I);
906
+ const I = await j(R);
907
907
  k = {};
908
- for (const [N, U] of Object.entries(R)) {
909
- const D = b.find((z) => z.id === N);
910
- D && (k[D.name] = U);
908
+ for (const [N, O] of Object.entries(I)) {
909
+ const D = b.find((K) => K.id === N);
910
+ D && (k[D.name] = O);
911
911
  }
912
912
  } else {
913
- const R = u.getActiveArtboard();
914
- if (!R) return;
915
- const N = await M(R.id, I);
916
- k = { [R.name]: N };
913
+ const I = u.getActiveArtboard();
914
+ if (!I) return;
915
+ const N = await M(I.id, R);
916
+ k = { [I.name]: N };
917
917
  }
918
918
  h == null || h(k), l == null || l({ status: "complete", artboardId: P, result: k });
919
919
  } catch (k) {
920
- const I = k instanceof Error ? k.message : String(k);
921
- if (I.includes("Canvas ref not available"))
920
+ const R = k instanceof Error ? k.message : String(k);
921
+ if (R.includes("Canvas ref not available"))
922
922
  return;
923
- const R = Date.now() - L;
923
+ const I = Date.now() - L;
924
924
  _.error("Export failed (export #" + T + "):", {
925
- duration: `${R}ms`,
926
- error: I
925
+ duration: `${I}ms`,
926
+ error: R
927
927
  });
928
- const N = k instanceof Error ? k : new Error(I);
928
+ const N = k instanceof Error ? k : new Error(R);
929
929
  l == null || l({ status: "error", artboardId: P, error: N }), v({
930
930
  category: "export",
931
931
  message: N.message,
@@ -934,26 +934,26 @@ function Bt(n, e) {
934
934
  recoverable: !0
935
935
  });
936
936
  }
937
- }, [h, l, s, r, c, d, o, f, M, Y, $, j, b, u, i, a, v]);
937
+ }, [h, l, s, r, c, d, o, f, M, j, U, Y, b, u, i, a, v]);
938
938
  C(() => {
939
939
  t !== void 0 && t > 0 && _.warn(
940
940
  "autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
941
941
  );
942
942
  }, []);
943
- const se = H(() => {
943
+ const se = z(() => {
944
944
  if (p == null || p(), l) {
945
945
  const T = u.getActiveArtboard();
946
946
  l({ status: "scheduled", artboardId: (T == null ? void 0 : T.id) ?? "unknown" });
947
947
  }
948
- }, [p, l, u]), Q = Et({
948
+ }, [p, l, u]), J = yt({
949
949
  isCanvasReady: y,
950
950
  elements: i,
951
951
  hasInitialElements: m,
952
952
  initialElementsLoaded: A
953
953
  }), te = F(!1);
954
954
  C(() => {
955
- Q && !te.current && (te.current = !0, w == null || w());
956
- }, [Q, w]), gt({
955
+ J && !te.current && (te.current = !0, w == null || w());
956
+ }, [J, w]), bt({
957
957
  config: a ? {
958
958
  enabled: a.enabled ?? !0,
959
959
  debounceMs: a.debounceMs ?? 100,
@@ -967,7 +967,7 @@ function Bt(n, e) {
967
967
  elements: i,
968
968
  onExport: oe,
969
969
  onExportScheduled: se,
970
- isCanvasReady: Q
970
+ isCanvasReady: J
971
971
  // Gate exports until content is fully ready (fonts loaded, elements deserialized)
972
972
  }), C(() => {
973
973
  if (b.length > 0 && !y) {
@@ -980,7 +980,8 @@ function Bt(n, e) {
980
980
  S(!1);
981
981
  }, [S]);
982
982
  }
983
- const Se = G("SnowconeCanvas"), Me = Re((n, e) => {
983
+ const Ae = Q("SnowconeCanvas"), Fe = Re((n, e) => {
984
+ var be;
984
985
  const {
985
986
  exportConfig: t,
986
987
  imageConfig: a,
@@ -1005,47 +1006,47 @@ const Se = G("SnowconeCanvas"), Me = Re((n, e) => {
1005
1006
  style: S,
1006
1007
  enableShortcuts: b,
1007
1008
  overlay: M,
1008
- resetDocumentOnMount: Y
1009
- } = n, $ = l, j = n.autoExportConfig ?? (t == null ? void 0 : t.autoExportConfig), ne = n.autoExportFormat ?? (t == null ? void 0 : t.format) ?? "dataUrl", ae = n.autoExportAll ?? (t == null ? void 0 : t.exportAll) ?? !1, oe = n.exportScale ?? (t == null ? void 0 : t.scale) ?? 2, se = n.maxExportSize ?? (t == null ? void 0 : t.maxSize) ?? 4e3, Q = n.exportImageFormat ?? (t == null ? void 0 : t.imageFormat) ?? "png", te = n.exportImageQuality ?? (t == null ? void 0 : t.imageQuality) ?? 0.92, T = n.initialImage ?? (a == null ? void 0 : a.src), L = n.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", B = n.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, W = n.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", P = n.width ?? (r == null ? void 0 : r.width) ?? 1200, k = n.height ?? (r == null ? void 0 : r.height) ?? 1200, I = n.viewPadding ?? (r == null ? void 0 : r.viewPadding) ?? 0.9, R = n.artboardBorderRadius ?? (r == null ? void 0 : r.artboardBorderRadius) ?? 0, N = n.fixedMargin ?? (r == null ? void 0 : r.fixedMargin), U = n.maxHeight ?? (r == null ? void 0 : r.maxHeight), D = n.showRotationHandle ?? (r == null ? void 0 : r.showRotationHandle) ?? !0, z = n.hideCanvas ?? (r == null ? void 0 : r.hideCanvas) ?? !1, fe = n.canvasWrapperClassName ?? (r == null ? void 0 : r.canvasWrapperClassName), me = n.canvasWrapperStyle ?? (r == null ? void 0 : r.canvasWrapperStyle), Fe = n.canvasCutouts ?? (r == null ? void 0 : r.canvasCutouts), he = n.pieceGuides, Ne = n.pieceFocus, Te = b ?? !0, J = ke(() => Ze(s ?? "pro-studio"), [s]);
1009
+ resetDocumentOnMount: j
1010
+ } = n, U = l, Y = n.autoExportConfig ?? (t == null ? void 0 : t.autoExportConfig), ne = n.autoExportFormat ?? (t == null ? void 0 : t.format) ?? "dataUrl", ae = n.autoExportAll ?? (t == null ? void 0 : t.exportAll) ?? !1, oe = n.exportScale ?? (t == null ? void 0 : t.scale) ?? 2, se = n.maxExportSize ?? (t == null ? void 0 : t.maxSize) ?? 4e3, J = n.exportImageFormat ?? (t == null ? void 0 : t.imageFormat) ?? "png", te = n.exportImageQuality ?? (t == null ? void 0 : t.imageQuality) ?? 0.92, T = n.initialImage ?? (a == null ? void 0 : a.src), L = n.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", B = n.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, $ = n.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", P = n.width ?? (r == null ? void 0 : r.width) ?? 1200, k = n.height ?? (r == null ? void 0 : r.height) ?? 1200, R = n.viewPadding ?? (r == null ? void 0 : r.viewPadding) ?? 0.9, I = n.artboardBorderRadius ?? (r == null ? void 0 : r.artboardBorderRadius) ?? 0, N = n.fixedMargin ?? (r == null ? void 0 : r.fixedMargin), O = n.maxHeight ?? (r == null ? void 0 : r.maxHeight), D = n.showRotationHandle ?? (r == null ? void 0 : r.showRotationHandle) ?? !0, K = n.hideCanvas ?? (r == null ? void 0 : r.hideCanvas) ?? !1, fe = n.canvasWrapperClassName ?? (r == null ? void 0 : r.canvasWrapperClassName), me = n.canvasWrapperStyle ?? (r == null ? void 0 : r.canvasWrapperStyle), Ne = n.canvasCutouts ?? (r == null ? void 0 : r.canvasCutouts), he = n.pieceGuides, Te = n.pieceFocus, Le = b ?? !0, V = Ie(() => et(s ?? "pro-studio"), [s]);
1010
1011
  C(() => {
1011
- var K;
1012
- if (typeof V < "u" && ((K = V.env) == null ? void 0 : K.NODE_ENV) === "development" && J) {
1013
- const O = _e(J);
1014
- O.valid || Se.warn("Kit validation warnings:", O.errors), O.warnings.length > 0 && Se.warn("Kit validation warnings:", O.warnings);
1012
+ var H;
1013
+ if (typeof G < "u" && ((H = G.env) == null ? void 0 : H.NODE_ENV) === "development" && V) {
1014
+ const W = tt(V);
1015
+ W.valid || Ae.warn("Kit validation warnings:", W.errors), W.warnings.length > 0 && Ae.warn("Kit validation warnings:", W.warnings);
1015
1016
  }
1016
- }, [J]);
1017
- const { emitError: ie, handleBoundaryError: Le } = Mt(u);
1018
- Ft({
1017
+ }, [V]);
1018
+ const { emitError: ie, handleBoundaryError: Be } = Nt(u);
1019
+ Tt({
1019
1020
  artboardConfigs: c,
1020
1021
  width: P,
1021
1022
  height: k,
1022
1023
  pieceGuides: he,
1023
1024
  controlledActiveArtboard: d,
1024
1025
  onArtboardChange: o,
1025
- resetDocumentOnMount: Y
1026
+ resetDocumentOnMount: j
1026
1027
  });
1027
- const { initialElementsLoadedState: Be } = Nt({
1028
+ const { initialElementsLoadedState: Pe } = Lt({
1028
1029
  initialElements: f,
1029
1030
  emitError: ie
1030
- }), { imageLoadingState: ge, imageError: pe } = Tt({
1031
+ }), { imageLoadingState: ge, imageError: pe } = Bt({
1031
1032
  initialImage: T,
1032
1033
  initialImageAlignment: L,
1033
1034
  initialImageScale: B,
1034
- initialImageScaleMode: W,
1035
+ initialImageScaleMode: $,
1035
1036
  artboardConfigs: c,
1036
1037
  onImageLoad: v,
1037
1038
  onImageError: i,
1038
1039
  emitError: ie
1039
1040
  });
1040
- return Lt({ onChange: h, onSelectionChange: p }), Bt(
1041
+ if (Pt({ onChange: h, onSelectionChange: p }), Dt(
1041
1042
  {
1042
- autoExportInterval: $,
1043
- autoExportConfig: j,
1043
+ autoExportInterval: U,
1044
+ autoExportConfig: Y,
1044
1045
  autoExportFormat: ne,
1045
1046
  autoExportAll: ae,
1046
1047
  exportScale: oe,
1047
1048
  maxExportSize: se,
1048
- exportImageFormat: Q,
1049
+ exportImageFormat: J,
1049
1050
  exportImageQuality: te,
1050
1051
  onExport: g,
1051
1052
  onExportScheduled: w,
@@ -1053,46 +1054,53 @@ const Se = G("SnowconeCanvas"), Me = Re((n, e) => {
1053
1054
  onExportReady: A,
1054
1055
  onReady: x,
1055
1056
  hasInitialElements: !!f && f.length > 0,
1056
- initialElementsLoaded: Be,
1057
+ initialElementsLoaded: Pe,
1057
1058
  emitError: ie
1058
1059
  },
1059
1060
  e
1060
- ), ge === "loading" ? /* @__PURE__ */ E(
1061
- "div",
1062
- {
1063
- className: y,
1064
- style: {
1065
- ...S,
1066
- display: "flex",
1067
- alignItems: "center",
1068
- justifyContent: "center",
1069
- backgroundColor: "var(--surface, #f5f5f5)"
1070
- },
1071
- children: /* @__PURE__ */ E(et, { size: 48 })
1072
- }
1073
- ) : ge === "error" && pe ? /* @__PURE__ */ E(
1074
- "div",
1075
- {
1076
- className: y,
1077
- style: {
1078
- ...S,
1079
- display: "flex",
1080
- alignItems: "center",
1081
- justifyContent: "center",
1082
- backgroundColor: "var(--surface, #f5f5f5)",
1083
- color: "var(--danger, #dc2626)",
1084
- padding: "1rem"
1085
- },
1086
- children: /* @__PURE__ */ X("div", { className: "sc:text-center", children: [
1087
- /* @__PURE__ */ E("div", { className: "sc:font-medium", children: "Failed to load image" }),
1088
- /* @__PURE__ */ E("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: pe.message })
1089
- ] })
1090
- }
1091
- ) : /* @__PURE__ */ E(tt, { kit: J, children: /* @__PURE__ */ E("div", { className: `sc-root ${y || ""}`, style: { ...S, position: "relative" }, children: /* @__PURE__ */ X(
1092
- ft,
1061
+ ), ge === "loading")
1062
+ return /* @__PURE__ */ E(
1063
+ "div",
1064
+ {
1065
+ className: y,
1066
+ style: {
1067
+ ...S,
1068
+ display: "flex",
1069
+ alignItems: "center",
1070
+ justifyContent: "center",
1071
+ backgroundColor: "var(--surface, #f5f5f5)"
1072
+ },
1073
+ children: /* @__PURE__ */ E(rt, { size: 48 })
1074
+ }
1075
+ );
1076
+ if (ge === "error" && pe)
1077
+ return /* @__PURE__ */ E(
1078
+ "div",
1079
+ {
1080
+ className: y,
1081
+ style: {
1082
+ ...S,
1083
+ display: "flex",
1084
+ alignItems: "center",
1085
+ justifyContent: "center",
1086
+ backgroundColor: "var(--surface, #f5f5f5)",
1087
+ color: "var(--danger, #dc2626)",
1088
+ padding: "1rem"
1089
+ },
1090
+ children: /* @__PURE__ */ X("div", { className: "sc:text-center", children: [
1091
+ /* @__PURE__ */ E("div", { className: "sc:font-medium", children: "Failed to load image" }),
1092
+ /* @__PURE__ */ E("div", { className: "sc:text-sm sc:mt-1 sc:opacity-70", children: pe.message })
1093
+ ] })
1094
+ }
1095
+ );
1096
+ const De = Object.entries(((be = V.layout) == null ? void 0 : be.slots) ?? {}).every(
1097
+ ([H, W]) => H === "canvas" || !W || W.length === 0
1098
+ ) ? { "--color-canvas-bg": "transparent" } : void 0;
1099
+ return /* @__PURE__ */ E(nt, { kit: V, children: /* @__PURE__ */ E("div", { className: `sc-root ${y || ""}`, style: { ...De, ...S, position: "relative" }, children: /* @__PURE__ */ X(
1100
+ ht,
1093
1101
  {
1094
- onError: Le,
1095
- fallback: (K, O) => /* @__PURE__ */ X(
1102
+ onError: Be,
1103
+ fallback: (H, W) => /* @__PURE__ */ X(
1096
1104
  "div",
1097
1105
  {
1098
1106
  style: {
@@ -1109,11 +1117,11 @@ const Se = G("SnowconeCanvas"), Me = Re((n, e) => {
1109
1117
  },
1110
1118
  children: [
1111
1119
  /* @__PURE__ */ E("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
1112
- /* @__PURE__ */ E("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: K.message }),
1120
+ /* @__PURE__ */ E("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: H.message }),
1113
1121
  /* @__PURE__ */ E(
1114
1122
  "button",
1115
1123
  {
1116
- onClick: O,
1124
+ onClick: W,
1117
1125
  style: {
1118
1126
  padding: "8px 20px",
1119
1127
  backgroundColor: "var(--primary, #333)",
@@ -1131,49 +1139,49 @@ const Se = G("SnowconeCanvas"), Me = Re((n, e) => {
1131
1139
  }
1132
1140
  ),
1133
1141
  children: [
1134
- !z && /* @__PURE__ */ (() => {
1135
- const K = /* @__PURE__ */ E(
1136
- rt,
1142
+ !K && /* @__PURE__ */ (() => {
1143
+ const H = /* @__PURE__ */ E(
1144
+ at,
1137
1145
  {
1138
1146
  style: { width: "100%" },
1139
- fitPadding: I,
1140
- artboardBorderRadius: R,
1147
+ fitPadding: R,
1148
+ artboardBorderRadius: I,
1141
1149
  fixedMargin: N,
1142
- maxHeight: U,
1150
+ maxHeight: O,
1143
1151
  showRotationHandle: D,
1144
- enableShortcuts: Te,
1145
- canvasCutouts: Fe,
1152
+ enableShortcuts: Le,
1153
+ canvasCutouts: Ne,
1146
1154
  pieceGuides: he,
1147
- pieceFocus: Ne
1155
+ pieceFocus: Te
1148
1156
  }
1149
1157
  );
1150
- return /* @__PURE__ */ E(dt, { kit: J, canvas: fe || me ? /* @__PURE__ */ E("div", { className: fe, style: me, children: K }) : K });
1158
+ return /* @__PURE__ */ E(ft, { kit: V, canvas: fe || me ? /* @__PURE__ */ E("div", { className: fe, style: me, children: H }) : H });
1151
1159
  })(),
1152
1160
  M
1153
1161
  ]
1154
1162
  }
1155
1163
  ) }) });
1156
1164
  });
1157
- Me.displayName = "SnowconeCanvasInner";
1158
- const Pt = Re((n, e) => {
1165
+ Fe.displayName = "SnowconeCanvasInner";
1166
+ const Wt = Re((n, e) => {
1159
1167
  var c;
1160
1168
  const { inheritTheme: t, externalProvider: a, services: r } = n, s = n.viewPadding ?? ((c = n.layoutConfig) == null ? void 0 : c.viewPadding);
1161
1169
  return /* @__PURE__ */ E(
1162
- mt,
1170
+ gt,
1163
1171
  {
1164
1172
  inheritTheme: t,
1165
1173
  externalProvider: a,
1166
1174
  services: r,
1167
1175
  viewPadding: s,
1168
- children: /* @__PURE__ */ E(Me, { ref: e, ...n })
1176
+ children: /* @__PURE__ */ E(Fe, { ref: e, ...n })
1169
1177
  }
1170
1178
  );
1171
1179
  });
1172
- Pt.displayName = "SnowconeCanvas";
1180
+ Wt.displayName = "SnowconeCanvas";
1173
1181
  export {
1174
- ft as E,
1175
- Pt as S,
1176
- Et as a,
1177
- gt as u
1182
+ ht as E,
1183
+ Wt as S,
1184
+ yt as a,
1185
+ bt as u
1178
1186
  };
1179
- //# sourceMappingURL=SnowconeCanvas-wdckG-6O.js.map
1187
+ //# sourceMappingURL=SnowconeCanvas-DBbmx9qW.js.map