@useinsider/guido 3.17.0 → 3.18.0-beta.a0b94e0

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 (119) hide show
  1. package/README.md +6 -5
  2. package/dist/@types/config/schemas.js +7 -6
  3. package/dist/components/Guido.vue.js +10 -10
  4. package/dist/components/Guido.vue2.js +82 -76
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
  7. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.js +17 -0
  8. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
  9. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  10. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  11. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  12. package/dist/composables/useModuleRepair.js +33 -0
  13. package/dist/composables/useRecommendation.js +41 -34
  14. package/dist/composables/useSave.js +30 -29
  15. package/dist/composables/useStripo.js +15 -15
  16. package/dist/composables/useSyncModuleExtractor.js +15 -13
  17. package/dist/composables/validators/useSyncModuleBlockValidator.js +24 -0
  18. package/dist/config/i18n/en/labels.json.js +1 -1
  19. package/dist/config/migrator/index.js +9 -8
  20. package/dist/config/migrator/itemsBlockMigrator.js +197 -137
  21. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  22. package/dist/config/migrator/recommendation/extractors.js +29 -24
  23. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  24. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  25. package/dist/config/migrator/recommendationMigrator.js +31 -25
  26. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  27. package/dist/enums/academy.js +2 -1
  28. package/dist/enums/date.js +5 -3
  29. package/dist/enums/extensions/recommendationBlock.js +3 -1
  30. package/dist/extensions/Blocks/Items/block.js +118 -49
  31. package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
  32. package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
  33. package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
  34. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  35. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
  36. package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
  37. package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
  38. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
  39. package/dist/extensions/Blocks/Items/template.js +189 -179
  40. package/dist/extensions/Blocks/Items/utils/constants.js +4 -0
  41. package/dist/extensions/Blocks/Recommendation/block.js +35 -29
  42. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  43. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  44. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +29 -27
  45. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
  46. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +309 -236
  47. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +241 -180
  48. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  49. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  51. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  52. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  53. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  54. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +175 -79
  55. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  56. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  57. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  58. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
  59. package/dist/extensions/Blocks/Recommendation/utils/recommendationBlockCount.js +10 -6
  60. package/dist/extensions/Blocks/common-control.js +22 -19
  61. package/dist/guido.css +1 -1
  62. package/dist/services/recommendationApi.js +69 -30
  63. package/dist/src/@types/config/schemas.d.ts +2 -0
  64. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  65. package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
  66. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  67. package/dist/src/composables/useConfig.d.ts +2 -0
  68. package/dist/src/composables/useModuleRepair.d.ts +18 -0
  69. package/dist/src/composables/useRecommendation.d.ts +1 -0
  70. package/dist/src/composables/useSyncModuleExtractor.d.ts +2 -0
  71. package/dist/src/composables/validators/useSyncModuleBlockValidator.d.ts +3 -0
  72. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  73. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  74. package/dist/src/enums/academy.d.ts +1 -0
  75. package/dist/src/enums/date.d.ts +1 -0
  76. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  77. package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
  78. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
  79. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
  80. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  81. package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
  82. package/dist/src/extensions/Blocks/Items/utils/constants.d.ts +6 -0
  83. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  84. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  85. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +3 -6
  86. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  87. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  88. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  89. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  90. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
  91. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  92. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  93. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  94. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  95. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +176 -10
  96. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  97. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +7 -0
  98. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
  99. package/dist/src/extensions/Blocks/Recommendation/utils/recommendationBlockCount.d.ts +6 -2
  100. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  101. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  102. package/dist/src/services/recommendationApi.d.ts +4 -1
  103. package/dist/src/stores/config.d.ts +18 -0
  104. package/dist/src/stores/save-as-template.d.ts +4 -3
  105. package/dist/src/utils/genericUtil.d.ts +5 -0
  106. package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
  107. package/dist/static/assets/icons/line-change.svg.js +5 -0
  108. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  109. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  110. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  111. package/dist/static/styles/customEditorStyle.css.js +3 -1
  112. package/dist/utils/dateUtil.js +23 -10
  113. package/dist/utils/genericUtil.js +28 -27
  114. package/dist/utils/itemsCurrencyRepair.js +39 -0
  115. package/dist/utils/pairProductVariables.js +77 -77
  116. package/dist/utils/templatePreparation.js +35 -34
  117. package/package.json +3 -2
  118. package/dist/composables/useModuleDynamicContentRepair.js +0 -37
  119. package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
