@useinsider/guido 3.10.0-beta.cbd47be → 3.10.0-beta.dfe1fa6
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/useCortexBlueprintBridge.js +7 -7
- package/dist/composables/useCustomInterfaceAppearance.js +16 -18
- package/dist/composables/useEmailTemplateApplier.js +9 -9
- package/dist/composables/useExport.js +18 -18
- package/dist/composables/useHtmlValidator.js +90 -90
- package/dist/composables/useStripo.js +53 -51
- package/dist/composables/useStripoNotifications.js +26 -0
- package/dist/composables/useToaster.js +11 -11
- package/dist/composables/useVersionHistoryApi.js +2 -2
- package/dist/composables/validators/useLiquidValidator.js +1 -1
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +10 -10
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +125 -94
- package/dist/enums/toaster.js +2 -2
- package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
- package/dist/services/blankTemplate.js +1 -1
- package/dist/services/templateLibraryApi.js +8 -7
- package/dist/src/composables/useStripoNotifications.d.ts +10 -0
- package/dist/src/enums/toaster.d.ts +2 -2
- package/dist/src/stores/toaster.d.ts +2 -3
- package/dist/static/styles/components/wide-panel.css.js +7 -0
- 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
|
|
13
|
-
import { useEditorStore as
|
|
14
|
-
import { dynamicContentToMergeTags as
|
|
15
|
-
import
|
|
16
|
-
const
|
|
17
|
-
const { features: c, template: w, isFeatureEnabled: u } =
|
|
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";
|
|
14
|
+
import { useEditorStore as E } from "../stores/editor.js";
|
|
15
|
+
import { dynamicContentToMergeTags as X } from "../utils/genericUtil.js";
|
|
16
|
+
import j from "../package.json.js";
|
|
17
|
+
const fo = (C, 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
|
|
20
|
+
const o = E(), { 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
|
-
metadata:
|
|
24
|
+
metadata: C,
|
|
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,82 +52,83 @@ 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
|
)
|
|
62
63
|
}
|
|
63
64
|
],
|
|
64
|
-
async onTokenRefreshRequest(
|
|
65
|
+
async onTokenRefreshRequest(e) {
|
|
65
66
|
try {
|
|
66
67
|
const n = await T();
|
|
67
|
-
|
|
68
|
+
e(n);
|
|
68
69
|
} catch (n) {
|
|
69
70
|
m(n, "Failed to refresh token");
|
|
70
71
|
}
|
|
71
72
|
},
|
|
72
73
|
onTemplateLoaded() {
|
|
73
74
|
try {
|
|
74
|
-
const { importCss:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const { importCss: e } = O(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: D } = U(), { injectFullStory: I } = q();
|
|
76
|
+
e(), n(), I(), D(), l.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
77
|
+
o.hasChanges = !1;
|
|
77
78
|
}, 1e3);
|
|
78
|
-
} catch (
|
|
79
|
-
m(
|
|
79
|
+
} catch (e) {
|
|
80
|
+
m(e, "Failed to load custom interface appearance");
|
|
80
81
|
}
|
|
81
82
|
},
|
|
82
|
-
onCodeEditorVisibilityChanged(
|
|
83
|
-
|
|
83
|
+
onCodeEditorVisibilityChanged(e) {
|
|
84
|
+
o.isCodeEditorOpen = e;
|
|
84
85
|
},
|
|
85
|
-
onEditorVisualModeChanged(
|
|
86
|
-
|
|
86
|
+
onEditorVisualModeChanged(e) {
|
|
87
|
+
o.editorVisualMode = e.toLowerCase();
|
|
87
88
|
},
|
|
88
|
-
onVersionHistoryVisibilityChanged(
|
|
89
|
-
|
|
89
|
+
onVersionHistoryVisibilityChanged(e) {
|
|
90
|
+
o.isVersionHistoryOpen = e;
|
|
90
91
|
},
|
|
91
92
|
onDataChanged() {
|
|
92
|
-
|
|
93
|
+
o.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
|
|
112
|
+
const o = j.guido, a = `https://email-static.useinsider.com/guido/${(d = o == null ? void 0 : o.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 = E();
|
|
119
121
|
try {
|
|
120
|
-
await
|
|
121
|
-
const [
|
|
122
|
+
await A(async () => {
|
|
123
|
+
const [r, o] = await Promise.all([
|
|
122
124
|
k(),
|
|
123
125
|
B()
|
|
124
126
|
]);
|
|
125
|
-
|
|
127
|
+
i.syncModulesEnabled = o, await _(s, r, o);
|
|
126
128
|
});
|
|
127
129
|
} catch {
|
|
128
|
-
|
|
129
|
-
type:
|
|
130
|
+
i.loadingStatus = !1, b({
|
|
131
|
+
type: $.Error,
|
|
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
|
+
fo 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: s, hideToaster: u } = d();
|
|
5
|
+
let r = null;
|
|
6
|
+
const n = (o, t, i, e, f = !0) => {
|
|
7
|
+
r = i;
|
|
8
|
+
const l = e != null && e.action ? { text: e.action.label, onClick: e.action.func } : void 0;
|
|
9
|
+
s({ type: o, message: t, actionButton: l, 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.Error, 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
|
+
r === o && (u(), r = null);
|
|
21
|
+
}
|
|
22
|
+
}) };
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
g as useStripoNotifications
|
|
26
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { ToasterTypeOptions as T } from "../enums/toaster.js";
|
|
2
2
|
import { useToasterStore as c } from "../stores/toaster.js";
|
|
3
|
-
import { watch as u, nextTick as
|
|
3
|
+
import { watch as u, nextTick as f } from "vue";
|
|
4
4
|
const p = () => {
|
|
5
|
-
const
|
|
6
|
-
let
|
|
5
|
+
const o = c();
|
|
6
|
+
let t = null;
|
|
7
7
|
const s = () => {
|
|
8
|
-
|
|
8
|
+
t && (clearTimeout(t), t = null);
|
|
9
9
|
};
|
|
10
10
|
function r(e = { message: "" }) {
|
|
11
|
-
s(),
|
|
12
|
-
|
|
11
|
+
s(), o.hideToaster(), f(() => {
|
|
12
|
+
o.showToaster(e);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
function i() {
|
|
16
|
-
s(),
|
|
16
|
+
s(), o.hideToaster();
|
|
17
17
|
}
|
|
18
18
|
function n(e, a) {
|
|
19
19
|
const m = e instanceof Error ? e.message : String(e);
|
|
20
|
-
r({ type: T.
|
|
20
|
+
r({ type: T.Error, message: `${a}: ${m}` });
|
|
21
21
|
}
|
|
22
22
|
return u(
|
|
23
|
-
() =>
|
|
23
|
+
() => o.shouldAutoHide,
|
|
24
24
|
(e) => {
|
|
25
|
-
s(), e && (
|
|
26
|
-
|
|
25
|
+
s(), e && (t = setTimeout(() => {
|
|
26
|
+
o.hideToaster(), s();
|
|
27
27
|
}, 6e3));
|
|
28
28
|
}
|
|
29
29
|
), { showToaster: r, hideToaster: i, handleError: n };
|
|
@@ -24,7 +24,7 @@ const S = () => {
|
|
|
24
24
|
window.StripoEditorApi.versionHistoryApi.previewVersion(e, (o) => {
|
|
25
25
|
const r = o instanceof Error ? o.message : String(o);
|
|
26
26
|
s({
|
|
27
|
-
type: t.
|
|
27
|
+
type: t.Error,
|
|
28
28
|
message: `Error compiling email: ${r}`
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -41,7 +41,7 @@ const S = () => {
|
|
|
41
41
|
(o) => {
|
|
42
42
|
const r = o instanceof Error ? o.message : String(o);
|
|
43
43
|
s({
|
|
44
|
-
type: t.
|
|
44
|
+
type: t.Error,
|
|
45
45
|
message: `Error compiling email: ${r}`
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
2
|
import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
|
|
3
3
|
import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
4
|
+
import { useToaster as E } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
6
6
|
const T = [
|
|
7
7
|
{
|
|
8
8
|
pageType: u.GLOBAL_UNSUBSCRIBE,
|
|
@@ -13,23 +13,23 @@ const T = [
|
|
|
13
13
|
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
14
|
}
|
|
15
15
|
], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
|
|
16
|
-
const { showToaster: c } =
|
|
16
|
+
const { showToaster: c } = E(), p = m();
|
|
17
17
|
return { validateUnsubscribeBlockUniqueness: (n) => {
|
|
18
|
-
const o = new DOMParser().parseFromString(n, "text/html"),
|
|
18
|
+
const o = new DOMParser().parseFromString(n, "text/html"), r = /* @__PURE__ */ new Map();
|
|
19
19
|
o.querySelectorAll(l).forEach((e) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const s = Number(e.getAttribute(a.PAGE_TYPE));
|
|
21
|
+
r.set(s, (r.get(s) ?? 0) + 1);
|
|
22
22
|
});
|
|
23
|
-
const t = T.filter((e) => (
|
|
23
|
+
const t = T.filter((e) => (r.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
|
|
24
24
|
return t.length ? (c({
|
|
25
|
-
type: i.
|
|
25
|
+
type: i.Error,
|
|
26
26
|
message: p(t.length > 1 ? g : t[0])
|
|
27
27
|
}), !1) : !0;
|
|
28
28
|
}, validateUnsubscribeBlockHasTemplate: (n) => {
|
|
29
29
|
const o = new DOMParser().parseFromString(n, "text/html");
|
|
30
30
|
return Array.from(o.querySelectorAll(l)).some((t) => {
|
|
31
|
-
const e = t.getAttribute(a.PAGE_TYPE),
|
|
32
|
-
return !e || !
|
|
31
|
+
const e = t.getAttribute(a.PAGE_TYPE), s = t.getAttribute(a.PAGE_LIST);
|
|
32
|
+
return !e || !s;
|
|
33
33
|
}) ? (c({
|
|
34
34
|
type: i.Warning,
|
|
35
35
|
message: p(b)
|
|
@@ -1,30 +1,30 @@
|
|
|
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
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function
|
|
1
|
+
import { useConfig as C } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as E } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as q } 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 R(t, r, e, o, s = "") {
|
|
7
|
+
const i = `{{${s}${t}_${r}_${e}}}`, n = `{{${s}${t}_${r}_currency}}`;
|
|
8
|
+
return o === "before" ? `${n} ${i}` : `${i} ${n}`;
|
|
9
|
+
}
|
|
10
|
+
function y(t) {
|
|
11
11
|
let r = t;
|
|
12
12
|
for (; r.children.length === 1; )
|
|
13
13
|
[r] = r.children;
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function A(t, r, e, o, s, i) {
|
|
17
17
|
switch (r) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const n = t.querySelector("img");
|
|
20
|
+
n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
|
|
21
|
+
const c = t.querySelector("a");
|
|
22
|
+
c && (c.setAttribute("href", `{{${i}${e}_${o}_url}}`), c.classList.add(q));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const n = t.querySelector("p");
|
|
27
|
+
n && (y(n).textContent = `{{${i}${e}_${o}_name}}`);
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
@@ -32,145 +32,176 @@ function b(t, r, e, n, s, c) {
|
|
|
32
32
|
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
33
33
|
case "productPrice":
|
|
34
34
|
case "productOldPrice": {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const n = (l, d) => {
|
|
36
|
+
l && (y(l).textContent = R(
|
|
37
37
|
e,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
o,
|
|
39
|
+
d,
|
|
40
40
|
s,
|
|
41
|
-
|
|
41
|
+
i
|
|
42
42
|
));
|
|
43
|
-
},
|
|
44
|
-
|
|
43
|
+
}, c = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !c && !a ? t.querySelector("p") : null;
|
|
44
|
+
n(c ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
case "productButton": {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const n = t.querySelector("a");
|
|
49
|
+
n && n.setAttribute("href", `{{${i}${e}_${o}_url}}`);
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case "productOmnibusPrice": {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
53
|
+
const n = t.querySelector(".omnibus-price-value");
|
|
54
|
+
if (n) {
|
|
55
|
+
n.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
|
|
56
|
+
const c = n.closest("p");
|
|
57
|
+
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
58
58
|
}
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
61
|
case "productOmnibusDiscount": {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
62
|
+
const n = t.querySelector(".omnibus-discount-value");
|
|
63
|
+
if (n) {
|
|
64
|
+
n.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
|
|
65
|
+
const c = n.closest("p");
|
|
66
|
+
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
67
67
|
}
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
default: {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
a && (
|
|
71
|
+
const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
72
|
+
if (n) {
|
|
73
|
+
const c = n.getAttribute("product-attr"), a = n.querySelector("p");
|
|
74
|
+
a && (y(a).textContent = `{{${i}${e}_${o}_${c}}}`);
|
|
75
75
|
}
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
const B = "name";
|
|
81
|
+
function S(t, r, e, o) {
|
|
82
|
+
const s = `${o}${r}_${e}_${B}`;
|
|
83
|
+
return {
|
|
84
|
+
open: t.createComment(`{% if ${s} and ${s} != "" %}`),
|
|
85
|
+
close: t.createComment("{% endif %}")
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function L(t, r, e) {
|
|
89
|
+
return S(t, r, 0, e);
|
|
90
|
+
}
|
|
91
|
+
function N(t, r, e, o) {
|
|
92
|
+
if (!t.innerHTML.includes("{{"))
|
|
93
|
+
return;
|
|
94
|
+
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
95
|
+
t.insertBefore(s, t.firstChild), t.appendChild(i);
|
|
96
|
+
}
|
|
97
|
+
function T(t, r, e, o) {
|
|
98
|
+
var n, c;
|
|
99
|
+
if (!t.innerHTML.includes("{{"))
|
|
100
|
+
return;
|
|
101
|
+
const { open: s, close: i } = S(t.ownerDocument, r, e, o);
|
|
102
|
+
(n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
|
|
103
|
+
}
|
|
104
|
+
function v(t, r, e, o) {
|
|
105
|
+
t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
|
|
106
|
+
i.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
107
|
+
const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
108
|
+
l.length > 0 ? l.forEach((d) => {
|
|
109
|
+
A(d, u, r, n, e, o);
|
|
110
|
+
}) : A(a, u, r, n, e, o);
|
|
111
|
+
}), T(i, r, n, o);
|
|
88
112
|
});
|
|
89
113
|
}
|
|
90
|
-
function
|
|
114
|
+
function O(t, r, e, o) {
|
|
91
115
|
const s = t.querySelectorAll(".recommendation-product-row");
|
|
92
116
|
if (!s.length)
|
|
93
117
|
return;
|
|
94
|
-
const [
|
|
118
|
+
const [i] = s, n = i.querySelector("[data-attribute-type]"), c = n ? n.querySelectorAll(".attribute-cell").length : 1;
|
|
95
119
|
s.forEach((a, u) => {
|
|
96
|
-
a.querySelectorAll("[data-attribute-type]").forEach((
|
|
97
|
-
const p =
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
120
|
+
a.querySelectorAll("[data-attribute-type]").forEach((d) => {
|
|
121
|
+
const p = d.getAttribute("data-attribute-type") || "";
|
|
122
|
+
d.querySelectorAll(".attribute-cell").forEach((m, f) => {
|
|
123
|
+
const h = u * c + f;
|
|
124
|
+
A(m, p, r, h, e, o), N(m, r, h, o);
|
|
101
125
|
});
|
|
102
126
|
});
|
|
103
127
|
});
|
|
104
128
|
}
|
|
105
|
-
function
|
|
106
|
-
t.querySelectorAll(".ins-recommendation-product-container").forEach((
|
|
107
|
-
|
|
129
|
+
function W(t, r, e, o) {
|
|
130
|
+
t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
|
|
131
|
+
O(i, r, e, o);
|
|
108
132
|
});
|
|
109
133
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
|
|
134
|
+
function D(t, r, e) {
|
|
135
|
+
const o = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
|
|
136
|
+
o === "list" ? v(t, r, s, e) : W(t, r, s, e);
|
|
113
137
|
}
|
|
114
|
-
function
|
|
115
|
-
const
|
|
138
|
+
function $(t, r, e) {
|
|
139
|
+
const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(o);
|
|
116
140
|
return s ? parseInt(s[1]) : e;
|
|
117
141
|
}
|
|
118
|
-
function
|
|
142
|
+
function _(t) {
|
|
119
143
|
const r = t.trim();
|
|
120
144
|
return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
|
|
121
145
|
}
|
|
122
|
-
function
|
|
146
|
+
function g(t) {
|
|
123
147
|
const r = t.getAttribute("width");
|
|
124
|
-
if (r &&
|
|
148
|
+
if (r && _(r))
|
|
125
149
|
return r.trim();
|
|
126
150
|
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
127
|
-
return e &&
|
|
151
|
+
return e && _(e[1]) ? e[1] : null;
|
|
128
152
|
}
|
|
129
153
|
function M(t, r) {
|
|
130
154
|
let e = t.parentElement;
|
|
131
155
|
for (; e && e !== r; ) {
|
|
132
|
-
if (e.tagName === "TD" &&
|
|
156
|
+
if (e.tagName === "TD" && g(e))
|
|
133
157
|
return e;
|
|
134
158
|
e = e.parentElement;
|
|
135
159
|
}
|
|
136
160
|
return null;
|
|
137
161
|
}
|
|
138
|
-
function
|
|
139
|
-
const r = t.getAttribute("style") || "", e =
|
|
140
|
-
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((
|
|
141
|
-
if (
|
|
162
|
+
function G(t) {
|
|
163
|
+
const r = t.getAttribute("style") || "", e = $(r, "width", 600), o = $(r, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
164
|
+
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
|
|
165
|
+
if (i.hasAttribute("width"))
|
|
142
166
|
return;
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
167
|
+
const n = M(i, t);
|
|
168
|
+
if (!n)
|
|
145
169
|
return;
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
150
|
-
const p =
|
|
151
|
-
|
|
170
|
+
const c = g(n), a = $(n.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), l = Math.max(1, u - a);
|
|
171
|
+
i.setAttribute("width", String(l));
|
|
172
|
+
const d = i.getAttribute("style") || "";
|
|
173
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
174
|
+
const p = d && !d.trim().endsWith(";") ? "; " : "";
|
|
175
|
+
i.setAttribute("style", `${d}${p}width: ${l}px`);
|
|
152
176
|
}
|
|
153
177
|
});
|
|
154
178
|
}
|
|
155
|
-
function
|
|
179
|
+
function H(t, r) {
|
|
156
180
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
157
181
|
return (e ? `${e[0]}
|
|
158
182
|
` : "") + r.documentElement.outerHTML;
|
|
159
183
|
}
|
|
160
|
-
function
|
|
161
|
-
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"),
|
|
162
|
-
if (!
|
|
184
|
+
function Y(t) {
|
|
185
|
+
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
186
|
+
if (!o.length)
|
|
163
187
|
return t;
|
|
164
|
-
const { buildCampaignUrl: s } =
|
|
165
|
-
|
|
166
|
-
const { isFeatureEnabled:
|
|
167
|
-
return
|
|
168
|
-
var
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
const { buildCampaignUrl: s } = E(), i = w();
|
|
189
|
+
i.recommendationCampaignUrls = {};
|
|
190
|
+
const { isFeatureEnabled: n } = C(), c = n("liquidSyntax") ? "reco_" : "";
|
|
191
|
+
return o.forEach((u) => {
|
|
192
|
+
var d, p, b, m;
|
|
193
|
+
const l = u.getAttribute("recommendation-id");
|
|
194
|
+
if (l) {
|
|
195
|
+
if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), s(l), !P(u)) {
|
|
196
|
+
D(u, l, c);
|
|
197
|
+
const { open: f, close: h } = L(e, l, c);
|
|
198
|
+
(b = u.parentNode) == null || b.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
|
|
199
|
+
}
|
|
200
|
+
G(u);
|
|
201
|
+
}
|
|
202
|
+
}), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
172
203
|
}
|
|
173
204
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
205
|
+
R as formatPriceVariable,
|
|
206
|
+
Y as prepareRecommendationBlocks
|
|
176
207
|
};
|
package/dist/enums/toaster.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Error = "error", r.Info = "information", r))(n || {});
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
n as ToasterTypeOptions
|
|
4
4
|
};
|