@useinsider/guido 3.9.0-beta.ba394b1 → 3.9.0-beta.c6ff11c
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/useCustomInterfaceAppearance.js +18 -16
- package/dist/composables/useStripo.js +37 -39
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +118 -110
- package/dist/config/migrator/itemsBlockMigrator.js +159 -114
- package/dist/enums/toaster.js +2 -2
- package/dist/extensions/Blocks/Items/block.js +57 -37
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +67 -78
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +13 -9
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +26 -14
- package/dist/extensions/Blocks/Items/template.js +245 -247
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +53 -45
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +15 -15
- package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
- package/dist/services/templateLibraryApi.js +8 -9
- package/dist/src/enums/toaster.d.ts +2 -2
- package/dist/src/extensions/Blocks/Items/block.d.ts +9 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +7 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +12 -0
- package/dist/src/stores/toaster.d.ts +3 -2
- package/dist/static/styles/components/notification.css.js +74 -0
- package/dist/stores/toaster.js +10 -10
- package/dist/utils/pairProductVariables.js +64 -65
- package/package.json +2 -2
- package/dist/composables/useStripoNotifications.js +0 -26
- package/dist/src/composables/useStripoNotifications.d.ts +0 -10
|
@@ -4,20 +4,21 @@ import e from "../static/styles/components/amp-block.css.js";
|
|
|
4
4
|
import i from "../static/styles/components/base-input.css.js";
|
|
5
5
|
import p from "../static/styles/components/button-group.css.js";
|
|
6
6
|
import n from "../static/styles/components/button.css.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import C from "../static/styles/components/combobox.css.js";
|
|
8
|
+
import s from "../static/styles/components/counter.css.js";
|
|
9
9
|
import f from "../static/styles/components/dropdown-menu.css.js";
|
|
10
10
|
import a from "../static/styles/components/loader.css.js";
|
|
11
11
|
import u from "../static/styles/components/narrow-panel.css.js";
|
|
12
|
-
import c from "../static/styles/components/
|
|
13
|
-
import d from "../static/styles/components/
|
|
14
|
-
import l from "../static/styles/components/
|
|
15
|
-
import h from "../static/styles/components/
|
|
16
|
-
import w from "../static/styles/components/
|
|
17
|
-
import y from "../static/styles/components/
|
|
18
|
-
import B from "../static/styles/
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
import c from "../static/styles/components/notification.css.js";
|
|
13
|
+
import d from "../static/styles/components/popup.css.js";
|
|
14
|
+
import l from "../static/styles/components/switcher.css.js";
|
|
15
|
+
import h from "../static/styles/components/tabs.css.js";
|
|
16
|
+
import w from "../static/styles/components/tools.css.js";
|
|
17
|
+
import y from "../static/styles/components/version-history.css.js";
|
|
18
|
+
import B from "../static/styles/components/wide-panel.css.js";
|
|
19
|
+
import b from "../static/styles/variables.css.js";
|
|
20
|
+
const A = [
|
|
21
|
+
b,
|
|
21
22
|
// Must be on top
|
|
22
23
|
S,
|
|
23
24
|
// Must be on top
|
|
@@ -26,8 +27,8 @@ const b = [
|
|
|
26
27
|
i,
|
|
27
28
|
p,
|
|
28
29
|
n,
|
|
29
|
-
s,
|
|
30
30
|
C,
|
|
31
|
+
s,
|
|
31
32
|
f,
|
|
32
33
|
a,
|
|
33
34
|
u,
|
|
@@ -36,12 +37,13 @@ const b = [
|
|
|
36
37
|
l,
|
|
37
38
|
h,
|
|
38
39
|
w,
|
|
39
|
-
y
|
|
40
|
+
y,
|
|
41
|
+
B
|
|
40
42
|
].join(`
|
|
41
43
|
|
|
42
|
-
`),
|
|
44
|
+
`), F = () => ({ importCss: () => {
|
|
43
45
|
const o = new CSSStyleSheet();
|
|
44
|
-
o.replaceSync(
|
|
46
|
+
o.replaceSync(A);
|
|
45
47
|
const r = document.querySelector("ui-editor");
|
|
46
48
|
if (!r)
|
|
47
49
|
return;
|
|
@@ -49,5 +51,5 @@ const b = [
|
|
|
49
51
|
t && (t.adoptedStyleSheets = [o]);
|
|
50
52
|
} });
|
|
51
53
|
export {
|
|
52
|
-
|
|
54
|
+
F as useCustomInterfaceAppearance
|
|
53
55
|
};
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useFullStoryBridge as
|
|
6
|
-
import { useStripoEventHandler as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { localePatch as L } from "../config/i18n/index.js";
|
|
1
|
+
import { useActionsApi as I } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as U } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as R } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as x } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useFullStoryBridge as O } from "./useFullStoryBridge.js";
|
|
6
|
+
import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
|
|
7
|
+
import { useToaster as H } from "./useToaster.js";
|
|
8
|
+
import { localePatch as z } from "../config/i18n/index.js";
|
|
10
9
|
import { en as h } from "../config/i18n/en/index.js";
|
|
11
|
-
import { ToasterTypeOptions as
|
|
12
|
-
import { useStripoApi as
|
|
13
|
-
import
|
|
10
|
+
import { ToasterTypeOptions as L } from "../enums/toaster.js";
|
|
11
|
+
import { useStripoApi as $ } from "../services/stripoApi.js";
|
|
12
|
+
import G from "../static/styles/customEditorStyle.css.js";
|
|
14
13
|
import { useEditorStore as C } from "../stores/editor.js";
|
|
15
|
-
import { dynamicContentToMergeTags as
|
|
16
|
-
import
|
|
17
|
-
const
|
|
18
|
-
const { features: c, template: w, isFeatureEnabled: u } =
|
|
14
|
+
import { dynamicContentToMergeTags as J } from "../utils/genericUtil.js";
|
|
15
|
+
import N from "../package.json.js";
|
|
16
|
+
const ce = (E, l) => {
|
|
17
|
+
const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
|
|
19
18
|
var g, S, y;
|
|
20
|
-
const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0,
|
|
19
|
+
const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
|
|
21
20
|
await window.UIEditor.initEditor(
|
|
22
21
|
document.querySelector("#guido-editor"),
|
|
23
22
|
{
|
|
24
23
|
metadata: E,
|
|
25
24
|
html: p,
|
|
26
25
|
css: a,
|
|
27
|
-
forceRecreate:
|
|
26
|
+
forceRecreate: M,
|
|
28
27
|
locale: "en",
|
|
29
28
|
undoButtonSelector: "#guido__undo-button",
|
|
30
29
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -34,12 +33,12 @@ const pe = (E, l) => {
|
|
|
34
33
|
customAppearanceMergetags: !u("liquidSyntax"),
|
|
35
34
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
36
35
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
37
|
-
customViewStyles:
|
|
36
|
+
customViewStyles: G,
|
|
38
37
|
conditionsEnabled: f,
|
|
39
38
|
customConditionsEnabled: f,
|
|
40
39
|
enableXSSSecurity: !0,
|
|
41
|
-
modulesDisabled:
|
|
42
|
-
syncModulesEnabled:
|
|
40
|
+
modulesDisabled: A,
|
|
41
|
+
syncModulesEnabled: i,
|
|
43
42
|
messageSettingsEnabled: !0,
|
|
44
43
|
displayGmailAnnotations: !0,
|
|
45
44
|
displayHiddenPreheader: !1,
|
|
@@ -52,11 +51,11 @@ const pe = (E, l) => {
|
|
|
52
51
|
editorFonts: {
|
|
53
52
|
showDefaultStandardFonts: !0,
|
|
54
53
|
showDefaultNotStandardFonts: !0,
|
|
55
|
-
customFonts:
|
|
54
|
+
customFonts: r
|
|
56
55
|
},
|
|
57
56
|
mergeTags: [
|
|
58
57
|
{
|
|
59
|
-
entries:
|
|
58
|
+
entries: J(
|
|
60
59
|
l.preselectedDynamicContentList,
|
|
61
60
|
u("liquidSyntax")
|
|
62
61
|
)
|
|
@@ -72,8 +71,8 @@ const pe = (E, l) => {
|
|
|
72
71
|
},
|
|
73
72
|
onTemplateLoaded() {
|
|
74
73
|
try {
|
|
75
|
-
const { importCss: o } =
|
|
76
|
-
o(), n(),
|
|
74
|
+
const { importCss: o } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
|
|
75
|
+
o(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
77
76
|
e.hasChanges = !1;
|
|
78
77
|
}, 1e3);
|
|
79
78
|
} catch (o) {
|
|
@@ -93,42 +92,41 @@ const pe = (E, l) => {
|
|
|
93
92
|
e.hasChanges = !0;
|
|
94
93
|
},
|
|
95
94
|
onEvent: F,
|
|
96
|
-
notifications: V(),
|
|
97
95
|
ignoreClickOutsideSelectors: [
|
|
98
96
|
"#guido-dynamic-content-modal",
|
|
99
97
|
".in-on-board-wrapper",
|
|
100
98
|
".in-drawer__container"
|
|
101
99
|
],
|
|
102
100
|
extensions: d,
|
|
103
|
-
localePatch:
|
|
101
|
+
localePatch: z
|
|
104
102
|
}
|
|
105
103
|
);
|
|
106
|
-
},
|
|
104
|
+
}, _ = (s) => new Promise((r, i) => {
|
|
107
105
|
var d;
|
|
108
106
|
if (document.getElementById("UiEditorScript")) {
|
|
109
|
-
Promise.resolve(s()).then(
|
|
107
|
+
Promise.resolve(s()).then(r, i);
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
|
-
const e =
|
|
110
|
+
const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
|
|
113
111
|
t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
|
|
114
|
-
Promise.resolve(s()).then(
|
|
112
|
+
Promise.resolve(s()).then(r, i);
|
|
115
113
|
}, t.onerror = () => {
|
|
116
|
-
|
|
114
|
+
i(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
117
115
|
}, document.body.appendChild(t);
|
|
118
116
|
});
|
|
119
117
|
return { initPlugin: async (s) => {
|
|
120
|
-
const
|
|
118
|
+
const r = C();
|
|
121
119
|
try {
|
|
122
|
-
await
|
|
123
|
-
const [
|
|
120
|
+
await _(async () => {
|
|
121
|
+
const [i, e] = await Promise.all([
|
|
124
122
|
k(),
|
|
125
123
|
B()
|
|
126
124
|
]);
|
|
127
|
-
|
|
125
|
+
r.syncModulesEnabled = e, await V(s, i, e);
|
|
128
126
|
});
|
|
129
127
|
} catch {
|
|
130
|
-
|
|
131
|
-
type:
|
|
128
|
+
r.loadingStatus = !1, b({
|
|
129
|
+
type: L.Alert,
|
|
132
130
|
message: h["An error has occurred. Please report the error code to support."],
|
|
133
131
|
actionButton: {
|
|
134
132
|
text: h["Reload page"],
|
|
@@ -139,5 +137,5 @@ const pe = (E, l) => {
|
|
|
139
137
|
} };
|
|
140
138
|
};
|
|
141
139
|
export {
|
|
142
|
-
|
|
140
|
+
ce as useStripo
|
|
143
141
|
};
|
|
@@ -1,181 +1,189 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import { isIgnoredRecommendationBlock as
|
|
6
|
-
function
|
|
7
|
-
const i = `{{${
|
|
8
|
-
return
|
|
1
|
+
import { useConfig as q } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as C } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function f(t, o, e, n, s = "") {
|
|
7
|
+
const i = `{{${s}${t}_${o}_${e}}}`, r = `{{${s}${t}_${o}_currency}}`;
|
|
8
|
+
return n === "before" ? `${r} ${i}` : `${i} ${r}`;
|
|
9
9
|
}
|
|
10
|
-
function m(
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
10
|
+
function m(t) {
|
|
11
|
+
let o = t;
|
|
12
|
+
for (; o.children.length === 1; )
|
|
13
|
+
[o] = o.children;
|
|
14
|
+
return o;
|
|
15
15
|
}
|
|
16
|
-
function h(
|
|
17
|
-
switch (
|
|
16
|
+
function h(t, o, e, n, s, i) {
|
|
17
|
+
switch (o) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const r =
|
|
20
|
-
r && (r.setAttribute("src", `{{${i}${
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const r = t.querySelector("img");
|
|
20
|
+
r && (r.setAttribute("src", `{{${i}${e}_${n}_image_url}}`), r.setAttribute("alt", `{{${i}${e}_${n}_name}}`));
|
|
21
|
+
const c = t.querySelector("a");
|
|
22
|
+
c && (c.setAttribute("href", `{{${i}${e}_${n}_url}}`), c.classList.add(E));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const r =
|
|
27
|
-
r && (m(r).textContent = `{{${i}${
|
|
26
|
+
const r = t.querySelector("p");
|
|
27
|
+
r && (m(r).textContent = `{{${i}${e}_${n}_name}}`);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
case "productPrice": {
|
|
31
|
-
const r =
|
|
32
|
-
r && (m(r).textContent =
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const r = t.querySelector(".product-price p") ?? t.querySelector("p");
|
|
32
|
+
r && (m(r).textContent = f(
|
|
33
|
+
e,
|
|
34
|
+
n,
|
|
35
35
|
"price",
|
|
36
|
-
|
|
36
|
+
s,
|
|
37
37
|
i
|
|
38
38
|
));
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const c = t.querySelector(".product-old-price p");
|
|
40
|
+
c && (m(c).textContent = f(
|
|
41
|
+
e,
|
|
42
|
+
n,
|
|
43
43
|
"original_price",
|
|
44
|
-
|
|
44
|
+
s,
|
|
45
45
|
i
|
|
46
46
|
));
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case "productOldPrice": {
|
|
50
|
-
const r =
|
|
51
|
-
r && (m(r).textContent =
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const r = t.querySelector("p");
|
|
51
|
+
r && (m(r).textContent = f(
|
|
52
|
+
e,
|
|
53
|
+
n,
|
|
54
54
|
"original_price",
|
|
55
|
-
|
|
55
|
+
s,
|
|
56
56
|
i
|
|
57
57
|
));
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
case "productButton": {
|
|
61
|
-
const r =
|
|
62
|
-
r && r.setAttribute("href", `{{${i}${
|
|
61
|
+
const r = t.querySelector("a");
|
|
62
|
+
r && r.setAttribute("href", `{{${i}${e}_${n}_url}}`);
|
|
63
63
|
break;
|
|
64
64
|
}
|
|
65
65
|
case "productOmnibusPrice": {
|
|
66
|
-
const r =
|
|
66
|
+
const r = t.querySelector(".omnibus-price-value");
|
|
67
67
|
if (r) {
|
|
68
|
-
r.textContent = `{{${i}${
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
r.textContent = `{{${i}${e}_${n}_omnibus_price}}`;
|
|
69
|
+
const c = r.closest("p");
|
|
70
|
+
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
71
71
|
}
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
case "productOmnibusDiscount": {
|
|
75
|
-
const r =
|
|
75
|
+
const r = t.querySelector(".omnibus-discount-value");
|
|
76
76
|
if (r) {
|
|
77
|
-
r.textContent = `{{${i}${
|
|
78
|
-
const
|
|
79
|
-
|
|
77
|
+
r.textContent = `{{${i}${e}_${n}_omnibus_discount}}`;
|
|
78
|
+
const c = r.closest("p");
|
|
79
|
+
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
80
80
|
}
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
default: {
|
|
84
|
-
const r =
|
|
84
|
+
const r = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
85
85
|
if (r) {
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const c = r.getAttribute("product-attr"), l = r.querySelector("p");
|
|
87
|
+
l && (m(l).textContent = `{{${i}${e}_${n}_${c}}}`);
|
|
88
88
|
}
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
i.querySelectorAll("[data-attribute-type]").forEach((
|
|
96
|
-
const u =
|
|
97
|
-
p.length > 0 ? p.forEach((
|
|
98
|
-
h(
|
|
99
|
-
}) : h(
|
|
93
|
+
function R(t, o, e, n) {
|
|
94
|
+
t.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
|
|
95
|
+
i.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
96
|
+
const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
|
|
97
|
+
p.length > 0 ? p.forEach((a) => {
|
|
98
|
+
h(a, u, o, r, e, n);
|
|
99
|
+
}) : h(l, u, o, r, e, n);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
103
|
+
function W(t, o, e, n) {
|
|
104
|
+
const s = t.querySelectorAll(".recommendation-product-row");
|
|
105
|
+
if (!s.length)
|
|
106
106
|
return;
|
|
107
|
-
const [i] =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const d =
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
h(
|
|
107
|
+
const [i] = s, r = i.querySelector("[data-attribute-type]"), c = r ? r.querySelectorAll(".attribute-cell").length : 1;
|
|
108
|
+
s.forEach((l, u) => {
|
|
109
|
+
l.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
110
|
+
const d = a.getAttribute("data-attribute-type") || "";
|
|
111
|
+
a.querySelectorAll(".attribute-cell").forEach((S, _) => {
|
|
112
|
+
const g = u * c + _;
|
|
113
|
+
h(S, d, o, g, e, n);
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
function v(t, o, e, n) {
|
|
119
|
+
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
120
|
+
W(i, o, e, n);
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
function O(
|
|
124
|
-
const
|
|
125
|
-
|
|
123
|
+
function O(t, o, e) {
|
|
124
|
+
const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
|
|
125
|
+
n === "list" ? R(t, o, s, e) : v(t, o, s, e);
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
return
|
|
127
|
+
function b(t, o, e) {
|
|
128
|
+
const n = new RegExp(`${o}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
|
|
129
|
+
return s ? parseInt(s[1]) : e;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
131
|
+
function A(t) {
|
|
132
|
+
const o = t.trim();
|
|
133
|
+
return o.endsWith("%") ? parseFloat(o) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(o) && parseInt(o) > 0;
|
|
134
|
+
}
|
|
135
|
+
function $(t) {
|
|
136
|
+
const o = t.getAttribute("width");
|
|
137
|
+
if (o && A(o))
|
|
138
|
+
return o.trim();
|
|
139
|
+
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
140
|
+
return e && A(e[1]) ? e[1] : null;
|
|
141
|
+
}
|
|
142
|
+
function T(t, o) {
|
|
143
|
+
let e = t.parentElement;
|
|
144
|
+
for (; e && e !== o; ) {
|
|
145
|
+
if (e.tagName === "TD" && $(e))
|
|
146
|
+
return e;
|
|
147
|
+
e = e.parentElement;
|
|
140
148
|
}
|
|
141
149
|
return null;
|
|
142
150
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
|
|
151
|
+
function M(t) {
|
|
152
|
+
const o = t.getAttribute("style") || "", e = b(o, "width", 600), n = b(o, "padding", 0) * 2, s = Math.max(0, e - n);
|
|
153
|
+
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
146
154
|
if (i.hasAttribute("width"))
|
|
147
155
|
return;
|
|
148
|
-
const r = T(i,
|
|
156
|
+
const r = T(i, t);
|
|
149
157
|
if (!r)
|
|
150
158
|
return;
|
|
151
|
-
const
|
|
152
|
-
i.setAttribute("width", String(
|
|
153
|
-
const
|
|
154
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
155
|
-
const
|
|
156
|
-
i.setAttribute("style", `${
|
|
159
|
+
const c = $(r), l = b(r.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), p = Math.max(1, u - l);
|
|
160
|
+
i.setAttribute("width", String(p));
|
|
161
|
+
const a = i.getAttribute("style") || "";
|
|
162
|
+
if (!/\bwidth\s*:\s*\d/i.test(a)) {
|
|
163
|
+
const d = a && !a.trim().endsWith(";") ? "; " : "";
|
|
164
|
+
i.setAttribute("style", `${a}${d}width: ${p}px`);
|
|
157
165
|
}
|
|
158
166
|
});
|
|
159
167
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
162
|
-
return (
|
|
163
|
-
` : "") +
|
|
168
|
+
function B(t, o) {
|
|
169
|
+
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
170
|
+
return (e ? `${e[0]}
|
|
171
|
+
` : "") + o.documentElement.outerHTML;
|
|
164
172
|
}
|
|
165
|
-
function
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
168
|
-
return
|
|
169
|
-
const { buildCampaignUrl:
|
|
173
|
+
function G(t) {
|
|
174
|
+
const o = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(o, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
|
|
175
|
+
if (!n.length)
|
|
176
|
+
return t;
|
|
177
|
+
const { buildCampaignUrl: s } = C(), i = w();
|
|
170
178
|
i.recommendationCampaignUrls = {};
|
|
171
|
-
const { isFeatureEnabled: r } =
|
|
172
|
-
return
|
|
173
|
-
var
|
|
179
|
+
const { isFeatureEnabled: r } = q(), c = r("liquidSyntax") ? "reco_" : "";
|
|
180
|
+
return n.forEach((u) => {
|
|
181
|
+
var a, d;
|
|
174
182
|
const p = u.getAttribute("recommendation-id");
|
|
175
|
-
p && ((
|
|
176
|
-
}),
|
|
183
|
+
p && ((a = u.parentNode) == null || a.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((y) => y.remove()), s(p), P(u) || O(u, p, c), M(u));
|
|
184
|
+
}), B(o, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
177
185
|
}
|
|
178
186
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
187
|
+
f as formatPriceVariable,
|
|
188
|
+
G as prepareRecommendationBlocks
|
|
181
189
|
};
|