@@ -1,11 +1,11 @@
1
- var v = Object.defineProperty;
2
- var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
- var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
4
- import { BLOCK_ID as w } from "../../extensions/Blocks/Items/block.js";
5
- import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
- import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
- import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
8
- import { useTemplateStore as q } from "../../stores/template.js";
1
+ var q = Object.defineProperty;
2
+ var v = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var P = (o, t, e) => v(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as F } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { ItemInCartOptions as I, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as O } from "../../stores/template.js";
9
9
  const x = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
@@ -73,10 +73,10 @@ const x = {
73
73
  isArray: !1
74
74
  }
75
75
  };
76
- function O() {
76
+ function $() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function k(o) {
79
+ function R(o) {
80
80
  return o ? {
81
81
  CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
82
  BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
@@ -86,38 +86,41 @@ function k(o) {
86
86
  PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
87
  }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
88
88
  }
89
- function h(o) {
90
- var e;
91
- const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), i = I[a];
92
- let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
- if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
- const l = parseInt(n) - 1, u = I[a];
95
- u && u[l] && (n = u[l].value);
89
+ function V(o) {
90
+ return o.classList.contains("esd-browsed-items-block") ? p.ITEMS_TYPE.BROWSED_ITEMS : o.classList.contains("esd-purchased-items-block") ? p.ITEMS_TYPE.PURCHASED_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
91
+ }
92
+ function M(o) {
93
+ var r;
94
+ const t = (l, u) => l == null ? u : l === "1" || l === "true", e = (l, u) => l || u, i = o["data-type"] || o["data-source"], a = R(i), n = I[a];
95
+ let c = o["data-cart_items_select_control_value"] || ((r = n == null ? void 0 : n[0]) == null ? void 0 : r.value) || S.cartItemsSelectControlValue;
96
+ if (c && !c.includes("{{") && /^\d+$/.test(c)) {
97
+ const l = parseInt(c) - 1, u = I[a];
98
+ u && u[l] && (c = u[l].value);
96
99
  }
97
100
  return {
98
101
  initialized: !0,
99
- blockInstanceId: r(o["data-block-instance-id"], O()),
102
+ blockInstanceId: e(o["data-block-instance-id"], $()),
100
103
  source: a,
101
104
  type: a,
102
- itemsSelectValue: n,
105
+ itemsSelectValue: c,
103
106
  orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
104
107
  nameTrimming: t(o["data-product_name_control_trim"], !0),
105
108
  priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
106
109
  priceFormatted: t(o["data-product_price_control_formated"], !0),
107
110
  priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
108
- priceCurrencySymbol: r(
111
+ priceCurrencySymbol: e(
109
112
  o["data-product_price_control_currency_symbol"],
110
- g.productPriceCurrencySymbolControlValue
113
+ S.productPriceCurrencySymbolControlValue
111
114
  ),
112
- priceCurrencyLocation: r(
115
+ priceCurrencyLocation: e(
113
116
  o["data-product_price_currency_location"],
114
- g.productPriceCurrencyLocationControlValue
117
+ S.productPriceCurrencyLocationControlValue
115
118
  ),
116
119
  priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
117
120
  quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
118
- buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
119
- imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
120
- buttonLabel: r(o["data-product_button_control_label"], "Buy"),
121
+ buttonLink: e(o["data-product_button_link"], S.productButtonLinkControlValue),
122
+ imageLink: e(o["data-product_image_link"], S.productImageLinkControlValue),
123
+ buttonLabel: e(o["data-product_button_control_label"], "Buy"),
121
124
  buttonFullWidth: t(o["data-product_button_control_atw"], !0),
122
125
  imageVisible: t(o["data-product_image_control_enabled"], !0),
123
126
  nameVisible: t(o["data-product_name_control_enabled"], !0),
@@ -127,72 +130,72 @@ function h(o) {
127
130
  buttonVisible: t(o["data-product_button_control_enabled"], !0)
128
131
  };
129
132
  }
130
- const V = {
133
+ const H = {
131
134
  ins_apr: "CART_ITEMS",
132
135
  browsed_item: "BROWSED_ITEMS",
133
136
  purchased_item: "PURCHASED_ITEMS"
134
137
  };
135
- function $(o, t) {
136
- const r = {
138
+ function N(o, t) {
139
+ const e = {
137
140
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
138
141
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
139
142
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
140
143
  };
141
- return r[o] || r.CART_ITEMS;
144
+ return e[o] || e.CART_ITEMS;
142
145
  }
143
- function N(o, t) {
144
- const r = {
146
+ function z(o, t) {
147
+ const e = {
145
148
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
146
149
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
147
150
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
148
151
  };
149
- return r[o] || r.CART_ITEMS;
152
+ return e[o] || e.CART_ITEMS;
150
153
  }
151
- class H {
154
+ class Y {
152
155
  constructor() {
153
- M(this, "parser");
156
+ P(this, "parser");
154
157
  this.parser = new DOMParser();
155
158
  }
156
159
  migrate(t) {
157
160
  try {
158
161
  if (!this.containsItemsBlock(t))
159
162
  return this.backfillV2ProductTdAttributes(t);
160
- let r = this.removeJinjaConditionals(t);
161
- r = this.replaceTemplateVariables(r);
162
- const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
163
+ let e = this.removeJinjaConditionals(t);
164
+ e = this.replaceTemplateVariables(e);
165
+ const i = this.parser.parseFromString(e, "text/html"), a = i.querySelectorAll(
163
166
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
167
  );
165
- return q().$patch((n) => {
166
- n.migrations = { ...n.migrations, [w]: a.length };
167
- }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
168
- const e = this.extractConfiguration(n), l = F({
169
- orientation: e.orientation,
170
- itemsType: e.itemsType,
171
- itemId: e.itemId,
172
- currencySymbol: e.currencySymbol,
173
- currencyLocation: e.currencyLocation,
174
- formattedPrice: e.formattedPrice,
175
- configBlockAttributes: e.configBlockAttributes,
168
+ return O().$patch((c) => {
169
+ c.migrations = { ...c.migrations, [U]: a.length };
170
+ }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (a.forEach((c) => {
171
+ const r = this.extractConfiguration(c), l = K({
172
+ orientation: r.orientation,
173
+ itemsType: r.itemsType,
174
+ itemId: r.itemId,
175
+ currencySymbol: r.currencySymbol,
176
+ currencyLocation: r.currencyLocation,
177
+ formattedPrice: r.formattedPrice,
178
+ configBlockAttributes: r.configBlockAttributes,
176
179
  migrate: !0,
177
- nameStyles: e.nameStyles,
178
- buttonStyles: e.buttonStyles,
179
- priceStyles: e.priceStyles,
180
- originalPriceStyles: e.originalPriceStyles,
181
- quantityStyles: e.quantityStyles,
182
- nodeConfig: h(e.configBlockAttributes)
183
- }), s = this.parser.parseFromString(
180
+ nameStyles: r.nameStyles,
181
+ buttonStyles: r.buttonStyles,
182
+ priceStyles: r.priceStyles,
183
+ originalPriceStyles: r.originalPriceStyles,
184
+ quantityStyles: r.quantityStyles,
185
+ nodeConfig: M(r.configBlockAttributes)
186
+ }), d = this.parser.parseFromString(
184
187
  `<table><tbody><tr>${l}</tr></tbody></table>`,
185
188
  "text/html"
186
189
  ).querySelector("td");
187
- if (s && n.parentNode) {
188
- const _ = h(e.configBlockAttributes);
189
- s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
190
- const d = s.querySelector("esd-config-block");
191
- d && d.remove(), n.parentNode.replaceChild(s, n);
190
+ if (d && c.parentNode) {
191
+ const _ = M(r.configBlockAttributes);
192
+ d.setAttribute("esd-ext-config", JSON.stringify(_)), d.setAttribute("data-type", _.type);
193
+ const s = d.querySelector("esd-config-block");
194
+ s && s.remove(), c.parentNode.replaceChild(d, c);
192
195
  }
193
- }), c.documentElement.outerHTML);
194
- } catch (r) {
195
- return console.error("ItemsBlockMigrator failed:", r), t;
196
+ }), i.documentElement.outerHTML);
197
+ } catch (e) {
198
+ return console.error("ItemsBlockMigrator failed:", e), t;
196
199
  }
197
200
  }
198
201
  /**
@@ -202,28 +205,85 @@ class H {
202
205
  * - UI styles from product elements (name, price, button, quantity, etc.)
203
206
  */
204
207
  extractConfiguration(t) {
205
- var C, D, P;
206
- const r = k(
207
- ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
- ), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), l = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, c), b = d["data-card_orientation_control_value"];
209
- let S;
210
- b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
211
- const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
208
+ var D;
209
+ const e = R(
210
+ this.readSelfOrDescendantAttribute(t, "data-type") || V(t)
211
+ ), i = this.readSelfOrDescendantAttribute(t, "data-number") || "1", a = parseInt(i) - 1, n = I[e], c = ((D = n == null ? void 0 : n[a]) == null ? void 0 : D.value) || n[0].value, r = this.extractConfigBlockAttributes(t, e, i);
212
+ this.applyDomFallbacks(t, r);
213
+ const l = t.querySelector('[product-attr="price"]'), u = l ?? t.querySelector('[product-attr="originalPrice"]'), d = (u == null ? void 0 : u.getAttribute("data-currency_symbol")) || r["data-product_price_control_currency_symbol"], _ = u == null ? void 0 : u.getAttribute("data-curency");
214
+ let s = r["data-product_price_currency_location"] || "0";
215
+ _ && (s = _ === "after" ? "1" : "0");
216
+ const A = (u == null ? void 0 : u.getAttribute("data-formated")) ?? r["data-product_price_control_formated"], h = A !== "false" && A !== "0", m = r["data-card_orientation_control_value"];
217
+ let g;
218
+ m ? g = m === "horizontal" ? "horizontal" : "vertical" : g = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
219
+ const y = t.querySelector('a[product-attr="name"]'), b = (y == null ? void 0 : y.getAttribute("style")) || void 0, E = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, k = (l == null ? void 0 : l.getAttribute("style")) || void 0, f = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = f != null && f.getAttribute("style") ? f : (f == null ? void 0 : f.closest("p")) ?? f, w = (T == null ? void 0 : T.getAttribute("style")) || void 0, C = t.querySelector('[product-attr="quantity"]'), B = (C == null ? void 0 : C.getAttribute("style")) || void 0;
212
220
  return {
213
- orientation: S,
214
- itemsType: r,
215
- itemId: n,
216
- currencySymbol: l,
221
+ orientation: g,
222
+ itemsType: e,
223
+ itemId: c,
224
+ currencySymbol: d,
217
225
  currencyLocation: s,
218
- formattedPrice: _,
219
- configBlockAttributes: d,
220
- nameStyles: A,
221
- buttonStyles: m,
222
- priceStyles: R,
223
- originalPriceStyles: L,
226
+ formattedPrice: h,
227
+ configBlockAttributes: r,
228
+ nameStyles: b,
229
+ buttonStyles: L,
230
+ priceStyles: k,
231
+ originalPriceStyles: w,
224
232
  quantityStyles: B
225
233
  };
226
234
  }
235
+ /**
236
+ * DOM fallback for hand-edited templates whose esd-config-block was deleted. With no
237
+ * toggle record left, derive each field's enabled state from whether its product-attr
238
+ * element still exists and read the button label from the live caption — a deleted
239
+ * element means the field is off, not an all-ON default. A present config block stays
240
+ * authoritative (a missing flag there still means "default on"), so we no-op for it.
241
+ */
242
+ applyDomFallbacks(t, e) {
243
+ var u;
244
+ const i = t.querySelector("esd-config-block");
245
+ if (Object.entries({
246
+ image: '[product-attr="imageSrc"]',
247
+ name: '[product-attr="name"]',
248
+ price: '[product-attr="price"]',
249
+ original_price: '[product-attr="originalPrice"], p.original-price',
250
+ quantity: '[product-attr="quantity"]',
251
+ button: '[product-attr="button"]'
252
+ }).forEach(([d, _]) => {
253
+ const s = `data-product_${d}_control_enabled`;
254
+ (!i || !i.hasAttribute(s)) && (e[s] = t.querySelector(_) ? "true" : "false");
255
+ }), i)
256
+ return;
257
+ e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal";
258
+ const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), c = (u = n == null ? void 0 : n.textContent) == null ? void 0 : u.replace(/\s+/g, " ").trim();
259
+ c && (e["data-product_button_control_label"] = c), /display:\s*inline/.test((n == null ? void 0 : n.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
260
+ const r = t.querySelector('[product-attr="imageSrc"]'), l = r ? this.readImageDimension(r) : null;
261
+ l && (e["data-product_image_control_image-height"] = l, e["data-product_image_control_image-width"] = l);
262
+ }
263
+ /**
264
+ * Reads an attribute from the block element itself before falling back to a descendant.
265
+ * Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
266
+ * esd-config-block; when an author deletes the config block only the td's copy survives.
267
+ */
268
+ readSelfOrDescendantAttribute(t, e) {
269
+ var i;
270
+ return t.getAttribute(e) || ((i = t.querySelector(`[${e}]`)) == null ? void 0 : i.getAttribute(e)) || null;
271
+ }
272
+ /**
273
+ * Reads a pixel dimension for the product image from its DOM element — the legacy
274
+ * `width` attribute first, then a px value in the inline style. An explicit `width` wins
275
+ * over `max-width`, which is only an upper bound; `max-width` still covers the common
276
+ * `width: 100%` case, where no pixel size can be read from `width` itself.
277
+ * Returns null when no pixel size is present.
278
+ */
279
+ readImageDimension(t) {
280
+ var n;
281
+ const e = (n = t.getAttribute("width")) == null ? void 0 : n.trim();
282
+ if (e && /^\d+$/.test(e))
283
+ return e;
284
+ const i = t.getAttribute("style") || "", a = i.match(/(?:^|;)\s*width:\s*(\d+)px/) || i.match(/max-width:\s*(\d+)px/);
285
+ return a ? a[1] : null;
286
+ }
227
287
  /**
228
288
  * Extracts all data-* attributes from the esd-config-block element
229
289
  * Returns a key-value mapping of all configuration attributes
@@ -231,27 +291,27 @@ class H {
231
291
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
232
292
  * @param itemNumber - The item number (1-based index)
233
293
  */
234
- extractConfigBlockAttributes(t, r, c) {
235
- const a = t.querySelector("esd-config-block"), i = {};
236
- if (!a)
237
- return this.getDefaultConfigBlockAttributes();
238
- if (Array.from(a.attributes).forEach((e) => {
239
- e.name.startsWith("data-") && (i[e.name] = e.value);
240
- }), i["data-cart_items_select_control_value"]) {
241
- const e = i["data-cart_items_select_control_value"];
242
- if (/^\d+$/.test(e)) {
243
- const l = parseInt(e) - 1, u = I[r];
244
- u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
294
+ extractConfigBlockAttributes(t, e, i) {
295
+ const a = t.querySelector("esd-config-block"), n = {};
296
+ if (a) {
297
+ if (Array.from(a.attributes).forEach((r) => {
298
+ r.name.startsWith("data-") && (n[r.name] = r.value);
299
+ }), n["data-cart_items_select_control_value"]) {
300
+ const r = n["data-cart_items_select_control_value"];
301
+ if (/^\d+$/.test(r)) {
302
+ const l = parseInt(r) - 1, u = I[e];
303
+ u && u[l] && (n["data-cart_items_select_control_value"] = u[l].value);
304
+ }
245
305
  }
306
+ if (n["data-product_price_control_curency"]) {
307
+ const r = n["data-product_price_control_curency"];
308
+ let l = r;
309
+ r === "before" ? l = "0" : r === "after" && (l = "1"), n["data-product_price_control_curency"] = l, n["data-product_price_currency_location"] = l;
310
+ }
311
+ (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
246
312
  }
247
- if (i["data-product_price_control_curency"]) {
248
- const e = i["data-product_price_control_curency"];
249
- let l = e;
250
- e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
251
- }
252
- (!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
253
- const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
254
- return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
313
+ const c = { ...this.getDefaultConfigBlockAttributes(), ...n };
314
+ return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = N(e, i), c["data-product_button_link"] = z(e, i), c;
255
315
  }
256
316
  /**
257
317
  * Returns default esd-config-block attributes based on the old template structure
@@ -325,25 +385,25 @@ class H {
325
385
  backfillV2ProductTdAttributes(t) {
326
386
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
387
  return t;
328
- const r = this.parser.parseFromString(t, "text/html");
329
- let c = !1;
330
- return r.querySelectorAll(".ins-product-td").forEach((a) => {
331
- a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
332
- const i = a.getAttribute("esd-ext-config");
333
- let n = null;
388
+ const e = this.parser.parseFromString(t, "text/html");
389
+ let i = !1;
390
+ return e.querySelectorAll(".ins-product-td").forEach((a) => {
391
+ a.hasAttribute("width") && (a.removeAttribute("width"), i = !0);
392
+ const n = a.getAttribute("esd-ext-config");
393
+ let c = null;
334
394
  try {
335
- n = i ? JSON.parse(i) : null;
395
+ c = n ? JSON.parse(n) : null;
336
396
  } catch {
337
397
  }
338
- if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
398
+ if (!c || (!a.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(c.priceHideDiscount)), i = !0), a.getAttribute("data-type")))
339
399
  return;
340
- const e = n.type || n.source;
341
- if (!e)
400
+ const r = c.type || c.source;
401
+ if (!r)
342
402
  return;
343
- a.setAttribute("data-type", e), c = !0;
344
- const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
403
+ a.setAttribute("data-type", r), i = !0;
404
+ const l = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
345
405
  l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
346
- }), c ? r.documentElement.outerHTML : t;
406
+ }), i ? e.documentElement.outerHTML : t;
347
407
  }
348
408
  /**
349
409
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -364,15 +424,15 @@ class H {
364
424
  * contains display condition Jinja scripts that should NOT be removed.
365
425
  */
366
426
  removeJinjaConditionals(t) {
367
- const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
368
- let a = c ? t.replace(c[0], r) : t;
427
+ const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", i = t.match(/esd-custom-display-conditions="[^"]*"/);
428
+ let a = i ? t.replace(i[0], e) : t;
369
429
  return a = a.replace(
370
430
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
371
431
  ""
372
432
  ), a = a.replace(
373
433
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
374
434
  ""
375
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
435
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), i && (a = a.replace(e, i[0])), a = a.replace(/\n\s*\n\s*\n/g, `
376
436
 
377
437
  `), a;
378
438
  }
@@ -386,32 +446,32 @@ class H {
386
446
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
447
  */
388
448
  replaceTemplateVariables(t) {
389
- const { PAIRS_FOR_EXTENSION: r } = K;
390
- return t.replace(/{{([^}]+)}}/g, (c, a) => {
391
- const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
392
- if (!i)
393
- return c;
394
- const [, n, e, l] = i, u = V[n];
449
+ const { PAIRS_FOR_EXTENSION: e } = F;
450
+ return t.replace(/{{([^}]+)}}/g, (i, a) => {
451
+ const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
452
+ if (!n)
453
+ return i;
454
+ const [, c, r, l] = n, u = H[c];
395
455
  if (!u)
396
- return console.warn(`Unknown variable prefix: ${n}`), c;
397
- const s = x[e];
398
- if (!s)
399
- return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
400
- const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
401
- if (!y)
402
- return console.warn(`No data found for: ${_}.${u}`), c;
403
- if (b) {
404
- const f = parseInt(l) - 1, m = y[d];
405
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
456
+ return console.warn(`Unknown variable prefix: ${c}`), i;
457
+ const d = x[r];
458
+ if (!d)
459
+ return console.warn(`Unknown variable suffix mapping for: ${r}`), i;
460
+ const { pairsKey: _, defaultKey: s, isArray: A } = d, m = e[_][u];
461
+ if (!m)
462
+ return console.warn(`No data found for: ${_}.${u}`), i;
463
+ if (A) {
464
+ const y = parseInt(l) - 1, b = m[s];
465
+ return Array.isArray(b) && b[y] ? b[y] : (console.warn(`Array value not found: ${_}.${u}.${s}[${y}]`), i);
406
466
  }
407
- const A = y[d];
408
- return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
467
+ const g = m[s];
468
+ return g !== void 0 ? String(g) : (console.warn(`Default value not found: ${_}.${u}.${s}`), i);
409
469
  });
410
470
  }
411
471
  }
412
- function Q(o) {
413
- return new H().migrate(o);
472
+ function tt(o) {
473
+ return new Y().migrate(o);
414
474
  }
415
475
  export {
416
- Q as migrateItemsBlock
476
+ tt as migrateItemsBlock
417
477
  };
@@ -1,34 +1,34 @@
1
1
  import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
- import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
- import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
4
- const C = "__title__", a = "product_attribute.";
5
- function N(r) {
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
6
  const t = r.variable ?? "";
7
7
  switch (t) {
8
8
  case "p_recommendation_title":
9
9
  return { key: C, kind: "title" };
10
10
  case "p_image":
11
- return { key: y, kind: "image" };
11
+ return { key: O, kind: "image" };
12
12
  case "p_name":
13
- return { key: h, kind: "text" };
13
+ return { key: E, kind: "text" };
14
14
  case "p_price":
15
- return { key: R, kind: "text" };
15
+ return { key: h, kind: "text" };
16
16
  case "p_original_price":
17
17
  return { key: f, kind: "text" };
18
18
  case "p_omnibus_price":
19
19
  return { key: x, kind: "text" };
20
20
  case "p_omnibus_discount":
21
- return { key: A, kind: "text" };
21
+ return { key: R, kind: "text" };
22
22
  case "p_button":
23
- return { key: k, kind: "button" };
23
+ return { key: A, kind: "button" };
24
24
  default:
25
25
  if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const o = r.value ?? "", s = o.startsWith(a) ? o.slice(a.length) : o;
26
+ const o = r.value ?? "", s = o.startsWith(T) ? o.slice(T.length) : o;
27
27
  if (!s)
28
28
  return null;
29
- const e = o || `${a}${s}`;
29
+ const e = o || `${T}${s}`;
30
30
  return {
31
- key: `${l}${e}`,
31
+ key: `${k}${e}`,
32
32
  kind: "custom",
33
33
  customAttrName: s,
34
34
  customAttrValue: e
@@ -41,7 +41,7 @@ function _(r) {
41
41
  const t = p.indexOf(r);
42
42
  return t === -1 ? Number.POSITIVE_INFINITY : t;
43
43
  }
44
- function S(r) {
44
+ function V(r) {
45
45
  const t = {
46
46
  composition: [],
47
47
  visibility: { ...I },
@@ -54,10 +54,10 @@ function S(r) {
54
54
  return t.composition = [...p], t;
55
55
  const o = [];
56
56
  r.forEach((e, i) => {
57
- const n = N(e);
57
+ const n = P(e);
58
58
  if (n) {
59
59
  if (n.kind === "title") {
60
- t.titleVariable = e;
60
+ t.titleVariable = e, t.visibility[l] = e.hidden !== !0;
61
61
  return;
62
62
  }
63
63
  o.push({
@@ -82,20 +82,20 @@ function S(r) {
82
82
  const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
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) {
84
84
  case "image":
85
- s[i] = b(c.theme);
85
+ s[i] = N(c.theme);
86
86
  break;
87
87
  case "button":
88
- s[i] = O(c.theme);
88
+ s[i] = y(c.theme);
89
89
  break;
90
90
  case "text":
91
91
  case "custom": {
92
- const T = E(c.theme);
93
- s[i] = T, T.textTrimming && (t.anyTextTrimming = !0);
92
+ const a = b(c.theme);
93
+ s[i] = a, a.textTrimming && (t.anyTextTrimming = !0);
94
94
  break;
95
95
  }
96
96
  }
97
97
  }), t.perElementStyles = s, t;
98
98
  }
99
99
  export {
100
- S as mapComposition
100
+ V as mapComposition
101
101
  };
@@ -1,49 +1,54 @@
1
1
  import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
2
  const a = "You May Also Like!";
3
- function l(t) {
4
- var o;
5
- const r = t.querySelector(".ext-recommendation-title");
6
- if (!r)
3
+ function A(t) {
4
+ var i;
5
+ const e = t.querySelector(".ext-recommendation-title");
6
+ if (!e)
7
7
  return a;
8
- const e = (o = r.textContent) == null ? void 0 : o.trim();
9
- return e && e.length > 0 ? e : a;
8
+ const r = (i = e.textContent) == null ? void 0 : i.trim();
9
+ return r && r.length > 0 ? r : a;
10
10
  }
11
11
  function m(t) {
12
- const r = [
12
+ const e = t.querySelector(".ext-recommendation-title");
13
+ return e ? !/display\s*:\s*none/i.test(e.getAttribute("style") ?? "") : !1;
14
+ }
15
+ function d(t) {
16
+ const e = [
13
17
  t,
14
18
  ...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
15
19
  ];
16
- let e = "";
17
- return r.some((o) => {
18
- const i = o.getAttribute("bgcolor");
19
- if (i && i.trim())
20
- return e = i.trim(), !0;
21
- const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
22
- return u && u[1] ? (e = u[1].trim(), !0) : !1;
23
- }), e;
20
+ let r = "";
21
+ return e.some((i) => {
22
+ const o = i.getAttribute("bgcolor");
23
+ 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;
24
28
  }
25
29
  function C(t) {
26
- const r = t.getAttribute(n.CURRENCY);
27
- if (!r)
30
+ const e = t.getAttribute(n.CURRENCY);
31
+ if (!e)
28
32
  return;
29
- const e = t.getAttribute(n.SYMBOL);
33
+ const r = t.getAttribute(n.SYMBOL);
30
34
  return {
31
- value: r,
35
+ value: e,
32
36
  // An empty `currency-symbol` is omitted so `mapCurrency` falls back to
33
37
  // the currency code as the symbol.
34
- ...e ? { symbol: e } : {},
38
+ ...r ? { symbol: r } : {},
35
39
  alignment: t.getAttribute(n.ALIGNMENT) ?? "",
36
40
  decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
37
41
  decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
38
42
  thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
39
43
  };
40
44
  }
41
- function d(t) {
45
+ function g(t) {
42
46
  return t.classList.contains(c);
43
47
  }
44
48
  export {
45
- m as extractCardBgColor,
49
+ d as extractCardBgColor,
46
50
  C as extractCurrencyFromBlock,
47
- l as extractTitleText,
48
- d as isPartnerManagedBlock
51
+ A as extractTitleText,
52
+ m as hasVisibleTitle,
53
+ g as isPartnerManagedBlock
49
54
  };