@snowcone-app/canvas 0.30.0 → 0.32.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 (80) hide show
  1. package/ERROR_CONTRACT.md +11 -0
  2. package/STYLING_CONTRACT.md +3 -3
  3. package/dist/{CanvasRenderer-BEf0hXeF.js → CanvasRenderer-1j-twIbs.js} +443 -431
  4. package/dist/{CanvasRenderer-BEf0hXeF.js.map → CanvasRenderer-1j-twIbs.js.map} +1 -1
  5. package/dist/{CanvasStateV1-BDSyYo4A.js → CanvasStateV1-BmC1JfPv.js} +813 -798
  6. package/dist/{CanvasStateV1-BDSyYo4A.js.map → CanvasStateV1-BmC1JfPv.js.map} +1 -1
  7. package/dist/ContextualToolbars-BKU8IoAM.js +6474 -0
  8. package/dist/ContextualToolbars-BKU8IoAM.js.map +1 -0
  9. package/dist/{EditorCanvasImpl-DXeBz2CX.js → EditorCanvasImpl-4voOsj2k.js} +19 -20
  10. package/dist/{EditorCanvasImpl-DXeBz2CX.js.map → EditorCanvasImpl-4voOsj2k.js.map} +1 -1
  11. package/dist/{ExportManager-DUdis6se.js → ExportManager-Ci81K6xA.js} +783 -500
  12. package/dist/ExportManager-Ci81K6xA.js.map +1 -0
  13. package/dist/{FontAnalyzer-DKG5JK0x.js → FontAnalyzer-BrKY6XYn.js} +1604 -1444
  14. package/dist/FontAnalyzer-BrKY6XYn.js.map +1 -0
  15. package/dist/{ImagePanel-CBgGqmVV.js → ImagePanel-ntJBepby.js} +49 -49
  16. package/dist/{ImagePanel-CBgGqmVV.js.map → ImagePanel-ntJBepby.js.map} +1 -1
  17. package/dist/{SnowconeCanvas-BWPBngvI.js → SnowconeCanvas-CgQdiBXv.js} +27 -27
  18. package/dist/{SnowconeCanvas-BWPBngvI.js.map → SnowconeCanvas-CgQdiBXv.js.map} +1 -1
  19. package/dist/advanced.mjs +14 -14
  20. package/dist/components/ImageToolbar.d.ts +12 -0
  21. package/dist/components/ShapeToolbar.d.ts +8 -0
  22. package/dist/components/TextToolbar.d.ts +5 -1
  23. package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +6 -0
  24. package/dist/components/toolbars/GroupElementToolbar.d.ts +8 -0
  25. package/dist/components/toolbars/SecondaryPanels.d.ts +40 -1
  26. package/dist/components/toolbars/index.d.ts +2 -2
  27. package/dist/components/ui/SliderRow.d.ts +6 -0
  28. package/dist/components/ui/toolbar-button.d.ts +2 -2
  29. package/dist/core/BaseElement.d.ts +2 -1
  30. package/dist/core/image-adjustments.d.ts +32 -0
  31. package/dist/core/shape-fill.d.ts +31 -0
  32. package/dist/{custom-icons-BIaRovwG.js → custom-icons-DTWtkJ9N.js} +7 -7
  33. package/dist/{custom-icons-BIaRovwG.js.map → custom-icons-DTWtkJ9N.js.map} +1 -1
  34. package/dist/design-builder-BpbYUYtK.js +1672 -0
  35. package/dist/design-builder-BpbYUYtK.js.map +1 -0
  36. package/dist/{embed-Csez1hui.js → embed-C69x0jHc.js} +110 -111
  37. package/dist/{embed-Csez1hui.js.map → embed-C69x0jHc.js.map} +1 -1
  38. package/dist/embed.mjs +53 -54
  39. package/dist/embed.mjs.map +1 -1
  40. package/dist/errors/editorError.d.ts +7 -0
  41. package/dist/{guards-BSoX73yg.js → guards-BhaQgJrE.js} +2 -2
  42. package/dist/{guards-BSoX73yg.js.map → guards-BhaQgJrE.js.map} +1 -1
  43. package/dist/hooks/elementPatch.d.ts +14 -4
  44. package/dist/index.mjs +41 -41
  45. package/dist/internals.mjs +202 -133
  46. package/dist/internals.mjs.map +1 -1
  47. package/dist/rendering/LayerEffectsRenderer.d.ts +24 -0
  48. package/dist/rendering/element-painters.d.ts +0 -13
  49. package/dist/rendering/element-serializer.d.ts +3 -1
  50. package/dist/rendering/image-adjustments.d.ts +24 -0
  51. package/dist/rendering/renderer-types.d.ts +10 -1
  52. package/dist/state/CanvasStateV1.d.ts +22 -0
  53. package/dist/style.css +1 -1
  54. package/dist/template-fields-D-2oLhCi.js +505 -0
  55. package/dist/template-fields-D-2oLhCi.js.map +1 -0
  56. package/dist/testing.mjs +40 -41
  57. package/dist/testing.mjs.map +1 -1
  58. package/dist/types/index.d.ts +105 -1
  59. package/dist/types/public.d.ts +3 -2
  60. package/dist/{UnifiedFontService-Co9tQ59z.js → useCommands-DwnZHUg8.js} +2361 -2103
  61. package/dist/useCommands-DwnZHUg8.js.map +1 -0
  62. package/dist/{usePieceGuideBundle-CRLY2iQa.js → usePieceGuideBundle-CnSmYrmM.js} +2 -2
  63. package/dist/{usePieceGuideBundle-CRLY2iQa.js.map → usePieceGuideBundle-CnSmYrmM.js.map} +1 -1
  64. package/dist/utils/featureApplied.d.ts +6 -0
  65. package/dist/{validation-BGEl9rrE.js → validation-DyUOjRGa.js} +465 -465
  66. package/dist/{validation-BGEl9rrE.js.map → validation-DyUOjRGa.js.map} +1 -1
  67. package/dist/workers/export-worker.bundle.string.d.ts +1 -1
  68. package/example/package.json +1 -1
  69. package/package.json +1 -1
  70. package/dist/ContextualToolbars-C3D_6sep.js +0 -5960
  71. package/dist/ContextualToolbars-C3D_6sep.js.map +0 -1
  72. package/dist/ExportManager-DUdis6se.js.map +0 -1
  73. package/dist/FontAnalyzer-DKG5JK0x.js.map +0 -1
  74. package/dist/UnifiedFontService-Co9tQ59z.js.map +0 -1
  75. package/dist/design-builder-JYLO_Hyi.js +0 -470
  76. package/dist/design-builder-JYLO_Hyi.js.map +0 -1
  77. package/dist/editorErrors-WzaNxU1Y.js +0 -1206
  78. package/dist/editorErrors-WzaNxU1Y.js.map +0 -1
  79. package/dist/template-fields-DYPW7bVU.js +0 -716
  80. package/dist/template-fields-DYPW7bVU.js.map +0 -1
