@useinsider/guido 3.30.0-beta.1360af2 → 3.30.0-beta.16d665a

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 (27) hide show
  1. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +16 -11
  2. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
  3. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
  4. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
  5. package/dist/composables/useExport.js +7 -8
  6. package/dist/composables/useHtmlValidator.js +100 -102
  7. package/dist/composables/useToaster.js +10 -11
  8. package/dist/composables/useVersionHistoryApi.js +21 -22
  9. package/dist/composables/validators/useLiquidValidator.js +24 -26
  10. package/dist/config/migrator/itemsBlockMigrator.js +164 -161
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +141 -148
  12. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
  13. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +39 -40
  14. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +26 -27
  15. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +32 -33
  16. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +22 -23
  17. package/dist/extensions/Blocks/Recommendation/templates/utils.js +78 -79
  18. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +41 -50
  19. package/dist/guido.css +1 -1
  20. package/dist/package.json.js +1 -1
  21. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +0 -2
  22. package/dist/src/stores/preview.d.ts +0 -3
  23. package/dist/stores/preview.js +15 -21
  24. package/dist/utils/pairProductVariables.js +98 -108
  25. package/package.json +1 -1
  26. package/dist/src/utils/ampPreviewSanitizer.d.ts +0 -5
  27. package/dist/utils/ampPreviewSanitizer.js +0 -46
@@ -1,18 +1,23 @@
1
- import t from "./DesktopPreview.vue2.js";
1
+ import o from "./DesktopPreview.vue2.js";
2
2
  /* empty css */
