@spiffcommerce/core 21.8.2-7 → 21.8.2

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHttpLink as EA, InMemoryCache as hA, ApolloClient as CA, from as uA, gql as D } from "@apollo/client/core";
2
- import { fetch as $e, getAttributesFromArrayBuffer as yt, AssetType as Bt, StepType as F, getFrameData as _e, frameDataCache as QA, GroupCommand as G, UpdateFramePattern as Yt, UpdateFrameThresholdSettingsCommand as mA, calculateOffsets as et, LayoutElementType as v, generate as J, CreateElementCommand as L, generateSVGWithUnknownColors as St, svgObjectURL as De, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as dt, GetSVGDimensions as IA, patternImageDataCache as wt, fetchAsArrayBuffer as pA, findElement as Fe, modifySVGWithElementProperties as fA, IllustrationColorCommand as Ke, IllustrationCacheCommand as DA, getFontMetrics as FA, getPatternImageData as je, FontAlignmentCommand as MA, FontColorCommand as yA, FontImageFillCommand as Je, applyTextTransformations as Ve, determineCorrectFontSizeAndLines as Ie, FontSourceCommand as Et, loadFont as tt, TextChangeCommand as YA, FontSizeCommand as SA, createElementNS as xA, createElement as de, _loadFontExternalDataURL as At, UpdateWorkflowStateCommand as ht, CommandContext as PA, createCanvas as Me, getSvgElement as xt, LayoutRenderingPurpose as Pt, renderPapyrusComponentAsString as Nt, loadImage as Ht, getDomParser as Rt, toBase64 as Ct, getVariant as NA, generateFrameSVG as HA, getDefaultVariant as He, domParser as Ut, sanitizeSvgTree as Gt, traverse as RA, xmlSerializer as vt, CreateLayoutCommand as UA, AspectType as pe, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
2
+ import { fetch as $e, getAttributesFromArrayBuffer as yt, AssetType as Bt, StepType as M, getFrameData as _e, frameDataCache as QA, GroupCommand as G, UpdateFramePattern as Yt, UpdateFrameThresholdSettingsCommand as mA, calculateOffsets as et, LayoutElementType as v, generate as J, CreateElementCommand as L, generateSVGWithUnknownColors as St, svgObjectURL as De, fetchAsString as Z, DeleteElementCommand as $, generateDefaultRectangleFrameSvg as dt, GetSVGDimensions as IA, patternImageDataCache as wt, fetchAsArrayBuffer as pA, findElement as Fe, modifySVGWithElementProperties as fA, IllustrationColorCommand as Ke, IllustrationCacheCommand as DA, getFontMetrics as FA, getPatternImageData as je, FontAlignmentCommand as MA, FontColorCommand as yA, FontImageFillCommand as Je, applyTextTransformations as Ve, determineCorrectFontSizeAndLines as Ie, FontSourceCommand as Et, loadFont as tt, TextChangeCommand as YA, FontSizeCommand as SA, createElementNS as xA, createElement as de, _loadFontExternalDataURL as At, UpdateWorkflowStateCommand as ht, CommandContext as PA, createCanvas as Me, getSvgElement as xt, LayoutRenderingPurpose as Pt, renderPapyrusComponentAsString as Nt, loadImage as Ht, getDomParser as Rt, toBase64 as Ct, getVariant as NA, generateFrameSVG as HA, getDefaultVariant as He, domParser as Ut, sanitizeSvgTree as Gt, traverse as RA, xmlSerializer as vt, CreateLayoutCommand as UA, AspectType as pe, rehydrateSerializedLayout as ee } from "@spiffcommerce/papyrus";
3
3
  import { AspectType as ji, AssetType as Vi, BringForwardCommand as Wi, BringToBackCommand as Xi, BringToFrontCommand as qi, CanvasCommand as Zi, CommandContext as $i, CreateElementCommand as _i, CreateLayoutCommand as es, DeleteElementCommand as ts, FontAlignmentCommand as As, FontColorCommand as ns, FontSizeCommand as as, FontSourceCommand as is, GroupCommand as ss, LayoutElementFactory as os, LayoutElementType as rs, MoveCommand as cs, ResizeCommand as gs, RotateCommand as ls, SendBackwardsCommand as Bs, StepAspectType as ds, StepType as ws, TextChangeCommand as Es, UnitOfMeasurement as hs, dataUrlFromExternalUrl as Cs, determineCorrectFontSizeAndLines as us, findElement as Qs, frameDataCache as ms, generate as Is, generateSVGWithUnknownColors as ps, getAttributesFromArrayBuffer as fs, getAxisAlignedBoundingBox as Ds, getFrameData as Fs, getSvgElement as Ms, loadFont as ys, patternImageDataCache as Ys, registerFetchImplementation as Ss, registerWindowImplementation as xs, rehydrateSerializedLayout as Ps, setCanvasModule as Ns } from "@spiffcommerce/papyrus";
4
4
  import { setContext as GA } from "@apollo/client/link/context";
5
5
  import { onError as vA } from "@apollo/client/link/error";
@@ -1193,14 +1193,14 @@ const jt = D`
1193
1193
  ...IntegrationProductFields
1194
1194
  }
1195
1195
  }
1196
- `, se = [F.SilentIllustration, F.ProductOverlay], Cn = async (c) => {
1196
+ `, se = [M.SilentIllustration, M.ProductOverlay], Cn = async (c) => {
1197
1197
  const e = [];
1198
1198
  c.introduction && e.push({
1199
1199
  name: "Introduction",
1200
1200
  title: c.name,
1201
1201
  renderableSteps: [
1202
1202
  {
1203
- type: F.Introduction,
1203
+ type: M.Introduction,
1204
1204
  stepName: "Introduction",
1205
1205
  stepTitle: c.name,
1206
1206
  helpText: c.introduction,
@@ -1235,7 +1235,7 @@ const jt = D`
1235
1235
  title: t,
1236
1236
  renderableSteps: [
1237
1237
  {
1238
- type: F.Finish,
1238
+ type: M.Finish,
1239
1239
  stepName: "Finish",
1240
1240
  stepTitle: t,
1241
1241
  helpText: "",
@@ -1271,7 +1271,7 @@ const jt = D`
1271
1271
  for (const s of A)
1272
1272
  for (const o of s.renderableSteps) {
1273
1273
  const r = (((i = o.option) == null ? void 0 : i.variants) || []).length;
1274
- o.silent || (o.type === F.Model || o.type === F.Material || o.type === F.Picture || o.type === F.Shape ? (r > 1 || t) && n.push(o.stepName) : n.push(o.stepName));
1274
+ o.silent || (o.type === M.Model || o.type === M.Material || o.type === M.Picture || o.type === M.Shape ? (r > 1 || t) && n.push(o.stepName) : n.push(o.stepName));
1275
1275
  }
1276
1276
  const a = A.filter((s) => s.renderableSteps.filter(
1277
1277
  (r) => n.includes(r.stepName)
@@ -1564,14 +1564,14 @@ class pt {
1564
1564
  if (!a)
1565
1565
  throw new z(n);
1566
1566
  let i = "";
1567
- if (this.configuration.type === F.ProductOverlay) {
1567
+ if (this.configuration.type === M.ProductOverlay) {
1568
1568
  let l = "";
1569
1569
  if ((o = this.product) != null && o.overlayImageUrl && (l = this.product.overlayImageUrl), i = l, !l)
1570
1570
  throw new Ye(this.configuration, "Couldn't find an asset for product overlay step");
1571
1571
  }
1572
1572
  const s = this.evaluateAssetType();
1573
1573
  if (s === v.Image) {
1574
- const l = this.configuration.type === F.SilentIllustration ? (r = this.configuration.data.asset) == null ? void 0 : r.fileLink : (g = this.product) == null ? void 0 : g.overlayImageUrl;
1574
+ const l = this.configuration.type === M.SilentIllustration ? (r = this.configuration.data.asset) == null ? void 0 : r.fileLink : (g = this.product) == null ? void 0 : g.overlayImageUrl;
1575
1575
  if (!l)
1576
1576
  throw new Error("Undefined raster silent step source");
1577
1577
  const d = {
@@ -1586,7 +1586,7 @@ class pt {
1586
1586
  layer: n.layer,
1587
1587
  layerIndex: n.layerIndex,
1588
1588
  immutable: n.immutable,
1589
- productOverlay: this.configuration.type === F.ProductOverlay ? !0 : void 0,
1589
+ productOverlay: this.configuration.type === M.ProductOverlay ? !0 : void 0,
1590
1590
  rotation: n.rotation,
1591
1591
  excludeFromExport: this.configuration.data.excludeFromPrint,
1592
1592
  preserveAspectRatio: "none"
@@ -1599,7 +1599,7 @@ class pt {
1599
1599
  command: new L(d, a)
1600
1600
  };
1601
1601
  } else {
1602
- const l = this.configuration.type === F.SilentIllustration ? (B = this.configuration.data.asset) == null ? void 0 : B.fileLink : i, w = await St(await (async () => new Promise((E, u) => {
1602
+ const l = this.configuration.type === M.SilentIllustration ? (B = this.configuration.data.asset) == null ? void 0 : B.fileLink : i, w = await St(await (async () => new Promise((E, u) => {
1603
1603
  if (!l) {
1604
1604
  u("Undefined vector silent step source");
1605
1605
  return;
@@ -1623,7 +1623,7 @@ class pt {
1623
1623
  layerIndex: n.layerIndex,
1624
1624
  rotation: n.rotation,
1625
1625
  immutable: n.immutable,
1626
- productOverlay: this.configuration.type === F.ProductOverlay ? !0 : void 0,
1626
+ productOverlay: this.configuration.type === M.ProductOverlay ? !0 : void 0,
1627
1627
  excludeFromExport: this.configuration.data.excludeFromPrint
1628
1628
  };
1629
1629
  return {
@@ -1639,11 +1639,11 @@ class pt {
1639
1639
  async trigger() {
1640
1640
  if (!this.configuration.data.regions)
1641
1641
  throw new Ye(this.configuration, "Missing regions.");
1642
- if (this.configuration.type === F.SilentIllustration) {
1642
+ if (this.configuration.type === M.SilentIllustration) {
1643
1643
  const e = this.configuration.data.regions.map(this.processRegion);
1644
1644
  return Promise.all(e);
1645
1645
  } else
1646
- return this.configuration.type === F.ProductOverlay ? Promise.all(
1646
+ return this.configuration.type === M.ProductOverlay ? Promise.all(
1647
1647
  this.configuration.data.regions.map((e) => {
1648
1648
  if (!this.layouts.find((A) => e.panelId === A.panelId))
1649
1649
  throw new z(e);
@@ -1653,7 +1653,7 @@ class pt {
1653
1653
  }
1654
1654
  evaluateAssetType() {
1655
1655
  var t, A, n;
1656
- const e = this.configuration.type === F.ProductOverlay && ((t = this.product) != null && t.overlayImageUrl) ? this.product.overlayImageUrl.toLowerCase() : (n = (A = this.configuration.data.asset) == null ? void 0 : A.fileLink) == null ? void 0 : n.toLowerCase().split("?")[0];
1656
+ const e = this.configuration.type === M.ProductOverlay && ((t = this.product) != null && t.overlayImageUrl) ? this.product.overlayImageUrl.toLowerCase() : (n = (A = this.configuration.data.asset) == null ? void 0 : A.fileLink) == null ? void 0 : n.toLowerCase().split("?")[0];
1657
1657
  return e != null && e.startsWith("data:image/png") || e != null && e.endsWith(".jpeg") || e != null && e.endsWith(".jpg") || e != null && e.endsWith(".png") ? v.Image : e != null && e.endsWith(".svg") || e != null && e.startsWith("image/svg+xml") ? v.Illustration : v.Illustration;
1658
1658
  }
1659
1659
  }
@@ -3293,7 +3293,7 @@ class kn {
3293
3293
  }, m = [], I = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
3294
3294
  if (!Q.fontData)
3295
3295
  throw new k("Failed to resolve font data for text.");
3296
- const [M, y] = Ie(
3296
+ const [F, y] = Ie(
3297
3297
  Q.fontSize,
3298
3298
  Q.fontData,
3299
3299
  {
@@ -3307,11 +3307,11 @@ class kn {
3307
3307
  [o],
3308
3308
  { size: A.size, minSize: A.minSize, maxSize: A.maxSize }
3309
3309
  );
3310
- I.set(Q.id, M), p.set(Q.id, y);
3310
+ I.set(Q.id, F), p.set(Q.id, y);
3311
3311
  const S = A.curved || A.vertical ? o : (y || []).join(`
3312
3312
  `);
3313
3313
  m.push(
3314
- this.generateTextChangeCommandsForRegion(M, A, Q.id, S)
3314
+ this.generateTextChangeCommandsForRegion(F, A, Q.id, S)
3315
3315
  );
3316
3316
  const Y = new L(Q, d);
3317
3317
  return {
@@ -3369,8 +3369,8 @@ class kn {
3369
3369
  const Q = i.getProfanities(), m = We(l.toLowerCase());
3370
3370
  for (const I of m)
3371
3371
  for (const p in Q) {
3372
- const M = Q[p].toLowerCase().replace(/\s/g, "");
3373
- if (I === M)
3372
+ const F = Q[p].toLowerCase().replace(/\s/g, "");
3373
+ if (I === F)
3374
3374
  return o(!0), { error: "Blocked profanity." };
3375
3375
  }
3376
3376
  return !e.data.vertical && !e.data.allowNewlines && (l.includes(`
@@ -4846,8 +4846,8 @@ class Kn extends st {
4846
4846
  m.appendChild(I), I.appendChild(nA(3, 7, 4, "shadow"));
4847
4847
  const p = R("g");
4848
4848
  m.appendChild(p), p.setAttribute("filter", "url(#shadow)"), p.innerHTML = A;
4849
- const M = R("g");
4850
- m.appendChild(M), M.setAttribute("fill", "red"), M.setAttribute("stroke", "red"), M.setAttribute("stroke-width", "9"), M.innerHTML = A;
4849
+ const F = R("g");
4850
+ m.appendChild(F), F.setAttribute("fill", "red"), F.setAttribute("stroke", "red"), F.setAttribute("stroke-width", "9"), F.innerHTML = A;
4851
4851
  const y = R("g");
4852
4852
  m.appendChild(y), y.setAttribute("fill", "#9d2621"), y.setAttribute("transform", "translate(1,1)"), y.innerHTML = A;
4853
4853
  const S = R("g");
@@ -4886,8 +4886,8 @@ class Vn extends st {
4886
4886
  }
4887
4887
  brandSvg(e, t, A) {
4888
4888
  const n = e.toSVG(2), a = e.getBoundingBox(), i = a.y2 - a.y1, s = a.x2 - a.x1, o = e.toPathData(3), r = () => {
4889
- const p = R("g"), M = R("g");
4890
- p.appendChild(M), M.setAttribute("stroke", "#5C1A0D"), M.setAttribute("stroke-width", "4"), M.setAttribute("transform", "translate(1,1)"), M.innerHTML = n;
4889
+ const p = R("g"), F = R("g");
4890
+ p.appendChild(F), F.setAttribute("stroke", "#5C1A0D"), F.setAttribute("stroke-width", "4"), F.setAttribute("transform", "translate(1,1)"), F.innerHTML = n;
4891
4891
  const y = R("g");
4892
4892
  p.appendChild(y), y.setAttribute("fill", "#FFE386"), y.setAttribute("transform", "translate(1,1)"), y.innerHTML = n;
4893
4893
  const S = R("g");
@@ -4940,8 +4940,8 @@ class Xn extends st {
4940
4940
  I.classList.add("module-layer0"), f.appendChild(I), I.setAttribute("filter", "url(#shadow)"), I.innerHTML = m.outerHTML;
4941
4941
  const p = R("g");
4942
4942
  p.classList.add("module-layer1"), f.appendChild(p), p.setAttribute("stroke-width", "3"), p.setAttribute("stroke", "rgb(45,41,38)"), p.setAttribute("fill", "rgb(45,41,38)"), p.setAttribute("transform", "translate(0.5,0)"), p.innerHTML = s;
4943
- const M = R("g");
4944
- M.classList.add("module-layer2"), f.appendChild(M), M.setAttribute("fill", "rgb(255,209,0)"), M.setAttribute("transform", "translate(1,-0.1)"), M.innerHTML = s;
4943
+ const F = R("g");
4944
+ F.classList.add("module-layer2"), f.appendChild(F), F.setAttribute("fill", "rgb(255,209,0)"), F.setAttribute("transform", "translate(1,-0.1)"), F.innerHTML = s;
4945
4945
  const y = R("g");
4946
4946
  return y.classList.add("module-layer3"), f.appendChild(y), y.setAttribute("fill", "white"), y.innerHTML = s, new ct(f).transform(([Y, N]) => [Y, N + (r / 2 - Y) ** 2 / (r * 6)]), f;
4947
4947
  }, l = R("g");
@@ -5189,7 +5189,7 @@ class Zn {
5189
5189
  },
5190
5190
  { refocusCamera: t }
5191
5191
  );
5192
- this.setModelContainer(A), Ae(this.allScenes, this.stepSelections).filter((i) => i).map((i) => i.renderableSteps).flat().filter((i) => i.type === F.Model || i.type === F.Material).forEach((i) => {
5192
+ this.setModelContainer(A), Ae(this.allScenes, this.stepSelections).filter((i) => i).map((i) => i.renderableSteps).flat().filter((i) => i.type === M.Model || i.type === M.Material).forEach((i) => {
5193
5193
  var r, g, B;
5194
5194
  if (!((r = i.option) != null && r.id)) {
5195
5195
  console.error(`Failed to read option id from step: ${i.stepName}`);
@@ -5199,7 +5199,7 @@ class Zn {
5199
5199
  if (s.length === 0)
5200
5200
  return;
5201
5201
  const o = s[0];
5202
- if (i.type === F.Model) {
5202
+ if (i.type === M.Model) {
5203
5203
  if (!this.modelContainer)
5204
5204
  throw new k(
5205
5205
  "We should always have a model container when injecting a preview!"
@@ -5333,17 +5333,17 @@ class Zn {
5333
5333
  ), e), []);
5334
5334
  }
5335
5335
  getInvalidModelVariants() {
5336
- return this.workflow.steps.reduce((e, t) => (t.type === F.Model && !ne(t, this.stepSelections) && e.push(t.stepName), e), []);
5336
+ return this.workflow.steps.reduce((e, t) => (t.type === M.Model && !ne(t, this.stepSelections) && e.push(t.stepName), e), []);
5337
5337
  }
5338
5338
  async stepElementsForIntroducedSilentSteps(e, t) {
5339
5339
  const A = this.product;
5340
5340
  if (!A)
5341
5341
  return Promise.resolve({ stepElements: {}, commands: [] });
5342
5342
  const n = async (r, g, B) => {
5343
- if (r.type === F.SilentIllustration) {
5343
+ if (r.type === M.SilentIllustration) {
5344
5344
  const l = await new pt(r, g).trigger();
5345
5345
  return { step: r, results: l };
5346
- } else if (r.type === F.ProductOverlay) {
5346
+ } else if (r.type === M.ProductOverlay) {
5347
5347
  const l = await new pt(
5348
5348
  r,
5349
5349
  g,
@@ -5393,7 +5393,7 @@ class Zn {
5393
5393
  this.stepSelections = {
5394
5394
  ...this.stepSelections,
5395
5395
  [e]: { selectedVariants: t }
5396
- }, this.selectionCost = Object.values(this.stepSelections).reduce((I, p) => I + p.selectedVariants.map((M) => M.priceModifier || 0).reduce((M, y) => M + y, 0), 0), this.workflow.steps.forEach((I) => {
5396
+ }, this.selectionCost = Object.values(this.stepSelections).reduce((I, p) => I + p.selectedVariants.map((F) => F.priceModifier || 0).reduce((F, y) => F + y, 0), 0), this.workflow.steps.forEach((I) => {
5397
5397
  ne(I, this.stepSelections) || (this.stepInitialised[I.stepName] = !1, delete this.stepMetadata[I.stepName], delete this.stepSelections[I.stepName], delete this.storage[I.stepName]);
5398
5398
  });
5399
5399
  const i = this.allScenes, s = Ae(i, a), o = Ae(i, this.stepSelections), r = s.map((I) => I.silentSteps).flat(), B = o.map((I) => I.silentSteps).flat().filter(
@@ -5409,7 +5409,7 @@ class Zn {
5409
5409
  [e]: A
5410
5410
  }, this.removeElements(l);
5411
5411
  const h = this.workflow.steps.find((I) => I.stepName === e);
5412
- if ((h == null ? void 0 : h.type) === F.Frame) {
5412
+ if ((h == null ? void 0 : h.type) === M.Frame) {
5413
5413
  const I = this.getStepSpecificServices(e);
5414
5414
  (m = I == null ? void 0 : I.frameService) == null || m.setTargetElements(A.map((p) => p.id));
5415
5415
  }
@@ -5435,7 +5435,7 @@ class Zn {
5435
5435
  for (const o of n)
5436
5436
  if (!this.stepInitialised[o.stepName])
5437
5437
  switch (this.stepInitialised[o.stepName] = !0, o.type) {
5438
- case F.DigitalContent:
5438
+ case M.DigitalContent:
5439
5439
  A.push(
5440
5440
  Fn.init(
5441
5441
  o,
@@ -5444,8 +5444,8 @@ class Zn {
5444
5444
  )
5445
5445
  );
5446
5446
  break;
5447
- case F.Frame:
5448
- case F.Photo:
5447
+ case M.Frame:
5448
+ case M.Photo:
5449
5449
  {
5450
5450
  const r = new pn(o.data.forceImageCover);
5451
5451
  r.connectWorkflowManager(this, o.stepName), this.stepSpecificServices[o.stepName] = {
@@ -5455,40 +5455,40 @@ class Zn {
5455
5455
  );
5456
5456
  }
5457
5457
  break;
5458
- case F.Illustration:
5458
+ case M.Illustration:
5459
5459
  A.push(
5460
5460
  fe.init(o, this, this.reloadedState)
5461
5461
  );
5462
5462
  break;
5463
- case F.Material:
5463
+ case M.Material:
5464
5464
  A.push(
5465
5465
  Zt.init(o, this, this.reloadedState)
5466
5466
  );
5467
5467
  break;
5468
- case F.Model:
5468
+ case M.Model:
5469
5469
  A.push($t.init(o, this, this.reloadedState));
5470
5470
  break;
5471
- case F.Module:
5471
+ case M.Module:
5472
5472
  this.stepSpecificServices[o.stepName] = {
5473
5473
  module: await iA(o.data.module)
5474
5474
  }, A.push(
5475
5475
  Pn.init(o, this, this.reloadedState)
5476
5476
  );
5477
5477
  break;
5478
- case F.Picture:
5478
+ case M.Picture:
5479
5479
  A.push(
5480
5480
  _t.init(o, this, this.reloadedState)
5481
5481
  );
5482
5482
  break;
5483
- case F.Question:
5483
+ case M.Question:
5484
5484
  A.push(
5485
5485
  eA.init(o, this, this.reloadedState)
5486
5486
  );
5487
5487
  break;
5488
- case F.Shape:
5488
+ case M.Shape:
5489
5489
  A.push(re.init(o, this, this.reloadedState));
5490
5490
  break;
5491
- case F.Text:
5491
+ case M.Text:
5492
5492
  A.push(K.init(o, this, this.reloadedState));
5493
5493
  break;
5494
5494
  }
@@ -6125,23 +6125,23 @@ class ia extends W {
6125
6125
  class he {
6126
6126
  static get(e, t) {
6127
6127
  switch (t.type) {
6128
- case F.Information:
6128
+ case M.Information:
6129
6129
  return new ia(e, t);
6130
- case F.Question:
6130
+ case M.Question:
6131
6131
  return new Aa(e, t);
6132
- case F.Text:
6132
+ case M.Text:
6133
6133
  return new aa(e, t);
6134
- case F.Illustration:
6134
+ case M.Illustration:
6135
6135
  return new $n(e, t);
6136
- case F.Picture:
6136
+ case M.Picture:
6137
6137
  return new ta(e, t);
6138
- case F.Shape:
6138
+ case M.Shape:
6139
6139
  return new na(e, t);
6140
- case F.Material:
6140
+ case M.Material:
6141
6141
  return new _n(e, t);
6142
- case F.Model:
6142
+ case M.Model:
6143
6143
  return new ea(e, t);
6144
- case F.Frame:
6144
+ case M.Frame:
6145
6145
  return new Mi(e, t);
6146
6146
  default:
6147
6147
  throw new k(`Step type ${t.type} not yet supported in Core SDK`);
@@ -6343,7 +6343,7 @@ const oA = D`
6343
6343
  };
6344
6344
  return a && (d.metadata = a), A && (d.selectedVariants = A), n && (d.sku = n), d;
6345
6345
  }, cA = async (c, e, t, A, n, a, i, s, o, r) => {
6346
- var M;
6346
+ var F;
6347
6347
  await (async () => {
6348
6348
  var O;
6349
6349
  if (r !== void 0)
@@ -6362,7 +6362,7 @@ const oA = D`
6362
6362
  N.errors && console.log("Server Error:", b.message);
6363
6363
  }), null) : H ?? null;
6364
6364
  })() || (console.warn("State mismatch detected. Uploading known state explicitly"), console.warn("State Object:", JSON.stringify(A())), await c.updateStateWithServerImmediate(A), console.log("Server state is undefined @ Workflow completion"));
6365
- const l = c.getPreviewService(), d = (M = e == null ? void 0 : e.finalizeStepConfig) == null ? void 0 : M.lookAtAnimation, w = l && e.showModelOnFinishStep && !!d, h = o && Ze(o, e, !0), E = o && Ze(o, e, !1), u = async (y) => {
6365
+ const l = c.getPreviewService(), d = (F = e == null ? void 0 : e.finalizeStepConfig) == null ? void 0 : F.lookAtAnimation, w = l && e.showModelOnFinishStep && !!d, h = o && Ze(o, e, !0), E = o && Ze(o, e, !1), u = async (y) => {
6366
6366
  const S = {};
6367
6367
  let Y = 0;
6368
6368
  if (Object.keys(a).length > 0)
@@ -6913,7 +6913,7 @@ class Ce {
6913
6913
  * @returns Returns true when a valid handle is implemented for a given step type. Certain steps don't support handles, such as silent illustrations.
6914
6914
  */
6915
6915
  stepHasHandle(e) {
6916
- return e.type !== F.SilentIllustration && e.type !== F.ProductOverlay;
6916
+ return e.type !== M.SilentIllustration && e.type !== M.ProductOverlay;
6917
6917
  }
6918
6918
  getExportedData() {
6919
6919
  var n;
@@ -7084,9 +7084,9 @@ const ha = [
7084
7084
  const h = {};
7085
7085
  RA(w, (p) => {
7086
7086
  ha.includes(p.tagName) && !p.attributes.getNamedItem("fill") && p.setAttribute("fill", "#000000");
7087
- const M = p.attributes.getNamedItem("fill");
7088
- if (M && M.value !== "none") {
7089
- const S = M.value, N = `spiff-fill-${S.replace(/\W/g, "")}`;
7087
+ const F = p.attributes.getNamedItem("fill");
7088
+ if (F && F.value !== "none") {
7089
+ const S = F.value, N = `spiff-fill-${S.replace(/\W/g, "")}`;
7090
7090
  p.classList.add(N), h[N] = { browserValue: S };
7091
7091
  }
7092
7092
  const y = p.attributes.getNamedItem("stroke");
@@ -7097,16 +7097,16 @@ const ha = [
7097
7097
  });
7098
7098
  const u = vt().serializeToString(w), C = n.colors;
7099
7099
  if (C) {
7100
- for (const [p, M] of Object.entries(h))
7100
+ for (const [p, F] of Object.entries(h))
7101
7101
  for (const y of Object.keys(C))
7102
- if (M.browserValue === y) {
7102
+ if (F.browserValue === y) {
7103
7103
  h[p] = { browserValue: C[y] };
7104
7104
  break;
7105
7105
  }
7106
7106
  }
7107
7107
  const f = (p) => {
7108
- const M = c.find((S) => S.panelId === p.panelId);
7109
- if (!M)
7108
+ const F = c.find((S) => S.panelId === p.panelId);
7109
+ if (!F)
7110
7110
  throw new z(p);
7111
7111
  const y = J();
7112
7112
  return new L(
@@ -7124,7 +7124,7 @@ const ha = [
7124
7124
  layerIndex: p.layerIndex,
7125
7125
  immutable: p.immutable
7126
7126
  },
7127
- M
7127
+ F
7128
7128
  );
7129
7129
  }, Q = A.data.regions;
7130
7130
  try {
@@ -7264,7 +7264,7 @@ const ha = [
7264
7264
  }, fa = async (c, e, t) => {
7265
7265
  const A = [], a = (() => {
7266
7266
  var r, g;
7267
- return e.type === F.ProductOverlay ? t || ((r = e.data.asset) == null ? void 0 : r.fileLink) || "" : ((g = e.data.asset) == null ? void 0 : g.fileLink) || "";
7267
+ return e.type === M.ProductOverlay ? t || ((r = e.data.asset) == null ? void 0 : r.fileLink) || "" : ((g = e.data.asset) == null ? void 0 : g.fileLink) || "";
7268
7268
  })(), s = (() => a.endsWith(".jpeg") || a.endsWith(".jpg") || a.endsWith(".png") ? v.Image : a.endsWith(".svg") ? v.Illustration : v.Illustration)(), o = e.data.regions;
7269
7269
  if (s === "image")
7270
7270
  try {
@@ -7282,7 +7282,7 @@ const ha = [
7282
7282
  height: r.height,
7283
7283
  layer: r.layer,
7284
7284
  layerIndex: r.layerIndex,
7285
- productOverlay: e.type === F.ProductOverlay ? !0 : void 0,
7285
+ productOverlay: e.type === M.ProductOverlay ? !0 : void 0,
7286
7286
  scaleX: 1,
7287
7287
  scaleY: 1,
7288
7288
  rotation: r.rotation,
@@ -7321,7 +7321,7 @@ const ha = [
7321
7321
  scaleX: 1,
7322
7322
  scaleY: 1,
7323
7323
  rotation: B.rotation,
7324
- productOverlay: e.type === F.ProductOverlay ? !0 : void 0,
7324
+ productOverlay: e.type === M.ProductOverlay ? !0 : void 0,
7325
7325
  excludeFromExport: e.data.excludeFromPrint
7326
7326
  };
7327
7327
  A.push(new L(d, l));
@@ -7432,18 +7432,18 @@ const ha = [
7432
7432
  const s = e.steps.find((o) => o.stepName === i.name);
7433
7433
  if (s)
7434
7434
  switch (s.type) {
7435
- case F.DigitalContent:
7435
+ case M.DigitalContent:
7436
7436
  n.push(
7437
7437
  ...await Ca(t, i, s)
7438
7438
  );
7439
7439
  break;
7440
- case F.Frame:
7441
- case F.Photo:
7440
+ case M.Frame:
7441
+ case M.Photo:
7442
7442
  n.push(
7443
7443
  ...await ua(t, a, i, s)
7444
7444
  );
7445
7445
  break;
7446
- case F.Illustration:
7446
+ case M.Illustration:
7447
7447
  n.push(
7448
7448
  ...await Qa(
7449
7449
  t,
@@ -7453,20 +7453,20 @@ const ha = [
7453
7453
  )
7454
7454
  );
7455
7455
  break;
7456
- case F.Module:
7456
+ case M.Module:
7457
7457
  n.push(...await ma(t, i, s));
7458
7458
  break;
7459
- case F.Picture:
7459
+ case M.Picture:
7460
7460
  n.push(
7461
7461
  ...await Ia(t, a, i, s)
7462
7462
  );
7463
7463
  break;
7464
- case F.Shape:
7464
+ case M.Shape:
7465
7465
  n.push(
7466
7466
  ...await pa(t, a, i, s)
7467
7467
  );
7468
7468
  break;
7469
- case F.Text:
7469
+ case M.Text:
7470
7470
  n.push(
7471
7471
  ...await Da(t, a, i, s)
7472
7472
  );
@@ -7474,7 +7474,7 @@ const ha = [
7474
7474
  }
7475
7475
  }
7476
7476
  for (const i of e.steps)
7477
- i.type !== F.SilentIllustration && i.type !== F.ProductOverlay || Fa(i, a) && n.push(
7477
+ i.type !== M.SilentIllustration && i.type !== M.ProductOverlay || Fa(i, a) && n.push(
7478
7478
  ...await fa(t, i, A)
7479
7479
  );
7480
7480
  return n;
@@ -7646,7 +7646,7 @@ const Ji = (c, e) => {
7646
7646
  const t = [];
7647
7647
  return c.forEach((A) => {
7648
7648
  const n = e.steps.find((a) => a.stepName === A.stepName);
7649
- (n == null ? void 0 : n.type) === F.Text && A.stepAspectType === "Text" && t.push({
7649
+ (n == null ? void 0 : n.type) === M.Text && A.stepAspectType === "Text" && t.push({
7650
7650
  name: n.stepName,
7651
7651
  data: {
7652
7652
  text: A.value
@@ -10308,26 +10308,29 @@ class Di {
10308
10308
  * @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
10309
10309
  */
10310
10310
  async getExistingBundle(e, t, A, n) {
10311
- var l, d, w, h, E, u, C, f;
10312
- const a = x.getMap("bundleOwnerIds"), i = a == null ? void 0 : a.get(e), s = {
10311
+ var E, u, C, f, Q, m, I, p, F;
10312
+ const a = x.getMap("bundleOwnerIds"), i = a == null ? void 0 : a.get(e), o = ((E = Object.entries(localStorage).find(([y, S]) => y.startsWith("CognitoIdentityServiceProvider") && y.endsWith("idToken"))) == null ? void 0 : E[0]) || "", r = localStorage.getItem(o), g = {};
10313
+ r && (g.Authorization = `Bearer ${r}`);
10314
+ const B = {
10313
10315
  bundleOwnerId: i,
10314
- ...(l = n == null ? void 0 : n.graphql) == null ? void 0 : l.additionalHeaders
10315
- }, o = await P.getShadowGraphqlClient().query({
10316
- query: Na(((w = (d = n == null ? void 0 : n.graphql) == null ? void 0 : d.productCollection) == null ? void 0 : w.eagerFetchProducts) || !1),
10316
+ ...g,
10317
+ ...(u = n == null ? void 0 : n.graphql) == null ? void 0 : u.additionalHeaders
10318
+ }, l = await P.getShadowGraphqlClient().query({
10319
+ query: Na(((f = (C = n == null ? void 0 : n.graphql) == null ? void 0 : C.productCollection) == null ? void 0 : f.eagerFetchProducts) || !1),
10317
10320
  variables: {
10318
10321
  id: e
10319
10322
  },
10320
10323
  fetchPolicy: "no-cache",
10321
10324
  context: {
10322
- headers: s
10325
+ headers: B
10323
10326
  }
10324
10327
  });
10325
- if (!((h = o.data) != null && h.bundles) || ((E = o.data) == null ? void 0 : E.bundles.length) === 0 || !((u = o.data) != null && u.bundles[0]))
10328
+ if (!((Q = l.data) != null && Q.bundles) || ((m = l.data) == null ? void 0 : m.bundles.length) === 0 || !((I = l.data) != null && I.bundles[0]))
10326
10329
  throw new Error(`Unable to find bundle: ${e}`);
10327
- const r = (C = o.data) == null ? void 0 : C.bundles[0], g = x.getMap("bundlePartnerIds") || /* @__PURE__ */ new Map();
10328
- g.set(r.id, r.partner.id), x.setMap("bundlePartnerIds", g);
10329
- const B = new Ft(this, r, t, A, i, { additionalHeaders: (f = n == null ? void 0 : n.graphql) == null ? void 0 : f.additionalHeaders });
10330
- return await B.getInitializationPromise(), B;
10330
+ const d = (p = l.data) == null ? void 0 : p.bundles[0], w = x.getMap("bundlePartnerIds") || /* @__PURE__ */ new Map();
10331
+ w.set(d.id, d.partner.id), x.setMap("bundlePartnerIds", w);
10332
+ const h = new Ft(this, d, t, A, i, { additionalHeaders: (F = n == null ? void 0 : n.graphql) == null ? void 0 : F.additionalHeaders });
10333
+ return await h.getInitializationPromise(), h;
10331
10334
  }
10332
10335
  /**
10333
10336
  * Retrieves all existing bundle stakeholders from the API, for the currently authenticated customer.
@@ -10391,7 +10394,7 @@ class Di {
10391
10394
  const p = n.type === "integration" ? { integrationProductId: n.integrationProductId } : {
10392
10395
  externalIntegrationId: n.externalIntegrationId,
10393
10396
  externalProductId: n.externalProductId
10394
- }, M = await E.mutate({
10397
+ }, F = await E.mutate({
10395
10398
  mutation: It,
10396
10399
  variables: {
10397
10400
  ...p,
@@ -10403,9 +10406,9 @@ class Di {
10403
10406
  // TODO: this should be changed to required once the API is updated. Should this also be moved to server.ts?
10404
10407
  context: this.options.applicationKey ? { headers: { "X-Application-Key": this.options.applicationKey } } : void 0
10405
10408
  });
10406
- if (!M.data || !M.data.transactionCreate)
10409
+ if (!F.data || !F.data.transactionCreate)
10407
10410
  throw new U("Failed to create transaction!");
10408
- const y = M.data.transactionCreate;
10411
+ const y = F.data.transactionCreate;
10409
10412
  if (!y.product)
10410
10413
  throw new U("Failed to create transaction, product not available.");
10411
10414
  return y;
@@ -10478,12 +10481,12 @@ class Di {
10478
10481
  },
10479
10482
  errorPolicy: "all",
10480
10483
  fetchPolicy: "no-cache"
10481
- }), M = p.data.transactions;
10482
- if (M.length !== m.length) {
10484
+ }), F = p.data.transactions;
10485
+ if (F.length !== m.length) {
10483
10486
  const Y = ((S = (y = p.errors) == null ? void 0 : y[0]) == null ? void 0 : S.message) || "Unknown error";
10484
10487
  throw new U(`Not all transactions were found: ${Y}`);
10485
10488
  }
10486
- return M.map((Y, N) => {
10489
+ return F.map((Y, N) => {
10487
10490
  var H;
10488
10491
  return {
10489
10492
  transaction: Y,
@@ -10493,7 +10496,7 @@ class Di {
10493
10496
  };
10494
10497
  });
10495
10498
  }, a = async (m) => {
10496
- var M, y, S;
10499
+ var F, y, S;
10497
10500
  if (m.length === 0)
10498
10501
  return [];
10499
10502
  const I = await A.mutate({
@@ -10509,7 +10512,7 @@ class Di {
10509
10512
  },
10510
10513
  errorPolicy: "all",
10511
10514
  fetchPolicy: "no-cache"
10512
- }), p = (M = I.data) == null ? void 0 : M.transactionCreateMany;
10515
+ }), p = (F = I.data) == null ? void 0 : F.transactionCreateMany;
10513
10516
  if (!p || p.length === 0) {
10514
10517
  const Y = ((S = (y = I.errors) == null ? void 0 : y[0]) == null ? void 0 : S.message) || "Unknown error";
10515
10518
  throw new U(`Failed to create transactions: ${Y}`);
@@ -10527,24 +10530,24 @@ class Di {
10527
10530
  ...g.map(a)
10528
10531
  ])).flat(), l = [...new Set(B.map((m) => m.workflowId))], d = await wA(l, t), w = new Map(d.map((m) => [m.id, m])), h = x.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), E = B.map(async (m) => {
10529
10532
  var O;
10530
- const { transaction: I, workflowId: p, readOnly: M, index: y } = m, S = w.get(p), Y = e[y];
10533
+ const { transaction: I, workflowId: p, readOnly: F, index: y } = m, S = w.get(p), Y = e[y];
10531
10534
  !h.get(I.id) && I.transactionOwnerId && h.set(I.id, I.transactionOwnerId);
10532
10535
  const N = h.get(I.id) || void 0, H = {
10533
10536
  product: I.product,
10534
10537
  transaction: I,
10535
10538
  layouts: [],
10536
10539
  singleVariantsRenderable: (O = Y == null ? void 0 : Y.workflowConfiguration) == null ? void 0 : O.singleVariantsRenderable,
10537
- stateMutationFunc: M ? async () => {
10540
+ stateMutationFunc: F ? async () => {
10538
10541
  throw new k("State mutation is forbidden in read only mode!");
10539
10542
  } : async (b) => this.updateTransactionState({ ...b, context: { transactionOwnerId: N } }),
10540
- readOnly: M,
10543
+ readOnly: F,
10541
10544
  workflow: S,
10542
10545
  isReloadedTransaction: Y.type === "transaction"
10543
10546
  };
10544
10547
  if (Y.type === "transaction" && I.workflowState) {
10545
10548
  const b = JSON.parse(I.workflowState);
10546
10549
  H.layouts = Object.values(b.layouts || {}).map((V) => V.layout), await ee(b), await te(b), H.reloadedState = b;
10547
- } else if (!M && Y.workflowState) {
10550
+ } else if (!F && Y.workflowState) {
10548
10551
  const b = JSON.parse(Y.workflowState);
10549
10552
  H.layouts = Object.values(b.layouts || {}).map((V) => V.layout), await ee(b), await te(b), H.reloadedState = b;
10550
10553
  } else
@@ -10558,8 +10561,8 @@ class Di {
10558
10561
  });
10559
10562
  x.setMap("transactionOwnerIds", h);
10560
10563
  const f = (await Promise.all(E)).sort((m, I) => m.index - I.index).map(async (m) => {
10561
- const { experienceOptions: I, options: p } = m, M = new Ce(this, I);
10562
- return await M.getWorkflowManager().getInitializationPromise(), p.type !== "transaction" && this.customer && await M.attachCustomerDetails({ email: this.customer.emailAddress }), M;
10564
+ const { experienceOptions: I, options: p } = m, F = new Ce(this, I);
10565
+ return await F.getWorkflowManager().getInitializationPromise(), p.type !== "transaction" && this.customer && await F.attachCustomerDetails({ email: this.customer.emailAddress }), F;
10563
10566
  }), Q = await Promise.all(f);
10564
10567
  return Q.forEach((m) => m.getWorkflowManager().setWorkflowStateSyncEnabled(!0)), Q;
10565
10568
  }
@@ -3010,4 +3010,4 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
3010
3010
  }
3011
3011
  }
3012
3012
  }
3013
- `,ne=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await g.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await g.loadFont(i.fontData.assetUrl)}}},ma=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:la(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&k.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&k.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(l=>{l.asset&&k.cacheAsset(l.asset),l.displayImage&&k.cacheAsset(l.displayImage),l.thumbnail&&k.cacheAsset(l.thumbnail),l.material&&k.cacheMaterial(l.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Ia=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},qe=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=ma(A,e),a=A.map(o=>Z.set({id:o,options:e},Ia(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},we=async(c,e)=>(await qe([c],e))[0],fa=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:g.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),Ze=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):fa(e.panels)};class oA{constructor(e){this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:HA})}catch(A){throw console.error(A),new G("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&dA(this.options.applicationKey)}getAssetManager(){return k}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!wA())throw new Error("Application key required to use Flow Service.");return new nA}async getIntegration(){return(await N.getShadowGraphqlClient().query({query:da,errorPolicy:"all"})).data.currentIntegration}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:re.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const l=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(d=>{var B;return((B=d.bundle)==null?void 0:B.id)===e});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var l,d,B,w,E,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:Ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((d=(l=n.product)==null?void 0:l.partner)==null?void 0:d.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:re.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const h=o.get(e);if(h&&await this.authenticateCustomerId(h)){const u=((w=(B=this.customer)==null?void 0:B.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((C=(E=this.customer)==null?void 0:E.stakeholders)==null?void 0:C.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(u)return Promise.resolve({success:!0,stakeholderType:u.type})}}const r=(await t.query({query:wa,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Ca,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),rt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Qa,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:ua,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),rt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,l;const a=(l=(await N.getShadowGraphqlClient().mutate({mutation:Ln(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((d,B)=>({key:d[0],value:d[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:l.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new AA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var B,w,E,C,h,m,u,F;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),o={bundleOwnerId:i,...(B=n==null?void 0:n.graphql)==null?void 0:B.additionalHeaders},s=await N.getShadowGraphqlClient().query({query:kn(((E=(w=n==null?void 0:n.graphql)==null?void 0:w.productCollection)==null?void 0:E.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:o}});if(!((C=s.data)!=null&&C.bundles)||((h=s.data)==null?void 0:h.bundles.length)===0||!((m=s.data)!=null&&m.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const r=(u=s.data)==null?void 0:u.bundles[0],l=P.getMap("bundlePartnerIds")||new Map;l.set(r.id,r.partner.id),P.setMap("bundlePartnerIds",l);const d=new AA(this,r,t,A,i,{additionalHeaders:(F=n==null?void 0:n.graphql)==null?void 0:F.additionalHeaders});return await d.getInitializationPromise(),d}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:Jn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var d,B,w,E,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,u;const h=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await h.query({query:ue,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new G("Existing transaction not found.");const D=(u=f.data)==null?void 0:u.transactions[0];if(!D.workflowId)throw new G("Existing transaction has no workflow ID.");const p=await we(D.workflowId);if(!D.product)throw new G("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},S=await h.mutate({mutation:Et,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!S.data||!S.data.transactionCreate)throw new G("Failed to create transaction!");const y=S.data.transactionCreate;if(!y.product)throw new G("Failed to create transaction, product not available.");return y},I=we(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new G("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(d=i.product.partner)==null?void 0:d.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(B=n==null?void 0:n.workflowConfiguration)==null?void 0:B.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async h=>{const u=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...h,context:{transactionOwnerId:u}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const h=JSON.parse(i.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await ne(h),r.reloadedState=h}else if(!s&&n.workflowState){const h=JSON.parse(n.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await ne(h),r.reloadedState=h}else r.layouts=Ze(r.transaction,r.workflow);if(r.renderableContextService=new Me(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(E=r.product)!=null&&E.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const h=P.getMap("transactionOwnerIds")||new Map;h.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",h)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const l=new Be(this,r);return await l.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await l.attachCustomerDetails({email:this.customer.emailAddress}),l}async getWorkflowExperiences(e,t){if(e.length===0)throw new G("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var y,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:ue,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),S=p.data.transactions;if(S.length!==f.length){const Y=((x=(y=p.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Not all transactions were found: ${Y}`)}return S.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var S,y,x;if(f.length===0)return[];const D=await A.mutate({mutation:xA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(S=D.data)==null?void 0:S.transactionCreateMany;if(!p||p.length===0){const Y=((x=(y=D.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=at(o,10),l=at(s,10),d=(await Promise.all([...r.map(n),...l.map(a)])).flat(),B=[...new Set(d.map(f=>f.workflowId))],w=await qe(B,t),E=new Map(w.map(f=>[f.id,f])),C=P.getMap("transactionOwnerIds")||new Map,h=d.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:S,index:y}=f,x=E.get(p),Y=e[y];!C.get(D.id)&&D.transactionOwnerId&&C.set(D.id,D.transactionOwnerId);const H=C.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:S?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:S,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const b=JSON.parse(D.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await g.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else if(!S&&Y.workflowState){const b=JSON.parse(Y.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await g.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else R.layouts=Ze(R.transaction,R.workflow);return R.renderableContextService=new Me(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:y,options:Y}});P.setMap("transactionOwnerIds",C);const F=(await Promise.all(h)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,S=new Be(this,D);return await S.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await S.attachCustomerDetails({email:this.customer.emailAddress}),S}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new G("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:Et,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new G("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new G("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,l;if(e==="")throw new G("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,E;const B=(w=(await A.query({query:ue,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(E=B.product.partner)==null?void 0:E.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async()=>{throw new v("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const B=(o=(await A.query({query:ue,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(s=B.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const B=(r=(await A.mutate({mutation:NA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(l=B.product.partner)==null?void 0:l.currencyCode,B.transactionOwnerId&&(a.set(B.id,B.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:B.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new G("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new G("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await we(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const l=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(l.layouts).map(d=>d.layout),await g.rehydrateSerializedLayout(l),await ne(l),this.experienceOptions.reloadedState=l}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new Be(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),l=N.getShadowGraphqlClient().mutate({mutation:RA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),d=we(e);if(await Promise.all([l,d]),this.experienceOptions.workflow=await d,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(E=>E.layout),await g.rehydrateSerializedLayout(w),await ne(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=Ze(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await d),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const B=new Be(this,this.experienceOptions);return await B.getWorkflowManager().getInitializationPromise(),B}throw new G("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A)}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:GA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new Xe(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:vA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new Xe(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class Da{getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var sA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(sA||{});class rA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return Ie.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}selectImage(e){return Ie.selectImage(this.step,e,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}}Object.defineProperty(Q,"AspectType",{enumerable:!0,get:()=>g.AspectType}),Object.defineProperty(Q,"AssetType",{enumerable:!0,get:()=>g.AssetType}),Object.defineProperty(Q,"BringForwardCommand",{enumerable:!0,get:()=>g.BringForwardCommand}),Object.defineProperty(Q,"BringToBackCommand",{enumerable:!0,get:()=>g.BringToBackCommand}),Object.defineProperty(Q,"BringToFrontCommand",{enumerable:!0,get:()=>g.BringToFrontCommand}),Object.defineProperty(Q,"CanvasCommand",{enumerable:!0,get:()=>g.CanvasCommand}),Object.defineProperty(Q,"CommandContext",{enumerable:!0,get:()=>g.CommandContext}),Object.defineProperty(Q,"CreateElementCommand",{enumerable:!0,get:()=>g.CreateElementCommand}),Object.defineProperty(Q,"CreateLayoutCommand",{enumerable:!0,get:()=>g.CreateLayoutCommand}),Object.defineProperty(Q,"DeleteElementCommand",{enumerable:!0,get:()=>g.DeleteElementCommand}),Object.defineProperty(Q,"FontAlignmentCommand",{enumerable:!0,get:()=>g.FontAlignmentCommand}),Object.defineProperty(Q,"FontColorCommand",{enumerable:!0,get:()=>g.FontColorCommand}),Object.defineProperty(Q,"FontSizeCommand",{enumerable:!0,get:()=>g.FontSizeCommand}),Object.defineProperty(Q,"FontSourceCommand",{enumerable:!0,get:()=>g.FontSourceCommand}),Object.defineProperty(Q,"GroupCommand",{enumerable:!0,get:()=>g.GroupCommand}),Object.defineProperty(Q,"LayoutElementFactory",{enumerable:!0,get:()=>g.LayoutElementFactory}),Object.defineProperty(Q,"LayoutElementType",{enumerable:!0,get:()=>g.LayoutElementType}),Object.defineProperty(Q,"MoveCommand",{enumerable:!0,get:()=>g.MoveCommand}),Object.defineProperty(Q,"ResizeCommand",{enumerable:!0,get:()=>g.ResizeCommand}),Object.defineProperty(Q,"RotateCommand",{enumerable:!0,get:()=>g.RotateCommand}),Object.defineProperty(Q,"SendBackwardsCommand",{enumerable:!0,get:()=>g.SendBackwardsCommand}),Object.defineProperty(Q,"StepAspectType",{enumerable:!0,get:()=>g.StepAspectType}),Object.defineProperty(Q,"StepType",{enumerable:!0,get:()=>g.StepType}),Object.defineProperty(Q,"TextChangeCommand",{enumerable:!0,get:()=>g.TextChangeCommand}),Object.defineProperty(Q,"UnitOfMeasurement",{enumerable:!0,get:()=>g.UnitOfMeasurement}),Object.defineProperty(Q,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>g.dataUrlFromExternalUrl}),Object.defineProperty(Q,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>g.determineCorrectFontSizeAndLines}),Object.defineProperty(Q,"findElement",{enumerable:!0,get:()=>g.findElement}),Object.defineProperty(Q,"frameDataCache",{enumerable:!0,get:()=>g.frameDataCache}),Object.defineProperty(Q,"generate",{enumerable:!0,get:()=>g.generate}),Object.defineProperty(Q,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>g.generateSVGWithUnknownColors}),Object.defineProperty(Q,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>g.getAttributesFromArrayBuffer}),Object.defineProperty(Q,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>g.getAxisAlignedBoundingBox}),Object.defineProperty(Q,"getFrameData",{enumerable:!0,get:()=>g.getFrameData}),Object.defineProperty(Q,"getSvgElement",{enumerable:!0,get:()=>g.getSvgElement}),Object.defineProperty(Q,"loadFont",{enumerable:!0,get:()=>g.loadFont}),Object.defineProperty(Q,"patternImageDataCache",{enumerable:!0,get:()=>g.patternImageDataCache}),Object.defineProperty(Q,"registerFetchImplementation",{enumerable:!0,get:()=>g.registerFetchImplementation}),Object.defineProperty(Q,"registerWindowImplementation",{enumerable:!0,get:()=>g.registerWindowImplementation}),Object.defineProperty(Q,"rehydrateSerializedLayout",{enumerable:!0,get:()=>g.rehydrateSerializedLayout}),Object.defineProperty(Q,"setCanvasModule",{enumerable:!0,get:()=>g.setCanvasModule}),Q.ArrayInput=oa,Q.AssetNotFoundError=V,Q.CollectionProduct=ye,Q.ColorOptionGlobalPropertyHandle=$t,Q.ConversionDataType=wt,Q.ConversionLocation=dt,Q.FileUploadGlobalPropertyHandle=qt,Q.FlowExecutionNodeResult=de,Q.FlowExecutionResult=aA,Q.FlowService=nA,Q.FrameService=ut,Q.FrameStep=sA,Q.FrameStepHandle=rA,Q.GlobalPropertyHandle=Se,Q.IllustrationStepHandle=Rt,Q.InformationMessageType=le,Q.InformationStepHandle=Tt,Q.IntegrationProduct=Xe,Q.IntegrationType=lt,Q.LayoutNotFoundError=J,Q.MaterialStepHandle=Ut,Q.MisconfigurationError=oe,Q.MockWorkflowManager=Da,Q.ModelStepHandle=Gt,Q.ObjectInput=We,Q.ObjectInputType=iA,Q.OptionGlobalPropertyHandle=Ke,Q.OptionNotFoundError=ie,Q.ParseError=q,Q.PictureStepHandle=vt,Q.ProductCameraRig=Bt,Q.ProductCollection=_t,Q.ProductWorkflow=Ae,Q.PromiseCache=Z,Q.PromiseQueue=Ue,Q.QuestionStepHandle=kt,Q.QueueablePromise=Re,Q.ResourceNotFoundError=X,Q.ShapeStepHandle=bt,Q.SpiffCommerceClient=oA,Q.StakeholderType=re,Q.StepHandle=j,Q.TextGlobalPropertyHandle=Zt,Q.TextInput=ia,Q.TextStepHandle=Jt,Q.Transform=tA,Q.TransformCollection=eA,Q.UnhandledBehaviorError=v,Q.Variant=K,Q.WorkflowExperienceEventType=Kt,Q.WorkflowExperienceImpl=Be,Q.assetService=k,Q.createDesign=jt,Q.designService=Fe,Q.digitalContentStepService=Dt,Q.frameStepService=Ie,Q.generateCommands=Vt,Q.generateStateFromDesignInputSteps=Gn,Q.getBoundedOffsets=Qt,Q.getWorkflow=we,Q.getWorkflows=qe,Q.graphQlManager=N,Q.illustrationStepService=ge,Q.materialStepService=Ge,Q.modelStepService=ve,Q.moduleStepService=pt,Q.optionService=L,Q.persistenceService=P,Q.pictureStepService=ke,Q.questionStepService=be,Q.shapeStepService=te,Q.shortenUrl=It,Q.spiffCoreConfiguration=W,Q.stepAspectValuesToDesignInputSteps=Un,Q.textStepService=O,Q.toast=Ft,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})});
3013
+ `,ne=async c=>{var e;for(const t in c.layouts){const A=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Illustration);for(let a=0;a<A.length;++a){const i=A[a];i.src&&i.svg&&(i.cachedObjectURL=await g.svgObjectURL(i.svg))}const n=c.layouts[t].elements.filter(a=>a.type===g.LayoutElementType.Textbox);for(let a=0;a<n.length;++a){const i=n[a];(e=i.fontData)!=null&&e.assetUrl&&await g.loadFont(i.fontData.assetUrl)}}},ma=async(c,e)=>{var n;const t=await N.getShadowGraphqlClient().query({query:la(((n=e==null?void 0:e.assets)==null?void 0:n.metadata)||!1),errorPolicy:"all",fetchPolicy:"no-cache",variables:{ids:c}}),A=t.data.workflows;if(A===void 0||A.length!==c.length)throw new Error(`Unable to read workflows: ${t.errors??"Length mismatch in response"}`);return A.forEach(a=>{a.steps.forEach(i=>{var o,s,r;delete i.data.__typename,(o=i.option)!=null&&o.id&&((s=i.option.defaultVariant)!=null&&s.asset&&k.cacheAsset(i.option.defaultVariant.asset),i.option.colorProfile&&k.cacheAsset(i.option.colorProfile),(r=i.option.variants)==null||r.forEach(l=>{l.asset&&k.cacheAsset(l.asset),l.displayImage&&k.cacheAsset(l.displayImage),l.thumbnail&&k.cacheAsset(l.thumbnail),l.material&&k.cacheMaterial(l.material)}),Z.set({id:i.option.id},Promise.resolve(i.option)))})}),A},Ia=async(c,e)=>{const A=(await e).find(n=>n.id===c);if(!A)throw new Error(`Workflow not found: ${c}`);return A},qe=async(c,e)=>{const t=c.map(o=>Z.get({id:o,options:e})),A=c.filter((o,s)=>t[s]===void 0);if(A.length===0)return Promise.all(t);const n=ma(A,e),a=A.map(o=>Z.set({id:o,options:e},Ia(o,n))),i=t.filter(o=>o!==void 0);return await Promise.all(i.concat(a))},we=async(c,e)=>(await qe([c],e))[0],fa=c=>c.sort((e,t)=>e.index-t.index).map(e=>({id:g.generate(),panelId:e.name,name:e.name,index:e.index,createdAt:new Date,updatedAt:new Date,transparentBackground:e.transparentBackground,height:e.height,width:e.width,previewRegion:e.previewRegion,useEditableArea:e.useEditableArea,editableArea:e.editableArea})),Ze=(c,e)=>{const t=c.workflowState,A=t?JSON.parse(t):void 0;return A?Object.values(A.layouts).map(n=>n.layout):fa(e.panels)};class oA{constructor(e){this.updateTransactionState=async t=>{try{return N.getShadowGraphqlClient().mutate({...t,mutation:HA})}catch(A){throw console.error(A),new G("Critical - Unable to synchronize workflow state with server.")}},this.initialized=!1,this.options=e,this.options.applicationKey&&dA(this.options.applicationKey)}getAssetManager(){return k}getCurrencyCode(){if(this.currencyCode===void 0)throw new Error("No currency code set.");return this.currencyCode}getFlowService(){if(!wA())throw new Error("Application key required to use Flow Service.");return new nA}async getIntegration(){return(await N.getShadowGraphqlClient().query({query:da,errorPolicy:"all"})).data.currentIntegration}async authenticateBundleFromLocalStorage(e){var n,a;const t=P.getMap("bundleOwnerIds");if(t!=null&&t.has(e))return Promise.resolve({success:!0,stakeholderType:re.Owner});const A=P.getMap("bundlePartnerIds")||new Map;if(A.has(e)){const i=A.get(e),s=(P.getMap("partnerCustomerIds")||new Map).get(i);if(s&&await this.authenticateCustomerId(s)){const l=(a=(n=this.customer)==null?void 0:n.bundleStakeholders)==null?void 0:a.find(d=>{var B;return((B=d.bundle)==null?void 0:B.id)===e});if(l)return Promise.resolve({success:!0,stakeholderType:l.type})}}return Promise.resolve({success:!1})}async authenticateTransactionFromLocalStorage(e){var l,d,B,w,E,C;const t=N.getShadowGraphqlClient(),A=await t.query({query:Ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{id:e}});if(!A.data.transactions||A.data.transactions.length===0)throw new Error(`Transaction not found: ${e}`);const n=A.data.transactions[0];if(!((d=(l=n.product)==null?void 0:l.partner)==null?void 0:d.id))throw new Error(`Unable to read transaction: ${e}`);if(n.isOrdered)return Promise.resolve({success:!1,transactionReadOnly:!0});const i=P.getMap("transactionOwnerIds");if(i!=null&&i.has(e))return Promise.resolve({success:!0,stakeholderType:re.Owner});const o=P.getMap("transactionCustomerIds");if(o!=null&&o.has(e)){const h=o.get(e);if(h&&await this.authenticateCustomerId(h)){const u=((w=(B=this.customer)==null?void 0:B.bundleStakeholders)==null?void 0:w.find(F=>{var I,f;return(f=(I=F.bundle)==null?void 0:I.transactions)==null?void 0:f.some(D=>D.id===e)}))||((C=(E=this.customer)==null?void 0:E.stakeholders)==null?void 0:C.find(F=>{var I;return((I=F.transaction)==null?void 0:I.id)===e}));if(u)return Promise.resolve({success:!0,stakeholderType:u.type})}}const r=(await t.query({query:wa,errorPolicy:"all",variables:{id:n.workflowId}})).data.workflow;if(!r)throw new Error(`Unable to read workflow: ${n.workflowId}`);return Promise.resolve({success:!1,theme:r.overrideTheme,customLogoLink:n.customLogoLink})}clearCustomer(){this.customer=void 0}clearCustomerForTransaction(e){const t=P.getMap("transactionCustomerIds");t!=null&&t.has(e)&&(t.delete(e),P.setMap("transactionCustomerIds",t))}getStakeholderTypeForTransaction(e){var A,n;const t=(n=(A=this.customer)==null?void 0:A.stakeholders)==null?void 0:n.find(a=>{var i;return((i=a.transaction)==null?void 0:i.id)===e});if(t)return t.type}async getOrCreateCustomer(e){var i;this.customer=void 0;const t=N.getShadowGraphqlClient(),n=(await t.query({query:Ea,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e}})).data.customer;if(!n.id){const s=(i=(await t.mutate({mutation:ha,errorPolicy:"all",fetchPolicy:"no-cache",variables:{details:{emailAddress:e}}})).data)==null?void 0:i.customerCreate;if(!s)throw new Error("Unable to create customer.");return this.storeCustomer(s),this.customer=s,{customer:s,isAuthenticated:!1}}this.storeCustomer(n);const a=await this.authenticateCustomerId(n.id);return{customer:this.customer||n,isAuthenticated:a}}async authenticateCustomerId(e){var o;const t=N.getShadowGraphqlClient(),A=P.getMap("customerTokens");if(!(A!=null&&A.has(e)))return!1;const n=A.get(e);if(!n)return!1;const i=(o=(await t.mutate({mutation:Ca,errorPolicy:"all",fetchPolicy:"no-cache",variables:{loginToken:n}})).data)==null?void 0:o.customerAuthenticate;return i?(this.storeCustomer(i),rt(n),this.customer=i,!0):!1}async generateVerificationCode(e){await N.getShadowGraphqlClient().mutate({mutation:Qa,variables:{emailAddress:e}})}async verifyCode(e,t){var a,i;const n=(a=(await N.getShadowGraphqlClient().mutate({mutation:ua,errorPolicy:"all",fetchPolicy:"no-cache",variables:{emailAddress:e,verificationCode:t}})).data)==null?void 0:a.customerVerifyCode;if(n!=null&&n.loginToken){if(!((i=n.partner)!=null&&i.id))throw new Error(`Unable to find customer: ${e}`);const o=P.getMap("customerTokens")||new Map;return o.set(n.id,n.loginToken),P.setMap("customerTokens",o),this.storeCustomer(n),rt(n.loginToken),this.customer={...n,loginToken:void 0},!0}return!1}async getNewBundle(e,t,A){var s,r,l;const a=(l=(await N.getShadowGraphqlClient().mutate({mutation:Ln(((r=(s=A==null?void 0:A.graphql)==null?void 0:s.productCollection)==null?void 0:r.eagerFetchProducts)||!1),variables:{collectionId:e,initialMetadata:t?Object.entries(t).map((d,B)=>({key:d[0],value:d[1]})):void 0},fetchPolicy:"no-cache"})).data)==null?void 0:l.bundleCreate;if(!(a!=null&&a.id))throw new Error("Unable to create bundle");const i=P.getMap("bundlePartnerIds")||new Map;i.set(a.id,a.partner.id),P.setMap("bundlePartnerIds",i);const o=P.getMap("bundleOwnerIds")||new Map;return o.set(a.id,a.bundleOwnerId),P.setMap("bundleOwnerIds",o),new AA(this,a,void 0,void 0,a.bundleOwnerId)}async getExistingBundle(e,t,A,n){var h,m,u,F,I,f,D,p,S;const a=P.getMap("bundleOwnerIds"),i=a==null?void 0:a.get(e),s=((h=Object.entries(localStorage).find(([y,x])=>y.startsWith("CognitoIdentityServiceProvider")&&y.endsWith("idToken")))==null?void 0:h[0])||"",r=localStorage.getItem(s),l={};r&&(l.Authorization=`Bearer ${r}`);const d={bundleOwnerId:i,...l,...(m=n==null?void 0:n.graphql)==null?void 0:m.additionalHeaders},B=await N.getShadowGraphqlClient().query({query:kn(((F=(u=n==null?void 0:n.graphql)==null?void 0:u.productCollection)==null?void 0:F.eagerFetchProducts)||!1),variables:{id:e},fetchPolicy:"no-cache",context:{headers:d}});if(!((I=B.data)!=null&&I.bundles)||((f=B.data)==null?void 0:f.bundles.length)===0||!((D=B.data)!=null&&D.bundles[0]))throw new Error(`Unable to find bundle: ${e}`);const w=(p=B.data)==null?void 0:p.bundles[0],E=P.getMap("bundlePartnerIds")||new Map;E.set(w.id,w.partner.id),P.setMap("bundlePartnerIds",E);const C=new AA(this,w,t,A,i,{additionalHeaders:(S=n==null?void 0:n.graphql)==null?void 0:S.additionalHeaders});return await C.getInitializationPromise(),C}async getBundleStakeholders(){var a;if(!this.customer)throw new Error("Customer not authenticated.");const e=await N.getShadowGraphqlClient().query({query:Jn,variables:{id:this.customer.id},fetchPolicy:"no-cache"});if(!((a=e.data)!=null&&a.customers)||e.data.customers.length===0)throw new Error("Unable to find customer.");const A=e.data.customers[0].bundleStakeholders||[],n=P.getMap("bundlePartnerIds")||new Map;return A.forEach(i=>{var o,s;(o=i.bundle)!=null&&o.id&&((s=i.bundle.partner)!=null&&s.id)&&n.set(i.bundle.id,i.bundle.partner.id)}),P.setMap("bundlePartnerIds",n),A}async getWorkflowExperience(e,t,A,n){var d,B,w,E,C;if(!n)return await this.getWorkflowExperienceDeprecated(e,t,A);const a=async()=>{var m,u;const h=N.getShadowGraphqlClient();if(n.type==="transaction"){const{transactionId:F,readOnly:I}=n,f=await h.query({query:ue,variables:{ids:[F]},errorPolicy:"all",fetchPolicy:"no-cache"});if(!((m=f.data)!=null&&m.transactions)||f.data.transactions.length===0)throw new G("Existing transaction not found.");const D=(u=f.data)==null?void 0:u.transactions[0];if(!D.workflowId)throw new G("Existing transaction has no workflow ID.");const p=await we(D.workflowId);if(!D.product)throw new G("Failed to load transaction, product not available.");return{transaction:D,workflow:p,readOnly:I}}if(n.type==="integration"||n.type==="external"){const F=async()=>{const p=n.type==="integration"?{integrationProductId:n.integrationProductId}:{externalIntegrationId:n.externalIntegrationId,externalProductId:n.externalProductId},S=await h.mutate({mutation:Et,variables:{...p,workflowId:n.workflowId,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!S.data||!S.data.transactionCreate)throw new G("Failed to create transaction!");const y=S.data.transactionCreate;if(!y.product)throw new G("Failed to create transaction, product not available.");return y},I=we(n.workflowId,n==null?void 0:n.graphql),[f,D]=await Promise.all([F(),I]);return{transaction:f,workflow:D}}throw new G("No workflow ID provided.")},{transaction:i,workflow:o,readOnly:s}=await a();this.currencyCode=(d=i.product.partner)==null?void 0:d.currencyCode;const r={product:i.product,transaction:i,layouts:[],singleVariantsRenderable:(B=n==null?void 0:n.workflowConfiguration)==null?void 0:B.singleVariantsRenderable,stateMutationFunc:s?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async h=>{const u=(P.getMap("transactionOwnerIds")||new Map).get(i.id)||void 0;return this.updateTransactionState({...h,context:{transactionOwnerId:u}})},readOnly:s,workflow:o};if(n.type==="transaction"&&i.workflowState){const h=JSON.parse(i.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await ne(h),r.reloadedState=h}else if(!s&&n.workflowState){const h=JSON.parse(n.workflowState);r.layouts=Object.values(h.layouts).map(m=>m.layout),await g.rehydrateSerializedLayout(h),await ne(h),r.reloadedState=h}else r.layouts=Ze(r.transaction,r.workflow);if(r.renderableContextService=new Me(r.layouts),n.previewService?(r.previewService=n.previewService,(w=r.product)!=null&&w.modelUrl&&(r.modelContainer=r.previewService.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))):(r.previewService=A&&A(o),(E=r.product)!=null&&E.modelUrl&&(r.modelContainer=(C=r.previewService)==null?void 0:C.loadModel({model:r.product.modelUrl,contextService:r.renderableContextService}))),n.type!=="transaction"){const h=P.getMap("transactionOwnerIds")||new Map;h.set(i.id,i.transactionOwnerId),P.setMap("transactionOwnerIds",h)}else r.isReloadedTransaction=!0;this.initialized=!0,this.experienceOptions=r;const l=new Be(this,r);return await l.getWorkflowManager().getInitializationPromise(),n.type!=="transaction"&&this.customer&&await l.attachCustomerDetails({email:this.customer.emailAddress}),l}async getWorkflowExperiences(e,t){if(e.length===0)throw new G("No options provided!");const A=N.getShadowGraphqlClient(),n=async f=>{var y,x;if(f.length===0)return[];const D=f.map(Y=>Y.option.transactionId),p=await A.query({query:ue,variables:{ids:D},errorPolicy:"all",fetchPolicy:"no-cache"}),S=p.data.transactions;if(S.length!==f.length){const Y=((x=(y=p.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Not all transactions were found: ${Y}`)}return S.map((Y,H)=>{var R;return{transaction:Y,workflowId:Y.workflowId,readOnly:((R=f.find(T=>T.option.transactionId===Y.id))==null?void 0:R.option.readOnly)??!1,index:f[H].index}})},a=async f=>{var S,y,x;if(f.length===0)return[];const D=await A.mutate({mutation:xA,variables:{inputs:f.map(Y=>({integrationProductId:Y.option.type==="integration"?Y.option.integrationProductId:void 0,externalIntegrationId:Y.option.type==="external"?Y.option.externalIntegrationId:void 0,externalProductId:Y.option.type==="external"?Y.option.externalProductId:void 0,workflowId:Y.option.workflowId,claim:!0}))},errorPolicy:"all",fetchPolicy:"no-cache"}),p=(S=D.data)==null?void 0:S.transactionCreateMany;if(!p||p.length===0){const Y=((x=(y=D.errors)==null?void 0:y[0])==null?void 0:x.message)||"Unknown error";throw new G(`Failed to create transactions: ${Y}`)}return p.map((Y,H)=>({transaction:Y,workflowId:Y.workflowId,readOnly:!1,index:f[H].index}))},i=e.map((f,D)=>({option:f,index:D})),o=i.filter(f=>f.option.type==="transaction"),s=i.filter(f=>f.option.type==="integration"||f.option.type==="external"),r=at(o,10),l=at(s,10),d=(await Promise.all([...r.map(n),...l.map(a)])).flat(),B=[...new Set(d.map(f=>f.workflowId))],w=await qe(B,t),E=new Map(w.map(f=>[f.id,f])),C=P.getMap("transactionOwnerIds")||new Map,h=d.map(async f=>{var T;const{transaction:D,workflowId:p,readOnly:S,index:y}=f,x=E.get(p),Y=e[y];!C.get(D.id)&&D.transactionOwnerId&&C.set(D.id,D.transactionOwnerId);const H=C.get(D.id)||void 0,R={product:D.product,transaction:D,layouts:[],singleVariantsRenderable:(T=Y==null?void 0:Y.workflowConfiguration)==null?void 0:T.singleVariantsRenderable,stateMutationFunc:S?async()=>{throw new v("State mutation is forbidden in read only mode!")}:async b=>this.updateTransactionState({...b,context:{transactionOwnerId:H}}),readOnly:S,workflow:x,isReloadedTransaction:Y.type==="transaction"};if(Y.type==="transaction"&&D.workflowState){const b=JSON.parse(D.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await g.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else if(!S&&Y.workflowState){const b=JSON.parse(Y.workflowState);R.layouts=Object.values(b.layouts||{}).map(z=>z.layout),await g.rehydrateSerializedLayout(b),await ne(b),R.reloadedState=b}else R.layouts=Ze(R.transaction,R.workflow);return R.renderableContextService=new Me(R.layouts),R.delayWorkflowStateSync=!0,this.initialized=!0,this.experienceOptions=R,{experienceOptions:R,index:y,options:Y}});P.setMap("transactionOwnerIds",C);const F=(await Promise.all(h)).sort((f,D)=>f.index-D.index).map(async f=>{const{experienceOptions:D,options:p}=f,S=new Be(this,D);return await S.getWorkflowManager().getInitializationPromise(),p.type!=="transaction"&&this.customer&&await S.attachCustomerDetails({email:this.customer.emailAddress}),S}),I=await Promise.all(F);return I.forEach(f=>f.getWorkflowManager().setWorkflowStateSyncEnabled(!0)),I}async initFromIntegrationProduct(e){var i;if(e==="")throw new G("No integration product ID provided.");const A=await N.getShadowGraphqlClient().mutate({mutation:Et,variables:{integrationProductId:e,claim:!0},errorPolicy:"all",fetchPolicy:"no-cache",context:this.options.applicationKey?{headers:{"X-Application-Key":this.options.applicationKey}}:void 0});if(!A.data||!A.data.transactionCreate)throw new G("Failed to create transaction!");const n=A.data.transactionCreate;if(!n.product)throw new G("Failed to create transaction, product not available.");this.currencyCode=(i=n.product.partner)==null?void 0:i.currencyCode;const a=P.getMap("transactionOwnerIds")||new Map;a.set(n.id,n.transactionOwnerId),P.setMap("transactionOwnerIds",a),this.experienceOptions={product:n.product,transaction:n,layouts:[],stateMutationFunc:async o=>this.updateTransactionState({...o,context:{transactionOwnerId:n.transactionOwnerId}})},this.initialized=!0}async initFromTransaction(e,t=!1){var o,s,r,l;if(e==="")throw new G("No transaction ID provided.");const A=N.getShadowGraphqlClient(),n=async()=>{var w,E;const B=(w=(await A.query({query:ue,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:w.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(E=B.product.partner)==null?void 0:E.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async()=>{throw new v("State mutation is forbidden in read only mode!")},readOnly:t},this.initialized=!0};if(t)return await n();const a=P.getMap("transactionOwnerIds")||new Map,i=a.get(e);if(i){const B=(o=(await A.query({query:ue,variables:{ids:[e]},errorPolicy:"all"})).data)==null?void 0:o.transactions[0];if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(s=B.product.partner)==null?void 0:s.currencyCode,this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:i}}),readOnly:t},this.initialized=!0;return}try{const B=(r=(await A.mutate({mutation:NA,variables:{id:e},errorPolicy:"all"})).data)==null?void 0:r.transactionClaim;if(!B)throw new G("Failed to read transaction.");if(!B.product)throw new G("Failed to load transaction, product not available.");this.currencyCode=(l=B.product.partner)==null?void 0:l.currencyCode,B.transactionOwnerId&&(a.set(B.id,B.transactionOwnerId),P.setMap("transactionOwnerIds",a)),this.experienceOptions={product:B.product,transaction:B,layouts:[],stateMutationFunc:async w=>this.updateTransactionState({...w,context:{transactionOwnerId:B.transactionOwnerId}}),readOnly:t},this.initialized=!0}catch{throw new G("Attempted to access a transaction that isn't available.")}}async getWorkflowExperienceDeprecated(e,t,A){var n,a,i,o;if(!this.initialized||!this.experienceOptions)throw new G("Cannot launch experience: Not initialized.");if(this.experienceOptions.transaction.workflowId){const s=await we(this.experienceOptions.transaction.workflowId);if(this.experienceOptions.workflow=s,this.experienceOptions.transaction.workflowState){const l=JSON.parse(this.experienceOptions.transaction.workflowState);this.experienceOptions.layouts=Object.values(l.layouts).map(d=>d.layout),await g.rehydrateSerializedLayout(l),await ne(l),this.experienceOptions.reloadedState=l}this.experienceOptions.previewService=A&&A(s),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(n=this.experienceOptions.product)!=null&&n.modelUrl&&(this.experienceOptions.modelContainer=(a=this.experienceOptions.previewService)==null?void 0:a.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const r=new Be(this,this.experienceOptions);return await r.getWorkflowManager().getInitializationPromise(),r}if(e){const r=(P.getMap("transactionOwnerIds")||new Map).get(this.experienceOptions.transaction.id),l=N.getShadowGraphqlClient().mutate({mutation:RA,variables:{workflowId:e,id:this.experienceOptions.transaction.id},context:{transactionOwnerId:r}}),d=we(e);if(await Promise.all([l,d]),this.experienceOptions.workflow=await d,t){const w=JSON.parse(t);this.experienceOptions.layouts=Object.values(w.layouts).map(E=>E.layout),await g.rehydrateSerializedLayout(w),await ne(w),this.experienceOptions.reloadedState=w}else this.experienceOptions.layouts=Ze(this.experienceOptions.transaction,this.experienceOptions.workflow);this.experienceOptions.previewService=A&&A(await d),this.experienceOptions.renderableContextService=new Me(this.experienceOptions.layouts),(i=this.experienceOptions.product)!=null&&i.modelUrl&&(this.experienceOptions.modelContainer=(o=this.experienceOptions.previewService)==null?void 0:o.loadModel({model:this.experienceOptions.product.modelUrl,contextService:this.experienceOptions.renderableContextService}));const B=new Be(this,this.experienceOptions);return await B.getWorkflowManager().getInitializationPromise(),B}throw new G("No workflow ID provided.")}getPreviewService(){var e;return(e=this.experienceOptions)==null?void 0:e.previewService}getProduct(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get product: Not initialized.");return this.experienceOptions.product}getTransaction(){if(!this.initialized||!this.experienceOptions)throw new G("Cannot get transaction: Not initialized.");return this.experienceOptions.transaction}configureUrls(e,t,A){W.setHubUrl(e),W.setServerUrl(t),W.setServicesApiUrl(A)}storeCustomer(e){const t=P.getMap("partnerCustomerIds")||new Map;t.set(e.partner.id,e.id),P.setMap("partnerCustomerIds",t)}async getIntegrationProductById(e){var a,i;const n=(a=(await N.getShadowGraphqlClient().query({query:GA,variables:{ids:[e]},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:a.integrationProducts;if(!n||n.length===0||!((i=n[0])!=null&&i.id))throw new Error("Integration product not found.");return new Xe(n[0])}async getIntegrationProductFromExternalIds(e,t){var i;const a=(i=(await N.getShadowGraphqlClient().query({query:vA,variables:{externalProductId:t,externalIntegrationId:e},fetchPolicy:"no-cache",errorPolicy:"all"})).data)==null?void 0:i.integrationProductFromExternalIds;if(!(a!=null&&a.id))throw new Error("Integration product not found.");return new Xe(a)}async getIntegrationProduct(e){return e.type==="integration"?this.getIntegrationProductById(e.integrationProductId):this.getIntegrationProductFromExternalIds(e.externalIntegrationId,e.externalProductId)}}class Da{getInitializationPromise(){return Promise.resolve()}isInitialized(){return!0}getInformationResults(){return[]}async reset(){}updateStateWithServer(e){}async outstandingRequestsPromise(){}async updateStateWithServerImmediate(e){}addPoller(e){}addConfirmCallback(e){}addEditedCallback(e){}addElementsCallback(e){}addInformationResultCallback(e){}addInitCallback(e){}addMakingAdjustmentsCallback(e){}addMandatoryCallback(e){}addMetadataCallback(e){}addSelectionCallback(e){}addStepSpecificStorageCallback(e,t){}addStorageCallback(e){}getCommandDispatcher(){return e=>{}}getLayouts(){return[]}getLayoutPreviewService(){return{getAll:()=>new Map}}getPreviewService(){}getModelContainer(){}getProfanities(){return[]}getRegionElements(e){return[]}getSerializedStep(e,t){}getStepSpecificServices(e){}getTransaction(){return{id:""}}getTransactionCustomer(){}setTransactionCustomer(){}setTransactionCustomerDetails(){}getWorkflow(){return{id:"",name:"",panels:[],steps:[],showModelOnFinishStep:!1,allowProofDownload:!1,introduction:"",stepGroups:[]}}markStepsAsInitialised(e){}markUpdateCompleted(e){}markUpdatePending(){return"123"}getWorkflowSelections(){return{}}setCurrentAdjustingStepId(e){}setEditedStatus(e,t){}setInformationResults(e){}setMandatoryFulfilled(e,t){}async setSelectionsAndElements(e,t,A){}toggleDesignConfirmed(){}updateMetadata(e,t){}async updateStorage(e,t){}injectIntoPreviewService(e){return Promise.resolve()}ejectFromPreviewService(){}setWorkflowStateSyncEnabled(e){}}var sA=(c=>(c.SelectFrame="SelectFrame",c.SelectImage="SelectImage",c.Position="Position",c))(sA||{});class rA extends j{constructor(e,t){var A;super(e,t),this.frameService=(A=this.manager.getStepSpecificServices(this.getId()))==null?void 0:A.frameService}selectVariant(e){const t=this.manager.getRegionElements(this.step.stepName);return Ie.selectVariant(this.step,e.getResource(),t,this.manager,A=>this.setUpdateState(A))}onFrameDataChanged(e){this.frameService&&this.frameService.onFrameDataChanged(t=>{t&&e(t)})}selectImage(e){return Ie.selectImage(this.step,e,this.manager)}getImageData(){if(this.frameService)return this.frameService.getImageData()}getCurrentFrameStep(e,t,A,n){return n&&n.length>1&&e===void 0?"SelectFrame":t||A||this.getImageData()?"Position":"SelectImage"}getFrameService(){return this.frameService}hasOverlayImageKey(){return this.step.data.overlayImageKey}hasOverlayImageUrl(){return this.step.data.overlayImageUrl}}Object.defineProperty(Q,"AspectType",{enumerable:!0,get:()=>g.AspectType}),Object.defineProperty(Q,"AssetType",{enumerable:!0,get:()=>g.AssetType}),Object.defineProperty(Q,"BringForwardCommand",{enumerable:!0,get:()=>g.BringForwardCommand}),Object.defineProperty(Q,"BringToBackCommand",{enumerable:!0,get:()=>g.BringToBackCommand}),Object.defineProperty(Q,"BringToFrontCommand",{enumerable:!0,get:()=>g.BringToFrontCommand}),Object.defineProperty(Q,"CanvasCommand",{enumerable:!0,get:()=>g.CanvasCommand}),Object.defineProperty(Q,"CommandContext",{enumerable:!0,get:()=>g.CommandContext}),Object.defineProperty(Q,"CreateElementCommand",{enumerable:!0,get:()=>g.CreateElementCommand}),Object.defineProperty(Q,"CreateLayoutCommand",{enumerable:!0,get:()=>g.CreateLayoutCommand}),Object.defineProperty(Q,"DeleteElementCommand",{enumerable:!0,get:()=>g.DeleteElementCommand}),Object.defineProperty(Q,"FontAlignmentCommand",{enumerable:!0,get:()=>g.FontAlignmentCommand}),Object.defineProperty(Q,"FontColorCommand",{enumerable:!0,get:()=>g.FontColorCommand}),Object.defineProperty(Q,"FontSizeCommand",{enumerable:!0,get:()=>g.FontSizeCommand}),Object.defineProperty(Q,"FontSourceCommand",{enumerable:!0,get:()=>g.FontSourceCommand}),Object.defineProperty(Q,"GroupCommand",{enumerable:!0,get:()=>g.GroupCommand}),Object.defineProperty(Q,"LayoutElementFactory",{enumerable:!0,get:()=>g.LayoutElementFactory}),Object.defineProperty(Q,"LayoutElementType",{enumerable:!0,get:()=>g.LayoutElementType}),Object.defineProperty(Q,"MoveCommand",{enumerable:!0,get:()=>g.MoveCommand}),Object.defineProperty(Q,"ResizeCommand",{enumerable:!0,get:()=>g.ResizeCommand}),Object.defineProperty(Q,"RotateCommand",{enumerable:!0,get:()=>g.RotateCommand}),Object.defineProperty(Q,"SendBackwardsCommand",{enumerable:!0,get:()=>g.SendBackwardsCommand}),Object.defineProperty(Q,"StepAspectType",{enumerable:!0,get:()=>g.StepAspectType}),Object.defineProperty(Q,"StepType",{enumerable:!0,get:()=>g.StepType}),Object.defineProperty(Q,"TextChangeCommand",{enumerable:!0,get:()=>g.TextChangeCommand}),Object.defineProperty(Q,"UnitOfMeasurement",{enumerable:!0,get:()=>g.UnitOfMeasurement}),Object.defineProperty(Q,"dataUrlFromExternalUrl",{enumerable:!0,get:()=>g.dataUrlFromExternalUrl}),Object.defineProperty(Q,"determineCorrectFontSizeAndLines",{enumerable:!0,get:()=>g.determineCorrectFontSizeAndLines}),Object.defineProperty(Q,"findElement",{enumerable:!0,get:()=>g.findElement}),Object.defineProperty(Q,"frameDataCache",{enumerable:!0,get:()=>g.frameDataCache}),Object.defineProperty(Q,"generate",{enumerable:!0,get:()=>g.generate}),Object.defineProperty(Q,"generateSVGWithUnknownColors",{enumerable:!0,get:()=>g.generateSVGWithUnknownColors}),Object.defineProperty(Q,"getAttributesFromArrayBuffer",{enumerable:!0,get:()=>g.getAttributesFromArrayBuffer}),Object.defineProperty(Q,"getAxisAlignedBoundingBox",{enumerable:!0,get:()=>g.getAxisAlignedBoundingBox}),Object.defineProperty(Q,"getFrameData",{enumerable:!0,get:()=>g.getFrameData}),Object.defineProperty(Q,"getSvgElement",{enumerable:!0,get:()=>g.getSvgElement}),Object.defineProperty(Q,"loadFont",{enumerable:!0,get:()=>g.loadFont}),Object.defineProperty(Q,"patternImageDataCache",{enumerable:!0,get:()=>g.patternImageDataCache}),Object.defineProperty(Q,"registerFetchImplementation",{enumerable:!0,get:()=>g.registerFetchImplementation}),Object.defineProperty(Q,"registerWindowImplementation",{enumerable:!0,get:()=>g.registerWindowImplementation}),Object.defineProperty(Q,"rehydrateSerializedLayout",{enumerable:!0,get:()=>g.rehydrateSerializedLayout}),Object.defineProperty(Q,"setCanvasModule",{enumerable:!0,get:()=>g.setCanvasModule}),Q.ArrayInput=oa,Q.AssetNotFoundError=V,Q.CollectionProduct=ye,Q.ColorOptionGlobalPropertyHandle=$t,Q.ConversionDataType=wt,Q.ConversionLocation=dt,Q.FileUploadGlobalPropertyHandle=qt,Q.FlowExecutionNodeResult=de,Q.FlowExecutionResult=aA,Q.FlowService=nA,Q.FrameService=ut,Q.FrameStep=sA,Q.FrameStepHandle=rA,Q.GlobalPropertyHandle=Se,Q.IllustrationStepHandle=Rt,Q.InformationMessageType=le,Q.InformationStepHandle=Tt,Q.IntegrationProduct=Xe,Q.IntegrationType=lt,Q.LayoutNotFoundError=J,Q.MaterialStepHandle=Ut,Q.MisconfigurationError=oe,Q.MockWorkflowManager=Da,Q.ModelStepHandle=Gt,Q.ObjectInput=We,Q.ObjectInputType=iA,Q.OptionGlobalPropertyHandle=Ke,Q.OptionNotFoundError=ie,Q.ParseError=q,Q.PictureStepHandle=vt,Q.ProductCameraRig=Bt,Q.ProductCollection=_t,Q.ProductWorkflow=Ae,Q.PromiseCache=Z,Q.PromiseQueue=Ue,Q.QuestionStepHandle=kt,Q.QueueablePromise=Re,Q.ResourceNotFoundError=X,Q.ShapeStepHandle=bt,Q.SpiffCommerceClient=oA,Q.StakeholderType=re,Q.StepHandle=j,Q.TextGlobalPropertyHandle=Zt,Q.TextInput=ia,Q.TextStepHandle=Jt,Q.Transform=tA,Q.TransformCollection=eA,Q.UnhandledBehaviorError=v,Q.Variant=K,Q.WorkflowExperienceEventType=Kt,Q.WorkflowExperienceImpl=Be,Q.assetService=k,Q.createDesign=jt,Q.designService=Fe,Q.digitalContentStepService=Dt,Q.frameStepService=Ie,Q.generateCommands=Vt,Q.generateStateFromDesignInputSteps=Gn,Q.getBoundedOffsets=Qt,Q.getWorkflow=we,Q.getWorkflows=qe,Q.graphQlManager=N,Q.illustrationStepService=ge,Q.materialStepService=Ge,Q.modelStepService=ve,Q.moduleStepService=pt,Q.optionService=L,Q.persistenceService=P,Q.pictureStepService=ke,Q.questionStepService=be,Q.shapeStepService=te,Q.shortenUrl=It,Q.spiffCoreConfiguration=W,Q.stepAspectValuesToDesignInputSteps=Un,Q.textStepService=O,Q.toast=Ft,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "21.8.2-7",
3
+ "version": "21.8.2",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.cjs",