@useinsider/guido 3.1.1-beta.f9482a3 → 3.2.0-beta.4aabac5

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 (51) hide show
  1. package/dist/@types/config/schemas.js +69 -59
  2. package/dist/components/Guido.vue.js +4 -4
  3. package/dist/components/Guido.vue2.js +91 -81
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  6. package/dist/composables/useHtmlCompiler.js +20 -20
  7. package/dist/composables/usePreviewMode.js +20 -16
  8. package/dist/composables/useSave.js +15 -13
  9. package/dist/config/compiler/recommendationCompilerRules.js +88 -82
  10. package/dist/config/compiler/utils/recommendationCompilerUtils.js +66 -64
  11. package/dist/config/migrator/checkboxMigrator.js +5 -3
  12. package/dist/config/migrator/radioButtonMigrator.js +14 -12
  13. package/dist/enums/extensions/recommendationBlock.js +14 -11
  14. package/dist/enums/recommendation.js +2 -2
  15. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  16. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  17. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  18. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +95 -93
  19. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  20. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  22. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  23. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  24. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
  25. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  26. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  27. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  28. package/dist/guido.css +1 -1
  29. package/dist/services/recommendationApi.js +15 -15
  30. package/dist/src/@types/config/index.d.ts +1 -1
  31. package/dist/src/@types/config/schemas.d.ts +24 -0
  32. package/dist/src/@types/config/types.d.ts +3 -1
  33. package/dist/src/@types/generic.d.ts +0 -1
  34. package/dist/src/composables/useConfig.d.ts +10 -0
  35. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  36. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  37. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  38. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  39. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  40. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  41. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  42. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  43. package/dist/src/stores/config.d.ts +90 -0
  44. package/dist/src/stores/preview.d.ts +3 -0
  45. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  46. package/dist/static/styles/base.css.js +7 -2
  47. package/dist/stores/preview.js +4 -3
  48. package/dist/utils/htmlCompiler.js +48 -41
  49. package/dist/utils/templatePreparation.js +35 -26
  50. package/dist/utils/tooltipUtils.js +4 -5
  51. package/package.json +2 -2
