@useinsider/guido 3.21.0-beta.f545026 → 3.21.0-beta.ff98fc3

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.
@@ -6,15 +6,15 @@ var t = function() {
6
6
  return r("div", { ref: "wrapperRef", staticClass: "guido-editor__wrapper", class: { "guido-editor__no-header": e.noHeader } }, [r(e.HeaderWrapper, { ref: "headerWrapperRef" }), r(e.AutoSaveController), e.editorStore.isPreviewModeOpen ? r(e.PreviewContainer) : a._e(), r("div", { directives: [{ name: "show", rawName: "v-show", value: !e.previewStore.isLoaded, expression: "!previewStore.isLoaded" }], staticClass: "guido-editor__container", class: { "guido-editor__no-header": e.noHeader }, attrs: { id: "guido-editor" } }), r(e.Toaster), r(e.AuthErrorModal), r(e.FilterSelectionDrawer), e.isRrsEnabled || e.hasAssignedStrategy ? r(e.AssignStrategyDrawer) : a._e(), e.isRrsEnabled || e.hasAssignedStrategy ? r(e.RemoveStrategyModal) : a._e(), e.isRrsEnabled ? r(e.LegacyStrategyUpdatedModal) : a._e(), r(e.SaveAsTemplateDrawer), e.isSaveValidationEnabled ? r(e.ValidationErrorDrawer) : a._e(), e.isTestPartner() ? a._e() : r(e.OnboardingWrapper, { on: { "onboarding-finished": function(_) {
7
7
  return e.emit("onboarding:finished");
8
8
  } } }), r(e.UnsubscribeWrapper), r(e.LoadingWrapper)], 1);
9
- }, s = [], n = /* @__PURE__ */ i(
9
+ }, s = [], d = /* @__PURE__ */ i(
10
10
  o,
11
11
  t,
12
12
  s,
13
13
  !1,
14
14
  null,
15
- "65036aaf"
15
+ "1a3ddd48"
16
16
  );
17
- const v = n.exports;
17
+ const v = d.exports;
18
18
  export {
19
19
  v as default
20
20
  };
@@ -1,180 +1,189 @@
1
- import { defineComponent as ie, defineAsyncComponent as m, ref as W, computed as p, watch as G, onMounted as ce, onUnmounted as de } from "vue";
2
- import { useCortexBlueprintBridge as me } from "../composables/useCortexBlueprintBridge.js";
3
- import { useEditorLock as le } from "../composables/useEditorLock.js";
4
- import { provideGuidoActions as ue } from "../composables/useGuidoActions.js";
5
- import { useGuidoStateBridge as pe } from "../composables/useGuidoStateBridge.js";
6
- import { usePartner as fe } from "../composables/usePartner.js";
7
- import { useSaveValidationRollout as ge } from "../composables/useSaveValidationRollout.js";
8
- import { useStripo as ye } from "../composables/useStripo.js";
9
- import { useTimerClone as Se } from "../composables/useTimerClone.js";
10
- import { migrate as H } from "../config/migrator/index.js";
11
- import { ModuleFolderDefaults as V } from "../enums/defaults.js";
12
- import { RIBBON_SELECTOR as ve } from "../enums/onboarding.js";
13
- import { forgetHeightBounds as be } from "../extensions/Blocks/Recommendation/controls/image/index.js";
14
- import { useRecommendationExtensionStore as $, disposeStrategyPageReturnListeners as he } from "../extensions/Blocks/Recommendation/store/recommendation.js";
15
- import { disposeUnsubscribeListeners as Ee } from "../extensions/Blocks/Unsubscribe/block.js";
16
- import we from "./organisms/AutoSaveController.vue.js";
17
- import De from "./organisms/base/AuthErrorModal.vue.js";
18
- import Ce from "./organisms/base/Toaster.vue.js";
19
- import ke from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
1
+ import { defineComponent as de, defineAsyncComponent as l, ref as W, computed as f, watch as G, onMounted as me, onUnmounted as le } from "vue";
2
+ import { useCortexBlueprintBridge as ue } from "../composables/useCortexBlueprintBridge.js";
3
+ import { useEditorLock as pe } from "../composables/useEditorLock.js";
4
+ import { startEditorOpenMetrics as fe } from "../composables/useEditorOpenMetrics.js";
5
+ import { provideGuidoActions as ye } from "../composables/useGuidoActions.js";
6
+ import { useGuidoStateBridge as ge } from "../composables/useGuidoStateBridge.js";
7
+ import { usePartner as ve } from "../composables/usePartner.js";
8
+ import { useSaveValidationRollout as Se } from "../composables/useSaveValidationRollout.js";
9
+ import { useStripo as be } from "../composables/useStripo.js";
10
+ import { useTimerClone as he } from "../composables/useTimerClone.js";
11
+ import { migrate as Ee } from "../config/migrator/index.js";
12
+ import { ModuleFolderDefaults as H } from "../enums/defaults.js";
13
+ import { RIBBON_SELECTOR as we } from "../enums/onboarding.js";
14
+ import { useRecommendationExtensionStore as V, disposeStrategyPageReturnListeners as ke } from "../extensions/Blocks/Recommendation/store/recommendation.js";
15
+ import { disposeUnsubscribeListeners as Ce } from "../extensions/Blocks/Unsubscribe/block.js";
16
+ import De from "./organisms/AutoSaveController.vue.js";
17
+ import Ie from "./organisms/base/AuthErrorModal.vue.js";
18
+ import Fe from "./organisms/base/Toaster.vue.js";
19
+ import Me from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
20
20
  import Re from "./organisms/header/HeaderWrapper.vue.js";
