@montonio/montonio-js 1.1.8 → 1.1.9-prelive.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.
@@ -33,10 +33,10 @@ ${n}
33
33
  Please fix these validation errors and try again.`), this.name = Q.CHECKOUT_OPTIONS_VALIDATION_ERROR;
34
34
  }
35
35
  }
36
- var _;
36
+ var S;
37
37
  (function(e) {
38
38
  e.CHECKOUT_PAYMENT_COMPONENT_READY = "montonio:checkout.paymentComponentReady", e.CHECKOUT_CHANGE_LOCALE = "montonio:checkout.changeLocale", e.CHECKOUT_SUBMIT_PAYMENT = "montonio:checkout.submitPayment", e.CHECKOUT_START_PAYMENT_AUTH = "montonio:checkout.startPaymentAuth", e.CHECKOUT_SEND_PAYMENT_AUTH_DATA = "montonio:checkout.sendPaymentAuthData", e.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY = "montonio:checkout.paymentAuthComponentReady", e.CHECKOUT_PAYMENT_AUTH_COMPLETED = "montonio:checkout.paymentAuthCompleted", e.CHECKOUT_PAYMENT_COMPLETED = "montonio:checkout.paymentCompleted", e.CHECKOUT_PAYMENT_FAILED = "montonio:checkout.paymentFailed", e.CHECKOUT_SEND_PAYMENT_FAILED_DATA = "montonio:checkout.sendPaymentFailedData", e.CHECKOUT_HEIGHT_CHANGED = "montonio:checkout.heightChanged", e.CHECKOUT_VALIDATE_FIELDS = "montonio:checkout.validateFields", e.CHECKOUT_VALIDATE_FIELDS_RESULT = "montonio:checkout.validateFieldsResult", e.CHECKOUT_PAYMENT_FORM_CHANGED = "montonio:checkout.paymentFormChanged", e.CHECKOUT_REDIRECT = "montonio:checkout.redirect", e.CHECKOUT_ACTION_REQUIRED = "montonio:checkout.actionRequired";
39
- })(_ || (_ = {}));
39
+ })(S || (S = {}));
40
40
  class q {
41
41
  constructor() {
42
42
  this.environmentVariables = {
@@ -90,7 +90,7 @@ class ie {
90
90
  try {
91
91
  const i = {
92
92
  Accept: "application/json",
93
- "X-Montonio-Js-Version": "1.1.8"
93
+ "X-Montonio-Js-Version": "1.1.9-prelive.0"
94
94
  };
95
95
  r && (i["Content-Type"] = "application/json");
96
96
  const c = {
@@ -128,7 +128,7 @@ const ye = "Datadog Browser SDK:", y = {
128
128
  info: j.info.bind(k, ye),
129
129
  warn: j.warn.bind(k, ye),
130
130
  error: j.error.bind(k, ye)
131
- }, St = "https://docs.datadoghq.com", pr = `${St}/real_user_monitoring/browser/troubleshooting`, _t = "More details:";
131
+ }, _t = "https://docs.datadoghq.com", pr = `${_t}/real_user_monitoring/browser/troubleshooting`, St = "More details:";
132
132
  function nn(e, t) {
133
133
  return (...n) => {
134
134
  try {
@@ -138,7 +138,7 @@ function nn(e, t) {
138
138
  }
139
139
  };
140
140
  }
141
- function _e(e) {
141
+ function Se(e) {
142
142
  return e !== 0 && Math.random() * 100 <= e;
143
143
  }
144
144
  function mr(e) {
@@ -166,10 +166,10 @@ function yr() {
166
166
  function on(e, t) {
167
167
  return t - e;
168
168
  }
169
- function Sr(e, t) {
169
+ function _r(e, t) {
170
170
  return e + t;
171
171
  }
172
- function _r(e) {
172
+ function Sr(e) {
173
173
  return e - sn();
174
174
  }
175
175
  let Qe;
@@ -261,7 +261,7 @@ function Ht(e) {
261
261
  const n = (t = I.queueMicrotask) === null || t === void 0 ? void 0 : t.bind(I);
262
262
  typeof n == "function" ? n(b(e)) : Promise.resolve().then(b(e));
263
263
  }
264
- class S {
264
+ class _ {
265
265
  constructor(t) {
266
266
  this.onFirstSubscribe = t, this.observers = [];
267
267
  }
@@ -281,12 +281,12 @@ class S {
281
281
  }
282
282
  }
283
283
  function hn(...e) {
284
- return new S((t) => {
284
+ return new _((t) => {
285
285
  const n = e.map((r) => r.subscribe((o) => t.notify(o)));
286
286
  return () => n.forEach((r) => r.unsubscribe());
287
287
  });
288
288
  }
289
- class pn extends S {
289
+ class pn extends _ {
290
290
  constructor(t) {
291
291
  super(), this.maxBufferSize = t, this.buffer = [];
292
292
  }
@@ -480,9 +480,9 @@ function $r(e) {
480
480
  const wt = 4 * rn, bn = 15 * B, Fr = br, yn = "0", Te = {
481
481
  COOKIE: "cookie",
482
482
  LOCAL_STORAGE: "local-storage"
483
- }, Sn = /^([a-zA-Z]+)=([a-z0-9-]+)$/, At = "&";
483
+ }, _n = /^([a-zA-Z]+)=([a-z0-9-]+)$/, At = "&";
484
484
  function Hr(e) {
485
- return !!e && (e.indexOf(At) !== -1 || Sn.test(e));
485
+ return !!e && (e.indexOf(At) !== -1 || _n.test(e));
486
486
  }
487
487
  const Br = "1";
488
488
  function V(e, t) {
@@ -494,7 +494,7 @@ function V(e, t) {
494
494
  function Ue(e) {
495
495
  return qe(e);
496
496
  }
497
- function _n(e) {
497
+ function Sn(e) {
498
498
  return !Ue(e);
499
499
  }
500
500
  function Ce(e) {
@@ -512,7 +512,7 @@ function Tn(e) {
512
512
  function Rt(e) {
513
513
  const t = {};
514
514
  return Hr(e) && e.split(At).forEach((n) => {
515
- const r = Sn.exec(n);
515
+ const r = _n.exec(n);
516
516
  if (r !== null) {
517
517
  const [, o, s] = r;
518
518
  o === "aid" ? t.anonymousId = s : t[o] = s;
@@ -523,7 +523,7 @@ const Kr = "_dd", jr = "_dd_r", Vr = "_dd_l", Yr = "rum", zr = "logs";
523
523
  function qr(e) {
524
524
  if (!W(H)) {
525
525
  const n = W(Kr), r = W(jr), o = W(Vr), s = {};
526
- n && (s.id = n), o && /^[01]$/.test(o) && (s[zr] = o), r && /^[012]$/.test(r) && (s[Yr] = r), _n(s) && (Cn(s), e.persistSession(s));
526
+ n && (s.id = n), o && /^[01]$/.test(o) && (s[zr] = o), r && /^[012]$/.test(r) && (s[Yr] = r), Sn(s) && (Cn(s), e.persistSession(s));
527
527
  }
528
528
  }
529
529
  function Bt(e) {
@@ -669,7 +669,7 @@ function co(e, t) {
669
669
  return e.type === Te.COOKIE ? Wr(t, e.cookieOptions) : Zr(t);
670
670
  }
671
671
  function ao(e, t, n, r, o = co(e, t)) {
672
- const s = new S(), i = new S(), c = new S(), a = Tt(h, Vt);
672
+ const s = new _(), i = new _(), c = new _(), a = Tt(h, Vt);
673
673
  let u;
674
674
  C();
675
675
  const { throttled: d, cancel: l } = Ar(() => {
@@ -681,7 +681,7 @@ function ao(e, t, n, r, o = co(e, t)) {
681
681
  return E(L), L;
682
682
  },
683
683
  after: (g) => {
684
- _n(g) && !M() && lr(g), u = g;
684
+ Sn(g) && !M() && lr(g), u = g;
685
685
  }
686
686
  }, o);
687
687
  }, Vt);
@@ -757,7 +757,7 @@ const gt = {
757
757
  NOT_GRANTED: "not-granted"
758
758
  };
759
759
  function uo(e) {
760
- const t = new S();
760
+ const t = new _();
761
761
  return {
762
762
  tryToInit(n) {
763
763
  e || (e = n);
@@ -811,7 +811,7 @@ function go(e, t, n = typeof location != "undefined" ? location.origin : "") {
811
811
  const o = lo(r, n);
812
812
  return o || y.error(mo), o;
813
813
  }
814
- const Eo = "datad0g.com", bo = "dd0g-gov.com", ce = "datadoghq.com", yo = "ddog-gov.com", So = "pci.browser-intake-datadoghq.com", _o = ["ddsource", "dd-api-key", "dd-request-id"];
814
+ const Eo = "datad0g.com", bo = "dd0g-gov.com", ce = "datadoghq.com", yo = "ddog-gov.com", _o = "pci.browser-intake-datadoghq.com", So = ["ddsource", "dd-api-key", "dd-request-id"];
815
815
  function z(e, t, n) {
816
816
  const r = Co(e, t);
817
817
  return {
@@ -836,7 +836,7 @@ function Co(e, t) {
836
836
  function To(e, t) {
837
837
  const { site: n = ce, internalAnalyticsSubdomain: r } = t;
838
838
  if (e === "logs" && t.usePciIntake && n === ce)
839
- return So;
839
+ return _o;
840
840
  if (r && n === ce)
841
841
  return `${r}.${ce}`;
842
842
  if (n === bo)
@@ -891,13 +891,13 @@ function Ro(e) {
891
891
  };
892
892
  }
893
893
  function Io(e) {
894
- return _o.every((t) => e.includes(t));
894
+ return So.every((t) => e.includes(t));
895
895
  }
896
896
  function rt(e, t) {
897
897
  return e != null && typeof e != "string" ? (y.error(`${t} must be defined as a string`), !1) : !0;
898
898
  }
899
899
  function xo(e) {
900
- return e && typeof e == "string" && !/(datadog|ddog|datad0g|dd0g)/.test(e) ? (y.error(`Site should be a valid Datadog site. ${_t} ${St}/getting_started/site/.`), !1) : !0;
900
+ return e && typeof e == "string" && !/(datadog|ddog|datad0g|dd0g)/.test(e) ? (y.error(`Site should be a valid Datadog site. ${St} ${_t}/getting_started/site/.`), !1) : !0;
901
901
  }
902
902
  function Le(e, t) {
903
903
  return e !== void 0 && !mr(e) ? (y.error(`${t} Sample Rate should be a number between 0 and 100`), !1) : !0;
@@ -1331,7 +1331,7 @@ const A = {
1331
1331
  REPORT: "report"
1332
1332
  };
1333
1333
  function as() {
1334
- return new S((e) => {
1334
+ return new _((e) => {
1335
1335
  const t = (o, s) => {
1336
1336
  const i = xt({
1337
1337
  stackTrace: s,
@@ -1412,7 +1412,7 @@ function hs(e, t) {
1412
1412
  return r.length && n.push(ps(r)), hn(...n);
1413
1413
  }
1414
1414
  function ps(e) {
1415
- return new S((t) => {
1415
+ return new _((t) => {
1416
1416
  if (!window.ReportingObserver)
1417
1417
  return;
1418
1418
  const n = b((o, s) => o.forEach((i) => t.notify(gs(i)))), r = new window.ReportingObserver(n, {
@@ -1425,7 +1425,7 @@ function ps(e) {
1425
1425
  });
1426
1426
  }
1427
1427
  function ms(e) {
1428
- return new S((t) => {
1428
+ return new _((t) => {
1429
1429
  const { stop: n } = oe(e, document, "securitypolicyviolation", (r) => {
1430
1430
  t.notify(Es(r));
1431
1431
  });
@@ -1482,15 +1482,15 @@ function Dn(e) {
1482
1482
  }
1483
1483
  function K(e, t) {
1484
1484
  const n = t ? `${e}:${t}` : e;
1485
- return (n.length > bs || ys(n)) && y.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${_t} ${St}/getting_started/tagging/#defining-tags`), Mn(n);
1485
+ return (n.length > bs || ys(n)) && y.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${St} ${_t}/getting_started/tagging/#defining-tags`), Mn(n);
1486
1486
  }
