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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/@types/config/schemas.js +104 -91
  2. package/dist/components/Guido.vue.js +3 -3
  3. package/dist/components/Guido.vue2.js +89 -79
  4. package/dist/components/organisms/base/AuthErrorModal.vue.js +5 -5
  5. package/dist/components/organisms/base/AuthErrorModal.vue2.js +29 -16
  6. package/dist/composables/useAuthError.js +1 -0
  7. package/dist/composables/useAutoSave.js +11 -11
  8. package/dist/composables/useCortexBlueprintBridge.js +122 -54
  9. package/dist/composables/useEmailTemplateApplier.js +111 -50
  10. package/dist/composables/useHttp.js +34 -31
  11. package/dist/composables/useLegacyStrategyConversion.js +23 -19
  12. package/dist/composables/useStripo.js +24 -20
  13. package/dist/config/migrator/index.js +14 -13
  14. package/dist/config/migrator/itemsBlockMigrator.js +236 -248
  15. package/dist/config/migrator/recommendationMigrator.js +28 -21
  16. package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
  17. package/dist/enums/extensions/recommendationBlock.js +30 -29
  18. package/dist/extensions/Blocks/Items/block.js +48 -45
  19. package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
  20. package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
  21. package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
  22. package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
  23. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
  24. package/dist/extensions/Blocks/Items/template.js +219 -204
  25. package/dist/extensions/Blocks/Recommendation/block.js +15 -14
  26. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
  27. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  28. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
  29. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
  30. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  31. package/dist/guido.css +1 -1
  32. package/dist/src/@types/config/schemas.d.ts +16 -0
  33. package/dist/src/composables/useAuthError.d.ts +1 -0
  34. package/dist/src/composables/useConfig.d.ts +2 -0
  35. package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
  36. package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
  37. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  38. package/dist/src/config/migrator/index.d.ts +2 -1
  39. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  40. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
  42. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  43. package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
  44. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  45. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  46. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  47. package/dist/src/stores/config.d.ts +20 -0
  48. package/dist/src/stores/guido-email-editor.d.ts +20 -10
  49. package/dist/src/stores/onboarding.d.ts +4 -0
  50. package/dist/src/stores/recommendation.d.ts +5 -0
  51. package/dist/src/utils/dateUtil.d.ts +10 -0
  52. package/dist/src/utils/genericUtil.d.ts +3 -0
  53. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  54. package/dist/static/styles/components/version-history.css.js +2 -6
  55. package/dist/stores/guido-email-editor.js +3 -1
  56. package/dist/stores/onboarding.js +4 -0
  57. package/dist/utils/pairProductVariables.js +71 -71
  58. package/package.json +1 -1
@@ -1,77 +1,77 @@
1
- import { defineComponent as re, defineAsyncComponent as m, ref as O, computed as u, watch as x, onMounted as se, onUnmounted as ae } from "vue";
2
- import { useCortexBlueprintBridge as ie } from "../composables/useCortexBlueprintBridge.js";
3
- import { useEditorLock as ce } from "../composables/useEditorLock.js";
4
- import { provideGuidoActions as de } from "../composables/useGuidoActions.js";
5
- import { useGuidoStateBridge as me } from "../composables/useGuidoStateBridge.js";
6
- import { usePartner as le } from "../composables/usePartner.js";
7
- import { useStripo as ue } from "../composables/useStripo.js";
8
- import { useTimerClone as pe } from "../composables/useTimerClone.js";
9
- import { migrate as W } from "../config/migrator/index.js";
10
- import { ModuleFolderDefaults as G } from "../enums/defaults.js";
11
- import { RIBBON_SELECTOR as fe } from "../enums/onboarding.js";
12
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
13
- import ye from "./organisms/AutoSaveController.vue.js";
14
- import ge from "./organisms/base/AuthErrorModal.vue.js";
1
+ import { defineComponent as ae, defineAsyncComponent as m, ref as W, computed as p, watch as G, onMounted as se, onUnmounted as ie } from "vue";
2
+ import { useCortexBlueprintBridge as ce } from "../composables/useCortexBlueprintBridge.js";
3
+ import { useEditorLock as de } from "../composables/useEditorLock.js";
4
+ import { provideGuidoActions as me } from "../composables/useGuidoActions.js";
5
+ import { useGuidoStateBridge as le } from "../composables/useGuidoStateBridge.js";
6
+ import { usePartner as ue } from "../composables/usePartner.js";
7
+ import { useStripo as pe } from "../composables/useStripo.js";
8
+ import { useTimerClone as fe } from "../composables/useTimerClone.js";
9
+ import { migrate as z } from "../config/migrator/index.js";
10
+ import { ModuleFolderDefaults as H } from "../enums/defaults.js";
11
+ import { RIBBON_SELECTOR as ye } from "../enums/onboarding.js";
12
+ import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
13
+ import ge from "./organisms/AutoSaveController.vue.js";
14
+ import Se from "./organisms/base/AuthErrorModal.vue.js";
15
15
  import ve from "./organisms/base/Toaster.vue.js";
