@useinsider/guido 3.8.0-beta.eb4074b → 3.8.1-beta.2ee94c2

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 (33) hide show
  1. package/dist/composables/useHtmlValidator.js +133 -180
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +57 -58
  3. package/dist/config/migrator/recommendation/extractors.js +22 -44
  4. package/dist/config/migrator/recommendation/htmlBuilder.js +169 -175
  5. package/dist/config/migrator/recommendationMigrator.js +31 -30
  6. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +20 -26
  7. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +41 -55
  8. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -58
  9. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +31 -43
  10. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +2 -3
  11. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +45 -55
  12. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +56 -63
  13. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +6 -7
  14. package/dist/extensions/Blocks/Recommendation/extension.js +2 -3
  15. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
  16. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -3
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +12 -13
  18. package/dist/extensions/Blocks/Recommendation/templates/index.js +6 -7
  19. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  20. package/dist/src/composables/useHtmlValidator.d.ts +0 -27
  21. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -15
  22. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -8
  23. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  24. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -21
  25. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -7
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +0 -5
  27. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -6
  28. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -9
  29. package/package.json +1 -1
  30. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +0 -15
  31. package/dist/src/composables/useHtmlValidator.test.d.ts +0 -1
  32. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +0 -17
  33. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +0 -1
@@ -1,219 +1,172 @@
1
- import { useConfig as W } from "./useConfig.js";
2
- import { getIgnoredRecommendationBlockIds as G } from "../config/compiler/utils/recommendationIgnoreUtils.js";
3
- import { TemplateTypes as H } from "../enums/defaults.js";
4
- import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as $, CanNotMakeAnyChangesForRunningKey as Y, DATA_ATTRIBUTE_REGEX as U, DYNAMIC_CONTENT_TAG_REGEX as j, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
1
+ import { useConfig as V } from "./useConfig.js";
2
+ import { TemplateTypes as G } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
5
4
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
6
- import { itemsBlockDynamicVariables as z } from "../extensions/Blocks/Items/enums/productEnums.js";
7
- import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as Z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
8
- import { useRecommendationExtensionStore as J } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { resolveProductAttrValue as Q } from "../extensions/Blocks/Recommendation/templates/utils.js";
10
- import { RecommendationRequiredFieldsKey as ee } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
11
- import { useRecommendationStore as te } from "../stores/recommendation.js";
12
- import { base64EncodeWithSpecialChars as ne } from "../utils/base64.js";
13
- import { useHttp as se } from "./useHttp.js";
14
- import { useToaster as oe } from "./useToaster.js";
15
- import { useTranslations as ie } from "./useTranslations.js";
16
- const re = /recommendation-id="(\d+)"/g;
17
- function ae(t) {
18
- return [...t.matchAll(re)].map((m) => m[1]);
5
+ import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as U } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { RecommendationRequiredFieldsKey as z } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
+ import { useRecommendationStore as Z } from "../stores/recommendation.js";
9
+ import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
10
+ import { useHttp as Q } from "./useHttp.js";
11
+ import { useToaster as ee } from "./useToaster.js";
12
+ import { useTranslations as te } from "./useTranslations.js";
13
+ const se = /recommendation-id="(\d+)"/g;
14
+ function ne(i) {
15
+ return [...i.matchAll(se)].map((d) => d[1]);
19
16
  }
