@spiffcommerce/core 32.2.4-beta.4afe3abf-22fb-564b-b8a7-84762f8e91f4 → 32.2.4-beta.bd4bf70f-5b7f-54e2-840c-b9b707d86b8d
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/index.js +24 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +137 -129
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,11 +7,11 @@ import { orientation as pr } from "exifr/dist/mini.umd.cjs";
|
|
|
7
7
|
import { parse as ln } from "css";
|
|
8
8
|
import fr from "fuse.js";
|
|
9
9
|
import { Pith as ua } from "pith";
|
|
10
|
-
import
|
|
10
|
+
import ct from "lodash.clonedeep";
|
|
11
11
|
import { toString as cn } from "qrcode";
|
|
12
12
|
import Cr from "svg-path-bbox";
|
|
13
13
|
import { parse as ea } from "opentype.js";
|
|
14
|
-
import { jsx as D, jsxs as
|
|
14
|
+
import { jsx as D, jsxs as dt, Fragment as Gt } from "preact/jsx-runtime";
|
|
15
15
|
import wr from "handlebars";
|
|
16
16
|
import { dataUriToBuffer as yr } from "data-uri-to-buffer";
|
|
17
17
|
import xa from "lodash.chunk";
|
|
@@ -74,7 +74,7 @@ class Dt extends ke {
|
|
|
74
74
|
super(`Parsing Error: ${t}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class mt extends ke {
|
|
78
78
|
constructor(t) {
|
|
79
79
|
super(`Client Error: ${t}`);
|
|
80
80
|
}
|
|
@@ -160,7 +160,7 @@ class Mr {
|
|
|
160
160
|
this.serverUrlCallbacks.push(t);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
const
|
|
163
|
+
const pt = new Mr();
|
|
164
164
|
let na, ra;
|
|
165
165
|
function Qc(r) {
|
|
166
166
|
na = r;
|
|
@@ -201,7 +201,7 @@ const hn = /* @__PURE__ */ new Map(), Na = /* @__PURE__ */ new Map(), Qa = /* @_
|
|
|
201
201
|
return document.createElementNS(r, t);
|
|
202
202
|
const a = Zt().document.createElement(t);
|
|
203
203
|
return a.setAttribute("xmlns", r), a;
|
|
204
|
-
},
|
|
204
|
+
}, At = () => {
|
|
205
205
|
if (Tt([typeof DOMParser]))
|
|
206
206
|
return new DOMParser();
|
|
207
207
|
const r = Zt();
|
|
@@ -295,7 +295,7 @@ let fn;
|
|
|
295
295
|
const Gr = (r) => {
|
|
296
296
|
fn = r;
|
|
297
297
|
}, Wr = () => new Promise((r) => {
|
|
298
|
-
const t =
|
|
298
|
+
const t = pt.getHubUrl(), e = (a) => {
|
|
299
299
|
a.origin === t && (window.removeEventListener("message", e), r(a.data));
|
|
300
300
|
};
|
|
301
301
|
window.parent !== window && (window.addEventListener("message", e, !1), window.parent.postMessage("ready", t));
|
|
@@ -308,13 +308,13 @@ const Gr = (r) => {
|
|
|
308
308
|
return typeof window < "u" && (window.location.href.includes("/workflows/product/") || window.location.href.includes("hub=true")) ? { ...await Wr(), ...r } : r;
|
|
309
309
|
};
|
|
310
310
|
async function jr(r, t) {
|
|
311
|
-
const e =
|
|
311
|
+
const e = pt.getServerUrl(), a = e.includes(".aumelbdev.spiffcommerce.com") ? "https://moonlight.aumelbdev.spiffcommerce.com" : e.includes(".us.spiffcommerce.com") ? "https://moonlight.us.spiffcommerce.com" : "https://moonlight.au.spiffcommerce.com";
|
|
312
312
|
let n = await rt(r, { ...t, redirect: "manual" });
|
|
313
313
|
return n.type === "opaqueredirect" && (typeof r != "string" && "url" in r ? n = await rt({ ...r, url: `${a}/graphql` }, t) : n = await rt(`${a}/graphql`, t)), n;
|
|
314
314
|
}
|
|
315
315
|
class Hr {
|
|
316
316
|
constructor() {
|
|
317
|
-
this.shadowGraphqlClient = this.constructShadowGraphqlClient(),
|
|
317
|
+
this.shadowGraphqlClient = this.constructShadowGraphqlClient(), pt.addServerUrlCallback(() => {
|
|
318
318
|
this.shadowGraphqlClient = this.constructShadowGraphqlClient();
|
|
319
319
|
});
|
|
320
320
|
}
|
|
@@ -326,7 +326,7 @@ class Hr {
|
|
|
326
326
|
}
|
|
327
327
|
constructShadowGraphqlClient() {
|
|
328
328
|
const t = lr({
|
|
329
|
-
uri: `${
|
|
329
|
+
uri: `${pt.getServerUrl()}/graphql`,
|
|
330
330
|
fetch: jr
|
|
331
331
|
}), e = ur(async (i, s) => {
|
|
332
332
|
const { headers: o } = s, l = o || {}, c = await qr();
|
|
@@ -365,7 +365,7 @@ class Hr {
|
|
|
365
365
|
}
|
|
366
366
|
const y = new Hr();
|
|
367
367
|
let ia, sa;
|
|
368
|
-
const
|
|
368
|
+
const ft = (r, t, e) => {
|
|
369
369
|
if (ia !== void 0)
|
|
370
370
|
return ia(r, t, e);
|
|
371
371
|
try {
|
|
@@ -426,10 +426,10 @@ const Yr = (r) => new Promise((t) => {
|
|
|
426
426
|
}, _r = async (r) => {
|
|
427
427
|
const t = await $r(r), e = await te(t), [a, n] = Kr(e);
|
|
428
428
|
if (!await Jr()) {
|
|
429
|
-
const A =
|
|
429
|
+
const A = ft(a, n);
|
|
430
430
|
return A.getContext("2d")?.drawImage(e, 0, 0, a, n), A;
|
|
431
431
|
}
|
|
432
|
-
const s = await Yr(r), [o, l] = s > 4 ? [n, a] : [a, n], c =
|
|
432
|
+
const s = await Yr(r), [o, l] = s > 4 ? [n, a] : [a, n], c = ft(o, l), d = c.getContext("2d");
|
|
433
433
|
switch (s) {
|
|
434
434
|
case 2:
|
|
435
435
|
d.translate(o, 0), d.scale(-1, 1);
|
|
@@ -3287,7 +3287,7 @@ const le = (r) => {
|
|
|
3287
3287
|
const t = /pt|pc|mm|cm|in/gm, e = r.getAttribute("viewBox"), a = r.getAttribute("width"), n = r.getAttribute("height");
|
|
3288
3288
|
if (!e) throw new Error("viewBox not specified on SVG!");
|
|
3289
3289
|
a && r.setAttribute("width", a.replace(t, "")), n && r.setAttribute("height", n.replace(t, ""));
|
|
3290
|
-
}, Sn = (r) =>
|
|
3290
|
+
}, Sn = (r) => At().parseFromString(r, "image/svg+xml").firstElementChild, si = (r, t, e) => {
|
|
3291
3291
|
r.setAttribute("height", `${e}px`), r.setAttribute("width", `${t}px`);
|
|
3292
3292
|
}, vn = (r, t, e) => {
|
|
3293
3293
|
kt(r, (a) => {
|
|
@@ -3340,7 +3340,7 @@ const le = (r) => {
|
|
|
3340
3340
|
return vn(a, t, e), En(a);
|
|
3341
3341
|
}, oi = (r) => {
|
|
3342
3342
|
const t = /<svg.*<\/svg>/s, e = r.match(t) || [], a = e?.length > 0 ? e[0] : "";
|
|
3343
|
-
return
|
|
3343
|
+
return At().parseFromString(a, "image/svg+xml");
|
|
3344
3344
|
}, ot = async (r) => {
|
|
3345
3345
|
const e = oi(r).firstElementChild;
|
|
3346
3346
|
if (!e)
|
|
@@ -3603,7 +3603,7 @@ class gi {
|
|
|
3603
3603
|
d.lengthComputable && a(d.loaded * 100 / d.total);
|
|
3604
3604
|
}, c.onload = () => {
|
|
3605
3605
|
const d = s.assetResponse.asset;
|
|
3606
|
-
|
|
3606
|
+
ut.add(s.assetResponse.asset), o(d);
|
|
3607
3607
|
}, c.onerror = l, this.postProcessFileUpload(t, s.mimeType).then((d) => c.send(d.blob)).catch(l);
|
|
3608
3608
|
}), this.cacheAsset(s.assetResponse.asset), s.assetResponse.asset;
|
|
3609
3609
|
}
|
|
@@ -3634,7 +3634,7 @@ class gi {
|
|
|
3634
3634
|
});
|
|
3635
3635
|
if (this.bgrmProcessCache.delete(e), !i.data?.assetRemoveBackground?.key)
|
|
3636
3636
|
throw new Error("Failed to remove background from image");
|
|
3637
|
-
return
|
|
3637
|
+
return ut.add(i.data.assetRemoveBackground), J.add(e, i.data.assetRemoveBackground.key), this.cache.set(
|
|
3638
3638
|
i.data.assetRemoveBackground.key,
|
|
3639
3639
|
Promise.resolve(i.data.assetRemoveBackground)
|
|
3640
3640
|
), i.data.assetRemoveBackground;
|
|
@@ -3642,16 +3642,16 @@ class gi {
|
|
|
3642
3642
|
return this.bgrmProcessCache.set(e, n), n;
|
|
3643
3643
|
}
|
|
3644
3644
|
removePersistedAsset(t) {
|
|
3645
|
-
|
|
3645
|
+
ut.remove(t), J.delete(t), J.deleteForBgRemovedKey(t);
|
|
3646
3646
|
}
|
|
3647
3647
|
getPersistedAssets() {
|
|
3648
|
-
return
|
|
3648
|
+
return ut.list();
|
|
3649
3649
|
}
|
|
3650
3650
|
registerPersistedAssetListener(t) {
|
|
3651
|
-
|
|
3651
|
+
ut.addCallback(t);
|
|
3652
3652
|
}
|
|
3653
3653
|
unRegisterPersistedAssetListener(t) {
|
|
3654
|
-
|
|
3654
|
+
ut.removeCallback(t);
|
|
3655
3655
|
}
|
|
3656
3656
|
isRaster(t) {
|
|
3657
3657
|
return !(t.type === "image/svg+xml" || t.type === "application/pdf" || t.type === "application/postscript");
|
|
@@ -3747,7 +3747,7 @@ const Rt = "persistentAssets", lt = class lt {
|
|
|
3747
3747
|
}
|
|
3748
3748
|
};
|
|
3749
3749
|
lt.callbacks = [];
|
|
3750
|
-
let
|
|
3750
|
+
let ut = lt;
|
|
3751
3751
|
const Ua = "bgrmPersistentAssets";
|
|
3752
3752
|
class J {
|
|
3753
3753
|
static has(t) {
|
|
@@ -5215,7 +5215,7 @@ const H = new Si(), Bn = w`
|
|
|
5215
5215
|
],
|
|
5216
5216
|
silentSteps: []
|
|
5217
5217
|
}), t;
|
|
5218
|
-
}, Hi = (r, t) => t.find((e) => e.stepNames.includes(r)),
|
|
5218
|
+
}, Hi = (r, t) => t.find((e) => e.stepNames.includes(r)), Et = (r, t) => (r.conditions || []).every((e) => {
|
|
5219
5219
|
const a = t[e.targetStepName];
|
|
5220
5220
|
if (a && a.selectedVariants) {
|
|
5221
5221
|
const n = a.selectedVariants;
|
|
@@ -5228,12 +5228,12 @@ const H = new Si(), Bn = w`
|
|
|
5228
5228
|
const e = {
|
|
5229
5229
|
name: r.name,
|
|
5230
5230
|
title: r.title,
|
|
5231
|
-
renderableSteps: r.renderableSteps.filter((a) =>
|
|
5232
|
-
silentSteps: r.silentSteps.filter((a) =>
|
|
5231
|
+
renderableSteps: r.renderableSteps.filter((a) => Et(a, t)),
|
|
5232
|
+
silentSteps: r.silentSteps.filter((a) => Et(a, t))
|
|
5233
5233
|
};
|
|
5234
5234
|
return e.silentSteps.length === 0 && e.renderableSteps.length === 0 ? null : e;
|
|
5235
|
-
},
|
|
5236
|
-
const a =
|
|
5235
|
+
}, St = (r, t) => r.map((e) => Yi(e, t)).filter((e) => e !== null), Ji = async (r, t, e = !1) => {
|
|
5236
|
+
const a = St(r, t), n = [];
|
|
5237
5237
|
for (const s of a)
|
|
5238
5238
|
for (const o of s.renderableSteps) {
|
|
5239
5239
|
const l = (o.option?.variants || []).length;
|
|
@@ -5349,7 +5349,7 @@ const M = () => {
|
|
|
5349
5349
|
_renderingConfiguration: a,
|
|
5350
5350
|
mask: l ? `url(#viewmask-${f})` : void 0
|
|
5351
5351
|
})), C = va(I);
|
|
5352
|
-
return /* @__PURE__ */
|
|
5352
|
+
return /* @__PURE__ */ dt(
|
|
5353
5353
|
"svg",
|
|
5354
5354
|
{
|
|
5355
5355
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -5401,7 +5401,7 @@ const M = () => {
|
|
|
5401
5401
|
strokeDasharray: `${m * 2} ${m}`
|
|
5402
5402
|
}
|
|
5403
5403
|
),
|
|
5404
|
-
l && /* @__PURE__ */
|
|
5404
|
+
l && /* @__PURE__ */ dt("mask", { id: `viewmask-${f}`, children: [
|
|
5405
5405
|
/* @__PURE__ */ D(
|
|
5406
5406
|
"rect",
|
|
5407
5407
|
{
|
|
@@ -5427,7 +5427,7 @@ const M = () => {
|
|
|
5427
5427
|
}
|
|
5428
5428
|
);
|
|
5429
5429
|
}, Vc = (r, t, e, a, n) => {
|
|
5430
|
-
const i =
|
|
5430
|
+
const i = Ct(n), s = e / 2, o = a / 2, l = r + s, c = t + o, d = Math.sin(i), A = Math.cos(i), u = s, h = s, m = -o, g = o, p = u * A - m * d, f = h * A - g * d, S = u * d + m * A, b = h * d + g * A, I = Math.max(Math.abs(p), Math.abs(f)), C = Math.max(Math.abs(S), Math.abs(b));
|
|
5431
5431
|
return {
|
|
5432
5432
|
minX: l - I,
|
|
5433
5433
|
maxX: l + I,
|
|
@@ -5437,8 +5437,8 @@ const M = () => {
|
|
|
5437
5437
|
}, zc = (r, t, e) => {
|
|
5438
5438
|
const a = Math.sqrt(Math.pow(t.x - r.x, 2) + Math.pow(t.y - r.y, 2)), n = Math.sqrt(Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)), i = Math.sqrt(Math.pow(e.x - r.x, 2) + Math.pow(e.y - r.y, 2));
|
|
5439
5439
|
return Math.acos((n * n + a * a - i * i) / (2 * n * a)) * (180 / Math.PI);
|
|
5440
|
-
},
|
|
5441
|
-
const a = Math.sin(
|
|
5440
|
+
}, Ct = (r) => r * (Math.PI / 180), Gc = (r, t, e) => Math.abs(r - t) < e, Wc = (r, t, e) => {
|
|
5441
|
+
const a = Math.sin(Ct(e)), n = Math.cos(Ct(e));
|
|
5442
5442
|
return {
|
|
5443
5443
|
x: (r.x - t.x) * n - (r.y - t.y) * a + t.x,
|
|
5444
5444
|
y: (r.x - t.x) * a + (r.y - t.y) * n + t.y
|
|
@@ -5475,7 +5475,7 @@ const M = () => {
|
|
|
5475
5475
|
return j.Northwest;
|
|
5476
5476
|
}
|
|
5477
5477
|
}, Jc = (r, t) => t > 45 && t <= 135 ? Pt(r) : t > 135 && t <= 225 ? Pt(Pt(r)) : t > 225 && t <= 315 ? Pt(Pt(Pt(r))) : r, Kc = (r, t = { x: 0, y: 0 }, e = { x: 1, y: 1 }) => {
|
|
5478
|
-
const a =
|
|
5478
|
+
const a = Ct(r.rotation), n = {
|
|
5479
5479
|
x: t.x + r.x * e.x,
|
|
5480
5480
|
y: t.x + r.y * e.y
|
|
5481
5481
|
}, i = {
|
|
@@ -5505,7 +5505,7 @@ const M = () => {
|
|
|
5505
5505
|
y: (r.x - t.x) * a + (r.y - t.y) * n + t.y
|
|
5506
5506
|
};
|
|
5507
5507
|
}, _c = 0.352778, Xc = 0.035277, Mn = (r) => {
|
|
5508
|
-
const t = r.rotation || 0, e =
|
|
5508
|
+
const t = r.rotation || 0, e = Ct(t), a = Math.cos(e), n = -Math.sin(e);
|
|
5509
5509
|
return /* @__PURE__ */ D("g", { mask: r.stepName || r.productOverlay ? void 0 : r.mask, children: /* @__PURE__ */ D(
|
|
5510
5510
|
"g",
|
|
5511
5511
|
{
|
|
@@ -5527,10 +5527,10 @@ const M = () => {
|
|
|
5527
5527
|
}
|
|
5528
5528
|
) });
|
|
5529
5529
|
}, Tn = (r) => {
|
|
5530
|
-
const t = `spiff-group-clip-${r.id}`, e = r.rotation || 0, a =
|
|
5531
|
-
return /* @__PURE__ */
|
|
5530
|
+
const t = `spiff-group-clip-${r.id}`, e = r.rotation || 0, a = Ct(e), n = Math.cos(a), i = -Math.sin(a), s = va(r.children);
|
|
5531
|
+
return /* @__PURE__ */ dt(Gt, { children: [
|
|
5532
5532
|
/* @__PURE__ */ D("defs", { children: /* @__PURE__ */ D("clipPath", { id: t, preserveAspectRatio: "none", children: r.clipPath ? /* @__PURE__ */ D("path", { d: r.clipPath }) : /* @__PURE__ */ D("rect", { x: 0, y: 0, width: r.width, height: r.height }) }) }),
|
|
5533
|
-
/* @__PURE__ */
|
|
5533
|
+
/* @__PURE__ */ dt(
|
|
5534
5534
|
"g",
|
|
5535
5535
|
{
|
|
5536
5536
|
transform: `
|
|
@@ -5569,7 +5569,7 @@ const M = () => {
|
|
|
5569
5569
|
};
|
|
5570
5570
|
if (!a())
|
|
5571
5571
|
return /* @__PURE__ */ D(Gt, {});
|
|
5572
|
-
const n = () => r.threshold ? r.invertThreshold ? "1 ".repeat(r.threshold) + "0 ".repeat(256 - r.threshold) : "0 ".repeat(r.threshold) + "1 ".repeat(256 - r.threshold) : "", i = () => /* @__PURE__ */ D(Gt, { children: r.useThreshold && /* @__PURE__ */ D("defs", { children: /* @__PURE__ */
|
|
5572
|
+
const n = () => r.threshold ? r.invertThreshold ? "1 ".repeat(r.threshold) + "0 ".repeat(256 - r.threshold) : "0 ".repeat(r.threshold) + "1 ".repeat(256 - r.threshold) : "", i = () => /* @__PURE__ */ D(Gt, { children: r.useThreshold && /* @__PURE__ */ D("defs", { children: /* @__PURE__ */ dt("filter", { id: e, "color-interpolation-filters": "sRGB", children: [
|
|
5573
5573
|
/* @__PURE__ */ D(
|
|
5574
5574
|
"feColorMatrix",
|
|
5575
5575
|
{
|
|
@@ -5583,12 +5583,12 @@ const M = () => {
|
|
|
5583
5583
|
result: "greyscale"
|
|
5584
5584
|
}
|
|
5585
5585
|
),
|
|
5586
|
-
/* @__PURE__ */
|
|
5586
|
+
/* @__PURE__ */ dt("feComponentTransfer", { in: "greyscale", children: [
|
|
5587
5587
|
/* @__PURE__ */ D("feFuncR", { type: "discrete", tableValues: n() }),
|
|
5588
5588
|
/* @__PURE__ */ D("feFuncG", { type: "discrete", tableValues: n() }),
|
|
5589
5589
|
/* @__PURE__ */ D("feFuncB", { type: "discrete", tableValues: n() })
|
|
5590
5590
|
] })
|
|
5591
|
-
] }) }) }), s = r.rotation || 0, o =
|
|
5591
|
+
] }) }) }), s = r.rotation || 0, o = Ct(s), l = Math.cos(o), c = -Math.sin(o), d = () => {
|
|
5592
5592
|
const A = r.pattern?.x || 0, u = r.pattern?.y || 0, h = r.pattern?.width || 0, m = r.pattern?.height || 0, g = r.pattern?.scaleX || 1, p = r.pattern?.scaleY || 1, f = r.pattern?.rotation || 0;
|
|
5593
5593
|
return [r.pattern?.svg ? {
|
|
5594
5594
|
id: `${t}-contents`,
|
|
@@ -5612,7 +5612,7 @@ const M = () => {
|
|
|
5612
5612
|
src: a()
|
|
5613
5613
|
}];
|
|
5614
5614
|
};
|
|
5615
|
-
return /* @__PURE__ */
|
|
5615
|
+
return /* @__PURE__ */ dt(Gt, { children: [
|
|
5616
5616
|
i(),
|
|
5617
5617
|
/* @__PURE__ */ D(
|
|
5618
5618
|
"g",
|
|
@@ -5703,7 +5703,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5703
5703
|
return Ge.get(r);
|
|
5704
5704
|
const e = (async () => {
|
|
5705
5705
|
try {
|
|
5706
|
-
return
|
|
5706
|
+
return wt(r).getFont();
|
|
5707
5707
|
} catch {
|
|
5708
5708
|
if (Zi(r)) {
|
|
5709
5709
|
const a = pn(r), n = ea(a);
|
|
@@ -5718,7 +5718,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5718
5718
|
}, ts = (r) => {
|
|
5719
5719
|
const t = pn(r), e = ea(t);
|
|
5720
5720
|
return oa(r, e), e;
|
|
5721
|
-
},
|
|
5721
|
+
}, wt = (r) => {
|
|
5722
5722
|
const t = Nn.get(r);
|
|
5723
5723
|
if (t)
|
|
5724
5724
|
return t;
|
|
@@ -5727,7 +5727,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5727
5727
|
const e = new Xi(t);
|
|
5728
5728
|
return Nn.set(r, e), e;
|
|
5729
5729
|
}, Zc = async (r) => {
|
|
5730
|
-
const t =
|
|
5730
|
+
const t = At(), e = t.parseFromString(r, "image/svg+xml"), a = e.firstElementChild, n = /* @__PURE__ */ new Map();
|
|
5731
5731
|
a.querySelectorAll("style").forEach((d) => {
|
|
5732
5732
|
ln(d.innerHTML).stylesheet?.rules.forEach((u) => {
|
|
5733
5733
|
if (u.type === "font-face" && u.declarations) {
|
|
@@ -5782,7 +5782,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5782
5782
|
};
|
|
5783
5783
|
}
|
|
5784
5784
|
}, ge = (r, t, e, a) => {
|
|
5785
|
-
const n =
|
|
5785
|
+
const n = gt(r, e, a);
|
|
5786
5786
|
if (n <= t)
|
|
5787
5787
|
return { lines: [r], width: n };
|
|
5788
5788
|
if (!(r.indexOf(" ") > -1)) {
|
|
@@ -5795,15 +5795,15 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5795
5795
|
let l = -1 / 0, c = 0;
|
|
5796
5796
|
for (; c < s.length; ) {
|
|
5797
5797
|
const d = s[c];
|
|
5798
|
-
if (
|
|
5798
|
+
if (gt(d, e, a) > t) {
|
|
5799
5799
|
const A = ge(d, t, e, a);
|
|
5800
5800
|
o.push(...A.lines), l = Math.max(l, A.width), c++;
|
|
5801
5801
|
} else {
|
|
5802
5802
|
const A = [d];
|
|
5803
|
-
l = Math.max(l,
|
|
5803
|
+
l = Math.max(l, gt(d, e, a));
|
|
5804
5804
|
let u = c + 1, h = !0;
|
|
5805
5805
|
for (; u < s.length && h; ) {
|
|
5806
|
-
const m = s[u], g =
|
|
5806
|
+
const m = s[u], g = gt(`${A.join(" ")} ${m}`, e, a);
|
|
5807
5807
|
g <= t ? (A.push(m), l = Math.max(l, g), u++) : h = !1;
|
|
5808
5808
|
}
|
|
5809
5809
|
o.push(A.join(" ")), c = u;
|
|
@@ -5816,7 +5816,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5816
5816
|
const s = (i ?? On) * t.getApproximateHeight(), o = 1 / e.unitsPerEm, l = Qn(r, o, t), c = r.length * s * o, d = a / l, A = n / c;
|
|
5817
5817
|
return Math.min(A, d);
|
|
5818
5818
|
}, as = (r, t, e, a) => {
|
|
5819
|
-
const n =
|
|
5819
|
+
const n = wt(t.fontData.assetUrl), i = n.getFont(), s = t.fontSize / i.unitsPerEm;
|
|
5820
5820
|
if (!e)
|
|
5821
5821
|
return La(t, r, t.fontSize, s, n, a);
|
|
5822
5822
|
let o;
|
|
@@ -5837,11 +5837,11 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5837
5837
|
fontSize: es(o, n, i, t.width, t.height, a)
|
|
5838
5838
|
} : La(t, r, t.fontSize, s, n, a);
|
|
5839
5839
|
}, ns = (r, t, e, a, n) => {
|
|
5840
|
-
const s =
|
|
5840
|
+
const s = wt(t.assetUrl).getFont();
|
|
5841
5841
|
let o = { ...r };
|
|
5842
|
-
const l = { ...r }, c = Qn(a, e / s.unitsPerEm,
|
|
5842
|
+
const l = { ...r }, c = Qn(a, e / s.unitsPerEm, wt(t.assetUrl));
|
|
5843
5843
|
return c && c < o.width && (l.width = c, n === "left" ? (l.left += Math.sin(o.rotation * Math.PI / 360) * (o.width - c), l.top += Math.sin(o.rotation * Math.PI / 180) * (c - o.width) / 2) : n === "right" ? l.left += o.width - c : l.left += (o.width - c) / 2, a && is(a, a).every(([d, A]) => d === A) && (o = l)), o;
|
|
5844
|
-
}, We = 1,
|
|
5844
|
+
}, We = 1, gt = (r, t, e) => {
|
|
5845
5845
|
let a = 0;
|
|
5846
5846
|
const n = e.getGlyphs(r);
|
|
5847
5847
|
return n.forEach((i, s) => {
|
|
@@ -5862,7 +5862,7 @@ const Zi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ge = /* @_
|
|
|
5862
5862
|
}, Qn = (r, t, e) => {
|
|
5863
5863
|
let a = 0;
|
|
5864
5864
|
return r.forEach((n) => {
|
|
5865
|
-
a = Math.max(a,
|
|
5865
|
+
a = Math.max(a, gt(n, t, e));
|
|
5866
5866
|
}), a;
|
|
5867
5867
|
}, Va = {
|
|
5868
5868
|
stripControlCharacters: !0,
|
|
@@ -5909,8 +5909,8 @@ const os = (r) => {
|
|
|
5909
5909
|
if (r.curved && !r.paths || !r.fontData)
|
|
5910
5910
|
return null;
|
|
5911
5911
|
const h = () => r.textFillImage ? `url("#${s}")` : r._renderingConfiguration?.spotColors && r.fillSpotColorDefinition ? `${r.fill} ${yn(r.fillSpotColorDefinition)}` : r.fill;
|
|
5912
|
-
return /* @__PURE__ */
|
|
5913
|
-
/* @__PURE__ */
|
|
5912
|
+
return /* @__PURE__ */ dt(Gt, { children: [
|
|
5913
|
+
/* @__PURE__ */ dt("defs", { children: [
|
|
5914
5914
|
r.textFillImage && /* @__PURE__ */ D(
|
|
5915
5915
|
"pattern",
|
|
5916
5916
|
{
|
|
@@ -5987,7 +5987,7 @@ const os = (r) => {
|
|
|
5987
5987
|
const t = () => {
|
|
5988
5988
|
if (r.lineHeight !== void 0)
|
|
5989
5989
|
return r.lineHeight * r.fontSize;
|
|
5990
|
-
const n =
|
|
5990
|
+
const n = wt(r.fontData.assetUrl), i = n.getFont(), s = r.fontSize / i.unitsPerEm;
|
|
5991
5991
|
return n.getApproximateHeight() * s;
|
|
5992
5992
|
}, e = () => r.align === "left" ? -r.textboxWidth / 2 : r.align === "right" ? r.textboxWidth / 2 : 0, a = () => {
|
|
5993
5993
|
const n = t(), i = r.textboxHeight / 2;
|
|
@@ -6030,7 +6030,7 @@ const os = (r) => {
|
|
|
6030
6030
|
mask: r.stepName ? void 0 : r.mask
|
|
6031
6031
|
}
|
|
6032
6032
|
);
|
|
6033
|
-
const t = r.rotation || 0, e =
|
|
6033
|
+
const t = r.rotation || 0, e = Ct(t), a = Math.cos(e), n = -Math.sin(e), i = `
|
|
6034
6034
|
matrix(1, 0, 0, 1, ${r.x}, ${r.y})
|
|
6035
6035
|
matrix(1, 0, 0, 1, ${r.width / 2}, ${r.height / 2})
|
|
6036
6036
|
matrix(${a}, ${-n}, ${n}, ${a}, 0, 0)
|
|
@@ -6194,7 +6194,7 @@ const ne = (r) => {
|
|
|
6194
6194
|
if (r.defaultVariant !== void 0)
|
|
6195
6195
|
return t.find((e) => e.id === r.defaultVariant);
|
|
6196
6196
|
}
|
|
6197
|
-
},
|
|
6197
|
+
}, ht = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Map(), qe = /* @__PURE__ */ new Map(), Ln = async (r, t) => {
|
|
6198
6198
|
if (!t) {
|
|
6199
6199
|
if (!r) throw new Error("No region or src supplied. Cannot construct frame!");
|
|
6200
6200
|
return la(r);
|
|
@@ -6222,7 +6222,7 @@ const ne = (r) => {
|
|
|
6222
6222
|
if (Vt.has(r))
|
|
6223
6223
|
return Vt.get(r);
|
|
6224
6224
|
await new Promise((u) => setTimeout(u, 0));
|
|
6225
|
-
const n =
|
|
6225
|
+
const n = At().parseFromString(r, "image/svg+xml"), i = n.querySelector("svg");
|
|
6226
6226
|
if (!i)
|
|
6227
6227
|
throw new Error("Malformed frame SVG: <svg> tag not found");
|
|
6228
6228
|
const s = i.getAttribute("viewBox");
|
|
@@ -6265,8 +6265,8 @@ const ne = (r) => {
|
|
|
6265
6265
|
zoom: s
|
|
6266
6266
|
};
|
|
6267
6267
|
}, ca = async (r) => {
|
|
6268
|
-
if (
|
|
6269
|
-
return
|
|
6268
|
+
if (ht.has(r))
|
|
6269
|
+
return ht.get(r);
|
|
6270
6270
|
if (r.startsWith("data:image/svg+xml")) {
|
|
6271
6271
|
const e = yr(r), a = new TextDecoder().decode(e.buffer), n = Vn(a), i = {
|
|
6272
6272
|
src: r,
|
|
@@ -6274,7 +6274,7 @@ const ne = (r) => {
|
|
|
6274
6274
|
height: n.height,
|
|
6275
6275
|
aspect: n.width / n.height
|
|
6276
6276
|
};
|
|
6277
|
-
return
|
|
6277
|
+
return ht.set(r, i), i;
|
|
6278
6278
|
}
|
|
6279
6279
|
if ((r.split(".").pop()?.toLowerCase() ?? "") === "svg") {
|
|
6280
6280
|
const e = await ba(r), a = e.width, n = e.height, i = {
|
|
@@ -6283,7 +6283,7 @@ const ne = (r) => {
|
|
|
6283
6283
|
height: n,
|
|
6284
6284
|
aspect: a / n
|
|
6285
6285
|
};
|
|
6286
|
-
return
|
|
6286
|
+
return ht.set(r, i), i;
|
|
6287
6287
|
} else {
|
|
6288
6288
|
const e = await Te(r, !0), a = await Qe(e), n = {
|
|
6289
6289
|
src: r,
|
|
@@ -6291,13 +6291,13 @@ const ne = (r) => {
|
|
|
6291
6291
|
height: a.height,
|
|
6292
6292
|
aspect: a.width / a.height
|
|
6293
6293
|
};
|
|
6294
|
-
return
|
|
6294
|
+
return ht.set(r, n), n;
|
|
6295
6295
|
}
|
|
6296
6296
|
}, ba = async (r) => {
|
|
6297
6297
|
const t = await nt(r);
|
|
6298
6298
|
return Vn(t);
|
|
6299
6299
|
}, za = (r) => r.endsWith("mm") ? Number(r.replace("mm", "")) * 3.7795275591 : r.endsWith("px") ? Number(r.replace("px", "")) : Number(r), Vn = (r) => {
|
|
6300
|
-
const a =
|
|
6300
|
+
const a = At().parseFromString(r, "image/svg+xml").querySelector("svg");
|
|
6301
6301
|
if (!a)
|
|
6302
6302
|
throw new Error("No svg tag found, this svg must be malformed!");
|
|
6303
6303
|
const n = a.getAttribute("viewBox"), i = a.getAttribute("width"), s = a.getAttribute("height"), o = s && i ? [0, 0, za(i), za(s)] : n?.split(" ").map((l) => Number(l));
|
|
@@ -6329,13 +6329,13 @@ const ne = (r) => {
|
|
|
6329
6329
|
s(o);
|
|
6330
6330
|
}
|
|
6331
6331
|
}), a = (async () => {
|
|
6332
|
-
const s =
|
|
6332
|
+
const s = At().parseFromString(r, "image/svg+xml").firstElementChild;
|
|
6333
6333
|
if (!s)
|
|
6334
6334
|
throw new Error("Failed to read SVG");
|
|
6335
|
-
const l = It().serializeToString(s), c =
|
|
6335
|
+
const l = It().serializeToString(s), c = ft(), d = c.getContext("2d"), A = await ua.from(d, l, {
|
|
6336
6336
|
anonymousCrossOrigin: !0,
|
|
6337
6337
|
ignoreDimensions: !1,
|
|
6338
|
-
createCanvas:
|
|
6338
|
+
createCanvas: ft,
|
|
6339
6339
|
createImage: te,
|
|
6340
6340
|
DOMParser: pa(),
|
|
6341
6341
|
fetch: rt
|
|
@@ -6363,7 +6363,7 @@ const ne = (r) => {
|
|
|
6363
6363
|
panelId: r.layoutState.layout.panelId
|
|
6364
6364
|
};
|
|
6365
6365
|
if (e && t === x.Illustration) {
|
|
6366
|
-
const l = await ot(await zn(e)), u =
|
|
6366
|
+
const l = await ot(await zn(e)), u = At().parseFromString(l.svg, "image/svg+xml").firstElementChild.getAttribute("viewBox");
|
|
6367
6367
|
if (!u) throw new Error("SVG missing viewBox.");
|
|
6368
6368
|
const h = o.height, m = u.split(" "), g = parseFloat(m[2]) || 1, p = parseFloat(m[3]) || 1, f = g / p;
|
|
6369
6369
|
o.height = o.width / f, o.top += (h - o.height) / 2;
|
|
@@ -6374,7 +6374,7 @@ const ne = (r) => {
|
|
|
6374
6374
|
}
|
|
6375
6375
|
if (e && t === x.Textbox && a?.text && a?.fontScale) {
|
|
6376
6376
|
await Nt(e);
|
|
6377
|
-
const l =
|
|
6377
|
+
const l = wt(e), c = gt(a.text, a?.fontScale, l);
|
|
6378
6378
|
o.width = Math.min(c, n.width * 0.85), o.left = n.x + n.width / 2 - o.width / 2;
|
|
6379
6379
|
}
|
|
6380
6380
|
return o;
|
|
@@ -7310,7 +7310,7 @@ class ja {
|
|
|
7310
7310
|
}
|
|
7311
7311
|
}
|
|
7312
7312
|
const ys = async (r) => {
|
|
7313
|
-
const t = `${
|
|
7313
|
+
const t = `${pt.getServicesApiUrl()}/shortener`;
|
|
7314
7314
|
try {
|
|
7315
7315
|
return (await (await rt(t, {
|
|
7316
7316
|
method: "POST",
|
|
@@ -7624,7 +7624,7 @@ class De {
|
|
|
7624
7624
|
svg: d.svg,
|
|
7625
7625
|
colors: n ?? d.colors
|
|
7626
7626
|
};
|
|
7627
|
-
|
|
7627
|
+
ht.set(t, A), e.setPatternData(A, a);
|
|
7628
7628
|
} else {
|
|
7629
7629
|
const s = await Te(t, !0), o = await Qe(s), l = {
|
|
7630
7630
|
src: t,
|
|
@@ -7634,7 +7634,7 @@ class De {
|
|
|
7634
7634
|
svg: void 0,
|
|
7635
7635
|
colors: void 0
|
|
7636
7636
|
};
|
|
7637
|
-
|
|
7637
|
+
ht.set(t, l), e.setPatternData(l, a);
|
|
7638
7638
|
}
|
|
7639
7639
|
}
|
|
7640
7640
|
changeColors(t, e, a) {
|
|
@@ -7802,7 +7802,7 @@ class De {
|
|
|
7802
7802
|
), this.validateColorCount(e, a);
|
|
7803
7803
|
}
|
|
7804
7804
|
}
|
|
7805
|
-
const
|
|
7805
|
+
const vt = new De();
|
|
7806
7806
|
class vs {
|
|
7807
7807
|
async getIllustrationBody(t) {
|
|
7808
7808
|
return new Promise((e) => {
|
|
@@ -8644,7 +8644,7 @@ const xs = new Fs(), Je = (r, t, e, a, n) => {
|
|
|
8644
8644
|
if (t.some((d) => d == null))
|
|
8645
8645
|
throw new Error(`Failed to autosize lines: ${t.join(", ")}`);
|
|
8646
8646
|
let i = t.map((d) => d.split(`
|
|
8647
|
-
`)).flat(), s = i.length, o = i.map((d) =>
|
|
8647
|
+
`)).flat(), s = i.length, o = i.map((d) => gt(d, a, n));
|
|
8648
8648
|
const l = n.getApproximateHeight() * a;
|
|
8649
8649
|
let c = !0;
|
|
8650
8650
|
for (; c; ) {
|
|
@@ -8657,7 +8657,7 @@ const xs = new Fs(), Je = (r, t, e, a, n) => {
|
|
|
8657
8657
|
let m = !1, g = h.length;
|
|
8658
8658
|
for (; !m && g > -1; ) {
|
|
8659
8659
|
g = h.lastIndexOf(" ", g - 1);
|
|
8660
|
-
const p = [h.slice(0, g), h.slice(g + 1)], f = p.map((b) =>
|
|
8660
|
+
const p = [h.slice(0, g), h.slice(g + 1)], f = p.map((b) => gt(b, a, n));
|
|
8661
8661
|
f[0] <= r.width && (i = [...i.slice(0, u), ...p, ...i.slice(u + 1)], o = [
|
|
8662
8662
|
...o.slice(0, u),
|
|
8663
8663
|
...f,
|
|
@@ -8669,7 +8669,7 @@ const xs = new Fs(), Je = (r, t, e, a, n) => {
|
|
|
8669
8669
|
return [null, null];
|
|
8670
8670
|
}, fe = (r, t, e, a, n) => {
|
|
8671
8671
|
let i, s;
|
|
8672
|
-
const o =
|
|
8672
|
+
const o = wt(t.assetUrl), l = o.getFont();
|
|
8673
8673
|
if (n.size) {
|
|
8674
8674
|
const u = r / l.unitsPerEm;
|
|
8675
8675
|
return [i, s] = Je(e, a, r, u, o), [n.size, i, s];
|
|
@@ -8704,7 +8704,7 @@ class Ms {
|
|
|
8704
8704
|
/(\r\n|\r|(\u2665|\u00a9|\u00ae|[\u2000-\u2017]|[\u201E-\u3300]]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]))/gm,
|
|
8705
8705
|
""
|
|
8706
8706
|
);
|
|
8707
|
-
const n = [], i = e ?
|
|
8707
|
+
const n = [], i = e ? wt(e.assetUrl) : void 0;
|
|
8708
8708
|
if (i) {
|
|
8709
8709
|
const s = a.split("").filter((l) => !ks.includes(l)).join(""), o = s.split("").map((l) => i.getFont().charToGlyph(l));
|
|
8710
8710
|
for (let l = 0; l < o.length; l++)
|
|
@@ -10397,7 +10397,7 @@ class So {
|
|
|
10397
10397
|
this.reloadedState && this.reloadedState.serializableWorkflow.steps.forEach((o) => {
|
|
10398
10398
|
this.storage[o.stepName] = o.storage || {};
|
|
10399
10399
|
}), await this.fetchConversionConfiguration(), this.allScenes = await ji(t);
|
|
10400
|
-
const n =
|
|
10400
|
+
const n = St(this.allScenes, this.stepSelections).map((o) => o.silentSteps).flat(), { stepElements: i, commands: s } = await this.stepElementsForIntroducedSilentSteps(n, !!this.reloadedState);
|
|
10401
10401
|
this.commandContext.apply(new R(s), !0), this.stepElements = { ...this.stepElements, ...i }, await this.ensureStepsAreLoaded(), !this.isReloadedTransaction && this.updateStateWithServer(), this.renderLayouts(), this.reloadedState && e();
|
|
10402
10402
|
}
|
|
10403
10403
|
getWorkflowExperience() {
|
|
@@ -10570,7 +10570,7 @@ class So {
|
|
|
10570
10570
|
this.mandatorySteps[t] !== e && (this.mandatorySteps = { ...this.mandatorySteps, [t]: e }, this.onMandatoryChange());
|
|
10571
10571
|
}
|
|
10572
10572
|
getMandatoryUnfulfilledSteps() {
|
|
10573
|
-
return
|
|
10573
|
+
return St(this.allScenes, this.stepSelections).flatMap((i) => i.renderableSteps).filter((i) => i.mandatory).filter((i) => !this.mandatorySteps[i.stepName]).map((i) => i.stepName);
|
|
10574
10574
|
}
|
|
10575
10575
|
setStepError(t, e, a) {
|
|
10576
10576
|
let n = !1;
|
|
@@ -10605,7 +10605,7 @@ class So {
|
|
|
10605
10605
|
},
|
|
10606
10606
|
{ refocusCamera: e }
|
|
10607
10607
|
);
|
|
10608
|
-
this.setModelContainer(a),
|
|
10608
|
+
this.setModelContainer(a), St(this.allScenes, this.stepSelections).filter((s) => s).map((s) => s.renderableSteps).flat().filter((s) => s.type === v.Model || s.type === v.Material).forEach((s) => {
|
|
10609
10609
|
if (!s.option?.id) {
|
|
10610
10610
|
console.error(`Failed to read option id from step: ${s.stepName}`);
|
|
10611
10611
|
return;
|
|
@@ -10712,7 +10712,7 @@ class So {
|
|
|
10712
10712
|
const t = this.getCommandContext().getState();
|
|
10713
10713
|
if (!t)
|
|
10714
10714
|
throw new V("Attempted to serialize state before it was initialized.");
|
|
10715
|
-
const e =
|
|
10715
|
+
const e = ct(t.transaction), a = this.dehydrateState(e);
|
|
10716
10716
|
return JSON.stringify(a);
|
|
10717
10717
|
}
|
|
10718
10718
|
/**
|
|
@@ -10748,12 +10748,12 @@ class So {
|
|
|
10748
10748
|
this.stepElements = e(this.stepElements, t);
|
|
10749
10749
|
}
|
|
10750
10750
|
getInvalidCanvasRegions() {
|
|
10751
|
-
return this.workflow.steps.reduce((t, e) => (
|
|
10751
|
+
return this.workflow.steps.reduce((t, e) => (Et(e, this.stepSelections) || this.stepElements[e.stepName] && this.stepElements[e.stepName].forEach(
|
|
10752
10752
|
(a) => t.push(a)
|
|
10753
10753
|
), t), []);
|
|
10754
10754
|
}
|
|
10755
10755
|
getInvalidModelVariants() {
|
|
10756
|
-
return this.workflow.steps.reduce((t, e) => (e.type === v.Model && !
|
|
10756
|
+
return this.workflow.steps.reduce((t, e) => (e.type === v.Model && !Et(e, this.stepSelections) && t.push(e.stepName), t), []);
|
|
10757
10757
|
}
|
|
10758
10758
|
async stepElementsForIntroducedSilentSteps(t, e) {
|
|
10759
10759
|
const a = this.product;
|
|
@@ -10853,13 +10853,13 @@ class So {
|
|
|
10853
10853
|
...this.stepSelections,
|
|
10854
10854
|
[t]: { selectedVariants: e }
|
|
10855
10855
|
}, this.selectionCost = Object.values(this.stepSelections).reduce((C, E) => C + E.selectedVariants.map((P) => P.priceModifier || 0).reduce((P, B) => P + B, 0), 0), this.workflow.steps.forEach((C) => {
|
|
10856
|
-
|
|
10856
|
+
Et(C, this.stepSelections) || (this.stepInitialised[C.stepName] = !1, delete this.stepMetadata[C.stepName], delete this.stepSelections[C.stepName], delete this.storage[C.stepName]);
|
|
10857
10857
|
});
|
|
10858
|
-
const s = this.allScenes, o =
|
|
10858
|
+
const s = this.allScenes, o = St(s, i), l = St(s, this.stepSelections), c = o.map((C) => C.silentSteps).flat(), A = l.map((C) => C.silentSteps).flat().filter(
|
|
10859
10859
|
(C) => !c.some((E) => E.stepName === C.stepName)
|
|
10860
10860
|
);
|
|
10861
10861
|
c.forEach((C) => {
|
|
10862
|
-
|
|
10862
|
+
Et(C, this.stepSelections) || (this.stepInitialised[C.stepName] = !1);
|
|
10863
10863
|
});
|
|
10864
10864
|
const u = this.getInvalidCanvasRegions(), { stepElements: h, commands: m } = await this.stepElementsForIntroducedSilentSteps(A, !1);
|
|
10865
10865
|
this.stepElements = {
|
|
@@ -10887,7 +10887,7 @@ class So {
|
|
|
10887
10887
|
await this.onSelectionChange(), n && await n();
|
|
10888
10888
|
}
|
|
10889
10889
|
async ensureStepsAreLoaded() {
|
|
10890
|
-
const e =
|
|
10890
|
+
const e = St(this.allScenes, this.stepSelections).map((l) => l.renderableSteps), a = [], n = e.flat();
|
|
10891
10891
|
for (const l of n)
|
|
10892
10892
|
if (!this.stepInitialised[l.stepName])
|
|
10893
10893
|
switch (this.stepInitialised[l.stepName] = !0, l.type) {
|
|
@@ -10901,7 +10901,7 @@ class So {
|
|
|
10901
10901
|
);
|
|
10902
10902
|
break;
|
|
10903
10903
|
case v.Frame:
|
|
10904
|
-
a.push(
|
|
10904
|
+
a.push(vt.init(l, this, this.reloadedState));
|
|
10905
10905
|
break;
|
|
10906
10906
|
case v.Illustration:
|
|
10907
10907
|
a.push(
|
|
@@ -11937,12 +11937,12 @@ const No = async (r, t) => {
|
|
|
11937
11937
|
for (let W = 0; W < tt.selections.length; ++W) {
|
|
11938
11938
|
const q = tt.selections[W];
|
|
11939
11939
|
if (et && (!B || et.option && (et.option.variants || []).length > 1 && !et.data.hideSelectionInCart && !et.data.hideSelectionsInCart)) {
|
|
11940
|
-
const
|
|
11941
|
-
F[
|
|
11940
|
+
const yt = et.stepTitle;
|
|
11941
|
+
F[yt] ? F[yt].push({
|
|
11942
11942
|
id: q.id || "",
|
|
11943
11943
|
name: q.name,
|
|
11944
11944
|
priceModifier: q.priceModifier
|
|
11945
|
-
}) : F[
|
|
11945
|
+
}) : F[yt] = [
|
|
11946
11946
|
{
|
|
11947
11947
|
id: q.id || "",
|
|
11948
11948
|
name: q.name,
|
|
@@ -12300,7 +12300,7 @@ class Wo {
|
|
|
12300
12300
|
}
|
|
12301
12301
|
let i = 2048;
|
|
12302
12302
|
e && e <= 2048 && (i = e);
|
|
12303
|
-
const s =
|
|
12303
|
+
const s = ft(i, i), o = this.commandContext.getAllLayouts(), l = a.defaultPreviewPanelIndex || 0, c = a.panels[l], d = o.find((b) => b.layoutState?.layout.panelId === c?.name) || o[0], A = d.layoutState.layout.previewRegion ? {
|
|
12304
12304
|
x: d.layoutState.layout.previewRegion.left,
|
|
12305
12305
|
y: d.layoutState.layout.previewRegion.top,
|
|
12306
12306
|
width: d.layoutState.layout.previewRegion.width,
|
|
@@ -12323,7 +12323,7 @@ class Wo {
|
|
|
12323
12323
|
await (await ua.from(h, p, {
|
|
12324
12324
|
anonymousCrossOrigin: !0,
|
|
12325
12325
|
ignoreDimensions: !1,
|
|
12326
|
-
createCanvas:
|
|
12326
|
+
createCanvas: ft,
|
|
12327
12327
|
createImage: te,
|
|
12328
12328
|
DOMParser: pa(),
|
|
12329
12329
|
fetch
|
|
@@ -12346,7 +12346,7 @@ class Wo {
|
|
|
12346
12346
|
getStepsConditionallyActive() {
|
|
12347
12347
|
return this.getScenes().flatMap(
|
|
12348
12348
|
(t) => this.getStepsByScene(t).filter(
|
|
12349
|
-
(e) =>
|
|
12349
|
+
(e) => Et(e.getRaw(), this.getWorkflowManager().getStepSelections())
|
|
12350
12350
|
)
|
|
12351
12351
|
);
|
|
12352
12352
|
}
|
|
@@ -12497,7 +12497,7 @@ class Wo {
|
|
|
12497
12497
|
return await _e.addDesign(n), n;
|
|
12498
12498
|
}
|
|
12499
12499
|
async copy() {
|
|
12500
|
-
const t =
|
|
12500
|
+
const t = ct(this.getCommandContext().getState());
|
|
12501
12501
|
if (!t) throw new V("Internal state is undefined! Cannot copy experience!");
|
|
12502
12502
|
const e = JSON.stringify(t.transaction), a = this.getWorkflowManager().getWorkflow(), n = this.getWorkflowManager().getTransaction().integrationProduct?.id;
|
|
12503
12503
|
if (!n) throw new V("Integration product id is undefined!");
|
|
@@ -12779,7 +12779,7 @@ const qo = (r) => {
|
|
|
12779
12779
|
const o = s.asset?.fileLink;
|
|
12780
12780
|
if (!o)
|
|
12781
12781
|
return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`), [];
|
|
12782
|
-
const l = await nt(o, !0), c = /<svg.*?<\/svg>/s, d = l.match(c) || [], A = d?.length > 0 ? d[0] : "", m =
|
|
12782
|
+
const l = await nt(o, !0), c = /<svg.*?<\/svg>/s, d = l.match(c) || [], A = d?.length > 0 ? d[0] : "", m = At().parseFromString(A, "image/svg+xml").firstElementChild;
|
|
12783
12783
|
if (!m)
|
|
12784
12784
|
return console.error("Failed to read SVG."), [];
|
|
12785
12785
|
fa(m);
|
|
@@ -12993,7 +12993,7 @@ const qo = (r) => {
|
|
|
12993
12993
|
}
|
|
12994
12994
|
else {
|
|
12995
12995
|
const c = await nt(i, !0), d = (A) => {
|
|
12996
|
-
const u = /<svg.*?<\/svg>/s, h = A.match(u) || [], m = h?.length > 0 ? h[0] : "", f =
|
|
12996
|
+
const u = /<svg.*?<\/svg>/s, h = A.match(u) || [], m = h?.length > 0 ? h[0] : "", f = At().parseFromString(m, "image/svg+xml").firstElementChild;
|
|
12997
12997
|
if (!f)
|
|
12998
12998
|
throw new Dt("Failed to read SVG.");
|
|
12999
12999
|
return fa(f), It().serializeToString(f);
|
|
@@ -13207,7 +13207,7 @@ class rl {
|
|
|
13207
13207
|
}
|
|
13208
13208
|
const il = () => new Promise((r, t) => {
|
|
13209
13209
|
try {
|
|
13210
|
-
const a =
|
|
13210
|
+
const a = ft().getContext("webgl2");
|
|
13211
13211
|
r(!!a);
|
|
13212
13212
|
} catch {
|
|
13213
13213
|
r(!1);
|
|
@@ -13261,7 +13261,7 @@ class ol {
|
|
|
13261
13261
|
* Actions to perform when a static render event is fired for this canvas.
|
|
13262
13262
|
*/
|
|
13263
13263
|
async render(t) {
|
|
13264
|
-
const e =
|
|
13264
|
+
const e = ct(t);
|
|
13265
13265
|
this.lastRequestedRenderArguments = e;
|
|
13266
13266
|
const a = this.getStaticContext();
|
|
13267
13267
|
if (!a) {
|
|
@@ -13344,7 +13344,7 @@ class ll extends xn {
|
|
|
13344
13344
|
ignoreClear: !0,
|
|
13345
13345
|
ignoreMouse: !0,
|
|
13346
13346
|
enableRedraw: !1,
|
|
13347
|
-
createCanvas:
|
|
13347
|
+
createCanvas: ft,
|
|
13348
13348
|
createImage: te,
|
|
13349
13349
|
DOMParser: pa(),
|
|
13350
13350
|
fetch
|
|
@@ -13519,7 +13519,7 @@ class dl extends Ia {
|
|
|
13519
13519
|
svg: s.svg,
|
|
13520
13520
|
colors: s.colors
|
|
13521
13521
|
};
|
|
13522
|
-
|
|
13522
|
+
ht.set(t?.fileLink, l), this.imageData = l;
|
|
13523
13523
|
} else
|
|
13524
13524
|
this.imageData = void 0;
|
|
13525
13525
|
}
|
|
@@ -13918,7 +13918,7 @@ class ml {
|
|
|
13918
13918
|
}
|
|
13919
13919
|
async setGlobalPropertyState(t) {
|
|
13920
13920
|
this.globalPropertyState || await this.initPromise;
|
|
13921
|
-
const e =
|
|
13921
|
+
const e = ct(this.globalPropertyState);
|
|
13922
13922
|
this.globalPropertyState = { ...t, id: e.id }, this.recalculateMandatoryStates(), await this.updateGlobalPropertyState(), await this.onGlobalPropertyStateChange(e, this.globalPropertyState);
|
|
13923
13923
|
}
|
|
13924
13924
|
getAspectMandatoryFulfilled(t) {
|
|
@@ -13945,7 +13945,7 @@ class ml {
|
|
|
13945
13945
|
if (!i)
|
|
13946
13946
|
throw new Error(`Failed to find configuration aspect with name: ${t}`);
|
|
13947
13947
|
this.mandatoryFulfilledAspects.set(t, e !== "");
|
|
13948
|
-
const s =
|
|
13948
|
+
const s = ct(this.globalPropertyState), o = this.globalPropertyState.aspects.filter((l) => l.name === t);
|
|
13949
13949
|
if (o.length > 0)
|
|
13950
13950
|
if (n) {
|
|
13951
13951
|
const l = o.find((c) => c.channel === n);
|
|
@@ -13978,7 +13978,11 @@ class ml {
|
|
|
13978
13978
|
storage: a !== null ? a : void 0,
|
|
13979
13979
|
channel: n
|
|
13980
13980
|
});
|
|
13981
|
-
ye(s, this.globalPropertyState)
|
|
13981
|
+
if (ye(s, this.globalPropertyState)) {
|
|
13982
|
+
console.log("Is different", s, ct(this.globalPropertyState));
|
|
13983
|
+
return;
|
|
13984
|
+
}
|
|
13985
|
+
await this.updateGlobalPropertyState(), await this.onGlobalPropertyStateChange(s, this.globalPropertyState);
|
|
13982
13986
|
}
|
|
13983
13987
|
async setAspectStorage(t, e, a) {
|
|
13984
13988
|
if (!this.globalPropertyState)
|
|
@@ -13988,7 +13992,7 @@ class ml {
|
|
|
13988
13992
|
const n = this.configuration.aspects.find((o) => o.name === t);
|
|
13989
13993
|
if (!n)
|
|
13990
13994
|
throw new Error(`Failed to find configuration aspect with name: ${t}`);
|
|
13991
|
-
const i =
|
|
13995
|
+
const i = ct(this.globalPropertyState), s = this.globalPropertyState.aspects.filter((o) => o.name === t);
|
|
13992
13996
|
if (s.length > 0)
|
|
13993
13997
|
if (a) {
|
|
13994
13998
|
const o = s.find((l) => l.channel === a);
|
|
@@ -14005,7 +14009,11 @@ class ml {
|
|
|
14005
14009
|
storage: e !== null ? e : void 0,
|
|
14006
14010
|
channel: a
|
|
14007
14011
|
});
|
|
14008
|
-
ye(i, this.globalPropertyState)
|
|
14012
|
+
if (ye(i, this.globalPropertyState)) {
|
|
14013
|
+
console.log("Is different stor", i, ct(this.globalPropertyState));
|
|
14014
|
+
return;
|
|
14015
|
+
}
|
|
14016
|
+
await this.updateGlobalPropertyState(), await this.onGlobalPropertyStateChange(i, this.globalPropertyState);
|
|
14009
14017
|
}
|
|
14010
14018
|
async updateGlobalPropertyState() {
|
|
14011
14019
|
if (!this.globalPropertyState)
|
|
@@ -14390,7 +14398,7 @@ class nr {
|
|
|
14390
14398
|
if (h || g.partial && (!g.data.productCollections || g.data.productCollections.length === 0 || !g.data.productCollections[0].productCollectionProductsFeed?.items || g.data.productCollections[0].productCollectionProductsFeed?.items.length === 0))
|
|
14391
14399
|
return;
|
|
14392
14400
|
c.abort(), h = !0, m.unsubscribe();
|
|
14393
|
-
const p = g.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((f) => !!f.product).map((f) => new Ae(
|
|
14401
|
+
const p = g.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((f) => !!f.product).map((f) => new Ae(ct(f))) || [];
|
|
14394
14402
|
u({
|
|
14395
14403
|
items: p,
|
|
14396
14404
|
// Clone items because it could be cached data (immutable)
|
|
@@ -14462,11 +14470,11 @@ class Ae {
|
|
|
14462
14470
|
getDefaultWorkflow() {
|
|
14463
14471
|
const t = this.product.workflows;
|
|
14464
14472
|
if (t === void 0)
|
|
14465
|
-
throw new
|
|
14473
|
+
throw new mt(
|
|
14466
14474
|
"Called getDefaultWorkflow() before fetching collection products. Use collection.fetchProducts() first to ensure the data is available."
|
|
14467
14475
|
);
|
|
14468
14476
|
if (t.length === 0)
|
|
14469
|
-
throw new
|
|
14477
|
+
throw new mt(
|
|
14470
14478
|
"Called getDefaultWorkflow() but no workflows on requested product. Ensure at least 1 workflow is assigned to this product."
|
|
14471
14479
|
);
|
|
14472
14480
|
const e = this.productResource.workflowId;
|
|
@@ -14478,7 +14486,7 @@ class Ae {
|
|
|
14478
14486
|
return console.warn(
|
|
14479
14487
|
"Called getDefaultWorkflow() but no default was configured. There is only one workflow available so we will fall back to using this!"
|
|
14480
14488
|
), new qt(t[0]);
|
|
14481
|
-
throw new
|
|
14489
|
+
throw new mt(
|
|
14482
14490
|
"Called getDefaultWorkflow() but no default workflow is configured for the requested product. Multiple workflows exist so we can't assume!"
|
|
14483
14491
|
);
|
|
14484
14492
|
}
|
|
@@ -14487,7 +14495,7 @@ class Ae {
|
|
|
14487
14495
|
*/
|
|
14488
14496
|
getAllWorkflows() {
|
|
14489
14497
|
if ((this.product.workflows || []).length === 0)
|
|
14490
|
-
throw new
|
|
14498
|
+
throw new mt(
|
|
14491
14499
|
"No workflows on configured product. Ensure at least 1 workflow is assigned to this product."
|
|
14492
14500
|
);
|
|
14493
14501
|
return this.product.workflows.sort((e, a) => (e.index ?? 0) - (a.index ?? 0)).map((e) => new qt(e));
|
|
@@ -15970,12 +15978,12 @@ class pd {
|
|
|
15970
15978
|
mutation: bi
|
|
15971
15979
|
});
|
|
15972
15980
|
} catch (a) {
|
|
15973
|
-
throw console.error(a), new
|
|
15981
|
+
throw console.error(a), new mt("Critical - Unable to synchronize workflow state with server.");
|
|
15974
15982
|
}
|
|
15975
|
-
}, this.options = t, this.options.applicationKey && Vr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 32.2.4-beta.
|
|
15983
|
+
}, this.options = t, this.options.applicationKey && Vr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 32.2.4-beta.4afe3abf-22fb-564b-b8a7-84762f8e91f4"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
|
|
15976
15984
|
}
|
|
15977
15985
|
configure(t) {
|
|
15978
|
-
|
|
15986
|
+
pt.setHubUrl(t.hubUrl), pt.setServerUrl(t.serverUrl), pt.setServicesApiUrl(t.servicesApiUrl), this.marketplaceThemeInstallId = t.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = t.marketplaceThemeInstallConfigurationId, this.userPoolClientId = t.userPoolClientId, this.userPoolRegion = t.userPoolRegion, this.spiffRegion = t.spiffRegion, t.bearerAuthenticationToken && Gr(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Lt.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
|
|
15979
15987
|
}
|
|
15980
15988
|
/**
|
|
15981
15989
|
* @returns The asset manager allows for common operations related to assets
|
|
@@ -16430,7 +16438,7 @@ class pd {
|
|
|
16430
16438
|
*/
|
|
16431
16439
|
async getWorkflowExperiences(t, e) {
|
|
16432
16440
|
if (t.length === 0)
|
|
16433
|
-
throw new
|
|
16441
|
+
throw new mt("No options provided!");
|
|
16434
16442
|
const a = y.getShadowGraphqlClient(), n = async (C) => {
|
|
16435
16443
|
if (C.length === 0)
|
|
16436
16444
|
return [];
|
|
@@ -16444,7 +16452,7 @@ class pd {
|
|
|
16444
16452
|
}), B = P.data.transactions;
|
|
16445
16453
|
if (B.length !== C.length) {
|
|
16446
16454
|
const F = P.errors?.[0]?.message || "Unknown error";
|
|
16447
|
-
throw new
|
|
16455
|
+
throw new mt(`Not all transactions were found: ${F}`);
|
|
16448
16456
|
}
|
|
16449
16457
|
return !this.activeIntegration && B[0].integrationProduct?.integration && (this.activeIntegration = Promise.resolve(B[0].integrationProduct.integration)), B.map((F, Q) => ({
|
|
16450
16458
|
transaction: F,
|
|
@@ -16474,7 +16482,7 @@ class pd {
|
|
|
16474
16482
|
}), P = E.data?.transactionCreateMany;
|
|
16475
16483
|
if (!P || P.length === 0) {
|
|
16476
16484
|
const B = E.errors?.[0]?.message || "Unknown error";
|
|
16477
|
-
throw new
|
|
16485
|
+
throw new mt(`Failed to create transactions: ${B}`);
|
|
16478
16486
|
}
|
|
16479
16487
|
return P.map((B, F) => ({
|
|
16480
16488
|
transaction: B,
|
|
@@ -16511,10 +16519,10 @@ class pd {
|
|
|
16511
16519
|
};
|
|
16512
16520
|
if (T.type === "transaction" && E.workflowState) {
|
|
16513
16521
|
const q = JSON.parse(E.workflowState);
|
|
16514
|
-
W.layouts = Object.values(q.layouts || {}).map((
|
|
16522
|
+
W.layouts = Object.values(q.layouts || {}).map((yt) => yt.layout), await Ga(q), W.reloadedState = q;
|
|
16515
16523
|
} else if (!B && T.workflowState) {
|
|
16516
16524
|
const q = JSON.parse(T.workflowState);
|
|
16517
|
-
W.layouts = Object.values(q.layouts || {}).map((
|
|
16525
|
+
W.layouts = Object.values(q.layouts || {}).map((yt) => yt.layout), await Ga(q), W.reloadedState = q;
|
|
16518
16526
|
} else
|
|
16519
16527
|
W.layouts = Vl(
|
|
16520
16528
|
W.transaction,
|
|
@@ -17050,7 +17058,7 @@ class jl extends Z {
|
|
|
17050
17058
|
}
|
|
17051
17059
|
selectVariant(t) {
|
|
17052
17060
|
const e = this.manager.getRegionElements(this.step.stepName);
|
|
17053
|
-
return
|
|
17061
|
+
return vt.selectVariant(
|
|
17054
17062
|
this.step,
|
|
17055
17063
|
t.getResource(),
|
|
17056
17064
|
e,
|
|
@@ -17070,7 +17078,7 @@ class jl extends Z {
|
|
|
17070
17078
|
* @param [recalculateOffsets=true] Optional: Recalculates the offsets of the image inside the frame. Default: `true`.
|
|
17071
17079
|
*/
|
|
17072
17080
|
async selectImage(t, e = !0, a = !0) {
|
|
17073
|
-
if (await
|
|
17081
|
+
if (await vt.selectImage(this.step, t, this.manager, a), e) {
|
|
17074
17082
|
const n = this.manager.getStepStorage(this.step.stepName)?.framePatternData || {};
|
|
17075
17083
|
this.manager.updateStorage(this.step.stepName, {
|
|
17076
17084
|
framePatternData: {
|
|
@@ -17108,7 +17116,7 @@ class jl extends Z {
|
|
|
17108
17116
|
if (!e)
|
|
17109
17117
|
throw new Error("You must supply an image selection before attempting to remove the background.");
|
|
17110
17118
|
const a = await O.removeBackgroundFromAsset(e);
|
|
17111
|
-
t && await
|
|
17119
|
+
t && await vt.selectImage(this.step, a, this.manager, !1);
|
|
17112
17120
|
const n = this.manager.getStepStorage(this.step.stepName)?.framePatternData || {};
|
|
17113
17121
|
return this.manager.updateStorage(this.step.stepName, {
|
|
17114
17122
|
framePatternData: {
|
|
@@ -17119,7 +17127,7 @@ class jl extends Z {
|
|
|
17119
17127
|
}), a;
|
|
17120
17128
|
}
|
|
17121
17129
|
changeColors(t) {
|
|
17122
|
-
|
|
17130
|
+
vt.changeColors(this.step, this.manager, t);
|
|
17123
17131
|
}
|
|
17124
17132
|
getImageData() {
|
|
17125
17133
|
if (this.frameService)
|
|
@@ -17129,7 +17137,7 @@ class jl extends Z {
|
|
|
17129
17137
|
return this.step.data.colorOption;
|
|
17130
17138
|
}
|
|
17131
17139
|
getAvailableColors() {
|
|
17132
|
-
return this.step.data.colorPickerEnabled ?
|
|
17140
|
+
return this.step.data.colorPickerEnabled ? vt.availableColors(this.step, this.manager) : Promise.resolve([]);
|
|
17133
17141
|
}
|
|
17134
17142
|
isColorPickerEnabled() {
|
|
17135
17143
|
return this.step.data.colorPickerEnabled ?? !1;
|
|
@@ -17142,7 +17150,7 @@ class jl extends Z {
|
|
|
17142
17150
|
return this.step.data.maxColors;
|
|
17143
17151
|
}
|
|
17144
17152
|
getUniqueColorCount() {
|
|
17145
|
-
return
|
|
17153
|
+
return vt.getUniqueColorCount(this.step, this.manager);
|
|
17146
17154
|
}
|
|
17147
17155
|
getCurrentFrameStep(t, e, a, n) {
|
|
17148
17156
|
return n && n.length > 1 && t === void 0 ? "SelectFrame" : e || a || this.getImageData() ? "Position" : "SelectImage";
|
|
@@ -17757,7 +17765,7 @@ export {
|
|
|
17757
17765
|
_e as designService,
|
|
17758
17766
|
fe as determineCorrectFontSizeAndLines,
|
|
17759
17767
|
qn as digitalContentStepService,
|
|
17760
|
-
|
|
17768
|
+
At as domParser,
|
|
17761
17769
|
bd as duplicateBundle,
|
|
17762
17770
|
Bd as duplicateTransaction,
|
|
17763
17771
|
nt as fetchAsString,
|
|
@@ -17765,7 +17773,7 @@ export {
|
|
|
17765
17773
|
$ as findElement,
|
|
17766
17774
|
Lc as findPmsColors,
|
|
17767
17775
|
Vt as frameDataCache,
|
|
17768
|
-
|
|
17776
|
+
vt as frameStepService,
|
|
17769
17777
|
M as generate,
|
|
17770
17778
|
nl as generateCommands,
|
|
17771
17779
|
ot as generateSVGWithUnknownColors,
|
|
@@ -17815,7 +17823,7 @@ export {
|
|
|
17815
17823
|
H as optionService,
|
|
17816
17824
|
Zc as outlineFontsInSvg,
|
|
17817
17825
|
Od as overrideWorkflowExperienceRecipientAddress,
|
|
17818
|
-
|
|
17826
|
+
ht as patternImageDataCache,
|
|
17819
17827
|
k as persistenceService,
|
|
17820
17828
|
Jn as pictureStepService,
|
|
17821
17829
|
$c as pmsToRgb,
|
|
@@ -17830,7 +17838,7 @@ export {
|
|
|
17830
17838
|
Cn as setCanvasModule,
|
|
17831
17839
|
zt as shapeStepService,
|
|
17832
17840
|
ys as shortenUrl,
|
|
17833
|
-
|
|
17841
|
+
pt as spiffCoreConfiguration,
|
|
17834
17842
|
dd as stepAspectValuesToDesignInputSteps,
|
|
17835
17843
|
$a as svgColorValueToDefinition,
|
|
17836
17844
|
Vn as svgStringDimensions,
|