@useinsider/guido 3.19.0-beta.8776c42 → 3.19.0-beta.892c3ca

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 (51) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +33 -31
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +87 -90
  5. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  6. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  7. package/dist/components/organisms/header/EditorActions.vue2.js +90 -55
  8. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  9. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  10. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  11. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +49 -0
  12. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  13. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  14. package/dist/composables/useCortexBlueprintBridge.js +54 -122
  15. package/dist/composables/useEmailTemplateApplier.js +50 -106
  16. package/dist/composables/useHtmlCompiler.js +37 -26
  17. package/dist/composables/useHtmlValidator.js +2 -0
  18. package/dist/composables/useSave.js +90 -45
  19. package/dist/composables/useSaveValidation.js +282 -0
  20. package/dist/composables/useSaveValidationRollout.js +9 -0
  21. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  22. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  23. package/dist/enums/save-validation.js +4 -0
  24. package/dist/guido.css +1 -1
  25. package/dist/src/@types/config/schemas.d.ts +4 -0
  26. package/dist/src/@types/save-validation.d.ts +19 -0
  27. package/dist/src/components/Guido.vue.d.ts +17 -1
  28. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  29. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  30. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  31. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  32. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  33. package/dist/src/composables/useConfig.d.ts +2 -0
  34. package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -2
  35. package/dist/src/composables/useEmailTemplateApplier.d.ts +5 -18
  36. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  37. package/dist/src/composables/useSave.d.ts +6 -1
  38. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  39. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  40. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  41. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  42. package/dist/src/enums/save-validation.d.ts +27 -0
  43. package/dist/src/stores/config.d.ts +32 -0
  44. package/dist/src/stores/guido-email-editor.d.ts +10 -20
  45. package/dist/src/stores/save-validation.d.ts +22 -0
  46. package/dist/src/utils/templatePreparation.d.ts +30 -0
  47. package/dist/stores/config.js +84 -67
  48. package/dist/stores/guido-email-editor.js +1 -3
  49. package/dist/stores/save-validation.js +30 -0
  50. package/dist/utils/templatePreparation.js +39 -36
  51. package/package.json +1 -1
