@flashlog/tracker-sdk 0.1.0

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.
@@ -0,0 +1,4247 @@
1
+ const br = (e) => {
2
+ const t = e.trim();
3
+ return t.length > 0 ? t : null;
4
+ }, vr = () => {
5
+ if (typeof window > "u")
6
+ return null;
7
+ const { hostname: e, protocol: t } = window.location;
8
+ return e === "localhost" || e === "127.0.0.1" ? `${t}//${e}:3008/api` : null;
9
+ }, wr = () => {
10
+ const e = br("https://api.flashlog.app/api");
11
+ if (e) return e;
12
+ const t = vr();
13
+ return t || "https://api.flashlog.app/api";
14
+ }, ft = /* @__PURE__ */ new Set([
15
+ "NETWORK_ERROR",
16
+ "SOCKET_ERROR",
17
+ "JS_ERROR",
18
+ "UNHANDLED_REJECTION",
19
+ "MANUAL_ERROR"
20
+ ]), ze = [
21
+ "password",
22
+ "passwd",
23
+ "authorization",
24
+ "credentials",
25
+ "secret",
26
+ "token",
27
+ "jwt",
28
+ "cookie",
29
+ "session",
30
+ "csrf",
31
+ "passcode",
32
+ "otp",
33
+ "apiKey",
34
+ "accessToken",
35
+ "refreshToken",
36
+ "clientSecret",
37
+ "privateKey",
38
+ "authCode",
39
+ "verificationCode",
40
+ "sessionToken",
41
+ "sessionCookie",
42
+ "sessionSecret"
43
+ ], Ar = [
44
+ "password",
45
+ "passwd",
46
+ "authorization",
47
+ "secret",
48
+ "token",
49
+ "jwt",
50
+ "cookie",
51
+ "session",
52
+ "csrf",
53
+ "passcode",
54
+ "otp",
55
+ "apiKey",
56
+ "accessToken",
57
+ "refreshToken",
58
+ "clientSecret",
59
+ "privateKey",
60
+ "authCode",
61
+ "verificationCode",
62
+ "sessionToken",
63
+ "sessionCookie",
64
+ "sessionSecret"
65
+ ], w = {
66
+ apiUrl: wr(),
67
+ apiKey: "",
68
+ debug: !1,
69
+ autoCapture: !0,
70
+ captureNetworkErrors: !0,
71
+ captureJsErrors: !0,
72
+ captureSocketErrors: !0,
73
+ sessionTimeoutMs: 30 * 60 * 1e3,
74
+ maxActionBufferSize: 50,
75
+ allowNonErrorEvents: !1,
76
+ captureRequestBody: !0,
77
+ captureResponseBody: !0,
78
+ redactKeys: ze,
79
+ redactUrlParams: Ar,
80
+ propagateTraceHeaders: !1,
81
+ traceOrigins: [],
82
+ traceHeaderName: "x-flashlog-trace-id",
83
+ enableSessionReplay: !0,
84
+ replayFlushIntervalMs: 1e4,
85
+ replayMaxSegmentBytes: 512 * 1024,
86
+ replayMaxSegmentEvents: 400,
87
+ replayMaskAllInputs: !0,
88
+ ignoredStatusCodes: [401, 403],
89
+ ignoredUrls: [
90
+ "/api/v1/integration/webhook",
91
+ "/api/v1/tracking-issues",
92
+ "/api/v1/session-replays/public/segments/upload-url",
93
+ "/api/v1/session-replays/public/local-upload/",
94
+ "/api/v1/session-replays/public/finalize",
95
+ "tracking.api.founder-os.ai/api/v2/tracking-session-data",
96
+ "googletagmanager.com",
97
+ "google-analytics.com",
98
+ "clarity.ms",
99
+ "facebook.com/tr"
100
+ ]
101
+ }, M = {
102
+ sessionId: "flashlog_tracker_session_id",
103
+ sessionSeenAt: "flashlog_tracker_session_seen_at",
104
+ deviceId: "flashlog_tracker_device_id",
105
+ accountId: "flashlog_tracker_account_id",
106
+ accountTraits: "flashlog_tracker_account_traits"
107
+ }, kr = (e) => {
108
+ if (e.scriptUrl)
109
+ return e.scriptUrl;
110
+ if (e.source === "package")
111
+ return "package:@flashlog/tracker-sdk";
112
+ }, Vt = async (e) => {
113
+ if (typeof window > "u" || typeof document > "u")
114
+ return;
115
+ const t = Number(e.brandId);
116
+ if (!Number.isFinite(t) || t <= 0)
117
+ return;
118
+ const r = `${(e.apiUrl || w.apiUrl).replace(/\/$/, "")}/v1/tracking-events/public/script-installations/ping`;
119
+ try {
120
+ const n = await fetch(r, {
121
+ method: "POST",
122
+ keepalive: !0,
123
+ headers: {
124
+ "Content-Type": "application/json",
125
+ "x-api-key": e.apiKey
126
+ },
127
+ body: JSON.stringify({
128
+ brand_id: t,
129
+ url: window.location.href,
130
+ referrer: document.referrer || void 0,
131
+ script_url: kr(e)
132
+ })
133
+ });
134
+ !n.ok && e.debug && console.warn("[FlashlogTracker] Installation ping failed", {
135
+ status: n.status
136
+ });
137
+ } catch (n) {
138
+ e.debug && console.warn("[FlashlogTracker] Installation ping error", n);
139
+ }
140
+ }, de = "[redacted]", mt = "[omitted by privacy config]", Ge = (e) => {
141
+ const t = e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().toLowerCase();
142
+ return t ? t.split(/\s+/) : [];
143
+ }, Rr = (e, t) => {
144
+ if (t.length === 0 || t.length > e.length) return !1;
145
+ for (let r = 0; r <= e.length - t.length; r += 1)
146
+ if (t.every((s, i) => e[r + i] === s)) return !0;
147
+ return !1;
148
+ }, Oe = (e, t) => {
149
+ const r = Ge(e);
150
+ if (r.length === 0) return !1;
151
+ const n = r.join("");
152
+ return t.some((s) => {
153
+ const i = Ge(s);
154
+ return i.length === 0 ? !1 : i.length === 1 ? r.includes(i[0]) : n === i.join("") || Rr(r, i);
155
+ });
156
+ }, gt = (e, t) => e ? Ge(e).join("") === t : !1, Er = (e) => e ? Ge(e).includes("url") : !1, Tr = (e) => {
157
+ const t = e.trim();
158
+ if (!t.startsWith("{") && !t.startsWith("[")) return null;
159
+ try {
160
+ const r = JSON.parse(e);
161
+ return r && typeof r == "object" ? r : null;
162
+ } catch {
163
+ return null;
164
+ }
165
+ }, Pt = (e, t) => {
166
+ let r = e.replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, `$1${de}`).replace(/\b(Basic\s+)[A-Za-z0-9+/=-]+/gi, `$1${de}`).replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g, de);
167
+ return r !== e && (t.redactedFieldsCount += 1), r;
168
+ }, Zt = (e) => Pt(e, {
169
+ redactedFieldsCount: 0
170
+ }), _r = (e, t, r) => {
171
+ try {
172
+ const n = e.startsWith("/"), s = new URL(e, "https://flashlog.local");
173
+ let i = !1;
174
+ return s.searchParams.forEach((a, o) => {
175
+ Oe(o, t.redactUrlParams) && (s.searchParams.set(o, de), i = !0);
176
+ }), i ? (r.redactedFieldsCount += 1, n ? `${s.pathname}${s.search}${s.hash}` : s.toString()) : e;
177
+ } catch {
178
+ return e;
179
+ }
180
+ }, Nr = (e, t, r, n, s = /* @__PURE__ */ new WeakSet()) => {
181
+ if (Er(n))
182
+ return _r(e, t, r);
183
+ const i = Tr(e);
184
+ if (i !== null) {
185
+ const a = Ke(i, t, r, n, s);
186
+ return JSON.stringify(a);
187
+ }
188
+ return Pt(e, r);
189
+ }, Ke = (e, t, r, n, s = /* @__PURE__ */ new WeakSet()) => {
190
+ if (gt(n, "requestbody") && !t.captureRequestBody || gt(n, "responsebody") && !t.captureResponseBody)
191
+ return r.omittedFieldsCount += 1, mt;
192
+ if (n && Oe(n, t.redactKeys))
193
+ return r.redactedFieldsCount += 1, de;
194
+ if (typeof e == "string")
195
+ return Nr(e, t, r, n, s);
196
+ if (Array.isArray(e))
197
+ return e.map((i) => Ke(i, t, r, void 0, s));
198
+ if (!e || typeof e != "object")
199
+ return e;
200
+ if (s.has(e))
201
+ return r.redactedFieldsCount += 1, de;
202
+ s.add(e);
203
+ try {
204
+ return Object.entries(e).reduce(
205
+ (i, [a, o]) => (i[a] = Ke(o, t, r, a, s), i),
206
+ {}
207
+ );
208
+ } finally {
209
+ s.delete(e);
210
+ }
211
+ }, Mr = (e, t) => {
212
+ const r = {
213
+ redactedFieldsCount: 0,
214
+ omittedFieldsCount: 0
215
+ }, n = Ke(e.data, t, r), s = n.privacy && typeof n.privacy == "object" ? n.privacy : {};
216
+ return {
217
+ ...e,
218
+ data: {
219
+ ...n,
220
+ privacy: {
221
+ ...s,
222
+ client_redaction: !0,
223
+ redacted: r.redactedFieldsCount > 0,
224
+ redacted_fields_count: r.redactedFieldsCount,
225
+ omitted_fields_count: r.omittedFieldsCount,
226
+ request_body_capture: t.captureRequestBody ? "redacted" : "off",
227
+ response_body_capture: t.captureResponseBody ? "redacted" : "off"
228
+ }
229
+ }
230
+ };
231
+ }, Or = () => typeof window < "u" && window.location ? window.location.href : "", Lr = 120, Ht = (e, t = Lr) => e.length > t ? e.slice(0, t) : e, lt = (e) => {
232
+ const t = e == null ? void 0 : e.trim();
233
+ if (t)
234
+ return Ht(Zt(t));
235
+ }, yt = (e) => {
236
+ const r = Zt(e).split(/([_:.=-])/), n = r.map((s, i) => {
237
+ if (!s || /^[_:.=-]$/.test(s)) return s;
238
+ const o = `${i >= 2 ? r[i - 2] : ""} ${s}`;
239
+ return Oe(s, ze) || Oe(o, ze) ? de : s;
240
+ });
241
+ return Ht(n.join(""), 80);
242
+ }, st = (e) => {
243
+ if (!e) return "";
244
+ if (e.id) return `#${yt(e.id)}`;
245
+ const t = [];
246
+ let r = e;
247
+ for (; r && t.length < 5; ) {
248
+ const n = typeof r.className == "string" ? r.className.trim().split(/\s+/).slice(0, 2).map(yt).join(".") : "";
249
+ t.unshift(`${r.tagName.toLowerCase()}${n ? `.${n}` : ""}`), r = r.parentElement;
250
+ }
251
+ return t.join(" > ");
252
+ }, Fr = (e) => [
253
+ e.getAttribute("name"),
254
+ e.getAttribute("id"),
255
+ e.getAttribute("aria-label"),
256
+ e.getAttribute("placeholder"),
257
+ e.getAttribute("autocomplete"),
258
+ e.getAttribute("type")
259
+ ].filter(Boolean).join(" "), xr = (e) => {
260
+ const t = Fr(e);
261
+ return (e.getAttribute("type") || "").toLowerCase() === "password" || Oe(t, ze);
262
+ }, ge = (e, t) => {
263
+ const r = e == null ? void 0 : e.trim();
264
+ if (r)
265
+ return xr(t) ? de : lt(r);
266
+ }, Dr = (e) => {
267
+ const t = {
268
+ tagName: e == null ? void 0 : e.tagName,
269
+ selector: st(e)
270
+ };
271
+ if (!e) return t;
272
+ if (e instanceof HTMLSelectElement) {
273
+ const r = Array.from(e.selectedOptions), n = r.map((a) => ge(a.value, e)), s = r.map((a) => ge(a.text, e)), i = e.multiple;
274
+ return {
275
+ ...t,
276
+ value: i ? n : n[0],
277
+ text: i ? s : s[0]
278
+ };
279
+ }
280
+ if (e instanceof HTMLInputElement) {
281
+ const r = e.type.toLowerCase();
282
+ return r === "checkbox" || r === "radio" ? {
283
+ ...t,
284
+ checked: e.checked,
285
+ value: ge(e.value, e)
286
+ } : {
287
+ ...t,
288
+ value: ge(e.value, e)
289
+ };
290
+ }
291
+ return e instanceof HTMLTextAreaElement ? {
292
+ ...t,
293
+ value: ge(e.value, e)
294
+ } : e.isContentEditable ? {
295
+ ...t,
296
+ text: ge(e.innerText, e)
297
+ } : {
298
+ ...t,
299
+ text: lt(e.innerText)
300
+ };
301
+ };
302
+ class Br {
303
+ constructor(t) {
304
+ this.actions = [], this.detachHandlers = [], this.maxSize = t;
305
+ }
306
+ start() {
307
+ if (typeof window > "u" || typeof document > "u" || this.detachHandlers.length > 0) return;
308
+ const t = (i) => {
309
+ const a = i.target;
310
+ this.add("CLICK", {
311
+ tagName: a == null ? void 0 : a.tagName,
312
+ text: lt(a == null ? void 0 : a.innerText),
313
+ selector: st(a)
314
+ });
315
+ }, r = (i) => {
316
+ const a = i.target;
317
+ this.add("INPUT_CHANGE", Dr(a));
318
+ }, n = (i) => {
319
+ const a = i.target;
320
+ this.add("FORM_SUBMIT", {
321
+ tagName: a == null ? void 0 : a.tagName,
322
+ selector: st(a)
323
+ });
324
+ }, s = () => {
325
+ this.add("VISIBILITY_CHANGE", {
326
+ text: typeof document < "u" ? document.visibilityState : "unknown"
327
+ });
328
+ };
329
+ document.addEventListener("click", t, !0), document.addEventListener("input", r, !0), document.addEventListener("submit", n, !0), document.addEventListener("visibilitychange", s, !0), this.detachHandlers = [
330
+ () => document.removeEventListener("click", t, !0),
331
+ () => document.removeEventListener("input", r, !0),
332
+ () => document.removeEventListener("submit", n, !0),
333
+ () => document.removeEventListener("visibilitychange", s, !0)
334
+ ];
335
+ }
336
+ stop() {
337
+ this.detachHandlers.forEach((t) => t()), this.detachHandlers = [];
338
+ }
339
+ add(t, r) {
340
+ this.actions.push({
341
+ action: t,
342
+ details: r,
343
+ timestamp: Date.now(),
344
+ url: Or()
345
+ }), this.actions.length > this.maxSize && (this.actions = this.actions.slice(-this.maxSize));
346
+ }
347
+ getAll() {
348
+ return [...this.actions];
349
+ }
350
+ clear() {
351
+ this.actions = [];
352
+ }
353
+ }
354
+ const Ur = (e) => {
355
+ const t = [
356
+ { key: "edg/", name: "Edge" },
357
+ { key: "chrome/", name: "Chrome" },
358
+ { key: "firefox/", name: "Firefox" },
359
+ { key: "safari/", name: "Safari" }
360
+ ], r = e.toLowerCase();
361
+ for (const n of t) {
362
+ const s = r.indexOf(n.key);
363
+ if (s >= 0) {
364
+ const i = r.slice(s + n.key.length).split(/[^\d.]/)[0] || "unknown";
365
+ return { name: n.name, version: i };
366
+ }
367
+ }
368
+ return { name: "Unknown", version: "unknown" };
369
+ }, Wr = (e) => {
370
+ const t = e.toLowerCase();
371
+ return t.includes("windows") ? "Windows" : t.includes("mac os") ? "MacOS" : t.includes("android") ? "Android" : t.includes("iphone") || t.includes("ipad") || t.includes("ios") ? "iOS" : t.includes("linux") ? "Linux" : "Unknown";
372
+ }, zr = () => {
373
+ if (typeof window > "u") return "Unknown";
374
+ const e = window.innerWidth || 0;
375
+ return e <= 768 ? "Mobile" : e <= 1024 ? "Tablet" : "Desktop";
376
+ }, It = (e) => {
377
+ const t = typeof navigator < "u" ? navigator : {}, r = t.userAgent || "", n = Ur(r);
378
+ return {
379
+ os_name: Wr(r),
380
+ device_type: zr(),
381
+ device_id: e,
382
+ browser_name: n.name,
383
+ browser_version: n.version,
384
+ screen_width: typeof screen < "u" ? screen.width : 0,
385
+ screen_height: typeof screen < "u" ? screen.height : 0,
386
+ viewport_width: typeof window < "u" ? window.innerWidth : 0,
387
+ viewport_height: typeof window < "u" ? window.innerHeight : 0,
388
+ language: t.language || "unknown",
389
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "unknown",
390
+ user_agent: r.toLowerCase()
391
+ };
392
+ }, Ct = () => {
393
+ const e = {
394
+ online: typeof navigator < "u" ? navigator.onLine : !0
395
+ }, t = typeof navigator < "u" ? navigator : void 0, r = t == null ? void 0 : t.connection;
396
+ return r && (e.connection_type = r.effectiveType, e.downlink = r.downlink, e.rtt = r.rtt, e.save_data = r.saveData), e;
397
+ }, Xe = typeof window < "u" && window.location ? window.location.origin : void 0, St = (e) => {
398
+ if (typeof crypto < "u" && typeof crypto.getRandomValues == "function") {
399
+ const r = new Uint8Array(e);
400
+ return crypto.getRandomValues(r), Array.from(r, (n) => n.toString(16).padStart(2, "0")).join("");
401
+ }
402
+ let t = "";
403
+ for (let r = 0; r < e; r += 1)
404
+ t += Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
405
+ return t;
406
+ }, Ve = () => {
407
+ const e = St(16), t = St(8);
408
+ return {
409
+ trace_id: e,
410
+ span_id: t,
411
+ traceparent: `00-${e}-${t}-01`
412
+ };
413
+ }, Gr = (e = {}) => {
414
+ const t = typeof e.trace_id == "string" && e.trace_id.trim() ? e.trace_id.trim() : null, r = typeof e.span_id == "string" && e.span_id.trim() ? e.span_id.trim() : null, n = typeof e.traceparent == "string" && e.traceparent.trim() ? e.traceparent.trim() : null;
415
+ return t && r ? {
416
+ trace_id: t,
417
+ span_id: r,
418
+ traceparent: n || `00-${t}-${r}-01`
419
+ } : Ve();
420
+ }, it = (e, t) => ({
421
+ traceparent: e.traceparent,
422
+ [t]: e.trace_id
423
+ }), bt = (e, t) => {
424
+ if (!t.propagateTraceHeaders || !e)
425
+ return !1;
426
+ try {
427
+ const r = new URL(e, Xe), n = t.traceOrigins.map((s) => s.trim()).filter(Boolean);
428
+ return n.length === 0 ? Xe ? r.origin === Xe : !0 : n.some((s) => s === "*" ? !0 : r.origin === s || r.href.startsWith(s));
429
+ } catch {
430
+ return !1;
431
+ }
432
+ }, Kr = "[omitted: non-json body]";
433
+ class Vr {
434
+ constructor(t, r) {
435
+ this.socketMeta = /* @__PURE__ */ new WeakMap(), this.initialized = !1, this.handleWindowError = (n) => {
436
+ var s;
437
+ this.hooks.onJsError({
438
+ message: n.message || "Unknown JS error",
439
+ filename: n.filename || "",
440
+ lineno: n.lineno || 0,
441
+ colno: n.colno || 0,
442
+ stack: ((s = n.error) == null ? void 0 : s.stack) || "",
443
+ timestamp: Date.now()
444
+ });
445
+ }, this.handleUnhandledRejection = (n) => {
446
+ const s = n.reason, i = s instanceof Error ? s.message : typeof s == "string" ? s : "Unhandled rejection", a = s instanceof Error ? s.stack : "";
447
+ this.hooks.onUnhandledRejection({
448
+ message: i,
449
+ stack: a || "",
450
+ timestamp: Date.now()
451
+ });
452
+ }, this.config = t, this.hooks = r;
453
+ }
454
+ start() {
455
+ typeof window > "u" || this.initialized || (this.initialized = !0, this.config.captureNetworkErrors && (this.interceptFetch(), this.interceptXhr()), this.config.captureSocketErrors && this.interceptWebSocket(), this.config.captureJsErrors && (window.addEventListener("error", this.handleWindowError, !0), window.addEventListener("unhandledrejection", this.handleUnhandledRejection, !0)));
456
+ }
457
+ stop() {
458
+ typeof window > "u" || !this.initialized || (this.initialized = !1, this.originalFetch && (window.fetch = this.originalFetch), this.originalXhrOpen && (XMLHttpRequest.prototype.open = this.originalXhrOpen), this.originalXhrSend && (XMLHttpRequest.prototype.send = this.originalXhrSend), this.originalWebSocket && (window.WebSocket = this.originalWebSocket), window.removeEventListener("error", this.handleWindowError, !0), window.removeEventListener("unhandledrejection", this.handleUnhandledRejection, !0));
459
+ }
460
+ shouldIgnoreUrl(t) {
461
+ return this.config.ignoredUrls.some((r) => t.includes(r));
462
+ }
463
+ shouldIgnoreStatus(t) {
464
+ return this.config.ignoredStatusCodes.includes(t);
465
+ }
466
+ truncate(t, r = 3e3) {
467
+ if (t)
468
+ return t.length <= r ? t : `${t.slice(0, r)}... [truncated]`;
469
+ }
470
+ getBodyType(t) {
471
+ var r, n;
472
+ return t ? typeof FormData < "u" && t instanceof FormData ? "FormData" : typeof URLSearchParams < "u" && t instanceof URLSearchParams ? "URLSearchParams" : typeof File < "u" && t instanceof File ? "File" : typeof Blob < "u" && t instanceof Blob ? "Blob" : typeof ArrayBuffer < "u" && t instanceof ArrayBuffer ? "ArrayBuffer" : typeof ReadableStream < "u" && t instanceof ReadableStream ? "ReadableStream" : typeof ArrayBuffer < "u" && ArrayBuffer.isView(t) ? ((r = t.constructor) == null ? void 0 : r.name) || "ArrayBufferView" : typeof t == "object" ? ((n = t.constructor) == null ? void 0 : n.name) || "Object" : typeof t : "Unknown";
473
+ }
474
+ safeBodyPreview(t) {
475
+ if (t)
476
+ return typeof t == "string" ? t : JSON.stringify({
477
+ body_type: this.getBodyType(t),
478
+ captured: !1,
479
+ reason: Kr
480
+ });
481
+ }
482
+ attachTraceHeadersToFetchRequest(t, r, n, s) {
483
+ if (!bt(n, this.config))
484
+ return { input: t, init: r };
485
+ if (t instanceof Request) {
486
+ const a = new Headers(t.headers);
487
+ return new Headers(r == null ? void 0 : r.headers).forEach((c, d) => {
488
+ a.set(d, c);
489
+ }), Object.entries(s).forEach(([c, d]) => {
490
+ a.set(c, d);
491
+ }), {
492
+ input: new Request(t, {
493
+ ...r,
494
+ headers: a
495
+ })
496
+ };
497
+ }
498
+ const i = new Headers(r == null ? void 0 : r.headers);
499
+ return Object.entries(s).forEach(([a, o]) => {
500
+ i.set(a, o);
501
+ }), {
502
+ input: t,
503
+ init: {
504
+ ...r || {},
505
+ headers: i
506
+ }
507
+ };
508
+ }
509
+ interceptFetch() {
510
+ if (typeof window.fetch != "function") return;
511
+ const t = this;
512
+ this.originalFetch = window.fetch, window.fetch = async function(n, s) {
513
+ const i = Date.now(), a = (s == null ? void 0 : s.method) || "GET", o = typeof n == "string" ? n : n instanceof URL ? n.toString() : n.url;
514
+ if (t.shouldIgnoreUrl(o))
515
+ return t.originalFetch.call(window, n, s);
516
+ const c = t.safeBodyPreview(s == null ? void 0 : s.body), d = Ve(), l = it(d, t.config.traceHeaderName), u = t.attachTraceHeadersToFetchRequest(n, s, o, l);
517
+ try {
518
+ const h = await t.originalFetch.call(
519
+ window,
520
+ u.input,
521
+ u.init
522
+ ), f = Date.now() - i;
523
+ if ((h.ok || t.shouldIgnoreStatus(h.status)) && t.hooks.onNetworkActivity({
524
+ type: "fetch",
525
+ url: o,
526
+ method: a.toUpperCase(),
527
+ status: h.status,
528
+ statusText: h.statusText,
529
+ duration_ms: f,
530
+ trace_id: d.trace_id,
531
+ span_id: d.span_id,
532
+ traceparent: d.traceparent,
533
+ timestamp: Date.now()
534
+ }), !h.ok && h.status >= 400 && !t.shouldIgnoreStatus(h.status)) {
535
+ let p;
536
+ try {
537
+ p = await h.clone().text();
538
+ } catch {
539
+ p = "[unreadable]";
540
+ }
541
+ t.hooks.onNetworkError({
542
+ type: "fetch",
543
+ url: o,
544
+ method: a.toUpperCase(),
545
+ status: h.status,
546
+ statusText: h.statusText,
547
+ duration_ms: f,
548
+ request_body: t.truncate(c),
549
+ response_body: t.truncate(p),
550
+ trace_id: d.trace_id,
551
+ span_id: d.span_id,
552
+ traceparent: d.traceparent,
553
+ timestamp: Date.now()
554
+ });
555
+ }
556
+ return h;
557
+ } catch (h) {
558
+ throw t.hooks.onNetworkError({
559
+ type: "fetch",
560
+ url: o,
561
+ method: a.toUpperCase(),
562
+ status: 0,
563
+ statusText: "NETWORK_ERROR",
564
+ duration_ms: Date.now() - i,
565
+ request_body: t.truncate(c),
566
+ response_body: t.truncate(h instanceof Error ? h.message : String(h)),
567
+ trace_id: d.trace_id,
568
+ span_id: d.span_id,
569
+ traceparent: d.traceparent,
570
+ timestamp: Date.now()
571
+ }), h;
572
+ }
573
+ };
574
+ }
575
+ interceptXhr() {
576
+ const t = this;
577
+ this.originalXhrOpen = XMLHttpRequest.prototype.open, this.originalXhrSend = XMLHttpRequest.prototype.send, XMLHttpRequest.prototype.open = function(n, s, i, a, o) {
578
+ const c = s instanceof URL ? s.toString() : String(s);
579
+ return this.__flashlog_meta = {
580
+ method: (n || "GET").toUpperCase(),
581
+ url: c
582
+ }, t.originalXhrOpen.call(this, n, s, i ?? !0, a ?? null, o ?? null);
583
+ }, XMLHttpRequest.prototype.send = function(n) {
584
+ const s = this, i = s.__flashlog_meta || {};
585
+ if (t.shouldIgnoreUrl(i.url || ""))
586
+ return t.originalXhrSend.call(this, n);
587
+ const a = Date.now(), o = t.safeBodyPreview(n), c = Ve(), d = it(c, t.config.traceHeaderName);
588
+ return bt(i.url || "", t.config) && Object.entries(d).forEach(([l, u]) => {
589
+ try {
590
+ s.setRequestHeader(l, u);
591
+ } catch {
592
+ t.hooks.debug && console.warn("[FlashlogTracker] Failed to attach trace header", {
593
+ key: l,
594
+ url: i.url
595
+ });
596
+ }
597
+ }), s.addEventListener("loadend", () => {
598
+ const l = s.status || 0;
599
+ (l >= 200 && l < 400 || t.shouldIgnoreStatus(l)) && t.hooks.onNetworkActivity({
600
+ type: "xhr",
601
+ url: i.url,
602
+ method: i.method || "GET",
603
+ status: l,
604
+ statusText: s.statusText || "HTTP_RESULT",
605
+ duration_ms: Date.now() - a,
606
+ trace_id: c.trace_id,
607
+ span_id: c.span_id,
608
+ traceparent: c.traceparent,
609
+ timestamp: Date.now()
610
+ }), l >= 400 && !t.shouldIgnoreStatus(l) && t.hooks.onNetworkError({
611
+ type: "xhr",
612
+ url: i.url,
613
+ method: i.method || "GET",
614
+ status: l,
615
+ statusText: s.statusText || "HTTP_ERROR",
616
+ duration_ms: Date.now() - a,
617
+ request_body: t.truncate(o),
618
+ response_body: t.truncate(s.responseText || ""),
619
+ trace_id: c.trace_id,
620
+ span_id: c.span_id,
621
+ traceparent: c.traceparent,
622
+ timestamp: Date.now()
623
+ });
624
+ }), s.addEventListener("error", () => {
625
+ t.hooks.onNetworkError({
626
+ type: "xhr",
627
+ url: i.url,
628
+ method: i.method || "GET",
629
+ status: 0,
630
+ statusText: "NETWORK_ERROR",
631
+ duration_ms: Date.now() - a,
632
+ request_body: t.truncate(o),
633
+ response_body: "XHR network error",
634
+ trace_id: c.trace_id,
635
+ span_id: c.span_id,
636
+ traceparent: c.traceparent,
637
+ timestamp: Date.now()
638
+ });
639
+ }), t.originalXhrSend.call(this, n);
640
+ };
641
+ }
642
+ interceptWebSocket() {
643
+ if (typeof window.WebSocket != "function") return;
644
+ const t = this;
645
+ this.originalWebSocket = window.WebSocket;
646
+ const r = this.originalWebSocket, n = function(i, a) {
647
+ const o = i instanceof URL ? i.toString() : String(i), c = a !== void 0 ? new r(i, a) : new r(i);
648
+ return t.shouldIgnoreUrl(o) || (t.socketMeta.set(c, {
649
+ url: o,
650
+ createdAt: Date.now(),
651
+ openedAt: null
652
+ }), c.addEventListener("open", () => {
653
+ const d = t.socketMeta.get(c);
654
+ d && (d.openedAt = Date.now());
655
+ }), c.addEventListener("error", () => {
656
+ const d = t.socketMeta.get(c), l = (d == null ? void 0 : d.openedAt) || (d == null ? void 0 : d.createdAt) || Date.now();
657
+ t.hooks.onSocketError({
658
+ type: "websocket",
659
+ phase: "error",
660
+ url: (d == null ? void 0 : d.url) || o,
661
+ method: "CONNECT",
662
+ status: 0,
663
+ statusText: "WEBSOCKET_ERROR",
664
+ duration_ms: Date.now() - l,
665
+ timestamp: Date.now()
666
+ });
667
+ }), c.addEventListener("close", (d) => {
668
+ if (d.code === 1e3 || d.code === 1001)
669
+ return;
670
+ const l = t.socketMeta.get(c), u = (l == null ? void 0 : l.openedAt) || (l == null ? void 0 : l.createdAt) || Date.now();
671
+ t.hooks.onSocketError({
672
+ type: "websocket",
673
+ phase: "close",
674
+ url: (l == null ? void 0 : l.url) || o,
675
+ method: "CONNECT",
676
+ status: 0,
677
+ socket_close_code: d.code,
678
+ statusText: d.reason || "WEBSOCKET_CLOSED_ABNORMALLY",
679
+ was_clean: d.wasClean,
680
+ duration_ms: Date.now() - u,
681
+ timestamp: Date.now()
682
+ });
683
+ })), c;
684
+ };
685
+ n.prototype = r.prototype, Object.defineProperty(n, "CONNECTING", {
686
+ value: r.CONNECTING
687
+ }), Object.defineProperty(n, "OPEN", {
688
+ value: r.OPEN
689
+ }), Object.defineProperty(n, "CLOSING", {
690
+ value: r.CLOSING
691
+ }), Object.defineProperty(n, "CLOSED", {
692
+ value: r.CLOSED
693
+ }), window.WebSocket = n;
694
+ }
695
+ }
696
+ var F;
697
+ (function(e) {
698
+ e[e.Document = 0] = "Document", e[e.DocumentType = 1] = "DocumentType", e[e.Element = 2] = "Element", e[e.Text = 3] = "Text", e[e.CDATA = 4] = "CDATA", e[e.Comment = 5] = "Comment";
699
+ })(F || (F = {}));
700
+ function Pr(e) {
701
+ return e.nodeType === e.ELEMENT_NODE;
702
+ }
703
+ function Ne(e) {
704
+ var t = e == null ? void 0 : e.host;
705
+ return (t == null ? void 0 : t.shadowRoot) === e;
706
+ }
707
+ function Me(e) {
708
+ return Object.prototype.toString.call(e) === "[object ShadowRoot]";
709
+ }
710
+ function Zr(e) {
711
+ return e.includes(" background-clip: text;") && !e.includes(" -webkit-background-clip: text;") && (e = e.replace(" background-clip: text;", " -webkit-background-clip: text; background-clip: text;")), e;
712
+ }
713
+ function at(e) {
714
+ try {
715
+ var t = e.rules || e.cssRules;
716
+ return t ? Zr(Array.from(t).map(jt).join("")) : null;
717
+ } catch {
718
+ return null;
719
+ }
720
+ }
721
+ function jt(e) {
722
+ var t = e.cssText;
723
+ if (Hr(e))
724
+ try {
725
+ t = at(e.styleSheet) || t;
726
+ } catch {
727
+ }
728
+ return t;
729
+ }
730
+ function Hr(e) {
731
+ return "styleSheet" in e;
732
+ }
733
+ var Jt = function() {
734
+ function e() {
735
+ this.idNodeMap = /* @__PURE__ */ new Map(), this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
736
+ }
737
+ return e.prototype.getId = function(t) {
738
+ var r;
739
+ if (!t)
740
+ return -1;
741
+ var n = (r = this.getMeta(t)) === null || r === void 0 ? void 0 : r.id;
742
+ return n ?? -1;
743
+ }, e.prototype.getNode = function(t) {
744
+ return this.idNodeMap.get(t) || null;
745
+ }, e.prototype.getIds = function() {
746
+ return Array.from(this.idNodeMap.keys());
747
+ }, e.prototype.getMeta = function(t) {
748
+ return this.nodeMetaMap.get(t) || null;
749
+ }, e.prototype.removeNodeFromMap = function(t) {
750
+ var r = this, n = this.getId(t);
751
+ this.idNodeMap.delete(n), t.childNodes && t.childNodes.forEach(function(s) {
752
+ return r.removeNodeFromMap(s);
753
+ });
754
+ }, e.prototype.has = function(t) {
755
+ return this.idNodeMap.has(t);
756
+ }, e.prototype.hasNode = function(t) {
757
+ return this.nodeMetaMap.has(t);
758
+ }, e.prototype.add = function(t, r) {
759
+ var n = r.id;
760
+ this.idNodeMap.set(n, t), this.nodeMetaMap.set(t, r);
761
+ }, e.prototype.replace = function(t, r) {
762
+ var n = this.getNode(t);
763
+ if (n) {
764
+ var s = this.nodeMetaMap.get(n);
765
+ s && this.nodeMetaMap.set(r, s);
766
+ }
767
+ this.idNodeMap.set(t, r);
768
+ }, e.prototype.reset = function() {
769
+ this.idNodeMap = /* @__PURE__ */ new Map(), this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
770
+ }, e;
771
+ }();
772
+ function jr() {
773
+ return new Jt();
774
+ }
775
+ function ut(e) {
776
+ var t = e.maskInputOptions, r = e.tagName, n = e.type, s = e.value, i = e.maskInputFn, a = s || "";
777
+ return (t[r.toLowerCase()] || t[n]) && (i ? a = i(a) : a = "*".repeat(a.length)), a;
778
+ }
779
+ var vt = "__rrweb_original__";
780
+ function Jr(e) {
781
+ var t = e.getContext("2d");
782
+ if (!t)
783
+ return !0;
784
+ for (var r = 50, n = 0; n < e.width; n += r)
785
+ for (var s = 0; s < e.height; s += r) {
786
+ var i = t.getImageData, a = vt in i ? i[vt] : i, o = new Uint32Array(a.call(t, n, s, Math.min(r, e.width - n), Math.min(r, e.height - s)).data.buffer);
787
+ if (o.some(function(c) {
788
+ return c !== 0;
789
+ }))
790
+ return !1;
791
+ }
792
+ return !0;
793
+ }
794
+ var qr = 1, Yr = new RegExp("[^a-z0-9-_:]"), Le = -2;
795
+ function qt() {
796
+ return qr++;
797
+ }
798
+ function Xr(e) {
799
+ if (e instanceof HTMLFormElement)
800
+ return "form";
801
+ var t = e.tagName.toLowerCase().trim();
802
+ return Yr.test(t) ? "div" : t;
803
+ }
804
+ function Qr(e) {
805
+ return e.cssRules ? Array.from(e.cssRules).map(function(t) {
806
+ return t.cssText || "";
807
+ }).join("") : "";
808
+ }
809
+ function $r(e) {
810
+ var t = "";
811
+ return e.indexOf("//") > -1 ? t = e.split("/").slice(0, 3).join("/") : t = e.split("/")[0], t = t.split("?")[0], t;
812
+ }
813
+ var ye, wt, en = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm, tn = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/, rn = /^(data:)([^,]*),(.*)/i;
814
+ function Pe(e, t) {
815
+ return (e || "").replace(en, function(r, n, s, i, a, o) {
816
+ var c = s || a || o, d = n || i || "";
817
+ if (!c)
818
+ return r;
819
+ if (!tn.test(c) || rn.test(c))
820
+ return "url(".concat(d).concat(c).concat(d, ")");
821
+ if (c[0] === "/")
822
+ return "url(".concat(d).concat($r(t) + c).concat(d, ")");
823
+ var l = t.split("/"), u = c.split("/");
824
+ l.pop();
825
+ for (var h = 0, f = u; h < f.length; h++) {
826
+ var p = f[h];
827
+ p !== "." && (p === ".." ? l.pop() : l.push(p));
828
+ }
829
+ return "url(".concat(d).concat(l.join("/")).concat(d, ")");
830
+ });
831
+ }
832
+ var nn = /^[^ \t\n\r\u000c]+/, sn = /^[, \t\n\r\u000c]+/;
833
+ function an(e, t) {
834
+ if (t.trim() === "")
835
+ return t;
836
+ var r = 0;
837
+ function n(d) {
838
+ var l, u = d.exec(t.substring(r));
839
+ return u ? (l = u[0], r += l.length, l) : "";
840
+ }
841
+ for (var s = []; n(sn), !(r >= t.length); ) {
842
+ var i = n(nn);
843
+ if (i.slice(-1) === ",")
844
+ i = be(e, i.substring(0, i.length - 1)), s.push(i);
845
+ else {
846
+ var a = "";
847
+ i = be(e, i);
848
+ for (var o = !1; ; ) {
849
+ var c = t.charAt(r);
850
+ if (c === "") {
851
+ s.push((i + a).trim());
852
+ break;
853
+ } else if (o)
854
+ c === ")" && (o = !1);
855
+ else if (c === ",") {
856
+ r += 1, s.push((i + a).trim());
857
+ break;
858
+ } else c === "(" && (o = !0);
859
+ a += c, r += 1;
860
+ }
861
+ }
862
+ }
863
+ return s.join(", ");
864
+ }
865
+ function be(e, t) {
866
+ if (!t || t.trim() === "")
867
+ return t;
868
+ var r = e.createElement("a");
869
+ return r.href = t, r.href;
870
+ }
871
+ function on(e) {
872
+ return !!(e.tagName === "svg" || e.ownerSVGElement);
873
+ }
874
+ function pt() {
875
+ var e = document.createElement("a");
876
+ return e.href = "", e.href;
877
+ }
878
+ function Yt(e, t, r, n) {
879
+ return r === "src" || r === "href" && n && !(t === "use" && n[0] === "#") || r === "xlink:href" && n && n[0] !== "#" || r === "background" && n && (t === "table" || t === "td" || t === "th") ? be(e, n) : r === "srcset" && n ? an(e, n) : r === "style" && n ? Pe(n, pt()) : t === "object" && r === "data" && n ? be(e, n) : n;
880
+ }
881
+ function cn(e, t, r) {
882
+ if (typeof t == "string") {
883
+ if (e.classList.contains(t))
884
+ return !0;
885
+ } else
886
+ for (var n = e.classList.length; n--; ) {
887
+ var s = e.classList[n];
888
+ if (t.test(s))
889
+ return !0;
890
+ }
891
+ return r ? e.matches(r) : !1;
892
+ }
893
+ function Ze(e, t, r) {
894
+ if (!e)
895
+ return !1;
896
+ if (e.nodeType !== e.ELEMENT_NODE)
897
+ return r ? Ze(e.parentNode, t, r) : !1;
898
+ for (var n = e.classList.length; n--; ) {
899
+ var s = e.classList[n];
900
+ if (t.test(s))
901
+ return !0;
902
+ }
903
+ return r ? Ze(e.parentNode, t, r) : !1;
904
+ }
905
+ function Xt(e, t, r) {
906
+ var n = e.nodeType === e.ELEMENT_NODE ? e : e.parentElement;
907
+ if (n === null)
908
+ return !1;
909
+ if (typeof t == "string") {
910
+ if (n.classList.contains(t) || n.closest(".".concat(t)))
911
+ return !0;
912
+ } else if (Ze(n, t, !0))
913
+ return !0;
914
+ return !!(r && (n.matches(r) || n.closest(r)));
915
+ }
916
+ function dn(e, t, r) {
917
+ var n = e.contentWindow;
918
+ if (n) {
919
+ var s = !1, i;
920
+ try {
921
+ i = n.document.readyState;
922
+ } catch {
923
+ return;
924
+ }
925
+ if (i !== "complete") {
926
+ var a = setTimeout(function() {
927
+ s || (t(), s = !0);
928
+ }, r);
929
+ e.addEventListener("load", function() {
930
+ clearTimeout(a), s = !0, t();
931
+ });
932
+ return;
933
+ }
934
+ var o = "about:blank";
935
+ if (n.location.href !== o || e.src === o || e.src === "")
936
+ return setTimeout(t, 0), e.addEventListener("load", t);
937
+ e.addEventListener("load", t);
938
+ }
939
+ }
940
+ function ln(e, t, r) {
941
+ var n = !1, s;
942
+ try {
943
+ s = e.sheet;
944
+ } catch {
945
+ return;
946
+ }
947
+ if (!s) {
948
+ var i = setTimeout(function() {
949
+ n || (t(), n = !0);
950
+ }, r);
951
+ e.addEventListener("load", function() {
952
+ clearTimeout(i), n = !0, t();
953
+ });
954
+ }
955
+ }
956
+ function un(e, t) {
957
+ var r = t.doc, n = t.mirror, s = t.blockClass, i = t.blockSelector, a = t.maskTextClass, o = t.maskTextSelector, c = t.inlineStylesheet, d = t.maskInputOptions, l = d === void 0 ? {} : d, u = t.maskTextFn, h = t.maskInputFn, f = t.dataURLOptions, p = f === void 0 ? {} : f, y = t.inlineImages, S = t.recordCanvas, C = t.keepIframeSrcFn, m = t.newlyAddedElement, g = m === void 0 ? !1 : m, k = pn(r, n);
958
+ switch (e.nodeType) {
959
+ case e.DOCUMENT_NODE:
960
+ return e.compatMode !== "CSS1Compat" ? {
961
+ type: F.Document,
962
+ childNodes: [],
963
+ compatMode: e.compatMode
964
+ } : {
965
+ type: F.Document,
966
+ childNodes: []
967
+ };
968
+ case e.DOCUMENT_TYPE_NODE:
969
+ return {
970
+ type: F.DocumentType,
971
+ name: e.name,
972
+ publicId: e.publicId,
973
+ systemId: e.systemId,
974
+ rootId: k
975
+ };
976
+ case e.ELEMENT_NODE:
977
+ return fn(e, {
978
+ doc: r,
979
+ blockClass: s,
980
+ blockSelector: i,
981
+ inlineStylesheet: c,
982
+ maskInputOptions: l,
983
+ maskInputFn: h,
984
+ dataURLOptions: p,
985
+ inlineImages: y,
986
+ recordCanvas: S,
987
+ keepIframeSrcFn: C,
988
+ newlyAddedElement: g,
989
+ rootId: k
990
+ });
991
+ case e.TEXT_NODE:
992
+ return hn(e, {
993
+ maskTextClass: a,
994
+ maskTextSelector: o,
995
+ maskTextFn: u,
996
+ rootId: k
997
+ });
998
+ case e.CDATA_SECTION_NODE:
999
+ return {
1000
+ type: F.CDATA,
1001
+ textContent: "",
1002
+ rootId: k
1003
+ };
1004
+ case e.COMMENT_NODE:
1005
+ return {
1006
+ type: F.Comment,
1007
+ textContent: e.textContent || "",
1008
+ rootId: k
1009
+ };
1010
+ default:
1011
+ return !1;
1012
+ }
1013
+ }
1014
+ function pn(e, t) {
1015
+ if (t.hasNode(e)) {
1016
+ var r = t.getId(e);
1017
+ return r === 1 ? void 0 : r;
1018
+ }
1019
+ }
1020
+ function hn(e, t) {
1021
+ var r, n = t.maskTextClass, s = t.maskTextSelector, i = t.maskTextFn, a = t.rootId, o = e.parentNode && e.parentNode.tagName, c = e.textContent, d = o === "STYLE" ? !0 : void 0, l = o === "SCRIPT" ? !0 : void 0;
1022
+ if (d && c) {
1023
+ try {
1024
+ e.nextSibling || e.previousSibling || !((r = e.parentNode.sheet) === null || r === void 0) && r.cssRules && (c = Qr(e.parentNode.sheet));
1025
+ } catch (u) {
1026
+ console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(u), e);
1027
+ }
1028
+ c = Pe(c, pt());
1029
+ }
1030
+ return l && (c = "SCRIPT_PLACEHOLDER"), !d && !l && c && Xt(e, n, s) && (c = i ? i(c) : c.replace(/[\S]/g, "*")), {
1031
+ type: F.Text,
1032
+ textContent: c || "",
1033
+ isStyle: d,
1034
+ rootId: a
1035
+ };
1036
+ }
1037
+ function fn(e, t) {
1038
+ for (var r = t.doc, n = t.blockClass, s = t.blockSelector, i = t.inlineStylesheet, a = t.maskInputOptions, o = a === void 0 ? {} : a, c = t.maskInputFn, d = t.dataURLOptions, l = d === void 0 ? {} : d, u = t.inlineImages, h = t.recordCanvas, f = t.keepIframeSrcFn, p = t.newlyAddedElement, y = p === void 0 ? !1 : p, S = t.rootId, C = cn(e, n, s), m = Xr(e), g = {}, k = e.attributes.length, U = 0; U < k; U++) {
1039
+ var x = e.attributes[U];
1040
+ g[x.name] = Yt(r, m, x.name, x.value);
1041
+ }
1042
+ if (m === "link" && i) {
1043
+ var D = Array.from(r.styleSheets).find(function(q) {
1044
+ return q.href === e.href;
1045
+ }), R = null;
1046
+ D && (R = at(D)), R && (delete g.rel, delete g.href, g._cssText = Pe(R, D.href));
1047
+ }
1048
+ if (m === "style" && e.sheet && !(e.innerText || e.textContent || "").trim().length) {
1049
+ var R = at(e.sheet);
1050
+ R && (g._cssText = Pe(R, pt()));
1051
+ }
1052
+ if (m === "input" || m === "textarea" || m === "select") {
1053
+ var H = e.value, j = e.checked;
1054
+ g.type !== "radio" && g.type !== "checkbox" && g.type !== "submit" && g.type !== "button" && H ? g.value = ut({
1055
+ type: g.type,
1056
+ tagName: m,
1057
+ value: H,
1058
+ maskInputOptions: o,
1059
+ maskInputFn: c
1060
+ }) : j && (g.checked = j);
1061
+ }
1062
+ if (m === "option" && (e.selected && !o.select ? g.selected = !0 : delete g.selected), m === "canvas" && h) {
1063
+ if (e.__context === "2d")
1064
+ Jr(e) || (g.rr_dataURL = e.toDataURL(l.type, l.quality));
1065
+ else if (!("__context" in e)) {
1066
+ var X = e.toDataURL(l.type, l.quality), Q = document.createElement("canvas");
1067
+ Q.width = e.width, Q.height = e.height;
1068
+ var $ = Q.toDataURL(l.type, l.quality);
1069
+ X !== $ && (g.rr_dataURL = X);
1070
+ }
1071
+ }
1072
+ if (m === "img" && u) {
1073
+ ye || (ye = r.createElement("canvas"), wt = ye.getContext("2d"));
1074
+ var O = e, J = O.crossOrigin;
1075
+ O.crossOrigin = "anonymous";
1076
+ var ee = function() {
1077
+ try {
1078
+ ye.width = O.naturalWidth, ye.height = O.naturalHeight, wt.drawImage(O, 0, 0), g.rr_dataURL = ye.toDataURL(l.type, l.quality);
1079
+ } catch (q) {
1080
+ console.warn("Cannot inline img src=".concat(O.currentSrc, "! Error: ").concat(q));
1081
+ }
1082
+ J ? g.crossOrigin = J : O.removeAttribute("crossorigin");
1083
+ };
1084
+ O.complete && O.naturalWidth !== 0 ? ee() : O.onload = ee;
1085
+ }
1086
+ if ((m === "audio" || m === "video") && (g.rr_mediaState = e.paused ? "paused" : "played", g.rr_mediaCurrentTime = e.currentTime), y || (e.scrollLeft && (g.rr_scrollLeft = e.scrollLeft), e.scrollTop && (g.rr_scrollTop = e.scrollTop)), C) {
1087
+ var se = e.getBoundingClientRect(), ae = se.width, V = se.height;
1088
+ g = {
1089
+ class: g.class,
1090
+ rr_width: "".concat(ae, "px"),
1091
+ rr_height: "".concat(V, "px")
1092
+ };
1093
+ }
1094
+ return m === "iframe" && !f(g.src) && (e.contentDocument || (g.rr_src = g.src), delete g.src), {
1095
+ type: F.Element,
1096
+ tagName: m,
1097
+ attributes: g,
1098
+ childNodes: [],
1099
+ isSVG: on(e) || void 0,
1100
+ needBlock: C,
1101
+ rootId: S
1102
+ };
1103
+ }
1104
+ function E(e) {
1105
+ return e === void 0 ? "" : e.toLowerCase();
1106
+ }
1107
+ function mn(e, t) {
1108
+ if (t.comment && e.type === F.Comment)
1109
+ return !0;
1110
+ if (e.type === F.Element) {
1111
+ if (t.script && (e.tagName === "script" || e.tagName === "link" && e.attributes.rel === "preload" && e.attributes.as === "script" || e.tagName === "link" && e.attributes.rel === "prefetch" && typeof e.attributes.href == "string" && e.attributes.href.endsWith(".js")))
1112
+ return !0;
1113
+ if (t.headFavicon && (e.tagName === "link" && e.attributes.rel === "shortcut icon" || e.tagName === "meta" && (E(e.attributes.name).match(/^msapplication-tile(image|color)$/) || E(e.attributes.name) === "application-name" || E(e.attributes.rel) === "icon" || E(e.attributes.rel) === "apple-touch-icon" || E(e.attributes.rel) === "shortcut icon")))
1114
+ return !0;
1115
+ if (e.tagName === "meta") {
1116
+ if (t.headMetaDescKeywords && E(e.attributes.name).match(/^description|keywords$/))
1117
+ return !0;
1118
+ if (t.headMetaSocial && (E(e.attributes.property).match(/^(og|twitter|fb):/) || E(e.attributes.name).match(/^(og|twitter):/) || E(e.attributes.name) === "pinterest"))
1119
+ return !0;
1120
+ if (t.headMetaRobots && (E(e.attributes.name) === "robots" || E(e.attributes.name) === "googlebot" || E(e.attributes.name) === "bingbot"))
1121
+ return !0;
1122
+ if (t.headMetaHttpEquiv && e.attributes["http-equiv"] !== void 0)
1123
+ return !0;
1124
+ if (t.headMetaAuthorship && (E(e.attributes.name) === "author" || E(e.attributes.name) === "generator" || E(e.attributes.name) === "framework" || E(e.attributes.name) === "publisher" || E(e.attributes.name) === "progid" || E(e.attributes.property).match(/^article:/) || E(e.attributes.property).match(/^product:/)))
1125
+ return !0;
1126
+ if (t.headMetaVerification && (E(e.attributes.name) === "google-site-verification" || E(e.attributes.name) === "yandex-verification" || E(e.attributes.name) === "csrf-token" || E(e.attributes.name) === "p:domain_verify" || E(e.attributes.name) === "verify-v1" || E(e.attributes.name) === "verification" || E(e.attributes.name) === "shopify-checkout-api-token"))
1127
+ return !0;
1128
+ }
1129
+ }
1130
+ return !1;
1131
+ }
1132
+ function ve(e, t) {
1133
+ var r = t.doc, n = t.mirror, s = t.blockClass, i = t.blockSelector, a = t.maskTextClass, o = t.maskTextSelector, c = t.skipChild, d = c === void 0 ? !1 : c, l = t.inlineStylesheet, u = l === void 0 ? !0 : l, h = t.maskInputOptions, f = h === void 0 ? {} : h, p = t.maskTextFn, y = t.maskInputFn, S = t.slimDOMOptions, C = t.dataURLOptions, m = C === void 0 ? {} : C, g = t.inlineImages, k = g === void 0 ? !1 : g, U = t.recordCanvas, x = U === void 0 ? !1 : U, D = t.onSerialize, R = t.onIframeLoad, H = t.iframeLoadTimeout, j = H === void 0 ? 5e3 : H, X = t.onStylesheetLoad, Q = t.stylesheetLoadTimeout, $ = Q === void 0 ? 5e3 : Q, O = t.keepIframeSrcFn, J = O === void 0 ? function() {
1134
+ return !1;
1135
+ } : O, ee = t.newlyAddedElement, se = ee === void 0 ? !1 : ee, ae = t.preserveWhiteSpace, V = ae === void 0 ? !0 : ae, q = un(e, {
1136
+ doc: r,
1137
+ mirror: n,
1138
+ blockClass: s,
1139
+ blockSelector: i,
1140
+ maskTextClass: a,
1141
+ maskTextSelector: o,
1142
+ inlineStylesheet: u,
1143
+ maskInputOptions: f,
1144
+ maskTextFn: p,
1145
+ maskInputFn: y,
1146
+ dataURLOptions: m,
1147
+ inlineImages: k,
1148
+ recordCanvas: x,
1149
+ keepIframeSrcFn: J,
1150
+ newlyAddedElement: se
1151
+ });
1152
+ if (!q)
1153
+ return console.warn(e, "not serialized"), null;
1154
+ var oe;
1155
+ n.hasNode(e) ? oe = n.getId(e) : mn(q, S) || !V && q.type === F.Text && !q.isStyle && !q.textContent.replace(/^\s+|\s+$/gm, "").length ? oe = Le : oe = qt();
1156
+ var N = Object.assign(q, { id: oe });
1157
+ if (n.add(e, N), oe === Le)
1158
+ return null;
1159
+ D && D(e);
1160
+ var te = !d;
1161
+ if (N.type === F.Element) {
1162
+ te = te && !N.needBlock, delete N.needBlock;
1163
+ var ie = e.shadowRoot;
1164
+ ie && Me(ie) && (N.isShadowHost = !0);
1165
+ }
1166
+ if ((N.type === F.Document || N.type === F.Element) && te) {
1167
+ S.headWhitespace && N.type === F.Element && N.tagName === "head" && (V = !1);
1168
+ for (var me = {
1169
+ doc: r,
1170
+ mirror: n,
1171
+ blockClass: s,
1172
+ blockSelector: i,
1173
+ maskTextClass: a,
1174
+ maskTextSelector: o,
1175
+ skipChild: d,
1176
+ inlineStylesheet: u,
1177
+ maskInputOptions: f,
1178
+ maskTextFn: p,
1179
+ maskInputFn: y,
1180
+ slimDOMOptions: S,
1181
+ dataURLOptions: m,
1182
+ inlineImages: k,
1183
+ recordCanvas: x,
1184
+ preserveWhiteSpace: V,
1185
+ onSerialize: D,
1186
+ onIframeLoad: R,
1187
+ iframeLoadTimeout: j,
1188
+ onStylesheetLoad: X,
1189
+ stylesheetLoadTimeout: $,
1190
+ keepIframeSrcFn: J
1191
+ }, I = 0, W = Array.from(e.childNodes); I < W.length; I++) {
1192
+ var P = W[I], T = ve(P, me);
1193
+ T && N.childNodes.push(T);
1194
+ }
1195
+ if (Pr(e) && e.shadowRoot)
1196
+ for (var Y = 0, A = Array.from(e.shadowRoot.childNodes); Y < A.length; Y++) {
1197
+ var P = A[Y], T = ve(P, me);
1198
+ T && (Me(e.shadowRoot) && (T.isShadow = !0), N.childNodes.push(T));
1199
+ }
1200
+ }
1201
+ return e.parentNode && Ne(e.parentNode) && Me(e.parentNode) && (N.isShadow = !0), N.type === F.Element && N.tagName === "iframe" && dn(e, function() {
1202
+ var Z = e.contentDocument;
1203
+ if (Z && R) {
1204
+ var Ee = ve(Z, {
1205
+ doc: Z,
1206
+ mirror: n,
1207
+ blockClass: s,
1208
+ blockSelector: i,
1209
+ maskTextClass: a,
1210
+ maskTextSelector: o,
1211
+ skipChild: !1,
1212
+ inlineStylesheet: u,
1213
+ maskInputOptions: f,
1214
+ maskTextFn: p,
1215
+ maskInputFn: y,
1216
+ slimDOMOptions: S,
1217
+ dataURLOptions: m,
1218
+ inlineImages: k,
1219
+ recordCanvas: x,
1220
+ preserveWhiteSpace: V,
1221
+ onSerialize: D,
1222
+ onIframeLoad: R,
1223
+ iframeLoadTimeout: j,
1224
+ onStylesheetLoad: X,
1225
+ stylesheetLoadTimeout: $,
1226
+ keepIframeSrcFn: J
1227
+ });
1228
+ Ee && R(e, Ee);
1229
+ }
1230
+ }, j), N.type === F.Element && N.tagName === "link" && N.attributes.rel === "stylesheet" && ln(e, function() {
1231
+ if (X) {
1232
+ var Z = ve(e, {
1233
+ doc: r,
1234
+ mirror: n,
1235
+ blockClass: s,
1236
+ blockSelector: i,
1237
+ maskTextClass: a,
1238
+ maskTextSelector: o,
1239
+ skipChild: !1,
1240
+ inlineStylesheet: u,
1241
+ maskInputOptions: f,
1242
+ maskTextFn: p,
1243
+ maskInputFn: y,
1244
+ slimDOMOptions: S,
1245
+ dataURLOptions: m,
1246
+ inlineImages: k,
1247
+ recordCanvas: x,
1248
+ preserveWhiteSpace: V,
1249
+ onSerialize: D,
1250
+ onIframeLoad: R,
1251
+ iframeLoadTimeout: j,
1252
+ onStylesheetLoad: X,
1253
+ stylesheetLoadTimeout: $,
1254
+ keepIframeSrcFn: J
1255
+ });
1256
+ Z && X(e, Z);
1257
+ }
1258
+ }, $), N;
1259
+ }
1260
+ function gn(e, t) {
1261
+ var r = t || {}, n = r.mirror, s = n === void 0 ? new Jt() : n, i = r.blockClass, a = i === void 0 ? "rr-block" : i, o = r.blockSelector, c = o === void 0 ? null : o, d = r.maskTextClass, l = d === void 0 ? "rr-mask" : d, u = r.maskTextSelector, h = u === void 0 ? null : u, f = r.inlineStylesheet, p = f === void 0 ? !0 : f, y = r.inlineImages, S = y === void 0 ? !1 : y, C = r.recordCanvas, m = C === void 0 ? !1 : C, g = r.maskAllInputs, k = g === void 0 ? !1 : g, U = r.maskTextFn, x = r.maskInputFn, D = r.slimDOM, R = D === void 0 ? !1 : D, H = r.dataURLOptions, j = r.preserveWhiteSpace, X = r.onSerialize, Q = r.onIframeLoad, $ = r.iframeLoadTimeout, O = r.onStylesheetLoad, J = r.stylesheetLoadTimeout, ee = r.keepIframeSrcFn, se = ee === void 0 ? function() {
1262
+ return !1;
1263
+ } : ee, ae = k === !0 ? {
1264
+ color: !0,
1265
+ date: !0,
1266
+ "datetime-local": !0,
1267
+ email: !0,
1268
+ month: !0,
1269
+ number: !0,
1270
+ range: !0,
1271
+ search: !0,
1272
+ tel: !0,
1273
+ text: !0,
1274
+ time: !0,
1275
+ url: !0,
1276
+ week: !0,
1277
+ textarea: !0,
1278
+ select: !0,
1279
+ password: !0
1280
+ } : k === !1 ? {
1281
+ password: !0
1282
+ } : k, V = R === !0 || R === "all" ? {
1283
+ script: !0,
1284
+ comment: !0,
1285
+ headFavicon: !0,
1286
+ headWhitespace: !0,
1287
+ headMetaDescKeywords: R === "all",
1288
+ headMetaSocial: !0,
1289
+ headMetaRobots: !0,
1290
+ headMetaHttpEquiv: !0,
1291
+ headMetaAuthorship: !0,
1292
+ headMetaVerification: !0
1293
+ } : R === !1 ? {} : R;
1294
+ return ve(e, {
1295
+ doc: e,
1296
+ mirror: s,
1297
+ blockClass: a,
1298
+ blockSelector: c,
1299
+ maskTextClass: l,
1300
+ maskTextSelector: h,
1301
+ skipChild: !1,
1302
+ inlineStylesheet: p,
1303
+ maskInputOptions: ae,
1304
+ maskTextFn: U,
1305
+ maskInputFn: x,
1306
+ slimDOMOptions: V,
1307
+ dataURLOptions: H,
1308
+ inlineImages: S,
1309
+ recordCanvas: m,
1310
+ preserveWhiteSpace: j,
1311
+ onSerialize: X,
1312
+ onIframeLoad: Q,
1313
+ iframeLoadTimeout: $,
1314
+ onStylesheetLoad: O,
1315
+ stylesheetLoadTimeout: J,
1316
+ keepIframeSrcFn: se,
1317
+ newlyAddedElement: !1
1318
+ });
1319
+ }
1320
+ function G(e, t, r = document) {
1321
+ const n = { capture: !0, passive: !0 };
1322
+ return r.addEventListener(e, t, n), () => r.removeEventListener(e, t, n);
1323
+ }
1324
+ const Se = `Please stop import mirror directly. Instead of that,\r
1325
+ now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
1326
+ or you can use record.mirror to access the mirror instance during recording.`;
1327
+ let At = {
1328
+ map: {},
1329
+ getId() {
1330
+ return console.error(Se), -1;
1331
+ },
1332
+ getNode() {
1333
+ return console.error(Se), null;
1334
+ },
1335
+ removeNodeFromMap() {
1336
+ console.error(Se);
1337
+ },
1338
+ has() {
1339
+ return console.error(Se), !1;
1340
+ },
1341
+ reset() {
1342
+ console.error(Se);
1343
+ }
1344
+ };
1345
+ typeof window < "u" && window.Proxy && window.Reflect && (At = new Proxy(At, {
1346
+ get(e, t, r) {
1347
+ return t === "map" && console.error(Se), Reflect.get(e, t, r);
1348
+ }
1349
+ }));
1350
+ function Fe(e, t, r = {}) {
1351
+ let n = null, s = 0;
1352
+ return function(...i) {
1353
+ const a = Date.now();
1354
+ !s && r.leading === !1 && (s = a);
1355
+ const o = t - (a - s), c = this;
1356
+ o <= 0 || o > t ? (n && (clearTimeout(n), n = null), s = a, e.apply(c, i)) : !n && r.trailing !== !1 && (n = setTimeout(() => {
1357
+ s = r.leading === !1 ? 0 : Date.now(), n = null, e.apply(c, i);
1358
+ }, o));
1359
+ };
1360
+ }
1361
+ function qe(e, t, r, n, s = window) {
1362
+ const i = s.Object.getOwnPropertyDescriptor(e, t);
1363
+ return s.Object.defineProperty(e, t, n ? r : {
1364
+ set(a) {
1365
+ setTimeout(() => {
1366
+ r.set.call(this, a);
1367
+ }, 0), i && i.set && i.set.call(this, a);
1368
+ }
1369
+ }), () => qe(e, t, i || {}, !0);
1370
+ }
1371
+ function he(e, t, r) {
1372
+ try {
1373
+ if (!(t in e))
1374
+ return () => {
1375
+ };
1376
+ const n = e[t], s = r(n);
1377
+ return typeof s == "function" && (s.prototype = s.prototype || {}, Object.defineProperties(s, {
1378
+ __rrweb_original__: {
1379
+ enumerable: !1,
1380
+ value: n
1381
+ }
1382
+ })), e[t] = s, () => {
1383
+ e[t] = n;
1384
+ };
1385
+ } catch {
1386
+ return () => {
1387
+ };
1388
+ }
1389
+ }
1390
+ function Qt() {
1391
+ return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
1392
+ }
1393
+ function $t() {
1394
+ return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
1395
+ }
1396
+ function K(e, t, r, n) {
1397
+ if (!e)
1398
+ return !1;
1399
+ const s = e.nodeType === e.ELEMENT_NODE ? e : e.parentElement;
1400
+ if (!s)
1401
+ return !1;
1402
+ if (typeof t == "string") {
1403
+ if (s.classList.contains(t) || n && s.closest("." + t) !== null)
1404
+ return !0;
1405
+ } else if (Ze(s, t, n))
1406
+ return !0;
1407
+ return !!(r && (e.matches(r) || n && s.closest(r) !== null));
1408
+ }
1409
+ function yn(e, t) {
1410
+ return t.getId(e) !== -1;
1411
+ }
1412
+ function Qe(e, t) {
1413
+ return t.getId(e) === Le;
1414
+ }
1415
+ function er(e, t) {
1416
+ if (Ne(e))
1417
+ return !1;
1418
+ const r = t.getId(e);
1419
+ return t.has(r) ? e.parentNode && e.parentNode.nodeType === e.DOCUMENT_NODE ? !1 : e.parentNode ? er(e.parentNode, t) : !0 : !0;
1420
+ }
1421
+ function tr(e) {
1422
+ return !!e.changedTouches;
1423
+ }
1424
+ function In(e = window) {
1425
+ "NodeList" in e && !e.NodeList.prototype.forEach && (e.NodeList.prototype.forEach = Array.prototype.forEach), "DOMTokenList" in e && !e.DOMTokenList.prototype.forEach && (e.DOMTokenList.prototype.forEach = Array.prototype.forEach), Node.prototype.contains || (Node.prototype.contains = (...t) => {
1426
+ let r = t[0];
1427
+ if (!(0 in t))
1428
+ throw new TypeError("1 argument is required");
1429
+ do
1430
+ if (this === r)
1431
+ return !0;
1432
+ while (r = r && r.parentNode);
1433
+ return !1;
1434
+ });
1435
+ }
1436
+ function rr(e, t) {
1437
+ return !!(e.nodeName === "IFRAME" && t.getMeta(e));
1438
+ }
1439
+ function nr(e, t) {
1440
+ return !!(e.nodeName === "LINK" && e.nodeType === e.ELEMENT_NODE && e.getAttribute && e.getAttribute("rel") === "stylesheet" && t.getMeta(e));
1441
+ }
1442
+ function sr(e) {
1443
+ return !!(e != null && e.shadowRoot);
1444
+ }
1445
+ class Cn {
1446
+ constructor() {
1447
+ this.id = 1, this.styleIDMap = /* @__PURE__ */ new WeakMap(), this.idStyleMap = /* @__PURE__ */ new Map();
1448
+ }
1449
+ getId(t) {
1450
+ var r;
1451
+ return (r = this.styleIDMap.get(t)) !== null && r !== void 0 ? r : -1;
1452
+ }
1453
+ has(t) {
1454
+ return this.styleIDMap.has(t);
1455
+ }
1456
+ add(t, r) {
1457
+ if (this.has(t))
1458
+ return this.getId(t);
1459
+ let n;
1460
+ return r === void 0 ? n = this.id++ : n = r, this.styleIDMap.set(t, n), this.idStyleMap.set(n, t), n;
1461
+ }
1462
+ getStyle(t) {
1463
+ return this.idStyleMap.get(t) || null;
1464
+ }
1465
+ reset() {
1466
+ this.styleIDMap = /* @__PURE__ */ new WeakMap(), this.idStyleMap = /* @__PURE__ */ new Map(), this.id = 1;
1467
+ }
1468
+ generateId() {
1469
+ return this.id++;
1470
+ }
1471
+ }
1472
+ var v = /* @__PURE__ */ ((e) => (e[e.DomContentLoaded = 0] = "DomContentLoaded", e[e.Load = 1] = "Load", e[e.FullSnapshot = 2] = "FullSnapshot", e[e.IncrementalSnapshot = 3] = "IncrementalSnapshot", e[e.Meta = 4] = "Meta", e[e.Custom = 5] = "Custom", e[e.Plugin = 6] = "Plugin", e))(v || {}), b = /* @__PURE__ */ ((e) => (e[e.Mutation = 0] = "Mutation", e[e.MouseMove = 1] = "MouseMove", e[e.MouseInteraction = 2] = "MouseInteraction", e[e.Scroll = 3] = "Scroll", e[e.ViewportResize = 4] = "ViewportResize", e[e.Input = 5] = "Input", e[e.TouchMove = 6] = "TouchMove", e[e.MediaInteraction = 7] = "MediaInteraction", e[e.StyleSheetRule = 8] = "StyleSheetRule", e[e.CanvasMutation = 9] = "CanvasMutation", e[e.Font = 10] = "Font", e[e.Log = 11] = "Log", e[e.Drag = 12] = "Drag", e[e.StyleDeclaration = 13] = "StyleDeclaration", e[e.Selection = 14] = "Selection", e[e.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", e))(b || {}), ot = /* @__PURE__ */ ((e) => (e[e.MouseUp = 0] = "MouseUp", e[e.MouseDown = 1] = "MouseDown", e[e.Click = 2] = "Click", e[e.ContextMenu = 3] = "ContextMenu", e[e.DblClick = 4] = "DblClick", e[e.Focus = 5] = "Focus", e[e.Blur = 6] = "Blur", e[e.TouchStart = 7] = "TouchStart", e[e.TouchMove_Departed = 8] = "TouchMove_Departed", e[e.TouchEnd = 9] = "TouchEnd", e[e.TouchCancel = 10] = "TouchCancel", e))(ot || {}), ke = /* @__PURE__ */ ((e) => (e[e["2D"] = 0] = "2D", e[e.WebGL = 1] = "WebGL", e[e.WebGL2 = 2] = "WebGL2", e))(ke || {});
1473
+ function kt(e) {
1474
+ return "__ln" in e;
1475
+ }
1476
+ class Sn {
1477
+ constructor() {
1478
+ this.length = 0, this.head = null;
1479
+ }
1480
+ get(t) {
1481
+ if (t >= this.length)
1482
+ throw new Error("Position outside of list range");
1483
+ let r = this.head;
1484
+ for (let n = 0; n < t; n++)
1485
+ r = (r == null ? void 0 : r.next) || null;
1486
+ return r;
1487
+ }
1488
+ addNode(t) {
1489
+ const r = {
1490
+ value: t,
1491
+ previous: null,
1492
+ next: null
1493
+ };
1494
+ if (t.__ln = r, t.previousSibling && kt(t.previousSibling)) {
1495
+ const n = t.previousSibling.__ln.next;
1496
+ r.next = n, r.previous = t.previousSibling.__ln, t.previousSibling.__ln.next = r, n && (n.previous = r);
1497
+ } else if (t.nextSibling && kt(t.nextSibling) && t.nextSibling.__ln.previous) {
1498
+ const n = t.nextSibling.__ln.previous;
1499
+ r.previous = n, r.next = t.nextSibling.__ln, t.nextSibling.__ln.previous = r, n && (n.next = r);
1500
+ } else
1501
+ this.head && (this.head.previous = r), r.next = this.head, this.head = r;
1502
+ this.length++;
1503
+ }
1504
+ removeNode(t) {
1505
+ const r = t.__ln;
1506
+ this.head && (r.previous ? (r.previous.next = r.next, r.next && (r.next.previous = r.previous)) : (this.head = r.next, this.head && (this.head.previous = null)), t.__ln && delete t.__ln, this.length--);
1507
+ }
1508
+ }
1509
+ const Rt = (e, t) => `${e}@${t}`;
1510
+ class bn {
1511
+ constructor() {
1512
+ this.frozen = !1, this.locked = !1, this.texts = [], this.attributes = [], this.removes = [], this.mapRemoves = [], this.movedMap = {}, this.addedSet = /* @__PURE__ */ new Set(), this.movedSet = /* @__PURE__ */ new Set(), this.droppedSet = /* @__PURE__ */ new Set(), this.processMutations = (t) => {
1513
+ t.forEach(this.processMutation), this.emit();
1514
+ }, this.emit = () => {
1515
+ if (this.frozen || this.locked)
1516
+ return;
1517
+ const t = [], r = new Sn(), n = (o) => {
1518
+ let c = o, d = Le;
1519
+ for (; d === Le; )
1520
+ c = c && c.nextSibling, d = c && this.mirror.getId(c);
1521
+ return d;
1522
+ }, s = (o) => {
1523
+ var c, d, l, u;
1524
+ let h = null;
1525
+ ((d = (c = o.getRootNode) === null || c === void 0 ? void 0 : c.call(o)) === null || d === void 0 ? void 0 : d.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && o.getRootNode().host && (h = o.getRootNode().host);
1526
+ let f = h;
1527
+ for (; ((u = (l = f == null ? void 0 : f.getRootNode) === null || l === void 0 ? void 0 : l.call(f)) === null || u === void 0 ? void 0 : u.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && f.getRootNode().host; )
1528
+ f = f.getRootNode().host;
1529
+ const p = !this.doc.contains(o) && (!f || !this.doc.contains(f));
1530
+ if (!o.parentNode || p)
1531
+ return;
1532
+ const y = Ne(o.parentNode) ? this.mirror.getId(h) : this.mirror.getId(o.parentNode), S = n(o);
1533
+ if (y === -1 || S === -1)
1534
+ return r.addNode(o);
1535
+ const C = ve(o, {
1536
+ doc: this.doc,
1537
+ mirror: this.mirror,
1538
+ blockClass: this.blockClass,
1539
+ blockSelector: this.blockSelector,
1540
+ maskTextClass: this.maskTextClass,
1541
+ maskTextSelector: this.maskTextSelector,
1542
+ skipChild: !0,
1543
+ newlyAddedElement: !0,
1544
+ inlineStylesheet: this.inlineStylesheet,
1545
+ maskInputOptions: this.maskInputOptions,
1546
+ maskTextFn: this.maskTextFn,
1547
+ maskInputFn: this.maskInputFn,
1548
+ slimDOMOptions: this.slimDOMOptions,
1549
+ dataURLOptions: this.dataURLOptions,
1550
+ recordCanvas: this.recordCanvas,
1551
+ inlineImages: this.inlineImages,
1552
+ onSerialize: (m) => {
1553
+ rr(m, this.mirror) && this.iframeManager.addIframe(m), nr(m, this.mirror) && this.stylesheetManager.trackLinkElement(m), sr(o) && this.shadowDomManager.addShadowRoot(o.shadowRoot, this.doc);
1554
+ },
1555
+ onIframeLoad: (m, g) => {
1556
+ this.iframeManager.attachIframe(m, g), this.shadowDomManager.observeAttachShadow(m);
1557
+ },
1558
+ onStylesheetLoad: (m, g) => {
1559
+ this.stylesheetManager.attachLinkElement(m, g);
1560
+ }
1561
+ });
1562
+ C && t.push({
1563
+ parentId: y,
1564
+ nextId: S,
1565
+ node: C
1566
+ });
1567
+ };
1568
+ for (; this.mapRemoves.length; )
1569
+ this.mirror.removeNodeFromMap(this.mapRemoves.shift());
1570
+ for (const o of Array.from(this.movedSet.values()))
1571
+ Et(this.removes, o, this.mirror) && !this.movedSet.has(o.parentNode) || s(o);
1572
+ for (const o of Array.from(this.addedSet.values()))
1573
+ !Tt(this.droppedSet, o) && !Et(this.removes, o, this.mirror) || Tt(this.movedSet, o) ? s(o) : this.droppedSet.add(o);
1574
+ let i = null;
1575
+ for (; r.length; ) {
1576
+ let o = null;
1577
+ if (i) {
1578
+ const c = this.mirror.getId(i.value.parentNode), d = n(i.value);
1579
+ c !== -1 && d !== -1 && (o = i);
1580
+ }
1581
+ if (!o)
1582
+ for (let c = r.length - 1; c >= 0; c--) {
1583
+ const d = r.get(c);
1584
+ if (d) {
1585
+ const l = this.mirror.getId(d.value.parentNode);
1586
+ if (n(d.value) === -1)
1587
+ continue;
1588
+ if (l !== -1) {
1589
+ o = d;
1590
+ break;
1591
+ } else {
1592
+ const h = d.value;
1593
+ if (h.parentNode && h.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
1594
+ const f = h.parentNode.host;
1595
+ if (this.mirror.getId(f) !== -1) {
1596
+ o = d;
1597
+ break;
1598
+ }
1599
+ }
1600
+ }
1601
+ }
1602
+ }
1603
+ if (!o) {
1604
+ for (; r.head; )
1605
+ r.removeNode(r.head.value);
1606
+ break;
1607
+ }
1608
+ i = o.previous, r.removeNode(o.value), s(o.value);
1609
+ }
1610
+ const a = {
1611
+ texts: this.texts.map((o) => ({
1612
+ id: this.mirror.getId(o.node),
1613
+ value: o.value
1614
+ })).filter((o) => this.mirror.has(o.id)),
1615
+ attributes: this.attributes.map((o) => ({
1616
+ id: this.mirror.getId(o.node),
1617
+ attributes: o.attributes
1618
+ })).filter((o) => this.mirror.has(o.id)),
1619
+ removes: this.removes,
1620
+ adds: t
1621
+ };
1622
+ !a.texts.length && !a.attributes.length && !a.removes.length && !a.adds.length || (this.texts = [], this.attributes = [], this.removes = [], this.addedSet = /* @__PURE__ */ new Set(), this.movedSet = /* @__PURE__ */ new Set(), this.droppedSet = /* @__PURE__ */ new Set(), this.movedMap = {}, this.mutationCb(a));
1623
+ }, this.processMutation = (t) => {
1624
+ if (!Qe(t.target, this.mirror))
1625
+ switch (t.type) {
1626
+ case "characterData": {
1627
+ const r = t.target.textContent;
1628
+ !K(t.target, this.blockClass, this.blockSelector, !1) && r !== t.oldValue && this.texts.push({
1629
+ value: Xt(t.target, this.maskTextClass, this.maskTextSelector) && r ? this.maskTextFn ? this.maskTextFn(r) : r.replace(/[\S]/g, "*") : r,
1630
+ node: t.target
1631
+ });
1632
+ break;
1633
+ }
1634
+ case "attributes": {
1635
+ const r = t.target;
1636
+ let n = t.target.getAttribute(t.attributeName);
1637
+ if (t.attributeName === "value" && (n = ut({
1638
+ maskInputOptions: this.maskInputOptions,
1639
+ tagName: t.target.tagName,
1640
+ type: t.target.getAttribute("type"),
1641
+ value: n,
1642
+ maskInputFn: this.maskInputFn
1643
+ })), K(t.target, this.blockClass, this.blockSelector, !1) || n === t.oldValue)
1644
+ return;
1645
+ let s = this.attributes.find((i) => i.node === t.target);
1646
+ if (r.tagName === "IFRAME" && t.attributeName === "src" && !this.keepIframeSrcFn(n))
1647
+ if (!r.contentDocument)
1648
+ t.attributeName = "rr_src";
1649
+ else
1650
+ return;
1651
+ if (s || (s = {
1652
+ node: t.target,
1653
+ attributes: {}
1654
+ }, this.attributes.push(s)), t.attributeName === "style") {
1655
+ const i = this.doc.createElement("span");
1656
+ t.oldValue && i.setAttribute("style", t.oldValue), (s.attributes.style === void 0 || s.attributes.style === null) && (s.attributes.style = {});
1657
+ const a = s.attributes.style;
1658
+ for (const o of Array.from(r.style)) {
1659
+ const c = r.style.getPropertyValue(o), d = r.style.getPropertyPriority(o);
1660
+ (c !== i.style.getPropertyValue(o) || d !== i.style.getPropertyPriority(o)) && (d === "" ? a[o] = c : a[o] = [c, d]);
1661
+ }
1662
+ for (const o of Array.from(i.style))
1663
+ r.style.getPropertyValue(o) === "" && (a[o] = !1);
1664
+ } else
1665
+ s.attributes[t.attributeName] = Yt(this.doc, r.tagName, t.attributeName, n);
1666
+ break;
1667
+ }
1668
+ case "childList": {
1669
+ if (K(t.target, this.blockClass, this.blockSelector, !0))
1670
+ return;
1671
+ t.addedNodes.forEach((r) => this.genAdds(r, t.target)), t.removedNodes.forEach((r) => {
1672
+ const n = this.mirror.getId(r), s = Ne(t.target) ? this.mirror.getId(t.target.host) : this.mirror.getId(t.target);
1673
+ K(t.target, this.blockClass, this.blockSelector, !1) || Qe(r, this.mirror) || !yn(r, this.mirror) || (this.addedSet.has(r) ? (ct(this.addedSet, r), this.droppedSet.add(r)) : this.addedSet.has(t.target) && n === -1 || er(t.target, this.mirror) || (this.movedSet.has(r) && this.movedMap[Rt(n, s)] ? ct(this.movedSet, r) : this.removes.push({
1674
+ parentId: s,
1675
+ id: n,
1676
+ isShadow: Ne(t.target) && Me(t.target) ? !0 : void 0
1677
+ })), this.mapRemoves.push(r));
1678
+ });
1679
+ break;
1680
+ }
1681
+ }
1682
+ }, this.genAdds = (t, r) => {
1683
+ if (this.mirror.hasNode(t)) {
1684
+ if (Qe(t, this.mirror))
1685
+ return;
1686
+ this.movedSet.add(t);
1687
+ let n = null;
1688
+ r && this.mirror.hasNode(r) && (n = this.mirror.getId(r)), n && n !== -1 && (this.movedMap[Rt(this.mirror.getId(t), n)] = !0);
1689
+ } else
1690
+ this.addedSet.add(t), this.droppedSet.delete(t);
1691
+ K(t, this.blockClass, this.blockSelector, !1) || t.childNodes.forEach((n) => this.genAdds(n));
1692
+ };
1693
+ }
1694
+ init(t) {
1695
+ [
1696
+ "mutationCb",
1697
+ "blockClass",
1698
+ "blockSelector",
1699
+ "maskTextClass",
1700
+ "maskTextSelector",
1701
+ "inlineStylesheet",
1702
+ "maskInputOptions",
1703
+ "maskTextFn",
1704
+ "maskInputFn",
1705
+ "keepIframeSrcFn",
1706
+ "recordCanvas",
1707
+ "inlineImages",
1708
+ "slimDOMOptions",
1709
+ "dataURLOptions",
1710
+ "doc",
1711
+ "mirror",
1712
+ "iframeManager",
1713
+ "stylesheetManager",
1714
+ "shadowDomManager",
1715
+ "canvasManager"
1716
+ ].forEach((r) => {
1717
+ this[r] = t[r];
1718
+ });
1719
+ }
1720
+ freeze() {
1721
+ this.frozen = !0, this.canvasManager.freeze();
1722
+ }
1723
+ unfreeze() {
1724
+ this.frozen = !1, this.canvasManager.unfreeze(), this.emit();
1725
+ }
1726
+ isFrozen() {
1727
+ return this.frozen;
1728
+ }
1729
+ lock() {
1730
+ this.locked = !0, this.canvasManager.lock();
1731
+ }
1732
+ unlock() {
1733
+ this.locked = !1, this.canvasManager.unlock(), this.emit();
1734
+ }
1735
+ reset() {
1736
+ this.shadowDomManager.reset(), this.canvasManager.reset();
1737
+ }
1738
+ }
1739
+ function ct(e, t) {
1740
+ e.delete(t), t.childNodes.forEach((r) => ct(e, r));
1741
+ }
1742
+ function Et(e, t, r) {
1743
+ return e.length === 0 ? !1 : ir(e, t, r);
1744
+ }
1745
+ function ir(e, t, r) {
1746
+ const { parentNode: n } = t;
1747
+ if (!n)
1748
+ return !1;
1749
+ const s = r.getId(n);
1750
+ return e.some((i) => i.id === s) ? !0 : ir(e, n, r);
1751
+ }
1752
+ function Tt(e, t) {
1753
+ return e.size === 0 ? !1 : ar(e, t);
1754
+ }
1755
+ function ar(e, t) {
1756
+ const { parentNode: r } = t;
1757
+ return r ? e.has(r) ? !0 : ar(e, r) : !1;
1758
+ }
1759
+ const ue = [], or = typeof CSSGroupingRule < "u", cr = typeof CSSMediaRule < "u", dr = typeof CSSSupportsRule < "u", lr = typeof CSSConditionRule < "u";
1760
+ function xe(e) {
1761
+ try {
1762
+ if ("composedPath" in e) {
1763
+ const t = e.composedPath();
1764
+ if (t.length)
1765
+ return t[0];
1766
+ } else if ("path" in e && e.path.length)
1767
+ return e.path[0];
1768
+ return e.target;
1769
+ } catch {
1770
+ return e.target;
1771
+ }
1772
+ }
1773
+ function ur(e, t) {
1774
+ var r, n;
1775
+ const s = new bn();
1776
+ ue.push(s), s.init(e);
1777
+ let i = window.MutationObserver || window.__rrMutationObserver;
1778
+ const a = (n = (r = window == null ? void 0 : window.Zone) === null || r === void 0 ? void 0 : r.__symbol__) === null || n === void 0 ? void 0 : n.call(r, "MutationObserver");
1779
+ a && window[a] && (i = window[a]);
1780
+ const o = new i(s.processMutations.bind(s));
1781
+ return o.observe(t, {
1782
+ attributes: !0,
1783
+ attributeOldValue: !0,
1784
+ characterData: !0,
1785
+ characterDataOldValue: !0,
1786
+ childList: !0,
1787
+ subtree: !0
1788
+ }), o;
1789
+ }
1790
+ function vn({ mousemoveCb: e, sampling: t, doc: r, mirror: n }) {
1791
+ if (t.mousemove === !1)
1792
+ return () => {
1793
+ };
1794
+ const s = typeof t.mousemove == "number" ? t.mousemove : 50, i = typeof t.mousemoveCallback == "number" ? t.mousemoveCallback : 500;
1795
+ let a = [], o;
1796
+ const c = Fe((u) => {
1797
+ const h = Date.now() - o;
1798
+ e(a.map((f) => (f.timeOffset -= h, f)), u), a = [], o = null;
1799
+ }, i), d = Fe((u) => {
1800
+ const h = xe(u), { clientX: f, clientY: p } = tr(u) ? u.changedTouches[0] : u;
1801
+ o || (o = Date.now()), a.push({
1802
+ x: f,
1803
+ y: p,
1804
+ id: n.getId(h),
1805
+ timeOffset: Date.now() - o
1806
+ }), c(typeof DragEvent < "u" && u instanceof DragEvent ? b.Drag : u instanceof MouseEvent ? b.MouseMove : b.TouchMove);
1807
+ }, s, {
1808
+ trailing: !1
1809
+ }), l = [
1810
+ G("mousemove", d, r),
1811
+ G("touchmove", d, r),
1812
+ G("drag", d, r)
1813
+ ];
1814
+ return () => {
1815
+ l.forEach((u) => u());
1816
+ };
1817
+ }
1818
+ function wn({ mouseInteractionCb: e, doc: t, mirror: r, blockClass: n, blockSelector: s, sampling: i }) {
1819
+ if (i.mouseInteraction === !1)
1820
+ return () => {
1821
+ };
1822
+ const a = i.mouseInteraction === !0 || i.mouseInteraction === void 0 ? {} : i.mouseInteraction, o = [], c = (d) => (l) => {
1823
+ const u = xe(l);
1824
+ if (K(u, n, s, !0))
1825
+ return;
1826
+ const h = tr(l) ? l.changedTouches[0] : l;
1827
+ if (!h)
1828
+ return;
1829
+ const f = r.getId(u), { clientX: p, clientY: y } = h;
1830
+ e({
1831
+ type: ot[d],
1832
+ id: f,
1833
+ x: p,
1834
+ y
1835
+ });
1836
+ };
1837
+ return Object.keys(ot).filter((d) => Number.isNaN(Number(d)) && !d.endsWith("_Departed") && a[d] !== !1).forEach((d) => {
1838
+ const l = d.toLowerCase(), u = c(d);
1839
+ o.push(G(l, u, t));
1840
+ }), () => {
1841
+ o.forEach((d) => d());
1842
+ };
1843
+ }
1844
+ function pr({ scrollCb: e, doc: t, mirror: r, blockClass: n, blockSelector: s, sampling: i }) {
1845
+ const a = Fe((o) => {
1846
+ const c = xe(o);
1847
+ if (!c || K(c, n, s, !0))
1848
+ return;
1849
+ const d = r.getId(c);
1850
+ if (c === t) {
1851
+ const l = t.scrollingElement || t.documentElement;
1852
+ e({
1853
+ id: d,
1854
+ x: l.scrollLeft,
1855
+ y: l.scrollTop
1856
+ });
1857
+ } else
1858
+ e({
1859
+ id: d,
1860
+ x: c.scrollLeft,
1861
+ y: c.scrollTop
1862
+ });
1863
+ }, i.scroll || 100);
1864
+ return G("scroll", a, t);
1865
+ }
1866
+ function An({ viewportResizeCb: e }) {
1867
+ let t = -1, r = -1;
1868
+ const n = Fe(() => {
1869
+ const s = Qt(), i = $t();
1870
+ (t !== s || r !== i) && (e({
1871
+ width: Number(i),
1872
+ height: Number(s)
1873
+ }), t = s, r = i);
1874
+ }, 200);
1875
+ return G("resize", n, window);
1876
+ }
1877
+ function _t(e, t) {
1878
+ const r = Object.assign({}, e);
1879
+ return t || delete r.userTriggered, r;
1880
+ }
1881
+ const kn = ["INPUT", "TEXTAREA", "SELECT"], Nt = /* @__PURE__ */ new WeakMap();
1882
+ function Rn({ inputCb: e, doc: t, mirror: r, blockClass: n, blockSelector: s, ignoreClass: i, maskInputOptions: a, maskInputFn: o, sampling: c, userTriggeredOnInput: d }) {
1883
+ function l(C) {
1884
+ let m = xe(C);
1885
+ const g = C.isTrusted;
1886
+ if (m && m.tagName === "OPTION" && (m = m.parentElement), !m || !m.tagName || kn.indexOf(m.tagName) < 0 || K(m, n, s, !0))
1887
+ return;
1888
+ const k = m.type;
1889
+ if (m.classList.contains(i))
1890
+ return;
1891
+ let U = m.value, x = !1;
1892
+ k === "radio" || k === "checkbox" ? x = m.checked : (a[m.tagName.toLowerCase()] || a[k]) && (U = ut({
1893
+ maskInputOptions: a,
1894
+ tagName: m.tagName,
1895
+ type: k,
1896
+ value: U,
1897
+ maskInputFn: o
1898
+ })), u(m, _t({ text: U, isChecked: x, userTriggered: g }, d));
1899
+ const D = m.name;
1900
+ k === "radio" && D && x && t.querySelectorAll(`input[type="radio"][name="${D}"]`).forEach((R) => {
1901
+ R !== m && u(R, _t({
1902
+ text: R.value,
1903
+ isChecked: !x,
1904
+ userTriggered: !1
1905
+ }, d));
1906
+ });
1907
+ }
1908
+ function u(C, m) {
1909
+ const g = Nt.get(C);
1910
+ if (!g || g.text !== m.text || g.isChecked !== m.isChecked) {
1911
+ Nt.set(C, m);
1912
+ const k = r.getId(C);
1913
+ e(Object.assign(Object.assign({}, m), { id: k }));
1914
+ }
1915
+ }
1916
+ const f = (c.input === "last" ? ["change"] : ["input", "change"]).map((C) => G(C, l, t)), p = t.defaultView;
1917
+ if (!p)
1918
+ return () => {
1919
+ f.forEach((C) => C());
1920
+ };
1921
+ const y = p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype, "value"), S = [
1922
+ [p.HTMLInputElement.prototype, "value"],
1923
+ [p.HTMLInputElement.prototype, "checked"],
1924
+ [p.HTMLSelectElement.prototype, "value"],
1925
+ [p.HTMLTextAreaElement.prototype, "value"],
1926
+ [p.HTMLSelectElement.prototype, "selectedIndex"],
1927
+ [p.HTMLOptionElement.prototype, "selected"]
1928
+ ];
1929
+ return y && y.set && f.push(...S.map((C) => qe(C[0], C[1], {
1930
+ set() {
1931
+ l({ target: this });
1932
+ }
1933
+ }, !1, p))), () => {
1934
+ f.forEach((C) => C());
1935
+ };
1936
+ }
1937
+ function He(e) {
1938
+ const t = [];
1939
+ function r(n, s) {
1940
+ if (or && n.parentRule instanceof CSSGroupingRule || cr && n.parentRule instanceof CSSMediaRule || dr && n.parentRule instanceof CSSSupportsRule || lr && n.parentRule instanceof CSSConditionRule) {
1941
+ const a = Array.from(n.parentRule.cssRules).indexOf(n);
1942
+ s.unshift(a);
1943
+ } else if (n.parentStyleSheet) {
1944
+ const a = Array.from(n.parentStyleSheet.cssRules).indexOf(n);
1945
+ s.unshift(a);
1946
+ }
1947
+ return s;
1948
+ }
1949
+ return r(e, t);
1950
+ }
1951
+ function ce(e, t, r) {
1952
+ let n, s;
1953
+ return e ? (e.ownerNode ? n = t.getId(e.ownerNode) : s = r.getId(e), {
1954
+ styleId: s,
1955
+ id: n
1956
+ }) : {};
1957
+ }
1958
+ function En({ styleSheetRuleCb: e, mirror: t, stylesheetManager: r }, { win: n }) {
1959
+ const s = n.CSSStyleSheet.prototype.insertRule;
1960
+ n.CSSStyleSheet.prototype.insertRule = function(l, u) {
1961
+ const { id: h, styleId: f } = ce(this, t, r.styleMirror);
1962
+ return (h && h !== -1 || f && f !== -1) && e({
1963
+ id: h,
1964
+ styleId: f,
1965
+ adds: [{ rule: l, index: u }]
1966
+ }), s.apply(this, [l, u]);
1967
+ };
1968
+ const i = n.CSSStyleSheet.prototype.deleteRule;
1969
+ n.CSSStyleSheet.prototype.deleteRule = function(l) {
1970
+ const { id: u, styleId: h } = ce(this, t, r.styleMirror);
1971
+ return (u && u !== -1 || h && h !== -1) && e({
1972
+ id: u,
1973
+ styleId: h,
1974
+ removes: [{ index: l }]
1975
+ }), i.apply(this, [l]);
1976
+ };
1977
+ let a;
1978
+ n.CSSStyleSheet.prototype.replace && (a = n.CSSStyleSheet.prototype.replace, n.CSSStyleSheet.prototype.replace = function(l) {
1979
+ const { id: u, styleId: h } = ce(this, t, r.styleMirror);
1980
+ return (u && u !== -1 || h && h !== -1) && e({
1981
+ id: u,
1982
+ styleId: h,
1983
+ replace: l
1984
+ }), a.apply(this, [l]);
1985
+ });
1986
+ let o;
1987
+ n.CSSStyleSheet.prototype.replaceSync && (o = n.CSSStyleSheet.prototype.replaceSync, n.CSSStyleSheet.prototype.replaceSync = function(l) {
1988
+ const { id: u, styleId: h } = ce(this, t, r.styleMirror);
1989
+ return (u && u !== -1 || h && h !== -1) && e({
1990
+ id: u,
1991
+ styleId: h,
1992
+ replaceSync: l
1993
+ }), o.apply(this, [l]);
1994
+ });
1995
+ const c = {};
1996
+ or ? c.CSSGroupingRule = n.CSSGroupingRule : (cr && (c.CSSMediaRule = n.CSSMediaRule), lr && (c.CSSConditionRule = n.CSSConditionRule), dr && (c.CSSSupportsRule = n.CSSSupportsRule));
1997
+ const d = {};
1998
+ return Object.entries(c).forEach(([l, u]) => {
1999
+ d[l] = {
2000
+ insertRule: u.prototype.insertRule,
2001
+ deleteRule: u.prototype.deleteRule
2002
+ }, u.prototype.insertRule = function(h, f) {
2003
+ const { id: p, styleId: y } = ce(this.parentStyleSheet, t, r.styleMirror);
2004
+ return (p && p !== -1 || y && y !== -1) && e({
2005
+ id: p,
2006
+ styleId: y,
2007
+ adds: [
2008
+ {
2009
+ rule: h,
2010
+ index: [
2011
+ ...He(this),
2012
+ f || 0
2013
+ ]
2014
+ }
2015
+ ]
2016
+ }), d[l].insertRule.apply(this, [h, f]);
2017
+ }, u.prototype.deleteRule = function(h) {
2018
+ const { id: f, styleId: p } = ce(this.parentStyleSheet, t, r.styleMirror);
2019
+ return (f && f !== -1 || p && p !== -1) && e({
2020
+ id: f,
2021
+ styleId: p,
2022
+ removes: [
2023
+ { index: [...He(this), h] }
2024
+ ]
2025
+ }), d[l].deleteRule.apply(this, [h]);
2026
+ };
2027
+ }), () => {
2028
+ n.CSSStyleSheet.prototype.insertRule = s, n.CSSStyleSheet.prototype.deleteRule = i, a && (n.CSSStyleSheet.prototype.replace = a), o && (n.CSSStyleSheet.prototype.replaceSync = o), Object.entries(c).forEach(([l, u]) => {
2029
+ u.prototype.insertRule = d[l].insertRule, u.prototype.deleteRule = d[l].deleteRule;
2030
+ });
2031
+ };
2032
+ }
2033
+ function hr({ mirror: e, stylesheetManager: t }, r) {
2034
+ var n, s, i;
2035
+ let a = null;
2036
+ r.nodeName === "#document" ? a = e.getId(r) : a = e.getId(r.host);
2037
+ const o = r.nodeName === "#document" ? (n = r.defaultView) === null || n === void 0 ? void 0 : n.Document : (i = (s = r.ownerDocument) === null || s === void 0 ? void 0 : s.defaultView) === null || i === void 0 ? void 0 : i.ShadowRoot, c = Object.getOwnPropertyDescriptor(o == null ? void 0 : o.prototype, "adoptedStyleSheets");
2038
+ return a === null || a === -1 || !o || !c ? () => {
2039
+ } : (Object.defineProperty(r, "adoptedStyleSheets", {
2040
+ configurable: c.configurable,
2041
+ enumerable: c.enumerable,
2042
+ get() {
2043
+ var d;
2044
+ return (d = c.get) === null || d === void 0 ? void 0 : d.call(this);
2045
+ },
2046
+ set(d) {
2047
+ var l;
2048
+ const u = (l = c.set) === null || l === void 0 ? void 0 : l.call(this, d);
2049
+ if (a !== null && a !== -1)
2050
+ try {
2051
+ t.adoptStyleSheets(d, a);
2052
+ } catch {
2053
+ }
2054
+ return u;
2055
+ }
2056
+ }), () => {
2057
+ Object.defineProperty(r, "adoptedStyleSheets", {
2058
+ configurable: c.configurable,
2059
+ enumerable: c.enumerable,
2060
+ get: c.get,
2061
+ set: c.set
2062
+ });
2063
+ });
2064
+ }
2065
+ function Tn({ styleDeclarationCb: e, mirror: t, ignoreCSSAttributes: r, stylesheetManager: n }, { win: s }) {
2066
+ const i = s.CSSStyleDeclaration.prototype.setProperty;
2067
+ s.CSSStyleDeclaration.prototype.setProperty = function(o, c, d) {
2068
+ var l;
2069
+ if (r.has(o))
2070
+ return i.apply(this, [o, c, d]);
2071
+ const { id: u, styleId: h } = ce((l = this.parentRule) === null || l === void 0 ? void 0 : l.parentStyleSheet, t, n.styleMirror);
2072
+ return (u && u !== -1 || h && h !== -1) && e({
2073
+ id: u,
2074
+ styleId: h,
2075
+ set: {
2076
+ property: o,
2077
+ value: c,
2078
+ priority: d
2079
+ },
2080
+ index: He(this.parentRule)
2081
+ }), i.apply(this, [o, c, d]);
2082
+ };
2083
+ const a = s.CSSStyleDeclaration.prototype.removeProperty;
2084
+ return s.CSSStyleDeclaration.prototype.removeProperty = function(o) {
2085
+ var c;
2086
+ if (r.has(o))
2087
+ return a.apply(this, [o]);
2088
+ const { id: d, styleId: l } = ce((c = this.parentRule) === null || c === void 0 ? void 0 : c.parentStyleSheet, t, n.styleMirror);
2089
+ return (d && d !== -1 || l && l !== -1) && e({
2090
+ id: d,
2091
+ styleId: l,
2092
+ remove: {
2093
+ property: o
2094
+ },
2095
+ index: He(this.parentRule)
2096
+ }), a.apply(this, [o]);
2097
+ }, () => {
2098
+ s.CSSStyleDeclaration.prototype.setProperty = i, s.CSSStyleDeclaration.prototype.removeProperty = a;
2099
+ };
2100
+ }
2101
+ function _n({ mediaInteractionCb: e, blockClass: t, blockSelector: r, mirror: n, sampling: s }) {
2102
+ const i = (o) => Fe((c) => {
2103
+ const d = xe(c);
2104
+ if (!d || K(d, t, r, !0))
2105
+ return;
2106
+ const { currentTime: l, volume: u, muted: h, playbackRate: f } = d;
2107
+ e({
2108
+ type: o,
2109
+ id: n.getId(d),
2110
+ currentTime: l,
2111
+ volume: u,
2112
+ muted: h,
2113
+ playbackRate: f
2114
+ });
2115
+ }, s.media || 500), a = [
2116
+ G("play", i(0)),
2117
+ G("pause", i(1)),
2118
+ G("seeked", i(2)),
2119
+ G("volumechange", i(3)),
2120
+ G("ratechange", i(4))
2121
+ ];
2122
+ return () => {
2123
+ a.forEach((o) => o());
2124
+ };
2125
+ }
2126
+ function Nn({ fontCb: e, doc: t }) {
2127
+ const r = t.defaultView;
2128
+ if (!r)
2129
+ return () => {
2130
+ };
2131
+ const n = [], s = /* @__PURE__ */ new WeakMap(), i = r.FontFace;
2132
+ r.FontFace = function(c, d, l) {
2133
+ const u = new i(c, d, l);
2134
+ return s.set(u, {
2135
+ family: c,
2136
+ buffer: typeof d != "string",
2137
+ descriptors: l,
2138
+ fontSource: typeof d == "string" ? d : JSON.stringify(Array.from(new Uint8Array(d)))
2139
+ }), u;
2140
+ };
2141
+ const a = he(t.fonts, "add", function(o) {
2142
+ return function(c) {
2143
+ return setTimeout(() => {
2144
+ const d = s.get(c);
2145
+ d && (e(d), s.delete(c));
2146
+ }, 0), o.apply(this, [c]);
2147
+ };
2148
+ });
2149
+ return n.push(() => {
2150
+ r.FontFace = i;
2151
+ }), n.push(a), () => {
2152
+ n.forEach((o) => o());
2153
+ };
2154
+ }
2155
+ function Mn(e) {
2156
+ const { doc: t, mirror: r, blockClass: n, blockSelector: s, selectionCb: i } = e;
2157
+ let a = !0;
2158
+ const o = () => {
2159
+ const c = t.getSelection();
2160
+ if (!c || a && (c != null && c.isCollapsed))
2161
+ return;
2162
+ a = c.isCollapsed || !1;
2163
+ const d = [], l = c.rangeCount || 0;
2164
+ for (let u = 0; u < l; u++) {
2165
+ const h = c.getRangeAt(u), { startContainer: f, startOffset: p, endContainer: y, endOffset: S } = h;
2166
+ K(f, n, s, !0) || K(y, n, s, !0) || d.push({
2167
+ start: r.getId(f),
2168
+ startOffset: p,
2169
+ end: r.getId(y),
2170
+ endOffset: S
2171
+ });
2172
+ }
2173
+ i({ ranges: d });
2174
+ };
2175
+ return o(), G("selectionchange", o);
2176
+ }
2177
+ function On(e, t) {
2178
+ const { mutationCb: r, mousemoveCb: n, mouseInteractionCb: s, scrollCb: i, viewportResizeCb: a, inputCb: o, mediaInteractionCb: c, styleSheetRuleCb: d, styleDeclarationCb: l, canvasMutationCb: u, fontCb: h, selectionCb: f } = e;
2179
+ e.mutationCb = (...p) => {
2180
+ t.mutation && t.mutation(...p), r(...p);
2181
+ }, e.mousemoveCb = (...p) => {
2182
+ t.mousemove && t.mousemove(...p), n(...p);
2183
+ }, e.mouseInteractionCb = (...p) => {
2184
+ t.mouseInteraction && t.mouseInteraction(...p), s(...p);
2185
+ }, e.scrollCb = (...p) => {
2186
+ t.scroll && t.scroll(...p), i(...p);
2187
+ }, e.viewportResizeCb = (...p) => {
2188
+ t.viewportResize && t.viewportResize(...p), a(...p);
2189
+ }, e.inputCb = (...p) => {
2190
+ t.input && t.input(...p), o(...p);
2191
+ }, e.mediaInteractionCb = (...p) => {
2192
+ t.mediaInteaction && t.mediaInteaction(...p), c(...p);
2193
+ }, e.styleSheetRuleCb = (...p) => {
2194
+ t.styleSheetRule && t.styleSheetRule(...p), d(...p);
2195
+ }, e.styleDeclarationCb = (...p) => {
2196
+ t.styleDeclaration && t.styleDeclaration(...p), l(...p);
2197
+ }, e.canvasMutationCb = (...p) => {
2198
+ t.canvasMutation && t.canvasMutation(...p), u(...p);
2199
+ }, e.fontCb = (...p) => {
2200
+ t.font && t.font(...p), h(...p);
2201
+ }, e.selectionCb = (...p) => {
2202
+ t.selection && t.selection(...p), f(...p);
2203
+ };
2204
+ }
2205
+ function Ln(e, t = {}) {
2206
+ const r = e.doc.defaultView;
2207
+ if (!r)
2208
+ return () => {
2209
+ };
2210
+ On(e, t);
2211
+ const n = ur(e, e.doc), s = vn(e), i = wn(e), a = pr(e), o = An(e), c = Rn(e), d = _n(e), l = En(e, { win: r }), u = hr(e, e.doc), h = Tn(e, {
2212
+ win: r
2213
+ }), f = e.collectFonts ? Nn(e) : () => {
2214
+ }, p = Mn(e), y = [];
2215
+ for (const S of e.plugins)
2216
+ y.push(S.observer(S.callback, r, S.options));
2217
+ return () => {
2218
+ ue.forEach((S) => S.reset()), n.disconnect(), s(), i(), a(), o(), c(), d(), l(), u(), h(), f(), p(), y.forEach((S) => S());
2219
+ };
2220
+ }
2221
+ class Mt {
2222
+ constructor(t) {
2223
+ this.generateIdFn = t, this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap(), this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
2224
+ }
2225
+ getId(t, r, n, s) {
2226
+ const i = n || this.getIdToRemoteIdMap(t), a = s || this.getRemoteIdToIdMap(t);
2227
+ let o = i.get(r);
2228
+ return o || (o = this.generateIdFn(), i.set(r, o), a.set(o, r)), o;
2229
+ }
2230
+ getIds(t, r) {
2231
+ const n = this.getIdToRemoteIdMap(t), s = this.getRemoteIdToIdMap(t);
2232
+ return r.map((i) => this.getId(t, i, n, s));
2233
+ }
2234
+ getRemoteId(t, r, n) {
2235
+ const s = n || this.getRemoteIdToIdMap(t);
2236
+ if (typeof r != "number")
2237
+ return r;
2238
+ const i = s.get(r);
2239
+ return i || -1;
2240
+ }
2241
+ getRemoteIds(t, r) {
2242
+ const n = this.getRemoteIdToIdMap(t);
2243
+ return r.map((s) => this.getRemoteId(t, s, n));
2244
+ }
2245
+ reset(t) {
2246
+ if (!t) {
2247
+ this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap(), this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
2248
+ return;
2249
+ }
2250
+ this.iframeIdToRemoteIdMap.delete(t), this.iframeRemoteIdToIdMap.delete(t);
2251
+ }
2252
+ getIdToRemoteIdMap(t) {
2253
+ let r = this.iframeIdToRemoteIdMap.get(t);
2254
+ return r || (r = /* @__PURE__ */ new Map(), this.iframeIdToRemoteIdMap.set(t, r)), r;
2255
+ }
2256
+ getRemoteIdToIdMap(t) {
2257
+ let r = this.iframeRemoteIdToIdMap.get(t);
2258
+ return r || (r = /* @__PURE__ */ new Map(), this.iframeRemoteIdToIdMap.set(t, r)), r;
2259
+ }
2260
+ }
2261
+ class Fn {
2262
+ constructor(t) {
2263
+ this.iframes = /* @__PURE__ */ new WeakMap(), this.crossOriginIframeMap = /* @__PURE__ */ new WeakMap(), this.crossOriginIframeMirror = new Mt(qt), this.mutationCb = t.mutationCb, this.wrappedEmit = t.wrappedEmit, this.stylesheetManager = t.stylesheetManager, this.recordCrossOriginIframes = t.recordCrossOriginIframes, this.crossOriginIframeStyleMirror = new Mt(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)), this.mirror = t.mirror, this.recordCrossOriginIframes && window.addEventListener("message", this.handleMessage.bind(this));
2264
+ }
2265
+ addIframe(t) {
2266
+ this.iframes.set(t, !0), t.contentWindow && this.crossOriginIframeMap.set(t.contentWindow, t);
2267
+ }
2268
+ addLoadListener(t) {
2269
+ this.loadListener = t;
2270
+ }
2271
+ attachIframe(t, r) {
2272
+ var n;
2273
+ this.mutationCb({
2274
+ adds: [
2275
+ {
2276
+ parentId: this.mirror.getId(t),
2277
+ nextId: null,
2278
+ node: r
2279
+ }
2280
+ ],
2281
+ removes: [],
2282
+ texts: [],
2283
+ attributes: [],
2284
+ isAttachIframe: !0
2285
+ }), (n = this.loadListener) === null || n === void 0 || n.call(this, t), t.contentDocument && t.contentDocument.adoptedStyleSheets && t.contentDocument.adoptedStyleSheets.length > 0 && this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets, this.mirror.getId(t.contentDocument));
2286
+ }
2287
+ handleMessage(t) {
2288
+ if (t.data.type === "rrweb") {
2289
+ if (!t.source)
2290
+ return;
2291
+ const n = this.crossOriginIframeMap.get(t.source);
2292
+ if (!n)
2293
+ return;
2294
+ const s = this.transformCrossOriginEvent(n, t.data.event);
2295
+ s && this.wrappedEmit(s, t.data.isCheckout);
2296
+ }
2297
+ }
2298
+ transformCrossOriginEvent(t, r) {
2299
+ var n;
2300
+ switch (r.type) {
2301
+ case v.FullSnapshot:
2302
+ return this.crossOriginIframeMirror.reset(t), this.crossOriginIframeStyleMirror.reset(t), this.replaceIdOnNode(r.data.node, t), {
2303
+ timestamp: r.timestamp,
2304
+ type: v.IncrementalSnapshot,
2305
+ data: {
2306
+ source: b.Mutation,
2307
+ adds: [
2308
+ {
2309
+ parentId: this.mirror.getId(t),
2310
+ nextId: null,
2311
+ node: r.data.node
2312
+ }
2313
+ ],
2314
+ removes: [],
2315
+ texts: [],
2316
+ attributes: [],
2317
+ isAttachIframe: !0
2318
+ }
2319
+ };
2320
+ case v.Meta:
2321
+ case v.Load:
2322
+ case v.DomContentLoaded:
2323
+ return !1;
2324
+ case v.Plugin:
2325
+ return r;
2326
+ case v.Custom:
2327
+ return this.replaceIds(r.data.payload, t, ["id", "parentId", "previousId", "nextId"]), r;
2328
+ case v.IncrementalSnapshot:
2329
+ switch (r.data.source) {
2330
+ case b.Mutation:
2331
+ return r.data.adds.forEach((s) => {
2332
+ this.replaceIds(s, t, [
2333
+ "parentId",
2334
+ "nextId",
2335
+ "previousId"
2336
+ ]), this.replaceIdOnNode(s.node, t);
2337
+ }), r.data.removes.forEach((s) => {
2338
+ this.replaceIds(s, t, ["parentId", "id"]);
2339
+ }), r.data.attributes.forEach((s) => {
2340
+ this.replaceIds(s, t, ["id"]);
2341
+ }), r.data.texts.forEach((s) => {
2342
+ this.replaceIds(s, t, ["id"]);
2343
+ }), r;
2344
+ case b.Drag:
2345
+ case b.TouchMove:
2346
+ case b.MouseMove:
2347
+ return r.data.positions.forEach((s) => {
2348
+ this.replaceIds(s, t, ["id"]);
2349
+ }), r;
2350
+ case b.ViewportResize:
2351
+ return !1;
2352
+ case b.MediaInteraction:
2353
+ case b.MouseInteraction:
2354
+ case b.Scroll:
2355
+ case b.CanvasMutation:
2356
+ case b.Input:
2357
+ return this.replaceIds(r.data, t, ["id"]), r;
2358
+ case b.StyleSheetRule:
2359
+ case b.StyleDeclaration:
2360
+ return this.replaceIds(r.data, t, ["id"]), this.replaceStyleIds(r.data, t, ["styleId"]), r;
2361
+ case b.Font:
2362
+ return r;
2363
+ case b.Selection:
2364
+ return r.data.ranges.forEach((s) => {
2365
+ this.replaceIds(s, t, ["start", "end"]);
2366
+ }), r;
2367
+ case b.AdoptedStyleSheet:
2368
+ return this.replaceIds(r.data, t, ["id"]), this.replaceStyleIds(r.data, t, ["styleIds"]), (n = r.data.styles) === null || n === void 0 || n.forEach((s) => {
2369
+ this.replaceStyleIds(s, t, ["styleId"]);
2370
+ }), r;
2371
+ }
2372
+ }
2373
+ }
2374
+ replace(t, r, n, s) {
2375
+ for (const i of s)
2376
+ !Array.isArray(r[i]) && typeof r[i] != "number" || (Array.isArray(r[i]) ? r[i] = t.getIds(n, r[i]) : r[i] = t.getId(n, r[i]));
2377
+ return r;
2378
+ }
2379
+ replaceIds(t, r, n) {
2380
+ return this.replace(this.crossOriginIframeMirror, t, r, n);
2381
+ }
2382
+ replaceStyleIds(t, r, n) {
2383
+ return this.replace(this.crossOriginIframeStyleMirror, t, r, n);
2384
+ }
2385
+ replaceIdOnNode(t, r) {
2386
+ this.replaceIds(t, r, ["id"]), "childNodes" in t && t.childNodes.forEach((n) => {
2387
+ this.replaceIdOnNode(n, r);
2388
+ });
2389
+ }
2390
+ }
2391
+ class xn {
2392
+ constructor(t) {
2393
+ this.shadowDoms = /* @__PURE__ */ new WeakSet(), this.restorePatches = [], this.mutationCb = t.mutationCb, this.scrollCb = t.scrollCb, this.bypassOptions = t.bypassOptions, this.mirror = t.mirror;
2394
+ const r = this;
2395
+ this.restorePatches.push(he(Element.prototype, "attachShadow", function(n) {
2396
+ return function(s) {
2397
+ const i = n.call(this, s);
2398
+ return this.shadowRoot && r.addShadowRoot(this.shadowRoot, this.ownerDocument), i;
2399
+ };
2400
+ }));
2401
+ }
2402
+ addShadowRoot(t, r) {
2403
+ Me(t) && (this.shadowDoms.has(t) || (this.shadowDoms.add(t), ur(Object.assign(Object.assign({}, this.bypassOptions), { doc: r, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), t), pr(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: t, mirror: this.mirror })), setTimeout(() => {
2404
+ t.adoptedStyleSheets && t.adoptedStyleSheets.length > 0 && this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets, this.mirror.getId(t.host)), hr({
2405
+ mirror: this.mirror,
2406
+ stylesheetManager: this.bypassOptions.stylesheetManager
2407
+ }, t);
2408
+ }, 0)));
2409
+ }
2410
+ observeAttachShadow(t) {
2411
+ if (t.contentWindow) {
2412
+ const r = this;
2413
+ this.restorePatches.push(he(t.contentWindow.HTMLElement.prototype, "attachShadow", function(n) {
2414
+ return function(s) {
2415
+ const i = n.call(this, s);
2416
+ return this.shadowRoot && r.addShadowRoot(this.shadowRoot, t.contentDocument), i;
2417
+ };
2418
+ }));
2419
+ }
2420
+ }
2421
+ reset() {
2422
+ this.restorePatches.forEach((t) => t()), this.shadowDoms = /* @__PURE__ */ new WeakSet();
2423
+ }
2424
+ }
2425
+ /*! *****************************************************************************
2426
+ Copyright (c) Microsoft Corporation.
2427
+
2428
+ Permission to use, copy, modify, and/or distribute this software for any
2429
+ purpose with or without fee is hereby granted.
2430
+
2431
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2432
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2433
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2434
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2435
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2436
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2437
+ PERFORMANCE OF THIS SOFTWARE.
2438
+ ***************************************************************************** */
2439
+ function Dn(e, t) {
2440
+ var r = {};
2441
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
2442
+ if (e != null && typeof Object.getOwnPropertySymbols == "function")
2443
+ for (var s = 0, n = Object.getOwnPropertySymbols(e); s < n.length; s++)
2444
+ t.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[s]) && (r[n[s]] = e[n[s]]);
2445
+ return r;
2446
+ }
2447
+ function Bn(e, t, r, n) {
2448
+ function s(i) {
2449
+ return i instanceof r ? i : new r(function(a) {
2450
+ a(i);
2451
+ });
2452
+ }
2453
+ return new (r || (r = Promise))(function(i, a) {
2454
+ function o(l) {
2455
+ try {
2456
+ d(n.next(l));
2457
+ } catch (u) {
2458
+ a(u);
2459
+ }
2460
+ }
2461
+ function c(l) {
2462
+ try {
2463
+ d(n.throw(l));
2464
+ } catch (u) {
2465
+ a(u);
2466
+ }
2467
+ }
2468
+ function d(l) {
2469
+ l.done ? i(l.value) : s(l.value).then(o, c);
2470
+ }
2471
+ d((n = n.apply(e, [])).next());
2472
+ });
2473
+ }
2474
+ var we = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Un = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
2475
+ for (var De = 0; De < we.length; De++)
2476
+ Un[we.charCodeAt(De)] = De;
2477
+ var Wn = function(e) {
2478
+ var t = new Uint8Array(e), r, n = t.length, s = "";
2479
+ for (r = 0; r < n; r += 3)
2480
+ s += we[t[r] >> 2], s += we[(t[r] & 3) << 4 | t[r + 1] >> 4], s += we[(t[r + 1] & 15) << 2 | t[r + 2] >> 6], s += we[t[r + 2] & 63];
2481
+ return n % 3 === 2 ? s = s.substring(0, s.length - 1) + "=" : n % 3 === 1 && (s = s.substring(0, s.length - 2) + "=="), s;
2482
+ };
2483
+ const Ot = /* @__PURE__ */ new Map();
2484
+ function zn(e, t) {
2485
+ let r = Ot.get(e);
2486
+ return r || (r = /* @__PURE__ */ new Map(), Ot.set(e, r)), r.has(t) || r.set(t, []), r.get(t);
2487
+ }
2488
+ const fr = (e, t, r) => {
2489
+ if (!e || !(gr(e, t) || typeof e == "object"))
2490
+ return;
2491
+ const n = e.constructor.name, s = zn(r, n);
2492
+ let i = s.indexOf(e);
2493
+ return i === -1 && (i = s.length, s.push(e)), i;
2494
+ };
2495
+ function Be(e, t, r) {
2496
+ if (e instanceof Array)
2497
+ return e.map((n) => Be(n, t, r));
2498
+ if (e === null)
2499
+ return e;
2500
+ if (e instanceof Float32Array || e instanceof Float64Array || e instanceof Int32Array || e instanceof Uint32Array || e instanceof Uint8Array || e instanceof Uint16Array || e instanceof Int16Array || e instanceof Int8Array || e instanceof Uint8ClampedArray)
2501
+ return {
2502
+ rr_type: e.constructor.name,
2503
+ args: [Object.values(e)]
2504
+ };
2505
+ if (e instanceof ArrayBuffer) {
2506
+ const n = e.constructor.name, s = Wn(e);
2507
+ return {
2508
+ rr_type: n,
2509
+ base64: s
2510
+ };
2511
+ } else {
2512
+ if (e instanceof DataView)
2513
+ return {
2514
+ rr_type: e.constructor.name,
2515
+ args: [
2516
+ Be(e.buffer, t, r),
2517
+ e.byteOffset,
2518
+ e.byteLength
2519
+ ]
2520
+ };
2521
+ if (e instanceof HTMLImageElement) {
2522
+ const n = e.constructor.name, { src: s } = e;
2523
+ return {
2524
+ rr_type: n,
2525
+ src: s
2526
+ };
2527
+ } else if (e instanceof HTMLCanvasElement) {
2528
+ const n = "HTMLImageElement", s = e.toDataURL();
2529
+ return {
2530
+ rr_type: n,
2531
+ src: s
2532
+ };
2533
+ } else {
2534
+ if (e instanceof ImageData)
2535
+ return {
2536
+ rr_type: e.constructor.name,
2537
+ args: [Be(e.data, t, r), e.width, e.height]
2538
+ };
2539
+ if (gr(e, t) || typeof e == "object") {
2540
+ const n = e.constructor.name, s = fr(e, t, r);
2541
+ return {
2542
+ rr_type: n,
2543
+ index: s
2544
+ };
2545
+ }
2546
+ }
2547
+ }
2548
+ return e;
2549
+ }
2550
+ const mr = (e, t, r) => [...e].map((n) => Be(n, t, r)), gr = (e, t) => !![
2551
+ "WebGLActiveInfo",
2552
+ "WebGLBuffer",
2553
+ "WebGLFramebuffer",
2554
+ "WebGLProgram",
2555
+ "WebGLRenderbuffer",
2556
+ "WebGLShader",
2557
+ "WebGLShaderPrecisionFormat",
2558
+ "WebGLTexture",
2559
+ "WebGLUniformLocation",
2560
+ "WebGLVertexArrayObject",
2561
+ "WebGLVertexArrayObjectOES"
2562
+ ].filter((s) => typeof t[s] == "function").find((s) => e instanceof t[s]);
2563
+ function Gn(e, t, r, n) {
2564
+ const s = [], i = Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);
2565
+ for (const a of i)
2566
+ try {
2567
+ if (typeof t.CanvasRenderingContext2D.prototype[a] != "function")
2568
+ continue;
2569
+ const o = he(t.CanvasRenderingContext2D.prototype, a, function(c) {
2570
+ return function(...d) {
2571
+ return K(this.canvas, r, n, !0) || setTimeout(() => {
2572
+ const l = mr([...d], t, this);
2573
+ e(this.canvas, {
2574
+ type: ke["2D"],
2575
+ property: a,
2576
+ args: l
2577
+ });
2578
+ }, 0), c.apply(this, d);
2579
+ };
2580
+ });
2581
+ s.push(o);
2582
+ } catch {
2583
+ const c = qe(t.CanvasRenderingContext2D.prototype, a, {
2584
+ set(d) {
2585
+ e(this.canvas, {
2586
+ type: ke["2D"],
2587
+ property: a,
2588
+ args: [d],
2589
+ setter: !0
2590
+ });
2591
+ }
2592
+ });
2593
+ s.push(c);
2594
+ }
2595
+ return () => {
2596
+ s.forEach((a) => a());
2597
+ };
2598
+ }
2599
+ function Lt(e, t, r) {
2600
+ const n = [];
2601
+ try {
2602
+ const s = he(e.HTMLCanvasElement.prototype, "getContext", function(i) {
2603
+ return function(a, ...o) {
2604
+ return K(this, t, r, !0) || "__context" in this || (this.__context = a), i.apply(this, [a, ...o]);
2605
+ };
2606
+ });
2607
+ n.push(s);
2608
+ } catch {
2609
+ console.error("failed to patch HTMLCanvasElement.prototype.getContext");
2610
+ }
2611
+ return () => {
2612
+ n.forEach((s) => s());
2613
+ };
2614
+ }
2615
+ function Ft(e, t, r, n, s, i, a) {
2616
+ const o = [], c = Object.getOwnPropertyNames(e);
2617
+ for (const d of c)
2618
+ if (![
2619
+ "isContextLost",
2620
+ "canvas",
2621
+ "drawingBufferWidth",
2622
+ "drawingBufferHeight"
2623
+ ].includes(d))
2624
+ try {
2625
+ if (typeof e[d] != "function")
2626
+ continue;
2627
+ const l = he(e, d, function(u) {
2628
+ return function(...h) {
2629
+ const f = u.apply(this, h);
2630
+ if (fr(f, a, this), !K(this.canvas, n, s, !0)) {
2631
+ const p = mr([...h], a, this), y = {
2632
+ type: t,
2633
+ property: d,
2634
+ args: p
2635
+ };
2636
+ r(this.canvas, y);
2637
+ }
2638
+ return f;
2639
+ };
2640
+ });
2641
+ o.push(l);
2642
+ } catch {
2643
+ const u = qe(e, d, {
2644
+ set(h) {
2645
+ r(this.canvas, {
2646
+ type: t,
2647
+ property: d,
2648
+ args: [h],
2649
+ setter: !0
2650
+ });
2651
+ }
2652
+ });
2653
+ o.push(u);
2654
+ }
2655
+ return o;
2656
+ }
2657
+ function Kn(e, t, r, n, s) {
2658
+ const i = [];
2659
+ return i.push(...Ft(t.WebGLRenderingContext.prototype, ke.WebGL, e, r, n, s, t)), typeof t.WebGL2RenderingContext < "u" && i.push(...Ft(t.WebGL2RenderingContext.prototype, ke.WebGL2, e, r, n, s, t)), () => {
2660
+ i.forEach((a) => a());
2661
+ };
2662
+ }
2663
+ var yr = null;
2664
+ try {
2665
+ var Vn = typeof module < "u" && typeof module.require == "function" && module.require("worker_threads") || typeof __non_webpack_require__ == "function" && __non_webpack_require__("worker_threads") || typeof require == "function" && require("worker_threads");
2666
+ yr = Vn.Worker;
2667
+ } catch {
2668
+ }
2669
+ function Pn(e, t) {
2670
+ return Buffer.from(e, "base64").toString("utf8");
2671
+ }
2672
+ function Zn(e, t, r) {
2673
+ var n = Pn(e), s = n.indexOf(`
2674
+ `, 10) + 1, i = n.substring(s) + "";
2675
+ return function(o) {
2676
+ return new yr(i, Object.assign({}, o, { eval: !0 }));
2677
+ };
2678
+ }
2679
+ function Hn(e, t) {
2680
+ var r = atob(e);
2681
+ return r;
2682
+ }
2683
+ function jn(e, t, r) {
2684
+ var n = Hn(e), s = n.indexOf(`
2685
+ `, 10) + 1, i = n.substring(s) + "", a = new Blob([i], { type: "application/javascript" });
2686
+ return URL.createObjectURL(a);
2687
+ }
2688
+ function Jn(e, t, r) {
2689
+ var n;
2690
+ return function(i) {
2691
+ return n = n || jn(e), new Worker(n, i);
2692
+ };
2693
+ }
2694
+ var qn = Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]";
2695
+ function Yn() {
2696
+ return qn;
2697
+ }
2698
+ function Xn(e, t, r) {
2699
+ return Yn() ? Zn(e) : Jn(e);
2700
+ }
2701
+ var Qn = Xn("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=");
2702
+ class $n {
2703
+ constructor(t) {
2704
+ this.pendingCanvasMutations = /* @__PURE__ */ new Map(), this.rafStamps = { latestId: 0, invokeId: null }, this.frozen = !1, this.locked = !1, this.processMutation = (c, d) => {
2705
+ (this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId || !this.rafStamps.invokeId) && (this.rafStamps.invokeId = this.rafStamps.latestId), this.pendingCanvasMutations.has(c) || this.pendingCanvasMutations.set(c, []), this.pendingCanvasMutations.get(c).push(d);
2706
+ };
2707
+ const { sampling: r = "all", win: n, blockClass: s, blockSelector: i, recordCanvas: a, dataURLOptions: o } = t;
2708
+ this.mutationCb = t.mutationCb, this.mirror = t.mirror, a && r === "all" && this.initCanvasMutationObserver(n, s, i), a && typeof r == "number" && this.initCanvasFPSObserver(r, n, s, i, {
2709
+ dataURLOptions: o
2710
+ });
2711
+ }
2712
+ reset() {
2713
+ this.pendingCanvasMutations.clear(), this.resetObservers && this.resetObservers();
2714
+ }
2715
+ freeze() {
2716
+ this.frozen = !0;
2717
+ }
2718
+ unfreeze() {
2719
+ this.frozen = !1;
2720
+ }
2721
+ lock() {
2722
+ this.locked = !0;
2723
+ }
2724
+ unlock() {
2725
+ this.locked = !1;
2726
+ }
2727
+ initCanvasFPSObserver(t, r, n, s, i) {
2728
+ const a = Lt(r, n, s), o = /* @__PURE__ */ new Map(), c = new Qn();
2729
+ c.onmessage = (p) => {
2730
+ const { id: y } = p.data;
2731
+ if (o.set(y, !1), !("base64" in p.data))
2732
+ return;
2733
+ const { base64: S, type: C, width: m, height: g } = p.data;
2734
+ this.mutationCb({
2735
+ id: y,
2736
+ type: ke["2D"],
2737
+ commands: [
2738
+ {
2739
+ property: "clearRect",
2740
+ args: [0, 0, m, g]
2741
+ },
2742
+ {
2743
+ property: "drawImage",
2744
+ args: [
2745
+ {
2746
+ rr_type: "ImageBitmap",
2747
+ args: [
2748
+ {
2749
+ rr_type: "Blob",
2750
+ data: [{ rr_type: "ArrayBuffer", base64: S }],
2751
+ type: C
2752
+ }
2753
+ ]
2754
+ },
2755
+ 0,
2756
+ 0
2757
+ ]
2758
+ }
2759
+ ]
2760
+ });
2761
+ };
2762
+ const d = 1e3 / t;
2763
+ let l = 0, u;
2764
+ const h = () => {
2765
+ const p = [];
2766
+ return r.document.querySelectorAll("canvas").forEach((y) => {
2767
+ K(y, n, s, !0) || p.push(y);
2768
+ }), p;
2769
+ }, f = (p) => {
2770
+ if (l && p - l < d) {
2771
+ u = requestAnimationFrame(f);
2772
+ return;
2773
+ }
2774
+ l = p, h().forEach((y) => Bn(this, void 0, void 0, function* () {
2775
+ var S;
2776
+ const C = this.mirror.getId(y);
2777
+ if (o.get(C))
2778
+ return;
2779
+ if (o.set(C, !0), ["webgl", "webgl2"].includes(y.__context)) {
2780
+ const g = y.getContext(y.__context);
2781
+ ((S = g == null ? void 0 : g.getContextAttributes()) === null || S === void 0 ? void 0 : S.preserveDrawingBuffer) === !1 && (g == null || g.clear(g.COLOR_BUFFER_BIT));
2782
+ }
2783
+ const m = yield createImageBitmap(y);
2784
+ c.postMessage({
2785
+ id: C,
2786
+ bitmap: m,
2787
+ width: y.width,
2788
+ height: y.height,
2789
+ dataURLOptions: i.dataURLOptions
2790
+ }, [m]);
2791
+ })), u = requestAnimationFrame(f);
2792
+ };
2793
+ u = requestAnimationFrame(f), this.resetObservers = () => {
2794
+ a(), cancelAnimationFrame(u);
2795
+ };
2796
+ }
2797
+ initCanvasMutationObserver(t, r, n) {
2798
+ this.startRAFTimestamping(), this.startPendingCanvasMutationFlusher();
2799
+ const s = Lt(t, r, n), i = Gn(this.processMutation.bind(this), t, r, n), a = Kn(this.processMutation.bind(this), t, r, n, this.mirror);
2800
+ this.resetObservers = () => {
2801
+ s(), i(), a();
2802
+ };
2803
+ }
2804
+ startPendingCanvasMutationFlusher() {
2805
+ requestAnimationFrame(() => this.flushPendingCanvasMutations());
2806
+ }
2807
+ startRAFTimestamping() {
2808
+ const t = (r) => {
2809
+ this.rafStamps.latestId = r, requestAnimationFrame(t);
2810
+ };
2811
+ requestAnimationFrame(t);
2812
+ }
2813
+ flushPendingCanvasMutations() {
2814
+ this.pendingCanvasMutations.forEach((t, r) => {
2815
+ const n = this.mirror.getId(r);
2816
+ this.flushPendingCanvasMutationFor(r, n);
2817
+ }), requestAnimationFrame(() => this.flushPendingCanvasMutations());
2818
+ }
2819
+ flushPendingCanvasMutationFor(t, r) {
2820
+ if (this.frozen || this.locked)
2821
+ return;
2822
+ const n = this.pendingCanvasMutations.get(t);
2823
+ if (!n || r === -1)
2824
+ return;
2825
+ const s = n.map((a) => Dn(a, ["type"])), { type: i } = n[0];
2826
+ this.mutationCb({ id: r, type: i, commands: s }), this.pendingCanvasMutations.delete(t);
2827
+ }
2828
+ }
2829
+ class es {
2830
+ constructor(t) {
2831
+ this.trackedLinkElements = /* @__PURE__ */ new WeakSet(), this.styleMirror = new Cn(), this.mutationCb = t.mutationCb, this.adoptedStyleSheetCb = t.adoptedStyleSheetCb;
2832
+ }
2833
+ attachLinkElement(t, r) {
2834
+ "_cssText" in r.attributes && this.mutationCb({
2835
+ adds: [],
2836
+ removes: [],
2837
+ texts: [],
2838
+ attributes: [
2839
+ {
2840
+ id: r.id,
2841
+ attributes: r.attributes
2842
+ }
2843
+ ]
2844
+ }), this.trackLinkElement(t);
2845
+ }
2846
+ trackLinkElement(t) {
2847
+ this.trackedLinkElements.has(t) || (this.trackedLinkElements.add(t), this.trackStylesheetInLinkElement(t));
2848
+ }
2849
+ adoptStyleSheets(t, r) {
2850
+ if (t.length === 0)
2851
+ return;
2852
+ const n = {
2853
+ id: r,
2854
+ styleIds: []
2855
+ }, s = [];
2856
+ for (const i of t) {
2857
+ let a;
2858
+ if (this.styleMirror.has(i))
2859
+ a = this.styleMirror.getId(i);
2860
+ else {
2861
+ a = this.styleMirror.add(i);
2862
+ const o = Array.from(i.rules || CSSRule);
2863
+ s.push({
2864
+ styleId: a,
2865
+ rules: o.map((c, d) => ({
2866
+ rule: jt(c),
2867
+ index: d
2868
+ }))
2869
+ });
2870
+ }
2871
+ n.styleIds.push(a);
2872
+ }
2873
+ s.length > 0 && (n.styles = s), this.adoptedStyleSheetCb(n);
2874
+ }
2875
+ reset() {
2876
+ this.styleMirror.reset(), this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
2877
+ }
2878
+ trackStylesheetInLinkElement(t) {
2879
+ }
2880
+ }
2881
+ function L(e) {
2882
+ return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
2883
+ }
2884
+ let _, Ue, $e, je = !1;
2885
+ const ne = jr();
2886
+ function Re(e = {}) {
2887
+ const { emit: t, checkoutEveryNms: r, checkoutEveryNth: n, blockClass: s = "rr-block", blockSelector: i = null, ignoreClass: a = "rr-ignore", maskTextClass: o = "rr-mask", maskTextSelector: c = null, inlineStylesheet: d = !0, maskAllInputs: l, maskInputOptions: u, slimDOMOptions: h, maskInputFn: f, maskTextFn: p, hooks: y, packFn: S, sampling: C = {}, dataURLOptions: m = {}, mousemoveWait: g, recordCanvas: k = !1, recordCrossOriginIframes: U = !1, userTriggeredOnInput: x = !1, collectFonts: D = !1, inlineImages: R = !1, plugins: H, keepIframeSrcFn: j = () => !1, ignoreCSSAttributes: X = /* @__PURE__ */ new Set([]) } = e, Q = U ? window.parent === window : !0;
2888
+ let $ = !1;
2889
+ if (!Q)
2890
+ try {
2891
+ window.parent.document, $ = !1;
2892
+ } catch {
2893
+ $ = !0;
2894
+ }
2895
+ if (Q && !t)
2896
+ throw new Error("emit function is required");
2897
+ g !== void 0 && C.mousemove === void 0 && (C.mousemove = g), ne.reset();
2898
+ const O = l === !0 ? {
2899
+ color: !0,
2900
+ date: !0,
2901
+ "datetime-local": !0,
2902
+ email: !0,
2903
+ month: !0,
2904
+ number: !0,
2905
+ range: !0,
2906
+ search: !0,
2907
+ tel: !0,
2908
+ text: !0,
2909
+ time: !0,
2910
+ url: !0,
2911
+ week: !0,
2912
+ textarea: !0,
2913
+ select: !0,
2914
+ password: !0
2915
+ } : u !== void 0 ? u : { password: !0 }, J = h === !0 || h === "all" ? {
2916
+ script: !0,
2917
+ comment: !0,
2918
+ headFavicon: !0,
2919
+ headWhitespace: !0,
2920
+ headMetaSocial: !0,
2921
+ headMetaRobots: !0,
2922
+ headMetaHttpEquiv: !0,
2923
+ headMetaVerification: !0,
2924
+ headMetaAuthorship: h === "all",
2925
+ headMetaDescKeywords: h === "all"
2926
+ } : h || {};
2927
+ In();
2928
+ let ee, se = 0;
2929
+ const ae = (I) => {
2930
+ for (const W of H || [])
2931
+ W.eventProcessor && (I = W.eventProcessor(I));
2932
+ return S && (I = S(I)), I;
2933
+ };
2934
+ _ = (I, W) => {
2935
+ var P;
2936
+ if (!((P = ue[0]) === null || P === void 0) && P.isFrozen() && I.type !== v.FullSnapshot && !(I.type === v.IncrementalSnapshot && I.data.source === b.Mutation) && ue.forEach((T) => T.unfreeze()), Q)
2937
+ t == null || t(ae(I), W);
2938
+ else if ($) {
2939
+ const T = {
2940
+ type: "rrweb",
2941
+ event: ae(I),
2942
+ isCheckout: W
2943
+ };
2944
+ window.parent.postMessage(T, "*");
2945
+ }
2946
+ if (I.type === v.FullSnapshot)
2947
+ ee = I, se = 0;
2948
+ else if (I.type === v.IncrementalSnapshot) {
2949
+ if (I.data.source === b.Mutation && I.data.isAttachIframe)
2950
+ return;
2951
+ se++;
2952
+ const T = n && se >= n, Y = r && I.timestamp - ee.timestamp > r;
2953
+ (T || Y) && Ue(!0);
2954
+ }
2955
+ };
2956
+ const V = (I) => {
2957
+ _(L({
2958
+ type: v.IncrementalSnapshot,
2959
+ data: Object.assign({ source: b.Mutation }, I)
2960
+ }));
2961
+ }, q = (I) => _(L({
2962
+ type: v.IncrementalSnapshot,
2963
+ data: Object.assign({ source: b.Scroll }, I)
2964
+ })), oe = (I) => _(L({
2965
+ type: v.IncrementalSnapshot,
2966
+ data: Object.assign({ source: b.CanvasMutation }, I)
2967
+ })), N = (I) => _(L({
2968
+ type: v.IncrementalSnapshot,
2969
+ data: Object.assign({ source: b.AdoptedStyleSheet }, I)
2970
+ })), te = new es({
2971
+ mutationCb: V,
2972
+ adoptedStyleSheetCb: N
2973
+ }), ie = new Fn({
2974
+ mirror: ne,
2975
+ mutationCb: V,
2976
+ stylesheetManager: te,
2977
+ recordCrossOriginIframes: U,
2978
+ wrappedEmit: _
2979
+ });
2980
+ for (const I of H || [])
2981
+ I.getMirror && I.getMirror({
2982
+ nodeMirror: ne,
2983
+ crossOriginIframeMirror: ie.crossOriginIframeMirror,
2984
+ crossOriginIframeStyleMirror: ie.crossOriginIframeStyleMirror
2985
+ });
2986
+ $e = new $n({
2987
+ recordCanvas: k,
2988
+ mutationCb: oe,
2989
+ win: window,
2990
+ blockClass: s,
2991
+ blockSelector: i,
2992
+ mirror: ne,
2993
+ sampling: C.canvas,
2994
+ dataURLOptions: m
2995
+ });
2996
+ const me = new xn({
2997
+ mutationCb: V,
2998
+ scrollCb: q,
2999
+ bypassOptions: {
3000
+ blockClass: s,
3001
+ blockSelector: i,
3002
+ maskTextClass: o,
3003
+ maskTextSelector: c,
3004
+ inlineStylesheet: d,
3005
+ maskInputOptions: O,
3006
+ dataURLOptions: m,
3007
+ maskTextFn: p,
3008
+ maskInputFn: f,
3009
+ recordCanvas: k,
3010
+ inlineImages: R,
3011
+ sampling: C,
3012
+ slimDOMOptions: J,
3013
+ iframeManager: ie,
3014
+ stylesheetManager: te,
3015
+ canvasManager: $e,
3016
+ keepIframeSrcFn: j
3017
+ },
3018
+ mirror: ne
3019
+ });
3020
+ Ue = (I = !1) => {
3021
+ var W, P, T, Y, A, Z;
3022
+ _(L({
3023
+ type: v.Meta,
3024
+ data: {
3025
+ href: window.location.href,
3026
+ width: $t(),
3027
+ height: Qt()
3028
+ }
3029
+ }), I), te.reset(), ue.forEach((z) => z.lock());
3030
+ const Ee = gn(document, {
3031
+ mirror: ne,
3032
+ blockClass: s,
3033
+ blockSelector: i,
3034
+ maskTextClass: o,
3035
+ maskTextSelector: c,
3036
+ inlineStylesheet: d,
3037
+ maskAllInputs: O,
3038
+ maskTextFn: p,
3039
+ slimDOM: J,
3040
+ dataURLOptions: m,
3041
+ recordCanvas: k,
3042
+ inlineImages: R,
3043
+ onSerialize: (z) => {
3044
+ rr(z, ne) && ie.addIframe(z), nr(z, ne) && te.trackLinkElement(z), sr(z) && me.addShadowRoot(z.shadowRoot, document);
3045
+ },
3046
+ onIframeLoad: (z, Ye) => {
3047
+ ie.attachIframe(z, Ye), me.observeAttachShadow(z);
3048
+ },
3049
+ onStylesheetLoad: (z, Ye) => {
3050
+ te.attachLinkElement(z, Ye);
3051
+ },
3052
+ keepIframeSrcFn: j
3053
+ });
3054
+ if (!Ee)
3055
+ return console.warn("Failed to snapshot the document");
3056
+ _(L({
3057
+ type: v.FullSnapshot,
3058
+ data: {
3059
+ node: Ee,
3060
+ initialOffset: {
3061
+ left: window.pageXOffset !== void 0 ? window.pageXOffset : (document == null ? void 0 : document.documentElement.scrollLeft) || ((P = (W = document == null ? void 0 : document.body) === null || W === void 0 ? void 0 : W.parentElement) === null || P === void 0 ? void 0 : P.scrollLeft) || ((T = document == null ? void 0 : document.body) === null || T === void 0 ? void 0 : T.scrollLeft) || 0,
3062
+ top: window.pageYOffset !== void 0 ? window.pageYOffset : (document == null ? void 0 : document.documentElement.scrollTop) || ((A = (Y = document == null ? void 0 : document.body) === null || Y === void 0 ? void 0 : Y.parentElement) === null || A === void 0 ? void 0 : A.scrollTop) || ((Z = document == null ? void 0 : document.body) === null || Z === void 0 ? void 0 : Z.scrollTop) || 0
3063
+ }
3064
+ }
3065
+ })), ue.forEach((z) => z.unlock()), document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0 && te.adoptStyleSheets(document.adoptedStyleSheets, ne.getId(document));
3066
+ };
3067
+ try {
3068
+ const I = [];
3069
+ I.push(G("DOMContentLoaded", () => {
3070
+ _(L({
3071
+ type: v.DomContentLoaded,
3072
+ data: {}
3073
+ }));
3074
+ }));
3075
+ const W = (T) => {
3076
+ var Y;
3077
+ return Ln({
3078
+ mutationCb: V,
3079
+ mousemoveCb: (A, Z) => _(L({
3080
+ type: v.IncrementalSnapshot,
3081
+ data: {
3082
+ source: Z,
3083
+ positions: A
3084
+ }
3085
+ })),
3086
+ mouseInteractionCb: (A) => _(L({
3087
+ type: v.IncrementalSnapshot,
3088
+ data: Object.assign({ source: b.MouseInteraction }, A)
3089
+ })),
3090
+ scrollCb: q,
3091
+ viewportResizeCb: (A) => _(L({
3092
+ type: v.IncrementalSnapshot,
3093
+ data: Object.assign({ source: b.ViewportResize }, A)
3094
+ })),
3095
+ inputCb: (A) => _(L({
3096
+ type: v.IncrementalSnapshot,
3097
+ data: Object.assign({ source: b.Input }, A)
3098
+ })),
3099
+ mediaInteractionCb: (A) => _(L({
3100
+ type: v.IncrementalSnapshot,
3101
+ data: Object.assign({ source: b.MediaInteraction }, A)
3102
+ })),
3103
+ styleSheetRuleCb: (A) => _(L({
3104
+ type: v.IncrementalSnapshot,
3105
+ data: Object.assign({ source: b.StyleSheetRule }, A)
3106
+ })),
3107
+ styleDeclarationCb: (A) => _(L({
3108
+ type: v.IncrementalSnapshot,
3109
+ data: Object.assign({ source: b.StyleDeclaration }, A)
3110
+ })),
3111
+ canvasMutationCb: oe,
3112
+ fontCb: (A) => _(L({
3113
+ type: v.IncrementalSnapshot,
3114
+ data: Object.assign({ source: b.Font }, A)
3115
+ })),
3116
+ selectionCb: (A) => {
3117
+ _(L({
3118
+ type: v.IncrementalSnapshot,
3119
+ data: Object.assign({ source: b.Selection }, A)
3120
+ }));
3121
+ },
3122
+ blockClass: s,
3123
+ ignoreClass: a,
3124
+ maskTextClass: o,
3125
+ maskTextSelector: c,
3126
+ maskInputOptions: O,
3127
+ inlineStylesheet: d,
3128
+ sampling: C,
3129
+ recordCanvas: k,
3130
+ inlineImages: R,
3131
+ userTriggeredOnInput: x,
3132
+ collectFonts: D,
3133
+ doc: T,
3134
+ maskInputFn: f,
3135
+ maskTextFn: p,
3136
+ keepIframeSrcFn: j,
3137
+ blockSelector: i,
3138
+ slimDOMOptions: J,
3139
+ dataURLOptions: m,
3140
+ mirror: ne,
3141
+ iframeManager: ie,
3142
+ stylesheetManager: te,
3143
+ shadowDomManager: me,
3144
+ canvasManager: $e,
3145
+ ignoreCSSAttributes: X,
3146
+ plugins: ((Y = H == null ? void 0 : H.filter((A) => A.observer)) === null || Y === void 0 ? void 0 : Y.map((A) => ({
3147
+ observer: A.observer,
3148
+ options: A.options,
3149
+ callback: (Z) => _(L({
3150
+ type: v.Plugin,
3151
+ data: {
3152
+ plugin: A.name,
3153
+ payload: Z
3154
+ }
3155
+ }))
3156
+ }))) || []
3157
+ }, y);
3158
+ };
3159
+ ie.addLoadListener((T) => {
3160
+ I.push(W(T.contentDocument));
3161
+ });
3162
+ const P = () => {
3163
+ Ue(), I.push(W(document)), je = !0;
3164
+ };
3165
+ return document.readyState === "interactive" || document.readyState === "complete" ? P() : I.push(G("load", () => {
3166
+ _(L({
3167
+ type: v.Load,
3168
+ data: {}
3169
+ })), P();
3170
+ }, window)), () => {
3171
+ I.forEach((T) => T()), je = !1;
3172
+ };
3173
+ } catch (I) {
3174
+ console.warn(I);
3175
+ }
3176
+ }
3177
+ Re.addCustomEvent = (e, t) => {
3178
+ if (!je)
3179
+ throw new Error("please add custom event after start recording");
3180
+ _(L({
3181
+ type: v.Custom,
3182
+ data: {
3183
+ tag: e,
3184
+ payload: t
3185
+ }
3186
+ }));
3187
+ };
3188
+ Re.freezePage = () => {
3189
+ ue.forEach((e) => e.freeze());
3190
+ };
3191
+ Re.takeFullSnapshot = (e) => {
3192
+ if (!je)
3193
+ throw new Error("please take full snapshot after start recording");
3194
+ Ue(e);
3195
+ };
3196
+ Re.mirror = ne;
3197
+ const { addCustomEvent: ts } = Re;
3198
+ class Ie {
3199
+ constructor(t) {
3200
+ this.fileName = t.fileName || "", this.functionName = t.functionName || "", this.lineNumber = t.lineNumber, this.columnNumber = t.columnNumber;
3201
+ }
3202
+ toString() {
3203
+ const t = this.lineNumber || "", r = this.columnNumber || "";
3204
+ return this.functionName ? `${this.functionName} (${this.fileName}:${t}:${r})` : `${this.fileName}:${t}:${r}`;
3205
+ }
3206
+ }
3207
+ const rs = /(^|@)\S+:\d+/, xt = /^\s*at .*(\S+:\d+|\(native\))/m, ns = /^(eval@)?(\[native code])?$/, Dt = {
3208
+ parse: function(e) {
3209
+ if (!e)
3210
+ return [];
3211
+ if (typeof e.stacktrace < "u" || typeof e["opera#sourceloc"] < "u")
3212
+ return this.parseOpera(e);
3213
+ if (e.stack && e.stack.match(xt))
3214
+ return this.parseV8OrIE(e);
3215
+ if (e.stack)
3216
+ return this.parseFFOrSafari(e);
3217
+ throw new Error("Cannot parse given Error object");
3218
+ },
3219
+ extractLocation: function(e) {
3220
+ if (e.indexOf(":") === -1)
3221
+ return [e];
3222
+ const r = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g, ""));
3223
+ if (!r)
3224
+ throw new Error(`Cannot parse given url: ${e}`);
3225
+ return [r[1], r[2] || void 0, r[3] || void 0];
3226
+ },
3227
+ parseV8OrIE: function(e) {
3228
+ return e.stack.split(`
3229
+ `).filter(function(r) {
3230
+ return !!r.match(xt);
3231
+ }, this).map(function(r) {
3232
+ r.indexOf("(eval ") > -1 && (r = r.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, ""));
3233
+ let n = r.replace(/^\s+/, "").replace(/\(eval code/g, "(");
3234
+ const s = n.match(/ (\((.+):(\d+):(\d+)\)$)/);
3235
+ n = s ? n.replace(s[0], "") : n;
3236
+ const i = n.split(/\s+/).slice(1), a = this.extractLocation(s ? s[1] : i.pop()), o = i.join(" ") || void 0, c = ["eval", "<anonymous>"].indexOf(a[0]) > -1 ? void 0 : a[0];
3237
+ return new Ie({
3238
+ functionName: o,
3239
+ fileName: c,
3240
+ lineNumber: a[1],
3241
+ columnNumber: a[2]
3242
+ });
3243
+ }, this);
3244
+ },
3245
+ parseFFOrSafari: function(e) {
3246
+ return e.stack.split(`
3247
+ `).filter(function(r) {
3248
+ return !r.match(ns);
3249
+ }, this).map(function(r) {
3250
+ if (r.indexOf(" > eval") > -1 && (r = r.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), r.indexOf("@") === -1 && r.indexOf(":") === -1)
3251
+ return new Ie({
3252
+ functionName: r
3253
+ });
3254
+ {
3255
+ const n = /((.*".+"[^@]*)?[^@]*)(?:@)/, s = r.match(n), i = s && s[1] ? s[1] : void 0, a = this.extractLocation(r.replace(n, ""));
3256
+ return new Ie({
3257
+ functionName: i,
3258
+ fileName: a[0],
3259
+ lineNumber: a[1],
3260
+ columnNumber: a[2]
3261
+ });
3262
+ }
3263
+ }, this);
3264
+ },
3265
+ parseOpera: function(e) {
3266
+ return !e.stacktrace || e.message.indexOf(`
3267
+ `) > -1 && e.message.split(`
3268
+ `).length > e.stacktrace.split(`
3269
+ `).length ? this.parseOpera9(e) : e.stack ? this.parseOpera11(e) : this.parseOpera10(e);
3270
+ },
3271
+ parseOpera9: function(e) {
3272
+ const t = /Line (\d+).*script (?:in )?(\S+)/i, r = e.message.split(`
3273
+ `), n = [];
3274
+ for (let s = 2, i = r.length; s < i; s += 2) {
3275
+ const a = t.exec(r[s]);
3276
+ a && n.push(new Ie({
3277
+ fileName: a[2],
3278
+ lineNumber: parseFloat(a[1])
3279
+ }));
3280
+ }
3281
+ return n;
3282
+ },
3283
+ parseOpera10: function(e) {
3284
+ const t = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i, r = e.stacktrace.split(`
3285
+ `), n = [];
3286
+ for (let s = 0, i = r.length; s < i; s += 2) {
3287
+ const a = t.exec(r[s]);
3288
+ a && n.push(new Ie({
3289
+ functionName: a[3] || void 0,
3290
+ fileName: a[2],
3291
+ lineNumber: parseFloat(a[1])
3292
+ }));
3293
+ }
3294
+ return n;
3295
+ },
3296
+ parseOpera11: function(e) {
3297
+ return e.stack.split(`
3298
+ `).filter(function(r) {
3299
+ return !!r.match(rs) && !r.match(/^Error created at/);
3300
+ }, this).map(function(r) {
3301
+ const n = r.split("@"), s = this.extractLocation(n.pop()), a = (n.shift() || "").replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
3302
+ return new Ie({
3303
+ functionName: a,
3304
+ fileName: s[0],
3305
+ lineNumber: s[1],
3306
+ columnNumber: s[2]
3307
+ });
3308
+ }, this);
3309
+ }
3310
+ };
3311
+ function ss(e) {
3312
+ if (!e || !e.outerHTML)
3313
+ return "";
3314
+ let t = "";
3315
+ for (; e.parentElement; ) {
3316
+ let r = e.localName;
3317
+ if (!r)
3318
+ break;
3319
+ r = r.toLowerCase();
3320
+ const n = e.parentElement, s = [];
3321
+ if (n.children && n.children.length > 0)
3322
+ for (let i = 0; i < n.children.length; i++) {
3323
+ const a = n.children[i];
3324
+ a.localName && a.localName.toLowerCase && a.localName.toLowerCase() === r && s.push(a);
3325
+ }
3326
+ s.length > 1 && (r += `:eq(${s.indexOf(e)})`), t = r + (t ? ">" + t : ""), e = n;
3327
+ }
3328
+ return t;
3329
+ }
3330
+ function dt(e) {
3331
+ return Object.prototype.toString.call(e) === "[object Object]";
3332
+ }
3333
+ function Ir(e, t) {
3334
+ if (t === 0)
3335
+ return !0;
3336
+ const r = Object.keys(e);
3337
+ for (const n of r)
3338
+ if (dt(e[n]) && Ir(e[n], t - 1))
3339
+ return !0;
3340
+ return !1;
3341
+ }
3342
+ function et(e, t) {
3343
+ const r = {
3344
+ numOfKeysLimit: 50,
3345
+ depthOfLimit: 4
3346
+ };
3347
+ Object.assign(r, t);
3348
+ const n = [], s = [];
3349
+ return JSON.stringify(e, function(o, c) {
3350
+ if (n.length > 0) {
3351
+ const d = n.indexOf(this);
3352
+ ~d ? n.splice(d + 1) : n.push(this), ~d ? s.splice(d, 1 / 0, o) : s.push(o), ~n.indexOf(c) && (n[0] === c ? c = "[Circular ~]" : c = "[Circular ~." + s.slice(0, n.indexOf(c)).join(".") + "]");
3353
+ } else
3354
+ n.push(c);
3355
+ if (c === null)
3356
+ return c;
3357
+ if (c === void 0)
3358
+ return "undefined";
3359
+ if (i(c))
3360
+ return a(c);
3361
+ if (c instanceof Event) {
3362
+ const d = {};
3363
+ for (const l in c) {
3364
+ const u = c[l];
3365
+ Array.isArray(u) ? d[l] = ss(u.length ? u[0] : null) : d[l] = u;
3366
+ }
3367
+ return d;
3368
+ } else {
3369
+ if (c instanceof Node)
3370
+ return c instanceof HTMLElement ? c ? c.outerHTML : "" : c.nodeName;
3371
+ if (c instanceof Error)
3372
+ return c.stack ? c.stack + `
3373
+ End of stack for Error object` : c.name + ": " + c.message;
3374
+ }
3375
+ return c;
3376
+ });
3377
+ function i(o) {
3378
+ return !!(dt(o) && Object.keys(o).length > r.numOfKeysLimit || typeof o == "function" || dt(o) && Ir(o, r.depthOfLimit));
3379
+ }
3380
+ function a(o) {
3381
+ let c = o.toString();
3382
+ return r.stringLengthLimit && c.length > r.stringLengthLimit && (c = `${c.slice(0, r.stringLengthLimit)}...`), c;
3383
+ }
3384
+ }
3385
+ const Bt = {
3386
+ level: [
3387
+ "assert",
3388
+ "clear",
3389
+ "count",
3390
+ "countReset",
3391
+ "debug",
3392
+ "dir",
3393
+ "dirxml",
3394
+ "error",
3395
+ "group",
3396
+ "groupCollapsed",
3397
+ "groupEnd",
3398
+ "info",
3399
+ "log",
3400
+ "table",
3401
+ "time",
3402
+ "timeEnd",
3403
+ "timeLog",
3404
+ "trace",
3405
+ "warn"
3406
+ ],
3407
+ lengthThreshold: 1e3,
3408
+ logger: "console"
3409
+ };
3410
+ function is(e, t, r) {
3411
+ const n = r ? Object.assign({}, Bt, r) : Bt, s = n.logger;
3412
+ if (!s)
3413
+ return () => {
3414
+ };
3415
+ let i;
3416
+ typeof s == "string" ? i = t[s] : i = s;
3417
+ let a = 0;
3418
+ const o = [];
3419
+ if (n.level.includes("error") && window) {
3420
+ const d = (l) => {
3421
+ const u = l.message, h = l.error, f = Dt.parse(h).map((y) => y.toString()), p = [et(u, n.stringifyOptions)];
3422
+ e({
3423
+ level: "error",
3424
+ trace: f,
3425
+ payload: p
3426
+ });
3427
+ };
3428
+ window.addEventListener("error", d), o.push(() => {
3429
+ window && window.removeEventListener("error", d);
3430
+ });
3431
+ }
3432
+ for (const d of n.level)
3433
+ o.push(c(i, d));
3434
+ return () => {
3435
+ o.forEach((d) => d());
3436
+ };
3437
+ function c(d, l) {
3438
+ return d[l] ? he(d, l, (u) => (...h) => {
3439
+ u.apply(this, h);
3440
+ try {
3441
+ const f = Dt.parse(new Error()).map((y) => y.toString()).splice(1), p = h.map((y) => et(y, n.stringifyOptions));
3442
+ a++, a < n.lengthThreshold ? e({
3443
+ level: l,
3444
+ trace: f,
3445
+ payload: p
3446
+ }) : a === n.lengthThreshold && e({
3447
+ level: "warn",
3448
+ trace: [],
3449
+ payload: [
3450
+ et("The number of log records reached the threshold.")
3451
+ ]
3452
+ });
3453
+ } catch (f) {
3454
+ u("rrweb logger error:", f, ...h);
3455
+ }
3456
+ }) : () => {
3457
+ };
3458
+ }
3459
+ }
3460
+ const as = "rrweb/console@1", os = (e) => ({
3461
+ name: as,
3462
+ observer: is,
3463
+ options: e
3464
+ }), cs = "application/json", ds = "flashlog", ls = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`, Te = () => typeof window < "u" && window.location ? window.location.href : "", Ut = (e) => new Date(typeof e == "number" ? e : Date.now()).toISOString(), tt = async (e) => {
3465
+ try {
3466
+ return await e.json();
3467
+ } catch {
3468
+ return null;
3469
+ }
3470
+ };
3471
+ class Wt extends Error {
3472
+ constructor(t) {
3473
+ super(t), this.name = "ReplayQuotaError";
3474
+ }
3475
+ }
3476
+ class us {
3477
+ constructor() {
3478
+ this.config = null, this.currentBytes = 0, this.currentEvents = [], this.detachListeners = [], this.finalized = !1, this.flushInFlight = null, this.flushTimer = null, this.replaySessionId = null, this.segmentSequence = 0;
3479
+ }
3480
+ async start(t) {
3481
+ await this.dispose({
3482
+ finalize: !0,
3483
+ keepalive: !1,
3484
+ reason: "reinit"
3485
+ }), !(typeof window > "u" || typeof document > "u") && (this.config = t, this.currentBytes = 0, this.currentEvents = [], this.detachListeners = [], this.finalized = !1, this.flushInFlight = null, this.replaySessionId = null, this.segmentSequence = 0, this.stopRecording = Re({
3486
+ emit: (r) => this.pushEvent(r),
3487
+ collectFonts: !0,
3488
+ inlineStylesheet: !0,
3489
+ maskAllInputs: t.maskAllInputs,
3490
+ userTriggeredOnInput: !0,
3491
+ plugins: [os()]
3492
+ }) || void 0, this.bindLifecycleListeners(), this.flushTimer = window.setInterval(() => {
3493
+ this.flush("interval");
3494
+ }, t.flushIntervalMs), this.addCustomEvent("session-start", {
3495
+ session_id: t.sessionId,
3496
+ brand_id: t.brandId,
3497
+ device_id: t.deviceId,
3498
+ page_url: Te(),
3499
+ started_at: (/* @__PURE__ */ new Date()).toISOString()
3500
+ }));
3501
+ }
3502
+ async flush(t = "manual", r) {
3503
+ if (this.flushInFlight)
3504
+ return this.flushInFlight;
3505
+ if (!this.config || this.finalized)
3506
+ return null;
3507
+ const n = this.takePendingSegment();
3508
+ return n ? (this.flushInFlight = this.uploadSegment(
3509
+ n,
3510
+ t,
3511
+ (r == null ? void 0 : r.keepalive) === !0
3512
+ ).catch((s) => s instanceof Wt ? (this.currentBytes = 0, this.currentEvents = [], this.finalized = !0, this.stopCapture(), this.debug("Replay capture stopped by server quota", {
3513
+ message: s.message,
3514
+ reason: t,
3515
+ segmentId: n.segmentId
3516
+ }), null) : (this.restorePendingSegment(n), this.debug("Replay upload failed", {
3517
+ message: s instanceof Error ? s.message : String(s),
3518
+ reason: t,
3519
+ segmentId: n.segmentId
3520
+ }), null)).finally(() => {
3521
+ this.flushInFlight = null;
3522
+ }), this.flushInFlight) : null;
3523
+ }
3524
+ async finalize(t = "manual", r) {
3525
+ if (!this.config || this.finalized)
3526
+ return null;
3527
+ this.addCustomEvent("session-finalize", {
3528
+ reason: t,
3529
+ page_url: Te(),
3530
+ session_id: this.config.sessionId,
3531
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
3532
+ }), this.stopCapture();
3533
+ const n = await this.flush(t, {
3534
+ keepalive: (r == null ? void 0 : r.keepalive) === !0
3535
+ });
3536
+ if (this.replaySessionId = (n == null ? void 0 : n.replay_session_id) || this.replaySessionId, this.finalized = !0, !this.replaySessionId)
3537
+ return this.config = null, null;
3538
+ const s = this.config, i = `${s.apiUrl.replace(/\/+$/, "")}/v1/session-replays/public/finalize`, a = await fetch(i, {
3539
+ body: JSON.stringify({
3540
+ brand_id: s.brandId,
3541
+ device_id: s.deviceId,
3542
+ finalized_reason: t,
3543
+ page_url: Te(),
3544
+ replay_session_id: this.replaySessionId,
3545
+ session_id: s.sessionId
3546
+ }),
3547
+ headers: {
3548
+ "Content-Type": "application/json",
3549
+ "x-api-key": s.apiKey
3550
+ },
3551
+ keepalive: (r == null ? void 0 : r.keepalive) === !0,
3552
+ method: "POST"
3553
+ }).catch((c) => (this.debug("Replay finalize failed", {
3554
+ message: c instanceof Error ? c.message : String(c),
3555
+ reason: t
3556
+ }), null));
3557
+ if (this.config = null, !a)
3558
+ return null;
3559
+ const o = await tt(
3560
+ a
3561
+ );
3562
+ return a.ok ? (o == null ? void 0 : o.data) || null : (this.debug("Replay finalize returned non-200", {
3563
+ message: (o == null ? void 0 : o.message) || `HTTP ${a.status}`,
3564
+ reason: t
3565
+ }), null);
3566
+ }
3567
+ async dispose(t) {
3568
+ if ((t == null ? void 0 : t.finalize) === !0 && !!this.config && !this.finalized) {
3569
+ await this.finalize((t == null ? void 0 : t.reason) || "dispose", {
3570
+ keepalive: (t == null ? void 0 : t.keepalive) === !0
3571
+ }).catch(() => null);
3572
+ return;
3573
+ }
3574
+ this.stopCapture(), this.config = null, this.currentBytes = 0, this.currentEvents = [], this.flushInFlight = null, this.finalized = !0, this.replaySessionId = null, this.segmentSequence = 0;
3575
+ }
3576
+ addCustomEvent(t, r) {
3577
+ if (!(!this.config || this.finalized))
3578
+ try {
3579
+ ts(`${ds}:${t}`, r);
3580
+ } catch (n) {
3581
+ this.debug("Replay custom event skipped", {
3582
+ message: n instanceof Error ? n.message : String(n),
3583
+ tag: t
3584
+ });
3585
+ }
3586
+ }
3587
+ bindLifecycleListeners() {
3588
+ if (typeof window > "u" || typeof document > "u")
3589
+ return;
3590
+ const t = () => {
3591
+ document.visibilityState === "hidden" && this.flush("visibility-hidden", { keepalive: !0 });
3592
+ }, r = () => {
3593
+ this.finalize("pagehide", { keepalive: !0 });
3594
+ }, n = () => {
3595
+ this.flush("beforeunload", { keepalive: !0 });
3596
+ };
3597
+ document.addEventListener("visibilitychange", t, !0), window.addEventListener("pagehide", r), window.addEventListener("beforeunload", n), this.detachListeners = [
3598
+ () => document.removeEventListener("visibilitychange", t, !0),
3599
+ () => window.removeEventListener("pagehide", r),
3600
+ () => window.removeEventListener("beforeunload", n)
3601
+ ];
3602
+ }
3603
+ debug(t, r) {
3604
+ var n;
3605
+ (n = this.config) != null && n.debug && console.log("[FlashlogTracker][Replay]", t, r || {});
3606
+ }
3607
+ pushEvent(t) {
3608
+ !this.config || this.finalized || (this.currentEvents.push(t), this.currentBytes += this.estimateEventSize(t), (this.currentBytes >= this.config.maxSegmentBytes || this.currentEvents.length >= this.config.maxSegmentEvents) && this.flush("buffer-threshold"));
3609
+ }
3610
+ estimateEventSize(t) {
3611
+ try {
3612
+ return JSON.stringify(t).length;
3613
+ } catch {
3614
+ return 0;
3615
+ }
3616
+ }
3617
+ nextSegmentId(t) {
3618
+ return `segment-${String(t).padStart(6, "0")}-${ls()}`;
3619
+ }
3620
+ restorePendingSegment(t) {
3621
+ this.currentEvents = [...t.events, ...this.currentEvents], this.currentBytes += t.sizeBytes, this.segmentSequence = Math.min(this.segmentSequence, t.sequenceNumber);
3622
+ }
3623
+ stopCapture() {
3624
+ var t;
3625
+ (t = this.stopRecording) == null || t.call(this), this.stopRecording = void 0, this.flushTimer !== null && typeof window < "u" && (window.clearInterval(this.flushTimer), this.flushTimer = null), this.detachListeners.forEach((r) => r()), this.detachListeners = [];
3626
+ }
3627
+ takePendingSegment() {
3628
+ var s, i;
3629
+ if (this.currentEvents.length === 0)
3630
+ return null;
3631
+ const t = this.currentEvents, r = this.currentBytes, n = this.segmentSequence;
3632
+ return this.currentEvents = [], this.currentBytes = 0, this.segmentSequence += 1, {
3633
+ endedAt: Ut((s = t[t.length - 1]) == null ? void 0 : s.timestamp),
3634
+ eventCount: t.length,
3635
+ events: t,
3636
+ segmentId: this.nextSegmentId(n),
3637
+ sequenceNumber: n,
3638
+ sizeBytes: r,
3639
+ startedAt: Ut((i = t[0]) == null ? void 0 : i.timestamp)
3640
+ };
3641
+ }
3642
+ async uploadSegment(t, r, n) {
3643
+ var h;
3644
+ if (!this.config)
3645
+ throw new Error("Replay recorder is not configured");
3646
+ const s = this.config, i = `${s.apiUrl.replace(
3647
+ /\/+$/,
3648
+ ""
3649
+ )}/v1/session-replays/public/segments/upload-url`, a = {
3650
+ brand_id: s.brandId,
3651
+ content_type: cs,
3652
+ device_id: s.deviceId,
3653
+ ended_at: t.endedAt,
3654
+ event_count: t.eventCount,
3655
+ page_url: Te(),
3656
+ replay_session_id: this.replaySessionId,
3657
+ segment_id: t.segmentId,
3658
+ sequence_number: t.sequenceNumber,
3659
+ session_id: s.sessionId,
3660
+ started_at: t.startedAt,
3661
+ upload_reason: r
3662
+ }, o = await fetch(i, {
3663
+ body: JSON.stringify(a),
3664
+ headers: {
3665
+ "Content-Type": "application/json",
3666
+ "x-api-key": s.apiKey
3667
+ },
3668
+ keepalive: n,
3669
+ method: "POST"
3670
+ }), c = await tt(o);
3671
+ if (!o.ok || !((h = c == null ? void 0 : c.data) != null && h.upload_url)) {
3672
+ const f = c == null ? void 0 : c.message, p = typeof f == "object" && f ? f.code : c == null ? void 0 : c.code, y = typeof f == "object" && f ? f.message : f;
3673
+ throw o.status === 403 && typeof p == "string" && p.startsWith("REPLAY_") ? new Wt(y || "Replay capture quota exhausted") : new Error(
3674
+ y || `Failed to create replay upload URL (${o.status})`
3675
+ );
3676
+ }
3677
+ this.replaySessionId = c.data.replay_session_id || this.replaySessionId;
3678
+ const d = JSON.stringify({
3679
+ events: t.events,
3680
+ meta: {
3681
+ brand_id: s.brandId,
3682
+ device_id: s.deviceId,
3683
+ ended_at: t.endedAt,
3684
+ event_count: t.eventCount,
3685
+ page_url: Te(),
3686
+ reason: r,
3687
+ segment_id: t.segmentId,
3688
+ sequence_number: t.sequenceNumber,
3689
+ session_id: s.sessionId,
3690
+ started_at: t.startedAt
3691
+ },
3692
+ source: "flashlog-tracker-sdk",
3693
+ type: "rrweb-event-segment",
3694
+ version: 1
3695
+ }), l = await fetch(c.data.upload_url, {
3696
+ body: d,
3697
+ headers: {
3698
+ "Content-Type": "application/octet-stream"
3699
+ },
3700
+ keepalive: n,
3701
+ method: c.data.method || "PUT"
3702
+ }), u = await tt(l);
3703
+ if (!l.ok || !(u != null && u.data))
3704
+ throw new Error(
3705
+ (u == null ? void 0 : u.message) || `Replay segment upload failed (${l.status})`
3706
+ );
3707
+ return this.debug("Replay segment uploaded", {
3708
+ objectKey: u.data.object_key,
3709
+ reason: r,
3710
+ segmentId: u.data.segment_id,
3711
+ sequenceNumber: u.data.sequence_number
3712
+ }), u.data;
3713
+ }
3714
+ }
3715
+ const ht = () => typeof window < "u" && typeof window.localStorage < "u", Cr = () => {
3716
+ if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
3717
+ return crypto.randomUUID();
3718
+ const e = Date.now().toString(36), t = Math.random().toString(36).slice(2, 12);
3719
+ return `${e}-${t}`;
3720
+ }, fe = (e) => ht() ? window.localStorage.getItem(e) : null, pe = (e, t) => {
3721
+ ht() && window.localStorage.setItem(e, t);
3722
+ }, Ae = (e) => {
3723
+ ht() && window.localStorage.removeItem(e);
3724
+ }, ps = (e) => {
3725
+ const t = fe(e);
3726
+ if (!t) return null;
3727
+ try {
3728
+ return JSON.parse(t);
3729
+ } catch {
3730
+ return null;
3731
+ }
3732
+ }, hs = (e, t) => {
3733
+ pe(e, JSON.stringify(t));
3734
+ }, zt = () => {
3735
+ const e = fe(M.deviceId);
3736
+ if (e) return e;
3737
+ const t = Cr();
3738
+ return pe(M.deviceId, t), t;
3739
+ }, Gt = (e) => {
3740
+ const t = Date.now(), r = fe(M.sessionId), n = fe(M.sessionSeenAt), s = n ? Number(n) : NaN, i = Number.isFinite(s) && t - s <= e;
3741
+ if (r && i)
3742
+ return pe(M.sessionSeenAt, String(t)), r;
3743
+ const a = Cr();
3744
+ return pe(M.sessionId, a), pe(M.sessionSeenAt, String(t)), a;
3745
+ }, fs = () => {
3746
+ pe(M.sessionSeenAt, String(Date.now()));
3747
+ }, ms = () => fe(M.sessionId), gs = () => fe(M.deviceId), ys = (e, t) => {
3748
+ if (pe(M.accountId, e), t && Object.keys(t).length > 0) {
3749
+ hs(M.accountTraits, t);
3750
+ return;
3751
+ }
3752
+ Ae(M.accountTraits);
3753
+ }, Is = () => fe(M.accountId), Cs = () => ps(M.accountTraits), Sr = () => {
3754
+ Ae(M.accountId), Ae(M.accountTraits);
3755
+ }, Ss = () => {
3756
+ Ae(M.sessionId), Ae(M.sessionSeenAt), Ae(M.deviceId), Sr();
3757
+ }, Kt = (e, t) => Array.from(/* @__PURE__ */ new Set([...e, ...t || []])), bs = (e) => {
3758
+ var t, r;
3759
+ return {
3760
+ apiUrl: ((t = e == null ? void 0 : e.apiUrl) == null ? void 0 : t.trim()) || w.apiUrl,
3761
+ apiKey: (e == null ? void 0 : e.apiKey) ?? w.apiKey,
3762
+ debug: (e == null ? void 0 : e.debug) ?? w.debug,
3763
+ autoCapture: (e == null ? void 0 : e.autoCapture) ?? w.autoCapture,
3764
+ captureNetworkErrors: (e == null ? void 0 : e.captureNetworkErrors) ?? w.captureNetworkErrors,
3765
+ captureJsErrors: (e == null ? void 0 : e.captureJsErrors) ?? w.captureJsErrors,
3766
+ captureSocketErrors: (e == null ? void 0 : e.captureSocketErrors) ?? w.captureSocketErrors,
3767
+ sessionTimeoutMs: (e == null ? void 0 : e.sessionTimeoutMs) ?? w.sessionTimeoutMs,
3768
+ maxActionBufferSize: (e == null ? void 0 : e.maxActionBufferSize) ?? w.maxActionBufferSize,
3769
+ allowNonErrorEvents: (e == null ? void 0 : e.allowNonErrorEvents) ?? w.allowNonErrorEvents,
3770
+ ignoredStatusCodes: (e == null ? void 0 : e.ignoredStatusCodes) || w.ignoredStatusCodes,
3771
+ ignoredUrls: (e == null ? void 0 : e.ignoredUrls) || w.ignoredUrls,
3772
+ captureRequestBody: (e == null ? void 0 : e.captureRequestBody) ?? w.captureRequestBody,
3773
+ captureResponseBody: (e == null ? void 0 : e.captureResponseBody) ?? w.captureResponseBody,
3774
+ redactKeys: Kt(w.redactKeys, e == null ? void 0 : e.redactKeys),
3775
+ redactUrlParams: Kt(w.redactUrlParams, e == null ? void 0 : e.redactUrlParams),
3776
+ propagateTraceHeaders: (e == null ? void 0 : e.propagateTraceHeaders) ?? w.propagateTraceHeaders,
3777
+ traceOrigins: (e == null ? void 0 : e.traceOrigins) || w.traceOrigins,
3778
+ traceHeaderName: ((r = e == null ? void 0 : e.traceHeaderName) == null ? void 0 : r.trim()) || w.traceHeaderName,
3779
+ enableSessionReplay: (e == null ? void 0 : e.enableSessionReplay) ?? w.enableSessionReplay,
3780
+ replayFlushIntervalMs: (e == null ? void 0 : e.replayFlushIntervalMs) ?? w.replayFlushIntervalMs,
3781
+ replayMaxSegmentBytes: (e == null ? void 0 : e.replayMaxSegmentBytes) ?? w.replayMaxSegmentBytes,
3782
+ replayMaxSegmentEvents: (e == null ? void 0 : e.replayMaxSegmentEvents) ?? w.replayMaxSegmentEvents,
3783
+ replayMaskAllInputs: (e == null ? void 0 : e.replayMaskAllInputs) ?? w.replayMaskAllInputs
3784
+ };
3785
+ }, B = () => typeof window < "u" && window.location ? window.location.href : "", le = () => typeof document < "u" && document.title || "", vs = /* @__PURE__ */ new Set(["beacon", "fetch", "xmlhttprequest"]), Ce = 1e3, We = () => typeof performance < "u" && Number.isFinite(performance.timeOrigin) ? performance.timeOrigin : Date.now(), ws = (e) => {
3786
+ const t = String(e.initiatorType || "").toLowerCase(), r = String(e.name || "").toLowerCase();
3787
+ return t === "fetch" || t === "xmlhttprequest" || t === "beacon" ? "xhr" : t === "css" || t === "link" || r.endsWith(".css") || r.includes(".css?") ? "css" : t === "script" || r.endsWith(".js") || r.includes(".js?") ? "js" : t === "img" || t === "image" || /\.(png|jpg|jpeg|gif|svg|webp|avif|ico)(\?|$)/.test(r) ? "images" : t === "font" || /\.(woff|woff2|ttf|otf|eot)(\?|$)/.test(r) ? "fonts" : "other";
3788
+ }, As = (e) => {
3789
+ if (!(e != null && e.name))
3790
+ return !1;
3791
+ if (e.entryType === "navigation")
3792
+ return !0;
3793
+ const t = String(e.initiatorType || "").toLowerCase();
3794
+ return vs.has(t) ? !1 : !/^wss?:/i.test(e.name);
3795
+ }, ks = (e) => {
3796
+ const t = Number(e.responseStatus);
3797
+ if (Number.isFinite(t) && t > 0)
3798
+ return t;
3799
+ if (e.entryType === "navigation")
3800
+ return 200;
3801
+ const r = Number(e.transferSize || 0), n = Number(e.encodedBodySize || 0), s = Number(e.decodedBodySize || 0);
3802
+ return r > 0 || n > 0 || s > 0 ? 200 : null;
3803
+ }, Rs = (e) => Math.round(We() + Math.max(0, Number(e.startTime || 0))), rt = (e) => Math.round(e / (1024 * 1024) * 10) / 10, Es = () => {
3804
+ if (typeof performance > "u")
3805
+ return null;
3806
+ const e = performance.memory;
3807
+ if (!e)
3808
+ return null;
3809
+ const t = Number(e.usedJSHeapSize || 0), r = Number(e.totalJSHeapSize || 0), n = Number(e.jsHeapSizeLimit || 0);
3810
+ return t <= 0 && r <= 0 && n <= 0 ? null : {
3811
+ js_heap_limit_mb: rt(n),
3812
+ total_js_heap_mb: rt(r),
3813
+ used_js_heap_mb: rt(t)
3814
+ };
3815
+ }, Ts = () => {
3816
+ if (typeof performance > "u")
3817
+ return null;
3818
+ const e = performance.getEntriesByType("navigation")[0], t = performance.getEntriesByName("first-contentful-paint")[0];
3819
+ if (!e && !t)
3820
+ return null;
3821
+ const r = {};
3822
+ return e && (r.dom_content_loaded_ms = Math.round(e.domContentLoadedEventEnd || 0), r.load_event_ms = Math.round(e.loadEventEnd || 0), r.response_end_ms = Math.round(e.responseEnd || 0), r.dom_complete_ms = Math.round(e.domComplete || 0), r.transfer_size = Math.round(e.transferSize || 0)), t && (r.first_contentful_paint_ms = Math.round(t.startTime || 0)), Object.keys(r).length > 0 ? r : null;
3823
+ };
3824
+ class _s {
3825
+ constructor() {
3826
+ this.config = w, this.brandId = null, this.sessionId = null, this.deviceId = null, this.accountId = null, this.accountTraits = null, this.errorCapture = null, this.initialized = !1, this.performanceObservers = [], this.performanceSampleTimer = null, this.pendingLongTaskMs = 0, this.resourceObserver = null, this.replayResourceKeys = /* @__PURE__ */ new Set(), this.nextPerformanceSampleAt = 0, this.actionBuffer = new Br(w.maxActionBufferSize), this.replayRecorder = new us();
3827
+ }
3828
+ async init(t, r) {
3829
+ var i;
3830
+ const n = Number(t);
3831
+ if (!Number.isFinite(n) || n <= 0)
3832
+ throw new Error("[FlashlogTracker] Invalid brand id");
3833
+ const s = bs(r);
3834
+ if (!s.apiKey || !s.apiKey.trim())
3835
+ throw new Error("[FlashlogTracker] Missing api key");
3836
+ this.config = {
3837
+ ...s,
3838
+ apiKey: s.apiKey.trim()
3839
+ }, this.brandId = n, this.sessionId = Gt(this.config.sessionTimeoutMs), this.deviceId = zt(), this.accountId = Is(), this.accountTraits = Cs(), this.actionBuffer.stop(), this.actionBuffer.clear(), this.actionBuffer.start(), this.stopReplayResourceCapture(), await this.replayRecorder.dispose({
3840
+ finalize: !0,
3841
+ keepalive: !1,
3842
+ reason: "reinit"
3843
+ }), (i = this.errorCapture) == null || i.stop(), this.errorCapture = null, this.config.autoCapture && (this.errorCapture = new Vr(this.config, {
3844
+ debug: this.config.debug,
3845
+ onNetworkActivity: (a) => {
3846
+ this.replayRecorder.addCustomEvent("network-activity", {
3847
+ ...a,
3848
+ page_title: le(),
3849
+ session_id: this.sessionId,
3850
+ url_bug_happened: B()
3851
+ });
3852
+ },
3853
+ onNetworkError: (a) => {
3854
+ this.trackInternal("NETWORK_ERROR", {
3855
+ ...a,
3856
+ error_type: "network_error",
3857
+ url_bug_happened: B(),
3858
+ url: String(a.url || "")
3859
+ });
3860
+ },
3861
+ onSocketError: (a) => {
3862
+ this.trackInternal("SOCKET_ERROR", {
3863
+ ...a,
3864
+ error_type: "socket_error",
3865
+ url_bug_happened: B(),
3866
+ url: String(a.url || "")
3867
+ });
3868
+ },
3869
+ onJsError: (a) => {
3870
+ this.trackInternal("JS_ERROR", {
3871
+ ...a,
3872
+ error_type: "js_error",
3873
+ url_bug_happened: B(),
3874
+ url: B()
3875
+ });
3876
+ },
3877
+ onUnhandledRejection: (a) => {
3878
+ this.trackInternal("UNHANDLED_REJECTION", {
3879
+ ...a,
3880
+ error_type: "unhandled_rejection",
3881
+ url_bug_happened: B(),
3882
+ url: B()
3883
+ });
3884
+ }
3885
+ }), this.errorCapture.start()), this.config.enableSessionReplay && (await this.replayRecorder.start({
3886
+ apiKey: this.config.apiKey,
3887
+ apiUrl: this.config.apiUrl,
3888
+ brandId: this.brandId,
3889
+ debug: this.config.debug,
3890
+ deviceId: this.deviceId,
3891
+ flushIntervalMs: this.config.replayFlushIntervalMs,
3892
+ maskAllInputs: this.config.replayMaskAllInputs,
3893
+ maxSegmentBytes: this.config.replayMaxSegmentBytes,
3894
+ maxSegmentEvents: this.config.replayMaxSegmentEvents,
3895
+ sessionId: this.sessionId
3896
+ }), this.recordReplaySessionContext("init"), this.startReplayResourceCapture(), this.startReplayPerformanceCapture()), this.initialized = !0, Vt({
3897
+ apiKey: this.config.apiKey,
3898
+ apiUrl: this.config.apiUrl,
3899
+ brandId: this.brandId,
3900
+ debug: this.config.debug,
3901
+ source: "package"
3902
+ }), this.config.debug && console.log("[FlashlogTracker] Initialized", {
3903
+ brandId: this.brandId,
3904
+ apiUrl: this.config.apiUrl
3905
+ });
3906
+ }
3907
+ async track(t, r = {}) {
3908
+ return !this.config.allowNonErrorEvents && !ft.has(t) ? (this.config.debug && console.warn("[FlashlogTracker] Ignored non-error event", { eventName: t }), !1) : this.trackInternal(t, r);
3909
+ }
3910
+ async reportError(t, r = {}) {
3911
+ const n = t instanceof Error ? t.message : String(t), s = t instanceof Error ? t.stack : void 0;
3912
+ return this.trackInternal("MANUAL_ERROR", {
3913
+ message: n,
3914
+ stack: s,
3915
+ context: r,
3916
+ error_type: "manual_error",
3917
+ url_bug_happened: B(),
3918
+ url: B(),
3919
+ timestamp: Date.now()
3920
+ });
3921
+ }
3922
+ addUserAction(t, r) {
3923
+ this.actionBuffer.add(t, r), this.replayRecorder.addCustomEvent("user-action", {
3924
+ action: t,
3925
+ details: r || null,
3926
+ session_id: this.sessionId,
3927
+ timestamp: Date.now(),
3928
+ url: B()
3929
+ });
3930
+ }
3931
+ identify(t, r = {}) {
3932
+ const n = String(t || "").trim();
3933
+ if (!n)
3934
+ throw new Error("[FlashlogTracker] identify requires a non-empty account id");
3935
+ this.accountId = n, this.accountTraits = Object.keys(r).length > 0 ? r : null, ys(n, this.accountTraits || void 0), this.recordReplaySessionContext("identify");
3936
+ }
3937
+ clearIdentity() {
3938
+ this.accountId = null, this.accountTraits = null, Sr(), this.recordReplaySessionContext("clear-identity");
3939
+ }
3940
+ getTraceHeaders() {
3941
+ return it(Ve(), this.config.traceHeaderName);
3942
+ }
3943
+ getSessionId() {
3944
+ return this.sessionId || ms();
3945
+ }
3946
+ getDeviceId() {
3947
+ return this.deviceId || gs();
3948
+ }
3949
+ async flushReplay(t = "manual") {
3950
+ return this.replayRecorder.flush(t);
3951
+ }
3952
+ async finalizeReplay(t = "manual") {
3953
+ return this.captureReplayPerformanceSample("finalize"), this.stopReplayPerformanceCapture(), this.stopReplayResourceCapture(), this.replayRecorder.finalize(t);
3954
+ }
3955
+ reset() {
3956
+ var t;
3957
+ (t = this.errorCapture) == null || t.stop(), this.errorCapture = null, this.actionBuffer.stop(), this.actionBuffer.clear(), this.stopReplayPerformanceCapture(), this.stopReplayResourceCapture(), this.replayRecorder.dispose({
3958
+ finalize: !0,
3959
+ keepalive: !1,
3960
+ reason: "reset"
3961
+ }), Ss(), this.initialized = !1, this.brandId = null, this.sessionId = null, this.deviceId = null;
3962
+ }
3963
+ buildPayload(t, r, n) {
3964
+ if (!this.brandId || !this.sessionId || !this.deviceId) return null;
3965
+ const s = {
3966
+ actions: this.actionBuffer.getAll(),
3967
+ device_info: It(this.deviceId),
3968
+ network_status: Ct(),
3969
+ url_bug_happened: r.url_bug_happened || B(),
3970
+ trace_id: n.trace_id,
3971
+ span_id: n.span_id,
3972
+ traceparent: n.traceparent,
3973
+ ...this.accountId ? { account_id: this.accountId } : {},
3974
+ ...this.accountTraits ? { account_traits: this.accountTraits } : {},
3975
+ ...r
3976
+ };
3977
+ return {
3978
+ event_name: t,
3979
+ session_id: this.sessionId,
3980
+ brand_id: this.brandId,
3981
+ data: s
3982
+ };
3983
+ }
3984
+ async trackInternal(t, r) {
3985
+ if (!this.initialized)
3986
+ return this.config.debug && console.warn("[FlashlogTracker] Not initialized"), !1;
3987
+ fs(), this.sessionId || (this.sessionId = Gt(this.config.sessionTimeoutMs)), this.deviceId || (this.deviceId = zt());
3988
+ const n = Gr(r), s = this.buildPayload(t, r, n);
3989
+ if (!s) return !1;
3990
+ const i = Mr(s, this.config), a = typeof i.data.status == "number" ? i.data.status : typeof i.data.http_status == "number" ? i.data.http_status : null, o = typeof i.data.method == "string" ? i.data.method.toUpperCase() : typeof i.data.http_method == "string" ? i.data.http_method.toUpperCase() : null, c = typeof i.data.request_url == "string" ? i.data.request_url : typeof i.data.url == "string" ? i.data.url : null;
3991
+ this.replayRecorder.addCustomEvent("tracking-event", {
3992
+ ...i.data,
3993
+ event_name: t,
3994
+ error_type: typeof i.data.error_type == "string" ? i.data.error_type : null,
3995
+ http_method: o,
3996
+ http_status: a,
3997
+ method: o,
3998
+ page_title: le(),
3999
+ request_url: c,
4000
+ session_id: s.session_id,
4001
+ timestamp: typeof i.data.timestamp == "number" ? i.data.timestamp : Date.now()
4002
+ });
4003
+ try {
4004
+ const d = {
4005
+ "Content-Type": "application/json",
4006
+ "x-api-key": this.config.apiKey
4007
+ }, l = `${this.config.apiUrl.replace(/\/$/, "")}/v1/integration/webhook`, u = await fetch(l, {
4008
+ method: "POST",
4009
+ headers: d,
4010
+ body: JSON.stringify(i)
4011
+ });
4012
+ return u.ok ? (ft.has(t) && this.replayRecorder.flush("tracked-error"), !0) : (this.config.debug && console.error("[FlashlogTracker] Track failed", {
4013
+ eventName: t,
4014
+ status: u.status
4015
+ }), !1);
4016
+ } catch (d) {
4017
+ return this.config.debug && console.error("[FlashlogTracker] Track error", d), !1;
4018
+ }
4019
+ }
4020
+ recordReplaySessionContext(t) {
4021
+ !this.config.enableSessionReplay || !this.sessionId || !this.deviceId || this.replayRecorder.addCustomEvent("session-context", {
4022
+ account_id: this.accountId,
4023
+ account_traits: this.accountTraits,
4024
+ device_info: It(this.deviceId),
4025
+ network_status: Ct(),
4026
+ page_title: le(),
4027
+ page_url: B(),
4028
+ performance: Ts(),
4029
+ reason: t,
4030
+ session_id: this.sessionId,
4031
+ timestamp: Date.now()
4032
+ });
4033
+ }
4034
+ stopReplayResourceCapture() {
4035
+ var t;
4036
+ (t = this.resourceObserver) == null || t.disconnect(), this.resourceObserver = null, this.replayResourceKeys.clear();
4037
+ }
4038
+ stopReplayPerformanceCapture() {
4039
+ this.performanceObservers.forEach((t) => t.disconnect()), this.performanceObservers = [], this.performanceSampleTimer !== null && typeof window < "u" && (window.clearTimeout(this.performanceSampleTimer), this.performanceSampleTimer = null), this.pendingLongTaskMs = 0, this.nextPerformanceSampleAt = 0;
4040
+ }
4041
+ startReplayResourceCapture() {
4042
+ if (this.stopReplayResourceCapture(), !(!this.config.enableSessionReplay || !this.sessionId || typeof performance > "u") && (this.captureReplayResourceEntries(
4043
+ performance.getEntriesByType("navigation"),
4044
+ "buffered"
4045
+ ), this.captureReplayResourceEntries(
4046
+ performance.getEntriesByType("resource"),
4047
+ "buffered"
4048
+ ), !(typeof PerformanceObserver > "u")))
4049
+ try {
4050
+ this.resourceObserver = new PerformanceObserver((t) => {
4051
+ this.captureReplayResourceEntries(
4052
+ t.getEntries(),
4053
+ "observed"
4054
+ );
4055
+ }), this.resourceObserver.observe({ entryTypes: ["resource"] });
4056
+ } catch {
4057
+ this.resourceObserver = null;
4058
+ }
4059
+ }
4060
+ startReplayPerformanceCapture() {
4061
+ this.stopReplayPerformanceCapture(), !(!this.config.enableSessionReplay || !this.sessionId || typeof performance > "u" || typeof window > "u") && (this.observeReplayLongTasks(), this.observeReplayLayoutShifts(), this.nextPerformanceSampleAt = performance.now(), this.captureReplayPerformanceSample("start"), this.scheduleReplayPerformanceSample());
4062
+ }
4063
+ scheduleReplayPerformanceSample() {
4064
+ typeof window > "u" || typeof performance > "u" || !this.config.enableSessionReplay || !this.sessionId || (this.performanceSampleTimer = window.setTimeout(() => {
4065
+ this.captureReplayPerformanceSample("interval"), this.scheduleReplayPerformanceSample();
4066
+ }, Ce));
4067
+ }
4068
+ captureReplayPerformanceSample(t) {
4069
+ if (!this.sessionId || typeof performance > "u" || !this.config.enableSessionReplay)
4070
+ return;
4071
+ const r = performance.now(), n = this.nextPerformanceSampleAt || r, s = Math.max(0, r - n);
4072
+ this.nextPerformanceSampleAt = r + Ce;
4073
+ const i = Math.min(
4074
+ 100,
4075
+ Math.round(
4076
+ Math.min(Ce, s) / Ce * 100 + Math.min(Ce, this.pendingLongTaskMs) / Ce * 100
4077
+ )
4078
+ ), a = Es();
4079
+ this.pendingLongTaskMs = 0, this.replayRecorder.addCustomEvent("performance-sample", {
4080
+ cpu_usage_pct: i,
4081
+ js_heap_limit_mb: (a == null ? void 0 : a.js_heap_limit_mb) ?? null,
4082
+ memory_mb: (a == null ? void 0 : a.used_js_heap_mb) ?? null,
4083
+ page_title: le(),
4084
+ page_url: B(),
4085
+ reason: t,
4086
+ session_id: this.sessionId,
4087
+ timestamp: Math.round(We() + r),
4088
+ total_memory_mb: (a == null ? void 0 : a.total_js_heap_mb) ?? null
4089
+ });
4090
+ }
4091
+ observeReplayLongTasks() {
4092
+ if (!(typeof PerformanceObserver > "u" || !this.sessionId))
4093
+ try {
4094
+ const t = new PerformanceObserver((r) => {
4095
+ r.getEntries().forEach((n) => {
4096
+ const s = Math.round(Number(n.duration || 0));
4097
+ s <= 0 || (this.pendingLongTaskMs += s, this.replayRecorder.addCustomEvent("long-task", {
4098
+ duration_ms: s,
4099
+ name: n.name || "longtask",
4100
+ page_title: le(),
4101
+ page_url: B(),
4102
+ session_id: this.sessionId,
4103
+ start_time_ms: Math.round(Number(n.startTime || 0)),
4104
+ timestamp: Math.round(We() + Number(n.startTime || performance.now()))
4105
+ }));
4106
+ });
4107
+ });
4108
+ t.observe({ type: "longtask", buffered: !0 }), this.performanceObservers.push(t);
4109
+ } catch {
4110
+ }
4111
+ }
4112
+ observeReplayLayoutShifts() {
4113
+ if (!(typeof PerformanceObserver > "u" || !this.sessionId))
4114
+ try {
4115
+ const t = new PerformanceObserver((r) => {
4116
+ r.getEntries().forEach((n) => {
4117
+ const s = Number(n.value || 0);
4118
+ !Number.isFinite(s) || s <= 0 || n.hadRecentInput || this.replayRecorder.addCustomEvent("layout-shift", {
4119
+ page_title: le(),
4120
+ page_url: B(),
4121
+ session_id: this.sessionId,
4122
+ timestamp: Math.round(We() + Number(n.startTime || performance.now())),
4123
+ value: Math.round(s * 1e4) / 1e4
4124
+ });
4125
+ });
4126
+ });
4127
+ t.observe({ type: "layout-shift", buffered: !0 }), this.performanceObservers.push(t);
4128
+ } catch {
4129
+ }
4130
+ }
4131
+ captureReplayResourceEntries(t, r) {
4132
+ this.sessionId && t.forEach((n) => {
4133
+ if (!As(n))
4134
+ return;
4135
+ const s = [
4136
+ n.entryType,
4137
+ n.name,
4138
+ Math.round(Number(n.startTime || 0)),
4139
+ Math.round(Number(n.duration || 0)),
4140
+ String(n.initiatorType || "")
4141
+ ].join("|");
4142
+ this.replayResourceKeys.has(s) || (this.replayResourceKeys.add(s), this.replayRecorder.addCustomEvent("resource-entry", {
4143
+ capture_mode: r,
4144
+ duration_ms: Math.round(Number(n.duration || 0)),
4145
+ encoded_body_size: Math.round(Number(n.encodedBodySize || 0)),
4146
+ entry_type: n.entryType,
4147
+ initiator_type: String(n.initiatorType || ""),
4148
+ method: "GET",
4149
+ page_title: le(),
4150
+ page_url: B(),
4151
+ request_url: n.name,
4152
+ resource_type: ws(n),
4153
+ response_end_ms: Math.round(Number(n.responseEnd || 0)),
4154
+ session_id: this.sessionId,
4155
+ status: ks(n),
4156
+ timestamp: Rs(n),
4157
+ transfer_size: Math.round(Number(n.transferSize || 0)),
4158
+ url: n.name
4159
+ }));
4160
+ });
4161
+ }
4162
+ }
4163
+ const Ns = () => new _s(), Je = Ns(), Ls = Je, re = (e, t) => e === void 0 ? t : e === "true", _e = (e, t) => {
4164
+ if (!e) return t;
4165
+ const r = Number(e);
4166
+ return Number.isFinite(r) ? r : t;
4167
+ }, nt = (e) => {
4168
+ if (!e) return;
4169
+ const t = e.split(",").map((r) => r.trim()).filter(Boolean);
4170
+ return t.length > 0 ? t : void 0;
4171
+ }, Ms = () => {
4172
+ if (typeof document > "u") return null;
4173
+ if (document.currentScript instanceof HTMLScriptElement) return document.currentScript;
4174
+ const e = document.getElementsByTagName("script");
4175
+ for (let t = e.length - 1; t >= 0; t -= 1) {
4176
+ const r = e[t];
4177
+ if (r.src.includes("tracker.umd.js"))
4178
+ return r;
4179
+ }
4180
+ return null;
4181
+ }, Os = async () => {
4182
+ if (typeof window > "u" || typeof document > "u") return;
4183
+ const e = Ms();
4184
+ if (!e || e.dataset.autoInit !== "true") return;
4185
+ const t = e.dataset.productId || e.dataset.brandId, r = e.dataset.apiKey, n = re(e.dataset.debug, !1);
4186
+ if (t) {
4187
+ if (!r) {
4188
+ console.error("[FlashlogTracker] Auto init failed: missing data-api-key");
4189
+ return;
4190
+ }
4191
+ try {
4192
+ await Je.init(t, {
4193
+ apiUrl: e.dataset.apiUrl,
4194
+ apiKey: r,
4195
+ debug: n,
4196
+ autoCapture: re(e.dataset.autoCapture, !0),
4197
+ captureNetworkErrors: re(e.dataset.captureNetworkErrors, !0),
4198
+ captureJsErrors: re(e.dataset.captureJsErrors, !0),
4199
+ captureSocketErrors: re(e.dataset.captureSocketErrors, !0),
4200
+ allowNonErrorEvents: re(e.dataset.allowNonErrorEvents, !1),
4201
+ sessionTimeoutMs: _e(e.dataset.sessionTimeoutMs, 30 * 60 * 1e3),
4202
+ maxActionBufferSize: _e(e.dataset.maxActionBufferSize, 50),
4203
+ captureRequestBody: re(e.dataset.captureRequestBody, !0),
4204
+ captureResponseBody: re(e.dataset.captureResponseBody, !0),
4205
+ propagateTraceHeaders: re(e.dataset.propagateTraceHeaders, !1),
4206
+ traceOrigins: nt(e.dataset.traceOrigins),
4207
+ traceHeaderName: e.dataset.traceHeaderName,
4208
+ redactKeys: nt(e.dataset.redactKeys),
4209
+ redactUrlParams: nt(e.dataset.redactUrlParams),
4210
+ enableSessionReplay: re(e.dataset.enableSessionReplay, !0),
4211
+ replayFlushIntervalMs: _e(
4212
+ e.dataset.replayFlushIntervalMs,
4213
+ w.replayFlushIntervalMs
4214
+ ),
4215
+ replayMaxSegmentBytes: _e(
4216
+ e.dataset.replayMaxSegmentBytes,
4217
+ w.replayMaxSegmentBytes
4218
+ ),
4219
+ replayMaxSegmentEvents: _e(
4220
+ e.dataset.replayMaxSegmentEvents,
4221
+ w.replayMaxSegmentEvents
4222
+ ),
4223
+ replayMaskAllInputs: re(
4224
+ e.dataset.replayMaskAllInputs,
4225
+ w.replayMaskAllInputs
4226
+ )
4227
+ }), Vt({
4228
+ apiUrl: e.dataset.apiUrl,
4229
+ apiKey: r,
4230
+ brandId: t,
4231
+ source: "script",
4232
+ scriptUrl: e.src,
4233
+ debug: n
4234
+ });
4235
+ } catch (s) {
4236
+ console.error("[FlashlogTracker] Auto init failed", s);
4237
+ }
4238
+ }
4239
+ };
4240
+ typeof window < "u" && (window.FlashlogBugTracker = Je, window.Tracker || (window.Tracker = Je), Os());
4241
+ export {
4242
+ w as DEFAULT_CONFIG,
4243
+ _s as FlashlogTrackerLite,
4244
+ Ns as createTracker,
4245
+ Je as default,
4246
+ Ls as flashlogTracker
4247
+ };