@useinsider/guido 3.21.2-beta.45bb425 → 3.21.2-beta.4b0fed7
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/useSave.js +68 -75
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
- package/dist/config/migrator/recommendation/extractors.js +68 -29
- package/dist/config/migrator/recommendation/htmlBuilder.js +283 -200
- package/dist/config/migrator/recommendation/settingsMapper.js +35 -32
- package/dist/config/migrator/recommendationMigrator.js +32 -29
- package/dist/extensions/Blocks/Recommendation/block.js +33 -24
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +146 -162
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +1 -2
- package/dist/services/templateLibraryApi.js +31 -36
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
- package/dist/src/config/migrator/recommendation/extractors.d.ts +20 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -8
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +3 -2
- package/dist/src/utils/templatePreparation.d.ts +1 -2
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +0 -22
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +0 -3
|
@@ -1,91 +1,84 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import { useSaveValidation as
|
|
6
|
-
import { useSaveValidationRollout as
|
|
7
|
-
import { useSyncModuleExtractor as
|
|
8
|
-
import { ToasterTypeOptions as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useSaveValidationStore as
|
|
13
|
-
import { useTemplatePreparation as
|
|
14
|
-
import { useAllowlist as
|
|
15
|
-
import { useHtmlValidator as
|
|
16
|
-
import { useToaster as
|
|
17
|
-
import { useCouponBlockValidator as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
if (!v("allowlistEnabled"))
|
|
1
|
+
import { useActionsApi as R } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as q } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as O } from "./useEditorLock.js";
|
|
4
|
+
import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
|
|
5
|
+
import { useSaveValidation as j } from "./useSaveValidation.js";
|
|
6
|
+
import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
|
|
7
|
+
import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
|
|
8
|
+
import { ToasterTypeOptions as I } from "../enums/toaster.js";
|
|
9
|
+
import { useStripoApi as J } from "../services/stripoApi.js";
|
|
10
|
+
import { useConfigStore as K } from "../stores/config.js";
|
|
11
|
+
import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
|
|
12
|
+
import { useSaveValidationStore as Q } from "../stores/save-validation.js";
|
|
13
|
+
import { useTemplatePreparation as X, getHtmlReferencedUnsubscribePages as Y } from "../utils/templatePreparation.js";
|
|
14
|
+
import { useAllowlist as Z } from "./useAllowlist.js";
|
|
15
|
+
import { useHtmlValidator as _ } from "./useHtmlValidator.js";
|
|
16
|
+
import { useToaster as $ } from "./useToaster.js";
|
|
17
|
+
import { useCouponBlockValidator as tt } from "./validators/useCouponBlockValidator.js";
|
|
18
|
+
import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
|
|
19
|
+
import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
|
|
20
|
+
import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
|
|
21
|
+
const Bt = () => {
|
|
22
|
+
const a = D(), p = F(), { validateHtml: v } = _(), { validateLiquidSyntax: S } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: w, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: r, isFeatureEnabled: d } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: H, getTemplateData: V } = R(), { showToaster: x } = $(), { getBlockedDomains: k, resolveToast: C } = Z(), { prepareTemplateDetails: m } = X(), { collectSaveValidationErrors: B } = j(), { isEnabled: h } = z(), T = Q(), P = N(), f = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
|
|
23
|
+
if (!d("allowlistEnabled"))
|
|
25
24
|
return !1;
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
25
|
+
const i = await k(t, e);
|
|
26
|
+
if (!i.length)
|
|
28
27
|
return !1;
|
|
29
|
-
if (!
|
|
30
|
-
const s = await
|
|
31
|
-
s != null && s.message &&
|
|
32
|
-
type:
|
|
28
|
+
if (!o) {
|
|
29
|
+
const s = await C(i);
|
|
30
|
+
s != null && s.message && x({
|
|
31
|
+
type: I.Warning,
|
|
33
32
|
message: s.message,
|
|
34
33
|
actionButton: s.actionButton
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
return !0;
|
|
38
|
-
},
|
|
39
|
-
if (!await
|
|
37
|
+
}, L = async (t) => !y(t.compiledHtml) || !w(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? S(t.compiledHtml) : v(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
|
|
38
|
+
if (!await H())
|
|
40
39
|
return;
|
|
41
|
-
const { unsubscribePayload:
|
|
42
|
-
if (await
|
|
43
|
-
const
|
|
44
|
-
|
|
40
|
+
const { unsubscribePayload: i, stripoModules: s } = b(t.rawHtml);
|
|
41
|
+
if (await g(i), t.modules = s, !e.suppress) {
|
|
42
|
+
const W = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
|
|
43
|
+
p({ ...t, ...W, silent: e.silent });
|
|
45
44
|
}
|
|
46
45
|
return t;
|
|
47
|
-
},
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (l(o.rawHtml, e)) {
|
|
55
|
-
if (P.value && !e) {
|
|
56
|
-
const a = await T(
|
|
46
|
+
}, U = async (t, e) => {
|
|
47
|
+
var i;
|
|
48
|
+
a();
|
|
49
|
+
const o = await m();
|
|
50
|
+
if (n(o.rawHtml, e)) {
|
|
51
|
+
if (h.value && !e) {
|
|
52
|
+
const s = await B(
|
|
57
53
|
o.compiledHtml,
|
|
58
54
|
o.dynamicContentList
|
|
59
55
|
);
|
|
60
|
-
if (
|
|
61
|
-
|
|
56
|
+
if (s.length) {
|
|
57
|
+
T.open(s, "save");
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
64
|
-
} else if (!await
|
|
60
|
+
} else if (!await L(o))
|
|
65
61
|
return;
|
|
66
|
-
if (!((
|
|
67
|
-
return
|
|
62
|
+
if (!((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
|
|
63
|
+
return u(o, { silent: e, suppress: t });
|
|
68
64
|
}
|
|
69
|
-
},
|
|
70
|
-
var
|
|
71
|
-
if (!
|
|
72
|
-
return;
|
|
73
|
-
n();
|
|
74
|
-
const t = await u();
|
|
75
|
-
if (!c(t.html, !1))
|
|
65
|
+
}, A = async () => {
|
|
66
|
+
var e;
|
|
67
|
+
if (!f.allowSaveWithErrors)
|
|
76
68
|
return;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
a();
|
|
70
|
+
const t = await m();
|
|
71
|
+
if (n(t.rawHtml, !1) && !((e = r.value) != null && e.externalValidation && !await r.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
|
|
72
|
+
return u(t, { silent: !1, blankCompiled: !0 });
|
|
73
|
+
}, M = async () => {
|
|
74
|
+
if (!f.allowSaveWithErrors)
|
|
82
75
|
return;
|
|
83
|
-
|
|
84
|
-
const { html: t, css: e } = await
|
|
85
|
-
if (!
|
|
76
|
+
a();
|
|
77
|
+
const { html: t, css: e } = await V();
|
|
78
|
+
if (!n(t, !0) || await c(t, e, !0))
|
|
86
79
|
return;
|
|
87
|
-
const
|
|
88
|
-
dynamicContentList:
|
|
80
|
+
const o = Y(t), i = {
|
|
81
|
+
dynamicContentList: P.getSelectedDynamicContentList,
|
|
89
82
|
compiledHtml: "",
|
|
90
83
|
rawHtml: t,
|
|
91
84
|
css: e,
|
|
@@ -95,16 +88,16 @@ const Pt = () => {
|
|
|
95
88
|
// No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
|
|
96
89
|
recommendation: { configs: {} },
|
|
97
90
|
unsubscribe: {
|
|
98
|
-
status:
|
|
99
|
-
config:
|
|
91
|
+
status: o.length > 0,
|
|
92
|
+
config: o
|
|
100
93
|
}
|
|
101
94
|
};
|
|
102
|
-
return
|
|
95
|
+
return u(i, { silent: !0 });
|
|
103
96
|
};
|
|
104
|
-
return { save: (t = !1, e = !1) =>
|
|
105
|
-
() =>
|
|
106
|
-
), saveWithErrors: () =>
|
|
97
|
+
return { save: (t = !1, e = !1) => l(
|
|
98
|
+
() => U(t, e)
|
|
99
|
+
), saveWithErrors: () => l(A), saveRawOnly: () => l(M) };
|
|
107
100
|
};
|
|
108
101
|
export {
|
|
109
|
-
|
|
102
|
+
Bt as useSave
|
|
110
103
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useConfig as
|
|
1
|
+
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
2
|
import { useRecommendation as O } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
@@ -13,7 +13,7 @@ function A(t) {
|
|
|
13
13
|
[r] = r.children;
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function _(t, r, e, o, c, i) {
|
|
17
17
|
switch (r) {
|
|
18
18
|
case "productImage": {
|
|
19
19
|
const n = t.querySelector("img");
|
|
@@ -78,7 +78,7 @@ function y(t, r, e, o, c, i) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
const P = "name";
|
|
81
|
-
function
|
|
81
|
+
function y(t, r, e, o) {
|
|
82
82
|
const c = `${o}${r}_${e}_${P}`;
|
|
83
83
|
return {
|
|
84
84
|
open: t.createComment(`{% if ${c} and ${c} != "" %}`),
|
|
@@ -86,19 +86,19 @@ function b(t, r, e, o) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function R(t, r, e) {
|
|
89
|
-
return
|
|
89
|
+
return y(t, r, 0, e);
|
|
90
90
|
}
|
|
91
91
|
function w(t, r, e, o) {
|
|
92
92
|
if (!t.innerHTML.includes("{{"))
|
|
93
93
|
return;
|
|
94
|
-
const { open: c, close: i } =
|
|
94
|
+
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
95
95
|
t.insertBefore(c, t.firstChild), t.appendChild(i);
|
|
96
96
|
}
|
|
97
97
|
function D(t, r, e, o) {
|
|
98
98
|
var n, s;
|
|
99
99
|
if (!t.innerHTML.includes("{{"))
|
|
100
100
|
return;
|
|
101
|
-
const { open: c, close: i } =
|
|
101
|
+
const { open: c, close: i } = y(t.ownerDocument, r, e, o);
|
|
102
102
|
(n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
|
|
103
103
|
}
|
|
104
104
|
function v(t, r, e, o) {
|
|
@@ -106,8 +106,8 @@ function v(t, r, e, o) {
|
|
|
106
106
|
i.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
107
107
|
const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
|
|
108
108
|
a.length > 0 ? a.forEach((l) => {
|
|
109
|
-
|
|
110
|
-
}) :
|
|
109
|
+
_(l, u, r, n, e, o);
|
|
110
|
+
}) : _(d, u, r, n, e, o);
|
|
111
111
|
}), D(i, r, n, o);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -119,9 +119,9 @@ function H(t, r, e, o) {
|
|
|
119
119
|
c.forEach((d, u) => {
|
|
120
120
|
d.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
121
121
|
const p = l.getAttribute("data-attribute-type") || "";
|
|
122
|
-
l.querySelectorAll(".attribute-cell").forEach((
|
|
122
|
+
l.querySelectorAll(".attribute-cell").forEach((m, h) => {
|
|
123
123
|
const S = u * s + h;
|
|
124
|
-
|
|
124
|
+
_(m, p, r, S, e, o), w(m, r, S, o);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
});
|
|
@@ -132,10 +132,10 @@ function W(t, r, e, o) {
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
function F(t, r, e) {
|
|
135
|
-
const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
|
|
136
|
-
o === "list" ? v(t, r,
|
|
135
|
+
const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
|
|
136
|
+
o === "list" ? v(t, r, i, e) : W(t, r, i, e);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function b(t, r, e) {
|
|
139
139
|
const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
|
|
140
140
|
return c ? parseInt(c[1]) : e;
|
|
141
141
|
}
|
|
@@ -143,7 +143,7 @@ function $(t) {
|
|
|
143
143
|
const r = t.trim();
|
|
144
144
|
return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function g(t) {
|
|
147
147
|
const r = t.getAttribute("width");
|
|
148
148
|
if (r && $(r))
|
|
149
149
|
return r.trim();
|
|
@@ -153,28 +153,28 @@ function C(t) {
|
|
|
153
153
|
function x(t, r) {
|
|
154
154
|
let e = t.parentElement;
|
|
155
155
|
for (; e && e !== r; ) {
|
|
156
|
-
if (e.tagName === "TD" &&
|
|
156
|
+
if (e.tagName === "TD" && g(e))
|
|
157
157
|
return e;
|
|
158
158
|
e = e.parentElement;
|
|
159
159
|
}
|
|
160
160
|
return null;
|
|
161
161
|
}
|
|
162
162
|
function G(t) {
|
|
163
|
-
const r = t.getAttribute("style") || "", e =
|
|
163
|
+
const r = t.getAttribute("style") || "", e = b(r, "width", 600), o = b(r, "padding", 0) * 2, c = Math.max(0, e - o);
|
|
164
164
|
c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
165
165
|
if (i.hasAttribute("width"))
|
|
166
166
|
return;
|
|
167
167
|
const n = x(i, t);
|
|
168
168
|
if (!n)
|
|
169
169
|
return;
|
|
170
|
-
const s =
|
|
170
|
+
const s = g(n), d = b(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
|
|
171
171
|
if (p) {
|
|
172
172
|
i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
|
|
176
|
-
const
|
|
177
|
-
i.setAttribute("style", `${l}${
|
|
176
|
+
const f = l && !l.trim().endsWith(";") ? "; " : "";
|
|
177
|
+
i.setAttribute("style", `${l}${f}width: ${a}px`);
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -200,15 +200,15 @@ function Q(t) {
|
|
|
200
200
|
return t;
|
|
201
201
|
const { buildCampaignUrl: c } = O(), i = N();
|
|
202
202
|
i.recommendationCampaignUrls = {};
|
|
203
|
-
const { isFeatureEnabled: n } =
|
|
203
|
+
const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
|
|
204
204
|
return o.forEach((u) => {
|
|
205
|
-
var l, p,
|
|
205
|
+
var l, p, f, m;
|
|
206
206
|
const a = u.getAttribute("recommendation-id");
|
|
207
207
|
if (a) {
|
|
208
208
|
if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
|
|
209
209
|
F(u, a, s);
|
|
210
210
|
const { open: h, close: S } = R(e, a, s);
|
|
211
|
-
(
|
|
211
|
+
(f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
|
|
212
212
|
}
|
|
213
213
|
G(u);
|
|
214
214
|
}
|
|
@@ -1,101 +1,108 @@
|
|
|
1
|
-
import { DEFAULT_COMPOSITION as
|
|
2
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
3
|
-
import { mapTextTheme as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
switch (
|
|
1
|
+
import { DEFAULT_COMPOSITION as k, DEFAULT_VISIBILITY as f } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { ATTR_RECOMMENDATION_TITLE as R, ATTR_CUSTOM_PREFIX as x, ATTR_PRODUCT_BUTTON as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as O, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as d, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_IMAGE as b } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { mapTextTheme as C, mapButtonTheme as N, mapImageTheme as P } from "./themeMapper.js";
|
|
4
|
+
const U = "__title__", _ = "product_attribute.";
|
|
5
|
+
function D(n) {
|
|
6
|
+
const s = n.variable ?? "";
|
|
7
|
+
switch (s) {
|
|
8
8
|
case "p_recommendation_title":
|
|
9
|
-
return { key:
|
|
9
|
+
return { key: U, kind: "title" };
|
|
10
10
|
case "p_image":
|
|
11
|
-
return { key:
|
|
11
|
+
return { key: b, kind: "image" };
|
|
12
12
|
case "p_name":
|
|
13
|
-
return { key:
|
|
13
|
+
return { key: y, kind: "text" };
|
|
14
14
|
case "p_price":
|
|
15
|
-
return { key:
|
|
15
|
+
return { key: d, kind: "text" };
|
|
16
16
|
case "p_original_price":
|
|
17
|
-
return { key:
|
|
17
|
+
return { key: a, kind: "text" };
|
|
18
18
|
case "p_omnibus_price":
|
|
19
|
-
return { key:
|
|
19
|
+
return { key: O, kind: "text" };
|
|
20
20
|
case "p_omnibus_discount":
|
|
21
|
-
return { key:
|
|
21
|
+
return { key: h, kind: "text" };
|
|
22
22
|
case "p_button":
|
|
23
|
-
return { key:
|
|
23
|
+
return { key: E, kind: "button" };
|
|
24
24
|
default:
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
25
|
+
if (n.variableType === "p_attribute" || s.startsWith("p_attribute_")) {
|
|
26
|
+
const t = n.value ?? "", o = t.startsWith(_) ? t.slice(_.length) : t;
|
|
27
|
+
if (!o)
|
|
28
28
|
return null;
|
|
29
|
-
const
|
|
29
|
+
const u = t || `${_}${o}`;
|
|
30
30
|
return {
|
|
31
|
-
key: `${
|
|
31
|
+
key: `${x}${u}`,
|
|
32
32
|
kind: "custom",
|
|
33
|
-
customAttrName:
|
|
34
|
-
customAttrValue:
|
|
33
|
+
customAttrName: o,
|
|
34
|
+
customAttrValue: u
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
return
|
|
40
|
+
function I(n) {
|
|
41
|
+
const s = k.indexOf(n);
|
|
42
|
+
return s === -1 ? Number.POSITIVE_INFINITY : s;
|
|
43
|
+
}
|
|
44
|
+
const l = [d, a];
|
|
45
|
+
function S(n, s, t) {
|
|
46
|
+
return n === s || !l.includes(n) || !l.includes(s) ? 0 : n === (t ? a : d) ? -1 : 1;
|
|
43
47
|
}
|
|
44
|
-
function
|
|
48
|
+
function F(n, { oldPriceFirst: s = !1 } = {}) {
|
|
45
49
|
const t = {
|
|
46
50
|
composition: [],
|
|
47
|
-
visibility: { ...
|
|
51
|
+
visibility: { ...f },
|
|
48
52
|
customAttributes: [],
|
|
49
53
|
customAttrValues: {},
|
|
50
54
|
perElementStyles: {},
|
|
51
55
|
anyTextTrimming: !1
|
|
52
56
|
};
|
|
53
|
-
if (!
|
|
54
|
-
return t.composition = [...
|
|
57
|
+
if (!n || n.length === 0)
|
|
58
|
+
return t.composition = [...k], t;
|
|
55
59
|
const o = [];
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
t.titleVariable = e, t.visibility[
|
|
60
|
+
n.forEach((e, i) => {
|
|
61
|
+
const r = D(e);
|
|
62
|
+
if (r) {
|
|
63
|
+
if (r.kind === "title") {
|
|
64
|
+
t.titleVariable = e, t.visibility[R] = e.hidden !== !0;
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
67
|
o.push({
|
|
64
|
-
key:
|
|
65
|
-
kind:
|
|
68
|
+
key: r.key,
|
|
69
|
+
kind: r.kind,
|
|
66
70
|
hidden: e.hidden === !0,
|
|
67
71
|
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
68
72
|
legacy: e,
|
|
69
|
-
customAttrName:
|
|
70
|
-
customAttrValue:
|
|
73
|
+
customAttrName: r.customAttrName,
|
|
74
|
+
customAttrValue: r.customAttrValue,
|
|
71
75
|
originalIndex: i
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
}), o.sort((e, i) => {
|
|
75
79
|
if (e.positionIdx !== i.positionIdx)
|
|
76
80
|
return e.positionIdx - i.positionIdx;
|
|
77
|
-
const
|
|
78
|
-
|
|
81
|
+
const r = S(e.key, i.key, s);
|
|
82
|
+
if (r !== 0)
|
|
83
|
+
return r;
|
|
84
|
+
const m = I(e.key), c = I(i.key);
|
|
85
|
+
return m !== c ? m - c : e.originalIndex - i.originalIndex;
|
|
79
86
|
});
|
|
80
|
-
const
|
|
87
|
+
const u = {};
|
|
81
88
|
return o.forEach((e) => {
|
|
82
|
-
const { key: i, kind:
|
|
83
|
-
switch (t.composition.push(i), t.visibility[i] = !
|
|
89
|
+
const { key: i, kind: r, hidden: m, legacy: c, customAttrName: A, customAttrValue: T } = e;
|
|
90
|
+
switch (t.composition.push(i), t.visibility[i] = !m, r === "custom" && A && T && (t.customAttributes.includes(T) || t.customAttributes.push(T), t.customAttrValues[i] = T), r) {
|
|
84
91
|
case "image":
|
|
85
|
-
|
|
92
|
+
u[i] = P(c.theme);
|
|
86
93
|
break;
|
|
87
94
|
case "button":
|
|
88
|
-
|
|
95
|
+
u[i] = N(c.theme);
|
|
89
96
|
break;
|
|
90
97
|
case "text":
|
|
91
98
|
case "custom": {
|
|
92
|
-
const
|
|
93
|
-
|
|
99
|
+
const p = C(c.theme);
|
|
100
|
+
u[i] = p, p.textTrimming && (t.anyTextTrimming = !0);
|
|
94
101
|
break;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
|
-
}), t.perElementStyles =
|
|
104
|
+
}), t.perElementStyles = u, t;
|
|
98
105
|
}
|
|
99
106
|
export {
|
|
100
|
-
|
|
107
|
+
F as mapComposition
|
|
101
108
|
};
|
|
@@ -1,54 +1,93 @@
|
|
|
1
|
-
import { CURRENCY_ATTR as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
var
|
|
1
|
+
import { CURRENCY_ATTR as c, CSS_CLASS_SKIP_COMPILE as a } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
const m = "You May Also Like!";
|
|
3
|
+
function S(t) {
|
|
4
|
+
var o;
|
|
5
5
|
const e = t.querySelector(".ext-recommendation-title");
|
|
6
6
|
if (!e)
|
|
7
|
-
return
|
|
8
|
-
const r = (
|
|
9
|
-
return r && r.length > 0 ? r :
|
|
7
|
+
return m;
|
|
8
|
+
const r = (o = e.textContent) == null ? void 0 : o.trim();
|
|
9
|
+
return r && r.length > 0 ? r : m;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function T(t) {
|
|
12
12
|
const e = t.querySelector(".ext-recommendation-title");
|
|
13
13
|
return e ? !/display\s*:\s*none/i.test(e.getAttribute("style") ?? "") : !1;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function f(t) {
|
|
16
|
+
var r;
|
|
17
|
+
const e = t.querySelector(".ext-recommendation-title");
|
|
18
|
+
return !!e && !((r = e == null ? void 0 : e.textContent) != null && r.trim());
|
|
19
|
+
}
|
|
20
|
+
function g(t) {
|
|
21
|
+
const e = t.querySelector(".ext-product-price"), r = t.querySelector(".ext-product-original-price");
|
|
22
|
+
return !e || !r ? !1 : e.compareDocumentPosition(r) === Node.DOCUMENT_POSITION_PRECEDING;
|
|
23
|
+
}
|
|
24
|
+
const d = /* @__PURE__ */ new Map([
|
|
25
|
+
["p_name", ".ext-product-name p"],
|
|
26
|
+
["p_price", ".ext-product-price p"],
|
|
27
|
+
["p_original_price", ".ext-product-original-price p"]
|
|
28
|
+
]);
|
|
29
|
+
function p(t) {
|
|
30
|
+
const e = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
|
|
31
|
+
return (e == null ? void 0 : e[1].trim()) || void 0;
|
|
32
|
+
}
|
|
33
|
+
const A = "ins-trim-text";
|
|
34
|
+
function x(t, e) {
|
|
35
|
+
return t == null ? void 0 : t.map((r) => {
|
|
36
|
+
var s, l;
|
|
37
|
+
const o = d.get(r.variable ?? "");
|
|
38
|
+
if (!o)
|
|
39
|
+
return r;
|
|
40
|
+
const n = e.querySelector(o), u = (l = (s = r.theme) == null ? void 0 : s.textColor) != null && l.color ? void 0 : p(n), i = r.variable === "p_name" && (n == null ? void 0 : n.classList.contains(A));
|
|
41
|
+
return !u && !i ? r : {
|
|
42
|
+
...r,
|
|
43
|
+
theme: {
|
|
44
|
+
...r.theme,
|
|
45
|
+
...u ? { textColor: { color: u } } : {},
|
|
46
|
+
...i ? { textTrimming: !0 } : {}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function E(t) {
|
|
16
52
|
const e = [
|
|
17
53
|
t,
|
|
18
54
|
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
19
55
|
];
|
|
20
56
|
let r = "";
|
|
21
|
-
return e.some((
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
return r =
|
|
25
|
-
const
|
|
26
|
-
return
|
|
57
|
+
return e.some((o) => {
|
|
58
|
+
const n = o.getAttribute("bgcolor");
|
|
59
|
+
if (n && n.trim())
|
|
60
|
+
return r = n.trim(), !0;
|
|
61
|
+
const i = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
62
|
+
return i && i[1] ? (r = i[1].trim(), !0) : !1;
|
|
27
63
|
}), r;
|
|
28
64
|
}
|
|
29
|
-
function
|
|
30
|
-
const e = t.getAttribute(
|
|
65
|
+
function _(t) {
|
|
66
|
+
const e = t.getAttribute(c.CURRENCY);
|
|
31
67
|
if (!e)
|
|
32
68
|
return;
|
|
33
|
-
const r = t.getAttribute(
|
|
69
|
+
const r = t.getAttribute(c.SYMBOL);
|
|
34
70
|
return {
|
|
35
71
|
value: e,
|
|
36
72
|
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
37
73
|
// the currency code as the symbol.
|
|
38
74
|
...r ? { symbol: r } : {},
|
|
39
|
-
alignment: t.getAttribute(
|
|
40
|
-
decimalCount: t.getAttribute(
|
|
41
|
-
decimalSeparator: t.getAttribute(
|
|
42
|
-
thousandSeparator: t.getAttribute(
|
|
75
|
+
alignment: t.getAttribute(c.ALIGNMENT) ?? "",
|
|
76
|
+
decimalCount: t.getAttribute(c.DECIMAL_COUNT) ?? "",
|
|
77
|
+
decimalSeparator: t.getAttribute(c.DECIMAL_SEPARATOR) ?? "",
|
|
78
|
+
thousandSeparator: t.getAttribute(c.THOUSAND_SEPARATOR) ?? ""
|
|
43
79
|
};
|
|
44
80
|
}
|
|
45
|
-
function
|
|
46
|
-
return t.classList.contains(
|
|
81
|
+
function y(t) {
|
|
82
|
+
return t.classList.contains(a);
|
|
47
83
|
}
|
|
48
84
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
85
|
+
E as extractCardBgColor,
|
|
86
|
+
_ as extractCurrencyFromBlock,
|
|
87
|
+
S as extractTitleText,
|
|
88
|
+
f as hasEmptyTitle,
|
|
89
|
+
T as hasVisibleTitle,
|
|
90
|
+
g as isOldPriceFirst,
|
|
91
|
+
y as isPartnerManagedBlock,
|
|
92
|
+
x as withRenderedTextTheme
|
|
54
93
|
};
|