@@ -1,14 +1,13 @@
1
- import { E as Le, o as Ve, p as Be, C as Fe, q as H, r as J, t as Ue, v as Me, w as je, x as qe, y as ze, g as Ke, e as We } from "./UnifiedFontService-Co9tQ59z.js";
2
- import { E as T, y as be, z as L } from "./FontAnalyzer-DKG5JK0x.js";
1
+ import { E as Le, p as Ve, q as Be, C as Fe, r as H, t as J, v as Ue, w as Me, x as je, y as qe, z as ze, h as Ke, e as We } from "./useCommands-DwnZHUg8.js";
2
+ import { E as T, y as be, z as L } from "./FontAnalyzer-BrKY6XYn.js";
3
3
  import { jsx as l, jsxs as N, Fragment as Ge } from "react/jsx-runtime";
4
4
  import { useContext as He, createContext as Je, useRef as x, useState as C, useMemo as O, useCallback as F, useLayoutEffect as Q, useEffect as $, useSyncExternalStore as z, Component as Qe, forwardRef as we, useId as de, memo as Ye, isValidElement as Ee } from "react";
5
5
  import { assertVariantSelected as Xe, RenderSession as Ze, createCartDetail as et } from "@snowcone-app/sdk";
6
- import { B as tt, E as nt, r as rt } from "./editorErrors-WzaNxU1Y.js";
7
- import { u as ot, p as it } from "./usePieceGuideBundle-CRLY2iQa.js";
8
- import { s as le, i as st } from "./design-builder-JYLO_Hyi.js";
9
- import { D as at, C as dt, g as lt, e as ct } from "./template-fields-DYPW7bVU.js";
10
- import "./ExportManager-DUdis6se.js";
11
- import "./CanvasStateV1-BDSyYo4A.js";
6
+ import { s as le, B as tt, E as nt, r as rt, i as ot } from "./design-builder-BpbYUYtK.js";
7
+ import { u as it, p as st } from "./usePieceGuideBundle-CnSmYrmM.js";
8
+ import { D as at, C as dt, f as lt, d as ct } from "./template-fields-D-2oLhCi.js";
9
+ import "./ExportManager-Ci81K6xA.js";
10
+ import "./CanvasStateV1-BmC1JfPv.js";
12
11
  const xe = Je(void 0);
13
12
  function K() {
14
13
  const t = He(xe);
@@ -65,14 +64,14 @@ function Re({ shop: t, product: e, design: n, hasGrant: r }) {
65
64
  issue: "placement-mismatch",
66
65
  message: `the design's artboard(s) [${a.join(", ")}] are not in product.placements [${e.placements.join(", ")}]. Every artboard name must equal a real product placement label (renderState targets placements by that name), or the server renders a blank mockup. Fix the \`name\` passed to design({ name }) / design().artboard(name, …).`
67
66
  });
