@useinsider/guido 2.1.0-beta.038f431 → 2.1.0-beta.09c0a14

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 (48) hide show
  1. package/dist/composables/useActionsApi.js +15 -13
  2. package/dist/composables/useHtmlValidator.js +106 -84
  3. package/dist/composables/useRecommendation.js +54 -21
  4. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +147 -0
  6. package/dist/config/migrator/itemsBlockMigrator.js +140 -123
  7. package/dist/enums/recommendation.js +16 -15
  8. package/dist/extensions/Blocks/Items/block.js +19 -28
  9. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  10. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  11. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  12. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  13. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  14. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  15. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  16. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  17. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  18. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  19. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  20. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  21. package/dist/extensions/Blocks/Items/extension.js +8 -9
  22. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  23. package/dist/extensions/Blocks/Items/template.js +181 -175
  24. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  25. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  26. package/dist/extensions/Blocks/common-control.js +91 -92
  27. package/dist/services/templateLibraryApi.js +16 -13
  28. package/dist/src/composables/useRecommendation.d.ts +1 -0
  29. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  30. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  31. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  32. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  33. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  34. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  35. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  36. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  37. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  38. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  41. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  42. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  43. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  44. package/dist/utils/pairProductVariables.js +57 -56
  45. package/dist/utils/templatePreparation.js +15 -14
  46. package/package.json +1 -1
  47. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  48. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -1,6 +1,6 @@
1
1
  import { useToaster as w } from "./useToaster.js";
