@useinsider/guido 3.15.0 → 3.16.0-beta.0faee0c

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