68
- const f = s.elements.map((o) => o.name).filter((o) => !!o), m = f.filter((o, g) => f.indexOf(o) !== g);
67
+ const p = s.elements.map((o) => o.name).filter((o) => !!o), m = p.filter((o, g) => p.indexOf(o) !== g);
69
68
  return m.length && i.push({
70
69
  severity: "warn",
71
70
  issue: "duplicate-layer-names",
72
71
  message: `duplicate layer name(s) [${[...new Set(m)].join(", ")}] — useTextBinding(name) / useImageBinding(name) bind to the FIRST match, so a duplicate name makes a control edit the wrong layer. Keep names unique.`
73
72
  }), i;
74
73
  }
75
- function pt(t) {
74
+ function ft(t) {
76
75
  for (const e of Re(t))
77
76
  (e.severity === "error" && e.issue !== "placement-mismatch" ? console.error : console.warn)(`${ut} ${e.message}`);
78
77
  }
@@ -111,15 +110,15 @@ function Se({ registry: t, store: e, product: n }) {
111
110
  fix: "Mount <Editor.Buy onAddToCart={…}/> under the same <Editor.Root> (it assembles the payload and gates on completeness), or ignore if this composition is deliberately non-commerce."
112
111
  });
113
112
  }
114
- const f = [];
113
+ const p = [];
115
114
  for (const o of s)
