@useinsider/guido 3.8.3-beta.96b5eeb → 3.9.0-beta.ba394b1

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 (67) hide show
  1. package/dist/@types/config/schemas.js +70 -66
  2. package/dist/composables/useCustomInterfaceAppearance.js +16 -18
  3. package/dist/composables/usePreviewMode.js +15 -14
  4. package/dist/composables/useRecommendationPreview.js +111 -0
  5. package/dist/composables/useStripo.js +39 -37
  6. package/dist/composables/useStripoNotifications.js +26 -0
  7. package/dist/config/compiler/recommendationCompilerRules.js +1 -1
  8. package/dist/config/compiler/utils/recommendationCompilerUtils.js +88 -80
  9. package/dist/config/migrator/recommendation/htmlBuilder.js +53 -52
  10. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  11. package/dist/enums/toaster.js +2 -2
  12. package/dist/extensions/Blocks/Items/block.js +48 -29
  13. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
  14. package/dist/extensions/Blocks/Recommendation/block.js +64 -42
  15. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
  16. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  17. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +461 -363
  18. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +99 -87
  19. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +162 -160
  21. package/dist/extensions/Blocks/Recommendation/extension.js +30 -29
  22. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  23. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  24. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -1
  25. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
  26. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -54
  27. package/dist/extensions/Blocks/Recommendation/templates/index.js +17 -14
  28. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
  29. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
  30. package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
  31. package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
  32. package/dist/extensions/Blocks/controlFactories.js +76 -57
  33. package/dist/services/templateLibraryApi.js +9 -8
  34. package/dist/src/@types/config/schemas.d.ts +16 -0
  35. package/dist/src/composables/useConfig.d.ts +4 -0
  36. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  37. package/dist/src/composables/useStripoNotifications.d.ts +10 -0
  38. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  39. package/dist/src/enums/toaster.d.ts +2 -2
  40. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
  42. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +3 -3
  43. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
  44. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  45. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
  46. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  49. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +1 -1
  50. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +1 -1
  51. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +1 -1
  53. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  55. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
  56. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  57. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
  59. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  60. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
  61. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +10 -1
  63. package/dist/src/stores/config.d.ts +36 -0
  64. package/dist/src/stores/toaster.d.ts +2 -3
  65. package/dist/stores/toaster.js +10 -10
  66. package/package.json +2 -2
  67. package/dist/static/styles/components/notification.css.js +0 -74
@@ -1,29 +1,30 @@
1
- import { useActionsApi as I } from "./useActionsApi.js";
2
- import { useBlocksConfig as U } from "./useBlocksConfig.js";
3
- import { useConfig as R } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as x } from "./useCustomInterfaceAppearance.js";
5
- import { useFullStoryBridge as O } from "./useFullStoryBridge.js";
6
- import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
7
- import { useToaster as H } from "./useToaster.js";
8
- import { localePatch as z } from "../config/i18n/index.js";
1
+ import { useActionsApi as U } from "./useActionsApi.js";
2
+ import { useBlocksConfig as R } from "./useBlocksConfig.js";
3
+ import { useConfig as x } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as O } from "./useCustomInterfaceAppearance.js";
5
+ import { useFullStoryBridge as q } from "./useFullStoryBridge.js";
6
+ import { useStripoEventHandler as H } from "./useStripoEventHandler.js";
7
+ import { useStripoNotifications as N } from "./useStripoNotifications.js";
8
+ import { useToaster as z } from "./useToaster.js";
9
+ import { localePatch as L } from "../config/i18n/index.js";
9
10
  import { en as h } from "../config/i18n/en/index.js";
10
- import { ToasterTypeOptions as L } from "../enums/toaster.js";
11
- import { useStripoApi as $ } from "../services/stripoApi.js";
12
- import G from "../static/styles/customEditorStyle.css.js";
11
+ import { ToasterTypeOptions as $ } from "../enums/toaster.js";
12
+ import { useStripoApi as G } from "../services/stripoApi.js";
13
+ import J from "../static/styles/customEditorStyle.css.js";
13
14
  import { useEditorStore as C } from "../stores/editor.js";