16
- import Se from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
16
+ import be from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
17
17
  import he from "./organisms/header/HeaderWrapper.vue.js";
18
- import be from "./organisms/LoadingWrapper.vue.js";
19
- import Ee from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
20
- import we from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
21
- import { useStripoApi as Ce } from "../services/stripoApi.js";
22
- import { useConfigStore as De } from "../stores/config.js";
23
- import { useDynamicContentStore as ke } from "../stores/dynamic-content.js";
24
- import { useEditorStore as H } from "../stores/editor.js";
18
+ import Ee from "./organisms/LoadingWrapper.vue.js";
19
+ import we from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
20
+ import Ce from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
21
+ import { useStripoApi as De } from "../services/stripoApi.js";
22
+ import { useConfigStore as ke } from "../stores/config.js";
23
+ import { useDynamicContentStore as Fe } from "../stores/dynamic-content.js";
24
+ import { useEditorStore as w } from "../stores/editor.js";
25
25
  import { usePreviewStore as Me } from "../stores/preview.js";
26
- import { useTemplateStore as Te } from "../stores/template.js";
27
- import { useUnsubscribeStore as Fe } from "../stores/unsubscribe.js";
26
+ import { useTemplateStore as Re } from "../stores/template.js";
27
+ import { useUnsubscribeStore as Te } from "../stores/unsubscribe.js";
28
28
  import { readTrackFloor as $ } from "../utils/linkTrackingIds.js";