116
115
  e.layerKindOf(o.name) === void 0 ? r.push({
117
116
  code: "A_LAYER_UNMATCHED",
118
117
  severity: "error",
119
118
  message: `<Editor.TextField layer={design.layer("${o.name}")}> matches zero elements in the current design state — the layer was removed or renamed after the field mounted, so the binding is dead and writes will fail. Bindable layers now: ${JSON.stringify(e.bindableLayerNames())}.`,
120
119
  fix: `Restore a text layer named "${o.name}" to the design, or bind the field to an existing layer: layer={design.layer(<one of ${JSON.stringify(e.bindableLayerNames())}>)}.`
121
- }) : f.push(o);
122
- const m = f.filter((o) => !o.optional);
120
+ }) : p.push(o);
121
+ const m = p.filter((o) => !o.optional);
123
122
  if (m.length > 0 && m.every((o) => e.textOf(o.name) === e.seedTextOf(o.name))) {
124
123
  const o = m.map((g) => g.name);
125
124
  r.push({
@@ -141,13 +140,13 @@ function Se({ registry: t, store: e, product: n }) {
141
140
  return { findings: r, parts: b };
142
141
  }
143
142
  const G = [];
144
- function ft(t) {
143
+ function pt(t) {
145
144
  return G.push(t), () => {
146
145
  const e = G.indexOf(t);
147
146
  e !== -1 && G.splice(e, 1);
148
147
  };
149
148
  }
150
- function on() {
149
+ function rn() {
151
150
  const t = G[G.length - 1];
152
151
  if (!t)
153
152
  throw new T(
@@ -247,11 +246,11 @@ function bt(t) {
247
246
  onIssue: c,
248
247
  wsUrl: u,
249
248
  services: a,
250
- children: f,
249
+ children: p,
251
250
  internals: m,
252
251
  recordAudit: y,
253
252
  __validation: b = "throw"
254
- } = t, o = O(() => r.toJSON().activeArtboard, [r]), g = O(() => r.toJSON().artboards.map((h) => h.name), [r]), [w, p] = C(null), S = w && w.design === r ? w.label : o, v = O(
253
+ } = t, o = O(() => r.toJSON().activeArtboard, [r]), g = O(() => r.toJSON().artboards.map((h) => h.name), [r]), [w, f] = C(null), S = w && w.design === r ? w.label : o, v = O(
255
254
  () => (h) => {
256
255
  if (!g.includes(h))
257
256
  throw new T(
@@ -259,7 +258,7 @@ function bt(t) {
259
258
  `no placement "${h}" in this design — its artboards are ${JSON.stringify(g)}. Add it to the seed with design(…).artboard('${h}', { width, height }) (ADR-0088).`,
260
259
  { placement: h, validNames: g, docSlug: "embed-mode" }
261
260
  );
262
- p({ design: r, label: h });
261
+ f({ design: r, label: h });
263
262
  },
264
263
  [r, g]
265
264
  ), V = O(() => {
@@ -277,10 +276,10 @@ function bt(t) {
277
276
  m.commerce.getVersion,
278
277
  m.commerce.getVersion
279
278
  );
280
- const R = m.commerce.renderVariantId(), _ = ot(R ?? n.variantId ?? n.defaultGvid), D = O(() => {
279
+ const R = m.commerce.renderVariantId(), _ = it(R ?? n.variantId ?? n.defaultGvid), D = O(() => {
281
280
  if (!_) return null;
282
281
  const h = r.toJSON().artboards[0];
283
- return it(_, h) ?? null;
282
+ return st(_, h) ?? null;
284
283
  }, [_, r]), P = x(s), A = x(d), j = x(c);
285
284
  P.current = s, A.current = d, j.current = c;
286
285
  const [ce, _e] = C([]), [Y, W] = C(!0), [ue, X] = C(null), ne = !!("grantUrl" in t && t.grantUrl || "grant" in t && t.grant), re = gt(t), Ae = "grantUrl" in re ? re.grantUrl : "getToken", me = `${n.productId}|${n.mockupIds.join(",")}|${n.variantId ?? ""}`, q = `${e}|${me}|${o}|${ne}`, oe = O(() => {
@@ -296,20 +295,20 @@ function bt(t) {
296
295
  for (const B of h)
297
296
  typeof L < "u" && ((I = L.env) == null ? void 0 : I.NODE_ENV) !== "production" && console.warn(`[Editor.Root] ${B.message}`);
298
297
  return h;
299
- }, [q, b]), pe = x(null);
298
+ }, [q, b]), fe = x(null);
300
299
  $(() => {
301
300
  var h;
302
- if (oe.length !== 0 && pe.current !== q) {
303
- pe.current = q;
301
+ if (oe.length !== 0 && fe.current !== q) {
302
+ fe.current = q;
304
303
  for (const E of oe) (h = j.current) == null || h.call(j, E);
305
304
  }
306
305
  }, [oe, q]);
307
- const fe = x(null);
306
+ const pe = x(null);
308
307
  $(() => {
309
308
  var h;
310
309
  if (b === "warn" && typeof L < "u" && ((h = L.env) == null ? void 0 : h.NODE_ENV) !== "production") {
311
- if (fe.current === q) return;
312
- fe.current = q, pt({ shop: e, product: n, design: r, hasGrant: ne });
310
+ if (pe.current === q) return;
311
+ pe.current = q, ft({ shop: e, product: n, design: r, hasGrant: ne });
313
312
  }
314
313
  }, [q, b]);
315
314
  const Z = O(
@@ -410,7 +409,7 @@ function bt(t) {
410
409
  nt,
411
410
  {
412
411
  ...V ? { initialArtboardConfig: V } : {},
413
- children: f
412
+ children: p
414
413
  }
415
414
  ) }) }) });
416
415
  return a ? /* @__PURE__ */ l(Fe, { services: a, children: he }) : he;
@@ -432,8 +431,8 @@ function Ie(t) {
432
431
  }),
433
432
  // eslint-disable-next-line react-hooks/exhaustive-deps
434
433
  [s.current.internals, d.current.commerce]
435
- ), f = x(n);
436
- f.current = n;
434
+ ), p = x(n);
435
+ p.current = n;
437
436
  const m = x(r);
438
437
  m.current = r;
439
438
  const y = x(null), b = F((w) => {
@@ -442,17 +441,17 @@ function Ie(t) {
442
441
  () => Se({
443
442
  registry: s.current.internals.registry,
444
443
  store: s.current.internals.store,
445
- product: f.current
444
+ product: p.current
446
445
  }),
447
446
  []
448
447
  );
449
- Q(() => ft({ compute: o }), [o]);
448
+ Q(() => pt({ compute: o }), [o]);
450
449
  const g = x(!1);
451
450
  return $(() => {
452
451
  let w = !1;
453
452
  return queueMicrotask(() => {
454
- var p;
455
- w || g.current || (g.current = !0, (p = m.current) == null || p.call(m, y.current ?? o()));
453
+ var f;
454
+ w || g.current || (g.current = !0, (f = m.current) == null || f.call(m, y.current ?? o()));
456
455
  }), () => {
457
456
  w = !0;
458
457
  };
@@ -461,7 +460,7 @@ function Ie(t) {
461
460
  // wrapper, which had no DOM at all, stays layout-identical).
462
461
  /* @__PURE__ */ l("div", { className: "sc-root", style: { display: "contents" }, "data-sc-part": "root", children: /* @__PURE__ */ l(vt, { reportedError: c, onRetry: () => u(null), children: /* @__PURE__ */ l(bt, { ...t, internals: a, recordAudit: b }) }) });
463
462
  }
464
- let wt = () => import("./EditorCanvasImpl-DXeBz2CX.js").then((t) => t.EditorCanvasImpl);
463
+ let wt = () => import("./EditorCanvasImpl-4voOsj2k.js").then((t) => t.EditorCanvasImpl);
465
464
  function Oe() {
466
465
  return wt();
467
466
  }
@@ -470,12 +469,12 @@ const Et = we(function({ children: e, maxHeight: n, floatingToolbar: r = !0, cla
470
469
  J("Editor.Canvas", { floatingToolbar: r });
471
470
  const u = de();
472
471
  Q(() => c.registry.registerCanvas(u), [c.registry, u]);
473
- const [a, f] = C(null);
472
+ const [a, p] = C(null);
474
473
  return $(() => {
475
474
  let m = !1;
476
475
  return Oe().then(
477
476
  (y) => {
478
- m || f(() => y);
477
+ m || p(() => y);
479
478
  },
480
479
  (y) => {
481
480
  m || c.reportRuntimeError(
@@ -601,12 +600,12 @@ const Ne = Ye(function({
601
600
  }, []);
602
601
  const [d, c] = C(!1);
603
602
  $(() => {
604
- const f = requestAnimationFrame(() => c(!0));
605
- return () => cancelAnimationFrame(f);
603
+ const p = requestAnimationFrame(() => c(!0));
604
+ return () => cancelAnimationFrame(p);
606
605
  }, []);
607
606
  const u = F(
608
- (f) => {
609
- f.propertyName === "background-color" && (e || n == null || n());
607
+ (p) => {
608
+ p.propertyName === "background-color" && (e || n == null || n());
610
609
  },
611
610
  [e, n]
612
611
  );
@@ -619,18 +618,18 @@ const Ne = Ye(function({
619
618
  onTransitionEnd: u,
620
619
  "aria-hidden": "true",
621
620
  children: [
622
- Array.from({ length: 6 }, (f, m) => /* @__PURE__ */ l("div", { className: "sc-prism-band" }, `b-${m}`)),
623
- i.map((f, m) => /* @__PURE__ */ l(
621
+ Array.from({ length: 6 }, (p, m) => /* @__PURE__ */ l("div", { className: "sc-prism-band" }, `b-${m}`)),
622
+ i.map((p, m) => /* @__PURE__ */ l(
624
623
  "div",
625
624
  {
626
625
  className: "sc-prism-particle",
627
626
  style: {
628
- left: `${f.left}%`,
629
- top: `${f.top}%`,
630
- animationDelay: `${f.delay}s`,
631
- animationDuration: `${f.duration}s`,
632
- width: `${f.size}px`,
633
- height: `${f.size}px`
627
+ left: `${p.left}%`,
628
+ top: `${p.top}%`,
629
+ animationDelay: `${p.delay}s`,
630
+ animationDuration: `${p.duration}s`,
631
+ width: `${p.size}px`,
632
+ height: `${p.size}px`
634
633
  }
635
634
  },
636
635
  `p-${m}`
@@ -681,18 +680,18 @@ function $e({
681
680
  }) {
682
681
  const { mockups: d, error: c, isRendering: u } = K();
683
682
  J("Editor.Preview", { ...t !== void 0 ? { mockupId: t } : {} });
684
- const a = $t(r), f = a === "dark" || a === "light" ? a : null, m = Ee(a) ? a : null, y = a !== "host-owned", { showOverlay: b, overlayVisible: o, handleExited: g } = Te(
683
+ const a = $t(r), p = a === "dark" || a === "light" ? a : null, m = Ee(a) ? a : null, y = a !== "host-owned", { showOverlay: b, overlayVisible: o, handleExited: g } = Te(
685
684
  y && u
686
- ), w = x(/* @__PURE__ */ new Set()), p = t ? d.find((v) => v.mockupId === t && v.imageUrl) : d.find((v) => v.imageUrl), S = (v) => {
685
+ ), w = x(/* @__PURE__ */ new Set()), f = t ? d.find((v) => v.mockupId === t && v.imageUrl) : d.find((v) => v.imageUrl), S = (v) => {
687
686
  var P;
688
- if (!p || typeof L > "u" || ((P = L.env) == null ? void 0 : P.NODE_ENV) === "production" || typeof window > "u" || w.current.has(p.mockupId)) return;
687
+ if (!f || typeof L > "u" || ((P = L.env) == null ? void 0 : P.NODE_ENV) === "production" || typeof window > "u" || w.current.has(f.mockupId)) return;
689
688
  const V = v.currentTarget, R = V.getBoundingClientRect().width;
690
689
  if (R <= 0) return;
691
690
  const _ = Math.round(R * (window.devicePixelRatio || 1)), D = Tt(V.naturalWidth, _);
692
- D && (w.current.add(p.mockupId), console.warn(D));
691
+ D && (w.current.add(f.mockupId), console.warn(D));
693
692
  };
694
693
  if (y) {
695
- const v = p != null && p.imageUrl ? u ? "rendering" : "ready" : c ? "error" : "rendering";
694
+ const v = f != null && f.imageUrl ? u ? "rendering" : "ready" : c ? "error" : "rendering";
696
695
  return /* @__PURE__ */ N(
697
696
  "div",
698
697
  {
@@ -702,9 +701,9 @@ function $e({
702
701
  className: `sc-preview-frame${i ? ` ${i}` : ""}`,
703
702
  style: s,
704
703
  children: [
705
- p != null && p.imageUrl ? (
704
+ f != null && f.imageUrl ? (
706
705
  // eslint-disable-next-line @next/next/no-img-element
707
- /* @__PURE__ */ l("img", { "data-sc-part": "preview-image", src: p.imageUrl, alt: n, onLoad: S })
706
+ /* @__PURE__ */ l("img", { "data-sc-part": "preview-image", src: f.imageUrl, alt: n, onLoad: S })
708
707
  ) : c ? /* @__PURE__ */ l("div", { "data-sc-part": "preview-error", role: "alert", "data-sc-error": c, children: e ?? `Render failed: ${c}` }) : e,
709
708
  m ? (
710
709
  // Custom indicator: same show-delay + linger window; no exit fade
@@ -719,11 +718,11 @@ function $e({
719
718
  children: m
720
719
  }
721
720
  ) : null
722
- ) : b && f ? /* @__PURE__ */ l(
721
+ ) : b && p ? /* @__PURE__ */ l(
723
722
  Ne,
724
723
  {
725
724
  visible: o,
726
- variant: f,
725
+ variant: p,
727
726
  onExited: g
728
727
  }
729
728
  ) : null
@@ -731,14 +730,14 @@ function $e({
731
730
  }
732
731
  );
733
732
  }
734
- return p != null && p.imageUrl ? (
733
+ return f != null && f.imageUrl ? (
735
734
  // eslint-disable-next-line @next/next/no-img-element
736
735
  /* @__PURE__ */ l(
737
736
  "img",
738
737
  {
739
738
  "data-sc-part": "preview",
740
739
  "data-sc-preview-state": u ? "rendering" : "ready",
741
- src: p.imageUrl,
740
+ src: f.imageUrl,
742
741
  alt: n,
743
742
  className: i,
744
743
  style: s,
@@ -761,8 +760,8 @@ function $e({
761
760
  function _t(t) {
762
761
  const { layer: e, optional: n = !1, placeholder: r, className: i, style: s } = t, d = H("Editor.TextField");
763
762
  J("Editor.TextField");
764
- const { pushRender: c, throttleMs: u, stateStore: a } = K(), f = de(), m = x(null);
765
- if (!st(e))
763
+ const { pushRender: c, throttleMs: u, stateStore: a } = K(), p = de(), m = x(null);
764
+ if (!ot(e))
766
765
  throw new T(
767
766
  "E_LAYER_TOKEN_REQUIRED",
768
767
  `the \`layer\` prop must be a token minted by the design — pass layer={design.layer("name")}, not ${typeof e == "string" ? `the bare string "${e}"` : "a plain value"}. Tokens validate the name against the design's layers at mint time.`,
@@ -784,7 +783,7 @@ function _t(t) {
784
783
  );
785
784
  m.current = e.name;
786
785
  }
787
- Q(() => d.registry.registerTextField(f, { name: e.name, optional: n }), [d.registry, f, e.name, n]);
786
+ Q(() => d.registry.registerTextField(p, { name: e.name, optional: n }), [d.registry, p, e.name, n]);
788
787
  const y = z(
789
788
  a.subscribe,
790
789
  () => a.textOf(e.name) ?? "",
@@ -862,9 +861,9 @@ function Pt(t) {
862
861
  "<Editor.Buy> has no product context — pass `product` (with `productId`) on <Editor.Root product={…}>. Buy assembles its cart payload from the Root product and the live design state.",
863
862
  { docSlug: "embed-mode" }
864
863
  );
865
- const f = x(!1);
864
+ const p = x(!1);
866
865
  Q(() => {
867
- f.current || (f.current = !0, typeof n == "number" && a.setQuantity(n));
866
+ p.current || (p.current = !0, typeof n == "number" && a.setQuantity(n));
868
867
  }, [a]);
869
868
  const m = z(u.subscribe, u.getState, u.getState), y = z(a.subscribe, a.getVersion, a.getVersion), b = z(
870
869
  d.registry.subscribe,
@@ -882,7 +881,7 @@ function Pt(t) {
882
881
  }),
883
882
  // eslint-disable-next-line react-hooks/exhaustive-deps
884
883
  [a, o, m, y, b]
885
- ), w = g.length === 0, [p, S] = C(!1), v = x(!1), V = F(() => {
884
+ ), w = g.length === 0, [f, S] = C(!1), v = x(!1), V = F(() => {
886
885
  if (v.current || !w) return;
887
886
  v.current = !0, S(!0);
888
887
  const R = u.getState(), _ = a.resolvedVariantId(), D = {
@@ -909,10 +908,10 @@ function Pt(t) {
909
908
  {
910
909
  type: "button",
911
910
  "data-sc-part": "buy",
912
- "data-sc-buy-state": p ? "busy" : w ? "ready" : "incomplete",
911
+ "data-sc-buy-state": f ? "busy" : w ? "ready" : "incomplete",
913
912
  "data-sc-buy-missing": g.join(",") || void 0,
914
- disabled: !w || p,
915
- "aria-busy": p || void 0,
913
+ disabled: !w || f,
914
+ "aria-busy": f || void 0,
916
915
  onClick: V,
917
916
  className: i,
918
917
  style: s,
@@ -936,7 +935,7 @@ function Lt({
936
935
  return $(() => {
937
936
  if (!s) return;
938
937
  let u = !1;
939
- return import("./ContextualToolbars-C3D_6sep.js").then((a) => a.s).then(
938
+ return import("./ContextualToolbars-BKU8IoAM.js").then((a) => a.s).then(
940
939
  (a) => {
941
940
  u || c(() => a.ContextualToolbars);
942
941
  },
@@ -1028,23 +1027,23 @@ const M = {
1028
1027
  * Fills its positioned parent; rides the session (canvas-free). */
1029
1028
  LoadingOverlay: Vt
1030
1029
  };
1031
- function sn(t) {
1030
+ function on(t) {
1032
1031
  return /* @__PURE__ */ l(Ie, { ...t, __validation: "warn" });
1033
1032
  }
1034
- const an = we(
1033
+ const sn = we(
1035
1034
  function(e, n) {
1036
1035
  const { children: r, className: i, style: s, maxHeight: d, ...c } = e, [u, a] = C(null);
1037
1036
  return $(() => {
1038
- let f = !1;
1037
+ let p = !1;
1039
1038
  return Oe().then(
1040
1039
  (m) => {
1041
- f || a(() => m);
1040
+ p || a(() => m);
1042
1041
  },
1043
1042
  (m) => {
1044
1043
  console.error("[RealtimeCanvas] failed to load the rendering chunk:", m);
1045
1044
  }
1046
1045
  ), () => {
1047
- f = !0;
1046
+ p = !0;
1048
1047
  };
1049
1048
  }, []), u ? /* @__PURE__ */ l(u, { ref: n, selfScope: !0, maxHeight: d, className: i, style: s, ...c, children: r }) : /* @__PURE__ */ l(
1050
1049
  "div",
@@ -1056,19 +1055,19 @@ const an = we(
1056
1055
  );
1057
1056
  }
1058
1057
  );
1059
- function dn(t) {
1058
+ function an(t) {
1060
1059
  return /* @__PURE__ */ l($e, { ...t });
1061
1060
  }
1062
- function ln() {
1061
+ function dn() {
1063
1062
  const { mockups: t, isRendering: e, error: n } = K();
1064
1063
  return { mockups: t, isRendering: e, error: n };
1065
1064
  }
1066
1065
  function Ft(t) {
1067
1066
  return t.type !== "color" && typeof t.width == "number" && t.width > 0 && typeof t.height == "number" && t.height > 0;
1068
1067
  }
1069
- function cn(t, e = {}) {
1068
+ function ln(t, e = {}) {
1070
1069
  var y, b, o, g, w;
1071
- const n = (t.placements ?? []).filter(Ft), r = n.map((p) => p.label), i = e.placement ? n.find((p) => p.label === e.placement) : n[0];
1070
+ const n = (t.placements ?? []).filter(Ft), r = n.map((f) => f.label), i = e.placement ? n.find((f) => f.label === e.placement) : n[0];
1072
1071
  if (!i)
1073
1072
  throw e.placement ? new T(
1074
1073
  "E_PRODUCT_NOT_RENDERABLE",
@@ -1080,17 +1079,17 @@ function cn(t, e = {}) {
1080
1079
  { productId: t.id, docSlug: "embed-mode" }
1081
1080
  );
1082
1081
  const s = ((y = t.options) == null ? void 0 : y.attributes) ?? {}, c = Object.values(s).some(
1083
- (p) => {
1082
+ (f) => {
1084
1083
  var S;
1085
- return (S = p == null ? void 0 : p.choices) == null ? void 0 : S.some((v) => v == null ? void 0 : v.hex);
1084
+ return (S = f == null ? void 0 : f.choices) == null ? void 0 : S.some((v) => v == null ? void 0 : v.hex);
1086
1085
  }
1087
1086
  ) ? (g = (o = (b = t.options) == null ? void 0 : b.combinations) == null ? void 0 : o.find(
1088
- (p) => typeof p.variantId == "string" && p.variantId !== ""
1089
- )) == null ? void 0 : g.variantId : void 0, u = t.mockups ?? [], a = c ? u.filter((p) => {
1087
+ (f) => typeof f.variantId == "string" && f.variantId !== ""
1088
+ )) == null ? void 0 : g.variantId : void 0, u = t.mockups ?? [], a = c ? u.filter((f) => {
1090
1089
  var S;
1091
- return (S = p.gvids) == null ? void 0 : S.includes(c);
1092
- }) : u, f = (a.length > 0 ? a : u).map((p) => p.id);
1093
- if (f.length === 0)
1090
+ return (S = f.gvids) == null ? void 0 : S.includes(c);
1091
+ }) : u, p = (a.length > 0 ? a : u).map((f) => f.id);
1092
+ if (p.length === 0)
1094
1093
  throw new T(
1095
1094
  "E_PRODUCT_NOT_RENDERABLE",
1096
1095
  `product ${t.id} has no mockup scenes — nothing to render a preview into.`,
@@ -1099,10 +1098,10 @@ function cn(t, e = {}) {
1099
1098
  return {
1100
1099
  product: {
1101
1100
  productId: t.id,
1102
- mockupIds: f,
1101
+ mockupIds: p,
1103
1102
  ...typeof c == "string" ? { variantId: c } : {},
1104
1103
  options: t.options,
1105
- placements: (w = t.placements) == null ? void 0 : w.map((p) => p.label),
1104
+ placements: (w = t.placements) == null ? void 0 : w.map((f) => f.label),
1106
1105
  mockups: u,
1107
1106
  requiredPlacements: t.requiredPlacements,
1108
1107
  ...t.defaultGvid ? { defaultGvid: t.defaultGvid } : {},
@@ -1115,13 +1114,13 @@ function cn(t, e = {}) {
1115
1114
  aspectRatio: i.width / i.height
1116
1115
  },
1117
1116
  placementLabels: r,
1118
- placements: n.map((p) => ({
1119
- label: p.label,
1120
- width: p.width,
1121
- height: p.height,
1122
- aspectRatio: p.width / p.height
1117
+ placements: n.map((f) => ({
1118
+ label: f.label,
1119
+ width: f.width,
1120
+ height: f.height,
1121
+ aspectRatio: f.width / f.height
1123
1122
  })),
1124
- primaryMockupId: f[0],
1123
+ primaryMockupId: p[0],
1125
1124
  variantId: c
1126
1125
  };
1127
1126
  }
@@ -1240,15 +1239,15 @@ function qt({
1240
1239
  }
1241
1240
  }
1242
1241
  ),
1243
- n > 1 ? Array.from({ length: n }, (a, f) => /* @__PURE__ */ l(
1242
+ n > 1 ? Array.from({ length: n }, (a, p) => /* @__PURE__ */ l(
1244
1243
  ae,
1245
1244
  {
1246
- label: `View ${f + 1}${f === r ? " ✓" : ""}`,
1245
+ label: `View ${p + 1}${p === r ? " ✓" : ""}`,
1247
1246
  onSelect: () => {
1248
- u(), i(f);
1247
+ u(), i(p);
1249
1248
  }
1250
1249
  },
1251
- f
1250
+ p
1252
1251
  )) : null,
1253
1252
  /* @__PURE__ */ l(
1254
1253
  ae,
@@ -1365,7 +1364,7 @@ function Wt({
1365
1364
  className: s,
1366
1365
  style: d
1367
1366
  }) {
1368
- const [c, u] = C(!1), [a, f] = C(0), [m, y] = C(!1), b = x(null), o = ct(), g = n[Math.min(a, n.length - 1)], w = F(async () => {
1367
+ const [c, u] = C(!1), [a, p] = C(0), [m, y] = C(!1), b = x(null), o = ct(), g = n[Math.min(a, n.length - 1)], w = F(async () => {
1369
1368
  var D;
1370
1369
  const v = await ((D = b.current) == null ? void 0 : D.exportArtboards({ format: "dataUrl" }));
1371
1370
  if (!v) return;
@@ -1373,7 +1372,7 @@ function Wt({
1373
1372
  if (typeof R != "string") return;
1374
1373
  const _ = document.createElement("a");
1375
1374
  _.href = R, _.download = `${V ?? "design"}.png`, _.click();
1376
- }, []), p = {
1375
+ }, []), f = {
1377
1376
  display: "flex",
1378
1377
  flexDirection: "column",
1379
1378
  overflow: "hidden",
@@ -1415,7 +1414,7 @@ function Wt({
1415
1414
  "data-sc-part": "snowcone-editor",
1416
1415
  "data-sc-fullscreen": c ? "true" : void 0,
1417
1416
  className: s,
1418
- style: p,
1417
+ style: f,
1419
1418
  children: [
1420
1419
  /* @__PURE__ */ N(
1421
1420
  "div",
@@ -1438,7 +1437,7 @@ function Wt({
1438
1437
  onToggleFullscreen: () => u((v) => !v),
1439
1438
  viewCount: n.length,
1440
1439
  viewIndex: a,
1441
- onSelectView: f,
1440
+ onSelectView: p,
1442
1441
  onExport: () => void w()
1443
1442
  }
1444
1443
  ),
@@ -1544,7 +1543,7 @@ function Wt({
1544
1543
  }
1545
1544
  );
1546
1545
  }
1547
- function un(t) {
1546
+ function cn(t) {
1548
1547
  const {
1549
1548
  onAddToCart: e,
1550
1549
  defaultQuantity: n,
@@ -1570,18 +1569,18 @@ function un(t) {
1570
1569
  We();
1571
1570
  export {
1572
1571
  M as E,
1573
- an as R,
1574
- un as S,
1575
- sn as a,
1576
- dn as b,
1577
- on as c,
1572
+ sn as R,
1573
+ cn as S,
1574
+ on as a,
1575
+ an as b,
1576
+ rn as c,
1578
1577
  Re as d,
1579
1578
  xt as e,
1580
1579
  Ut as f,
1581
1580
  Bt as g,
1582
- ln as h,
1583
- cn as p,
1581
+ dn as h,
1582
+ ln as p,
1584
1583
  K as u,
1585
- pt as v
1584
+ ft as v
1586
1585
  };
1587
- //# sourceMappingURL=embed-Csez1hui.js.map
1586
+ //# sourceMappingURL=embed-C69x0jHc.js.map