@useinsider/guido 3.19.0 → 3.20.0-beta.0849ec7

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