@useinsider/guido 3.21.0-beta.f049776 → 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
- "c5146fc5"
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,179 +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 ye } from "../composables/useSaveValidationRollout.js";
8
- import { useStripo as ge } from "../composables/useStripo.js";
9
- import { useTimerClone as Se } from "../composables/useTimerClone.js";
10
- import { migrate as V } from "../config/migrator/index.js";
11
- import { ModuleFolderDefaults as $ } from "../enums/defaults.js";
12
- import { RIBBON_SELECTOR as ve } from "../enums/onboarding.js";
13
- import { useRecommendationExtensionStore as z, disposeStrategyPageReturnListeners as be } from "../extensions/Blocks/Recommendation/store/recommendation.js";
14
- import { disposeUnsubscribeListeners as he } from "../extensions/Blocks/Unsubscribe/block.js";
15
- import Ee from "./organisms/AutoSaveController.vue.js";
16
- import we from "./organisms/base/AuthErrorModal.vue.js";
17
- import De from "./organisms/base/Toaster.vue.js";
18
- import Ce from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
19
- import ke from "./organisms/header/HeaderWrapper.vue.js";
20
- import Re from "./organisms/LoadingWrapper.vue.js";
21
- import Fe from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
22
- import Le from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
23
- import Me from "./organisms/validation/ValidationErrorDrawer.vue.js";
24
- import { useStripoApi as Te } from "../services/stripoApi.js";
25
- import { useConfigStore as Ie } from "../stores/config.js";
26
- import { useDynamicContentStore as Ue } from "../stores/dynamic-content.js";
27
- import { useEditorStore as E } from "../stores/editor.js";
28
- import { usePreviewStore as Ae } from "../stores/preview.js";
29
- import { useSaveValidationStore as Be } from "../stores/save-validation.js";
30
- import { useTemplateStore as Ne } from "../stores/template.js";
31
- import { useUnsubscribeStore as Pe } from "../stores/unsubscribe.js";
32
- import { readTrackFloor as H } from "../utils/linkTrackingIds.js";
33
- const yt = /* @__PURE__ */ ie({
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
+ import Re from "./organisms/header/HeaderWrapper.vue.js";
21
+ import Te from "./organisms/LoadingWrapper.vue.js";
22
+ import Le from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.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
+ import { useDynamicContentStore as Be } from "../stores/dynamic-content.js";
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({
34
35
  __name: "Guido",
35
36
  props: {
36
37
  config: null,
37
38
  ready: { type: Boolean, default: !0 }
38
39
  },
39
40
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
40
- setup(q, { expose: K, emit: r }) {
41
- const s = q, j = m(
41
+ setup(z, { expose: q, emit: n }) {
42
+ const s = z, a = fe(), K = l(
42
43
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
43
- ), J = m(
44
+ ), j = l(
44
45
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
45
- ), Q = m(
46
+ ), J = l(
46
47
  () => import("./organisms/extensions/recommendation/AssignStrategyDrawer.vue.js")
47
- ), X = m(
48
+ ), Q = l(
48
49
  () => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
49
- ), Y = m(
50
+ ), X = l(
50
51
  () => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
51
- ), w = W(), f = W(), y = Ue(), D = Pe(), o = Ie();
52
+ ), k = W(), y = W(), g = Be(), C = We(), o = Ae();
52
53
  s.ready && o.init(s.config);
53
- const c = E(), Z = Ae(), l = p(() => c.hasChanges), { isTestPartner: ee } = fe(), { isEnabled: te, loadRollout: C } = ye(), k = () => {
54
+ const d = w(), Y = Oe(), u = f(() => d.hasChanges), { isTestPartner: Z } = ve(), { isEnabled: ee, loadRollout: D } = Se(), I = () => {
54
55
  var t;
55
- return (t = w.value) == null ? void 0 : t.handleSave(!0);
56
- }, R = (t) => {
57
- c.loadingStatus = t;
56
+ return (t = k.value) == null ? void 0 : t.handleSave(!0);
57
+ }, F = (t) => {
58
+ d.loadingStatus = t;
58
59
  };
59
- me(), pe();
60
- const g = () => {
60
+ ue(), ge();
61
+ const v = () => {
61
62
  var t, e;
62
63
  return {
63
64
  emailId: o.templateId,
64
65
  userId: o.userId,
65
66
  username: o.username,
66
67
  partnerName: o.partnerName,
67
- savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || $.SAVED_MODULES,
68
- defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || $.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
69
70
  };
70
- }, { initPlugin: F, preloadRuntime: L } = ge(), { runExclusive: M, beginMount: T, isCurrentMount: S } = le();
71
- let u = 0;
72
- const { getDefaultTemplate: I } = Te(), { cloneTimersOnSave: U, hasTimerBlocks: A } = 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(() => {
73
74
  var t;
74
75
  return !((t = o.ui) != null && t.showHeader);
75
- }), ne = p(() => o.isFeatureEnabled("reusableRecommendationStrategy")), re = p(
76
- () => !!z().recommendationConfigs.strategyId
76
+ }), oe = f(() => o.isFeatureEnabled("reusableRecommendationStrategy")), re = f(
77
+ () => !!V().recommendationConfigs.strategyId
77
78
  );
78
- ue({
79
+ ye({
79
80
  onBack: () => {
80
- console.debug("guido:back"), r("back");
81
+ console.debug("guido:back"), n("back");
81
82
  },
82
83
  onSaveStart: () => {
83
- console.debug("guido:save:start"), r("save:start");
84
+ console.debug("guido:save:start"), n("save:start");
84
85
  },
85
86
  onSaveComplete: (t) => {
86
- const e = { ...t, metadata: g() };
87
- 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);
88
89
  },
89
90
  onTestEmailClick: () => {
90
- console.debug("guido:test-email:click"), r("test-email:click");
91
+ console.debug("guido:test-email:click"), n("test-email:click");
91
92
  }
92
93
  });
93
- const B = (t) => {
94
- console.debug("dynamic-content:close", t), y.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
95
- }, N = () => {
94
+ const A = (t) => {
95
+ console.debug("dynamic-content:close", t), g.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
96
+ }, B = () => {
96
97
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
97
98
  };
98
- G(() => l.value, () => {
99
- r("on-change", l.value);
99
+ G(() => u.value, () => {
100
+ n("on-change", u.value);
100
101
  });
101
- const v = (t) => {
102
- const e = t, { attribute: a, position: d } = e.detail;
103
- 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);
104
105
  };
105
- let i = null;
106
- const b = () => {
106
+ let c = null;
107
+ const h = () => {
107
108
  var e;
108
- const t = document.querySelector(ve);
109
- (e = f.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
110
- }, 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 () => {
111
112
  var t;
113
+ a.mark("host_ready");
112
114
  try {
113
- o.initialized || o.init(s.config), c.templateId = o.templateId;
114
- 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) || [];
115
- D.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
116
- 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 = {
117
124
  partnerName: o.partnerName,
118
125
  campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
119
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
120
134
  };
121
- let n = {
122
- html: a && await V(a, _, x),
123
- css: d
124
- };
125
- n.html || (n = await I(), n.html = await V(n.html, _, x));
126
- const ae = O ? H(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
127
- A(n.html) && (n.html = await U(n.html)), O && (c.trackIdSessionFloor = Math.max(ae, H(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)));
128
138
  const se = {
129
- preselectedDynamicContentList: P,
139
+ preselectedDynamicContentList: O,
130
140
  onReady: () => {
131
- console.debug("guido:ready"), r("ready");
141
+ console.debug("guido:ready"), n("ready");
132
142
  }
133
143
  };
134
- u = T(), await F(n, g(), se), y.selectedDynamicContentList = P;
144
+ p = L(), await M(r, v(), se), g.selectedDynamicContentList = O;
135
145
  } catch (e) {
136
- console.error("Failed to initialize Stripo editor:", e);
146
+ console.error("Failed to initialize Stripo editor:", e), a.markFailed();
137
147
  }
138
148
  };
139
- return ce(async () => {
149
+ return me(async () => {
140
150
  var e;
141
- console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), z().$reset(), E().$reset(), Ne().$reset(), Be().$reset(), C(), b();
142
- const t = (e = f.value) == null ? void 0 : e.parentElement;
143
- if (t && (i = new ResizeObserver(b), i.observe(t)), L(), s.ready)
144
- 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();
145
155
  else {
146
- const a = G(() => s.ready, (d) => {
147
- d && (a(), h());
156
+ const i = G(() => s.ready, (m) => {
157
+ m && (i(), E());
148
158
  });
149
159
  }
150
- document.addEventListener("dynamic-content:open", v);
151
- }), de(() => {
152
- if (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))
153
163
  try {
154
- E().isStripoInitialized = !1;
164
+ w().isStripoInitialized = !1;
155
165
  } catch (t) {
156
166
  console.debug("Failed to close the editor readiness gate on unmount", t);
157
167
  }
158
- M(async () => {
159
- if (S(u))
168
+ T(async () => {
169
+ if (S(p))
160
170
  try {
161
171
  window.UIEditor.removeEditor();
162
172
  } catch {
163
173
  console.debug("Failed to remove Stripo editor: No editor found");
164
174
  }
165
175
  }), o.reset();
166
- }), K({
176
+ }), q({
167
177
  dynamicContent: {
168
- insert: B,
169
- close: N
178
+ insert: A,
179
+ close: B
170
180
  },
171
- hasChanges: l,
172
- saveSilent: k,
173
- setLoading: R
174
- }), { __sfc: !0, PreviewContainer: j, OnboardingWrapper: J, AssignStrategyDrawer: Q, RemoveStrategyModal: X, LegacyStrategyUpdatedModal: Y, headerWrapperRef: w, wrapperRef: f, dynamicContentStore: y, 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: g, initPlugin: F, preloadRuntime: L, runExclusive: M, beginMount: T, isCurrentMount: S, mountGeneration: u, getDefaultTemplate: I, cloneTimersOnSave: U, hasTimerBlocks: A, noHeader: oe, isRrsEnabled: ne, hasAssignedStrategy: re, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: b, startEditor: h, AutoSaveController: Ee, AuthErrorModal: we, Toaster: De, FilterSelectionDrawer: Ce, HeaderWrapper: ke, LoadingWrapper: Re, SaveAsTemplateDrawer: Fe, UnsubscribeWrapper: Le, ValidationErrorDrawer: Me };
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 };
175
185
  }
176
186
  });
177
187
  export {
178
- yt as default
188
+ ht as default
179
189
  };
@@ -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
+ };