20
- function ce(t, m) {
21
- return m.some((f) => t.startsWith(`${f}_`));
17
+ function ie(i, d) {
18
+ return d.some((g) => i.startsWith(`${g}_`));
22
19
  }
23
- const le = /^(\d+)_\d+_(.+)$/;
24
- function me(t) {
25
- const m = t.match(le);
26
- return m ? { recoId: m[1], attribute: m[2] } : null;
27
- }
28
- function ue(t) {
29
- const m = new Set(Z);
30
- return Object.values(t).forEach((f) => {
31
- m.add(Q(f.attributeName, t).toLowerCase());
32
- }), m;
33
- }
34
- function de(t, m, f, i, d) {
35
- const u = t.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
36
- if (!u)
37
- return [];
38
- const p = new Set(m.map((y) => y.toLowerCase())), h = [];
39
- return u.forEach((y) => {
40
- const g = y.slice(2, -2).trim().toLowerCase();
41
- if (g !== "" && p.has(g))
42
- return;
43
- const E = me(g);
44
- if (E && i.has(E.recoId)) {
45
- if (!d || d.has(E.attribute))
46
- return;
47
- h.push(g);
48
- return;
49
- }
50
- ce(g, f) || g.includes(".") || h.push(g);
51
- }), h;
52
- }
53
- function fe(t) {
54
- return (t.replace(U, "$1").match(j) ?? []).filter((i) => {
55
- const d = i.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
56
- return q.includes(p) ? !1 : K.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
20
+ function oe(i) {
21
+ return (i.replace(Y, "$1").match($) ?? []).filter((r) => {
22
+ const u = r.slice(2, -2), f = u.indexOf("|"), p = (f === -1 ? u : u.slice(0, f)).trim();
23
+ return q.includes(p) ? !1 : K.test(p) ? f !== -1 && u.slice(f + 1).trim() === "" : !0;
57
24
  });
58
25
  }
59
- const xe = () => {
60
- var I, b;
61
- const { showToaster: t } = oe(), { post: m } = se(), { config: f } = W(), i = ie(), d = te(), u = J(), p = ((b = (I = f.value) == null ? void 0 : I.partner) == null ? void 0 : b.messageType) === H.transactional, h = async (e) => {
62
- if (e.size === 0)
63
- return /* @__PURE__ */ new Set();
64
- try {
65
- await u.fetchRecommendationFilters();
66
- } catch {
67
- return null;
68
- }
69
- return ue(u.filterList);
70
- }, y = async (e) => {
71
- const n = await m(
26
+ const Ce = () => {
27
+ var h, v;
28
+ const { showToaster: i } = ee(), { post: d } = Q(), { config: g } = V(), r = te(), u = Z(), f = U(), p = ((v = (h = g.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === G.transactional, A = async (e) => {
29
+ const t = await d(
72
30
  "/newsletter/template-library/check-template-html-body",
73
- { html: ne(e) }
74
- ), { status: o, message: a } = n.data;
75
- return o || t({
31
+ { html: J(e) }
32
+ ), { status: n, message: l } = t.data;
33
+ return n || i({
76
34
  type: c.Alert,
77
- message: o === void 0 ? a : i("newsletter.invalid-url-link-for-toaster")
78
- }), i($), a === i(Y) && t({
35
+ message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
36
+ }), r(X), l === r(P) && i({
79
37
  type: c.Alert,
80
- message: i("newsletter.already-in-progress")
81
- }), o;
82
- }, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), T = (e, s) => {
83
- const n = e.match(/({%(.*?)%})/g);
84
- let o = !0;
85
- return n !== null && !p && n.forEach((a) => {
86
- const r = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
87
- if (r && r.length > 0) {
88
- const [l] = r;
89
- g(l) && !s.includes(l) && (t({
38
+ message: r("newsletter.already-in-progress")
39
+ }), n;
40
+ }, S = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), b = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
41
+ const t = e.match(/({%(.*?)%})/g);
42
+ let n = !0;
43
+ return t !== null && !p && t.forEach((l) => {
44
+ const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
45
+ if (o && o.length > 0) {
46
+ const [a] = o;
47
+ S(a) && !s.includes(a) && (i({
90
48
  type: c.Warning,
91
- message: i("custom-fields.invalid-custom-fields")
92
- }), o = !1);
49
+ message: r("custom-fields.invalid-custom-fields")
50
+ }), n = !1);
93
51
  }
94
- }), o;
95
- }, w = async (e, s, n) => {
96
- const o = n ? await y(e) : !0;
97
- return T(e, s) && o;
98
- }, R = (e) => e.length > 0 ? !0 : (t({
52
+ }), n;
53
+ }, T = async (e, s, t) => {
54
+ const n = t ? await A(e) : !0;
55
+ return I(e, s) && n;
56
+ }, w = (e) => e.length > 0 ? !0 : (i({
99
57
  type: c.Warning,
100
- message: i("newsletter.html-content-is-empty")
101
- }), !1), _ = (e) => {
102
- const s = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
103
- return s > n && t({
58
+ message: r("newsletter.html-content-is-empty")
59
+ }), !1), x = (e) => {
60
+ const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
61
+ return s > t && i({
104
62
  type: c.Warning,
105
- message: i("custom-fields.missing-closing-braces")
106
- }), s < n && t({
63
+ message: r("custom-fields.missing-closing-braces")
64
+ }), s < t && i({
107
65
  type: c.Warning,
108
- message: i("custom-fields.missing-opening-braces")
109
- }), s === n;
110
- }, N = (e) => {
111
- const s = fe(e).length === 0;
112
- return s || t({
66
+ message: r("custom-fields.missing-opening-braces")
67
+ }), s === t;
68
+ }, _ = (e) => {
69
+ const s = oe(e).length === 0;
70
+ return s || i({
113
71
  type: c.Warning,
114
- message: i("custom-fields.invalid-custom-fields")
72
+ message: r("custom-fields.invalid-custom-fields")
115
73
  }), s;
116
- }, x = (e, s, n, o) => {
117
- if (p)
118
- return !0;
119
- const a = de(
120
- e,
121
- s,
122
- ae(e),
123
- n,
124
- o
125
- );
126
- if (a.length > 0) {
127
- const r = `
128
- <ul>
129
- ${a.map((l) => `<li>${l}</li>`).join("")}
130
- </ul>
131
- `;
132
- return t({
133
- type: c.Alert,
134
- message: i("custom-fields.invalid-custom-fields") + r
135
- }), !1;
74
+ }, k = (e, s) => {
75
+ const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
76
+ if (t && !p) {
77
+ const n = new Set(s.map((a) => a.toLowerCase())), l = ne(e), o = [];
78
+ if (t.forEach((a) => {
79
+ const m = a.slice(2, -2).trim().toLowerCase();
80
+ (!n.has(m) || m === "") && !ie(m, l) && o.push(m);
81
+ }), o.length > 0) {
82
+ const a = `
83
+ <ul>
84
+ ${o.map((m) => `<li>${m}</li>`).join("")}
85
+ </ul>
86
+ `;
87
+ return i({
88
+ type: c.Alert,
89
+ message: r("custom-fields.invalid-custom-fields") + a
90
+ }), !1;
91
+ }
136
92
  }
137
93
  return !0;
138
- }, O = (e) => {
139
- const s = e.match(/{%(.*?)%}/g), n = [];
140
- let o = !0;
141
- if (s && s.forEach((a) => {
142
- const r = a.match(P), l = a.match(X), v = (r == null ? void 0 : r.join("")) || "";
143
- (!r || a !== v) && !l && (t({
94
+ }, R = (e) => {
95
+ const s = e.match(/{%(.*?)%}/g), t = [];
96
+ let n = !0;
97
+ if (s && s.forEach((l) => {
98
+ const o = l.match(H), a = l.match(M), m = (o == null ? void 0 : o.join("")) || "";
99
+ (!o || l !== m) && !a && (i({
144
100
  type: c.Alert,
145
- message: i("newsletter.display-conditions-invalid-syntax")
146
- }), o = !1), r && r.forEach((C) => {
147
- C.trim() === "=" && (t({
101
+ message: r("newsletter.display-conditions-invalid-syntax")
102
+ }), n = !1), o && o.forEach((y) => {
103
+ y.trim() === "=" && (i({
148
104
  type: c.Alert,
149
- message: i("custom-conditions.wrong-equality-operators")
150
- }), o = !1);
151
- const A = C.match(/^[a-zA-Z]*$/g);
152
- A && A.forEach((S) => {
153
- E(S) && n.push(S);
105
+ message: r("custom-conditions.wrong-equality-operators")
106
+ }), n = !1);
107
+ const C = y.match(/^[a-zA-Z]*$/g);
108
+ C && C.forEach((E) => {
109
+ b(E) && t.push(E);
154
110
  });
155
111
  });
156
- }), n.length) {
157
- const a = n.filter((l) => l === "if"), r = n.filter((l) => l === "endif");
158
- a.length !== r.length && (t({
112
+ }), t.length) {
113
+ const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
114
+ l.length !== o.length && (i({
159
115
  type: c.Alert,
160
- message: i("custom-conditions.missing-if-endif-tag")
161
- }), o = !1);
116
+ message: r("custom-conditions.missing-if-endif-tag")
117
+ }), n = !1);
162
118
  }
163
- return o;
164
- }, k = (e) => {
165
- const s = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, o = s === n;
166
- return o || t({
119
+ return n;
120
+ }, N = (e) => {
121
+ const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
122
+ return n || i({
167
123
  type: c.Warning,
168
- message: i("custom-conditions.no-space-after-braces")
169
- }), o;
170
- }, B = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, o) => n + o, 0) > 0 ? (t({
124
+ message: r("custom-conditions.no-space-after-braces")
125
+ }), n;
126
+ }, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
171
127
  type: c.Warning,
172
- message: i("custom-conditions.no-braces-inside-if-tag")
173
- }), !1) : !0, D = () => u.hasInvalidBlock() ? (t({
128
+ message: r("custom-conditions.no-braces-inside-if-tag")
129
+ }), !1) : !0, F = () => f.hasInvalidBlock() ? (i({
174
130
  type: c.Alert,
175
- message: i(ee)
176
- }), !1) : !0, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((s) => s.filters.find((n) => n.value === "")) !== void 0 ? (t({
131
+ message: r(z)
132
+ }), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
177
133
  type: c.Alert,
178
- message: i("newsletter.fill-all-necessary-fields")
179
- }), !1) : !0, L = (e) => {
134
+ message: r("newsletter.fill-all-necessary-fields")
135
+ }), !1) : !0, B = (e) => {
180
136
  const s = /src="[^"]*\.(svg|pst)"/gm;
181
- return e.match(s) === null ? !0 : (t({
137
+ return e.match(s) === null ? !0 : (i({
182
138
  type: c.Alert,
183
- message: i("newsletter.invalid-image-type")
139
+ message: r("newsletter.invalid-image-type")
184
140
  }), !1);
185
- }, V = (e) => {
186
- const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
187
- return Array.from(o).find((r) => {
188
- var l;
189
- return !((l = r.id) != null && l.trim());
190
- }) ? (t({
141
+ }, L = (e) => {
142
+ const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
143
+ return Array.from(n).find((o) => {
144
+ var a;
145
+ return !((a = o.id) != null && a.trim());
146
+ }) ? (i({
191
147
  type: c.Alert,
192
- message: i("unsubscribe-templates.select-checkbox-groups")
148
+ message: r("unsubscribe-templates.select-checkbox-groups")
193
149
  }), !1) : !0;
194
- }, M = (e) => {
195
- const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
196
- return Array.from(o).find((r) => {
197
- var l;
198
- return !((l = r.id) != null && l.trim());
199
- }) ? (t({
150
+ }, W = (e) => {
151
+ const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
152
+ return Array.from(n).find((o) => {
153
+ var a;
154
+ return !((a = o.id) != null && a.trim());
155
+ }) ? (i({
200
156
  type: c.Alert,
201
- message: i("unsubscribe-templates.select-radio-button-groups")
157
+ message: r("unsubscribe-templates.select-radio-button-groups")
202
158
  }), !1) : !0;
203
159
  };
204
- return { validateHtml: async (e, s, n = !1) => {
205
- var v, C;
206
- const o = [
207
- ...s.map((A) => A.value),
208
- ...z,
209
- ...((C = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : C.customFieldAttributes) ?? []
210
- ], a = G(e), r = await h(a);
211
- return await w(e, o, n) && R(e) && _(e) && N(e) && x(e, o, a, r) && O(e) && k(e) && B(e) && D() && F() && L(e) && V(e) && M(e);
160
+ return { validateHtml: async (e, s, t = !1) => {
161
+ var o, a;
162
+ const n = [
163
+ ...s.map((m) => m.value),
164
+ ...j,
165
+ ...((a = (o = g.value) == null ? void 0 : o.template) == null ? void 0 : a.customFieldAttributes) ?? []
166
+ ];
167
+ return await T(e, n, t) && w(e) && x(e) && _(e) && k(e, n) && R(e) && N(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
212
168
  } };
213
169
  };
214
170
  export {
215
- ue as buildPartnerAttributeNameSet,
216
- de as findInvalidCustomFields,
217
- me as parseRecommendationVariable,
218
- xe as useHtmlValidator
171
+ Ce as useHtmlValidator
219
172
  };
@@ -2,62 +2,61 @@ import { useConfig as _ } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as g } from "../../../composables/useRecommendation.js";
3
3
  import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
- function h(r, n, e, o, c = "") {
7
- const i = `{{${c}${r}_${n}_${e}}}`, t = `{{${c}${r}_${n}_currency}}`;
8
- return o === "before" ? `${t} ${i}` : `${i} ${t}`;
5
+ function h(r, n, e, o, i = "") {
6
+ const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
+ return o === "before" ? `${t} ${c}` : `${c} ${t}`;
9
8
  }
10
- function f(r) {
9
+ function b(r) {
11
10
  let n = r;
12
11
  for (; n.children.length === 1; )
13
12
  [n] = n.children;
14
13
  return n;
15
14
  }
16
- function A(r, n, e, o, c, i) {
15
+ function A(r, n, e, o, i, c) {
17
16
  switch (n) {
18
17
  case "productImage": {
19
18
  const t = r.querySelector("img");
20
- t && (t.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
19
+ t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
21
20
  const s = r.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
21
+ s && (s.setAttribute("href", `{{${c}${e}_${o}_url}}`), s.classList.add(q));
23
22
  break;
24
23
  }
25
24
  case "productName": {
26
25
  const t = r.querySelector("p");
27
- t && (f(t).textContent = `{{${i}${e}_${o}_name}}`);
26
+ t && (b(t).textContent = `{{${c}${e}_${o}_name}}`);
28
27
  break;
29
28
  }
30
29
  case "productPrice": {
31
30
  const t = r.querySelector("p");
32
- t && (f(t).textContent = h(
31
+ t && (b(t).textContent = h(
33
32
  e,
34
33
  o,
35
34
  "price",
36
- c,
37
- i
35
+ i,
36
+ c
38
37
  ));
39
38
  break;
40
39
  }
41
40
  case "productOldPrice": {
42
41
  const t = r.querySelector("p");
43
- t && (f(t).textContent = h(
42
+ t && (b(t).textContent = h(
44
43
  e,
45
44
  o,
46
45
  "original_price",
47
- c,
48
- i
46
+ i,
47
+ c
49
48
  ), t.setAttribute("product-attr", "discount"));
50
49
  break;
51
50
  }
52
51
  case "productButton": {
53
52
  const t = r.querySelector("a");
54
- t && t.setAttribute("href", `{{${i}${e}_${o}_url}}`);
53
+ t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
55
54
  break;
56
55
  }
57
56
  case "productOmnibusPrice": {
58
57
  const t = r.querySelector(".omnibus-price-value");
59
58
  if (t) {
60
- t.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
59
+ t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
61
60
  const s = t.closest("p");
62
61
  s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
63
62
  }
@@ -66,7 +65,7 @@ function A(r, n, e, o, c, i) {
66
65
  case "productOmnibusDiscount": {
67
66
  const t = r.querySelector(".omnibus-discount-value");
68
67
  if (t) {
69
- t.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
68
+ t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
70
69
  const s = t.closest("p");
71
70
  s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
72
71
  }
@@ -76,15 +75,15 @@ function A(r, n, e, o, c, i) {
76
75
  const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
77
76
  if (t) {
78
77
  const s = t.getAttribute("product-attr"), a = t.querySelector("p");
79
- a && (f(a).textContent = `{{${i}${e}_${o}_${s}}}`);
78
+ a && (b(a).textContent = `{{${c}${e}_${o}_${s}}}`);
80
79
  }
81
80
  break;
82
81
  }
83
82
  }
84
83
  }
85
- function E(r, n, e, o) {
86
- r.querySelectorAll(".recommendation-product-row").forEach((i, t) => {
87
- i.querySelectorAll("[data-attribute-type]").forEach((a) => {
84
+ function w(r, n, e, o) {
85
+ r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
86
+ c.querySelectorAll("[data-attribute-type]").forEach((a) => {
88
87
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
89
88
  p.length > 0 ? p.forEach((l) => {
90
89
  A(l, u, n, t, e, o);
@@ -92,35 +91,35 @@ function E(r, n, e, o) {
92
91
  });
93
92
  });
94
93
  }
95
- function R(r, n, e, o) {
96
- const c = r.querySelectorAll(".recommendation-product-row");
97
- if (!c.length)
94
+ function E(r, n, e, o) {
95
+ const i = r.querySelectorAll(".recommendation-product-row");
96
+ if (!i.length)
98
97
  return;
99
- const [i] = c, t = i.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
100
- c.forEach((a, u) => {
98
+ const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
99
+ i.forEach((a, u) => {
101
100
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
102
- const m = l.getAttribute("data-attribute-type") || "";
101
+ const d = l.getAttribute("data-attribute-type") || "";
103
102
  l.querySelectorAll(".attribute-cell").forEach((y, $) => {
104
103
  const S = u * s + $;
105
- A(y, m, n, S, e, o);
104
+ A(y, d, n, S, e, o);
106
105
  });
107
106
  });
108
107
  });
109
108
  }
110
- function P(r, n, e, o) {
111
- r.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
112
- R(i, n, e, o);
109
+ function R(r, n, e, o) {
110
+ r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
111
+ E(c, n, e, o);
113
112
  });
114
113
  }
115
- function T(r, n, e) {
116
- const o = r.getAttribute("data-layout") || "grid", c = r.getAttribute("currency-alignment") || "after";
117
- o === "list" ? E(r, n, c, e) : P(r, n, c, e);
114
+ function P(r, n, e) {
115
+ const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
116
+ o === "list" ? w(r, n, i, e) : R(r, n, i, e);
118
117
  }
119
- function b(r, n, e) {
120
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = r.match(o);
121
- return c ? parseInt(c[1]) : e;
118
+ function f(r, n, e) {
119
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
120
+ return i ? parseInt(i[1]) : e;
122
121
  }
123
- function v(r, n) {
122
+ function T(r, n) {
124
123
  let e = r.parentElement;
125
124
  for (; e && e !== n; ) {
126
125
  if (e.tagName === "TD") {
@@ -132,42 +131,42 @@ function v(r, n) {
132
131
  }
133
132
  return null;
134
133
  }
135
- function O(r) {
136
- const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, c = Math.max(0, e - o);
137
- c !== 0 && r.querySelectorAll("img.adapt-img").forEach((i) => {
138
- if (i.hasAttribute("width"))
134
+ function v(r) {
135
+ const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
136
+ i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
137
+ if (c.hasAttribute("width"))
139
138
  return;
140
- const t = v(i, r);
139
+ const t = T(c, r);
141
140
  if (!t)
142
141
  return;
143
- const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
144
- i.setAttribute("width", String(l));
145
- const m = i.getAttribute("style") || "";
146
- if (!/\bwidth\s*:\s*\d/i.test(m)) {
147
- const d = m && !m.trim().endsWith(";") ? "; " : "";
148
- i.setAttribute("style", `${m}${d}width: ${l}px`);
142
+ const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
143
+ c.setAttribute("width", String(l));
144
+ const d = c.getAttribute("style") || "";
145
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
146
+ const m = d && !d.trim().endsWith(";") ? "; " : "";
147
+ c.setAttribute("style", `${d}${m}width: ${l}px`);
149
148
  }
150
149
  });
151
150
  }
152
- function W(r, n) {
151
+ function O(r, n) {
153
152
  const e = r.match(/<!DOCTYPE[^>]*>/i);
154
153
  return (e ? `${e[0]}
155
154
  ` : "") + n.documentElement.outerHTML;
156
155
  }
157
- function F(r) {
156
+ function N(r) {
158
157
  const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
159
158
  if (!o.length)
160
159
  return r;
161
- const { buildCampaignUrl: c } = g(), i = C();
162
- i.recommendationCampaignUrls = {};
160
+ const { buildCampaignUrl: i } = g(), c = C();
161
+ c.recommendationCampaignUrls = {};
163
162
  const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
164
163
  return o.forEach((u) => {
165
- var l, m;
164
+ var l, d;
166
165
  const p = u.getAttribute("recommendation-id");
167
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), c(p), w(u) || T(u, p, s), O(u));
168
- }), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
166
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
167
+ }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
169
168
  }
170
169
  export {
171
170
  h as formatPriceVariable,
172
- F as prepareRecommendationBlocks
171
+ N as prepareRecommendationBlocks
173
172
  };