@snowcone-app/canvas 0.46.2 → 0.46.5
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/dist/{CanvasRenderer-B8BADU_r.js → CanvasRenderer-CmIQSVCK.js} +4 -4
- package/dist/{CanvasRenderer-B8BADU_r.js.map → CanvasRenderer-CmIQSVCK.js.map} +1 -1
- package/dist/{ContextualToolbars-5tHC6s0Y.js → ContextualToolbars-Dmo86Wd2.js} +323 -322
- package/dist/{ContextualToolbars-5tHC6s0Y.js.map → ContextualToolbars-Dmo86Wd2.js.map} +1 -1
- package/dist/{EditorCanvasImpl-Cd_umlTI.js → EditorCanvasImpl-BHa8q4iO.js} +16 -15
- package/dist/{EditorCanvasImpl-Cd_umlTI.js.map → EditorCanvasImpl-BHa8q4iO.js.map} +1 -1
- package/dist/{ExportManager-xRsXgyNo.js → ExportManager-DEJgxB0S.js} +79 -78
- package/dist/{ExportManager-xRsXgyNo.js.map → ExportManager-DEJgxB0S.js.map} +1 -1
- package/dist/{FontAnalyzer-Ds3Wdba7.js → FontAnalyzer-CLMJi2Sw.js} +374 -409
- package/dist/FontAnalyzer-CLMJi2Sw.js.map +1 -0
- package/dist/{ImagePanel-bW3yr6Ac.js → ImagePanel-4fHABjNT.js} +6 -6
- package/dist/{ImagePanel-bW3yr6Ac.js.map → ImagePanel-4fHABjNT.js.map} +1 -1
- package/dist/{SnowconeCanvas-crxPwbib.js → SnowconeCanvas-GPag5BXG.js} +10 -10
- package/dist/{SnowconeCanvas-crxPwbib.js.map → SnowconeCanvas-GPag5BXG.js.map} +1 -1
- package/dist/advanced.mjs +54 -54
- package/dist/core/image-adjustments.d.ts +2 -4
- package/dist/core/masked-crop.d.ts +3 -55
- package/dist/{custom-icons-DQRp8GhF.js → custom-icons-Dt0Y4VSn.js} +2 -2
- package/dist/{custom-icons-DQRp8GhF.js.map → custom-icons-Dt0Y4VSn.js.map} +1 -1
- package/dist/design-builder-HKRo18WT.js +1798 -0
- package/dist/design-builder-HKRo18WT.js.map +1 -0
- package/dist/{embed-DvN5BVmQ.js → embed-DhjsJ3ni.js} +698 -688
- package/dist/embed-DhjsJ3ni.js.map +1 -0
- package/dist/embed.mjs +35 -36
- package/dist/embed.mjs.map +1 -1
- package/dist/{export-worker.bundle.string-BL30CYzH.js → export-worker.bundle.string-CyMb_XjB.js} +27 -25
- package/dist/{export-worker.bundle.string-BL30CYzH.js.map → export-worker.bundle.string-CyMb_XjB.js.map} +1 -1
- package/dist/{guards-DwYEoqcn.js → guards-Dk86a-kH.js} +2 -2
- package/dist/{guards-DwYEoqcn.js.map → guards-Dk86a-kH.js.map} +1 -1
- package/dist/index.mjs +43 -43
- package/dist/internals.mjs +150 -149
- package/dist/internals.mjs.map +1 -1
- package/dist/rendering/serialize-for-server.d.ts +4 -91
- package/dist/state/CanvasStateV1.d.ts +1 -363
- package/dist/{CanvasStateV1-BlDWgOzV.js → template-fields-CKEuUmTM.js} +1997 -1835
- package/dist/template-fields-CKEuUmTM.js.map +1 -0
- package/dist/testing.mjs +61 -60
- package/dist/testing.mjs.map +1 -1
- package/dist/{useCommands-F-b_SwW-.js → useCommands-BI7O5Lf0.js} +225 -225
- package/dist/{useCommands-F-b_SwW-.js.map → useCommands-BI7O5Lf0.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BWdobHQE.js → usePieceGuideBundle-DJfjOVEd.js} +2 -2
- package/dist/{usePieceGuideBundle-BWdobHQE.js.map → usePieceGuideBundle-DJfjOVEd.js.map} +1 -1
- package/dist/utils/custom-fonts.d.ts +2 -16
- package/dist/{validation-hn5ZX8Po.js → validation-au_-Sj-A.js} +11 -11
- package/dist/{validation-hn5ZX8Po.js.map → validation-au_-Sj-A.js.map} +1 -1
- package/dist/workers/export-worker.bundle.string.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +5 -4
- package/dist/CanvasStateV1-BlDWgOzV.js.map +0 -1
- package/dist/FontAnalyzer-Ds3Wdba7.js.map +0 -1
- package/dist/design-builder-sH53Og6j.js +0 -1870
- package/dist/design-builder-sH53Og6j.js.map +0 -1
- package/dist/embed-DvN5BVmQ.js.map +0 -1
- package/dist/template-fields-BaQG0CJY.js +0 -559
- package/dist/template-fields-BaQG0CJY.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
4
|
-
import we, { useContext as ut, createContext as mt, useRef 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-BI7O5Lf0.js";
|
|
2
|
+
import { q as I, Y as De, p as K } from "./FontAnalyzer-CLMJi2Sw.js";
|
|
3
|
+
import { jsx as f, jsxs as U, Fragment as ct } from "react/jsx-runtime";
|
|
4
|
+
import we, { useContext as ut, createContext as mt, useRef as C, useState as D, useMemo as L, useCallback as G, 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
5
|
import { assertVariantSelected as ht, RenderSession as gt, createCartDetail as yt } from "@snowcone-app/sdk";
|
|
6
|
-
import {
|
|
7
|
-
import { u as kt, p as xt } from "./usePieceGuideBundle-
|
|
8
|
-
import { D as St, C as Rt,
|
|
9
|
-
import "
|
|
10
|
-
import "./
|
|
6
|
+
import { B as bt, E as vt, o as wt, q as Et } from "./design-builder-HKRo18WT.js";
|
|
7
|
+
import { u as kt, p as xt } from "./usePieceGuideBundle-DJfjOVEd.js";
|
|
8
|
+
import { D as St, C as Rt, g as It, e as Ot } from "./template-fields-CKEuUmTM.js";
|
|
9
|
+
import { serializeStateForServer as ee } from "@snowcone-app/design/wire";
|
|
10
|
+
import "./ExportManager-DEJgxB0S.js";
|
|
11
11
|
const Be = mt(void 0);
|
|
12
12
|
function te() {
|
|
13
13
|
const e = ut(Be);
|
|
@@ -33,149 +33,149 @@ 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
35
|
function Nt(e, t) {
|
|
36
|
-
var i,
|
|
37
|
-
const n = (
|
|
36
|
+
var i, s;
|
|
37
|
+
const n = (s = (i = e.options) == null ? void 0 : i.combinations) == null ? void 0 : s.find((o) => o.variantId === t);
|
|
38
38
|
if (!n) return t;
|
|
39
|
-
const r = Object.entries(n).filter(([
|
|
39
|
+
const r = Object.entries(n).filter(([o, c]) => o !== "variantId" && o !== "price" && (typeof c == "string" || typeof c == "number")).map(([o, c]) => `${o} ${String(c)}`);
|
|
40
40
|
return r.length > 0 ? r.join(" · ") : t;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
var
|
|
42
|
+
function _n(e, t = {}) {
|
|
43
|
+
var x, w, T, _, V;
|
|
44
44
|
if (!Ue(e))
|
|
45
|
-
throw new
|
|
45
|
+
throw new I(
|
|
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((h) => h.role);
|
|
51
|
+
for (const [h, S] of [
|
|
52
52
|
["picks", t.picks],
|
|
53
53
|
["variants", t.variants]
|
|
54
54
|
])
|
|
55
55
|
for (const B of Object.keys(S ?? {}))
|
|
56
56
|
if (!r.includes(B))
|
|
57
|
-
throw new
|
|
57
|
+
throw new I(
|
|
58
58
|
"E_BUNDLE_ROLE_NOT_FOUND",
|
|
59
|
-
`bundle ${e.id} has no role "${B}" (in ${
|
|
60
|
-
{ productId: e.id, field:
|
|
59
|
+
`bundle ${e.id} has no role "${B}" (in ${h}). Roles: [${r.join(", ")}].`,
|
|
60
|
+
{ productId: e.id, field: h, role: B, validNames: r, docSlug: W }
|
|
61
61
|
);
|
|
62
|
-
const i = {},
|
|
63
|
-
for (const
|
|
64
|
-
const S =
|
|
65
|
-
if (!
|
|
66
|
-
throw new
|
|
62
|
+
const i = {}, s = {}, o = {}, c = e.placements ?? [], a = [];
|
|
63
|
+
for (const h of n) {
|
|
64
|
+
const S = h.products.map((v) => v.productId), B = (x = t.picks) == null ? void 0 : x[h.role], A = B === void 0 ? h.products[0] : h.products.find((v) => v.productId === B);
|
|
65
|
+
if (!A)
|
|
66
|
+
throw new I(
|
|
67
67
|
"E_BUNDLE_PICK_NOT_FOUND",
|
|
68
|
-
`bundle ${e.id} role "${
|
|
69
|
-
{ productId: e.id, role:
|
|
68
|
+
`bundle ${e.id} role "${h.role}" has no alternative "${B}". Alternatives: [${S.join(", ")}] — pass picks: { ${h.role}: "${S[0]}" }.`,
|
|
69
|
+
{ productId: e.id, role: h.role, requested: B, validNames: S, docSlug: W }
|
|
70
70
|
);
|
|
71
|
-
i[
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
const
|
|
75
|
-
throw new
|
|
71
|
+
i[h.role] = A.productId;
|
|
72
|
+
const j = (A.variants ?? []).map((v) => v.gvid).filter((v) => typeof v == "string" && v !== ""), P = j.length > 0 ? j : A.defaultGvid ? [A.defaultGvid] : [], M = ((w = t.variants) == null ? void 0 : w[h.role]) ?? A.defaultGvid ?? j[0];
|
|
73
|
+
if (!M || !P.includes(M)) {
|
|
74
|
+
const v = (T = t.variants) == null ? void 0 : T[h.role];
|
|
75
|
+
throw new I(
|
|
76
76
|
"E_BUNDLE_VARIANT_NOT_FOUND",
|
|
77
|
-
|
|
77
|
+
P.length === 0 ? `bundle ${e.id} role "${h.role}": alternative ${A.productId} publishes no variant — nothing can render this slot (catalog data is incomplete).` : `bundle ${e.id} role "${h.role}" (${A.productId}) has no variant "${v}". Variants: [${P.join(", ")}] — pass variants: { ${h.role}: "${P[0]}" }.`,
|
|
78
78
|
{
|
|
79
79
|
productId: e.id,
|
|
80
|
-
role:
|
|
81
|
-
memberProductId:
|
|
82
|
-
requested:
|
|
83
|
-
validNames:
|
|
80
|
+
role: h.role,
|
|
81
|
+
memberProductId: A.productId,
|
|
82
|
+
requested: v,
|
|
83
|
+
validNames: P,
|
|
84
84
|
docSlug: W
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
const X =
|
|
90
|
-
(
|
|
91
|
-
).map((
|
|
92
|
-
key:
|
|
93
|
-
role:
|
|
94
|
-
label:
|
|
95
|
-
memberProductId:
|
|
96
|
-
width:
|
|
97
|
-
height:
|
|
98
|
-
aspectRatio:
|
|
88
|
+
s[h.role] = M, o[h.role] = ((V = (_ = A.variants) == null ? void 0 : _.find((v) => v.gvid === M)) == null ? void 0 : V.gvidForMockup) || M;
|
|
89
|
+
const X = c.filter(
|
|
90
|
+
(v) => v.role === h.role && v.memberProductId === A.productId && typeof v.key == "string" && v.key !== "" && Ct(v)
|
|
91
|
+
).map((v) => ({
|
|
92
|
+
key: v.key,
|
|
93
|
+
role: h.role,
|
|
94
|
+
label: v.label,
|
|
95
|
+
memberProductId: A.productId,
|
|
96
|
+
width: v.width,
|
|
97
|
+
height: v.height,
|
|
98
|
+
aspectRatio: v.width / v.height
|
|
99
99
|
}));
|
|
100
|
-
|
|
101
|
-
role:
|
|
102
|
-
required:
|
|
100
|
+
a.push({
|
|
101
|
+
role: h.role,
|
|
102
|
+
required: h.required !== !1,
|
|
103
103
|
alternatives: S,
|
|
104
|
-
pick:
|
|
105
|
-
variantId:
|
|
106
|
-
variantChoices:
|
|
104
|
+
pick: A.productId,
|
|
105
|
+
variantId: M,
|
|
106
|
+
variantChoices: P.map((v) => ({ gvid: v, label: Nt(A, v) })),
|
|
107
107
|
placements: X
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
for (const
|
|
112
|
-
if (typeof
|
|
113
|
-
const S =
|
|
114
|
-
S && !
|
|
110
|
+
const d = new Set(a.flatMap((h) => h.placements.map((S) => S.key))), l = new Map(a.flatMap((h) => h.placements.map((S) => [S.key, S]))), u = [];
|
|
111
|
+
for (const h of c) {
|
|
112
|
+
if (typeof h.key != "string" || !d.has(h.key)) continue;
|
|
113
|
+
const S = l.get(h.key);
|
|
114
|
+
S && !u.includes(S) && u.push(S);
|
|
115
115
|
}
|
|
116
|
-
const
|
|
117
|
-
let
|
|
116
|
+
const b = u.map((h) => h.key);
|
|
117
|
+
let R;
|
|
118
118
|
if (t.placement !== void 0) {
|
|
119
119
|
if (!xe(t.placement))
|
|
120
|
-
throw new
|
|
120
|
+
throw new I(
|
|
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: [${b.join(", ")}].`,
|
|
123
|
+
{ productId: e.id, requested: t.placement, validNames: b, docSlug: W }
|
|
124
124
|
);
|
|
125
|
-
if (
|
|
126
|
-
throw new
|
|
125
|
+
if (R = u.find((h) => h.key === t.placement), !R)
|
|
126
|
+
throw new I(
|
|
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: [${b.join(", ")}].`,
|
|
129
|
+
{ productId: e.id, requested: t.placement, picks: i, validNames: b, docSlug: W }
|
|
130
130
|
);
|
|
131
131
|
} else
|
|
132
|
-
|
|
133
|
-
if (!
|
|
134
|
-
throw new
|
|
132
|
+
R = u[0];
|
|
133
|
+
if (!R)
|
|
134
|
+
throw new I(
|
|
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 m = e.mockups ?? [], E = m.filter(
|
|
140
|
+
(h) => !h.picks || Object.entries(h.picks).every(([S, B]) => i[S] === B)
|
|
141
|
+
), y = (E.length > 0 ? E : m).map((h) => h.id);
|
|
142
|
+
if (y.length === 0)
|
|
143
|
+
throw new I(
|
|
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 g = (e.requiredPlacements ?? []).filter((
|
|
148
|
+
const g = (e.requiredPlacements ?? []).filter((h) => typeof h.key == "string" && h.key !== "" && d.has(h.key)).map((h) => ({ label: h.key, key: h.key, type: h.type, autoFilledByVariant: h.autoFilledByVariant }));
|
|
149
149
|
return {
|
|
150
150
|
kind: "bundle",
|
|
151
151
|
product: {
|
|
152
152
|
productId: e.id,
|
|
153
|
-
mockupIds:
|
|
153
|
+
mockupIds: y,
|
|
154
154
|
picks: i,
|
|
155
|
-
variants:
|
|
156
|
-
placements:
|
|
157
|
-
mockups:
|
|
155
|
+
variants: s,
|
|
156
|
+
placements: b,
|
|
157
|
+
mockups: m,
|
|
158
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: $t(
|
|
164
|
-
roles:
|
|
165
|
-
placement:
|
|
166
|
-
placements:
|
|
167
|
-
placementKeys:
|
|
162
|
+
variants: s,
|
|
163
|
+
variantToken: $t(o),
|
|
164
|
+
roles: a,
|
|
165
|
+
placement: R,
|
|
166
|
+
placements: u,
|
|
167
|
+
placementKeys: b,
|
|
168
168
|
roleNames: r,
|
|
169
|
-
primaryMockupId:
|
|
169
|
+
primaryMockupId: y[0]
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
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((s) => !s.autoFilledByVariant).map((s) => s.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((s) => s.variantId).filter((s) => typeof s == "string" && s !== "")
|
|
179
179
|
);
|
|
180
180
|
return !!(e != null && e.variantId) || t.size > 1 ? [] : (e == null ? void 0 : e.placements) ?? [];
|
|
181
181
|
}
|
|
@@ -193,7 +193,7 @@ function At(e) {
|
|
|
193
193
|
return [...t];
|
|
194
194
|
}
|
|
195
195
|
function Fe({ shop: e, product: t, design: n, hasGrant: r }) {
|
|
196
|
-
var
|
|
196
|
+
var m, E;
|
|
197
197
|
const i = [];
|
|
198
198
|
if (e || i.push({
|
|
199
199
|
severity: "error",
|
|
@@ -203,60 +203,60 @@ function Fe({ 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
|
+
}), (m = t == null ? void 0 : t.mockupIds) != null && m.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
212
|
ht(t);
|
|
213
|
-
} catch (
|
|
213
|
+
} catch (y) {
|
|
214
214
|
i.push({
|
|
215
215
|
severity: "error",
|
|
216
216
|
issue: "variant-required",
|
|
217
|
-
message:
|
|
217
|
+
message: y instanceof Error ? y.message : String(y)
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
|
-
const
|
|
221
|
-
let
|
|
222
|
-
if (
|
|
223
|
-
const
|
|
224
|
-
|
|
220
|
+
const s = n.toJSON(), o = s.artboards.map((y) => y.name), c = Tt(t);
|
|
221
|
+
let a = [];
|
|
222
|
+
if (c) {
|
|
223
|
+
const y = t.placements ?? [];
|
|
224
|
+
a = o.filter((x) => !xe(x)), a.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) [${
|
|
227
|
+
message: `product ${t.productId} is a bundle, but the design's artboard(s) [${a.join(", ")}] name no role. On a bundle every placement is addressed by its role-scoped key (<role>.<key>)${y.length ? ` — keys: [${y.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 N = At(t).filter((x) => {
|
|
234
|
+
var w;
|
|
235
|
+
return !((w = t.variants) != null && w[x]);
|
|
236
236
|
});
|
|
237
|
-
|
|
237
|
+
N.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) [${N.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 d = pe(t), l = d.filter((y) => !o.includes(y));
|
|
244
|
+
d.length > 1 && o.length > 1 && l.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 [${d.join(", ")}]; the design authors [${o.join(", ")}], so [${l.join(", ")}] inherit the base artboard "${o[0]}" (re-fit per placement, ADR-0101). Intended? Otherwise split them: design(…).artboard('` + l[0] + "', { width, height })… or usePlacements().split('" + l[0] + "') at runtime."
|
|
248
248
|
});
|
|
249
|
-
const
|
|
250
|
-
|
|
249
|
+
const u = (E = t == null ? void 0 : t.placements) != null && E.length ? o.filter((y) => !t.placements.includes(y) && !a.includes(y)) : [];
|
|
250
|
+
u.length > 0 && i.push({
|
|
251
251
|
severity: "error",
|
|
252
252
|
issue: "placement-mismatch",
|
|
253
|
-
message: `the design's artboard(s) [${
|
|
253
|
+
message: `the design's artboard(s) [${u.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
|
|
256
|
-
return
|
|
255
|
+
const b = s.elements.map((y) => y.name).filter((y) => !!y), R = b.filter((y, g) => b.indexOf(y) !== g);
|
|
256
|
+
return R.length && i.push({
|
|
257
257
|
severity: "warn",
|
|
258
258
|
issue: "duplicate-layer-names",
|
|
259
|
-
message: `duplicate layer name(s) [${[...new Set(
|
|
259
|
+
message: `duplicate layer name(s) [${[...new Set(R)].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
262
|
function Dt(e) {
|
|
@@ -278,63 +278,63 @@ function Pe(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((
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
(
|
|
281
|
+
const i = n.map((a) => typeof a.name == "string" ? a.name : ""), s = new Map(n.map((a, d) => [i[d], a])), o = Pe(i, t);
|
|
282
|
+
if (o.every((a) => !a.inherited)) return e;
|
|
283
|
+
const c = o.map(
|
|
284
|
+
(a) => a.inherited ? { ...r, name: a.label } : s.get(a.label)
|
|
285
285
|
);
|
|
286
|
-
return { ...e, artboards:
|
|
286
|
+
return { ...e, artboards: c };
|
|
287
287
|
}
|
|
288
288
|
function je({ registry: e, store: t, product: n }) {
|
|
289
|
-
const r = [], i = e.getParts(),
|
|
290
|
-
|
|
289
|
+
const r = [], i = e.getParts(), s = e.getTextFields(), o = e.requiresCanvasPartNames();
|
|
290
|
+
o.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: `${o.join(", ")} ${o.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 ${o.join(", ")}. Canvas-free parts: Editor.Preview, Editor.Buy, Editor.TextField, Editor.Layers.`
|
|
295
295
|
});
|
|
296
|
-
const
|
|
297
|
-
e.hasDockedControls() &&
|
|
296
|
+
const c = i.filter((m) => m.name === "Editor.Canvas").some((m) => m.meta.floatingToolbar !== !1);
|
|
297
|
+
e.hasDockedControls() && c && r.push({
|
|
298
298
|
code: "A_CONTROLS_INERT",
|
|
299
299
|
severity: "warn",
|
|
300
300
|
message: "a docked <Editor.Controls> is mounted while <Editor.Canvas> still has floatingToolbar={true} (the default) — both contextual zones are armed, and the floating toolbar is suppressed only as a side effect of the docked Controls being mounted this frame (it silently reappears when the Controls unmounts).",
|
|
301
301
|
fix: 'Declare contextual-zone ownership in the type surface: pass floatingToolbar={false} on <Editor.Canvas> when a <Editor.Controls placement="docked"> owns the zone.'
|
|
302
302
|
});
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
303
|
+
const a = (n == null ? void 0 : n.mockupIds) ?? [];
|
|
304
|
+
if (a.length > 1) {
|
|
305
|
+
const m = i.filter((E) => E.name === "Editor.Preview" && E.meta.mockupId === void 0);
|
|
306
|
+
m.length > 0 && r.push({
|
|
307
307
|
code: "A_PREVIEW_AMBIGUOUS",
|
|
308
308
|
severity: "warn",
|
|
309
|
-
message: `${
|
|
310
|
-
fix: `Pin each <Editor.Preview> to a scene: mockupId="${
|
|
309
|
+
message: `${m.length} <Editor.Preview> part${m.length === 1 ? " has" : "s have"} no mockupId while the product renders ${a.length} mockup scenes [${a.join(", ")}] — each shows whichever scene renders first, an ambiguous fan-out.`,
|
|
310
|
+
fix: `Pin each <Editor.Preview> to a scene: mockupId="${a[0]}" (one of product.mockupIds).`
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
313
|
+
const d = i.some((m) => m.name === "Editor.Buy");
|
|
314
|
+
if (s.length > 0 && !d) {
|
|
315
|
+
const m = s.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 [${m.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
|
-
const
|
|
324
|
-
for (const
|
|
325
|
-
t.layerKindOf(
|
|
323
|
+
const l = [];
|
|
324
|
+
for (const m of s)
|
|
325
|
+
t.layerKindOf(m.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
|
-
}) :
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
const
|
|
328
|
+
message: `<Editor.TextField layer={design.layer("${m.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 "${m.name}" to the design, or bind the field to an existing layer: layer={design.layer(<one of ${JSON.stringify(t.bindableLayerNames())}>)}.`
|
|
330
|
+
}) : l.push(m);
|
|
331
|
+
const u = l.filter((m) => !m.optional);
|
|
332
|
+
if (u.length > 0 && u.every((m) => t.textOf(m.name) === t.seedTextOf(m.name))) {
|
|
333
|
+
const m = u.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 [${m.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,10 +344,10 @@ function je({ 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
|
|
350
|
-
return { findings: r, parts:
|
|
347
|
+
const b = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const m of i) b.set(m.name, (b.get(m.name) ?? 0) + 1);
|
|
349
|
+
const R = [...b.entries()].map(([m, E]) => ({ name: m, count: E })).sort((m, E) => m.name.localeCompare(E.name));
|
|
350
|
+
return { findings: r, parts: R };
|
|
351
351
|
}
|
|
352
352
|
const ie = [];
|
|
353
353
|
function Lt(e) {
|
|
@@ -356,10 +356,10 @@ function Lt(e) {
|
|
|
356
356
|
t !== -1 && ie.splice(t, 1);
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Tn() {
|
|
360
360
|
const e = ie[ie.length - 1];
|
|
361
361
|
if (!e)
|
|
362
|
-
throw new
|
|
362
|
+
throw new I(
|
|
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" }
|
|
@@ -398,8 +398,8 @@ function qe({ error: e, onRetry: t }) {
|
|
|
398
398
|
"Editor failed: ",
|
|
399
399
|
n
|
|
400
400
|
] }),
|
|
401
|
-
/* @__PURE__ */
|
|
402
|
-
t ? /* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ f("p", { style: { margin: "4px 0 0" }, children: e.message }),
|
|
402
|
+
t ? /* @__PURE__ */ f(
|
|
403
403
|
"button",
|
|
404
404
|
{
|
|
405
405
|
type: "button",
|
|
@@ -432,18 +432,18 @@ class Ft extends pt {
|
|
|
432
432
|
}
|
|
433
433
|
componentDidCatch(t) {
|
|
434
434
|
var n;
|
|
435
|
-
wt(t), typeof
|
|
435
|
+
wt(t), typeof K < "u" && ((n = K.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__ */ f(qe, { error: this.state.caught }) : this.props.children;
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
function Pt({ reportedError: e, onRetry: t, children: n }) {
|
|
442
442
|
if (e) {
|
|
443
443
|
const r = De(e) && e.code === "E_CHUNK_LOAD_FAILED";
|
|
444
|
-
return /* @__PURE__ */
|
|
444
|
+
return /* @__PURE__ */ f(qe, { error: e, onRetry: r ? t : void 0 });
|
|
445
445
|
}
|
|
446
|
-
return /* @__PURE__ */
|
|
446
|
+
return /* @__PURE__ */ f(Ft, { reportedError: null, onRetry: t, children: n });
|
|
447
447
|
}
|
|
448
448
|
function Vt(e) {
|
|
449
449
|
const {
|
|
@@ -451,191 +451,191 @@ function Vt(e) {
|
|
|
451
451
|
product: n,
|
|
452
452
|
design: r,
|
|
453
453
|
throttleMs: i = 200,
|
|
454
|
-
onMockups:
|
|
455
|
-
onRenderError:
|
|
456
|
-
onIssue:
|
|
457
|
-
wsUrl:
|
|
458
|
-
services:
|
|
459
|
-
children:
|
|
460
|
-
internals:
|
|
461
|
-
recordAudit:
|
|
462
|
-
__validation:
|
|
463
|
-
} = e,
|
|
464
|
-
() =>
|
|
465
|
-
[
|
|
466
|
-
),
|
|
467
|
-
() => (
|
|
468
|
-
const k = [.../* @__PURE__ */ new Set([...
|
|
469
|
-
if (!k.includes(
|
|
470
|
-
throw new
|
|
454
|
+
onMockups: s,
|
|
455
|
+
onRenderError: o,
|
|
456
|
+
onIssue: c,
|
|
457
|
+
wsUrl: a,
|
|
458
|
+
services: d,
|
|
459
|
+
children: l,
|
|
460
|
+
internals: u,
|
|
461
|
+
recordAudit: b,
|
|
462
|
+
__validation: R = "throw"
|
|
463
|
+
} = e, m = L(() => r.toJSON().activeArtboard, [r]), y = J(u.store.subscribe, u.store.getState, u.store.getState).artboards.map((p) => p.name).join("\0"), g = L(
|
|
464
|
+
() => y ? y.split("\0") : [],
|
|
465
|
+
[y]
|
|
466
|
+
), N = JSON.stringify(pe(n)), x = L(() => JSON.parse(N), [N]), [w, T] = D(null), _ = w && w.design === r ? w.label : m, V = L(
|
|
467
|
+
() => (p) => {
|
|
468
|
+
const k = [.../* @__PURE__ */ new Set([...x, ...g])];
|
|
469
|
+
if (!k.includes(p))
|
|
470
|
+
throw new I(
|
|
471
471
|
"E_UNKNOWN_PLACEMENT",
|
|
472
|
-
`no placement "${
|
|
473
|
-
{ placement:
|
|
472
|
+
`no placement "${p}" — the product's placements are ${JSON.stringify(x)} and the design's artboards are ${JSON.stringify(g)} (ADR-0088 / ADR-0101).`,
|
|
473
|
+
{ placement: p, validNames: k, docSlug: "embed-mode" }
|
|
474
474
|
);
|
|
475
|
-
const
|
|
476
|
-
|
|
475
|
+
const O = g[0] ?? p;
|
|
476
|
+
T({ design: r, label: g.includes(p) ? p : O });
|
|
477
477
|
},
|
|
478
|
-
[r, g,
|
|
479
|
-
),
|
|
480
|
-
() => (
|
|
478
|
+
[r, g, x]
|
|
479
|
+
), h = C(null), S = L(
|
|
480
|
+
() => (p) => {
|
|
481
481
|
var k;
|
|
482
|
-
if (!
|
|
483
|
-
throw new
|
|
482
|
+
if (!x.includes(p) && !g.includes(p))
|
|
483
|
+
throw new I(
|
|
484
484
|
"E_UNKNOWN_PLACEMENT",
|
|
485
|
-
`cannot split "${
|
|
486
|
-
{ placement:
|
|
485
|
+
`cannot split "${p}" — the product's placements are ${JSON.stringify(x)} (ADR-0101).`,
|
|
486
|
+
{ placement: p, validNames: x, docSlug: "embed-mode" }
|
|
487
487
|
);
|
|
488
|
-
if (!g.includes(
|
|
489
|
-
const
|
|
490
|
-
|
|
488
|
+
if (!g.includes(p)) {
|
|
489
|
+
const O = u.registry.getCanvasBridge();
|
|
490
|
+
O ? O.splitArtboard(p) : (u.store.splitArtboard(p), (k = h.current) == null || k.call(h, ee(u.store.getState())));
|
|
491
491
|
}
|
|
492
|
-
|
|
492
|
+
T({ design: r, label: p });
|
|
493
493
|
},
|
|
494
|
-
[r, g,
|
|
494
|
+
[r, g, x, u]
|
|
495
495
|
), B = L(
|
|
496
|
-
() => (
|
|
497
|
-
var
|
|
496
|
+
() => (p) => {
|
|
497
|
+
var q;
|
|
498
498
|
const k = g[0];
|
|
499
|
-
if (
|
|
500
|
-
throw new
|
|
499
|
+
if (p === k)
|
|
500
|
+
throw new I(
|
|
501
501
|
"E_LINK_BASE",
|
|
502
|
-
`"${
|
|
503
|
-
{ artboardName:
|
|
502
|
+
`"${p}" 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: p, validNames: g.slice(1), docSlug: "embed-mode" }
|
|
504
504
|
);
|
|
505
|
-
if (!g.includes(
|
|
506
|
-
const
|
|
507
|
-
|
|
505
|
+
if (!g.includes(p)) return;
|
|
506
|
+
const O = u.registry.getCanvasBridge();
|
|
507
|
+
O ? O.removeArtboard(p) : (u.store.removeArtboard(p), (q = h.current) == null || q.call(h, ee(u.store.getState()))), _ === p && k && T({ design: r, label: k });
|
|
508
508
|
},
|
|
509
|
-
[r, g,
|
|
510
|
-
),
|
|
511
|
-
const
|
|
512
|
-
if (
|
|
509
|
+
[r, g, u, _]
|
|
510
|
+
), A = L(() => {
|
|
511
|
+
const p = r.toJSON().artboards[0];
|
|
512
|
+
if (p)
|
|
513
513
|
return {
|
|
514
|
-
name:
|
|
515
|
-
width:
|
|
516
|
-
height:
|
|
517
|
-
...
|
|
514
|
+
name: p.name,
|
|
515
|
+
width: p.width,
|
|
516
|
+
height: p.height,
|
|
517
|
+
...p.backgroundColor ? { backgroundColor: p.backgroundColor } : {}
|
|
518
518
|
};
|
|
519
519
|
}, [r]);
|
|
520
520
|
J(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
521
|
+
u.commerce.subscribe,
|
|
522
|
+
u.commerce.getVersion,
|
|
523
|
+
u.commerce.getVersion
|
|
524
524
|
);
|
|
525
|
-
const
|
|
526
|
-
if (!
|
|
527
|
-
const
|
|
528
|
-
return xt(
|
|
529
|
-
}, [
|
|
530
|
-
X.current =
|
|
531
|
-
const [Se, Je] =
|
|
532
|
-
var
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
535
|
-
const k =
|
|
525
|
+
const j = u.commerce.renderVariantId(), P = kt(j ?? n.variantId ?? n.defaultGvid), M = L(() => {
|
|
526
|
+
if (!P) return null;
|
|
527
|
+
const p = r.toJSON().artboards, k = p.find((O) => O.name === _) ?? p[0];
|
|
528
|
+
return xt(P, k) ?? null;
|
|
529
|
+
}, [P, r, _]), X = C(s), v = C(o), Q = C(c);
|
|
530
|
+
X.current = s, v.current = o, Q.current = c;
|
|
531
|
+
const [Se, Je] = D([]), [de, ne] = D(!0), [Re, le] = D(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}|${m}|${fe}`, ge = L(() => {
|
|
532
|
+
var O;
|
|
533
|
+
const p = Fe({ shop: t, product: n, design: r, hasGrant: fe });
|
|
534
|
+
if (R !== "throw") return p;
|
|
535
|
+
const k = p.find((q) => q.severity === "error");
|
|
536
536
|
if (k)
|
|
537
|
-
throw new
|
|
537
|
+
throw new I("E_EMBED_CONFIG", k.message, {
|
|
538
538
|
issue: k.issue,
|
|
539
539
|
docSlug: "embed-mode"
|
|
540
540
|
});
|
|
541
|
-
for (const
|
|
542
|
-
typeof
|
|
543
|
-
return
|
|
544
|
-
}, [Y,
|
|
541
|
+
for (const q of p)
|
|
542
|
+
typeof K < "u" && ((O = K.env) == null ? void 0 : O.NODE_ENV) !== "production" && console.warn(`[Editor.Root] ${q.message}`);
|
|
543
|
+
return p;
|
|
544
|
+
}, [Y, R]), Oe = C(null);
|
|
545
545
|
F(() => {
|
|
546
|
-
var
|
|
546
|
+
var p;
|
|
547
547
|
if (ge.length !== 0 && Oe.current !== Y) {
|
|
548
548
|
Oe.current = Y;
|
|
549
|
-
for (const k of ge) (
|
|
549
|
+
for (const k of ge) (p = Q.current) == null || p.call(Q, k);
|
|
550
550
|
}
|
|
551
551
|
}, [ge, Y]);
|
|
552
|
-
const $e =
|
|
552
|
+
const $e = C(null);
|
|
553
553
|
F(() => {
|
|
554
|
-
var
|
|
555
|
-
if (
|
|
554
|
+
var p;
|
|
555
|
+
if (R === "warn" && typeof K < "u" && ((p = K.env) == null ? void 0 : p.NODE_ENV) !== "production") {
|
|
556
556
|
if ($e.current === Y) return;
|
|
557
557
|
$e.current = Y, Dt({ shop: t, product: n, design: r, hasGrant: fe });
|
|
558
558
|
}
|
|
559
|
-
}, [Y,
|
|
559
|
+
}, [Y, R]);
|
|
560
560
|
const ce = L(
|
|
561
561
|
() => {
|
|
562
562
|
try {
|
|
563
|
-
return { session: new gt({ shop: t, product: n, wsUrl:
|
|
564
|
-
} catch (
|
|
565
|
-
return { error:
|
|
563
|
+
return { session: new gt({ shop: t, product: n, wsUrl: a, ...he }) };
|
|
564
|
+
} catch (p) {
|
|
565
|
+
return { error: p instanceof Error ? p.message : String(p) };
|
|
566
566
|
}
|
|
567
567
|
},
|
|
568
568
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
569
|
-
[t, Ie,
|
|
570
|
-
),
|
|
571
|
-
if (
|
|
569
|
+
[t, Ie, m, a, Qe]
|
|
570
|
+
), $ = "session" in ce ? ce.session : null, ue = "error" in ce ? ce.error : null, Z = L(() => (p, k = i) => {
|
|
571
|
+
if (!$) return;
|
|
572
572
|
le(null), ne(!0);
|
|
573
|
-
const
|
|
573
|
+
const O = (z) => {
|
|
574
574
|
var Te;
|
|
575
|
-
const me =
|
|
576
|
-
le(me), ne(!1), (Te =
|
|
577
|
-
},
|
|
575
|
+
const me = z instanceof Error ? z.message : String(z);
|
|
576
|
+
le(me), ne(!1), (Te = v.current) == null || Te.call(v, me);
|
|
577
|
+
}, q = (z, me) => void $.renderState(z, { schemaVersion: p.schemaVersion, artboards: [me] }, k).catch(O), _e = Ve(p, pe(n)).artboards ?? [];
|
|
578
578
|
if (_e.length > 1) {
|
|
579
|
-
for (const
|
|
580
|
-
|
|
579
|
+
for (const z of _e)
|
|
580
|
+
q(typeof z.name == "string" && z.name ? z.name : m, z);
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
|
-
|
|
584
|
-
}, [
|
|
585
|
-
|
|
586
|
-
var
|
|
583
|
+
$.renderState(m, p, k).catch(O);
|
|
584
|
+
}, [$, m, n, i]);
|
|
585
|
+
h.current = Z, F(() => {
|
|
586
|
+
var p;
|
|
587
587
|
if (ue) {
|
|
588
|
-
le(ue), ne(!1), (
|
|
588
|
+
le(ue), ne(!1), (p = v.current) == null || p.call(v, ue);
|
|
589
589
|
return;
|
|
590
590
|
}
|
|
591
|
-
if (
|
|
592
|
-
return
|
|
593
|
-
var
|
|
594
|
-
Je(k), ne(!1), (
|
|
595
|
-
}),
|
|
596
|
-
var
|
|
597
|
-
le(k), ne(!1), (
|
|
598
|
-
}), Z(r.toServerRequest()), () =>
|
|
599
|
-
}, [
|
|
600
|
-
const ye =
|
|
591
|
+
if ($)
|
|
592
|
+
return $.onMockups((k) => {
|
|
593
|
+
var O;
|
|
594
|
+
Je(k), ne(!1), (O = X.current) == null || O.call(X, k);
|
|
595
|
+
}), $.onError((k) => {
|
|
596
|
+
var O;
|
|
597
|
+
le(k), ne(!1), (O = v.current) == null || O.call(v, k);
|
|
598
|
+
}), Z(r.toServerRequest()), () => $.close();
|
|
599
|
+
}, [$, ue]);
|
|
600
|
+
const ye = C({
|
|
601
601
|
session: null,
|
|
602
602
|
variantId: void 0
|
|
603
603
|
});
|
|
604
604
|
F(() => {
|
|
605
|
-
if (
|
|
606
|
-
const
|
|
607
|
-
if (
|
|
608
|
-
ye.current = { session:
|
|
605
|
+
if (!$ || !j) return;
|
|
606
|
+
const p = ye.current, k = p.session === $ ? p.variantId : n.variantId;
|
|
607
|
+
if (j === k) {
|
|
608
|
+
ye.current = { session: $, variantId: k };
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
611
|
-
ye.current = { session:
|
|
612
|
-
}, [
|
|
613
|
-
const Ce =
|
|
611
|
+
ye.current = { session: $, variantId: j }, $.setProduct({ ...n, variantId: j }), Z(ee(u.store.getState()));
|
|
612
|
+
}, [$, j]);
|
|
613
|
+
const Ce = C({ session: null, key: "" });
|
|
614
614
|
F(() => {
|
|
615
|
-
if (
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
618
|
-
const k =
|
|
619
|
-
Ce.current = { session:
|
|
620
|
-
}, [
|
|
615
|
+
if (!$ || !re) return;
|
|
616
|
+
const p = Ce.current;
|
|
617
|
+
if (p.session === $ && p.key === re) return;
|
|
618
|
+
const k = p.session !== $;
|
|
619
|
+
Ce.current = { session: $, key: re }, !k && ($.setProduct(n), Z(ee(u.store.getState())));
|
|
620
|
+
}, [$, re]), F(() => {
|
|
621
621
|
if (!de) return;
|
|
622
|
-
const
|
|
623
|
-
var
|
|
624
|
-
const k = Bt(
|
|
625
|
-
typeof
|
|
622
|
+
const p = setTimeout(() => {
|
|
623
|
+
var O, q;
|
|
624
|
+
const k = Bt(m);
|
|
625
|
+
typeof K < "u" && ((O = K.env) == null ? void 0 : O.NODE_ENV) !== "production" && console.warn(k), (q = Q.current) == null || q.call(Q, { severity: "warn", issue: "slow-render", message: k });
|
|
626
626
|
}, Me);
|
|
627
|
-
return () => clearTimeout(
|
|
628
|
-
}, [de,
|
|
627
|
+
return () => clearTimeout(p);
|
|
628
|
+
}, [de, m]);
|
|
629
629
|
const Ye = L(
|
|
630
630
|
() => ({
|
|
631
|
-
session:
|
|
631
|
+
session: $,
|
|
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:
|
|
635
|
+
placement: _,
|
|
636
636
|
placements: g,
|
|
637
|
-
selectPlacement:
|
|
638
|
-
requiredPlacements:
|
|
637
|
+
selectPlacement: V,
|
|
638
|
+
requiredPlacements: x,
|
|
639
639
|
splitPlacement: S,
|
|
640
640
|
linkPlacement: B,
|
|
641
641
|
product: n,
|
|
@@ -643,157 +643,157 @@ function Vt(e) {
|
|
|
643
643
|
isRendering: de,
|
|
644
644
|
error: Re,
|
|
645
645
|
throttleMs: i,
|
|
646
|
-
pieceGuides:
|
|
646
|
+
pieceGuides: M,
|
|
647
647
|
pushRender: Z,
|
|
648
|
-
stateStore:
|
|
648
|
+
stateStore: u.store
|
|
649
649
|
}),
|
|
650
|
-
[
|
|
650
|
+
[$, r, _, g, V, x, S, B, n, Se, de, Re, i, M, Z, u.store]
|
|
651
651
|
), Xe = J(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
652
|
+
u.registry.subscribe,
|
|
653
|
+
u.registry.getVersion,
|
|
654
|
+
u.registry.getVersion
|
|
655
655
|
);
|
|
656
656
|
L(() => {
|
|
657
|
-
|
|
658
|
-
je({ registry:
|
|
659
|
-
),
|
|
660
|
-
}, [
|
|
661
|
-
const Ne = /* @__PURE__ */
|
|
657
|
+
b(
|
|
658
|
+
je({ registry: u.registry, store: u.store, product: n })
|
|
659
|
+
), u.registry.validate();
|
|
660
|
+
}, [u.registry, Xe]);
|
|
661
|
+
const Ne = /* @__PURE__ */ f(tt.Provider, { value: u, children: /* @__PURE__ */ f(Be.Provider, { value: Ye, children: /* @__PURE__ */ f(bt.Provider, { value: u.registry, children: /* @__PURE__ */ f(
|
|
662
662
|
vt,
|
|
663
663
|
{
|
|
664
|
-
...
|
|
665
|
-
children:
|
|
664
|
+
...A ? { initialArtboardConfig: A } : {},
|
|
665
|
+
children: l
|
|
666
666
|
}
|
|
667
667
|
) }) }) });
|
|
668
|
-
return
|
|
668
|
+
return d ? /* @__PURE__ */ f(nt, { services: d, children: Ne }) : Ne;
|
|
669
669
|
}
|
|
670
670
|
function ze(e) {
|
|
671
|
-
const { design: t, product: n, onAudit: r } = e, i = `${n.productId}|${n.variantId ?? ""}`,
|
|
672
|
-
(
|
|
671
|
+
const { design: t, product: n, onAudit: r } = e, i = `${n.productId}|${n.variantId ?? ""}`, s = C(null), o = C(null), [c, a] = D(null);
|
|
672
|
+
(s.current === null || s.current.design !== t) && (s.current = {
|
|
673
673
|
design: t,
|
|
674
674
|
internals: {
|
|
675
675
|
store: new St(t.toJSON()),
|
|
676
676
|
registry: new Ze()
|
|
677
677
|
}
|
|
678
|
-
}), (
|
|
679
|
-
const
|
|
678
|
+
}), (o.current === null || o.current.productIdentity !== i) && (o.current = { productIdentity: i, commerce: new Rt(n) });
|
|
679
|
+
const d = L(
|
|
680
680
|
() => ({
|
|
681
|
-
...
|
|
682
|
-
commerce:
|
|
683
|
-
...et(
|
|
681
|
+
...s.current.internals,
|
|
682
|
+
commerce: o.current.commerce,
|
|
683
|
+
...et(a)
|
|
684
684
|
}),
|
|
685
685
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
686
|
-
[
|
|
687
|
-
),
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
}, []),
|
|
686
|
+
[s.current.internals, o.current.commerce]
|
|
687
|
+
), l = C(n);
|
|
688
|
+
l.current = n;
|
|
689
|
+
const u = C(r);
|
|
690
|
+
u.current = r;
|
|
691
|
+
const b = C(null), R = G((y) => {
|
|
692
|
+
b.current = y;
|
|
693
|
+
}, []), m = G(
|
|
694
694
|
() => je({
|
|
695
|
-
registry:
|
|
696
|
-
store:
|
|
697
|
-
product:
|
|
695
|
+
registry: s.current.internals.registry,
|
|
696
|
+
store: s.current.internals.store,
|
|
697
|
+
product: l.current
|
|
698
698
|
}),
|
|
699
699
|
[]
|
|
700
700
|
);
|
|
701
|
-
ae(() => Lt({ compute:
|
|
702
|
-
const E =
|
|
701
|
+
ae(() => Lt({ compute: m }), [m]);
|
|
702
|
+
const E = C(!1);
|
|
703
703
|
return F(() => {
|
|
704
|
-
let
|
|
704
|
+
let y = !1;
|
|
705
705
|
return queueMicrotask(() => {
|
|
706
706
|
var g;
|
|
707
|
-
|
|
707
|
+
y || E.current || (E.current = !0, (g = u.current) == null || g.call(u, b.current ?? m()));
|
|
708
708
|
}), () => {
|
|
709
|
-
|
|
709
|
+
y = !0;
|
|
710
710
|
};
|
|
711
|
-
}, [
|
|
711
|
+
}, [m]), // `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__ */ f("div", { className: "sc-root", style: { display: "contents" }, "data-sc-part": "root", children: /* @__PURE__ */ f(Pt, { reportedError: c, onRetry: () => a(null), children: /* @__PURE__ */ f(Vt, { ...e, internals: d, recordAudit: R }) }) });
|
|
715
715
|
}
|
|
716
|
-
let jt = () => import("./EditorCanvasImpl-
|
|
716
|
+
let jt = () => import("./EditorCanvasImpl-BHa8q4iO.js").then((e) => e.EditorCanvasImpl);
|
|
717
717
|
function Ke() {
|
|
718
718
|
return jt();
|
|
719
719
|
}
|
|
720
|
-
const Mt = Le(function({ children: t, maxHeight: n, floatingToolbar: r = !0, className: i, style:
|
|
721
|
-
const
|
|
720
|
+
const Mt = Le(function({ children: t, maxHeight: n, floatingToolbar: r = !0, className: i, style: s }, o) {
|
|
721
|
+
const c = se("Editor.Canvas");
|
|
722
722
|
oe("Editor.Canvas", { floatingToolbar: r });
|
|
723
|
-
const
|
|
724
|
-
ae(() =>
|
|
725
|
-
const [
|
|
723
|
+
const a = Ee();
|
|
724
|
+
ae(() => c.registry.registerCanvas(a), [c.registry, a]);
|
|
725
|
+
const [d, l] = D(null);
|
|
726
726
|
return F(() => {
|
|
727
|
-
let
|
|
727
|
+
let u = !1;
|
|
728
728
|
return Ke().then(
|
|
729
|
-
(
|
|
730
|
-
|
|
729
|
+
(b) => {
|
|
730
|
+
u || l(() => b);
|
|
731
731
|
},
|
|
732
|
-
(
|
|
733
|
-
|
|
734
|
-
new
|
|
732
|
+
(b) => {
|
|
733
|
+
u || c.reportRuntimeError(
|
|
734
|
+
new I(
|
|
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 (${b instanceof Error ? b.message : String(b)}). This is a network/CDN failure, not a composition mistake — retry, or check the deployment serves the @snowcone-app/canvas lazy chunks.`,
|
|
737
|
+
{ cause: b instanceof Error ? b.message : String(b), docSlug: "embed-mode" }
|
|
738
738
|
)
|
|
739
739
|
);
|
|
740
740
|
}
|
|
741
741
|
), () => {
|
|
742
|
-
|
|
742
|
+
u = !0;
|
|
743
743
|
};
|
|
744
|
-
}, [
|
|
744
|
+
}, [c]), d ? (
|
|
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__ */ f(
|
|
750
|
+
d,
|
|
751
751
|
{
|
|
752
|
-
ref:
|
|
752
|
+
ref: o,
|
|
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: s,
|
|
759
759
|
children: t
|
|
760
760
|
}
|
|
761
761
|
)
|
|
762
|
-
) : /* @__PURE__ */
|
|
762
|
+
) : /* @__PURE__ */ f(
|
|
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, ...s },
|
|
769
769
|
"aria-busy": "true"
|
|
770
770
|
}
|
|
771
771
|
);
|
|
772
772
|
});
|
|
773
773
|
function qt() {
|
|
774
|
-
const { placements: e, requiredPlacements: t, placement: n, selectPlacement: r, splitPlacement: i, linkPlacement:
|
|
774
|
+
const { placements: e, requiredPlacements: t, placement: n, selectPlacement: r, splitPlacement: i, linkPlacement: s } = te();
|
|
775
775
|
return L(() => {
|
|
776
|
-
const
|
|
777
|
-
label:
|
|
778
|
-
inherited:
|
|
779
|
-
active:
|
|
780
|
-
})),
|
|
776
|
+
const o = Pe(e, t), c = e[0] ?? n, a = o.map((l) => ({
|
|
777
|
+
label: l.label,
|
|
778
|
+
inherited: l.inherited,
|
|
779
|
+
active: l.inherited ? n === c : n === l.label
|
|
780
|
+
})), d = a.length > 1 && a.every((l) => l.inherited || l.label === c);
|
|
781
781
|
return {
|
|
782
|
-
placements:
|
|
782
|
+
placements: a,
|
|
783
783
|
activePlacement: n,
|
|
784
|
-
basePlacement:
|
|
785
|
-
linked:
|
|
784
|
+
basePlacement: c,
|
|
785
|
+
linked: d,
|
|
786
786
|
select: r,
|
|
787
787
|
split: i,
|
|
788
|
-
link:
|
|
788
|
+
link: s,
|
|
789
789
|
splitAll: () => {
|
|
790
|
-
for (const
|
|
790
|
+
for (const l of a) l.inherited && i(l.label);
|
|
791
791
|
},
|
|
792
792
|
linkAll: () => {
|
|
793
|
-
for (const
|
|
793
|
+
for (const l of a) !l.inherited && l.label !== c && s(l.label);
|
|
794
794
|
}
|
|
795
795
|
};
|
|
796
|
-
}, [e, t, n, r, i,
|
|
796
|
+
}, [e, t, n, r, i, s]);
|
|
797
797
|
}
|
|
798
798
|
const zt = (e) => e.length === 2 ? "Both sides" : `All ${e.length} areas`, Kt = {
|
|
799
799
|
font: "inherit",
|
|
@@ -807,9 +807,9 @@ const zt = (e) => e.length === 2 ? "Both sides" : `All ${e.length} areas`, Kt =
|
|
|
807
807
|
textUnderlineOffset: "4px"
|
|
808
808
|
};
|
|
809
809
|
function Gt({ className: e, style: t, labels: n }) {
|
|
810
|
-
const { placements: r, linked: i, select:
|
|
810
|
+
const { placements: r, linked: i, select: s, splitAll: o, linkAll: c } = qt();
|
|
811
811
|
if (r.length < 2) return null;
|
|
812
|
-
const
|
|
812
|
+
const a = r.map((d) => d.label);
|
|
813
813
|
return /* @__PURE__ */ U(
|
|
814
814
|
"div",
|
|
815
815
|
{
|
|
@@ -818,50 +818,50 @@ function Gt({ 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__ */ f(
|
|
822
822
|
"span",
|
|
823
823
|
{
|
|
824
824
|
"data-sc-part": "placements-item",
|
|
825
825
|
"data-sc-active": "true",
|
|
826
826
|
"data-sc-linked": "true",
|
|
827
|
-
title:
|
|
827
|
+
title: a.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) ?? zt)(
|
|
829
|
+
children: ((n == null ? void 0 : n.linked) ?? zt)(a)
|
|
830
830
|
}
|
|
831
|
-
) : r.map(({ label:
|
|
831
|
+
) : r.map(({ label: d, active: l, inherited: u }) => /* @__PURE__ */ f(
|
|
832
832
|
"button",
|
|
833
833
|
{
|
|
834
834
|
type: "button",
|
|
835
835
|
"data-sc-part": "placements-item",
|
|
836
|
-
"data-sc-active":
|
|
837
|
-
"data-sc-linked":
|
|
838
|
-
"aria-pressed":
|
|
839
|
-
onClick: () =>
|
|
836
|
+
"data-sc-active": l ? "true" : "false",
|
|
837
|
+
"data-sc-linked": u ? "true" : "false",
|
|
838
|
+
"aria-pressed": l,
|
|
839
|
+
onClick: () => s(d),
|
|
840
840
|
style: {
|
|
841
841
|
font: "inherit",
|
|
842
842
|
fontSize: "13px",
|
|
843
|
-
fontWeight:
|
|
843
|
+
fontWeight: l ? 700 : 400,
|
|
844
844
|
color: "var(--sc-color-foreground, inherit)",
|
|
845
|
-
opacity:
|
|
845
|
+
opacity: u ? 0.6 : 1,
|
|
846
846
|
background: "transparent",
|
|
847
847
|
border: "none",
|
|
848
848
|
borderRadius: "9999px",
|
|
849
849
|
padding: "2px 8px",
|
|
850
|
-
cursor:
|
|
851
|
-
textDecoration:
|
|
850
|
+
cursor: l ? "default" : "pointer",
|
|
851
|
+
textDecoration: l ? "underline" : "none",
|
|
852
852
|
textUnderlineOffset: "4px"
|
|
853
853
|
},
|
|
854
|
-
children:
|
|
854
|
+
children: d
|
|
855
855
|
},
|
|
856
|
-
|
|
856
|
+
d
|
|
857
857
|
)),
|
|
858
|
-
/* @__PURE__ */
|
|
858
|
+
/* @__PURE__ */ f(
|
|
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 ?
|
|
864
|
+
onClick: i ? o : c,
|
|
865
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
|
}
|
|
@@ -900,81 +900,88 @@ const Ge = ft(function({
|
|
|
900
900
|
variant: r = "dark"
|
|
901
901
|
}) {
|
|
902
902
|
Qt();
|
|
903
|
-
const [i,
|
|
903
|
+
const [i, s] = D([]);
|
|
904
904
|
F(() => {
|
|
905
|
-
|
|
905
|
+
s(Jt());
|
|
906
906
|
}, []);
|
|
907
|
-
const [
|
|
907
|
+
const [o, c] = D(!1);
|
|
908
908
|
F(() => {
|
|
909
|
-
const
|
|
910
|
-
return () => cancelAnimationFrame(
|
|
909
|
+
const l = requestAnimationFrame(() => c(!0));
|
|
910
|
+
return () => cancelAnimationFrame(l);
|
|
911
911
|
}, []);
|
|
912
|
-
const
|
|
913
|
-
(
|
|
914
|
-
|
|
912
|
+
const a = G(
|
|
913
|
+
(l) => {
|
|
914
|
+
l.propertyName === "background-color" && (t || n == null || n());
|
|
915
915
|
},
|
|
916
916
|
[t, n]
|
|
917
917
|
);
|
|
918
|
-
let
|
|
919
|
-
return t ?
|
|
918
|
+
let d = "";
|
|
919
|
+
return t ? o && (d = "sc-prism-fade-in") : d = "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" : "",
|
|
924
|
-
onTransitionEnd:
|
|
923
|
+
className: ["sc-prism-overlay", r === "light" ? "sc-prism-on-light" : "", d].filter(Boolean).join(" "),
|
|
924
|
+
onTransitionEnd: a,
|
|
925
925
|
"aria-hidden": "true",
|
|
926
926
|
children: [
|
|
927
|
-
Array.from({ length: 6 }, (
|
|
928
|
-
i.map((
|
|
927
|
+
Array.from({ length: 6 }, (l, u) => /* @__PURE__ */ f("div", { className: "sc-prism-band" }, `b-${u}`)),
|
|
928
|
+
i.map((l, u) => /* @__PURE__ */ f(
|
|
929
929
|
"div",
|
|
930
930
|
{
|
|
931
931
|
className: "sc-prism-particle",
|
|
932
932
|
style: {
|
|
933
|
-
left: `${
|
|
934
|
-
top: `${
|
|
935
|
-
animationDelay: `${
|
|
936
|
-
animationDuration: `${
|
|
937
|
-
width: `${
|
|
938
|
-
height: `${
|
|
933
|
+
left: `${l.left}%`,
|
|
934
|
+
top: `${l.top}%`,
|
|
935
|
+
animationDelay: `${l.delay}s`,
|
|
936
|
+
animationDuration: `${l.duration}s`,
|
|
937
|
+
width: `${l.size}px`,
|
|
938
|
+
height: `${l.size}px`
|
|
939
939
|
}
|
|
940
940
|
},
|
|
941
|
-
`p-${
|
|
941
|
+
`p-${u}`
|
|
942
942
|
))
|
|
943
943
|
]
|
|
944
944
|
}
|
|
945
945
|
);
|
|
946
946
|
});
|
|
947
947
|
function We(e) {
|
|
948
|
-
const [t, n] =
|
|
949
|
-
|
|
950
|
-
|
|
948
|
+
const [t, n] = D(!1), [r, i] = D(!1), s = C(null), o = C(null), c = C(!1);
|
|
949
|
+
c.current = t, F(() => (e ? (i(!1), o.current && clearTimeout(o.current), s.current = setTimeout(() => n(!0), Wt)) : (s.current && (clearTimeout(s.current), s.current = null), c.current && (i(!0), o.current = setTimeout(() => i(!1), Ht))), () => {
|
|
950
|
+
s.current && clearTimeout(s.current), o.current && clearTimeout(o.current);
|
|
951
951
|
}), [e]);
|
|
952
|
-
const
|
|
952
|
+
const a = G(() => n(!1), []);
|
|
953
953
|
return {
|
|
954
954
|
showOverlay: t,
|
|
955
955
|
overlayVisible: e || r,
|
|
956
|
-
handleExited:
|
|
956
|
+
handleExited: a
|
|
957
957
|
};
|
|
958
958
|
}
|
|
959
|
-
const Yt = we.lazy(() => import("@snowcone-app/loaders/beam").then((e) => ({ default: e.BeamLoader })))
|
|
960
|
-
function
|
|
959
|
+
const Yt = we.lazy(() => import("@snowcone-app/loaders/beam").then((e) => ({ default: e.BeamLoader })));
|
|
960
|
+
function Xt(e, t) {
|
|
961
|
+
var r;
|
|
962
|
+
if (!t) return null;
|
|
963
|
+
const n = (r = e == null ? void 0 : e.mockups) == null ? void 0 : r.find((i) => (i == null ? void 0 : i.id) === t);
|
|
964
|
+
return typeof (n == null ? void 0 : n.printMask) == "string" && n.printMask ? n.printMask : null;
|
|
965
|
+
}
|
|
966
|
+
const Zt = 1.2, be = [1200, 1400, 1600, 1800, 2e3, 2500, 3e3, 4e3];
|
|
967
|
+
function en(e) {
|
|
961
968
|
for (const t of be)
|
|
962
969
|
if (t >= e) return t;
|
|
963
970
|
return be[be.length - 1];
|
|
964
971
|
}
|
|
965
|
-
function
|
|
966
|
-
if (!(e > 0) || !(t > 0) || t <= e *
|
|
967
|
-
const n =
|
|
972
|
+
function tn(e, t) {
|
|
973
|
+
if (!(e > 0) || !(t > 0) || t <= e * Zt) return null;
|
|
974
|
+
const n = en(t);
|
|
968
975
|
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
976
|
}
|
|
970
|
-
function
|
|
977
|
+
function nn(e) {
|
|
971
978
|
return typeof e == "function" ? !0 : typeof e == "object" && e !== null && "$$typeof" in e && !ke(e);
|
|
972
979
|
}
|
|
973
|
-
function
|
|
980
|
+
function rn(e) {
|
|
974
981
|
if (e === void 0 || e === !0) return "auto";
|
|
975
982
|
if (e === "dark" || e === "light" || e === "host-owned" || ke(e)) return e;
|
|
976
|
-
if (
|
|
977
|
-
throw new
|
|
983
|
+
if (nn(e)) return { loader: e };
|
|
984
|
+
throw new I(
|
|
978
985
|
"E_PREVIEW_NO_LOADER",
|
|
979
986
|
`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>.`,
|
|
980
987
|
{ docSlug: "preview-loading-overlay" }
|
|
@@ -986,42 +993,42 @@ function He({
|
|
|
986
993
|
alt: n = "Live product mockup",
|
|
987
994
|
loadingOverlay: r,
|
|
988
995
|
className: i,
|
|
989
|
-
style:
|
|
996
|
+
style: s
|
|
990
997
|
}) {
|
|
991
|
-
const { mockups:
|
|
998
|
+
const { mockups: o, error: c, isRendering: a, product: d } = te();
|
|
992
999
|
oe("Editor.Preview", { ...e !== void 0 ? { mockupId: e } : {} });
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
),
|
|
996
|
-
!
|
|
997
|
-
const
|
|
998
|
-
var
|
|
999
|
-
if (!
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1000
|
+
const l = rn(r), u = ke(l) ? l : null, b = l !== "host-owned", R = l === "auto" ? Yt : typeof l == "object" && l !== null && "loader" in l ? l.loader : null, m = C(null), E = G(() => m.current, []), { showOverlay: y, overlayVisible: g, handleExited: N } = We(
|
|
1001
|
+
b && a
|
|
1002
|
+
), x = C(/* @__PURE__ */ new Set()), w = e ? o.find((S) => S.mockupId === e && S.imageUrl) : o.find((S) => S.imageUrl), T = l === "light" ? "light" : R && (w != null && w.imageUrl) ? "edit" : "dark", [_, V] = D(T);
|
|
1003
|
+
!y && _ !== T && V(T);
|
|
1004
|
+
const h = (S) => {
|
|
1005
|
+
var M;
|
|
1006
|
+
if (!w || typeof K > "u" || ((M = K.env) == null ? void 0 : M.NODE_ENV) === "production" || typeof window > "u" || x.current.has(w.mockupId)) return;
|
|
1007
|
+
const B = S.currentTarget, A = B.getBoundingClientRect().width;
|
|
1008
|
+
if (A <= 0) return;
|
|
1009
|
+
const j = Math.round(A * (window.devicePixelRatio || 1)), P = tn(B.naturalWidth, j);
|
|
1010
|
+
P && (x.current.add(w.mockupId), console.warn(P));
|
|
1004
1011
|
};
|
|
1005
|
-
if (
|
|
1006
|
-
const
|
|
1012
|
+
if (b) {
|
|
1013
|
+
const S = w != null && w.imageUrl ? a ? "rendering" : "ready" : c ? "error" : "rendering";
|
|
1007
1014
|
return /* @__PURE__ */ U(
|
|
1008
1015
|
"div",
|
|
1009
1016
|
{
|
|
1010
1017
|
"data-sc-part": "preview",
|
|
1011
|
-
"data-sc-preview-state":
|
|
1012
|
-
"aria-busy":
|
|
1018
|
+
"data-sc-preview-state": S,
|
|
1019
|
+
"aria-busy": S === "rendering" || void 0,
|
|
1013
1020
|
className: `sc-preview-frame${i ? ` ${i}` : ""}`,
|
|
1014
|
-
style:
|
|
1021
|
+
style: s,
|
|
1015
1022
|
children: [
|
|
1016
|
-
|
|
1023
|
+
w != null && w.imageUrl ? (
|
|
1017
1024
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1018
|
-
/* @__PURE__ */
|
|
1019
|
-
) :
|
|
1025
|
+
/* @__PURE__ */ f("img", { ref: m, "data-sc-part": "preview-image", src: w.imageUrl, alt: n, onLoad: h })
|
|
1026
|
+
) : c ? /* @__PURE__ */ f("div", { "data-sc-part": "preview-error", role: "alert", "data-sc-error": c, children: t ?? `Render failed: ${c}` }) : t,
|
|
1020
1027
|
u ? (
|
|
1021
1028
|
// Custom indicator: same show-delay + linger window; no exit fade
|
|
1022
1029
|
// (the host owns its animation), so it unmounts when the window
|
|
1023
1030
|
// closes.
|
|
1024
|
-
|
|
1031
|
+
y && g ? /* @__PURE__ */ f(
|
|
1025
1032
|
"div",
|
|
1026
1033
|
{
|
|
1027
1034
|
"data-sc-part": "preview-loading",
|
|
@@ -1030,88 +1037,91 @@ function He({
|
|
|
1030
1037
|
children: u
|
|
1031
1038
|
}
|
|
1032
1039
|
) : null
|
|
1033
|
-
) :
|
|
1034
|
-
visible:
|
|
1035
|
-
onExited:
|
|
1036
|
-
picture:
|
|
1037
|
-
maskKey:
|
|
1040
|
+
) : y && _ === "edit" && R ? /* @__PURE__ */ f("div", { "data-sc-part": "preview-loading", className: "sc-preview-edit-loading", "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: /* @__PURE__ */ f(we.Suspense, { fallback: null, children: we.createElement(R, {
|
|
1041
|
+
visible: g,
|
|
1042
|
+
onExited: N,
|
|
1043
|
+
picture: E,
|
|
1044
|
+
maskKey: w == null ? void 0 : w.mockupId,
|
|
1045
|
+
// the scene's print mask from the catalog (RenderProduct.mockups[].printMask): the first edit covers
|
|
1046
|
+
// only the print instead of learning it from frames
|
|
1047
|
+
maskUrl: Xt(d, w == null ? void 0 : w.mockupId),
|
|
1038
1048
|
fit: "cover"
|
|
1039
|
-
}) }) }) :
|
|
1049
|
+
}) }) }) : y && _ !== "edit" ? /* @__PURE__ */ f(
|
|
1040
1050
|
Ge,
|
|
1041
1051
|
{
|
|
1042
|
-
visible:
|
|
1043
|
-
variant:
|
|
1044
|
-
onExited:
|
|
1052
|
+
visible: g,
|
|
1053
|
+
variant: _,
|
|
1054
|
+
onExited: N
|
|
1045
1055
|
}
|
|
1046
1056
|
) : null
|
|
1047
1057
|
]
|
|
1048
1058
|
}
|
|
1049
1059
|
);
|
|
1050
1060
|
}
|
|
1051
|
-
return
|
|
1061
|
+
return w != null && w.imageUrl ? (
|
|
1052
1062
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1053
|
-
/* @__PURE__ */
|
|
1063
|
+
/* @__PURE__ */ f(
|
|
1054
1064
|
"img",
|
|
1055
1065
|
{
|
|
1056
1066
|
"data-sc-part": "preview",
|
|
1057
|
-
"data-sc-preview-state":
|
|
1058
|
-
src:
|
|
1067
|
+
"data-sc-preview-state": a ? "rendering" : "ready",
|
|
1068
|
+
src: w.imageUrl,
|
|
1059
1069
|
alt: n,
|
|
1060
1070
|
className: i,
|
|
1061
|
-
style:
|
|
1062
|
-
onLoad:
|
|
1071
|
+
style: s,
|
|
1072
|
+
onLoad: h
|
|
1063
1073
|
}
|
|
1064
1074
|
)
|
|
1065
|
-
) :
|
|
1075
|
+
) : c ? /* @__PURE__ */ f(
|
|
1066
1076
|
"div",
|
|
1067
1077
|
{
|
|
1068
1078
|
"data-sc-part": "preview-error",
|
|
1069
1079
|
"data-sc-preview-state": "error",
|
|
1070
1080
|
role: "alert",
|
|
1071
|
-
"data-sc-error":
|
|
1081
|
+
"data-sc-error": c,
|
|
1072
1082
|
className: i,
|
|
1073
|
-
style:
|
|
1074
|
-
children: t ?? `Render failed: ${
|
|
1083
|
+
style: s,
|
|
1084
|
+
children: t ?? `Render failed: ${c}`
|
|
1075
1085
|
}
|
|
1076
|
-
) : /* @__PURE__ */
|
|
1086
|
+
) : /* @__PURE__ */ f("div", { "data-sc-part": "preview", "data-sc-preview-state": "rendering", "aria-busy": "true", style: { display: "contents" }, children: t });
|
|
1077
1087
|
}
|
|
1078
|
-
function
|
|
1079
|
-
const { layer: t, optional: n = !1, placeholder: r, className: i, style:
|
|
1088
|
+
function sn(e) {
|
|
1089
|
+
const { layer: t, optional: n = !1, placeholder: r, className: i, style: s } = e, o = se("Editor.TextField");
|
|
1080
1090
|
oe("Editor.TextField");
|
|
1081
|
-
const { pushRender:
|
|
1091
|
+
const { pushRender: c, throttleMs: a, stateStore: d } = te(), l = Ee(), u = C(null);
|
|
1082
1092
|
if (!Et(t))
|
|
1083
|
-
throw new
|
|
1093
|
+
throw new I(
|
|
1084
1094
|
"E_LAYER_TOKEN_REQUIRED",
|
|
1085
1095
|
`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.`,
|
|
1086
1096
|
{ received: typeof t == "string" ? t : typeof t, docSlug: "embed-mode" }
|
|
1087
1097
|
);
|
|
1088
|
-
if (
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1091
|
-
throw new
|
|
1098
|
+
if (u.current !== t.name) {
|
|
1099
|
+
const m = d.layerKindOf(t.name);
|
|
1100
|
+
if (m === void 0)
|
|
1101
|
+
throw new I(
|
|
1092
1102
|
"E_LAYER_NOT_FOUND",
|
|
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(
|
|
1094
|
-
{ layerName: t.name, validNames:
|
|
1103
|
+
`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(d.bindableLayerNames())}.`,
|
|
1104
|
+
{ layerName: t.name, validNames: d.bindableLayerNames(), docSlug: "embed-mode" }
|
|
1095
1105
|
);
|
|
1096
|
-
if (
|
|
1097
|
-
throw new
|
|
1106
|
+
if (m !== "text")
|
|
1107
|
+
throw new I(
|
|
1098
1108
|
"E_LAYER_WRONG_KIND",
|
|
1099
|
-
`layer "${t.name}" is ${
|
|
1100
|
-
{ layerName: t.name, actualKind:
|
|
1109
|
+
`layer "${t.name}" is ${m === null ? "not a bindable kind" : `an ${m} layer`} — <Editor.TextField> binds text layers only.`,
|
|
1110
|
+
{ layerName: t.name, actualKind: m, docSlug: "embed-mode" }
|
|
1101
1111
|
);
|
|
1102
|
-
|
|
1112
|
+
u.current = t.name;
|
|
1103
1113
|
}
|
|
1104
|
-
ae(() =>
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
() =>
|
|
1108
|
-
() =>
|
|
1109
|
-
),
|
|
1110
|
-
(
|
|
1111
|
-
const E =
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1114
|
-
new
|
|
1114
|
+
ae(() => o.registry.registerTextField(l, { name: t.name, optional: n }), [o.registry, l, t.name, n]);
|
|
1115
|
+
const b = J(
|
|
1116
|
+
d.subscribe,
|
|
1117
|
+
() => d.textOf(t.name) ?? "",
|
|
1118
|
+
() => d.textOf(t.name) ?? ""
|
|
1119
|
+
), R = G(
|
|
1120
|
+
(m) => {
|
|
1121
|
+
const E = m.target.value, y = o.registry.getCanvasBridge();
|
|
1122
|
+
if (y) {
|
|
1123
|
+
y.setTextByName(t.name, E) || o.reportInvariant(
|
|
1124
|
+
new I(
|
|
1115
1125
|
"E_LAYER_NOT_FOUND",
|
|
1116
1126
|
`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).`,
|
|
1117
1127
|
{ layerName: t.name, docSlug: "embed-mode" }
|
|
@@ -1119,26 +1129,26 @@ function rn(e) {
|
|
|
1119
1129
|
);
|
|
1120
1130
|
return;
|
|
1121
1131
|
}
|
|
1122
|
-
|
|
1132
|
+
d.updateTextLayer(t.name, E), c(ee(d.getState()), a);
|
|
1123
1133
|
},
|
|
1124
|
-
[
|
|
1134
|
+
[o, t.name, d, c, a]
|
|
1125
1135
|
);
|
|
1126
|
-
return /* @__PURE__ */
|
|
1136
|
+
return /* @__PURE__ */ f(
|
|
1127
1137
|
"input",
|
|
1128
1138
|
{
|
|
1129
1139
|
"data-sc-part": "textfield",
|
|
1130
1140
|
"data-sc-layer": t.name,
|
|
1131
1141
|
type: "text",
|
|
1132
|
-
value:
|
|
1133
|
-
onChange:
|
|
1142
|
+
value: b,
|
|
1143
|
+
onChange: R,
|
|
1134
1144
|
placeholder: r,
|
|
1135
1145
|
"aria-label": e["aria-label"] ?? t.name,
|
|
1136
1146
|
className: i,
|
|
1137
|
-
style:
|
|
1147
|
+
style: s
|
|
1138
1148
|
}
|
|
1139
1149
|
);
|
|
1140
1150
|
}
|
|
1141
|
-
function
|
|
1151
|
+
function on(e) {
|
|
1142
1152
|
const t = [];
|
|
1143
1153
|
for (const n of e.missingOptionKeys)
|
|
1144
1154
|
t.push(`option:${n}`);
|
|
@@ -1155,11 +1165,11 @@ function sn(e) {
|
|
|
1155
1165
|
}
|
|
1156
1166
|
return e.hasRenderableElement || t.push("empty-design"), (!Number.isInteger(e.quantity) || e.quantity < 1) && t.push("quantity"), t;
|
|
1157
1167
|
}
|
|
1158
|
-
function
|
|
1168
|
+
function an(e, t) {
|
|
1159
1169
|
const n = t.getCombinations(), r = t.getAttributes();
|
|
1160
1170
|
if (Object.keys(r).length === 0 || n.length === 0) return null;
|
|
1161
1171
|
const i = Object.fromEntries(
|
|
1162
|
-
Object.entries(r).map(([
|
|
1172
|
+
Object.entries(r).map(([s, o]) => [s, { ...o, choices: It(o) }])
|
|
1163
1173
|
);
|
|
1164
1174
|
return yt({
|
|
1165
1175
|
productId: e.productId,
|
|
@@ -1169,81 +1179,81 @@ function on(e, t) {
|
|
|
1169
1179
|
attributes: i
|
|
1170
1180
|
});
|
|
1171
1181
|
}
|
|
1172
|
-
function
|
|
1173
|
-
const { onAddToCart: t, defaultQuantity: n, children: r, className: i, style:
|
|
1182
|
+
function dn(e) {
|
|
1183
|
+
const { onAddToCart: t, defaultQuantity: n, children: r, className: i, style: s } = e, o = se("Editor.Buy");
|
|
1174
1184
|
oe("Editor.Buy");
|
|
1175
|
-
const { product:
|
|
1176
|
-
if (!(
|
|
1177
|
-
throw new
|
|
1185
|
+
const { product: c, stateStore: a } = te(), d = o.commerce;
|
|
1186
|
+
if (!(c != null && c.productId))
|
|
1187
|
+
throw new I(
|
|
1178
1188
|
"E_BUY_NO_PRODUCT",
|
|
1179
1189
|
"<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.",
|
|
1180
1190
|
{ docSlug: "embed-mode" }
|
|
1181
1191
|
);
|
|
1182
|
-
const
|
|
1192
|
+
const l = C(!1);
|
|
1183
1193
|
ae(() => {
|
|
1184
|
-
|
|
1185
|
-
}, [
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
),
|
|
1191
|
-
() =>
|
|
1192
|
-
quantity:
|
|
1193
|
-
missingOptionKeys:
|
|
1194
|
-
selectionValid:
|
|
1195
|
-
textFields:
|
|
1196
|
-
textOf: (
|
|
1197
|
-
seedTextOf: (
|
|
1198
|
-
hasRenderableElement:
|
|
1194
|
+
l.current || (l.current = !0, typeof n == "number" && d.setQuantity(n));
|
|
1195
|
+
}, [d]);
|
|
1196
|
+
const u = J(a.subscribe, a.getState, a.getState), b = J(d.subscribe, d.getVersion, d.getVersion), R = J(
|
|
1197
|
+
o.registry.subscribe,
|
|
1198
|
+
o.registry.getVersion,
|
|
1199
|
+
o.registry.getVersion
|
|
1200
|
+
), m = d.getQuantity(), E = L(
|
|
1201
|
+
() => on({
|
|
1202
|
+
quantity: m,
|
|
1203
|
+
missingOptionKeys: d.missingOptionKeys(),
|
|
1204
|
+
selectionValid: d.selectionValid(),
|
|
1205
|
+
textFields: o.registry.getTextFields(),
|
|
1206
|
+
textOf: (T) => a.textOf(T),
|
|
1207
|
+
seedTextOf: (T) => a.seedTextOf(T),
|
|
1208
|
+
hasRenderableElement: a.hasRenderableElement()
|
|
1199
1209
|
}),
|
|
1200
1210
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1201
|
-
[
|
|
1202
|
-
),
|
|
1203
|
-
if (
|
|
1204
|
-
|
|
1205
|
-
const
|
|
1206
|
-
productId:
|
|
1207
|
-
...
|
|
1208
|
-
quantity:
|
|
1209
|
-
selection:
|
|
1210
|
-
cartDetail:
|
|
1211
|
-
designState:
|
|
1211
|
+
[d, m, u, b, R]
|
|
1212
|
+
), y = E.length === 0, [g, N] = D(!1), x = C(!1), w = G(() => {
|
|
1213
|
+
if (x.current || !y) return;
|
|
1214
|
+
x.current = !0, N(!0);
|
|
1215
|
+
const T = a.getState(), _ = d.resolvedVariantId(), V = {
|
|
1216
|
+
productId: c.productId,
|
|
1217
|
+
..._ ? { variantId: _ } : {},
|
|
1218
|
+
quantity: d.getQuantity(),
|
|
1219
|
+
selection: d.getSelection(),
|
|
1220
|
+
cartDetail: an(c, d),
|
|
1221
|
+
designState: T,
|
|
1212
1222
|
// ADR-0101: one artboard per REQUIRED placement — linked placements
|
|
1213
1223
|
// carry the base relabelled — so buy and preview are the same bytes
|
|
1214
1224
|
// and the order pipeline never re-derives the link rule.
|
|
1215
1225
|
serverRequest: Ve(
|
|
1216
|
-
ee(
|
|
1217
|
-
pe(
|
|
1226
|
+
ee(T),
|
|
1227
|
+
pe(c)
|
|
1218
1228
|
)
|
|
1219
1229
|
};
|
|
1220
|
-
let
|
|
1230
|
+
let h;
|
|
1221
1231
|
try {
|
|
1222
|
-
|
|
1232
|
+
h = t(V);
|
|
1223
1233
|
} catch (S) {
|
|
1224
|
-
throw
|
|
1234
|
+
throw x.current = !1, N(!1), S;
|
|
1225
1235
|
}
|
|
1226
|
-
Promise.resolve(
|
|
1227
|
-
|
|
1236
|
+
Promise.resolve(h).finally(() => {
|
|
1237
|
+
x.current = !1, N(!1);
|
|
1228
1238
|
});
|
|
1229
|
-
}, [
|
|
1230
|
-
return /* @__PURE__ */
|
|
1239
|
+
}, [y, c, d, a, t]);
|
|
1240
|
+
return /* @__PURE__ */ f(
|
|
1231
1241
|
"button",
|
|
1232
1242
|
{
|
|
1233
1243
|
type: "button",
|
|
1234
1244
|
"data-sc-part": "buy",
|
|
1235
|
-
"data-sc-buy-state": g ? "busy" :
|
|
1245
|
+
"data-sc-buy-state": g ? "busy" : y ? "ready" : "incomplete",
|
|
1236
1246
|
"data-sc-buy-missing": E.join(",") || void 0,
|
|
1237
|
-
disabled: !
|
|
1247
|
+
disabled: !y || g,
|
|
1238
1248
|
"aria-busy": g || void 0,
|
|
1239
|
-
onClick:
|
|
1249
|
+
onClick: w,
|
|
1240
1250
|
className: i,
|
|
1241
|
-
style:
|
|
1251
|
+
style: s,
|
|
1242
1252
|
children: r ?? "Add to cart"
|
|
1243
1253
|
}
|
|
1244
1254
|
);
|
|
1245
1255
|
}
|
|
1246
|
-
function
|
|
1256
|
+
function ln({
|
|
1247
1257
|
placement: e = "docked",
|
|
1248
1258
|
className: t,
|
|
1249
1259
|
style: n
|
|
@@ -1255,57 +1265,57 @@ function dn({
|
|
|
1255
1265
|
() => r.registry.registerControls(i, e),
|
|
1256
1266
|
[r.registry, i, e]
|
|
1257
1267
|
);
|
|
1258
|
-
const
|
|
1268
|
+
const s = e === "docked", [o, c] = D(null);
|
|
1259
1269
|
return F(() => {
|
|
1260
|
-
if (!
|
|
1261
|
-
let
|
|
1262
|
-
return import("./ContextualToolbars-
|
|
1263
|
-
(
|
|
1264
|
-
|
|
1270
|
+
if (!s) return;
|
|
1271
|
+
let a = !1;
|
|
1272
|
+
return import("./ContextualToolbars-Dmo86Wd2.js").then((d) => d.s).then(
|
|
1273
|
+
(d) => {
|
|
1274
|
+
a || c(() => d.ContextualToolbars);
|
|
1265
1275
|
},
|
|
1266
|
-
(
|
|
1267
|
-
|
|
1268
|
-
new
|
|
1276
|
+
(d) => {
|
|
1277
|
+
a || r.reportRuntimeError(
|
|
1278
|
+
new I(
|
|
1269
1279
|
"E_CHUNK_LOAD_FAILED",
|
|
1270
|
-
`the editor's controls chunk failed to load (${
|
|
1271
|
-
{ cause:
|
|
1280
|
+
`the editor's controls chunk failed to load (${d instanceof Error ? d.message : String(d)}). This is a network/CDN failure, not a composition mistake — retry, or check the deployment serves the @snowcone-app/canvas lazy chunks.`,
|
|
1281
|
+
{ cause: d instanceof Error ? d.message : String(d), docSlug: "embed-mode" }
|
|
1272
1282
|
)
|
|
1273
1283
|
);
|
|
1274
1284
|
}
|
|
1275
1285
|
), () => {
|
|
1276
|
-
|
|
1286
|
+
a = !0;
|
|
1277
1287
|
};
|
|
1278
|
-
}, [
|
|
1288
|
+
}, [s, r]), s ? /* @__PURE__ */ f(
|
|
1279
1289
|
"div",
|
|
1280
1290
|
{
|
|
1281
1291
|
"data-sc-part": "controls",
|
|
1282
1292
|
"data-sc-placement": "docked",
|
|
1283
1293
|
className: t,
|
|
1284
1294
|
style: n,
|
|
1285
|
-
"aria-busy":
|
|
1286
|
-
children:
|
|
1295
|
+
"aria-busy": o ? void 0 : "true",
|
|
1296
|
+
children: o ? /* @__PURE__ */ f(o, { mode: "embedded" }) : null
|
|
1287
1297
|
}
|
|
1288
1298
|
) : null;
|
|
1289
1299
|
}
|
|
1290
|
-
function
|
|
1300
|
+
function cn({
|
|
1291
1301
|
variant: e = "dark",
|
|
1292
1302
|
className: t,
|
|
1293
1303
|
style: n
|
|
1294
1304
|
}) {
|
|
1295
|
-
const { isRendering: r } = te(), { showOverlay: i, overlayVisible:
|
|
1296
|
-
return i ? /* @__PURE__ */
|
|
1305
|
+
const { isRendering: r } = te(), { showOverlay: i, overlayVisible: s, handleExited: o } = We(r);
|
|
1306
|
+
return i ? /* @__PURE__ */ f(
|
|
1297
1307
|
"div",
|
|
1298
1308
|
{
|
|
1299
1309
|
"data-sc-part": "loading-overlay",
|
|
1300
1310
|
className: `sc-loading-overlay-host${t ? ` ${t}` : ""}`,
|
|
1301
1311
|
style: n,
|
|
1302
1312
|
"aria-hidden": "true",
|
|
1303
|
-
children: /* @__PURE__ */
|
|
1313
|
+
children: /* @__PURE__ */ f(Ge, { visible: s, variant: e, onExited: o })
|
|
1304
1314
|
}
|
|
1305
1315
|
) : null;
|
|
1306
1316
|
}
|
|
1307
|
-
function
|
|
1308
|
-
const t = se("useProductSelection").commerce, n = J(t.subscribe, t.getVersion, t.getVersion), r =
|
|
1317
|
+
function un() {
|
|
1318
|
+
const t = se("useProductSelection").commerce, n = J(t.subscribe, t.getVersion, t.getVersion), r = G((s, o) => t.select(s, o), [t]), i = G((s) => t.setQuantity(s), [t]);
|
|
1309
1319
|
return L(
|
|
1310
1320
|
() => ({
|
|
1311
1321
|
attributes: t.getAttributes(),
|
|
@@ -1334,13 +1344,13 @@ const H = {
|
|
|
1334
1344
|
* single-placement design; headless floor = usePlacements(). */
|
|
1335
1345
|
Placements: Gt,
|
|
1336
1346
|
/** Form input bound to a design text layer by typed token (T1). */
|
|
1337
|
-
TextField:
|
|
1347
|
+
TextField: sn,
|
|
1338
1348
|
/** Smart commerce part: completeness + payload assembly; submit = host callback. */
|
|
1339
|
-
Buy:
|
|
1349
|
+
Buy: dn,
|
|
1340
1350
|
/** Layer list. The one editor part that works canvas-free (ADR-0085 §4). */
|
|
1341
1351
|
Layers: at,
|
|
1342
1352
|
/** Morphing contextual zone — ONE coarse part; placement docked|floating (§5). */
|
|
1343
|
-
Controls:
|
|
1353
|
+
Controls: ln,
|
|
1344
1354
|
/** Undo/redo controls. Requires Editor.Canvas. */
|
|
1345
1355
|
History: ot,
|
|
1346
1356
|
/** The one ⋯ overflow menu. Requires Editor.Canvas. */
|
|
@@ -1349,50 +1359,50 @@ const H = {
|
|
|
1349
1359
|
Add: it,
|
|
1350
1360
|
/** Standalone render-in-flight rainbow for host-owned preview surfaces.
|
|
1351
1361
|
* Fills its positioned parent; rides the session (canvas-free). */
|
|
1352
|
-
LoadingOverlay:
|
|
1362
|
+
LoadingOverlay: cn
|
|
1353
1363
|
};
|
|
1354
|
-
function
|
|
1355
|
-
return /* @__PURE__ */
|
|
1364
|
+
function An(e) {
|
|
1365
|
+
return /* @__PURE__ */ f(ze, { ...e, __validation: "warn" });
|
|
1356
1366
|
}
|
|
1357
|
-
const
|
|
1367
|
+
const Dn = Le(
|
|
1358
1368
|
function(t, n) {
|
|
1359
|
-
const { children: r, className: i, style:
|
|
1369
|
+
const { children: r, className: i, style: s, maxHeight: o, ...c } = t, [a, d] = D(null);
|
|
1360
1370
|
return F(() => {
|
|
1361
|
-
let
|
|
1371
|
+
let l = !1;
|
|
1362
1372
|
return Ke().then(
|
|
1363
|
-
(
|
|
1364
|
-
|
|
1373
|
+
(u) => {
|
|
1374
|
+
l || d(() => u);
|
|
1365
1375
|
},
|
|
1366
|
-
(
|
|
1367
|
-
console.error("[RealtimeCanvas] failed to load the rendering chunk:",
|
|
1376
|
+
(u) => {
|
|
1377
|
+
console.error("[RealtimeCanvas] failed to load the rendering chunk:", u);
|
|
1368
1378
|
}
|
|
1369
1379
|
), () => {
|
|
1370
|
-
|
|
1380
|
+
l = !0;
|
|
1371
1381
|
};
|
|
1372
|
-
}, []),
|
|
1382
|
+
}, []), a ? /* @__PURE__ */ f(a, { ref: n, selfScope: !0, maxHeight: o, className: i, style: s, ...c, children: r }) : /* @__PURE__ */ f(
|
|
1373
1383
|
"div",
|
|
1374
1384
|
{
|
|
1375
1385
|
className: `sc-root${i ? ` ${i}` : ""}`,
|
|
1376
|
-
style: { minHeight:
|
|
1386
|
+
style: { minHeight: o ?? 200, ...s },
|
|
1377
1387
|
"aria-busy": "true"
|
|
1378
1388
|
}
|
|
1379
1389
|
);
|
|
1380
1390
|
}
|
|
1381
1391
|
);
|
|
1382
|
-
function
|
|
1383
|
-
return /* @__PURE__ */
|
|
1392
|
+
function Ln(e) {
|
|
1393
|
+
return /* @__PURE__ */ f(He, { ...e });
|
|
1384
1394
|
}
|
|
1385
|
-
function
|
|
1395
|
+
function Bn() {
|
|
1386
1396
|
const { mockups: e, isRendering: t, error: n } = te();
|
|
1387
1397
|
return { mockups: e, isRendering: t, error: n };
|
|
1388
1398
|
}
|
|
1389
|
-
function
|
|
1399
|
+
function mn(e) {
|
|
1390
1400
|
return e.type !== "color" && typeof e.width == "number" && e.width > 0 && typeof e.height == "number" && e.height > 0;
|
|
1391
1401
|
}
|
|
1392
|
-
function
|
|
1393
|
-
var
|
|
1402
|
+
function Un(e, t = {}) {
|
|
1403
|
+
var b, R, m, E, y;
|
|
1394
1404
|
if (Ue(e))
|
|
1395
|
-
throw new
|
|
1405
|
+
throw new I(
|
|
1396
1406
|
"E_BUNDLE_CONFIG_REQUIRED",
|
|
1397
1407
|
`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.`,
|
|
1398
1408
|
{
|
|
@@ -1401,30 +1411,30 @@ function Bn(e, t = {}) {
|
|
|
1401
1411
|
docSlug: "bundles"
|
|
1402
1412
|
}
|
|
1403
1413
|
);
|
|
1404
|
-
const n = (e.placements ?? []).filter(
|
|
1414
|
+
const n = (e.placements ?? []).filter(mn), r = n.map((g) => g.label), i = t.placement ? n.find((g) => g.label === t.placement) : n[0];
|
|
1405
1415
|
if (!i)
|
|
1406
|
-
throw t.placement ? new
|
|
1416
|
+
throw t.placement ? new I(
|
|
1407
1417
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1408
1418
|
`product ${e.id} has no renderable placement "${t.placement}". Renderable image placements: [${r.join(", ")}].`,
|
|
1409
1419
|
{ productId: e.id, requested: t.placement, validNames: r, docSlug: "embed-mode" }
|
|
1410
|
-
) : new
|
|
1420
|
+
) : new I(
|
|
1411
1421
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1412
1422
|
`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.`,
|
|
1413
1423
|
{ productId: e.id, docSlug: "embed-mode" }
|
|
1414
1424
|
);
|
|
1415
|
-
const
|
|
1425
|
+
const s = ((b = e.options) == null ? void 0 : b.attributes) ?? {}, c = Object.values(s).some(
|
|
1416
1426
|
(g) => {
|
|
1417
|
-
var
|
|
1418
|
-
return (
|
|
1427
|
+
var N;
|
|
1428
|
+
return (N = g == null ? void 0 : g.choices) == null ? void 0 : N.some((x) => x == null ? void 0 : x.hex);
|
|
1419
1429
|
}
|
|
1420
|
-
) ? (E = (
|
|
1430
|
+
) ? (E = (m = (R = e.options) == null ? void 0 : R.combinations) == null ? void 0 : m.find(
|
|
1421
1431
|
(g) => typeof g.variantId == "string" && g.variantId !== ""
|
|
1422
|
-
)) == null ? void 0 : E.variantId : void 0,
|
|
1423
|
-
var
|
|
1424
|
-
return (
|
|
1425
|
-
}) :
|
|
1426
|
-
if (
|
|
1427
|
-
throw new
|
|
1432
|
+
)) == null ? void 0 : E.variantId : void 0, a = e.mockups ?? [], d = c ? a.filter((g) => {
|
|
1433
|
+
var N;
|
|
1434
|
+
return (N = g.gvids) == null ? void 0 : N.includes(c);
|
|
1435
|
+
}) : a, l = (d.length > 0 ? d : a).map((g) => g.id);
|
|
1436
|
+
if (l.length === 0)
|
|
1437
|
+
throw new I(
|
|
1428
1438
|
"E_PRODUCT_NOT_RENDERABLE",
|
|
1429
1439
|
`product ${e.id} has no mockup scenes — nothing to render a preview into.`,
|
|
1430
1440
|
{ productId: e.id, docSlug: "embed-mode" }
|
|
@@ -1432,11 +1442,11 @@ function Bn(e, t = {}) {
|
|
|
1432
1442
|
return {
|
|
1433
1443
|
product: {
|
|
1434
1444
|
productId: e.id,
|
|
1435
|
-
mockupIds:
|
|
1436
|
-
...typeof
|
|
1445
|
+
mockupIds: l,
|
|
1446
|
+
...typeof c == "string" ? { variantId: c } : {},
|
|
1437
1447
|
options: e.options,
|
|
1438
|
-
placements: (
|
|
1439
|
-
mockups:
|
|
1448
|
+
placements: (y = e.placements) == null ? void 0 : y.map((g) => g.label),
|
|
1449
|
+
mockups: a,
|
|
1440
1450
|
requiredPlacements: e.requiredPlacements,
|
|
1441
1451
|
...e.defaultGvid ? { defaultGvid: e.defaultGvid } : {},
|
|
1442
1452
|
...typeof t.width == "number" ? { width: t.width } : {}
|
|
@@ -1454,11 +1464,11 @@ function Bn(e, t = {}) {
|
|
|
1454
1464
|
height: g.height,
|
|
1455
1465
|
aspectRatio: g.width / g.height
|
|
1456
1466
|
})),
|
|
1457
|
-
primaryMockupId:
|
|
1458
|
-
variantId:
|
|
1467
|
+
primaryMockupId: l[0],
|
|
1468
|
+
variantId: c
|
|
1459
1469
|
};
|
|
1460
1470
|
}
|
|
1461
|
-
function
|
|
1471
|
+
function pn(e) {
|
|
1462
1472
|
return new Intl.NumberFormat("en-US", {
|
|
1463
1473
|
style: "currency",
|
|
1464
1474
|
currency: "USD",
|
|
@@ -1466,7 +1476,7 @@ function mn(e) {
|
|
|
1466
1476
|
maximumFractionDigits: e % 100 === 0 ? 0 : 2
|
|
1467
1477
|
}).format(e / 100);
|
|
1468
1478
|
}
|
|
1469
|
-
const
|
|
1479
|
+
const fn = {
|
|
1470
1480
|
display: "inline-flex",
|
|
1471
1481
|
alignItems: "center",
|
|
1472
1482
|
justifyContent: "center",
|
|
@@ -1481,7 +1491,7 @@ const pn = {
|
|
|
1481
1491
|
fontSize: 16,
|
|
1482
1492
|
lineHeight: 1,
|
|
1483
1493
|
cursor: "pointer"
|
|
1484
|
-
},
|
|
1494
|
+
}, hn = {
|
|
1485
1495
|
display: "flex",
|
|
1486
1496
|
alignItems: "center",
|
|
1487
1497
|
gap: 10,
|
|
@@ -1501,47 +1511,47 @@ function ve({
|
|
|
1501
1511
|
label: e,
|
|
1502
1512
|
onSelect: t
|
|
1503
1513
|
}) {
|
|
1504
|
-
return /* @__PURE__ */
|
|
1514
|
+
return /* @__PURE__ */ f(
|
|
1505
1515
|
"button",
|
|
1506
1516
|
{
|
|
1507
1517
|
type: "button",
|
|
1508
1518
|
role: "menuitem",
|
|
1509
1519
|
"data-sc-part": "snowcone-editor-menu-item",
|
|
1510
|
-
style:
|
|
1520
|
+
style: hn,
|
|
1511
1521
|
onClick: t,
|
|
1512
1522
|
children: e
|
|
1513
1523
|
}
|
|
1514
1524
|
);
|
|
1515
1525
|
}
|
|
1516
|
-
function
|
|
1526
|
+
function gn({
|
|
1517
1527
|
fullscreen: e,
|
|
1518
1528
|
onToggleFullscreen: t,
|
|
1519
1529
|
viewCount: n,
|
|
1520
1530
|
viewIndex: r,
|
|
1521
1531
|
onSelectView: i,
|
|
1522
|
-
onExport:
|
|
1532
|
+
onExport: s
|
|
1523
1533
|
}) {
|
|
1524
|
-
const [
|
|
1534
|
+
const [o, c] = D(!1), a = () => c(!1);
|
|
1525
1535
|
return /* @__PURE__ */ U("div", { style: { position: "relative" }, children: [
|
|
1526
|
-
/* @__PURE__ */
|
|
1536
|
+
/* @__PURE__ */ f(
|
|
1527
1537
|
"button",
|
|
1528
1538
|
{
|
|
1529
1539
|
type: "button",
|
|
1530
1540
|
"aria-label": "Editor menu",
|
|
1531
1541
|
"aria-haspopup": "menu",
|
|
1532
|
-
"aria-expanded":
|
|
1542
|
+
"aria-expanded": o,
|
|
1533
1543
|
"data-sc-part": "snowcone-editor-menu",
|
|
1534
|
-
style:
|
|
1535
|
-
onClick: () =>
|
|
1544
|
+
style: fn,
|
|
1545
|
+
onClick: () => c((d) => !d),
|
|
1536
1546
|
children: "⋮"
|
|
1537
1547
|
}
|
|
1538
1548
|
),
|
|
1539
|
-
|
|
1540
|
-
/* @__PURE__ */
|
|
1549
|
+
o ? /* @__PURE__ */ U(ct, { children: [
|
|
1550
|
+
/* @__PURE__ */ f(
|
|
1541
1551
|
"div",
|
|
1542
1552
|
{
|
|
1543
1553
|
style: { position: "fixed", inset: 0, zIndex: 39 },
|
|
1544
|
-
onClick:
|
|
1554
|
+
onClick: a,
|
|
1545
1555
|
"aria-hidden": "true"
|
|
1546
1556
|
}
|
|
1547
1557
|
),
|
|
@@ -1564,31 +1574,31 @@ function hn({
|
|
|
1564
1574
|
zIndex: 40
|
|
1565
1575
|
},
|
|
1566
1576
|
children: [
|
|
1567
|
-
/* @__PURE__ */
|
|
1577
|
+
/* @__PURE__ */ f(
|
|
1568
1578
|
ve,
|
|
1569
1579
|
{
|
|
1570
1580
|
label: e ? "Exit fullscreen" : "Fullscreen",
|
|
1571
1581
|
onSelect: () => {
|
|
1572
|
-
|
|
1582
|
+
a(), t();
|
|
1573
1583
|
}
|
|
1574
1584
|
}
|
|
1575
1585
|
),
|
|
1576
|
-
n > 1 ? Array.from({ length: n }, (
|
|
1586
|
+
n > 1 ? Array.from({ length: n }, (d, l) => /* @__PURE__ */ f(
|
|
1577
1587
|
ve,
|
|
1578
1588
|
{
|
|
1579
|
-
label: `View ${
|
|
1589
|
+
label: `View ${l + 1}${l === r ? " ✓" : ""}`,
|
|
1580
1590
|
onSelect: () => {
|
|
1581
|
-
|
|
1591
|
+
a(), i(l);
|
|
1582
1592
|
}
|
|
1583
1593
|
},
|
|
1584
|
-
|
|
1594
|
+
l
|
|
1585
1595
|
)) : null,
|
|
1586
|
-
/* @__PURE__ */
|
|
1596
|
+
/* @__PURE__ */ f(
|
|
1587
1597
|
ve,
|
|
1588
1598
|
{
|
|
1589
1599
|
label: "Export PNG",
|
|
1590
1600
|
onSelect: () => {
|
|
1591
|
-
|
|
1601
|
+
a(), s();
|
|
1592
1602
|
}
|
|
1593
1603
|
}
|
|
1594
1604
|
)
|
|
@@ -1598,7 +1608,7 @@ function hn({
|
|
|
1598
1608
|
] }) : null
|
|
1599
1609
|
] });
|
|
1600
1610
|
}
|
|
1601
|
-
function
|
|
1611
|
+
function yn() {
|
|
1602
1612
|
const { flatLayers: e, selectLayer: t, generateAllPreviews: n } = dt({ previewSize: 96 });
|
|
1603
1613
|
return F(() => {
|
|
1604
1614
|
e.length > 0 && n();
|
|
@@ -1608,9 +1618,9 @@ function gn() {
|
|
|
1608
1618
|
"data-sc-part": "snowcone-editor-idle-dock",
|
|
1609
1619
|
style: { display: "flex", alignItems: "center", justifyContent: "center", gap: 8, minHeight: 44 },
|
|
1610
1620
|
children: [
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
e.length > 0 ? /* @__PURE__ */
|
|
1613
|
-
e.map((r) => /* @__PURE__ */
|
|
1621
|
+
/* @__PURE__ */ f(H.Add, {}),
|
|
1622
|
+
e.length > 0 ? /* @__PURE__ */ f("div", { style: { width: 1, height: 28, background: "rgba(0,0,0,0.1)", flexShrink: 0 }, "aria-hidden": "true" }) : null,
|
|
1623
|
+
e.map((r) => /* @__PURE__ */ f(
|
|
1614
1624
|
"button",
|
|
1615
1625
|
{
|
|
1616
1626
|
type: "button",
|
|
@@ -1633,8 +1643,8 @@ function gn() {
|
|
|
1633
1643
|
},
|
|
1634
1644
|
children: r.previewUrl ? (
|
|
1635
1645
|
// eslint-disable-next-line @next/next/no-img-element
|
|
1636
|
-
/* @__PURE__ */
|
|
1637
|
-
) : /* @__PURE__ */
|
|
1646
|
+
/* @__PURE__ */ f("img", { src: r.previewUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "contain" } })
|
|
1647
|
+
) : /* @__PURE__ */ f(
|
|
1638
1648
|
"span",
|
|
1639
1649
|
{
|
|
1640
1650
|
style: {
|
|
@@ -1655,11 +1665,11 @@ function gn() {
|
|
|
1655
1665
|
}
|
|
1656
1666
|
);
|
|
1657
1667
|
}
|
|
1658
|
-
function
|
|
1668
|
+
function bn({
|
|
1659
1669
|
onAddToCart: e,
|
|
1660
1670
|
defaultQuantity: t
|
|
1661
1671
|
}) {
|
|
1662
|
-
const { price: n, complete: r } =
|
|
1672
|
+
const { price: n, complete: r } = un();
|
|
1663
1673
|
return /* @__PURE__ */ U(
|
|
1664
1674
|
H.Buy,
|
|
1665
1675
|
{
|
|
@@ -1684,28 +1694,28 @@ function yn({
|
|
|
1684
1694
|
},
|
|
1685
1695
|
children: [
|
|
1686
1696
|
"Add to cart",
|
|
1687
|
-
typeof n == "number" ? ` · ${
|
|
1697
|
+
typeof n == "number" ? ` · ${pn(n)}` : ""
|
|
1688
1698
|
]
|
|
1689
1699
|
}
|
|
1690
1700
|
);
|
|
1691
1701
|
}
|
|
1692
|
-
function
|
|
1702
|
+
function vn({
|
|
1693
1703
|
title: e,
|
|
1694
1704
|
height: t,
|
|
1695
1705
|
mockupIds: n,
|
|
1696
1706
|
onAddToCart: r,
|
|
1697
1707
|
defaultQuantity: i,
|
|
1698
|
-
className:
|
|
1699
|
-
style:
|
|
1708
|
+
className: s,
|
|
1709
|
+
style: o
|
|
1700
1710
|
}) {
|
|
1701
|
-
const [
|
|
1702
|
-
var
|
|
1703
|
-
const
|
|
1704
|
-
if (!
|
|
1705
|
-
const [
|
|
1706
|
-
if (typeof
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1711
|
+
const [c, a] = D(!1), [d, l] = D(0), [u, b] = D(!1), R = C(null), m = Ot(), E = n[Math.min(d, n.length - 1)], y = G(async () => {
|
|
1712
|
+
var V;
|
|
1713
|
+
const x = await ((V = R.current) == null ? void 0 : V.exportArtboards({ format: "dataUrl" }));
|
|
1714
|
+
if (!x) return;
|
|
1715
|
+
const [w, T] = Object.entries(x)[0] ?? [];
|
|
1716
|
+
if (typeof T != "string") return;
|
|
1717
|
+
const _ = document.createElement("a");
|
|
1718
|
+
_.href = T, _.download = `${w ?? "design"}.png`, _.click();
|
|
1709
1719
|
}, []), g = {
|
|
1710
1720
|
display: "flex",
|
|
1711
1721
|
flexDirection: "column",
|
|
@@ -1713,7 +1723,7 @@ function bn({
|
|
|
1713
1723
|
background: "var(--sc-color-surface, #fff)",
|
|
1714
1724
|
color: "var(--sc-color-foreground, #111)",
|
|
1715
1725
|
fontFamily: "ui-sans-serif, system-ui, sans-serif",
|
|
1716
|
-
...
|
|
1726
|
+
...c ? {
|
|
1717
1727
|
position: "fixed",
|
|
1718
1728
|
inset: 0,
|
|
1719
1729
|
zIndex: 9999,
|
|
@@ -1726,8 +1736,8 @@ function bn({
|
|
|
1726
1736
|
border: "1px solid rgba(0,0,0,0.08)",
|
|
1727
1737
|
boxShadow: "0 1px 3px rgba(0,0,0,0.08)"
|
|
1728
1738
|
},
|
|
1729
|
-
...
|
|
1730
|
-
},
|
|
1739
|
+
...o
|
|
1740
|
+
}, N = {
|
|
1731
1741
|
position: "absolute",
|
|
1732
1742
|
top: 8,
|
|
1733
1743
|
right: 12,
|
|
@@ -1746,8 +1756,8 @@ function bn({
|
|
|
1746
1756
|
"div",
|
|
1747
1757
|
{
|
|
1748
1758
|
"data-sc-part": "snowcone-editor",
|
|
1749
|
-
"data-sc-fullscreen":
|
|
1750
|
-
className:
|
|
1759
|
+
"data-sc-fullscreen": c ? "true" : void 0,
|
|
1760
|
+
className: s,
|
|
1751
1761
|
style: g,
|
|
1752
1762
|
children: [
|
|
1753
1763
|
/* @__PURE__ */ U(
|
|
@@ -1762,20 +1772,20 @@ function bn({
|
|
|
1762
1772
|
flexShrink: 0
|
|
1763
1773
|
},
|
|
1764
1774
|
children: [
|
|
1765
|
-
/* @__PURE__ */
|
|
1766
|
-
/* @__PURE__ */
|
|
1767
|
-
/* @__PURE__ */
|
|
1768
|
-
|
|
1775
|
+
/* @__PURE__ */ f("span", { style: { fontSize: 14, fontWeight: 700, marginRight: "auto" }, children: e }),
|
|
1776
|
+
/* @__PURE__ */ f(H.History, {}),
|
|
1777
|
+
/* @__PURE__ */ f(
|
|
1778
|
+
gn,
|
|
1769
1779
|
{
|
|
1770
|
-
fullscreen:
|
|
1771
|
-
onToggleFullscreen: () =>
|
|
1780
|
+
fullscreen: c,
|
|
1781
|
+
onToggleFullscreen: () => a((x) => !x),
|
|
1772
1782
|
viewCount: n.length,
|
|
1773
|
-
viewIndex:
|
|
1774
|
-
onSelectView:
|
|
1775
|
-
onExport: () => void
|
|
1783
|
+
viewIndex: d,
|
|
1784
|
+
onSelectView: l,
|
|
1785
|
+
onExport: () => void y()
|
|
1776
1786
|
}
|
|
1777
1787
|
),
|
|
1778
|
-
/* @__PURE__ */
|
|
1788
|
+
/* @__PURE__ */ f(bn, { onAddToCart: r, defaultQuantity: i })
|
|
1779
1789
|
]
|
|
1780
1790
|
}
|
|
1781
1791
|
),
|
|
@@ -1785,8 +1795,8 @@ function bn({
|
|
|
1785
1795
|
"data-sc-part": "snowcone-editor-stage",
|
|
1786
1796
|
style: { position: "relative", flex: 1, minHeight: 0, padding: "4px 12px" },
|
|
1787
1797
|
children: [
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
|
|
1798
|
+
/* @__PURE__ */ f(H.Canvas, { ref: R, style: { height: "100%" } }),
|
|
1799
|
+
u ? (
|
|
1790
1800
|
// Swapped: the mockup IS the stage; the corner chip returns to the
|
|
1791
1801
|
// artwork. The canvas stays mounted underneath (no document
|
|
1792
1802
|
// teardown), just covered.
|
|
@@ -1805,25 +1815,25 @@ function bn({
|
|
|
1805
1815
|
padding: 8
|
|
1806
1816
|
},
|
|
1807
1817
|
children: [
|
|
1808
|
-
/* @__PURE__ */
|
|
1818
|
+
/* @__PURE__ */ f(
|
|
1809
1819
|
H.Preview,
|
|
1810
1820
|
{
|
|
1811
1821
|
mockupId: E,
|
|
1812
1822
|
alt: "Product mockup",
|
|
1813
1823
|
loadingOverlay: !0,
|
|
1814
|
-
fallback: /* @__PURE__ */
|
|
1824
|
+
fallback: /* @__PURE__ */ f("div", { "aria-busy": "true", children: "Rendering…" }),
|
|
1815
1825
|
style: { maxWidth: "100%", maxHeight: "100%", borderRadius: 12 }
|
|
1816
1826
|
}
|
|
1817
1827
|
),
|
|
1818
|
-
/* @__PURE__ */
|
|
1828
|
+
/* @__PURE__ */ f(
|
|
1819
1829
|
"button",
|
|
1820
1830
|
{
|
|
1821
1831
|
type: "button",
|
|
1822
1832
|
"aria-label": "Back to artwork",
|
|
1823
1833
|
"data-sc-part": "snowcone-editor-swap-back",
|
|
1824
|
-
onClick: () =>
|
|
1834
|
+
onClick: () => b(!1),
|
|
1825
1835
|
style: {
|
|
1826
|
-
...
|
|
1836
|
+
...N,
|
|
1827
1837
|
display: "flex",
|
|
1828
1838
|
alignItems: "center",
|
|
1829
1839
|
justifyContent: "center",
|
|
@@ -1838,21 +1848,21 @@ function bn({
|
|
|
1838
1848
|
]
|
|
1839
1849
|
}
|
|
1840
1850
|
)
|
|
1841
|
-
) : /* @__PURE__ */
|
|
1851
|
+
) : /* @__PURE__ */ f(
|
|
1842
1852
|
"button",
|
|
1843
1853
|
{
|
|
1844
1854
|
type: "button",
|
|
1845
1855
|
"aria-label": "Show product mockup",
|
|
1846
1856
|
"data-sc-part": "snowcone-editor-pip",
|
|
1847
|
-
onClick: () =>
|
|
1848
|
-
style:
|
|
1849
|
-
children: /* @__PURE__ */
|
|
1857
|
+
onClick: () => b(!0),
|
|
1858
|
+
style: N,
|
|
1859
|
+
children: /* @__PURE__ */ f(
|
|
1850
1860
|
H.Preview,
|
|
1851
1861
|
{
|
|
1852
1862
|
mockupId: E,
|
|
1853
1863
|
alt: "Product mockup preview",
|
|
1854
1864
|
loadingOverlay: !0,
|
|
1855
|
-
fallback: /* @__PURE__ */
|
|
1865
|
+
fallback: /* @__PURE__ */ f("span", { style: { fontSize: 10, opacity: 0.5 }, "aria-busy": "true", children: "mockup…" }),
|
|
1856
1866
|
style: { width: "100%", height: "100%", display: "block" }
|
|
1857
1867
|
}
|
|
1858
1868
|
)
|
|
@@ -1865,11 +1875,11 @@ function bn({
|
|
|
1865
1875
|
"div",
|
|
1866
1876
|
{
|
|
1867
1877
|
"data-sc-part": "snowcone-editor-zone",
|
|
1868
|
-
"data-sc-zone-state":
|
|
1878
|
+
"data-sc-zone-state": m ? "selected" : "idle",
|
|
1869
1879
|
style: { flexShrink: 0, padding: "4px 16px 14px" },
|
|
1870
1880
|
children: [
|
|
1871
|
-
/* @__PURE__ */
|
|
1872
|
-
|
|
1881
|
+
/* @__PURE__ */ f("div", { style: { display: m ? void 0 : "none" }, children: /* @__PURE__ */ f(H.Controls, { placement: "docked" }) }),
|
|
1882
|
+
m ? null : /* @__PURE__ */ f(yn, {})
|
|
1873
1883
|
]
|
|
1874
1884
|
}
|
|
1875
1885
|
)
|
|
@@ -1877,49 +1887,49 @@ function bn({
|
|
|
1877
1887
|
}
|
|
1878
1888
|
);
|
|
1879
1889
|
}
|
|
1880
|
-
function
|
|
1890
|
+
function Fn(e) {
|
|
1881
1891
|
const {
|
|
1882
1892
|
onAddToCart: t,
|
|
1883
1893
|
defaultQuantity: n,
|
|
1884
1894
|
title: r = "Editor",
|
|
1885
1895
|
height: i = 480,
|
|
1886
|
-
className:
|
|
1887
|
-
style:
|
|
1888
|
-
...
|
|
1896
|
+
className: s,
|
|
1897
|
+
style: o,
|
|
1898
|
+
...c
|
|
1889
1899
|
} = e;
|
|
1890
|
-
return /* @__PURE__ */
|
|
1891
|
-
|
|
1900
|
+
return /* @__PURE__ */ f(H.Root, { ...c, children: /* @__PURE__ */ f(
|
|
1901
|
+
vn,
|
|
1892
1902
|
{
|
|
1893
1903
|
title: r,
|
|
1894
1904
|
height: i,
|
|
1895
|
-
mockupIds:
|
|
1905
|
+
mockupIds: c.product.mockupIds,
|
|
1896
1906
|
onAddToCart: t,
|
|
1897
1907
|
...typeof n == "number" ? { defaultQuantity: n } : {},
|
|
1898
|
-
className:
|
|
1899
|
-
style:
|
|
1908
|
+
className: s,
|
|
1909
|
+
style: o
|
|
1900
1910
|
}
|
|
1901
1911
|
) });
|
|
1902
1912
|
}
|
|
1903
1913
|
lt();
|
|
1904
1914
|
export {
|
|
1905
1915
|
H as E,
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1916
|
+
Dn as R,
|
|
1917
|
+
Fn as S,
|
|
1918
|
+
An as a,
|
|
1919
|
+
Ln as b,
|
|
1920
|
+
Tn as c,
|
|
1921
|
+
_n as d,
|
|
1912
1922
|
$t as e,
|
|
1913
1923
|
Fe as f,
|
|
1914
|
-
|
|
1924
|
+
pn as g,
|
|
1915
1925
|
Tt as h,
|
|
1916
1926
|
Ue as i,
|
|
1917
1927
|
qt as j,
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1928
|
+
un as k,
|
|
1929
|
+
Bn as l,
|
|
1930
|
+
Un as p,
|
|
1921
1931
|
xe as s,
|
|
1922
1932
|
te as u,
|
|
1923
1933
|
Dt as v
|
|
1924
1934
|
};
|
|
1925
|
-
//# sourceMappingURL=embed-
|
|
1935
|
+
//# sourceMappingURL=embed-DhjsJ3ni.js.map
|