2
2
  const v = () => {
3
- const { handleError: l } = w(), r = (t = {}) => new Promise((e, a) => {
3
+ const { handleError: n } = w(), m = (t = {}) => new Promise((e, a) => {
4
4
  const o = { ...{
5
5
  minimize: !0,
6
6
  utmEntity: {
@@ -21,9 +21,9 @@ const v = () => {
21
21
  resetDataSavedFlag: !1,
22
22
  disableLineHeightsReplace: !0
23
23
  }, ...t }, s = {
24
- callback: (n, p, d, c, u) => {
25
- n ? a(n) : e({
26
- html: p,
24
+ callback: (l, r, d, c, u) => {
25
+ l ? a(l) : e({
26
+ html: r,
27
27
  ampHtml: d,
28
28
  ampErrors: c,
29
29
  displayConditions: u
@@ -34,15 +34,15 @@ const v = () => {
34
34
  window.StripoEditorApi.actionsApi.compileEmail(s);
35
35
  });
36
36
  return {
37
- getCompiledEmail: r,
37
+ getCompiledEmail: m,
38
38
  getTemplateData: () => new Promise((t) => {
39
- const e = ({ html: a, css: i, width: o, height: m, utmParams: s, syncModulesIds: n }) => t({
39
+ const e = ({ html: a, css: i, width: o, height: p, utmParams: s, syncModulesIds: l }) => t({
40
40
  html: a,
41
41
  css: i,
42
42
  width: o,
43
- height: m,
43
+ height: p,
44
44
  utmParams: s,
45
- syncModulesIds: n
45
+ syncModulesIds: l
46
46
  });
47
47
  window.StripoEditorApi.actionsApi.getTemplateData(e);
48
48
  }),
@@ -56,7 +56,7 @@ const v = () => {
56
56
  displayConditions: a,
57
57
  ampHtml: i = "",
58
58
  ampErrors: o = []
59
- } = await r({ minimize: !1, resetDataSavedFlag: !1, ...t });
59
+ } = await m({ minimize: !1, resetDataSavedFlag: !1, ...t });
60
60
  return {
61
61
  html: e,
62
62
  ampHtml: i,
@@ -64,7 +64,7 @@ const v = () => {
64
64
  displayConditions: a
65
65
  };
66
66
  } catch (e) {
67
- return l(e, "Error loading preview"), {
67
+ return n(e, "Error loading preview"), {
68
68
  html: "",
69
69
  ampHtml: "",
70
70
  ampErrors: [],
@@ -80,17 +80,19 @@ const v = () => {
80
80
  }
81
81
  try {
82
82
  window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
83
- i ? (l(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
83
+ i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
84
84
  });
85
85
  } catch (i) {
86
- l(i, "Failed to call updateTimerInClonedTemplate"), t(null);
86
+ n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
87
87
  }
88
88
  }),
89
89
  updateHtmlAndCss: (t, e) => {
90
90
  window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
91
91
  },
92
92
  editorSave: () => {
93
- window.StripoEditorApi.actionsApi.save();
93
+ window.StripoEditorApi.actionsApi.save((t) => {
94
+ t && n(t, "Failed to save template");
95
+ });
94
96
  }
95
97
  };
96
98
  };
@@ -1,149 +1,171 @@
1
1
  import { useConfig as D } from "./useConfig.js";
2
- import { TemplateTypes as H } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as R, CampaignCouldNotBeSavedKey as _, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
2
+ import { TemplateTypes as L } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as V, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as l } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as $ } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationStore as j } from "../stores/recommendation.js";
5
+ import { itemsBlockDynamicVariables as P } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as j } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { useRecommendationStore as G } from "../stores/recommendation.js";
7
8
  import { base64EncodeWithSpecialChars as q } from "../utils/base64.js";
8
- import { useHttp as M } from "./useHttp.js";
9
- import { useToaster as X } from "./useToaster.js";
10
- import { useTranslations as z } from "./useTranslations.js";
11
- const oe = () => {
12
- var d, f;
13
- const { showToaster: c } = X(), { post: h } = M(), { config: v } = D(), a = z(), m = j(), u = ((f = (d = v.value) == null ? void 0 : d.partner) == null ? void 0 : f.messageType) === H.transactional, C = async (e) => {
14
- const t = await h(
9
+ import { useHttp as z } from "./useHttp.js";
10
+ import { useToaster as U } from "./useToaster.js";
11
+ import { useTranslations as X } from "./useTranslations.js";
12
+ const K = [
13
+ "img",
14
+ "url",
15
+ "name",
16
+ "price",
17
+ "currency",
18
+ "original_price",
19
+ "omnibus_price",
20
+ "omnibus_discount"
21
+ ];
22
+ function Y() {
23
+ const a = j();
24
+ return Object.keys(a.blockStates).flatMap((d) => {
25
+ const f = a.blockStates[Number(d)], i = parseInt(f.recommendationConfigs.size) || 10;
26
+ return Array.from({ length: i }, (m, u) => u).flatMap((m) => K.map((u) => `${d}_${m}_${u}`));
27
+ });
28
+ }
29
+ const le = () => {
30
+ var p, y;
31
+ const { showToaster: a } = U(), { post: d } = z(), { config: f } = D(), i = X(), g = G(), m = ((y = (p = f.value) == null ? void 0 : p.partner) == null ? void 0 : y.messageType) === L.transactional, u = async (e) => {
32
+ const t = await d(
15
33
  "/newsletter/template-library/check-template-html-body",
16
34
  { html: q(e) }
17
- ), { status: n, message: r } = t.data;
18
- return n || c({
35
+ ), { status: n, message: c } = t.data;
36
+ return n || a({
19
37
  type: l.Alert,
20
- message: n === void 0 ? r : a("newsletter.invalid-url-link-for-toaster")
21
- }), a(_), r === a(G) && c({
38
+ message: n === void 0 ? c : i("newsletter.invalid-url-link-for-toaster")
39
+ }), i(M), c === i($) && a({
22
40
  type: l.Alert,
23
- message: a("newsletter.already-in-progress")
41
+ message: i("newsletter.already-in-progress")
24
42
  }), n;
25
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), b = (e, s) => {
43
+ }, b = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), w = (e, s) => {
26
44
  const t = e.match(/({%(.*?)%})/g);
27
45
  let n = !0;
28
- return t !== null && !u && t.forEach((r) => {
29
- const i = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
30
- if (i && i.length > 0) {
31
- const [o] = i;
32
- w(o) && !s.includes(o) && (c({
46
+ return t !== null && !m && t.forEach((c) => {
47
+ const o = c.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
48
+ if (o && o.length > 0) {
49
+ const [r] = o;
50
+ b(r) && !s.includes(r) && (a({
33
51
  type: l.Warning,
34
- message: a("custom-fields.invalid-custom-fields")
52
+ message: i("custom-fields.invalid-custom-fields")
35
53
  }), n = !1);
36
54
  }
37
55
  }), n;
38
56
  }, E = async (e, s, t) => {
39
- const n = t ? await C(e) : !0;
40
- return b(e, s) && n;
41
- }, A = (e) => e.length > 0 ? !0 : (c({
57
+ const n = t ? await u(e) : !0;
58
+ return w(e, s) && n;
59
+ }, A = (e) => e.length > 0 ? !0 : (a({
42
60
  type: l.Warning,
43
- message: a("newsletter.html-content-is-empty")
44
- }), !1), x = (e) => {
61
+ message: i("newsletter.html-content-is-empty")
62
+ }), !1), k = (e) => {
45
63
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
46
- return s > t && c({
64
+ return s > t && a({
47
65
  type: l.Warning,
48
- message: a("custom-fields.missing-closing-braces")
49
- }), s < t && c({
66
+ message: i("custom-fields.missing-closing-braces")
67
+ }), s < t && a({
50
68
  type: l.Warning,
51
- message: a("custom-fields.missing-opening-braces")
69
+ message: i("custom-fields.missing-opening-braces")
52
70
  }), s === t;
53
- }, k = (e) => {
71
+ }, x = (e) => {
54
72
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
55
- return s || c({
73
+ return s || a({
56
74
  type: l.Warning,
57
- message: a("custom-fields.invalid-custom-fields")
75
+ message: i("custom-fields.invalid-custom-fields")
58
76
  }), s;
59
77
  }, T = (e, s) => {
60
78
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
61
- if (t && !u) {
62
- const n = new Set(s.map((i) => i.toLowerCase())), r = [];
63
- if (t.forEach((i) => {
64
- const o = i.slice(2, -2).trim().toLowerCase();
65
- (!n.has(o) || o === "") && r.push(o);
66
- }), r.length > 0) {
67
- const i = `
79
+ if (t && !m) {
80
+ const n = new Set(s.map((o) => o.toLowerCase())), c = [];
81
+ if (t.forEach((o) => {
82
+ const r = o.slice(2, -2).trim().toLowerCase();
83
+ (!n.has(r) || r === "") && c.push(r);
84
+ }), c.length > 0) {
85
+ const o = `
68
86
  <ul>
69
- ${r.map((o) => `<li>${o}</li>`).join("")}
87
+ ${c.map((r) => `<li>${r}</li>`).join("")}
70
88
  </ul>
71
89
  `;
72
- return c({
90
+ return a({
73
91
  type: l.Alert,
74
- message: a("custom-fields.invalid-custom-fields") + i
92
+ message: i("custom-fields.invalid-custom-fields") + o
75
93
  }), !1;
76
94
  }
77
95
  }
78
96
  return !0;
79
- }, F = (e) => {
97
+ }, I = (e) => {
80
98
  const s = e.match(/{%(.*?)%}/g), t = [];
81
99
  let n = !0;
82
- if (s && s.forEach((r) => {
83
- const i = r.match(P), o = r.match(R), V = (i == null ? void 0 : i.join("")) || "";
84
- (!i || r !== V) && !o && (c({
100
+ if (s && s.forEach((c) => {
101
+ const o = c.match(V), r = c.match(H), B = (o == null ? void 0 : o.join("")) || "";
102
+ (!o || c !== B) && !r && (a({
85
103
  type: l.Alert,
86
- message: a("newsletter.display-conditions-invalid-syntax")
87
- }), n = !1), i && i.forEach((g) => {
88
- g.trim() === "=" && (c({
104
+ message: i("newsletter.display-conditions-invalid-syntax")
105
+ }), n = !1), o && o.forEach((h) => {
106
+ h.trim() === "=" && (a({
89
107
  type: l.Alert,
90
- message: a("custom-conditions.wrong-equality-operators")
108
+ message: i("custom-conditions.wrong-equality-operators")
91
109
  }), n = !1);
92
- const p = g.match(/^[a-zA-Z]*$/g);
93
- p && p.forEach((y) => {
94
- S(y) && t.push(y);
110
+ const C = h.match(/^[a-zA-Z]*$/g);
111
+ C && C.forEach((v) => {
112
+ S(v) && t.push(v);
95
113
  });
96
114
  });
97
115
  }), t.length) {
98
- const r = t.filter((o) => o === "if"), i = t.filter((o) => o === "endif");
99
- r.length !== i.length && (c({
116
+ const c = t.filter((r) => r === "if"), o = t.filter((r) => r === "endif");
117
+ c.length !== o.length && (a({
100
118
  type: l.Alert,
101
- message: a("custom-conditions.missing-if-endif-tag")
119
+ message: i("custom-conditions.missing-if-endif-tag")
102
120
  }), n = !1);
103
121
  }
104
122
  return n;
105
- }, I = (e) => {
123
+ }, F = (e) => {
106
124
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
107
- return n || c({
125
+ return n || a({
108
126
  type: l.Warning,
109
- message: a("custom-conditions.no-space-after-braces")
127
+ message: i("custom-conditions.no-space-after-braces")
110
128
  }), n;
111
- }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (c({
129
+ }, _ = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
112
130
  type: l.Warning,
113
- message: a("custom-conditions.no-braces-inside-if-tag")
114
- }), !1) : !0, L = () => m.recommendationConfigs && Object.values(m.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (c({
131
+ message: i("custom-conditions.no-braces-inside-if-tag")
132
+ }), !1) : !0, N = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
115
133
  type: l.Alert,
116
- message: a("newsletter.fill-all-necessary-fields")
117
- }), !1) : !0, N = (e) => {
134
+ message: i("newsletter.fill-all-necessary-fields")
135
+ }), !1) : !0, O = (e) => {
118
136
  const s = /src="[^"]*\.(svg|pst)"/gm;
119
- return e.match(s) === null ? !0 : (c({
137
+ return e.match(s) === null ? !0 : (a({
120
138
  type: l.Alert,
121
- message: a("newsletter.invalid-image-type")
139
+ message: i("newsletter.invalid-image-type")
122
140
  }), !1);
123
- }, O = (e) => {
141
+ }, W = (e) => {
124
142
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
125
- return Array.from(n).find((i) => {
126
- var o;
127
- return !((o = i.id) != null && o.trim());
128
- }) ? (c({
143
+ return Array.from(n).find((o) => {
144
+ var r;
145
+ return !((r = o.id) != null && r.trim());
146
+ }) ? (a({
129
147
  type: l.Alert,
130
- message: a("unsubscribe-templates.select-checkbox-groups")
148
+ message: i("unsubscribe-templates.select-checkbox-groups")
131
149
  }), !1) : !0;
132
- }, B = (e) => {
150
+ }, R = (e) => {
133
151
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
134
- return Array.from(n).find((i) => {
135
- var o;
136
- return !((o = i.id) != null && o.trim());
137
- }) ? (c({
152
+ return Array.from(n).find((o) => {
153
+ var r;
154
+ return !((r = o.id) != null && r.trim());
155
+ }) ? (a({
138
156
  type: l.Alert,
139
- message: a("unsubscribe-templates.select-radio-button-groups")
157
+ message: i("unsubscribe-templates.select-radio-button-groups")
140
158
  }), !1) : !0;
141
159
  };
142
160
  return { validateHtml: async (e, s, t = !1) => {
143
- const n = [...s.map((i) => i.value), ...$];
144
- return await E(e, n, t) && A(e) && x(e) && k(e) && T(e, n) && F(e) && I(e) && W(e) && L() && N(e) && O(e) && B(e);
161
+ const n = [
162
+ ...s.map((o) => o.value),
163
+ ...P,
164
+ ...Y()
165
+ ];
166
+ return await E(e, n, t) && A(e) && k(e) && x(e) && T(e, n) && I(e) && F(e) && _(e) && N() && O(e) && W(e) && R(e);
145
167
  } };
146
168
  };
147
169
  export {
148
- oe as useHtmlValidator
170
+ le as useHtmlValidator
149
171
  };
@@ -1,27 +1,60 @@
1
- import { MinDeviceViewport as r, DefaultPadding as c } from "../enums/recommendation.js";
2
- const m = () => ({
1
+ import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
+ import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { useConfigStore as C } from "../stores/config.js";
6
+ const N = () => ({
3
7
  calculateCardWidth: ({
4
- mobileLeftPadding: e,
5
- mobileRightPadding: a,
6
- cardsInRow: n,
7
- unresponsive: i
8
+ mobileLeftPadding: i,
9
+ mobileRightPadding: n,
10
+ cardsInRow: o,
11
+ unresponsive: a
8
12
  }) => {
9
- const t = i ? n : 1, o = e + a + (t - 1) * c;
10
- return (r - o) / t;
13
+ const r = a ? o : 1, e = i + n + (r - 1) * b;
14
+ return (R - e) / r;
11
15
  },
12
- getRecommendationCampaignData: (e) => (console.debug(e), {
13
- textTrimming: !1,
14
- orientation: "vertical",
15
- mobileLeftPadding: 0,
16
- mobileRightPadding: 0,
17
- cardsInRow: 2,
18
- unresponsive: !1,
19
- priceBeforeTextValue: "",
20
- priceAfterTextValue: "",
21
- discountBeforeTextValue: "",
22
- discountAfterTextValue: ""
23
- })
16
+ getRecommendationCampaignData: (i) => {
17
+ const n = l(), o = Number(i), a = n.blockStates[o];
18
+ if (!a)
19
+ return {
20
+ textTrimming: !1,
21
+ orientation: "vertical",
22
+ mobileLeftPadding: 0,
23
+ mobileRightPadding: 0,
24
+ cardsInRow: 2,
25
+ unresponsive: !1,
26
+ priceBeforeTextValue: "",
27
+ priceAfterTextValue: "",
28
+ discountBeforeTextValue: "",
29
+ discountAfterTextValue: ""
30
+ };
31
+ const { recommendationConfigs: r } = a, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
+ return {
33
+ textTrimming: r.textTrimming,
34
+ orientation: e,
35
+ mobileLeftPadding: 0,
36
+ mobileRightPadding: 0,
37
+ cardsInRow: r.cardsInRow,
38
+ unresponsive: r.unresponsive,
39
+ priceBeforeTextValue: "",
40
+ priceAfterTextValue: "",
41
+ discountBeforeTextValue: "",
42
+ discountAfterTextValue: ""
43
+ };
44
+ },
45
+ buildCampaignUrl: (i) => {
46
+ var d;
47
+ const n = l(), o = C(), a = Number(i), r = n.blockStates[a];
48
+ if (!r)
49
+ return "";
50
+ const { recommendationConfigs: e } = r, u = ((d = g.find((s) => s.key === e.strategy)) == null ? void 0 : d.path) || "", t = new URLSearchParams();
51
+ t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}");
52
+ const f = e.filters.filter((s) => s.isValid), c = x(f);
53
+ c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
54
+ const m = `${p.RECOMMENDATION_API_URL}/v2/${u}?${t.toString()}`;
55
+ return n.recommendationCampaignUrls[i] = m, m;
56
+ }
24
57
  });
25
58
  export {
26
- m as useRecommendation
59
+ N as useRecommendation
27
60
  };
@@ -1,15 +1,16 @@
1
- import { useRecommendation as u } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as P, REGEX as i, CSS as e, CONDITIONS as E, ATTRIBUTES as r, HTML as h } from "../../enums/recommendation.js";
3
- const H = [
1
+ import { useRecommendation as f } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
4
+ const G = [
4
5
  {
5
6
  id: "replace-images-with-variable-names",
6
7
  description: "Replacing dummy images with variable names in recommendation module",
7
8
  type: "custom",
8
- processor: (a) => {
9
- let t = a;
10
- return Object.entries(P).forEach(([, n]) => {
11
- Object.entries(n).forEach(([s, o]) => {
12
- t = t.replaceAll(o, `{{${s}}}`);
9
+ processor: (s) => {
10
+ let t = s;
11
+ return Object.entries(P).forEach(([, l]) => {
12
+ Object.entries(l).forEach(([n, o]) => {
13
+ t = t.replaceAll(o, `{{${n}}}`);
13
14
  });
14
15
  }), t;
15
16
  },
@@ -28,17 +29,17 @@ const H = [
28
29
  id: "add-recommendation-unresponsive-css",
29
30
  description: "Adding recommendation unresponsive css",
30
31
  type: "custom",
31
- processor: (a) => {
32
- const { getRecommendationCampaignData: t } = u();
33
- let n = a;
34
- const s = n.match(i.ID);
35
- if (s) {
36
- const o = [];
37
- if (s.forEach((c) => {
38
- const m = c.slice(35, c.length - 1).trim();
39
- t(m);
40
- }), o.length) {
41
- const c = `width:${Math.min(...o)}px!important;`;
32
+ processor: (s) => {
33
+ const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
34
+ let n = s;
35
+ const o = n.match(m.ID);
36
+ if (o) {
37
+ const d = [];
38
+ if (o.forEach((c) => {
39
+ const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
40
+ p.textTrimming && p.orientation === g && d.push(t(p));
41
+ }), d.length) {
42
+ const c = `width:${Math.min(...d)}px!important;`;
42
43
  n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
43
44
  }
44
45
  }
@@ -46,32 +47,37 @@ const H = [
46
47
  },
47
48
  priority: 52
48
49
  },
49
- // TODO: prepareRecommendations
50
- // TODO: addRecommendationCustomFields
50
+ {
51
+ id: "prepare-recommendations",
52
+ description: "Replacing product data with template variables in recommendation blocks",
53
+ type: "custom",
54
+ processor: (s) => D(s),
55
+ priority: 48
56
+ },
51
57
  {
52
58
  id: "add-discount-conditions",
53
59
  description: "Adding discount conditions to the recommendation block",
54
60
  type: "custom",
55
- processor: (a) => {
56
- let t = a;
57
- const n = t.match(i.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: s } = u();
58
- return n !== null && n.forEach((o) => {
59
- const c = o.match(i.CUSTOM_FIELD);
60
- if (!c)
61
+ processor: (s) => {
62
+ let t = s;
63
+ const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
64
+ return l !== null && l.forEach((o) => {
65
+ const d = o.match(m.CUSTOM_FIELD);
66
+ if (!d)
61
67
  return;
62
- const [m] = c, p = m.match(i.CUSTOM_FIELD_INDEXES_PART), A = m.match(i.CUSTOM_FIELD_NAME_PART), _ = o.match(i.ATTRIBUTE_PARAGRAPH_START_TAG);
63
- if (!p || !A || !_)
68
+ const [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!E || !I || !p)
64
70
  return;
65
- const [l] = p, [T] = A, [d] = _, N = T.substring(1, T.length - 2), R = d.match(i.COMPOSITION) !== null;
66
- let O = m;
67
- if (R) {
68
- const M = l.substring(2, l.length - 3);
69
- s(M);
71
+ const [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
72
+ let i = c;
73
+ if (S) {
74
+ const $ = u.substring(2, u.length - 3), r = n($);
75
+ T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
70
76
  }
71
- const I = l.substring(2);
72
- let S = "";
73
- N in E.IF && (S = E.IF[N].replaceAll(`{${r.DISCOUNT}}`, `${I}${r.DISCOUNT}`).replaceAll(`{${r.OMNIBUS_DISCOUNT}}`, `${I}${r.OMNIBUS_DISCOUNT}`).replaceAll(`{${r.OMNIBUS_PRICE}}`, `${I}${r.OMNIBUS_PRICE}`));
74
- const $ = `${d}${O}${h.PARAGRAPH_END_TAG}`, C = `${S}${R ? $ : o}${E.ELSE}${d}${h.PARAGRAPH_END_TAG}${E.END_IF}`;
77
+ const N = u.substring(2);
78
+ let M = "";
79
+ T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
80
+ const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
75
81
  t = t.replace(o, C);
76
82
  }), t;
77
83
  },
@@ -79,5 +85,5 @@ const H = [
79
85
  }
80
86
  ];
81
87
  export {
82
- H as recommendationCompilerRules
88
+ G as recommendationCompilerRules
83
89
  };