@useinsider/guido 3.3.0-beta.6d597b3 → 3.3.0-beta.7f3bdce

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.
Files changed (38) hide show
  1. package/dist/@types/config/schemas.js +1 -1
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +42 -40
  4. package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
  5. package/dist/composables/useCortexBlueprintBridge.js +66 -0
  6. package/dist/composables/useEmailTemplateApplier.js +41 -0
  7. package/dist/composables/useGuidoStateBridge.js +48 -0
  8. package/dist/composables/useHtmlValidator.js +41 -36
  9. package/dist/composables/useRecommendation.js +2 -2
  10. package/dist/composables/useResponsivePreview.js +1 -1
  11. package/dist/config/migrator/radioButtonMigrator.js +30 -29
  12. package/dist/enums/extensions/recommendationBlock.js +95 -41
  13. package/dist/enums/unsubscribe.js +25 -24
  14. package/dist/extensions/Blocks/Checkbox/control.js +23 -23
  15. package/dist/extensions/Blocks/RadioButton/control.js +15 -15
  16. package/dist/extensions/Blocks/RadioButton/template.js +6 -6
  17. package/dist/extensions/Blocks/Recommendation/block.js +43 -36
  18. package/dist/extensions/Blocks/Recommendation/services/configService.js +33 -26
  19. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +35 -26
  20. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +3 -3
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  22. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -3
  23. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/valibot/dist/index.js +329 -252
  26. package/dist/services/unsubscribeApi.js +6 -6
  27. package/dist/src/composables/useCortexBlueprintBridge.d.ts +25 -0
  28. package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
  29. package/dist/src/composables/useGuidoStateBridge.d.ts +22 -0
  30. package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
  31. package/dist/src/enums/unsubscribe.d.ts +8 -3
  32. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  33. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +11 -3
  34. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -1
  35. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
  36. package/dist/src/stores/guido-email-editor.d.ts +41 -0
  37. package/dist/stores/guido-email-editor.js +20 -0
  38. package/package.json +3 -30
@@ -1,5 +1,5 @@
1
1
  import { ModuleFolderDefaults as S } from "../../enums/defaults.js";
