@useinsider/guido 2.1.0-beta.e13d291 → 2.1.0-beta.e2153c2

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 (138) hide show
  1. package/README.md +36 -0
  2. package/dist/@types/config/schemas.js +70 -65
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +69 -58
  5. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +15 -14
  6. package/dist/components/organisms/header/HeaderWrapper.vue.js +9 -9
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  9. package/dist/composables/useActionsApi.js +15 -13
  10. package/dist/composables/useBlocksConfig.js +26 -16
  11. package/dist/composables/useHtmlValidator.js +114 -104
  12. package/dist/composables/useRecommendation.js +54 -21
  13. package/dist/composables/useStripo.js +25 -23
  14. package/dist/composables/useVersionHistoryApi.js +1 -1
  15. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  16. package/dist/config/compiler/utils/recommendationCompilerUtils.js +121 -0
  17. package/dist/config/i18n/en/index.js +11 -0
  18. package/dist/config/i18n/en/labels.json.js +7 -0
  19. package/dist/config/i18n/en/toasters.json.js +56 -0
  20. package/dist/config/i18n/en/tooltips.json.js +82 -0
  21. package/dist/config/i18n/index.js +7 -0
  22. package/dist/config/migrator/itemsBlockMigrator.js +142 -120
  23. package/dist/enums/defaults.js +8 -4
  24. package/dist/enums/extensions/recommendationBlock.js +1 -1
  25. package/dist/enums/recommendation.js +16 -15
  26. package/dist/extensions/Blocks/Items/block.js +19 -28
  27. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  28. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  29. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  30. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  31. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  32. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  33. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  34. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  35. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  36. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  37. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  38. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  39. package/dist/extensions/Blocks/Items/extension.js +8 -9
  40. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  41. package/dist/extensions/Blocks/Items/template.js +181 -175
  42. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  43. package/dist/extensions/Blocks/Recommendation/block.js +117 -27
  44. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +33 -31
  45. package/dist/extensions/Blocks/Recommendation/constants/layout.js +6 -4
  46. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -10
  47. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +10 -14
  48. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +19 -27
  49. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +49 -44
  50. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +1 -3
  51. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +147 -102
  52. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +1 -5
  53. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +85 -43
  54. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +9 -13
  55. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +138 -117
  56. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +21 -0
  57. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +66 -34
  58. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +2 -2
  59. package/dist/extensions/Blocks/Recommendation/services/configService.js +2 -1
  60. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +248 -206
  61. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +26 -31
  62. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  63. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +31 -34
  64. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +20 -25
  65. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +22 -22
  66. package/dist/extensions/Blocks/Recommendation/templates/utils.js +52 -39
  67. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  68. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  69. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  70. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  71. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  72. package/dist/extensions/Blocks/common-control.js +91 -92
  73. package/dist/extensions/ModulesTabIcons/extension.js +17 -0
  74. package/dist/guido.css +1 -1
  75. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +257 -187
  76. package/dist/package.json.js +1 -1
  77. package/dist/services/recommendationApi.js +11 -9
  78. package/dist/services/stripoApi.js +20 -17
  79. package/dist/services/templateLibraryApi.js +16 -13
  80. package/dist/src/@types/config/schemas.d.ts +8 -0
  81. package/dist/src/composables/useConfig.d.ts +4 -0
  82. package/dist/src/composables/useRecommendation.d.ts +1 -0
  83. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  84. package/dist/src/config/i18n/en/index.d.ts +1 -0
  85. package/dist/src/config/i18n/index.d.ts +16 -0
  86. package/dist/src/enums/defaults.d.ts +4 -0
  87. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  88. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  89. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  90. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  91. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  92. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  93. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  94. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  95. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  96. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  97. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  98. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  99. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  100. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +44 -11
  101. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  102. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -0
  103. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +4 -0
  104. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +8 -1
  105. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +27 -5
  106. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +22 -4
  107. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -2
  108. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +29 -0
  109. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +19 -1
  110. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +2 -2
  111. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +138 -469
  112. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +2 -2
  113. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  114. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +2 -0
  115. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +2 -2
  116. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -2
  117. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +16 -4
  118. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +14 -2
  119. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +1 -1
  120. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  121. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  122. package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
  123. package/dist/src/stores/config.d.ts +36 -0
  124. package/dist/static/styles/components/notification.css.js +19 -0
  125. package/dist/static/styles/components/tools.css.js +6 -2
  126. package/dist/static/styles/components/version-history.css.js +10 -2
  127. package/dist/static/styles/components/wide-panel.css.js +18 -2
  128. package/dist/static/styles/customEditorStyle.css.js +10 -9
  129. package/dist/static/styles/variables.css.js +2 -0
  130. package/dist/static/templates/empty/index.html.js +74 -0
  131. package/dist/static/templates/empty/style.css.js +779 -0
  132. package/dist/stores/unsubscribe.js +37 -34
  133. package/dist/utils/pairProductVariables.js +57 -56
  134. package/dist/utils/templatePreparation.js +15 -14
  135. package/package.json +2 -2
  136. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  137. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
  138. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +0 -16
