@useinsider/guido 3.7.0-beta.b2980d8 → 3.7.0-beta.ec4dd67
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/composables/useHtmlValidator.js +165 -118
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +39 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +44 -33
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -52
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +75 -68
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +13 -12
- package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
- package/dist/extensions/Blocks/Unsubscribe/block.js +72 -122
- package/dist/extensions/Blocks/Unsubscribe/template.js +4 -4
- package/dist/src/composables/useHtmlValidator.d.ts +27 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +0 -9
- package/package.json +1 -1
|
@@ -1,166 +1,213 @@
|
|
|
1
|
-
import { useConfig as
|
|
1
|
+
import { useConfig as M } from "./useConfig.js";
|
|
2
|
+
import { getIgnoredRecommendationBlockIds as P } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
2
3
|
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
3
|
-
import { DISPLAY_CONDITIONS_REGEX as
|
|
4
|
+
import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as $, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as j } from "../enums/html-validator.js";
|
|
4
5
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
6
|
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as U } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
8
|
+
import { useRecommendationExtensionStore as z } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { resolveProductAttrValue as K } from "../extensions/Blocks/Recommendation/templates/utils.js";
|
|
10
|
+
import { RecommendationRequiredFieldsKey as Y } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
11
|
+
import { useRecommendationStore as Z } from "../stores/recommendation.js";
|
|
12
|
+
import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
|
|
13
|
+
import { useHttp as Q } from "./useHttp.js";
|
|
14
|
+
import { useToaster as ee } from "./useToaster.js";
|
|
15
|
+
import { useTranslations as te } from "./useTranslations.js";
|
|
16
|
+
const ne = /recommendation-id="(\d+)"/g;
|
|
17
|
+
function se(n) {
|
|
18
|
+
return [...n.matchAll(ne)].map((m) => m[1]);
|
|
16
19
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
20
|
+
function oe(n, m) {
|
|
21
|
+
return m.some((d) => n.startsWith(`${d}_`));
|
|
19
22
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const ie = /^(\d+)_\d+_(.+)$/;
|
|
24
|
+
function re(n) {
|
|
25
|
+
const m = n.match(ie);
|
|
26
|
+
return m ? { recoId: m[1], attribute: m[2] } : null;
|
|
27
|
+
}
|
|
28
|
+
function ae(n) {
|
|
29
|
+
const m = new Set(U);
|
|
30
|
+
return Object.values(n).forEach((d) => {
|
|
31
|
+
m.add(K(d.attributeName, n).toLowerCase());
|
|
32
|
+
}), m;
|
|
33
|
+
}
|
|
34
|
+
function ce(n, m, d, i, g) {
|
|
35
|
+
const f = n.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
36
|
+
if (!f)
|
|
37
|
+
return [];
|
|
38
|
+
const C = new Set(m.map((h) => h.toLowerCase())), p = [];
|
|
39
|
+
return f.forEach((h) => {
|
|
40
|
+
const u = h.slice(2, -2).trim().toLowerCase();
|
|
41
|
+
if (u !== "" && C.has(u))
|
|
42
|
+
return;
|
|
43
|
+
const y = re(u);
|
|
44
|
+
if (y && i.has(y.recoId)) {
|
|
45
|
+
if (!g || g.has(y.attribute))
|
|
46
|
+
return;
|
|
47
|
+
p.push(u);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
oe(u, d) || u.includes(".") || p.push(u);
|
|
51
|
+
}), p;
|
|
52
|
+
}
|
|
53
|
+
const Ie = () => {
|
|
54
|
+
var A, w;
|
|
55
|
+
const { showToaster: n } = ee(), { post: m } = Q(), { config: d } = M(), i = te(), g = Z(), f = z(), C = ((w = (A = d.value) == null ? void 0 : A.partner) == null ? void 0 : w.messageType) === H.transactional, p = async (e) => {
|
|
56
|
+
if (e.size === 0)
|
|
57
|
+
return /* @__PURE__ */ new Set();
|
|
58
|
+
try {
|
|
59
|
+
await f.fetchRecommendationFilters();
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return ae(f.filterList);
|
|
64
|
+
}, h = async (e) => {
|
|
65
|
+
const t = await m(
|
|
24
66
|
"/newsletter/template-library/check-template-html-body",
|
|
25
|
-
{ html:
|
|
26
|
-
), { status:
|
|
27
|
-
return
|
|
67
|
+
{ html: J(e) }
|
|
68
|
+
), { status: o, message: a } = t.data;
|
|
69
|
+
return o || n({
|
|
28
70
|
type: c.Alert,
|
|
29
|
-
message:
|
|
30
|
-
}),
|
|
71
|
+
message: o === void 0 ? a : i("newsletter.invalid-url-link-for-toaster")
|
|
72
|
+
}), i(X), a === i(j) && n({
|
|
31
73
|
type: c.Alert,
|
|
32
|
-
message:
|
|
33
|
-
}),
|
|
34
|
-
},
|
|
74
|
+
message: i("newsletter.already-in-progress")
|
|
75
|
+
}), o;
|
|
76
|
+
}, u = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), y = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
|
|
35
77
|
const t = e.match(/({%(.*?)%})/g);
|
|
36
|
-
let
|
|
37
|
-
return t !== null && !
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const [
|
|
41
|
-
|
|
78
|
+
let o = !0;
|
|
79
|
+
return t !== null && !C && t.forEach((a) => {
|
|
80
|
+
const r = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
81
|
+
if (r && r.length > 0) {
|
|
82
|
+
const [l] = r;
|
|
83
|
+
u(l) && !s.includes(l) && (n({
|
|
42
84
|
type: c.Warning,
|
|
43
|
-
message:
|
|
44
|
-
}),
|
|
85
|
+
message: i("custom-fields.invalid-custom-fields")
|
|
86
|
+
}), o = !1);
|
|
45
87
|
}
|
|
46
|
-
}),
|
|
47
|
-
},
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
},
|
|
88
|
+
}), o;
|
|
89
|
+
}, R = async (e, s, t) => {
|
|
90
|
+
const o = t ? await h(e) : !0;
|
|
91
|
+
return I(e, s) && o;
|
|
92
|
+
}, T = (e) => e.length > 0 ? !0 : (n({
|
|
51
93
|
type: c.Warning,
|
|
52
|
-
message:
|
|
53
|
-
}), !1),
|
|
94
|
+
message: i("newsletter.html-content-is-empty")
|
|
95
|
+
}), !1), k = (e) => {
|
|
54
96
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
55
|
-
return s > t &&
|
|
97
|
+
return s > t && n({
|
|
56
98
|
type: c.Warning,
|
|
57
|
-
message:
|
|
58
|
-
}), s < t &&
|
|
99
|
+
message: i("custom-fields.missing-closing-braces")
|
|
100
|
+
}), s < t && n({
|
|
59
101
|
type: c.Warning,
|
|
60
|
-
message:
|
|
102
|
+
message: i("custom-fields.missing-opening-braces")
|
|
61
103
|
}), s === t;
|
|
62
|
-
},
|
|
104
|
+
}, x = (e) => {
|
|
63
105
|
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
64
|
-
return s ||
|
|
106
|
+
return s || n({
|
|
65
107
|
type: c.Warning,
|
|
66
|
-
message:
|
|
108
|
+
message: i("custom-fields.invalid-custom-fields")
|
|
67
109
|
}), s;
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
110
|
+
}, N = (e, s, t, o) => {
|
|
111
|
+
if (C)
|
|
112
|
+
return !0;
|
|
113
|
+
const a = ce(
|
|
114
|
+
e,
|
|
115
|
+
s,
|
|
116
|
+
se(e),
|
|
117
|
+
t,
|
|
118
|
+
o
|
|
119
|
+
);
|
|
120
|
+
if (a.length > 0) {
|
|
121
|
+
const r = `
|
|
122
|
+
<ul>
|
|
123
|
+
${a.map((l) => `<li>${l}</li>`).join("")}
|
|
124
|
+
</ul>
|
|
125
|
+
`;
|
|
126
|
+
return n({
|
|
127
|
+
type: c.Alert,
|
|
128
|
+
message: i("custom-fields.invalid-custom-fields") + r
|
|
129
|
+
}), !1;
|
|
86
130
|
}
|
|
87
131
|
return !0;
|
|
88
|
-
},
|
|
132
|
+
}, F = (e) => {
|
|
89
133
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
90
|
-
let
|
|
91
|
-
if (s && s.forEach((
|
|
92
|
-
const
|
|
93
|
-
(!
|
|
134
|
+
let o = !0;
|
|
135
|
+
if (s && s.forEach((a) => {
|
|
136
|
+
const r = a.match(G), l = a.match($), E = (r == null ? void 0 : r.join("")) || "";
|
|
137
|
+
(!r || a !== E) && !l && (n({
|
|
94
138
|
type: c.Alert,
|
|
95
|
-
message:
|
|
96
|
-
}),
|
|
97
|
-
|
|
139
|
+
message: i("newsletter.display-conditions-invalid-syntax")
|
|
140
|
+
}), o = !1), r && r.forEach((v) => {
|
|
141
|
+
v.trim() === "=" && (n({
|
|
98
142
|
type: c.Alert,
|
|
99
|
-
message:
|
|
100
|
-
}),
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
143
|
+
message: i("custom-conditions.wrong-equality-operators")
|
|
144
|
+
}), o = !1);
|
|
145
|
+
const b = v.match(/^[a-zA-Z]*$/g);
|
|
146
|
+
b && b.forEach((S) => {
|
|
147
|
+
y(S) && t.push(S);
|
|
104
148
|
});
|
|
105
149
|
});
|
|
106
150
|
}), t.length) {
|
|
107
|
-
const
|
|
108
|
-
|
|
151
|
+
const a = t.filter((l) => l === "if"), r = t.filter((l) => l === "endif");
|
|
152
|
+
a.length !== r.length && (n({
|
|
109
153
|
type: c.Alert,
|
|
110
|
-
message:
|
|
111
|
-
}),
|
|
154
|
+
message: i("custom-conditions.missing-if-endif-tag")
|
|
155
|
+
}), o = !1);
|
|
112
156
|
}
|
|
113
|
-
return
|
|
157
|
+
return o;
|
|
114
158
|
}, B = (e) => {
|
|
115
|
-
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length,
|
|
116
|
-
return
|
|
159
|
+
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, o = s === t;
|
|
160
|
+
return o || n({
|
|
117
161
|
type: c.Warning,
|
|
118
|
-
message:
|
|
119
|
-
}),
|
|
120
|
-
},
|
|
162
|
+
message: i("custom-conditions.no-space-after-braces")
|
|
163
|
+
}), o;
|
|
164
|
+
}, O = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, o) => t + o, 0) > 0 ? (n({
|
|
121
165
|
type: c.Warning,
|
|
122
|
-
message:
|
|
123
|
-
}), !1) : !0,
|
|
166
|
+
message: i("custom-conditions.no-braces-inside-if-tag")
|
|
167
|
+
}), !1) : !0, _ = () => f.hasInvalidBlock() ? (n({
|
|
124
168
|
type: c.Alert,
|
|
125
|
-
message:
|
|
126
|
-
}), !1) : !0,
|
|
169
|
+
message: i(Y)
|
|
170
|
+
}), !1) : !0, L = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (n({
|
|
127
171
|
type: c.Alert,
|
|
128
|
-
message:
|
|
129
|
-
}), !1) : !0,
|
|
172
|
+
message: i("newsletter.fill-all-necessary-fields")
|
|
173
|
+
}), !1) : !0, V = (e) => {
|
|
130
174
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
131
|
-
return e.match(s) === null ? !0 : (
|
|
175
|
+
return e.match(s) === null ? !0 : (n({
|
|
132
176
|
type: c.Alert,
|
|
133
|
-
message:
|
|
177
|
+
message: i("newsletter.invalid-image-type")
|
|
134
178
|
}), !1);
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
return Array.from(
|
|
138
|
-
var
|
|
139
|
-
return !((
|
|
140
|
-
}) ? (
|
|
179
|
+
}, W = (e) => {
|
|
180
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
181
|
+
return Array.from(o).find((r) => {
|
|
182
|
+
var l;
|
|
183
|
+
return !((l = r.id) != null && l.trim());
|
|
184
|
+
}) ? (n({
|
|
141
185
|
type: c.Alert,
|
|
142
|
-
message:
|
|
186
|
+
message: i("unsubscribe-templates.select-checkbox-groups")
|
|
143
187
|
}), !1) : !0;
|
|
144
|
-
},
|
|
145
|
-
const
|
|
146
|
-
return Array.from(
|
|
147
|
-
var
|
|
148
|
-
return !((
|
|
149
|
-
}) ? (
|
|
188
|
+
}, D = (e) => {
|
|
189
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
190
|
+
return Array.from(o).find((r) => {
|
|
191
|
+
var l;
|
|
192
|
+
return !((l = r.id) != null && l.trim());
|
|
193
|
+
}) ? (n({
|
|
150
194
|
type: c.Alert,
|
|
151
|
-
message:
|
|
195
|
+
message: i("unsubscribe-templates.select-radio-button-groups")
|
|
152
196
|
}), !1) : !0;
|
|
153
197
|
};
|
|
154
198
|
return { validateHtml: async (e, s, t = !1) => {
|
|
155
|
-
var
|
|
156
|
-
const
|
|
157
|
-
...s.map((
|
|
199
|
+
var E, v;
|
|
200
|
+
const o = [
|
|
201
|
+
...s.map((b) => b.value),
|
|
158
202
|
...q,
|
|
159
|
-
...((
|
|
160
|
-
];
|
|
161
|
-
return await
|
|
203
|
+
...((v = (E = d.value) == null ? void 0 : E.template) == null ? void 0 : v.customFieldAttributes) ?? []
|
|
204
|
+
], a = P(e), r = await p(a);
|
|
205
|
+
return await R(e, o, t) && T(e) && k(e) && x(e) && N(e, o, a, r) && F(e) && B(e) && O(e) && _() && L() && V(e) && W(e) && D(e);
|
|
162
206
|
} };
|
|
163
207
|
};
|
|
164
208
|
export {
|
|
165
|
-
|
|
209
|
+
ae as buildPartnerAttributeNameSet,
|
|
210
|
+
ce as findInvalidCustomFields,
|
|
211
|
+
re as parseRecommendationVariable,
|
|
212
|
+
Ie as useHtmlValidator
|
|
166
213
|
};
|
|
@@ -2,6 +2,7 @@ import { useConfig as g } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
5
6
|
function y(r, n, e, o, i = "") {
|
|
6
7
|
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
7
8
|
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
@@ -12,7 +13,7 @@ function A(r) {
|
|
|
12
13
|
[n] = n.children;
|
|
13
14
|
return n;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function b(r, n, e, o, i, c) {
|
|
16
17
|
switch (n) {
|
|
17
18
|
case "productImage": {
|
|
18
19
|
const t = r.querySelector("img");
|
|
@@ -87,45 +88,45 @@ function f(r, n, e, o, i, c) {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
+
function E(r, n, e, o) {
|
|
91
92
|
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
92
93
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
93
94
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
94
95
|
p.length > 0 ? p.forEach((l) => {
|
|
95
|
-
|
|
96
|
-
}) :
|
|
96
|
+
b(l, u, n, t, e, o);
|
|
97
|
+
}) : b(a, u, n, t, e, o);
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function R(r, n, e, o) {
|
|
101
102
|
const i = r.querySelectorAll(".recommendation-product-row");
|
|
102
103
|
if (!i.length)
|
|
103
104
|
return;
|
|
104
105
|
const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
105
106
|
i.forEach((a, u) => {
|
|
106
107
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
107
|
-
const
|
|
108
|
+
const m = l.getAttribute("data-attribute-type") || "";
|
|
108
109
|
l.querySelectorAll(".attribute-cell").forEach((h, $) => {
|
|
109
110
|
const S = u * s + $;
|
|
110
|
-
|
|
111
|
+
b(h, m, n, S, e, o);
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function P(r, n, e, o) {
|
|
116
117
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
117
|
-
|
|
118
|
+
R(c, n, e, o);
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
+
function T(r, n, e) {
|
|
121
122
|
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
122
|
-
o === "list" ?
|
|
123
|
+
o === "list" ? E(r, n, i, e) : P(r, n, i, e);
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function f(r, n, e) {
|
|
125
126
|
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
126
127
|
return i ? parseInt(i[1]) : e;
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function v(r, n) {
|
|
129
130
|
let e = r.parentElement;
|
|
130
131
|
for (; e && e !== n; ) {
|
|
131
132
|
if (e.tagName === "TD") {
|
|
@@ -137,29 +138,29 @@ function T(r, n) {
|
|
|
137
138
|
}
|
|
138
139
|
return null;
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
const n = r.getAttribute("style") || "", e =
|
|
141
|
+
function O(r) {
|
|
142
|
+
const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
142
143
|
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
143
144
|
if (c.hasAttribute("width"))
|
|
144
145
|
return;
|
|
145
|
-
const t =
|
|
146
|
+
const t = v(c, r);
|
|
146
147
|
if (!t)
|
|
147
148
|
return;
|
|
148
|
-
const s = t.getAttribute("width"), a = parseFloat(s), u =
|
|
149
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
149
150
|
c.setAttribute("width", String(l));
|
|
150
|
-
const
|
|
151
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
152
|
-
const
|
|
153
|
-
c.setAttribute("style", `${
|
|
151
|
+
const m = c.getAttribute("style") || "";
|
|
152
|
+
if (!/\bwidth\s*:\s*\d/i.test(m)) {
|
|
153
|
+
const d = m && !m.trim().endsWith(";") ? "; " : "";
|
|
154
|
+
c.setAttribute("style", `${m}${d}width: ${l}px`);
|
|
154
155
|
}
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function W(r, n) {
|
|
158
159
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
159
160
|
return (e ? `${e[0]}
|
|
160
161
|
` : "") + n.documentElement.outerHTML;
|
|
161
162
|
}
|
|
162
|
-
function
|
|
163
|
+
function F(r) {
|
|
163
164
|
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
164
165
|
if (!o.length)
|
|
165
166
|
return r;
|
|
@@ -167,12 +168,12 @@ function N(r) {
|
|
|
167
168
|
c.recommendationCampaignUrls = {};
|
|
168
169
|
const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
|
|
169
170
|
return o.forEach((u) => {
|
|
170
|
-
var l,
|
|
171
|
+
var l, m;
|
|
171
172
|
const p = u.getAttribute("recommendation-id");
|
|
172
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (
|
|
173
|
-
}),
|
|
173
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), i(p), w(u) || T(u, p, s), O(u));
|
|
174
|
+
}), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
174
175
|
}
|
|
175
176
|
export {
|
|
176
177
|
y as formatPriceVariable,
|
|
177
|
-
|
|
178
|
+
F as prepareRecommendationBlocks
|
|
178
179
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CSS_CLASS_SKIP_COMPILE as n, BLOCK_ROOT_SELECTOR as i } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
function m(o) {
|
|
3
|
+
return o.classList.contains(n);
|
|
4
|
+
}
|
|
5
|
+
function a(o) {
|
|
6
|
+
const r = new DOMParser().parseFromString(o, "text/html").querySelectorAll(`${i}.${n}`), t = /* @__PURE__ */ new Set();
|
|
7
|
+
return r.forEach((c) => {
|
|
8
|
+
const e = c.getAttribute("recommendation-id");
|
|
9
|
+
e && t.add(e);
|
|
10
|
+
}), t;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
a as getIgnoredRecommendationBlockIds,
|
|
14
|
+
m as isIgnoredRecommendationBlock
|
|
15
|
+
};
|
|
@@ -1,27 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const a = "You May Also Like!";
|
|
3
|
+
function l(t) {
|
|
4
|
+
var o;
|
|
5
|
+
const r = t.querySelector(".ext-recommendation-title");
|
|
6
|
+
if (!r)
|
|
7
|
+
return a;
|
|
8
|
+
const e = (o = r.textContent) == null ? void 0 : o.trim();
|
|
9
|
+
return e && e.length > 0 ? e : a;
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
...Array.from(
|
|
11
|
+
function m(t) {
|
|
12
|
+
const r = [
|
|
13
|
+
t,
|
|
14
|
+
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
15
|
];
|
|
15
|
-
let
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
}),
|
|
16
|
+
let e = "";
|
|
17
|
+
return r.some((o) => {
|
|
18
|
+
const i = o.getAttribute("bgcolor");
|
|
19
|
+
if (i && i.trim())
|
|
20
|
+
return e = i.trim(), !0;
|
|
21
|
+
const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
22
|
+
return u && u[1] ? (e = u[1].trim(), !0) : !1;
|
|
23
|
+
}), e;
|
|
24
|
+
}
|
|
25
|
+
function C(t) {
|
|
26
|
+
const r = t.getAttribute(n.CURRENCY);
|
|
27
|
+
if (!r)
|
|
28
|
+
return;
|
|
29
|
+
const e = t.getAttribute(n.SYMBOL);
|
|
30
|
+
return {
|
|
31
|
+
value: r,
|
|
32
|
+
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
33
|
+
// the currency code as the symbol.
|
|
34
|
+
...e ? { symbol: e } : {},
|
|
35
|
+
alignment: t.getAttribute(n.ALIGNMENT) ?? "",
|
|
36
|
+
decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
|
|
37
|
+
decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
|
|
38
|
+
thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function d(t) {
|
|
42
|
+
return t.classList.contains(c);
|
|
23
43
|
}
|
|
24
44
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
m as extractCardBgColor,
|
|
46
|
+
C as extractCurrencyFromBlock,
|
|
47
|
+
l as extractTitleText,
|
|
48
|
+
d as isPartnerManagedBlock
|
|
27
49
|
};
|