2
- import { object as o, number as n, optional as e, string as t, picklist as l, pipe as p, minLength as b, custom as h, boolean as a, array as c, record as k, literal as i, looseObject as y, variant as g, union as f, unknown as s } from "../../node_modules/valibot/dist/index.js";
2
+ import { object as o, number as n, optional as e, string as t, pipe as p, picklist as l, minLength as b, custom as h, boolean as a, array as c, record as k, looseObject as y, literal as i, variant as g, union as f, unknown as s } from "../../node_modules/valibot/dist/index.js";
3
3
  const d = {
4
4
  /** Promotional/marketing emails */
5
5
  PROMOTIONAL: 1,
@@ -12,7 +12,7 @@ var t = function() {
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "1a4e7084"
15
+ "cdee3452"
16
16
  );
17
17
  const l = s.exports;
18
18
  export {
@@ -1,38 +1,40 @@
1
- import { defineComponent as J, defineAsyncComponent as I, ref as W, computed as B, watch as Q, onMounted as X, onUnmounted as Y } from "vue";
2
- import { provideGuidoActions as Z } from "../composables/useGuidoActions.js";
3
- import { usePartner as ee } from "../composables/usePartner.js";
4
- import { useStripo as oe } from "../composables/useStripo.js";
5
- import { useTimerClone as te } from "../composables/useTimerClone.js";
6
- import { migrate as H } from "../config/migrator/index.js";
7
- import { ModuleFolderDefaults as x } from "../enums/defaults.js";
8
- import { RIBBON_SELECTOR as ne } from "../enums/onboarding.js";
9
- import re from "./organisms/AutoSaveController.vue.js";
10
- import se from "./organisms/base/Toaster.vue.js";
11
- import ce from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
12
- import ae from "./organisms/header/HeaderWrapper.vue.js";
13
- import ie from "./organisms/LoadingWrapper.vue.js";
14
- import me from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
15
- import de from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
16
- import { useStripoApi as le } from "../services/stripoApi.js";
17
- import { useConfigStore as ue } from "../stores/config.js";
18
- import { useDynamicContentStore as pe } from "../stores/dynamic-content.js";
19
- import { useEditorStore as fe } from "../stores/editor.js";
20
- import { usePreviewStore as ve } from "../stores/preview.js";
21
- import { useUnsubscribeStore as ye } from "../stores/unsubscribe.js";
22
- const We = /* @__PURE__ */ J({
1
+ import { defineComponent as J, defineAsyncComponent as R, ref as I, computed as W, watch as Q, onMounted as X, onUnmounted as Y } from "vue";
2
+ import { useCortexBlueprintBridge as Z } from "../composables/useCortexBlueprintBridge.js";
3
+ import { provideGuidoActions as ee } from "../composables/useGuidoActions.js";
4
+ import { useGuidoStateBridge as oe } from "../composables/useGuidoStateBridge.js";
5
+ import { usePartner as te } from "../composables/usePartner.js";
6
+ import { useStripo as ne } from "../composables/useStripo.js";
7
+ import { useTimerClone as re } from "../composables/useTimerClone.js";
8
+ import { migrate as x } from "../config/migrator/index.js";
9
+ import { ModuleFolderDefaults as G } from "../enums/defaults.js";
10
+ import { RIBBON_SELECTOR as se } from "../enums/onboarding.js";
11
+ import ce from "./organisms/AutoSaveController.vue.js";
12
+ import ae from "./organisms/base/Toaster.vue.js";
13
+ import ie from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
14
+ import me from "./organisms/header/HeaderWrapper.vue.js";
15
+ import de from "./organisms/LoadingWrapper.vue.js";
16
+ import le from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
17
+ import ue from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
18
+ import { useStripoApi as pe } from "../services/stripoApi.js";
19
+ import { useConfigStore as fe } from "../stores/config.js";
20
+ import { useDynamicContentStore as ve } from "../stores/dynamic-content.js";
21
+ import { useEditorStore as ye } from "../stores/editor.js";
22
+ import { usePreviewStore as he } from "../stores/preview.js";
23
+ import { useUnsubscribeStore as Se } from "../stores/unsubscribe.js";
24
+ const He = /* @__PURE__ */ J({
23
25
  __name: "Guido",
24
26
  props: {
25
27
  config: null
26
28
  },
27
29
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
28
- setup(G, { expose: z, emit: n }) {
29
- const g = G, q = I(
30
+ setup(H, { expose: z, emit: n }) {
31
+ const g = H, q = R(
30
32
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
31
- ), K = I(
33
+ ), K = R(
32
34
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
33
- ), w = W(), u = W(), p = pe(), E = ye(), i = ue();
35
+ ), w = I(), u = I(), p = ve(), E = Se(), i = fe();
34
36
  i.init(g.config);
35
- const f = fe(), V = ve(), m = B(() => f.hasChanges), { isTestPartner: $ } = ee(), D = () => {
37
+ const f = ye(), V = he(), m = W(() => f.hasChanges), { isTestPartner: $ } = te(), D = () => {
36
38
  var e;
37
39
  return (e = w.value) == null ? void 0 : e.handleSave(!0);
38
40
  }, {
@@ -42,8 +44,8 @@ const We = /* @__PURE__ */ J({
42
44
  username: k,
43
45
  template: o,
44
46
  editor: s
45
- } = i, d = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", y = (o == null ? void 0 : o.preselectedDynamicContent) || [], L = (s == null ? void 0 : s.savedModulesFolderName) || x.SAVED_MODULES, U = (s == null ? void 0 : s.defaultModulesFolderName) || x.DEFAULT_MODULES;
46
- f.templateId = v;
47
+ } = i, d = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", y = (o == null ? void 0 : o.preselectedDynamicContent) || [], L = (s == null ? void 0 : s.savedModulesFolderName) || G.SAVED_MODULES, U = (s == null ? void 0 : s.defaultModulesFolderName) || G.DEFAULT_MODULES;
48
+ f.templateId = v, Z(), oe();
47
49
  const h = {
48
50
  emailId: v,
49
51
  userId: C,
@@ -56,11 +58,11 @@ const We = /* @__PURE__ */ J({
56
58
  onReady: () => {
57
59
  console.debug("guido:ready"), n("ready");
58
60
  }
59
- }, { initPlugin: M } = oe(h, _), { getDefaultTemplate: O } = le(), { cloneTimersOnSave: P, hasTimerBlocks: A } = te(), j = B(() => {
61
+ }, { initPlugin: M } = ne(h, _), { getDefaultTemplate: O } = pe(), { cloneTimersOnSave: P, hasTimerBlocks: A } = re(), j = W(() => {
60
62
  var e;
61
63
  return !((e = i.ui) != null && e.showHeader);
62
64
  });
63
- Z({
65
+ ee({
64
66
  onBack: () => {
65
67
  console.debug("guido:back"), n("back");
66
68
  },
@@ -75,9 +77,9 @@ const We = /* @__PURE__ */ J({
75
77
  console.debug("guido:test-email:click"), n("test-email:click");
76
78
  }
77
79
  });
78
- const N = (e) => {
80
+ const B = (e) => {
79
81
  console.debug("dynamic-content:close", e), p.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
80
- }, R = () => {
82
+ }, N = () => {
81
83
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
82
84
  };
83
85
  Q(() => m.value, () => {
@@ -90,7 +92,7 @@ const We = /* @__PURE__ */ J({
90
92
  let c = null;
91
93
  const b = () => {
92
94
  var t;
93
- const e = document.querySelector(ne);
95
+ const e = document.querySelector(se);
94
96
  (t = u.value) == null || t.style.setProperty("--ribbon-offset", `${(e == null ? void 0 : e.offsetHeight) ?? 0}px`);
95
97
  };
96
98
  return X(async () => {
@@ -102,10 +104,10 @@ const We = /* @__PURE__ */ J({
102
104
  E.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
103
105
  const a = ((l = o == null ? void 0 : o.migration) == null ? void 0 : l.recommendationConfigs) ?? {};
104
106
  let r = {
105
- html: d && await H(d, a),
107
+ html: d && await x(d, a),
106
108
  css: F
107
109
  };
108
- r.html || (r = await O(), r.html = await H(r.html, a)), A(r.html) && (r.html = await P(r.html)), await M(r), p.selectedDynamicContentList = y;
110
+ r.html || (r = await O(), r.html = await x(r.html, a)), A(r.html) && (r.html = await P(r.html)), await M(r), p.selectedDynamicContentList = y;
109
111
  } catch (a) {
110
112
  console.error("Failed to initialize Stripo editor:", a);
111
113
  }
@@ -120,14 +122,14 @@ const We = /* @__PURE__ */ J({
120
122
  i.reset();
121
123
  }), z({
122
124
  dynamicContent: {
123
- insert: N,
124
- close: R
125
+ insert: B,
126
+ close: N
125
127
  },
126
128
  hasChanges: m,
127
129
  saveSilent: D
128
- }), { __sfc: !0, PreviewContainer: q, OnboardingWrapper: K, headerWrapperRef: w, wrapperRef: u, dynamicContentStore: p, unsubscribeStore: E, props: g, configStore: i, editorStore: f, previewStore: V, hasChanges: m, isTestPartner: $, saveSilent: D, templateId: v, userId: C, partnerName: T, username: k, templateConfig: o, editorConfig: s, html: d, css: F, preselectedDynamicContentList: y, savedModulesFolderName: L, defaultModulesFolderName: U, emit: n, metadata: h, options: _, initPlugin: M, getDefaultTemplate: O, cloneTimersOnSave: P, hasTimerBlocks: A, noHeader: j, insertDynamicContent: N, closeDynamicContent: R, handleDynamicContentOpen: S, ribbonObserver: c, updateRibbonOffset: b, AutoSaveController: re, Toaster: se, FilterSelectionDrawer: ce, HeaderWrapper: ae, LoadingWrapper: ie, SaveAsTemplateDrawer: me, UnsubscribeWrapper: de };
130
+ }), { __sfc: !0, PreviewContainer: q, OnboardingWrapper: K, headerWrapperRef: w, wrapperRef: u, dynamicContentStore: p, unsubscribeStore: E, props: g, configStore: i, editorStore: f, previewStore: V, hasChanges: m, isTestPartner: $, saveSilent: D, templateId: v, userId: C, partnerName: T, username: k, templateConfig: o, editorConfig: s, html: d, css: F, preselectedDynamicContentList: y, savedModulesFolderName: L, defaultModulesFolderName: U, emit: n, metadata: h, options: _, initPlugin: M, getDefaultTemplate: O, cloneTimersOnSave: P, hasTimerBlocks: A, noHeader: j, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: S, ribbonObserver: c, updateRibbonOffset: b, AutoSaveController: ce, Toaster: ae, FilterSelectionDrawer: ie, HeaderWrapper: me, LoadingWrapper: de, SaveAsTemplateDrawer: le, UnsubscribeWrapper: ue };
129
131
  }
130
132
  });
131
133
  export {
132
- We as default
134
+ He as default
133
135
  };
@@ -1,17 +1,17 @@
1
- import i from "./MiddleSlot.vue2.js";
1
+ import r from "./MiddleSlot.vue2.js";
2
2
  import s from "../../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var t = function() {
4
- var r = this, e = r._self._c, o = r._self._setupProxy;
5
- return e("div", [o.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(o.VersionHistory), e(o.VersionHistoryViewOptions)], 1) : o.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(o.EmailSizeIndicator), e(o.AmpToggle)], 1) : r._e(), e(o.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: o.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] })], 1);
6
- }, n = [], a = /* @__PURE__ */ s(
7
- i,
4
+ var o = this, e = o._self._c, i = o._self._setupProxy;
5
+ return e("div", { staticClass: "d-f a-i-c" }, [i.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(i.VersionHistory), e(i.VersionHistoryViewOptions)], 1) : i.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(i.EmailSizeIndicator), e(i.AmpToggle)], 1) : o._e(), e(i.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: i.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] })], 1);
6
+ }, a = [], n = /* @__PURE__ */ s(
7
+ r,
8
8
  t,
9
- n,
9
+ a,
10
10
  !1,
11
11
  null,
12
12
  null
13
13
  );
14
- const c = a.exports;
14
+ const c = n.exports;
15
15
  export {
16
16
  c as default
17
17
  };
@@ -0,0 +1,66 @@
1
+ import { useEmailTemplateApplier as m, resetEmailTemplateApplier as w } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as _ } from "./useToaster.js";
3
+ import { useTranslations as I } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as S } from "../enums/toaster.js";
5
+ import { getActivePinia as v } from "pinia";
6
+ import { watch as B, onUnmounted as D } from "vue";
7
+ const P = "email_template", x = "chat", L = "guido:debug:ai", M = () => {
8
+ if (typeof window > "u")
9
+ return !1;
10
+ try {
11
+ return window.localStorage.getItem(L) === "1";
12
+ } catch {
13
+ return !1;
14
+ }
15
+ }, O = () => {
16
+ const a = v();
17
+ if (!a)
18
+ return;
19
+ const l = a._s, p = l == null ? void 0 : l.get(x);
20
+ if (!p)
21
+ return;
22
+ const { applyTemplate: d, applyTemplateDebounced: f } = m(), { showToaster: T } = _(), h = I(), A = (e, t) => {
23
+ const r = h(e);
24
+ return r === e ? t : r;
25
+ }, i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), u = M(), E = (e, t) => {
26
+ u && console.debug(`[guido:cortex] msg=${e ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
27
+ }, y = (e) => {
28
+ if (e.blueprintType !== P)
29
+ return;
30
+ const t = e.blueprintId, r = e.blueprintData;
31
+ if (!t || !(r != null && r.html))
32
+ return;
33
+ const o = i.get(t);
34
+ o === void 0 ? (i.set(t, r.html), d(t, r)) : o !== r.html && (i.set(t, r.html), f(t, r));
35
+ }, s = (e) => e === void 0 || c.has(e) ? !1 : (c.add(e), T({
36
+ type: S.Alert,
37
+ message: A("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
38
+ }), !0), b = B(
39
+ () => p.messages,
40
+ (e) => {
41
+ Array.isArray(e) && e.forEach((t) => {
42
+ const r = t == null ? void 0 : t.id;
43
+ (t == null ? void 0 : t.isError) === !0 && s(r) && u && console.debug(`[guido:cortex] message-level error id=${r}`, t);
44
+ const o = t == null ? void 0 : t.segments;
45
+ Array.isArray(o) && o.forEach((n) => {
46
+ if (n)
47
+ switch (E(r, n), n.type) {
48
+ case "blueprint":
49
+ y(n);
50
+ break;
51
+ case "error":
52
+ s(r);
53
+ break;
54
+ }
55
+ });
56
+ });
57
+ },
58
+ { deep: !0, immediate: !0 }
59
+ );
60
+ D(() => {
61
+ b(), i.clear(), c.clear(), w();
62
+ });
63
+ };
64
+ export {
65
+ O as useCortexBlueprintBridge
66
+ };
@@ -0,0 +1,41 @@
1
+ import { useActionsApi as u } from "./useActionsApi.js";
2
+ import { useToaster as T } from "./useToaster.js";
3
+ import { useTranslations as f } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as n } from "../enums/toaster.js";
5
+ import { ref as y } from "vue";
6
+ const h = 250, s = y({}), o = {}, j = () => {
7
+ const { updateHtmlAndCss: l } = u(), { showToaster: r } = T(), i = f(), c = (e, t, p) => {
8
+ s.value = { ...s.value, [e]: "applying" };
9
+ try {
10
+ l(t, p), s.value = { ...s.value, [e]: "applied" }, r({
11
+ type: n.Success,
12
+ message: i("newsletter.ai-template-applied")
13
+ });
14
+ } catch (a) {
15
+ s.value = { ...s.value, [e]: "failed" }, r({
16
+ type: n.Alert,
17
+ message: a instanceof Error ? a.message : "Failed to apply template"
18
+ });
19
+ }
20
+ }, m = (e) => {
21
+ const t = o[e];
22
+ t && (clearTimeout(t), delete o[e]);
23
+ };
24
+ return { applyStatus: s, applyTemplate: (e, t) => {
25
+ t.html && (m(e), c(e, t.html, t.css ?? ""));
26
+ }, applyTemplateDebounced: (e, t) => {
27
+ if (!t.html)
28
+ return;
29
+ m(e);
30
+ const { html: p } = t, a = t.css ?? "";
31
+ o[e] = setTimeout(() => {
32
+ delete o[e], c(e, p, a);
33
+ }, h);
34
+ } };
35
+ }, w = () => {
36
+ Object.values(o).forEach(clearTimeout), Object.keys(o).forEach((l) => delete o[l]), s.value = {};
37
+ };
38
+ export {
39
+ w as resetEmailTemplateApplier,
40
+ j as useEmailTemplateApplier
41
+ };
@@ -0,0 +1,48 @@
1
+ import { useActionsApi as g } from "./useActionsApi.js";
2
+ import { useConfigStore as I } from "../stores/config.js";
3
+ import { useEditorStore as b } from "../stores/editor.js";
4
+ import { useGuidoEmailEditorStore as E } from "../stores/guido-email-editor.js";
5
+ import { watch as c, onUnmounted as T } from "vue";
6
+ const w = 500, z = () => {
7
+ const i = b(), a = E(), l = I(), { getTemplateData: m } = g();
8
+ let e = null, n = !1;
9
+ const r = () => {
10
+ e && (clearTimeout(e), e = null);
11
+ }, s = async () => {
12
+ var t, o;
13
+ if (!(n || !i.isStripoInitialized))
14
+ try {
15
+ const { html: f, css: h } = await m(), S = ((o = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : o.templateId) ?? "";
16
+ if (n)
17
+ return;
18
+ a.$patch({
19
+ html: f ?? "",
20
+ css: h ?? "",
21
+ templateId: S,
22
+ lastUpdatedAt: Date.now()
23
+ });
24
+ } catch {
25
+ }
26
+ }, u = () => {
27
+ r(), e = setTimeout(() => {
28
+ e = null, s();
29
+ }, w);
30
+ }, d = c(
31
+ () => i.isStripoInitialized,
32
+ (t) => {
33
+ t && s();
34
+ },
35
+ { immediate: !0 }
36
+ ), p = c(
37
+ () => i.hasChanges,
38
+ (t, o) => {
39
+ i.isStripoInitialized && (t ? u() : o && (r(), s()));
40
+ }
41
+ );
42
+ T(() => {
43
+ n = !0, r(), d(), p();
44
+ });
45
+ };
46
+ export {
47
+ z as useGuidoStateBridge
48
+ };
@@ -1,35 +1,37 @@
1
- import { useConfig as L } from "./useConfig.js";
2
- import { TemplateTypes as V } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as _, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
1
+ import { useConfig as _ } from "./useConfig.js";
2
+ import { TemplateTypes as H } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as M } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationStore as $ } from "../stores/recommendation.js";
7
- import { base64EncodeWithSpecialChars as X } from "../utils/base64.js";
8
- import { useHttp as j } from "./useHttp.js";
9
- import { useToaster as q } from "./useToaster.js";
10
- import { useTranslations as z } from "./useTranslations.js";
11
- const K = /recommendation-id="(\d+)"/g;
12
- function U(a) {
13
- return [...a.matchAll(K)].map((u) => u[1]);
5
+ import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
+ import { useRecommendationStore as K } from "../stores/recommendation.js";
9
+ import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
10
+ import { useHttp as U } from "./useHttp.js";
11
+ import { useToaster as Y } from "./useToaster.js";
12
+ import { useTranslations as Z } from "./useTranslations.js";
13
+ const J = /recommendation-id="(\d+)"/g;
14
+ function Q(a) {
15
+ return [...a.matchAll(J)].map((u) => u[1]);
14
16
  }
15
- function Y(a, u) {
17
+ function ee(a, u) {
16
18
  return u.some((d) => a.startsWith(`${d}_`));
17
19
  }
18
- const ce = () => {
20
+ const ge = () => {
19
21
  var y, h;
20
- const { showToaster: a } = q(), { post: u } = j(), { config: d } = L(), r = z(), g = $(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === V.transactional, b = async (e) => {
22
+ const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
21
23
  const t = await u(
22
24
  "/newsletter/template-library/check-template-html-body",
23
- { html: X(e) }
25
+ { html: z(e) }
24
26
  ), { status: n, message: l } = t.data;
25
27
  return n || a({
26
28
  type: c.Alert,
27
29
  message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
28
- }), r(P), l === r(G) && a({
30
+ }), r(M), l === r($) && a({
29
31
  type: c.Alert,
30
32
  message: r("newsletter.already-in-progress")
31
33
  }), n;
32
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
34
+ }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
33
35
  const t = e.match(/({%(.*?)%})/g);
34
36
  let n = !0;
35
37
  return t !== null && !p && t.forEach((l) => {
@@ -42,13 +44,13 @@ const ce = () => {
42
44
  }), n = !1);
43
45
  }
44
46
  }), n;
45
- }, A = async (e, s, t) => {
47
+ }, k = async (e, s, t) => {
46
48
  const n = t ? await b(e) : !0;
47
- return E(e, s) && n;
48
- }, I = (e) => e.length > 0 ? !0 : (a({
49
+ return A(e, s) && n;
50
+ }, x = (e) => e.length > 0 ? !0 : (a({
49
51
  type: c.Warning,
50
52
  message: r("newsletter.html-content-is-empty")
51
- }), !1), k = (e) => {
53
+ }), !1), I = (e) => {
52
54
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
53
55
  return s > t && a({
54
56
  type: c.Warning,
@@ -57,7 +59,7 @@ const ce = () => {
57
59
  type: c.Warning,
58
60
  message: r("custom-fields.missing-opening-braces")
59
61
  }), s === t;
60
- }, x = (e) => {
62
+ }, F = (e) => {
61
63
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
62
64
  return s || a({
63
65
  type: c.Warning,
@@ -66,10 +68,10 @@ const ce = () => {
66
68
  }, T = (e, s) => {
67
69
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
68
70
  if (t && !p) {
69
- const n = new Set(s.map((i) => i.toLowerCase())), l = U(e), o = [];
71
+ const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
70
72
  if (t.forEach((i) => {
71
73
  const m = i.slice(2, -2).trim().toLowerCase();
72
- (!n.has(m) || m === "") && !Y(m, l) && o.push(m);
74
+ (!n.has(m) || m === "") && !ee(m, l) && o.push(m);
73
75
  }), o.length > 0) {
74
76
  const i = `
75
77
  <ul>
@@ -83,11 +85,11 @@ const ce = () => {
83
85
  }
84
86
  }
85
87
  return !0;
86
- }, F = (e) => {
88
+ }, R = (e) => {
87
89
  const s = e.match(/{%(.*?)%}/g), t = [];
88
90
  let n = !0;
89
91
  if (s && s.forEach((l) => {
90
- const o = l.match(_), i = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
92
+ const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
91
93
  (!o || l !== m) && !i && (a({
92
94
  type: c.Alert,
93
95
  message: r("newsletter.display-conditions-invalid-syntax")
@@ -98,7 +100,7 @@ const ce = () => {
98
100
  }), n = !1);
99
101
  const v = f.match(/^[a-zA-Z]*$/g);
100
102
  v && v.forEach((C) => {
101
- S(C) && t.push(C);
103
+ E(C) && t.push(C);
102
104
  });
103
105
  });
104
106
  }), t.length) {
@@ -109,25 +111,28 @@ const ce = () => {
109
111
  }), n = !1);
110
112
  }
111
113
  return n;
112
- }, W = (e) => {
114
+ }, B = (e) => {
113
115
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
114
116
  return n || a({
115
117
  type: c.Warning,
116
118
  message: r("custom-conditions.no-space-after-braces")
117
119
  }), n;
118
- }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
120
+ }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
119
121
  type: c.Warning,
