@useinsider/guido 3.19.0-beta.0a1f92f → 3.19.0-beta.11ec5b2

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 (111) hide show
  1. package/README.md +21 -3
  2. package/dist/@types/config/schemas.js +62 -55
  3. package/dist/components/Guido.vue.js +7 -7
  4. package/dist/components/Guido.vue2.js +80 -85
  5. package/dist/components/organisms/AutoSaveController.vue2.js +8 -10
  6. package/dist/components/organisms/base/Toaster.vue2.js +13 -12
  7. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
  8. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
  9. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  10. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  11. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
  12. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  13. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  14. package/dist/components/organisms/header/EditorActions.vue.js +13 -13
  15. package/dist/components/organisms/header/EditorActions.vue2.js +51 -37
  16. package/dist/components/organisms/header/HeaderWrapper.vue.js +6 -6
  17. package/dist/components/organisms/header/HeaderWrapper.vue2.js +17 -9
  18. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  19. package/dist/components/organisms/header/LeftSlot.vue2.js +23 -32
  20. package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
  21. package/dist/components/organisms/header/MiddleSlot.vue2.js +7 -8
  22. package/dist/components/organisms/header/RightSlot.vue.js +8 -9
  23. package/dist/components/organisms/header/RightSlot.vue2.js +18 -13
  24. package/dist/components/organisms/onboarding/OnboardingWrapper.vue.js +12 -12
  25. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +40 -54
  26. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  27. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  28. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
  29. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
  30. package/dist/composables/useActionsApi.js +52 -47
  31. package/dist/composables/useCodeEditorApi.js +23 -9
  32. package/dist/composables/useCustomInterfaceAppearance.js +65 -52
  33. package/dist/composables/useHtmlValidator.js +87 -82
  34. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  35. package/dist/composables/useRecommendation.js +40 -35
  36. package/dist/composables/useStripo.js +43 -39
  37. package/dist/composables/useToaster.js +14 -20
  38. package/dist/composables/useTranslations.js +3 -2
  39. package/dist/composables/useVersionHistoryApi.js +33 -24
  40. package/dist/config/i18n/en/labels.json.js +4 -36
  41. package/dist/config/i18n/en/tooltips.json.js +1 -2
  42. package/dist/enums/extensions/recommendationBlock.js +51 -34
  43. package/dist/extensions/Blocks/Recommendation/block.js +61 -42
  44. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
  45. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +100 -94
  46. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +130 -55
  47. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
  48. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +273 -92
  49. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  50. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
  51. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
  52. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
  53. package/dist/guido.css +1 -1
  54. package/dist/services/recommendationApi.js +46 -37
  55. package/dist/sprite.svg +0 -6
  56. package/dist/src/@types/config/schemas.d.ts +16 -2
  57. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +1 -3
  58. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +3 -1
  59. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +3 -1
  60. package/dist/src/composables/useActionsApi.d.ts +2 -2
  61. package/dist/src/composables/useConfig.d.ts +4 -2
  62. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  63. package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
  64. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  65. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
  66. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  67. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
  70. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
  71. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  72. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
  73. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
  74. package/dist/src/services/recommendationApi.d.ts +2 -1
  75. package/dist/src/stores/config.d.ts +322 -18
  76. package/dist/src/stores/editor.d.ts +0 -109
  77. package/dist/src/stores/onboarding.d.ts +284 -201
  78. package/dist/src/stores/version-history.d.ts +1 -1
  79. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  80. package/dist/src/utils/timeUtil.d.ts +0 -5
  81. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  82. package/dist/static/assets/icons/line-info.svg.js +5 -0
  83. package/dist/static/styles/components/recommendation-strategy.css.js +104 -9
  84. package/dist/static/styles/components/skeleton.css.js +23 -0
  85. package/dist/static/styles/variables.css.js +0 -2
  86. package/dist/stores/config.js +74 -60
  87. package/dist/stores/editor.js +4 -7
  88. package/dist/stores/onboarding.js +30 -42
  89. package/dist/stores/unsubscribe.js +3 -3
  90. package/dist/utils/stripoEditorApi.js +11 -0
  91. package/dist/utils/templatePreparation.js +55 -55
  92. package/dist/utils/timeUtil.js +17 -6
  93. package/package.json +2 -1
  94. package/dist/components/organisms/header/AutoSaveStatus.vue.js +0 -17
  95. package/dist/components/organisms/header/AutoSaveStatus.vue2.js +0 -25
  96. package/dist/components/organisms/header/EditorActionsMenu.vue.js +0 -20
  97. package/dist/components/organisms/header/EditorActionsMenu.vue2.js +0 -98
  98. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue.js +0 -18
  99. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue2.js +0 -37
  100. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue.js +0 -22
  101. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue2.js +0 -48
  102. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue.js +0 -19
  103. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue2.js +0 -90
  104. package/dist/composables/useAccessibilityApi.js +0 -35
  105. package/dist/src/components/organisms/onboarding/EditorTabBarOnboarding.vue.d.ts +0 -2
  106. package/dist/src/composables/useAccessibilityApi.d.ts +0 -15
  107. package/dist/static/styles/components/accessibility.css.js +0 -234
  108. /package/dist/src/components/organisms/{header/AutoSaveStatus.vue.d.ts → extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts} +0 -0
  109. /package/dist/src/components/organisms/header/{EditorActionsMenu.vue.d.ts → AutoSaveToggle.vue.d.ts} +0 -0
  110. /package/dist/src/components/organisms/{header/accessibility/AccessibilityToolbar.vue.d.ts → onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts} +0 -0
  111. /package/dist/src/components/organisms/{header/accessibility/ColorVisionSelect.vue.d.ts → onboarding/RecommendationStrategyOnboarding.vue.d.ts} +0 -0