21
- import Fe from "./organisms/LoadingWrapper.vue.js";
21
+ import Te from "./organisms/LoadingWrapper.vue.js";
22
22
  import Le from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
23
- import Me from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
24
- import Te from "./organisms/validation/ValidationErrorDrawer.vue.js";
25
- import { useStripoApi as Ie } from "../services/stripoApi.js";
26
- import { useConfigStore as Ue } from "../stores/config.js";
23
+ import Ue from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
24
+ import Ne from "./organisms/validation/ValidationErrorDrawer.vue.js";
25
+ import { useStripoApi as _e } from "../services/stripoApi.js";
26
+ import { useConfigStore as Ae } from "../stores/config.js";
27
27
  import { useDynamicContentStore as Be } from "../stores/dynamic-content.js";
28
- import { useEditorStore as E } from "../stores/editor.js";
29
- import { usePreviewStore as Ae } from "../stores/preview.js";
30
- import { useSaveValidationStore as Ne } from "../stores/save-validation.js";
31
- import { useTemplateStore as Pe } from "../stores/template.js";
32
- import { useUnsubscribeStore as _e } from "../stores/unsubscribe.js";
33
- import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
34
- const St = /* @__PURE__ */ ie({
28
+ import { useEditorStore as w } from "../stores/editor.js";
29
+ import { usePreviewStore as Oe } from "../stores/preview.js";
30
+ import { useSaveValidationStore as Pe } from "../stores/save-validation.js";
31
+ import { useTemplateStore as xe } from "../stores/template.js";
32
+ import { useUnsubscribeStore as We } from "../stores/unsubscribe.js";
33
+ import { readTrackFloor as $ } from "../utils/linkTrackingIds.js";
34
+ const ht = /* @__PURE__ */ de({
35
35
  __name: "Guido",
36
36
  props: {
37
37
  config: null,
38
38
  ready: { type: Boolean, default: !0 }
39
39
  },
40
40
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
41
- setup(q, { expose: K, emit: r }) {
42
- const s = q, j = m(
41
+ setup(z, { expose: q, emit: n }) {
42
+ const s = z, a = fe(), K = l(
43
43
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
44
- ), J = m(
44
+ ), j = l(
45
45
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
46
- ), Q = m(
46
+ ), J = l(
47
47
  () => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
48
- ), X = m(
48
+ ), Q = l(
49
49
  () => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
50
- ), Y = m(
50
+ ), X = l(
51
51
  () => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
52
- ), w = W(), f = W(), g = Be(), D = _e(), o = Ue();
52
+ ), k = W(), y = W(), g = Be(), C = We(), o = Ae();
53
53
  s.ready && o.init(s.config);
54
- const c = E(), Z = Ae(), l = p(() => c.hasChanges), { isTestPartner: ee } = fe(), { isEnabled: te, loadRollout: C } = ge(), k = () => {
54
+ const d = w(), Y = Oe(), u = f(() => d.hasChanges), { isTestPartner: Z } = ve(), { isEnabled: ee, loadRollout: D } = Se(), I = () => {
55
55
  var t;
56
- return (t = w.value) == null ? void 0 : t.handleSave(!0);
57
- }, R = (t) => {
58
- c.loadingStatus = t;
56
+ return (t = k.value) == null ? void 0 : t.handleSave(!0);
57
+ }, F = (t) => {
58
+ d.loadingStatus = t;
59
59
  };
60
- me(), pe();
61
- const y = () => {
60
+ ue(), ge();
61
+ const v = () => {
62
62
  var t, e;
63
63
  return {
64
64
  emailId: o.templateId,
65
65
  userId: o.userId,
66
66
  username: o.username,
67
67
  partnerName: o.partnerName,
68
- savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || V.SAVED_MODULES,
69
- defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || V.DEFAULT_MODULES
68
+ savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || H.SAVED_MODULES,
69
+ defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || H.DEFAULT_MODULES
70
70
  };
71
- }, { initPlugin: F, preloadRuntime: L } = ye(), { runExclusive: M, beginMount: T, isCurrentMount: S } = le();
72
- let u = 0;
73
- const { getDefaultTemplate: I } = Ie(), { cloneTimersOnSave: U, hasTimerBlocks: B } = Se(), oe = p(() => {
71
+ }, { initPlugin: M, preloadRuntime: R } = be(), { runExclusive: T, beginMount: L, isCurrentMount: S } = pe();
72
+ let p = 0;
73
+ const { getDefaultTemplate: U } = _e(), { cloneTimersOnSave: N, hasTimerBlocks: _ } = he(), te = f(() => {
74
74
  var t;
75
75
  return !((t = o.ui) != null && t.showHeader);
76
- }), ne = p(() => o.isFeatureEnabled("reusableRecommendationStrategy")), re = p(
77
- () => !!$().recommendationConfigs.strategyId
76
+ }), oe = f(() => o.isFeatureEnabled("reusableRecommendationStrategy")), re = f(
77
+ () => !!V().recommendationConfigs.strategyId
78
78
  );
79
- ue({
79
+ ye({
80
80
  onBack: () => {
81
- console.debug("guido:back"), r("back");
81
+ console.debug("guido:back"), n("back");
82
82
  },
83
83
  onSaveStart: () => {
84
- console.debug("guido:save:start"), r("save:start");
84
+ console.debug("guido:save:start"), n("save:start");
85
85
  },
86
86
  onSaveComplete: (t) => {
87
- const e = { ...t, metadata: y() };
88
- console.debug("guido:save:complete", e), r("save:complete", e);
87
+ const e = { ...t, metadata: v() };
88
+ console.debug("guido:save:complete", e), n("save:complete", e);
89
89
  },
90
90
  onTestEmailClick: () => {
91
- console.debug("guido:test-email:click"), r("test-email:click");
91
+ console.debug("guido:test-email:click"), n("test-email:click");
92
92
  }
93
93
  });
94
94
  const A = (t) => {
95
95
  console.debug("dynamic-content:close", t), g.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
96
- }, N = () => {
96
+ }, B = () => {
97
97
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
98
98
  };
99
- G(() => l.value, () => {
100
- r("on-change", l.value);
99
+ G(() => u.value, () => {
100
+ n("on-change", u.value);
101
101
  });
102
- const v = (t) => {
103
- const e = t, { attribute: a, position: d } = e.detail;
104
- console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
102
+ const b = (t) => {
103
+ const e = t, { attribute: i, position: m } = e.detail;
104
+ console.debug("dynamic-content:open", e.detail), n("dynamic-content:open", i, m);
105
105
  };
106
- let i = null;
107
- const b = () => {
106
+ let c = null;
107
+ const h = () => {
108
108
  var e;
109
- const t = document.querySelector(ve);
110
- (e = f.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
111
- }, h = async () => {
109
+ const t = document.querySelector(we);
110
+ (e = y.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
111
+ }, E = async () => {
112
112
  var t;
113
+ a.mark("host_ready");
113
114
  try {
114
- o.initialized || o.init(s.config), c.templateId = o.templateId;
115
- 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) || [];
116
- D.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
117
- const _ = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, O = o.isFeatureEnabled("linkTrackingIds"), x = {
115
+ o.initialized || o.init(s.config), d.templateId = o.templateId, a.setContext({
116
+ partnerName: o.partnerName,
117
+ productType: o.productType,
118
+ templateId: o.templateId,
119
+ variationId: o.variationId
120
+ });
121
+ const e = o.template, i = (e == null ? void 0 : e.html) || "", m = (e == null ? void 0 : e.css) || "", O = (e == null ? void 0 : e.preselectedDynamicContent) || [];
122
+ C.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
123
+ const ne = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, P = o.isFeatureEnabled("linkTrackingIds"), ae = {
118
124
  partnerName: o.partnerName,
119
125
  campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
120
126
  rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
127
+ }, x = (ce) => a.timed(
128
+ "migration",
129
+ () => Ee(ce, ne, ae)
130
+ );
131
+ let r = {
132
+ html: i && await x(i),
133
+ css: m
121
134
  };
122
- let n = {
123
- html: a && await H(a, _, x),
124
- css: d
125
- };
126
- n.html || (n = await I(), n.html = await H(n.html, _, x));
127
- const ae = O ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
128
- B(n.html) && (n.html = await U(n.html)), O && (c.trackIdSessionFloor = Math.max(ae, z(n.html)));
135
+ r.html || (r = await a.timed("default_template", () => U()), r.html = await x(r.html));
136
+ const ie = P ? $(r.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
137
+ _(r.html) && (r.html = await a.timed("timer_clone", () => N(r.html))), P && (d.trackIdSessionFloor = Math.max(ie, $(r.html)));
129
138
  const se = {
130
- preselectedDynamicContentList: P,
139
+ preselectedDynamicContentList: O,
131
140
  onReady: () => {
132
- console.debug("guido:ready"), r("ready");
141
+ console.debug("guido:ready"), n("ready");
133
142
  }
134
143
  };
135
- u = T(), await F(n, y(), se), g.selectedDynamicContentList = P;
144
+ p = L(), await M(r, v(), se), g.selectedDynamicContentList = O;
136
145
  } catch (e) {
137
- console.error("Failed to initialize Stripo editor:", e);
146
+ console.error("Failed to initialize Stripo editor:", e), a.markFailed();
138
147
  }
139
148
  };
140
- return ce(async () => {
149
+ return me(async () => {
141
150
  var e;
142
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), $().$reset(), E().$reset(), Pe().$reset(), Ne().$reset(), C(), b();
143
- const t = (e = f.value) == null ? void 0 : e.parentElement;
144
- if (t && (i = new ResizeObserver(b), i.observe(t)), L(), s.ready)
145
- await h();
151
+ console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), V().$reset(), w().$reset(), xe().$reset(), Pe().$reset(), D(), h();
152
+ const t = (e = y.value) == null ? void 0 : e.parentElement;
153
+ if (t && (c = new ResizeObserver(h), c.observe(t)), R(), s.ready)
154
+ await E();
146
155
  else {
147
- const a = G(() => s.ready, (d) => {
148
- d && (a(), h());
156
+ const i = G(() => s.ready, (m) => {
157
+ m && (i(), E());
149
158
  });
150
159
  }
151
- document.addEventListener("dynamic-content:open", v);
152
- }), de(() => {
153
- if (Ee(), he(), be(), i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", v), S(u))
160
+ document.addEventListener("dynamic-content:open", b);
161
+ }), le(() => {
162
+ if (Ce(), ke(), a.dispose(), c == null || c.disconnect(), document.removeEventListener("dynamic-content:open", b), S(p))
154
163
  try {
155
- E().isStripoInitialized = !1;
164
+ w().isStripoInitialized = !1;
156
165
  } catch (t) {
157
166
  console.debug("Failed to close the editor readiness gate on unmount", t);
158
167
  }
159
- M(async () => {
160
- if (S(u))
168
+ T(async () => {
169
+ if (S(p))
161
170
  try {
162
171
  window.UIEditor.removeEditor();
163
172
  } catch {
164
173
  console.debug("Failed to remove Stripo editor: No editor found");
165
174
  }
166
175
  }), o.reset();
167
- }), K({
176
+ }), q({
168
177
  dynamicContent: {
169
178
  insert: A,
170
- close: N
179
+ close: B
171
180
  },
172
- hasChanges: l,
173
- saveSilent: k,
174
- setLoading: R
175
- }), { __sfc: !0, PreviewContainer: j, OnboardingWrapper: J, AssignStrategyDrawer: Q, RemoveStrategyModal: X, LegacyStrategyUpdatedModal: Y, headerWrapperRef: w, wrapperRef: f, dynamicContentStore: g, unsubscribeStore: D, props: s, configStore: o, editorStore: c, previewStore: Z, hasChanges: l, isTestPartner: ee, isSaveValidationEnabled: te, loadRollout: C, saveSilent: k, setLoading: R, emit: r, buildMetadata: y, initPlugin: F, preloadRuntime: L, runExclusive: M, beginMount: T, isCurrentMount: S, mountGeneration: u, getDefaultTemplate: I, cloneTimersOnSave: U, hasTimerBlocks: B, noHeader: oe, isRrsEnabled: ne, hasAssignedStrategy: re, insertDynamicContent: A, closeDynamicContent: N, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: b, startEditor: h, AutoSaveController: we, AuthErrorModal: De, Toaster: Ce, FilterSelectionDrawer: ke, HeaderWrapper: Re, LoadingWrapper: Fe, SaveAsTemplateDrawer: Le, UnsubscribeWrapper: Me, ValidationErrorDrawer: Te };
181
+ hasChanges: u,
182
+ saveSilent: I,
183
+ setLoading: F
184
+ }), { __sfc: !0, openMetrics: a, PreviewContainer: K, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: k, wrapperRef: y, dynamicContentStore: g, unsubscribeStore: C, props: s, configStore: o, editorStore: d, previewStore: Y, hasChanges: u, isTestPartner: Z, isSaveValidationEnabled: ee, loadRollout: D, saveSilent: I, setLoading: F, emit: n, buildMetadata: v, initPlugin: M, preloadRuntime: R, runExclusive: T, beginMount: L, isCurrentMount: S, mountGeneration: p, getDefaultTemplate: U, cloneTimersOnSave: N, hasTimerBlocks: _, noHeader: te, isRrsEnabled: oe, hasAssignedStrategy: re, insertDynamicContent: A, closeDynamicContent: B, handleDynamicContentOpen: b, ribbonObserver: c, updateRibbonOffset: h, startEditor: E, AutoSaveController: De, AuthErrorModal: Ie, Toaster: Fe, FilterSelectionDrawer: Me, HeaderWrapper: Re, LoadingWrapper: Te, SaveAsTemplateDrawer: Le, UnsubscribeWrapper: Ue, ValidationErrorDrawer: Ne };
176
185
  }
177
186
  });
178
187
  export {
179
- St as default
188
+ ht as default
180
189
  };
@@ -1,21 +1,20 @@
1
- import { forgetHeightBounds as y } from "../extensions/Blocks/Recommendation/controls/image/index.js";
2
- import { filterAmpErrors as h } from "../utils/ampErrorFilter.js";
3
- import { getEditorApi as r } from "../utils/stripoEditorApi.js";
1
+ import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
2
+ import { getEditorApi as s } from "../utils/stripoEditorApi.js";
4
3
  import { useToaster as D } from "./useToaster.js";
5
- const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((f, p) => {
6
- const C = setTimeout(
4
+ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
5
+ const f = setTimeout(
7
6
  () => p(new Error(`${n} did not report completion within ${l}ms`)),
8
7
  l
9
8
  ), c = (t) => (e) => {
10
- clearTimeout(C), t(e);
9
+ clearTimeout(f), t(e);
11
10
  }, d = c(p);
12
11
  try {
13
- A(c(f), d);
12
+ A(c(C), d);
14
13
  } catch (t) {
15
14
  d(t);
16
15
  }
17
- }), b = () => {
18
- const { handleError: n } = D(), l = (t = {}) => m(
16
+ }), P = () => {
17
+ const { handleError: n } = D(), l = (t = {}) => r(
19
18
  "compileEmail",
20
19
  T,
21
20
  (e, i) => {
@@ -39,38 +38,38 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((f, p) => {
39
38
  resetDataSavedFlag: !1,
40
39
  disableLineHeightsReplace: !0
41
40
  }, ...t }, u = {
42
- callback: (s, E, w, S, v) => {
43
- s ? i(s) : e({
44
- html: E,
41
+ callback: (m, g, w, S, v) => {
42
+ m ? i(m) : e({
43
+ html: g,
45
44
  ampHtml: w,
46
- ampErrors: h(S ?? []),
45
+ ampErrors: y(S ?? []),
47
46
  displayConditions: v
48
47
  });
49
48
  },
50
49
  ...o
51
50
  };
52
- r().actionsApi.compileEmail(u);
51
+ s().actionsApi.compileEmail(u);
53
52
  }
54
53
  );
55
54
  return {
56
55
  getCompiledEmail: l,
57
- getTemplateData: () => m(
56
+ getTemplateData: () => r(
58
57
  "getTemplateData",
59
58
  T,
60
59
  (t) => {
61
- const e = ({ html: i, css: a, width: o, height: g, utmParams: u, syncModulesIds: s }) => t({
60
+ const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
62
61
  html: i,
63
62
  css: a,
64
63
  width: o,
65
- height: g,
64
+ height: E,
66
65
  utmParams: u,
67
- syncModulesIds: s
66
+ syncModulesIds: m
68
67
  });
69
- r().actionsApi.getTemplateData(e);
68
+ s().actionsApi.getTemplateData(e);
70
69
  }
71
70
  ),
72
71
  activateCustomViewStyles: (t = !0) => {
73
- r().actionsApi.activateCustomViewStyles(t);
72
+ s().actionsApi.activateCustomViewStyles(t);
74
73
  },
75
74
  getPreviewData: async (t) => {
76
75
  try {
@@ -110,16 +109,16 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((f, p) => {
110
109
  }
111
110
  }),
112
111
  updateHtmlAndCss: (t, e) => {
113
- const { actionsApi: i } = r();
114
- return y(), m("updateHtmlAndCss", H, (a) => {
112
+ const { actionsApi: i } = s();
113
+ return r("updateHtmlAndCss", h, (a) => {
115
114
  i.updateHtmlAndCss(t, e, () => a());
116
115
  });
117
116
  },
118
- editorSave: () => m(
117
+ editorSave: () => r(
119
118
  "save",
120
119
  T,
121
120
  (t) => {
122
- r().actionsApi.save((e) => {
121
+ s().actionsApi.save((e) => {
123
122
  if (e) {
124
123
  n(e, "Failed to save template"), t(!1);
125
124
  return;
@@ -131,5 +130,5 @@ const H = 1e4, T = 3e4, m = (n, l, A) => new Promise((f, p) => {
131
130
  };
132
131
  };
133
132
  export {
134
- b as useActionsApi
133
+ P as useActionsApi
135
134
  };
@@ -0,0 +1,159 @@
1
+ import { SYNC_MODULE_CLASS as S } from "./useSyncModuleExtractor.js";
2
+ import g from "../package.json.js";
3
+ const s = "guido:open:", b = "total", P = [
4
+ "setup",
5
+ "host_ready",
6
+ "migration_start",
7
+ "migration_end",
8
+ "default_template_start",
9
+ "default_template_end",
10
+ "timer_clone_start",
11
+ "timer_clone_end",
12
+ "plugin_start",
13
+ "script_ready",
14
+ "fonts_sync_ready",
15
+ "blocks_config_ready",
16
+ "init_editor",
17
+ "token_start",
18
+ "token_end",
19
+ "ready"
20
+ ], p = [
21
+ ["host_wait", "setup", "host_ready"],
22
+ ["migration", "migration_start", "migration_end"],
23
+ ["default_template", "default_template_start", "default_template_end"],
24
+ ["timer_clone", "timer_clone_start", "timer_clone_end"],
25
+ ["script", "plugin_start", "script_ready"],
26
+ ["fonts_sync", "script_ready", "fonts_sync_ready"],
27
+ ["blocks_config", "fonts_sync_ready", "blocks_config_ready"],
28
+ ["editor_config", "blocks_config_ready", "init_editor"],
29
+ ["stripo_load", "init_editor", "ready"],
30
+ ["token", "token_start", "token_end"]
31
+ ], h = (e) => new RegExp(`(?:^|[\\s"'])(?:${e})(?=[\\s"'])`, "g"), A = /<img\b/gi, N = h(S), $ = /\srecommendation-id=/g, C = h("items-block-v2|esd-(?:cart|browsed|purchased)-items-block"), O = "esd-timer-id", f = {
32
+ html_bytes: null,
33
+ css_bytes: null,
34
+ image_count: null,
35
+ synced_module_count: null,
36
+ recommendation_block_count: null,
37
+ items_block_count: null,
38
+ has_timers: null,
39
+ force_recreate: null
40
+ };
41
+ let c = null;
42
+ const d = (e) => {
43
+ try {
44
+ e();
45
+ } catch (t) {
46
+ console.debug("guido:open: metrics step failed", t);
47
+ }
48
+ }, E = () => window.DD_RUM, y = (e, t) => e === void 0 || t === void 0 ? null : Math.round(t - e), _ = (e, t) => {
49
+ var r;
50
+ return ((r = e.match(t)) == null ? void 0 : r.length) ?? 0;
51
+ }, k = (e) => new TextEncoder().encode(e).length, I = (e) => {
52
+ if (!e)
53
+ return f;
54
+ try {
55
+ const { html: t, css: r, forceRecreate: o } = e;
56
+ return {
57
+ html_bytes: k(t),
58
+ css_bytes: k(r),
59
+ image_count: _(t, A),
60
+ synced_module_count: _(t, N),
61
+ recommendation_block_count: _(t, $),
62
+ items_block_count: _(t, C),
63
+ has_timers: t.includes(O),
64
+ force_recreate: o
65
+ };
66
+ } catch (t) {
67
+ return console.debug("guido:open: template weight failed", t), f;
68
+ }
69
+ }, T = () => {
70
+ d(() => {
71
+ P.forEach((e) => performance.clearMarks(`${s}${e}`)), [...p.map(([e]) => e), b].forEach((e) => performance.clearMeasures(`${s}${e}`));
72
+ });
73
+ }, v = (e) => {
74
+ const t = {
75
+ marks: {},
76
+ context: null,
77
+ template: null,
78
+ scriptPreloaded: null,
79
+ wasBackgrounded: document.visibilityState === "hidden",
80
+ finished: e,
81
+ onVisibilityChange: () => {
82
+ document.visibilityState === "hidden" && (t.wasBackgrounded = !0);
83
+ }
84
+ };
85
+ return t;
86
+ }, l = (e, t) => {
87
+ if (e.finished || e.marks[t] !== void 0)
88
+ return;
89
+ const r = performance.now();
90
+ e.marks[t] = r, e === c && d(() => performance.mark(`${s}${t}`, { startTime: r }));
91
+ }, u = (e) => {
92
+ e.finished = !0, document.removeEventListener("visibilitychange", e.onVisibilityChange);
93
+ }, L = (e, t) => {
94
+ const { marks: r } = e, o = p.map(([n, a, i]) => [n, r[a], r[i]]);
95
+ o.push([b, r.setup, t]), o.forEach(([n, a, i]) => {
96
+ a !== void 0 && i !== void 0 && d(() => performance.measure(`${s}${n}`, { start: a, end: i }));
97
+ });
98
+ }, B = (e, t, r) => {
99
+ const { marks: o, context: n } = e, a = Object.fromEntries(
100
+ p.map(([i, M, R]) => [`${i}_ms`, y(o[M], o[R])])
101
+ );
102
+ return {
103
+ outcome: t,
104
+ open_ms: y(o.setup, r),
105
+ ...a,
106
+ script_preloaded: e.scriptPreloaded,
107
+ ...I(e.template),
108
+ partner_name: (n == null ? void 0 : n.partnerName) ?? null,
109
+ product_type: (n == null ? void 0 : n.productType) ?? null,
110
+ template_id: (n == null ? void 0 : n.templateId) ?? null,
111
+ variation_id: (n == null ? void 0 : n.variationId) ?? null,
112
+ guido_version: g.version,
113
+ stripo_version: g.guido.stripo.version,
114
+ was_backgrounded: e.wasBackgrounded
115
+ };
116
+ }, m = (e, t) => {
117
+ d(() => {
118
+ const r = e.marks.ready ?? performance.now(), o = B(e, t, r);
119
+ e.template = null, e === c && L(e, r), console.debug("guido:open", o), d(() => {
120
+ var n, a;
121
+ return (a = (n = E()) == null ? void 0 : n.addAction) == null ? void 0 : a.call(n, "guido_editor_open", o);
122
+ });
123
+ });
124
+ }, w = (e) => ({
125
+ mark: (t) => l(e, t),
126
+ timed: async (t, r) => {
127
+ l(e, `${t}_start`);
128
+ const o = await r();
129
+ return l(e, `${t}_end`), o;
130
+ },
131
+ setContext: (t) => {
132
+ e.context = t;
133
+ },
134
+ setTemplate: (t) => {
135
+ e.template = t;
136
+ },
137
+ setScriptPreloaded: (t) => {
138
+ e.scriptPreloaded = t;
139
+ },
140
+ markReady: () => {
141
+ e.finished || (l(e, "ready"), u(e), d(() => {
142
+ var t, r;
143
+ return (r = (t = E()) == null ? void 0 : t.addTiming) == null ? void 0 : r.call(t, "guido_editor_ready");
144
+ }), setTimeout(() => m(e, "ready"), 0));
145
+ },
146
+ markFailed: () => {
147
+ e.finished || (u(e), m(e, "error"));
148
+ },
149
+ dispose: () => {
150
+ e.finished || (u(e), m(e, "abandoned")), e === c && (T(), c = null);
151
+ }
152
+ }), U = () => {
153
+ const e = v(!1);
154
+ return T(), c = e, document.addEventListener("visibilitychange", e.onVisibilityChange), l(e, "setup"), w(e);
155
+ }, V = () => w(c ?? v(!0));
156
+ export {
157
+ U as startEditorOpenMetrics,
158
+ V as useEditorOpenMetrics
159
+ };