@useinsider/guido 3.15.0 → 3.16.0-beta.089654a
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 +108 -92
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +78 -75
- package/dist/composables/useActionsApi.js +30 -22
- package/dist/composables/useEmailTemplateApplier.js +25 -23
- package/dist/composables/useHtmlValidator.js +108 -106
- package/dist/composables/useRecommendation.js +20 -19
- package/dist/composables/useTimerClone.js +21 -19
- package/dist/config/i18n/en/labels.json.js +7 -3
- package/dist/config/migrator/checkboxMigrator.js +20 -19
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/config/migrator/radioButtonMigrator.js +26 -25
- package/dist/config/migrator/recommendation/compositionMapper.js +26 -23
- package/dist/config/migrator/recommendation/htmlBuilder.js +156 -155
- package/dist/enums/recommendation.js +17 -17
- package/dist/extensions/Blocks/Checkbox/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/Checkbox/constants/selectors.js +6 -0
- package/dist/extensions/Blocks/Checkbox/controls/blockBackground/index.js +10 -0
- package/dist/extensions/Blocks/Checkbox/extension.js +6 -5
- package/dist/extensions/Blocks/Checkbox/settingsPanel.js +15 -14
- package/dist/extensions/Blocks/Checkbox/template.js +10 -9
- package/dist/extensions/Blocks/Items/block.js +44 -42
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Items/template.js +86 -86
- package/dist/extensions/Blocks/RadioButton/constants/controlIds.js +4 -0
- package/dist/extensions/Blocks/RadioButton/constants/selectors.js +6 -0
- package/dist/extensions/Blocks/RadioButton/controls/blockBackground/index.js +10 -0
- package/dist/extensions/Blocks/RadioButton/extension.js +5 -4
- package/dist/extensions/Blocks/RadioButton/settingsPanel.js +12 -11
- package/dist/extensions/Blocks/RadioButton/template.js +16 -9
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +18 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +5 -9
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +363 -322
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +21 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +271 -231
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +98 -113
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +21 -0
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +13 -12
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +16 -16
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +120 -120
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +55 -54
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +89 -0
- package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
- package/dist/extensions/Blocks/common-control.js +42 -35
- package/dist/extensions/Blocks/controlFactories.js +117 -115
- package/dist/guido.css +1 -1
- package/dist/library.js +11 -7
- package/dist/node_modules/valibot/dist/index.js +230 -216
- package/dist/package.json.js +1 -1
- package/dist/public/trackingIds.js +8 -0
- package/dist/src/@types/config/schemas.d.ts +20 -0
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useHtmlValidator.d.ts +3 -2
- package/dist/src/config/migrator/recommendation/types.d.ts +1 -0
- package/dist/src/extensions/Blocks/Checkbox/constants/controlIds.d.ts +7 -0
- package/dist/src/extensions/Blocks/Checkbox/constants/index.d.ts +10 -0
- package/dist/src/extensions/Blocks/Checkbox/constants/selectors.d.ts +16 -0
- package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +14 -0
- package/dist/src/extensions/Blocks/RadioButton/constants/controlIds.d.ts +7 -0
- package/dist/src/extensions/Blocks/RadioButton/constants/index.d.ts +10 -0
- package/dist/src/extensions/Blocks/RadioButton/constants/selectors.d.ts +16 -0
- package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +27 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +4 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +12 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +47 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
- package/dist/src/extensions/Blocks/_Boilerplate/constants/controlIds.d.ts +7 -0
- package/dist/src/extensions/Blocks/_Boilerplate/constants/index.d.ts +10 -0
- package/dist/src/extensions/Blocks/_Boilerplate/constants/selectors.d.ts +16 -0
- package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +14 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +3 -1
- package/dist/src/library.d.ts +1 -0
- package/dist/src/public/trackingIds.d.ts +9 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/src/stores/editor.d.ts +25 -0
- package/dist/src/utils/linkTrackingIds.d.ts +30 -0
- package/dist/stores/editor.js +4 -1
- package/dist/stores/onboarding.js +11 -7
- package/dist/utils/linkTrackingIds.js +56 -0
- package/dist/utils/pairProductVariables.js +105 -99
- package/dist/utils/templatePreparation.js +72 -61
- package/package.json +6 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { filterAmpErrors as
|
|
1
|
+
import { filterAmpErrors as T } from "../utils/ampErrorFilter.js";
|
|
2
2
|
import { useToaster as A } from "./useToaster.js";
|
|
3
|
-
const D = () => {
|
|
4
|
-
const { handleError:
|
|
3
|
+
const p = 1e4, D = () => {
|
|
4
|
+
const { handleError: r } = A(), l = (t = {}) => new Promise((e, a) => {
|
|
5
5
|
const o = { ...{
|
|
6
6
|
minimize: !0,
|
|
7
7
|
utmEntity: {
|
|
@@ -21,29 +21,29 @@ const D = () => {
|
|
|
21
21
|
forceAmp: !1,
|
|
22
22
|
resetDataSavedFlag: !1,
|
|
23
23
|
disableLineHeightsReplace: !0
|
|
24
|
-
}, ...t },
|
|
25
|
-
callback: (
|
|
26
|
-
|
|
27
|
-
html:
|
|
28
|
-
ampHtml:
|
|
29
|
-
ampErrors:
|
|
30
|
-
displayConditions:
|
|
24
|
+
}, ...t }, n = {
|
|
25
|
+
callback: (m, d, c, u, w) => {
|
|
26
|
+
m ? a(m) : e({
|
|
27
|
+
html: d,
|
|
28
|
+
ampHtml: c,
|
|
29
|
+
ampErrors: T(u ?? []),
|
|
30
|
+
displayConditions: w
|
|
31
31
|
});
|
|
32
32
|
},
|
|
33
33
|
...o
|
|
34
34
|
};
|
|
35
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
35
|
+
window.StripoEditorApi.actionsApi.compileEmail(n);
|
|
36
36
|
});
|
|
37
37
|
return {
|
|
38
|
-
getCompiledEmail:
|
|
38
|
+
getCompiledEmail: l,
|
|
39
39
|
getTemplateData: () => new Promise((t) => {
|
|
40
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
40
|
+
const e = ({ html: a, css: i, width: o, height: s, utmParams: n, syncModulesIds: m }) => t({
|
|
41
41
|
html: a,
|
|
42
42
|
css: i,
|
|
43
43
|
width: o,
|
|
44
|
-
height:
|
|
45
|
-
utmParams:
|
|
46
|
-
syncModulesIds:
|
|
44
|
+
height: s,
|
|
45
|
+
utmParams: n,
|
|
46
|
+
syncModulesIds: m
|
|
47
47
|
});
|
|
48
48
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
49
49
|
}),
|
|
@@ -57,7 +57,7 @@ const D = () => {
|
|
|
57
57
|
displayConditions: a,
|
|
58
58
|
ampHtml: i = "",
|
|
59
59
|
ampErrors: o = []
|
|
60
|
-
} = await
|
|
60
|
+
} = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
|
|
61
61
|
return {
|
|
62
62
|
html: e,
|
|
63
63
|
ampHtml: i,
|
|
@@ -65,7 +65,7 @@ const D = () => {
|
|
|
65
65
|
displayConditions: a
|
|
66
66
|
};
|
|
67
67
|
} catch (e) {
|
|
68
|
-
return
|
|
68
|
+
return r(e, "Error loading preview"), {
|
|
69
69
|
html: "",
|
|
70
70
|
ampHtml: "",
|
|
71
71
|
ampErrors: [],
|
|
@@ -81,19 +81,27 @@ const D = () => {
|
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
83
|
window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
|
|
84
|
-
i ? (
|
|
84
|
+
i ? (r(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
|
|
85
85
|
});
|
|
86
86
|
} catch (i) {
|
|
87
|
-
|
|
87
|
+
r(i, "Failed to call updateTimerInClonedTemplate"), t(null);
|
|
88
88
|
}
|
|
89
89
|
}),
|
|
90
90
|
updateHtmlAndCss: (t, e) => {
|
|
91
|
-
window.StripoEditorApi
|
|
91
|
+
const { actionsApi: a } = window.StripoEditorApi;
|
|
92
|
+
return new Promise((i, o) => {
|
|
93
|
+
const s = new Error(
|
|
94
|
+
`updateHtmlAndCss did not report completion within ${p}ms`
|
|
95
|
+
), n = setTimeout(() => o(s), p);
|
|
96
|
+
a.updateHtmlAndCss(t, e, () => {
|
|
97
|
+
clearTimeout(n), i();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
92
100
|
},
|
|
93
101
|
editorSave: () => new Promise((t) => {
|
|
94
102
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
95
103
|
if (e) {
|
|
96
|
-
|
|
104
|
+
r(e, "Failed to save template"), t(!1);
|
|
97
105
|
return;
|
|
98
106
|
}
|
|
99
107
|
t(!0);
|
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useToaster as
|
|
1
|
+
import { useActionsApi as C } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as h } from "./useConfig.js";
|
|
3
|
+
import { useToaster as D } from "./useToaster.js";
|
|
4
4
|
import { useTranslations as E } from "./useTranslations.js";
|
|
5
5
|
import { ToasterTypeOptions as f } from "../enums/toaster.js";
|
|
6
6
|
import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
|
|
7
|
-
import { flattenDynamicContentList as
|
|
8
|
-
import { extractUsedDynamicContent as
|
|
9
|
-
import { ref as
|
|
10
|
-
const
|
|
11
|
-
const { updateHtmlAndCss:
|
|
7
|
+
import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
|
|
8
|
+
import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
|
|
9
|
+
import { ref as O } from "vue";
|
|
10
|
+
const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
|
|
11
|
+
const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
|
|
12
12
|
const a = y(e);
|
|
13
13
|
return a === e ? t : a;
|
|
14
|
-
},
|
|
14
|
+
}, v = (e) => {
|
|
15
15
|
o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
|
|
16
16
|
}, l = (e, t, a) => {
|
|
17
|
-
var
|
|
17
|
+
var c;
|
|
18
18
|
o.value = { ...o.value, [e]: "applying" };
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
r(t, a).catch((n) => {
|
|
21
|
+
console.warn("Editor did not acknowledge the template apply.", n);
|
|
22
|
+
}), o.value = { ...o.value, [e]: "applied" };
|
|
21
23
|
try {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
+
const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
|
|
25
|
+
i.length > 0 && d.registerDynamicContent(i);
|
|
24
26
|
} catch {
|
|
25
27
|
}
|
|
26
28
|
u.get(e) !== t && (u.set(e, t), m({
|
|
27
29
|
type: f.Success,
|
|
28
30
|
message: g("newsletter.ai-template-applied", "Template applied to the editor")
|
|
29
31
|
}));
|
|
30
|
-
} catch (
|
|
32
|
+
} catch (n) {
|
|
31
33
|
o.value = { ...o.value, [e]: "failed" }, m({
|
|
32
34
|
type: f.Error,
|
|
33
|
-
message:
|
|
35
|
+
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
|
-
},
|
|
38
|
+
}, p = (e) => {
|
|
37
39
|
const t = s[e];
|
|
38
40
|
t && (clearTimeout(t), delete s[e]);
|
|
39
41
|
};
|
|
40
|
-
return { applyStatus: o, markPending:
|
|
41
|
-
t.html && (
|
|
42
|
+
return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
|
|
43
|
+
t.html && (p(e), l(e, t.html, t.css ?? ""));
|
|
42
44
|
}, applyTemplateDebounced: (e, t) => {
|
|
43
45
|
if (!t.html)
|
|
44
46
|
return;
|
|
45
|
-
|
|
46
|
-
const { html: a } = t,
|
|
47
|
+
p(e);
|
|
48
|
+
const { html: a } = t, c = t.css ?? "";
|
|
47
49
|
s[e] = setTimeout(() => {
|
|
48
|
-
delete s[e], l(e, a,
|
|
49
|
-
},
|
|
50
|
+
delete s[e], l(e, a, c);
|
|
51
|
+
}, U);
|
|
50
52
|
} };
|
|
51
53
|
}, G = () => {
|
|
52
|
-
Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((
|
|
54
|
+
Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
|
|
53
55
|
};
|
|
54
56
|
export {
|
|
55
57
|
G as resetEmailTemplateApplier,
|
|
@@ -1,64 +1,66 @@
|
|
|
1
1
|
import { useConfig as V } from "./useConfig.js";
|
|
2
2
|
import { getIgnoredRecommendationBlockIds as M } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
3
3
|
import { TemplateTypes as W } from "../enums/defaults.js";
|
|
4
|
-
import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as $, DYNAMIC_CONTENT_TAG_REGEX as
|
|
4
|
+
import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as $, DYNAMIC_CONTENT_TAG_REGEX as K, ALLOWED_DYNAMIC_SYSTEM_TOKENS as Y, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
|
|
5
5
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
6
|
+
import { BLOCK_ROOT_SELECTOR as j } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
6
7
|
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
import { BLOCK_ROOT_SELECTOR as z } from "../extensions/Blocks/RadioButton/constants/selectors.js";
|
|
9
|
+
import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as Z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
10
|
+
import { useRecommendationExtensionStore as J } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
|
+
import { filterToProductAttrValue as Q } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
|
|
12
|
+
import { RecommendationRequiredFieldsKey as ee } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
13
|
+
import { useRecommendationStore as te } from "../stores/recommendation.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as ne } from "../utils/base64.js";
|
|
15
|
+
import { computed as se } from "vue";
|
|
16
|
+
import { useHttp as re } from "./useHttp.js";
|
|
17
|
+
import { useToaster as oe } from "./useToaster.js";
|
|
18
|
+
import { useTranslations as ie } from "./useTranslations.js";
|
|
19
|
+
const ae = /recommendation-id="(\d+)"/g;
|
|
20
|
+
function ce(s) {
|
|
21
|
+
return [...s.matchAll(ae)].map((l) => l[1]);
|
|
20
22
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
23
|
+
function me(s, l) {
|
|
24
|
+
return l.some((f) => s.startsWith(`${f}_`));
|
|
23
25
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
26
|
+
const le = /^(\d+)_\d+_(.+)$/;
|
|
27
|
+
function ue(s) {
|
|
28
|
+
const l = s.match(le);
|
|
29
|
+
return l ? { recoId: l[1], attribute: l[2] } : null;
|
|
28
30
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
return Object.values(
|
|
32
|
-
|
|
33
|
-
}),
|
|
31
|
+
function de(s) {
|
|
32
|
+
const l = new Set(Z);
|
|
33
|
+
return Object.values(s).forEach((f) => {
|
|
34
|
+
l.add(Q(f).toLowerCase());
|
|
35
|
+
}), l;
|
|
34
36
|
}
|
|
35
|
-
function
|
|
36
|
-
const u =
|
|
37
|
+
function fe(s, l, f, o, d) {
|
|
38
|
+
const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
37
39
|
if (!u)
|
|
38
40
|
return [];
|
|
39
|
-
const g = new Set(
|
|
40
|
-
return u.forEach((
|
|
41
|
-
const p =
|
|
41
|
+
const g = new Set(l.map((C) => C.toLowerCase())), E = [];
|
|
42
|
+
return u.forEach((C) => {
|
|
43
|
+
const p = C.slice(2, -2).trim().toLowerCase();
|
|
42
44
|
if (p !== "" && g.has(p))
|
|
43
45
|
return;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
if (!d || d.has(
|
|
46
|
+
const h = ue(p);
|
|
47
|
+
if (h && o.has(h.recoId)) {
|
|
48
|
+
if (!d || d.has(h.attribute))
|
|
47
49
|
return;
|
|
48
50
|
E.push(p);
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
me(p, f) || p.includes(".") || E.push(p);
|
|
52
54
|
}), E;
|
|
53
55
|
}
|
|
54
|
-
function
|
|
55
|
-
return (
|
|
56
|
+
function pe(s) {
|
|
57
|
+
return (s.replace($, "$1").match(K) ?? []).filter((o) => {
|
|
56
58
|
const d = o.slice(2, -2), u = d.indexOf("|"), g = (u === -1 ? d : d.slice(0, u)).trim();
|
|
57
|
-
return
|
|
59
|
+
return Y.includes(g) ? !1 : U.test(g) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
|
-
const
|
|
61
|
-
const { showToaster:
|
|
62
|
+
const De = () => {
|
|
63
|
+
const { showToaster: s } = oe(), { post: l } = re(), { config: f } = V(), o = ie(), d = te(), u = J(), g = se(
|
|
62
64
|
() => {
|
|
63
65
|
var e, t;
|
|
64
66
|
return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
|
|
@@ -71,154 +73,154 @@ const xe = () => {
|
|
|
71
73
|
} catch {
|
|
72
74
|
return null;
|
|
73
75
|
}
|
|
74
|
-
return
|
|
75
|
-
},
|
|
76
|
-
const
|
|
76
|
+
return de(u.filterList);
|
|
77
|
+
}, C = async (e) => {
|
|
78
|
+
const n = await l(
|
|
77
79
|
"/newsletter/template-library/check-template-html-body",
|
|
78
|
-
{ html:
|
|
79
|
-
), { status: r, message: a } =
|
|
80
|
-
return r ||
|
|
80
|
+
{ html: ne(e) }
|
|
81
|
+
), { status: r, message: a } = n.data;
|
|
82
|
+
return r || s({
|
|
81
83
|
type: c.Error,
|
|
82
84
|
message: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
|
|
83
|
-
}), o(P), a === o(X) &&
|
|
85
|
+
}), o(P), a === o(X) && s({
|
|
84
86
|
type: c.Error,
|
|
85
87
|
message: o("newsletter.already-in-progress")
|
|
86
88
|
}), r;
|
|
87
|
-
}, p = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()),
|
|
88
|
-
const
|
|
89
|
+
}, p = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), h = (e) => ["if", "endif"].includes(e.toLowerCase()), T = (e, t) => {
|
|
90
|
+
const n = e.match(/({%(.*?)%})/g);
|
|
89
91
|
let r = !0;
|
|
90
|
-
return
|
|
92
|
+
return n !== null && !g.value && n.forEach((a) => {
|
|
91
93
|
const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
92
94
|
if (i && i.length > 0) {
|
|
93
|
-
const [
|
|
94
|
-
p(
|
|
95
|
+
const [m] = i;
|
|
96
|
+
p(m) && !t.includes(m) && (s({
|
|
95
97
|
type: c.Warning,
|
|
96
98
|
message: o("custom-fields.invalid-custom-fields")
|
|
97
99
|
}), r = !1);
|
|
98
100
|
}
|
|
99
101
|
}), r;
|
|
100
|
-
},
|
|
101
|
-
const r =
|
|
102
|
-
return
|
|
103
|
-
},
|
|
102
|
+
}, R = async (e, t, n) => {
|
|
103
|
+
const r = n ? await C(e) : !0;
|
|
104
|
+
return T(e, t) && r;
|
|
105
|
+
}, b = (e) => e.length > 0 ? !0 : (s({
|
|
104
106
|
type: c.Warning,
|
|
105
107
|
message: o("newsletter.html-content-is-empty")
|
|
106
|
-
}), !1),
|
|
107
|
-
const t = (e.match(/{/gm) || []).length,
|
|
108
|
-
return t >
|
|
108
|
+
}), !1), A = (e) => {
|
|
109
|
+
const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
|
|
110
|
+
return t > n && s({
|
|
109
111
|
type: c.Warning,
|
|
110
112
|
message: o("custom-fields.missing-closing-braces")
|
|
111
|
-
}), t <
|
|
113
|
+
}), t < n && s({
|
|
112
114
|
type: c.Warning,
|
|
113
115
|
message: o("custom-fields.missing-opening-braces")
|
|
114
|
-
}), t ===
|
|
115
|
-
},
|
|
116
|
-
const t =
|
|
117
|
-
return t ||
|
|
116
|
+
}), t === n;
|
|
117
|
+
}, _ = (e) => {
|
|
118
|
+
const t = pe(e).length === 0;
|
|
119
|
+
return t || s({
|
|
118
120
|
type: c.Warning,
|
|
119
121
|
message: o("custom-fields.invalid-custom-fields")
|
|
120
122
|
}), t;
|
|
121
|
-
},
|
|
123
|
+
}, O = (e, t, n, r) => {
|
|
122
124
|
if (g.value)
|
|
123
125
|
return !0;
|
|
124
|
-
const a =
|
|
126
|
+
const a = fe(
|
|
125
127
|
e,
|
|
126
128
|
t,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
ce(e),
|
|
130
|
+
n,
|
|
129
131
|
r
|
|
130
132
|
);
|
|
131
133
|
if (a.length > 0) {
|
|
132
134
|
const i = `
|
|
133
135
|
<ul>
|
|
134
|
-
${a.map((
|
|
136
|
+
${a.map((m) => `<li>${m}</li>`).join("")}
|
|
135
137
|
</ul>
|
|
136
138
|
`;
|
|
137
|
-
return
|
|
139
|
+
return s({
|
|
138
140
|
type: c.Error,
|
|
139
141
|
message: o("custom-fields.invalid-custom-fields") + i
|
|
140
142
|
}), !1;
|
|
141
143
|
}
|
|
142
144
|
return !0;
|
|
143
|
-
},
|
|
144
|
-
const t = e.match(/{%(.*?)%}/g),
|
|
145
|
+
}, w = (e) => {
|
|
146
|
+
const t = e.match(/{%(.*?)%}/g), n = [];
|
|
145
147
|
let r = !0;
|
|
146
148
|
if (t && t.forEach((a) => {
|
|
147
|
-
const i = a.match(G),
|
|
148
|
-
(!i || a !==
|
|
149
|
+
const i = a.match(G), m = a.match(H), v = (i == null ? void 0 : i.join("")) || "";
|
|
150
|
+
(!i || a !== v) && !m && (s({
|
|
149
151
|
type: c.Error,
|
|
150
152
|
message: o("newsletter.display-conditions-invalid-syntax")
|
|
151
|
-
}), r = !1), i && i.forEach((
|
|
152
|
-
|
|
153
|
+
}), r = !1), i && i.forEach((y) => {
|
|
154
|
+
y.trim() === "=" && (s({
|
|
153
155
|
type: c.Error,
|
|
154
156
|
message: o("custom-conditions.wrong-equality-operators")
|
|
155
157
|
}), r = !1);
|
|
156
|
-
const I =
|
|
157
|
-
I && I.forEach((
|
|
158
|
-
|
|
158
|
+
const I = y.match(/^[a-zA-Z]*$/g);
|
|
159
|
+
I && I.forEach((S) => {
|
|
160
|
+
h(S) && n.push(S);
|
|
159
161
|
});
|
|
160
162
|
});
|
|
161
|
-
}),
|
|
162
|
-
const a =
|
|
163
|
-
a.length !== i.length && (
|
|
163
|
+
}), n.length) {
|
|
164
|
+
const a = n.filter((m) => m === "if"), i = n.filter((m) => m === "endif");
|
|
165
|
+
a.length !== i.length && (s({
|
|
164
166
|
type: c.Error,
|
|
165
167
|
message: o("custom-conditions.missing-if-endif-tag")
|
|
166
168
|
}), r = !1);
|
|
167
169
|
}
|
|
168
170
|
return r;
|
|
169
|
-
},
|
|
170
|
-
const t = (e.match(/{% /gm) || []).length,
|
|
171
|
-
return r ||
|
|
171
|
+
}, L = (e) => {
|
|
172
|
+
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
|
|
173
|
+
return r || s({
|
|
172
174
|
type: c.Warning,
|
|
173
175
|
message: o("custom-conditions.no-space-after-braces")
|
|
174
176
|
}), r;
|
|
175
|
-
},
|
|
177
|
+
}, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
|
|
176
178
|
type: c.Warning,
|
|
177
179
|
message: o("custom-conditions.no-braces-inside-if-tag")
|
|
178
|
-
}), !1) : !0,
|
|
180
|
+
}), !1) : !0, B = () => u.hasInvalidBlock() ? (s({
|
|
179
181
|
type: c.Error,
|
|
180
|
-
message: o(
|
|
181
|
-
}), !1) : !0,
|
|
182
|
+
message: o(ee)
|
|
183
|
+
}), !1) : !0, x = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
|
|
182
184
|
type: c.Error,
|
|
183
185
|
message: o("newsletter.fill-all-necessary-fields")
|
|
184
186
|
}), !1) : !0, D = (e) => {
|
|
185
187
|
const t = /src="[^"]*\.(svg|pst)"/gm;
|
|
186
|
-
return e.match(t) === null ? !0 : (
|
|
188
|
+
return e.match(t) === null ? !0 : (s({
|
|
187
189
|
type: c.Error,
|
|
188
190
|
message: o("newsletter.invalid-image-type")
|
|
189
191
|
}), !1);
|
|
190
192
|
}, F = (e) => {
|
|
191
|
-
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(
|
|
193
|
+
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(j);
|
|
192
194
|
return Array.from(r).find((i) => {
|
|
193
|
-
var
|
|
194
|
-
return !((
|
|
195
|
-
}) ? (
|
|
195
|
+
var m;
|
|
196
|
+
return !((m = i.id) != null && m.trim());
|
|
197
|
+
}) ? (s({
|
|
196
198
|
type: c.Error,
|
|
197
199
|
message: o("unsubscribe-templates.select-checkbox-groups")
|
|
198
200
|
}), !1) : !0;
|
|
199
|
-
},
|
|
200
|
-
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(
|
|
201
|
+
}, k = (e) => {
|
|
202
|
+
const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(z);
|
|
201
203
|
return Array.from(r).find((i) => {
|
|
202
|
-
var
|
|
203
|
-
return !((
|
|
204
|
-
}) ? (
|
|
204
|
+
var m;
|
|
205
|
+
return !((m = i.id) != null && m.trim());
|
|
206
|
+
}) ? (s({
|
|
205
207
|
type: c.Error,
|
|
206
208
|
message: o("unsubscribe-templates.select-radio-button-groups")
|
|
207
209
|
}), !1) : !0;
|
|
208
210
|
};
|
|
209
|
-
return { validateHtml: async (e, t,
|
|
210
|
-
var
|
|
211
|
+
return { validateHtml: async (e, t, n = !1) => {
|
|
212
|
+
var v, y;
|
|
211
213
|
const r = [
|
|
212
214
|
...t.map((I) => I.value),
|
|
213
215
|
...q,
|
|
214
|
-
...((
|
|
216
|
+
...((y = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : y.customFieldAttributes) ?? []
|
|
215
217
|
], a = M(e), i = await E(a);
|
|
216
|
-
return await
|
|
218
|
+
return await R(e, r, n) && b(e) && A(e) && _(e) && O(e, r, a, i) && w(e) && L(e) && N(e) && B() && x() && D(e) && F(e) && k(e);
|
|
217
219
|
} };
|
|
218
220
|
};
|
|
219
221
|
export {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
de as buildPartnerAttributeNameSet,
|
|
223
|
+
fe as findInvalidCustomFields,
|
|
224
|
+
ue as parseRecommendationVariable,
|
|
225
|
+
De as useHtmlValidator
|
|
224
226
|
};
|
|
@@ -3,20 +3,21 @@ import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommenda
|
|
|
3
3
|
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
5
|
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
|
|
7
|
+
import { useConfigStore as P } from "../stores/config.js";
|
|
8
|
+
const B = () => ({
|
|
8
9
|
calculateCardWidth: ({
|
|
9
10
|
mobileLeftPadding: a,
|
|
10
11
|
mobileRightPadding: s,
|
|
11
12
|
cardsInRow: c,
|
|
12
|
-
unresponsive:
|
|
13
|
+
unresponsive: n
|
|
13
14
|
}) => {
|
|
14
|
-
const r =
|
|
15
|
+
const r = n ? c : 1, e = a + s + (r - 1) * b;
|
|
15
16
|
return (C - e) / r;
|
|
16
17
|
},
|
|
17
18
|
getRecommendationCampaignData: (a) => {
|
|
18
|
-
const s = l(), c = Number(a),
|
|
19
|
-
if (!
|
|
19
|
+
const s = l(), c = Number(a), n = s.blockStates[c];
|
|
20
|
+
if (!n)
|
|
20
21
|
return {
|
|
21
22
|
textTrimming: !1,
|
|
22
23
|
orientation: "vertical",
|
|
@@ -29,7 +30,7 @@ const k = () => ({
|
|
|
29
30
|
discountBeforeTextValue: "",
|
|
30
31
|
discountAfterTextValue: ""
|
|
31
32
|
};
|
|
32
|
-
const { recommendationConfigs: r } =
|
|
33
|
+
const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
33
34
|
return {
|
|
34
35
|
textTrimming: r.textTrimming,
|
|
35
36
|
orientation: e,
|
|
@@ -45,7 +46,7 @@ const k = () => ({
|
|
|
45
46
|
},
|
|
46
47
|
buildCampaignUrl: (a, s) => {
|
|
47
48
|
var m;
|
|
48
|
-
const c = l(),
|
|
49
|
+
const c = l(), n = P(), r = Number(a);
|
|
49
50
|
let e;
|
|
50
51
|
if (s)
|
|
51
52
|
e = s;
|
|
@@ -53,25 +54,25 @@ const k = () => ({
|
|
|
53
54
|
const i = c.blockStates[r];
|
|
54
55
|
if (!i)
|
|
55
56
|
return "";
|
|
56
|
-
const { recommendationConfigs:
|
|
57
|
+
const { recommendationConfigs: o } = i;
|
|
57
58
|
e = {
|
|
58
|
-
strategy:
|
|
59
|
-
language:
|
|
60
|
-
currencyCode:
|
|
61
|
-
size:
|
|
62
|
-
productIds:
|
|
63
|
-
filters:
|
|
64
|
-
shuffleProducts:
|
|
59
|
+
strategy: o.strategy,
|
|
60
|
+
language: o.language,
|
|
61
|
+
currencyCode: o.currencySettings.value,
|
|
62
|
+
size: o.size,
|
|
63
|
+
productIds: o.productIds,
|
|
64
|
+
filters: o.filters,
|
|
65
|
+
shuffleProducts: o.shuffleProducts
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
68
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName",
|
|
69
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
70
|
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
70
|
-
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(
|
|
71
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
|
|
71
72
|
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
73
|
return c.recommendationCampaignUrls[a] = u, u;
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
export {
|
|
76
|
-
|
|
77
|
+
B as useRecommendation
|
|
77
78
|
};
|