@useinsider/guido 3.19.0-beta.e110e88 → 3.19.0-beta.e424587

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 (81) hide show
  1. package/dist/@types/config/schemas.js +104 -91
  2. package/dist/components/Guido.vue.js +6 -6
  3. package/dist/components/Guido.vue2.js +96 -85
  4. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  5. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  6. package/dist/components/wrappers/WpModal.vue.js +1 -1
  7. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  8. package/dist/composables/useAuthError.js +52 -0
  9. package/dist/composables/useAutoSave.js +11 -11
  10. package/dist/composables/useCortexBlueprintBridge.js +122 -54
  11. package/dist/composables/useEmailTemplateApplier.js +111 -50
  12. package/dist/composables/useHttp.js +64 -54
  13. package/dist/composables/useLegacyStrategyConversion.js +23 -19
  14. package/dist/composables/useStripo.js +24 -20
  15. package/dist/composables/useToaster.js +17 -15
  16. package/dist/composables/validators/useLiquidValidator.js +15 -15
  17. package/dist/config/compiler/itemsCompilerRules.js +14 -5
  18. package/dist/config/compiler/utils/itemsCompilerUtils.js +48 -21
  19. package/dist/config/migrator/index.js +14 -13
  20. package/dist/config/migrator/itemsBlockMigrator.js +245 -253
  21. package/dist/config/migrator/recommendationMigrator.js +28 -21
  22. package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
  23. package/dist/enums/extensions/recommendationBlock.js +30 -29
  24. package/dist/extensions/Blocks/Items/block.js +78 -67
  25. package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
  26. package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
  27. package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
  28. package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
  29. package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
  30. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
  31. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
  32. package/dist/extensions/Blocks/Items/template.js +219 -204
  33. package/dist/extensions/Blocks/Recommendation/block.js +21 -22
  34. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +97 -107
  35. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  36. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +203 -209
  37. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +67 -91
  38. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +21 -26
  39. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
  40. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  41. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +16 -55
  42. package/dist/guido.css +1 -1
  43. package/dist/src/@types/config/schemas.d.ts +16 -0
  44. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  45. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  46. package/dist/src/composables/useAuthError.d.ts +12 -0
  47. package/dist/src/composables/useConfig.d.ts +2 -0
  48. package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
  49. package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
  50. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  51. package/dist/src/composables/useHttp.d.ts +2 -0
  52. package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
  53. package/dist/src/config/migrator/index.d.ts +2 -1
  54. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  55. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  56. package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
  57. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
  58. package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
  59. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  60. package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
  61. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
  62. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -13
  63. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  64. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +1 -3
  65. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  66. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -7
  67. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  68. package/dist/src/stores/config.d.ts +20 -0
  69. package/dist/src/stores/guido-email-editor.d.ts +20 -10
  70. package/dist/src/stores/onboarding.d.ts +4 -0
  71. package/dist/src/stores/recommendation.d.ts +5 -0
  72. package/dist/src/utils/dateUtil.d.ts +10 -0
  73. package/dist/src/utils/genericUtil.d.ts +3 -0
  74. package/dist/src/utils/liquidProtection.d.ts +3 -0
  75. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  76. package/dist/static/styles/components/version-history.css.js +2 -6
  77. package/dist/stores/guido-email-editor.js +3 -1
  78. package/dist/stores/onboarding.js +4 -0
  79. package/dist/utils/liquidProtection.js +5 -0
  80. package/dist/utils/pairProductVariables.js +71 -71
  81. package/package.json +1 -1