@@ -1,5 +1,5 @@
1
1
  import { ATTR_PRODUCT_BUTTON as s, ATTR_PRODUCT_OMNIBUS_DISCOUNT as d, ATTR_PRODUCT_OMNIBUS_PRICE as c, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as i, ATTR_PRODUCT_NAME as r, ATTR_PRODUCT_IMAGE as p } from "../../constants/selectors.js";
2
- import { prepareVerticalProductRows as b } from "./template.js";
2
+ import { prepareGridProductRows as b } from "./template.js";
3
3
  const u = `
4
4
  <td
5
5
  align="left"
@@ -1,7 +1,7 @@
1
- import { DEFAULT_PRODUCTS_PER_ROW as T } from "../../constants/layout.js";
2
- import { DEFAULT_CARD_COMPOSITION as d, spacer as m, createBlockTemplate as R, DEFAULTS as I, getDefaultProducts as L, DEFAULT_CARD_VISIBILITY as b } from "../utils.js";
3
- import { verticalElementRenderer as w } from "./elementRenderer.js";
4
- const E = `
1
+ import { DEFAULT_PRODUCTS_PER_ROW as m, DEFAULT_MOBILE_CARDS_IN_ROW as I } from "../../constants/layout.js";
2
+ import { DEFAULT_CARD_COMPOSITION as _, spacer as E, getDefaultProducts as S, createBlockTemplate as A, DEFAULTS as b, DEFAULT_CARD_VISIBILITY as D } from "../utils.js";
3
+ import { gridElementRenderer as w, ATTRIBUTE_CELL_CLASS as C, DEFAULT_CELL_PADDING as f } from "./elementRenderer.js";
4
+ const O = `
5
5
  <tr class="recommendation-product-row">
6
6
  <td>
7
7
  <table
@@ -18,7 +18,7 @@ const E = `
18
18
  </table>
19
19
  </td>
20
20
  </tr>
21
- `, S = `
21
+ `, U = `
22
22
  <tr
23
23
  class="recommendation-attribute-row"
24
24
  data-attribute-type="{-{-ATTR_TYPE-}-}"
@@ -27,43 +27,40 @@ const E = `
27
27
  {-{-CELLS-}-}
28
28
  </tr>
29
29
  `;
