@astropay/payments-lib 0.0.12 → 0.1.2

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,1146 @@
1
+ import { s as A, C, b as ft, i as Y, g as V, N as h, P as X, S as pt, a as B, c as ht, d as mt, e as St, f as q, r as gt, h as Et, j as yt, k as Tt, l as j, m as J, t as _, n as x, o as M, p as K, q as N, u as Q, v as Z, w as Nt, x as vt, y as b, z as D, A as R, B as wt, D as Mt, E as It, F as Rt, G as Ct, H as bt, I as _t, J as Lt, K as Dt, L as xt, M as Ot, O as At, Q as Vt, R as Pt, T as kt, U as zt } from "./main-DcyIcTY7.js";
2
+ const P = /* @__PURE__ */ new WeakMap();
3
+ function T(t) {
4
+ return P.has(t);
5
+ }
6
+ function Ft(t) {
7
+ let e = t;
8
+ for (; e; ) {
9
+ if (!T(e) && !Y(e))
10
+ return !1;
11
+ e = V(e);
12
+ }
13
+ return !0;
14
+ }
15
+ function m(t) {
16
+ return P.get(t);
17
+ }
18
+ function Bt(t, e) {
19
+ P.set(t, e);
20
+ }
21
+ function k(t, e) {
22
+ const n = t.tagName, o = t.value;
23
+ if (A(t, e)) {
24
+ const s = t.type;
25
+ return n === "INPUT" && (s === "button" || s === "submit" || s === "reset") ? o : !o || n === "OPTION" ? void 0 : C;
26
+ }
27
+ if (n === "OPTION" || n === "SELECT")
28
+ return t.value;
29
+ if (!(n !== "INPUT" && n !== "TEXTAREA"))
30
+ return o;
31
+ }
32
+ const Ut = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm, Ht = /^[A-Za-z]+:|^\/\//, Gt = /^data:.*,/i;
33
+ function Wt(t, e) {
34
+ return t.replace(Ut, (n, o, s, r, u, i) => {
35
+ const a = s || u || i;
36
+ if (!e || !a || Ht.test(a) || Gt.test(a))
37
+ return n;
38
+ const d = o || r || "";
39
+ return `url(${d}${$t(a, e)}${d})`;
40
+ });
41
+ }
42
+ function $t(t, e) {
43
+ try {
44
+ return ft(t, e).href;
45
+ } catch {
46
+ return t;
47
+ }
48
+ }
49
+ const Yt = /[^a-z1-6-_]/;
50
+ function tt(t) {
51
+ const e = t.toLowerCase().trim();
52
+ return Yt.test(e) ? "div" : e;
53
+ }
54
+ function U(t, e) {
55
+ return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${e}' style='background-color:silver'%3E%3C/svg%3E`;
56
+ }
57
+ const y = {
58
+ FullSnapshot: 2,
59
+ IncrementalSnapshot: 3,
60
+ Meta: 4,
61
+ Focus: 6,
62
+ ViewEnd: 7,
63
+ VisualViewport: 8,
64
+ FrustrationRecord: 9
65
+ }, w = {
66
+ Document: 0,
67
+ DocumentType: 1,
68
+ Element: 2,
69
+ Text: 3,
70
+ CDATA: 4,
71
+ DocumentFragment: 11
72
+ }, S = {
73
+ Mutation: 0,
74
+ MouseMove: 1,
75
+ MouseInteraction: 2,
76
+ Scroll: 3,
77
+ ViewportResize: 4,
78
+ Input: 5,
79
+ TouchMove: 6,
80
+ MediaInteraction: 7,
81
+ StyleSheetRule: 8
82
+ // CanvasMutation : 9,
83
+ // Font : 10,
84
+ }, g = {
85
+ MouseUp: 0,
86
+ MouseDown: 1,
87
+ Click: 2,
88
+ ContextMenu: 3,
89
+ DblClick: 4,
90
+ Focus: 5,
91
+ Blur: 6,
92
+ TouchStart: 7,
93
+ TouchEnd: 9
94
+ }, H = {
95
+ Play: 0,
96
+ Pause: 1
97
+ };
98
+ function et(t) {
99
+ if (!(t === void 0 || t.length === 0))
100
+ return t.map((e) => {
101
+ const n = e.cssRules || e.rules;
102
+ return {
103
+ cssRules: Array.from(n, (r) => r.cssText),
104
+ disabled: e.disabled || void 0,
105
+ media: e.media.length > 0 ? Array.from(e.media) : void 0
106
+ };
107
+ });
108
+ }
109
+ function nt(t, e, n, o) {
110
+ if (e === h.HIDDEN)
111
+ return null;
112
+ const s = t.getAttribute(n);
113
+ if (e === h.MASK && n !== X && !pt.includes(n) && n !== o.actionNameAttribute) {
114
+ const r = t.tagName;
115
+ switch (n) {
116
+ // Mask Attribute text content
117
+ case "title":
118
+ case "alt":
119
+ case "placeholder":
120
+ return C;
121
+ }
122
+ if (r === "IMG" && (n === "src" || n === "srcset")) {
123
+ const u = t;
124
+ if (u.naturalWidth > 0)
125
+ return U(u.naturalWidth, u.naturalHeight);
126
+ const { width: i, height: a } = t.getBoundingClientRect();
127
+ return i > 0 || a > 0 ? U(i, a) : B;
128
+ }
129
+ if (r === "SOURCE" && (n === "src" || n === "srcset"))
130
+ return B;
131
+ if (r === "A" && n === "href")
132
+ return C;
133
+ if (s && n.startsWith("data-"))
134
+ return C;
135
+ if (r === "IFRAME" && n === "srcdoc")
136
+ return C;
137
+ }
138
+ return !s || typeof s != "string" ? s : ht(s) ? mt(s) : s;
139
+ }
140
+ function Xt(t, e, n) {
141
+ if (e === h.HIDDEN)
142
+ return {};
143
+ const o = {}, s = tt(t.tagName), r = t.ownerDocument;
144
+ for (let c = 0; c < t.attributes.length; c += 1) {
145
+ const f = t.attributes.item(c).name, p = nt(t, e, f, n.configuration);
146
+ p !== null && (o[f] = p);
147
+ }
148
+ if (t.value && (s === "textarea" || s === "select" || s === "option" || s === "input")) {
149
+ const c = k(t, e);
150
+ c !== void 0 && (o.value = c);
151
+ }
152
+ if (s === "option" && e === h.ALLOW) {
153
+ const c = t;
154
+ c.selected && (o.selected = c.selected);
155
+ }
156
+ if (s === "link") {
157
+ const c = Array.from(r.styleSheets).find((f) => f.href === t.href), l = O(c);
158
+ l && c && (o._cssText = l);
159
+ }
160
+ if (s === "style" && t.sheet) {
161
+ const c = O(t.sheet);
162
+ c && (o._cssText = c);
163
+ }
164
+ const u = t;
165
+ if (s === "input" && (u.type === "radio" || u.type === "checkbox") && (e === h.ALLOW ? o.checked = !!u.checked : A(u, e) && delete o.checked), s === "audio" || s === "video") {
166
+ const c = t;
167
+ o.rr_mediaState = c.paused ? "paused" : "played";
168
+ }
169
+ let i, a;
170
+ const d = n.serializationContext;
171
+ switch (d.status) {
172
+ case 0:
173
+ i = Math.round(t.scrollTop), a = Math.round(t.scrollLeft), (i || a) && d.elementsScrollPositions.set(t, { scrollTop: i, scrollLeft: a });
174
+ break;
175
+ case 1:
176
+ d.elementsScrollPositions.has(t) && ({ scrollTop: i, scrollLeft: a } = d.elementsScrollPositions.get(t));
177
+ break;
178
+ }
179
+ return a && (o.rr_scrollLeft = a), i && (o.rr_scrollTop = i), o;
180
+ }
181
+ function O(t) {
182
+ if (!t)
183
+ return null;
184
+ let e;
185
+ try {
186
+ e = t.rules || t.cssRules;
187
+ } catch {
188
+ }
189
+ if (!e)
190
+ return null;
191
+ const n = Array.from(e, St() ? qt : st).join("");
192
+ return Wt(n, t.href);
193
+ }
194
+ function qt(t) {
195
+ if (Jt(t) && t.selectorText.includes(":")) {
196
+ const e = /(\[[\w-]+[^\\])(:[^\]]+\])/g;
197
+ return t.cssText.replace(e, "$1\\$2");
198
+ }
199
+ return st(t);
200
+ }
201
+ function st(t) {
202
+ return jt(t) && O(t.styleSheet) || t.cssText;
203
+ }
204
+ function jt(t) {
205
+ return "styleSheet" in t;
206
+ }
207
+ function Jt(t) {
208
+ return "selectorText" in t;
209
+ }
210
+ function z(t, e) {
211
+ const n = Zt(t, e);
212
+ if (!n)
213
+ return null;
214
+ const o = m(t) || Qt(), s = n;
215
+ return s.id = o, Bt(t, o), e.serializedNodeIds && e.serializedNodeIds.add(o), s;
216
+ }
217
+ let Kt = 1;
218
+ function Qt() {
219
+ return Kt++;
220
+ }
221
+ function F(t, e) {
222
+ const n = [];
223
+ return j(t, (o) => {
224
+ const s = z(o, e);
225
+ s && n.push(s);
226
+ }), n;
227
+ }
228
+ function Zt(t, e) {
229
+ switch (t.nodeType) {
230
+ case t.DOCUMENT_NODE:
231
+ return te(t, e);
232
+ case t.DOCUMENT_FRAGMENT_NODE:
233
+ return ee(t, e);
234
+ case t.DOCUMENT_TYPE_NODE:
235
+ return ne(t);
236
+ case t.ELEMENT_NODE:
237
+ return se(t, e);
238
+ case t.TEXT_NODE:
239
+ return re(t, e);
240
+ case t.CDATA_SECTION_NODE:
241
+ return ie();
242
+ }
243
+ }
244
+ function te(t, e) {
245
+ return {
246
+ type: w.Document,
247
+ childNodes: F(t, e),
248
+ adoptedStyleSheets: et(t.adoptedStyleSheets)
249
+ };
250
+ }
251
+ function ee(t, e) {
252
+ const n = Y(t);
253
+ return n && e.serializationContext.shadowRootsController.addShadowRoot(t), {
254
+ type: w.DocumentFragment,
255
+ childNodes: F(t, e),
256
+ isShadowRoot: n,
257
+ adoptedStyleSheets: n ? et(t.adoptedStyleSheets) : void 0
258
+ };
259
+ }
260
+ function ne(t) {
261
+ return {
262
+ type: w.DocumentType,
263
+ name: t.name,
264
+ publicId: t.publicId,
265
+ systemId: t.systemId
266
+ };
267
+ }
268
+ function se(t, e) {
269
+ const n = tt(t.tagName), o = oe(t) || void 0, s = gt(Et(t), e.parentNodePrivacyLevel);
270
+ if (s === h.HIDDEN) {
271
+ const { width: i, height: a } = t.getBoundingClientRect();
272
+ return {
273
+ type: w.Element,
274
+ tagName: n,
275
+ attributes: {
276
+ rr_width: `${i}px`,
277
+ rr_height: `${a}px`,
278
+ [X]: yt
279
+ },
280
+ childNodes: [],
281
+ isSVG: o
282
+ };
283
+ }
284
+ if (s === h.IGNORE)
285
+ return;
286
+ const r = Xt(t, s, e);
287
+ let u = [];
288
+ if (Tt(t) && // Do not serialize style children as the css rules are already in the _cssText attribute
289
+ n !== "style") {
290
+ let i;
291
+ e.parentNodePrivacyLevel === s && e.ignoreWhiteSpace === (n === "head") ? i = e : i = {
292
+ ...e,
293
+ parentNodePrivacyLevel: s,
294
+ ignoreWhiteSpace: n === "head"
295
+ }, u = F(t, i);
296
+ }
297
+ return {
298
+ type: w.Element,
299
+ tagName: n,
300
+ attributes: r,
301
+ childNodes: u,
302
+ isSVG: o
303
+ };
304
+ }
305
+ function oe(t) {
306
+ return t.tagName === "svg" || t instanceof SVGElement;
307
+ }
308
+ function re(t, e) {
309
+ const n = q(t, e.ignoreWhiteSpace || !1, e.parentNodePrivacyLevel);
310
+ if (n !== void 0)
311
+ return {
312
+ type: w.Text,
313
+ textContent: n
314
+ };
315
+ }
316
+ function ie() {
317
+ return {
318
+ type: w.CDATA,
319
+ textContent: ""
320
+ };
321
+ }
322
+ function ae(t, e, n) {
323
+ return z(t, {
324
+ serializationContext: n,
325
+ parentNodePrivacyLevel: e.defaultPrivacyLevel,
326
+ configuration: e
327
+ });
328
+ }
329
+ function ot(t) {
330
+ return !!t.changedTouches;
331
+ }
332
+ function L(t) {
333
+ return t.composed === !0 && J(t.target) ? t.composedPath()[0] : t.target;
334
+ }
335
+ const G = 25;
336
+ function ue(t) {
337
+ return Math.abs(t.pageTop - t.offsetTop - window.scrollY) > G || Math.abs(t.pageLeft - t.offsetLeft - window.scrollX) > G;
338
+ }
339
+ const ce = (t, e) => {
340
+ const n = window.visualViewport, o = {
341
+ layoutViewportX: t,
342
+ layoutViewportY: e,
343
+ visualViewportX: t,
344
+ visualViewportY: e
345
+ };
346
+ if (n)
347
+ ue(n) ? (o.layoutViewportX = Math.round(t + n.offsetLeft), o.layoutViewportY = Math.round(e + n.offsetTop)) : (o.visualViewportX = Math.round(t - n.offsetLeft), o.visualViewportY = Math.round(e - n.offsetTop));
348
+ else return o;
349
+ return o;
350
+ }, rt = (t) => ({
351
+ scale: t.scale,
352
+ offsetLeft: t.offsetLeft,
353
+ offsetTop: t.offsetTop,
354
+ pageLeft: t.pageLeft,
355
+ pageTop: t.pageTop,
356
+ height: t.height,
357
+ width: t.width
358
+ });
359
+ function E(t, e) {
360
+ return {
361
+ data: {
362
+ source: t,
363
+ ...e
364
+ },
365
+ type: y.IncrementalSnapshot,
366
+ timestamp: _()
367
+ };
368
+ }
369
+ const le = 50;
370
+ function de(t, e) {
371
+ const { throttled: n, cancel: o } = x((r) => {
372
+ const u = L(r);
373
+ if (T(u)) {
374
+ const i = it(r);
375
+ if (!i)
376
+ return;
377
+ const a = {
378
+ id: m(u),
379
+ timeOffset: 0,
380
+ x: i.x,
381
+ y: i.y
382
+ };
383
+ e(E(ot(r) ? S.TouchMove : S.MouseMove, { positions: [a] }));
384
+ }
385
+ }, le, {
386
+ trailing: !1
387
+ }), { stop: s } = M(t, document, [
388
+ "mousemove",
389
+ "touchmove"
390
+ /* DOM_EVENT.TOUCH_MOVE */
391
+ ], n, {
392
+ capture: !0,
393
+ passive: !0
394
+ });
395
+ return {
396
+ stop: () => {
397
+ s(), o();
398
+ }
399
+ };
400
+ }
401
+ function it(t) {
402
+ let { clientX: e, clientY: n } = ot(t) ? t.changedTouches[0] : t;
403
+ if (window.visualViewport) {
404
+ const { visualViewportX: o, visualViewportY: s } = ce(e, n);
405
+ e = o, n = s;
406
+ }
407
+ if (!Number.isFinite(e) || !Number.isFinite(n)) {
408
+ t.isTrusted && K("mouse/touch event without x/y");
409
+ return;
410
+ }
411
+ return { x: e, y: n };
412
+ }
413
+ const W = {
414
+ // Listen for pointerup DOM events instead of mouseup for MouseInteraction/MouseUp records. This
415
+ // allows to reference such records from Frustration records.
416
+ //
417
+ // In the context of supporting Mobile Session Replay, we introduced `PointerInteraction` records
418
+ // used by the Mobile SDKs in place of `MouseInteraction`. In the future, we should replace
419
+ // `MouseInteraction` by `PointerInteraction` in the Browser SDK so we have an uniform way to
420
+ // convey such interaction. This would cleanly solve the issue since we would have
421
+ // `PointerInteraction/Up` records that we could reference from `Frustration` records.
422
+ pointerup: g.MouseUp,
423
+ mousedown: g.MouseDown,
424
+ click: g.Click,
425
+ contextmenu: g.ContextMenu,
426
+ dblclick: g.DblClick,
427
+ focus: g.Focus,
428
+ blur: g.Blur,
429
+ touchstart: g.TouchStart,
430
+ touchend: g.TouchEnd
431
+ };
432
+ function fe(t, e, n) {
433
+ const o = (s) => {
434
+ const r = L(s);
435
+ if (N(r, t.defaultPrivacyLevel) === h.HIDDEN || !T(r))
436
+ return;
437
+ const u = m(r), i = W[s.type];
438
+ let a;
439
+ if (i !== g.Blur && i !== g.Focus) {
440
+ const c = it(s);
441
+ if (!c)
442
+ return;
443
+ a = { id: u, type: i, x: c.x, y: c.y };
444
+ } else
445
+ a = { id: u, type: i };
446
+ const d = {
447
+ id: n.getIdForEvent(s),
448
+ ...E(S.MouseInteraction, a)
449
+ };
450
+ e(d);
451
+ };
452
+ return M(t, document, Object.keys(W), o, {
453
+ capture: !0,
454
+ passive: !0
455
+ });
456
+ }
457
+ const pe = 100;
458
+ function at(t, e, n, o = document) {
459
+ const { throttled: s, cancel: r } = x((i) => {
460
+ const a = L(i);
461
+ if (!a || N(a, t.defaultPrivacyLevel) === h.HIDDEN || !T(a))
462
+ return;
463
+ const d = m(a), c = a === document ? {
464
+ scrollTop: Q(),
465
+ scrollLeft: Z()
466
+ } : {
467
+ scrollTop: Math.round(a.scrollTop),
468
+ scrollLeft: Math.round(a.scrollLeft)
469
+ };
470
+ n.set(a, c), e(E(S.Scroll, {
471
+ id: d,
472
+ x: c.scrollLeft,
473
+ y: c.scrollTop
474
+ }));
475
+ }, pe), { stop: u } = Nt(t, o, "scroll", s, {
476
+ capture: !0,
477
+ passive: !0
478
+ });
479
+ return {
480
+ stop: () => {
481
+ u(), r();
482
+ }
483
+ };
484
+ }
485
+ const he = 200;
486
+ function me(t, e) {
487
+ const n = vt(t).subscribe((o) => {
488
+ e(E(S.ViewportResize, o));
489
+ });
490
+ return {
491
+ stop: () => {
492
+ n.unsubscribe();
493
+ }
494
+ };
495
+ }
496
+ function Se(t, e) {
497
+ const n = window.visualViewport;
498
+ if (!n)
499
+ return { stop: b };
500
+ const { throttled: o, cancel: s } = x(() => {
501
+ e({
502
+ data: rt(n),
503
+ type: y.VisualViewport,
504
+ timestamp: _()
505
+ });
506
+ }, he, {
507
+ trailing: !1
508
+ }), { stop: r } = M(t, n, [
509
+ "resize",
510
+ "scroll"
511
+ /* DOM_EVENT.SCROLL */
512
+ ], o, {
513
+ capture: !0,
514
+ passive: !0
515
+ });
516
+ return {
517
+ stop: () => {
518
+ r(), s();
519
+ }
520
+ };
521
+ }
522
+ function ge(t, e) {
523
+ return M(t, document, [
524
+ "play",
525
+ "pause"
526
+ /* DOM_EVENT.PAUSE */
527
+ ], (n) => {
528
+ const o = L(n);
529
+ !o || N(o, t.defaultPrivacyLevel) === h.HIDDEN || !T(o) || e(E(S.MediaInteraction, {
530
+ id: m(o),
531
+ type: n.type === "play" ? H.Play : H.Pause
532
+ }));
533
+ }, {
534
+ capture: !0,
535
+ passive: !0
536
+ });
537
+ }
538
+ function Ee(t) {
539
+ function e(s, r) {
540
+ s && T(s.ownerNode) && r(m(s.ownerNode));
541
+ }
542
+ const n = [
543
+ D(CSSStyleSheet.prototype, "insertRule", ({ target: s, parameters: [r, u] }) => {
544
+ e(s, (i) => t(E(S.StyleSheetRule, {
545
+ id: i,
546
+ adds: [{ rule: r, index: u }]
547
+ })));
548
+ }),
549
+ D(CSSStyleSheet.prototype, "deleteRule", ({ target: s, parameters: [r] }) => {
550
+ e(s, (u) => t(E(S.StyleSheetRule, {
551
+ id: u,
552
+ removes: [{ index: r }]
553
+ })));
554
+ })
555
+ ];
556
+ typeof CSSGroupingRule < "u" ? o(CSSGroupingRule) : (o(CSSMediaRule), o(CSSSupportsRule));
557
+ function o(s) {
558
+ n.push(D(s.prototype, "insertRule", ({ target: r, parameters: [u, i] }) => {
559
+ e(r.parentStyleSheet, (a) => {
560
+ const d = $(r);
561
+ d && (d.push(i || 0), t(E(S.StyleSheetRule, {
562
+ id: a,
563
+ adds: [{ rule: u, index: d }]
564
+ })));
565
+ });
566
+ }), D(s.prototype, "deleteRule", ({ target: r, parameters: [u] }) => {
567
+ e(r.parentStyleSheet, (i) => {
568
+ const a = $(r);
569
+ a && (a.push(u), t(E(S.StyleSheetRule, {
570
+ id: i,
571
+ removes: [{ index: a }]
572
+ })));
573
+ });
574
+ }));
575
+ }
576
+ return {
577
+ stop: () => {
578
+ n.forEach((s) => s.stop());
579
+ }
580
+ };
581
+ }
582
+ function $(t) {
583
+ const e = [];
584
+ let n = t;
585
+ for (; n.parentRule; ) {
586
+ const u = Array.from(n.parentRule.cssRules).indexOf(n);
587
+ e.unshift(u), n = n.parentRule;
588
+ }
589
+ if (!n.parentStyleSheet)
590
+ return;
591
+ const s = Array.from(n.parentStyleSheet.cssRules).indexOf(n);
592
+ return e.unshift(s), e;
593
+ }
594
+ function ye(t, e) {
595
+ return M(t, window, [
596
+ "focus",
597
+ "blur"
598
+ /* DOM_EVENT.BLUR */
599
+ ], () => {
600
+ e({
601
+ data: { has_focus: document.hasFocus() },
602
+ type: y.Focus,
603
+ timestamp: _()
604
+ });
605
+ });
606
+ }
607
+ function Te(t, e, n) {
608
+ const o = t.subscribe(12, (s) => {
609
+ var r, u;
610
+ s.rawRumEvent.type === "action" && s.rawRumEvent.action.type === "click" && (!((u = (r = s.rawRumEvent.action.frustration) === null || r === void 0 ? void 0 : r.type) === null || u === void 0) && u.length) && "events" in s.domainContext && s.domainContext.events && s.domainContext.events.length && e({
611
+ timestamp: s.rawRumEvent.date,
612
+ type: y.FrustrationRecord,
613
+ data: {
614
+ frustrationTypes: s.rawRumEvent.action.frustration.type,
615
+ recordIds: s.domainContext.events.map((i) => n.getIdForEvent(i))
616
+ }
617
+ });
618
+ });
619
+ return {
620
+ stop: () => {
621
+ o.unsubscribe();
622
+ }
623
+ };
624
+ }
625
+ function Ne(t, e) {
626
+ const n = t.subscribe(5, () => {
627
+ e({
628
+ timestamp: _(),
629
+ type: y.ViewEnd
630
+ });
631
+ });
632
+ return {
633
+ stop: () => {
634
+ n.unsubscribe();
635
+ }
636
+ };
637
+ }
638
+ function ut(t, e, n = document) {
639
+ const o = t.defaultPrivacyLevel, s = /* @__PURE__ */ new WeakMap(), r = n !== document, { stop: u } = M(
640
+ t,
641
+ n,
642
+ // The 'input' event bubbles across shadow roots, so we don't have to listen for it on shadow
643
+ // roots since it will be handled by the event listener that we did add to the document. Only
644
+ // the 'change' event is blocked and needs to be handled on shadow roots.
645
+ r ? [
646
+ "change"
647
+ /* DOM_EVENT.CHANGE */
648
+ ] : [
649
+ "input",
650
+ "change"
651
+ /* DOM_EVENT.CHANGE */
652
+ ],
653
+ (c) => {
654
+ const l = L(c);
655
+ (l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement || l instanceof HTMLSelectElement) && a(l);
656
+ },
657
+ {
658
+ capture: !0,
659
+ passive: !0
660
+ }
661
+ );
662
+ let i;
663
+ if (r)
664
+ i = b;
665
+ else {
666
+ const c = [
667
+ R(HTMLInputElement.prototype, "value", a),
668
+ R(HTMLInputElement.prototype, "checked", a),
669
+ R(HTMLSelectElement.prototype, "value", a),
670
+ R(HTMLTextAreaElement.prototype, "value", a),
671
+ R(HTMLSelectElement.prototype, "selectedIndex", a)
672
+ ];
673
+ i = () => {
674
+ c.forEach((l) => l.stop());
675
+ };
676
+ }
677
+ return {
678
+ stop: () => {
679
+ i(), u();
680
+ }
681
+ };
682
+ function a(c) {
683
+ const l = N(c, o);
684
+ if (l === h.HIDDEN)
685
+ return;
686
+ const f = c.type;
687
+ let p;
688
+ if (f === "radio" || f === "checkbox") {
689
+ if (A(c, l))
690
+ return;
691
+ p = { isChecked: c.checked };
692
+ } else {
693
+ const v = k(c, l);
694
+ if (v === void 0)
695
+ return;
696
+ p = { text: v };
697
+ }
698
+ d(c, p);
699
+ const I = c.name;
700
+ f === "radio" && I && c.checked && document.querySelectorAll(`input[type="radio"][name="${CSS.escape(I)}"]`).forEach((v) => {
701
+ v !== c && d(v, { isChecked: !1 });
702
+ });
703
+ }
704
+ function d(c, l) {
705
+ if (!T(c))
706
+ return;
707
+ const f = s.get(c);
708
+ (!f || f.text !== l.text || f.isChecked !== l.isChecked) && (s.set(c, l), e(E(S.Input, {
709
+ id: m(c),
710
+ ...l
711
+ })));
712
+ }
713
+ }
714
+ const ve = 100, we = 16;
715
+ function Me(t) {
716
+ let e = b, n = [];
717
+ function o() {
718
+ e(), t(n), n = [];
719
+ }
720
+ const { throttled: s, cancel: r } = x(o, we, {
721
+ leading: !1
722
+ });
723
+ return {
724
+ addMutations: (u) => {
725
+ n.length === 0 && (e = wt(s, { timeout: ve })), n.push(...u);
726
+ },
727
+ flush: o,
728
+ stop: () => {
729
+ e(), r();
730
+ }
731
+ };
732
+ }
733
+ function ct(t, e, n, o) {
734
+ const s = Mt();
735
+ if (!s)
736
+ return { stop: b, flush: b };
737
+ const r = Me((i) => {
738
+ Ie(i.concat(u.takeRecords()), t, e, n);
739
+ }), u = new s(It(r.addMutations));
740
+ return u.observe(o, {
741
+ attributeOldValue: !0,
742
+ attributes: !0,
743
+ characterData: !0,
744
+ characterDataOldValue: !0,
745
+ childList: !0,
746
+ subtree: !0
747
+ }), {
748
+ stop: () => {
749
+ u.disconnect(), r.stop();
750
+ },
751
+ flush: () => {
752
+ r.flush();
753
+ }
754
+ };
755
+ }
756
+ function Ie(t, e, n, o) {
757
+ const s = /* @__PURE__ */ new Map();
758
+ t.filter((l) => l.type === "childList").forEach((l) => {
759
+ l.removedNodes.forEach((f) => {
760
+ lt(f, o.removeShadowRoot);
761
+ });
762
+ });
763
+ const r = t.filter((l) => l.target.isConnected && Ft(l.target) && N(l.target, n.defaultPrivacyLevel, s) !== h.HIDDEN), { adds: u, removes: i, hasBeenSerialized: a } = Re(r.filter((l) => l.type === "childList"), n, o, s), d = Ce(r.filter((l) => l.type === "characterData" && !a(l.target)), n, s), c = be(r.filter((l) => l.type === "attributes" && !a(l.target)), n, s);
764
+ !d.length && !c.length && !i.length && !u.length || e(E(S.Mutation, { adds: u, removes: i, texts: d, attributes: c }));
765
+ }
766
+ function Re(t, e, n, o) {
767
+ const s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
768
+ for (const f of t)
769
+ f.addedNodes.forEach((p) => {
770
+ s.add(p);
771
+ }), f.removedNodes.forEach((p) => {
772
+ s.has(p) || r.set(p, f.target), s.delete(p);
773
+ });
774
+ const u = Array.from(s);
775
+ _e(u);
776
+ const i = /* @__PURE__ */ new Set(), a = [];
777
+ for (const f of u) {
778
+ if (c(f))
779
+ continue;
780
+ const p = N(f.parentNode, e.defaultPrivacyLevel, o);
781
+ if (p === h.HIDDEN || p === h.IGNORE)
782
+ continue;
783
+ const I = z(f, {
784
+ serializedNodeIds: i,
785
+ parentNodePrivacyLevel: p,
786
+ serializationContext: { status: 2, shadowRootsController: n },
787
+ configuration: e
788
+ });
789
+ if (!I)
790
+ continue;
791
+ const v = V(f);
792
+ a.push({
793
+ nextId: l(f),
794
+ parentId: m(v),
795
+ node: I
796
+ });
797
+ }
798
+ const d = [];
799
+ return r.forEach((f, p) => {
800
+ T(p) && d.push({
801
+ parentId: m(f),
802
+ id: m(p)
803
+ });
804
+ }), { adds: a, removes: d, hasBeenSerialized: c };
805
+ function c(f) {
806
+ return T(f) && i.has(m(f));
807
+ }
808
+ function l(f) {
809
+ let p = f.nextSibling;
810
+ for (; p; ) {
811
+ if (T(p))
812
+ return m(p);
813
+ p = p.nextSibling;
814
+ }
815
+ return null;
816
+ }
817
+ }
818
+ function Ce(t, e, n) {
819
+ var o;
820
+ const s = [], r = /* @__PURE__ */ new Set(), u = t.filter((i) => r.has(i.target) ? !1 : (r.add(i.target), !0));
821
+ for (const i of u) {
822
+ if (i.target.textContent === i.oldValue)
823
+ continue;
824
+ const d = N(V(i.target), e.defaultPrivacyLevel, n);
825
+ d === h.HIDDEN || d === h.IGNORE || s.push({
826
+ id: m(i.target),
827
+ // TODO: pass a valid "ignoreWhiteSpace" argument
828
+ value: (o = q(i.target, !1, d)) !== null && o !== void 0 ? o : null
829
+ });
830
+ }
831
+ return s;
832
+ }
833
+ function be(t, e, n) {
834
+ const o = [], s = /* @__PURE__ */ new Map(), r = t.filter((i) => {
835
+ const a = s.get(i.target);
836
+ return a && a.has(i.attributeName) ? !1 : (a ? a.add(i.attributeName) : s.set(i.target, /* @__PURE__ */ new Set([i.attributeName])), !0);
837
+ }), u = /* @__PURE__ */ new Map();
838
+ for (const i of r) {
839
+ if (i.target.getAttribute(i.attributeName) === i.oldValue)
840
+ continue;
841
+ const d = N(i.target, e.defaultPrivacyLevel, n), c = nt(i.target, d, i.attributeName, e);
842
+ let l;
843
+ if (i.attributeName === "value") {
844
+ const p = k(i.target, d);
845
+ if (p === void 0)
846
+ continue;
847
+ l = p;
848
+ } else typeof c == "string" ? l = c : l = null;
849
+ let f = u.get(i.target);
850
+ f || (f = {
851
+ id: m(i.target),
852
+ attributes: {}
853
+ }, o.push(f), u.set(i.target, f)), f.attributes[i.attributeName] = l;
854
+ }
855
+ return o;
856
+ }
857
+ function _e(t) {
858
+ t.sort((e, n) => {
859
+ const o = e.compareDocumentPosition(n);
860
+ return o & Node.DOCUMENT_POSITION_CONTAINED_BY ? -1 : o & Node.DOCUMENT_POSITION_CONTAINS || o & Node.DOCUMENT_POSITION_FOLLOWING ? 1 : o & Node.DOCUMENT_POSITION_PRECEDING ? -1 : 0;
861
+ });
862
+ }
863
+ function lt(t, e) {
864
+ J(t) && e(t.shadowRoot), j(t, (n) => lt(n, e));
865
+ }
866
+ function Le() {
867
+ const t = /* @__PURE__ */ new WeakMap();
868
+ return {
869
+ set(e, n) {
870
+ e === document && !document.scrollingElement || t.set(e === document ? document.scrollingElement : e, n);
871
+ },
872
+ get(e) {
873
+ return t.get(e);
874
+ },
875
+ has(e) {
876
+ return t.has(e);
877
+ }
878
+ };
879
+ }
880
+ const De = (t, e, n) => {
881
+ const o = /* @__PURE__ */ new Map(), s = {
882
+ addShadowRoot: (r) => {
883
+ if (o.has(r))
884
+ return;
885
+ const u = ct(e, t, s, r), i = ut(t, e, r), a = at(t, e, n, r);
886
+ o.set(r, {
887
+ flush: () => u.flush(),
888
+ stop: () => {
889
+ u.stop(), i.stop(), a.stop();
890
+ }
891
+ });
892
+ },
893
+ removeShadowRoot: (r) => {
894
+ const u = o.get(r);
895
+ u && (u.stop(), o.delete(r));
896
+ },
897
+ stop: () => {
898
+ o.forEach(({ stop: r }) => r());
899
+ },
900
+ flush: () => {
901
+ o.forEach(({ flush: r }) => r());
902
+ }
903
+ };
904
+ return s;
905
+ };
906
+ function xe(t, e, n, o, s, r) {
907
+ const u = (a = _(), d = {
908
+ status: 0,
909
+ elementsScrollPositions: t,
910
+ shadowRootsController: e
911
+ }) => {
912
+ const { width: c, height: l } = Rt(), f = [
913
+ {
914
+ data: {
915
+ height: l,
916
+ href: window.location.href,
917
+ width: c
918
+ },
919
+ type: y.Meta,
920
+ timestamp: a
921
+ },
922
+ {
923
+ data: {
924
+ has_focus: document.hasFocus()
925
+ },
926
+ type: y.Focus,
927
+ timestamp: a
928
+ },
929
+ {
930
+ data: {
931
+ node: ae(document, o, d),
932
+ initialOffset: {
933
+ left: Z(),
934
+ top: Q()
935
+ }
936
+ },
937
+ type: y.FullSnapshot,
938
+ timestamp: a
939
+ }
940
+ ];
941
+ return window.visualViewport && f.push({
942
+ data: rt(window.visualViewport),
943
+ type: y.VisualViewport,
944
+ timestamp: a
945
+ }), f;
946
+ };
947
+ r(u());
948
+ const { unsubscribe: i } = n.subscribe(2, (a) => {
949
+ s(), r(u(a.startClocks.timeStamp, {
950
+ shadowRootsController: e,
951
+ status: 1,
952
+ elementsScrollPositions: t
953
+ }));
954
+ });
955
+ return {
956
+ stop: i
957
+ };
958
+ }
959
+ function Oe() {
960
+ const t = /* @__PURE__ */ new WeakMap();
961
+ let e = 1;
962
+ return {
963
+ getIdForEvent(n) {
964
+ return t.has(n) || t.set(n, e++), t.get(n);
965
+ }
966
+ };
967
+ }
968
+ function Ae(t) {
969
+ const { emit: e, configuration: n, lifeCycle: o } = t;
970
+ if (!e)
971
+ throw new Error("emit function is required");
972
+ const s = (f) => {
973
+ e(f), Ct("record", { record: f });
974
+ const p = t.viewHistory.findView();
975
+ bt(p.id);
976
+ }, r = Le(), u = De(n, s, r), { stop: i } = xe(r, u, o, n, a, (f) => f.forEach((p) => s(p)));
977
+ function a() {
978
+ u.flush(), c.flush();
979
+ }
980
+ const d = Oe(), c = ct(s, n, u, document), l = [
981
+ c,
982
+ de(n, s),
983
+ fe(n, s, d),
984
+ at(n, s, r, document),
985
+ me(n, s),
986
+ ut(n, s),
987
+ ge(n, s),
988
+ Ee(s),
989
+ ye(n, s),
990
+ Se(n, s),
991
+ Te(o, s, d),
992
+ Ne(o, (f) => {
993
+ a(), s(f);
994
+ })
995
+ ];
996
+ return {
997
+ stop: () => {
998
+ u.stop(), l.forEach((f) => f.stop()), i();
999
+ },
1000
+ flushMutations: a,
1001
+ shadowRootsController: u
1002
+ };
1003
+ }
1004
+ function Ve(t, e, n) {
1005
+ const o = new FormData();
1006
+ o.append("segment", new Blob([t], {
1007
+ type: "application/octet-stream"
1008
+ }), `${e.session.id}-${e.start}`);
1009
+ const s = {
1010
+ raw_segment_size: n,
1011
+ compressed_segment_size: t.byteLength,
1012
+ ...e
1013
+ }, r = JSON.stringify(s);
1014
+ return o.append("event", new Blob([r], { type: "application/json" })), { data: o, bytesCount: t.byteLength };
1015
+ }
1016
+ function Pe({ context: t, creationReason: e, encoder: n }) {
1017
+ let o = 0;
1018
+ const s = t.view.id, r = {
1019
+ start: 1 / 0,
1020
+ end: -1 / 0,
1021
+ creation_reason: e,
1022
+ records_count: 0,
1023
+ has_full_snapshot: !1,
1024
+ index_in_view: _t(s),
1025
+ source: "browser",
1026
+ ...t
1027
+ };
1028
+ Lt(s);
1029
+ function u(a, d) {
1030
+ r.start = Math.min(r.start, a.timestamp), r.end = Math.max(r.end, a.timestamp), r.records_count += 1, r.has_full_snapshot || (r.has_full_snapshot = a.type === y.FullSnapshot);
1031
+ const c = n.isEmpty ? '{"records":[' : ",";
1032
+ n.write(c + JSON.stringify(a), (l) => {
1033
+ o += l, d(o);
1034
+ });
1035
+ }
1036
+ function i(a) {
1037
+ if (n.isEmpty)
1038
+ throw new Error("Empty segment flushed");
1039
+ n.write(`],${JSON.stringify(r).slice(1)}
1040
+ `), n.finish((d) => {
1041
+ Dt(r.view.id, d.rawBytesCount), a(r, d);
1042
+ });
1043
+ }
1044
+ return { addRecord: u, flush: i };
1045
+ }
1046
+ const ke = 5 * Vt;
1047
+ let dt = 6e4;
1048
+ function ze(t, e, n, o, s, r) {
1049
+ return Fe(t, () => Be(e.applicationId, n, o), s, r);
1050
+ }
1051
+ function Fe(t, e, n, o) {
1052
+ let s = {
1053
+ status: 0,
1054
+ nextSegmentCreationReason: "init"
1055
+ };
1056
+ const { unsubscribe: r } = t.subscribe(2, () => {
1057
+ i("view_change");
1058
+ }), { unsubscribe: u } = t.subscribe(11, (a) => {
1059
+ i(a.reason);
1060
+ });
1061
+ function i(a) {
1062
+ s.status === 1 && (s.segment.flush((d, c) => {
1063
+ const l = Ve(c.output, d, c.rawBytesCount);
1064
+ xt(a) ? n.sendOnExit(l) : n.send(l);
1065
+ }), Ot(s.expirationTimeoutId)), a !== "stop" ? s = {
1066
+ status: 0,
1067
+ nextSegmentCreationReason: a
1068
+ } : s = {
1069
+ status: 2
1070
+ };
1071
+ }
1072
+ return {
1073
+ addRecord: (a) => {
1074
+ if (s.status !== 2) {
1075
+ if (s.status === 0) {
1076
+ const d = e();
1077
+ if (!d)
1078
+ return;
1079
+ s = {
1080
+ status: 1,
1081
+ segment: Pe({ encoder: o, context: d, creationReason: s.nextSegmentCreationReason }),
1082
+ expirationTimeoutId: At(() => {
1083
+ i("segment_duration_limit");
1084
+ }, ke)
1085
+ };
1086
+ }
1087
+ s.segment.addRecord(a, (d) => {
1088
+ d > dt && i("segment_bytes_limit");
1089
+ });
1090
+ }
1091
+ },
1092
+ stop: () => {
1093
+ i("stop"), r(), u();
1094
+ }
1095
+ };
1096
+ }
1097
+ function Be(t, e, n) {
1098
+ const o = e.findTrackedSession(), s = n.findView();
1099
+ if (!(!o || !s))
1100
+ return {
1101
+ application: {
1102
+ id: t
1103
+ },
1104
+ session: {
1105
+ id: o.id
1106
+ },
1107
+ view: {
1108
+ id: s.id
1109
+ }
1110
+ };
1111
+ }
1112
+ function Ue(t) {
1113
+ const e = Pt();
1114
+ return {
1115
+ addRecord: (n) => {
1116
+ const o = t.findView();
1117
+ e.send("record", n, o.id);
1118
+ }
1119
+ };
1120
+ }
1121
+ function Ge(t, e, n, o, s, r) {
1122
+ const u = [], i = (l) => {
1123
+ t.notify(14, { error: l }), K("Error reported to customer", { "error.message": l.message });
1124
+ }, a = r || kt(e.sessionReplayEndpointBuilder, dt, i);
1125
+ let d;
1126
+ if (zt())
1127
+ ({ addRecord: d } = Ue(o));
1128
+ else {
1129
+ const l = ze(t, e, n, o, a, s);
1130
+ d = l.addRecord, u.push(l.stop);
1131
+ }
1132
+ const { stop: c } = Ae({
1133
+ emit: d,
1134
+ configuration: e,
1135
+ lifeCycle: t,
1136
+ viewHistory: o
1137
+ });
1138
+ return u.push(c), {
1139
+ stop: () => {
1140
+ u.forEach((l) => l());
1141
+ }
1142
+ };
1143
+ }
1144
+ export {
1145
+ Ge as startRecording
1146
+ };