@@ -1,154 +1,86 @@
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";
9
- const x = {
10
- img: {
11
- pairsKey: "imageSrc",
12
- defaultKey: "DEFAULT",
13
- isArray: !0
14
- },
15
- name: {
16
- pairsKey: "name",
17
- defaultKey: "DEFAULT",
18
- isArray: !0
19
- },
20
- url: {
21
- pairsKey: "button",
22
- defaultKey: "DEFAULT_HREF",
23
- isArray: !1
24
- },
25
- formattedprice: {
26
- pairsKey: "price",
27
- defaultKey: "DEFAULT_PRICE_FORMATTED",
28
- isArray: !1
29
- },
30
- productcurrency: {
31
- pairsKey: "price",
32
- defaultKey: "DEFAULT_CURRENCY",
33
- isArray: !1
34
- },
35
- quantity: {
36
- pairsKey: "quantity",
37
- defaultKey: "DEFAULT",
38
- isArray: !1
39
- },
40
- price: {
41
- pairsKey: "price",
42
- defaultKey: "DEFAULT_PRICE",
43
- isArray: !1
44
- },
45
- originalprice: {
46
- pairsKey: "originalPrice",
47
- defaultKey: "DEFAULT_PRICE",
48
- isArray: !1
49
- },
50
- originalformattedprice: {
51
- pairsKey: "originalPrice",
52
- defaultKey: "DEFAULT_PRICE_FORMATTED",
53
- isArray: !1
54
- },
55
- single_price: {
56
- pairsKey: "price",
57
- defaultKey: "DEFAULT_SINGLE_PRICE",
58
- isArray: !1
59
- },
60
- single_formattedprice: {
61
- pairsKey: "price",
62
- defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
63
- isArray: !1
64
- },
65
- single_originalprice: {
66
- pairsKey: "originalPrice",
67
- defaultKey: "DEFAULT_SINGLE_PRICE",
68
- isArray: !1
69
- },
70
- single_originalformattedprice: {
71
- pairsKey: "originalPrice",
72
- defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
73
- isArray: !1
74
- }
75
- };
76
- function O() {
1
+ var B = Object.defineProperty;
2
+ var v = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var M = (n, t, e) => v(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as R } from "../../extensions/Blocks/Items/block.js";
5
+ import { hasZeroWidthDeclaration as L, withoutZeroWidth as x } from "../../extensions/Blocks/Items/constants/cardWidth.js";
6
+ import { ItemInCartOptions as h, DefaultConfigValues as b, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as V } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as O } from "../../stores/template.js";
9
+ import { protectLiquid as H, restoreLiquid as $ } from "../../utils/liquidProtection.js";
10
+ function F() {
77
11
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
12
  }