30
- function _(r, e, o, i = d) {
31
- const c = (100 / e).toFixed(2);
32
- return i.filter((t) => o[t]).map((t) => {
33
- const l = b[t] ?? !0, n = l ? "" : 'style="display: none;"', a = r.map((p) => {
34
- const u = o[t];
35
- return u(p).replace("<td", `<td width="${c}%"`);
30
+ function g(t, e, r, n = _) {
31
+ const c = (100 / e).toFixed(2), s = e - t.length, o = `<td class="${C}" style="padding: ${f};" width="${c}%"></td>`, i = s > 0 ? o.repeat(s) : "";
32
+ return n.filter((l) => r[l]).map((l) => {
33
+ const p = D[l] ?? !0, T = p ? "" : 'style="display: none;"', u = t.map((R) => {
34
+ const L = r[l];
35
+ return L(R).replace("<td", `<td width="${c}%"`);
36
36
  }).join("");
37
- return S.replace("{-{-ATTR_TYPE-}-}", t).replace("{-{-VISIBILITY-}-}", l ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", n).replace("{-{-CELLS-}-}", a);
37
+ return U.replace("{-{-ATTR_TYPE-}-}", l).replace("{-{-VISIBILITY-}-}", p ? "1" : "0").replace("{-{-DISPLAY_STYLE-}-}", T).replace("{-{-CELLS-}-}", u + i);
38
38
  }).join("");
39
39
  }
40
- function A(r, e, o, i) {
40
+ function P(t, e, r, n) {
41
41
  const c = [];
42
- for (let t = 0; t < r.length; t += e)
43
- c.push(r.slice(t, t + e));
44
- return c.map((t, l) => {
45
- const n = _(
46
- t,
47
- e,
42
+ for (let o = 0; o < t.length; o += e)
43
+ c.push(t.slice(o, o + e));
44
+ return c.map((o, i) => {
45
+ const a = g(
48
46
  o,
49
- i
50
- ), a = E.replace("{-{-ATTRIBUTE_ROWS-}-}", n);
51
- return l > 0 ? m + a : a;
47
+ e,
48
+ r,
49
+ n
50
+ ), l = O.replace("{-{-ATTRIBUTE_ROWS-}-}", a);
51
+ return i > 0 ? E + l : l;
52
52
  }).join("");
53
53
  }
54
- function f(r, e, o) {
55
- return A(r, e, w, o);
54
+ function d(t, e, r) {
55
+ return P(t, e, w, r);
56
56
  }
57
- function y() {
58
- const r = R("grid"), e = f(
59
- L(),
60
- T
61
- );
62
- return r.replace("{-{-TITLE-}-}", I.TITLE).replace("{-{-PRODUCT_ROWS-}-}", e);
57
+ function W(t) {
58
+ const e = t ? `ins-recommendation-v3-block-${t}` : void 0, r = A("grid", e), n = S(), c = d(n, m), s = d(n, I);
59
+ return r.replace("{-{-TITLE-}-}", b.TITLE).replace("{-{-PRODUCT_ROWS-}-}", c).replace("{-{-MOBILE_PRODUCT_ROWS-}-}", s);
63
60
  }
64
61
  export {
65
- y as getDefaultTemplate,
66
- f as prepareProductRows,
67
- _ as prepareVerticalAttributeRows,
68
- A as prepareVerticalProductRows
62
+ W as getDefaultTemplate,
63
+ g as prepareGridAttributeRows,
64
+ P as prepareGridProductRows,
65
+ d as prepareProductRows
69
66
  };
@@ -1,5 +1,5 @@
1
1
  import { RecommendationBlockId as o } from "../../constants/blockIds.js";
2
- import { ATTR_PRODUCT_BUTTON as l, ATTR_PRODUCT_IMAGE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_OMNIBUS_PRICE as u, ATTR_PRODUCT_OLD_PRICE as g, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as x } from "../../constants/selectors.js";
2
+ import { ATTR_PRODUCT_BUTTON as l, ATTR_PRODUCT_IMAGE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as u, ATTR_PRODUCT_OMNIBUS_PRICE as m, ATTR_PRODUCT_OLD_PRICE as g, ATTR_PRODUCT_PRICE as f, ATTR_PRODUCT_NAME as x } from "../../constants/selectors.js";
3
3
  import { useRecommendationExtensionStore as T } from "../../store/recommendation.js";
4
4
  import { formatPrice as _ } from "../../utils/priceFormatter.js";
5
5
  import { sanitizeImageUrl as y } from "../utils.js";
@@ -14,14 +14,14 @@ function p() {
14
14
  thousandSeparator: e.thousandSeparator
15
15
  };
16
16
  }
17
- function a(t, e = "price") {
18
- const n = p(), r = t[e], i = (r == null ? void 0 : r[n.code]) ?? Object.values(r ?? {})[0] ?? 0;
17
+ function s(t, e = "price") {
18
+ const n = p(), r = t[e], a = (r == null ? void 0 : r[n.code]) ?? Object.values(r ?? {})[0] ?? 0;
19
19
  return _({
20
- price: i,
20
+ price: a,
21
21
  currency: n
22
22
  });
23
23
  }
24
- const P = {
24
+ const $ = {
25
25
  /**
26
26
  * Image cell - left column (120px fixed width)
27
27
  * Has recommendation-attribute-row class and data attributes for Card Composition control
@@ -35,18 +35,13 @@ const P = {
35
35
  data-visibility="1"
36
36
  align="center"
37
37
  valign="middle">
38
- <div style="position: relative; width: 100%; padding-bottom: 100%; overflow: hidden;">
39
- <a
40
- target="_blank"
41
- href="${t.url}"
42
- style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
43
- <img
44
- src="${y(t.image_url)}"
45
- alt="${t.name}"
46
- style="max-width: 100%; max-height: 100%; object-fit: contain; display: block;"
47
- class="adapt-img product-image">
48
- </a>
49
- </div>
38
+ <a target="_blank" href="${t.url}">
39
+ <img
40
+ src="${y(t.image_url)}"
41
+ alt="${t.name}"
42
+ style="display: block; max-width: 100%; height: auto;"
43
+ class="adapt-img product-image">
44
+ </a>
50
45
  </td>
51
46
  `,
52
47
  /**
@@ -74,7 +69,7 @@ const P = {
74
69
  esd-extension-block-id="${o.PRICE}"
75
70
  align="left">
76
71
  <p contenteditable="false" style="font-size: 16px; color: #333333; font-weight: bold; margin: 0;">
77
- <strong>${a(t, "price")}</strong>
72
+ <strong>${s(t, "price")}</strong>
78
73
  </p>
79
74
  </td>
80
75
  </tr>
@@ -91,7 +86,7 @@ const P = {
91
86
  <p
92
87
  contenteditable="false"
93
88
  style="font-size: 14px; color: #999999; text-decoration: line-through; margin: 0;">
94
- <strong>${a(t, "original_price")}</strong>
89
+ <strong>${s(t, "original_price")}</strong>
95
90
  </p>
96
91
  </td>
97
92
  </tr>
@@ -99,7 +94,7 @@ const P = {
99
94
  /**
100
95
  * Omnibus price element - row for info cell table
101
96
  */
102
- [u]: (t) => `
97
+ [m]: (t) => `
103
98
  <tr>
104
99
  <td
105
100
  class="esd-block-text product-omnibus-price"
@@ -109,7 +104,7 @@ const P = {
109
104
  align="left">
110
105
  <p style="font-size: 12px; color: #666666; margin: 0;">
111
106
  <span class="omnibus-text-before">Lowest 30-day price: </span>
112
- <span class="omnibus-price-value">${a(t, "original_price")}</span>
107
+ <span class="omnibus-price-value">${s(t, "original_price")}</span>
113
108
  <span class="omnibus-text-after"></span>
114
109
  </p>
115
110
  </td>
@@ -118,9 +113,9 @@ const P = {
118
113
  /**
119
114
  * Omnibus discount element - row for info cell table
120
115
  */
121
- [m]: (t) => {
122
- var s, c;
123
- const e = p(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, r = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, i = n > 0 ? Math.round((n - r) / n * 100) : 0, b = i > 0 ? `-${i}%` : "0%";
116
+ [u]: (t) => {
117
+ var i, c;
118
+ const e = p(), n = ((i = t.original_price) == null ? void 0 : i[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, r = ((c = t.price) == null ? void 0 : c[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, a = n > 0 ? Math.round((n - r) / n * 100) : 0, b = a > 0 ? `-${a}%` : "0%";
124
119
  return `
125
120
  <tr>
126
121
  <td
@@ -170,5 +165,5 @@ const P = {
170
165
  `
171
166
  };
172
167
  export {
173
- P as horizontalElementRenderer
168
+ $ as listElementRenderer
174
169
  };
@@ -1,6 +1,6 @@
1
- import { ATTR_PRODUCT_IMAGE as E, ATTR_PRODUCT_NAME as s, ATTR_PRODUCT_OLD_PRICE as c, ATTR_PRODUCT_PRICE as a, ATTR_PRODUCT_OMNIBUS_PRICE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as T, ATTR_PRODUCT_BUTTON as N } from "../../constants/selectors.js";
2
- import { spacer as $, DEFAULT_CARD_VISIBILITY as n } from "../utils.js";
3
- import { horizontalElementRenderer as o } from "./elementRenderer.js";
1
+ import { ATTR_PRODUCT_IMAGE as E, ATTR_PRODUCT_NAME as l, ATTR_PRODUCT_OLD_PRICE as c, ATTR_PRODUCT_PRICE as a, ATTR_PRODUCT_OMNIBUS_PRICE as d, ATTR_PRODUCT_OMNIBUS_DISCOUNT as T, ATTR_PRODUCT_BUTTON as N } from "../../constants/selectors.js";
2
+ import { spacer as $, DEFAULT_CARD_VISIBILITY as o } from "../utils.js";
3
+ import { listElementRenderer as e } from "./elementRenderer.js";
4
4
  const f = `
5
5
  <tr class="recommendation-product-row">
6
6
  <td style="padding: 0 5px;">
@@ -20,30 +20,30 @@ const f = `
20
20
  </tr>
21
21
  `;
22
22
  function V(t) {
23
- const i = o[E](t), l = n[s], r = n[c], R = n[a], C = n[d], b = n[T], e = (w, A, p) => {
23
+ const r = e[E](t), s = o[l], i = o[c], R = o[a], C = o[d], b = o[T], n = (w, A, p) => {
24
24
  const I = p ? "" : ' style="display: none;"', g = w.replace(/<tr>/, "").replace(/<\/tr>/, "");
25
25
  return `<tr
26
26
  class="recommendation-attribute-row"
27
27
  data-attribute-type="${A}"
28
28
  data-visibility="${p ? "1" : "0"}"${I}>${g}</tr>`;
29
- }, m = e(
30
- o[s](t),
31
- s,
32
- l
33
- ), _ = e(
34
- o[c](t),
29
+ }, m = n(
30
+ e[l](t),
31
+ l,
32
+ s
33
+ ), _ = n(
34
+ e[c](t),
35
35
  c,
36
- r
37
- ), O = e(
38
- o[a](t),
36
+ i
37
+ ), O = n(
38
+ e[a](t),
39
39
  a,
40
40
  R
41
- ), P = e(
42
- o[d](t),
41
+ ), P = n(
42
+ e[d](t),
43
43
  d,
44
44
  C
45
- ), u = e(
46
- o[T](t),
45
+ ), u = n(
46
+ e[T](t),
47
47
  T,
48
48
  b
49
49
  ), D = `
@@ -58,16 +58,16 @@ function V(t) {
58
58
  </tbody>
59
59
  </table>
60
60
  </td>
61
- `, U = o[N](t), y = i + D + U;
61
+ `, U = e[N](t), y = r + D + U;
62
62
  return f.replace("{-{-PRODUCT_CONTENT-}-}", y);
63
63
  }
64
64
  function M(t) {
65
- return t.map((i, l) => {
66
- const r = V(i);
67
- return l > 0 ? $ + r : r;
65
+ return t.map((r, s) => {
66
+ const i = V(r);
67
+ return s > 0 ? $ + i : i;
68
68
  }).join("");
69
69
  }
70
70
  export {
71
- V as getHorizontalProductCard,
71
+ V as getListProductCard,
72
72
  M as prepareProductRows
73
73
  };
@@ -1,34 +1,34 @@
1
- import { ATTR_PRODUCT_IMAGE as r, ATTR_PRODUCT_NAME as a, ATTR_PRODUCT_OLD_PRICE as o, ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OMNIBUS_PRICE as l, ATTR_PRODUCT_OMNIBUS_DISCOUNT as s, ATTR_PRODUCT_BUTTON as n } from "../constants/selectors.js";
2
- const _ = {
1
+ import { ATTR_PRODUCT_IMAGE as n, ATTR_PRODUCT_NAME as o, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OMNIBUS_PRICE as l, ATTR_PRODUCT_OMNIBUS_DISCOUNT as i, ATTR_PRODUCT_BUTTON as s } from "../constants/selectors.js";
2
+ const g = {
3
3
  TITLE: "You May Also Like!"
4
4
  }, u = [
5
- r,
6
- a,
5
+ n,
7
6
  o,
7
+ a,
8
8
  c,
9
9
  l,
10
- s,
11
- n
12
- ], m = {
13
- [r]: !0,
14
- [a]: !0,
15
- [c]: !0,
10
+ i,
11
+ s
12
+ ], b = {
13
+ [n]: !0,
16
14
  [o]: !0,
15
+ [c]: !0,
16
+ [a]: !0,
17
17
  [l]: !1,
18
- [s]: !1,
19
- [n]: !0
20
- }, d = `
18
+ [i]: !1,
19
+ [s]: !0
20
+ }, p = `
21
21
  <tr>
22
22
  <td class="spacer" style="height: 10px;"></td>
23
23
  </tr>
24
- `, i = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
25
- function g(t) {
26
- return !t || typeof t != "string" || t.trim() === "" ? i : t.startsWith("http://") ? t.replace("http://", "https://") : t;
24
+ `, d = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
25
+ function R(t) {
26
+ return !t || typeof t != "string" || t.trim() === "" ? d : t.startsWith("http://") ? t.replace("http://", "https://") : t;
27
27
  }
28
- function e(t) {
28
+ function T(t) {
29
29
  return {
30
30
  name: "Product Name",
31
- image_url: i,
31
+ image_url: d,
32
32
  price: { USD: 18 },
33
33
  original_price: { USD: 20 },
34
34
  discount: { USD: 2 },
@@ -40,22 +40,19 @@ function e(t) {
40
40
  category: []
41
41
  };
42
42
  }
43
- function b() {
44
- return [
45
- e("1"),
46
- e("2"),
47
- e("3"),
48
- e("4"),
49
- e("5"),
50
- e("6")
51
- ];
43
+ function D(t = 6) {
44
+ return Array.from(
45
+ { length: t },
46
+ (e, r) => T(String(r + 1))
47
+ );
52
48
  }
53
- function R(t = "grid") {
49
+ function O(t = "grid", e) {
50
+ const r = t === "list" ? `
51
+ data-layout="list"` : "";
54
52
  return `
55
53
  <td
56
54
  align="left"
57
- class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block es-p20"${t === "list" ? `
58
- data-layout="list"` : ""}>
55
+ class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block es-p20${e ? ` ${e}` : ""}"${r}>
59
56
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
60
57
  <tr>
61
58
  <td align="center">
@@ -87,11 +84,12 @@ function R(t = "grid") {
87
84
  </table>
88
85
  </td>
89
86
  </tr>
90
- ${d}
87
+ ${p}
91
88
  <tr>
92
89
  <td>
93
90
  <table
94
- class="ins-recommendation-product-container"
91
+ class="ins-recommendation-product-container
92
+ ins-recommendation-desktop-container"
95
93
  width="100%"
96
94
  cellpadding="0"
97
95
  cellspacing="0"
@@ -101,6 +99,21 @@ function R(t = "grid") {
101
99
  </table>
102
100
  </td>
103
101
  </tr>
102
+ <tr>
103
+ <td>
104
+ <table
105
+ class="ins-recommendation-product-container
106
+ ins-recommendation-mobile-container"
107
+ width="100%"
108
+ cellpadding="0"
109
+ cellspacing="0"
110
+ border="0"
111
+ style="display: none;"
112
+ >
113
+ {-{-MOBILE_PRODUCT_ROWS-}-}
114
+ </table>
115
+ </td>
116
+ </tr>
104
117
  </tbody>
105
118
  </table>
106
119
  </td>
@@ -110,12 +123,12 @@ function R(t = "grid") {
110
123
  `;
111
124
  }
112
125
  export {
113
- _ as DEFAULTS,
126
+ g as DEFAULTS,
114
127
  u as DEFAULT_CARD_COMPOSITION,
115
- m as DEFAULT_CARD_VISIBILITY,
116
- i as PLACEHOLDER_IMAGE,
117
- R as createBlockTemplate,
118
- b as getDefaultProducts,
119
- g as sanitizeImageUrl,
120
- d as spacer
128
+ b as DEFAULT_CARD_VISIBILITY,
129
+ d as PLACEHOLDER_IMAGE,
130
+ O as createBlockTemplate,
131
+ D as getDefaultProducts,
132
+ R as sanitizeImageUrl,
133
+ p as spacer
121
134
  };
@@ -1,25 +1,25 @@
1
- function p(t) {
2
- const r = {
1
+ function m(t) {
2
+ const e = {
3
3
  "&": "&amp;",
4
4
  "<": "&lt;",
5
5
  ">": "&gt;",
6
6
  '"': "&quot;",
7
7
  "'": "&#39;"
8
8
  };
9
- return t.replace(/[&<>"']/g, (n) => r[n]);
9
+ return t.replace(/[&<>"']/g, (n) => e[n]);
10
10
  }
11
- function m(t) {
12
- return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML() : "innerHTML" in t ? t.innerHTML : "";
11
+ function p(t) {
12
+ return "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "innerHTML" in t ? t.innerHTML : "";
13
13
  }
14
- function T(t, r) {
15
- const n = p(r);
14
+ function T(t, e) {
15
+ const n = m(e);
16
16
  if (!t)
17
17
  return n;
18
- const e = m(t);
19
- if (!e || e.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(e))
18
+ const r = p(t);
19
+ if (!r || r.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(r))
20
20
  return n;
21
21
  const i = [], o = [];
22
- let c = e.trim();
22
+ let c = r.trim();
23
23
  for (; ; ) {
24
24
  const u = c.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
25
25
  if (!u)
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { getDefaultTemplate as L } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
9
  import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class R extends _ {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,7 +19,7 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
@@ -47,8 +47,8 @@ class R extends h {
47
47
  }
48
48
  _setupSelectEventListener() {
49
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
50
- const s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
52
  }, document.addEventListener(a.SELECT, this.selectEventListener);
53
53
  }
54
54
  _removeSelectEventListener() {
@@ -74,17 +74,17 @@ class R extends h {
74
74
  _removeEventListeners() {
75
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
76
76
  }
77
- _updateBlock(e, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
85
85
  }
86
86
  _getMergeTag(e) {
87
- return T[e] ?? B;
87
+ return B[e] ?? T;
88
88
  }
89
89
  _openDrawer() {
90
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
@@ -97,24 +97,24 @@ class R extends h {
97
97
  }
98
98
  _checkExistingBlocks() {
99
99
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
105
  l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
106
106
  }
107
107
  }
108
108
  });
109
109
  }
110
- _loadBlockState(e) {
110
+ async _loadBlockState(e) {
111
111
  if (!("getAttribute" in e))
112
112
  return;
113
- const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
118
118
  }
119
119
  _resetStoreState() {
120
120
  c().$reset();
@@ -122,14 +122,14 @@ class R extends h {
122
122
  _removeBlockTemplatesFromStore(e) {
123
123
  if (!("getAttribute" in e))
124
124
  return;
125
- const s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };
@@ -1,18 +1,18 @@
1
- var h = Object.defineProperty;
2
- var d = (a, s, e) => s in a ? h(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => d(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var d = Object.defineProperty;
2
+ var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
5
  import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
7
  import { parsePageList as _ } from "./utils/utils.js";
8
- const g = "ui-elements-unsubscribe", r = {
8
+ const v = "ui-elements-unsubscribe", r = {
9
9
  SELECT_BUTTON: "selectTemplateButton",
10
10
  PREV_BUTTON: "prevButton",
11
11
  NEXT_BUTTON: "nextButton",
12
12
  COUNTER_TEXT: "counterText",
13
13
  PREVIEW_IMAGE: "previewImage"
14
14
  };
15
- class N extends T {
15
+ class B extends T {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  u(this, "currentPreviewIndex", 0);
@@ -22,7 +22,7 @@ class N extends T {
22
22
  u(this, "lastParsedAttribute");
23
23
  }
24
24
  getId() {
25
- return g;
25
+ return v;
26
26
  }
27
27
  getTemplate() {
28
28
  return `
@@ -35,7 +35,7 @@ class N extends T {
35
35
  onTemplateNodeUpdated(e) {
36
36
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
37
  const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updatePreview(), this._updateCounter());
38
+ t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
39
  }
40
40
  }
41
41
  onRender() {
@@ -73,6 +73,9 @@ class N extends T {
73
73
  _onNextClick() {
74
74
  this.currentPreviewIndex < this.totalTemplates - 1 && (this.currentPreviewIndex++, this._updatePreview(), this._updateCounter());
75
75
  }
76
+ async _loadAndUpdatePreview() {
77
+ await l().fetchTemplates(), this._updatePreview(), this._updateCounter();
78
+ }
76
79
  _updatePreview() {
77
80
  var e;
78
81
  if ((e = this.currentPages) != null && e.length)
@@ -162,6 +165,6 @@ class N extends T {
162
165
  }
163
166
  }
164
167
  export {
165
- g as UNSUBSCRIBE_CONTROL_ID,
166
- N as UnsubscribeControl
168
+ v as UNSUBSCRIBE_CONTROL_ID,
169
+ B as UnsubscribeControl
167
170
  };