1487
1487
  function Mn(e) {
1488
1488
  return e.replace(/,/g, "_");
1489
1489
  }
1490
1490
  function ys(e) {
1491
- return Ss() ? new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]", "u").test(e) : !1;
1491
+ return _s() ? new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]", "u").test(e) : !1;
1492
1492
  }
1493
- function Ss() {
1493
+ function _s() {
1494
1494
  try {
1495
1495
  return new RegExp("[\\p{Ll}]", "u"), !0;
1496
1496
  } catch (e) {
@@ -1501,7 +1501,7 @@ function $n(e, t) {
1501
1501
  const n = I.__ddBrowserSdkExtensionCallback;
1502
1502
  n && n({ type: e, payload: t });
1503
1503
  }
1504
- function je(e, t, n = _s()) {
1504
+ function je(e, t, n = Ss()) {
1505
1505
  if (t === void 0)
1506
1506
  return e;
1507
1507
  if (typeof t != "object" || t === null)
@@ -1541,7 +1541,7 @@ function te(...e) {
1541
1541
  n != null && (t = je(t, n));
1542
1542
  return t;
1543
1543
  }
1544
- function _s() {
1544
+ function Ss() {
1545
1545
  if (typeof WeakSet != "undefined") {
1546
1546
  const t = /* @__PURE__ */ new WeakSet();
1547
1547
  return {
@@ -1674,7 +1674,7 @@ function Is() {
1674
1674
  };
1675
1675
  }
1676
1676
  function qn(e, t, n) {
1677
- const r = new S(), o = Rs();
1677
+ const r = new _(), o = Rs();
1678
1678
  return {
1679
1679
  observable: r,
1680
1680
  send: (s) => {
@@ -1761,7 +1761,7 @@ const De = {
1761
1761
  FROZEN: "page_frozen"
1762
1762
  };
1763
1763
  function Ps(e) {
1764
- return new S((t) => {
1764
+ return new _((t) => {
1765
1765
  const { stop: n } = Lt(e, window, [
1766
1766
  "visibilitychange",
1767
1767
  "freeze"
@@ -1800,7 +1800,7 @@ ${l}`, (m) => {
1800
1800
  function u(l, f) {
1801
1801
  const h = Ae(l), m = e.estimateEncodedBytesCount(h);
1802
1802
  if (m >= r) {
1803
- y.warn(`Discarded a message whose size was bigger than the maximum allowed size ${r}KB. ${_t} ${pr}/#technical-limitations`);
1803
+ y.warn(`Discarded a message whose size was bigger than the maximum allowed size ${r}KB. ${St} ${pr}/#technical-limitations`);
1804
1804
  return;
1805
1805
  }
1806
1806
  c(f) && a(f), i(h, m, f);
@@ -1853,7 +1853,7 @@ function qt(e) {
1853
1853
  };
1854
1854
  }
1855
1855
  function Xn({ messagesLimit: e, bytesLimit: t, durationLimit: n, pageMayExitObservable: r, sessionExpireObservable: o }) {
1856
- const s = r.subscribe((m) => d(m.reason)), i = o.subscribe(() => d("session_expire")), c = new S(() => () => {
1856
+ const s = r.subscribe((m) => d(m.reason)), i = o.subscribe(() => d("session_expire")), c = new _(() => () => {
1857
1857
  s.unsubscribe(), i.unsubscribe();
1858
1858
  });
1859
1859
  let a = 0, u = 0;
@@ -1960,7 +1960,7 @@ function Re() {
1960
1960
  return ct || (ct = new pn(100)), ct;
1961
1961
  }
1962
1962
  function Bs(e, t, n, r, o, s) {
1963
- const i = new S(), { stop: c } = Ks(t, r, o, s, i), { enabled: a, metricsEnabled: u } = Gs(e, t, n, i);
1963
+ const i = new _(), { stop: c } = Ks(t, r, o, s, i), { enabled: a, metricsEnabled: u } = Gs(e, t, n, i);
1964
1964
  return {
1965
1965
  stop: c,
1966
1966
  enabled: a,
@@ -1968,12 +1968,12 @@ function Bs(e, t, n, r, o, s) {
1968
1968
  };
1969
1969
  }
1970
1970
  function Gs(e, t, n, r, o = Fs) {
1971
- const s = {}, i = !Hs.includes(t.site) && _e(t.telemetrySampleRate), c = {
1971
+ const s = {}, i = !Hs.includes(t.site) && Se(t.telemetrySampleRate), c = {
1972
1972
  [J.LOG]: i,
1973
- [J.CONFIGURATION]: i && _e(t.telemetryConfigurationSampleRate),
1974
- [J.USAGE]: i && _e(t.telemetryUsageSampleRate),
1973
+ [J.CONFIGURATION]: i && Se(t.telemetryConfigurationSampleRate),
1974
+ [J.USAGE]: i && Se(t.telemetryUsageSampleRate),
1975
1975
  // not an actual "type" but using a single draw for all metrics
1976
- metric: i && _e(o)
1976
+ metric: i && Se(o)
1977
1977
  }, a = js(), u = Re();
1978
1978
  return u.subscribe(({ rawEvent: l, metricName: f }) => {
1979
1979
  if (f && !c.metric || !c[l.type])
@@ -2038,7 +2038,7 @@ function Ks(e, t, n, r, o) {
2038
2038
  pageMayExitObservable: n,
2039
2039
  // We don't use an actual session expire observable here, to make telemetry collection
2040
2040
  // independent of the session. This allows to start and send telemetry events earlier.
2041
- sessionExpireObservable: new S()
2041
+ sessionExpireObservable: new _()
2042
2042
  }),
2043
2043
  messageBytesLimit: e.messageBytesLimit
2044
2044
  });
@@ -2126,14 +2126,14 @@ function Jn(e, t) {
2126
2126
  n >= 0 && e.splice(n, 1);
2127
2127
  }
2128
2128
  const Ne = 1 / 0, Zs = B;
2129
- let Se = null;
2129
+ let _e = null;
2130
2130
  const Me = /* @__PURE__ */ new Set();
2131
2131
  function Qs() {
2132
2132
  Me.forEach((e) => e());
2133
2133
  }
2134
2134
  function ei({ expireDelay: e, maxEntries: t }) {
2135
2135
  let n = [];
2136
- Se || (Se = Tt(() => Qs(), Zs));
2136
+ _e || (_e = Tt(() => Qs(), Zs));
2137
2137
  const r = () => {
2138
2138
  const d = $e() - e;
2139
2139
  for (; n.length > 0 && n[n.length - 1].endTime < d; )
@@ -2167,14 +2167,14 @@ function ei({ expireDelay: e, maxEntries: t }) {
2167
2167
  l && l.endTime === Ne && l.close(d);
2168
2168
  }
2169
2169
  function c(d = Ne, l = 0) {
2170
- const f = Sr(d, l);
2170
+ const f = _r(d, l);
2171
2171
  return n.filter((h) => h.startTime <= f && d <= h.endTime).map((h) => h.value);
2172
2172
  }
2173
2173
  function a() {
2174
2174
  n = [];
2175
2175
  }
2176
2176
  function u() {
2177
- Me.delete(r), Me.size === 0 && Se && (fn(Se), Se = null);
2177
+ Me.delete(r), Me.size === 0 && _e && (fn(_e), _e = null);
2178
2178
  }
2179
2179
  return { add: o, find: s, closeActive: i, findAll: c, reset: a, stop: u };
2180
2180
  }
@@ -2195,7 +2195,7 @@ function ii() {
2195
2195
  }
2196
2196
  const ci = B, ai = wt;
2197
2197
  function ui(e, t, n, r) {
2198
- const o = new S(), s = new S(), i = ao(e.sessionStoreStrategyType, e, t, n), c = ei({
2198
+ const o = new _(), s = new _(), i = ao(e.sessionStoreStrategyType, e, t, n), c = ei({
2199
2199
  expireDelay: ai
2200
2200
  });
2201
2201
  if (i.renewObservable.subscribe(() => {
@@ -2375,10 +2375,10 @@ function Ei(e) {
2375
2375
  return at || (at = bi(e)), at;
2376
2376
  }
2377
2377
  function bi(e) {
2378
- return new S((t) => {
2378
+ return new _((t) => {
2379
2379
  const { stop: n } = X(XMLHttpRequest.prototype, "open", yi), { stop: r } = X(XMLHttpRequest.prototype, "send", (s) => {
2380
- Si(s, e, t);
2381
- }, { computeHandlingStack: !0 }), { stop: o } = X(XMLHttpRequest.prototype, "abort", _i);
2380
+ _i(s, e, t);
2381
+ }, { computeHandlingStack: !0 }), { stop: o } = X(XMLHttpRequest.prototype, "abort", Si);
2382
2382
  return () => {
2383
2383
  n(), r(), o();
2384
2384
  };
@@ -2391,7 +2391,7 @@ function yi({ target: e, parameters: [t, n] }) {
2391
2391
  url: vt(String(n))
2392
2392
  });
2393
2393
  }
2394
- function Si({ target: e, parameters: [t], handlingStack: n }, r, o) {
2394
+ function _i({ target: e, parameters: [t], handlingStack: n }, r, o) {
2395
2395
  const s = Ut.get(e);
2396
2396
  if (!s)
2397
2397
  return;
@@ -2409,7 +2409,7 @@ function Si({ target: e, parameters: [t], handlingStack: n }, r, o) {
2409
2409
  }, { stop: d } = oe(r, e, "loadend", u);
2410
2410
  o.notify(i);
2411
2411
  }
2412
- function _i({ target: e }) {
2412
+ function Si({ target: e }) {
2413
2413
  const t = Ut.get(e);
2414
2414
  t && (t.isAborted = !0);
2415
2415
  }
@@ -2418,7 +2418,7 @@ function tr() {
2418
2418
  return ut || (ut = Ci()), ut;
2419
2419
  }
2420
2420
  function Ci() {
2421
- return new S((e) => {
2421
+ return new _((e) => {
2422
2422
  if (!I.fetch)
2423
2423
  return;
2424
2424
  const { stop: t } = X(I, "fetch", (n) => Ti(n, e), {
@@ -2469,7 +2469,7 @@ function Oi(e) {
2469
2469
  return hn(...t);
2470
2470
  }
2471
2471
  function wi(e) {
2472
- return new S((t) => {
2472
+ return new _((t) => {
2473
2473
  const n = k[e];
2474
2474
  return k[e] = (...r) => {
2475
2475
  n.apply(console, r);
@@ -2544,7 +2544,7 @@ function Wt(e) {
2544
2544
  }
2545
2545
  function Je(e = "", { propertiesConfig: t = {} } = {}) {
2546
2546
  let n = {};
2547
- const r = new S(), o = {
2547
+ const r = new _(), o = {
2548
2548
  getContext: () => Fn(n),
2549
2549
  setContext: (s) => {
2550
2550
  Li(s) ? n = U(dt(s, t, e)) : o.clearContext(), r.notify();
@@ -3012,11 +3012,11 @@ function Zi(e) {
3012
3012
  const n = sr(e) === "1" ? {} : void 0;
3013
3013
  return {
3014
3014
  findTrackedSession: () => n,
3015
- expireObservable: new S()
3015
+ expireObservable: new _()
3016
3016
  };
3017
3017
  }
3018
3018
  function sr(e, t) {
3019
- return Qi(t) ? t : _e(e.sessionSampleRate) ? "1" : "0";
3019
+ return Qi(t) ? t : Se(e.sessionSampleRate) ? "1" : "0";
3020
3020
  }
3021
3021
  function Qi(e) {
3022
3022
  return e === "0" || e === "1";
@@ -3027,7 +3027,7 @@ function ec(e, t, n, r, o) {
3027
3027
  i[c] = gi(c, e.eventRateLimiterThreshold, o);
3028
3028
  }), t.subscribe(0, ({ rawLogsEvent: c, messageContext: a = void 0, savedCommonContext: u = void 0, domainContext: d, ddtags: l = [] }) => {
3029
3029
  var f, h;
3030
- const m = _r(c.date), C = u || r(), E = n.triggerHook(0, {
3030
+ const m = Sr(c.date), C = u || r(), E = n.triggerHook(0, {
3031
3031
  startTime: m
3032
3032
  });
3033
3033
  if (E === me)
@@ -3094,7 +3094,7 @@ function rc(e, t) {
3094
3094
  function oc(e, t) {
3095
3095
  if (!e.forwardErrorsToLogs)
3096
3096
  return { stop: F };
3097
- const n = (ee ? new S() : Ei(e)).subscribe((s) => {
3097
+ const n = (ee ? new _() : Ei(e)).subscribe((s) => {
3098
3098
  s.state === "complete" && o(yt.XHR, s);
3099
3099
  }), r = tr().subscribe((s) => {
3100
3100
  s.state === "resolve" && o(yt.FETCH, s);
@@ -3276,8 +3276,8 @@ function yc(e) {
3276
3276
  }), Nt("Error reported to customer", { "error.message": t.message });
3277
3277
  };
3278
3278
  }
3279
- const Sc = Ms;
3280
- function _c(e) {
3279
+ const _c = Ms;
3280
+ function Sc(e) {
3281
3281
  const t = I;
3282
3282
  e.register(0, ({ startTime: o }) => {
3283
3283
  const s = n(o);
@@ -3324,14 +3324,14 @@ function Tc(e, t) {
3324
3324
  }
3325
3325
  const ht = "logs";
3326
3326
  function vc(e, t, n, r) {
3327
- const o = new fc(), s = Sc(), i = [];
3327
+ const o = new fc(), s = _c(), i = [];
3328
3328
  o.subscribe(1, (E) => $n("logs", E));
3329
- const c = yc(o), a = ee ? new S() : Ps(e), u = Bs("browser-logs-sdk", e, s, c, a, er);
3329
+ const c = yc(o), a = ee ? new _() : Ps(e), u = Bs("browser-logs-sdk", e, s, c, a, er);
3330
3330
  i.push(u.stop);
3331
3331
  const d = e.sessionStoreStrategyType && !Ve() && !Zn() ? Ji(e, n) : Zi(e);
3332
3332
  Tc(s, n), Cc(s, e, d);
3333
3333
  const l = Pi(s, e, ht), f = Mi(s, e, d, ht), h = Di(s, e, ht);
3334
- _c(s), oc(e, o), dc(e, o, r), r.unbuffer(), nc(e, o), rc(e, o);
3334
+ Sc(s), oc(e, o), dc(e, o, r), r.unbuffer(), nc(e, o), rc(e, o);
3335
3335
  const { handleLog: m } = hc(o);
3336
3336
  if (ec(e, o, s, t, c), Ve())
3337
3337
  Ec(o);
@@ -3400,7 +3400,7 @@ class ue {
3400
3400
  site: "datadoghq.eu",
3401
3401
  env: t === Oe.PRODUCTION ? "live-production" : "live-sandbox",
3402
3402
  service: "montonio-js",
3403
- version: "1.1.8",
3403
+ version: "1.1.9-prelive.0",
3404
3404
  silentMultipleInit: !0,
3405
3405
  forwardErrorsToLogs: !1,
3406
3406
  forwardConsoleLogs: []
@@ -3414,7 +3414,15 @@ class ue {
3414
3414
  }
3415
3415
  class ir {
3416
3416
  constructor() {
3417
- this.logger = new Mt("MessagingService"), this.subscriptions = /* @__PURE__ */ new Map(), this.setupMessageListener();
3417
+ this.logger = new Mt("MessagingService"), this.subscriptions = /* @__PURE__ */ new Map(), this.messageHandler = (t) => this.handleWindowMessage(t), window.addEventListener("message", this.messageHandler);
3418
+ }
3419
+ /**
3420
+ * Tear down this MessagingService: clear all subscriptions and remove
3421
+ * the global window message listener. Call this when the owning component
3422
+ * is being disposed to avoid leaking listeners across the page lifetime.
3423
+ */
3424
+ destroy() {
3425
+ this.clearAllSubscriptions(), window.removeEventListener("message", this.messageHandler);
3418
3426
  }
3419
3427
  /**
3420
3428
  * Subscribe to messages of a specific type from a specific source iframe.
@@ -3463,19 +3471,6 @@ class ir {
3463
3471
  postMessage(t, n, r = "*") {
3464
3472
  t.getContentWindow().postMessage(n, r);
3465
3473
  }
3466
- /**
3467
- * Clear all subscriptions
3468
- */
3469
- clearAllSubscriptions() {
3470
- this.subscriptions.clear();
3471
- }
3472
- /**
3473
- * Clear all subscriptions except the ones in the except array
3474
- */
3475
- clearSubscriptionsExcept(t) {
3476
- for (const n of [...this.subscriptions.keys()])
3477
- t.includes(n) || this.subscriptions.delete(n);
3478
- }
3479
3474
  /**
3480
3475
  * Remove an iframe from a subscription's sources
3481
3476
  */
@@ -3486,32 +3481,37 @@ class ir {
3486
3481
  r.sources = r.sources.filter((o) => o !== n), r.sources.length === 0 && this.subscriptions.delete(t);
3487
3482
  }
3488
3483
  /**
3489
- * Set up the message listener for capturing all window messages
3484
+ * Clear all subscriptions
3490
3485
  */
3491
- setupMessageListener() {
3492
- window.addEventListener("message", (t) => {
3493
- try {
3494
- if (!t.data || typeof t.data != "object" || !t.data.name)
3495
- return;
3496
- const n = t.data;
3497
- this.subscriptions.forEach((r, o) => {
3498
- if (!(o !== n.name || !r.sources.some((i) => {
3499
- try {
3500
- return i.getContentWindow() === t.source;
3501
- } catch (c) {
3502
- return this.logger.error("Failed to resolve contentWindow object for Iframe", c, { event: t }), !1;
3503
- }
3504
- })))
3505
- try {
3506
- r.handler(n);
3507
- } catch (i) {
3508
- this.logger.error("Error in message handler", i);
3509
- }
3510
- });
3511
- } catch (n) {
3512
- this.logger.error("Error processing iframe message", n);
3513
- }
3514
- });
3486
+ clearAllSubscriptions() {
3487
+ this.subscriptions.clear();
3488
+ }
3489
+ /**
3490
+ * Handle a window 'message' event: route it to any matching subscription
3491
+ * whose source iframe sent it.
3492
+ */
3493
+ handleWindowMessage(t) {
3494
+ try {
3495
+ if (!t.data || typeof t.data != "object" || !t.data.name)
3496
+ return;
3497
+ const n = t.data;
3498
+ this.subscriptions.forEach((r, o) => {
3499
+ if (!(o !== n.name || !r.sources.some((i) => {
3500
+ try {
3501
+ return i.getContentWindow() === t.source;
3502
+ } catch (c) {
3503
+ return this.logger.error("Failed to resolve contentWindow object for Iframe", c, { event: t }), !1;
3504
+ }
3505
+ })))
3506
+ try {
3507
+ r.handler(n);
3508
+ } catch (i) {
3509
+ this.logger.error("Error in message handler", i);
3510
+ }
3511
+ });
3512
+ } catch (n) {
3513
+ this.logger.error("Error processing iframe message", n);
3514
+ }
3515
3515
  }
3516
3516
  }
3517
3517
  class cr {
@@ -3528,7 +3528,7 @@ class cr {
3528
3528
  return this.options.mountElement.appendChild(this.element), this.resizeOnHeightChange && this.startResizing(this.element), this.element;
3529
3529
  }
3530
3530
  unmount() {
3531
- this.element.contentWindow && this.messagingService.clearAllSubscriptions(), this.element.parentNode && this.element.parentNode.removeChild(this.element);
3531
+ this.messagingService.destroy(), this.element.parentNode && this.element.parentNode.removeChild(this.element);
3532
3532
  }
3533
3533
  /**
3534
3534
  * Get the Window object of the iframe
@@ -3542,7 +3542,7 @@ class cr {
3542
3542
  * Listen to height change messages from the child window and change the height of the iframe element
3543
3543
  */
3544
3544
  startResizing(t) {
3545
- this.messagingService.subscribe(_.CHECKOUT_HEIGHT_CHANGED, (n) => {
3545
+ this.messagingService.subscribe(S.CHECKOUT_HEIGHT_CHANGED, (n) => {
3546
3546
  t.style.height = n.payload.height + "px";
3547
3547
  }, this);
3548
3548
  }
@@ -3565,8 +3565,8 @@ class ar {
3565
3565
  set iframe(t) {
3566
3566
  this._iframe = t;
3567
3567
  }
3568
- cleanup() {
3569
- this.iframe && (this.iframe.unmount(), this.iframe = null);
3568
+ destroy() {
3569
+ this._iframe && (this._iframe.unmount(), this._iframe = null), this.messagingService.destroy(), this.loaded = !1;
3570
3570
  }
3571
3571
  }
3572
3572
  function Oc(e) {
@@ -3646,21 +3646,21 @@ class Lc extends ar {
3646
3646
  zIndex: "2147483647"
3647
3647
  },
3648
3648
  resizeOnHeightChange: !1
3649
- }), this.iframe.mount(), await this.messagingService.waitForMessage(_.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY, this.iframe), this.messagingService.postMessage(this.iframe, {
3650
- name: _.CHECKOUT_SEND_PAYMENT_AUTH_DATA,
3649
+ }), this.iframe.mount(), await this.messagingService.waitForMessage(S.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY, this.iframe), this.messagingService.postMessage(this.iframe, {
3650
+ name: S.CHECKOUT_SEND_PAYMENT_AUTH_DATA,
3651
3651
  payload: {
3652
3652
  paymentAuthData: this.options.paymentAuthData
3653
3653
  }
3654
3654
  }), this.loaded = !0;
3655
3655
  } catch (t) {
3656
- throw this.cleanup(), t;
3656
+ throw this.destroy(), t;
3657
3657
  }
3658
3658
  }
3659
3659
  /**
3660
- * Clean up the payment auth component and restore body overflow
3660
+ * Destroy the payment auth component and restore body overflow
3661
3661
  */
3662
- cleanup() {
3663
- this.loaded && Ac(this.originalBodyOverflow), super.cleanup();
3662
+ destroy() {
3663
+ this.loaded && Ac(this.originalBodyOverflow), super.destroy();
3664
3664
  }
3665
3665
  /**
3666
3666
  * Handle redirect-based payment auth
@@ -3692,9 +3692,9 @@ class kc extends ar {
3692
3692
  return this.iframe = new cr({
3693
3693
  src: n.url,
3694
3694
  mountElement: this.mountElement
3695
- }), this.iframe.mount(), await this.messagingService.waitForMessage(_.CHECKOUT_PAYMENT_COMPONENT_READY, this.iframe), this.setUpListeners(), this.loaded = !0, this.logger.info(`Successfully mounted checkout to [${t}]`), !0;
3695
+ }), this.iframe.mount(), await this.messagingService.waitForMessage(S.CHECKOUT_PAYMENT_COMPONENT_READY, this.iframe), this.setUpListeners(), this.loaded = !0, this.logger.info(`Successfully mounted checkout to [${t}]`), !0;
3696
3696
  } catch (n) {
3697
- throw this.logger.error(`Error mounting checkout to [${t}]`, n), this.cleanup(), n;
3697
+ throw this.logger.error(`Error mounting checkout to [${t}]`, n), this.destroy(), n;
3698
3698
  }
3699
3699
  }
3700
3700
  /**
@@ -3705,7 +3705,7 @@ class kc extends ar {
3705
3705
  if (this.logger.info("Updating checkout options", { options: t }), !this.loaded)
3706
3706
  throw new $t();
3707
3707
  xc(t), t.locale !== void 0 && (this.options.locale = t.locale, this.messagingService.postMessage(this.iframe, {
3708
- name: _.CHECKOUT_CHANGE_LOCALE,
3708
+ name: S.CHECKOUT_CHANGE_LOCALE,
3709
3709
  payload: { locale: t.locale }
3710
3710
  }));
3711
3711
  }
@@ -3715,7 +3715,7 @@ class kc extends ar {
3715
3715
  validateOrReject() {
3716
3716
  if (!this.isValid)
3717
3717
  throw this.messagingService.postMessage(this.iframe, {
3718
- name: _.CHECKOUT_VALIDATE_FIELDS
3718
+ name: S.CHECKOUT_VALIDATE_FIELDS
3719
3719
  }), new Ft();
3720
3720
  }
3721
3721
  /**
@@ -3726,7 +3726,7 @@ class kc extends ar {
3726
3726
  if (!this.loaded)
3727
3727
  throw new $t();
3728
3728
  this.messagingService.postMessage(this.iframe, {
3729
- name: _.CHECKOUT_SUBMIT_PAYMENT
3729
+ name: S.CHECKOUT_SUBMIT_PAYMENT
3730
3730
  });
3731
3731
  }
3732
3732
  /**
@@ -3743,7 +3743,7 @@ class kc extends ar {
3743
3743
  this.logger.info("setUpListeners: Setting up listeners"), this.setUpFormChangeListener(), this.setUpPaymentCompletedListener(), this.setUpPaymentFailedListener(), this.setUpValidationListener(), this.setUpActionRequiredListener(), this.setUpPaymentAuthListener(), this.setUpRedirectListener();
3744
3744
  }
3745
3745
  setUpRedirectListener() {
3746
- this.messagingService.subscribe(_.CHECKOUT_REDIRECT, (t) => {
3746
+ this.messagingService.subscribe(S.CHECKOUT_REDIRECT, (t) => {
3747
3747
  window.location.href = t.payload.redirectUrl;
3748
3748
  }, this.iframe);
3749
3749
  }
@@ -3751,7 +3751,7 @@ class kc extends ar {
3751
3751
  * Listen for action required (e.g. 3DS started)
3752
3752
  */
3753
3753
  setUpActionRequiredListener() {
3754
- this.messagingService.subscribe(_.CHECKOUT_ACTION_REQUIRED, (t) => {
3754
+ this.messagingService.subscribe(S.CHECKOUT_ACTION_REQUIRED, (t) => {
3755
3755
  this.handleActionRequired(t.payload);
3756
3756
  }, this.iframe);
3757
3757
  }
@@ -3759,7 +3759,7 @@ class kc extends ar {
3759
3759
  * Listen for payment form changes and update the isValid property
3760
3760
  */
3761
3761
  setUpFormChangeListener() {
3762
- this.messagingService.subscribe(_.CHECKOUT_PAYMENT_FORM_CHANGED, (t) => {
3762
+ this.messagingService.subscribe(S.CHECKOUT_PAYMENT_FORM_CHANGED, (t) => {
3763
3763
  this.isValid = t.payload.isValid;
3764
3764
  }, this.iframe);
3765
3765
  }
@@ -3767,7 +3767,7 @@ class kc extends ar {
3767
3767
  * Listen for payment completion messages and handle the payment success
3768
3768
  */
3769
3769
  setUpPaymentCompletedListener() {
3770
- this.messagingService.subscribe(_.CHECKOUT_PAYMENT_COMPLETED, async (t) => {
3770
+ this.messagingService.subscribe(S.CHECKOUT_PAYMENT_COMPLETED, async (t) => {
3771
3771
  this.logger.info("Checkout payment completed", { event: t }), this.cleanupPaymentAuth();
3772
3772
  try {
3773
3773
  const n = await this.getPaymentResult(t.payload.paymentIntentUuid);
@@ -3781,9 +3781,9 @@ class kc extends ar {
3781
3781
  * Listen for payment failure messages and handle the error
3782
3782
  */
3783
3783
  setUpPaymentFailedListener() {
3784
- this.messagingService.subscribe(_.CHECKOUT_PAYMENT_FAILED, (t) => {
3784
+ this.messagingService.subscribe(S.CHECKOUT_PAYMENT_FAILED, (t) => {
3785
3785
  this.logger.warn("Checkout payment failed", t), this.cleanupPaymentAuth(), this.messagingService.postMessage(this.iframe, {
3786
- name: _.CHECKOUT_SEND_PAYMENT_FAILED_DATA,
3786
+ name: S.CHECKOUT_SEND_PAYMENT_FAILED_DATA,
3787
3787
  payload: t.payload
3788
3788
  }), this.handlePaymentError(new fr(t.payload));
3789
3789
  }, this.iframe);
@@ -3792,7 +3792,7 @@ class kc extends ar {
3792
3792
  * Listen for validation result messages from the iframe
3793
3793
  */
3794
3794
  setUpValidationListener() {
3795
- this.messagingService.subscribe(_.CHECKOUT_VALIDATE_FIELDS_RESULT, (t) => {
3795
+ this.messagingService.subscribe(S.CHECKOUT_VALIDATE_FIELDS_RESULT, (t) => {
3796
3796
  this.logger.info("Checkout validate fields result", { event: t }), t.payload.isValid || this.handlePaymentError(new Ft());
3797
3797
  }, this.iframe);
3798
3798
  }
@@ -3800,13 +3800,13 @@ class kc extends ar {
3800
3800
  * Listen for payment auth (3DS) requests and initialize the PaymentAuth component
3801
3801
  */
3802
3802
  setUpPaymentAuthListener() {
3803
- this.messagingService.subscribe(_.CHECKOUT_START_PAYMENT_AUTH, async (t) => {
3803
+ this.messagingService.subscribe(S.CHECKOUT_START_PAYMENT_AUTH, async (t) => {
3804
3804
  try {
3805
3805
  this.logger.info("Payment auth started", { event: t }), this.paymentAuth = new Lc({
3806
3806
  paymentAuthData: t.payload.paymentAuthData
3807
3807
  }), await this.paymentAuth.initialize();
3808
3808
  const n = this.paymentAuth.iframe;
3809
- this.messagingService.addIframeToSubscription(_.CHECKOUT_PAYMENT_COMPLETED, n), this.messagingService.addIframeToSubscription(_.CHECKOUT_PAYMENT_FAILED, n);
3809
+ this.messagingService.addIframeToSubscription(S.CHECKOUT_PAYMENT_COMPLETED, n), this.messagingService.addIframeToSubscription(S.CHECKOUT_PAYMENT_FAILED, n);
3810
3810
  } catch (n) {
3811
3811
  this.handlePaymentError(n);
3812
3812
  }
@@ -3840,7 +3840,7 @@ class kc extends ar {
3840
3840
  * Destroy the PaymentAuth component and remove it from success/failure subscriptions
3841
3841
  */
3842
3842
  cleanupPaymentAuth() {
3843
- this.paymentAuth && (this.messagingService.removeIframeFromSubscription(_.CHECKOUT_PAYMENT_COMPLETED, this.paymentAuth.iframe), this.messagingService.removeIframeFromSubscription(_.CHECKOUT_PAYMENT_FAILED, this.paymentAuth.iframe), this.paymentAuth.cleanup(), this.paymentAuth = null);
3843
+ this.paymentAuth && (this.messagingService.removeIframeFromSubscription(S.CHECKOUT_PAYMENT_COMPLETED, this.paymentAuth.iframe), this.messagingService.removeIframeFromSubscription(S.CHECKOUT_PAYMENT_FAILED, this.paymentAuth.iframe), this.paymentAuth.destroy(), this.paymentAuth = null);
3844
3844
  }
3845
3845
  /**
3846
3846
  * Handle payment success - calls the onSuccess callback
@@ -3866,7 +3866,7 @@ export {
3866
3866
  Oe as Environment,
3867
3867
  Q as ErrorEnum,
3868
3868
  ze as LocaleEnum,
3869
- _ as MessageTypeEnum,
3869
+ S as MessageTypeEnum,
3870
3870
  kc as MontonioCheckout
3871
3871
  };
3872
3872
  //# sourceMappingURL=montonio.es.js.map