120
122
  message: r("custom-conditions.no-braces-inside-if-tag")
123
+ }), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
124
+ type: c.Alert,
125
+ message: r(j)
121
126
  }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
122
127
  type: c.Alert,
123
128
  message: r("newsletter.fill-all-necessary-fields")
124
- }), !1) : !0, B = (e) => {
129
+ }), !1) : !0, D = (e) => {
125
130
  const s = /src="[^"]*\.(svg|pst)"/gm;
126
131
  return e.match(s) === null ? !0 : (a({
127
132
  type: c.Alert,
128
133
  message: r("newsletter.invalid-image-type")
129
134
  }), !1);
130
- }, R = (e) => {
135
+ }, L = (e) => {
131
136
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
132
137
  return Array.from(n).find((o) => {
133
138
  var i;
@@ -136,7 +141,7 @@ const ce = () => {
136
141
  type: c.Alert,
137
142
  message: r("unsubscribe-templates.select-checkbox-groups")
138
143
  }), !1) : !0;
139
- }, D = (e) => {
144
+ }, V = (e) => {
140
145
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
141
146
  return Array.from(n).find((o) => {
142
147
  var i;
@@ -150,12 +155,12 @@ const ce = () => {
150
155
  var o, i;
151
156
  const n = [
152
157
  ...s.map((m) => m.value),
153
- ...M,
158
+ ...q,
154
159
  ...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
155
160
  ];
156
- return await A(e, n, t) && I(e) && k(e) && x(e) && T(e, n) && F(e) && W(e) && N(e) && O() && B(e) && R(e) && D(e);
161
+ return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
157
162
  } };
158
163
  };
159
164
  export {
160
- ce as useHtmlValidator
165
+ ge as useHtmlValidator
161
166
  };
@@ -1,4 +1,4 @@
1
- import { RecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
1
+ import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
2
2
  import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
@@ -63,7 +63,7 @@ const w = () => ({
63
63
  shuffleProducts: o.shuffleProducts
64
64
  };
65
65
  }
66
- const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
66
+ const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
67
  if (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") {
68
68
  const i = parseInt(e.size) || 6;
69
69
  t.set("productId", e.productIds.slice(0, i).join(","));
@@ -1,5 +1,5 @@
1
1
  import { useDebounce as p } from "./useDebounce.js";
2
- import { ResponsivePreviewRegex as c, ResponsivePreviewConfig as a, ResponsivePreviewSelectors as v } from "../enums/preview.js";
2
+ import { ResponsivePreviewRegex as c, ResponsivePreviewSelectors as v, ResponsivePreviewConfig as a } from "../enums/preview.js";
3
3
  let i = null, l = null;
4
4
  const { debounce: y } = p(), h = (t) => {
5
5
  if (!t)