@@ -1,31 +1,35 @@
1
- import { useEditorStore as n } from "../stores/editor.js";
2
- import { usePreviewStore as l } from "../stores/preview.js";
3
- import { useActionsApi as m } from "./useActionsApi.js";
4
- import { useCodeEditorApi as p } from "./useCodeEditorApi.js";
5
- const E = () => {
6
- const o = n(), e = l(), { closeCodeEditor: a } = p(), { getPreviewData: s } = m(), r = () => {
7
- o.isPreviewModeOpen = !1, e.$reset();
1
+ import { useEditorStore as d } from "../stores/editor.js";
2
+ import { usePreviewStore as n } from "../stores/preview.js";
3
+ import { useActionsApi as p } from "./useActionsApi.js";
4
+ import { useCodeEditorApi as c } from "./useCodeEditorApi.js";
5
+ import { useHtmlCompiler as u } from "./useHtmlCompiler.js";
6
+ const g = () => {
7
+ const t = d(), e = n(), { closeCodeEditor: i } = c(), { getPreviewData: a, getCompiledEmail: s } = p(), { compileHtml: m } = u(), r = () => {
8
+ t.isPreviewModeOpen = !1, e.$reset();
8
9
  };
9
10
  return {
10
11
  closePreviewMode: r,
11
12
  openPreviewMode: () => {
12
- o.isCodeEditorOpen && a(), o.isPreviewModeOpen = !0;
13
+ t.isCodeEditorOpen && i(), t.isPreviewModeOpen = !0;
13
14
  },
14
15
  loadPreviewData: async () => {
15
- if (!(o.loadingStatus || e.isLoaded)) {
16
- o.loadingStatus = !0;
16
+ if (!(t.loadingStatus || e.isLoaded)) {
17
+ t.loadingStatus = !0;
17
18
  try {
18
- const { html: t, ampHtml: i, ampErrors: d } = await s();
19
- e.templateHtml = t || "", e.ampHtml = i || "", e.ampErrors = d || [], e.setEmailFormat(i ? "AMP" : "html"), e.isLoaded = !0;
20
- } catch (t) {
21
- console.error("Failed to load preview data:", t), r();
19
+ const [o, l] = await Promise.all([
20
+ a(),
21
+ s({ minimize: !0, resetDataSavedFlag: !1 })
22
+ ]);
23
+ e.templateHtml = o.html || "", e.ampHtml = o.ampHtml || "", e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = m(l.html).estimatedSizeKB, e.isLoaded = !0;
24
+ } catch (o) {
25
+ console.error("Failed to load preview data:", o), r();
22
26
  } finally {
23
- o.loadingStatus = !1;
27
+ t.loadingStatus = !1;
24
28
  }
25
29
  }
26
30
  }
27
31
  };
28
32
  };
29
33
  export {
30
- E as usePreviewMode
34
+ g as usePreviewMode
31
35
  };
@@ -1,21 +1,23 @@
1
- import { useConfig as d } from "./useConfig.js";
2
- import { useSaveStart as p, useSaveComplete as f } from "./useGuidoActions.js";
3
- import { useSyncModuleExtractor as v } from "./useSyncModuleExtractor.js";
4
- import { useStripoApi as S } from "../services/stripoApi.js";
5
- import { useTemplatePreparation as x } from "../utils/templatePreparation.js";
6
- import { useHtmlValidator as V } from "./useHtmlValidator.js";
7
- const g = () => {
8
- const o = p(), s = f(), { validateHtml: i } = V(), { callbacks: a } = d(), { extractSyncModuleData: r } = v(), { setSyncModuleUnsubscriptionPages: n } = S();
9
- return { save: async (l = !1) => {
1
+ import { useActionsApi as d } from "./useActionsApi.js";
2
+ import { useConfig as f } from "./useConfig.js";
3
+ import { useSaveStart as v, useSaveComplete as S } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as x } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as V } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as y } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as w } from "./useHtmlValidator.js";
8
+ const k = () => {
9
+ const o = v(), s = S(), { validateHtml: i } = w(), { callbacks: a } = f(), { extractSyncModuleData: r } = x(), { setSyncModuleUnsubscriptionPages: n } = V(), { editorSave: l } = d();
10
+ return { save: async (c = !1) => {
10
11
  var e;
11
12
  o();
12
- const { prepareTemplateDetails: c } = x(), t = await c();
13
+ const { prepareTemplateDetails: m } = y(), t = await m();
13
14
  if (!await i(t.compiledHtml, t.dynamicContentList, !0) || (e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t))
14
15
  return;
15
- const { unsubscribePayload: m, stripoModules: u } = r(t.rawHtml);
16
- return await n(m), t.modules = u, l || s(t), t;
16
+ l();
17
+ const { unsubscribePayload: u, stripoModules: p } = r(t.rawHtml);
18
+ return await n(u), t.modules = p, c || s(t), t;
17
19
  } };
18
20
  };
19
21
  export {
20
- g as useSave
22
+ k as useSave
21
23
  };
@@ -1,16 +1,16 @@
1
1
  import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as M, REGEX as _, VerticalOrientation as h, CSS as d, ATTRIBUTES as R, CONDITIONS as y, HTML as C } from "../../enums/recommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as C, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as R, CONDITIONS as $, HTML as h } from "../../enums/recommendation.js";
3
3
  import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
4
4
  const w = [
5
5
  {
6
6
  id: "replace-images-with-variable-names",
7
7
  description: "Replacing dummy images with variable names in recommendation module",
8
8
  type: "custom",
9
- processor: (n) => {
10
- let e = n;
11
- return Object.entries(M).forEach(([, l]) => {
12
- Object.entries(l).forEach(([s, r]) => {
13
- e = e.replaceAll(r, `{{${s}}}`);
9
+ processor: (i) => {
10
+ let e = i;
11
+ return Object.entries(C).forEach(([, p]) => {
12
+ Object.entries(p).forEach(([c, n]) => {
13
+ e = e.replaceAll(n, `{{${c}}}`);
14
14
  });
15
15
  }), e;
16
16
  },
@@ -29,21 +29,21 @@ const w = [
29
29
  id: "add-recommendation-unresponsive-css",
30
30
  description: "Adding recommendation unresponsive css",
31
31
  type: "custom",
32
- processor: (n) => {
33
- const { calculateCardWidth: e, getRecommendationCampaignData: l } = N();
34
- let s = n;
35
- const r = s.match(_.ID);
36
- if (r) {
37
- const i = [];
38
- if (r.forEach((p) => {
39
- const u = /recommendation-id="(.*?)"/i.exec(p), I = u ? u[1].trim() : "", E = l(I);
40
- E.textTrimming && E.orientation === h && i.push(e(E));
41
- }), i.length) {
42
- const p = `width:${Math.min(...i)}px!important;`;
43
- s = s.replace(d.REGULAR_NAME_HEIGHT, `${d.TRIMMED_NAME_HEIGHT} ${p} ${d.ELLIPSIS}`).replace(d.REGULAR_NAME_CONTAINER_HEIGHT, d.TRIMMED_NAME_CONTAINER_CSS).replace(d.RESPONSIVE_NAME_SIZE, `${d.RESPONSIVE_NAME_HEIGHT} ${p} ${d.ELLIPSIS}`).replace(d.RESPONSIVE_NAME_CONTAINER_HEIGHT, d.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
32
+ processor: (i) => {
33
+ const { calculateCardWidth: e, getRecommendationCampaignData: p } = N();
34
+ let c = i;
35
+ const n = c.match(T.ID);
36
+ if (n) {
37
+ const a = [];
38
+ if (n.forEach((s) => {
39
+ const d = /recommendation-id="(.*?)"/i.exec(s), _ = d ? d[1].trim() : "", A = p(_);
40
+ A.textTrimming && A.orientation === M && a.push(e(A));
41
+ }), a.length) {
42
+ const s = `width:${Math.min(...a)}px!important;`;
43
+ c = c.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
44
44
  }
45
45
  }
46
- return s;
46
+ return c;
47
47
  },
48
48
  priority: 52
49
49
  },
@@ -51,34 +51,34 @@ const w = [
51
51
  id: "prepare-recommendations",
52
52
  description: "Replacing product data with template variables in recommendation blocks",
53
53
  type: "custom",
54
- processor: (n) => x(n),
54
+ processor: (i) => x(i),
55
55
  priority: 48
56
56
  },
57
57
  {
58
58
  id: "add-discount-conditions",
59
59
  description: "Adding discount conditions to the recommendation block",
60
60
  type: "custom",
61
- processor: (n) => {
62
- let e = n;
63
- const l = e.match(_.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: s } = N();
64
- return l !== null && l.forEach((r) => {
65
- const i = r.match(_.CUSTOM_FIELD);
66
- if (!i)
61
+ processor: (i) => {
62
+ let e = i;
63
+ const p = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: c } = N();
64
+ return p !== null && p.forEach((n) => {
65
+ const a = n.match(T.CUSTOM_FIELD);
66
+ if (!a)
67
67
  return;
68
- const [p] = i, u = p.match(_.CUSTOM_FIELD_INDEXES_PART), I = p.match(_.CUSTOM_FIELD_NAME_PART), E = r.match(_.ATTRIBUTE_PARAGRAPH_START_TAG);
69
- if (!u || !I || !E)
68
+ const [s] = a, d = s.match(T.CUSTOM_FIELD_INDEXES_PART), _ = s.match(T.CUSTOM_FIELD_NAME_PART), A = n.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!d || !_ || !A)
70
70
  return;
71
- const [S] = u, [m] = I, [t] = E, o = m.substring(1, m.length - 2), c = t.match(_.COMPOSITION) !== null;
72
- let a = p;
73
- if (c) {
74
- const b = S.substring(2, S.length - 3), A = s(b);
75
- o === R.OMNIBUS_PRICE && (A.priceBeforeTextValue && (a = `${A.priceBeforeTextValue}${a}`), A.priceAfterTextValue && (a = `${a}${A.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (A.discountBeforeTextValue && (a = `${A.discountBeforeTextValue}${a}`), A.discountAfterTextValue && (a = `${a}${A.discountAfterTextValue}`));
71
+ const [I] = d, [S] = _, [m] = A, o = S.substring(1, S.length - 2), r = m.match(T.COMPOSITION) !== null;
72
+ let t = s;
73
+ if (r) {
74
+ const b = I.substring(2, I.length - 3), l = c(b);
75
+ o === R.OMNIBUS_PRICE && (l.priceBeforeTextValue && (t = `${l.priceBeforeTextValue}${t}`), l.priceAfterTextValue && (t = `${t}${l.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (t = `${l.discountBeforeTextValue}${t}`), l.discountAfterTextValue && (t = `${t}${l.discountAfterTextValue}`));
76
76
  }
77
- const f = S.substring(2);
78
- let T = "";
79
- o in y.IF && (T = y.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${f}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${f}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${f}${R.OMNIBUS_PRICE}`));
80
- const $ = `${t}${a}${C.PARAGRAPH_END_TAG}`, g = `${T}${c ? $ : r}${y.ELSE}${t}${C.PARAGRAPH_END_TAG}${y.END_IF}`;
81
- e = e.replace(r, g);
77
+ const u = I.substring(2);
78
+ let f = "";
79
+ o in $.IF && (f = $.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${u}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${u}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${u}${R.OMNIBUS_PRICE}`));
80
+ const g = `${m}${t}${h.PARAGRAPH_END_TAG}`, y = `${f}${r ? g : n}${$.ELSE}${m}${h.PARAGRAPH_END_TAG}${$.END_IF}`;
81
+ e = e.replace(n, y);
82
82
  }), e;
83
83
  },
84
84
  priority: 53
@@ -106,8 +106,8 @@ const w = [
106
106
  id: "strip-unused-recommendation-classes",
107
107
  description: "Remove CSS classes not referenced by any style rule from recommendation elements",
108
108
  type: "custom",
109
- processor: (n) => {
110
- let e = n.replace(
109
+ processor: (i) => {
110
+ let e = i.replace(
111
111
  / class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
112
112
  ""
113
113
  );
@@ -119,8 +119,8 @@ const w = [
119
119
  id: "remove-empty-mobile-layout-artifacts",
120
120
  description: "Remove empty mobile container rows and unused mobile layout CSS",
121
121
  type: "custom",
122
- processor: (n) => {
123
- let e = n;
122
+ processor: (i) => {
123
+ let e = i;
124
124
  return e = e.replace(
125
125
  /<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
126
126
  ""
@@ -129,9 +129,9 @@ const w = [
129
129
  ""
130
130
  ), e = e.replace(
131
131
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
132
- (l, s) => {
133
- const r = s.match(/[^{}]+\{[^{}]*\}/g) || [], i = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
134
- return r.every((u) => i.test(u)) ? "" : l;
132
+ (p, c) => {
133
+ const n = c.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
134
+ return n.every((d) => a.test(d)) ? "" : p;
135
135
  }
136
136
  )), e;
137
137
  },
@@ -141,51 +141,57 @@ const w = [
141
141
  id: "deduplicate-inline-styles",
142
142
  description: "Replace repeated inline styles with CSS class references within recommendation blocks",
143
143
  type: "custom",
144
- processor: (n) => {
145
- const e = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, l = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
146
- let r = e.exec(n);
147
- for (; r !== null; ) {
148
- let t = l.exec(r[1]);
149
- for (; t !== null; ) {
150
- const [, o] = t;
151
- s.set(o, (s.get(o) || 0) + 1), t = l.exec(r[1]);
144
+ processor: (i) => {
145
+ const e = i.replace(
146
+ /<a\b[^>]*\bes-button\b[^>]*>/g,
147
+ (o) => o.replace(
148
+ /([;"]color:)([^;"]+)/g,
149
+ (r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
150
+ )
151
+ ), p = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, c = / style="([^"]*)"/g, n = /* @__PURE__ */ new Map();
152
+ let a = p.exec(e);
153
+ for (; a !== null; ) {
154
+ let o = c.exec(a[1]);
155
+ for (; o !== null; ) {
156
+ const [, r] = o;
157
+ n.set(r, (n.get(r) || 0) + 1), o = c.exec(a[1]);
152
158
  }
153
- l.lastIndex = 0, r = e.exec(n);
159
+ c.lastIndex = 0, a = p.exec(e);
154
160
  }
155
- const i = /* @__PURE__ */ new Map(), p = [];
156
- let u = 0;
157
- if (s.forEach((t, o) => {
158
- if (t >= 6) {
159
- const c = `rc${u++}`;
160
- i.set(o, c), p.push(`.${c}{${o}}`);
161
+ const s = /* @__PURE__ */ new Map(), d = [];
162
+ let _ = 0;
163
+ if (n.forEach((o, r) => {
164
+ if (o >= 6) {
165
+ const t = `rc${_++}`;
166
+ s.set(r, t), d.push(`.${t}{${r}}`);
161
167
  }
162
- }), i.size === 0) {
163
- let t = n;
164
- return t = t.replaceAll("<!--REC_START-->", ""), t = t.replaceAll("<!--REC_END-->", ""), t;
168
+ }), s.size === 0) {
169
+ let o = e;
170
+ return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
165
171
  }
166
- const I = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), E = (t, o) => `${t.slice(0, -1)} ${o}"`, S = /* @__PURE__ */ new Map();
167
- i.forEach((t, o) => {
168
- const c = I(o);
169
- S.set(o, {
170
- caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${c}"`, "g"),
171
- caseB: new RegExp(` style="${c}"((?:[^>]*?))(class="[^"]*")`, "g")
172
+ const A = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), I = (o, r) => `${o.slice(0, -1)} ${r}"`, S = /* @__PURE__ */ new Map();
173
+ s.forEach((o, r) => {
174
+ const t = A(r);
175
+ S.set(r, {
176
+ caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
177
+ caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
172
178
  });
173
179
  });
174
- let m = n.replace("</style>", `${p.join("")}</style>`);
180
+ let m = e.replace("</style>", `${d.join("")}</style>`);
175
181
  return m = m.replace(
176
182
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
177
- (t, o) => {
178
- let c = o;
179
- return i.forEach((a, f) => {
180
- const T = S.get(f);
181
- T.caseA.lastIndex = 0, c = c.replace(
182
- T.caseA,
183
- ($, g, b) => E(g, a) + b
184
- ), T.caseB.lastIndex = 0, c = c.replace(
185
- T.caseB,
186
- ($, g, b) => g + E(b, a)
187
- ), c = c.replaceAll(` style="${f}"`, ` class="${a}"`);
188
- }), c;
183
+ (o, r) => {
184
+ let t = r;
185
+ return s.forEach((u, f) => {
186
+ const g = S.get(f);
187
+ t = t.replace(
188
+ g.caseA,
189
+ (y, b, l) => I(b, u) + l
190
+ ), t = t.replace(
191
+ g.caseB,
192
+ (y, b, l) => b + I(l, u)
193
+ ), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
194
+ }), t;
189
195
  }
190
196
  ), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
191
197
  },
@@ -1,133 +1,135 @@
1
- import { useRecommendation as S } from "../../../composables/useRecommendation.js";
2
- function b(e, n, r, c) {
3
- const u = `{{${e}_${n}_${r}}}`, t = `{{${e}_${n}_currency}}`;
4
- return c === "before" ? `${t} ${u}` : `${u} ${t}`;
1
+ import { useConfig as S } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
+ function y(e, u, r, o, s = "") {
4
+ const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
5
+ return o === "before" ? `${t} ${n}` : `${n} ${t}`;
5
6
  }
6
- function p(e, n, r, c, u) {
7
- switch (n) {
7
+ function p(e, u, r, o, s, n) {
8
+ switch (u) {
8
9
  case "productImage": {
9
10
  const t = e.querySelector("img");
10
- t && (t.setAttribute("src", `{{${r}_${c}_image_url}}`), t.setAttribute("alt", `{{${r}_${c}_name}}`));
11
- const o = e.querySelector("a");
12
- o && o.setAttribute("href", `{{${r}_${c}_url}}`);
11
+ t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
12
+ const c = e.querySelector("a");
13
+ c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
13
14
  break;
14
15
  }
15
16
  case "productName": {
16
17
  const t = e.querySelector("p");
17
18
  if (t) {
18
- const o = t.querySelector("strong") || t;
19
- o.textContent = `{{${r}_${c}_name}}`;
19
+ const c = t.querySelector("strong") || t;
20
+ c.textContent = `{{${n}${r}_${o}_name}}`;
20
21
  }
21
22
  break;
22
23
  }
23
24
  case "productPrice": {
24
25
  const t = e.querySelector("p");
25
26
  if (t) {
26
- const o = t.querySelector("strong") || t;
27
- o.textContent = b(r, c, "price", u);
27
+ const c = t.querySelector("strong") || t;
28
+ c.textContent = y(r, o, "price", s, n);
28
29
  }
29
30
  break;
30
31
  }
31
32
  case "productOldPrice": {
32
33
  const t = e.querySelector("p");
33
34
  if (t) {
34
- const o = t.querySelector("strong") || t;
35
- o.textContent = b(
35
+ const c = t.querySelector("strong") || t;
36
+ c.textContent = y(
36
37
  r,
37
- c,
38
+ o,
38
39
  "original_price",
39
- u
40
+ s,
41
+ n
40
42
  ), t.setAttribute("product-attr", "discount");
41
43
  }
42
44
  break;
43
45
  }
44
46
  case "productButton": {
45
47
  const t = e.querySelector("a");
46
- t && t.setAttribute("href", `{{${r}_${c}_url}}`);
48
+ t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
47
49
  break;
48
50
  }
49
51
  case "productOmnibusPrice": {
50
52
  const t = e.querySelector(".omnibus-price-value");
51
53
  if (t) {
52
- t.textContent = `{{${r}_${c}_omnibus_price}}`;
53
- const o = t.closest("p");
54
- o && (o.setAttribute("product-attr", "omnibus_price"), o.setAttribute("composition", "true"));
54
+ t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
55
+ const c = t.closest("p");
56
+ c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
55
57
  }
56
58
  break;
57
59
  }
58
60
  case "productOmnibusDiscount": {
59
61
  const t = e.querySelector(".omnibus-discount-value");
60
62
  if (t) {
61
- t.textContent = `{{${r}_${c}_omnibus_discount}}`;
62
- const o = t.closest("p");
63
- o && (o.setAttribute("product-attr", "omnibus_discount"), o.setAttribute("composition", "true"));
63
+ t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
64
+ const c = t.closest("p");
65
+ c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
64
66
  }
65
67
  break;
66
68
  }
67
69
  default: {
68
70
  const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
69
71
  if (t) {
70
- const o = t.getAttribute("product-attr"), s = t.querySelector("p");
71
- if (s) {
72
- const i = s.querySelector("strong") || s;
73
- i.textContent = `{{${r}_${c}_${o}}}`;
72
+ const c = t.getAttribute("product-attr"), i = t.querySelector("p");
73
+ if (i) {
74
+ const a = i.querySelector("strong") || i;
75
+ a.textContent = `{{${n}${r}_${o}_${c}}}`;
74
76
  }
75
77
  }
76
78
  break;
77
79
  }
78
80
  }
79
81
  }
80
- function _(e, n, r) {
81
- e.querySelectorAll(".recommendation-product-row").forEach((u, t) => {
82
- u.querySelectorAll("[data-attribute-type]").forEach((s) => {
83
- const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
84
- a.length > 0 ? a.forEach((l) => {
85
- p(l, i, n, t, r);
86
- }) : p(s, i, n, t, r);
82
+ function d(e, u, r, o) {
83
+ e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
84
+ n.querySelectorAll("[data-attribute-type]").forEach((i) => {
85
+ const a = i.getAttribute("data-attribute-type") || "", b = i.querySelectorAll(".attribute-cell");
86
+ b.length > 0 ? b.forEach((l) => {
87
+ p(l, a, u, t, r, o);
88
+ }) : p(i, a, u, t, r, o);
87
89
  });
88
90
  });
89
91
  }
90
- function $(e, n, r) {
91
- const c = e.querySelectorAll(".recommendation-product-row");
92
- if (!c.length)
92
+ function q(e, u, r, o) {
93
+ const s = e.querySelectorAll(".recommendation-product-row");
94
+ if (!s.length)
93
95
  return;
94
- const [u] = c, t = u.querySelector("[data-attribute-type]"), o = t ? t.querySelectorAll(".attribute-cell").length : 1;
95
- c.forEach((s, i) => {
96
- s.querySelectorAll("[data-attribute-type]").forEach((l) => {
97
- const f = l.getAttribute("data-attribute-type") || "";
98
- l.querySelectorAll(".attribute-cell").forEach((y, m) => {
99
- const A = i * o + m;
100
- p(y, f, n, A, r);
96
+ const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
97
+ s.forEach((i, a) => {
98
+ i.querySelectorAll("[data-attribute-type]").forEach((l) => {
99
+ const m = l.getAttribute("data-attribute-type") || "";
100
+ l.querySelectorAll(".attribute-cell").forEach(($, f) => {
101
+ const A = a * c + f;
102
+ p($, m, u, A, r, o);
101
103
  });
102
104
  });
103
105
  });
104
106
  }
105
- function d(e, n, r) {
106
- e.querySelectorAll(".ins-recommendation-product-container").forEach((u) => {
107
- $(u, n, r);
107
+ function g(e, u, r, o) {
108
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
109
+ q(n, u, r, o);
108
110
  });
109
111
  }
110
- function q(e, n) {
111
- const r = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
112
- r === "list" ? _(e, n, c) : d(e, n, c);
112
+ function h(e, u, r) {
113
+ const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
114
+ o === "list" ? d(e, u, s, r) : g(e, u, s, r);
113
115
  }
114
- function g(e, n) {
116
+ function C(e, u) {
115
117
  const r = e.match(/<!DOCTYPE[^>]*>/i);
116
118
  return (r ? `${r[0]}
117
- ` : "") + n.documentElement.outerHTML;
119
+ ` : "") + u.documentElement.outerHTML;
118
120
  }
119
- function E(e) {
120
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html"), c = r.querySelectorAll(".recommendation-block-v2");
121
- if (!c.length)
121
+ function P(e) {
122
+ const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
123
+ if (!o.length)
122
124
  return e;
123
- const { buildCampaignUrl: u } = S();
124
- return c.forEach((o) => {
125
- var i, a;
126
- const s = o.getAttribute("recommendation-id");
127
- s && ((i = o.parentNode) == null || i.insertBefore(r.createComment("REC_START"), o), (a = o.parentNode) == null || a.insertBefore(r.createComment("REC_END"), o.nextSibling), u(s), q(o, s));
128
- }), g(n, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
125
+ const { buildCampaignUrl: s } = _(), { isFeatureEnabled: n } = S(), t = n("liquidSyntax") ? "reco_" : "";
126
+ return o.forEach((i) => {
127
+ var b, l;
128
+ const a = i.getAttribute("recommendation-id");
129
+ a && ((b = i.parentNode) == null || b.insertBefore(r.createComment("REC_START"), i), (l = i.parentNode) == null || l.insertBefore(r.createComment("REC_END"), i.nextSibling), s(a), h(i, a, t));
130
+ }), C(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
129
131
  }
130
132
  export {
131
- b as formatPriceVariable,
132
- E as prepareRecommendationBlocks
133
+ y as formatPriceVariable,
134
+ P as prepareRecommendationBlocks
133
135
  };
@@ -11,6 +11,8 @@ class f {
11
11
  try {
12
12
  const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
13
13
  return i.length === 0 ? t : (i.forEach((r) => {
14
+ if (r.classList.contains("checkbox-block-v2"))
15
+ return;
14
16
  const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
15
17
  `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
16
18
  "text/html"
@@ -22,7 +24,7 @@ class f {
22
24
  }
23
25
  }
24
26
  extractTextFromElement(t, e) {
25
- var o, u;
27
+ var o, d;
26
28
  const i = t.querySelector(`.${e}`);
27
29
  if (!i)
28
30
  return {
@@ -41,13 +43,13 @@ class f {
41
43
  align: i.getAttribute("align") || "left",
42
44
  styles: ""
43
45
  };
44
- const n = ((u = r.textContent) == null ? void 0 : u.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), d = this.convertInlineToBlock(g);
46
+ const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
45
47
  return {
46
48
  text: n,
47
49
  isBold: a,
48
50
  isItalic: p,
49
51
  align: c,
50
- styles: d
52
+ styles: u
51
53
  };
52
54
  }
53
55
  buildTextBlock(t) {