@useinsider/guido 3.23.0-beta.86bed27 → 3.23.0

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 (54) hide show
  1. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
  2. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
  3. package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
  4. package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
  5. package/dist/config/migrator/recommendation/extractors.js +100 -40
  6. package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
  7. package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
  8. package/dist/config/migrator/recommendation/themeMapper.js +53 -41
  9. package/dist/config/migrator/recommendationMigrator.js +68 -61
  10. package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
  11. package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
  12. package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
  13. package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
  14. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  15. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
  16. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
  17. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
  18. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
  19. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
  20. package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
  21. package/dist/extensions/Blocks/Recommendation/block.js +33 -24
  22. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
  23. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
  24. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
  25. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +165 -175
  26. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  27. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  28. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
  29. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  30. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
  31. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
  32. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
  33. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
  34. package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
  35. package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
  36. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
  37. package/dist/extensions/Blocks/common-control.js +62 -55
  38. package/dist/guido.css +1 -1
  39. package/dist/package.json.js +2 -2
  40. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
  41. package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
  42. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
  43. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
  44. package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
  45. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
  46. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
  48. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
  49. package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
  50. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
  51. package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
  52. package/dist/src/stores/unsubscribe.d.ts +10 -0
  53. package/dist/stores/unsubscribe.js +33 -29
  54. package/package.json +2 -2
@@ -1,22 +1,22 @@
1
1
  import a from "./UnsubscribePageSelection.vue2.js";
2
2
  /* empty css */
