@adobe/helix-rum-enhancer 2.49.0 → 2.50.1

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.
@@ -9,287 +9,395 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- (function (e) {
12
+ (function (t) {
13
13
 
14
- let t = -1;
15
- const n = e => {
16
- addEventListener("pageshow", n => {
17
- n.persisted && (t = n.timeStamp, e(n));
14
+ let n = -1;
15
+ const e = () => n,
16
+ i = t => {
17
+ addEventListener("pageshow", e => {
18
+ e.persisted && (n = e.timeStamp, t(e));
18
19
  }, true);
19
20
  },
20
- i = (e, t, n, i) => {
21
- let s, o;
22
- return r => {
23
- t.value >= 0 && (r || i) && (o = t.value - (s ?? 0), (o || void 0 === s) && (s = t.value, t.delta = o, t.rating = ((e, t) => e > t[1] ? "poor" : e > t[0] ? "needs-improvement" : "good")(t.value, n), e(t)));
21
+ o = (t, n, e, i) => {
22
+ let o, s;
23
+ return a => {
24
+ n.value >= 0 && (a || i) && (s = n.value - (o ?? 0), (s || void 0 === o) && (o = n.value, n.delta = s, n.rating = ((t, n) => t > n[1] ? "poor" : t > n[0] ? "needs-improvement" : "good")(n.value, e), t(n)));
24
25
  };
25
26
  },
26
- s = e => {
27
- requestAnimationFrame(() => requestAnimationFrame(e));
27
+ s = t => {
28
+ requestAnimationFrame(() => requestAnimationFrame(() => t()));
28
29
  },
29
- o = () => {
30
- const e = performance.getEntriesByType("navigation")[0];
31
- if (e && e.responseStart > 0 && e.responseStart < performance.now()) return e;
30
+ a = () => {
31
+ const t = performance.getEntriesByType("navigation")[0];
32
+ if (t && t.responseStart > 0 && t.responseStart < performance.now()) return t;
32
33
  },
33
- r = () => o()?.activationStart ?? 0,
34
- c = (e, n = -1) => {
35
- const i = o();
36
- let s = "navigate";
37
- t >= 0 ? s = "back-forward-cache" : i && (document.prerendering || r() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : i.type && (s = i.type.replace(/_/g, "-")));
34
+ r = () => a()?.activationStart ?? 0;
35
+ let c = -1;
36
+ const f = new Set(),
37
+ h = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0,
38
+ d = t => {
39
+ if ("hidden" === document.visibilityState) {
40
+ if ("visibilitychange" === t.type) for (const t of f) t();
41
+ isFinite(c) || (c = "visibilitychange" === t.type ? t.timeStamp : 0, removeEventListener("prerenderingchange", d, true));
42
+ }
43
+ },
44
+ l = (t = false) => {
45
+ if (t && (c = 1 / 0), c < 0) {
46
+ const t = r(),
47
+ n = document.prerendering ? void 0 : globalThis.performance.getEntriesByType("visibility-state").find(n => "hidden" === n.name && n.startTime >= t)?.startTime;
48
+ c = n ?? h(), addEventListener("visibilitychange", d, true), addEventListener("prerenderingchange", d, true), i(() => {
49
+ setTimeout(() => {
50
+ c = h();
51
+ });
52
+ });
53
+ }
38
54
  return {
39
- name: e,
55
+ get firstHiddenTime() {
56
+ return c;
57
+ },
58
+ onHidden(t) {
59
+ f.add(t);
60
+ }
61
+ };
62
+ },
63
+ g = (t, n = -1, i, o = 0, s, c, f) => {
64
+ const h = a(),
65
+ d = h?.navigationId || 0;
66
+ let l = "navigate";
67
+ i ? l = i : e() >= 0 ? l = "back-forward-cache" : h && (document.prerendering || r() > 0 ? l = "prerender" : document.wasDiscarded ? l = "restore" : h.type && (l = h.type.replace(/_/g, "-")));
68
+ return {
69
+ name: t,
40
70
  value: n,
41
71
  rating: "good",
42
72
  delta: 0,
43
73
  entries: [],
44
- id: `v5-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`,
45
- navigationType: s
74
+ id: `v6-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`,
75
+ navigationType: l,
76
+ navigationId: o || d,
77
+ navigationInteractionId: s,
78
+ navigationURL: c || h?.name,
79
+ navigationStartTime: f || 0
46
80
  };
47
81
  },
48
- a = new WeakMap();
49
- function d(e, t) {
50
- let n = a.get(t);
51
- return n || (n = new WeakMap(), a.set(t, n)), n.get(e) || n.set(e, new t()), n.get(e);
82
+ u = new WeakMap();
83
+ function v(t, n) {
84
+ let e = u.get(n);
85
+ return e || (e = new WeakMap(), u.set(n, e)), e.get(t) || e.set(t, new n()), e.get(t);
52
86
  }
53
- class h {
87
+ class m {
54
88
  t;
55
89
  i = 0;
56
90
  o = [];
57
- h(e) {
58
- if (e.hadRecentInput) return;
59
- const t = this.o[0],
60
- n = this.o.at(-1);
61
- this.i && t && n && e.startTime - n.startTime < 1e3 && e.startTime - t.startTime < 5e3 ? (this.i += e.value, this.o.push(e)) : (this.i = e.value, this.o = [e]), this.t?.(e);
91
+ h(t) {
92
+ if (t.hadRecentInput) return;
93
+ const n = this.o[0],
94
+ e = this.o.at(-1);
95
+ this.i && n && e && t.startTime - e.startTime < 1e3 && t.startTime - n.startTime < 5e3 ? (this.i += t.value, this.o.push(t)) : (this.i = t.value, this.o = [t]), this.t?.(t);
62
96
  }
63
97
  }
64
- const f = (e, t, n = {}) => {
98
+ const p = (t, n, e = {}) => {
65
99
  try {
66
- if (PerformanceObserver.supportedEntryTypes.includes(e)) {
67
- const i = new PerformanceObserver(e => {
100
+ const i = t.filter(t => PerformanceObserver.supportedEntryTypes.includes(t));
101
+ if (i.length > 0) {
102
+ const t = new PerformanceObserver(t => {
68
103
  queueMicrotask(() => {
69
- t(e.getEntries());
104
+ const e = t.getEntries();
105
+ i.length > 1 && e.sort((t, n) => t.startTime + t.duration - (n.startTime + n.duration)), n(e);
70
106
  });
71
107
  });
72
- return i.observe({
73
- type: e,
108
+ for (const n of i) t.observe({
109
+ type: n,
74
110
  buffered: !0,
75
- ...n
76
- }), i;
111
+ ...e
112
+ });
113
+ return t;
77
114
  }
78
115
  } catch {}
79
116
  },
80
- l = e => {
81
- let t = false;
82
- return () => {
83
- t || (e(), t = true);
84
- };
85
- };
86
- let u = -1;
87
- const m = new Set(),
88
- g = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0,
89
- p = e => {
90
- if ("hidden" === document.visibilityState) {
91
- if ("visibilitychange" === e.type) for (const e of m) e();
92
- isFinite(u) || (u = "visibilitychange" === e.type ? e.timeStamp : 0, removeEventListener("prerenderingchange", p, true));
117
+ b = t => globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation") && "function" == typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint && t && t.reportSoftNavs,
118
+ T = (t, n) => {
119
+ if (t.set(n.navigationId, n), t.size > 2) {
120
+ const n = t.keys().next().value;
121
+ void 0 !== n && t.delete(n);
93
122
  }
94
123
  },
95
- v = () => {
96
- if (u < 0) {
97
- const e = r(),
98
- t = document.prerendering ? void 0 : globalThis.performance.getEntriesByType("visibility-state").find(t => "hidden" === t.name && t.startTime >= e)?.startTime;
99
- u = t ?? g(), addEventListener("visibilitychange", p, true), addEventListener("prerenderingchange", p, true), n(() => {
100
- setTimeout(() => {
101
- u = g();
102
- });
103
- });
104
- }
105
- return {
106
- get firstHiddenTime() {
107
- return u;
108
- },
109
- onHidden(e) {
110
- m.add(e);
111
- }
124
+ y = t => {
125
+ let n = false;
126
+ return () => {
127
+ n || (t(), n = true);
112
128
  };
129
+ };
130
+ class _ {
131
+ l;
132
+ }
133
+ const E = t => {
134
+ document.prerendering ? addEventListener("prerenderingchange", t, true) : t();
113
135
  },
114
- y = e => {
115
- document.prerendering ? addEventListener("prerenderingchange", e, true) : e();
116
- },
117
- T = [1800, 3e3],
118
- b = (e, t = {}) => {
119
- y(() => {
120
- const o = v();
121
- let a,
122
- d = c("FCP");
123
- const h = f("paint", e => {
124
- for (const t of e) "first-contentful-paint" === t.name && (h.disconnect(), t.startTime < o.firstHiddenTime && (d.value = Math.max(t.startTime - r(), 0), d.entries.push(t), a(true)));
136
+ M = [1800, 3e3],
137
+ L = (t, n = {}) => {
138
+ const a = b(n);
139
+ E(() => {
140
+ const c = v(n, _),
141
+ f = l();
142
+ let h,
143
+ d = g("FCP");
144
+ const u = p(["paint"], t => {
145
+ for (const n of t) "first-contentful-paint" === n.name && (u.disconnect(), n.startTime < f.firstHiddenTime && (d.value = Math.max(n.startTime - r(), 0), d.entries.push(n), d.navigationId = n.navigationId || d.navigationId, h(true)));
125
146
  });
126
- h && (a = i(e, d, T, t.reportAllChanges), n(n => {
127
- d = c("FCP"), a = i(e, d, T, t.reportAllChanges), s(() => {
128
- d.value = performance.now() - n.timeStamp, a(true);
147
+ if (u && (h = o(t, d, M, n.reportAllChanges), i(i => {
148
+ d = g("FCP", -1, "back-forward-cache", d.navigationId, d.navigationInteractionId, d.navigationURL, e()), h = o(t, d, M, n.reportAllChanges), s(() => {
149
+ d.value = performance.now() - i.timeStamp, h(true);
129
150
  });
130
- }));
151
+ })), a) {
152
+ p(["soft-navigation"], e => {
153
+ e.forEach(e => {
154
+ c.l && e.navigationId && T(c.l, e);
155
+ const i = Math.max((e.presentationTime || e.paintTime || 0) - e.startTime, 0);
156
+ d = g("FCP", i, "soft-navigation", e.navigationId, e.interactionId, e.name, e.startTime), h = o(t, d, M, n.reportAllChanges), h(true);
157
+ });
158
+ }, n);
159
+ }
131
160
  });
132
161
  },
133
- E = [.1, .25];
134
- let L = 0,
135
- P = 1 / 0,
136
- _ = 0;
137
- const M = e => {
138
- for (const t of e) t.interactionId && (P = Math.min(P, t.interactionId), _ = Math.max(_, t.interactionId), L = _ ? (_ - P) / 7 + 1 : 0);
162
+ w = [.1, .25];
163
+ let P = 0,
164
+ I = 1 / 0,
165
+ k = 0;
166
+ const C = t => {
167
+ for (const n of t) n.interactionId && (I = Math.min(I, n.interactionId), k = Math.max(k, n.interactionId), P = k ? (k - I) / 7 + 1 : 0);
139
168
  };
140
- let w;
141
- const C = () => w ? L : performance.interactionCount ?? 0,
142
- I = () => {
143
- "interactionCount" in performance || w || (w = f("event", M, {
169
+ let F;
170
+ const N = () => F ? P : performance.interactionCount ?? 0,
171
+ B = () => {
172
+ "interactionCount" in performance || F || (F = p(["event"], C, {
144
173
  durationThreshold: 0
145
174
  }));
146
175
  };
147
- let F = 0;
148
- class k {
149
- l = [];
150
- u = new Map();
151
- m;
176
+ class S {
177
+ u = 0;
178
+ v = [];
179
+ m = new Map();
152
180
  p;
153
- v() {
154
- F = C(), this.l.length = 0, this.u.clear();
181
+ T;
182
+ _() {
183
+ return N() - this.u;
155
184
  }
156
- T() {
157
- const e = Math.min(this.l.length - 1, Math.floor((C() - F) / 50));
158
- return this.l[e];
185
+ M() {
186
+ this.u = N(), this.v.length = 0, this.m.clear();
159
187
  }
160
- h(e) {
161
- if (this.m?.(e), !e.interactionId && "first-input" !== e.entryType) return;
162
- const t = this.l.at(-1);
163
- let n = this.u.get(e.interactionId);
164
- if (n || this.l.length < 10 || e.duration > t.L) {
165
- if (n ? e.duration > n.L ? (n.entries = [e], n.L = e.duration) : e.duration === n.L && e.startTime === n.entries[0].startTime && n.entries.push(e) : (n = {
166
- id: e.interactionId,
167
- entries: [e],
168
- L: e.duration
169
- }, this.u.set(n.id, n), this.l.push(n)), this.l.sort((e, t) => t.L - e.L), this.l.length > 10) {
170
- const e = this.l.splice(10);
171
- for (const t of e) this.u.delete(t.id);
188
+ L(t) {
189
+ const n = this._(),
190
+ e = Math.min(this.v.length - 1, Math.floor(n / 50));
191
+ return !n || -1 !== e || "soft-navigation" !== t && "back-forward-cache" !== t ? this.v[e] : {
192
+ P: 8,
193
+ id: -1,
194
+ entries: []
195
+ };
196
+ }
197
+ h(t) {
198
+ if (this.p?.(t), !t.interactionId) return;
199
+ const n = this.v.at(-1);
200
+ let e = this.m.get(t.interactionId);
201
+ if (e || this.v.length < 10 || t.duration > n.P) {
202
+ if (e ? t.duration > e.P ? (e.entries = [t], e.P = t.duration) : t.duration === e.P && t.startTime === e.entries[0].startTime && e.entries.push(t) : (e = {
203
+ id: t.interactionId,
204
+ entries: [t],
205
+ P: t.duration
206
+ }, this.m.set(e.id, e), this.v.push(e)), this.v.sort((t, n) => n.P - t.P), this.v.length > 10) {
207
+ const t = this.v.splice(10);
208
+ for (const n of t) this.m.delete(n.id);
172
209
  }
173
- this.p?.(n);
210
+ this.T?.(e);
174
211
  }
175
212
  }
176
213
  }
177
- const A = e => {
178
- const t = globalThis.requestIdleCallback || setTimeout,
179
- n = globalThis.cancelIdleCallback || clearTimeout;
180
- if ("hidden" === document.visibilityState) e();else {
181
- const i = l(e);
214
+ const q = t => {
215
+ const n = "requestIdleCallback" in globalThis ? 1e3 : 0,
216
+ e = globalThis.requestIdleCallback || setTimeout,
217
+ i = globalThis.cancelIdleCallback || clearTimeout;
218
+ if ("hidden" === document.visibilityState) t();else {
219
+ const o = y(t);
182
220
  let s = -1;
183
- const o = () => {
184
- n(s), i();
221
+ const a = () => {
222
+ i(s), o();
185
223
  };
186
- addEventListener("visibilitychange", o, {
224
+ addEventListener("visibilitychange", a, {
187
225
  once: true,
188
226
  capture: true
189
- }), s = t(() => {
190
- removeEventListener("visibilitychange", o, {
227
+ }), s = e(() => {
228
+ removeEventListener("visibilitychange", a, {
191
229
  capture: true
192
- }), i();
230
+ }), o();
231
+ }, {
232
+ timeout: n
193
233
  });
194
234
  }
195
235
  },
196
- B = [200, 500];
197
- class S {
198
- m;
199
- h(e) {
200
- this.m?.(e);
236
+ A = [200, 500];
237
+ class H {
238
+ p;
239
+ l;
240
+ h(t) {
241
+ this.p?.(t);
201
242
  }
202
243
  }
203
- const q = [2500, 4e3],
204
- N = [800, 1800],
205
- H = e => {
206
- document.prerendering ? y(() => H(e)) : "complete" !== document.readyState ? addEventListener("load", () => H(e), true) : setTimeout(e);
244
+ const O = [2500, 4e3],
245
+ U = [800, 1800],
246
+ V = t => {
247
+ document.prerendering ? E(() => V(t)) : "complete" !== document.readyState ? addEventListener("load", () => V(t), true) : setTimeout(t);
207
248
  };
208
- return e.CLSThresholds = E, e.FCPThresholds = T, e.INPThresholds = B, e.LCPThresholds = q, e.TTFBThresholds = N, e.onCLS = (e, t = {}) => {
209
- const o = v();
210
- b(l(() => {
249
+ return t.CLSThresholds = w, t.FCPThresholds = M, t.INPThresholds = A, t.LCPThresholds = O, t.TTFBThresholds = U, t.onCLS = (t, n = {}) => {
250
+ const a = l();
251
+ L(y(() => {
211
252
  let r,
212
- a = c("CLS", 0);
213
- const l = d(t, h),
214
- u = e => {
215
- for (const t of e) l.h(t);
216
- l.i > a.value && (a.value = l.i, a.entries = l.o, r());
253
+ c = g("CLS", 0);
254
+ const f = v(n, m),
255
+ h = (e, i, s, a, h) => {
256
+ c = g("CLS", 0, e, i, s, a, h), f.i = 0, r = o(t, c, w, n.reportAllChanges);
257
+ },
258
+ d = (t = false) => {
259
+ f.i > c.value && (c.value = f.i, c.entries = f.o), r(t);
260
+ },
261
+ l = t => {
262
+ d(true), h("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
263
+ },
264
+ u = t => {
265
+ for (const n of t) "soft-navigation" !== n.entryType ? f.h(n) : l(n);
266
+ d();
217
267
  },
218
- m = f("layout-shift", u);
219
- m && (r = i(e, a, E, t.reportAllChanges), o.onHidden(() => {
220
- u(m.takeRecords()), r(true);
221
- }), n(() => {
222
- l.i = 0, a = c("CLS", 0), r = i(e, a, E, t.reportAllChanges), s(r);
268
+ T = ["layout-shift"];
269
+ b(n) && T.push("soft-navigation");
270
+ const y = p(T, u);
271
+ y && (r = o(t, c, w, n.reportAllChanges), a.onHidden(() => {
272
+ u(y.takeRecords()), r(true);
273
+ }), i(() => {
274
+ h("back-forward-cache", c.navigationId, c.navigationInteractionId, c.navigationURL, e()), s(r);
223
275
  }), setTimeout(r));
224
276
  }));
225
- }, e.onFCP = b, e.onINP = (e, t = {}) => {
277
+ }, t.onFCP = L, t.onINP = (t, n = {}) => {
226
278
  if (!globalThis.PerformanceEventTiming || !("interactionId" in PerformanceEventTiming.prototype)) return;
227
- const s = v();
228
- y(() => {
229
- I();
230
- let o,
231
- r = c("INP");
232
- const a = d(t, k),
233
- h = e => {
234
- A(() => {
235
- for (const t of e) a.h(t);
236
- const t = a.T();
237
- t && t.L !== r.value && (r.value = t.L, r.entries = t.entries, o());
279
+ const s = l();
280
+ E(() => {
281
+ B();
282
+ let a,
283
+ r = g("INP");
284
+ const c = v(n, S),
285
+ f = (e, i, s, f, h) => {
286
+ c.M(), r = g("INP", -1, e, i, s, f, h), a = o(t, r, A, n.reportAllChanges);
287
+ },
288
+ h = () => {
289
+ const t = c.L(r.navigationType);
290
+ t && t.P !== r.value && (r.value = t.P, r.entries = t.entries, a());
291
+ },
292
+ d = t => {
293
+ h(), a(true), f("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
294
+ },
295
+ l = (t, n = false) => {
296
+ q(() => {
297
+ for (const n of t) "soft-navigation" !== n.entryType ? c.h(n) : d(n);
298
+ h(), n && a(true);
238
299
  });
239
300
  },
240
- l = f("event", h, {
241
- durationThreshold: t.durationThreshold ?? 40
242
- });
243
- o = i(e, r, B, t.reportAllChanges), l && (l.observe({
244
- type: "first-input",
245
- buffered: true
246
- }), s.onHidden(() => {
247
- h(l.takeRecords()), o(true);
248
- }), n(() => {
249
- a.v(), r = c("INP"), o = i(e, r, B, t.reportAllChanges);
301
+ u = ["event", "first-input"];
302
+ b(n) && u.push("soft-navigation");
303
+ const m = p(u, l, {
304
+ ...n,
305
+ durationThreshold: n.durationThreshold ?? 40
306
+ });
307
+ a = o(t, r, A, n.reportAllChanges), m && (s.onHidden(() => {
308
+ l(m.takeRecords(), true);
309
+ }), i(() => {
310
+ f("back-forward-cache", r.navigationId, r.navigationInteractionId, r.navigationURL, e());
250
311
  }));
251
312
  });
252
- }, e.onLCP = (e, t = {}) => {
253
- y(() => {
254
- const o = v();
255
- let a,
256
- h = c("LCP");
257
- const u = d(t, S),
258
- m = e => {
259
- t.reportAllChanges || (e = e.slice(-1));
260
- for (const t of e) u.h(t), t.startTime < o.firstHiddenTime && (h.value = Math.max(t.startTime - r(), 0), h.entries = [t], a());
313
+ }, t.onLCP = (t, n = {}) => {
314
+ let a = false;
315
+ const c = b(n);
316
+ E(() => {
317
+ let f,
318
+ h = l(),
319
+ d = g("LCP");
320
+ const u = v(n, H),
321
+ m = (e, i, s, r, c) => {
322
+ d = g("LCP", -1, e, i, s, r, c), f = o(t, d, O, n.reportAllChanges), a = false, "soft-navigation" === e && (h = l(true));
323
+ },
324
+ b = t => {
325
+ u.l && t.navigationId && T(u.l, t), a || f(true), m("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
326
+ const n = t.getLargestInteractionContentfulPaint?.();
327
+ n && y([n]);
328
+ },
329
+ y = t => {
330
+ n.reportAllChanges || c || (t = t.slice(-1));
331
+ for (const n of t) {
332
+ if (!n) continue;
333
+ if ("soft-navigation" === n.entryType) {
334
+ b(n);
335
+ continue;
336
+ }
337
+ let t = 0,
338
+ e = [],
339
+ i = n.startTime;
340
+ if ("largest-contentful-paint" === n.entryType) t = Math.max(n.startTime - r(), 0), u.h(n), e = [n];else if ("interaction-contentful-paint" === n.entryType) {
341
+ const o = n;
342
+ if (!d.navigationId) continue;
343
+ if ("interactionId" in o && o.interactionId != d.navigationInteractionId) continue;
344
+ i = o.largestContentfulPaint?.renderTime || 0, t = Math.max(i - n.startTime, 0), o.largestContentfulPaint && (u.h(o.largestContentfulPaint), e = [o.largestContentfulPaint]);
345
+ }
346
+ i < h.firstHiddenTime && (d.value = t, d.entries = e, f());
347
+ }
261
348
  },
262
- g = f("largest-contentful-paint", m);
263
- if (g) {
264
- a = i(e, h, q, t.reportAllChanges);
265
- const o = l(() => {
266
- m(g.takeRecords()), g.disconnect(), a(true);
267
- }),
268
- r = e => {
269
- e.isTrusted && (A(o), removeEventListener(e.type, r, {
270
- capture: true
271
- }));
349
+ _ = ["largest-contentful-paint"];
350
+ c && _.push("interaction-contentful-paint", "soft-navigation");
351
+ const E = p(_, y);
352
+ if (E) {
353
+ f = o(t, d, O, n.reportAllChanges);
354
+ const r = ["keydown", "click", "visibilitychange"],
355
+ h = t => {
356
+ if (t.isTrusted && !a) {
357
+ const t = d.id;
358
+ q(() => {
359
+ if (!a) {
360
+ if (!c) {
361
+ E.disconnect();
362
+ for (const t of r) removeEventListener(t, h, {
363
+ capture: true
364
+ });
365
+ }
366
+ t === d.id && (a = true, f(true));
367
+ }
368
+ });
369
+ }
272
370
  };
273
- for (const e of ["keydown", "click", "visibilitychange"]) addEventListener(e, r, {
371
+ for (const t of r) addEventListener(t, h, {
274
372
  capture: true
275
373
  });
276
- n(n => {
277
- h = c("LCP"), a = i(e, h, q, t.reportAllChanges), s(() => {
278
- h.value = performance.now() - n.timeStamp, a(true);
374
+ i(i => {
375
+ m("back-forward-cache", d.navigationId, d.navigationInteractionId, d.navigationURL, e()), f = o(t, d, O, n.reportAllChanges), s(() => {
376
+ d.value = performance.now() - i.timeStamp, a = true, f(true);
279
377
  });
280
378
  });
281
379
  }
282
380
  });
283
- }, e.onTTFB = (e, t = {}) => {
284
- let s = c("TTFB"),
285
- a = i(e, s, N, t.reportAllChanges);
286
- H(() => {
287
- const d = o();
288
- d && (s.value = Math.max(d.responseStart - r(), 0), s.entries = [d], a(true), n(() => {
289
- s = c("TTFB", 0), a = i(e, s, N, t.reportAllChanges), a(true);
290
- }));
381
+ }, t.onTTFB = (t, n = {}) => {
382
+ const s = b(n);
383
+ let c = g("TTFB"),
384
+ f = o(t, c, U, n.reportAllChanges);
385
+ V(() => {
386
+ const h = a();
387
+ if (h) {
388
+ const a = h.responseStart;
389
+ if (c.value = Math.max(a - r(), 0), c.entries = [h], f(true), i(() => {
390
+ c = g("TTFB", 0, "back-forward-cache", c.navigationId, c.navigationInteractionId, c.navigationURL, e()), f = o(t, c, U, n.reportAllChanges), f(true);
391
+ }), s) {
392
+ p(["soft-navigation"], e => {
393
+ e.forEach(e => {
394
+ e.navigationId && (c = g("TTFB", 0, "soft-navigation", e.navigationId, e.interactionId, e.name, e.startTime), c.entries = [e], f = o(t, c, U, n.reportAllChanges), f(true));
395
+ });
396
+ }, n);
397
+ }
398
+ }
291
399
  });
292
- }, e;
400
+ }, t;
293
401
  })({});
294
402
 
295
403
  function addCWVTracking({