@spiffcommerce/core 17.4.0 → 17.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -0
- package/dist/index.js +108 -87
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1428,6 +1428,13 @@ interface WorkflowExperience {
|
|
|
1428
1428
|
* A convenience function returning the sum of the selection and base price values.
|
|
1429
1429
|
*/
|
|
1430
1430
|
getTotalPriceSubunits(): number;
|
|
1431
|
+
/**
|
|
1432
|
+
* Takes selections made by the user in another workflow and applies them to this workflow. For
|
|
1433
|
+
* selections to be copied they must both have a matching global property configuration.
|
|
1434
|
+
* @param experience The experience to take selections from.
|
|
1435
|
+
* @param filter A list of steps to apply the selections to. If undefined all steps will be updated.
|
|
1436
|
+
*/
|
|
1437
|
+
copySelections(experience: WorkflowExperience, filter?: StepHandle<AnyStepData>[]): any;
|
|
1431
1438
|
/**
|
|
1432
1439
|
* Attach specific details about the customer to the experience. This is useful for things like retargeting. Currently only
|
|
1433
1440
|
* email is supported. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.
|
|
@@ -1504,6 +1511,7 @@ declare class WorkflowExperienceImpl implements WorkflowExperience {
|
|
|
1504
1511
|
getSelectionPriceSubunits(): number;
|
|
1505
1512
|
getBasePriceSubunits(): number;
|
|
1506
1513
|
getTotalPriceSubunits(): number;
|
|
1514
|
+
copySelections(experience: WorkflowExperience, filter?: StepHandle<AnyStepData>[]): void;
|
|
1507
1515
|
getStepByName(name: string): TextStepHandle | FrameStepHandle | ShapeStepHandle | InformationStepHandle | IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | undefined;
|
|
1508
1516
|
getStepsByType(type: StepType): StepHandle<AnyStepData>[];
|
|
1509
1517
|
getStepsByScene(scene: Scene): StepHandle<AnyStepData>[];
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createHttpLink as ct, InMemoryCache as gt, ApolloClient as lt, from as Bt, gql as y } from "@apollo/client/core";
|
|
2
|
-
import { fetch as qA, getAttributesFromArrayBuffer as pe, AssetType as re, StepType as f, getFrameData as ZA, frameDataCache as wt, GroupCommand as R, UpdateFramePattern as De, UpdateFrameThresholdSettingsCommand as dt, calculateOffsets as $A, LayoutElementType as U, generate as k, CreateElementCommand as b, generateSVGWithUnknownColors as fe, svgObjectURL as pA, fetchAsString as q, DeleteElementCommand as Z, generateDefaultRectangleFrameSvg as ce, GetSVGDimensions as Et, patternImageDataCache as ge, fetchAsArrayBuffer as ht, findElement as DA, modifySVGWithElementProperties as Ct, IllustrationColorCommand as TA, IllustrationCacheCommand as Qt, getFontMetrics as ut, getPatternImageData as zA, FontAlignmentCommand as mt, FontColorCommand as It, FontImageFillCommand as kA, applyTextTransformations as KA, determineCorrectFontSizeAndLines as uA, FontSourceCommand as le, loadFont as _A, TextChangeCommand as pt, FontSizeCommand as Dt, createElementNS as ft, createElement as gA, _loadFontExternalDataURL as Ae, UpdateWorkflowStateCommand as Be, CommandContext as Ft, createCanvas as fA, getSvgElement as Fe, LayoutRenderingPurpose as Me, renderPapyrusComponentAsString as ye, loadImage as Ye, getDomParser as Se, toBase64 as we, getVariant as Mt, generateFrameSVG as yt, getDefaultVariant as
|
|
3
|
-
import { AssetType as Ns, BringForwardCommand as
|
|
2
|
+
import { fetch as qA, getAttributesFromArrayBuffer as pe, AssetType as re, StepType as f, getFrameData as ZA, frameDataCache as wt, GroupCommand as R, UpdateFramePattern as De, UpdateFrameThresholdSettingsCommand as dt, calculateOffsets as $A, LayoutElementType as U, generate as k, CreateElementCommand as b, generateSVGWithUnknownColors as fe, svgObjectURL as pA, fetchAsString as q, DeleteElementCommand as Z, generateDefaultRectangleFrameSvg as ce, GetSVGDimensions as Et, patternImageDataCache as ge, fetchAsArrayBuffer as ht, findElement as DA, modifySVGWithElementProperties as Ct, IllustrationColorCommand as TA, IllustrationCacheCommand as Qt, getFontMetrics as ut, getPatternImageData as zA, FontAlignmentCommand as mt, FontColorCommand as It, FontImageFillCommand as kA, applyTextTransformations as KA, determineCorrectFontSizeAndLines as uA, FontSourceCommand as le, loadFont as _A, TextChangeCommand as pt, FontSizeCommand as Dt, createElementNS as ft, createElement as gA, _loadFontExternalDataURL as Ae, UpdateWorkflowStateCommand as Be, CommandContext as Ft, createCanvas as fA, getSvgElement as Fe, LayoutRenderingPurpose as Me, renderPapyrusComponentAsString as ye, loadImage as Ye, getDomParser as Se, toBase64 as we, getVariant as Mt, generateFrameSVG as yt, getDefaultVariant as PA, domParser as xe, sanitizeSvgTree as Ne, traverse as Yt, xmlSerializer as Pe, CreateLayoutCommand as St, AspectType as mA, rehydrateSerializedLayout as _ } from "@spiffcommerce/papyrus";
|
|
3
|
+
import { AssetType as Ns, BringForwardCommand as Ps, BringToBackCommand as Hs, BringToFrontCommand as Rs, CanvasCommand as Us, CommandContext as Gs, CreateElementCommand as vs, CreateLayoutCommand as ks, DeleteElementCommand as Js, FontAlignmentCommand as bs, FontColorCommand as Ls, FontSizeCommand as Os, FontSourceCommand as Ts, GroupCommand as zs, LayoutElementFactory as Ks, LayoutElementType as js, MoveCommand as Vs, ResizeCommand as Ws, RotateCommand as Xs, SendBackwardsCommand as qs, StepAspectType as Zs, StepType as $s, TextChangeCommand as _s, UnitOfMeasurement as Ai, dataUrlFromExternalUrl as ei, determineCorrectFontSizeAndLines as ti, findElement as ai, frameDataCache as ni, generate as si, generateSVGWithUnknownColors as ii, getAttributesFromArrayBuffer as oi, getAxisAlignedBoundingBox as ri, getFrameData as ci, getSvgElement as gi, loadFont as li, patternImageDataCache as Bi, registerFetchImplementation as wi, registerWindowImplementation as di, rehydrateSerializedLayout as Ei, setCanvasModule as hi } from "@spiffcommerce/papyrus";
|
|
4
4
|
import { setContext as xt } from "@apollo/client/link/context";
|
|
5
5
|
import { onError as Nt } from "@apollo/client/link/error";
|
|
6
|
-
import { Pith as
|
|
6
|
+
import { Pith as He } from "pith";
|
|
7
7
|
import Re from "lodash.debounce";
|
|
8
8
|
import Ue from "lodash.isequal";
|
|
9
|
-
import
|
|
9
|
+
import HA from "lodash.clonedeep";
|
|
10
10
|
import { toString as Ge } from "qrcode";
|
|
11
11
|
import { split as jA } from "unicode-default-word-boundary";
|
|
12
12
|
import ee from "svg-path-bbox";
|
|
@@ -60,7 +60,7 @@ class sA extends RA {
|
|
|
60
60
|
super(`Parsing Error: ${A}`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class H extends RA {
|
|
64
64
|
constructor(A) {
|
|
65
65
|
super(`Client Error: ${A}`);
|
|
66
66
|
}
|
|
@@ -70,7 +70,7 @@ class UA extends RA {
|
|
|
70
70
|
super(`Resource Generation Failed: ${A}`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
class
|
|
73
|
+
class Pt {
|
|
74
74
|
get(A) {
|
|
75
75
|
return localStorage.getItem(A) || void 0;
|
|
76
76
|
}
|
|
@@ -113,13 +113,13 @@ class de {
|
|
|
113
113
|
this.set(A, t);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const Ht = () => {
|
|
117
117
|
try {
|
|
118
|
-
return localStorage ? new
|
|
118
|
+
return localStorage ? new Pt() : new de();
|
|
119
119
|
} catch {
|
|
120
120
|
return console.warn("Local storage was unavilable due to browser security settings. Using in-memory storage instead."), new de();
|
|
121
121
|
}
|
|
122
|
-
}, x =
|
|
122
|
+
}, x = Ht();
|
|
123
123
|
class Rt {
|
|
124
124
|
constructor() {
|
|
125
125
|
this.defaultServerUrl = "https://api.spiff.com.au", this.defaultServicesApiUrl = "https://services.spiff.com.au", this.defaultHubUrl = "https://hub.spiff.com.au", this.serverUrl = this.defaultServerUrl, this.servicesApiUrl = this.defaultServicesApiUrl, this.hubUrl = this.defaultHubUrl, this.serverUrlCallbacks = [];
|
|
@@ -4492,27 +4492,27 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
4492
4492
|
</g>
|
|
4493
4493
|
</svg>
|
|
4494
4494
|
|
|
4495
|
-
`,
|
|
4496
|
-
const e =
|
|
4495
|
+
`, P = (c) => ft("http://www.w3.org/2000/svg", c), ne = (c, A) => {
|
|
4496
|
+
const e = P("rect");
|
|
4497
4497
|
return e.setAttribute("height", `${c}`), e.setAttribute("width", `${A}`), e;
|
|
4498
4498
|
}, xa = () => {
|
|
4499
|
-
const c =
|
|
4499
|
+
const c = P("svg");
|
|
4500
4500
|
return c.setAttribute("xmlns", "http://www.w3.org/2000/svg"), c.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), c.setAttribute("version", "1.1"), c;
|
|
4501
4501
|
}, Na = (c) => {
|
|
4502
|
-
const A =
|
|
4502
|
+
const A = P("use");
|
|
4503
4503
|
return A.setAttribute("xlink:href", c), A.setAttribute("href", c), A;
|
|
4504
4504
|
};
|
|
4505
4505
|
function qe(c) {
|
|
4506
4506
|
const A = xa(), e = /viewBox="0 0 (.+?) (.+?)"/.exec(c) || ["0", "0"], t = parseFloat(e[1]), a = parseFloat(e[2]);
|
|
4507
4507
|
return A.setAttribute("height", `${a}`), A.setAttribute("width", `${t}`), [A, a, t];
|
|
4508
4508
|
}
|
|
4509
|
-
const
|
|
4510
|
-
const t =
|
|
4509
|
+
const Pa = (c, A, e) => {
|
|
4510
|
+
const t = P("g");
|
|
4511
4511
|
c.appendChild(t), t.setAttribute("id", e), t.innerHTML = A;
|
|
4512
4512
|
};
|
|
4513
4513
|
function Ze(c, A, e) {
|
|
4514
4514
|
const t = k();
|
|
4515
|
-
|
|
4515
|
+
Pa(A, e, `bgdef-${t}`), c.appendChild(Na(`#bgdef-${t}`));
|
|
4516
4516
|
}
|
|
4517
4517
|
const $e = (c, A, e, t) => {
|
|
4518
4518
|
const a = gA("filter");
|
|
@@ -4536,10 +4536,10 @@ function se(c, A, e, t, a, n) {
|
|
|
4536
4536
|
};
|
|
4537
4537
|
if (o.width <= 0)
|
|
4538
4538
|
return;
|
|
4539
|
-
const r =
|
|
4539
|
+
const r = Ha(o.height, o.width, e * s, t * i), g = (t - r * o.width) / 2 - r * o.x, B = (e - r * o.height) / 2 - r * o.y;
|
|
4540
4540
|
c.setAttribute("transform", `translate(${g} ${B}) scale(${r} ${r})`);
|
|
4541
4541
|
}
|
|
4542
|
-
function
|
|
4542
|
+
function Ha(c, A, e, t) {
|
|
4543
4543
|
const a = e / c, n = t / A;
|
|
4544
4544
|
return a > 1 && n > 1 ? Math.min(a, n) : a > 1 && n < 1 ? n : a < 1 && n > 1 ? a : Math.min(a, n);
|
|
4545
4545
|
}
|
|
@@ -4669,26 +4669,26 @@ class Ra extends ae {
|
|
|
4669
4669
|
}
|
|
4670
4670
|
brandSvg(A, e) {
|
|
4671
4671
|
const t = A.toSVG(2), a = A.getBoundingBox(), n = a.x2 - a.x1, s = A.toPathData(3), i = () => {
|
|
4672
|
-
const D =
|
|
4672
|
+
const D = P("g"), p = P("defs");
|
|
4673
4673
|
D.appendChild(p), p.appendChild($e(3, 7, 4, "shadow"));
|
|
4674
|
-
const m =
|
|
4674
|
+
const m = P("g");
|
|
4675
4675
|
D.appendChild(m), m.setAttribute("filter", "url(#shadow)"), m.innerHTML = t;
|
|
4676
|
-
const F =
|
|
4676
|
+
const F = P("g");
|
|
4677
4677
|
D.appendChild(F), F.setAttribute("fill", "red"), F.setAttribute("stroke", "red"), F.setAttribute("stroke-width", "9"), F.innerHTML = t;
|
|
4678
|
-
const Y =
|
|
4678
|
+
const Y = P("g");
|
|
4679
4679
|
D.appendChild(Y), Y.setAttribute("fill", "#9d2621"), Y.setAttribute("transform", "translate(1,1)"), Y.innerHTML = t;
|
|
4680
|
-
const M =
|
|
4680
|
+
const M = P("g");
|
|
4681
4681
|
return D.appendChild(M), M.setAttribute("fill", "yellow"), M.innerHTML = t, new ie(D).transform(([S, J]) => [S, J + (n / 2 - S) ** 2 / (n * 2.9)]), D;
|
|
4682
4682
|
}, [o, r, g] = qe(e);
|
|
4683
4683
|
if (!o)
|
|
4684
4684
|
return "";
|
|
4685
|
-
const B =
|
|
4685
|
+
const B = P("defs");
|
|
4686
4686
|
o.appendChild(B), Ze(o, B, e);
|
|
4687
|
-
const l = r * 0.23, w = g * 0.94, d = g * 0.04, C = r * 0.53, E =
|
|
4687
|
+
const l = r * 0.23, w = g * 0.94, d = g * 0.04, C = r * 0.53, E = P("g");
|
|
4688
4688
|
o.appendChild(E), E.setAttribute("transform", `translate(${d} ${C}) rotate(-21)`);
|
|
4689
4689
|
const Q = ne(l, w);
|
|
4690
4690
|
Q.setAttribute("opacity", "0"), E.appendChild(Q);
|
|
4691
|
-
const h =
|
|
4691
|
+
const h = P("g");
|
|
4692
4692
|
E.appendChild(h);
|
|
4693
4693
|
const I = i();
|
|
4694
4694
|
h.appendChild(I);
|
|
@@ -4713,11 +4713,11 @@ class Ga extends ae {
|
|
|
4713
4713
|
}
|
|
4714
4714
|
brandSvg(A, e, t) {
|
|
4715
4715
|
const a = A.toSVG(2), n = A.getBoundingBox(), s = n.y2 - n.y1, i = n.x2 - n.x1, o = A.toPathData(3), r = () => {
|
|
4716
|
-
const m =
|
|
4716
|
+
const m = P("g"), F = P("g");
|
|
4717
4717
|
m.appendChild(F), F.setAttribute("stroke", "#5C1A0D"), F.setAttribute("stroke-width", "4"), F.setAttribute("transform", "translate(1,1)"), F.innerHTML = a;
|
|
4718
|
-
const Y =
|
|
4718
|
+
const Y = P("g");
|
|
4719
4719
|
m.appendChild(Y), Y.setAttribute("fill", "#FFE386"), Y.setAttribute("transform", "translate(1,1)"), Y.innerHTML = a;
|
|
4720
|
-
const M =
|
|
4720
|
+
const M = P("g");
|
|
4721
4721
|
m.appendChild(M), M.setAttribute("fill", "white"), M.innerHTML = a;
|
|
4722
4722
|
const G = new ie(m);
|
|
4723
4723
|
return G.transform(([S, J]) => [S, J + ((i - S) * J) ** 2 / (i * 5e4)]), G.transform(([S, J]) => [
|
|
@@ -4727,15 +4727,15 @@ class Ga extends ae {
|
|
|
4727
4727
|
}, [g, B, l] = qe(e);
|
|
4728
4728
|
if (!g)
|
|
4729
4729
|
return "";
|
|
4730
|
-
const w =
|
|
4730
|
+
const w = P("defs");
|
|
4731
4731
|
g.appendChild(w), Ze(g, w, e);
|
|
4732
4732
|
let d, C, E, Q;
|
|
4733
4733
|
t ? (d = B * 0.25 * (1 + 0.1), C = l / 2 * (1 + 0.1), E = l * 0.22, Q = B * 0.32) : (d = B * 0.22 * (1 + 0.1), C = l * 0.8, E = l * 0.067, Q = B * 0.33);
|
|
4734
|
-
const h =
|
|
4734
|
+
const h = P("g");
|
|
4735
4735
|
g.appendChild(h), h.setAttribute("transform", `translate(${E} ${Q}) rotate(-10)`);
|
|
4736
4736
|
const I = ne(d, C);
|
|
4737
4737
|
I.setAttribute("opacity", "0"), h.appendChild(I);
|
|
4738
|
-
const u =
|
|
4738
|
+
const u = P("g");
|
|
4739
4739
|
h.appendChild(u);
|
|
4740
4740
|
const D = r();
|
|
4741
4741
|
u.appendChild(D);
|
|
@@ -4757,29 +4757,29 @@ class ka extends ae {
|
|
|
4757
4757
|
}
|
|
4758
4758
|
svgElement(A, e) {
|
|
4759
4759
|
const t = Ae(va), n = A !== "" ? ((I) => I.charAt(0).toUpperCase() + I.substr(1).toLowerCase())(A) : "", s = t.getPath(n, 0, 72, 72), i = s.toSVG(2), o = s.getBoundingBox(), r = o.x2 - o.x1, g = s.toPathData(3), B = () => {
|
|
4760
|
-
const I =
|
|
4760
|
+
const I = P("g");
|
|
4761
4761
|
I.classList.add("module-text-group");
|
|
4762
|
-
const u =
|
|
4762
|
+
const u = P("defs");
|
|
4763
4763
|
I.appendChild(u), u.appendChild($e(0, 2, 2, "shadow"));
|
|
4764
|
-
const D =
|
|
4764
|
+
const D = P("path");
|
|
4765
4765
|
D.setAttribute("d", g), D.setAttribute("stroke", "black"), D.setAttribute("stroke-width", "3"), u.appendChild(D);
|
|
4766
|
-
const p =
|
|
4766
|
+
const p = P("g");
|
|
4767
4767
|
p.classList.add("module-layer0"), I.appendChild(p), p.setAttribute("filter", "url(#shadow)"), p.innerHTML = D.outerHTML;
|
|
4768
|
-
const m =
|
|
4768
|
+
const m = P("g");
|
|
4769
4769
|
m.classList.add("module-layer1"), I.appendChild(m), m.setAttribute("stroke-width", "3"), m.setAttribute("stroke", "rgb(45,41,38)"), m.setAttribute("fill", "rgb(45,41,38)"), m.setAttribute("transform", "translate(0.5,0)"), m.innerHTML = i;
|
|
4770
|
-
const F =
|
|
4770
|
+
const F = P("g");
|
|
4771
4771
|
F.classList.add("module-layer2"), I.appendChild(F), F.setAttribute("fill", "rgb(255,209,0)"), F.setAttribute("transform", "translate(1,-0.1)"), F.innerHTML = i;
|
|
4772
|
-
const Y =
|
|
4772
|
+
const Y = P("g");
|
|
4773
4773
|
return Y.classList.add("module-layer3"), I.appendChild(Y), Y.setAttribute("fill", "white"), Y.innerHTML = i, new ie(I).transform(([G, S]) => [G, S + (r / 2 - G) ** 2 / (r * 6)]), I;
|
|
4774
|
-
}, l =
|
|
4774
|
+
}, l = P("g");
|
|
4775
4775
|
l.classList.add("module-root");
|
|
4776
|
-
const w =
|
|
4776
|
+
const w = P("defs");
|
|
4777
4777
|
l.appendChild(w);
|
|
4778
|
-
const d =
|
|
4778
|
+
const d = P("g");
|
|
4779
4779
|
d.classList.add("module-bounds"), l.appendChild(d);
|
|
4780
4780
|
const C = ne(e.height, e.width);
|
|
4781
4781
|
C.setAttribute("opacity", "0"), d.appendChild(C);
|
|
4782
|
-
const E =
|
|
4782
|
+
const E = P("g");
|
|
4783
4783
|
E.classList.add("module-text-enclosure"), l.appendChild(E);
|
|
4784
4784
|
const Q = B();
|
|
4785
4785
|
E.appendChild(Q);
|
|
@@ -5122,7 +5122,7 @@ class ba {
|
|
|
5122
5122
|
const A = this.getCommandContext().getState();
|
|
5123
5123
|
if (!A)
|
|
5124
5124
|
throw new v("Attempted to serialize state before it was initialized.");
|
|
5125
|
-
return { transaction: JSON.stringify(this.dehydrateState(
|
|
5125
|
+
return { transaction: JSON.stringify(this.dehydrateState(HA(A.transaction))) };
|
|
5126
5126
|
}
|
|
5127
5127
|
dehydrateState(A) {
|
|
5128
5128
|
for (const e of Object.values(A.layouts).map((t) => t.elements).flat())
|
|
@@ -6480,7 +6480,7 @@ class dA {
|
|
|
6480
6480
|
region: { left: B.x, top: B.y, width: B.width, height: B.height }
|
|
6481
6481
|
}
|
|
6482
6482
|
}), C = ye(d);
|
|
6483
|
-
await (await
|
|
6483
|
+
await (await He.from(w, C, {
|
|
6484
6484
|
anonymousCrossOrigin: !0,
|
|
6485
6485
|
ignoreDimensions: !1,
|
|
6486
6486
|
createCanvas: fA,
|
|
@@ -6519,6 +6519,27 @@ class dA {
|
|
|
6519
6519
|
getTotalPriceSubunits() {
|
|
6520
6520
|
return this.getBasePriceSubunits() + this.getSelectionPriceSubunits();
|
|
6521
6521
|
}
|
|
6522
|
+
copySelections(A, e) {
|
|
6523
|
+
const t = e == null ? void 0 : e.map((s) => s.getId()), a = this.getSteps().filter((s) => t === void 0 || t.includes(s.getId())), n = A.getSteps();
|
|
6524
|
+
a.forEach((s) => {
|
|
6525
|
+
const i = /* @__PURE__ */ new Set(), o = s.getRaw().globalPropertyAspectConfigurations;
|
|
6526
|
+
o !== void 0 && (o.forEach((r) => i.add(JSON.stringify(r))), n.forEach((r) => {
|
|
6527
|
+
const g = r.getRaw().globalPropertyAspectConfigurations;
|
|
6528
|
+
g !== void 0 && g.forEach((B) => {
|
|
6529
|
+
const l = i.has(JSON.stringify(B));
|
|
6530
|
+
if (l && B.aspectName === "Option") {
|
|
6531
|
+
const w = r.getCurrentVariant();
|
|
6532
|
+
if (!w)
|
|
6533
|
+
return;
|
|
6534
|
+
s.selectVariant(w), i.delete(JSON.stringify(B));
|
|
6535
|
+
} else if (l && B.aspectName === "Text") {
|
|
6536
|
+
const w = r.getText();
|
|
6537
|
+
s.setText(w), i.delete(JSON.stringify(B));
|
|
6538
|
+
}
|
|
6539
|
+
});
|
|
6540
|
+
}));
|
|
6541
|
+
});
|
|
6542
|
+
}
|
|
6522
6543
|
getStepByName(A) {
|
|
6523
6544
|
const e = this.getWorkflowManager().getWorkflow().steps.find((t) => t.stepTitle === A);
|
|
6524
6545
|
if (!(!e || !this.stepHasHandle(e)))
|
|
@@ -6592,7 +6613,7 @@ class dA {
|
|
|
6592
6613
|
}
|
|
6593
6614
|
async copy() {
|
|
6594
6615
|
var i;
|
|
6595
|
-
const A =
|
|
6616
|
+
const A = HA(this.getCommandContext().getState());
|
|
6596
6617
|
if (!A)
|
|
6597
6618
|
throw new v("Internal state is undefined! Cannot copy experience!");
|
|
6598
6619
|
const e = JSON.stringify(A.transaction), t = this.getWorkflowManager().getWorkflow(), a = new Bs({}), n = (i = this.getWorkflowManager().getTransaction().integrationProduct) == null ? void 0 : i.id;
|
|
@@ -6739,7 +6760,7 @@ const nn = [
|
|
|
6739
6760
|
const a = e.data, n = t.option;
|
|
6740
6761
|
if (!n)
|
|
6741
6762
|
return console.error(`No option for step ${t.stepName}.`), [];
|
|
6742
|
-
const s = ((D = n.variants) == null ? void 0 : D.find((m) => m.id === a.illustrationVariantId)) ||
|
|
6763
|
+
const s = ((D = n.variants) == null ? void 0 : D.find((m) => m.id === a.illustrationVariantId)) || PA(n);
|
|
6743
6764
|
if (!s)
|
|
6744
6765
|
return console.error(`No variant with ID: ${a.illustrationVariantId}`), [];
|
|
6745
6766
|
if (!s.asset)
|
|
@@ -6766,7 +6787,7 @@ const nn = [
|
|
|
6766
6787
|
m.classList.add(S), C[S] = { browserValue: M };
|
|
6767
6788
|
}
|
|
6768
6789
|
});
|
|
6769
|
-
const Q =
|
|
6790
|
+
const Q = Pe().serializeToString(d), h = a.colors;
|
|
6770
6791
|
if (h) {
|
|
6771
6792
|
for (const [m, F] of Object.entries(C))
|
|
6772
6793
|
for (const Y of Object.keys(h))
|
|
@@ -6838,7 +6859,7 @@ const nn = [
|
|
|
6838
6859
|
const a = e.data, n = t.option;
|
|
6839
6860
|
if (!n)
|
|
6840
6861
|
return console.error(`No option for step ${t.stepName}.`), [];
|
|
6841
|
-
const s = ((g = n.variants) == null ? void 0 : g.find((l) => l.id === a.pictureVariantId)) ||
|
|
6862
|
+
const s = ((g = n.variants) == null ? void 0 : g.find((l) => l.id === a.pictureVariantId)) || PA(n);
|
|
6842
6863
|
if (!s)
|
|
6843
6864
|
return console.error(`No variant with ID: ${a.pictureVariantId}`), [];
|
|
6844
6865
|
if (!s.asset)
|
|
@@ -6880,7 +6901,7 @@ const nn = [
|
|
|
6880
6901
|
const a = e.data, n = t.option;
|
|
6881
6902
|
if (!n)
|
|
6882
6903
|
return console.error(`No option for step ${t.stepName}.`), [];
|
|
6883
|
-
const s = ((r = n.variants) == null ? void 0 : r.find((g) => g.id === a.colorVariantId)) ||
|
|
6904
|
+
const s = ((r = n.variants) == null ? void 0 : r.find((g) => g.id === a.colorVariantId)) || PA(n);
|
|
6884
6905
|
if (!s)
|
|
6885
6906
|
return console.error(`No variant with ID: ${a.colorVariantId}`), [];
|
|
6886
6907
|
A[t.stepName] = { selectedVariants: [s] };
|
|
@@ -6970,7 +6991,7 @@ const nn = [
|
|
|
6970
6991
|
const l = /<svg.*?<\/svg>/s, w = B.match(l) || [], d = (w == null ? void 0 : w.length) > 0 ? w[0] : "", Q = xe().parseFromString(d, "image/svg+xml").firstElementChild;
|
|
6971
6992
|
if (!Q)
|
|
6972
6993
|
throw new sA("Failed to read SVG.");
|
|
6973
|
-
return Ne(Q),
|
|
6994
|
+
return Ne(Q), Pe().serializeToString(Q);
|
|
6974
6995
|
};
|
|
6975
6996
|
o.forEach((B) => {
|
|
6976
6997
|
const l = c.find((d) => d.panelId === B.panelId);
|
|
@@ -7005,7 +7026,7 @@ const nn = [
|
|
|
7005
7026
|
const E = t.option;
|
|
7006
7027
|
if (!E)
|
|
7007
7028
|
return;
|
|
7008
|
-
const Q = ((I = E.variants) == null ? void 0 : I.find((u) => u.id === n.fontVariantId)) ||
|
|
7029
|
+
const Q = ((I = E.variants) == null ? void 0 : I.find((u) => u.id === n.fontVariantId)) || PA(E);
|
|
7009
7030
|
if (!Q || !Q.asset)
|
|
7010
7031
|
return;
|
|
7011
7032
|
A[t.stepName] = { selectedVariants: [Q] };
|
|
@@ -7219,7 +7240,7 @@ class Cn {
|
|
|
7219
7240
|
* Actions to perform when a static render event is fired for this canvas.
|
|
7220
7241
|
*/
|
|
7221
7242
|
async render(A, e, t) {
|
|
7222
|
-
const a =
|
|
7243
|
+
const a = HA(e);
|
|
7223
7244
|
this.lastRequestedRenderArguments = {
|
|
7224
7245
|
workflow: A,
|
|
7225
7246
|
layouts: a,
|
|
@@ -7296,7 +7317,7 @@ class Qn extends Te {
|
|
|
7296
7317
|
i = this.getDynamicTextureResolution().width, o = this.getDynamicTextureResolution().height;
|
|
7297
7318
|
const r = Fe(A.layoutState.layout, e, {
|
|
7298
7319
|
renderingConfiguration: { purpose: Me.ThreeD }
|
|
7299
|
-
}), g = ye(r), B = await
|
|
7320
|
+
}), g = ye(r), B = await He.from(this.ctx, g, {
|
|
7300
7321
|
anonymousCrossOrigin: !0,
|
|
7301
7322
|
ignoreDimensions: !this.nonPOTSupport,
|
|
7302
7323
|
ignoreAnimation: !0,
|
|
@@ -7594,14 +7615,14 @@ const Ms = (c, A) => {
|
|
|
7594
7615
|
}
|
|
7595
7616
|
}
|
|
7596
7617
|
}
|
|
7597
|
-
`,
|
|
7618
|
+
`, Pn = y`
|
|
7598
7619
|
mutation BundleUpdateTransactionOrder($id: String!, $transactionIds: [String!]!) {
|
|
7599
7620
|
bundleUpdateTransactionOrder(id: $id, transactionIds: $transactionIds) {
|
|
7600
7621
|
id
|
|
7601
7622
|
}
|
|
7602
7623
|
}
|
|
7603
7624
|
`;
|
|
7604
|
-
class
|
|
7625
|
+
class Hn {
|
|
7605
7626
|
constructor(A) {
|
|
7606
7627
|
this.handleCache = {}, this.bundle = A;
|
|
7607
7628
|
}
|
|
@@ -7899,7 +7920,7 @@ class bn {
|
|
|
7899
7920
|
async setAspect(A, e) {
|
|
7900
7921
|
if (!this.globalPropertyState)
|
|
7901
7922
|
throw new Error("Global property state not initialized");
|
|
7902
|
-
const t =
|
|
7923
|
+
const t = HA(this.globalPropertyState), a = this.globalPropertyState.aspects.find((n) => n.name === A);
|
|
7903
7924
|
a ? a.value = e : this.globalPropertyState.aspects.push({ name: A, value: e }), await this.updateGlobalPropertyState(), await this.onGlobalPropertyStateChange(t, this.globalPropertyState);
|
|
7904
7925
|
}
|
|
7905
7926
|
async updateGlobalPropertyState() {
|
|
@@ -8095,7 +8116,7 @@ class Tn {
|
|
|
8095
8116
|
getDefaultWorkflow() {
|
|
8096
8117
|
const A = this.product.workflows || [];
|
|
8097
8118
|
if (A.length === 0)
|
|
8098
|
-
throw new
|
|
8119
|
+
throw new H(
|
|
8099
8120
|
"No workflows found on product. This is generally due to a configuration error. Please confirm at least one workflow is configured for this product."
|
|
8100
8121
|
);
|
|
8101
8122
|
const e = this.productResource.workflowId;
|
|
@@ -8201,7 +8222,7 @@ class Ie {
|
|
|
8201
8222
|
this.id,
|
|
8202
8223
|
this.ownerId,
|
|
8203
8224
|
this.checkConditionalHandlesChanged.bind(this)
|
|
8204
|
-
), this.globalPropertyHandleService = new
|
|
8225
|
+
), this.globalPropertyHandleService = new Hn(this), this.setPreviewService(t), this.initializationPromise = this.loadExistingBundles(
|
|
8205
8226
|
((o = e.transactions) == null ? void 0 : o.map((r) => r.id)) || [],
|
|
8206
8227
|
a
|
|
8207
8228
|
);
|
|
@@ -8575,7 +8596,7 @@ class Ie {
|
|
|
8575
8596
|
}
|
|
8576
8597
|
async updateTransactionOrder() {
|
|
8577
8598
|
await N.getShadowGraphqlClient().mutate({
|
|
8578
|
-
mutation:
|
|
8599
|
+
mutation: Pn,
|
|
8579
8600
|
variables: {
|
|
8580
8601
|
id: this.id,
|
|
8581
8602
|
transactionIds: this.workflowExperiences.map((A) => A.getWorkflowManager().getTransaction().id)
|
|
@@ -9475,7 +9496,7 @@ class Bs {
|
|
|
9475
9496
|
mutation: na
|
|
9476
9497
|
});
|
|
9477
9498
|
} catch (t) {
|
|
9478
|
-
throw console.error(t), new
|
|
9499
|
+
throw console.error(t), new H("Critical - Unable to synchronize workflow state with server.");
|
|
9479
9500
|
}
|
|
9480
9501
|
}, this.initialized = !1, this.options = A, this.options.applicationKey && Ut(this.options.applicationKey);
|
|
9481
9502
|
}
|
|
@@ -9799,13 +9820,13 @@ class Bs {
|
|
|
9799
9820
|
fetchPolicy: "no-cache"
|
|
9800
9821
|
});
|
|
9801
9822
|
if (!((Q = D.data) != null && Q.transactions) || D.data.transactions.length === 0)
|
|
9802
|
-
throw new
|
|
9823
|
+
throw new H("Existing transaction not found.");
|
|
9803
9824
|
const p = (h = D.data) == null ? void 0 : h.transactions[0];
|
|
9804
9825
|
if (!p.workflowId)
|
|
9805
|
-
throw new
|
|
9826
|
+
throw new H("Existing transaction has no workflow ID.");
|
|
9806
9827
|
const m = await QA(p.workflowId);
|
|
9807
9828
|
if (!p.product)
|
|
9808
|
-
throw new
|
|
9829
|
+
throw new H("Failed to load transaction, product not available.");
|
|
9809
9830
|
return { transaction: p, workflow: m, readOnly: u };
|
|
9810
9831
|
}
|
|
9811
9832
|
if (a.type === "integration" || a.type === "external") {
|
|
@@ -9826,15 +9847,15 @@ class Bs {
|
|
|
9826
9847
|
context: this.options.applicationKey ? { headers: { "X-Application-Key": this.options.applicationKey } } : void 0
|
|
9827
9848
|
});
|
|
9828
9849
|
if (!F.data || !F.data.transactionCreate)
|
|
9829
|
-
throw new
|
|
9850
|
+
throw new H("Failed to create transaction!");
|
|
9830
9851
|
const Y = F.data.transactionCreate;
|
|
9831
9852
|
if (!Y.product)
|
|
9832
|
-
throw new
|
|
9853
|
+
throw new H("Failed to create transaction, product not available.");
|
|
9833
9854
|
return Y;
|
|
9834
9855
|
}, u = QA(a.workflowId, a == null ? void 0 : a.graphql), [D, p] = await Promise.all([I(), u]);
|
|
9835
9856
|
return { transaction: D, workflow: p };
|
|
9836
9857
|
}
|
|
9837
|
-
throw new
|
|
9858
|
+
throw new H("No workflow ID provided.");
|
|
9838
9859
|
}, { transaction: s, workflow: i, readOnly: o } = await n();
|
|
9839
9860
|
this.currencyCode = (B = s.product.partner) == null ? void 0 : B.currencyCode;
|
|
9840
9861
|
const r = {
|
|
@@ -9888,7 +9909,7 @@ class Bs {
|
|
|
9888
9909
|
*/
|
|
9889
9910
|
async getWorkflowExperiences(A, e) {
|
|
9890
9911
|
if (A.length === 0)
|
|
9891
|
-
throw new
|
|
9912
|
+
throw new H("No options provided!");
|
|
9892
9913
|
const t = N.getShadowGraphqlClient(), a = A.map((h, I) => ({ option: h, index: I })), n = a.filter((h) => h.option.type === "transaction"), s = a.filter(
|
|
9893
9914
|
(h) => h.option.type === "integration" || h.option.type === "external"
|
|
9894
9915
|
), i = async () => {
|
|
@@ -9905,7 +9926,7 @@ class Bs {
|
|
|
9905
9926
|
}), u = I.data.transactions;
|
|
9906
9927
|
if (u.length !== n.length) {
|
|
9907
9928
|
const m = ((p = (D = I.errors) == null ? void 0 : D[0]) == null ? void 0 : p.message) || "Unknown error";
|
|
9908
|
-
throw new
|
|
9929
|
+
throw new H(`Not all transactions were found: ${m}`);
|
|
9909
9930
|
}
|
|
9910
9931
|
return u.map((m, F) => {
|
|
9911
9932
|
var Y;
|
|
@@ -9936,7 +9957,7 @@ class Bs {
|
|
|
9936
9957
|
}), I = (u = h.data) == null ? void 0 : u.transactionCreateMany;
|
|
9937
9958
|
if (!I || I.length === 0) {
|
|
9938
9959
|
const m = ((p = (D = h.errors) == null ? void 0 : D[0]) == null ? void 0 : p.message) || "Unknown error";
|
|
9939
|
-
throw new
|
|
9960
|
+
throw new H(`Failed to create transactions: ${m}`);
|
|
9940
9961
|
}
|
|
9941
9962
|
return I.map((m, F) => ({
|
|
9942
9963
|
transaction: m,
|
|
@@ -9990,7 +10011,7 @@ class Bs {
|
|
|
9990
10011
|
async initFromIntegrationProduct(A) {
|
|
9991
10012
|
var s;
|
|
9992
10013
|
if (A === "")
|
|
9993
|
-
throw new
|
|
10014
|
+
throw new H("No integration product ID provided.");
|
|
9994
10015
|
const t = await N.getShadowGraphqlClient().mutate({
|
|
9995
10016
|
mutation: he,
|
|
9996
10017
|
variables: {
|
|
@@ -10003,10 +10024,10 @@ class Bs {
|
|
|
10003
10024
|
context: this.options.applicationKey ? { headers: { "X-Application-Key": this.options.applicationKey } } : void 0
|
|
10004
10025
|
});
|
|
10005
10026
|
if (!t.data || !t.data.transactionCreate)
|
|
10006
|
-
throw new
|
|
10027
|
+
throw new H("Failed to create transaction!");
|
|
10007
10028
|
const a = t.data.transactionCreate;
|
|
10008
10029
|
if (!a.product)
|
|
10009
|
-
throw new
|
|
10030
|
+
throw new H("Failed to create transaction, product not available.");
|
|
10010
10031
|
this.currencyCode = (s = a.product.partner) == null ? void 0 : s.currencyCode;
|
|
10011
10032
|
const n = x.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map();
|
|
10012
10033
|
n.set(a.id, a.transactionOwnerId), x.setMap("transactionOwnerIds", n), this.experienceOptions = {
|
|
@@ -10025,7 +10046,7 @@ class Bs {
|
|
|
10025
10046
|
async initFromTransaction(A, e = !1) {
|
|
10026
10047
|
var i, o, r, g;
|
|
10027
10048
|
if (A === "")
|
|
10028
|
-
throw new
|
|
10049
|
+
throw new H("No transaction ID provided.");
|
|
10029
10050
|
const t = N.getShadowGraphqlClient(), a = async () => {
|
|
10030
10051
|
var w, d;
|
|
10031
10052
|
const l = (w = (await t.query({
|
|
@@ -10035,9 +10056,9 @@ class Bs {
|
|
|
10035
10056
|
errorPolicy: "all"
|
|
10036
10057
|
})).data) == null ? void 0 : w.transactions[0];
|
|
10037
10058
|
if (!l)
|
|
10038
|
-
throw new
|
|
10059
|
+
throw new H("Failed to read transaction.");
|
|
10039
10060
|
if (!l.product)
|
|
10040
|
-
throw new
|
|
10061
|
+
throw new H("Failed to load transaction, product not available.");
|
|
10041
10062
|
this.currencyCode = (d = l.product.partner) == null ? void 0 : d.currencyCode, this.experienceOptions = {
|
|
10042
10063
|
product: l.product,
|
|
10043
10064
|
transaction: l,
|
|
@@ -10060,9 +10081,9 @@ class Bs {
|
|
|
10060
10081
|
errorPolicy: "all"
|
|
10061
10082
|
})).data) == null ? void 0 : i.transactions[0];
|
|
10062
10083
|
if (!l)
|
|
10063
|
-
throw new
|
|
10084
|
+
throw new H("Failed to read transaction.");
|
|
10064
10085
|
if (!l.product)
|
|
10065
|
-
throw new
|
|
10086
|
+
throw new H("Failed to load transaction, product not available.");
|
|
10066
10087
|
this.currencyCode = (o = l.product.partner) == null ? void 0 : o.currencyCode, this.experienceOptions = {
|
|
10067
10088
|
product: l.product,
|
|
10068
10089
|
transaction: l,
|
|
@@ -10079,9 +10100,9 @@ class Bs {
|
|
|
10079
10100
|
errorPolicy: "all"
|
|
10080
10101
|
})).data) == null ? void 0 : r.transactionClaim;
|
|
10081
10102
|
if (!l)
|
|
10082
|
-
throw new
|
|
10103
|
+
throw new H("Failed to read transaction.");
|
|
10083
10104
|
if (!l.product)
|
|
10084
|
-
throw new
|
|
10105
|
+
throw new H("Failed to load transaction, product not available.");
|
|
10085
10106
|
this.currencyCode = (g = l.product.partner) == null ? void 0 : g.currencyCode, l.transactionOwnerId && (n.set(l.id, l.transactionOwnerId), x.setMap("transactionOwnerIds", n)), this.experienceOptions = {
|
|
10086
10107
|
product: l.product,
|
|
10087
10108
|
transaction: l,
|
|
@@ -10090,7 +10111,7 @@ class Bs {
|
|
|
10090
10111
|
readOnly: e
|
|
10091
10112
|
}, this.initialized = !0;
|
|
10092
10113
|
} catch {
|
|
10093
|
-
throw new
|
|
10114
|
+
throw new H("Attempted to access a transaction that isn't available.");
|
|
10094
10115
|
}
|
|
10095
10116
|
}
|
|
10096
10117
|
/**
|
|
@@ -10099,7 +10120,7 @@ class Bs {
|
|
|
10099
10120
|
async getWorkflowExperienceDeprecated(A, e, t) {
|
|
10100
10121
|
var a, n, s, i;
|
|
10101
10122
|
if (!this.initialized || !this.experienceOptions)
|
|
10102
|
-
throw new
|
|
10123
|
+
throw new H("Cannot launch experience: Not initialized.");
|
|
10103
10124
|
if (this.experienceOptions.transaction.workflowId) {
|
|
10104
10125
|
const o = await QA(this.experienceOptions.transaction.workflowId);
|
|
10105
10126
|
if (this.experienceOptions.workflow = o, this.experienceOptions.transaction.workflowState) {
|
|
@@ -10139,7 +10160,7 @@ class Bs {
|
|
|
10139
10160
|
const l = new dA(this, this.experienceOptions);
|
|
10140
10161
|
return await l.getWorkflowManager().getInitializationPromise(), l;
|
|
10141
10162
|
}
|
|
10142
|
-
throw new
|
|
10163
|
+
throw new H("No workflow ID provided.");
|
|
10143
10164
|
}
|
|
10144
10165
|
/**
|
|
10145
10166
|
* @deprecated The value this returns will be changed whenever `getWorkflowExperience()` is called. Use `workflowExperience.getWorkflowManager().getPreviewService()` instead.
|
|
@@ -10155,7 +10176,7 @@ class Bs {
|
|
|
10155
10176
|
*/
|
|
10156
10177
|
getProduct() {
|
|
10157
10178
|
if (!this.initialized || !this.experienceOptions)
|
|
10158
|
-
throw new
|
|
10179
|
+
throw new H("Cannot get product: Not initialized.");
|
|
10159
10180
|
return this.experienceOptions.product;
|
|
10160
10181
|
}
|
|
10161
10182
|
/**
|
|
@@ -10164,7 +10185,7 @@ class Bs {
|
|
|
10164
10185
|
*/
|
|
10165
10186
|
getTransaction() {
|
|
10166
10187
|
if (!this.initialized || !this.experienceOptions)
|
|
10167
|
-
throw new
|
|
10188
|
+
throw new H("Cannot get transaction: Not initialized.");
|
|
10168
10189
|
return this.experienceOptions.transaction;
|
|
10169
10190
|
}
|
|
10170
10191
|
storeCustomer(A) {
|
|
@@ -10339,8 +10360,8 @@ class ds extends j {
|
|
|
10339
10360
|
export {
|
|
10340
10361
|
$ as AssetNotFoundError,
|
|
10341
10362
|
Ns as AssetType,
|
|
10342
|
-
|
|
10343
|
-
|
|
10363
|
+
Ps as BringForwardCommand,
|
|
10364
|
+
Hs as BringToBackCommand,
|
|
10344
10365
|
Rs as BringToFrontCommand,
|
|
10345
10366
|
Us as CanvasCommand,
|
|
10346
10367
|
Tn as CollectionProduct,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1859,7 +1859,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
1861
|
}
|
|
1862
|
-
`;class ge{constructor(e,A){var n;if(this.renderableScenes=[],this.renderableSceneCallbacks=[],this.debouncedSavedDesignUpdate=qe(async()=>{await De.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async a=>new Promise((i,o)=>{try{a.toBlob(s=>{if(s){const r=URL.createObjectURL(s);i(r)}})}catch(s){o(s)}}),!A.workflow)throw new Error("No Workflow ID provided.");this.client=e;const t=A.layouts;this.commandContext=new c.CommandContext,this.commandContext.initialize(t,A.reloadedState),this.isReadOnly=A.transaction.isOrdered||!!A.readOnly,this.workflowManager=new _t(A.workflow,((n=A.product.profanities)==null?void 0:n.map(a=>a.word))||[],t,this.commandContext,a=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return A.stateMutationFunc(a)},A.transaction,A.product,A.previewService,A.renderableContextService,A.reloadedState,A.readOnly,A.modelContainer,A.isReloadedTransaction,A.singleVariantsRenderable),this.workflowManager.addSelectionCallback(a=>{const i=a.traversableScenes.map(o=>{const s=o.renderableSteps.map(r=>r.stepName);return{id:o.name,title:o.title,renderableSteps:s}});this.renderableScenes=i,this.renderableSceneCallbacks.forEach(o=>o(i))})}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async createPreviewImage(e,A){var C,D;const t=this.workflowManager.getWorkflow(),n=(C=t==null?void 0:t.finalizeStepConfig)==null?void 0:C.lookAtAnimation;if(e){if(!n)throw new Error("Failed to generate cart preview image!");return await((D=this.workflowManager.getPreviewService())==null?void 0:D.renderSceneScreenshot(A??512,n))||""}let a=2048;A&&A<=2048&&(a=A);const i=c.createCanvas(a,a),o=this.commandContext.getAllLayouts(),s=t.defaultPreviewPanelIndex||0,r=t.panels[s],l=o.find(I=>{var F;return((F=I.layoutState)==null?void 0:F.layout.panelId)===(r==null?void 0:r.name)})||o[0],d=l.layoutState.layout.previewRegion?{x:l.layoutState.layout.previewRegion.left,y:l.layoutState.layout.previewRegion.top,width:l.layoutState.layout.previewRegion.width,height:l.layoutState.layout.previewRegion.height}:{x:0,y:0,width:l.layoutState.layout.width,height:l.layoutState.layout.height},B=this.commandContext.getLayoutById(l.layoutState.layout.id),w=i.getContext("2d");if(!w)throw new Ee("Failed to obtain 2D context for preview image creation");const E=c.getSvgElement(B.layoutState.layout,B.layoutState.elements,{renderingConfiguration:{purpose:c.LayoutRenderingPurpose.Print,region:{left:d.x,top:d.y,width:d.width,height:d.height}}}),m=c.renderPapyrusComponentAsString(E);await(await Xe.Pith.from(w,m,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:c.createCanvas,createImage:c.loadImage,DOMParser:c.getDomParser(),fetch:c.fetch})).render();const u=await this.getCanvasObjectURLAsync(i);return i.toDataURL(u)}getStepById(e){const A=this.getWorkflowManager().getWorkflow().steps.find(t=>t.stepName===e);if(!(!A||!this.stepHasHandle(A)))return fe.get(this.getWorkflowManager(),A)}getSteps(){return this.getScenes().flatMap(e=>this.getStepsByScene(e))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map(A=>({id:A.id,name:A.name,stepIds:A.stepNames}))}getSelectionPriceSubunits(){const e=this.getWorkflowManager().getWorkflowSelections();let A=0;return Object.values(e).forEach(t=>{A+=t.selections.map(n=>n.priceModifier).reduce((n,a)=>n+a)}),A}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}getStepByName(e){const A=this.getWorkflowManager().getWorkflow().steps.find(t=>t.stepTitle===e);if(!(!A||!this.stepHasHandle(A)))return fe.get(this.getWorkflowManager(),A)}getStepsByType(e){return this.getWorkflowManager().getWorkflow().steps.filter(A=>A.type===e).map(A=>fe.get(this.getWorkflowManager(),A))}getStepsByScene(e){if(!this.getWorkflowManager().getWorkflow().stepGroups.find(t=>t.name===e.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return e.stepIds.map(t=>this.getWorkflowManager().getWorkflow().steps.find(n=>n.stepName===t)).filter(t=>this.stepHasHandle(t)).map(t=>fe.get(this.getWorkflowManager(),t))}async attachCustomerDetails(e){return this.assignCustomerDetails({emailAddress:e.email})}async assignCustomerDetails(e){var i,o,s;const t=(P.getMap("transactionOwnerIds")||new Map).get(this.getWorkflowManager().getTransaction().id),a=(s=(o=(i=(await H.getShadowGraphqlClient().mutate({mutation:rn,variables:{id:this.getWorkflowManager().getTransaction().id,details:e,type:"Owner"},context:{transactionOwnerId:t}})).data)==null?void 0:i.transactionAddStakeholder)==null?void 0:o.stakeholders)==null?void 0:s.find(r=>{var l;return((l=r.customer)==null?void 0:l.emailAddress)===e.emailAddress});if(a!=null&&a.customer){this.getWorkflowManager().setTransactionCustomer(a.customer);const r=P.getMap("transactionCustomerIds")||new Map;r.set(this.getWorkflowManager().getTransaction().id,a.customer.id),P.setMap("transactionCustomerIds",r)}}attachRenderableSceneListener(e){this.renderableSceneCallbacks.push(e),e(this.renderableScenes)}detachRenderableSceneListener(e){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(A=>A!==e)}async save(e){if(!this.getCommandContext().getState())throw new U("State undefined!");const n={title:await(async()=>{var s;if(e)return e;const a=this.getWorkflowManager().getTransaction().id,o=(s=(await De.getSavedDesigns()).find(r=>r.transactionId===a))==null?void 0:s.title;return o||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await De.addDesign(n),n}async copy(){var o;const e=de(this.getCommandContext().getState());if(!e)throw new U("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(e.transaction),t=this.getWorkflowManager().getWorkflow(),n=new ZA({}),a=(o=this.getWorkflowManager().getTransaction().integrationProduct)==null?void 0:o.id;if(!a)throw new U("Integration product id is undefined!");return await n.initFromIntegrationProduct(a),await n.getWorkflowExperience(t.id,A,void 0)}async onDesignFinished(e,A=!0){return bA(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),()=>this.commandContext.getState(),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,e||(()=>{}),t=>A?this.createPreviewImage(t,1024):Promise.resolve(void 0),this.workflowManager.getWorkflowMetadata())}stepHasHandle(e){return e.type!==c.StepType.SilentIllustration&&e.type!==c.StepType.ProductOverlay}getExportedData(){var n;const e=new Map,A=this.getWorkflowManager().getWorkflowMetadata(),t=this.getWorkflowManager().getWorkflowSelections();return Object.keys(A).forEach(a=>{const i=this.workflowManager.getWorkflow().steps.find(s=>s.stepName===a);if(!i)return;e.has(i.stepTitle)||e.set(i.stepTitle,{});const o=A[a];Object.keys(o).forEach(s=>{e.get(i.stepTitle)[s]=o[s]})}),(n=Object.keys(t))==null||n.forEach(a=>{const i=this.workflowManager.getWorkflow().steps.find(o=>o.stepName===a);i&&(e.has(i.stepTitle)||e.set(i.stepTitle,{}),e.get(i.stepTitle).selection=t[a].selections[0].name)}),e}}const cn=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],gn=async(g,e,A)=>{const t=e.data,n=A.data.baseUrl,a=t.assetUrl.replace("localhost","localstack"),i=n.slice(0,4)==="http"?"":"https://",o=new URL(i+n);o.searchParams.append("video",c.toBase64(JSON.stringify([{href:a}]))),o.pathname=o.pathname+(o.pathname.slice(-1)==="/"?"":"/");const s=o.toString(),l=`data:image/svg+xml;base64,${c.toBase64(await $e.toString(s,{type:"svg"}))}`,d=w=>{const E=g.find(h=>h.panelId===w.panelId);if(!E)throw new k(w);const m=c.generate();return new c.CreateElementCommand({id:m,src:l,type:c.LayoutElementType.Image,y:w.top,x:w.left,width:w.width,height:w.height,rotation:0},E)},B=A.data.regions;try{return B.map(d)}catch(w){return console.error(w),[]}},ln=async(g,e,A,t)=>{const n=A.data,a=n.assetUrl,i=await c.getPatternImageData(a);try{const o=c.getVariant(n,t.option);o&&(e[t.stepName]={selectedVariants:[o]});const s=async r=>{var m;const l=await c.generateFrameSVG(r||{width:1,height:1},(m=o==null?void 0:o.asset)==null?void 0:m.fileLink),d=await c.getFrameData(l),B=c.generate(),w=g.find(h=>h.panelId===r.panelId);if(!w)throw new k(r);const E=c.calculateOffsets(i,d,{scale:n.scale,left:n.x,top:n.y});return[new c.CreateElementCommand({id:B,path:d.path,dataWidth:d.width,dataHeight:d.height,type:c.LayoutElementType.Frame,focalBlur:t.data.focalBlur,focalBlurStrength:t.data.focalBlurStrength,focalBlurRadius:t.data.focalBlurRadius,forceImageCover:t.data.forceImageCover,x:r.left,y:r.top,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,rotation:r.rotation,scaleX:r.width/d.width,scaleY:r.height/d.height,pattern:void 0},w),new c.UpdateFramePattern(B,i,E)]};return(await Promise.all(t.data.regions.map(r=>s(r)))).flat()}catch(o){return console.error(o),[]}},Bn=async(g,e,A,t)=>{var F,p;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((F=a.variants)==null?void 0:F.find(f=>f.id===n.illustrationVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.illustrationVariantId}`),[];if(!i.asset)return console.error(`No asset for variant with ID: ${n.illustrationVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=(p=i.asset)==null?void 0:p.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`),[];const s=await c.fetchAsString(o,!0),r=/<svg.*?<\/svg>/s,l=s.match(r)||[],d=(l==null?void 0:l.length)>0?l[0]:"",E=c.domParser().parseFromString(d,"image/svg+xml").firstElementChild;if(!E)return console.error("Failed to read SVG."),[];c.sanitizeSvgTree(E);const m={};c.traverse(E,f=>{cn.includes(f.tagName)&&!f.attributes.getNamedItem("fill")&&f.setAttribute("fill","#000000");const S=f.attributes.getNamedItem("fill");if(S&&S.value!=="none"){const Y=S.value,N=`spiff-fill-${Y.replace(/\W/g,"")}`;f.classList.add(N),m[N]={browserValue:Y}}const y=f.attributes.getNamedItem("stroke");if(y&&y.value!=="none"){const Y=y.value,N=`spiff-stroke-${Y.replace(/\W/g,"")}`;f.classList.add(N),m[N]={browserValue:Y}}});const u=c.xmlSerializer().serializeToString(E),C=n.colors;if(C){for(const[f,S]of Object.entries(m))for(const y of Object.keys(C))if(S.browserValue===y){m[f]={browserValue:C[y]};break}}const D=f=>{const S=g.find(Y=>Y.panelId===f.panelId);if(!S)throw new k(f);const y=c.generate();return new c.CreateElementCommand({colors:m,id:y,svg:u,type:c.LayoutElementType.Illustration,y:f.top,x:f.left,rotation:f.rotation,width:f.width,height:f.height,layer:f.layer,layerIndex:f.layerIndex,immutable:f.immutable},S)},I=t.data.regions;try{return I.map(D)}catch(f){return console.error(f),[]}},dn=async(g,e,A)=>{const t=await FA(A.data.module),n=e.data,a=(o,s)=>{const r=g.find(d=>d.panelId===s.panelId);if(!r)throw new k(s);const l=c.generate();return new c.CreateElementCommand({colors:{},id:l,svg:o,type:c.LayoutElementType.Illustration,y:s.top,x:s.left,rotation:s.rotation,width:s.width,height:s.height,layer:s.layer,layerIndex:s.layerIndex},r)},i=A.data.regions;try{return i.map(o=>a(t.svgPrint(n.text,o),o))}catch(o){return console.error(o),[]}},wn=async(g,e,A,t)=>{var l,d;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((l=a.variants)==null?void 0:l.find(B=>B.id===n.pictureVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.pictureVariantId}`),[];if(!i.asset)return console.error(`No asset for variant with ID: ${n.pictureVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=(d=i.asset)==null?void 0:d.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.pictureVariantId}`),[];const s=B=>{const w=g.find(m=>m.panelId===B.panelId);if(!w)throw new k(B);const E=c.generate();return new c.CreateElementCommand({id:E,src:o,type:c.LayoutElementType.Image,y:B.top,x:B.left,rotation:B.rotation,width:B.width,height:B.height,layer:B.layer,layerIndex:B.layerIndex,immutable:B.immutable,preserveAspectRatio:"none"},w)},r=t.data.regions;try{return r.map(s)}catch(B){return console.error(B),[]}},En=async(g,e,A,t)=>{var r;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((r=a.variants)==null?void 0:r.find(l=>l.id===n.colorVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.colorVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=l=>{const d=g.find(h=>h.panelId===l.panelId);if(!d)throw new k(l);const B=`
|
|
1862
|
+
`;class ge{constructor(e,A){var n;if(this.renderableScenes=[],this.renderableSceneCallbacks=[],this.debouncedSavedDesignUpdate=qe(async()=>{await De.getSavedDesignByTransaction(this.getWorkflowManager().getTransaction().id)&&this.save()},2500),this.getCanvasObjectURLAsync=async a=>new Promise((i,o)=>{try{a.toBlob(s=>{if(s){const r=URL.createObjectURL(s);i(r)}})}catch(s){o(s)}}),!A.workflow)throw new Error("No Workflow ID provided.");this.client=e;const t=A.layouts;this.commandContext=new c.CommandContext,this.commandContext.initialize(t,A.reloadedState),this.isReadOnly=A.transaction.isOrdered||!!A.readOnly,this.workflowManager=new _t(A.workflow,((n=A.product.profanities)==null?void 0:n.map(a=>a.word))||[],t,this.commandContext,a=>{try{this.debouncedSavedDesignUpdate()}catch{console.error("Failed to update saved design details.")}return A.stateMutationFunc(a)},A.transaction,A.product,A.previewService,A.renderableContextService,A.reloadedState,A.readOnly,A.modelContainer,A.isReloadedTransaction,A.singleVariantsRenderable),this.workflowManager.addSelectionCallback(a=>{const i=a.traversableScenes.map(o=>{const s=o.renderableSteps.map(r=>r.stepName);return{id:o.name,title:o.title,renderableSteps:s}});this.renderableScenes=i,this.renderableSceneCallbacks.forEach(o=>o(i))})}getClient(){return this.client}getIsReadOnly(){return this.isReadOnly}getCommandContext(){return this.commandContext}getWorkflowManager(){return this.workflowManager}async createPreviewImage(e,A){var C,D;const t=this.workflowManager.getWorkflow(),n=(C=t==null?void 0:t.finalizeStepConfig)==null?void 0:C.lookAtAnimation;if(e){if(!n)throw new Error("Failed to generate cart preview image!");return await((D=this.workflowManager.getPreviewService())==null?void 0:D.renderSceneScreenshot(A??512,n))||""}let a=2048;A&&A<=2048&&(a=A);const i=c.createCanvas(a,a),o=this.commandContext.getAllLayouts(),s=t.defaultPreviewPanelIndex||0,r=t.panels[s],l=o.find(I=>{var F;return((F=I.layoutState)==null?void 0:F.layout.panelId)===(r==null?void 0:r.name)})||o[0],d=l.layoutState.layout.previewRegion?{x:l.layoutState.layout.previewRegion.left,y:l.layoutState.layout.previewRegion.top,width:l.layoutState.layout.previewRegion.width,height:l.layoutState.layout.previewRegion.height}:{x:0,y:0,width:l.layoutState.layout.width,height:l.layoutState.layout.height},B=this.commandContext.getLayoutById(l.layoutState.layout.id),w=i.getContext("2d");if(!w)throw new Ee("Failed to obtain 2D context for preview image creation");const E=c.getSvgElement(B.layoutState.layout,B.layoutState.elements,{renderingConfiguration:{purpose:c.LayoutRenderingPurpose.Print,region:{left:d.x,top:d.y,width:d.width,height:d.height}}}),m=c.renderPapyrusComponentAsString(E);await(await Xe.Pith.from(w,m,{anonymousCrossOrigin:!0,ignoreDimensions:!1,createCanvas:c.createCanvas,createImage:c.loadImage,DOMParser:c.getDomParser(),fetch:c.fetch})).render();const u=await this.getCanvasObjectURLAsync(i);return i.toDataURL(u)}getStepById(e){const A=this.getWorkflowManager().getWorkflow().steps.find(t=>t.stepName===e);if(!(!A||!this.stepHasHandle(A)))return fe.get(this.getWorkflowManager(),A)}getSteps(){return this.getScenes().flatMap(e=>this.getStepsByScene(e))}getScenes(){return this.getWorkflowManager().getWorkflow().stepGroups.map(A=>({id:A.id,name:A.name,stepIds:A.stepNames}))}getSelectionPriceSubunits(){const e=this.getWorkflowManager().getWorkflowSelections();let A=0;return Object.values(e).forEach(t=>{A+=t.selections.map(n=>n.priceModifier).reduce((n,a)=>n+a)}),A}getBasePriceSubunits(){return this.getWorkflowManager().getProduct().basePrice||0}getTotalPriceSubunits(){return this.getBasePriceSubunits()+this.getSelectionPriceSubunits()}copySelections(e,A){const t=A==null?void 0:A.map(i=>i.getId()),n=this.getSteps().filter(i=>t===void 0||t.includes(i.getId())),a=e.getSteps();n.forEach(i=>{const o=new Set,s=i.getRaw().globalPropertyAspectConfigurations;s!==void 0&&(s.forEach(r=>o.add(JSON.stringify(r))),a.forEach(r=>{const l=r.getRaw().globalPropertyAspectConfigurations;l!==void 0&&l.forEach(d=>{const B=o.has(JSON.stringify(d));if(B&&d.aspectName==="Option"){const w=r.getCurrentVariant();if(!w)return;i.selectVariant(w),o.delete(JSON.stringify(d))}else if(B&&d.aspectName==="Text"){const w=r.getText();i.setText(w),o.delete(JSON.stringify(d))}})}))})}getStepByName(e){const A=this.getWorkflowManager().getWorkflow().steps.find(t=>t.stepTitle===e);if(!(!A||!this.stepHasHandle(A)))return fe.get(this.getWorkflowManager(),A)}getStepsByType(e){return this.getWorkflowManager().getWorkflow().steps.filter(A=>A.type===e).map(A=>fe.get(this.getWorkflowManager(),A))}getStepsByScene(e){if(!this.getWorkflowManager().getWorkflow().stepGroups.find(t=>t.name===e.name))throw new Error("Given scene is not present on workflow! Be careful when persisting scenes that you only use them with the relevant workflow.");return e.stepIds.map(t=>this.getWorkflowManager().getWorkflow().steps.find(n=>n.stepName===t)).filter(t=>this.stepHasHandle(t)).map(t=>fe.get(this.getWorkflowManager(),t))}async attachCustomerDetails(e){return this.assignCustomerDetails({emailAddress:e.email})}async assignCustomerDetails(e){var i,o,s;const t=(P.getMap("transactionOwnerIds")||new Map).get(this.getWorkflowManager().getTransaction().id),a=(s=(o=(i=(await H.getShadowGraphqlClient().mutate({mutation:rn,variables:{id:this.getWorkflowManager().getTransaction().id,details:e,type:"Owner"},context:{transactionOwnerId:t}})).data)==null?void 0:i.transactionAddStakeholder)==null?void 0:o.stakeholders)==null?void 0:s.find(r=>{var l;return((l=r.customer)==null?void 0:l.emailAddress)===e.emailAddress});if(a!=null&&a.customer){this.getWorkflowManager().setTransactionCustomer(a.customer);const r=P.getMap("transactionCustomerIds")||new Map;r.set(this.getWorkflowManager().getTransaction().id,a.customer.id),P.setMap("transactionCustomerIds",r)}}attachRenderableSceneListener(e){this.renderableSceneCallbacks.push(e),e(this.renderableScenes)}detachRenderableSceneListener(e){this.renderableSceneCallbacks=this.renderableSceneCallbacks.filter(A=>A!==e)}async save(e){if(!this.getCommandContext().getState())throw new U("State undefined!");const n={title:await(async()=>{var s;if(e)return e;const a=this.getWorkflowManager().getTransaction().id,o=(s=(await De.getSavedDesigns()).find(r=>r.transactionId===a))==null?void 0:s.title;return o||"My design"})(),thumbnail:await this.createPreviewImage(!1,256),transactionId:this.getWorkflowManager().getTransaction().id,productId:this.getWorkflowManager().getProduct().id,integrationProductId:this.getWorkflowManager().getTransaction().integrationProduct.id,workflowName:this.getWorkflowManager().getWorkflow().name,workflowId:this.getWorkflowManager().getWorkflow().id,lastEdited:new Date};return await De.addDesign(n),n}async copy(){var o;const e=de(this.getCommandContext().getState());if(!e)throw new U("Internal state is undefined! Cannot copy experience!");const A=JSON.stringify(e.transaction),t=this.getWorkflowManager().getWorkflow(),n=new ZA({}),a=(o=this.getWorkflowManager().getTransaction().integrationProduct)==null?void 0:o.id;if(!a)throw new U("Integration product id is undefined!");return await n.initFromIntegrationProduct(a),await n.getWorkflowExperience(t.id,A,void 0)}async onDesignFinished(e,A=!0){return bA(this.workflowManager,this.workflowManager.getWorkflow(),this.workflowManager.getLayouts(),()=>this.commandContext.getState(),this.workflowManager.getProduct(),this.workflowManager.getTransaction(),this.workflowManager.getWorkflowSelections(),this.workflowManager.getWorkflow().name,e||(()=>{}),t=>A?this.createPreviewImage(t,1024):Promise.resolve(void 0),this.workflowManager.getWorkflowMetadata())}stepHasHandle(e){return e.type!==c.StepType.SilentIllustration&&e.type!==c.StepType.ProductOverlay}getExportedData(){var n;const e=new Map,A=this.getWorkflowManager().getWorkflowMetadata(),t=this.getWorkflowManager().getWorkflowSelections();return Object.keys(A).forEach(a=>{const i=this.workflowManager.getWorkflow().steps.find(s=>s.stepName===a);if(!i)return;e.has(i.stepTitle)||e.set(i.stepTitle,{});const o=A[a];Object.keys(o).forEach(s=>{e.get(i.stepTitle)[s]=o[s]})}),(n=Object.keys(t))==null||n.forEach(a=>{const i=this.workflowManager.getWorkflow().steps.find(o=>o.stepName===a);i&&(e.has(i.stepTitle)||e.set(i.stepTitle,{}),e.get(i.stepTitle).selection=t[a].selections[0].name)}),e}}const cn=["altGlyph","circle","ellipse","path","polygon","polyline","rect","text","textPath","tref","tspan"],gn=async(g,e,A)=>{const t=e.data,n=A.data.baseUrl,a=t.assetUrl.replace("localhost","localstack"),i=n.slice(0,4)==="http"?"":"https://",o=new URL(i+n);o.searchParams.append("video",c.toBase64(JSON.stringify([{href:a}]))),o.pathname=o.pathname+(o.pathname.slice(-1)==="/"?"":"/");const s=o.toString(),l=`data:image/svg+xml;base64,${c.toBase64(await $e.toString(s,{type:"svg"}))}`,d=w=>{const E=g.find(h=>h.panelId===w.panelId);if(!E)throw new k(w);const m=c.generate();return new c.CreateElementCommand({id:m,src:l,type:c.LayoutElementType.Image,y:w.top,x:w.left,width:w.width,height:w.height,rotation:0},E)},B=A.data.regions;try{return B.map(d)}catch(w){return console.error(w),[]}},ln=async(g,e,A,t)=>{const n=A.data,a=n.assetUrl,i=await c.getPatternImageData(a);try{const o=c.getVariant(n,t.option);o&&(e[t.stepName]={selectedVariants:[o]});const s=async r=>{var m;const l=await c.generateFrameSVG(r||{width:1,height:1},(m=o==null?void 0:o.asset)==null?void 0:m.fileLink),d=await c.getFrameData(l),B=c.generate(),w=g.find(h=>h.panelId===r.panelId);if(!w)throw new k(r);const E=c.calculateOffsets(i,d,{scale:n.scale,left:n.x,top:n.y});return[new c.CreateElementCommand({id:B,path:d.path,dataWidth:d.width,dataHeight:d.height,type:c.LayoutElementType.Frame,focalBlur:t.data.focalBlur,focalBlurStrength:t.data.focalBlurStrength,focalBlurRadius:t.data.focalBlurRadius,forceImageCover:t.data.forceImageCover,x:r.left,y:r.top,width:r.width,height:r.height,layer:r.layer,layerIndex:r.layerIndex,rotation:r.rotation,scaleX:r.width/d.width,scaleY:r.height/d.height,pattern:void 0},w),new c.UpdateFramePattern(B,i,E)]};return(await Promise.all(t.data.regions.map(r=>s(r)))).flat()}catch(o){return console.error(o),[]}},Bn=async(g,e,A,t)=>{var F,p;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((F=a.variants)==null?void 0:F.find(f=>f.id===n.illustrationVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.illustrationVariantId}`),[];if(!i.asset)return console.error(`No asset for variant with ID: ${n.illustrationVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=(p=i.asset)==null?void 0:p.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.illustrationVariantId}`),[];const s=await c.fetchAsString(o,!0),r=/<svg.*?<\/svg>/s,l=s.match(r)||[],d=(l==null?void 0:l.length)>0?l[0]:"",E=c.domParser().parseFromString(d,"image/svg+xml").firstElementChild;if(!E)return console.error("Failed to read SVG."),[];c.sanitizeSvgTree(E);const m={};c.traverse(E,f=>{cn.includes(f.tagName)&&!f.attributes.getNamedItem("fill")&&f.setAttribute("fill","#000000");const S=f.attributes.getNamedItem("fill");if(S&&S.value!=="none"){const Y=S.value,N=`spiff-fill-${Y.replace(/\W/g,"")}`;f.classList.add(N),m[N]={browserValue:Y}}const y=f.attributes.getNamedItem("stroke");if(y&&y.value!=="none"){const Y=y.value,N=`spiff-stroke-${Y.replace(/\W/g,"")}`;f.classList.add(N),m[N]={browserValue:Y}}});const u=c.xmlSerializer().serializeToString(E),C=n.colors;if(C){for(const[f,S]of Object.entries(m))for(const y of Object.keys(C))if(S.browserValue===y){m[f]={browserValue:C[y]};break}}const D=f=>{const S=g.find(Y=>Y.panelId===f.panelId);if(!S)throw new k(f);const y=c.generate();return new c.CreateElementCommand({colors:m,id:y,svg:u,type:c.LayoutElementType.Illustration,y:f.top,x:f.left,rotation:f.rotation,width:f.width,height:f.height,layer:f.layer,layerIndex:f.layerIndex,immutable:f.immutable},S)},I=t.data.regions;try{return I.map(D)}catch(f){return console.error(f),[]}},dn=async(g,e,A)=>{const t=await FA(A.data.module),n=e.data,a=(o,s)=>{const r=g.find(d=>d.panelId===s.panelId);if(!r)throw new k(s);const l=c.generate();return new c.CreateElementCommand({colors:{},id:l,svg:o,type:c.LayoutElementType.Illustration,y:s.top,x:s.left,rotation:s.rotation,width:s.width,height:s.height,layer:s.layer,layerIndex:s.layerIndex},r)},i=A.data.regions;try{return i.map(o=>a(t.svgPrint(n.text,o),o))}catch(o){return console.error(o),[]}},wn=async(g,e,A,t)=>{var l,d;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((l=a.variants)==null?void 0:l.find(B=>B.id===n.pictureVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.pictureVariantId}`),[];if(!i.asset)return console.error(`No asset for variant with ID: ${n.pictureVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=(d=i.asset)==null?void 0:d.fileLink;if(!o)return console.error(`No asset link for variant with ID: ${n.pictureVariantId}`),[];const s=B=>{const w=g.find(m=>m.panelId===B.panelId);if(!w)throw new k(B);const E=c.generate();return new c.CreateElementCommand({id:E,src:o,type:c.LayoutElementType.Image,y:B.top,x:B.left,rotation:B.rotation,width:B.width,height:B.height,layer:B.layer,layerIndex:B.layerIndex,immutable:B.immutable,preserveAspectRatio:"none"},w)},r=t.data.regions;try{return r.map(s)}catch(B){return console.error(B),[]}},En=async(g,e,A,t)=>{var r;const n=A.data,a=t.option;if(!a)return console.error(`No option for step ${t.stepName}.`),[];const i=((r=a.variants)==null?void 0:r.find(l=>l.id===n.colorVariantId))||c.getDefaultVariant(a);if(!i)return console.error(`No variant with ID: ${n.colorVariantId}`),[];e[t.stepName]={selectedVariants:[i]};const o=l=>{const d=g.find(h=>h.panelId===l.panelId);if(!d)throw new k(l);const B=`
|
|
1863
1863
|
<svg
|
|
1864
1864
|
xmlns="http://www.w3.org/2000/svg"
|
|
1865
1865
|
xmlnsXlink="http://www.w3.org/1999/xlink"
|