@useinsider/guido 3.19.0-beta.3abc7c5 → 3.19.0-beta.3d545d6

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 (58) hide show
  1. package/README.md +0 -1
  2. package/dist/@types/config/schemas.js +31 -33
  3. package/dist/components/Guido.vue.js +9 -9
  4. package/dist/components/Guido.vue2.js +57 -58
  5. package/dist/components/organisms/AutoSaveController.vue2.js +8 -9
  6. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  7. package/dist/components/organisms/base/AuthErrorModal.vue2.js +29 -0
  8. package/dist/components/organisms/header/EditorActions.vue.js +5 -5
  9. package/dist/components/organisms/header/EditorActions.vue2.js +55 -85
  10. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +12 -16
  12. package/dist/components/wrappers/WpDrawer.vue.js +7 -9
  13. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  14. package/dist/components/wrappers/WpModal.vue.js +1 -1
  15. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  16. package/dist/composables/useAuthError.js +51 -0
  17. package/dist/composables/useHtmlCompiler.js +26 -37
  18. package/dist/composables/useHtmlValidator.js +0 -2
  19. package/dist/composables/useHttp.js +58 -51
  20. package/dist/composables/useSave.js +45 -90
  21. package/dist/composables/useToaster.js +17 -15
  22. package/dist/composables/validators/useCouponBlockValidator.js +21 -24
  23. package/dist/composables/validators/useLiquidValidator.js +15 -15
  24. package/dist/composables/validators/useUnsubscribeBlockValidator.js +27 -34
  25. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +47 -54
  26. package/dist/guido.css +1 -1
  27. package/dist/src/@types/config/schemas.d.ts +0 -4
  28. package/dist/src/components/Guido.vue.d.ts +1 -17
  29. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -17
  30. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -17
  31. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -17
  32. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +3 -4
  33. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  34. package/dist/src/composables/useAuthError.d.ts +11 -0
  35. package/dist/src/composables/useConfig.d.ts +0 -2
  36. package/dist/src/composables/useHtmlValidator.d.ts +0 -21
  37. package/dist/src/composables/useHttp.d.ts +2 -0
  38. package/dist/src/composables/useSave.d.ts +1 -6
  39. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
  40. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -10
  41. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
  42. package/dist/src/stores/config.d.ts +0 -32
  43. package/dist/src/utils/templatePreparation.d.ts +0 -30
  44. package/dist/stores/config.js +67 -84
  45. package/dist/utils/templatePreparation.js +36 -39
  46. package/package.json +1 -1
  47. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +0 -20
  48. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +0 -48
  49. package/dist/composables/useSaveValidation.js +0 -279
  50. package/dist/composables/useSaveValidationRollout.js +0 -9
  51. package/dist/enums/save-validation.js +0 -4
  52. package/dist/src/@types/save-validation.d.ts +0 -19
  53. package/dist/src/composables/useSaveValidation.d.ts +0 -6
  54. package/dist/src/composables/useSaveValidationRollout.d.ts +0 -3
  55. package/dist/src/enums/save-validation.d.ts +0 -27
  56. package/dist/src/stores/save-validation.d.ts +0 -22
  57. package/dist/stores/save-validation.js +0 -30
  58. /package/dist/src/components/organisms/{validation/ValidationErrorDrawer.vue.d.ts → base/AuthErrorModal.vue.d.ts} +0 -0
@@ -1,100 +1,55 @@
1
- import { useActionsApi as W } from "./useActionsApi.js";
1
+ import { useActionsApi as T } from "./useActionsApi.js";
2
2
  import { useConfig as q } from "./useConfig.js";
