@useinsider/guido 3.17.0-beta.77567eb → 3.17.0-beta.a51375c
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/README.md +5 -5
- package/dist/config/migrator/itemsBlockMigrator.js +194 -150
- package/dist/extensions/Blocks/Items/block.js +98 -49
- package/dist/extensions/Blocks/Items/constants/currency.js +11 -0
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
- package/dist/extensions/Blocks/Items/enums/productEnums.js +5 -5
- package/dist/extensions/Blocks/Items/template.js +196 -195
- package/dist/package.json.js +1 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +21 -0
- package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +19 -0
- package/dist/utils/pairProductVariables.js +60 -59
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -633,16 +633,16 @@ toaster fires (useful before the host has wired the catalog).
|
|
|
633
633
|
|
|
634
634
|
```bash
|
|
635
635
|
# Install
|
|
636
|
-
|
|
636
|
+
bun install
|
|
637
637
|
|
|
638
638
|
# Start dev server
|
|
639
|
-
|
|
639
|
+
bun start
|
|
640
640
|
|
|
641
641
|
# Build
|
|
642
|
-
|
|
642
|
+
bun run build
|
|
643
643
|
|
|
644
644
|
# Lint & type-check
|
|
645
|
-
|
|
645
|
+
bun run lint
|
|
646
646
|
```
|
|
647
647
|
|
|
648
648
|
### Environment Variables
|
|
@@ -660,7 +660,7 @@ VITE_STRIPO_USER=your_user
|
|
|
660
660
|
|
|
661
661
|
```bash
|
|
662
662
|
# Build the package
|
|
663
|
-
|
|
663
|
+
bun run build
|
|
664
664
|
|
|
665
665
|
# Create tarball
|
|
666
666
|
npm pack
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var U = (
|
|
3
|
-
var M = (
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { productPairs as
|
|
6
|
-
import { ItemInCartOptions as
|
|
7
|
-
import { getDefaultTemplate as
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
const
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var U = (a, t, e) => t in a ? q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
|
|
3
|
+
var M = (a, t, e) => U(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as K } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as F } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as A, DefaultConfigValues as b, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as x } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as $ } from "../../stores/template.js";
|
|
9
|
+
const O = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
12
12
|
defaultKey: "DEFAULT",
|
|
@@ -73,82 +73,82 @@ const x = {
|
|
|
73
73
|
isArray: !1
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function V() {
|
|
77
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
78
78
|
}
|
|
79
|
-
function k(
|
|
80
|
-
return
|
|
79
|
+
function k(a) {
|
|
80
|
+
return a ? {
|
|
81
81
|
CartItems: p.ITEMS_TYPE.CART_ITEMS,
|
|
82
82
|
BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
83
|
PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
84
|
CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
|
|
85
85
|
BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
86
|
PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
-
}[
|
|
87
|
+
}[a] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
var
|
|
91
|
-
const t = (
|
|
92
|
-
let n =
|
|
89
|
+
function R(a) {
|
|
90
|
+
var o;
|
|
91
|
+
const t = (c, u) => c == null ? u : c === "1" || c === "true", e = (c, u) => c || u, l = a["data-type"] || a["data-source"], r = k(l), i = A[r];
|
|
92
|
+
let n = a["data-cart_items_select_control_value"] || ((o = i == null ? void 0 : i[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
|
|
93
93
|
if (n && !n.includes("{{") && /^\d+$/.test(n)) {
|
|
94
|
-
const
|
|
95
|
-
u && u[
|
|
94
|
+
const c = parseInt(n) - 1, u = A[r];
|
|
95
|
+
u && u[c] && (n = u[c].value);
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
98
|
initialized: !0,
|
|
99
|
-
blockInstanceId:
|
|
100
|
-
source:
|
|
101
|
-
type:
|
|
99
|
+
blockInstanceId: e(a["data-block-instance-id"], V()),
|
|
100
|
+
source: r,
|
|
101
|
+
type: r,
|
|
102
102
|
itemsSelectValue: n,
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
orientation: a["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
|
|
104
|
+
nameTrimming: t(a["data-product_name_control_trim"], !0),
|
|
105
|
+
priceHideDiscount: t(a["data-product_price_control_nodup"], !0),
|
|
106
|
+
priceFormatted: t(a["data-product_price_control_formated"], !0),
|
|
107
|
+
priceSinglePrice: t(a["data-product_price_control_single_price"], !1),
|
|
108
|
+
priceCurrencySymbol: e(
|
|
109
|
+
a["data-product_price_control_currency_symbol"],
|
|
110
|
+
b.productPriceCurrencySymbolControlValue
|
|
111
111
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
priceCurrencyLocation: e(
|
|
113
|
+
a["data-product_price_currency_location"],
|
|
114
|
+
b.productPriceCurrencyLocationControlValue
|
|
115
115
|
),
|
|
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(
|
|
116
|
+
priceOrientation: a["data-product_original_price_control_orientation"] || "horizontal",
|
|
117
|
+
quantityControlEnabled: t(a["data-product_quantity_control_enabled"], !0),
|
|
118
|
+
buttonLink: e(a["data-product_button_link"], b.productButtonLinkControlValue),
|
|
119
|
+
imageLink: e(a["data-product_image_link"], b.productImageLinkControlValue),
|
|
120
|
+
buttonLabel: e(a["data-product_button_control_label"], "Buy"),
|
|
121
|
+
buttonFullWidth: t(a["data-product_button_control_atw"], !0),
|
|
122
|
+
imageVisible: t(a["data-product_image_control_enabled"], !0),
|
|
123
|
+
nameVisible: t(a["data-product_name_control_enabled"], !0),
|
|
124
|
+
quantityVisible: t(a["data-product_quantity_control_enabled"], !0),
|
|
125
|
+
priceVisible: t(a["data-product_price_control_enabled"], !0),
|
|
126
|
+
originalPriceVisible: t(a["data-product_original_price_control_enabled"], !0),
|
|
127
|
+
buttonVisible: t(a["data-product_button_control_enabled"], !0)
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const N = {
|
|
131
131
|
ins_apr: "CART_ITEMS",
|
|
132
132
|
browsed_item: "BROWSED_ITEMS",
|
|
133
133
|
purchased_item: "PURCHASED_ITEMS"
|
|
134
134
|
};
|
|
135
|
-
function
|
|
136
|
-
const
|
|
135
|
+
function z(a, t) {
|
|
136
|
+
const e = {
|
|
137
137
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
138
138
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
139
139
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
140
140
|
};
|
|
141
|
-
return
|
|
141
|
+
return e[a] || e.CART_ITEMS;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
143
|
+
function H(a, t) {
|
|
144
|
+
const e = {
|
|
145
145
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
146
146
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
147
147
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
148
148
|
};
|
|
149
|
-
return
|
|
149
|
+
return e[a] || e.CART_ITEMS;
|
|
150
150
|
}
|
|
151
|
-
class
|
|
151
|
+
class Y {
|
|
152
152
|
constructor() {
|
|
153
153
|
M(this, "parser");
|
|
154
154
|
this.parser = new DOMParser();
|
|
@@ -157,42 +157,42 @@ class H {
|
|
|
157
157
|
try {
|
|
158
158
|
if (!this.containsItemsBlock(t))
|
|
159
159
|
return this.backfillV2ProductTdAttributes(t);
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const
|
|
160
|
+
let e = this.removeJinjaConditionals(t);
|
|
161
|
+
e = this.replaceTemplateVariables(e);
|
|
162
|
+
const l = this.parser.parseFromString(e, "text/html"), r = l.querySelectorAll(
|
|
163
163
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
164
|
);
|
|
165
|
-
return
|
|
166
|
-
n.migrations = { ...n.migrations, [
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
orientation:
|
|
170
|
-
itemsType:
|
|
171
|
-
itemId:
|
|
172
|
-
currencySymbol:
|
|
173
|
-
currencyLocation:
|
|
174
|
-
formattedPrice:
|
|
175
|
-
configBlockAttributes:
|
|
165
|
+
return $().$patch((n) => {
|
|
166
|
+
n.migrations = { ...n.migrations, [K]: r.length };
|
|
167
|
+
}), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (r.forEach((n) => {
|
|
168
|
+
const o = this.extractConfiguration(n), c = x({
|
|
169
|
+
orientation: o.orientation,
|
|
170
|
+
itemsType: o.itemsType,
|
|
171
|
+
itemId: o.itemId,
|
|
172
|
+
currencySymbol: o.currencySymbol,
|
|
173
|
+
currencyLocation: o.currencyLocation,
|
|
174
|
+
formattedPrice: o.formattedPrice,
|
|
175
|
+
configBlockAttributes: o.configBlockAttributes,
|
|
176
176
|
migrate: !0,
|
|
177
|
-
nameStyles:
|
|
178
|
-
buttonStyles:
|
|
179
|
-
priceStyles:
|
|
180
|
-
originalPriceStyles:
|
|
181
|
-
quantityStyles:
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
184
|
-
`<table><tbody><tr>${
|
|
177
|
+
nameStyles: o.nameStyles,
|
|
178
|
+
buttonStyles: o.buttonStyles,
|
|
179
|
+
priceStyles: o.priceStyles,
|
|
180
|
+
originalPriceStyles: o.originalPriceStyles,
|
|
181
|
+
quantityStyles: o.quantityStyles,
|
|
182
|
+
nodeConfig: R(o.configBlockAttributes)
|
|
183
|
+
}), d = this.parser.parseFromString(
|
|
184
|
+
`<table><tbody><tr>${c}</tr></tbody></table>`,
|
|
185
185
|
"text/html"
|
|
186
186
|
).querySelector("td");
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
187
|
+
if (d && n.parentNode) {
|
|
188
|
+
const s = R(o.configBlockAttributes);
|
|
189
|
+
d.setAttribute("esd-ext-config", JSON.stringify(s)), d.setAttribute("data-type", s.type);
|
|
190
|
+
const _ = d.querySelector("esd-config-block");
|
|
191
|
+
_ && _.remove(), n.parentNode.replaceChild(d, n);
|
|
192
192
|
}
|
|
193
|
-
}),
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
193
|
+
}), l.documentElement.outerHTML);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -202,28 +202,72 @@ class H {
|
|
|
202
202
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
203
203
|
*/
|
|
204
204
|
extractConfiguration(t) {
|
|
205
|
-
var
|
|
206
|
-
const
|
|
207
|
-
((
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
var h, D, P;
|
|
206
|
+
const e = k(
|
|
207
|
+
((h = t.querySelector("[data-type]")) == null ? void 0 : h.getAttribute("data-type")) ?? null
|
|
208
|
+
), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", r = parseInt(l) - 1, i = A[e], n = ((P = i == null ? void 0 : i[r]) == null ? void 0 : P.value) || i[0].value, o = this.extractConfigBlockAttributes(t, e, l);
|
|
209
|
+
this.applyDomFallbacks(t, o);
|
|
210
|
+
const c = t.querySelector('[product-attr="price"]'), u = c ?? t.querySelector('[product-attr="originalPrice"]'), d = (u == null ? void 0 : u.getAttribute("data-currency_symbol")) || o["data-product_price_control_currency_symbol"] || "USD", s = u == null ? void 0 : u.getAttribute("data-curency");
|
|
211
|
+
let _ = o["data-product_price_currency_location"] || "0";
|
|
212
|
+
s && (_ = s === "after" ? "1" : "0");
|
|
213
|
+
const S = (u == null ? void 0 : u.getAttribute("data-formated")) ?? o["data-product_price_control_formated"], C = S !== "false" && S !== "0", y = o["data-card_orientation_control_value"];
|
|
214
|
+
let f;
|
|
215
|
+
y ? f = y === "horizontal" ? "horizontal" : "vertical" : f = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
216
|
+
const m = t.querySelector('a[product-attr="name"]'), g = (m == null ? void 0 : m.getAttribute("style")) || void 0, I = t.querySelector('a[product-attr="button"]'), L = (I == null ? void 0 : I.getAttribute("style")) || void 0, w = (c == null ? void 0 : c.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), v = (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;
|
|
212
217
|
return {
|
|
213
|
-
orientation:
|
|
214
|
-
itemsType:
|
|
218
|
+
orientation: f,
|
|
219
|
+
itemsType: e,
|
|
215
220
|
itemId: n,
|
|
216
|
-
currencySymbol:
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
219
|
-
configBlockAttributes:
|
|
220
|
-
nameStyles:
|
|
221
|
-
buttonStyles:
|
|
222
|
-
priceStyles:
|
|
223
|
-
originalPriceStyles:
|
|
221
|
+
currencySymbol: d,
|
|
222
|
+
currencyLocation: _,
|
|
223
|
+
formattedPrice: C,
|
|
224
|
+
configBlockAttributes: o,
|
|
225
|
+
nameStyles: g,
|
|
226
|
+
buttonStyles: L,
|
|
227
|
+
priceStyles: w,
|
|
228
|
+
originalPriceStyles: v,
|
|
224
229
|
quantityStyles: B
|
|
225
230
|
};
|
|
226
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* DOM fallback for hand-edited templates whose esd-config-block was deleted. With no
|
|
234
|
+
* toggle record left, derive each field's enabled state from whether its product-attr
|
|
235
|
+
* element still exists and read the button label from the live caption — a deleted
|
|
236
|
+
* element means the field is off, not an all-ON default. A present config block stays
|
|
237
|
+
* authoritative (a missing flag there still means "default on"), so we no-op for it.
|
|
238
|
+
*/
|
|
239
|
+
applyDomFallbacks(t, e) {
|
|
240
|
+
var c;
|
|
241
|
+
if (t.querySelector("esd-config-block"))
|
|
242
|
+
return;
|
|
243
|
+
e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal", Object.entries({
|
|
244
|
+
image: "imageSrc",
|
|
245
|
+
name: "name",
|
|
246
|
+
price: "price",
|
|
247
|
+
original_price: "originalPrice",
|
|
248
|
+
quantity: "quantity",
|
|
249
|
+
button: "button"
|
|
250
|
+
}).forEach(([u, d]) => {
|
|
251
|
+
e[`data-product_${u}_control_enabled`] = t.querySelector(`[product-attr="${d}"]`) ? "true" : "false";
|
|
252
|
+
});
|
|
253
|
+
const r = t.querySelector('a[product-attr="button"]'), i = (c = r == null ? void 0 : r.textContent) == null ? void 0 : c.replace(/\s+/g, " ").trim();
|
|
254
|
+
i && (e["data-product_button_control_label"] = i), /display:\s*inline/.test((r == null ? void 0 : r.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
|
|
255
|
+
const n = t.querySelector('[product-attr="imageSrc"]'), o = n ? this.readImageDimension(n) : null;
|
|
256
|
+
o && (e["data-product_image_control_image-height"] = o, e["data-product_image_control_image-width"] = o);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Reads a pixel dimension for the product image from its DOM element — the legacy
|
|
260
|
+
* `width` attribute first, then a px value in the inline style (max-width wins over a
|
|
261
|
+
* percentage width). Returns null when no pixel size is present.
|
|
262
|
+
*/
|
|
263
|
+
readImageDimension(t) {
|
|
264
|
+
var i;
|
|
265
|
+
const e = (i = t.getAttribute("width")) == null ? void 0 : i.trim();
|
|
266
|
+
if (e && /^\d+$/.test(e))
|
|
267
|
+
return e;
|
|
268
|
+
const l = t.getAttribute("style") || "", r = l.match(/max-width:\s*(\d+)px/) || l.match(/(?:^|;)\s*width:\s*(\d+)px/);
|
|
269
|
+
return r ? r[1] : null;
|
|
270
|
+
}
|
|
227
271
|
/**
|
|
228
272
|
* Extracts all data-* attributes from the esd-config-block element
|
|
229
273
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -231,27 +275,27 @@ class H {
|
|
|
231
275
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
276
|
* @param itemNumber - The item number (1-based index)
|
|
233
277
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t,
|
|
235
|
-
const
|
|
236
|
-
if (!
|
|
278
|
+
extractConfigBlockAttributes(t, e, l) {
|
|
279
|
+
const r = t.querySelector("esd-config-block"), i = {};
|
|
280
|
+
if (!r)
|
|
237
281
|
return this.getDefaultConfigBlockAttributes();
|
|
238
|
-
if (Array.from(
|
|
239
|
-
|
|
282
|
+
if (Array.from(r.attributes).forEach((o) => {
|
|
283
|
+
o.name.startsWith("data-") && (i[o.name] = o.value);
|
|
240
284
|
}), i["data-cart_items_select_control_value"]) {
|
|
241
|
-
const
|
|
242
|
-
if (/^\d+$/.test(
|
|
243
|
-
const
|
|
244
|
-
u && u[
|
|
285
|
+
const o = i["data-cart_items_select_control_value"];
|
|
286
|
+
if (/^\d+$/.test(o)) {
|
|
287
|
+
const c = parseInt(o) - 1, u = A[e];
|
|
288
|
+
u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
|
|
245
289
|
}
|
|
246
290
|
}
|
|
247
291
|
if (i["data-product_price_control_curency"]) {
|
|
248
|
-
const
|
|
249
|
-
let
|
|
250
|
-
|
|
292
|
+
const o = i["data-product_price_control_curency"];
|
|
293
|
+
let c = o;
|
|
294
|
+
o === "before" ? c = "0" : o === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
|
|
251
295
|
}
|
|
252
296
|
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
253
297
|
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
-
return n["data-type"] =
|
|
298
|
+
return n["data-type"] = e, n["data-source"] = e, n["data-product_image_link"] = z(e, l), n["data-product_button_link"] = H(e, l), n;
|
|
255
299
|
}
|
|
256
300
|
/**
|
|
257
301
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -325,25 +369,25 @@ class H {
|
|
|
325
369
|
backfillV2ProductTdAttributes(t) {
|
|
326
370
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
371
|
return t;
|
|
328
|
-
const
|
|
329
|
-
let
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
const i =
|
|
372
|
+
const e = this.parser.parseFromString(t, "text/html");
|
|
373
|
+
let l = !1;
|
|
374
|
+
return e.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
375
|
+
r.hasAttribute("width") && (r.removeAttribute("width"), l = !0);
|
|
376
|
+
const i = r.getAttribute("esd-ext-config");
|
|
333
377
|
let n = null;
|
|
334
378
|
try {
|
|
335
379
|
n = i ? JSON.parse(i) : null;
|
|
336
380
|
} catch {
|
|
337
381
|
}
|
|
338
|
-
if (!n || (!
|
|
382
|
+
if (!n || (!r.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(n.priceHideDiscount)), l = !0), r.getAttribute("data-type")))
|
|
339
383
|
return;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
384
|
+
const o = n.type || n.source;
|
|
385
|
+
if (!o)
|
|
342
386
|
return;
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
}),
|
|
387
|
+
r.setAttribute("data-type", o), l = !0;
|
|
388
|
+
const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
389
|
+
c && r.getAttribute("data-number") !== c[1] && r.setAttribute("data-number", c[1]);
|
|
390
|
+
}), l ? e.documentElement.outerHTML : t;
|
|
347
391
|
}
|
|
348
392
|
/**
|
|
349
393
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -364,17 +408,17 @@ class H {
|
|
|
364
408
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
365
409
|
*/
|
|
366
410
|
removeJinjaConditionals(t) {
|
|
367
|
-
const
|
|
368
|
-
let
|
|
369
|
-
return
|
|
411
|
+
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
412
|
+
let r = l ? t.replace(l[0], e) : t;
|
|
413
|
+
return r = r.replace(
|
|
370
414
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
371
415
|
""
|
|
372
|
-
),
|
|
416
|
+
), r = r.replace(
|
|
373
417
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
374
418
|
""
|
|
375
|
-
),
|
|
419
|
+
), r = r.replace(/\{%\s*endif\s*%\}/g, ""), l && (r = r.replace(e, l[0])), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
376
420
|
|
|
377
|
-
`),
|
|
421
|
+
`), r;
|
|
378
422
|
}
|
|
379
423
|
/**
|
|
380
424
|
* Replaces template variables with default values from productPairs
|
|
@@ -386,32 +430,32 @@ class H {
|
|
|
386
430
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
431
|
*/
|
|
388
432
|
replaceTemplateVariables(t) {
|
|
389
|
-
const { PAIRS_FOR_EXTENSION:
|
|
390
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
391
|
-
const i =
|
|
433
|
+
const { PAIRS_FOR_EXTENSION: e } = F;
|
|
434
|
+
return t.replace(/{{([^}]+)}}/g, (l, r) => {
|
|
435
|
+
const i = r.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
392
436
|
if (!i)
|
|
393
|
-
return
|
|
394
|
-
const [, n,
|
|
437
|
+
return l;
|
|
438
|
+
const [, n, o, c] = i, u = N[n];
|
|
395
439
|
if (!u)
|
|
396
|
-
return console.warn(`Unknown variable prefix: ${n}`),
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
399
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
400
|
-
const { pairsKey:
|
|
440
|
+
return console.warn(`Unknown variable prefix: ${n}`), l;
|
|
441
|
+
const d = O[o];
|
|
442
|
+
if (!d)
|
|
443
|
+
return console.warn(`Unknown variable suffix mapping for: ${o}`), l;
|
|
444
|
+
const { pairsKey: s, defaultKey: _, isArray: S } = d, y = e[s][u];
|
|
401
445
|
if (!y)
|
|
402
|
-
return console.warn(`No data found for: ${
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
return Array.isArray(
|
|
446
|
+
return console.warn(`No data found for: ${s}.${u}`), l;
|
|
447
|
+
if (S) {
|
|
448
|
+
const m = parseInt(c) - 1, g = y[_];
|
|
449
|
+
return Array.isArray(g) && g[m] ? g[m] : (console.warn(`Array value not found: ${s}.${u}.${_}[${m}]`), l);
|
|
406
450
|
}
|
|
407
|
-
const
|
|
408
|
-
return
|
|
451
|
+
const f = y[_];
|
|
452
|
+
return f !== void 0 ? String(f) : (console.warn(`Default value not found: ${s}.${u}.${_}`), l);
|
|
409
453
|
});
|
|
410
454
|
}
|
|
411
455
|
}
|
|
412
|
-
function
|
|
413
|
-
return new
|
|
456
|
+
function tt(a) {
|
|
457
|
+
return new Y().migrate(a);
|
|
414
458
|
}
|
|
415
459
|
export {
|
|
416
|
-
|
|
460
|
+
tt as migrateItemsBlock
|
|
417
461
|
};
|