29
- const nt = /* @__PURE__ */ re({
29
+ const rt = /* @__PURE__ */ ae({
30
30
  __name: "Guido",
31
31
  props: {
32
32
  config: null,
33
33
  ready: { type: Boolean, default: !0 }
34
34
  },
35
35
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
36
- setup(z, { expose: q, emit: r }) {
37
- const a = z, K = m(
36
+ setup(q, { expose: K, emit: r }) {
37
+ const s = q, V = m(
38
38
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
39
- ), V = m(
40
- () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
41
39
  ), j = m(
42
- () => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
40
+ () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
43
41
  ), J = m(
44
- () => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
42
+ () => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
45
43
  ), Q = m(
44
+ () => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
45
+ ), X = m(
46
46
  () => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
47
- ), E = O(), p = O(), f = ke(), w = Fe(), o = De();
48
- a.ready && o.init(a.config);
49
- const c = H(), X = Me(), l = u(() => c.hasChanges), { isTestPartner: Y } = le(), C = () => {
47
+ ), C = W(), f = W(), y = Fe(), D = Te(), o = ke();
48
+ s.ready && o.init(s.config);
49
+ const c = w(), Y = Me(), l = p(() => c.hasChanges), { isTestPartner: Z } = ue(), k = () => {
50
50
  var t;
51
- return (t = E.value) == null ? void 0 : t.handleSave(!0);
52
- }, D = (t) => {
51
+ return (t = C.value) == null ? void 0 : t.handleSave(!0);
52
+ }, F = (t) => {
53
53
  c.loadingStatus = t;
54
54
  };
55
- ie(), me();
56
- const y = () => {
55
+ ce(), le();
56
+ const g = () => {
57
57
  var t, e;
58
58
  return {
59
59
  emailId: o.templateId,
60
60
  userId: o.userId,
61
61
  username: o.username,
62
62
  partnerName: o.partnerName,
63
- savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || G.SAVED_MODULES,
64
- defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || G.DEFAULT_MODULES
63
+ savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
64
+ defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
65
65
  };
66
- }, { initPlugin: k, preloadRuntime: M } = ue(), { runExclusive: T, beginMount: F, isCurrentMount: R } = ce();
67
- let g = 0;
68
- const { getDefaultTemplate: I } = Ce(), { cloneTimersOnSave: L, hasTimerBlocks: A } = pe(), Z = u(() => {
66
+ }, { initPlugin: M, preloadRuntime: R } = pe(), { runExclusive: T, beginMount: I, isCurrentMount: S } = de();
67
+ let u = 0;
68
+ const { getDefaultTemplate: L } = De(), { cloneTimersOnSave: U, hasTimerBlocks: A } = fe(), ee = p(() => {
69
69
  var t;
70
70
  return !((t = o.ui) != null && t.showHeader);
71
- }), ee = u(() => o.isFeatureEnabled("reusableRecommendationStrategy")), te = u(
72
- () => !!b().recommendationConfigs.strategyId
71
+ }), te = p(() => o.isFeatureEnabled("reusableRecommendationStrategy")), oe = p(
72
+ () => !!E().recommendationConfigs.strategyId
73
73
  );
74
- de({
74
+ me({
75
75
  onBack: () => {
76
76
  console.debug("guido:back"), r("back");
77
77
  },
@@ -79,7 +79,7 @@ const nt = /* @__PURE__ */ re({
79
79
  console.debug("guido:save:start"), r("save:start");
80
80
  },
81
81
  onSaveComplete: (t) => {
82
- const e = { ...t, metadata: y() };
82
+ const e = { ...t, metadata: g() };
83
83
  console.debug("guido:save:complete", e), r("save:complete", e);
84
84
  },
85
85
  onTestEmailClick: () => {
@@ -87,79 +87,89 @@ const nt = /* @__PURE__ */ re({
87
87
  }
88
88
  });
89
89
  const B = (t) => {
90
- console.debug("dynamic-content:close", t), f.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
91
- }, U = () => {
90
+ console.debug("dynamic-content:close", t), y.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
91
+ }, N = () => {
92
92
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
93
93
  };
94
- x(() => l.value, () => {
94
+ G(() => l.value, () => {
95
95
  r("on-change", l.value);
96
96
  });
97
97
  const v = (t) => {
98
- const e = t, { attribute: s, position: d } = e.detail;
99
- console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", s, d);
98
+ const e = t, { attribute: a, position: d } = e.detail;
99
+ console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
100
100
  };
101
101
  let i = null;
102
- const S = () => {
102
+ const b = () => {
103
103
  var e;
104
- const t = document.querySelector(fe);
105
- (e = p.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
104
+ const t = document.querySelector(ye);
105
+ (e = f.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
106
106
  }, h = async () => {
107
107
  var t;
108
108
  try {
109
- o.initialized || o.init(a.config), c.templateId = o.templateId;
110
- const e = o.template, s = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", P = (e == null ? void 0 : e.preselectedDynamicContent) || [];
111
- w.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
112
- const _ = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, N = o.isFeatureEnabled("linkTrackingIds");
109
+ o.initialized || o.init(s.config), c.templateId = o.templateId;
110
+ const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", P = (e == null ? void 0 : e.preselectedDynamicContent) || [];
111
+ D.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
112
+ const _ = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, O = o.isFeatureEnabled("linkTrackingIds"), x = {
113
+ partnerName: o.partnerName,
114
+ campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
115
+ rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
116
+ };
113
117
  let n = {
114
- html: s && await W(s, _),
118
+ html: a && await z(a, _, x),
115
119
  css: d
116
120
  };
117
- n.html || (n = await I(), n.html = await W(n.html, _));
118
- const oe = N ? $(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
119
- A(n.html) && (n.html = await L(n.html)), N && (c.trackIdSessionFloor = Math.max(oe, $(n.html)));
120
- const ne = {
121
+ n.html || (n = await L(), n.html = await z(n.html, _, x));
122
+ const ne = O ? $(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
123
+ A(n.html) && (n.html = await U(n.html)), O && (c.trackIdSessionFloor = Math.max(ne, $(n.html)));
124
+ const re = {
121
125
  preselectedDynamicContentList: P,
122
126
  onReady: () => {
123
127
  console.debug("guido:ready"), r("ready");
124
128
  }
125
129
  };
126
- g = F(), await k(n, y(), ne), f.selectedDynamicContentList = P;
130
+ u = I(), await M(n, g(), re), y.selectedDynamicContentList = P;
127
131
  } catch (e) {
128
132
  console.error("Failed to initialize Stripo editor:", e);
129
133
  }
130
134
  };
131
135
  return se(async () => {
132
136
  var e;
133
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), b().$reset(), H().$reset(), Te().$reset(), S();
134
- const t = (e = p.value) == null ? void 0 : e.parentElement;
135
- if (t && (i = new ResizeObserver(S), i.observe(t)), M(), a.ready)
137
+ console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), E().$reset(), w().$reset(), Re().$reset(), b();
138
+ const t = (e = f.value) == null ? void 0 : e.parentElement;
139
+ if (t && (i = new ResizeObserver(b), i.observe(t)), R(), s.ready)
136
140
  await h();
137
141
  else {
138
- const s = x(() => a.ready, (d) => {
139
- d && (s(), h());
142
+ const a = G(() => s.ready, (d) => {
143
+ d && (a(), h());
140
144
  });
141
145
  }
142
146
  document.addEventListener("dynamic-content:open", v);
143
- }), ae(() => {
144
- i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", v), b().disposeStrategyPageReturn(), T(async () => {
145
- if (R(g))
147
+ }), ie(() => {
148
+ if (i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", v), E().disposeStrategyPageReturn(), S(u))
149
+ try {
150
+ w().isStripoInitialized = !1;
151
+ } catch (t) {
152
+ console.debug("Failed to close the editor readiness gate on unmount", t);
153
+ }
154
+ T(async () => {
155
+ if (S(u))
146
156
  try {
147
157
  window.UIEditor.removeEditor();
148
158
  } catch {
149
159
  console.debug("Failed to remove Stripo editor: No editor found");
150
160
  }
151
161
  }), o.reset();
152
- }), q({
162
+ }), K({
153
163
  dynamicContent: {
154
164
  insert: B,
155
- close: U
165
+ close: N
156
166
  },
157
167
  hasChanges: l,
158
- saveSilent: C,
159
- setLoading: D
160
- }), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: V, AssignStrategyDrawer: j, RemoveStrategyModal: J, LegacyStrategyUpdatedModal: Q, headerWrapperRef: E, wrapperRef: p, dynamicContentStore: f, unsubscribeStore: w, props: a, configStore: o, editorStore: c, previewStore: X, hasChanges: l, isTestPartner: Y, saveSilent: C, setLoading: D, emit: r, buildMetadata: y, initPlugin: k, preloadRuntime: M, runExclusive: T, beginMount: F, isCurrentMount: R, mountGeneration: g, getDefaultTemplate: I, cloneTimersOnSave: L, hasTimerBlocks: A, noHeader: Z, isRrsEnabled: ee, hasAssignedStrategy: te, insertDynamicContent: B, closeDynamicContent: U, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: S, startEditor: h, AutoSaveController: ye, AuthErrorModal: ge, Toaster: ve, FilterSelectionDrawer: Se, HeaderWrapper: he, LoadingWrapper: be, SaveAsTemplateDrawer: Ee, UnsubscribeWrapper: we };
168
+ saveSilent: k,
169
+ setLoading: F
170
+ }), { __sfc: !0, PreviewContainer: V, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: C, wrapperRef: f, dynamicContentStore: y, unsubscribeStore: D, props: s, configStore: o, editorStore: c, previewStore: Y, hasChanges: l, isTestPartner: Z, saveSilent: k, setLoading: F, emit: r, buildMetadata: g, initPlugin: M, preloadRuntime: R, runExclusive: T, beginMount: I, isCurrentMount: S, mountGeneration: u, getDefaultTemplate: L, cloneTimersOnSave: U, hasTimerBlocks: A, noHeader: ee, isRrsEnabled: te, hasAssignedStrategy: oe, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: b, startEditor: h, AutoSaveController: ge, AuthErrorModal: Se, Toaster: ve, FilterSelectionDrawer: be, HeaderWrapper: he, LoadingWrapper: Ee, SaveAsTemplateDrawer: we, UnsubscribeWrapper: Ce };
161
171
  }
162
172
  });
163
173
  export {
164
- nt as default
174
+ rt as default
165
175
  };
@@ -2,17 +2,17 @@ import e from "./AuthErrorModal.vue2.js";
2
2
  /* empty css */
3
3
  import s from "../../../_virtual/_plugin-vue2_normalizer.js";
4
4
  var a = function() {
5
- var r = this, t = r._self._c, o = r._self._setupProxy;
6
- return o.authError ? t("div", { staticClass: "auth-error-modal" }, [t(o.WpModal, { attrs: { id: "guido__auth-error-modal", state: "warning", "close-button-status": !1, "close-on-outside-click": !1, "footer-button-options": o.footerButtonOptions, title: o.trans("action-builder.session-expired") }, on: { close: o.recover, "primary-action": o.recover } }, [t("p", [r._v(r._s(o.message))])])], 1) : r._e();
5
+ var o = this, r = o._self._c, t = o._self._setupProxy;
6
+ return t.authError ? r("div", { staticClass: "auth-error-modal" }, [r(t.WpModal, { attrs: { id: "guido__auth-error-modal", state: "warning", "close-button-status": !1, "close-on-outside-click": !1, "footer-button-options": t.footerButtonOptions, title: t.title }, on: { close: t.dismiss, "primary-action": t.recover } }, [r("p", [o._v(o._s(t.message))])])], 1) : o._e();
7
7
  }, n = [], i = /* @__PURE__ */ s(
8
8
  e,
9
9
  a,
10
10
  n,
11
11
  !1,
12
12
  null,
13
- "4f4ce4cc"
13
+ "b4d7ae51"
14
14
  );
15
- const f = i.exports;
15
+ const m = i.exports;
16
16
  export {
17
- f as default
17
+ m as default
18
18
  };
@@ -1,27 +1,40 @@
1
- import { defineComponent as i, computed as e } from "vue";
2
- import u from "../../wrappers/WpModal.vue.js";
3
- import { useAuthError as c } from "../../../composables/useAuthError.js";
4
- import { useTranslations as p } from "../../../composables/useTranslations.js";
5
- const _ = /* @__PURE__ */ i({
1
+ import { defineComponent as c, computed as n } from "vue";
2
+ import p from "../../wrappers/WpModal.vue.js";
3
+ import { useAuthError as d } from "../../../composables/useAuthError.js";
4
+ import { useTranslations as m } from "../../../composables/useTranslations.js";
5
+ const _ = /* @__PURE__ */ c({
6
6
  __name: "AuthErrorModal",
7
- setup(l) {
8
- const o = p(), { authError: t } = c(), r = e(() => {
9
- var n;
10
- return ((n = t.value) == null ? void 0 : n.status) === 419;
11
- }), s = e(() => r.value ? o("settings.session-on-another-device") : o("journey-builder.login-session-expired")), a = e(() => ({
7
+ setup(v) {
8
+ const e = m(), { authError: t } = d(), r = n(() => {
9
+ var o;
10
+ return ((o = t.value) == null ? void 0 : o.status) === 419 && t.value.data !== null;
11
+ }), s = n(() => {
12
+ var o;
13
+ return ((o = t.value) == null ? void 0 : o.status) === 419 && t.value.data === null;
14
+ }), i = n(() => r.value ? e("integration-hub.reload-this-page") : e("action-builder.session-expired")), u = n(() => r.value ? e("auth.error-occurred-refresh") : s.value ? e("settings.session-on-another-device") : e("journey-builder.login-session-expired")), l = n(() => ({
12
15
  primaryButton: {
13
16
  type: "primary",
14
- labelText: o("journey-builder.login-popup-button")
17
+ labelText: r.value ? e("integration-hub.reload") : e("journey-builder.login-popup-button")
15
18
  },
16
19
  cancelOrBackButton: {
17
20
  type: "secondary",
18
21
  styling: "ghost",
19
- labelText: o("settings.cancel")
22
+ labelText: e("settings.cancel")
20
23
  }
21
- }));
22
- return { __sfc: !0, trans: o, authError: t, isTakenOver: r, message: s, footerButtonOptions: a, recover: () => {
23
- window.location.replace("/login");
24
- }, WpModal: u };
24
+ })), a = () => {
25
+ if (r.value) {
26
+ window.location.reload();
27
+ return;
28
+ }
29
+ window.location.replace("/");
30
+ };
31
+ return { __sfc: !0, trans: e, authError: t, isPageExpired: r, isTakenOver: s, title: i, message: u, footerButtonOptions: l, recover: a, dismiss: () => {
32
+ if (r.value) {
33
+ t.value = null;
34
+ return;
35
+ }
36
+ a();
37
+ }, WpModal: p };
25
38
  }
26
39
  });
27
40
  export {
@@ -46,6 +46,7 @@ const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRe
46
46
  e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
47
47
  }, T = () => ({ authError: n });
48
48
  export {
49
+ a as isPanelOrigin,
49
50
  R as reportAuthError,
50
51
  T as useAuthError
51
52
  };
@@ -1,17 +1,17 @@
1
1
  import { useConfig as E } from "./useConfig.js";
2
- import { useEditorLock as p } from "./useEditorLock.js";
3
- import { useAutosaveStore as A, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
4
- import { useEditorStore as f } from "../stores/editor.js";
2
+ import { useEditorLock as f } from "./useEditorLock.js";
3
+ import { useAutosaveStore as p, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
4
+ import { useEditorStore as A } from "../stores/editor.js";
5
5
  import { computed as y, watch as I, onUnmounted as L } from "vue";
6
6
  const w = 18e4, v = 6e4, R = (b) => {
7
- const { isFeatureEnabled: S } = E(), o = f(), t = A(), { isEditorBusy: g } = p();
7
+ const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
8
8
  let i = null, c = 0;
9
9
  const u = y(
10
10
  () => S("autosave") && t.isOn
11
11
  ), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
12
12
  hasChanges: o.hasChanges,
13
13
  isInSaveableState: o.isInSaveableState
14
- }), r = async (e) => {
14
+ }), l = async (e) => {
15
15
  if (!u.value) {
16
16
  console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
17
17
  return;
@@ -28,7 +28,7 @@ const w = 18e4, v = 6e4, R = (b) => {
28
28
  console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
29
29
  return;
30
30
  }
31
- console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
31
+ e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
32
32
  try {
33
33
  if (await b() === void 0) {
34
34
  console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
@@ -53,22 +53,22 @@ const w = 18e4, v = 6e4, R = (b) => {
53
53
  });
54
54
  return;
55
55
  }
56
- c = Date.now(), r("visibility");
56
+ l("visibility");
57
57
  }, d = () => {
58
58
  i && (clearInterval(i), i = null);
59
- }, l = () => {
59
+ }, r = () => {
60
60
  document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
61
61
  };
62
62
  I(
63
63
  u,
64
64
  (e) => {
65
65
  console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
66
- console.debug("guido:autosave:interval-tick"), r("interval");
67
- }, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), l(), t.status = s.IDLE);
66
+ console.debug("guido:autosave:interval-tick"), l("interval");
67
+ }, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), r(), t.status = s.IDLE);
68
68
  },
69
69
  { immediate: !0 }
70
70
  ), L(() => {
71
- d(), l(), t.status = s.IDLE, t.lastSavedAt = null;
71
+ d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
72
72
  });
73
73
  };
74
74
  export {
@@ -1,70 +1,138 @@
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 = () => {
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 = () => {
8
11
  if (typeof window > "u")
9
12
  return !1;
10
13
  try {
11
- return window.localStorage.getItem(M) === "1";
14
+ return window.localStorage.getItem(ot) === "1";
12
15
  } catch {
13
16
  return !1;
14
17
  }
15
- }, H = () => {
16
- const c = v();
17
- if (!c)
18
+ }, bt = () => {
19
+ const b = k();
20
+ if (!b)
18
21
  return;
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)
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)
29
63
  return;
30
- const t = r.blueprintId, e = r.blueprintData;
31
- if (!t || !(e != null && e.html))
64
+ const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
65
+ if (!r || !n)
32
66
  return;
33
- if (!r.applyRequested) {
34
- d(t);
67
+ const e = ct(r, t.version);
68
+ if (!t.applyRequested) {
69
+ F(e);
70
+ 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");
80
+ return;
81
+ }
82
+ const a = E.get(e);
83
+ if (a === n || !P(e))
35
84
  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
+ }));
36
98
  }
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
- });
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
+ }
60
117
  });
61
- },
62
- { deep: !0, immediate: !0 }
63
- );
64
- D(() => {
65
- m(), i.clear(), a.clear(), _();
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());
66
134
  });
67
135
  };
68
136
  export {
69
- H as useCortexBlueprintBridge
137
+ bt as useCortexBlueprintBridge
70
138
  };