14
- import { dynamicContentToMergeTags as J } from "../utils/genericUtil.js";
15
- import N from "../package.json.js";
16
- const ce = (E, l) => {
17
- const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
15
+ import { dynamicContentToMergeTags as X } from "../utils/genericUtil.js";
16
+ import j from "../package.json.js";
17
+ const pe = (E, l) => {
18
+ const { features: c, template: w, isFeatureEnabled: u } = x(), { handleError: m, showToaster: b } = z(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = G(), { handleEvent: F } = H(), { getStripoBlocksConfig: v } = R(), { getStripoNotifications: V } = N(), _ = async (s, i = [], r = !1) => {
18
19
  var g, S, y;
19
- const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
20
+ const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, M = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, P = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
20
21
  await window.UIEditor.initEditor(
21
22
  document.querySelector("#guido-editor"),
22
23
  {
23
24
  metadata: E,
24
25
  html: p,
25
26
  css: a,
26
- forceRecreate: M,
27
+ forceRecreate: P,
27
28
  locale: "en",
28
29
  undoButtonSelector: "#guido__undo-button",
29
30
  redoButtonSelector: "#guido__redo-button",
@@ -33,12 +34,12 @@ const ce = (E, l) => {
33
34
  customAppearanceMergetags: !u("liquidSyntax"),
34
35
  customAppearanceMergetagsBorderColor: "#f1f3fe",
35
36
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
36
- customViewStyles: G,
37
+ customViewStyles: J,
37
38
  conditionsEnabled: f,
38
39
  customConditionsEnabled: f,
39
40
  enableXSSSecurity: !0,
40
- modulesDisabled: A,
41
- syncModulesEnabled: i,
41
+ modulesDisabled: M,
42
+ syncModulesEnabled: r,
42
43
  messageSettingsEnabled: !0,
43
44
  displayGmailAnnotations: !0,
44
45
  displayHiddenPreheader: !1,
@@ -51,11 +52,11 @@ const ce = (E, l) => {
51
52
  editorFonts: {
52
53
  showDefaultStandardFonts: !0,
53
54
  showDefaultNotStandardFonts: !0,
54
- customFonts: r
55
+ customFonts: i
55
56
  },
56
57
  mergeTags: [
57
58
  {
58
- entries: J(
59
+ entries: X(
59
60
  l.preselectedDynamicContentList,
60
61
  u("liquidSyntax")
61
62
  )
@@ -71,8 +72,8 @@ const ce = (E, l) => {
71
72
  },
72
73
  onTemplateLoaded() {
73
74
  try {
74
- const { importCss: o } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
75
- o(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
75
+ const { importCss: o } = O(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: D } = U(), { injectFullStory: I } = q();
76
+ o(), n(), I(), D(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
76
77
  e.hasChanges = !1;
77
78
  }, 1e3);
78
79
  } catch (o) {
@@ -92,41 +93,42 @@ const ce = (E, l) => {
92
93
  e.hasChanges = !0;
93
94
  },
94
95
  onEvent: F,
96
+ notifications: V(),
95
97
  ignoreClickOutsideSelectors: [
96
98
  "#guido-dynamic-content-modal",
97
99
  ".in-on-board-wrapper",
98
100
  ".in-drawer__container"
99
101
  ],
100
102
  extensions: d,
101
- localePatch: z
103
+ localePatch: L
102
104
  }
103
105
  );
104
- }, _ = (s) => new Promise((r, i) => {
106
+ }, A = (s) => new Promise((i, r) => {
105
107
  var d;
106
108
  if (document.getElementById("UiEditorScript")) {
107
- Promise.resolve(s()).then(r, i);
109
+ Promise.resolve(s()).then(i, r);
108
110
  return;
109
111
  }
110
- const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
112
+ const e = j.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
111
113
  t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
112
- Promise.resolve(s()).then(r, i);
114
+ Promise.resolve(s()).then(i, r);
113
115
  }, t.onerror = () => {
114
- i(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
116
+ r(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
115
117
  }, document.body.appendChild(t);
116
118
  });
117
119
  return { initPlugin: async (s) => {
118
- const r = C();
120
+ const i = C();
119
121
  try {
120
- await _(async () => {
121
- const [i, e] = await Promise.all([
122
+ await A(async () => {
123
+ const [r, e] = await Promise.all([
122
124
  k(),
123
125
  B()
124
126
  ]);
125
- r.syncModulesEnabled = e, await V(s, i, e);
127
+ i.syncModulesEnabled = e, await _(s, r, e);
126
128
  });
127
129
  } catch {
128
- r.loadingStatus = !1, b({
129
- type: L.Alert,
130
+ i.loadingStatus = !1, b({
131
+ type: $.Alert,
130
132
  message: h["An error has occurred. Please report the error code to support."],
131
133
  actionButton: {
132
134
  text: h["Reload page"],
@@ -137,5 +139,5 @@ const ce = (E, l) => {
137
139
  } };
138
140
  };
139
141
  export {
140
- ce as useStripo
142
+ pe as useStripo
141
143
  };
@@ -0,0 +1,26 @@
1
+ import { useToaster as d } from "./useToaster.js";
2
+ import { ToasterTypeOptions as c } from "../enums/toaster.js";
3
+ const g = () => {
4
+ const { showToaster: l, hideToaster: u } = d();
5
+ let s = null;
6
+ const n = (o, t, i, e, f = !0) => {
7
+ s = i;
8
+ const r = e != null && e.action ? { text: e.action.label, onClick: e.action.func } : void 0;
9
+ l({ type: o, message: t, actionButton: r, autoHide: (e == null ? void 0 : e.autoClose) ?? f });
10
+ };
11
+ return { getStripoNotifications: () => ({
12
+ info: (o, t, i) => n(c.Info, o, t, i),
13
+ success: (o, t, i) => n(c.Success, o, t, i),
14
+ warn: (o, t, i) => n(c.Warning, o, t, i),
15
+ error: (o, t, i) => n(c.Alert, o, t, i),
16
+ // A loader marks an in-progress operation; Stripo dismisses it via hide(id)
17
+ // when finished, so it must not auto-hide.
18
+ loader: (o, t, i) => n(c.Info, o, t, i, !1),
19
+ hide: (o) => {
20
+ s === o && (u(), s = null);
21
+ }
22
+ }) };
23
+ };
24
+ export {
25
+ g as useStripoNotifications
26
+ };
@@ -111,7 +111,7 @@ const U = [
111
111
  // Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
112
112
  // from Items block elements, which the items compiler rule depends on.
113
113
  processor: (o) => {
114
- const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
114
+ const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
115
115
  return o.replace(
116
116
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
117
117
  (r, t) => `<!--REC_START-->${t.replace(e, "")}<!--REC_END-->`
@@ -3,171 +3,179 @@ import { useRecommendation as g } from "../../../composables/useRecommendation.j
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
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}`;
6
+ function b(e, n, t, o, c = "") {
7
+ const i = `{{${c}${e}_${n}_${t}}}`, r = `{{${c}${e}_${n}_currency}}`;
8
+ return o === "before" ? `${r} ${i}` : `${i} ${r}`;
9
9
  }
10
- function f(r) {
11
- let n = r;
10
+ function m(e) {
11
+ let n = e;
12
12
  for (; n.children.length === 1; )
13
13
  [n] = n.children;
14
14
  return n;
15
15
  }
16
- function A(r, n, e, o, c, i) {
16
+ function h(e, n, t, o, c, i) {
17
17
  switch (n) {
18
18
  case "productImage": {
19
- const t = r.querySelector("img");
20
- t && (t.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
- const s = r.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
19
+ const r = e.querySelector("img");
20
+ r && (r.setAttribute("src", `{{${i}${t}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${o}_name}}`));
21
+ const s = e.querySelector("a");
22
+ s && (s.setAttribute("href", `{{${i}${t}_${o}_url}}`), s.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const t = r.querySelector("p");
27
- t && (f(t).textContent = `{{${i}${e}_${o}_name}}`);
26
+ const r = e.querySelector("p");
27
+ r && (m(r).textContent = `{{${i}${t}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  case "productPrice": {
31
- const t = r.querySelector("p");
32
- t && (f(t).textContent = h(
33
- e,
31
+ const r = e.querySelector(".product-price p") ?? e.querySelector("p");
32
+ r && (m(r).textContent = b(
33
+ t,
34
34
  o,
35
35
  "price",
36
36
  c,
37
37
  i
38
38
  ));
39
+ const s = e.querySelector(".product-old-price p");
40
+ s && (m(s).textContent = b(
41
+ t,
42
+ o,
43
+ "original_price",
44
+ c,
45
+ i
46
+ ));
39
47
  break;
40
48
  }
41
49
  case "productOldPrice": {
42
- const t = r.querySelector("p");
43
- t && (f(t).textContent = h(
44
- e,
50
+ const r = e.querySelector("p");
51
+ r && (m(r).textContent = b(
52
+ t,
45
53
  o,
46
54
  "original_price",
47
55
  c,
48
56
  i
49
- ), t.setAttribute("product-attr", "discount"));
57
+ ));
50
58
  break;
51
59
  }
52
60
  case "productButton": {
53
- const t = r.querySelector("a");
54
- t && t.setAttribute("href", `{{${i}${e}_${o}_url}}`);
61
+ const r = e.querySelector("a");
62
+ r && r.setAttribute("href", `{{${i}${t}_${o}_url}}`);
55
63
  break;
56
64
  }
57
65
  case "productOmnibusPrice": {
58
- const t = r.querySelector(".omnibus-price-value");
59
- if (t) {
60
- t.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
61
- const s = t.closest("p");
66
+ const r = e.querySelector(".omnibus-price-value");
67
+ if (r) {
68
+ r.textContent = `{{${i}${t}_${o}_omnibus_price}}`;
69
+ const s = r.closest("p");
62
70
  s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
63
71
  }
64
72
  break;
65
73
  }
66
74
  case "productOmnibusDiscount": {
67
- const t = r.querySelector(".omnibus-discount-value");
68
- if (t) {
69
- t.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
70
- const s = t.closest("p");
75
+ const r = e.querySelector(".omnibus-discount-value");
76
+ if (r) {
77
+ r.textContent = `{{${i}${t}_${o}_omnibus_discount}}`;
78
+ const s = r.closest("p");
71
79
  s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
72
80
  }
73
81
  break;
74
82
  }
75
83
  default: {
76
- const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
77
- if (t) {
78
- const s = t.getAttribute("product-attr"), a = t.querySelector("p");
79
- a && (f(a).textContent = `{{${i}${e}_${o}_${s}}}`);
84
+ const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
85
+ if (r) {
86
+ const s = r.getAttribute("product-attr"), a = r.querySelector("p");
87
+ a && (m(a).textContent = `{{${i}${t}_${o}_${s}}}`);
80
88
  }
81
89
  break;
82
90
  }
83
91
  }
84
92
  }
85
- function E(r, n, e, o) {
86
- r.querySelectorAll(".recommendation-product-row").forEach((i, t) => {
93
+ function E(e, n, t, o) {
94
+ e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
87
95
  i.querySelectorAll("[data-attribute-type]").forEach((a) => {
88
96
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
89
97
  p.length > 0 ? p.forEach((l) => {
90
- A(l, u, n, t, e, o);
91
- }) : A(a, u, n, t, e, o);
98
+ h(l, u, n, r, t, o);
99
+ }) : h(a, u, n, r, t, o);
92
100
  });
93
101
  });
94
102
  }
95
- function R(r, n, e, o) {
96
- const c = r.querySelectorAll(".recommendation-product-row");
103
+ function P(e, n, t, o) {
104
+ const c = e.querySelectorAll(".recommendation-product-row");
97
105
  if (!c.length)
98
106
  return;
99
- const [i] = c, t = i.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
107
+ const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
100
108
  c.forEach((a, u) => {
101
109
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
102
- const m = l.getAttribute("data-attribute-type") || "";
103
- l.querySelectorAll(".attribute-cell").forEach((y, $) => {
110
+ const d = l.getAttribute("data-attribute-type") || "";
111
+ l.querySelectorAll(".attribute-cell").forEach((A, $) => {
104
112
  const S = u * s + $;
105
- A(y, m, n, S, e, o);
113
+ h(A, d, n, S, t, o);
106
114
  });
107
115
  });
108
116
  });
109
117
  }
110
- function P(r, n, e, o) {
111
- r.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
112
- R(i, n, e, o);
118
+ function R(e, n, t, o) {
119
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
+ P(i, n, t, o);
113
121
  });
114
122
  }
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);
123
+ function O(e, n, t) {
124
+ const o = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
125
+ o === "list" ? E(e, n, c, t) : R(e, n, c, t);
118
126
  }
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;
127
+ function y(e, n, t) {
128
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(o);
129
+ return c ? parseInt(c[1]) : t;
122
130
  }
123
- function v(r, n) {
124
- let e = r.parentElement;
125
- for (; e && e !== n; ) {
126
- if (e.tagName === "TD") {
127
- const o = e.getAttribute("width");
131
+ function T(e, n) {
132
+ let t = e.parentElement;
133
+ for (; t && t !== n; ) {
134
+ if (t.tagName === "TD") {
135
+ const o = t.getAttribute("width");
128
136
  if (o && o.endsWith("%") && parseFloat(o) < 100)
129
- return e;
137
+ return t;
130
138
  }
131
- e = e.parentElement;
139
+ t = t.parentElement;
132
140
  }
133
141
  return null;
134
142
  }
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) => {
143
+ function v(e) {
144
+ const n = e.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, c = Math.max(0, t - o);
145
+ c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
138
146
  if (i.hasAttribute("width"))
139
147
  return;
140
- const t = v(i, r);
141
- if (!t)
148
+ const r = T(i, e);
149
+ if (!r)
142
150
  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);
151
+ const s = r.getAttribute("width"), a = parseFloat(s), u = y(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
144
152
  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`);
153
+ const d = i.getAttribute("style") || "";
154
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
155
+ const f = d && !d.trim().endsWith(";") ? "; " : "";
156
+ i.setAttribute("style", `${d}${f}width: ${l}px`);
149
157
  }
150
158
  });
151
159
  }
152
- function W(r, n) {
153
- const e = r.match(/<!DOCTYPE[^>]*>/i);
154
- return (e ? `${e[0]}
160
+ function W(e, n) {
161
+ const t = e.match(/<!DOCTYPE[^>]*>/i);
162
+ return (t ? `${t[0]}
155
163
  ` : "") + n.documentElement.outerHTML;
156
164
  }
157
- function F(r) {
158
- const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
165
+ function F(e) {
166
+ const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
159
167
  if (!o.length)
160
- return r;
168
+ return e;
161
169
  const { buildCampaignUrl: c } = g(), i = C();
162
170
  i.recommendationCampaignUrls = {};
163
- const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
171
+ const { isFeatureEnabled: r } = _(), s = r("liquidSyntax") ? "reco_" : "";
164
172
  return o.forEach((u) => {
165
- var l, m;
173
+ var l, d;
166
174
  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;", "%}");
175
+ p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || O(u, p, s), v(u));
176
+ }), W(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
169
177
  }
170
178
  export {
171
- h as formatPriceVariable,
179
+ b as formatPriceVariable,
172
180
  F as prepareRecommendationBlocks
173
181
  };