3
3
  import n from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var o = function() {
5
- var r = this, e = r._self._c, t = r._self._setupProxy;
6
- return e(t.WpDrawer, { attrs: { id: "unsubscribe-modal", "description-status": "", size: "large", "footer-button-group-options": t.footerButtonGroupOptions, status: t.unsubscribeStore.pageSelectionDrawerStatus, "title-text": t.trans("newsletter.select-a-template") }, on: { cancelOrBackButtonEvent: t.handleBack, onCloseEvent: t.handleClose, primaryButtonEvent: t.handleSave }, scopedSlots: r._u([{ key: "headerBottomSlot", fn: function() {
7
- return [e(t.UnsubscribeBreadcrumb, { staticClass: "px-5 py-3" })];
8
- }, proxy: !0 }]) }, [e("div", { staticClass: "d-g templates-wrapper" }, r._l(t.unsubscribeStore.getTemplatesByActiveType, function(s) {
9
- return e("div", { key: s.id, staticClass: "template-wrapper", on: { click: function(u) {
10
- return t.selectTemplate(s.id);
11
- } } }, [e(t.InContainer, { staticClass: "template-container o-h", class: { selected: t.unsubscribeStore.getSelectedTemplateByActiveType === s.id }, attrs: { border: t.getBorderClass(s.id) } }, [e("div", { staticClass: "w-1 h-1 d-f j-c-c a-i-c" }, [e("img", { staticClass: "w-1 h-1 thumbnail o-h", attrs: { alt: s.name, src: s.thumbnail } })])]), e("div", { staticClass: "mt-1 f-s-1" }, [r._v(" " + r._s(s.name) + " ")])], 1);
4
+ var i = function() {
5
+ var r = this, t = r._self._c, e = r._self._setupProxy;
6
+ return t(e.WpDrawer, { attrs: { id: "unsubscribe-modal", "description-status": "", size: "large", "footer-button-group-options": e.footerButtonGroupOptions, status: e.unsubscribeStore.pageSelectionDrawerStatus, "title-text": e.trans("newsletter.select-a-template") }, on: { cancelOrBackButtonEvent: e.handleBack, onCloseEvent: e.handleClose, primaryButtonEvent: e.handleSave }, scopedSlots: r._u([{ key: "headerBottomSlot", fn: function() {
7
+ return [t(e.UnsubscribeBreadcrumb, { staticClass: "px-5 py-3" })];
8
+ }, proxy: !0 }]) }, [t("div", { staticClass: "d-g templates-wrapper" }, r._l(e.unsubscribeStore.getTemplatesByActiveType, function(s) {
9
+ return t("div", { key: s.id, staticClass: "template-wrapper", on: { click: function(u) {
10
+ return e.selectTemplate(s.id);
11
+ } } }, [t(e.InContainer, { staticClass: "template-container o-h p-r", class: { selected: e.unsubscribeStore.getSelectedTemplateByActiveType === s.id }, attrs: { border: e.getBorderClass(s.id) } }, [t("div", { staticClass: "w-1 h-1 d-f j-c-c a-i-c" }, [t("img", { staticClass: "w-1 h-1 thumbnail o-h", attrs: { alt: s.name, src: s.thumbnail } })]), s.isDefault ? t(e.InChips, { staticClass: "p-a t-3 r-3", attrs: { id: "guido__unsubscribe-default-chip", type: "neutral", value: "default", "close-button": !1, interactive: !1, text: e.trans("unsubscription-preference.default") } }) : r._e()], 1), t("div", { staticClass: "mt-1 f-s-1" }, [r._v(" " + r._s(s.name) + " ")])], 1);
12
12
  }), 0)]);
13
- }, i = [], c = /* @__PURE__ */ n(
13
+ }, o = [], c = /* @__PURE__ */ n(
14
14
  a,
15
- o,
16
15
  i,
16
+ o,
17
17
  !1,
18
18
  null,
19
- "91a26acd"
19
+ "eaf8e461"
20
20
  );
21
21
  const _ = c.exports;
22
22
  export {
@@ -1,16 +1,16 @@
1
1
  import { defineComponent as y, ref as T, computed as a, watch as v } from "vue";
2
2
  import w from "../../wrappers/WpDrawer.vue.js";
3
- import { useToaster as B } from "../../../composables/useToaster.js";
4
- import { useTranslations as C } from "../../../composables/useTranslations.js";
3
+ import { useToaster as C } from "../../../composables/useToaster.js";
4
+ import { useTranslations as B } from "../../../composables/useTranslations.js";
5
5
  import { ToasterTypeOptions as h } from "../../../enums/toaster.js";
6
6
  import { useEditorStore as P } from "../../../stores/editor.js";
7
7
  import { useUnsubscribeStore as U } from "../../../stores/unsubscribe.js";
8
- import { InContainer as _ } from "@useinsider/design-system-vue";
9
- import I from "./UnsubscribeBreadcrumb.vue.js";
10
- const N = /* @__PURE__ */ y({
8
+ import { InContainer as I, InChips as _ } from "@useinsider/design-system-vue";
9
+ import x from "./UnsubscribeBreadcrumb.vue.js";
10
+ const W = /* @__PURE__ */ y({
11
11
  __name: "UnsubscribePageSelection",
12
- setup(x) {
13
- const s = C(), e = U(), r = P(), { showToaster: c } = B(), o = T(!1), i = a(() => e.isActiveTypeLastInCollection ? o.value ? s("unsubscription-preference.applying-changes") : s("statistics.apply") : s("products.select-and-continue")), l = a(() => e.pageSelectionUpdateStatus && e.isActiveTypeFirstInCollection ? s("products.cancel") : s("newsletter.back")), p = a(() => ({
12
+ setup(A) {
13
+ const s = B(), e = U(), r = P(), { showToaster: c } = C(), o = T(!1), i = a(() => e.isActiveTypeLastInCollection ? o.value ? s("unsubscription-preference.applying-changes") : s("statistics.apply") : s("products.select-and-continue")), l = a(() => e.pageSelectionUpdateStatus && e.isActiveTypeFirstInCollection ? s("products.cancel") : s("newsletter.back")), p = a(() => ({
14
14
  primaryButton: {
15
15
  styling: "solid",
16
16
  type: "primary",
@@ -63,9 +63,9 @@ const N = /* @__PURE__ */ y({
63
63
  };
64
64
  return v(() => e.pageSelectionDrawerStatus, (t) => {
65
65
  t && e.pageSelectionUpdateStatus && e.fetchTemplates();
66
- }), { __sfc: !0, trans: s, unsubscribeStore: e, editorStore: r, showToaster: c, isApplying: o, getPrimaryButtonText: i, getCancelOrBackButtonText: l, footerButtonGroupOptions: p, getBorderClass: d, closeModal: n, handleClose: m, handleBack: b, handleSave: f, selectTemplate: g, WpDrawer: w, InContainer: _, UnsubscribeBreadcrumb: I };
66
+ }), { __sfc: !0, trans: s, unsubscribeStore: e, editorStore: r, showToaster: c, isApplying: o, getPrimaryButtonText: i, getCancelOrBackButtonText: l, footerButtonGroupOptions: p, getBorderClass: d, closeModal: n, handleClose: m, handleBack: b, handleSave: f, selectTemplate: g, WpDrawer: w, InChips: _, InContainer: I, UnsubscribeBreadcrumb: x };
67
67
  }
68
68
  });
69
69
  export {
70
- N as default
70
+ W as default
71
71
  };
@@ -1,4 +1,4 @@
1
- import { useConfig as g } from "../../../composables/useConfig.js";
1
+ import { useConfig as C } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as O } from "../../../composables/useRecommendation.js";
3
3
  import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
@@ -13,7 +13,7 @@ function A(t) {
13
13
  [r] = r.children;
14
14
  return r;
15
15
  }
16
- function y(t, r, e, o, c, i) {
16
+ function _(t, r, e, o, c, i) {
17
17
  switch (r) {
18
18
  case "productImage": {
19
19
  const n = t.querySelector("img");
@@ -78,7 +78,7 @@ function y(t, r, e, o, c, i) {
78
78
  }
79
79
  }
80
80
  const P = "name";
81
- function b(t, r, e, o) {
81
+ function y(t, r, e, o) {
82
82
  const c = `${o}${r}_${e}_${P}`;
83
83
  return {
84
84
  open: t.createComment(`{% if ${c} and ${c} != "" %}`),
@@ -86,19 +86,19 @@ function b(t, r, e, o) {
86
86
  };
87
87
  }
88
88
  function R(t, r, e) {
89
- return b(t, r, 0, e);
89
+ return y(t, r, 0, e);
90
90
  }
91
91
  function w(t, r, e, o) {
92
92
  if (!t.innerHTML.includes("{{"))
93
93
  return;
94
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
94
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
95
95
  t.insertBefore(c, t.firstChild), t.appendChild(i);
96
96
  }
97
97
  function D(t, r, e, o) {
98
98
  var n, s;
99
99
  if (!t.innerHTML.includes("{{"))
100
100
  return;
101
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
101
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
102
102
  (n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
103
103
  }
104
104
  function v(t, r, e, o) {
@@ -106,8 +106,8 @@ function v(t, r, e, o) {
106
106
  i.querySelectorAll("[data-attribute-type]").forEach((d) => {
107
107
  const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
108
108
  a.length > 0 ? a.forEach((l) => {
109
- y(l, u, r, n, e, o);
110
- }) : y(d, u, r, n, e, o);
109
+ _(l, u, r, n, e, o);
110
+ }) : _(d, u, r, n, e, o);
111
111
  }), D(i, r, n, o);
112
112
  });
113
113
  }
@@ -119,9 +119,9 @@ function H(t, r, e, o) {
119
119
  c.forEach((d, u) => {
120
120
  d.querySelectorAll("[data-attribute-type]").forEach((l) => {
121
121
  const p = l.getAttribute("data-attribute-type") || "";
122
- l.querySelectorAll(".attribute-cell").forEach((f, h) => {
122
+ l.querySelectorAll(".attribute-cell").forEach((m, h) => {
123
123
  const S = u * s + h;
124
- y(f, p, r, S, e, o), w(f, r, S, o);
124
+ _(m, p, r, S, e, o), w(m, r, S, o);
125
125
  });
126
126
  });
127
127
  });
@@ -132,10 +132,10 @@ function W(t, r, e, o) {
132
132
  });
133
133
  }
134
134
  function F(t, r, e) {
135
- const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
136
- o === "list" ? v(t, r, c, e) : W(t, r, c, e);
135
+ const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
136
+ o === "list" ? v(t, r, i, e) : W(t, r, i, e);
137
137
  }
138
- function _(t, r, e) {
138
+ function b(t, r, e) {
139
139
  const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
140
140
  return c ? parseInt(c[1]) : e;
141
141
  }
@@ -143,7 +143,7 @@ function $(t) {
143
143
  const r = t.trim();
144
144
  return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
145
145
  }
146
- function C(t) {
146
+ function g(t) {
147
147
  const r = t.getAttribute("width");
148
148
  if (r && $(r))
149
149
  return r.trim();
@@ -153,28 +153,28 @@ function C(t) {
153
153
  function x(t, r) {
154
154
  let e = t.parentElement;
155
155
  for (; e && e !== r; ) {
156
- if (e.tagName === "TD" && C(e))
156
+ if (e.tagName === "TD" && g(e))
157
157
  return e;
158
158
  e = e.parentElement;
159
159
  }
160
160
  return null;
161
161
  }
162
162
  function G(t) {
163
- const r = t.getAttribute("style") || "", e = _(r, "width", 600), o = _(r, "padding", 0) * 2, c = Math.max(0, e - o);
163
+ const r = t.getAttribute("style") || "", e = b(r, "width", 600), o = b(r, "padding", 0) * 2, c = Math.max(0, e - o);
164
164
  c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
165
165
  if (i.hasAttribute("width"))
166
166
  return;
167
167
  const n = x(i, t);
168
168
  if (!n)
169
169
  return;
170
- const s = C(n), d = _(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
170
+ const s = g(n), d = b(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
171
171
  if (p) {
172
172
  i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
173
173
  return;
174
174
  }
175
175
  if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
176
- const m = l && !l.trim().endsWith(";") ? "; " : "";
177
- i.setAttribute("style", `${l}${m}width: ${a}px`);
176
+ const f = l && !l.trim().endsWith(";") ? "; " : "";
177
+ i.setAttribute("style", `${l}${f}width: ${a}px`);
178
178
  }
179
179
  });
180
180
  }
@@ -200,15 +200,15 @@ function Q(t) {
200
200
  return t;
201
201
  const { buildCampaignUrl: c } = O(), i = N();
202
202
  i.recommendationCampaignUrls = {};
203
- const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
203
+ const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
204
204
  return o.forEach((u) => {
205
- var l, p, m, f;
205
+ var l, p, f, m;
206
206
  const a = u.getAttribute("recommendation-id");
207
207
  if (a) {
208
208
  if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
209
209
  F(u, a, s);
210
210
  const { open: h, close: S } = R(e, a, s);
211
- (m = u.parentNode) == null || m.insertBefore(h, u), (f = u.parentNode) == null || f.insertBefore(S, u.nextSibling);
211
+ (f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
212
212
  }
213
213
  G(u);
214
214
  }
@@ -1,101 +1,108 @@
1
- import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
- import { ATTR_RECOMMENDATION_TITLE as l, ATTR_CUSTOM_PREFIX as k, ATTR_PRODUCT_BUTTON as A, ATTR_PRODUCT_OMNIBUS_DISCOUNT as R, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as h, ATTR_PRODUCT_NAME as E, ATTR_PRODUCT_IMAGE as O } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
- import { mapTextTheme as b, mapButtonTheme as y, mapImageTheme as N } from "./themeMapper.js";
4
- const C = "__title__", T = "product_attribute.";
5
- function P(r) {
6
- const t = r.variable ?? "";
7
- switch (t) {
1
+ import { DEFAULT_COMPOSITION as k, DEFAULT_VISIBILITY as f } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { ATTR_RECOMMENDATION_TITLE as R, ATTR_CUSTOM_PREFIX as x, ATTR_PRODUCT_BUTTON as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as O, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as d, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_IMAGE as b } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
+ import { mapTextTheme as C, mapButtonTheme as N, mapImageTheme as P } from "./themeMapper.js";
4
+ const U = "__title__", _ = "product_attribute.";
5
+ function D(n) {
6
+ const s = n.variable ?? "";
7
+ switch (s) {
8
8
  case "p_recommendation_title":
9
- return { key: C, kind: "title" };
9
+ return { key: U, kind: "title" };
10
10
  case "p_image":
11
- return { key: O, kind: "image" };
11
+ return { key: b, kind: "image" };
12
12
  case "p_name":
13
- return { key: E, kind: "text" };
13
+ return { key: y, kind: "text" };
14
14
  case "p_price":
15
- return { key: h, kind: "text" };
15
+ return { key: d, kind: "text" };
16
16
  case "p_original_price":
17
- return { key: f, kind: "text" };
17
+ return { key: a, kind: "text" };
18
18
  case "p_omnibus_price":
19
- return { key: x, kind: "text" };
19
+ return { key: O, kind: "text" };
20
20
  case "p_omnibus_discount":
21
- return { key: R, kind: "text" };
21
+ return { key: h, kind: "text" };
22
22
  case "p_button":
23
- return { key: A, kind: "button" };
23
+ return { key: E, kind: "button" };
24
24
  default:
25
- if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const o = r.value ?? "", s = o.startsWith(T) ? o.slice(T.length) : o;
27
- if (!s)
25
+ if (n.variableType === "p_attribute" || s.startsWith("p_attribute_")) {
26
+ const t = n.value ?? "", o = t.startsWith(_) ? t.slice(_.length) : t;
27
+ if (!o)
28
28
  return null;
29
- const e = o || `${T}${s}`;
29
+ const u = t || `${_}${o}`;
30
30
  return {
31
- key: `${k}${e}`,
31
+ key: `${x}${u}`,
32
32
  kind: "custom",
33
- customAttrName: s,
34
- customAttrValue: e
33
+ customAttrName: o,
34
+ customAttrValue: u
35
35
  };
36
36
  }
37
37
  return null;
38
38
  }
39
39
  }
40
- function _(r) {
41
- const t = p.indexOf(r);
42
- return t === -1 ? Number.POSITIVE_INFINITY : t;
40
+ function I(n) {
41
+ const s = k.indexOf(n);
42
+ return s === -1 ? Number.POSITIVE_INFINITY : s;
43
+ }
44
+ const l = [d, a];
45
+ function S(n, s, t) {
46
+ return n === s || !l.includes(n) || !l.includes(s) ? 0 : n === (t ? a : d) ? -1 : 1;
43
47
  }
44
- function V(r) {
48
+ function F(n, { oldPriceFirst: s = !1 } = {}) {
45
49
  const t = {
46
50
  composition: [],
47
- visibility: { ...I },
51
+ visibility: { ...f },
48
52
  customAttributes: [],
49
53
  customAttrValues: {},
50
54
  perElementStyles: {},
51
55
  anyTextTrimming: !1
52
56
  };
53
- if (!r || r.length === 0)
54
- return t.composition = [...p], t;
57
+ if (!n || n.length === 0)
58
+ return t.composition = [...k], t;
55
59
  const o = [];
56
- r.forEach((e, i) => {
57
- const n = P(e);
58
- if (n) {
59
- if (n.kind === "title") {
60
- t.titleVariable = e, t.visibility[l] = e.hidden !== !0;
60
+ n.forEach((e, i) => {
61
+ const r = D(e);
62
+ if (r) {
63
+ if (r.kind === "title") {
64
+ t.titleVariable = e, t.visibility[R] = e.hidden !== !0;
61
65
  return;
62
66
  }
63
67
  o.push({
64
- key: n.key,
65
- kind: n.kind,
68
+ key: r.key,
69
+ kind: r.kind,
66
70
  hidden: e.hidden === !0,
67
71
  positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
68
72
  legacy: e,
69
- customAttrName: n.customAttrName,
70
- customAttrValue: n.customAttrValue,
73
+ customAttrName: r.customAttrName,
74
+ customAttrValue: r.customAttrValue,
71
75
  originalIndex: i
72
76
  });
73
77
  }
74
78
  }), o.sort((e, i) => {
75
79
  if (e.positionIdx !== i.positionIdx)
76
80
  return e.positionIdx - i.positionIdx;
77
- const n = _(e.key), u = _(i.key);
78
- return n !== u ? n - u : e.originalIndex - i.originalIndex;
81
+ const r = S(e.key, i.key, s);
82
+ if (r !== 0)
83
+ return r;
84
+ const m = I(e.key), c = I(i.key);
85
+ return m !== c ? m - c : e.originalIndex - i.originalIndex;
79
86
  });
80
- const s = {};
87
+ const u = {};
81
88
  return o.forEach((e) => {
82
- const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
- switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
89
+ const { key: i, kind: r, hidden: m, legacy: c, customAttrName: A, customAttrValue: T } = e;
90
+ switch (t.composition.push(i), t.visibility[i] = !m, r === "custom" && A && T && (t.customAttributes.includes(T) || t.customAttributes.push(T), t.customAttrValues[i] = T), r) {
84
91
  case "image":
85
- s[i] = N(c.theme);
92
+ u[i] = P(c.theme);
86
93
  break;
87
94
  case "button":
88
- s[i] = y(c.theme);
95
+ u[i] = N(c.theme);
89
96
  break;
90
97
  case "text":
91
98
  case "custom": {
92
- const a = b(c.theme);
93
- s[i] = a, a.textTrimming && (t.anyTextTrimming = !0);
99
+ const p = C(c.theme);
100
+ u[i] = p, p.textTrimming && (t.anyTextTrimming = !0);
94
101
  break;
95
102
  }
96
103
  }
97
- }), t.perElementStyles = s, t;
104
+ }), t.perElementStyles = u, t;
98
105
  }
99
106
  export {
100
- V as mapComposition
107
+ F as mapComposition
101
108
  };
@@ -1,54 +1,114 @@
1
- import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
1
+ import { CURRENCY_ATTR as l, CSS_CLASS_SKIP_COMPILE as m } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
2
  const a = "You May Also Like!";
3
- function A(t) {
4
- var i;
5
- const e = t.querySelector(".ext-recommendation-title");
6
- if (!e)
3
+ function C(e) {
4
+ var n;
5
+ const r = e.querySelector(".ext-recommendation-title");
6
+ if (!r)
7
7
  return a;
8
- const r = (i = e.textContent) == null ? void 0 : i.trim();
9
- return r && r.length > 0 ? r : a;
8
+ const t = (n = r.textContent) == null ? void 0 : n.trim();
9
+ return t && t.length > 0 ? t : a;
10
10
  }
11
- function m(t) {
12
- const e = t.querySelector(".ext-recommendation-title");
13
- return e ? !/display\s*:\s*none/i.test(e.getAttribute("style") ?? "") : !1;
11
+ function A(e) {
12
+ const r = e.querySelector(".ext-recommendation-title");
13
+ return r ? !/display\s*:\s*none/i.test(r.getAttribute("style") ?? "") : !1;
14
14
  }
15
- function d(t) {
16
- const e = [
17
- t,
18
- ...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
15
+ function _(e) {
16
+ var t;
17
+ const r = e.querySelector(".ext-recommendation-title");
18
+ return !!r && !((t = r == null ? void 0 : r.textContent) != null && t.trim());
19
+ }
20
+ function E(e) {
21
+ const r = e.querySelector(".ext-product-price"), t = e.querySelector(".ext-product-original-price");
22
+ return !r || !t ? !1 : r.compareDocumentPosition(t) === Node.DOCUMENT_POSITION_PRECEDING;
23
+ }
24
+ function d(e) {
25
+ return /(?:^|;)\s*display\s*:\s*table-cell/i.test(e.getAttribute("style") ?? "");
26
+ }
27
+ function T(e) {
28
+ var n, o;
29
+ const r = (n = e.querySelector(".ext-product-price")) == null ? void 0 : n.closest("tr"), t = (o = e.querySelector(".ext-product-original-price")) == null ? void 0 : o.closest("tr");
30
+ return !r || !t || r === t ? !1 : !d(r) && !d(t);
31
+ }
32
+ const p = /* @__PURE__ */ new Map([
33
+ ["p_name", ".ext-product-name p"],
34
+ ["p_price", ".ext-product-price p"],
35
+ ["p_original_price", ".ext-product-original-price p"]
36
+ ]);
37
+ function f(e) {
38
+ const r = ((e == null ? void 0 : e.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
39
+ return (r == null ? void 0 : r[1].trim()) || void 0;
40
+ }
41
+ const x = "ins-trim-text";
42
+ function h(e, r) {
43
+ return e == null ? void 0 : e.map((t) => {
44
+ var s, u;
45
+ const n = p.get(t.variable ?? "");
46
+ if (!n)
47
+ return t;
48
+ const o = r.querySelector(n), c = (u = (s = t.theme) == null ? void 0 : s.textColor) != null && u.color ? void 0 : f(o), i = t.variable === "p_name" && (o == null ? void 0 : o.classList.contains(x));
49
+ return !c && !i ? t : {
50
+ ...t,
51
+ theme: {
52
+ ...t.theme,
53
+ ...c ? { textColor: { color: c } } : {},
54
+ ...i ? { textTrimming: !0 } : {}
55
+ }
56
+ };
57
+ });
58
+ }
59
+ function R(e) {
60
+ const r = [
61
+ e,
62
+ ...Array.from(e.querySelectorAll(".product-card, .ext-recommendation-card"))
19
63
  ];
20
- let r = "";
21
- return e.some((i) => {
22
- const o = i.getAttribute("bgcolor");
64
+ let t = "";
65
+ return r.some((n) => {
66
+ const o = n.getAttribute("bgcolor");
23
67
  if (o && o.trim())
24
- return r = o.trim(), !0;
25
- const u = (i.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
26
- return u && u[1] ? (r = u[1].trim(), !0) : !1;
27
- }), r;
28
- }
29
- function C(t) {
30
- const e = t.getAttribute(n.CURRENCY);
31
- if (!e)
32
- return;
33
- const r = t.getAttribute(n.SYMBOL);
68
+ return t = o.trim(), !0;
69
+ const i = (n.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
70
+ return i && i[1] ? (t = i[1].trim(), !0) : !1;
71
+ }), t;
72
+ }
73
+ function L(e) {
74
+ const r = e.getAttribute(l.CURRENCY), t = e.getAttribute(l.SYMBOL);
34
75
  return {
35
- value: e,
76
+ ...r ? { value: r } : {},
36
77
  // An empty `currency-symbol` is omitted so `mapCurrency` falls back to
37
78
  // the currency code as the symbol.
38
- ...r ? { symbol: r } : {},
39
- alignment: t.getAttribute(n.ALIGNMENT) ?? "",
40
- decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
41
- decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
42
- thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
79
+ ...t ? { symbol: t } : {},
80
+ alignment: 1,
81
+ decimalCount: "2",
82
+ decimalSeparator: ",",
83
+ thousandSeparator: "."
43
84
  };
44
85
  }
45
- function g(t) {
46
- return t.classList.contains(c);
86
+ const S = /^es-p(\d+)([trbl]?)$/, g = { t: "top", r: "right", b: "bottom", l: "left" };
87
+ function P(e) {
88
+ const r = e.querySelector("td.esd-structure.esd-extension-internal-block");
89
+ if (!r)
90
+ return;
91
+ const t = { top: 0, right: 0, bottom: 0, left: 0 };
92
+ return r.classList.forEach((n) => {
93
+ const o = n.match(S);
94
+ if (!o)
95
+ return;
96
+ const c = Number(o[1]), i = o[2];
97
+ i ? t[g[i]] = c : Object.assign(t, { top: c, right: c, bottom: c, left: c });
98
+ }), t;
99
+ }
100
+ function I(e) {
101
+ return e.classList.contains(m);
47
102
  }
48
103
  export {
49
- d as extractCardBgColor,
50
- C as extractCurrencyFromBlock,
51
- A as extractTitleText,
52
- m as hasVisibleTitle,
53
- g as isPartnerManagedBlock
104
+ R as extractCardBgColor,
105
+ L as extractCurrencyFromBlock,
106
+ P as extractRenderedBlockPadding,
107
+ C as extractTitleText,
108
+ _ as hasEmptyTitle,
109
+ A as hasVisibleTitle,
110
+ E as isOldPriceFirst,
111
+ I as isPartnerManagedBlock,
112
+ T as isPriceOnNextLine,
113
+ h as withRenderedTextTheme
54
114
  };