79
- function k(o) {
80
- return o ? {
81
- CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
- BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
83
- PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
84
- CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
85
- BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
86
- PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
- }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
13
+ function D(n) {
14
+ return n ? {
15
+ CartItems: _.ITEMS_TYPE.CART_ITEMS,
16
+ BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
17
+ PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
18
+ CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
19
+ BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
20
+ PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
21
+ }[n] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
88
22
  }
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);
23
+ function U(n) {
24
+ return n.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : n.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
25
+ }
26
+ function P(n) {
27
+ var o;
28
+ const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d, a = n["data-type"] || n["data-source"], r = D(a), u = h[r];
29
+ let c = n["data-cart_items_select_control_value"] || ((o = u == null ? void 0 : u[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
30
+ if (c && !c.includes("{{") && /^\d+$/.test(c)) {
31
+ const i = parseInt(c) - 1, d = h[r];
32
+ d && d[i] && (c = d[i].value);
96
33
  }
97
34
  return {
98
35
  initialized: !0,
99
- blockInstanceId: r(o["data-block-instance-id"], O()),
100
- source: a,
101
- type: a,
102
- itemsSelectValue: n,
103
- orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
104
- nameTrimming: t(o["data-product_name_control_trim"], !0),
105
- priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
106
- priceFormatted: t(o["data-product_price_control_formated"], !0),
107
- priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
108
- priceCurrencySymbol: r(
109
- o["data-product_price_control_currency_symbol"],
110
- g.productPriceCurrencySymbolControlValue
36
+ blockInstanceId: e(n["data-block-instance-id"], F()),
37
+ source: r,
38
+ type: r,
39
+ itemsSelectValue: c,
40
+ orientation: n["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
41
+ nameTrimming: t(n["data-product_name_control_trim"], !0),
42
+ priceHideDiscount: t(n["data-product_price_control_nodup"], !0),
43
+ priceFormatted: t(n["data-product_price_control_formated"], !0),
44
+ priceSinglePrice: t(n["data-product_price_control_single_price"], !1),
45
+ priceCurrencySymbol: e(
46
+ n["data-product_price_control_currency_symbol"],
47
+ b.productPriceCurrencySymbolControlValue
111
48
  ),
112
- priceCurrencyLocation: r(
113
- o["data-product_price_currency_location"],
114
- g.productPriceCurrencyLocationControlValue
49
+ priceCurrencyLocation: e(
50
+ n["data-product_price_currency_location"],
51
+ b.productPriceCurrencyLocationControlValue
115
52
  ),
116
- priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
117
- 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
- buttonFullWidth: t(o["data-product_button_control_atw"], !0),
122
- imageVisible: t(o["data-product_image_control_enabled"], !0),
123
- nameVisible: t(o["data-product_name_control_enabled"], !0),
124
- quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
125
- priceVisible: t(o["data-product_price_control_enabled"], !0),
126
- originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
127
- buttonVisible: t(o["data-product_button_control_enabled"], !0)
53
+ priceOrientation: n["data-product_original_price_control_orientation"] || "horizontal",
54
+ quantityControlEnabled: t(n["data-product_quantity_control_enabled"], !0),
55
+ buttonLink: e(n["data-product_button_link"], b.productButtonLinkControlValue),
56
+ imageLink: e(n["data-product_image_link"], b.productImageLinkControlValue),
57
+ buttonLabel: e(n["data-product_button_control_label"], "Buy"),
58
+ buttonFullWidth: t(n["data-product_button_control_atw"], !0),
59
+ imageVisible: t(n["data-product_image_control_enabled"], !0),
60
+ nameVisible: t(n["data-product_name_control_enabled"], !0),
61
+ quantityVisible: t(n["data-product_quantity_control_enabled"], !0),
62
+ priceVisible: t(n["data-product_price_control_enabled"], !0),
63
+ originalPriceVisible: t(n["data-product_original_price_control_enabled"], !0),
64
+ buttonVisible: t(n["data-product_button_control_enabled"], !0)
128
65
  };
129
66
  }
130
- const V = {
131
- ins_apr: "CART_ITEMS",
132
- browsed_item: "BROWSED_ITEMS",
133
- purchased_item: "PURCHASED_ITEMS"
134
- };
135
- function $(o, t) {
136
- const r = {
67
+ function Y(n, t) {
68
+ const e = {
137
69
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
138
70
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
139
71
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
140
72
  };
141
- return r[o] || r.CART_ITEMS;
73
+ return e[n] || e.CART_ITEMS;
142
74
  }
143
- function N(o, t) {
144
- const r = {
75
+ function W(n, t) {
76
+ const e = {
145
77
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
146
78
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
147
79
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
148
80
  };
149
- return r[o] || r.CART_ITEMS;
81
+ return e[n] || e.CART_ITEMS;
150
82
  }
151
- class H {
83
+ class z {
152
84
  constructor() {
153
85
  M(this, "parser");
154
86
  this.parser = new DOMParser();
@@ -157,42 +89,40 @@ class H {
157
89
  try {
158
90
  if (!this.containsItemsBlock(t))
159
91
  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(
92
+ const e = this.removeJinjaConditionals(t), a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
163
93
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
94
  );
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,
95
+ return O().$patch((c) => {
96
+ c.migrations = { ...c.migrations, [R]: r.length };
97
+ }), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e)) : (r.forEach((c) => {
98
+ const o = this.extractConfiguration(c), i = V({
99
+ orientation: o.orientation,
100
+ itemsType: o.itemsType,
101
+ itemId: o.itemId,
102
+ currencySymbol: o.currencySymbol,
103
+ currencyLocation: o.currencyLocation,
104
+ formattedPrice: o.formattedPrice,
105
+ configBlockAttributes: o.configBlockAttributes,
176
106
  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(
184
- `<table><tbody><tr>${l}</tr></tbody></table>`,
107
+ nameStyles: o.nameStyles,
108
+ buttonStyles: o.buttonStyles,
109
+ priceStyles: o.priceStyles,
110
+ originalPriceStyles: o.originalPriceStyles,
111
+ quantityStyles: o.quantityStyles,
112
+ nodeConfig: P(o.configBlockAttributes)
113
+ }), l = this.parser.parseFromString(
114
+ `<table><tbody><tr>${i}</tr></tbody></table>`,
185
115
  "text/html"
186
116
  ).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);
117
+ if (l && c.parentNode) {
118
+ const s = P(o.configBlockAttributes);
119
+ l.setAttribute("esd-ext-config", JSON.stringify(s)), l.setAttribute("data-type", s.type);
120
+ const p = l.querySelector("esd-config-block");
121
+ p && p.remove(), c.parentNode.replaceChild(l, c);
192
122
  }
193
- }), c.documentElement.outerHTML);
194
- } catch (r) {
195
- return console.error("ItemsBlockMigrator failed:", r), t;
123
+ }), this.backfillV2ProductTdAttributes(a.documentElement.outerHTML));
124
+ } catch (e) {
125
+ return console.error("ItemsBlockMigrator failed:", e), t;
196
126
  }
197
127
  }
198
128
  /**
@@ -202,28 +132,118 @@ class H {
202
132
  * - UI styles from product elements (name, price, button, quantity, etc.)
203
133
  */
204
134
  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;
135
+ var C;
136
+ const e = D(
137
+ this.readSelfOrDescendantAttribute(t, "data-type") || U(t)
138
+ ), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, u = h[e], c = ((C = u == null ? void 0 : u[r]) == null ? void 0 : C.value) || u[0].value, o = this.extractConfigBlockAttributes(t, e, a);
139
+ this.applyDomFallbacks(t, o);
140
+ const i = t.querySelector('[product-attr="price"]'), d = o["data-product_price_control_currency_symbol"], l = o["data-product_price_currency_location"] || "0", s = o["data-product_price_control_formated"], p = s !== "false" && s !== "0", S = o["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", f = t.querySelector('a[product-attr="name"]'), y = (f == null ? void 0 : f.getAttribute("style")) || void 0, g = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (g == null ? void 0 : g.getAttribute("style")) || void 0, k = (i == null ? void 0 : i.getAttribute("style")) || void 0, m = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), A = m != null && m.getAttribute("style") ? m : (m == null ? void 0 : m.closest("p")) ?? m, q = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), w = (E == null ? void 0 : E.getAttribute("style")) || void 0;
212
141
  return {
213
142
  orientation: S,
214
- itemsType: r,
215
- itemId: n,
216
- currencySymbol: l,
217
- currencyLocation: s,
218
- formattedPrice: _,
219
- configBlockAttributes: d,
220
- nameStyles: A,
221
- buttonStyles: m,
222
- priceStyles: R,
223
- originalPriceStyles: L,
224
- quantityStyles: B
143
+ itemsType: e,
144
+ itemId: c,
145
+ currencySymbol: d,
146
+ currencyLocation: l,
147
+ formattedPrice: p,
148
+ configBlockAttributes: o,
149
+ nameStyles: y,
150
+ buttonStyles: I,
151
+ priceStyles: k,
152
+ originalPriceStyles: q,
153
+ quantityStyles: w
154
+ };
155
+ }
156
+ /**
157
+ * DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
158
+ * the keys it ACTUALLY carries — every other key follows the live markup, whether the block
159
+ * was deleted outright or (far more common) survives carrying only a couple of `_opened`
160
+ * attributes. Without the per-key split, one such stub block shadows the whole DOM and the
161
+ * card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
162
+ */
163
+ applyDomFallbacks(t, e) {
164
+ var S, f;
165
+ const a = t.querySelector("esd-config-block"), r = (...y) => !a || y.every((g) => !(a.getAttribute(g) ?? "").trim());
166
+ Object.entries({
167
+ image: '[product-attr="imageSrc"]',
168
+ name: '[product-attr="name"]',
169
+ price: '[product-attr="price"]',
170
+ original_price: '[product-attr="originalPrice"], p.original-price',
171
+ quantity: '[product-attr="quantity"]',
172
+ button: '[product-attr="button"]'
173
+ }).forEach(([y, g]) => {
174
+ const I = `data-product_${y}_control_enabled`;
175
+ r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
176
+ }), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
177
+ const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = c == null ? void 0 : c.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
178
+ o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
179
+ const i = (c == null ? void 0 : c.getAttribute("style")) || "";
180
+ r("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
181
+ const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : null, s = (l == null ? void 0 : l.height) ?? (l == null ? void 0 : l.width), p = (l == null ? void 0 : l.width) ?? (l == null ? void 0 : l.height);
182
+ s && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), p && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, r);
183
+ const T = ((f = t.querySelector('[product-attr="name"]')) == null ? void 0 : f.getAttribute("style")) || "";
184
+ r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
185
+ }
186
+ /**
187
+ * Carries the price cell's own currency/format attributes into the config attributes when
188
+ * the config block omits them. extractConfiguration used to read the cell separately for the
189
+ * rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
190
+ * ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
191
+ * the default back over the real value.
192
+ */
193
+ applyPriceDomFallbacks(t, e, a) {
194
+ var d;
195
+ const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
196
+ if (!r)
197
+ return;
198
+ const u = (d = r.getAttribute("data-currency_symbol")) == null ? void 0 : d.trim();
199
+ u && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = u);
200
+ const c = r.getAttribute("data-curency");
201
+ if (c && a("data-product_price_currency_location", "data-product_price_control_curency")) {
202
+ const l = c === "after" ? "1" : "0";
203
+ e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
204
+ }
205
+ const o = r.getAttribute("data-formated");
206
+ o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
207
+ const i = r.getAttribute("data-single_price");
208
+ i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
209
+ }
210
+ /**
211
+ * Reads an attribute from the block element itself before falling back to a descendant.
212
+ * Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
213
+ * esd-config-block; when an author deletes the config block only the td's copy survives.
214
+ */
215
+ readSelfOrDescendantAttribute(t, e) {
216
+ var a;
217
+ return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
218
+ }
219
+ /**
220
+ * Reads the product image's pixel size — `width`/`height` attributes first, then px values
221
+ * in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
222
+ * upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
223
+ * be read from the property itself. Each side is null when it carries no pixel size.
224
+ */
225
+ readImageSize(t) {
226
+ return {
227
+ width: this.readImageDimension(t, "width"),
228
+ height: this.readImageDimension(t, "height")
225
229
  };
226
230
  }
231
+ /**
232
+ * One side of readImageSize. `width="0"` is not a size — authors who override the real
233
+ * dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
234
+ * to nothing, so only a positive integer counts as an answer.
235
+ */
236
+ readImageDimension(t, e) {
237
+ var d;
238
+ const a = (l) => {
239
+ const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
240
+ return p > 0 ? String(p) : null;
241
+ }, r = a((d = t.getAttribute(e)) == null ? void 0 : d.trim());
242
+ if (r)
243
+ return r;
244
+ const u = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = u.match(c) || u.match(o);
245
+ return a(i == null ? void 0 : i[1]);
246
+ }
227
247
  /**
228
248
  * Extracts all data-* attributes from the esd-config-block element
229
249
  * Returns a key-value mapping of all configuration attributes
@@ -231,27 +251,27 @@ class H {
231
251
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
232
252
  * @param itemNumber - The item number (1-based index)
233
253
  */
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);
254
+ extractConfigBlockAttributes(t, e, a) {
255
+ const r = t.querySelector("esd-config-block"), u = {};
256
+ if (r) {
257
+ if (Array.from(r.attributes).forEach((o) => {
258
+ o.name.startsWith("data-") && (u[o.name] = o.value);
259
+ }), u["data-cart_items_select_control_value"]) {
260
+ const o = u["data-cart_items_select_control_value"];
261
+ if (/^\d+$/.test(o)) {
262
+ const i = parseInt(o) - 1, d = h[e];
263
+ d && d[i] && (u["data-cart_items_select_control_value"] = d[i].value);
264
+ }
245
265
  }
266
+ if (u["data-product_price_control_curency"]) {
267
+ const o = u["data-product_price_control_curency"];
268
+ let i = o;
269
+ o === "before" ? i = "0" : o === "after" && (i = "1"), u["data-product_price_control_curency"] = i, u["data-product_price_currency_location"] = i;
270
+ }
271
+ (!u["data-product_price_control_currency_symbol"] || u["data-product_price_control_currency_symbol"].trim() === "") && (u["data-product_price_control_currency_symbol"] = "USD");
246
272
  }
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;
273
+ const c = { ...this.getDefaultConfigBlockAttributes(), ...u };
274
+ return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = Y(e, a), c["data-product_button_link"] = W(e, a), c;
255
275
  }
256
276
  /**
257
277
  * Returns default esd-config-block attributes based on the old template structure
@@ -325,25 +345,29 @@ class H {
325
345
  backfillV2ProductTdAttributes(t) {
326
346
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
347
  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;
348
+ const e = this.parser.parseFromString(H(t), "text/html");
349
+ let a = !1;
350
+ return e.querySelectorAll(".ins-product-td").forEach((r) => {
351
+ r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0), r.querySelectorAll("table.ins-product-wrapper").forEach((d) => {
352
+ d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), a = !0);
353
+ const l = d.getAttribute("style");
354
+ l && L(l) && (d.setAttribute("style", x(l)), d.setAttribute("width", "100%"), a = !0);
355
+ });
356
+ const u = r.getAttribute("esd-ext-config");
357
+ let c = null;
334
358
  try {
335
- n = i ? JSON.parse(i) : null;
359
+ c = u ? JSON.parse(u) : null;
336
360
  } catch {
337
361
  }
338
- if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
362
+ if (!c || (!r.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(c.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
339
363
  return;
340
- const e = n.type || n.source;
341
- if (!e)
364
+ const o = c.type || c.source;
365
+ if (!o)
342
366
  return;
343
- a.setAttribute("data-type", e), c = !0;
344
- const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
345
- l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
346
- }), c ? r.documentElement.outerHTML : t;
367
+ r.setAttribute("data-type", o), a = !0;
368
+ const i = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
369
+ i && r.getAttribute("data-number") !== i[1] && r.setAttribute("data-number", i[1]);
370
+ }), a ? $(e.documentElement.outerHTML) : t;
347
371
  }
348
372
  /**
349
373
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -364,54 +388,22 @@ class H {
364
388
  * contains display condition Jinja scripts that should NOT be removed.
365
389
  */
366
390
  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;
369
- return a = a.replace(
391
+ const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
392
+ let r = a ? t.replace(a[0], e) : t;
393
+ return r = r.replace(
370
394
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
371
395
  ""
372
- ), a = a.replace(
396
+ ), r = r.replace(
373
397
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
374
398
  ""
375
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
399
+ ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
376
400
 
377
- `), a;
378
- }
379
- /**
380
- * Replaces template variables with default values from productPairs
381
- * Supports all block types by detecting prefix and using appropriate type:
382
- *
383
- * Examples:
384
- * - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
385
- * - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
386
- * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
- */
388
- 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];
395
- 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);
406
- }
407
- const A = y[d];
408
- return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
409
- });
401
+ `), r;
410
402
  }
411
403
  }
412
- function Q(o) {
413
- return new H().migrate(o);
404
+ function X(n) {
405
+ return new z().migrate(n);
414
406
  }
415
407
  export {
416
- Q as migrateItemsBlock
408
+ X as migrateItemsBlock
417
409
  };