@@ -1,18 +1,23 @@
1
- import { filterAmpErrors as v } from "../utils/ampErrorFilter.js";
2
- import { useToaster as y } from "./useToaster.js";
3
- const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
4
- const w = setTimeout(
5
- () => m(new Error(`${n} did not report completion within ${l}ms`)),
1
+ import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
2
+ import { getEditorApi as s } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as D } from "./useToaster.js";
4
+ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
5
+ const f = setTimeout(
6
+ () => p(new Error(`${n} did not report completion within ${l}ms`)),
6
7
  l
7
- ), p = (A) => (t) => {
8
- clearTimeout(w), A(t);
9
- };
10
- u(p(T), p(m));
11
- }), I = () => {
12
- const { handleError: n } = y(), l = (t = {}) => s(
8
+ ), c = (t) => (e) => {
9
+ clearTimeout(f), t(e);
10
+ }, d = c(p);
11
+ try {
12
+ A(c(C), d);
13
+ } catch (t) {
14
+ d(t);
15
+ }
16
+ }), P = () => {
17
+ const { handleError: n } = D(), l = (t = {}) => r(
13
18
  "compileEmail",
14
- d,
15
- (e, a) => {
19
+ T,
20
+ (e, i) => {
16
21
  const o = { ...{
17
22
  minimize: !0,
18
23
  utmEntity: {
@@ -32,53 +37,53 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
32
37
  forceAmp: !1,
33
38
  resetDataSavedFlag: !1,
34
39
  disableLineHeightsReplace: !0
35
- }, ...t }, c = {
36
- callback: (r, C, f, S, g) => {
37
- r ? a(r) : e({
38
- html: C,
39
- ampHtml: f,
40
- ampErrors: v(S ?? []),
41
- displayConditions: g
40
+ }, ...t }, u = {
41
+ callback: (m, g, w, S, v) => {
42
+ m ? i(m) : e({
43
+ html: g,
44
+ ampHtml: w,
45
+ ampErrors: y(S ?? []),
46
+ displayConditions: v
42
47
  });
43
48
  },
44
49
  ...o
45
50
  };
46
- window.StripoEditorApi.actionsApi.compileEmail(c);
51
+ s().actionsApi.compileEmail(u);
47
52
  }
48
53
  );
49
54
  return {
50
55
  getCompiledEmail: l,
51
- getTemplateData: () => s(
56
+ getTemplateData: () => r(
52
57
  "getTemplateData",
53
- d,
58
+ T,
54
59
  (t) => {
55
- const e = ({ html: a, css: i, width: o, height: E, utmParams: c, syncModulesIds: r }) => t({
56
- html: a,
57
- css: i,
60
+ const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
61
+ html: i,
62
+ css: a,
58
63
  width: o,
59
64
  height: E,
60
- utmParams: c,
61
- syncModulesIds: r
65
+ utmParams: u,
66
+ syncModulesIds: m
62
67
  });
63
- window.StripoEditorApi.actionsApi.getTemplateData(e);
68
+ s().actionsApi.getTemplateData(e);
64
69
  }
65
70
  ),
66
71
  activateCustomViewStyles: (t = !0) => {
67
- window.StripoEditorApi.actionsApi.activateCustomViewStyles(t);
72
+ s().actionsApi.activateCustomViewStyles(t);
68
73
  },
69
74
  getPreviewData: async (t) => {
70
75
  try {
71
76
  const {
72
77
  html: e,
73
- displayConditions: a,
74
- ampHtml: i = "",
78
+ displayConditions: i,
79
+ ampHtml: a = "",
75
80
  ampErrors: o = []
76
81
  } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
77
82
  return {
78
83
  html: e,
79
- ampHtml: i,
84
+ ampHtml: a,
80
85
  ampErrors: o,
81
- displayConditions: a
86
+ displayConditions: i
82
87
  };
83
88
  } catch (e) {
84
89
  return n(e, "Error loading preview"), {
@@ -90,30 +95,30 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
90
95
  }
91
96
  },
92
97
  updateTimerInClonedTemplate: () => new Promise((t) => {
93
- var e, a;
94
- if (typeof ((a = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : a.updateTimerInClonedTemplate) != "function") {
98
+ var e, i;
99
+ if (typeof ((i = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : i.updateTimerInClonedTemplate) != "function") {
95
100
  t(null);
96
101
  return;
97
102
  }
98
103
  try {
99
- window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
100
- i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
104
+ window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, o) => {
105
+ a ? (n(a, "Failed to update timer in cloned template"), t(null)) : t(o || null);
101
106
  });
102
- } catch (i) {
103
- n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
107
+ } catch (a) {
108
+ n(a, "Failed to call updateTimerInClonedTemplate"), t(null);
104
109
  }
105
110
  }),
106
111
  updateHtmlAndCss: (t, e) => {
107
- const { actionsApi: a } = window.StripoEditorApi;
108
- return s("updateHtmlAndCss", D, (i) => {
109
- a.updateHtmlAndCss(t, e, () => i());
112
+ const { actionsApi: i } = s();
113
+ return r("updateHtmlAndCss", h, (a) => {
114
+ i.updateHtmlAndCss(t, e, () => a());
110
115
  });
111
116
  },
112
- editorSave: () => s(
117
+ editorSave: () => r(
113
118
  "save",
114
- d,
119
+ T,
115
120
  (t) => {
116
- window.StripoEditorApi.actionsApi.save((e) => {
121
+ s().actionsApi.save((e) => {
117
122
  if (e) {
118
123
  n(e, "Failed to save template"), t(!1);
119
124
  return;
@@ -125,5 +130,5 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
125
130
  };
126
131
  };
127
132
  export {
128
- I as useActionsApi
133
+ P as useActionsApi
129
134
  };
@@ -1,11 +1,25 @@
1
- const i = () => ({
2
- openCodeEditor: () => {
3
- window.StripoEditorApi.codeEditorApi.openCodeEditor();
4
- },
5
- closeCodeEditor: () => {
6
- window.StripoEditorApi.codeEditorApi.closeCodeEditor();
7
- }
8
- });
1
+ import { ToasterTypeOptions as d } from "../enums/toaster.js";
2
+ import { findEditorApi as s, EDITOR_NOT_READY_MESSAGE as p } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as E } from "./useToaster.js";
4
+ const T = () => {
5
+ const { showToaster: i } = E(), t = (o) => {
6
+ var r;
7
+ const e = (r = s()) == null ? void 0 : r.codeEditorApi;
8
+ if (!e) {
9
+ i({ type: d.Error, message: p });
10
+ return;
11
+ }
12
+ o(e);
13
+ };
14
+ return {
15
+ openCodeEditor: () => {
16
+ t((o) => o.openCodeEditor());
17
+ },
18
+ closeCodeEditor: () => {
19
+ t((o) => o.closeCodeEditor());
20
+ }
21
+ };
22
+ };
9
23
  export {
10
- i as useCodeEditorApi
24
+ T as useCodeEditorApi
11
25
  };
@@ -1,68 +1,81 @@
1
- import S from "../static/assets/icons/line-change.svg.js";
2
- import i from "../static/assets/icons/line-delete.svg.js";
3
- import n from "../static/assets/icons/line-plus.svg.js";
4
- import p from "../static/styles/base.css.js";
5
- import s from "../static/styles/components/accessibility.css.js";
1
+ import p from "../static/assets/icons/filled-arrow-rising.svg.js";
2
+ import s from "../static/assets/icons/line-change.svg.js";
3
+ import a from "../static/assets/icons/line-delete.svg.js";
4
+ import f from "../static/assets/icons/line-info.svg.js";
5
+ import c from "../static/assets/icons/line-plus.svg.js";
6
+ import l from "../static/styles/base.css.js";
6
7
  import C from "../static/styles/components/alert-message.css.js";
7
- import c from "../static/styles/components/amp-block.css.js";
8
- import f from "../static/styles/components/base-input.css.js";
9
- import a from "../static/styles/components/button-group.css.js";
10
- import u from "../static/styles/components/button.css.js";
11
- import l from "../static/styles/components/combobox.css.js";
12
- import d from "../static/styles/components/counter.css.js";
13
- import h from "../static/styles/components/dropdown-menu.css.js";
14
- import g from "../static/styles/components/loader.css.js";
15
- import y from "../static/styles/components/narrow-panel.css.js";
16
- import I from "../static/styles/components/popup.css.js";
17
- import b from "../static/styles/components/recommendation-strategy.css.js";
18
- import w from "../static/styles/components/switcher.css.js";
19
- import B from "../static/styles/components/tabs.css.js";
20
- import $ from "../static/styles/components/tools.css.js";
21
- import A from "../static/styles/components/version-history.css.js";
22
- import P from "../static/styles/components/wide-panel.css.js";
23
- import x from "../static/styles/variables.css.js";
24
- function r(t, o) {
25
- return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
8
+ import d from "../static/styles/components/amp-block.css.js";
9
+ import u from "../static/styles/components/base-input.css.js";
10
+ import h from "../static/styles/components/button-group.css.js";
11
+ import I from "../static/styles/components/button.css.js";
12
+ import g from "../static/styles/components/combobox.css.js";
13
+ import w from "../static/styles/components/counter.css.js";
14
+ import y from "../static/styles/components/dropdown-menu.css.js";
15
+ import A from "../static/styles/components/loader.css.js";
16
+ import $ from "../static/styles/components/narrow-panel.css.js";
17
+ import b from "../static/styles/components/popup.css.js";
18
+ import B from "../static/styles/components/recommendation-strategy.css.js";
19
+ import D from "../static/styles/components/skeleton.css.js";
20
+ import R from "../static/styles/components/switcher.css.js";
21
+ import P from "../static/styles/components/tabs.css.js";
22
+ import T from "../static/styles/components/tools.css.js";
23
+ import x from "../static/styles/components/version-history.css.js";
24
+ import M from "../static/styles/components/wide-panel.css.js";
25
+ import O from "../static/styles/variables.css.js";
26
+ function o(i, r) {
27
+ return `--guido-icon-${i}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
26
28
  }
27
- const R = `:host {
28
- ${r("line-change", S)}
29
- ${r("line-delete", i)}
30
- ${r("line-plus", n)}
31
- }`, V = [
32
- x,
29
+ const V = `:host {
30
+ ${o("line-change", s)}
31
+ ${o("line-delete", a)}
32
+ ${o("filled-arrow-rising", p)}
33
+ ${o("line-info", f)}
34
+ ${o("line-plus", c)}
35
+ }`, W = [
36
+ O,
33
37
  // Must be on top
34
- R,
35
- p,
38
+ V,
39
+ l,
36
40
  // Must be on top
37
41
  C,
38
- c,
39
- f,
40
- a,
41
- u,
42
- l,
43
42
  d,
43
+ u,
44
44
  h,
45
- g,
46
- y,
47
45
  I,
46
+ g,
48
47
  w,
49
- B,
50
- $,
48
+ y,
51
49
  A,
52
- P,
50
+ $,
53
51
  b,
54
- s
52
+ D,
53
+ R,
54
+ P,
55
+ T,
56
+ x,
57
+ M,
58
+ B
59
+ // Last: overrides button.css / wide-panel.css defaults
55
60
  ].join(`
56
61
 
57
- `), _ = () => ({ importCss: () => {
58
- const o = new CSSStyleSheet();
59
- o.replaceSync(V);
60
- const e = document.querySelector("ui-editor");
61
- if (!e)
62
- return;
63
- const m = e.shadowRoot;
64
- m && (m.adoptedStyleSheets = [o]);
62
+ `), _ = 3e4;
63
+ let e = null;
64
+ function k() {
65
+ return e || (e = new CSSStyleSheet(), e.replaceSync(W)), e;
66
+ }
67
+ const po = () => ({ importCss: () => {
68
+ const r = k(), S = Date.now() + _, n = () => {
69
+ var m;
70
+ const t = (m = document.querySelector("ui-editor")) == null ? void 0 : m.shadowRoot;
71
+ if (t) {
72
+ t.adoptedStyleSheets.includes(r) || (t.adoptedStyleSheets = [...t.adoptedStyleSheets, r]);
73
+ return;
74
+ }
75
+ Date.now() < S && requestAnimationFrame(n);
76
+ };
77
+ n();
65
78
  } });
66
79
  export {
67
- _ as useCustomInterfaceAppearance
80
+ po as useCustomInterfaceAppearance
68
81
  };
@@ -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 { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as $, DYNAMIC_CONTENT_TAG_REGEX as K, ALLOWED_DYNAMIC_SYSTEM_TOKENS as Y, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
4
+ import { DISPLAY_CONDITIONS_REGEX as G, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as K, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as X, DYNAMIC_CONTENT_TAG_REGEX as Y, ALLOWED_DYNAMIC_SYSTEM_TOKENS as $, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
5
5
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
6
6
  import { BLOCK_ROOT_SELECTOR as j } from "../extensions/Blocks/Checkbox/constants/selectors.js";
7
7
  import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
@@ -9,58 +9,58 @@ import { BLOCK_ROOT_SELECTOR as z } from "../extensions/Blocks/RadioButton/const
9
9
  import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as Z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
10
10
  import { useRecommendationExtensionStore as J } from "../extensions/Blocks/Recommendation/store/recommendation.js";
11
11
  import { filterToProductAttrValue as Q } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
12
- import { RecommendationRequiredFieldsKey as ee } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
13
- import { useRecommendationStore as te } from "../stores/recommendation.js";
14
- import { base64EncodeWithSpecialChars as ne } from "../utils/base64.js";
15
- import { computed as se } from "vue";
16
- import { useHttp as re } from "./useHttp.js";
17
- import { useToaster as oe } from "./useToaster.js";
18
- import { useTranslations as ie } from "./useTranslations.js";
19
- const ae = /recommendation-id="(\d+)"/g;
20
- function ce(s) {
21
- return [...s.matchAll(ae)].map((l) => l[1]);
12
+ import { STRATEGY_FIELD_KEY as ee, RecommendationAssignStrategyKey as te, RecommendationRequiredFieldsKey as ne } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
13
+ import { useRecommendationStore as se } from "../stores/recommendation.js";
14
+ import { base64EncodeWithSpecialChars as re } from "../utils/base64.js";
15
+ import { computed as oe } from "vue";
16
+ import { useHttp as ie } from "./useHttp.js";
17
+ import { useToaster as ae } from "./useToaster.js";
18
+ import { useTranslations as ce } from "./useTranslations.js";
19
+ const le = /recommendation-id="(\d+)"/g;
20
+ function me(s) {
21
+ return [...s.matchAll(le)].map((m) => m[1]);
22
22
  }
23
- function me(s, l) {
24
- return l.some((f) => s.startsWith(`${f}_`));
23
+ function ue(s, m) {
24
+ return m.some((f) => s.startsWith(`${f}_`));
25
25
  }
26
- const le = /^(\d+)_\d+_(.+)$/;
27
- function ue(s) {
28
- const l = s.match(le);
29
- return l ? { recoId: l[1], attribute: l[2] } : null;
26
+ const de = /^(\d+)_\d+_(.+)$/;
27
+ function fe(s) {
28
+ const m = s.match(de);
29
+ return m ? { recoId: m[1], attribute: m[2] } : null;
30
30
  }
31
- function de(s) {
32
- const l = new Set(Z);
31
+ function ge(s) {
32
+ const m = new Set(Z);
33
33
  return Object.values(s).forEach((f) => {
34
- l.add(Q(f).toLowerCase());
35
- }), l;
34
+ m.add(Q(f).toLowerCase());
35
+ }), m;
36
36
  }
37
- function fe(s, l, f, o, d) {
37
+ function pe(s, m, f, o, d) {
38
38
  const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
39
39
  if (!u)
40
40
  return [];
41
- const g = new Set(l.map((C) => C.toLowerCase())), E = [];
42
- return u.forEach((C) => {
43
- const p = C.slice(2, -2).trim().toLowerCase();
44
- if (p !== "" && g.has(p))
41
+ const p = new Set(m.map((y) => y.toLowerCase())), E = [];
42
+ return u.forEach((y) => {
43
+ const g = y.slice(2, -2).trim().toLowerCase();
44
+ if (g !== "" && p.has(g))
45
45
  return;
46
- const h = ue(p);
47
- if (h && o.has(h.recoId)) {
48
- if (!d || d.has(h.attribute))
46
+ const C = fe(g);
47
+ if (C && o.has(C.recoId)) {
48
+ if (!d || d.has(C.attribute))
49
49
  return;
50
- E.push(p);
50
+ E.push(g);
51
51
  return;
52
52
  }
53
- me(p, f) || p.includes(".") || E.push(p);
53
+ ue(g, f) || g.includes(".") || E.push(g);
54
54
  }), E;
55
55
  }
56
- function pe(s) {
57
- return (s.replace($, "$1").match(K) ?? []).filter((o) => {
58
- const d = o.slice(2, -2), u = d.indexOf("|"), g = (u === -1 ? d : d.slice(0, u)).trim();
59
- return Y.includes(g) ? !1 : U.test(g) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
56
+ function Ee(s) {
57
+ return (s.replace(X, "$1").match(Y) ?? []).filter((o) => {
58
+ const d = o.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
59
+ return $.includes(p) ? !1 : U.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
60
60
  });
61
61
  }
62
- const De = () => {
63
- const { showToaster: s } = oe(), { post: l } = re(), { config: f } = V(), o = ie(), d = te(), u = J(), g = se(
62
+ const ke = () => {
63
+ const { showToaster: s } = ae(), { post: m } = ie(), { config: f } = V(), o = ce(), d = se(), u = J(), p = oe(
64
64
  () => {
65
65
  var e, t;
66
66
  return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
@@ -73,39 +73,39 @@ const De = () => {
73
73
  } catch {
74
74
  return null;
75
75
  }
76
- return de(u.filterList);
77
- }, C = async (e) => {
78
- const n = await l(
76
+ return ge(u.filterList);
77
+ }, y = async (e) => {
78
+ const n = await m(
79
79
  "/newsletter/template-library/check-template-html-body",
80
- { html: ne(e) }
80
+ { html: re(e) }
81
81
  ), { status: r, message: a } = n.data;
82
82
  return r || s({
83
83
  type: c.Error,
84
84
  message: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
85
- }), o(P), a === o(X) && s({
85
+ }), o(K), a === o(P) && s({
86
86
  type: c.Error,
87
87
  message: o("newsletter.already-in-progress")
88
88
  }), r;
89
- }, p = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), h = (e) => ["if", "endif"].includes(e.toLowerCase()), T = (e, t) => {
89
+ }, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), C = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, t) => {
90
90
  const n = e.match(/({%(.*?)%})/g);
91
91
  let r = !0;
92
- return n !== null && !g.value && n.forEach((a) => {
92
+ return n !== null && !p.value && n.forEach((a) => {
93
93
  const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
94
94
  if (i && i.length > 0) {
95
- const [m] = i;
96
- p(m) && !t.includes(m) && (s({
95
+ const [l] = i;
96
+ g(l) && !t.includes(l) && (s({
97
97
  type: c.Warning,
98
98
  message: o("custom-fields.invalid-custom-fields")
99
99
  }), r = !1);
100
100
  }
101
101
  }), r;
102
102
  }, R = async (e, t, n) => {
103
- const r = n ? await C(e) : !0;
104
- return T(e, t) && r;
105
- }, b = (e) => e.length > 0 ? !0 : (s({
103
+ const r = n ? await y(e) : !0;
104
+ return I(e, t) && r;
105
+ }, A = (e) => e.length > 0 ? !0 : (s({
106
106
  type: c.Warning,
107
107
  message: o("newsletter.html-content-is-empty")
108
- }), !1), A = (e) => {
108
+ }), !1), _ = (e) => {
109
109
  const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
110
110
  return t > n && s({
111
111
  type: c.Warning,
@@ -114,26 +114,26 @@ const De = () => {
114
114
  type: c.Warning,
115
115
  message: o("custom-fields.missing-opening-braces")
116
116
  }), t === n;
117
- }, _ = (e) => {
118
- const t = pe(e).length === 0;
117
+ }, b = (e) => {
118
+ const t = Ee(e).length === 0;
119
119
  return t || s({
120
120
  type: c.Warning,
121
121
  message: o("custom-fields.invalid-custom-fields")
122
122
  }), t;
123
123
  }, O = (e, t, n, r) => {
124
- if (g.value)
124
+ if (p.value)
125
125
  return !0;
126
- const a = fe(
126
+ const a = pe(
127
127
  e,
128
128
  t,
129
- ce(e),
129
+ me(e),
130
130
  n,
131
131
  r
132
132
  );
133
133
  if (a.length > 0) {
134
134
  const i = `
135
135
  <ul>
136
- ${a.map((m) => `<li>${m}</li>`).join("")}
136
+ ${a.map((l) => `<li>${l}</li>`).join("")}
137
137
  </ul>
138
138
  `;
139
139
  return s({
@@ -146,22 +146,22 @@ const De = () => {
146
146
  const t = e.match(/{%(.*?)%}/g), n = [];
147
147
  let r = !0;
148
148
  if (t && t.forEach((a) => {
149
- const i = a.match(G), m = a.match(H), v = (i == null ? void 0 : i.join("")) || "";
150
- (!i || a !== v) && !m && (s({
149
+ const i = a.match(G), l = a.match(H), v = (i == null ? void 0 : i.join("")) || "";
150
+ (!i || a !== v) && !l && (s({
151
151
  type: c.Error,
152
152
  message: o("newsletter.display-conditions-invalid-syntax")
153
- }), r = !1), i && i.forEach((y) => {
154
- y.trim() === "=" && (s({
153
+ }), r = !1), i && i.forEach((h) => {
154
+ h.trim() === "=" && (s({
155
155
  type: c.Error,
156
156
  message: o("custom-conditions.wrong-equality-operators")
157
157
  }), r = !1);
158
- const I = y.match(/^[a-zA-Z]*$/g);
159
- I && I.forEach((S) => {
160
- h(S) && n.push(S);
158
+ const S = h.match(/^[a-zA-Z]*$/g);
159
+ S && S.forEach((T) => {
160
+ C(T) && n.push(T);
161
161
  });
162
162
  });
163
163
  }), n.length) {
164
- 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");
165
165
  a.length !== i.length && (s({
166
166
  type: c.Error,
167
167
  message: o("custom-conditions.missing-if-endif-tag")
@@ -177,23 +177,28 @@ const De = () => {
177
177
  }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
178
178
  type: c.Warning,
179
179
  message: o("custom-conditions.no-braces-inside-if-tag")
180
- }), !1) : !0, B = () => u.hasInvalidBlock() ? (s({
181
- type: c.Error,
182
- message: o(ee)
183
- }), !1) : !0, x = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
180
+ }), !1) : !0, B = () => {
181
+ if (!u.hasInvalidBlock())
182
+ return !0;
183
+ const e = u.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === ee);
184
+ return s({
185
+ type: t ? c.Warning : c.Error,
186
+ message: o(t ? te : ne)
187
+ }), !1;
188
+ }, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
184
189
  type: c.Error,
185
190
  message: o("newsletter.fill-all-necessary-fields")
186
- }), !1) : !0, D = (e) => {
191
+ }), !1) : !0, x = (e) => {
187
192
  const t = /src="[^"]*\.(svg|pst)"/gm;
188
193
  return e.match(t) === null ? !0 : (s({
189
194
  type: c.Error,
190
195
  message: o("newsletter.invalid-image-type")
191
196
  }), !1);
192
- }, F = (e) => {
197
+ }, D = (e) => {
193
198
  const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(j);
194
199
  return Array.from(r).find((i) => {
195
- var m;
196
- return !((m = i.id) != null && m.trim());
200
+ var l;
201
+ return !((l = i.id) != null && l.trim());
197
202
  }) ? (s({
198
203
  type: c.Error,
199
204
  message: o("unsubscribe-templates.select-checkbox-groups")
@@ -201,26 +206,26 @@ const De = () => {
201
206
  }, k = (e) => {
202
207
  const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(z);
203
208
  return Array.from(r).find((i) => {
204
- var m;
205
- return !((m = i.id) != null && m.trim());
209
+ var l;
210
+ return !((l = i.id) != null && l.trim());
206
211
  }) ? (s({
207
212
  type: c.Error,
208
213
  message: o("unsubscribe-templates.select-radio-button-groups")
209
214
  }), !1) : !0;
210
215
  };
211
216
  return { validateHtml: async (e, t, n = !1) => {
212
- var v, y;
217
+ var v, h;
213
218
  const r = [
214
- ...t.map((I) => I.value),
219
+ ...t.map((S) => S.value),
215
220
  ...q,
216
- ...((y = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : y.customFieldAttributes) ?? []
221
+ ...((h = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : h.customFieldAttributes) ?? []
217
222
  ], a = M(e), i = await E(a);
218
- return await R(e, r, n) && b(e) && A(e) && _(e) && O(e, r, a, i) && w(e) && L(e) && N(e) && B() && x() && D(e) && F(e) && k(e);
223
+ return await R(e, r, n) && A(e) && _(e) && b(e) && O(e, r, a, i) && w(e) && L(e) && N(e) && B() && F() && x(e) && D(e) && k(e);
219
224
  } };
220
225
  };
221
226
  export {
222
- de as buildPartnerAttributeNameSet,
223
- fe as findInvalidCustomFields,
224
- ue as parseRecommendationVariable,
225
- De as useHtmlValidator
227
+ ge as buildPartnerAttributeNameSet,
228
+ pe as findInvalidCustomFields,
229
+ fe as parseRecommendationVariable,
230
+ ke as useHtmlValidator
226
231
  };