@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.
- package/dist/@types/config/schemas.js +104 -91
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +96 -85
- package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
- package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
- package/dist/components/wrappers/WpModal.vue.js +1 -1
- package/dist/components/wrappers/WpModal.vue2.js +4 -3
- package/dist/composables/useAuthError.js +52 -0
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/composables/useHttp.js +64 -54
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/composables/useStripo.js +24 -20
- package/dist/composables/useToaster.js +17 -15
- package/dist/composables/validators/useLiquidValidator.js +15 -15
- package/dist/config/compiler/itemsCompilerRules.js +14 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +48 -21
- package/dist/config/migrator/index.js +14 -13
- package/dist/config/migrator/itemsBlockMigrator.js +245 -253
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
- package/dist/enums/extensions/recommendationBlock.js +30 -29
- package/dist/extensions/Blocks/Items/block.js +78 -67
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/block.js +21 -22
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +97 -107
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +203 -209
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +67 -91
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +21 -26
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +16 -55
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
- package/dist/src/composables/useAuthError.d.ts +12 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/composables/useHttp.d.ts +2 -0
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -13
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -7
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/config.d.ts +20 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
|
@@ -1,154 +1,86 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import {
|
|
6
|
-
import { ItemInCartOptions as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
80
|
-
return
|
|
81
|
-
CartItems:
|
|
82
|
-
BrowsedItems:
|
|
83
|
-
PurchasedItems:
|
|
84
|
-
CART_ITEMS:
|
|
85
|
-
BROWSED_ITEMS:
|
|
86
|
-
PURCHASED_ITEMS:
|
|
87
|
-
}[
|
|
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
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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:
|
|
100
|
-
source:
|
|
101
|
-
type:
|
|
102
|
-
itemsSelectValue:
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
110
|
-
|
|
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:
|
|
113
|
-
|
|
114
|
-
|
|
49
|
+
priceCurrencyLocation: e(
|
|
50
|
+
n["data-product_price_currency_location"],
|
|
51
|
+
b.productPriceCurrencyLocationControlValue
|
|
115
52
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink:
|
|
119
|
-
imageLink:
|
|
120
|
-
buttonLabel:
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
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
|
-
|
|
131
|
-
|
|
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
|
|
73
|
+
return e[n] || e.CART_ITEMS;
|
|
142
74
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
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
|
|
81
|
+
return e[n] || e.CART_ITEMS;
|
|
150
82
|
}
|
|
151
|
-
class
|
|
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
|
-
|
|
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
|
|
166
|
-
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
orientation:
|
|
170
|
-
itemsType:
|
|
171
|
-
itemId:
|
|
172
|
-
currencySymbol:
|
|
173
|
-
currencyLocation:
|
|
174
|
-
formattedPrice:
|
|
175
|
-
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:
|
|
178
|
-
buttonStyles:
|
|
179
|
-
priceStyles:
|
|
180
|
-
originalPriceStyles:
|
|
181
|
-
quantityStyles:
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
184
|
-
`<table><tbody><tr>${
|
|
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 (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
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
|
-
}),
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
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
|
|
206
|
-
const
|
|
207
|
-
(
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
|
|
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:
|
|
215
|
-
itemId:
|
|
216
|
-
currencySymbol:
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
219
|
-
configBlockAttributes:
|
|
220
|
-
nameStyles:
|
|
221
|
-
buttonStyles:
|
|
222
|
-
priceStyles:
|
|
223
|
-
originalPriceStyles:
|
|
224
|
-
quantityStyles:
|
|
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,
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
248
|
-
|
|
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
|
|
329
|
-
let
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
359
|
+
c = u ? JSON.parse(u) : null;
|
|
336
360
|
} catch {
|
|
337
361
|
}
|
|
338
|
-
if (!
|
|
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
|
|
341
|
-
if (!
|
|
364
|
+
const o = c.type || c.source;
|
|
365
|
+
if (!o)
|
|
342
366
|
return;
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
}),
|
|
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
|
|
368
|
-
let
|
|
369
|
-
return
|
|
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*(>|>)\s*\d+\s*%\}/g,
|
|
371
395
|
""
|
|
372
|
-
),
|
|
396
|
+
), r = r.replace(
|
|
373
397
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
374
398
|
""
|
|
375
|
-
),
|
|
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
|
-
`),
|
|
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
|
|
413
|
-
return new
|
|
404
|
+
function X(n) {
|
|
405
|
+
return new z().migrate(n);
|
|
414
406
|
}
|
|
415
407
|
export {
|
|
416
|
-
|
|
408
|
+
X as migrateItemsBlock
|
|
417
409
|
};
|