@snowcone-app/canvas 0.44.2 → 0.46.1
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.
- package/ERROR_CONTRACT.md +1 -1
- package/dist/{ContextualToolbars-rCZo-KCm.js → ContextualToolbars-5tHC6s0Y.js} +4 -4
- package/dist/{ContextualToolbars-rCZo-KCm.js.map → ContextualToolbars-5tHC6s0Y.js.map} +1 -1
- package/dist/{EditorCanvasImpl-Dcati77U.js → EditorCanvasImpl-Cd_umlTI.js} +6 -6
- package/dist/{EditorCanvasImpl-Dcati77U.js.map → EditorCanvasImpl-Cd_umlTI.js.map} +1 -1
- package/dist/{ImagePanel-DhOWKvIN.js → ImagePanel-bW3yr6Ac.js} +264 -259
- package/dist/{ImagePanel-DhOWKvIN.js.map → ImagePanel-bW3yr6Ac.js.map} +1 -1
- package/dist/{SnowconeCanvas-DjszZvte.js → SnowconeCanvas-crxPwbib.js} +441 -439
- package/dist/SnowconeCanvas-crxPwbib.js.map +1 -0
- package/dist/advanced.mjs +9 -9
- package/dist/components/editor/EditorPreview.d.ts +19 -8
- package/dist/components/editor/index.d.ts +1 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +6 -0
- package/dist/components/embed/kernel.d.ts +2 -0
- package/dist/{custom-icons-C4bzABm2.js → custom-icons-DQRp8GhF.js} +2 -2
- package/dist/{custom-icons-C4bzABm2.js.map → custom-icons-DQRp8GhF.js.map} +1 -1
- package/dist/{design-builder-DCHVrEFV.js → design-builder-sH53Og6j.js} +598 -589
- package/dist/design-builder-sH53Og6j.js.map +1 -0
- package/dist/{embed-DNWM7gZL.js → embed-DvN5BVmQ.js} +669 -657
- package/dist/embed-DvN5BVmQ.js.map +1 -0
- package/dist/embed.mjs +4 -4
- package/dist/index.mjs +7 -7
- package/dist/{template-fields-CK7Uvvc8.js → template-fields-BaQG0CJY.js} +3 -3
- package/dist/{template-fields-CK7Uvvc8.js.map → template-fields-BaQG0CJY.js.map} +1 -1
- package/dist/testing.mjs +2 -2
- package/dist/{useCommands-BrkGKdXr.js → useCommands-F-b_SwW-.js} +3 -3
- package/dist/{useCommands-BrkGKdXr.js.map → useCommands-F-b_SwW-.js.map} +1 -1
- package/dist/{validation-CaBO9Iw-.js → validation-hn5ZX8Po.js} +8 -8
- package/dist/{validation-CaBO9Iw-.js.map → validation-hn5ZX8Po.js.map} +1 -1
- package/example/package.json +1 -1
- package/package.json +4 -3
- package/dist/SnowconeCanvas-DjszZvte.js.map +0 -1
- package/dist/design-builder-DCHVrEFV.js.map +0 -1
- package/dist/embed-DNWM7gZL.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { t as
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useContext as
|
|
5
|
-
import { assertVariantSelected as
|
|
6
|
-
import { s as ee, B as
|
|
7
|
-
import { u as
|
|
8
|
-
import { D as
|
|
1
|
+
import { n as Ze, o as et, E as tt, C as nt, y as se, z as oe, A as rt, F as it, G as st, H as ot, J as at, l as dt, e as lt } from "./useCommands-F-b_SwW-.js";
|
|
2
|
+
import { t as R, Z as De, p as z } from "./FontAnalyzer-Ds3Wdba7.js";
|
|
3
|
+
import { jsx as h, jsxs as U, Fragment as ct } from "react/jsx-runtime";
|
|
4
|
+
import we, { useContext as ut, createContext as mt, useRef as $, useState as A, useMemo as L, useCallback as K, useLayoutEffect as ae, useEffect as F, useSyncExternalStore as J, Component as pt, forwardRef as Le, useId as Ee, memo as ft, isValidElement as ke } from "react";
|
|
5
|
+
import { assertVariantSelected as ht, RenderSession as gt, createCartDetail as yt } from "@snowcone-app/sdk";
|
|
6
|
+
import { s as ee, B as bt, E as vt, w as wt, m as Et } from "./design-builder-sH53Og6j.js";
|
|
7
|
+
import { u as kt, p as xt } from "./usePieceGuideBundle-BWdobHQE.js";
|
|
8
|
+
import { D as St, C as Rt, f as It, d as Ot } from "./template-fields-BaQG0CJY.js";
|
|
9
9
|
import "./ExportManager-xRsXgyNo.js";
|
|
10
10
|
import "./CanvasStateV1-BlDWgOzV.js";
|
|
11
|
-
const Be =
|
|
11
|
+
const Be = mt(void 0);
|
|
12
12
|
function te() {
|
|
13
|
-
const e =
|
|
13
|
+
const e = ut(Be);
|
|
14
14
|
if (!e)
|
|
15
15
|
throw new Error(
|
|
16
16
|
"useRealtimeMockups / <RealtimeCanvas> / <RealtimeMockup> must be rendered inside <RealtimeEmbed>. Wrap them: <RealtimeEmbed shop=… product=… design=… grantUrl=…>…</RealtimeEmbed>"
|
|
@@ -22,178 +22,178 @@ function Ue(e) {
|
|
|
22
22
|
return Array.isArray((t = e.bundle) == null ? void 0 : t.members) && e.bundle.members.length > 0;
|
|
23
23
|
}
|
|
24
24
|
const W = "bundles";
|
|
25
|
-
function
|
|
25
|
+
function $t(e) {
|
|
26
26
|
return Object.keys(e).sort().map((t) => `${t}:${e[t]}`).join(",");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function xe(e) {
|
|
29
29
|
const t = e.indexOf(".");
|
|
30
30
|
return t <= 0 || t === e.length - 1 ? null : { role: e.slice(0, t), key: e.slice(t + 1) };
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Ct(e) {
|
|
33
33
|
return e.type !== "color" && typeof e.width == "number" && e.width > 0 && typeof e.height == "number" && e.height > 0;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
var i,
|
|
37
|
-
const n = (
|
|
35
|
+
function Nt(e, t) {
|
|
36
|
+
var i, o;
|
|
37
|
+
const n = (o = (i = e.options) == null ? void 0 : i.combinations) == null ? void 0 : o.find((a) => a.variantId === t);
|
|
38
38
|
if (!n) return t;
|
|
39
|
-
const r = Object.entries(n).filter(([
|
|
39
|
+
const r = Object.entries(n).filter(([a, l]) => a !== "variantId" && a !== "price" && (typeof l == "string" || typeof l == "number")).map(([a, l]) => `${a} ${String(l)}`);
|
|
40
40
|
return r.length > 0 ? r.join(" · ") : t;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
var
|
|
42
|
+
function Nn(e, t = {}) {
|
|
43
|
+
var y, D, N, T, P;
|
|
44
44
|
if (!Ue(e))
|
|
45
|
-
throw new
|
|
45
|
+
throw new R(
|
|
46
46
|
"E_NOT_A_BUNDLE",
|
|
47
47
|
`product ${e.id} has no bundle block — picks / variants are bundle parameters the server refuses on a single product (E_NOT_A_BUNDLE). Use productToRenderConfig() for it.`,
|
|
48
48
|
{ productId: e.id, docSlug: W }
|
|
49
49
|
);
|
|
50
|
-
const n = e.bundle.members, r = n.map((
|
|
51
|
-
for (const [
|
|
50
|
+
const n = e.bundle.members, r = n.map((m) => m.role);
|
|
51
|
+
for (const [m, S] of [
|
|
52
52
|
["picks", t.picks],
|
|
53
53
|
["variants", t.variants]
|
|
54
54
|
])
|
|
55
|
-
for (const
|
|
56
|
-
if (!r.includes(
|
|
57
|
-
throw new
|
|
55
|
+
for (const B of Object.keys(S ?? {}))
|
|
56
|
+
if (!r.includes(B))
|
|
57
|
+
throw new R(
|
|
58
58
|
"E_BUNDLE_ROLE_NOT_FOUND",
|
|
59
|
-
`bundle ${e.id} has no role "${
|
|
60
|
-
{ productId: e.id, field:
|
|
59
|
+
`bundle ${e.id} has no role "${B}" (in ${m}). Roles: [${r.join(", ")}].`,
|
|
60
|
+
{ productId: e.id, field: m, role: B, validNames: r, docSlug: W }
|
|
61
61
|
);
|
|
62
|
-
const i = {},
|
|
63
|
-
for (const
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
throw new
|
|
62
|
+
const i = {}, o = {}, a = {}, l = e.placements ?? [], d = [];
|
|
63
|
+
for (const m of n) {
|
|
64
|
+
const S = m.products.map((w) => w.productId), B = (y = t.picks) == null ? void 0 : y[m.role], _ = B === void 0 ? m.products[0] : m.products.find((w) => w.productId === B);
|
|
65
|
+
if (!_)
|
|
66
|
+
throw new R(
|
|
67
67
|
"E_BUNDLE_PICK_NOT_FOUND",
|
|
68
|
-
`bundle ${e.id} role "${
|
|
69
|
-
{ productId: e.id, role:
|
|
68
|
+
`bundle ${e.id} role "${m.role}" has no alternative "${B}". Alternatives: [${S.join(", ")}] — pass picks: { ${m.role}: "${S[0]}" }.`,
|
|
69
|
+
{ productId: e.id, role: m.role, requested: B, validNames: S, docSlug: W }
|
|
70
70
|
);
|
|
71
|
-
i[
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
const w = (N = t.variants) == null ? void 0 : N[
|
|
75
|
-
throw new
|
|
71
|
+
i[m.role] = _.productId;
|
|
72
|
+
const V = (_.variants ?? []).map((w) => w.gvid).filter((w) => typeof w == "string" && w !== ""), j = V.length > 0 ? V : _.defaultGvid ? [_.defaultGvid] : [], G = ((D = t.variants) == null ? void 0 : D[m.role]) ?? _.defaultGvid ?? V[0];
|
|
73
|
+
if (!G || !j.includes(G)) {
|
|
74
|
+
const w = (N = t.variants) == null ? void 0 : N[m.role];
|
|
75
|
+
throw new R(
|
|
76
76
|
"E_BUNDLE_VARIANT_NOT_FOUND",
|
|
77
|
-
|
|
77
|
+
j.length === 0 ? `bundle ${e.id} role "${m.role}": alternative ${_.productId} publishes no variant — nothing can render this slot (catalog data is incomplete).` : `bundle ${e.id} role "${m.role}" (${_.productId}) has no variant "${w}". Variants: [${j.join(", ")}] — pass variants: { ${m.role}: "${j[0]}" }.`,
|
|
78
78
|
{
|
|
79
79
|
productId: e.id,
|
|
80
|
-
role:
|
|
81
|
-
memberProductId:
|
|
80
|
+
role: m.role,
|
|
81
|
+
memberProductId: _.productId,
|
|
82
82
|
requested: w,
|
|
83
|
-
validNames:
|
|
83
|
+
validNames: j,
|
|
84
84
|
docSlug: W
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
o[m.role] = G, a[m.role] = ((P = (T = _.variants) == null ? void 0 : T.find((w) => w.gvid === G)) == null ? void 0 : P.gvidForMockup) || G;
|
|
89
89
|
const X = l.filter(
|
|
90
|
-
(w) => w.role ===
|
|
90
|
+
(w) => w.role === m.role && w.memberProductId === _.productId && typeof w.key == "string" && w.key !== "" && Ct(w)
|
|
91
91
|
).map((w) => ({
|
|
92
92
|
key: w.key,
|
|
93
|
-
role:
|
|
93
|
+
role: m.role,
|
|
94
94
|
label: w.label,
|
|
95
|
-
memberProductId:
|
|
95
|
+
memberProductId: _.productId,
|
|
96
96
|
width: w.width,
|
|
97
97
|
height: w.height,
|
|
98
98
|
aspectRatio: w.width / w.height
|
|
99
99
|
}));
|
|
100
100
|
d.push({
|
|
101
|
-
role:
|
|
102
|
-
required:
|
|
103
|
-
alternatives:
|
|
104
|
-
pick:
|
|
105
|
-
variantId:
|
|
106
|
-
variantChoices:
|
|
101
|
+
role: m.role,
|
|
102
|
+
required: m.required !== !1,
|
|
103
|
+
alternatives: S,
|
|
104
|
+
pick: _.productId,
|
|
105
|
+
variantId: G,
|
|
106
|
+
variantChoices: j.map((w) => ({ gvid: w, label: Nt(_, w) })),
|
|
107
107
|
placements: X
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
for (const
|
|
112
|
-
if (typeof
|
|
113
|
-
const
|
|
114
|
-
|
|
110
|
+
const s = new Set(d.flatMap((m) => m.placements.map((S) => S.key))), u = new Map(d.flatMap((m) => m.placements.map((S) => [S.key, S]))), c = [];
|
|
111
|
+
for (const m of l) {
|
|
112
|
+
if (typeof m.key != "string" || !s.has(m.key)) continue;
|
|
113
|
+
const S = u.get(m.key);
|
|
114
|
+
S && !c.includes(S) && c.push(S);
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const v = c.map((m) => m.key);
|
|
117
117
|
let x;
|
|
118
118
|
if (t.placement !== void 0) {
|
|
119
|
-
if (!
|
|
120
|
-
throw new
|
|
119
|
+
if (!xe(t.placement))
|
|
120
|
+
throw new R(
|
|
121
121
|
"E_BUNDLE_ROLE_REQUIRED",
|
|
122
|
-
`placement "${t.placement}" names no role — on bundle ${e.id} a placement is addressed by its role-scoped key. Keys: [${
|
|
123
|
-
{ productId: e.id, requested: t.placement, validNames:
|
|
122
|
+
`placement "${t.placement}" names no role — on bundle ${e.id} a placement is addressed by its role-scoped key. Keys: [${v.join(", ")}].`,
|
|
123
|
+
{ productId: e.id, requested: t.placement, validNames: v, docSlug: W }
|
|
124
124
|
);
|
|
125
|
-
if (x = c.find((
|
|
126
|
-
throw new
|
|
125
|
+
if (x = c.find((m) => m.key === t.placement), !x)
|
|
126
|
+
throw new R(
|
|
127
127
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
128
|
-
`bundle ${e.id} has no renderable placement "${t.placement}" for picks ${JSON.stringify(i)}. Keys: [${
|
|
129
|
-
{ productId: e.id, requested: t.placement, picks: i, validNames:
|
|
128
|
+
`bundle ${e.id} has no renderable placement "${t.placement}" for picks ${JSON.stringify(i)}. Keys: [${v.join(", ")}].`,
|
|
129
|
+
{ productId: e.id, requested: t.placement, picks: i, validNames: v, docSlug: W }
|
|
130
130
|
);
|
|
131
131
|
} else
|
|
132
132
|
x = c[0];
|
|
133
133
|
if (!x)
|
|
134
|
-
throw new
|
|
134
|
+
throw new R(
|
|
135
135
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
136
136
|
`bundle ${e.id} has no renderable image placement for picks ${JSON.stringify(i)} (a role-scoped, non-color placement with width/height). The catalog payload may be incomplete — fetch it via getProduct(), not a search hit.`,
|
|
137
137
|
{ productId: e.id, picks: i, docSlug: W }
|
|
138
138
|
);
|
|
139
|
-
const
|
|
140
|
-
(
|
|
141
|
-
),
|
|
142
|
-
if (
|
|
143
|
-
throw new
|
|
139
|
+
const p = e.mockups ?? [], E = p.filter(
|
|
140
|
+
(m) => !m.picks || Object.entries(m.picks).every(([S, B]) => i[S] === B)
|
|
141
|
+
), b = (E.length > 0 ? E : p).map((m) => m.id);
|
|
142
|
+
if (b.length === 0)
|
|
143
|
+
throw new R(
|
|
144
144
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
145
145
|
`bundle ${e.id} has no mockup scenes — nothing to render a preview into.`,
|
|
146
146
|
{ productId: e.id, docSlug: W }
|
|
147
147
|
);
|
|
148
|
-
const
|
|
148
|
+
const g = (e.requiredPlacements ?? []).filter((m) => typeof m.key == "string" && m.key !== "" && s.has(m.key)).map((m) => ({ label: m.key, key: m.key, type: m.type, autoFilledByVariant: m.autoFilledByVariant }));
|
|
149
149
|
return {
|
|
150
150
|
kind: "bundle",
|
|
151
151
|
product: {
|
|
152
152
|
productId: e.id,
|
|
153
|
-
mockupIds:
|
|
153
|
+
mockupIds: b,
|
|
154
154
|
picks: i,
|
|
155
|
-
variants:
|
|
156
|
-
placements:
|
|
157
|
-
mockups:
|
|
158
|
-
...
|
|
155
|
+
variants: o,
|
|
156
|
+
placements: v,
|
|
157
|
+
mockups: p,
|
|
158
|
+
...g.length > 0 ? { requiredPlacements: g } : {},
|
|
159
159
|
...typeof t.width == "number" ? { width: t.width } : {}
|
|
160
160
|
},
|
|
161
161
|
picks: i,
|
|
162
|
-
variants:
|
|
163
|
-
variantToken:
|
|
162
|
+
variants: o,
|
|
163
|
+
variantToken: $t(a),
|
|
164
164
|
roles: d,
|
|
165
165
|
placement: x,
|
|
166
166
|
placements: c,
|
|
167
|
-
placementKeys:
|
|
167
|
+
placementKeys: v,
|
|
168
168
|
roleNames: r,
|
|
169
|
-
primaryMockupId:
|
|
169
|
+
primaryMockupId: b[0]
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const _t = "[RealtimeEmbed]";
|
|
173
173
|
function pe(e) {
|
|
174
174
|
var r, i;
|
|
175
175
|
if ((r = e == null ? void 0 : e.requiredPlacements) != null && r.length)
|
|
176
|
-
return e.requiredPlacements.filter((
|
|
176
|
+
return e.requiredPlacements.filter((o) => !o.autoFilledByVariant).map((o) => o.label);
|
|
177
177
|
const t = new Set(
|
|
178
|
-
(((i = e == null ? void 0 : e.options) == null ? void 0 : i.combinations) ?? []).map((
|
|
178
|
+
(((i = e == null ? void 0 : e.options) == null ? void 0 : i.combinations) ?? []).map((o) => o.variantId).filter((o) => typeof o == "string" && o !== "")
|
|
179
179
|
);
|
|
180
180
|
return !!(e != null && e.variantId) || t.size > 1 ? [] : (e == null ? void 0 : e.placements) ?? [];
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function Tt(e) {
|
|
183
183
|
return !!(e != null && e.picks) || !!(e != null && e.variants);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function At(e) {
|
|
186
186
|
const t = /* @__PURE__ */ new Set();
|
|
187
187
|
for (const n of e.placements ?? []) {
|
|
188
|
-
const r =
|
|
188
|
+
const r = xe(n);
|
|
189
189
|
r && t.add(r.role);
|
|
190
190
|
}
|
|
191
191
|
for (const n of Object.keys(e.picks ?? {})) t.add(n);
|
|
192
192
|
for (const n of Object.keys(e.variants ?? {})) t.add(n);
|
|
193
193
|
return [...t];
|
|
194
194
|
}
|
|
195
|
-
function
|
|
196
|
-
var
|
|
195
|
+
function Fe({ shop: e, product: t, design: n, hasGrant: r }) {
|
|
196
|
+
var p, E;
|
|
197
197
|
const i = [];
|
|
198
198
|
if (e || i.push({
|
|
199
199
|
severity: "error",
|
|
@@ -203,67 +203,67 @@ function Le({ shop: e, product: t, design: n, hasGrant: r }) {
|
|
|
203
203
|
severity: "error",
|
|
204
204
|
issue: "missing-grant",
|
|
205
205
|
message: "no grant source — pass `grantUrl` (a proxy to mintRealtimeGrant) or `grant`. Without it the session can never authorize and no mockup renders."
|
|
206
|
-
}), (
|
|
206
|
+
}), (p = t == null ? void 0 : t.mockupIds) != null && p.length || i.push({
|
|
207
207
|
severity: "error",
|
|
208
208
|
issue: "empty-mockup-ids",
|
|
209
209
|
message: 'product.mockupIds is empty — pass the catalog scene codes (product.mockups[].id) you want rendered, e.g. ["FV1qjO"].'
|
|
210
210
|
}), t != null && t.options)
|
|
211
211
|
try {
|
|
212
|
-
|
|
213
|
-
} catch (
|
|
212
|
+
ht(t);
|
|
213
|
+
} catch (b) {
|
|
214
214
|
i.push({
|
|
215
215
|
severity: "error",
|
|
216
216
|
issue: "variant-required",
|
|
217
|
-
message:
|
|
217
|
+
message: b instanceof Error ? b.message : String(b)
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const o = n.toJSON(), a = o.artboards.map((b) => b.name), l = Tt(t);
|
|
221
221
|
let d = [];
|
|
222
222
|
if (l) {
|
|
223
|
-
const
|
|
224
|
-
d =
|
|
223
|
+
const b = t.placements ?? [];
|
|
224
|
+
d = a.filter((y) => !xe(y)), d.length > 0 && i.push({
|
|
225
225
|
severity: "error",
|
|
226
226
|
issue: "bundle-role-required",
|
|
227
|
-
message: `product ${t.productId} is a bundle, but the design's artboard(s) [${d.join(", ")}] name no role. On a bundle every placement is addressed by its role-scoped key (<role>.<key>)${
|
|
227
|
+
message: `product ${t.productId} is a bundle, but the design's artboard(s) [${d.join(", ")}] name no role. On a bundle every placement is addressed by its role-scoped key (<role>.<key>)${b.length ? ` — keys: [${b.join(", ")}]` : ""}. Seed the design from bundleToRenderConfig(product).placement.key, not from a bare label.`
|
|
228
228
|
}), t.variantId && i.push({
|
|
229
229
|
severity: "error",
|
|
230
230
|
issue: "bundle-role-required",
|
|
231
231
|
message: `product ${t.productId} is a bundle, but product.variantId ("${t.variantId}") names no slot — the server refuses it (E_BUNDLE_ROLE_REQUIRED). Name the variant per role instead: product.variants = { <role>: <gvid> } (bundleToRenderConfig fills it), and leave variantId unset.`
|
|
232
232
|
});
|
|
233
|
-
const
|
|
234
|
-
var
|
|
235
|
-
return !((
|
|
233
|
+
const C = At(t).filter((y) => {
|
|
234
|
+
var D;
|
|
235
|
+
return !((D = t.variants) != null && D[y]);
|
|
236
236
|
});
|
|
237
|
-
|
|
237
|
+
C.length > 0 && i.push({
|
|
238
238
|
severity: "error",
|
|
239
239
|
issue: "bundle-variant-required",
|
|
240
|
-
message: `product ${t.productId} is a bundle, but role(s) [${
|
|
240
|
+
message: `product ${t.productId} is a bundle, but role(s) [${C.join(", ")}] have no entry in product.variants (${JSON.stringify(t.variants ?? {})}). Every role needs a variant — the server keys the render on the per-role set. Build the product with bundleToRenderConfig(product, { picks, variants }), which fills each slot's default.`
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const s = pe(t), u = s.filter((b) => !a.includes(b));
|
|
244
|
+
s.length > 1 && a.length > 1 && u.length > 0 && i.push({
|
|
245
245
|
severity: "warn",
|
|
246
246
|
issue: "placements-inherit-base",
|
|
247
|
-
message: `product ${t.productId} requires placements [${
|
|
247
|
+
message: `product ${t.productId} requires placements [${s.join(", ")}]; the design authors [${a.join(", ")}], so [${u.join(", ")}] inherit the base artboard "${a[0]}" (re-fit per placement, ADR-0101). Intended? Otherwise split them: design(…).artboard('` + u[0] + "', { width, height })… or usePlacements().split('" + u[0] + "') at runtime."
|
|
248
248
|
});
|
|
249
|
-
const c = (E = t == null ? void 0 : t.placements) != null && E.length ?
|
|
249
|
+
const c = (E = t == null ? void 0 : t.placements) != null && E.length ? a.filter((b) => !t.placements.includes(b) && !d.includes(b)) : [];
|
|
250
250
|
c.length > 0 && i.push({
|
|
251
251
|
severity: "error",
|
|
252
252
|
issue: "placement-mismatch",
|
|
253
253
|
message: `the design's artboard(s) [${c.join(", ")}] are not in product.placements [${t.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, …).`
|
|
254
254
|
});
|
|
255
|
-
const
|
|
255
|
+
const v = o.elements.map((b) => b.name).filter((b) => !!b), x = v.filter((b, g) => v.indexOf(b) !== g);
|
|
256
256
|
return x.length && i.push({
|
|
257
257
|
severity: "warn",
|
|
258
258
|
issue: "duplicate-layer-names",
|
|
259
259
|
message: `duplicate layer name(s) [${[...new Set(x)].join(", ")}] — useTextBinding(name) / useImageBinding(name) bind to the FIRST match, so a duplicate name makes a control edit the wrong layer. Keep names unique.`
|
|
260
260
|
}), i;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
263
|
-
for (const t of
|
|
264
|
-
(t.severity === "error" && t.issue !== "placement-mismatch" ? console.error : console.warn)(`${
|
|
262
|
+
function Dt(e) {
|
|
263
|
+
for (const t of Fe(e))
|
|
264
|
+
(t.severity === "error" && t.issue !== "placement-mismatch" ? console.error : console.warn)(`${_t} ${t.message}`);
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function Pe(e, t) {
|
|
267
267
|
const n = new Set(e);
|
|
268
268
|
if (t.length === 0)
|
|
269
269
|
return e.map((i) => ({ label: i, inherited: !1 }));
|
|
@@ -278,22 +278,22 @@ function Fe(e, t) {
|
|
|
278
278
|
function Ve(e, t) {
|
|
279
279
|
const n = e.artboards ?? [], r = n[0];
|
|
280
280
|
if (!r || t.length === 0) return e;
|
|
281
|
-
const i = n.map((d) => typeof d.name == "string" ? d.name : ""),
|
|
282
|
-
if (
|
|
283
|
-
const l =
|
|
284
|
-
(d) => d.inherited ? { ...r, name: d.label } :
|
|
281
|
+
const i = n.map((d) => typeof d.name == "string" ? d.name : ""), o = new Map(n.map((d, s) => [i[s], d])), a = Pe(i, t);
|
|
282
|
+
if (a.every((d) => !d.inherited)) return e;
|
|
283
|
+
const l = a.map(
|
|
284
|
+
(d) => d.inherited ? { ...r, name: d.label } : o.get(d.label)
|
|
285
285
|
);
|
|
286
286
|
return { ...e, artboards: l };
|
|
287
287
|
}
|
|
288
|
-
function
|
|
289
|
-
const r = [], i = e.getParts(),
|
|
290
|
-
|
|
288
|
+
function je({ registry: e, store: t, product: n }) {
|
|
289
|
+
const r = [], i = e.getParts(), o = e.getTextFields(), a = e.requiresCanvasPartNames();
|
|
290
|
+
a.length > 0 && !e.hasCanvas() && r.push({
|
|
291
291
|
code: "A_REQUIRES_CANVAS",
|
|
292
292
|
severity: "error",
|
|
293
|
-
message: `${
|
|
294
|
-
fix: `Mount <Editor.Canvas/> under the same <Editor.Root>, or remove ${
|
|
293
|
+
message: `${a.join(", ")} ${a.length === 1 ? "is" : "are"} mounted with no <Editor.Canvas> under this Root — they operate on the editable artboard (selection, editor commands) and throw E_REQUIRES_CANVAS.`,
|
|
294
|
+
fix: `Mount <Editor.Canvas/> under the same <Editor.Root>, or remove ${a.join(", ")}. Canvas-free parts: Editor.Preview, Editor.Buy, Editor.TextField, Editor.Layers.`
|
|
295
295
|
});
|
|
296
|
-
const l = i.filter((
|
|
296
|
+
const l = i.filter((p) => p.name === "Editor.Canvas").some((p) => p.meta.floatingToolbar !== !1);
|
|
297
297
|
e.hasDockedControls() && l && r.push({
|
|
298
298
|
code: "A_CONTROLS_INERT",
|
|
299
299
|
severity: "warn",
|
|
@@ -302,39 +302,39 @@ function Pe({ registry: e, store: t, product: n }) {
|
|
|
302
302
|
});
|
|
303
303
|
const d = (n == null ? void 0 : n.mockupIds) ?? [];
|
|
304
304
|
if (d.length > 1) {
|
|
305
|
-
const
|
|
306
|
-
|
|
305
|
+
const p = i.filter((E) => E.name === "Editor.Preview" && E.meta.mockupId === void 0);
|
|
306
|
+
p.length > 0 && r.push({
|
|
307
307
|
code: "A_PREVIEW_AMBIGUOUS",
|
|
308
308
|
severity: "warn",
|
|
309
|
-
message: `${
|
|
309
|
+
message: `${p.length} <Editor.Preview> part${p.length === 1 ? " has" : "s have"} no mockupId while the product renders ${d.length} mockup scenes [${d.join(", ")}] — each shows whichever scene renders first, an ambiguous fan-out.`,
|
|
310
310
|
fix: `Pin each <Editor.Preview> to a scene: mockupId="${d[0]}" (one of product.mockupIds).`
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
313
|
+
const s = i.some((p) => p.name === "Editor.Buy");
|
|
314
|
+
if (o.length > 0 && !s) {
|
|
315
|
+
const p = o.map((E) => E.name);
|
|
316
316
|
r.push({
|
|
317
317
|
code: "A_NO_BUY",
|
|
318
318
|
severity: "info",
|
|
319
|
-
message: `<Editor.TextField> parts are mounted (layers [${
|
|
319
|
+
message: `<Editor.TextField> parts are mounted (layers [${p.join(", ")}]) but no <Editor.Buy> — personalization has no commerce gate, so nothing enforces completeness (C2/C3) before the design is bought.`,
|
|
320
320
|
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."
|
|
321
321
|
});
|
|
322
322
|
}
|
|
323
323
|
const u = [];
|
|
324
|
-
for (const
|
|
325
|
-
t.layerKindOf(
|
|
324
|
+
for (const p of o)
|
|
325
|
+
t.layerKindOf(p.name) === void 0 ? r.push({
|
|
326
326
|
code: "A_LAYER_UNMATCHED",
|
|
327
327
|
severity: "error",
|
|
328
|
-
message: `<Editor.TextField layer={design.layer("${
|
|
329
|
-
fix: `Restore a text layer named "${
|
|
330
|
-
}) : u.push(
|
|
331
|
-
const c = u.filter((
|
|
332
|
-
if (c.length > 0 && c.every((
|
|
333
|
-
const
|
|
328
|
+
message: `<Editor.TextField layer={design.layer("${p.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(t.bindableLayerNames())}.`,
|
|
329
|
+
fix: `Restore a text layer named "${p.name}" to the design, or bind the field to an existing layer: layer={design.layer(<one of ${JSON.stringify(t.bindableLayerNames())}>)}.`
|
|
330
|
+
}) : u.push(p);
|
|
331
|
+
const c = u.filter((p) => !p.optional);
|
|
332
|
+
if (c.length > 0 && c.every((p) => t.textOf(p.name) === t.seedTextOf(p.name))) {
|
|
333
|
+
const p = c.map((E) => E.name);
|
|
334
334
|
r.push({
|
|
335
335
|
code: "A_TEXT_AT_SEED",
|
|
336
336
|
severity: "info",
|
|
337
|
-
message: `every required <Editor.TextField> still equals its seed value (layers [${
|
|
337
|
+
message: `every required <Editor.TextField> still equals its seed value (layers [${p.join(", ")}]) — <Editor.Buy>'s completeness rule C3 gates checkout until the shopper's text differs from the seed (placeholder text must not be bought).`,
|
|
338
338
|
fix: "Nothing to change for a fresh mount — this clears when the shopper edits the fields. For a field that should NOT gate Buy, pass optional on that <Editor.TextField>."
|
|
339
339
|
});
|
|
340
340
|
}
|
|
@@ -344,31 +344,31 @@ function Pe({ registry: e, store: t, product: n }) {
|
|
|
344
344
|
message: "the design state has zero renderable elements (no non-empty text, no image with a URL, no shape) — every mockup renders blank.",
|
|
345
345
|
fix: "Seed content on the builder passed to <Editor.Root design={…}> — design({…}).text(…)/.background(…)/.shape(…) — or add elements through <Editor.Add>."
|
|
346
346
|
});
|
|
347
|
-
const
|
|
348
|
-
for (const
|
|
349
|
-
const x = [...
|
|
347
|
+
const v = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const p of i) v.set(p.name, (v.get(p.name) ?? 0) + 1);
|
|
349
|
+
const x = [...v.entries()].map(([p, E]) => ({ name: p, count: E })).sort((p, E) => p.name.localeCompare(E.name));
|
|
350
350
|
return { findings: r, parts: x };
|
|
351
351
|
}
|
|
352
352
|
const ie = [];
|
|
353
|
-
function
|
|
353
|
+
function Lt(e) {
|
|
354
354
|
return ie.push(e), () => {
|
|
355
355
|
const t = ie.indexOf(e);
|
|
356
356
|
t !== -1 && ie.splice(t, 1);
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function _n() {
|
|
360
360
|
const e = ie[ie.length - 1];
|
|
361
361
|
if (!e)
|
|
362
|
-
throw new
|
|
362
|
+
throw new R(
|
|
363
363
|
"E_AUDIT_NO_ROOT",
|
|
364
364
|
"auditEditor() found no mounted <Editor.Root>. Mount a Root first — or, to audit at mount time, pass onAudit on the Root: <Editor.Root onAudit={(report) => …}>.",
|
|
365
365
|
{ docSlug: "embed-mode" }
|
|
366
366
|
);
|
|
367
367
|
return e.compute();
|
|
368
368
|
}
|
|
369
|
-
const
|
|
369
|
+
const Me = 8e3;
|
|
370
370
|
function Bt(e) {
|
|
371
|
-
return `[RealtimeEmbed] No mockup after ${Math.round(
|
|
371
|
+
return `[RealtimeEmbed] No mockup after ${Math.round(Me / 1e3)}s. Common causes: a variant product missing \`variantId\` (pass \`product.options\` so the embed can flag it up front), a multi-placement product (the server waits for every required placement but <RealtimeEmbed> sends only "${e}" — pass \`product.requiredPlacements\` so this is flagged at mount; such products need the eject path), an unreachable or non-public asset URL in the design, or the placement "${e}" not existing on the product. The render may still arrive — this is a heads-up, not a failure.`;
|
|
372
372
|
}
|
|
373
373
|
function Ut(e) {
|
|
374
374
|
if ("grantUrl" in e && e.grantUrl)
|
|
@@ -376,8 +376,8 @@ function Ut(e) {
|
|
|
376
376
|
const t = e.grant;
|
|
377
377
|
return typeof t == "function" ? { getToken: t } : { getToken: () => Promise.resolve(t) };
|
|
378
378
|
}
|
|
379
|
-
function
|
|
380
|
-
const n =
|
|
379
|
+
function qe({ error: e, onRetry: t }) {
|
|
380
|
+
const n = De(e) ? e.code : "EDITOR_ERROR";
|
|
381
381
|
return /* @__PURE__ */ U(
|
|
382
382
|
"div",
|
|
383
383
|
{
|
|
@@ -398,8 +398,8 @@ function Me({ error: e, onRetry: t }) {
|
|
|
398
398
|
"Editor failed: ",
|
|
399
399
|
n
|
|
400
400
|
] }),
|
|
401
|
-
/* @__PURE__ */
|
|
402
|
-
t ? /* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ h("p", { style: { margin: "4px 0 0" }, children: e.message }),
|
|
402
|
+
t ? /* @__PURE__ */ h(
|
|
403
403
|
"button",
|
|
404
404
|
{
|
|
405
405
|
type: "button",
|
|
@@ -423,7 +423,7 @@ function Me({ error: e, onRetry: t }) {
|
|
|
423
423
|
}
|
|
424
424
|
);
|
|
425
425
|
}
|
|
426
|
-
class
|
|
426
|
+
class Ft extends pt {
|
|
427
427
|
constructor() {
|
|
428
428
|
super(...arguments), this.state = { caught: null };
|
|
429
429
|
}
|
|
@@ -432,18 +432,18 @@ class Lt extends mt {
|
|
|
432
432
|
}
|
|
433
433
|
componentDidCatch(t) {
|
|
434
434
|
var n;
|
|
435
|
-
|
|
435
|
+
wt(t), typeof z < "u" && ((n = z.env) == null ? void 0 : n.NODE_ENV) !== "production" && console.error("[Editor.Root] contained a composition error:", t);
|
|
436
436
|
}
|
|
437
437
|
render() {
|
|
438
|
-
return this.state.caught ? /* @__PURE__ */
|
|
438
|
+
return this.state.caught ? /* @__PURE__ */ h(qe, { error: this.state.caught }) : this.props.children;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
function
|
|
441
|
+
function Pt({ reportedError: e, onRetry: t, children: n }) {
|
|
442
442
|
if (e) {
|
|
443
|
-
const r =
|
|
444
|
-
return /* @__PURE__ */
|
|
443
|
+
const r = De(e) && e.code === "E_CHUNK_LOAD_FAILED";
|
|
444
|
+
return /* @__PURE__ */ h(qe, { error: e, onRetry: r ? t : void 0 });
|
|
445
445
|
}
|
|
446
|
-
return /* @__PURE__ */
|
|
446
|
+
return /* @__PURE__ */ h(Ft, { reportedError: null, onRetry: t, children: n });
|
|
447
447
|
}
|
|
448
448
|
function Vt(e) {
|
|
449
449
|
const {
|
|
@@ -451,63 +451,63 @@ function Vt(e) {
|
|
|
451
451
|
product: n,
|
|
452
452
|
design: r,
|
|
453
453
|
throttleMs: i = 200,
|
|
454
|
-
onMockups:
|
|
455
|
-
onRenderError:
|
|
454
|
+
onMockups: o,
|
|
455
|
+
onRenderError: a,
|
|
456
456
|
onIssue: l,
|
|
457
457
|
wsUrl: d,
|
|
458
|
-
services:
|
|
458
|
+
services: s,
|
|
459
459
|
children: u,
|
|
460
460
|
internals: c,
|
|
461
|
-
recordAudit:
|
|
461
|
+
recordAudit: v,
|
|
462
462
|
__validation: x = "throw"
|
|
463
|
-
} = e,
|
|
464
|
-
() =>
|
|
465
|
-
[
|
|
466
|
-
),
|
|
463
|
+
} = e, p = L(() => r.toJSON().activeArtboard, [r]), b = J(c.store.subscribe, c.store.getState, c.store.getState).artboards.map((f) => f.name).join("\0"), g = L(
|
|
464
|
+
() => b ? b.split("\0") : [],
|
|
465
|
+
[b]
|
|
466
|
+
), C = JSON.stringify(pe(n)), y = L(() => JSON.parse(C), [C]), [D, N] = A(null), T = D && D.design === r ? D.label : p, P = L(
|
|
467
467
|
() => (f) => {
|
|
468
|
-
const k = [.../* @__PURE__ */ new Set([...
|
|
468
|
+
const k = [.../* @__PURE__ */ new Set([...y, ...g])];
|
|
469
469
|
if (!k.includes(f))
|
|
470
|
-
throw new
|
|
470
|
+
throw new R(
|
|
471
471
|
"E_UNKNOWN_PLACEMENT",
|
|
472
|
-
`no placement "${f}" — the product's placements are ${JSON.stringify(
|
|
472
|
+
`no placement "${f}" — the product's placements are ${JSON.stringify(y)} and the design's artboards are ${JSON.stringify(g)} (ADR-0088 / ADR-0101).`,
|
|
473
473
|
{ placement: f, validNames: k, docSlug: "embed-mode" }
|
|
474
474
|
);
|
|
475
|
-
const
|
|
476
|
-
N({ design: r, label:
|
|
475
|
+
const I = g[0] ?? f;
|
|
476
|
+
N({ design: r, label: g.includes(f) ? f : I });
|
|
477
477
|
},
|
|
478
|
-
[r,
|
|
479
|
-
),
|
|
478
|
+
[r, g, y]
|
|
479
|
+
), m = $(null), S = L(
|
|
480
480
|
() => (f) => {
|
|
481
481
|
var k;
|
|
482
|
-
if (!
|
|
483
|
-
throw new
|
|
482
|
+
if (!y.includes(f) && !g.includes(f))
|
|
483
|
+
throw new R(
|
|
484
484
|
"E_UNKNOWN_PLACEMENT",
|
|
485
|
-
`cannot split "${f}" — the product's placements are ${JSON.stringify(
|
|
486
|
-
{ placement: f, validNames:
|
|
485
|
+
`cannot split "${f}" — the product's placements are ${JSON.stringify(y)} (ADR-0101).`,
|
|
486
|
+
{ placement: f, validNames: y, docSlug: "embed-mode" }
|
|
487
487
|
);
|
|
488
|
-
if (!
|
|
489
|
-
const
|
|
490
|
-
|
|
488
|
+
if (!g.includes(f)) {
|
|
489
|
+
const I = c.registry.getCanvasBridge();
|
|
490
|
+
I ? I.splitArtboard(f) : (c.store.splitArtboard(f), (k = m.current) == null || k.call(m, ee(c.store.getState())));
|
|
491
491
|
}
|
|
492
492
|
N({ design: r, label: f });
|
|
493
493
|
},
|
|
494
|
-
[r,
|
|
495
|
-
),
|
|
494
|
+
[r, g, y, c]
|
|
495
|
+
), B = L(
|
|
496
496
|
() => (f) => {
|
|
497
|
-
var
|
|
498
|
-
const k =
|
|
497
|
+
var M;
|
|
498
|
+
const k = g[0];
|
|
499
499
|
if (f === k)
|
|
500
|
-
throw new
|
|
500
|
+
throw new R(
|
|
501
501
|
"E_LINK_BASE",
|
|
502
|
-
`"${f}" is the base artboard — every linked placement inherits it, so it cannot be re-linked. Link a split placement instead, or call linkAll(). Artboards: ${JSON.stringify(
|
|
503
|
-
{ artboardName: f, validNames:
|
|
502
|
+
`"${f}" is the base artboard — every linked placement inherits it, so it cannot be re-linked. Link a split placement instead, or call linkAll(). Artboards: ${JSON.stringify(g)}.`,
|
|
503
|
+
{ artboardName: f, validNames: g.slice(1), docSlug: "embed-mode" }
|
|
504
504
|
);
|
|
505
|
-
if (!
|
|
506
|
-
const
|
|
507
|
-
|
|
505
|
+
if (!g.includes(f)) return;
|
|
506
|
+
const I = c.registry.getCanvasBridge();
|
|
507
|
+
I ? I.removeArtboard(f) : (c.store.removeArtboard(f), (M = m.current) == null || M.call(m, ee(c.store.getState()))), T === f && k && N({ design: r, label: k });
|
|
508
508
|
},
|
|
509
|
-
[r,
|
|
510
|
-
),
|
|
509
|
+
[r, g, c, T]
|
|
510
|
+
), _ = L(() => {
|
|
511
511
|
const f = r.toJSON().artboards[0];
|
|
512
512
|
if (f)
|
|
513
513
|
return {
|
|
@@ -522,280 +522,280 @@ function Vt(e) {
|
|
|
522
522
|
c.commerce.getVersion,
|
|
523
523
|
c.commerce.getVersion
|
|
524
524
|
);
|
|
525
|
-
const
|
|
526
|
-
if (!
|
|
527
|
-
const f = r.toJSON().artboards, k = f.find((
|
|
528
|
-
return
|
|
529
|
-
}, [
|
|
530
|
-
X.current =
|
|
531
|
-
const [
|
|
532
|
-
var
|
|
533
|
-
const f =
|
|
525
|
+
const V = c.commerce.renderVariantId(), j = kt(V ?? n.variantId ?? n.defaultGvid), G = L(() => {
|
|
526
|
+
if (!j) return null;
|
|
527
|
+
const f = r.toJSON().artboards, k = f.find((I) => I.name === T) ?? f[0];
|
|
528
|
+
return xt(j, k) ?? null;
|
|
529
|
+
}, [j, r, T]), X = $(o), w = $(a), Q = $(l);
|
|
530
|
+
X.current = o, w.current = a, Q.current = l;
|
|
531
|
+
const [Se, Je] = A([]), [de, ne] = A(!0), [Re, le] = A(null), fe = !!("grantUrl" in e && e.grantUrl || "grant" in e && e.grant), he = Ut(e), Qe = "grantUrl" in he ? he.grantUrl : "getToken", Ie = `${n.productId}|${n.mockupIds.join(",")}|${n.variantId ?? ""}`, re = n.picks || n.variants ? JSON.stringify([n.picks ?? null, n.variants ?? null]) : "", Y = `${t}|${Ie}|${re}|${p}|${fe}`, ge = L(() => {
|
|
532
|
+
var I;
|
|
533
|
+
const f = Fe({ shop: t, product: n, design: r, hasGrant: fe });
|
|
534
534
|
if (x !== "throw") return f;
|
|
535
|
-
const k = f.find((
|
|
535
|
+
const k = f.find((M) => M.severity === "error");
|
|
536
536
|
if (k)
|
|
537
|
-
throw new
|
|
537
|
+
throw new R("E_EMBED_CONFIG", k.message, {
|
|
538
538
|
issue: k.issue,
|
|
539
539
|
docSlug: "embed-mode"
|
|
540
540
|
});
|
|
541
|
-
for (const
|
|
542
|
-
typeof z < "u" && ((
|
|
541
|
+
for (const M of f)
|
|
542
|
+
typeof z < "u" && ((I = z.env) == null ? void 0 : I.NODE_ENV) !== "production" && console.warn(`[Editor.Root] ${M.message}`);
|
|
543
543
|
return f;
|
|
544
|
-
}, [Y, x]),
|
|
545
|
-
|
|
544
|
+
}, [Y, x]), Oe = $(null);
|
|
545
|
+
F(() => {
|
|
546
546
|
var f;
|
|
547
|
-
if (ge.length !== 0 &&
|
|
548
|
-
|
|
547
|
+
if (ge.length !== 0 && Oe.current !== Y) {
|
|
548
|
+
Oe.current = Y;
|
|
549
549
|
for (const k of ge) (f = Q.current) == null || f.call(Q, k);
|
|
550
550
|
}
|
|
551
551
|
}, [ge, Y]);
|
|
552
|
-
const
|
|
553
|
-
|
|
552
|
+
const $e = $(null);
|
|
553
|
+
F(() => {
|
|
554
554
|
var f;
|
|
555
555
|
if (x === "warn" && typeof z < "u" && ((f = z.env) == null ? void 0 : f.NODE_ENV) !== "production") {
|
|
556
|
-
if (
|
|
557
|
-
|
|
556
|
+
if ($e.current === Y) return;
|
|
557
|
+
$e.current = Y, Dt({ shop: t, product: n, design: r, hasGrant: fe });
|
|
558
558
|
}
|
|
559
559
|
}, [Y, x]);
|
|
560
|
-
const ce =
|
|
560
|
+
const ce = L(
|
|
561
561
|
() => {
|
|
562
562
|
try {
|
|
563
|
-
return { session: new
|
|
563
|
+
return { session: new gt({ shop: t, product: n, wsUrl: d, ...he }) };
|
|
564
564
|
} catch (f) {
|
|
565
565
|
return { error: f instanceof Error ? f.message : String(f) };
|
|
566
566
|
}
|
|
567
567
|
},
|
|
568
568
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
569
|
-
[t,
|
|
570
|
-
),
|
|
571
|
-
if (!
|
|
569
|
+
[t, Ie, p, d, Qe]
|
|
570
|
+
), O = "session" in ce ? ce.session : null, ue = "error" in ce ? ce.error : null, Z = L(() => (f, k = i) => {
|
|
571
|
+
if (!O) return;
|
|
572
572
|
le(null), ne(!0);
|
|
573
|
-
const
|
|
574
|
-
var
|
|
573
|
+
const I = (q) => {
|
|
574
|
+
var Te;
|
|
575
575
|
const me = q instanceof Error ? q.message : String(q);
|
|
576
|
-
le(me), ne(!1), (
|
|
577
|
-
},
|
|
578
|
-
if (
|
|
579
|
-
for (const q of
|
|
580
|
-
|
|
576
|
+
le(me), ne(!1), (Te = w.current) == null || Te.call(w, me);
|
|
577
|
+
}, M = (q, me) => void O.renderState(q, { schemaVersion: f.schemaVersion, artboards: [me] }, k).catch(I), _e = Ve(f, pe(n)).artboards ?? [];
|
|
578
|
+
if (_e.length > 1) {
|
|
579
|
+
for (const q of _e)
|
|
580
|
+
M(typeof q.name == "string" && q.name ? q.name : p, q);
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
|
-
|
|
584
|
-
}, [
|
|
585
|
-
|
|
583
|
+
O.renderState(p, f, k).catch(I);
|
|
584
|
+
}, [O, p, n, i]);
|
|
585
|
+
m.current = Z, F(() => {
|
|
586
586
|
var f;
|
|
587
587
|
if (ue) {
|
|
588
588
|
le(ue), ne(!1), (f = w.current) == null || f.call(w, ue);
|
|
589
589
|
return;
|
|
590
590
|
}
|
|
591
|
-
if (
|
|
592
|
-
return
|
|
593
|
-
var
|
|
594
|
-
|
|
595
|
-
}),
|
|
596
|
-
var
|
|
597
|
-
le(k), ne(!1), (
|
|
598
|
-
}), Z(r.toServerRequest()), () =>
|
|
599
|
-
}, [
|
|
600
|
-
const ye =
|
|
591
|
+
if (O)
|
|
592
|
+
return O.onMockups((k) => {
|
|
593
|
+
var I;
|
|
594
|
+
Je(k), ne(!1), (I = X.current) == null || I.call(X, k);
|
|
595
|
+
}), O.onError((k) => {
|
|
596
|
+
var I;
|
|
597
|
+
le(k), ne(!1), (I = w.current) == null || I.call(w, k);
|
|
598
|
+
}), Z(r.toServerRequest()), () => O.close();
|
|
599
|
+
}, [O, ue]);
|
|
600
|
+
const ye = $({
|
|
601
601
|
session: null,
|
|
602
602
|
variantId: void 0
|
|
603
603
|
});
|
|
604
|
-
|
|
605
|
-
if (!
|
|
606
|
-
const f = ye.current, k = f.session ===
|
|
607
|
-
if (
|
|
608
|
-
ye.current = { session:
|
|
604
|
+
F(() => {
|
|
605
|
+
if (!O || !V) return;
|
|
606
|
+
const f = ye.current, k = f.session === O ? f.variantId : n.variantId;
|
|
607
|
+
if (V === k) {
|
|
608
|
+
ye.current = { session: O, variantId: k };
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
|
-
ye.current = { session:
|
|
612
|
-
}, [
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
if (!
|
|
616
|
-
const f =
|
|
617
|
-
if (f.session ===
|
|
618
|
-
const k = f.session !==
|
|
619
|
-
|
|
620
|
-
}, [
|
|
611
|
+
ye.current = { session: O, variantId: V }, O.setProduct({ ...n, variantId: V }), Z(ee(c.store.getState()));
|
|
612
|
+
}, [O, V]);
|
|
613
|
+
const Ce = $({ session: null, key: "" });
|
|
614
|
+
F(() => {
|
|
615
|
+
if (!O || !re) return;
|
|
616
|
+
const f = Ce.current;
|
|
617
|
+
if (f.session === O && f.key === re) return;
|
|
618
|
+
const k = f.session !== O;
|
|
619
|
+
Ce.current = { session: O, key: re }, !k && (O.setProduct(n), Z(ee(c.store.getState())));
|
|
620
|
+
}, [O, re]), F(() => {
|
|
621
621
|
if (!de) return;
|
|
622
622
|
const f = setTimeout(() => {
|
|
623
|
-
var
|
|
624
|
-
const k = Bt(
|
|
625
|
-
typeof z < "u" && ((
|
|
626
|
-
},
|
|
623
|
+
var I, M;
|
|
624
|
+
const k = Bt(p);
|
|
625
|
+
typeof z < "u" && ((I = z.env) == null ? void 0 : I.NODE_ENV) !== "production" && console.warn(k), (M = Q.current) == null || M.call(Q, { severity: "warn", issue: "slow-render", message: k });
|
|
626
|
+
}, Me);
|
|
627
627
|
return () => clearTimeout(f);
|
|
628
|
-
}, [de,
|
|
629
|
-
const
|
|
628
|
+
}, [de, p]);
|
|
629
|
+
const Ye = L(
|
|
630
630
|
() => ({
|
|
631
|
-
session:
|
|
631
|
+
session: O,
|
|
632
632
|
design: r,
|
|
633
633
|
// The ACTIVE placement (ADR-0088): Editor.Canvas follows it as its
|
|
634
634
|
// controlled artboard; single-placement designs never see it move.
|
|
635
|
-
placement:
|
|
636
|
-
placements:
|
|
637
|
-
selectPlacement:
|
|
638
|
-
requiredPlacements:
|
|
639
|
-
splitPlacement:
|
|
640
|
-
linkPlacement:
|
|
635
|
+
placement: T,
|
|
636
|
+
placements: g,
|
|
637
|
+
selectPlacement: P,
|
|
638
|
+
requiredPlacements: y,
|
|
639
|
+
splitPlacement: S,
|
|
640
|
+
linkPlacement: B,
|
|
641
641
|
product: n,
|
|
642
|
-
mockups:
|
|
642
|
+
mockups: Se,
|
|
643
643
|
isRendering: de,
|
|
644
|
-
error:
|
|
644
|
+
error: Re,
|
|
645
645
|
throttleMs: i,
|
|
646
|
-
pieceGuides:
|
|
646
|
+
pieceGuides: G,
|
|
647
647
|
pushRender: Z,
|
|
648
648
|
stateStore: c.store
|
|
649
649
|
}),
|
|
650
|
-
[
|
|
651
|
-
),
|
|
650
|
+
[O, r, T, g, P, y, S, B, n, Se, de, Re, i, G, Z, c.store]
|
|
651
|
+
), Xe = J(
|
|
652
652
|
c.registry.subscribe,
|
|
653
653
|
c.registry.getVersion,
|
|
654
654
|
c.registry.getVersion
|
|
655
655
|
);
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
656
|
+
L(() => {
|
|
657
|
+
v(
|
|
658
|
+
je({ registry: c.registry, store: c.store, product: n })
|
|
659
659
|
), c.registry.validate();
|
|
660
|
-
}, [c.registry,
|
|
661
|
-
const
|
|
662
|
-
|
|
660
|
+
}, [c.registry, Xe]);
|
|
661
|
+
const Ne = /* @__PURE__ */ h(tt.Provider, { value: c, children: /* @__PURE__ */ h(Be.Provider, { value: Ye, children: /* @__PURE__ */ h(bt.Provider, { value: c.registry, children: /* @__PURE__ */ h(
|
|
662
|
+
vt,
|
|
663
663
|
{
|
|
664
|
-
...
|
|
664
|
+
..._ ? { initialArtboardConfig: _ } : {},
|
|
665
665
|
children: u
|
|
666
666
|
}
|
|
667
667
|
) }) }) });
|
|
668
|
-
return
|
|
668
|
+
return s ? /* @__PURE__ */ h(nt, { services: s, children: Ne }) : Ne;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
const { design: t, product: n, onAudit: r } = e, i = `${n.productId}|${n.variantId ?? ""}`,
|
|
672
|
-
(
|
|
670
|
+
function ze(e) {
|
|
671
|
+
const { design: t, product: n, onAudit: r } = e, i = `${n.productId}|${n.variantId ?? ""}`, o = $(null), a = $(null), [l, d] = A(null);
|
|
672
|
+
(o.current === null || o.current.design !== t) && (o.current = {
|
|
673
673
|
design: t,
|
|
674
674
|
internals: {
|
|
675
|
-
store: new
|
|
676
|
-
registry: new
|
|
675
|
+
store: new St(t.toJSON()),
|
|
676
|
+
registry: new Ze()
|
|
677
677
|
}
|
|
678
|
-
}), (
|
|
679
|
-
const
|
|
678
|
+
}), (a.current === null || a.current.productIdentity !== i) && (a.current = { productIdentity: i, commerce: new Rt(n) });
|
|
679
|
+
const s = L(
|
|
680
680
|
() => ({
|
|
681
|
-
...
|
|
682
|
-
commerce:
|
|
683
|
-
...
|
|
681
|
+
...o.current.internals,
|
|
682
|
+
commerce: a.current.commerce,
|
|
683
|
+
...et(d)
|
|
684
684
|
}),
|
|
685
685
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
686
|
-
[
|
|
687
|
-
), u =
|
|
686
|
+
[o.current.internals, a.current.commerce]
|
|
687
|
+
), u = $(n);
|
|
688
688
|
u.current = n;
|
|
689
|
-
const c =
|
|
689
|
+
const c = $(r);
|
|
690
690
|
c.current = r;
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
}, []),
|
|
694
|
-
() =>
|
|
695
|
-
registry:
|
|
696
|
-
store:
|
|
691
|
+
const v = $(null), x = K((b) => {
|
|
692
|
+
v.current = b;
|
|
693
|
+
}, []), p = K(
|
|
694
|
+
() => je({
|
|
695
|
+
registry: o.current.internals.registry,
|
|
696
|
+
store: o.current.internals.store,
|
|
697
697
|
product: u.current
|
|
698
698
|
}),
|
|
699
699
|
[]
|
|
700
700
|
);
|
|
701
|
-
ae(() =>
|
|
702
|
-
const E =
|
|
703
|
-
return
|
|
704
|
-
let
|
|
701
|
+
ae(() => Lt({ compute: p }), [p]);
|
|
702
|
+
const E = $(!1);
|
|
703
|
+
return F(() => {
|
|
704
|
+
let b = !1;
|
|
705
705
|
return queueMicrotask(() => {
|
|
706
|
-
var
|
|
707
|
-
|
|
706
|
+
var g;
|
|
707
|
+
b || E.current || (E.current = !0, (g = c.current) == null || g.call(c, v.current ?? p()));
|
|
708
708
|
}), () => {
|
|
709
|
-
|
|
709
|
+
b = !0;
|
|
710
710
|
};
|
|
711
|
-
}, [
|
|
711
|
+
}, [p]), // `display: contents` — the .sc-root scope without a layout box, so the
|
|
712
712
|
// host's grid/flex sees the parts directly (and the legacy RealtimeEmbed
|
|
713
713
|
// wrapper, which had no DOM at all, stays layout-identical).
|
|
714
|
-
/* @__PURE__ */
|
|
714
|
+
/* @__PURE__ */ h("div", { className: "sc-root", style: { display: "contents" }, "data-sc-part": "root", children: /* @__PURE__ */ h(Pt, { reportedError: l, onRetry: () => d(null), children: /* @__PURE__ */ h(Vt, { ...e, internals: s, recordAudit: x }) }) });
|
|
715
715
|
}
|
|
716
|
-
let
|
|
717
|
-
function
|
|
718
|
-
return
|
|
716
|
+
let jt = () => import("./EditorCanvasImpl-Cd_umlTI.js").then((e) => e.EditorCanvasImpl);
|
|
717
|
+
function Ke() {
|
|
718
|
+
return jt();
|
|
719
719
|
}
|
|
720
|
-
const
|
|
720
|
+
const Mt = Le(function({ children: t, maxHeight: n, floatingToolbar: r = !0, className: i, style: o }, a) {
|
|
721
721
|
const l = se("Editor.Canvas");
|
|
722
722
|
oe("Editor.Canvas", { floatingToolbar: r });
|
|
723
|
-
const d =
|
|
723
|
+
const d = Ee();
|
|
724
724
|
ae(() => l.registry.registerCanvas(d), [l.registry, d]);
|
|
725
|
-
const [
|
|
726
|
-
return
|
|
725
|
+
const [s, u] = A(null);
|
|
726
|
+
return F(() => {
|
|
727
727
|
let c = !1;
|
|
728
|
-
return
|
|
729
|
-
(
|
|
730
|
-
c || u(() =>
|
|
728
|
+
return Ke().then(
|
|
729
|
+
(v) => {
|
|
730
|
+
c || u(() => v);
|
|
731
731
|
},
|
|
732
|
-
(
|
|
732
|
+
(v) => {
|
|
733
733
|
c || l.reportRuntimeError(
|
|
734
|
-
new
|
|
734
|
+
new R(
|
|
735
735
|
"E_CHUNK_LOAD_FAILED",
|
|
736
|
-
`the editor's rendering chunk failed to load (${
|
|
737
|
-
{ cause:
|
|
736
|
+
`the editor's rendering chunk failed to load (${v instanceof Error ? v.message : String(v)}). This is a network/CDN failure, not a composition mistake — retry, or check the deployment serves the @snowcone-app/canvas lazy chunks.`,
|
|
737
|
+
{ cause: v instanceof Error ? v.message : String(v), docSlug: "embed-mode" }
|
|
738
738
|
)
|
|
739
739
|
);
|
|
740
740
|
}
|
|
741
741
|
), () => {
|
|
742
742
|
c = !0;
|
|
743
743
|
};
|
|
744
|
-
}, [l]),
|
|
744
|
+
}, [l]), s ? (
|
|
745
745
|
// `builtinControls`: the canvas owns the floating contextual toolbar
|
|
746
746
|
// unless the host opts out via `floatingToolbar={false}` or a docked
|
|
747
747
|
// <Editor.Controls> is mounted (ADR-0085 §5). Only here — the legacy
|
|
748
748
|
// <RealtimeCanvas> wrapper stays chrome-less.
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
|
|
749
|
+
/* @__PURE__ */ h(
|
|
750
|
+
s,
|
|
751
751
|
{
|
|
752
|
-
ref:
|
|
752
|
+
ref: a,
|
|
753
753
|
kit: "embed-only",
|
|
754
754
|
partAttr: "canvas",
|
|
755
755
|
builtinControls: r,
|
|
756
756
|
maxHeight: n,
|
|
757
757
|
className: i,
|
|
758
|
-
style:
|
|
758
|
+
style: o,
|
|
759
759
|
children: t
|
|
760
760
|
}
|
|
761
761
|
)
|
|
762
|
-
) : /* @__PURE__ */
|
|
762
|
+
) : /* @__PURE__ */ h(
|
|
763
763
|
"div",
|
|
764
764
|
{
|
|
765
765
|
"data-sc-part": "canvas",
|
|
766
766
|
"data-sc-state": "loading",
|
|
767
767
|
className: i,
|
|
768
|
-
style: { minHeight: n ?? 200, ...
|
|
768
|
+
style: { minHeight: n ?? 200, ...o },
|
|
769
769
|
"aria-busy": "true"
|
|
770
770
|
}
|
|
771
771
|
);
|
|
772
772
|
});
|
|
773
|
-
function
|
|
774
|
-
const { placements: e, requiredPlacements: t, placement: n, selectPlacement: r, splitPlacement: i, linkPlacement:
|
|
775
|
-
return
|
|
776
|
-
const
|
|
773
|
+
function qt() {
|
|
774
|
+
const { placements: e, requiredPlacements: t, placement: n, selectPlacement: r, splitPlacement: i, linkPlacement: o } = te();
|
|
775
|
+
return L(() => {
|
|
776
|
+
const a = Pe(e, t), l = e[0] ?? n, d = a.map((u) => ({
|
|
777
777
|
label: u.label,
|
|
778
778
|
inherited: u.inherited,
|
|
779
779
|
active: u.inherited ? n === l : n === u.label
|
|
780
|
-
})),
|
|
780
|
+
})), s = d.length > 1 && d.every((u) => u.inherited || u.label === l);
|
|
781
781
|
return {
|
|
782
782
|
placements: d,
|
|
783
783
|
activePlacement: n,
|
|
784
784
|
basePlacement: l,
|
|
785
|
-
linked:
|
|
785
|
+
linked: s,
|
|
786
786
|
select: r,
|
|
787
787
|
split: i,
|
|
788
|
-
link:
|
|
788
|
+
link: o,
|
|
789
789
|
splitAll: () => {
|
|
790
790
|
for (const u of d) u.inherited && i(u.label);
|
|
791
791
|
},
|
|
792
792
|
linkAll: () => {
|
|
793
|
-
for (const u of d) !u.inherited && u.label !== l &&
|
|
793
|
+
for (const u of d) !u.inherited && u.label !== l && o(u.label);
|
|
794
794
|
}
|
|
795
795
|
};
|
|
796
|
-
}, [e, t, n, r, i,
|
|
796
|
+
}, [e, t, n, r, i, o]);
|
|
797
797
|
}
|
|
798
|
-
const
|
|
798
|
+
const zt = (e) => e.length === 2 ? "Both sides" : `All ${e.length} areas`, Kt = {
|
|
799
799
|
font: "inherit",
|
|
800
800
|
fontSize: "12px",
|
|
801
801
|
color: "var(--sc-color-muted-foreground, inherit)",
|
|
@@ -806,10 +806,10 @@ const qt = (e) => e.length === 2 ? "Both sides" : `All ${e.length} areas`, zt =
|
|
|
806
806
|
textDecoration: "underline",
|
|
807
807
|
textUnderlineOffset: "4px"
|
|
808
808
|
};
|
|
809
|
-
function
|
|
810
|
-
const { placements: r, linked: i, select:
|
|
809
|
+
function Gt({ className: e, style: t, labels: n }) {
|
|
810
|
+
const { placements: r, linked: i, select: o, splitAll: a, linkAll: l } = qt();
|
|
811
811
|
if (r.length < 2) return null;
|
|
812
|
-
const d = r.map((
|
|
812
|
+
const d = r.map((s) => s.label);
|
|
813
813
|
return /* @__PURE__ */ U(
|
|
814
814
|
"div",
|
|
815
815
|
{
|
|
@@ -818,7 +818,7 @@ function Kt({ className: e, style: t, labels: n }) {
|
|
|
818
818
|
className: e,
|
|
819
819
|
style: { display: "flex", alignItems: "center", gap: "4px", ...t },
|
|
820
820
|
children: [
|
|
821
|
-
i ? /* @__PURE__ */
|
|
821
|
+
i ? /* @__PURE__ */ h(
|
|
822
822
|
"span",
|
|
823
823
|
{
|
|
824
824
|
"data-sc-part": "placements-item",
|
|
@@ -826,9 +826,9 @@ function Kt({ className: e, style: t, labels: n }) {
|
|
|
826
826
|
"data-sc-linked": "true",
|
|
827
827
|
title: d.join(" · "),
|
|
828
828
|
style: { fontSize: "13px", fontWeight: 700, padding: "2px 8px", color: "var(--sc-color-foreground, inherit)" },
|
|
829
|
-
children: ((n == null ? void 0 : n.linked) ??
|
|
829
|
+
children: ((n == null ? void 0 : n.linked) ?? zt)(d)
|
|
830
830
|
}
|
|
831
|
-
) : r.map(({ label:
|
|
831
|
+
) : r.map(({ label: s, active: u, inherited: c }) => /* @__PURE__ */ h(
|
|
832
832
|
"button",
|
|
833
833
|
{
|
|
834
834
|
type: "button",
|
|
@@ -836,7 +836,7 @@ function Kt({ className: e, style: t, labels: n }) {
|
|
|
836
836
|
"data-sc-active": u ? "true" : "false",
|
|
837
837
|
"data-sc-linked": c ? "true" : "false",
|
|
838
838
|
"aria-pressed": u,
|
|
839
|
-
onClick: () => s
|
|
839
|
+
onClick: () => o(s),
|
|
840
840
|
style: {
|
|
841
841
|
font: "inherit",
|
|
842
842
|
fontSize: "13px",
|
|
@@ -851,18 +851,18 @@ function Kt({ className: e, style: t, labels: n }) {
|
|
|
851
851
|
textDecoration: u ? "underline" : "none",
|
|
852
852
|
textUnderlineOffset: "4px"
|
|
853
853
|
},
|
|
854
|
-
children:
|
|
854
|
+
children: s
|
|
855
855
|
},
|
|
856
|
-
|
|
856
|
+
s
|
|
857
857
|
)),
|
|
858
|
-
/* @__PURE__ */
|
|
858
|
+
/* @__PURE__ */ h(
|
|
859
859
|
"button",
|
|
860
860
|
{
|
|
861
861
|
type: "button",
|
|
862
862
|
"data-sc-part": "placements-link-toggle",
|
|
863
863
|
"data-sc-linked": i ? "true" : "false",
|
|
864
|
-
onClick: i ?
|
|
865
|
-
style:
|
|
864
|
+
onClick: i ? a : l,
|
|
865
|
+
style: Kt,
|
|
866
866
|
children: i ? (n == null ? void 0 : n.customizeSeparately) ?? "Customize separately" : (n == null ? void 0 : n.useOneDesign) ?? "Use one design for all"
|
|
867
867
|
}
|
|
868
868
|
)
|
|
@@ -870,8 +870,8 @@ function Kt({ className: e, style: t, labels: n }) {
|
|
|
870
870
|
}
|
|
871
871
|
);
|
|
872
872
|
}
|
|
873
|
-
const
|
|
874
|
-
function
|
|
873
|
+
const Wt = 200, Ht = 400;
|
|
874
|
+
function Jt() {
|
|
875
875
|
return Array.from({ length: 10 }, () => ({
|
|
876
876
|
left: 2 + Math.random() * 96,
|
|
877
877
|
top: 2 + Math.random() * 96,
|
|
@@ -880,10 +880,10 @@ function Ht() {
|
|
|
880
880
|
size: 3 + Math.random() * 5
|
|
881
881
|
}));
|
|
882
882
|
}
|
|
883
|
-
let
|
|
884
|
-
function
|
|
885
|
-
if (!(
|
|
886
|
-
|
|
883
|
+
let Ae = !1;
|
|
884
|
+
function Qt() {
|
|
885
|
+
if (!(Ae || typeof CSS > "u" || typeof CSS.registerProperty != "function")) {
|
|
886
|
+
Ae = !0;
|
|
887
887
|
try {
|
|
888
888
|
CSS.registerProperty({ name: "--sc-prism-mount", syntax: "<number>", initialValue: "0", inherits: !0 });
|
|
889
889
|
} catch {
|
|
@@ -894,38 +894,38 @@ function Jt() {
|
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
const
|
|
897
|
+
const Ge = ft(function({
|
|
898
898
|
visible: t = !0,
|
|
899
899
|
onExited: n,
|
|
900
900
|
variant: r = "dark"
|
|
901
901
|
}) {
|
|
902
|
-
|
|
903
|
-
const [i,
|
|
904
|
-
|
|
905
|
-
|
|
902
|
+
Qt();
|
|
903
|
+
const [i, o] = A([]);
|
|
904
|
+
F(() => {
|
|
905
|
+
o(Jt());
|
|
906
906
|
}, []);
|
|
907
|
-
const [
|
|
908
|
-
|
|
907
|
+
const [a, l] = A(!1);
|
|
908
|
+
F(() => {
|
|
909
909
|
const u = requestAnimationFrame(() => l(!0));
|
|
910
910
|
return () => cancelAnimationFrame(u);
|
|
911
911
|
}, []);
|
|
912
|
-
const d =
|
|
912
|
+
const d = K(
|
|
913
913
|
(u) => {
|
|
914
914
|
u.propertyName === "background-color" && (t || n == null || n());
|
|
915
915
|
},
|
|
916
916
|
[t, n]
|
|
917
917
|
);
|
|
918
|
-
let
|
|
919
|
-
return t ?
|
|
918
|
+
let s = "";
|
|
919
|
+
return t ? a && (s = "sc-prism-fade-in") : s = "sc-prism-fade-out", /* @__PURE__ */ U(
|
|
920
920
|
"div",
|
|
921
921
|
{
|
|
922
922
|
"data-sc-part": "preview-loading",
|
|
923
|
-
className: ["sc-prism-overlay", r === "light" ? "sc-prism-on-light" : "",
|
|
923
|
+
className: ["sc-prism-overlay", r === "light" ? "sc-prism-on-light" : "", s].filter(Boolean).join(" "),
|
|
924
924
|
onTransitionEnd: d,
|
|
925
925
|
"aria-hidden": "true",
|
|
926
926
|
children: [
|
|
927
|
-
Array.from({ length: 6 }, (u, c) => /* @__PURE__ */
|
|
928
|
-
i.map((u, c) => /* @__PURE__ */
|
|
927
|
+
Array.from({ length: 6 }, (u, c) => /* @__PURE__ */ h("div", { className: "sc-prism-band" }, `b-${c}`)),
|
|
928
|
+
i.map((u, c) => /* @__PURE__ */ h(
|
|
929
929
|
"div",
|
|
930
930
|
{
|
|
931
931
|
className: "sc-prism-particle",
|
|
@@ -944,113 +944,125 @@ const Ke = pt(function({
|
|
|
944
944
|
}
|
|
945
945
|
);
|
|
946
946
|
});
|
|
947
|
-
function
|
|
948
|
-
const [t, n] =
|
|
949
|
-
l.current = t,
|
|
950
|
-
|
|
947
|
+
function We(e) {
|
|
948
|
+
const [t, n] = A(!1), [r, i] = A(!1), o = $(null), a = $(null), l = $(!1);
|
|
949
|
+
l.current = t, F(() => (e ? (i(!1), a.current && clearTimeout(a.current), o.current = setTimeout(() => n(!0), Wt)) : (o.current && (clearTimeout(o.current), o.current = null), l.current && (i(!0), a.current = setTimeout(() => i(!1), Ht))), () => {
|
|
950
|
+
o.current && clearTimeout(o.current), a.current && clearTimeout(a.current);
|
|
951
951
|
}), [e]);
|
|
952
|
-
const d =
|
|
952
|
+
const d = K(() => n(!1), []);
|
|
953
953
|
return {
|
|
954
954
|
showOverlay: t,
|
|
955
955
|
overlayVisible: e || r,
|
|
956
956
|
handleExited: d
|
|
957
957
|
};
|
|
958
958
|
}
|
|
959
|
-
const
|
|
960
|
-
function
|
|
959
|
+
const Yt = we.lazy(() => import("@snowcone-app/loaders/beam").then((e) => ({ default: e.BeamLoader }))), Xt = 1.2, be = [1200, 1400, 1600, 1800, 2e3, 2500, 3e3, 4e3];
|
|
960
|
+
function Zt(e) {
|
|
961
961
|
for (const t of be)
|
|
962
962
|
if (t >= e) return t;
|
|
963
963
|
return be[be.length - 1];
|
|
964
964
|
}
|
|
965
|
-
function
|
|
966
|
-
if (!(e > 0) || !(t > 0) || t <= e *
|
|
967
|
-
const n =
|
|
965
|
+
function en(e, t) {
|
|
966
|
+
if (!(e > 0) || !(t > 0) || t <= e * Xt) return null;
|
|
967
|
+
const n = Zt(t);
|
|
968
968
|
return `[RealtimeMockup] mockup rendered at ${e}px but displayed at ~${t} device px — the preview will look soft. Pass \`product.width\` (e.g. ${n}) on the embed for a crisp preview.`;
|
|
969
969
|
}
|
|
970
|
-
function
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
970
|
+
function tn(e) {
|
|
971
|
+
return typeof e == "function" ? !0 : typeof e == "object" && e !== null && "$$typeof" in e && !ke(e);
|
|
972
|
+
}
|
|
973
|
+
function nn(e) {
|
|
974
|
+
if (e === void 0 || e === !0) return "auto";
|
|
975
|
+
if (e === "dark" || e === "light" || e === "host-owned" || ke(e)) return e;
|
|
976
|
+
if (tn(e)) return { loader: e };
|
|
977
|
+
throw new R(
|
|
974
978
|
"E_PREVIEW_NO_LOADER",
|
|
975
|
-
`Editor.Preview: invalid loadingOverlay value ${JSON.stringify(e)}. A mockup preview always has a render-in-flight treatment (the loader paints over the still-visible previous mockup). Omit the prop for the default rainbow
|
|
979
|
+
`Editor.Preview: invalid loadingOverlay value ${JSON.stringify(e)}. A mockup preview always has a render-in-flight treatment (the loader paints over the still-visible previous mockup). Omit the prop for the default (the beam over a picture being edited, the rainbow before one), pass an imported loader component (loadingOverlay={BeamLoader} from "@snowcone-app/loaders/beam"), "dark" | "light" for the rainbow always, a custom ReactElement, or declare "host-owned" if the host renders its own indicator off data-sc-preview-state / <Editor.LoadingOverlay>.`,
|
|
976
980
|
{ docSlug: "preview-loading-overlay" }
|
|
977
981
|
);
|
|
978
982
|
}
|
|
979
|
-
function
|
|
983
|
+
function He({
|
|
980
984
|
mockupId: e,
|
|
981
985
|
fallback: t = null,
|
|
982
986
|
alt: n = "Live product mockup",
|
|
983
987
|
loadingOverlay: r,
|
|
984
988
|
className: i,
|
|
985
|
-
style:
|
|
989
|
+
style: o
|
|
986
990
|
}) {
|
|
987
|
-
const { mockups:
|
|
991
|
+
const { mockups: a, error: l, isRendering: d } = te();
|
|
988
992
|
oe("Editor.Preview", { ...e !== void 0 ? { mockupId: e } : {} });
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
),
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
if (
|
|
996
|
-
const
|
|
997
|
-
|
|
993
|
+
const s = nn(r), u = ke(s) ? s : null, c = s !== "host-owned", v = s === "auto" ? Yt : typeof s == "object" && s !== null && "loader" in s ? s.loader : null, x = $(null), p = K(() => x.current, []), { showOverlay: E, overlayVisible: b, handleExited: g } = We(
|
|
994
|
+
c && d
|
|
995
|
+
), C = $(/* @__PURE__ */ new Set()), y = e ? a.find((m) => m.mockupId === e && m.imageUrl) : a.find((m) => m.imageUrl), D = s === "light" ? "light" : v && (y != null && y.imageUrl) ? "edit" : "dark", [N, T] = A(D);
|
|
996
|
+
!E && N !== D && T(D);
|
|
997
|
+
const P = (m) => {
|
|
998
|
+
var j;
|
|
999
|
+
if (!y || typeof z > "u" || ((j = z.env) == null ? void 0 : j.NODE_ENV) === "production" || typeof window > "u" || C.current.has(y.mockupId)) return;
|
|
1000
|
+
const S = m.currentTarget, B = S.getBoundingClientRect().width;
|
|
1001
|
+
if (B <= 0) return;
|
|
1002
|
+
const _ = Math.round(B * (window.devicePixelRatio || 1)), V = en(S.naturalWidth, _);
|
|
1003
|
+
V && (C.current.add(y.mockupId), console.warn(V));
|
|
998
1004
|
};
|
|
999
|
-
if (
|
|
1000
|
-
const
|
|
1005
|
+
if (c) {
|
|
1006
|
+
const m = y != null && y.imageUrl ? d ? "rendering" : "ready" : l ? "error" : "rendering";
|
|
1001
1007
|
return /* @__PURE__ */ U(
|
|
1002
1008
|
"div",
|
|
1003
1009
|
{
|
|
1004
1010
|
"data-sc-part": "preview",
|
|
1005
|
-
"data-sc-preview-state":
|
|
1006
|
-
"aria-busy":
|
|
1011
|
+
"data-sc-preview-state": m,
|
|
1012
|
+
"aria-busy": m === "rendering" || void 0,
|
|
1007
1013
|
className: `sc-preview-frame${i ? ` ${i}` : ""}`,
|
|
1008
|
-
style:
|
|
1014
|
+
style: o,
|
|
1009
1015
|
children: [
|
|
1010
|
-
|
|
1016
|
+
y != null && y.imageUrl ? (
|
|
1011
1017
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1012
|
-
/* @__PURE__ */
|
|
1013
|
-
) : l ? /* @__PURE__ */
|
|
1014
|
-
|
|
1018
|
+
/* @__PURE__ */ h("img", { ref: x, "data-sc-part": "preview-image", src: y.imageUrl, alt: n, onLoad: P })
|
|
1019
|
+
) : l ? /* @__PURE__ */ h("div", { "data-sc-part": "preview-error", role: "alert", "data-sc-error": l, children: t ?? `Render failed: ${l}` }) : t,
|
|
1020
|
+
u ? (
|
|
1015
1021
|
// Custom indicator: same show-delay + linger window; no exit fade
|
|
1016
1022
|
// (the host owns its animation), so it unmounts when the window
|
|
1017
1023
|
// closes.
|
|
1018
|
-
|
|
1024
|
+
E && b ? /* @__PURE__ */ h(
|
|
1019
1025
|
"div",
|
|
1020
1026
|
{
|
|
1021
1027
|
"data-sc-part": "preview-loading",
|
|
1022
1028
|
className: "sc-preview-custom-loading",
|
|
1023
1029
|
"aria-hidden": "true",
|
|
1024
|
-
children:
|
|
1030
|
+
children: u
|
|
1025
1031
|
}
|
|
1026
1032
|
) : null
|
|
1027
|
-
) :
|
|
1028
|
-
|
|
1033
|
+
) : E && N === "edit" && v ? /* @__PURE__ */ h("div", { "data-sc-part": "preview-loading", className: "sc-preview-edit-loading", "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: /* @__PURE__ */ h(we.Suspense, { fallback: null, children: we.createElement(v, {
|
|
1034
|
+
visible: b,
|
|
1035
|
+
onExited: g,
|
|
1036
|
+
picture: p,
|
|
1037
|
+
maskKey: y == null ? void 0 : y.mockupId,
|
|
1038
|
+
fit: "cover"
|
|
1039
|
+
}) }) }) : E && N !== "edit" ? /* @__PURE__ */ h(
|
|
1040
|
+
Ge,
|
|
1029
1041
|
{
|
|
1030
|
-
visible:
|
|
1031
|
-
variant:
|
|
1032
|
-
onExited:
|
|
1042
|
+
visible: b,
|
|
1043
|
+
variant: N,
|
|
1044
|
+
onExited: g
|
|
1033
1045
|
}
|
|
1034
1046
|
) : null
|
|
1035
1047
|
]
|
|
1036
1048
|
}
|
|
1037
1049
|
);
|
|
1038
1050
|
}
|
|
1039
|
-
return
|
|
1051
|
+
return y != null && y.imageUrl ? (
|
|
1040
1052
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1041
|
-
/* @__PURE__ */
|
|
1053
|
+
/* @__PURE__ */ h(
|
|
1042
1054
|
"img",
|
|
1043
1055
|
{
|
|
1044
1056
|
"data-sc-part": "preview",
|
|
1045
1057
|
"data-sc-preview-state": d ? "rendering" : "ready",
|
|
1046
|
-
src:
|
|
1058
|
+
src: y.imageUrl,
|
|
1047
1059
|
alt: n,
|
|
1048
1060
|
className: i,
|
|
1049
|
-
style:
|
|
1050
|
-
onLoad:
|
|
1061
|
+
style: o,
|
|
1062
|
+
onLoad: P
|
|
1051
1063
|
}
|
|
1052
1064
|
)
|
|
1053
|
-
) : l ? /* @__PURE__ */
|
|
1065
|
+
) : l ? /* @__PURE__ */ h(
|
|
1054
1066
|
"div",
|
|
1055
1067
|
{
|
|
1056
1068
|
"data-sc-part": "preview-error",
|
|
@@ -1058,48 +1070,48 @@ function We({
|
|
|
1058
1070
|
role: "alert",
|
|
1059
1071
|
"data-sc-error": l,
|
|
1060
1072
|
className: i,
|
|
1061
|
-
style:
|
|
1073
|
+
style: o,
|
|
1062
1074
|
children: t ?? `Render failed: ${l}`
|
|
1063
1075
|
}
|
|
1064
|
-
) : /* @__PURE__ */
|
|
1076
|
+
) : /* @__PURE__ */ h("div", { "data-sc-part": "preview", "data-sc-preview-state": "rendering", "aria-busy": "true", style: { display: "contents" }, children: t });
|
|
1065
1077
|
}
|
|
1066
|
-
function
|
|
1067
|
-
const { layer: t, optional: n = !1, placeholder: r, className: i, style:
|
|
1078
|
+
function rn(e) {
|
|
1079
|
+
const { layer: t, optional: n = !1, placeholder: r, className: i, style: o } = e, a = se("Editor.TextField");
|
|
1068
1080
|
oe("Editor.TextField");
|
|
1069
|
-
const { pushRender: l, throttleMs: d, stateStore:
|
|
1070
|
-
if (!
|
|
1071
|
-
throw new
|
|
1081
|
+
const { pushRender: l, throttleMs: d, stateStore: s } = te(), u = Ee(), c = $(null);
|
|
1082
|
+
if (!Et(t))
|
|
1083
|
+
throw new R(
|
|
1072
1084
|
"E_LAYER_TOKEN_REQUIRED",
|
|
1073
1085
|
`the \`layer\` prop must be a token minted by the design — pass layer={design.layer("name")}, not ${typeof t == "string" ? `the bare string "${t}"` : "a plain value"}. Tokens validate the name against the design's layers at mint time.`,
|
|
1074
1086
|
{ received: typeof t == "string" ? t : typeof t, docSlug: "embed-mode" }
|
|
1075
1087
|
);
|
|
1076
1088
|
if (c.current !== t.name) {
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
throw new
|
|
1089
|
+
const p = s.layerKindOf(t.name);
|
|
1090
|
+
if (p === void 0)
|
|
1091
|
+
throw new R(
|
|
1080
1092
|
"E_LAYER_NOT_FOUND",
|
|
1081
|
-
`no layer "${t.name}" in this Root's design — the token was minted from a different design than the one passed to <Editor.Root design={…}>. Bindable layers here: ${JSON.stringify(
|
|
1082
|
-
{ layerName: t.name, validNames:
|
|
1093
|
+
`no layer "${t.name}" in this Root's design — the token was minted from a different design than the one passed to <Editor.Root design={…}>. Bindable layers here: ${JSON.stringify(s.bindableLayerNames())}.`,
|
|
1094
|
+
{ layerName: t.name, validNames: s.bindableLayerNames(), docSlug: "embed-mode" }
|
|
1083
1095
|
);
|
|
1084
|
-
if (
|
|
1085
|
-
throw new
|
|
1096
|
+
if (p !== "text")
|
|
1097
|
+
throw new R(
|
|
1086
1098
|
"E_LAYER_WRONG_KIND",
|
|
1087
|
-
`layer "${t.name}" is ${
|
|
1088
|
-
{ layerName: t.name, actualKind:
|
|
1099
|
+
`layer "${t.name}" is ${p === null ? "not a bindable kind" : `an ${p} layer`} — <Editor.TextField> binds text layers only.`,
|
|
1100
|
+
{ layerName: t.name, actualKind: p, docSlug: "embed-mode" }
|
|
1089
1101
|
);
|
|
1090
1102
|
c.current = t.name;
|
|
1091
1103
|
}
|
|
1092
|
-
ae(() =>
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
() =>
|
|
1096
|
-
() =>
|
|
1097
|
-
), x =
|
|
1098
|
-
(
|
|
1099
|
-
const E =
|
|
1100
|
-
if (
|
|
1101
|
-
|
|
1102
|
-
new
|
|
1104
|
+
ae(() => a.registry.registerTextField(u, { name: t.name, optional: n }), [a.registry, u, t.name, n]);
|
|
1105
|
+
const v = J(
|
|
1106
|
+
s.subscribe,
|
|
1107
|
+
() => s.textOf(t.name) ?? "",
|
|
1108
|
+
() => s.textOf(t.name) ?? ""
|
|
1109
|
+
), x = K(
|
|
1110
|
+
(p) => {
|
|
1111
|
+
const E = p.target.value, b = a.registry.getCanvasBridge();
|
|
1112
|
+
if (b) {
|
|
1113
|
+
b.setTextByName(t.name, E) || a.reportInvariant(
|
|
1114
|
+
new R(
|
|
1103
1115
|
"E_LAYER_NOT_FOUND",
|
|
1104
1116
|
`layer "${t.name}" no longer exists in the mounted canvas — it was removed or renamed after this <Editor.TextField> bound to it. Bound layers must not be renamed or deleted while a field is mounted (ADR-0085 §3).`,
|
|
1105
1117
|
{ layerName: t.name, docSlug: "embed-mode" }
|
|
@@ -1107,26 +1119,26 @@ function en(e) {
|
|
|
1107
1119
|
);
|
|
1108
1120
|
return;
|
|
1109
1121
|
}
|
|
1110
|
-
|
|
1122
|
+
s.updateTextLayer(t.name, E), l(ee(s.getState()), d);
|
|
1111
1123
|
},
|
|
1112
|
-
[
|
|
1124
|
+
[a, t.name, s, l, d]
|
|
1113
1125
|
);
|
|
1114
|
-
return /* @__PURE__ */
|
|
1126
|
+
return /* @__PURE__ */ h(
|
|
1115
1127
|
"input",
|
|
1116
1128
|
{
|
|
1117
1129
|
"data-sc-part": "textfield",
|
|
1118
1130
|
"data-sc-layer": t.name,
|
|
1119
1131
|
type: "text",
|
|
1120
|
-
value:
|
|
1132
|
+
value: v,
|
|
1121
1133
|
onChange: x,
|
|
1122
1134
|
placeholder: r,
|
|
1123
1135
|
"aria-label": e["aria-label"] ?? t.name,
|
|
1124
1136
|
className: i,
|
|
1125
|
-
style:
|
|
1137
|
+
style: o
|
|
1126
1138
|
}
|
|
1127
1139
|
);
|
|
1128
1140
|
}
|
|
1129
|
-
function
|
|
1141
|
+
function sn(e) {
|
|
1130
1142
|
const t = [];
|
|
1131
1143
|
for (const n of e.missingOptionKeys)
|
|
1132
1144
|
t.push(`option:${n}`);
|
|
@@ -1143,13 +1155,13 @@ function tn(e) {
|
|
|
1143
1155
|
}
|
|
1144
1156
|
return e.hasRenderableElement || t.push("empty-design"), (!Number.isInteger(e.quantity) || e.quantity < 1) && t.push("quantity"), t;
|
|
1145
1157
|
}
|
|
1146
|
-
function
|
|
1158
|
+
function on(e, t) {
|
|
1147
1159
|
const n = t.getCombinations(), r = t.getAttributes();
|
|
1148
1160
|
if (Object.keys(r).length === 0 || n.length === 0) return null;
|
|
1149
1161
|
const i = Object.fromEntries(
|
|
1150
|
-
Object.entries(r).map(([
|
|
1162
|
+
Object.entries(r).map(([o, a]) => [o, { ...a, choices: It(a) }])
|
|
1151
1163
|
);
|
|
1152
|
-
return
|
|
1164
|
+
return yt({
|
|
1153
1165
|
productId: e.productId,
|
|
1154
1166
|
quantity: t.getQuantity(),
|
|
1155
1167
|
selection: t.getSelection(),
|
|
@@ -1157,45 +1169,45 @@ function nn(e, t) {
|
|
|
1157
1169
|
attributes: i
|
|
1158
1170
|
});
|
|
1159
1171
|
}
|
|
1160
|
-
function
|
|
1161
|
-
const { onAddToCart: t, defaultQuantity: n, children: r, className: i, style:
|
|
1172
|
+
function an(e) {
|
|
1173
|
+
const { onAddToCart: t, defaultQuantity: n, children: r, className: i, style: o } = e, a = se("Editor.Buy");
|
|
1162
1174
|
oe("Editor.Buy");
|
|
1163
|
-
const { product: l, stateStore: d } = te(),
|
|
1175
|
+
const { product: l, stateStore: d } = te(), s = a.commerce;
|
|
1164
1176
|
if (!(l != null && l.productId))
|
|
1165
|
-
throw new
|
|
1177
|
+
throw new R(
|
|
1166
1178
|
"E_BUY_NO_PRODUCT",
|
|
1167
1179
|
"<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.",
|
|
1168
1180
|
{ docSlug: "embed-mode" }
|
|
1169
1181
|
);
|
|
1170
|
-
const u =
|
|
1182
|
+
const u = $(!1);
|
|
1171
1183
|
ae(() => {
|
|
1172
|
-
u.current || (u.current = !0, typeof n == "number" &&
|
|
1173
|
-
}, [
|
|
1174
|
-
const c = J(d.subscribe, d.getState, d.getState),
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
),
|
|
1179
|
-
() =>
|
|
1180
|
-
quantity:
|
|
1181
|
-
missingOptionKeys:
|
|
1182
|
-
selectionValid:
|
|
1183
|
-
textFields:
|
|
1184
|
+
u.current || (u.current = !0, typeof n == "number" && s.setQuantity(n));
|
|
1185
|
+
}, [s]);
|
|
1186
|
+
const c = J(d.subscribe, d.getState, d.getState), v = J(s.subscribe, s.getVersion, s.getVersion), x = J(
|
|
1187
|
+
a.registry.subscribe,
|
|
1188
|
+
a.registry.getVersion,
|
|
1189
|
+
a.registry.getVersion
|
|
1190
|
+
), p = s.getQuantity(), E = L(
|
|
1191
|
+
() => sn({
|
|
1192
|
+
quantity: p,
|
|
1193
|
+
missingOptionKeys: s.missingOptionKeys(),
|
|
1194
|
+
selectionValid: s.selectionValid(),
|
|
1195
|
+
textFields: a.registry.getTextFields(),
|
|
1184
1196
|
textOf: (N) => d.textOf(N),
|
|
1185
1197
|
seedTextOf: (N) => d.seedTextOf(N),
|
|
1186
1198
|
hasRenderableElement: d.hasRenderableElement()
|
|
1187
1199
|
}),
|
|
1188
1200
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1189
|
-
[
|
|
1190
|
-
),
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1193
|
-
const N = d.getState(),
|
|
1201
|
+
[s, p, c, v, x]
|
|
1202
|
+
), b = E.length === 0, [g, C] = A(!1), y = $(!1), D = K(() => {
|
|
1203
|
+
if (y.current || !b) return;
|
|
1204
|
+
y.current = !0, C(!0);
|
|
1205
|
+
const N = d.getState(), T = s.resolvedVariantId(), P = {
|
|
1194
1206
|
productId: l.productId,
|
|
1195
|
-
...
|
|
1196
|
-
quantity:
|
|
1197
|
-
selection:
|
|
1198
|
-
cartDetail:
|
|
1207
|
+
...T ? { variantId: T } : {},
|
|
1208
|
+
quantity: s.getQuantity(),
|
|
1209
|
+
selection: s.getSelection(),
|
|
1210
|
+
cartDetail: on(l, s),
|
|
1199
1211
|
designState: N,
|
|
1200
1212
|
// ADR-0101: one artboard per REQUIRED placement — linked placements
|
|
1201
1213
|
// carry the base relabelled — so buy and preview are the same bytes
|
|
@@ -1205,96 +1217,96 @@ function rn(e) {
|
|
|
1205
1217
|
pe(l)
|
|
1206
1218
|
)
|
|
1207
1219
|
};
|
|
1208
|
-
let
|
|
1220
|
+
let m;
|
|
1209
1221
|
try {
|
|
1210
|
-
|
|
1211
|
-
} catch (
|
|
1212
|
-
throw
|
|
1222
|
+
m = t(P);
|
|
1223
|
+
} catch (S) {
|
|
1224
|
+
throw y.current = !1, C(!1), S;
|
|
1213
1225
|
}
|
|
1214
|
-
Promise.resolve(
|
|
1215
|
-
|
|
1226
|
+
Promise.resolve(m).finally(() => {
|
|
1227
|
+
y.current = !1, C(!1);
|
|
1216
1228
|
});
|
|
1217
|
-
}, [
|
|
1218
|
-
return /* @__PURE__ */
|
|
1229
|
+
}, [b, l, s, d, t]);
|
|
1230
|
+
return /* @__PURE__ */ h(
|
|
1219
1231
|
"button",
|
|
1220
1232
|
{
|
|
1221
1233
|
type: "button",
|
|
1222
1234
|
"data-sc-part": "buy",
|
|
1223
|
-
"data-sc-buy-state":
|
|
1235
|
+
"data-sc-buy-state": g ? "busy" : b ? "ready" : "incomplete",
|
|
1224
1236
|
"data-sc-buy-missing": E.join(",") || void 0,
|
|
1225
|
-
disabled: !
|
|
1226
|
-
"aria-busy":
|
|
1227
|
-
onClick:
|
|
1237
|
+
disabled: !b || g,
|
|
1238
|
+
"aria-busy": g || void 0,
|
|
1239
|
+
onClick: D,
|
|
1228
1240
|
className: i,
|
|
1229
|
-
style:
|
|
1241
|
+
style: o,
|
|
1230
1242
|
children: r ?? "Add to cart"
|
|
1231
1243
|
}
|
|
1232
1244
|
);
|
|
1233
1245
|
}
|
|
1234
|
-
function
|
|
1246
|
+
function dn({
|
|
1235
1247
|
placement: e = "docked",
|
|
1236
1248
|
className: t,
|
|
1237
1249
|
style: n
|
|
1238
1250
|
}) {
|
|
1239
1251
|
const r = se("Editor.Controls");
|
|
1240
|
-
|
|
1241
|
-
const i =
|
|
1252
|
+
rt("Editor.Controls"), oe("Editor.Controls");
|
|
1253
|
+
const i = Ee();
|
|
1242
1254
|
ae(
|
|
1243
1255
|
() => r.registry.registerControls(i, e),
|
|
1244
1256
|
[r.registry, i, e]
|
|
1245
1257
|
);
|
|
1246
|
-
const
|
|
1247
|
-
return
|
|
1248
|
-
if (!
|
|
1258
|
+
const o = e === "docked", [a, l] = A(null);
|
|
1259
|
+
return F(() => {
|
|
1260
|
+
if (!o) return;
|
|
1249
1261
|
let d = !1;
|
|
1250
|
-
return import("./ContextualToolbars-
|
|
1251
|
-
(
|
|
1252
|
-
d || l(() =>
|
|
1262
|
+
return import("./ContextualToolbars-5tHC6s0Y.js").then((s) => s.s).then(
|
|
1263
|
+
(s) => {
|
|
1264
|
+
d || l(() => s.ContextualToolbars);
|
|
1253
1265
|
},
|
|
1254
|
-
(
|
|
1266
|
+
(s) => {
|
|
1255
1267
|
d || r.reportRuntimeError(
|
|
1256
|
-
new
|
|
1268
|
+
new R(
|
|
1257
1269
|
"E_CHUNK_LOAD_FAILED",
|
|
1258
|
-
`the editor's controls chunk failed to load (${
|
|
1259
|
-
{ cause:
|
|
1270
|
+
`the editor's controls chunk failed to load (${s instanceof Error ? s.message : String(s)}). This is a network/CDN failure, not a composition mistake — retry, or check the deployment serves the @snowcone-app/canvas lazy chunks.`,
|
|
1271
|
+
{ cause: s instanceof Error ? s.message : String(s), docSlug: "embed-mode" }
|
|
1260
1272
|
)
|
|
1261
1273
|
);
|
|
1262
1274
|
}
|
|
1263
1275
|
), () => {
|
|
1264
1276
|
d = !0;
|
|
1265
1277
|
};
|
|
1266
|
-
}, [
|
|
1278
|
+
}, [o, r]), o ? /* @__PURE__ */ h(
|
|
1267
1279
|
"div",
|
|
1268
1280
|
{
|
|
1269
1281
|
"data-sc-part": "controls",
|
|
1270
1282
|
"data-sc-placement": "docked",
|
|
1271
1283
|
className: t,
|
|
1272
1284
|
style: n,
|
|
1273
|
-
"aria-busy":
|
|
1274
|
-
children:
|
|
1285
|
+
"aria-busy": a ? void 0 : "true",
|
|
1286
|
+
children: a ? /* @__PURE__ */ h(a, { mode: "embedded" }) : null
|
|
1275
1287
|
}
|
|
1276
1288
|
) : null;
|
|
1277
1289
|
}
|
|
1278
|
-
function
|
|
1290
|
+
function ln({
|
|
1279
1291
|
variant: e = "dark",
|
|
1280
1292
|
className: t,
|
|
1281
1293
|
style: n
|
|
1282
1294
|
}) {
|
|
1283
|
-
const { isRendering: r } = te(), { showOverlay: i, overlayVisible:
|
|
1284
|
-
return i ? /* @__PURE__ */
|
|
1295
|
+
const { isRendering: r } = te(), { showOverlay: i, overlayVisible: o, handleExited: a } = We(r);
|
|
1296
|
+
return i ? /* @__PURE__ */ h(
|
|
1285
1297
|
"div",
|
|
1286
1298
|
{
|
|
1287
1299
|
"data-sc-part": "loading-overlay",
|
|
1288
1300
|
className: `sc-loading-overlay-host${t ? ` ${t}` : ""}`,
|
|
1289
1301
|
style: n,
|
|
1290
1302
|
"aria-hidden": "true",
|
|
1291
|
-
children: /* @__PURE__ */
|
|
1303
|
+
children: /* @__PURE__ */ h(Ge, { visible: o, variant: e, onExited: a })
|
|
1292
1304
|
}
|
|
1293
1305
|
) : null;
|
|
1294
1306
|
}
|
|
1295
|
-
function
|
|
1296
|
-
const t = se("useProductSelection").commerce, n = J(t.subscribe, t.getVersion, t.getVersion), r =
|
|
1297
|
-
return
|
|
1307
|
+
function cn() {
|
|
1308
|
+
const t = se("useProductSelection").commerce, n = J(t.subscribe, t.getVersion, t.getVersion), r = K((o, a) => t.select(o, a), [t]), i = K((o) => t.setQuantity(o), [t]);
|
|
1309
|
+
return L(
|
|
1298
1310
|
() => ({
|
|
1299
1311
|
attributes: t.getAttributes(),
|
|
1300
1312
|
selection: t.getSelection(),
|
|
@@ -1313,43 +1325,43 @@ function an() {
|
|
|
1313
1325
|
}
|
|
1314
1326
|
const H = {
|
|
1315
1327
|
/** The one provider boundary — session, design, live state, error boundary. */
|
|
1316
|
-
Root:
|
|
1328
|
+
Root: ze,
|
|
1317
1329
|
/** The editable artboard (the ONE lazy renderer boundary — D9). */
|
|
1318
|
-
Canvas:
|
|
1330
|
+
Canvas: Mt,
|
|
1319
1331
|
/** Live product mockup. ×N under one Root is valid. */
|
|
1320
|
-
Preview:
|
|
1332
|
+
Preview: He,
|
|
1321
1333
|
/** Placement switcher tabs (ADR-0088). Renders nothing for a
|
|
1322
1334
|
* single-placement design; headless floor = usePlacements(). */
|
|
1323
|
-
Placements:
|
|
1335
|
+
Placements: Gt,
|
|
1324
1336
|
/** Form input bound to a design text layer by typed token (T1). */
|
|
1325
|
-
TextField:
|
|
1337
|
+
TextField: rn,
|
|
1326
1338
|
/** Smart commerce part: completeness + payload assembly; submit = host callback. */
|
|
1327
|
-
Buy:
|
|
1339
|
+
Buy: an,
|
|
1328
1340
|
/** Layer list. The one editor part that works canvas-free (ADR-0085 §4). */
|
|
1329
|
-
Layers:
|
|
1341
|
+
Layers: at,
|
|
1330
1342
|
/** Morphing contextual zone — ONE coarse part; placement docked|floating (§5). */
|
|
1331
|
-
Controls:
|
|
1343
|
+
Controls: dn,
|
|
1332
1344
|
/** Undo/redo controls. Requires Editor.Canvas. */
|
|
1333
|
-
History:
|
|
1345
|
+
History: ot,
|
|
1334
1346
|
/** The one ⋯ overflow menu. Requires Editor.Canvas. */
|
|
1335
|
-
Menu:
|
|
1347
|
+
Menu: st,
|
|
1336
1348
|
/** The ⊕ add-element menu. Requires Editor.Canvas. */
|
|
1337
|
-
Add:
|
|
1349
|
+
Add: it,
|
|
1338
1350
|
/** Standalone render-in-flight rainbow for host-owned preview surfaces.
|
|
1339
1351
|
* Fills its positioned parent; rides the session (canvas-free). */
|
|
1340
|
-
LoadingOverlay:
|
|
1352
|
+
LoadingOverlay: ln
|
|
1341
1353
|
};
|
|
1342
|
-
function
|
|
1343
|
-
return /* @__PURE__ */
|
|
1354
|
+
function Tn(e) {
|
|
1355
|
+
return /* @__PURE__ */ h(ze, { ...e, __validation: "warn" });
|
|
1344
1356
|
}
|
|
1345
|
-
const
|
|
1357
|
+
const An = Le(
|
|
1346
1358
|
function(t, n) {
|
|
1347
|
-
const { children: r, className: i, style:
|
|
1348
|
-
return
|
|
1359
|
+
const { children: r, className: i, style: o, maxHeight: a, ...l } = t, [d, s] = A(null);
|
|
1360
|
+
return F(() => {
|
|
1349
1361
|
let u = !1;
|
|
1350
|
-
return
|
|
1362
|
+
return Ke().then(
|
|
1351
1363
|
(c) => {
|
|
1352
|
-
u ||
|
|
1364
|
+
u || s(() => c);
|
|
1353
1365
|
},
|
|
1354
1366
|
(c) => {
|
|
1355
1367
|
console.error("[RealtimeCanvas] failed to load the rendering chunk:", c);
|
|
@@ -1357,62 +1369,62 @@ const Nn = Ae(
|
|
|
1357
1369
|
), () => {
|
|
1358
1370
|
u = !0;
|
|
1359
1371
|
};
|
|
1360
|
-
}, []), d ? /* @__PURE__ */
|
|
1372
|
+
}, []), d ? /* @__PURE__ */ h(d, { ref: n, selfScope: !0, maxHeight: a, className: i, style: o, ...l, children: r }) : /* @__PURE__ */ h(
|
|
1361
1373
|
"div",
|
|
1362
1374
|
{
|
|
1363
1375
|
className: `sc-root${i ? ` ${i}` : ""}`,
|
|
1364
|
-
style: { minHeight:
|
|
1376
|
+
style: { minHeight: a ?? 200, ...o },
|
|
1365
1377
|
"aria-busy": "true"
|
|
1366
1378
|
}
|
|
1367
1379
|
);
|
|
1368
1380
|
}
|
|
1369
1381
|
);
|
|
1370
|
-
function
|
|
1371
|
-
return /* @__PURE__ */
|
|
1382
|
+
function Dn(e) {
|
|
1383
|
+
return /* @__PURE__ */ h(He, { ...e });
|
|
1372
1384
|
}
|
|
1373
|
-
function
|
|
1385
|
+
function Ln() {
|
|
1374
1386
|
const { mockups: e, isRendering: t, error: n } = te();
|
|
1375
1387
|
return { mockups: e, isRendering: t, error: n };
|
|
1376
1388
|
}
|
|
1377
|
-
function
|
|
1389
|
+
function un(e) {
|
|
1378
1390
|
return e.type !== "color" && typeof e.width == "number" && e.width > 0 && typeof e.height == "number" && e.height > 0;
|
|
1379
1391
|
}
|
|
1380
|
-
function
|
|
1381
|
-
var
|
|
1392
|
+
function Bn(e, t = {}) {
|
|
1393
|
+
var v, x, p, E, b;
|
|
1382
1394
|
if (Ue(e))
|
|
1383
|
-
throw new
|
|
1395
|
+
throw new R(
|
|
1384
1396
|
"E_BUNDLE_CONFIG_REQUIRED",
|
|
1385
|
-
`product ${e.id} is a bundle (roles: [${e.bundle.members.map((
|
|
1397
|
+
`product ${e.id} is a bundle (roles: [${e.bundle.members.map((g) => g.role).join(", ")}]) — it has per-role variants and role-scoped placement keys, which the single-product config cannot describe. Use bundleToRenderConfig(product, { picks?, variants?, placement?, width? }) instead.`,
|
|
1386
1398
|
{
|
|
1387
1399
|
productId: e.id,
|
|
1388
|
-
validNames: e.bundle.members.map((
|
|
1400
|
+
validNames: e.bundle.members.map((g) => g.role),
|
|
1389
1401
|
docSlug: "bundles"
|
|
1390
1402
|
}
|
|
1391
1403
|
);
|
|
1392
|
-
const n = (e.placements ?? []).filter(
|
|
1404
|
+
const n = (e.placements ?? []).filter(un), r = n.map((g) => g.label), i = t.placement ? n.find((g) => g.label === t.placement) : n[0];
|
|
1393
1405
|
if (!i)
|
|
1394
|
-
throw t.placement ? new
|
|
1406
|
+
throw t.placement ? new R(
|
|
1395
1407
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1396
1408
|
`product ${e.id} has no renderable placement "${t.placement}". Renderable image placements: [${r.join(", ")}].`,
|
|
1397
1409
|
{ productId: e.id, requested: t.placement, validNames: r, docSlug: "embed-mode" }
|
|
1398
|
-
) : new
|
|
1410
|
+
) : new R(
|
|
1399
1411
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1400
1412
|
`product ${e.id} has no renderable image placement (a non-color placement with width/height). The catalog payload may be incomplete — fetch it via getProduct(), not a search hit.`,
|
|
1401
1413
|
{ productId: e.id, docSlug: "embed-mode" }
|
|
1402
1414
|
);
|
|
1403
|
-
const
|
|
1404
|
-
(
|
|
1405
|
-
var
|
|
1406
|
-
return (
|
|
1415
|
+
const o = ((v = e.options) == null ? void 0 : v.attributes) ?? {}, l = Object.values(o).some(
|
|
1416
|
+
(g) => {
|
|
1417
|
+
var C;
|
|
1418
|
+
return (C = g == null ? void 0 : g.choices) == null ? void 0 : C.some((y) => y == null ? void 0 : y.hex);
|
|
1407
1419
|
}
|
|
1408
|
-
) ? (E = (
|
|
1409
|
-
(
|
|
1410
|
-
)) == null ? void 0 : E.variantId : void 0, d = e.mockups ?? [],
|
|
1411
|
-
var
|
|
1412
|
-
return (
|
|
1413
|
-
}) : d, u = (
|
|
1420
|
+
) ? (E = (p = (x = e.options) == null ? void 0 : x.combinations) == null ? void 0 : p.find(
|
|
1421
|
+
(g) => typeof g.variantId == "string" && g.variantId !== ""
|
|
1422
|
+
)) == null ? void 0 : E.variantId : void 0, d = e.mockups ?? [], s = l ? d.filter((g) => {
|
|
1423
|
+
var C;
|
|
1424
|
+
return (C = g.gvids) == null ? void 0 : C.includes(l);
|
|
1425
|
+
}) : d, u = (s.length > 0 ? s : d).map((g) => g.id);
|
|
1414
1426
|
if (u.length === 0)
|
|
1415
|
-
throw new
|
|
1427
|
+
throw new R(
|
|
1416
1428
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1417
1429
|
`product ${e.id} has no mockup scenes — nothing to render a preview into.`,
|
|
1418
1430
|
{ productId: e.id, docSlug: "embed-mode" }
|
|
@@ -1423,7 +1435,7 @@ function An(e, t = {}) {
|
|
|
1423
1435
|
mockupIds: u,
|
|
1424
1436
|
...typeof l == "string" ? { variantId: l } : {},
|
|
1425
1437
|
options: e.options,
|
|
1426
|
-
placements: (
|
|
1438
|
+
placements: (b = e.placements) == null ? void 0 : b.map((g) => g.label),
|
|
1427
1439
|
mockups: d,
|
|
1428
1440
|
requiredPlacements: e.requiredPlacements,
|
|
1429
1441
|
...e.defaultGvid ? { defaultGvid: e.defaultGvid } : {},
|
|
@@ -1436,17 +1448,17 @@ function An(e, t = {}) {
|
|
|
1436
1448
|
aspectRatio: i.width / i.height
|
|
1437
1449
|
},
|
|
1438
1450
|
placementLabels: r,
|
|
1439
|
-
placements: n.map((
|
|
1440
|
-
label:
|
|
1441
|
-
width:
|
|
1442
|
-
height:
|
|
1443
|
-
aspectRatio:
|
|
1451
|
+
placements: n.map((g) => ({
|
|
1452
|
+
label: g.label,
|
|
1453
|
+
width: g.width,
|
|
1454
|
+
height: g.height,
|
|
1455
|
+
aspectRatio: g.width / g.height
|
|
1444
1456
|
})),
|
|
1445
1457
|
primaryMockupId: u[0],
|
|
1446
1458
|
variantId: l
|
|
1447
1459
|
};
|
|
1448
1460
|
}
|
|
1449
|
-
function
|
|
1461
|
+
function mn(e) {
|
|
1450
1462
|
return new Intl.NumberFormat("en-US", {
|
|
1451
1463
|
style: "currency",
|
|
1452
1464
|
currency: "USD",
|
|
@@ -1454,7 +1466,7 @@ function ln(e) {
|
|
|
1454
1466
|
maximumFractionDigits: e % 100 === 0 ? 0 : 2
|
|
1455
1467
|
}).format(e / 100);
|
|
1456
1468
|
}
|
|
1457
|
-
const
|
|
1469
|
+
const pn = {
|
|
1458
1470
|
display: "inline-flex",
|
|
1459
1471
|
alignItems: "center",
|
|
1460
1472
|
justifyContent: "center",
|
|
@@ -1469,7 +1481,7 @@ const cn = {
|
|
|
1469
1481
|
fontSize: 16,
|
|
1470
1482
|
lineHeight: 1,
|
|
1471
1483
|
cursor: "pointer"
|
|
1472
|
-
},
|
|
1484
|
+
}, fn = {
|
|
1473
1485
|
display: "flex",
|
|
1474
1486
|
alignItems: "center",
|
|
1475
1487
|
gap: 10,
|
|
@@ -1489,43 +1501,43 @@ function ve({
|
|
|
1489
1501
|
label: e,
|
|
1490
1502
|
onSelect: t
|
|
1491
1503
|
}) {
|
|
1492
|
-
return /* @__PURE__ */
|
|
1504
|
+
return /* @__PURE__ */ h(
|
|
1493
1505
|
"button",
|
|
1494
1506
|
{
|
|
1495
1507
|
type: "button",
|
|
1496
1508
|
role: "menuitem",
|
|
1497
1509
|
"data-sc-part": "snowcone-editor-menu-item",
|
|
1498
|
-
style:
|
|
1510
|
+
style: fn,
|
|
1499
1511
|
onClick: t,
|
|
1500
1512
|
children: e
|
|
1501
1513
|
}
|
|
1502
1514
|
);
|
|
1503
1515
|
}
|
|
1504
|
-
function
|
|
1516
|
+
function hn({
|
|
1505
1517
|
fullscreen: e,
|
|
1506
1518
|
onToggleFullscreen: t,
|
|
1507
1519
|
viewCount: n,
|
|
1508
1520
|
viewIndex: r,
|
|
1509
1521
|
onSelectView: i,
|
|
1510
|
-
onExport:
|
|
1522
|
+
onExport: o
|
|
1511
1523
|
}) {
|
|
1512
|
-
const [
|
|
1524
|
+
const [a, l] = A(!1), d = () => l(!1);
|
|
1513
1525
|
return /* @__PURE__ */ U("div", { style: { position: "relative" }, children: [
|
|
1514
|
-
/* @__PURE__ */
|
|
1526
|
+
/* @__PURE__ */ h(
|
|
1515
1527
|
"button",
|
|
1516
1528
|
{
|
|
1517
1529
|
type: "button",
|
|
1518
1530
|
"aria-label": "Editor menu",
|
|
1519
1531
|
"aria-haspopup": "menu",
|
|
1520
|
-
"aria-expanded":
|
|
1532
|
+
"aria-expanded": a,
|
|
1521
1533
|
"data-sc-part": "snowcone-editor-menu",
|
|
1522
|
-
style:
|
|
1523
|
-
onClick: () => l((
|
|
1534
|
+
style: pn,
|
|
1535
|
+
onClick: () => l((s) => !s),
|
|
1524
1536
|
children: "⋮"
|
|
1525
1537
|
}
|
|
1526
1538
|
),
|
|
1527
|
-
|
|
1528
|
-
/* @__PURE__ */
|
|
1539
|
+
a ? /* @__PURE__ */ U(ct, { children: [
|
|
1540
|
+
/* @__PURE__ */ h(
|
|
1529
1541
|
"div",
|
|
1530
1542
|
{
|
|
1531
1543
|
style: { position: "fixed", inset: 0, zIndex: 39 },
|
|
@@ -1552,7 +1564,7 @@ function mn({
|
|
|
1552
1564
|
zIndex: 40
|
|
1553
1565
|
},
|
|
1554
1566
|
children: [
|
|
1555
|
-
/* @__PURE__ */
|
|
1567
|
+
/* @__PURE__ */ h(
|
|
1556
1568
|
ve,
|
|
1557
1569
|
{
|
|
1558
1570
|
label: e ? "Exit fullscreen" : "Fullscreen",
|
|
@@ -1561,7 +1573,7 @@ function mn({
|
|
|
1561
1573
|
}
|
|
1562
1574
|
}
|
|
1563
1575
|
),
|
|
1564
|
-
n > 1 ? Array.from({ length: n }, (
|
|
1576
|
+
n > 1 ? Array.from({ length: n }, (s, u) => /* @__PURE__ */ h(
|
|
1565
1577
|
ve,
|
|
1566
1578
|
{
|
|
1567
1579
|
label: `View ${u + 1}${u === r ? " ✓" : ""}`,
|
|
@@ -1571,12 +1583,12 @@ function mn({
|
|
|
1571
1583
|
},
|
|
1572
1584
|
u
|
|
1573
1585
|
)) : null,
|
|
1574
|
-
/* @__PURE__ */
|
|
1586
|
+
/* @__PURE__ */ h(
|
|
1575
1587
|
ve,
|
|
1576
1588
|
{
|
|
1577
1589
|
label: "Export PNG",
|
|
1578
1590
|
onSelect: () => {
|
|
1579
|
-
d(),
|
|
1591
|
+
d(), o();
|
|
1580
1592
|
}
|
|
1581
1593
|
}
|
|
1582
1594
|
)
|
|
@@ -1586,9 +1598,9 @@ function mn({
|
|
|
1586
1598
|
] }) : null
|
|
1587
1599
|
] });
|
|
1588
1600
|
}
|
|
1589
|
-
function
|
|
1590
|
-
const { flatLayers: e, selectLayer: t, generateAllPreviews: n } =
|
|
1591
|
-
return
|
|
1601
|
+
function gn() {
|
|
1602
|
+
const { flatLayers: e, selectLayer: t, generateAllPreviews: n } = dt({ previewSize: 96 });
|
|
1603
|
+
return F(() => {
|
|
1592
1604
|
e.length > 0 && n();
|
|
1593
1605
|
}, [e.length, n]), /* @__PURE__ */ U(
|
|
1594
1606
|
"div",
|
|
@@ -1596,9 +1608,9 @@ function pn() {
|
|
|
1596
1608
|
"data-sc-part": "snowcone-editor-idle-dock",
|
|
1597
1609
|
style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, minHeight: 44 },
|
|
1598
1610
|
children: [
|
|
1599
|
-
/* @__PURE__ */
|
|
1600
|
-
e.length > 0 ? /* @__PURE__ */
|
|
1601
|
-
e.map((r) => /* @__PURE__ */
|
|
1611
|
+
/* @__PURE__ */ h(H.Add, {}),
|
|
1612
|
+
e.length > 0 ? /* @__PURE__ */ h("div", { style: { width: 1, height: 28, background: "rgba(0,0,0,0.1)", flexShrink: 0 }, "aria-hidden": "true" }) : null,
|
|
1613
|
+
e.map((r) => /* @__PURE__ */ h(
|
|
1602
1614
|
"button",
|
|
1603
1615
|
{
|
|
1604
1616
|
type: "button",
|
|
@@ -1621,8 +1633,8 @@ function pn() {
|
|
|
1621
1633
|
},
|
|
1622
1634
|
children: r.previewUrl ? (
|
|
1623
1635
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1624
|
-
/* @__PURE__ */
|
|
1625
|
-
) : /* @__PURE__ */
|
|
1636
|
+
/* @__PURE__ */ h("img", { src: r.previewUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "contain" } })
|
|
1637
|
+
) : /* @__PURE__ */ h(
|
|
1626
1638
|
"span",
|
|
1627
1639
|
{
|
|
1628
1640
|
style: {
|
|
@@ -1643,11 +1655,11 @@ function pn() {
|
|
|
1643
1655
|
}
|
|
1644
1656
|
);
|
|
1645
1657
|
}
|
|
1646
|
-
function
|
|
1658
|
+
function yn({
|
|
1647
1659
|
onAddToCart: e,
|
|
1648
1660
|
defaultQuantity: t
|
|
1649
1661
|
}) {
|
|
1650
|
-
const { price: n, complete: r } =
|
|
1662
|
+
const { price: n, complete: r } = cn();
|
|
1651
1663
|
return /* @__PURE__ */ U(
|
|
1652
1664
|
H.Buy,
|
|
1653
1665
|
{
|
|
@@ -1672,29 +1684,29 @@ function fn({
|
|
|
1672
1684
|
},
|
|
1673
1685
|
children: [
|
|
1674
1686
|
"Add to cart",
|
|
1675
|
-
typeof n == "number" ? ` · ${
|
|
1687
|
+
typeof n == "number" ? ` · ${mn(n)}` : ""
|
|
1676
1688
|
]
|
|
1677
1689
|
}
|
|
1678
1690
|
);
|
|
1679
1691
|
}
|
|
1680
|
-
function
|
|
1692
|
+
function bn({
|
|
1681
1693
|
title: e,
|
|
1682
1694
|
height: t,
|
|
1683
1695
|
mockupIds: n,
|
|
1684
1696
|
onAddToCart: r,
|
|
1685
1697
|
defaultQuantity: i,
|
|
1686
|
-
className:
|
|
1687
|
-
style:
|
|
1698
|
+
className: o,
|
|
1699
|
+
style: a
|
|
1688
1700
|
}) {
|
|
1689
|
-
const [l, d] =
|
|
1690
|
-
var
|
|
1691
|
-
const
|
|
1692
|
-
if (!
|
|
1693
|
-
const [
|
|
1701
|
+
const [l, d] = A(!1), [s, u] = A(0), [c, v] = A(!1), x = $(null), p = Ot(), E = n[Math.min(s, n.length - 1)], b = K(async () => {
|
|
1702
|
+
var P;
|
|
1703
|
+
const y = await ((P = x.current) == null ? void 0 : P.exportArtboards({ format: "dataUrl" }));
|
|
1704
|
+
if (!y) return;
|
|
1705
|
+
const [D, N] = Object.entries(y)[0] ?? [];
|
|
1694
1706
|
if (typeof N != "string") return;
|
|
1695
|
-
const
|
|
1696
|
-
|
|
1697
|
-
}, []),
|
|
1707
|
+
const T = document.createElement("a");
|
|
1708
|
+
T.href = N, T.download = `${D ?? "design"}.png`, T.click();
|
|
1709
|
+
}, []), g = {
|
|
1698
1710
|
display: "flex",
|
|
1699
1711
|
flexDirection: "column",
|
|
1700
1712
|
overflow: "hidden",
|
|
@@ -1714,8 +1726,8 @@ function hn({
|
|
|
1714
1726
|
border: "1px solid rgba(0,0,0,0.08)",
|
|
1715
1727
|
boxShadow: "0 1px 3px rgba(0,0,0,0.08)"
|
|
1716
1728
|
},
|
|
1717
|
-
...
|
|
1718
|
-
},
|
|
1729
|
+
...a
|
|
1730
|
+
}, C = {
|
|
1719
1731
|
position: "absolute",
|
|
1720
1732
|
top: 8,
|
|
1721
1733
|
right: 12,
|
|
@@ -1735,8 +1747,8 @@ function hn({
|
|
|
1735
1747
|
{
|
|
1736
1748
|
"data-sc-part": "snowcone-editor",
|
|
1737
1749
|
"data-sc-fullscreen": l ? "true" : void 0,
|
|
1738
|
-
className:
|
|
1739
|
-
style:
|
|
1750
|
+
className: o,
|
|
1751
|
+
style: g,
|
|
1740
1752
|
children: [
|
|
1741
1753
|
/* @__PURE__ */ U(
|
|
1742
1754
|
"div",
|
|
@@ -1750,20 +1762,20 @@ function hn({
|
|
|
1750
1762
|
flexShrink: 0
|
|
1751
1763
|
},
|
|
1752
1764
|
children: [
|
|
1753
|
-
/* @__PURE__ */
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
/* @__PURE__ */
|
|
1756
|
-
|
|
1765
|
+
/* @__PURE__ */ h("span", { style: { fontSize: 14, fontWeight: 700, marginRight: "auto" }, children: e }),
|
|
1766
|
+
/* @__PURE__ */ h(H.History, {}),
|
|
1767
|
+
/* @__PURE__ */ h(
|
|
1768
|
+
hn,
|
|
1757
1769
|
{
|
|
1758
1770
|
fullscreen: l,
|
|
1759
|
-
onToggleFullscreen: () => d((
|
|
1771
|
+
onToggleFullscreen: () => d((y) => !y),
|
|
1760
1772
|
viewCount: n.length,
|
|
1761
|
-
viewIndex:
|
|
1773
|
+
viewIndex: s,
|
|
1762
1774
|
onSelectView: u,
|
|
1763
|
-
onExport: () => void
|
|
1775
|
+
onExport: () => void b()
|
|
1764
1776
|
}
|
|
1765
1777
|
),
|
|
1766
|
-
/* @__PURE__ */
|
|
1778
|
+
/* @__PURE__ */ h(yn, { onAddToCart: r, defaultQuantity: i })
|
|
1767
1779
|
]
|
|
1768
1780
|
}
|
|
1769
1781
|
),
|
|
@@ -1773,7 +1785,7 @@ function hn({
|
|
|
1773
1785
|
"data-sc-part": "snowcone-editor-stage",
|
|
1774
1786
|
style: { position: "relative", flex: 1, minHeight: 0, padding: "4px 12px" },
|
|
1775
1787
|
children: [
|
|
1776
|
-
/* @__PURE__ */
|
|
1788
|
+
/* @__PURE__ */ h(H.Canvas, { ref: x, style: { height: "100%" } }),
|
|
1777
1789
|
c ? (
|
|
1778
1790
|
// Swapped: the mockup IS the stage; the corner chip returns to the
|
|
1779
1791
|
// artwork. The canvas stays mounted underneath (no document
|
|
@@ -1793,25 +1805,25 @@ function hn({
|
|
|
1793
1805
|
padding: 8
|
|
1794
1806
|
},
|
|
1795
1807
|
children: [
|
|
1796
|
-
/* @__PURE__ */
|
|
1808
|
+
/* @__PURE__ */ h(
|
|
1797
1809
|
H.Preview,
|
|
1798
1810
|
{
|
|
1799
1811
|
mockupId: E,
|
|
1800
1812
|
alt: "Product mockup",
|
|
1801
1813
|
loadingOverlay: !0,
|
|
1802
|
-
fallback: /* @__PURE__ */
|
|
1814
|
+
fallback: /* @__PURE__ */ h("div", { "aria-busy": "true", children: "Rendering…" }),
|
|
1803
1815
|
style: { maxWidth: "100%", maxHeight: "100%", borderRadius: 12 }
|
|
1804
1816
|
}
|
|
1805
1817
|
),
|
|
1806
|
-
/* @__PURE__ */
|
|
1818
|
+
/* @__PURE__ */ h(
|
|
1807
1819
|
"button",
|
|
1808
1820
|
{
|
|
1809
1821
|
type: "button",
|
|
1810
1822
|
"aria-label": "Back to artwork",
|
|
1811
1823
|
"data-sc-part": "snowcone-editor-swap-back",
|
|
1812
|
-
onClick: () =>
|
|
1824
|
+
onClick: () => v(!1),
|
|
1813
1825
|
style: {
|
|
1814
|
-
...
|
|
1826
|
+
...C,
|
|
1815
1827
|
display: "flex",
|
|
1816
1828
|
alignItems: "center",
|
|
1817
1829
|
justifyContent: "center",
|
|
@@ -1826,21 +1838,21 @@ function hn({
|
|
|
1826
1838
|
]
|
|
1827
1839
|
}
|
|
1828
1840
|
)
|
|
1829
|
-
) : /* @__PURE__ */
|
|
1841
|
+
) : /* @__PURE__ */ h(
|
|
1830
1842
|
"button",
|
|
1831
1843
|
{
|
|
1832
1844
|
type: "button",
|
|
1833
1845
|
"aria-label": "Show product mockup",
|
|
1834
1846
|
"data-sc-part": "snowcone-editor-pip",
|
|
1835
|
-
onClick: () =>
|
|
1836
|
-
style:
|
|
1837
|
-
children: /* @__PURE__ */
|
|
1847
|
+
onClick: () => v(!0),
|
|
1848
|
+
style: C,
|
|
1849
|
+
children: /* @__PURE__ */ h(
|
|
1838
1850
|
H.Preview,
|
|
1839
1851
|
{
|
|
1840
1852
|
mockupId: E,
|
|
1841
1853
|
alt: "Product mockup preview",
|
|
1842
1854
|
loadingOverlay: !0,
|
|
1843
|
-
fallback: /* @__PURE__ */
|
|
1855
|
+
fallback: /* @__PURE__ */ h("span", { style: { fontSize: 10, opacity: 0.5 }, "aria-busy": "true", children: "mockup…" }),
|
|
1844
1856
|
style: { width: "100%", height: "100%", display: "block" }
|
|
1845
1857
|
}
|
|
1846
1858
|
)
|
|
@@ -1853,11 +1865,11 @@ function hn({
|
|
|
1853
1865
|
"div",
|
|
1854
1866
|
{
|
|
1855
1867
|
"data-sc-part": "snowcone-editor-zone",
|
|
1856
|
-
"data-sc-zone-state":
|
|
1868
|
+
"data-sc-zone-state": p ? "selected" : "idle",
|
|
1857
1869
|
style: { flexShrink: 0, padding: "4px 16px 14px" },
|
|
1858
1870
|
children: [
|
|
1859
|
-
/* @__PURE__ */
|
|
1860
|
-
|
|
1871
|
+
/* @__PURE__ */ h("div", { style: { display: p ? void 0 : "none" }, children: /* @__PURE__ */ h(H.Controls, { placement: "docked" }) }),
|
|
1872
|
+
p ? null : /* @__PURE__ */ h(gn, {})
|
|
1861
1873
|
]
|
|
1862
1874
|
}
|
|
1863
1875
|
)
|
|
@@ -1865,49 +1877,49 @@ function hn({
|
|
|
1865
1877
|
}
|
|
1866
1878
|
);
|
|
1867
1879
|
}
|
|
1868
|
-
function
|
|
1880
|
+
function Un(e) {
|
|
1869
1881
|
const {
|
|
1870
1882
|
onAddToCart: t,
|
|
1871
1883
|
defaultQuantity: n,
|
|
1872
1884
|
title: r = "Editor",
|
|
1873
1885
|
height: i = 480,
|
|
1874
|
-
className:
|
|
1875
|
-
style:
|
|
1886
|
+
className: o,
|
|
1887
|
+
style: a,
|
|
1876
1888
|
...l
|
|
1877
1889
|
} = e;
|
|
1878
|
-
return /* @__PURE__ */
|
|
1879
|
-
|
|
1890
|
+
return /* @__PURE__ */ h(H.Root, { ...l, children: /* @__PURE__ */ h(
|
|
1891
|
+
bn,
|
|
1880
1892
|
{
|
|
1881
1893
|
title: r,
|
|
1882
1894
|
height: i,
|
|
1883
1895
|
mockupIds: l.product.mockupIds,
|
|
1884
1896
|
onAddToCart: t,
|
|
1885
1897
|
...typeof n == "number" ? { defaultQuantity: n } : {},
|
|
1886
|
-
className:
|
|
1887
|
-
style:
|
|
1898
|
+
className: o,
|
|
1899
|
+
style: a
|
|
1888
1900
|
}
|
|
1889
1901
|
) });
|
|
1890
1902
|
}
|
|
1891
|
-
|
|
1903
|
+
lt();
|
|
1892
1904
|
export {
|
|
1893
1905
|
H as E,
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1906
|
+
An as R,
|
|
1907
|
+
Un as S,
|
|
1908
|
+
Tn as a,
|
|
1909
|
+
Dn as b,
|
|
1910
|
+
_n as c,
|
|
1911
|
+
Nn as d,
|
|
1912
|
+
$t as e,
|
|
1913
|
+
Fe as f,
|
|
1914
|
+
mn as g,
|
|
1915
|
+
Tt as h,
|
|
1904
1916
|
Ue as i,
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1917
|
+
qt as j,
|
|
1918
|
+
cn as k,
|
|
1919
|
+
Ln as l,
|
|
1920
|
+
Bn as p,
|
|
1921
|
+
xe as s,
|
|
1910
1922
|
te as u,
|
|
1911
|
-
|
|
1923
|
+
Dt as v
|
|
1912
1924
|
};
|
|
1913
|
-
//# sourceMappingURL=embed-
|
|
1925
|
+
//# sourceMappingURL=embed-DvN5BVmQ.js.map
|