@useinsider/guido 3.30.0-beta.52efeeb → 3.30.0-beta.545589d
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/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/config/migrator/recommendation/extractors.js +72 -180
- package/dist/config/migrator/recommendation/themeMapper.js +21 -33
- package/dist/config/migrator/recommendationMigrator.js +48 -53
- package/dist/package.json.js +6 -6
- package/dist/src/config/migrator/recommendation/extractors.d.ts +1 -15
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -1,222 +1,114 @@
|
|
|
1
|
-
import { CURRENCY_ATTR as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { CURRENCY_ATTR as l, CSS_CLASS_SKIP_COMPILE as m } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const a = "You May Also Like!";
|
|
3
|
+
function C(e) {
|
|
4
4
|
var n;
|
|
5
|
-
const r =
|
|
5
|
+
const r = e.querySelector(".ext-recommendation-title");
|
|
6
6
|
if (!r)
|
|
7
|
-
return
|
|
8
|
-
const
|
|
9
|
-
return
|
|
7
|
+
return a;
|
|
8
|
+
const t = (n = r.textContent) == null ? void 0 : n.trim();
|
|
9
|
+
return t && t.length > 0 ? t : a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const r =
|
|
11
|
+
function A(e) {
|
|
12
|
+
const r = e.querySelector(".ext-recommendation-title");
|
|
13
13
|
return r ? !/display\s*:\s*none/i.test(r.getAttribute("style") ?? "") : !1;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
const r =
|
|
18
|
-
return !!r && !((
|
|
15
|
+
function _(e) {
|
|
16
|
+
var t;
|
|
17
|
+
const r = e.querySelector(".ext-recommendation-title");
|
|
18
|
+
return !!r && !((t = r == null ? void 0 : r.textContent) != null && t.trim());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const r =
|
|
22
|
-
return !r || !
|
|
20
|
+
function E(e) {
|
|
21
|
+
const r = e.querySelector(".ext-product-price"), t = e.querySelector(".ext-product-original-price");
|
|
22
|
+
return !r || !t ? !1 : r.compareDocumentPosition(t) === Node.DOCUMENT_POSITION_PRECEDING;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return /(?:^|;)\s*display\s*:\s*table-cell/i.test(
|
|
24
|
+
function d(e) {
|
|
25
|
+
return /(?:^|;)\s*display\s*:\s*table-cell/i.test(e.getAttribute("style") ?? "");
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
var n,
|
|
29
|
-
const r = (n =
|
|
30
|
-
return !r || !
|
|
27
|
+
function T(e) {
|
|
28
|
+
var n, o;
|
|
29
|
+
const r = (n = e.querySelector(".ext-product-price")) == null ? void 0 : n.closest("tr"), t = (o = e.querySelector(".ext-product-original-price")) == null ? void 0 : o.closest("tr");
|
|
30
|
+
return !r || !t || r === t ? !1 : !d(r) && !d(t);
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const p = /* @__PURE__ */ new Map([
|
|
33
33
|
["p_name", ".ext-product-name p"],
|
|
34
34
|
["p_price", ".ext-product-price p"],
|
|
35
35
|
["p_original_price", ".ext-product-original-price p"]
|
|
36
36
|
]);
|
|
37
|
-
function
|
|
38
|
-
const r = ((
|
|
37
|
+
function f(e) {
|
|
38
|
+
const r = ((e == null ? void 0 : e.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
|
|
39
39
|
return (r == null ? void 0 : r[1].trim()) || void 0;
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
function
|
|
43
|
-
return
|
|
44
|
-
var s,
|
|
45
|
-
const n =
|
|
41
|
+
const x = "ins-trim-text";
|
|
42
|
+
function h(e, r) {
|
|
43
|
+
return e == null ? void 0 : e.map((t) => {
|
|
44
|
+
var s, u;
|
|
45
|
+
const n = p.get(t.variable ?? "");
|
|
46
46
|
if (!n)
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
return !
|
|
50
|
-
...
|
|
47
|
+
return t;
|
|
48
|
+
const o = r.querySelector(n), c = (u = (s = t.theme) == null ? void 0 : s.textColor) != null && u.color ? void 0 : f(o), i = t.variable === "p_name" && (o == null ? void 0 : o.classList.contains(x));
|
|
49
|
+
return !c && !i ? t : {
|
|
50
|
+
...t,
|
|
51
51
|
theme: {
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
-
...
|
|
52
|
+
...t.theme,
|
|
53
|
+
...c ? { textColor: { color: c } } : {},
|
|
54
|
+
...i ? { textTrimming: !0 } : {}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
["none", "transparent", "inherit", "initial", "unset", "revert", "currentColor"].map((t) => t.toLowerCase())
|
|
61
|
-
), O = /^(\d+(?:\.\d+)?)(?:px)?$/i, P = /* @__PURE__ */ new Set([
|
|
62
|
-
"none",
|
|
63
|
-
"hidden",
|
|
64
|
-
"dotted",
|
|
65
|
-
"dashed",
|
|
66
|
-
"solid",
|
|
67
|
-
"double",
|
|
68
|
-
"groove",
|
|
69
|
-
"ridge",
|
|
70
|
-
"inset",
|
|
71
|
-
"outset"
|
|
72
|
-
]), w = /\s/, B = /\s*!important\s*$/i, N = ["padding-top", "padding-right", "padding-bottom", "padding-left"];
|
|
73
|
-
function x(t) {
|
|
74
|
-
const r = /* @__PURE__ */ new Map();
|
|
75
|
-
return ((t == null ? void 0 : t.getAttribute("style")) ?? "").split(";").forEach((o, n) => {
|
|
76
|
-
const e = o.indexOf(":");
|
|
77
|
-
if (e < 0)
|
|
78
|
-
return;
|
|
79
|
-
const i = o.slice(0, e).trim().toLowerCase(), c = o.slice(e + 1).replace(B, "").trim();
|
|
80
|
-
i && c && r.set(i, { value: c, position: n });
|
|
81
|
-
}), r;
|
|
82
|
-
}
|
|
83
|
-
function u(t, r) {
|
|
84
|
-
var o;
|
|
85
|
-
return (o = t.get(r)) == null ? void 0 : o.value;
|
|
86
|
-
}
|
|
87
|
-
function l(t) {
|
|
88
|
-
return t && R.test(t) && !I.has(t.toLowerCase()) ? t : void 0;
|
|
89
|
-
}
|
|
90
|
-
function f(t) {
|
|
91
|
-
const r = t == null ? void 0 : t.match(O);
|
|
92
|
-
return (r == null ? void 0 : r[1]) !== void 0 ? Number(r[1]) : void 0;
|
|
93
|
-
}
|
|
94
|
-
function b(t) {
|
|
95
|
-
const r = t == null ? void 0 : t.toLowerCase();
|
|
96
|
-
return r && P.has(r) ? r : void 0;
|
|
97
|
-
}
|
|
98
|
-
function T(t) {
|
|
99
|
-
let r = 0;
|
|
100
|
-
return Array.from(t).reduce((n, e) => (e === "(" ? r += 1 : e === ")" && r > 0 && (r -= 1), r === 0 && w.test(e) ? n.push("") : n[n.length - 1] += e, n), [""]).filter(Boolean);
|
|
101
|
-
}
|
|
102
|
-
function y(t, r) {
|
|
103
|
-
const o = T(t ?? "").map(r);
|
|
104
|
-
if (o.length === 0 || o.length > 4 || o.some((s) => s === void 0))
|
|
105
|
-
return;
|
|
106
|
-
const [n, e = n, i = n, c = e] = o;
|
|
107
|
-
return { top: n, right: e, bottom: i, left: c };
|
|
108
|
-
}
|
|
109
|
-
function D(t) {
|
|
110
|
-
const r = u(t, "padding");
|
|
111
|
-
if (r !== void 0)
|
|
112
|
-
return y(r, f);
|
|
113
|
-
const [o, n, e, i] = N.map((c) => f(u(t, c)));
|
|
114
|
-
if (!(o === void 0 || n === void 0 || e === void 0 || i === void 0))
|
|
115
|
-
return { top: o, right: n, bottom: e, left: i };
|
|
116
|
-
}
|
|
117
|
-
function q(t) {
|
|
118
|
-
return t === void 0 ? void 0 : { top: t, right: t, bottom: t, left: t };
|
|
119
|
-
}
|
|
120
|
-
function k(t) {
|
|
121
|
-
return T(t ?? "").reduce((o, n) => {
|
|
122
|
-
const e = f(n), i = b(n), c = l(n);
|
|
123
|
-
if (o) {
|
|
124
|
-
if (e !== void 0 && o.width === void 0)
|
|
125
|
-
return { ...o, width: e };
|
|
126
|
-
if (i && !o.style)
|
|
127
|
-
return { ...o, style: i };
|
|
128
|
-
if (c && !o.color)
|
|
129
|
-
return { ...o, color: c };
|
|
130
|
-
}
|
|
131
|
-
}, {}) ?? {};
|
|
132
|
-
}
|
|
133
|
-
function p(t, r, o, n) {
|
|
134
|
-
var s, d;
|
|
135
|
-
const e = y(u(t, r), o), i = q(n);
|
|
136
|
-
return (((s = t.get(r)) == null ? void 0 : s.position) ?? -1) > (((d = t.get("border")) == null ? void 0 : d.position) ?? -1) ? e ?? i : i ?? e;
|
|
137
|
-
}
|
|
138
|
-
function M(t) {
|
|
139
|
-
const r = k(u(t, "border")), o = p(t, "border-width", f, r.width);
|
|
140
|
-
if (!o)
|
|
141
|
-
return;
|
|
142
|
-
const n = p(t, "border-style", b, r.style), e = p(t, "border-color", l, r.color);
|
|
143
|
-
return {
|
|
144
|
-
width: o,
|
|
145
|
-
...n ? { style: n } : {},
|
|
146
|
-
...e ? { color: e } : {}
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function C(t) {
|
|
150
|
-
return l(u(t, "background")) ?? l(u(t, "background-color"));
|
|
151
|
-
}
|
|
152
|
-
function Y(t, r = {}) {
|
|
153
|
-
var a, g;
|
|
154
|
-
const o = x(t.querySelector(".ext-product-button a.es-button")), n = x(t.querySelector(".ext-product-button .es-button-border")), e = {}, i = (a = r.buttonColor) != null && a.color ? void 0 : C(n) ?? C(o), c = (g = r.textButtonColor) != null && g.color ? void 0 : l(u(o, "color")), s = r.buttonBorder === void 0 ? M(n) : void 0, d = r.buttonInternalPadding === void 0 ? D(o) : void 0;
|
|
155
|
-
return i && (e.buttonColor = { color: i }), c && (e.textButtonColor = { color: c }), s && (e.buttonBorder = s), d && (e.buttonInternalPadding = { desktop: d }), e;
|
|
156
|
-
}
|
|
157
|
-
function H(t, r) {
|
|
158
|
-
return t == null ? void 0 : t.map((o) => {
|
|
159
|
-
if (o.variable !== "p_button")
|
|
160
|
-
return o;
|
|
161
|
-
const n = Y(r, o.theme ?? {});
|
|
162
|
-
return Object.keys(n).length === 0 ? o : { ...o, theme: { ...o.theme, ...n } };
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function W(t) {
|
|
59
|
+
function R(e) {
|
|
166
60
|
const r = [
|
|
167
|
-
|
|
168
|
-
...Array.from(
|
|
61
|
+
e,
|
|
62
|
+
...Array.from(e.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
169
63
|
];
|
|
170
|
-
let
|
|
64
|
+
let t = "";
|
|
171
65
|
return r.some((n) => {
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
return
|
|
175
|
-
const
|
|
176
|
-
return
|
|
177
|
-
}),
|
|
178
|
-
}
|
|
179
|
-
function
|
|
180
|
-
const r =
|
|
66
|
+
const o = n.getAttribute("bgcolor");
|
|
67
|
+
if (o && o.trim())
|
|
68
|
+
return t = o.trim(), !0;
|
|
69
|
+
const i = (n.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
70
|
+
return i && i[1] ? (t = i[1].trim(), !0) : !1;
|
|
71
|
+
}), t;
|
|
72
|
+
}
|
|
73
|
+
function L(e) {
|
|
74
|
+
const r = e.getAttribute(l.CURRENCY), t = e.getAttribute(l.SYMBOL);
|
|
181
75
|
return {
|
|
182
76
|
...r ? { value: r } : {},
|
|
183
77
|
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
184
78
|
// the currency code as the symbol.
|
|
185
|
-
...
|
|
79
|
+
...t ? { symbol: t } : {},
|
|
186
80
|
alignment: 1,
|
|
187
81
|
decimalCount: "2",
|
|
188
82
|
decimalSeparator: ",",
|
|
189
83
|
thousandSeparator: "."
|
|
190
84
|
};
|
|
191
85
|
}
|
|
192
|
-
const
|
|
193
|
-
function
|
|
194
|
-
const r =
|
|
86
|
+
const S = /^es-p(\d+)([trbl]?)$/, g = { t: "top", r: "right", b: "bottom", l: "left" };
|
|
87
|
+
function P(e) {
|
|
88
|
+
const r = e.querySelector("td.esd-structure.esd-extension-internal-block");
|
|
195
89
|
if (!r)
|
|
196
90
|
return;
|
|
197
|
-
const
|
|
91
|
+
const t = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
198
92
|
return r.classList.forEach((n) => {
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
93
|
+
const o = n.match(S);
|
|
94
|
+
if (!o)
|
|
201
95
|
return;
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
}),
|
|
96
|
+
const c = Number(o[1]), i = o[2];
|
|
97
|
+
i ? t[g[i]] = c : Object.assign(t, { top: c, right: c, bottom: c, left: c });
|
|
98
|
+
}), t;
|
|
205
99
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
100
|
+
function I(e) {
|
|
101
|
+
return e.classList.contains(m);
|
|
208
102
|
}
|
|
209
103
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
H as withRenderedButtonTheme,
|
|
221
|
-
j as withRenderedTextTheme
|
|
104
|
+
R as extractCardBgColor,
|
|
105
|
+
L as extractCurrencyFromBlock,
|
|
106
|
+
P as extractRenderedBlockPadding,
|
|
107
|
+
C as extractTitleText,
|
|
108
|
+
_ as hasEmptyTitle,
|
|
109
|
+
A as hasVisibleTitle,
|
|
110
|
+
E as isOldPriceFirst,
|
|
111
|
+
I as isPartnerManagedBlock,
|
|
112
|
+
T as isPriceOnNextLine,
|
|
113
|
+
h as withRenderedTextTheme
|
|
222
114
|
};
|
|
@@ -16,21 +16,21 @@ function P(n) {
|
|
|
16
16
|
const t = n.top ?? n.all ?? 0, o = n.right ?? n.all ?? 0, i = n.bottom ?? n.all ?? 0, l = n.left ?? n.all ?? 0;
|
|
17
17
|
return t === 0 && o === 0 && i === 0 && l === 0 ? null : `${t}px ${o}px ${i}px ${l}px`;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function z(n) {
|
|
20
20
|
if (!n)
|
|
21
21
|
return null;
|
|
22
22
|
const { top: t, right: o, bottom: i, left: l } = n;
|
|
23
23
|
return t === void 0 ? null : t === o && t === i && t === l ? t : null;
|
|
24
24
|
}
|
|
25
25
|
function $(n, t, o, i) {
|
|
26
|
-
const l =
|
|
26
|
+
const l = z(o);
|
|
27
27
|
if (l !== null) {
|
|
28
28
|
r(n, `border-${t}`, i(l));
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
o && (r(n, `border-top-${t}`, o.top !== void 0 ? i(o.top) : null), r(n, `border-right-${t}`, o.right !== void 0 ? i(o.right) : null), r(n, `border-bottom-${t}`, o.bottom !== void 0 ? i(o.bottom) : null), r(n, `border-left-${t}`, o.left !== void 0 ? i(o.left) : null));
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function D(n) {
|
|
34
34
|
if (!n)
|
|
35
35
|
return null;
|
|
36
36
|
const t = x(n.radius ?? n.borderRadius);
|
|
@@ -42,14 +42,14 @@ function I(n) {
|
|
|
42
42
|
}
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function I(n) {
|
|
46
46
|
var t, o;
|
|
47
47
|
return ((t = n.textLineSpacing) == null ? void 0 : t.lineSpacing) ?? ((o = n.textLineSpacing) == null ? void 0 : o["font-lineSpacing"]);
|
|
48
48
|
}
|
|
49
49
|
function N(n) {
|
|
50
|
-
var u, s, a, d, g,
|
|
50
|
+
var u, s, a, d, g, b, p, y;
|
|
51
51
|
const t = [], o = [], i = (u = n == null ? void 0 : n.textAlign) == null ? void 0 : u.align, l = P((s = n == null ? void 0 : n.textPadding) == null ? void 0 : s.desktop), f = (a = n == null ? void 0 : n.textStyle) == null ? void 0 : a["font-weight"], c = (d = n == null ? void 0 : n.textStyle) == null ? void 0 : d["font-style"];
|
|
52
|
-
return r(t, "background-color", (g = n == null ? void 0 : n.textBackgroundColor) == null ? void 0 : g.color), r(t, "padding", l), r(o, "font-family", (
|
|
52
|
+
return r(t, "background-color", (g = n == null ? void 0 : n.textBackgroundColor) == null ? void 0 : g.color), r(t, "padding", l), r(o, "font-family", (b = n == null ? void 0 : n.textStyle) == null ? void 0 : b["font-family"]), r(o, "font-size", (p = n == null ? void 0 : n.textStyle) == null ? void 0 : p["font-size"]), r(o, "font-weight", f), r(o, "font-style", c), r(o, "color", (y = n == null ? void 0 : n.textColor) == null ? void 0 : y.color), r(o, "line-height", I(n ?? {})), r(o, "text-align", i), {
|
|
53
53
|
tdStyle: t.join("; "),
|
|
54
54
|
pStyle: o.join("; "),
|
|
55
55
|
align: i || void 0,
|
|
@@ -59,59 +59,47 @@ function N(n) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
function E(n) {
|
|
62
|
-
var s, a, d, g,
|
|
62
|
+
var s, a, d, g, b, p, y, k, w, B, T, j;
|
|
63
63
|
const t = [], o = [], i = [];
|
|
64
|
-
r(t, "padding", P((s = n == null ? void 0 : n.buttonExternalPadding) == null ? void 0 : s.desktop)), r(i, "padding", P((a = n == null ? void 0 : n.buttonInternalPadding) == null ? void 0 : a.desktop)), r(i, "font-family", (d = n == null ? void 0 : n.buttonStyle) == null ? void 0 : d["font-family"]), r(i, "font-size", (g = n == null ? void 0 : n.buttonStyle) == null ? void 0 : g["font-size"]), r(i, "font-weight", (
|
|
64
|
+
r(t, "padding", P((s = n == null ? void 0 : n.buttonExternalPadding) == null ? void 0 : s.desktop)), r(i, "padding", P((a = n == null ? void 0 : n.buttonInternalPadding) == null ? void 0 : a.desktop)), r(i, "font-family", (d = n == null ? void 0 : n.buttonStyle) == null ? void 0 : d["font-family"]), r(i, "font-size", (g = n == null ? void 0 : n.buttonStyle) == null ? void 0 : g["font-size"]), r(i, "font-weight", (b = n == null ? void 0 : n.buttonStyle) == null ? void 0 : b["font-weight"]), r(i, "font-style", (p = n == null ? void 0 : n.buttonStyle) == null ? void 0 : p["font-style"]);
|
|
65
65
|
const l = (y = n == null ? void 0 : n.buttonColor) == null ? void 0 : y.color, f = (k = n == null ? void 0 : n.textButtonColor) == null ? void 0 : k.color;
|
|
66
|
-
r(o, "background", l), r(i, "background", l), r(i, "color", f)
|
|
66
|
+
r(o, "background", l), r(i, "background", l), r(i, "color", f);
|
|
67
67
|
const c = n == null ? void 0 : n.buttonBorder;
|
|
68
68
|
$(o, "width", c == null ? void 0 : c.width, (S) => `${S}px`), $(o, "style", c == null ? void 0 : c.style, (S) => S), $(o, "color", c == null ? void 0 : c.color, (S) => S);
|
|
69
|
-
const u =
|
|
69
|
+
const u = D((n == null ? void 0 : n.buttonBorderRadius) ?? (n == null ? void 0 : n.borderRadius));
|
|
70
70
|
return u && (r(o, "border-radius", u), r(i, "border-radius", u)), ((w = n == null ? void 0 : n.buttonStretch) == null ? void 0 : w.stretched) === !1 ? (r(o, "display", "inline-block"), r(i, "display", "inline-block")) : ((B = n == null ? void 0 : n.buttonStretch) == null ? void 0 : B.stretched) === !0 && (r(o, "display", "block"), r(i, "display", "block")), {
|
|
71
71
|
tdStyle: t.join("; "),
|
|
72
|
-
align: ((
|
|
72
|
+
align: ((T = n == null ? void 0 : n.buttonAlign) == null ? void 0 : T.align) || void 0,
|
|
73
73
|
spanStyle: o.join("; "),
|
|
74
74
|
aStyle: i.join("; "),
|
|
75
|
-
text: (
|
|
75
|
+
text: (j = n == null ? void 0 : n.buttonText) == null ? void 0 : j.text
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function L(n) {
|
|
79
79
|
var t, o;
|
|
80
80
|
return {
|
|
81
81
|
width: x((t = n == null ? void 0 : n.imageSize) == null ? void 0 : t.width),
|
|
82
82
|
height: x((o = n == null ? void 0 : n.imageSize) == null ? void 0 : o.height)
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
const A = /* @__PURE__ */ new Set([5, 10, 15, 20, 25, 30, 35, 40]),
|
|
86
|
-
function
|
|
85
|
+
const A = /* @__PURE__ */ new Set([5, 10, 15, 20, 25, 30, 35, 40]), C = [["t", "top"], ["r", "right"], ["b", "bottom"], ["l", "left"]];
|
|
86
|
+
function R(n) {
|
|
87
87
|
if (!n)
|
|
88
88
|
return;
|
|
89
89
|
const t = [], o = [];
|
|
90
|
-
return
|
|
90
|
+
return C.forEach(([i, l]) => {
|
|
91
91
|
const f = x(n[l] ?? n.all) ?? 0;
|
|
92
92
|
A.has(f) ? t.push(`es-p${f}${i}`) : f > 0 && o.push(`padding-${l}: ${f}px`);
|
|
93
93
|
}), { classes: t.join(" "), style: o.join("; ") };
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
return n.split(";").map((t) => t.trim()).filter(Boolean);
|
|
97
|
-
}
|
|
98
|
-
function D(n) {
|
|
99
|
-
const t = n.indexOf(":");
|
|
100
|
-
return (t === -1 ? n : n.slice(0, t)).trim().toLowerCase();
|
|
101
|
-
}
|
|
102
|
-
function F(n, t) {
|
|
95
|
+
function v(n, t) {
|
|
103
96
|
const o = (n ?? "").trim().replace(/;$/, "").trim(), i = (t ?? "").trim().replace(/;$/, "").trim();
|
|
104
|
-
|
|
105
|
-
return i;
|
|
106
|
-
if (!i)
|
|
107
|
-
return o;
|
|
108
|
-
const l = new Set(z(i).map(D)), f = z(o), c = f.filter((u) => !l.has(D(u)));
|
|
109
|
-
return c.length === f.length ? `${o}; ${i}` : c.length ? `${c.join("; ")}; ${i}` : i;
|
|
97
|
+
return o ? i ? `${o}; ${i}` : o : i;
|
|
110
98
|
}
|
|
111
99
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
v as appendStyle,
|
|
101
|
+
R as mapBlockPadding,
|
|
114
102
|
E as mapButtonTheme,
|
|
115
|
-
|
|
103
|
+
L as mapImageTheme,
|
|
116
104
|
N as mapTextTheme
|
|
117
105
|
};
|
|
@@ -1,64 +1,59 @@
|
|
|
1
|
-
import { BlockId as
|
|
2
|
-
import { DEFAULT_NODE_CONFIG as
|
|
3
|
-
import {
|
|
4
|
-
import { useTemplateStore as
|
|
5
|
-
import { mapComposition as
|
|
6
|
-
import { isPriceOnNextLine as
|
|
7
|
-
import { buildBlockHtml as
|
|
8
|
-
import { parseRecommendationId as
|
|
9
|
-
import { mapSettings as
|
|
10
|
-
import {
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
var l,
|
|
14
|
-
const t =
|
|
1
|
+
import { BlockId as b } from "../../enums/block.js";
|
|
2
|
+
import { DEFAULT_NODE_CONFIG as C } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
3
|
+
import { ATTR_RECOMMENDATION_TITLE as f } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useTemplateStore as M } from "../../stores/template.js";
|
|
5
|
+
import { mapComposition as x } from "./recommendation/compositionMapper.js";
|
|
6
|
+
import { isPriceOnNextLine as R, extractCurrencyFromBlock as h, isOldPriceFirst as S, withRenderedTextTheme as w, extractTitleText as E, hasEmptyTitle as L, hasVisibleTitle as B, extractCardBgColor as P, isPartnerManagedBlock as A, extractRenderedBlockPadding as H } from "./recommendation/extractors.js";
|
|
7
|
+
import { buildBlockHtml as N } from "./recommendation/htmlBuilder.js";
|
|
8
|
+
import { parseRecommendationId as O, parseLegacyConfig as F } from "./recommendation/parseLegacyConfig.js";
|
|
9
|
+
import { mapSettings as I } from "./recommendation/settingsMapper.js";
|
|
10
|
+
import { mapBlockPadding as _ } from "./recommendation/themeMapper.js";
|
|
11
|
+
const k = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
|
|
12
|
+
function $(c, e, m) {
|
|
13
|
+
var l, g, p;
|
|
14
|
+
const t = O(e);
|
|
15
15
|
if (t === null)
|
|
16
16
|
return console.warn(
|
|
17
17
|
"[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
|
|
18
18
|
), !1;
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
19
|
+
const r = F(e);
|
|
20
|
+
if (!r)
|
|
21
21
|
return console.warn(
|
|
22
22
|
`[RecommendationMigrator] Aborting block id=${t} — \`esd-dev-product-config\` missing or unable to be parsed`
|
|
23
23
|
), !1;
|
|
24
|
-
const
|
|
25
|
-
...
|
|
26
|
-
currencySettings:
|
|
27
|
-
isPriceMovedToNextLine:
|
|
28
|
-
}, a =
|
|
29
|
-
w(
|
|
30
|
-
{ oldPriceFirst:
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Object.keys(u).length > 0 && (r.perElementStyles[f] = U(u));
|
|
35
|
-
}
|
|
36
|
-
const y = P(e);
|
|
37
|
-
A(e) ? r.visibility[T] = !1 : r.titleVariable || (r.visibility[T] = H(e));
|
|
38
|
-
const v = N(e), h = {
|
|
24
|
+
const o = m[String(t)] ?? {}, n = {
|
|
25
|
+
...o,
|
|
26
|
+
currencySettings: o.currencySettings ?? h(e),
|
|
27
|
+
isPriceMovedToNextLine: o.isPriceMovedToNextLine ?? R(e)
|
|
28
|
+
}, a = I(n, r, t), i = x(
|
|
29
|
+
w((l = r.composition) == null ? void 0 : l.variables, e),
|
|
30
|
+
{ oldPriceFirst: S(e) }
|
|
31
|
+
), u = E(e);
|
|
32
|
+
L(e) ? i.visibility[f] = !1 : i.titleVariable || (i.visibility[f] = B(e));
|
|
33
|
+
const y = P(e), T = {
|
|
39
34
|
...a,
|
|
40
35
|
strategyId: "",
|
|
41
|
-
composition:
|
|
42
|
-
visibility:
|
|
43
|
-
previousTitleHtml:
|
|
44
|
-
textTrimming:
|
|
45
|
-
}, s =
|
|
36
|
+
composition: i.composition,
|
|
37
|
+
visibility: i.visibility,
|
|
38
|
+
previousTitleHtml: C.previousTitleHtml,
|
|
39
|
+
textTrimming: i.anyTextTrimming
|
|
40
|
+
}, s = A(e), v = `
|
|
46
41
|
<table>
|
|
47
42
|
<tbody>
|
|
48
43
|
<tr>
|
|
49
44
|
<td class="esd-structure" align="left">
|
|
50
45
|
<table width="100%" cellpadding="0" cellspacing="0">
|
|
51
46
|
<tbody>
|
|
52
|
-
<tr>${
|
|
53
|
-
nodeConfig:
|
|
54
|
-
composition:
|
|
55
|
-
cardBg:
|
|
56
|
-
titleText:
|
|
47
|
+
<tr>${N({
|
|
48
|
+
nodeConfig: T,
|
|
49
|
+
composition: i,
|
|
50
|
+
cardBg: y,
|
|
51
|
+
titleText: u,
|
|
57
52
|
legacyId: e.getAttribute("id") ?? void 0,
|
|
58
53
|
legacyBgColor: e.getAttribute("bgcolor") ?? void 0,
|
|
59
54
|
preserveInnerHtml: s ? e.innerHTML : void 0,
|
|
60
55
|
skipCompile: s,
|
|
61
|
-
blockPadding:
|
|
56
|
+
blockPadding: _(((p = (g = r.theme) == null ? void 0 : g.blockPadding) == null ? void 0 : p.desktop) ?? H(e))
|
|
62
57
|
})}</tr>
|
|
63
58
|
</tbody>
|
|
64
59
|
</table>
|
|
@@ -66,12 +61,12 @@ function G(c, e, m) {
|
|
|
66
61
|
</tr>
|
|
67
62
|
</tbody>
|
|
68
63
|
</table>
|
|
69
|
-
`, d = c.parseFromString(
|
|
64
|
+
`, d = c.parseFromString(v, "text/html").querySelector("td.esd-structure");
|
|
70
65
|
return !d || !e.parentNode ? (console.warn(
|
|
71
66
|
`[RecommendationMigrator] Aborting block id=${t} — failed to construct new HTML element`
|
|
72
67
|
), !1) : (e.parentNode.replaceChild(d, e), !0);
|
|
73
68
|
}
|
|
74
|
-
function
|
|
69
|
+
function X(c, e = {}) {
|
|
75
70
|
const m = new DOMParser();
|
|
76
71
|
let t;
|
|
77
72
|
try {
|
|
@@ -79,27 +74,27 @@ function oe(c, e = {}) {
|
|
|
79
74
|
} catch (n) {
|
|
80
75
|
return console.error("[RecommendationMigrator] Failed to parse template:", n), c;
|
|
81
76
|
}
|
|
82
|
-
const
|
|
77
|
+
const r = Array.from(t.querySelectorAll(k));
|
|
83
78
|
try {
|
|
84
|
-
|
|
79
|
+
M().$patch((a) => {
|
|
85
80
|
a.migrations = {
|
|
86
81
|
...a.migrations,
|
|
87
|
-
[
|
|
82
|
+
[b.Recommendation]: r.length
|
|
88
83
|
};
|
|
89
84
|
});
|
|
90
85
|
} catch {
|
|
91
86
|
}
|
|
92
|
-
if (
|
|
87
|
+
if (r.length === 0)
|
|
93
88
|
return c;
|
|
94
|
-
let
|
|
95
|
-
return
|
|
89
|
+
let o = 0;
|
|
90
|
+
return r.forEach((n) => {
|
|
96
91
|
try {
|
|
97
|
-
|
|
92
|
+
$(m, n, e) && (o += 1);
|
|
98
93
|
} catch (a) {
|
|
99
94
|
console.error("[RecommendationMigrator] Unexpected error migrating block:", a);
|
|
100
95
|
}
|
|
101
|
-
}),
|
|
96
|
+
}), o > 0 && console.info(`[RecommendationMigrator] Migrated ${o} legacy Recommendation block(s)`), t.documentElement.outerHTML;
|
|
102
97
|
}
|
|
103
98
|
export {
|
|
104
|
-
|
|
99
|
+
X as migrateRecommendation
|
|
105
100
|
};
|
package/dist/package.json.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
version:
|
|
3
|
-
guido:
|
|
1
|
+
const o = "3.30.0-beta.545589d", s = { stripo: { version: "2.87.0" } }, t = {
|
|
2
|
+
version: o,
|
|
3
|
+
guido: s
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
t as default,
|
|
7
|
+
s as guido,
|
|
8
|
+
o as version
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LegacyPaddingViewport, LegacyVariable } from './types';
|
|
2
2
|
export declare function extractTitleText(block: Element): string;
|
|
3
3
|
/**
|
|
4
4
|
* Fallback for legacy configs that carry no `p_recommendation_title` variable:
|
|
@@ -33,20 +33,6 @@ export declare function isPriceOnNextLine(block: Element): boolean;
|
|
|
33
33
|
* @returns The variables, with `textColor` / `textTrimming` filled from the rendered HTML where the theme lacks them
|
|
34
34
|
*/
|
|
35
35
|
export declare function withRenderedTextTheme(variables: LegacyVariable[] | undefined, block: Element): LegacyVariable[] | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Reads the first legacy product button's inline colors, border and internal padding.
|
|
38
|
-
* @param block - The legacy recommendation block element
|
|
39
|
-
* @param theme - The legacy button theme; keys it already holds are not read
|
|
40
|
-
* @returns Only the keys filled from the rendered button, or an empty object
|
|
41
|
-
*/
|
|
42
|
-
export declare function extractRenderedButtonTheme(block: Element, theme?: LegacyButtonTheme): LegacyButtonTheme;
|
|
43
|
-
/**
|
|
44
|
-
* Legacy keeps the product button's colors, border and internal padding inline on the rendered button.
|
|
45
|
-
* @param variables - The legacy composition variables
|
|
46
|
-
* @param block - The legacy recommendation block element
|
|
47
|
-
* @returns The variables, with the `p_button` theme filled from the rendered button where the theme lacks a value
|
|
48
|
-
*/
|
|
49
|
-
export declare function withRenderedButtonTheme(variables: LegacyVariable[] | undefined, block: Element): LegacyVariable[] | undefined;
|
|
50
36
|
/**
|
|
51
37
|
* Card background lives on either the block (`bgcolor`/`style`) or per-card
|
|
52
38
|
* cells (`.product-card`). Returns empty string when no background is set —
|