@@ -1,77 +1,112 @@
1
- import { defineComponent as q, ref as n, computed as x } from "vue";
2
- import { useActionsApi as b } from "../../../composables/useActionsApi.js";
3
- import { useConfig as k } from "../../../composables/useConfig.js";
4
- import { useExport as B } from "../../../composables/useExport.js";
5
- import { useTestEmailClick as D } from "../../../composables/useGuidoActions.js";
6
- import { useHtmlCompiler as L } from "../../../composables/useHtmlCompiler.js";
7
- import { useSave as R } from "../../../composables/useSave.js";
8
- import { useToaster as z } from "../../../composables/useToaster.js";
9
- import { useTranslations as I } from "../../../composables/useTranslations.js";
10
- import { useVersionHistoryApi as P } from "../../../composables/useVersionHistoryApi.js";
11
- import { useLiquidValidator as j } from "../../../composables/validators/useLiquidValidator.js";
12
- import { useEditorStore as G } from "../../../stores/editor.js";
13
- import { useTemplateStore as J } from "../../../stores/template.js";
14
- import { getTooltipOptions as K } from "../../../utils/tooltipUtils.js";
15
- import { InButtonV2 as N } from "@useinsider/design-system-vue";
16
- import { storeToRefs as Q } from "pinia";
17
- import U from "./MigrationConfirmModal.vue.js";
18
- const ft = /* @__PURE__ */ q({
1
+ import { defineComponent as I, computed as c, ref as u } from "vue";
2
+ import { useActionsApi as P } from "../../../composables/useActionsApi.js";
3
+ import { useConfig as W } from "../../../composables/useConfig.js";
4
+ import { useExport as j } from "../../../composables/useExport.js";
5
+ import { useTestEmailClick as G } from "../../../composables/useGuidoActions.js";
6
+ import { useHtmlCompiler as J } from "../../../composables/useHtmlCompiler.js";
7
+ import { useSave as K } from "../../../composables/useSave.js";
8
+ import { useSaveValidation as N } from "../../../composables/useSaveValidation.js";
9
+ import { useSaveValidationRollout as Q } from "../../../composables/useSaveValidationRollout.js";
10
+ import { useToaster as U } from "../../../composables/useToaster.js";
11
+ import { useTranslations as X } from "../../../composables/useTranslations.js";
12
+ import { useVersionHistoryApi as Y } from "../../../composables/useVersionHistoryApi.js";
13
+ import { useLiquidValidator as Z } from "../../../composables/validators/useLiquidValidator.js";
14
+ import { ToasterTypeOptions as $ } from "../../../enums/toaster.js";
15
+ import { useConfigStore as tt } from "../../../stores/config.js";
16
+ import { useEditorStore as ot } from "../../../stores/editor.js";
17
+ import { useSaveValidationStore as et } from "../../../stores/save-validation.js";
18
+ import { useTemplateStore as rt } from "../../../stores/template.js";
19
+ import { getTooltipOptions as it } from "../../../utils/tooltipUtils.js";
20
+ import { InButtonV2 as st } from "@useinsider/design-system-vue";
21
+ import { storeToRefs as at } from "pinia";
22
+ import nt from "./MigrationConfirmModal.vue.js";
23
+ const bt = /* @__PURE__ */ I({
19
24
  __name: "EditorActions",
20
- setup(W, { expose: w }) {
21
- const { config: l, isFeatureEnabled: m } = k(), { exportHtml: c } = B(), { save: p } = R(), { openVersionHistory: u, closeVersionHistory: f } = P(), { getCompiledEmail: d } = b(), { compileHtml: v } = L(), { validateLiquidSyntax: y } = j(), { handleError: r } = z(), e = G(), g = J(), { hasMigrations: S } = Q(g), s = I(), i = n(!1), a = n(!1), H = n(), h = D(), _ = () => {
22
- if (e.isVersionHistoryOpen) {
23
- f();
25
+ setup(lt, { expose: k }) {
26
+ const { config: p, isFeatureEnabled: f } = W(), { exportHtml: d } = j(), { save: v } = K(), { validateCurrentTemplate: y } = N(), { isEnabled: i } = Q(), { showToaster: S, handleError: s } = U(), { openVersionHistory: g, closeVersionHistory: h } = Y(), { getCompiledEmail: T } = P(), { compileHtml: w } = J(), { validateLiquidSyntax: E } = Z(), V = tt(), o = ot(), H = et(), x = rt(), { hasMigrations: C } = at(x), r = X(), F = c(() => i.value && V.allowSaveWithErrors ? r("email-editor.save-and-continue") : "Save"), a = u(!1), n = u(!1), _ = u(), l = G(), q = () => {
27
+ if (o.isVersionHistoryOpen) {
28
+ h();
24
29
  return;
25
30
  }
26
- u();
27
- }, C = async () => {
28
- i.value = !0, await c(), i.value = !1;
29
- }, A = () => {
30
- e.isSaveAsTemplateDrawerOpen = !0;
31
- }, M = x(() => e.isVersionHistoryOpen ? s("newsletter.close-version-history") : s("newsletter.version-history")), O = x(
31
+ g();
32
+ }, B = async () => {
33
+ a.value = !0, await d(), a.value = !1;
34
+ }, L = () => {
35
+ o.isSaveAsTemplateDrawerOpen = !0;
36
+ }, R = c(() => o.isVersionHistoryOpen ? r("newsletter.close-version-history") : r("newsletter.version-history")), D = c(
32
37
  () => {
33
- var t, o;
34
- return ((o = (t = l.value) == null ? void 0 : t.features) == null ? void 0 : o.versionHistory) && !e.isPreviewModeOpen;
38
+ var t, e;
39
+ return ((e = (t = p.value) == null ? void 0 : t.features) == null ? void 0 : e.versionHistory) && !o.isPreviewModeOpen;
35
40
  }
36
- ), V = async (t) => {
37
- a.value = !0, t || (e.loadingStatus = !0);
38
- let o;
41
+ ), A = async (t) => {
42
+ n.value = !0, t || (o.loadingStatus = !0);
43
+ let e;
39
44
  try {
40
- o = await p(t);
41
- } catch (T) {
42
- r(T, "Failed to save template");
45
+ e = await v(t);
46
+ } catch (b) {
47
+ s(b, "Failed to save template");
43
48
  } finally {
44
- a.value = !1, !t && !o && (e.loadingStatus = !1);
49
+ n.value = !1, !t && !e && (o.loadingStatus = !1);
45
50
  }
46
- return o;
47
- }, E = (t) => {
48
- var o;
49
- if (!t && S.value) {
50
- (o = H.value) == null || o.open();
51
+ return e;
52
+ }, O = (t) => {
53
+ var e;
54
+ if (!t && C.value) {
55
+ (e = _.value) == null || e.open();
51
56
  return;
52
57
  }
53
- return V(t);
54
- }, F = async () => {
55
- if (m("liquidSyntax")) {
56
- e.loadingStatus = !0;
58
+ return A(t);
59
+ }, m = async () => {
60
+ o.loadingStatus = !0;
61
+ try {
62
+ return await y();
63
+ } catch (t) {
64
+ return console.warn("Test-path validation failed; sending without the drawer.", t), [];
65
+ } finally {
66
+ o.loadingStatus = !1;
67
+ }
68
+ }, M = async () => {
69
+ const t = await m();
70
+ t.length && H.open(t, "test");
71
+ }, z = async () => {
72
+ if (i.value) {
73
+ if ((await m()).length) {
74
+ S({
75
+ type: $.Error,
76
+ message: r("email-editor.validation-errors-found"),
77
+ actionButton: {
78
+ text: r("email-editor.check-errors"),
79
+ onClick: () => {
80
+ M();
81
+ }
82
+ },
83
+ autoHide: !1
84
+ });
85
+ return;
86
+ }
87
+ l();
88
+ return;
89
+ }
90
+ if (f("liquidSyntax")) {
91
+ o.loadingStatus = !0;
57
92
  try {
58
- const { html: t } = await d({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: o } = v(t);
59
- if (!await y(o))
93
+ const { html: t } = await T({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: e } = w(t);
94
+ if (!await E(e))
60
95
  return;
61
96
  } catch (t) {
62
- r(t, "Failed to prepare test email");
97
+ s(t, "Failed to prepare test email");
63
98
  return;
64
99
  } finally {
65
- e.loadingStatus = !1;
100
+ o.loadingStatus = !1;
66
101
  }
67
102
  }
68
- h();
103
+ l();
69
104
  };
70
- return w({
71
- handleSave: E
72
- }), { __sfc: !0, config: l, isFeatureEnabled: m, exportHtml: c, save: p, openVersionHistory: u, closeVersionHistory: f, getCompiledEmail: d, compileHtml: v, validateLiquidSyntax: y, handleError: r, editorStore: e, templateStore: g, hasMigrations: S, trans: s, isExporting: i, isSaving: a, migrationModalRef: H, testEmailClick: h, handleVersionHistory: _, handleExport: C, handleSaveAs: A, versionHistoryTooltipText: M, isVersionHistoryButtonVisible: O, executeSave: V, handleSave: E, handleTestEmail: F, getTooltipOptions: K, InButtonV2: N, MigrationConfirmModal: U };
105
+ return k({
106
+ handleSave: O
107
+ }), { __sfc: !0, config: p, isFeatureEnabled: f, exportHtml: d, save: v, validateCurrentTemplate: y, isEnabled: i, showToaster: S, handleError: s, openVersionHistory: g, closeVersionHistory: h, getCompiledEmail: T, compileHtml: w, validateLiquidSyntax: E, configStore: V, editorStore: o, saveValidationStore: H, templateStore: x, hasMigrations: C, trans: r, saveLabel: F, isExporting: a, isSaving: n, migrationModalRef: _, testEmailClick: l, handleVersionHistory: q, handleExport: B, handleSaveAs: L, versionHistoryTooltipText: R, isVersionHistoryButtonVisible: D, executeSave: A, handleSave: O, collectTestErrors: m, openTestErrors: M, handleTestEmail: z, getTooltipOptions: it, InButtonV2: st, MigrationConfirmModal: nt };
73
108
  }
74
109
  });
75
110
  export {
76
- ft as default
111
+ bt as default
77
112
  };
@@ -1,16 +1,16 @@
1
1
  import o from "./LeftSlot.vue2.js";
2
2
  /* empty css */
3
- import a from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var n = function() {
3
+ import n from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var a = function() {
5
5
  var e = this, s = e._self._c, t = e._self._setupProxy;
6
6
  return s("div", { staticClass: "d-f a-i-c" }, [s(t.InButtonV2, { attrs: { id: "guido__back-button", "left-icon": "line-arrow-left", styling: "ghost", type: "secondary", "disabled-status": t.isBackButtonDisabled, "label-text": t.backButtonLabel, "skeleton-sizing": { width: 150, height: 26 }, "skeleton-status": t.editorStore.loadingStatus }, on: { click: t.handleBackClick } })], 1);
7
- }, i = [], r = /* @__PURE__ */ a(
7
+ }, i = [], r = /* @__PURE__ */ n(
8
8
  o,
9
- n,
9
+ a,
10
10
  i,
11
11
  !1,
12
12
  null,
13
- "73199fa4"
13
+ "b8f24f34"
14
14
  );
15
15
  const f = r.exports;
16
16
  export {
@@ -1,19 +1,19 @@
1
- import { defineComponent as l, computed as p, ref as d } from "vue";
1
+ import { defineComponent as m, computed as p, ref as d } from "vue";
2
2
  import { useConfig as k } from "../../../composables/useConfig.js";
3
3
  import { useBack as B } from "../../../composables/useGuidoActions.js";
4
4
  import { usePreviewMode as b } from "../../../composables/usePreviewMode.js";
5
5
  import { useTranslations as v } from "../../../composables/useTranslations.js";
6
6
  import { useVersionHistoryApi as _ } from "../../../composables/useVersionHistoryApi.js";
7
- import { useEditorStore as V } from "../../../stores/editor.js";
7
+ import { useEditorStore as y } from "../../../stores/editor.js";
8
8
  import { InButtonV2 as w } from "@useinsider/design-system-vue";
9
- import { useDebounceFn as y } from "../../../node_modules/@vueuse/shared/index.js";
10
- const D = /* @__PURE__ */ l({
9
+ import { useDebounceFn as V } from "../../../node_modules/@vueuse/shared/index.js";
10
+ const D = /* @__PURE__ */ m({
11
11
  __name: "LeftSlot",
12
12
  setup(C) {
13
- const e = V(), i = B(), { closeVersionHistory: n } = _(), { closePreviewMode: s } = b(), o = v(), { config: t } = k(), f = p(() => {
14
- var u, m;
15
- return e.isVersionHistoryOpen || e.isPreviewModeOpen ? o("email-editor.back-to-editor") : (m = (u = t.value) == null ? void 0 : u.ui) != null && m.backButtonLabel ? t.value.ui.backButtonLabel : o("email-editor.back-to-design");
16
- }), r = d(!1), c = () => {
13
+ const e = y(), i = B(), { closeVersionHistory: n } = _(), { closePreviewMode: s } = b(), o = v(), { config: t } = k(), l = p(() => {
14
+ var u, f;
15
+ return e.isVersionHistoryOpen || e.isPreviewModeOpen ? o("email-editor.back-to-editor") : (f = (u = t.value) == null ? void 0 : u.ui) != null && f.backButtonLabel ? t.value.ui.backButtonLabel : o("email-editor.back-to-design");
16
+ }), r = d(!1), a = () => {
17
17
  if (e.isVersionHistoryOpen) {
18
18
  n();
19
19
  return;
@@ -23,11 +23,15 @@ const D = /* @__PURE__ */ l({
23
23
  return;
24
24
  }
25
25
  i();
26
- }, a = y(() => {
27
- c(), r.value = !1;
26
+ }, c = V(async () => {
27
+ try {
28
+ await a();
29
+ } finally {
30
+ r.value = !1;
31
+ }
28
32
  }, 500);
29
- return { __sfc: !0, editorStore: e, handleBack: i, closeVersionHistory: n, closePreviewMode: s, trans: o, config: t, backButtonLabel: f, isBackButtonDisabled: r, executeBackAction: c, debouncedBackAction: a, handleBackClick: () => {
30
- r.value = !0, a();
33
+ return { __sfc: !0, editorStore: e, handleBack: i, closeVersionHistory: n, closePreviewMode: s, trans: o, config: t, backButtonLabel: l, isBackButtonDisabled: r, executeBackAction: a, debouncedBackAction: c, handleBackClick: () => {
34
+ r.value = !0, c();
31
35
  }, InButtonV2: w };
32
36
  }
33
37
  });
@@ -0,0 +1,20 @@
1
+ import a from "./ValidationErrorDrawer.vue2.js";
2
+ /* empty css */
3
+ import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
+ var o = this, r = o._self._c, t = o._self._setupProxy;
6
+ return r(t.WpDrawer, { attrs: { id: "guido__validation-error-drawer", size: "small", "footer-button-group-options": t.footerButtonGroupOptions, status: t.store.isDrawerOpen, "title-text": t.titleText }, on: { onCloseEvent: t.handleClose, primaryButtonEvent: t.handleClose, secondaryButtonEvent: t.handleSaveAndContinue } }, [r("div", { staticClass: "d-f f-d-c validation-error-list" }, o._l(t.rows, function(e, n) {
7
+ return r("div", { key: n, staticClass: "d-f a-i-c validation-error-row" }, [r(t.InIcons, { staticClass: "validation-error-row__icon i-c-12", attrs: { name: "filled-caution-triangle" } }), r("span", { staticClass: "validation-error-row__text", domProps: { innerHTML: o._s(e) } })], 1);
8
+ }), 0)]);
9
+ }, l = [], d = /* @__PURE__ */ s(
10
+ a,
11
+ i,
12
+ l,
13
+ !1,
14
+ null,
15
+ "c5ff3804"
16
+ );
17
+ const u = d.exports;
18
+ export {
19
+ u as default
20
+ };
@@ -0,0 +1,49 @@
1
+ import { defineComponent as p, ref as c, computed as a } from "vue";
2
+ import f from "../../wrappers/WpDrawer.vue.js";
3
+ import { useSave as S } from "../../../composables/useSave.js";
4
+ import { useTranslations as v } from "../../../composables/useTranslations.js";
5
+ import { useConfigStore as g } from "../../../stores/config.js";
6
+ import { useEditorStore as y } from "../../../stores/editor.js";
7
+ import { useSaveValidationStore as h } from "../../../stores/save-validation.js";
8
+ import { escapeHtml as w } from "../../../utils/htmlEscape.js";
9
+ import { InIcons as _ } from "@useinsider/design-system-vue";
10
+ const V = /* @__PURE__ */ p({
11
+ __name: "ValidationErrorDrawer",
12
+ setup(C) {
13
+ const r = v(), e = h(), n = y(), s = g(), { saveWithErrors: i } = S(), o = c(!1), l = a(() => `${r("email-editor.validation-errors")} (${e.errorCount})`), u = a(() => {
14
+ const t = {
15
+ primaryButton: {
16
+ styling: "solid",
17
+ type: "primary",
18
+ labelText: r("email-editor.update-design")
19
+ }
20
+ };
21
+ return s.allowSaveWithErrors && e.intent !== "test" && (t.secondaryButton = {
22
+ styling: "solid",
23
+ type: "subtle-primary",
24
+ labelText: r("email-editor.save-and-continue"),
25
+ loadingStatus: o.value
26
+ }), t;
27
+ }), d = a(() => e.errors.map((t) => {
28
+ const m = t.detail ? ` (${w(t.detail)})` : "";
29
+ return `${t.message}${m}`;
30
+ }));
31
+ return { __sfc: !0, trans: r, store: e, editorStore: n, configStore: s, saveWithErrors: i, isSaving: o, titleText: l, footerButtonGroupOptions: u, rows: d, handleClose: () => {
32
+ e.isDrawerOpen && e.close();
33
+ }, handleSaveAndContinue: async () => {
34
+ if (!o.value) {
35
+ o.value = !0, n.loadingStatus = !0;
36
+ try {
37
+ await i() ? e.close() : n.loadingStatus = !1;
38
+ } catch (t) {
39
+ console.warn("Soft-save failed; keeping the drawer open.", t), n.loadingStatus = !1;
40
+ } finally {
41
+ o.value = !1;
42
+ }
43
+ }
44
+ }, WpDrawer: f, InIcons: _ };
45
+ }
46
+ });
47
+ export {
48
+ V as default
49
+ };
@@ -1,17 +1,19 @@
1
1
  import r from "./WpDrawer.vue2.js";
2
2
  import s from "../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var u = function() {
4
- var t = this, n = t._self._c, e = t._self._setupProxy;
5
- return n(e.InDrawer, { class: t.className, attrs: { id: t.id, "footer-status": "", "close-on-outside-click": t.closeOnOutsideClick, "description-status": t.descriptionStatus, "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, size: t.size, status: t.status, "title-text": t.titleText }, on: { cancelOrBackButtonEvent: function(o) {
4
+ var t = this, o = t._self._c, e = t._self._setupProxy;
5
+ return o(e.InDrawer, { class: t.className, attrs: { id: t.id, "footer-status": "", "close-on-outside-click": t.closeOnOutsideClick, "description-status": t.descriptionStatus, "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, size: t.size, status: t.status, "title-text": t.titleText }, on: { cancelOrBackButtonEvent: function(n) {
6
6
  return e.emit("cancelOrBackButtonEvent");
7
- }, onCloseEvent: function(o) {
7
+ }, onCloseEvent: function(n) {
8
8
  return e.emit("onCloseEvent");
9
- }, primaryButtonEvent: function(o) {
9
+ }, primaryButtonEvent: function(n) {
10
10
  return e.emit("primaryButtonEvent");
11
+ }, secondaryButtonEvent: function(n) {
12
+ return e.emit("secondaryButtonEvent");
11
13
  } }, scopedSlots: t._u([t.$slots.headerBottomSlot ? { key: "headerBottomSlot", fn: function() {
12
14
  return [t._t("headerBottomSlot")];
13
15
  }, proxy: !0 } : null, { key: "contentSlot", fn: function() {
14
- return [n("div", [t._t("default")], 2)];
16
+ return [o("div", [t._t("default")], 2)];
15
17
  }, proxy: !0 }], null, !0) });
16
18
  }, i = [], c = /* @__PURE__ */ s(
17
19
  r,
@@ -21,7 +23,7 @@ var u = function() {
21
23
  null,
22
24
  null
23
25
  );
24
- const f = c.exports;
26
+ const p = c.exports;
25
27
  export {
26
- f as default
28
+ p as default
27
29
  };
@@ -13,7 +13,7 @@ const r = /* @__PURE__ */ e({
13
13
  status: { type: Boolean },
14
14
  titleText: null
15
15
  },
16
- emits: ["cancelOrBackButtonEvent", "onCloseEvent", "primaryButtonEvent"],
16
+ emits: ["cancelOrBackButtonEvent", "onCloseEvent", "primaryButtonEvent", "secondaryButtonEvent"],
17
17
  setup(n, { emit: t }) {
18
18
  return { __sfc: !0, emit: t, InDrawer: o };
19
19
  }
@@ -1,138 +1,70 @@
1
- import { useEmailTemplateApplier as z, resetEmailTemplateApplier as J } from "./useEmailTemplateApplier.js";
2
- import { useToaster as Q } from "./useToaster.js";
3
- import { useTranslations as V } from "./useTranslations.js";
4
- import { ToasterTypeOptions as Z } from "../enums/toaster.js";
5
- import { useGuidoEmailEditorStore as W } from "../stores/guido-email-editor.js";
6
- import { getActivePinia as k } from "pinia";
7
- import { onUnmounted as tt, watch as et } from "vue";
8
- const rt = "email_template", nt = "chat", ot = "guido:debug:ai", it = 2, lt = 500, ct = (b, p) => `${b}:${p ?? 1}`;
9
- let S = null;
10
- const at = () => {
1
+ import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as I } from "./useToaster.js";
3
+ import { useTranslations as P } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as S } from "../enums/toaster.js";
5
+ import { getActivePinia as v } from "pinia";
6
+ import { watch as B, onUnmounted as D } from "vue";
7
+ const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
11
8
  if (typeof window > "u")
12
9
  return !1;
13
10
  try {
14
- return window.localStorage.getItem(ot) === "1";
11
+ return window.localStorage.getItem(M) === "1";
15
12
  } catch {
16
13
  return !1;
17
14
  }
18
- }, bt = () => {
19
- const b = k();
20
- if (!b)
15
+ }, H = () => {
16
+ const c = v();
17
+ if (!c)
21
18
  return;
22
- const p = W(), M = Symbol("cortexBlueprintBridge");
23
- S = M, p.$patch((t) => {
24
- t.bridgeActive = !0;
25
- });
26
- const { markPending: F, applyTemplate: H, applyTemplateDebounced: O } = z(), { showToaster: C } = Q(), G = V(), E = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
27
- let s = null;
28
- const d = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), B = at();
29
- let w = null, m = null, A;
30
- const K = (t, r) => {
31
- B && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
32
- }, U = () => new Set((A == null ? void 0 : A.appliedBlueprintKeys) ?? []), Y = (t) => t instanceof Error ? t.message : String(t), D = (t, r, n, e) => {
33
- if (S !== M)
34
- return;
35
- const o = p.applyAcks[t], c = Math.max(Date.now(), ((o == null ? void 0 : o.ackAt) ?? 0) + 1), a = { status: r, requestedAt: n, ackAt: c };
36
- e !== void 0 && (a.error = Y(e)), p.$patch((l) => {
37
- l.applyAcks = { ...l.applyAcks, [t]: a };
38
- });
39
- }, I = (t) => (d.get(t) ?? 0) > 0, P = (t) => (s == null ? void 0 : s.key) === t, v = async (t, r, n) => {
40
- var a, l, h;
41
- const e = ((a = r.blueprintData) == null ? void 0 : a.html) ?? "", o = ((l = r.blueprintData) == null ? void 0 : l.css) ?? "", c = r.applyRequestedAt ?? 0;
42
- d.set(t, (d.get(t) ?? 0) + 1);
43
- try {
44
- const i = n === "debounced" ? await O(t, { html: e, css: o }) : await H(t, { html: e, css: o });
45
- if (i.status === "superseded")
46
- return;
47
- if (i.status === "applied") {
48
- E.set(t, e), u.delete(t), D(t, "applied", c);
49
- return;
50
- }
51
- const y = u.get(t), j = (y == null ? void 0 : y.html) === e ? y.count + 1 : 1;
52
- u.set(t, { html: e, count: j }), D(t, "failed", c, i.error);
53
- } catch (i) {
54
- console.error("[guido:apply] apply threw before it could settle", i), D(t, "failed", c, i);
55
- } finally {
56
- d.set(t, (d.get(t) ?? 1) - 1);
57
- const i = T.get(t);
58
- i && !I(t) && (T.delete(t), P(t) && (((h = i.blueprintData) == null ? void 0 : h.html) ?? "") !== e && v(t, i, n));
59
- }
60
- }, N = (t) => {
61
- var h;
62
- if (t.blueprintType !== rt)
63
- return;
64
- const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
65
- if (!r || !n)
66
- return;
67
- const e = ct(r, t.version);
68
- if (!t.applyRequested) {
69
- F(e);
19
+ const l = c._s, p = l == null ? void 0 : l.get(L);
20
+ if (!p)
21
+ return;
22
+ const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: E } = I(), h = P(), y = (r, t) => {
23
+ const e = h(r);
24
+ return e === r ? t : e;
25
+ }, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), A = (r, t) => {
26
+ u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
27
+ }, b = (r) => {
28
+ if (r.blueprintType !== x)
70
29
  return;
71
- }
72
- const o = t.applyRequestedAt ?? 0, c = _.get(e);
73
- if (c === void 0 || o > c) {
74
- const i = c === void 0;
75
- if (_.set(e, o), u.delete(e), (!s || o >= s.requestedAt) && (s = { key: e, requestedAt: o }), i && U().has(e)) {
76
- E.set(e, n);
77
- return;
78
- }
79
- v(e, t, "immediate");
30
+ const t = r.blueprintId, e = r.blueprintData;
31
+ if (!t || !(e != null && e.html))
80
32
  return;
81
- }
82
- const a = E.get(e);
83
- if (a === n || !P(e))
33
+ if (!r.applyRequested) {
34
+ d(t);
84
35
  return;
85
- const l = u.get(e);
86
- if (!((l == null ? void 0 : l.html) === n && l.count >= it)) {
87
- if (a === void 0) {
88
- if (I(e)) {
89
- T.set(e, t);
90
- return;
91
- }
92
- v(e, t, "immediate");
93
- return;
94
- }
95
- f.get(e) !== n && (f.set(e, n), v(e, t, "debounced").finally(() => {
96
- f.get(e) === n && f.delete(e);
97
- }));
98
36
  }
99
- }, R = (t) => t === void 0 || g.has(t) ? !1 : (g.add(t), C({
100
- type: Z.Error,
101
- message: G("newsletter.ai-template-failed")
102
- }), !0), X = (t) => {
103
- Array.isArray(t) && t.forEach((r) => {
104
- const n = r == null ? void 0 : r.id;
105
- (r == null ? void 0 : r.isError) === !0 && R(n) && B && console.debug(`[guido:cortex] message-level error id=${n}`, r);
106
- const e = r == null ? void 0 : r.segments;
107
- Array.isArray(e) && e.forEach((o) => {
108
- if (o)
109
- switch (K(n, o), o.type) {
110
- case "blueprint":
111
- N(o);
112
- break;
113
- case "error":
114
- R(n);
115
- break;
116
- }
37
+ const o = i.get(t);
38
+ o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
39
+ }, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), E({
40
+ type: S.Error,
41
+ message: y("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
42
+ }), !0), m = B(
43
+ () => p.messages,
44
+ (r) => {
45
+ Array.isArray(r) && r.forEach((t) => {
46
+ const e = t == null ? void 0 : t.id;
47
+ (t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
48
+ const o = t == null ? void 0 : t.segments;
49
+ Array.isArray(o) && o.forEach((n) => {
50
+ if (n)
51
+ switch (A(e, n), n.type) {
52
+ case "blueprint":
53
+ b(n);
54
+ break;
55
+ case "error":
56
+ s(e);
57
+ break;
58
+ }
59
+ });
117
60
  });
118
- });
119
- }, $ = () => {
120
- w !== null && (clearInterval(w), w = null);
121
- }, q = () => {
122
- var t;
123
- return (t = b._s) == null ? void 0 : t.get(nt);
124
- }, L = (t) => {
125
- A = t, m = et(() => t.messages, X, { deep: !0, immediate: !0 });
126
- }, x = q();
127
- x ? L(x) : w = setInterval(() => {
128
- const t = q();
129
- t && ($(), L(t));
130
- }, lt), tt(() => {
131
- $(), m == null || m(), A = void 0, E.clear(), f.clear(), _.clear(), u.clear(), s = null, d.clear(), T.clear(), g.clear(), S === M && (S = null, p.$patch((t) => {
132
- t.bridgeActive = !1, t.applyAcks = {};
133
- }), J());
61
+ },
62
+ { deep: !0, immediate: !0 }
63
+ );
64
+ D(() => {
65
+ m(), i.clear(), a.clear(), _();
134
66
  });
135
67
  };
136
68
  export {
137
- bt as useCortexBlueprintBridge
69
+ H as useCortexBlueprintBridge
138
70
  };