@useinsider/guido 3.24.0-beta.0abeefe → 3.24.0-beta.0c16173

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.
Files changed (121) hide show
  1. package/README.md +7 -2
  2. package/dist/@types/config/schemas.js +40 -40
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +81 -85
  5. package/dist/composables/useActionsApi.js +2 -2
  6. package/dist/composables/useBlocksConfig.js +20 -31
  7. package/dist/composables/useEditorTrackingIds.js +49 -0
  8. package/dist/composables/useHtmlCompiler.js +2 -0
  9. package/dist/composables/useModuleRepair.js +14 -12
  10. package/dist/composables/useStripo.js +70 -70
  11. package/dist/composables/useTranslations.js +1 -2
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
  14. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
  15. package/dist/config/migrator/index.js +16 -15
  16. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  17. package/dist/enums/academy.js +0 -1
  18. package/dist/extensions/Blocks/Items/block.js +115 -77
  19. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  20. package/dist/extensions/Blocks/Items/controls/blockBackground/index.js +11 -0
  21. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +34 -23
  22. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  23. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  24. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  25. package/dist/extensions/Blocks/Items/controls/priceFormat.js +135 -0
  26. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  27. package/dist/extensions/Blocks/Items/enums/controlEnums.js +2 -2
  28. package/dist/extensions/Blocks/Items/extension.js +15 -13
  29. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  30. package/dist/extensions/Blocks/Items/settingsPanel.js +35 -25
  31. package/dist/extensions/Blocks/Items/template.js +250 -212
  32. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  34. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  35. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  36. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  37. package/dist/extensions/Blocks/controlFactories.js +104 -104
  38. package/dist/guido.css +1 -1
  39. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
  40. package/dist/node_modules/valibot/dist/index.js +261 -297
  41. package/dist/package.json.js +6 -6
  42. package/dist/services/templateLibraryApi.js +39 -36
  43. package/dist/src/@types/config/schemas.d.ts +4 -4
  44. package/dist/src/composables/useConfig.d.ts +2 -2
  45. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  46. package/dist/src/composables/useStripo.d.ts +1 -1
  47. package/dist/src/config/migrator/index.d.ts +4 -1
  48. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  49. package/dist/src/enums/academy.d.ts +0 -1
  50. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  51. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  52. package/dist/src/extensions/Blocks/Items/controls/blockBackground/index.d.ts +15 -0
  53. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +24 -0
  54. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  55. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +2 -0
  56. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  57. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  58. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +66 -0
  59. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  60. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  61. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -1
  62. package/dist/src/stores/config.d.ts +20 -167
  63. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  64. package/dist/src/utils/linkTrackingIds.d.ts +24 -22
  65. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  66. package/dist/stores/config.js +6 -13
  67. package/dist/utils/itemsCurrencyRepair.js +29 -24
  68. package/dist/utils/linkTrackingIds.js +72 -72
  69. package/dist/utils/pairProductVariables.js +119 -100
  70. package/dist/utils/templatePreparation.js +59 -72
  71. package/dist/utils/trimHrefWhitespace.js +10 -0
  72. package/package.json +1 -1
  73. package/dist/@types/display-condition.js +0 -25
  74. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -17
  75. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
  76. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
  77. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
  78. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +0 -17
  79. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +0 -45
  80. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -36
  81. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
  82. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
  83. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
  84. package/dist/composables/useDisplayConditions.js +0 -117
  85. package/dist/enums/display-condition.js +0 -12
  86. package/dist/extensions/DisplayConditions/bridge.js +0 -25
  87. package/dist/extensions/DisplayConditions/constants.js +0 -26
  88. package/dist/extensions/DisplayConditions/control.js +0 -215
  89. package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -226
  90. package/dist/extensions/DisplayConditions/extension.js +0 -28
  91. package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
  92. package/dist/extensions/DisplayConditions/library.js +0 -30
  93. package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
  94. package/dist/extensions/LinkTracking/extension.js +0 -17
  95. package/dist/extensions/LinkTracking/writer.js +0 -41
  96. package/dist/services/displayConditionApi.js +0 -39
  97. package/dist/src/@types/display-condition.d.ts +0 -60
  98. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
  99. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
  100. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +0 -18
  101. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
  102. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
  103. package/dist/src/composables/useDisplayConditions.d.ts +0 -18
  104. package/dist/src/enums/display-condition.d.ts +0 -15
  105. package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
  106. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -23
  107. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
  108. package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
  109. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
  110. package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
  111. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
  112. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  113. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
  114. package/dist/src/mock/api/display-conditions.d.ts +0 -2
  115. package/dist/src/services/displayConditionApi.d.ts +0 -8
  116. package/dist/src/stores/display-condition.d.ts +0 -84
  117. package/dist/src/utils/displayCondition.d.ts +0 -11
  118. package/dist/src/utils/protectTableText.d.ts +0 -2
  119. package/dist/stores/display-condition.js +0 -29
  120. package/dist/utils/displayCondition.js +0 -26
  121. package/dist/utils/protectTableText.js +0 -22