3
- import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var i = function() {
5
- var s = this, e = s._self._c, r = s._self._setupProxy;
6
- return e("div", { staticClass: "desktop-preview-wrapper" }, [e("p", { staticClass: "f-s-1 f-w-600 l-h-1 t-t-u t-c-53 mb-6 l-s-5" }, [s._v(" " + s._s(r.trans("email-editor.desktop-preview")) + " ")]), e("div", { ref: "containerRef", staticClass: "desktop-preview d-f f-d-c o-h s-1" }, [e(r.DesktopBrowserHeader), e("div", { staticClass: "desktop-preview__content d-f f-g-1 o-h b-c-5 min-h-0" }, [e("div", { staticClass: "f-g-1 h-1 o-h b-c-4 min-w-0" }, [r.isContainerReady ? e("iframe", { key: r.previewStore.previewSandbox, staticClass: "desktop-preview__iframe d-b w-1 h-1 b-c-4 bor-s-n", attrs: { sandbox: r.previewStore.previewSandbox, srcdoc: r.previewStore.previewHtml }, on: { load: r.onIframeLoad } }) : s._e()])])], 1)]);
7
- }, a = [], n = /* @__PURE__ */ o(
8
- t,
9
- i,
3
+ import r from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var a = function() {
5
+ var s = this, e = s._self._c, t = s._self._setupProxy;
6
+ return e("div", { staticClass: "desktop-preview-wrapper" }, [e("p", { staticClass: "f-s-1 f-w-600 l-h-1 t-t-u t-c-53 mb-6 l-s-5" }, [s._v(" " + s._s(t.trans("email-editor.desktop-preview")) + " ")]), e("div", { ref: "containerRef", staticClass: "desktop-preview d-f f-d-c o-h s-1" }, [e(t.DesktopBrowserHeader), e("div", { staticClass: "desktop-preview__content d-f f-g-1 o-h b-c-5 min-h-0" }, [e("div", { staticClass: "f-g-1 h-1 o-h b-c-4 min-w-0" }, [t.isContainerReady ? e("iframe", { staticClass: "desktop-preview__iframe d-b w-1 h-1 b-c-4 bor-s-n", attrs: { sandbox: `
7
+ allow-same-origin
8
+ allow-popups
9
+ allow-forms
10
+ allow-scripts
11
+ allow-popups-to-escape-sandbox`, srcdoc: t.previewStore.previewHtml }, on: { load: t.onIframeLoad } }) : s._e()])])], 1)]);
12
+ }, i = [], n = /* @__PURE__ */ r(
13
+ o,
10
14
  a,
15
+ i,
11
16
  !1,
12
17
  null,
13
- "f5ff6219"
18
+ "cf946232"
14
19
  );
15
- const _ = n.exports;
20
+ const f = n.exports;
16
21
  export {
17
- _ as default
22
+ f as default
18
23
  };
@@ -1,20 +1,20 @@
1
- import a from "./ContentView.vue2.js";
1
+ import e from "./ContentView.vue2.js";
2
2
  /* empty css */
3
- import r from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var n = function() {
5
- var t = this, s = t._self._c, e = t._self._setupProxy;
3
+ import n from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var o = function() {
5
+ var t = this, s = t._self._c, a = t._self._setupProxy;
6
6
  return s("div", { staticClass: "w-1 h-1 b-c-4 d-f f-d-c" }, [s("div", { staticClass: "d-f j-c-s-b a-i-c p-2 h-6-s" }, [s("div", { staticClass: "d-f a-i-c cur-p", on: { click: function(l) {
7
7
  return t.$emit("back-to-inbox");
8
- } } }, [s(e.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [t._v(t._s(e.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(e.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(e.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("div", { staticClass: "iframe-wrapper f-g-1 o-h" }, [s("iframe", { key: e.previewStore.previewSandbox, ref: "iframeRef", staticClass: "iframe-scaled d-b b-c-4 bor-s-n", attrs: { sandbox: e.previewStore.previewSandbox, srcdoc: e.previewStore.previewHtml }, on: { load: e.onLoad } })])]);
9
- }, i = [], c = /* @__PURE__ */ r(
10
- a,
11
- n,
8
+ } } }, [s(a.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [t._v(t._s(a.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(a.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(a.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("div", { staticClass: "iframe-wrapper f-g-1 o-h" }, [s("iframe", { ref: "iframeRef", staticClass: "iframe-scaled d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: a.previewStore.previewHtml }, on: { load: a.onLoad } })])]);
9
+ }, i = [], r = /* @__PURE__ */ n(
10
+ e,
11
+ o,
12
12
  i,
13
13
  !1,
14
14
  null,
15
- "a7102458"
15
+ "f255b2bb"
16
16
  );
17
- const p = c.exports;
17
+ const d = r.exports;
18
18
  export {
19
- p as default
19
+ d as default
20
20
  };
@@ -1,51 +1,51 @@
1
- import { defineComponent as N, defineAsyncComponent as E, ref as D, computed as o, watch as R } from "vue";
1
+ import { defineComponent as b, defineAsyncComponent as T, ref as w, computed as o, watch as N } from "vue";
2
2
  import "@useinsider/design-system-organisms/style";
3
- import { useToaster as P } from "../../../../composables/useToaster.js";
4
- import { useTranslations as U } from "../../../../composables/useTranslations.js";
5
- import { DOTTED_DATE_LOCALE as G } from "../../../../enums/date.js";
6
- import { URLS as M } from "../../../../enums/extensions/recommendationBlock.js";
7
- import { ToasterTypeOptions as p } from "../../../../enums/toaster.js";
8
- import { useRecommendationExtensionStore as $ } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { commitStrategyChange as O } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
10
- import z from "./StrategyInfoBoxContent.vue.js";
11
- import { formatShortDate as H } from "../../../../utils/dateUtil.js";
12
- import { asText as g } from "../../../../utils/genericUtil.js";
13
- import { escapeHtml as f } from "../../../../utils/htmlEscape.js";
14
- import { InSkeleton as I } from "@useinsider/design-system-vue";
15
- const it = /* @__PURE__ */ N({
3
+ import { useToaster as R } from "../../../../composables/useToaster.js";
4
+ import { useTranslations as P } from "../../../../composables/useTranslations.js";
5
+ import { DOTTED_DATE_LOCALE as U } from "../../../../enums/date.js";
6
+ import { URLS as G } from "../../../../enums/extensions/recommendationBlock.js";
7
+ import { ToasterTypeOptions as u } from "../../../../enums/toaster.js";
8
+ import { useRecommendationExtensionStore as M } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { commitStrategyChange as E } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
10
+ import $ from "./StrategyInfoBoxContent.vue.js";
11
+ import { formatShortDate as z } from "../../../../utils/dateUtil.js";
12
+ import { asText as D } from "../../../../utils/genericUtil.js";
13
+ import { escapeHtml as H } from "../../../../utils/htmlEscape.js";
14
+ import { InSkeleton as O } from "@useinsider/design-system-vue";
15
+ const it = /* @__PURE__ */ b({
16
16
  __name: "AssignStrategyDrawer",
17
17
  setup(F) {
18
- const d = () => import("@useinsider/design-system-organisms"), S = (t, r) => ({
19
- render: (s) => s(I, { props: { sizing: { width: t, height: r } } })
20
- }), h = E({
21
- loader: async () => (await d()).OrgStrategyDetailModal,
22
- loadingComponent: S(480, 240),
18
+ const g = () => import("@useinsider/design-system-organisms"), p = (t, r) => ({
19
+ render: (s) => s(O, { props: { sizing: { width: t, height: r } } })
20
+ }), I = T({
21
+ loader: async () => (await g()).OrgStrategyDetailModal,
22
+ loadingComponent: p(480, 240),
23
23
  delay: 0
24
- }), x = E({
25
- loader: async () => (await d()).OrgStrategyDropdown
26
- }), i = "guido-edit-strategy-", A = { width: 480, height: 42 }, a = U(), e = $(), { showToaster: c } = P(), n = D(null), m = "legacy", l = D(!1), C = o(() => e.strategiesLoading || e.legacyConversionLoading), L = o(() => e.assignStrategyDrawerStatus ? a("email-editor.assign-strategy-description", { url: M.RECOMMENDATION_STRATEGIES_PANEL_PATH }) : "");
27
- R(() => e.assignStrategyDrawerStatus, (t) => {
24
+ }), h = T({
25
+ loader: async () => (await g()).OrgStrategyDropdown
26
+ }), i = "guido-edit-strategy-", x = { width: 480, height: 42 }, a = P(), e = M(), { showToaster: c } = R(), n = w(null), d = "legacy", l = w(!1), A = o(() => e.strategiesLoading || e.legacyConversionLoading), C = o(() => e.assignStrategyDrawerStatus ? a("email-editor.assign-strategy-description", { url: G.RECOMMENDATION_STRATEGIES_PANEL_PATH }) : "");
27
+ N(() => e.assignStrategyDrawerStatus, (t) => {
28
28
  if (!t)
29
29
  return;
30
30
  const { strategyId: r } = e.recommendationConfigs;
31
- n.value = r || (e.isLegacyStrategyBlock ? m : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
31
+ n.value = r || (e.isLegacyStrategyBlock ? d : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
32
32
  c({
33
- type: p.Error,
33
+ type: u.Error,
34
34
  message: a("discovery-strategy.error-description")
35
35
  });
36
36
  });
37
37
  });
38
- const v = (t) => {
39
- const r = g(t.updated_at || t.created_at);
38
+ const f = (t) => {
39
+ const r = D(t.updated_at || t.created_at);
40
40
  if (!r)
41
41
  return "";
42
- const s = H(r, G);
42
+ const s = z(r, U);
43
43
  return a("recommendation-strategy.last-updated-on", { value: s });
44
- }, _ = o(() => ({
44
+ }, S = o(() => ({
45
45
  text: a("ds-steps.legacy-strategy"),
46
- value: m,
46
+ value: d,
47
47
  hidden: !0
48
- })), y = o(() => e.strategies.map((t) => ({
48
+ })), m = o(() => e.strategies.map((t) => ({
49
49
  text: t.name,
50
50
  value: t.strategy_id,
51
51
  infoBoxProps: {
@@ -54,10 +54,10 @@ const it = /* @__PURE__ */ N({
54
54
  variant: "information",
55
55
  size: "small",
56
56
  class: "assign-strategy-info-box",
57
- titleText: f(g(t.name)),
57
+ titleText: H(D(t.name)),
58
58
  descriptionStatus: !0,
59
- descriptionText: v(t),
60
- slot: z,
59
+ descriptionText: f(t),
60
+ slot: $,
61
61
  slotProps: { strategy: t },
62
62
  // The info box drops the option's value/text, so the id is the only channel
63
63
  // that can carry the strategy back to the click handler.
@@ -70,17 +70,17 @@ const it = /* @__PURE__ */ N({
70
70
  icon: "line-open-website"
71
71
  }]
72
72
  }
73
- }))), B = o(() => e.isLegacyStrategyBlock ? [_.value, ...y.value] : y.value), k = (t) => {
74
- var w;
75
- const r = (w = t == null ? void 0 : t.id) != null && w.startsWith(i) ? t.id.slice(i.length) : "";
73
+ }))), L = o(() => e.isLegacyStrategyBlock ? [S.value, ...m.value] : m.value), B = (t) => {
74
+ var _;
75
+ const r = (_ = t == null ? void 0 : t.id) != null && _.startsWith(i) ? t.id.slice(i.length) : "";
76
76
  if (!r)
77
77
  return;
78
- const s = e.currentRecommendationId, u = e.recommendationConfigs.strategyId === r;
79
- e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), u && (e.removeStrategy(), s !== null && O(s, "Removed recommendation strategy")));
80
- }, T = o(() => {
78
+ const s = e.currentRecommendationId, y = e.recommendationConfigs.strategyId === r;
79
+ e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), y && (e.removeStrategy(), s !== null && E(s, "Removed recommendation strategy")));
80
+ }, v = o(() => {
81
81
  const t = e.strategies.find((r) => String(r.strategy_id) === String(n.value ?? ""));
82
82
  return t ? { ...t, fallback_config: null } : null;
83
- }), b = o(() => ({
83
+ }), k = o(() => ({
84
84
  primaryButton: {
85
85
  styling: "solid",
86
86
  type: "primary",
@@ -92,10 +92,10 @@ const it = /* @__PURE__ */ N({
92
92
  labelText: a("products.cancel")
93
93
  }
94
94
  }));
95
- return { __sfc: !0, loadOrganisms: d, skeleton: S, OrgStrategyDetailModal: h, OrgStrategyDropdown: x, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: A, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: m, showSelectionError: l, strategiesLoading: C, drawerDescription: L, lastUpdatedText: v, legacyStrategyOption: _, remoteStrategyOptions: y, strategyOptions: B, onInfoBoxButtonClick: k, selectedStrategy: T, footerButtonGroupOptions: b, closeDrawer: () => {
95
+ return { __sfc: !0, loadOrganisms: g, skeleton: p, OrgStrategyDetailModal: I, OrgStrategyDropdown: h, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: x, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: d, showSelectionError: l, strategiesLoading: A, drawerDescription: C, lastUpdatedText: f, legacyStrategyOption: S, remoteStrategyOptions: m, strategyOptions: L, onInfoBoxButtonClick: B, selectedStrategy: v, footerButtonGroupOptions: k, closeDrawer: () => {
96
96
  e.closeAssignStrategyDrawer();
97
97
  }, assignStrategy: async () => {
98
- const t = T.value;
98
+ const t = v.value;
99
99
  if (!t) {
100
100
  l.value = !0;
101
101
  return;
@@ -103,24 +103,24 @@ const it = /* @__PURE__ */ N({
103
103
  let r = "";
104
104
  try {
105
105
  r = await e.resolveStrategyUrlTemplate(t, e.recommendationConfigs.currencySettings.value);
106
- } catch (u) {
107
- console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", u);
106
+ } catch (y) {
107
+ console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", y);
108
108
  }
109
109
  if (!r) {
110
110
  c({
111
- type: p.Error,
112
- message: a("email-editor.strategy-assign-failed", { strategyName: f(g(t.name)) })
111
+ type: u.Error,
112
+ message: a("email-editor.strategy-assign-failed", { strategyName: t.name })
113
113
  });
114
114
  return;
115
115
  }
116
116
  const s = e.currentRecommendationId;
117
117
  e.assignStrategy(t), c({
118
- type: p.Success,
119
- message: a("email-editor.strategy-assigned-success", { strategyName: f(g(t.name)) })
120
- }), e.closeAssignStrategyDrawer(), s !== null && await O(s, "Assigned recommendation strategy");
118
+ type: u.Success,
119
+ message: a("email-editor.strategy-assigned-success", { strategyName: t.name })
120
+ }), e.closeAssignStrategyDrawer(), s !== null && await E(s, "Assigned recommendation strategy");
121
121
  }, onSelect: (t) => {
122
122
  n.value = t.value, l.value = !1;
123
- }, InSkeleton: I };
123
+ }, InSkeleton: O };
124
124
  }
125
125
  });
126
126
  export {
@@ -12,9 +12,9 @@ var i = function() {
12
12
  l,
13
13
  !1,
14
14
  null,
15
- "c8351f74"
15
+ "e48cebe9"
16
16
  );
17
- const u = d.exports;
17
+ const f = d.exports;
18
18
  export {
19
- u as default
19
+ f as default
20
20
  };
@@ -1,9 +1,8 @@
1
1
  import { ToasterTypeOptions as a } from "../enums/toaster.js";
2
- import { escapeHtml as m } from "../utils/htmlEscape.js";
3
- import { useActionsApi as p } from "./useActionsApi.js";
4
- import { useHtmlCompiler as d } from "./useHtmlCompiler.js";
5
- import { useToaster as u } from "./useToaster.js";
6
- const x = () => {
2
+ import { useActionsApi as m } from "./useActionsApi.js";
3
+ import { useHtmlCompiler as p } from "./useHtmlCompiler.js";
4
+ import { useToaster as d } from "./useToaster.js";
5
+ const H = () => {
7
6
  const c = (s, o, n) => {
8
7
  const i = new Blob([s], { type: n }), t = URL.createObjectURL(i), e = document.createElement("a");
9
8
  e.href = t, e.download = o, document.body.appendChild(e), e.click(), document.body.removeChild(e), URL.revokeObjectURL(t);
@@ -12,7 +11,7 @@ const x = () => {
12
11
  return `${s}_${n}-${i}-${t}_${e}-${r}.html`;
13
12
  };
14
13
  return { exportHtml: async (s = !0) => {
15
- const { getCompiledEmail: o } = p(), { showToaster: n } = u(), { compileHtml: i } = d();
14
+ const { getCompiledEmail: o } = m(), { showToaster: n } = d(), { compileHtml: i } = p();
16
15
  try {
17
16
  const { html: t } = await o();
18
17
  if (t) {
@@ -37,11 +36,11 @@ const x = () => {
37
36
  const e = t instanceof Error ? t.message : String(t);
38
37
  n({
39
38
  type: a.Error,
40
- message: `Error compiling email: ${m(e)}`
39
+ message: `Error compiling email: ${e}`
41
40
  });
42
41
  }
43
42
  } };
44
43
  };
45
44
  export {
46
- x as useExport
45
+ H as useExport
47
46
  };
@@ -1,7 +1,7 @@
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 { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as j, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
4
+ import { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as U, VALID_DYNAMIC_VARIABLE_REGEX as j } from "../enums/html-validator.js";
5
5
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
6
6
  import { BLOCK_ROOT_SELECTOR as q } from "../extensions/Blocks/Checkbox/constants/selectors.js";
7
7
  import { itemsBlockDynamicVariables as z } from "../extensions/Blocks/Items/enums/productEnums.js";
@@ -10,59 +10,57 @@ import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as J } from "../extensions/B
10
10
  import { useRecommendationExtensionStore as Q } from "../extensions/Blocks/Recommendation/store/recommendation.js";
11
11
  import { filterToProductAttrValue as ee } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
12
12
  import { STRATEGY_FIELD_KEY as te, RecommendationAssignStrategyKey as ne, RecommendationRequiredFieldsKey as se } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
13
- import { useRecommendationStore as oe } from "../stores/recommendation.js";
14
- import { base64EncodeWithSpecialChars as re } from "../utils/base64.js";
15
- import { isPlainObject as ie, asText as ae } from "../utils/genericUtil.js";
16
- import { escapeHtml as ce } from "../utils/htmlEscape.js";
17
- import { computed as me } from "vue";
18
- import { useHttp as le } from "./useHttp.js";
19
- import { useToaster as ue } from "./useToaster.js";
20
- import { useTranslations as de } from "./useTranslations.js";
21
- const fe = /recommendation-id="(\d+)"/g;
22
- function ge(s) {
23
- return [...s.matchAll(fe)].map((l) => l[1]);
13
+ import { useRecommendationStore as re } from "../stores/recommendation.js";
14
+ import { base64EncodeWithSpecialChars as oe } from "../utils/base64.js";
15
+ import { computed as ie } from "vue";
16
+ import { useHttp as ae } from "./useHttp.js";
17
+ import { useToaster as ce } from "./useToaster.js";
18
+ import { useTranslations as le } from "./useTranslations.js";
19
+ const me = /recommendation-id="(\d+)"/g;
20
+ function ue(s) {
21
+ return [...s.matchAll(me)].map((m) => m[1]);
24
22
  }
25
- function pe(s, l) {
26
- return l.some((f) => s.startsWith(`${f}_`));
23
+ function de(s, m) {
24
+ return m.some((f) => s.startsWith(`${f}_`));
27
25
  }
28
- const Ee = /^(\d+)_\d+_(.+)$/;
29
- function Ce(s) {
30
- const l = s.match(Ee);
31
- return l ? { recoId: l[1], attribute: l[2] } : null;
26
+ const fe = /^(\d+)_\d+_(.+)$/;
27
+ function ge(s) {
28
+ const m = s.match(fe);
29
+ return m ? { recoId: m[1], attribute: m[2] } : null;
32
30
  }
33
- function ye(s) {
34
- const l = new Set(J);
31
+ function pe(s) {
32
+ const m = new Set(J);
35
33
  return Object.values(s).forEach((f) => {
36
- l.add(ee(f).toLowerCase());
37
- }), l;
34
+ m.add(ee(f).toLowerCase());
35
+ }), m;
38
36
  }
39
- function he(s, l, f, r, d) {
37
+ function Ee(s, m, f, o, d) {
40
38
  const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
41
39
  if (!u)
42
40
  return [];
43
- const p = new Set(l.map((C) => C.toLowerCase())), E = [];
41
+ const p = new Set(m.map((C) => C.toLowerCase())), E = [];
44
42
  return u.forEach((C) => {
45
43
  const g = C.slice(2, -2).trim().toLowerCase();
46
44
  if (g !== "" && p.has(g))
47
45
  return;
48
- const y = Ce(g);
49
- if (y && r.has(y.recoId)) {
46
+ const y = ge(g);
47
+ if (y && o.has(y.recoId)) {
50
48
  if (!d || d.has(y.attribute))
51
49
  return;
52
50
  E.push(g);
53
51
  return;
54
52
  }
55
- pe(g, f) || g.includes(".") || E.push(g);
53
+ de(g, f) || g.includes(".") || E.push(g);
56
54
  }), E;
57
55
  }
58
- function ve(s) {
59
- return (s.replace(Y, "$1").match($) ?? []).filter((r) => {
60
- const d = r.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
61
- return j.includes(p) ? !1 : U.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
56
+ function Ce(s) {
57
+ return (s.replace(Y, "$1").match($) ?? []).filter((o) => {
58
+ const d = o.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
59
+ return U.includes(p) ? !1 : j.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
62
60
  });
63
61
  }
64
- const Ke = () => {
65
- const { showToaster: s } = ue(), { post: l } = le(), { config: f } = V(), r = de(), d = oe(), u = Q(), p = me(
62
+ const Ve = () => {
63
+ const { showToaster: s } = ce(), { post: m } = ae(), { config: f } = V(), o = le(), d = re(), u = Q(), p = ie(
66
64
  () => {
67
65
  var e, t;
68
66
  return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
@@ -75,161 +73,161 @@ const Ke = () => {
75
73
  } catch {
76
74
  return null;
77
75
  }
78
- return ye(u.filterList);
76
+ return pe(u.filterList);
79
77
  }, C = async (e) => {
80
- const t = "/newsletter/template-library/check-template-html-body", { data: n } = await l(
81
- t,
82
- { html: re(e) }
83
- ), { status: o, message: a } = ie(n) ? n : { status: void 0, message: void 0 }, i = ae(a);
84
- return o || s({
78
+ const n = await m(
79
+ "/newsletter/template-library/check-template-html-body",
80
+ { html: oe(e) }
81
+ ), { status: r, message: a } = n.data;
82
+ return r || s({
85
83
  type: c.Error,
86
- message: o === void 0 && i !== "" ? ce(i) : r("newsletter.invalid-url-link-for-toaster")
87
- }), r(P), a === r(X) && s({
84
+ message: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
85
+ }), o(X), a === o(P) && s({
88
86
  type: c.Error,
89
- message: r("newsletter.already-in-progress")
90
- }), !!o;
87
+ message: o("newsletter.already-in-progress")
88
+ }), r;
91
89
  }, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), y = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, t) => {
92
90
  const n = e.match(/({%(.*?)%})/g);
93
- let o = !0;
91
+ let r = !0;
94
92
  return n !== null && !p.value && n.forEach((a) => {
95
93
  const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
96
94
  if (i && i.length > 0) {
97
- const [m] = i;
98
- g(m) && !t.includes(m) && (s({
95
+ const [l] = i;
96
+ g(l) && !t.includes(l) && (s({
99
97
  type: c.Warning,
100
- message: r("custom-fields.invalid-custom-fields")
101
- }), o = !1);
98
+ message: o("custom-fields.invalid-custom-fields")
99
+ }), r = !1);
102
100
  }
103
- }), o;
101
+ }), r;
104
102
  }, R = async (e, t, n) => {
105
- const o = n ? await C(e) : !0;
106
- return S(e, t) && o;
103
+ const r = n ? await C(e) : !0;
104
+ return S(e, t) && r;
107
105
  }, _ = (e) => e.length > 0 ? !0 : (s({
108
106
  type: c.Warning,
109
- message: r("newsletter.html-content-is-empty")
107
+ message: o("newsletter.html-content-is-empty")
110
108
  }), !1), A = (e) => {
111
109
  const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
112
110
  return t > n && s({
113
111
  type: c.Warning,
114
- message: r("custom-fields.missing-closing-braces")
112
+ message: o("custom-fields.missing-closing-braces")
115
113
  }), t < n && s({
116
114
  type: c.Warning,
117
- message: r("custom-fields.missing-opening-braces")
115
+ message: o("custom-fields.missing-opening-braces")
118
116
  }), t === n;
119
117
  }, O = (e) => {
120
- const t = ve(e).length === 0;
118
+ const t = Ce(e).length === 0;
121
119
  return t || s({
122
120
  type: c.Warning,
123
- message: r("custom-fields.invalid-custom-fields")
121
+ message: o("custom-fields.invalid-custom-fields")
124
122
  }), t;
125
- }, b = (e, t, n, o) => {
123
+ }, b = (e, t, n, r) => {
126
124
  if (p.value)
127
125
  return !0;
128
- const a = he(
126
+ const a = Ee(
129
127
  e,
130
128
  t,
131
- ge(e),
129
+ ue(e),
132
130
  n,
133
- o
131
+ r
134
132
  );
135
133
  if (a.length > 0) {
136
134
  const i = `
137
135
  <ul>
138
- ${a.map((m) => `<li>${m}</li>`).join("")}
136
+ ${a.map((l) => `<li>${l}</li>`).join("")}
139
137
  </ul>
140
138
  `;
141
139
  return s({
142
140
  type: c.Error,
143
- message: r("custom-fields.invalid-custom-fields") + i
141
+ message: o("custom-fields.invalid-custom-fields") + i
144
142
  }), !1;
145
143
  }
146
144
  return !0;
147
145
  }, w = (e) => {
148
146
  const t = e.match(G), n = [];
149
- let o = !0;
147
+ let r = !0;
150
148
  if (t && t.forEach((a) => {
151
- const i = a.match(H), m = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
152
- (!i || a !== v) && !m && (s({
149
+ const i = a.match(H), l = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
150
+ (!i || a !== v) && !l && (s({
153
151
  type: c.Error,
154
- message: r("newsletter.display-conditions-invalid-syntax")
155
- }), o = !1), i && i.forEach((h) => {
152
+ message: o("newsletter.display-conditions-invalid-syntax")
153
+ }), r = !1), i && i.forEach((h) => {
156
154
  h.trim() === "=" && (s({
157
155
  type: c.Error,
158
- message: r("custom-conditions.wrong-equality-operators")
159
- }), o = !1);
156
+ message: o("custom-conditions.wrong-equality-operators")
157
+ }), r = !1);
160
158
  const T = h.match(/^[a-zA-Z]*$/g);
161
159
  T && T.forEach((I) => {
162
160
  y(I) && n.push(I);
163
161
  });
164
162
  });
165
163
  }), n.length) {
166
- const a = n.filter((m) => m === "if"), i = n.filter((m) => m === "endif");
164
+ const a = n.filter((l) => l === "if"), i = n.filter((l) => l === "endif");
167
165
  a.length !== i.length && (s({
168
166
  type: c.Error,
169
- message: r("custom-conditions.missing-if-endif-tag")
170
- }), o = !1);
167
+ message: o("custom-conditions.missing-if-endif-tag")
168
+ }), r = !1);
171
169
  }
172
- return o;
170
+ return r;
173
171
  }, N = (e) => {
174
- const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, o = t === n;
175
- return o || s({
172
+ const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
173
+ return r || s({
176
174
  type: c.Warning,
177
- message: r("custom-conditions.no-space-after-braces")
178
- }), o;
179
- }, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, o) => n + o, 0) > 0 ? (s({
175
+ message: o("custom-conditions.no-space-after-braces")
176
+ }), r;
177
+ }, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
180
178
  type: c.Warning,
181
- message: r("custom-conditions.no-braces-inside-if-tag")
179
+ message: o("custom-conditions.no-braces-inside-if-tag")
182
180
  }), !1) : !0, B = () => {
183
181
  if (!u.hasInvalidBlock())
184
182
  return !0;
185
183
  const e = u.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === te);
186
184
  return s({
187
185
  type: t ? c.Warning : c.Error,
188
- message: r(t ? ne : se)
186
+ message: o(t ? ne : se)
189
187
  }), !1;
190
- }, x = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
188
+ }, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
191
189
  type: c.Error,
192
- message: r("newsletter.fill-all-necessary-fields")
193
- }), !1) : !0, F = (e) => {
190
+ message: o("newsletter.fill-all-necessary-fields")
191
+ }), !1) : !0, x = (e) => {
194
192
  const t = /src="[^"]*\.(svg|pst)"/gm;
195
193
  return e.match(t) === null ? !0 : (s({
196
194
  type: c.Error,
197
- message: r("newsletter.invalid-image-type")
195
+ message: o("newsletter.invalid-image-type")
198
196
  }), !1);
199
197
  }, D = (e) => {
200
- const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
201
- return Array.from(o).find((i) => {
202
- var m;
203
- return !((m = i.id) != null && m.trim());
198
+ const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
199
+ return Array.from(r).find((i) => {
200
+ var l;
201
+ return !((l = i.id) != null && l.trim());
204
202
  }) ? (s({
205
203
  type: c.Error,
206
- message: r("unsubscribe-templates.select-checkbox-groups")
204
+ message: o("unsubscribe-templates.select-checkbox-groups")
207
205
  }), !1) : !0;
208
206
  }, k = (e) => {
209
- const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
210
- return Array.from(o).find((i) => {
211
- var m;
212
- return !((m = i.id) != null && m.trim());
207
+ const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
208
+ return Array.from(r).find((i) => {
209
+ var l;
210
+ return !((l = i.id) != null && l.trim());
213
211
  }) ? (s({
214
212
  type: c.Error,
215
- message: r("unsubscribe-templates.select-radio-button-groups")
213
+ message: o("unsubscribe-templates.select-radio-button-groups")
216
214
  }), !1) : !0;
217
215
  };
218
216
  return { validateHtml: async (e, t, n = !1) => {
219
217
  var v, h;
220
- const o = [
218
+ const r = [
221
219
  ...t.map((T) => T.value),
222
220
  ...z,
223
221
  ...((h = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : h.customFieldAttributes) ?? []
224
222
  ], a = M(e), i = await E(a);
225
- return await R(e, o, n) && _(e) && A(e) && O(e) && b(e, o, a, i) && w(e) && N(e) && L(e) && B() && x() && F(e) && D(e) && k(e);
223
+ return await R(e, r, n) && _(e) && A(e) && O(e) && b(e, r, a, i) && w(e) && N(e) && L(e) && B() && F() && x(e) && D(e) && k(e);
226
224
  } };
227
225
  };
228
226
  export {
229
- ye as buildPartnerAttributeNameSet,
230
- he as findInvalidCustomFields,
231
- ve as getInvalidDynamicContentTags,
232
- ge as getRecommendationBlockIds,
233
- Ce as parseRecommendationVariable,
234
- Ke as useHtmlValidator
227
+ pe as buildPartnerAttributeNameSet,
228
+ Ee as findInvalidCustomFields,
229
+ Ce as getInvalidDynamicContentTags,
230
+ ue as getRecommendationBlockIds,
231
+ ge as parseRecommendationVariable,
232
+ Ve as useHtmlValidator
235
233
  };