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