@spiffcommerce/core 33.2.0 → 33.2.1-beta.608a39d6-d415-5e24-9212-3d6b4823b699

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.mjs CHANGED
@@ -7,7 +7,7 @@ import { orientation as yr } from "exifr/dist/mini.umd.cjs";
7
7
  import { parse as An } from "css";
8
8
  import Sr from "fuse.js";
9
9
  import { Pith as ma } from "pith";
10
- import vt from "lodash.clonedeep";
10
+ import Et from "lodash.clonedeep";
11
11
  import Ht from "lodash.isequal";
12
12
  import { jsx as D, jsxs as ct, Fragment as zt } from "preact/jsx-runtime";
13
13
  import { parse as aa } from "opentype.js";
@@ -45,7 +45,7 @@ class H extends Xt {
45
45
  super(`Panel not Found: ${t.panelId}`), this.panelId = t?.panelId || "N/A";
46
46
  }
47
47
  }
48
- class Et extends Xt {
48
+ class bt extends Xt {
49
49
  constructor(t) {
50
50
  super(`Asset not found for variant: ${t.name}`), this.variant = t;
51
51
  }
@@ -70,7 +70,7 @@ class T extends Me {
70
70
  super(`Unhandled Behavior Encountered: ${t}`);
71
71
  }
72
72
  }
73
- class Bt extends Me {
73
+ class Pt extends Me {
74
74
  constructor(t) {
75
75
  super(`Parsing Error: ${t}`);
76
76
  }
@@ -226,7 +226,7 @@ const fn = /* @__PURE__ */ new Map(), Ra = /* @__PURE__ */ new Map(), Oa = /* @_
226
226
  const r = a.load();
227
227
  return Ve.set(t, r), r;
228
228
  }
229
- }, bt = () => {
229
+ }, It = () => {
230
230
  if (kt([typeof XMLSerializer]))
231
231
  return new XMLSerializer();
232
232
  const n = Zt();
@@ -3329,7 +3329,7 @@ const ce = (n) => {
3329
3329
  }
3330
3330
  });
3331
3331
  });
3332
- }, Pn = (n) => bt().serializeToString(n), ya = (n, t, e, a, r) => {
3332
+ }, Pn = (n) => It().serializeToString(n), ya = (n, t, e, a, r) => {
3333
3333
  const i = In(n);
3334
3334
  if (!i)
3335
3335
  throw new Error("Failed to read SVG.");
@@ -3361,7 +3361,7 @@ const ce = (n) => {
3361
3361
  s.classList.add(A), s.setAttribute("stroke", c.browserValue), a[d] = c;
3362
3362
  }
3363
3363
  });
3364
- const i = bt().serializeToString(e);
3364
+ const i = It().serializeToString(e);
3365
3365
  return {
3366
3366
  colors: a,
3367
3367
  svg: i
@@ -3660,9 +3660,9 @@ class yi {
3660
3660
  async postProcessFileUpload(t, e) {
3661
3661
  if (e === "image/svg+xml") {
3662
3662
  const a = await t.blob.text(), s = new window.DOMParser().parseFromString(a, "image/svg+xml").documentElement;
3663
- if (!s) throw new Bt("Failed to read SVG.");
3663
+ if (!s) throw new Pt("Failed to read SVG.");
3664
3664
  di(s);
3665
- const l = bt().serializeToString(s);
3665
+ const l = It().serializeToString(s);
3666
3666
  return {
3667
3667
  name: t.name,
3668
3668
  blob: new Blob([l], { type: "image/svg+xml" })
@@ -5462,7 +5462,7 @@ const M = () => {
5462
5462
  }), id = (n, t, e, a) => ({
5463
5463
  x: n.x + (t?.x + t?.width) * e,
5464
5464
  y: n.y + (t?.y + t?.height) * a
5465
- }), It = (n) => {
5465
+ }), Bt = (n) => {
5466
5466
  switch (n) {
5467
5467
  case W.North:
5468
5468
  return W.East;
@@ -5481,7 +5481,7 @@ const M = () => {
5481
5481
  case W.Southwest:
5482
5482
  return W.Northwest;
5483
5483
  }
5484
- }, sd = (n, t) => t > 45 && t <= 135 ? It(n) : t > 135 && t <= 225 ? It(It(n)) : t > 225 && t <= 315 ? It(It(It(n))) : n, od = (n, t = { x: 0, y: 0 }, e = { x: 1, y: 1 }) => {
5484
+ }, sd = (n, t) => t > 45 && t <= 135 ? Bt(n) : t > 135 && t <= 225 ? Bt(Bt(n)) : t > 225 && t <= 315 ? Bt(Bt(Bt(n))) : n, od = (n, t = { x: 0, y: 0 }, e = { x: 1, y: 1 }) => {
5485
5485
  const a = ft(n.rotation), r = {
5486
5486
  x: t.x + n.x * e.x,
5487
5487
  y: t.x + n.y * e.y
@@ -5766,7 +5766,7 @@ const is = (n) => n.substring(0, 5).toLowerCase().trim() === "data:", We = /* @_
5766
5766
  const b = B.toSVG(2), R = t.parseFromString(b, "image/svg+xml").firstElementChild;
5767
5767
  h.appendChild(R);
5768
5768
  }
5769
- return e.querySelectorAll("text").forEach((d) => d.remove()), bt().serializeToString(a);
5769
+ return e.querySelectorAll("text").forEach((d) => d.remove()), It().serializeToString(a);
5770
5770
  }, Pe = (n, t, e, a) => Math.max(ds(n.join(`
5771
5771
  `), e, a), t), za = (n, t, e, a, r, i) => {
5772
5772
  const s = (i || Vn) * r.getApproximateHeight(), o = t.split(`
@@ -5899,7 +5899,7 @@ const is = (n) => n.substring(0, 5).toLowerCase().trim() === "data:", We = /* @_
5899
5899
  };
5900
5900
  })()
5901
5901
  } : n, Vn = 1.1;
5902
- function Pt(n, t) {
5902
+ function vt(n, t) {
5903
5903
  return zn(n, t.getTemplatingContext());
5904
5904
  }
5905
5905
  function zn(n, t) {
@@ -6339,7 +6339,7 @@ const re = (n) => {
6339
6339
  const s = dt().parseFromString(n, "image/svg+xml").firstElementChild;
6340
6340
  if (!s)
6341
6341
  throw new Error("Failed to read SVG");
6342
- const l = bt().serializeToString(s), c = pt(), d = c.getContext("2d"), A = await ma.from(d, l, {
6342
+ const l = It().serializeToString(s), c = pt(), d = c.getContext("2d"), A = await ma.from(d, l, {
6343
6343
  anonymousCrossOrigin: !0,
6344
6344
  ignoreDimensions: !1,
6345
6345
  createCanvas: pt,
@@ -7451,7 +7451,7 @@ class Fe {
7451
7451
  return ca(e);
7452
7452
  const a = t.asset;
7453
7453
  if (!a)
7454
- throw new Et(t);
7454
+ throw new bt(t);
7455
7455
  const r = a.fileLink;
7456
7456
  if (r)
7457
7457
  return at(r, !0);
@@ -7970,7 +7970,7 @@ class Ds {
7970
7970
  t.mandatory && i.setMandatoryFulfilled(t.stepName, !1);
7971
7971
  const o = e.asset;
7972
7972
  if (!o)
7973
- throw new Et(e);
7973
+ throw new bt(e);
7974
7974
  const l = o.fileLink;
7975
7975
  if (!l)
7976
7976
  throw new Yt(o);
@@ -8101,7 +8101,7 @@ class Fs {
8101
8101
  r(!0);
8102
8102
  const s = e.material;
8103
8103
  if (!s)
8104
- throw r(!1), new Et(e);
8104
+ throw r(!1), new bt(e);
8105
8105
  return {
8106
8106
  command: void 0,
8107
8107
  followup: async () => {
@@ -8152,7 +8152,7 @@ class xs {
8152
8152
  const u = e.getModelContainer();
8153
8153
  if (u && t.option) {
8154
8154
  const h = d.asset?.fileLink;
8155
- if (!h) throw new Et(d);
8155
+ if (!h) throw new bt(d);
8156
8156
  await u.applyModelVariant(
8157
8157
  t.stepName || "",
8158
8158
  {
@@ -8176,7 +8176,7 @@ class xs {
8176
8176
  r(!0);
8177
8177
  const i = e.asset?.fileLink;
8178
8178
  if (!i)
8179
- throw new Et(e);
8179
+ throw new bt(e);
8180
8180
  return {
8181
8181
  command: void 0,
8182
8182
  followup: async () => {
@@ -8353,7 +8353,7 @@ class Ms {
8353
8353
  async selectVariantCommand(t, e, a, r) {
8354
8354
  const i = e.asset;
8355
8355
  if (!i)
8356
- throw new Et(e);
8356
+ throw new bt(e);
8357
8357
  const s = i?.fileLink;
8358
8358
  if (!s)
8359
8359
  return console.error("No URL for picture!"), null;
@@ -8763,9 +8763,9 @@ class $s {
8763
8763
  f && (A = f);
8764
8764
  }
8765
8765
  }
8766
- e.updateStorage(t.stepName, {
8766
+ A = vt(A, e), e.updateStorage(t.stepName, {
8767
8767
  text: A,
8768
- inputText: t.data.defaultText || "",
8768
+ inputText: A,
8769
8769
  color: this.getDefaultColorVariant(t.data)?.color || this.getDefaultColor(t.data),
8770
8770
  fillImage: l,
8771
8771
  strokeColor: d
@@ -8919,7 +8919,7 @@ class $s {
8919
8919
  });
8920
8920
  }
8921
8921
  updateInputText(t, e, a, r) {
8922
- const i = r.getStepStorage(a.stepName), s = Pt(t, r), o = this.getProcessedInput(s, a.data, i?.customiseAllText ?? !1), l = {
8922
+ const i = r.getStepStorage(a.stepName), s = vt(t, r), o = this.getProcessedInput(s, a.data, i?.customiseAllText ?? !1), l = {
8923
8923
  command: void 0,
8924
8924
  helperData: {},
8925
8925
  errorData: this.getErrorsForText(t, o, a, r)
@@ -9087,7 +9087,7 @@ class $s {
9087
9087
  async fontDataFromVariant(t) {
9088
9088
  const e = t.asset;
9089
9089
  if (!e)
9090
- throw new Et(t);
9090
+ throw new bt(t);
9091
9091
  const a = e.fileLink;
9092
9092
  if (!a)
9093
9093
  throw new Yt(e);
@@ -9178,7 +9178,7 @@ class $s {
9178
9178
  async createTextboxRegions(t, e, a, r, i, s) {
9179
9179
  if (!a || !a.regions)
9180
9180
  throw new Error("Step data not supplied");
9181
- const o = i.text || a.defaultText || "", l = Pt(o, s), c = this.getProcessedInput(l, a, !1), d = async (u) => {
9181
+ const o = i.text || a.defaultText || "", l = vt(o, s), c = this.getProcessedInput(l, a, !1), d = async (u) => {
9182
9182
  const m = s.getLayouts().find((g) => g.panelId === u.panelId), p = M();
9183
9183
  try {
9184
9184
  if (!m)
@@ -9275,7 +9275,7 @@ class $s {
9275
9275
  * @deprecated
9276
9276
  */
9277
9277
  async changeInputTextWithRegion(t, e, a, r, i, s, o, l, c, d) {
9278
- const A = (r || "").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g, ""), u = Pt(A, s), h = this.getProcessedInput(u, t.data, o), m = s.getRegionElements(t.stepName), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
9278
+ const A = (r || "").replace(/^(?![\u000A\u000D])[\u0000-\u001F\u007F-\u009F]/g, ""), u = vt(A, s), h = this.getProcessedInput(u, t.data, o), m = s.getRegionElements(t.stepName), p = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
9279
9279
  for (const y of m)
9280
9280
  if (y.region) {
9281
9281
  const [S, B] = we(
@@ -9403,7 +9403,7 @@ class Hs {
9403
9403
  u = (A * 100 | 0) / 100;
9404
9404
  break;
9405
9405
  default:
9406
- throw new Bt("Failed to encode path.");
9406
+ throw new Pt("Failed to encode path.");
9407
9407
  }
9408
9408
  l || s.push(" "), s.push(u), l = !1;
9409
9409
  }
@@ -9417,12 +9417,12 @@ class Hs {
9417
9417
  for (e.lastIndex = 0; i = e.exec(t); ) {
9418
9418
  const s = i[1].toLowerCase(), o = (i[2].match(a) || []).map(parseFloat), l = s === i[1], c = Ja[s];
9419
9419
  if (o.length < c.length)
9420
- throw new Bt(
9420
+ throw new Pt(
9421
9421
  `Path type "${s}" given ${o.length} arguments, expected ${c.length}.`
9422
9422
  );
9423
9423
  if (c.length > 0) {
9424
9424
  if (o.length % c.length !== 0)
9425
- throw new Bt(
9425
+ throw new Pt(
9426
9426
  `Path type "${s}" given ${o.length} arguments, not divisible by ${c.length}`
9427
9427
  );
9428
9428
  for (let d = 0; d < o.length / c.length; d++) {
@@ -9447,7 +9447,7 @@ class Hs {
9447
9447
  if (o in i && l in i) {
9448
9448
  const c = [i[o], i[l]], d = e(c);
9449
9449
  if (d.length < 2)
9450
- throw new Bt("Transformer must return at least 2 points.");
9450
+ throw new Pt("Transformer must return at least 2 points.");
9451
9451
  i[o] = d[0], i[l] = d[1];
9452
9452
  }
9453
9453
  }
@@ -9644,7 +9644,7 @@ const Ys = [
9644
9644
  y.classList.add(R), p[R] = { browserValue: b };
9645
9645
  }
9646
9646
  });
9647
- const f = bt().serializeToString(m), w = r.colors;
9647
+ const f = It().serializeToString(m), w = r.colors;
9648
9648
  if (w) {
9649
9649
  for (const [y, S] of Object.entries(p))
9650
9650
  for (const B of Object.keys(w))
@@ -9842,8 +9842,8 @@ const Ys = [
9842
9842
  const c = await at(i, !0), d = (A) => {
9843
9843
  const u = /<svg.*?<\/svg>/s, h = A.match(u) || [], m = h?.length > 0 ? h[0] : "", f = dt().parseFromString(m, "image/svg+xml").firstElementChild;
9844
9844
  if (!f)
9845
- throw new Bt("Failed to read SVG.");
9846
- return wa(f), bt().serializeToString(f);
9845
+ throw new Pt("Failed to read SVG.");
9846
+ return wa(f), It().serializeToString(f);
9847
9847
  };
9848
9848
  l.forEach((A) => {
9849
9849
  const u = n.find((m) => m.panelId === A.panelId);
@@ -10108,7 +10108,7 @@ class lo {
10108
10108
  * Actions to perform when a static render event is fired for this canvas.
10109
10109
  */
10110
10110
  async render(t) {
10111
- const e = vt(t);
10111
+ const e = Et(t);
10112
10112
  this.lastRequestedRenderArguments = e;
10113
10113
  const a = this.getStaticContext();
10114
10114
  if (!a) {
@@ -11432,7 +11432,7 @@ class qo {
11432
11432
  const t = this.getCommandContext().getState();
11433
11433
  if (!t)
11434
11434
  throw new T("Attempted to serialize state before it was initialized.");
11435
- const e = vt(t.transaction), a = this.dehydrateState(e);
11435
+ const e = Et(t.transaction), a = this.dehydrateState(e);
11436
11436
  return JSON.stringify(a);
11437
11437
  }
11438
11438
  /**
@@ -12213,7 +12213,7 @@ class Xo extends X {
12213
12213
  const e = {
12214
12214
  input: t,
12215
12215
  helperData: {}
12216
- }, a = G.findLayoutElements(this.manager, this.step), r = G.filterUnsupportedCharacters(t, a[0]?.fontData), i = Pt(r, this.manager).length, s = !!this.step.data && !!this.step.data.maxLength && i > this.step.data.maxLength;
12216
+ }, a = G.findLayoutElements(this.manager, this.step), r = G.filterUnsupportedCharacters(t, a[0]?.fontData), i = vt(r, this.manager).length, s = !!this.step.data && !!this.step.data.maxLength && i > this.step.data.maxLength;
12217
12217
  s || (e.input = r);
12218
12218
  const o = a.length <= 0, l = o ? { inputText: r, text: r } : { inputText: r };
12219
12219
  this.manager.updateStorage(this.step.stepName, l);
@@ -12289,7 +12289,7 @@ class Xo extends X {
12289
12289
  const t = this.step.data.maxLength;
12290
12290
  if (t === void 0)
12291
12291
  return;
12292
- const e = Pt(this.getText(), this.manager);
12292
+ const e = vt(this.getText(), this.manager);
12293
12293
  return t - e.length;
12294
12294
  }
12295
12295
  setCustomColor(t) {
@@ -12370,7 +12370,7 @@ class el extends X {
12370
12370
  const t = this.step.data.maxLength;
12371
12371
  if (t === void 0)
12372
12372
  return;
12373
- const e = Pt(this.getText(), this.manager);
12373
+ const e = vt(this.getText(), this.manager);
12374
12374
  return t - e.length;
12375
12375
  }
12376
12376
  /**
@@ -13368,7 +13368,7 @@ class gl {
13368
13368
  return await Xe.addDesign(s), s;
13369
13369
  }
13370
13370
  async copy() {
13371
- const t = vt(this.getCommandContext().getState());
13371
+ const t = Et(this.getCommandContext().getState());
13372
13372
  if (!t) throw new T("Internal state is undefined! Cannot copy experience!");
13373
13373
  const e = JSON.stringify(t.transaction), a = this.getWorkflow();
13374
13374
  if (!a) throw new T("Workflow is undefined! Cannot copy experience!");
@@ -14122,7 +14122,7 @@ class Il {
14122
14122
  }
14123
14123
  async setGlobalPropertyState(t) {
14124
14124
  this.globalPropertyState || await this.initPromise;
14125
- const e = vt(this.globalPropertyState);
14125
+ const e = Et(this.globalPropertyState);
14126
14126
  this.globalPropertyState = { ...ue(t), id: e.id }, this.recalculateMandatoryStates(), await this.updateGlobalPropertyState(), await this.onGlobalPropertyStateChange(e, this.globalPropertyState);
14127
14127
  }
14128
14128
  getAspectMandatoryFulfilled(t) {
@@ -14149,7 +14149,7 @@ class Il {
14149
14149
  if (!i)
14150
14150
  throw new Error(`Failed to find configuration aspect with name: ${t}`);
14151
14151
  this.mandatoryFulfilledAspects.set(t, e !== "");
14152
- const s = vt(this.globalPropertyState), o = this.globalPropertyState.aspects.filter((l) => l.name === t);
14152
+ const s = Et(this.globalPropertyState), o = this.globalPropertyState.aspects.filter((l) => l.name === t);
14153
14153
  if (o.length > 0)
14154
14154
  if (r) {
14155
14155
  const l = o.find((c) => c.channel === r);
@@ -14192,7 +14192,7 @@ class Il {
14192
14192
  const r = this.configuration.aspects.find((o) => o.name === t);
14193
14193
  if (!r)
14194
14194
  throw new Error(`Failed to find configuration aspect with name: ${t}`);
14195
- const i = vt(this.globalPropertyState), s = this.globalPropertyState.aspects.filter((o) => o.name === t);
14195
+ const i = Et(this.globalPropertyState), s = this.globalPropertyState.aspects.filter((o) => o.name === t);
14196
14196
  if (s.length > 0)
14197
14197
  if (a) {
14198
14198
  const o = s.find((l) => l.channel === a);
@@ -14597,7 +14597,7 @@ class or {
14597
14597
  if (h || p.partial && (!p.data.productCollections || p.data.productCollections.length === 0 || !p.data.productCollections[0].productCollectionProductsFeed?.items || p.data.productCollections[0].productCollectionProductsFeed?.items.length === 0))
14598
14598
  return;
14599
14599
  c.abort(), h = !0, m.unsubscribe();
14600
- const g = p.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((f) => !!f.product).map((f) => new he(vt(f))) || [];
14600
+ const g = p.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((f) => !!f.product).map((f) => new he(Et(f))) || [];
14601
14601
  u({
14602
14602
  items: g,
14603
14603
  // Clone items because it could be cached data (immutable)
@@ -16177,7 +16177,7 @@ class Bd {
16177
16177
  } catch (a) {
16178
16178
  throw console.error(a), new ht("Critical - Unable to synchronize workflow state with server.");
16179
16179
  }
16180
- }, this.options = t, this.options.applicationKey && Hr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 33.2.0"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16180
+ }, this.options = t, this.options.applicationKey && Hr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 33.2.1"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16181
16181
  }
16182
16182
  configure(t) {
16183
16183
  gt.setHubUrl(t.hubUrl), gt.setServerUrl(t.serverUrl), gt.setServicesApiUrl(t.servicesApiUrl), this.marketplaceThemeInstallId = t.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = t.marketplaceThemeInstallConfigurationId, this.userPoolClientId = t.userPoolClientId, this.userPoolRegion = t.userPoolRegion, this.spiffRegion = t.spiffRegion, t.bearerAuthenticationToken && Yr(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Ut.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
@@ -16670,8 +16670,8 @@ class Bd {
16670
16670
  workflowId: b.option.workflowId,
16671
16671
  designName: b.option.designName,
16672
16672
  claim: !0,
16673
- quantity: b.option.type === "integration" ? b.option.quantity : void 0,
16674
- recipient: b.option.type === "integration" ? b.option.recipient : void 0
16673
+ quantity: b.option.type === "integration" || b.option.type === "blank" ? b.option.quantity : void 0,
16674
+ recipient: b.option.type === "integration" || b.option.type === "blank" ? b.option.recipient : void 0
16675
16675
  })),
16676
16676
  marketplaceThemeInstallId: this.marketplaceThemeInstallId,
16677
16677
  marketplaceThemeInstallConfigurationId: this.marketplaceThemeInstallConfigurationId
@@ -17874,7 +17874,7 @@ export {
17874
17874
  gn as AddressValidationStatus,
17875
17875
  Id as ArrayInput,
17876
17876
  L as AspectType,
17877
- Et as AssetNotFoundError,
17877
+ bt as AssetNotFoundError,
17878
17878
  ve as AssetType,
17879
17879
  Cd as BringForwardCommand,
17880
17880
  fd as BringToBackCommand,
@@ -17924,7 +17924,7 @@ export {
17924
17924
  Vl as ObjectInputType,
17925
17925
  ir as OptionGlobalPropertyHandle,
17926
17926
  be as OptionNotFoundError,
17927
- Bt as ParseError,
17927
+ Pt as ParseError,
17928
17928
  Jo as PictureStepHandle,
17929
17929
  Tr as ProductCameraRig,
17930
17930
  or as ProductCollection,
@@ -18051,6 +18051,6 @@ export {
18051
18051
  Rs as toast,
18052
18052
  Hd as validateWorkflowExperienceRecipient,
18053
18053
  jd as validateWorkflowExperienceRecipients,
18054
- bt as xmlSerializer
18054
+ It as xmlSerializer
18055
18055
  };
18056
18056
  //# sourceMappingURL=index.mjs.map