3
- import { useEditorLock as O } from "./useEditorLock.js";
4
- import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
5
- import { useSaveValidation as j } from "./useSaveValidation.js";
6
- import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
7
- import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
8
- import { ToasterTypeOptions as I } from "../enums/toaster.js";
9
- import { useStripoApi as J } from "../services/stripoApi.js";
10
- import { useConfigStore as K } from "../stores/config.js";
11
- import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
12
- import { useSaveValidationStore as Q } from "../stores/save-validation.js";
13
- import { useTemplatePreparation as X, getHtmlReferencedUnsubscribePages as Y } from "../utils/templatePreparation.js";
14
- import { useAllowlist as Z } from "./useAllowlist.js";
15
- import { useHtmlValidator as _ } from "./useHtmlValidator.js";
16
- import { useToaster as $ } from "./useToaster.js";
17
- import { useCouponBlockValidator as tt } from "./validators/useCouponBlockValidator.js";
18
- import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
19
- import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
20
- import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
21
- const Bt = () => {
22
- const r = D(), f = F(), { validateHtml: p } = _(), { validateLiquidSyntax: v } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: S, validateUnsubscribeBlockHasTemplate: w } = st(), { validateSyncModuleBlocks: u } = ot(), { callbacks: a, isFeatureEnabled: m } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: E, getTemplateData: H } = W(), { showToaster: V } = $(), { getBlockedDomains: x, resolveToast: k } = Z(), { prepareTemplateDetails: d } = X(), { collectSaveValidationErrors: C } = j(), { isEnabled: B } = z(), T = Q(), h = N(), P = K(), { runExclusive: n } = O(), l = async (t, e, o) => {
23
- if (!m("allowlistEnabled"))
24
- return !1;
25
- const i = await x(t, e);
26
- if (!i.length)
27
- return !1;
28
- if (!o) {
29
- const s = await k(i);
30
- s != null && s.message && V({
31
- type: I.Warning,
32
- message: s.message,
33
- actionButton: s.actionButton
34
- });
35
- }
36
- return !0;
37
- }, L = async (t) => !y(t.compiledHtml) || !S(t.compiledHtml) || !w(t.compiledHtml) ? !1 : m("liquidSyntax") ? v(t.compiledHtml) : p(t.compiledHtml, t.dynamicContentList, !0), c = async (t, e) => {
38
- if (!await E())
3
+ import { useEditorLock as C } from "./useEditorLock.js";
4
+ import { useSaveStart as L, useSaveComplete as M } from "./useGuidoActions.js";
5
+ import { useSyncModuleExtractor as D } from "./useSyncModuleExtractor.js";
6
+ import { ToasterTypeOptions as P } from "../enums/toaster.js";
7
+ import { useStripoApi as U } from "../services/stripoApi.js";
8
+ import { useTemplatePreparation as A } from "../utils/templatePreparation.js";
9
+ import { useAllowlist as h } from "./useAllowlist.js";
10
+ import { useHtmlValidator as F } from "./useHtmlValidator.js";
11
+ import { useToaster as O } from "./useToaster.js";
12
+ import { useCouponBlockValidator as W } from "./validators/useCouponBlockValidator.js";
13
+ import { useLiquidValidator as j } from "./validators/useLiquidValidator.js";
14
+ import { useSyncModuleBlockValidator as z } from "./validators/useSyncModuleBlockValidator.js";
15
+ import { useUnsubscribeBlockValidator as G } from "./validators/useUnsubscribeBlockValidator.js";
16
+ const rt = () => {
17
+ const n = L(), c = M(), { validateHtml: d } = F(), { validateLiquidSyntax: m } = j(), { validateCouponBlockTags: u } = W(), { validateUnsubscribeBlockUniqueness: p, validateUnsubscribeBlockHasTemplate: f } = G(), { validateSyncModuleBlocks: v } = z(), { callbacks: s, isFeatureEnabled: r } = q(), { extractSyncModuleData: S } = D(), { setSyncModuleUnsubscriptionPages: b } = U(), { editorSave: w } = T(), { showToaster: V } = O(), { getBlockedDomains: y, resolveToast: k } = h(), { runExclusive: x } = C(), H = async (a, o) => {
18
+ var l;
19
+ n();
20
+ const { prepareTemplateDetails: B } = A(), t = await B();
21
+ if (!v(t.rawHtml, o) || !u(t.compiledHtml) || !p(t.compiledHtml) || !f(t.compiledHtml))
39
22
  return;
40
- const { unsubscribePayload: i, stripoModules: s } = b(t.rawHtml);
41
- if (await g(i), t.modules = s, !e.suppress) {
42
- const R = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
43
- f({ ...t, ...R, silent: e.silent });
44
- }
45
- return t;
46
- }, U = async (t, e) => {
47
- var i;
48
- r();
49
- const o = await d();
50
- if (u(o.rawHtml, e)) {
51
- if (B.value && !e) {
52
- const s = await C(
53
- o.compiledHtml,
54
- o.dynamicContentList
55
- );
56
- if (s.length) {
57
- T.open(s, "save");
58
- return;
59
- }
60
- } else if (!await L(o))
23
+ if (r("liquidSyntax")) {
24
+ if (!await m(t.compiledHtml))
61
25
  return;
62
- if (!((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(o)) && !await l(o.compiledHtml, o.css, e))
63
- return c(o, { silent: e, suppress: t });
64
- }
65
- }, A = async () => {
66
- var e;
67
- if (!P.allowSaveWithErrors)
26
+ } else if (!await d(t.compiledHtml, t.dynamicContentList, !0))
68
27
  return;
69
- r();
70
- const t = await d();
71
- if (!((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)) && !await l(t.compiledHtml, t.css, !1))
72
- return c(t, { silent: !1, blankCompiled: !0 });
73
- }, M = async () => {
74
- r();
75
- const { html: t, css: e } = await H();
76
- if (!u(t, !0) || await l(t, e, !0))
28
+ if ((l = s.value) != null && l.externalValidation && !await s.value.externalValidation(t))
77
29
  return;
78
- const o = Y(t), i = {
79
- dynamicContentList: h.getSelectedDynamicContentList,
80
- compiledHtml: "",
81
- rawHtml: t,
82
- css: e,
83
- ampHtml: "",
84
- ampErrors: [],
85
- modules: [],
86
- recommendation: { campaignUrls: {}, configs: {} },
87
- unsubscribe: {
88
- status: o.length > 0,
89
- config: o
30
+ if (r("allowlistEnabled")) {
31
+ const i = await y(t.compiledHtml, t.css);
32
+ if (i.length) {
33
+ if (!o) {
34
+ const e = await k(i);
35
+ e != null && e.message && V({
36
+ type: P.Warning,
37
+ message: e.message,
38
+ actionButton: e.actionButton
39
+ });
40
+ }
41
+ return;
90
42
  }
91
- };
92
- return c(i, { silent: !0 });
43
+ }
44
+ if (!await w())
45
+ return;
46
+ const { unsubscribePayload: E, stripoModules: g } = S(t.rawHtml);
47
+ return await b(E), t.modules = g, a || c({ ...t, silent: o }), t;
93
48
  };
94
- return { save: (t = !1, e = !1) => n(
95
- () => U(t, e)
96
- ), saveWithErrors: () => n(A), saveRawOnly: () => n(M) };
49
+ return { save: (a = !1, o = !1) => x(
50
+ () => H(a, o)
51
+ ) };
97
52
  };
98
53
  export {
99
- Bt as useSave
54
+ rt as useSave
100
55
  };
@@ -1,26 +1,28 @@
1
1
  import { ToasterTypeOptions as T } from "../enums/toaster.js";
2
- import { useToasterStore as c } from "../stores/toaster.js";
3
- import { nextTick as u } from "vue";
2
+ import { useToasterStore as u } from "../stores/toaster.js";
3
+ import { nextTick as c } from "vue";
4
4
  const s = /* @__PURE__ */ new WeakMap(), p = () => {
5
- const e = c(), o = () => {
6
- const t = s.get(e);
7
- t && (clearTimeout(t), s.delete(e));
5
+ const t = u(), o = () => {
6
+ const e = s.get(t);
7
+ e && (clearTimeout(e), s.delete(t));
8
8
  };
9
- function r(t = { message: "" }) {
10
- o(), e.hideToaster(), u(() => {
11
- e.showToaster(t), e.shouldAutoHide && s.set(e, setTimeout(() => {
12
- e.hideToaster(), o();
9
+ function i(e = { message: "" }) {
10
+ o(), t.hideToaster(), c(() => {
11
+ t.showToaster(e), t.shouldAutoHide && s.set(t, setTimeout(() => {
12
+ t.hideToaster(), o();
13
13
  }, 6e3));
14
14
  });
15
15
  }
16
- function i() {
17
- o(), e.hideToaster();
16
+ function n() {
17
+ o(), t.hideToaster();
18
18
  }
19
- function n(t, a) {
20
- const m = t instanceof Error ? t.message : String(t);
21
- r({ type: T.Error, message: `${a}: ${m}` });
19
+ function a(e, r) {
20
+ if (e != null && e.authReported)
21
+ return;
22
+ const m = e instanceof Error ? e.message : String(e);
23
+ i({ type: T.Error, message: `${r}: ${m}` });
22
24
  }
23
- return { showToaster: r, hideToaster: i, handleError: n };
25
+ return { showToaster: i, hideToaster: n, handleError: a };
24
26
  };
25
27
  export {
26
28
  p as useToaster
@@ -1,27 +1,24 @@
1
- import { ToasterTypeOptions as n } from "../../enums/toaster.js";
2
- import { COUPON_PLACEHOLDER_DEFAULT as s, COUPON_PLACEHOLDER_LIQUID as a } from "../../extensions/Blocks/CouponBlock/template.js";
3
- import { useToaster as i } from "../useToaster.js";
4
- import { useTranslations as l } from "../useTranslations.js";
5
- const c = /* @__PURE__ */ new Set([
6
- s,
7
- a
8
- ]), p = "newsletter.coupon-tag-modified";
9
- function u(r) {
10
- const e = new DOMParser().parseFromString(r, "text/html");
11
- return Array.from(e.querySelectorAll(".coupon-block")).map((o) => {
12
- var t;
13
- return ((t = o.textContent) == null ? void 0 : t.trim()) ?? "";
14
- }).filter((o) => !c.has(o));
15
- }
16
- const T = () => {
17
- const { showToaster: r } = i(), e = l();
18
- return { validateCouponBlockTags: (t) => u(t).length > 0 ? (r({
19
- type: n.Warning,
20
- message: e(p)
21
- }), !1) : !0 };
1
+ import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
+ import { COUPON_PLACEHOLDER_DEFAULT as i, COUPON_PLACEHOLDER_LIQUID as l } from "../../extensions/Blocks/CouponBlock/template.js";
3
+ import { useToaster as m } from "../useToaster.js";
4
+ import { useTranslations as p } from "../useTranslations.js";
5
+ const u = /* @__PURE__ */ new Set([
6
+ i,
7
+ l
8
+ ]), A = () => {
9
+ const { showToaster: t } = m(), r = p();
10
+ return { validateCouponBlockTags: (e) => {
11
+ const n = new DOMParser().parseFromString(e, "text/html");
12
+ return Array.from(n.querySelectorAll(".coupon-block")).find((s) => {
13
+ var o;
14
+ const a = ((o = s.textContent) == null ? void 0 : o.trim()) ?? "";
15
+ return !u.has(a);
16
+ }) ? (t({
17
+ type: c.Warning,
18
+ message: r("newsletter.coupon-tag-modified")
19
+ }), !1) : !0;
20
+ } };
22
21
  };
23
22
  export {
24
- p as COUPON_TAG_MODIFIED_KEY,
25
- u as findInvalidCouponBlocks,
26
- T as useCouponBlockValidator
23
+ A as useCouponBlockValidator
27
24
  };
@@ -1,13 +1,13 @@
1
- import { ToasterTypeOptions as a } from "../../enums/toaster.js";
1
+ import { ToasterTypeOptions as r } from "../../enums/toaster.js";
2
2
  import { base64EncodeWithSpecialChars as u } from "../../utils/base64.js";
3
3
  import { useHttp as d } from "../useHttp.js";
4
- import { useToaster as c } from "../useToaster.js";
5
- import { useTranslations as p } from "../useTranslations.js";
4
+ import { useToaster as p } from "../useToaster.js";
5
+ import { useTranslations as c } from "../useTranslations.js";
6
6
  const v = () => {
7
- const { post: i } = d(), { showToaster: e } = c(), s = p();
7
+ const { post: i } = d(), { showToaster: t } = p(), s = c();
8
8
  return { validateLiquidSyntax: async (o) => {
9
9
  try {
10
- const t = await i("/newsletter/contents/validate-syntax", [{
10
+ const e = await i("/newsletter/contents/validate-syntax", [{
11
11
  identifier: "default",
12
12
  syntax: "liquid",
13
13
  contents: {
@@ -17,21 +17,21 @@ const v = () => {
17
17
  ampHtml: null
18
18
  }
19
19
  }]);
20
- if (!Array.isArray(t.data)) {
21
- const l = t.data;
22
- return e({
23
- type: a.Warning,
20
+ if (!Array.isArray(e.data)) {
21
+ const l = e.data;
22
+ return t({
23
+ type: r.Warning,
24
24
  message: l.message ?? s("journey-builder.liquid-validation-failed")
25
25
  }), !1;
26
26
  }
27
- const [r] = t.data, n = Object.values((r == null ? void 0 : r.errors) ?? {});
28
- return n.length ? (e({
29
- type: a.Warning,
27
+ const [a] = e.data, n = Object.values((a == null ? void 0 : a.errors) ?? {});
28
+ return n.length ? (t({
29
+ type: r.Warning,
30
30
  message: n[0].replace(/^line \d+:\s*/, "")
31
31
  }), !1) : !0;
32
- } catch {
33
- return e({
34
- type: a.Error,
32
+ } catch (e) {
33
+ return e != null && e.authReported || t({
34
+ type: r.Error,
35
35
  message: s("journey-builder.liquid-validation-failed")
36
36
  }), !1;
37
37
  }
@@ -1,8 +1,8 @@
1
- import { ToasterTypeOptions as c } from "../../enums/toaster.js";
1
+ import { ToasterTypeOptions as i } from "../../enums/toaster.js";
2
2
  import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
- import { UNSUBSCRIBE_BLOCK_SELECTOR as i, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
- import { useToaster as p } from "../useToaster.js";
5
- import { useTranslations as l } from "../useTranslations.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as E } from "../useToaster.js";
5
+ import { useTranslations as m } from "../useTranslations.js";
6
6
  const T = [
7
7
  {
8
8
  pageType: u.GLOBAL_UNSUBSCRIBE,
@@ -12,37 +12,30 @@ const T = [
12
12
  pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
13
13
  messageKey: "unsubscription-preference.duplicate-pref-center"
14
14
  }
15
- ], g = "unsubscription-preference.duplicate-both", E = "unsubscription-preference.select-page-to-continue";
16
- function m(r) {
17
- const s = new DOMParser().parseFromString(r, "text/html"), t = /* @__PURE__ */ new Map();
18
- return s.querySelectorAll(i).forEach((n) => {
19
- const e = Number(n.getAttribute(a.PAGE_TYPE));
20
- t.set(e, (t.get(e) ?? 0) + 1);
21
- }), T.filter((n) => (t.get(n.pageType) ?? 0) > 1);
22
- }
23
- function b(r) {
24
- const s = new DOMParser().parseFromString(r, "text/html");
25
- return Array.from(s.querySelectorAll(i)).filter((t) => {
26
- const n = t.getAttribute(a.PAGE_TYPE), e = t.getAttribute(a.PAGE_LIST);
27
- return !n || !e;
28
- }).length;
29
- }
30
- const y = () => {
31
- const { showToaster: r } = p(), s = l();
32
- return { validateUnsubscribeBlockUniqueness: (e) => {
33
- const o = m(e);
34
- return o.length ? (r({
35
- type: c.Error,
36
- message: s(o.length > 1 ? g : o[0].messageKey)
15
+ ], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
16
+ const { showToaster: c } = E(), p = m();
17
+ return { validateUnsubscribeBlockUniqueness: (n) => {
18
+ const o = new DOMParser().parseFromString(n, "text/html"), r = /* @__PURE__ */ new Map();
19
+ o.querySelectorAll(l).forEach((e) => {
20
+ const s = Number(e.getAttribute(a.PAGE_TYPE));
21
+ r.set(s, (r.get(s) ?? 0) + 1);
22
+ });
23
+ const t = T.filter((e) => (r.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
24
+ return t.length ? (c({
25
+ type: i.Error,
26
+ message: p(t.length > 1 ? g : t[0])
37
27
  }), !1) : !0;
38
- }, validateUnsubscribeBlockHasTemplate: (e) => b(e) === 0 ? !0 : (r({
39
- type: c.Warning,
40
- message: s(E)
41
- }), !1) };
28
+ }, validateUnsubscribeBlockHasTemplate: (n) => {
29
+ const o = new DOMParser().parseFromString(n, "text/html");
30
+ return Array.from(o.querySelectorAll(l)).some((t) => {
31
+ const e = t.getAttribute(a.PAGE_TYPE), s = t.getAttribute(a.PAGE_LIST);
32
+ return !e || !s;
33
+ }) ? (c({
34
+ type: i.Warning,
35
+ message: p(b)
36
+ }), !1) : !0;
37
+ } };
42
38
  };
43
39
  export {
44
- E as EMPTY_BLOCK_KEY,
45
- b as countUnsubBlocksWithoutPage,
46
- m as findDuplicateUnsubPageTypes,
47
- y as useUnsubscribeBlockValidator
40
+ P as useUnsubscribeBlockValidator
48
41
  };
@@ -1,27 +1,27 @@
1
- import { useToaster as L } from "../../../../composables/useToaster.js";
2
- import { useTranslations as U } from "../../../../composables/useTranslations.js";
3
- import { getRecommendationFeedSourceMaps as F, strategyEditPath as E, URLS as N, getOperatorOptions as M, PriceAttributes as A } from "../../../../enums/extensions/recommendationBlock.js";
4
- import { ToasterTypeOptions as B } from "../../../../enums/toaster.js";
5
- import { useRecommendationApi as O } from "../../../../services/recommendationApi.js";
6
- import { useConfigStore as R } from "../../../../stores/config.js";
7
- import { defineStore as T } from "pinia";
1
+ import { useToaster as D } from "../../../../composables/useToaster.js";
2
+ import { useTranslations as L } from "../../../../composables/useTranslations.js";
3
+ import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, URLS as E, getOperatorOptions as N, PriceAttributes as M } from "../../../../enums/extensions/recommendationBlock.js";
4
+ import { ToasterTypeOptions as A } from "../../../../enums/toaster.js";
5
+ import { useRecommendationApi as T } from "../../../../services/recommendationApi.js";
6
+ import { useConfigStore as k } from "../../../../stores/config.js";
7
+ import { defineStore as B } from "pinia";
8
8
  import "../constants/selectors.js";
9
- import { DEFAULT_MOBILE_CARDS_IN_ROW as z, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
- import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as V, EXCLUDED_ALGORITHM_IDS as j } from "../constants/defaultConfig.js";
9
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as z } from "../constants/layout.js";
10
+ import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as x, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
11
11
  import { getDefaultProducts as w } from "../templates/utils.js";
12
12
  import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
13
- import { isLegacyStrategyConfig as $ } from "../utils/legacyStrategyMigration.js";
14
- import { getPartnerRecommendationParams as q } from "../utils/partnerCustomizations.js";
15
- import { sanitizeProductIds as K } from "../utils/productIds.js";
16
- import { isFilterValid as H } from "../validation/filterSchema.js";
17
- import { getInvalidFields as J, isConfigValid as G } from "../validation/requiredFields.js";
18
- const m = O();
19
- let S = null, p = null, y = null, I = "", k = null, b = 0;
13
+ import { isLegacyStrategyConfig as j } from "../utils/legacyStrategyMigration.js";
14
+ import { getPartnerRecommendationParams as $ } from "../utils/partnerCustomizations.js";
15
+ import { sanitizeProductIds as q } from "../utils/productIds.js";
16
+ import { isFilterValid as K } from "../validation/filterSchema.js";
17
+ import { getInvalidFields as H, isConfigValid as J } from "../validation/requiredFields.js";
18
+ const m = T();
19
+ let S = null, p = null, y = null, I = "", R = null, b = 0;
20
20
  const g = /* @__PURE__ */ new Map();
21
21
  let l = null;
22
- function D() {
22
+ function _() {
23
23
  return {
24
- cardsInRow: x,
24
+ cardsInRow: z,
25
25
  currencySettings: {
26
26
  name: "USD",
27
27
  value: "USD",
@@ -35,7 +35,7 @@ function D() {
35
35
  productIds: [],
36
36
  id: 1,
37
37
  language: "en_US",
38
- mobileCardsInRow: z,
38
+ mobileCardsInRow: O,
39
39
  mobileLayoutEnabled: !1,
40
40
  orientation: "grid",
41
41
  recommendedProducts: [],
@@ -45,7 +45,7 @@ function D() {
45
45
  // that default is what reached buildCampaignUrl and baked a most-popular feed URL
46
46
  // for a block the user never configured (SD-149916). Legacy blocks still get their real
47
47
  // algorithm from the node-config sync or the save-time seed.
48
- strategy: R().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
48
+ strategy: k().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
49
49
  strategyId: "",
50
50
  nodeConfigVersion: C,
51
51
  textTrimming: !0,
@@ -56,9 +56,9 @@ function D() {
56
56
  priceHideIfSameAsDiscounted: !1
57
57
  };
58
58
  }
59
- function _() {
59
+ function G() {
60
60
  return {
61
- recommendationConfigs: D(),
61
+ recommendationConfigs: _(),
62
62
  recommendationProducts: [],
63
63
  filterStatus: !1,
64
64
  filterSelectionDrawerStatus: !1,
@@ -87,7 +87,7 @@ const Q = () => ({
87
87
  currentRecommendationId: null,
88
88
  strategyPanelOpen: !1,
89
89
  configVersion: 0
90
- }), ft = T("guidoRecommendationExtension", {
90
+ }), ft = B("guidoRecommendationExtension", {
91
91
  state: () => Q(),
92
92
  getters: {
93
93
  // ====================================================================
@@ -98,7 +98,7 @@ const Q = () => ({
98
98
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
99
99
  */
100
100
  recommendationConfigs(t) {
101
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : D();
101
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : _();
102
102
  },
103
103
  /**
104
104
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -119,7 +119,7 @@ const Q = () => ({
119
119
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
120
120
  },
121
121
  isLegacyStrategyBlock() {
122
- return R().isFeatureEnabled("reusableRecommendationStrategy") && $(this.recommendationConfigs);
122
+ return k().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
123
123
  },
124
124
  legacyConversionLoading(t) {
125
125
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
@@ -163,7 +163,7 @@ const Q = () => ({
163
163
  },
164
164
  getActivePredictiveAlgorithms: (t) => {
165
165
  const e = F(), r = [];
166
- return t.activePredictiveAlgorithms.filter((n) => !j.includes(n)).forEach((n) => {
166
+ return t.activePredictiveAlgorithms.filter((n) => !V.includes(n)).forEach((n) => {
167
167
  r.push(...e.filter((s) => s.id === n));
168
168
  }), r.map((n) => ({
169
169
  text: n.name,
@@ -181,7 +181,7 @@ const Q = () => ({
181
181
  getFilterList() {
182
182
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
183
183
  let e;
184
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : A.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
184
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : M.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
185
185
  text: t.displayName,
186
186
  value: e,
187
187
  type: t.attributeType
@@ -203,7 +203,7 @@ const Q = () => ({
203
203
  setCurrentBlock(t) {
204
204
  this.blockStates[t] || (this.blockStates = {
205
205
  ...this.blockStates,
206
- [t]: _()
206
+ [t]: G()
207
207
  }), this.currentRecommendationId = t;
208
208
  },
209
209
  /**
@@ -234,7 +234,7 @@ const Q = () => ({
234
234
  const r = this.blockStates[t];
235
235
  if (r) {
236
236
  const o = structuredClone(r);
237
- o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
237
+ o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && k().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
238
238
  ...this.blockStates,
239
239
  [e]: o
240
240
  };
@@ -275,7 +275,7 @@ const Q = () => ({
275
275
  decimalCount: String(e.currencyDecimalCount),
276
276
  decimalSeparator: r(e.currencyDecimalSeparator, ","),
277
277
  thousandSeparator: r(e.currencyThousandSeparator, ".")
278
- }, s = !this.blockStates[t], i = s ? _() : this.blockStates[t];
278
+ }, s = !this.blockStates[t], i = s ? G() : this.blockStates[t];
279
279
  i.recommendationConfigs = {
280
280
  ...i.recommendationConfigs,
281
281
  strategy: e.strategy,
@@ -314,7 +314,7 @@ const Q = () => ({
314
314
  * Creates a filter with the first available attribute and operator pre-selected.
315
315
  */
316
316
  createDefaultFilter(t, e) {
317
- const [r] = this.getFilterList, [n] = M(r == null ? void 0 : r.type);
317
+ const [r] = this.getFilterList, [n] = N(r == null ? void 0 : r.type);
318
318
  return {
319
319
  type: "standardFilter",
320
320
  attribute: (r == null ? void 0 : r.value) ?? "",
@@ -380,9 +380,9 @@ const Q = () => ({
380
380
  this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !1);
381
381
  },
382
382
  async fetchStrategies() {
383
- for (; k; )
383
+ for (; R; )
384
384
  try {
385
- await k;
385
+ await R;
386
386
  } catch {
387
387
  }
388
388
  if (this.strategiesFetched)
@@ -398,11 +398,11 @@ const Q = () => ({
398
398
  this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
399
399
  }
400
400
  })();
401
- k = e;
401
+ R = e;
402
402
  try {
403
403
  await e;
404
404
  } finally {
405
- k = null;
405
+ R = null;
406
406
  }
407
407
  },
408
408
  /**
@@ -434,9 +434,9 @@ const Q = () => ({
434
434
  _armStrategyPageReturn(t) {
435
435
  const e = window.open(t, "_blank");
436
436
  if (!e)
437
- return L().showToaster({
438
- type: B.Error,
439
- message: U()("discovery-strategy.error-description")
437
+ return D().showToaster({
438
+ type: A.Error,
439
+ message: L()("discovery-strategy.error-description")
440
440
  }), !1;
441
441
  e.opener = null, l == null || l();
442
442
  let r = !1;
@@ -471,14 +471,14 @@ const Q = () => ({
471
471
  * new strategy is offered; the user picks it themselves.
472
472
  */
473
473
  openStrategyCreation() {
474
- return this._armStrategyPageReturn(N.RECOMMENDATION_STRATEGY_CREATE_PATH);
474
+ return this._armStrategyPageReturn(E.RECOMMENDATION_STRATEGY_CREATE_PATH);
475
475
  },
476
476
  /**
477
477
  * Opens the strategy's edit page. Every return refreshes the list so the block reflects the
478
478
  * edited configuration.
479
479
  */
480
480
  openStrategyEdit(t) {
481
- return this._armStrategyPageReturn(E(t));
481
+ return this._armStrategyPageReturn(U(t));
482
482
  },
483
483
  async resolveStrategyUrlTemplate(t, e) {
484
484
  const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
@@ -532,7 +532,7 @@ const Q = () => ({
532
532
  this.patchCurrentBlockConfig({
533
533
  strategyId: "",
534
534
  strategy: "",
535
- size: V.size,
535
+ size: x.size,
536
536
  nodeConfigVersion: C
537
537
  });
538
538
  },
@@ -606,7 +606,7 @@ const Q = () => ({
606
606
  const n = [...e.recommendationConfigs.filters];
607
607
  n[r] = {
608
608
  ...t,
609
- isValid: H(t)
609
+ isValid: K(t)
610
610
  }, e.recommendationConfigs.filters = n;
611
611
  }
612
612
  },
@@ -652,21 +652,14 @@ const Q = () => ({
652
652
  * every block's recommendationConfigs across user edits.
653
653
  */
654
654
  hasInvalidBlock() {
655
- return Object.values(this.blockStates).some((t) => !G(t.recommendationConfigs, this));
656
- },
657
- /**
658
- * Per-instance counterpart to `hasInvalidBlock`: the ids of every block
659
- * that fails required-field validation, one drawer row each (SD-147430).
660
- */
661
- invalidBlockIds() {
662
- return Object.entries(this.blockStates).filter(([, t]) => !G(t.recommendationConfigs, this)).map(([t]) => t);
655
+ return Object.values(this.blockStates).some((t) => !J(t.recommendationConfigs, this));
663
656
  },
664
657
  /**
665
658
  * Which required fields are missing across the design's blocks, so the save
666
659
  * toaster can name the cause instead of always showing the generic message.
667
660
  */
668
661
  invalidBlockFields() {
669
- return Object.values(this.blockStates).flatMap((t) => J(t.recommendationConfigs, this));
662
+ return Object.values(this.blockStates).flatMap((t) => H(t.recommendationConfigs, this));
670
663
  },
671
664
  // ====================================================================
672
665
  // Per-Block Product Fetching
@@ -692,7 +685,7 @@ const Q = () => ({
692
685
  },
693
686
  async _doFetchProducts() {
694
687
  var h;
695
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = R();
688
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = k();
696
689
  if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
697
690
  await this._doFetchStrategyProducts(t);
698
691
  return;
@@ -712,9 +705,9 @@ const Q = () => ({
712
705
  details: !0,
713
706
  campaignId: n.variationId
714
707
  };
715
- r.strategy === "manualMerchandising" ? c.productId = K(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
708
+ r.strategy === "manualMerchandising" ? c.productId = q(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
716
709
  c,
717
- q(n.partnerName, r.strategy)
710
+ $(n.partnerName, r.strategy)
718
711
  );
719
712
  let u;
720
713
  try {