@@ -1,90 +1,90 @@
1
- const A = "data-ins-track-id", E = "data-ins-track-seq", g = `(?:[^>"']|"[^"]*"|'[^']*')*`, R = new RegExp(`<a\\b${g}>`, "gi"), _ = new RegExp(`<body\\b${g}>`, "i"), l = new RegExp(`<html\\b${g}>`, "i"), m = new RegExp(`\\b${A}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", d = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), I = /^[1-9][0-9]{0,14}$/, S = 999999999999999;
2
- function $(e) {
3
- const t = m.exec(e), n = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
4
- return { attrMatch: t, rawValue: n };
1
+ const l = "data-ins-track-id", E = "data-ins-track-seq", A = `(?:[^>"']|"[^"]*"|'[^']*')*`, k = new RegExp(`<a\\b${A}>`, "gi"), R = new RegExp(`<body\\b${A}>`, "i"), _ = new RegExp(`<html\\b${A}>`, "i"), m = new RegExp(`\\b${l}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", x = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), $ = /^[1-9][0-9]{0,14}$/, q = 999999999999999;
2
+ function I(e) {
3
+ const c = Number(e);
4
+ return Number.isSafeInteger(c) && c > 0 ? c : 0;
5
5
  }
6
- function k(e) {
7
- const t = Number(e);
8
- return Number.isSafeInteger(t) && t > 0 ? t : 0;
6
+ function T(e) {
7
+ return [...e.matchAll(k)].map((c) => {
8
+ const [n] = c, t = m.exec(n), r = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
9
+ return { index: c.index, tag: n, attrMatch: t, rawValue: r };
10
+ });
9
11
  }
10
- function N(e) {
11
- var s;
12
- const t = (o) => {
13
- var r;
14
- const a = (r = o.exec(e)) == null ? void 0 : r[0];
15
- return a ? f.exec(a) : null;
16
- }, n = t(_) ?? t(l), c = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((s = d.exec(e)) == null ? void 0 : s[1]) ?? "";
17
- return k(c);
12
+ function b(e) {
13
+ var r;
14
+ const c = (s) => {
15
+ var a;
16
+ const o = (a = s.exec(e)) == null ? void 0 : a[0];
17
+ return o ? f.exec(o) : null;
18
+ }, n = c(R) ?? c(_), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((r = x.exec(e)) == null ? void 0 : r[1]) ?? "";
19
+ return I(t);
18
20
  }
19
- function K(e, t = 0) {
21
+ function h(e, c = 0) {
20
22
  let n = 0;
21
- [...e.matchAll(R)].forEach(([s]) => {
22
- const { rawValue: o } = $(s);
23
- I.test(o) && (n = Math.max(n, Number(o)));
23
+ T(e).forEach(({ rawValue: r }) => {
24
+ $.test(r) && (n = Math.max(n, Number(r)));
24
25
  });
25
- const c = Number.isSafeInteger(t) && t > 0 ? t : 0;
26
- return Math.max(N(e), n, c);
26
+ const t = Number.isSafeInteger(c) && c > 0 ? c : 0;
27
+ return Math.max(b(e), n, t);
27
28
  }
28
- function M(e, t) {
29
- const n = `${E}="${t}"`, c = _.exec(e) ?? l.exec(e);
30
- if (c) {
31
- const [o] = c, a = f.exec(o), r = a ? o.replace(a[0], n) : o.replace(/\/?>$/, (i) => ` ${n}${i}`);
32
- return e.slice(0, c.index) + r + e.slice(c.index + o.length);
29
+ function w(e, c) {
30
+ const n = `${E}="${c}"`, t = R.exec(e) ?? _.exec(e);
31
+ if (t) {
32
+ const [s] = t, o = f.exec(s), a = o ? s.replace(o[0], n) : s.replace(/\/?>$/, (u) => ` ${n}${u}`);
33
+ return e.slice(0, t.index) + a + e.slice(t.index + s.length);
33
34
  }
34
- const s = `<!--${p}:${t}-->`;
35
- return d.test(e) ? e.replace(d, s) : `${s}${e}`;
35
+ const r = `<!--${p}:${c}-->`;
36
+ return x.test(e) ? e.replace(x, r) : `${r}${e}`;
36
37
  }
37
- function q(e, t, n) {
38
- const c = `${A}="${n}"`;
39
- return t ? e.replace(t[0], c) : e.replace(/^<a\b/i, (s) => `${s} ${c}`);
38
+ function M(e, c, n) {
39
+ const t = `${l}="${n}"`;
40
+ return c ? e.replace(c[0], t) : e.replace(/^<a\b/i, (r) => `${r} ${t}`);
40
41
  }
41
- function w(e, t, n = 0) {
42
- const c = /* @__PURE__ */ new Set();
43
- let s = 0;
44
- const o = e.map((u) => {
45
- if (u !== null && I.test(u) && !c.has(Number(u))) {
46
- const T = Number(u);
47
- return c.add(T), s = Math.max(s, T), T;
48
- }
49
- return null;
50
- }), a = Number.isSafeInteger(n) && n > 0 && n < S ? n : 0;
51
- let r = Math.max(t, s, a);
52
- const i = /* @__PURE__ */ new Map();
53
- o.forEach((u, T) => {
54
- u === null && (r += 1, i.set(T, r));
55
- });
56
- const x = r > 0 && t !== r;
57
- return { assignments: i, nextSeq: r, seqChanged: x, changed: i.size > 0 || x };
42
+ function C(e, c, n = 0) {
43
+ const t = /* @__PURE__ */ new Set();
44
+ let r = 0;
45
+ const s = e.map((i) => {
46
+ if (!$.test(i) || t.has(Number(i)))
47
+ return null;
48
+ const d = Number(i);
49
+ return t.add(d), r = Math.max(r, d), d;
50
+ }), o = Number.isSafeInteger(n) && n > 0 && n < q ? n : 0;
51
+ let a = Math.max(c, r, o);
52
+ const u = s.map((i) => i === null), S = s.map((i) => i !== null ? i : (a += 1, a)), g = a > 0 && c !== a;
53
+ return { ids: S, reassigned: u, nextSeq: a, seqChanged: g, changed: g || u.includes(!0) };
58
54
  }
59
- function b(e) {
60
- return [...e.matchAll(R)].map((t) => {
61
- const [n] = t;
62
- return { index: t.index, tag: n, ...$(n) };
63
- });
55
+ function D(e) {
56
+ return e !== null && /^\d+$/.test(e) ? I(e) : 0;
57
+ }
58
+ function N(e, c, n) {
59
+ let t = "", r = 0;
60
+ return c.forEach((s, o) => {
61
+ const a = n[o] ?? null;
62
+ t += e.slice(r, s.index), t += a === null ? s.tag : M(s.tag, s.attrMatch, a), r = s.index + s.tag.length;
63
+ }), t + e.slice(r);
64
64
  }
65
- const C = /<!--[\s\S]*?-->/g;
66
- function P(e, t = 0) {
67
- const n = b(e), c = n.map((a) => a.rawValue), s = [...e.matchAll(C)].map((a) => [a.index, a.index + a[0].length]), o = n.map(({ index: a }) => s.some(([r, i]) => a > r && a < i));
68
- return { anchorIds: c, inComment: o, plan: w(c, N(e), t) };
65
+ function P(e) {
66
+ return T(e).map((c) => c.rawValue);
69
67
  }
70
- function D(e, { plan: t }) {
71
- let n = "", c = 0;
72
- return b(e).forEach((s, o) => {
73
- const a = t.assignments.get(o);
74
- n += e.slice(c, s.index), n += a === void 0 ? s.tag : q(s.tag, s.attrMatch, a), c = s.index + s.tag.length;
75
- }), n += e.slice(c), t.seqChanged ? M(n, t.nextSeq) : n;
68
+ function K(e, c) {
69
+ return N(e, T(e), c);
76
70
  }
77
- function O(e, t = 0) {
78
- const n = P(e, t), { changed: c, nextSeq: s } = n.plan;
79
- return { html: c ? D(e, n) : e, changed: c, nextSeq: s };
71
+ function O(e, c = 0) {
72
+ const n = T(e), t = C(n.map((s) => s.rawValue), b(e), c);
73
+ let r = N(
74
+ e,
75
+ n,
76
+ t.ids.map((s, o) => t.reassigned[o] ? s : null)
77
+ );
78
+ return t.seqChanged && (r = w(r, t.nextSeq)), { html: r, changed: t.changed, nextSeq: t.nextSeq };
80
79
  }
81
80
  export {
82
- A as TRACK_ID_ATTRIBUTE,
81
+ l as TRACK_ID_ATTRIBUTE,
83
82
  E as TRACK_SEQ_ATTRIBUTE,
84
83
  O as assignTrackingIds,
85
- P as planDocumentTrackingIds,
86
- w as planTrackingIds,
87
- K as readTrackFloor,
88
- N as readTrackSeq,
89
- D as renderTrackingIdPlan
84
+ D as parseTrackSeq,
85
+ C as planTrackingIds,
86
+ P as readAnchorTrackIds,
87
+ h as readTrackFloor,
88
+ b as readTrackSeq,
89
+ K as writeAnchorTrackIds
90
90
  };
@@ -1,109 +1,128 @@
1
- import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extensions/Blocks/Items/constants/currency.js";
2
- import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
- import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
- import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
- import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
6
- import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
1
+ import { isNewPriceFormatRoot as G, ITEMS_PRICE_FORMAT_ATTR as N, currencyPositionFromLocation as Y, ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as B } from "../extensions/Blocks/Items/constants/currency.js";
2
+ import { productPairs as k } from "../extensions/Blocks/Items/enums/productEnums.js";
3
+ import { escapeReplacement as v } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
+ import { preserveTextStyles as w } from "./preserveTextStyles.js";
5
+ import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
7
6
  const q = {
8
7
  CART_ITEMS: "ins_apr",
9
8
  BROWSED_ITEMS: "browsed_item",
10
9
  PURCHASED_ITEMS: "purchased_item"
11
- }, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
12
- function Q($, C, A) {
13
- let d = C;
14
- for (; d > 0 && /\s/.test($[d - 1]); )
15
- d -= 1;
16
- return A.some((E) => $.endsWith(E, d));
10
+ }, W = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
11
+ function j(r, h, p) {
12
+ let u = h;
13
+ for (; u > 0 && /\s/.test(r[u - 1]); )
14
+ u -= 1;
15
+ return p.some((A) => r.endsWith(A, u));
17
16
  }
18
- const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
- function J($, C) {
20
- var d;
21
- const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
22
- for (let E = A.nextNode(); E; E = A.nextNode())
23
- (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
17
+ const Q = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
+ function z(r, h) {
19
+ var u;
20
+ const p = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
21
+ for (let A = p.nextNode(); A; A = p.nextNode())
22
+ (u = A.nodeValue) != null && u.includes("[if mso]") && (A.nodeValue = A.nodeValue.replace(Q, (L, P) => `${P}href="${h}"`));
24
23
  }
25
- function ot($) {
26
- const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
27
- j(A);
28
- const d = M.PAIRS_FOR_EXTENSION;
29
- Object.entries(d).forEach(([o, p]) => {
30
- A.querySelectorAll(".ins-product-td").forEach((r) => {
31
- const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
32
- r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
33
- var b, I, D, O;
34
- const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
24
+ function J(r) {
25
+ return {
26
+ isFormatted: r.getAttribute("data-formated") === "true",
27
+ isSinglePrice: r.getAttribute("data-single_price") === "true",
28
+ currencyPosition: r.getAttribute(U.POSITION) || "before",
29
+ configuredSymbol: (r.getAttribute(U.SYMBOL) || "").trim()
30
+ };
31
+ }
32
+ function K(r) {
33
+ return {
34
+ isFormatted: !1,
35
+ isSinglePrice: r.getAttribute(N.SINGLE_PRICE) === "true",
36
+ currencyPosition: Y(
37
+ r.getAttribute(N.ALIGNMENT) ?? void 0
38
+ ),
39
+ configuredSymbol: (r.getAttribute(N.SYMBOL) || "").trim()
40
+ };
41
+ }
42
+ function Z(r, h, p) {
43
+ const { isFormatted: u, isSinglePrice: A, currencyPosition: L, configuredSymbol: P } = p;
44
+ let y;
45
+ A ? y = u ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = u ? r.PRICE_FORMATTED : r.PRICE;
46
+ const E = r.CURRENCY;
47
+ let F = `{{${y}_${h}}}`, R = "";
48
+ return B(P) ? R = P : E && (R = `{{${E}_${h}}}`), R && (F = L === "after" ? `${F} ${R}` : `${R} ${F}`), F;
49
+ }
50
+ function ct(r) {
51
+ const h = W(r), p = new DOMParser().parseFromString(h, "text/html");
52
+ X(p);
53
+ const u = k.PAIRS_FOR_EXTENSION;
54
+ Object.entries(u).forEach(([o, T]) => {
55
+ p.querySelectorAll(".ins-product-td").forEach((n) => {
56
+ const S = n.getAttribute("data-number") || "1", I = n.getAttribute("data-type") || "CART_ITEMS";
57
+ n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
58
+ var b, M, D, x;
59
+ const m = t.getAttribute("data-type") || I, c = t.getAttribute("data-number") || S, f = T[m];
35
60
  if (f)
36
61
  switch (o) {
37
62
  case "imageSrc": {
38
- let e = null, s = null;
39
- if (t.tagName === "IMG" ? (e = t, s = e.closest("a")) : (e = t.querySelector("img"), s = t.querySelector("a") || t.closest("a")), !e)
63
+ let e = null, i = null;
64
+ if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
40
65
  break;
41
- const l = f.DEFAULT, c = f.ATTR;
42
- if (l && e.src) {
43
- const a = e.src;
44
- l.some((g) => {
45
- const u = g.split("/").pop() || "", H = a.split("/").pop() || "";
46
- return a.includes(g) || a.includes(u) || H === u;
47
- }) && (e.src = `{{${c}_${n}}}`);
66
+ const d = f.DEFAULT, a = f.ATTR;
67
+ if (d && e.src) {
68
+ const l = e.src;
69
+ d.some((C) => {
70
+ const $ = C.split("/").pop() || "", V = l.split("/").pop() || "";
71
+ return l.includes(C) || l.includes($) || V === $;
72
+ }) && (e.src = `{{${a}_${c}}}`);
48
73
  }
49
- const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
50
- if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
51
- const a = (D = d.itemLink) == null ? void 0 : D[m];
52
- if (a) {
53
- const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
54
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
74
+ const s = (M = (b = u.name) == null ? void 0 : b[m]) == null ? void 0 : M.ATTR;
75
+ if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
76
+ const l = (D = u.itemLink) == null ? void 0 : D[m];
77
+ if (l) {
78
+ const H = l.HREF, C = l.DEFAULT_HREF || "#!", $ = i.href;
79
+ ($ === "#" || $ === "" || $.endsWith("#!") || $.endsWith(C) || $ === `${window.location.href}${C}` || !$ || $ === window.location.href) && (i.href = `{{${H}_${c}}}`);
55
80
  }
56
81
  }
57
82
  break;
58
83
  }
59
84
  case "name": {
60
- const e = f, s = e.ATTR, l = e.DEFAULT_HREF || "#!", c = e.HREF;
61
- t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
62
- const i = t.closest("a") || (t.tagName === "A" ? t : null);
63
- if (i && c) {
64
- const a = i.href, S = `${window.location.href}${l}`;
65
- (a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
85
+ const e = f, i = e.ATTR, d = e.DEFAULT_HREF || "#!", a = e.HREF;
86
+ t.textContent && (t.innerHTML = w(t, `{{${i}_${c}}}`));
87
+ const s = t.closest("a") || (t.tagName === "A" ? t : null);
88
+ if (s && a) {
89
+ const l = s.href, H = `${window.location.href}${d}`;
90
+ (l === H || l.endsWith(d)) && (s.href = `{{${a}_${c}}}`);
66
91
  }
67
92
  break;
68
93
  }
69
94
  case "price":
70
95
  case "originalPrice": {
71
- const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
72
- let S;
73
- i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
74
- const g = e.CURRENCY;
75
- let u = `{{${S}_${n}}}`;
76
- const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
77
- let F = "";
78
- G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
96
+ const e = f, i = G(n) ? K(n) : J(t);
97
+ t.innerHTML = w(t, Z(e, c, i));
79
98
  break;
80
99
  }
81
100
  case "quantity": {
82
- const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
83
- c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
101
+ const e = f, i = e.ATTR, d = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (x = t.textContent) == null ? void 0 : x.trim();
102
+ a && d.includes(a) && (t.innerHTML = w(t, `{{${i}_${c}}}`));
84
103
  break;
85
104
  }
86
105
  case "button": {
87
- const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t.tagName === "A" ? t : t.querySelector("a");
88
- if (c) {
89
- const i = c.href || "", a = `${window.location.href}${l}`;
90
- (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
106
+ const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
107
+ if (a) {
108
+ const s = a.href || "", l = `${window.location.href}${d}`;
109
+ (s === "" || s === "#" || s === l || s.endsWith(d) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
91
110
  }
92
- J(t, `{{${s}_${n}}}`);
111
+ z(t, `{{${i}_${c}}}`);
93
112
  break;
94
113
  }
95
114
  case "itemLink": {
96
- const e = f, s = e.HREF, l = e.DEFAULT_HREF || "#!", c = t;
97
- if (c.href) {
98
- const i = c.href, a = `${window.location.href}${l}`;
99
- (i === a || i.endsWith(l)) && (c.href = `{{${s}_${n}}}`);
115
+ const e = f, i = e.HREF, d = e.DEFAULT_HREF || "#!", a = t;
116
+ if (a.href) {
117
+ const s = a.href, l = `${window.location.href}${d}`;
118
+ (s === l || s.endsWith(d)) && (a.href = `{{${i}_${c}}}`);
100
119
  }
101
120
  break;
102
121
  }
103
122
  default: {
104
123
  if ("ATTR" in f) {
105
124
  const e = f.ATTR;
106
- t.textContent && (t.innerHTML = L(t, `{{${e}_${n}}}`));
125
+ t.textContent && (t.innerHTML = w(t, `{{${e}_${c}}}`));
107
126
  }
108
127
  break;
109
128
  }
@@ -111,49 +130,49 @@ function ot($) {
111
130
  });
112
131
  });
113
132
  });
114
- const E = C.match(/<!DOCTYPE[^>]*>/i), k = E ? `${E[0]}
115
- ` : "", P = A.querySelectorAll(".ins-product-td"), N = [];
133
+ const A = h.match(/<!DOCTYPE[^>]*>/i), L = A ? `${A[0]}
134
+ ` : "", P = p.querySelectorAll(".ins-product-td"), y = [];
116
135
  P.forEach((o) => {
117
- const p = o.getAttribute("data-type") || "CART_ITEMS", T = o.getAttribute("data-number") || "1", r = o.outerHTML;
118
- N.push({
136
+ const T = o.getAttribute("data-type") || "CART_ITEMS", _ = o.getAttribute("data-number") || "1", n = o.outerHTML;
137
+ y.push({
119
138
  element: o,
120
- outerHtml: r,
121
- type: p,
122
- number: T
139
+ outerHtml: n,
140
+ type: T,
141
+ number: _
123
142
  });
124
143
  });
125
- let h = k + A.documentElement.outerHTML;
126
- N.reverse().forEach(({ outerHtml: o, type: p, number: T }) => {
127
- const r = q[p], _ = r ? `${r}_total_product_kind` : "";
128
- if (_) {
129
- const R = parseInt(T) - 1, n = `${`{% if ${_} > ${R} %}`}${o}{% endif %}`;
130
- h = h.replace(o, B(n));
144
+ let E = L + p.documentElement.outerHTML;
145
+ y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
146
+ const n = q[T], S = n ? `${n}_total_product_kind` : "";
147
+ if (S) {
148
+ const g = parseInt(_) - 1, c = `${`{% if ${S} > ${g} %}`}${o}{% endif %}`;
149
+ E = E.replace(o, v(c));
131
150
  }
132
151
  });
133
- const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
134
- return V.forEach((o) => {
152
+ const F = p.querySelectorAll('[product-attr="originalPrice"][data-type]'), R = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set();
153
+ return F.forEach((o) => {
135
154
  var t;
136
- const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
137
- if (!p || !q[T])
155
+ const T = o.getAttribute("data-number"), _ = o.getAttribute("data-type");
156
+ if (!T || !q[_])
138
157
  return;
139
- const r = o.closest(".product-original-price-class");
140
- if (!r || x.has(r))
158
+ const n = o.closest(".product-original-price-class");
159
+ if (!n || O.has(n))
141
160
  return;
142
- x.add(r);
143
- const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
144
- R.wrap.push(y !== "false"), w.set(_, R);
145
- }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
146
- if (r.includes("{% if") || !T.some(Boolean))
161
+ O.add(n);
162
+ const S = n.outerHTML, I = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = R.get(S) ?? { number: T, type: _, wrap: [] };
163
+ g.wrap.push(I !== "false"), R.set(S, g);
164
+ }), R.forEach(({ number: o, type: T, wrap: _ }, n) => {
165
+ if (n.includes("{% if") || !_.some(Boolean))
147
166
  return;
148
- const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
149
- let m = "", n = 0, f = 0, b = h.indexOf(r);
167
+ const S = k.PAIRS_FOR_EXTENSION.price[T].PRICE, I = k.PAIRS_FOR_EXTENSION.originalPrice[T].PRICE, g = `{% if ${S}_${o} != ${I}_${o} %}`, t = [g, W(g)];
168
+ let m = "", c = 0, f = 0, b = E.indexOf(n);
150
169
  for (; b !== -1; ) {
151
- const I = T[f] === !0 && !Q(h, b, t);
152
- m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
170
+ const M = _[f] === !0 && !j(E, b, t);
171
+ m += E.slice(c, b) + (M ? `${g}${n}{% endif %}` : n), c = b + n.length, f += 1, b = E.indexOf(n, c);
153
172
  }
154
- h = m + h.slice(n);
155
- }), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
173
+ E = m + E.slice(c);
174
+ }), E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
156
175
  }
157
176
  export {
158
- ot as pairProductVariables
177
+ ct as pairProductVariables
159
178
  };
@@ -1,45 +1,44 @@
1
- import { useActionsApi as E } from "../composables/useActionsApi.js";
2
- import { useConfig as R } from "../composables/useConfig.js";
3
- import { useHtmlCompiler as U } from "../composables/useHtmlCompiler.js";
4
- import { useRecommendationExtensionStore as k } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { toBlockUrlConfig as L } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
- import { DATA_ATTRIBUTES as b } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as v } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { writeTrackingIdsInPlace as N } from "../extensions/LinkTracking/writer.js";
9
- import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
- import { useEditorStore as q } from "../stores/editor.js";
11
- import { useUnsubscribeStore as M } from "../stores/unsubscribe.js";
12
- import { isPlainObject as O } from "./genericUtil.js";
13
- import { planDocumentTrackingIds as T, renderTrackingIdPlan as B } from "./linkTrackingIds.js";
14
- function _(c) {
15
- const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${b.PAGE_LIST}]`), e = [];
16
- return i.forEach((s) => {
17
- const o = s.getAttribute(b.PAGE_LIST);
18
- o && e.push(...v(o));
1
+ import { useActionsApi as x } from "../composables/useActionsApi.js";
2
+ import { useConfig as D } from "../composables/useConfig.js";
3
+ import { useEditorTrackingIds as F } from "../composables/useEditorTrackingIds.js";
4
+ import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
5
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
6
+ import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
7
+ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
8
+ import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
9
+ import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
10
+ import { useEditorStore as N } from "../stores/editor.js";
11
+ import { useUnsubscribeStore as z } from "../stores/unsubscribe.js";
12
+ import { isPlainObject as v } from "./genericUtil.js";
13
+ function M(n) {
14
+ const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
+ return r.forEach((i) => {
16
+ const t = i.getAttribute(g.PAGE_LIST);
17
+ t && e.push(...U(t));
19
18
  }), [...new Set(e)];
20
19
  }
21
- async function w(c) {
22
- const a = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
23
- if (a.length === 0)
20
+ async function S(n) {
21
+ const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (o.length === 0)
24
23
  return;
25
- const i = k();
26
- a.forEach((e) => {
27
- const s = e.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
28
- if (!Number.isFinite(o))
24
+ const r = b();
25
+ o.forEach((e) => {
26
+ const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
+ if (!Number.isFinite(t))
29
28
  return;
30
- const l = e.getAttribute("esd-ext-config");
31
- if (!l)
29
+ const c = e.getAttribute("esd-ext-config");
30
+ if (!c)
32
31
  return;
33
- let m;
32
+ let a;
34
33
  try {
35
- m = JSON.parse(l);
34
+ a = JSON.parse(c);
36
35
  } catch {
37
36
  return;
38
37
  }
39
- O(m) && i.seedBlockUrlConfig(o, L(m));
38
+ v(a) && r.seedBlockUrlConfig(t, R(a));
40
39
  });
41
40
  try {
42
- await i.fetchRecommendationCreateData();
41
+ await r.fetchRecommendationCreateData();
43
42
  } catch (e) {
44
43
  console.warn(
45
44
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -47,63 +46,51 @@ async function w(c) {
47
46
  );
48
47
  }
49
48
  }
50
- const oe = () => {
51
- const c = z(), n = q(), a = M(), { getCompiledEmail: i, getTemplateData: e, updateHtmlAndCss: s } = E(), { compileHtml: o, compileAmpHtml: l } = U(), { isFeatureEnabled: m } = R();
49
+ const Y = () => {
50
+ const n = L(), s = N(), o = z(), { getCompiledEmail: r, getTemplateData: e } = x(), { writeTrackingIds: i } = F(), { compileHtml: t, compileAmpHtml: c } = I(), { isFeatureEnabled: a } = D();
52
51
  return {
53
- prepareTemplateDetails: async (y) => {
54
- let { html: r, css: u, syncModulesIds: g = [] } = y ?? await e();
55
- if (m("linkTrackingIds"))
56
- try {
57
- let t = T(r, n.trackIdSessionFloor);
58
- n.trackIdSessionFloor = t.plan.nextSeq;
59
- let p = t.plan.changed;
60
- if (p && N(t)) {
61
- const h = await e().catch((x) => (console.warn(
62
- "Tracking-id re-read failed, saving the planned ids without a replacement:",
63
- x
64
- ), null));
65
- h ? ({ html: r, css: u, syncModulesIds: g = [] } = h, t = T(r, n.trackIdSessionFloor), n.trackIdSessionFloor = t.plan.nextSeq, p = t.plan.changed) : p = !1;
66
- }
67
- t.plan.changed && (r = B(r, t)), p && await s(r, u);
68
- } catch (t) {
69
- console.error("Tracking-id step failed, saving anyway:", t);
70
- }
71
- const { html: A, ampHtml: f = "", ampErrors: P = [] } = await i({
52
+ prepareTemplateDetails: async (h) => {
53
+ let { html: m, css: p, syncModulesIds: u = [] } = h ?? await e();
54
+ if (a("linkTrackingIds")) {
55
+ const { changed: P, nextSeq: E } = i(s.trackIdSessionFloor);
56
+ s.trackIdSessionFloor = E, P && ({ html: m, css: p, syncModulesIds: u = [] } = await e());
57
+ }
58
+ const { html: T, ampHtml: d = "", ampErrors: w = [] } = await r({
72
59
  minimize: !0,
73
60
  resetDataSavedFlag: !1
74
61
  });
75
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await w(r);
76
- const { compiledHtml: C, stats: d, appliedRules: I } = o(A), H = f && l(f).compiledHtml, D = c.getSelectedDynamicContentList, F = k(), S = _(r);
62
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(m);
63
+ const { compiledHtml: A, stats: l, appliedRules: y } = t(T), C = d && c(d).compiledHtml, k = n.getSelectedDynamicContentList, H = b(), f = M(m);
77
64
  return console.debug("HTML Compilation Stats:", {
78
- originalSize: d.originalSize,
79
- compiledSize: d.compiledSize,
80
- reduction: `${d.reductionPercentage.toFixed(2)}%`,
81
- appliedRules: I,
82
- executionTime: `${d.executionTime.toFixed(2)}ms`
65
+ originalSize: l.originalSize,
66
+ compiledSize: l.compiledSize,
67
+ reduction: `${l.reductionPercentage.toFixed(2)}%`,
68
+ appliedRules: y,
69
+ executionTime: `${l.executionTime.toFixed(2)}ms`
83
70
  }), {
84
- dynamicContentList: D,
85
- compiledHtml: C,
86
- rawHtml: r,
87
- css: u,
88
- ampHtml: H,
89
- ampErrors: P,
90
- modules: g.map(Number),
71
+ dynamicContentList: k,
72
+ compiledHtml: A,
73
+ rawHtml: m,
74
+ css: p,
75
+ ampHtml: C,
76
+ ampErrors: w,
77
+ modules: u.map(Number),
91
78
  recommendation: {
92
- campaignUrls: F.recommendationCampaignUrls,
79
+ campaignUrls: H.recommendationCampaignUrls,
93
80
  configs: {}
94
81
  },
95
82
  unsubscribe: {
96
- status: S.length > 0,
97
- config: S
83
+ status: f.length > 0,
84
+ config: f
98
85
  }
99
86
  };
100
87
  },
101
88
  // Exposed so the back/test validate-only path can seed the reco store the
102
89
  // same way a full save does (required-field findings depend on it).
103
- hydrateRecommendationStore: w
90
+ hydrateRecommendationStore: S
104
91
  };
105
92
  };
106
93
  export {
107
- _ as getHtmlReferencedUnsubscribePages,
108
- oe as useTemplatePreparation
94
+ M as getHtmlReferencedUnsubscribePages,
95
+ Y as useTemplatePreparation
109
96
  };