@montonio/montonio-js 1.1.6 → 1.1.7
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.
- package/dist/montonio.es.js +958 -944
- package/dist/montonio.es.js.map +1 -1
- package/dist/montonio.umd.js +9 -9
- package/dist/montonio.umd.js.map +1 -1
- package/dist/types/components/MontonioCheckout/MontonioCheckout.d.ts +1 -0
- package/dist/types/services/Logging/Logging.d.ts +15 -0
- package/dist/types/services/Messaging/Messaging.d.ts +1 -0
- package/dist/types/services/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/montonio.umd.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
The customer should not try again! We will inform you about the payment being paid via webhook.`),this.name=
|
|
1
|
+
(function(h,oe){typeof exports=="object"&&typeof module!="undefined"?oe(exports):typeof define=="function"&&define.amd?define(["exports"],oe):(h=typeof globalThis!="undefined"?globalThis:h||self,oe(h.Montonio={}))})(this,function(h){"use strict";h.ErrorEnum=void 0,function(e){e.MONTONIO_CHECKOUT_NOT_INITIALIZED="MONTONIO_CHECKOUT_NOT_INITIALIZED",e.VALIDATION_ERROR="VALIDATION_ERROR",e.CHECKOUT_OPTIONS_VALIDATION_ERROR="CHECKOUT_OPTIONS_VALIDATION_ERROR",e.PAYMENT_FAILED="PAYMENT_FAILED",e.FAILED_TO_FETCH_RETURN_URL="FAILED_TO_FETCH_RETURN_URL"}(h.ErrorEnum||(h.ErrorEnum={}));class oe extends Error{constructor(t="MontonioCheckout not initialized. Please call the .initialize() method of the MontonioCheckout class first."){super(t),this.name=h.ErrorEnum.MONTONIO_CHECKOUT_NOT_INITIALIZED}}class Dt extends Error{constructor(t="Validation failed. Check payment details and try again."){super(t),this.displayedInPaymentComponent=!0,this.name=h.ErrorEnum.VALIDATION_ERROR}}class sr extends Error{constructor(t){super(`Payment failed: ${t.errorCode}`),this.displayedInPaymentComponent=!0,this.name=h.ErrorEnum.PAYMENT_FAILED,this.paymentFailedMessageData=t}}class ir extends Error{constructor({attempts:t}){super(`Payment was successful but we failed to fetch the return-url from our servers after ${t} retries.
|
|
2
|
+
The customer should not try again! We will inform you about the payment being paid via webhook.`),this.name=h.ErrorEnum.FAILED_TO_FETCH_RETURN_URL}}class Je extends Error{constructor(t){const n=t.map((r,o)=>` ${o+1}. ${r}`).join(`
|
|
3
3
|
`);super(`Invalid CheckoutOptions provided:
|
|
4
4
|
${n}
|
|
5
5
|
|
|
6
|
-
Please fix these validation errors and try again.`),this.name=m.ErrorEnum.CHECKOUT_OPTIONS_VALIDATION_ERROR}}m.MessageTypeEnum=void 0,function(e){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"}(m.MessageTypeEnum||(m.MessageTypeEnum={}));class K{constructor(){this.environmentVariables={stargateUrl:{sandbox:"https://sandbox-stargate.montonio.com",production:"https://stargate.montonio.com","prelive-sandbox":"https://sandbox-stargate.prelive.montonio.com","prelive-production":"https://stargate.prelive.montonio.com",development:"https://api-stargate.montonio.dev"},datadogClientToken:"pubb5b1ffe19aeb16a90d1181fd3e866b83"}}static get instance(){return K._instance||(K._instance=new K),K._instance}getConfig(t,n){const r=this.environmentVariables[t];if(typeof r=="string")return r;if(!n)throw new Error(`Environment parameter required for config key: ${t}`);return r[n]}}class oe{constructor(){this.timeout=3e4}static get instance(){return oe._instance||(oe._instance=new oe),oe._instance}async get(t){return this.request(t,"GET")}async post(t,n){return this.request(t,"POST",n)}async patch(t,n){return this.request(t,"PATCH",n)}async request(t,n,r){const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout);try{const i={Accept:"application/json","X-Montonio-Js-Version":"1.1.6"};r&&(i["Content-Type"]="application/json");const c={method:n,headers:i,credentials:"include",mode:"cors",signal:o.signal};r&&(c.body=JSON.stringify(r));const a=await fetch(t,c);if(!a.ok)throw new Error(`HTTP error ${a.status}: ${a.statusText}`);return await a.json()}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timeout after ${this.timeout}ms`):i}finally{clearTimeout(s)}}}class Mt{constructor(){this.subscriptions=new Map,this.setupMessageListener()}subscribe(t,n,r){if(this.subscriptions.has(t))throw new Error(`Subscription for '${t}' already exists`);this.subscriptions.set(t,{handler:n,sources:[r]})}addIframeToSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);r.sources.includes(n)||r.sources.push(n)}waitForMessage(t,n,r=3e4){return new Promise((o,s)=>{const i=setTimeout(()=>{this.removeIframeFromSubscription(t,n),s(new Error(`Message ${t} timeout after ${r}ms`))},r);this.subscribe(t,c=>{clearTimeout(i),this.removeIframeFromSubscription(t,n),o(c)},n)})}postMessage(t,n,r="*"){t.getContentWindow().postMessage(n,r)}clearAllSubscriptions(){this.subscriptions.clear()}clearSubscriptionsExcept(t){for(const n of[...this.subscriptions.keys()])t.includes(n)||this.subscriptions.delete(n)}removeIframeFromSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);r.sources=r.sources.filter(o=>o!==n),r.sources.length===0&&this.subscriptions.delete(t)}setupMessageListener(){window.addEventListener("message",t=>{try{if(!t.data||typeof t.data!="object"||!t.data.name)return;const n=t.data;this.subscriptions.forEach((r,o)=>{if(!(o!==n.name||!r.sources.some(i=>{try{return i.getContentWindow()===t.source}catch(c){return console.error("MONTONIO-JS: MessagingService: Failed to resolve contentWindow for source:",c),!1}})))try{r.handler(n)}catch(i){console.error("Error in message handler:",i)}})}catch(n){console.error("Error processing iframe message:",n)}})}}const T={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},N=console,j={};Object.keys(T).forEach(e=>{j[e]=N[e]});const ye="Datadog Browser SDK:",y={debug:j.debug.bind(N,ye),log:j.log.bind(N,ye),info:j.info.bind(N,ye),warn:j.warn.bind(N,ye),error:j.error.bind(N,ye)},Ze="https://docs.datadoghq.com",ir=`${Ze}/real_user_monitoring/browser/troubleshooting`,Qe="More details:";function Dt(e,t){return(...n)=>{try{return e(...n)}catch(r){y.error(t,r)}}}function be(e){return e!==0&&Math.random()*100<=e}function cr(e){return ar(e)&&e>=0&&e<=100}function ar(e){return typeof e=="number"}const se=1e3,D=60*se,$t=60*D,ur=365*(24*$t);function $(){return new Date().getTime()}function U(){return $()}function we(){return performance.now()}function k(){return{relative:we(),timeStamp:U()}}function lr(){return{relative:0,timeStamp:Ht()}}function Ft(e,t){return t-e}function dr(e,t){return e+t}function fr(e){return e-Ht()}let et;function Ht(){var e,t;return et===void 0&&(et=(t=(e=performance.timing)===null||e===void 0?void 0:e.navigationStart)!==null&&t!==void 0?t:performance.timeOrigin),et}const ie=1024,Bt=1024*ie,mr=/[^\u0000-\u007F]/;function Gt(e){return mr.test(e)?window.TextEncoder!==void 0?new TextEncoder().encode(e).length:new Blob([e]).size:e.length}function hr(e){return{...e}}function Kt(e,t){return Object.keys(e).some(n=>e[n]===t)}function Re(e){return Object.keys(e).length===0}function I(){if(typeof globalThis=="object")return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,typeof e!="object"&&(typeof self=="object"?e=self:typeof window=="object"?e=window:e={}),e}const L=I(),z="WorkerGlobalScope"in L;function ce(e,t){const n=I();let r;return n.Zone&&typeof n.Zone.__symbol__=="function"&&(r=e[n.Zone.__symbol__(t)]),r||(r=e[t]),r}let Ie,jt=!1;function pr(e){Ie=e}function gr(e){jt=e}function Er(e,t,n){const r=n.value;n.value=function(...o){return(Ie?b(r):r).apply(this,o)}}function b(e){return function(){return ae(e,this,arguments)}}function ae(e,t,n){try{return e.apply(t,n)}catch(r){tt(r)}}function tt(e){if(nt(e),Ie)try{Ie(e)}catch(t){nt(t)}}function nt(...e){jt&&y.error("[MONITOR]",...e)}function Se(e,t){return ce(I(),"setTimeout")(b(e),t)}function zt(e){ce(I(),"clearTimeout")(e)}function rt(e,t){return ce(I(),"setInterval")(b(e),t)}function Yt(e){ce(I(),"clearInterval")(e)}function Vt(e){var t;const n=(t=L.queueMicrotask)===null||t===void 0?void 0:t.bind(L);typeof n=="function"?n(b(e)):Promise.resolve().then(b(e))}class S{constructor(t){this.onFirstSubscribe=t,this.observers=[]}subscribe(t){return this.addObserver(t),{unsubscribe:()=>this.removeObserver(t)}}notify(t){this.observers.forEach(n=>n(t))}addObserver(t){this.observers.push(t),this.observers.length===1&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(t){this.observers=this.observers.filter(n=>t!==n),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function qt(...e){return new S(t=>{const n=e.map(r=>r.subscribe(o=>t.notify(o)));return()=>n.forEach(r=>r.unsubscribe())})}class Wt extends S{constructor(t){super(),this.maxBufferSize=t,this.buffer=[]}notify(t){this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(t)}subscribe(t){let n=!1;const r={unsubscribe:()=>{n=!0,this.removeObserver(t)}};return Vt(()=>{for(const o of this.buffer){if(n)return;t(o)}n||this.addObserver(t)}),r}unbuffer(){Vt(()=>{this.maxBufferSize=this.buffer.length=0})}}function yr(e,t,n){let r=!1,o,s;return{throttled:(...i)=>{if(r){o=i;return}e(...i),r=!0,s=Se(()=>{o&&e(...o),r=!1,o=void 0},t)},cancel:()=>{zt(s),r=!1,o=void 0}}}function F(){}function H(e){return e?(parseInt(e,10)^Math.random()*16>>parseInt(e,10)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,H)}const Le=/([\w-]+)\s*=\s*([^;]+)/g;function br(e,t){for(Le.lastIndex=0;;){const n=Le.exec(e);if(n){if(n[1]===t)return n[2]}else break}}function Sr(e){const t=new Map;for(Le.lastIndex=0;;){const n=Le.exec(e);if(n)t.set(n[1],n[2]);else break}return t}function _r(e,t,n=""){const r=e.charCodeAt(t-1),s=r>=55296&&r<=56319?t+1:t;return e.length<=s?e:`${e.slice(0,s)}${n}`}function Tr(){return Or()===0}let Ne;function Or(){return Ne!=null?Ne:Ne=Cr()}function Cr(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:((t=e.navigator.vendor)===null||t===void 0?void 0:t.indexOf("Apple"))===0||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}function ot(e){return Jt(e,location.href).href}function Jt(e,t){const{URL:n}=vr();try{return t!==void 0?new n(e,t):new n(e)}catch(r){throw new Error(`Failed to construct URL: ${String(r)}`)}}let st;function vr(){if(!st){let e,t;try{e=document.createElement("iframe"),e.style.display="none",document.body.appendChild(e),t=e.contentWindow}catch(n){t=L}st={URL:t.URL},e==null||e.remove()}return st}function ke(e,t,n=0,r){const o=new Date;o.setTime(o.getTime()+n);const s=`expires=${o.toUTCString()}`,i=r&&r.crossSite?"none":"strict",c=r&&r.domain?`;domain=${r.domain}`:"",a=r&&r.secure?";secure":"",u=r&&r.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${c}${a}${u}`}function it(e){return br(document.cookie,e)}let ct;function Y(e){return ct||(ct=Sr(document.cookie)),ct.get(e)}function Xt(e,t){ke(e,"",0,t)}function Ar(e){if(document.cookie===void 0||document.cookie===null)return!1;try{const t=`dd_cookie_test_${H()}`,n="test";ke(t,n,D,e);const r=it(t)===n;return Xt(t,e),r}catch(t){return y.error(t),!1}}let at;function Zt(e=location.hostname,t=document.referrer){if(at===void 0){const n=wr(e,t);if(n){const r=`dd_site_test_${H()}`,o="test",s=n.split(".");let i=s.pop();for(;s.length&&!it(r);)i=`${s.pop()}.${i}`,ke(r,o,se,{domain:i});Xt(r,{domain:i}),at=i}}return at}function wr(e,t){try{return e||Jt(t).hostname}catch(n){}}const B="_dd_s";function Rr(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(t(r,n,e))return r}}function xe(e){return Object.values(e)}function Ir(e){return Object.entries(e)}const ut=4*$t,Qt=15*D,Lr=ur,en="0",_e={COOKIE:"cookie",LOCAL_STORAGE:"local-storage"},tn=/^([a-zA-Z]+)=([a-z0-9-]+)$/,lt="&";function Nr(e){return!!e&&(e.indexOf(lt)!==-1||tn.test(e))}const kr="1";function V(e,t){const n={isExpired:kr};return t.trackAnonymousUser&&(e!=null&&e.anonymousId?n.anonymousId=e==null?void 0:e.anonymousId:n.anonymousId=H()),n}function Ue(e){return Re(e)}function nn(e){return!Ue(e)}function Te(e){return e.isExpired!==void 0||!xr(e)}function xr(e){return(e.created===void 0||$()-Number(e.created)<ut)&&(e.expire===void 0||$()<Number(e.expire))}function rn(e){e.expire=String($()+Qt)}function on(e){return Ir(e).map(([t,n])=>t==="anonymousId"?`aid=${n}`:`${t}=${n}`).join(lt)}function dt(e){const t={};return Nr(e)&&e.split(lt).forEach(n=>{const r=tn.exec(n);if(r!==null){const[,o,s]=r;o==="aid"?t.anonymousId=s:t[o]=s}}),t}const Ur="_dd",Pr="_dd_r",Mr="_dd_l",Dr="rum",$r="logs";function Fr(e){if(!Y(B)){const n=Y(Ur),r=Y(Pr),o=Y(Mr),s={};n&&(s.id=n),o&&/^[01]$/.test(o)&&(s[$r]=o),r&&/^[012]$/.test(r)&&(s[Dr]=r),nn(s)&&(rn(s),e.persistSession(s))}}function sn(e){const t=Br(e);return t&&Ar(t)?{type:_e.COOKIE,cookieOptions:t}:void 0}function Hr(e,t){const n={isLockEnabled:Tr(),persistSession:r=>cn(t,e,r,Qt),retrieveSession:an,expireSession:r=>cn(t,e,V(r,e),ut)};return Fr(n),n}function cn(e,t,n,r){ke(B,on(n),t.trackAnonymousUser?Lr:r,e)}function an(){const e=it(B);return dt(e)}function Br(e){const t={};if(t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains){const n=Zt();if(!n)return;t.domain=n}return t}const Gr="_dd_test_";function un(){try{const e=H(),t=`${Gr}${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:_e.LOCAL_STORAGE}:void 0}catch(e){return}}function Kr(e){return{isLockEnabled:!1,persistSession:ln,retrieveSession:jr,expireSession:t=>zr(t,e)}}function ln(e){localStorage.setItem(B,on(e))}function jr(){const e=localStorage.getItem(B);return dt(e)}function zr(e,t){ln(V(e,t))}const Yr=10,Vr=100,qr=se,dn="--",fn=[];let Pe;function q(e,t,n=0){var r;const{isLockEnabled:o,persistSession:s,expireSession:i}=t,c=f=>s({...f,lock:u}),a=()=>{const{lock:f,...h}=t.retrieveSession();return{session:h,lock:f&&!Jr(f)?f:void 0}};if(Pe||(Pe=e),e!==Pe){fn.push(e);return}if(o&&n>=Vr){mn(t);return}let u,d=a();if(o){if(d.lock){Me(e,t,n);return}if(u=Wr(),c(d.session),d=a(),d.lock!==u){Me(e,t,n);return}}let l=e.process(d.session);if(o&&(d=a(),d.lock!==u)){Me(e,t,n);return}if(l&&(Te(l)?i(l):(rn(l),o?c(l):s(l))),o&&!(l&&Te(l))){if(d=a(),d.lock!==u){Me(e,t,n);return}s(d.session),l=d.session}(r=e.after)===null||r===void 0||r.call(e,l||d.session),mn(t)}function Me(e,t,n){Se(()=>{q(e,t,n+1)},Yr)}function mn(e){Pe=void 0;const t=fn.shift();t&&q(t,e)}function Wr(){return H()+dn+U()}function Jr(e){const[,t]=e.split(dn);return!t||Ft(Number(t),U())>qr}const hn=se;function Xr(e){switch(e.sessionPersistence){case _e.COOKIE:return sn(e);case _e.LOCAL_STORAGE:return un();case void 0:{let t=sn(e);return!t&&e.allowFallbackToLocalStorage&&(t=un()),t}default:y.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Zr(e,t){return e.type===_e.COOKIE?Hr(t,e.cookieOptions):Kr(t)}function Qr(e,t,n,r,o=Zr(e,t)){const s=new S,i=new S,c=new S,a=rt(h,hn);let u;O();const{throttled:d,cancel:l}=yr(()=>{q({process:E=>{if(Ue(E))return;const x=g(E);return _(x),x},after:E=>{nn(E)&&!G()&&vc(E),u=E}},o)},hn);function f(){q({process:E=>G()?g(E):void 0},o)}function h(){const E=o.retrieveSession();Te(E)?q({process:x=>Te(x)?V(x,t):void 0,after:g},o):g(E)}function g(E){return Te(E)&&(E=V(E,t)),G()&&(Ee(E)?Cc():(c.notify({previousState:u,newState:E}),u=E)),E}function O(){q({process:E=>{if(Ue(E))return V(E,t)},after:E=>{u=E}},o)}function _(E){if(Ue(E))return!1;const x=r(E[n]);E[n]=x,delete E.isExpired,x!==en&&!E.id&&(E.id=H(),E.created=String($()))}function G(){return(u==null?void 0:u[n])!==void 0}function Ee(E){return u.id!==E.id||u[n]!==E[n]}function Cc(){u=V(u,t),i.notify()}function vc(E){u=E,s.notify()}function Ac(E){q({process:x=>({...x,...E}),after:g},o)}return{expandOrRenewSession:d,expandSession:f,getSession:()=>u,renewObservable:s,expireObservable:i,sessionStateUpdateObservable:c,restartSession:O,expire:()=>{l(),o.expireSession(u),g(V(u,t))},stop:()=>{Yt(a)},updateSessionState:Ac}}const ft={GRANTED:"granted",NOT_GRANTED:"not-granted"};function eo(e){const t=new S;return{tryToInit(n){e||(e=n)},update(n){e=n,t.notify()},isGranted(){return e===ft.GRANTED},observable:t}}function pn(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function to(e,t,n=!1){return e.some(r=>{try{if(typeof r=="function")return r(t);if(r instanceof RegExp)return r.test(t);if(typeof r=="string")return n?t.startsWith(r):r===t}catch(o){y.error(o)}return!1})}const no=["chrome-extension://","moz-extension://"];function gn(e){return no.some(t=>e.includes(t))}function ro(e,t=""){if(gn(e))return!1;const r=t.split(`
|
|
7
|
-
`).filter(o=>{const s=o.trim();return s.length&&/^at\s+|@/.test(s)})[1]||"";return gn(r)}const
|
|
8
|
-
`).forEach(i=>{const c=
|
|
9
|
-
at ${r}${o} @ ${n.url}${s}${i}`}),t}function bn(e){return`${e.name||"Error"}: ${e.message}`}function J(e,t,n,{computeHandlingStack:r}={}){let o=e[t];if(typeof o!="function")if(t in e&&t.startsWith("on"))o=F;else return{stop:F};let s=!1;const i=function(){if(s)return o.apply(this,arguments);const c=Array.from(arguments);let a;ae(n,null,[{target:this,parameters:c,onPostCall:d=>{a=d},handlingStack:r?He("instrumented method"):void 0}]);const u=o.apply(this,c);return a&&ae(a,null,[u]),u};return e[t]=i,{stop:()=>{s=!0,e[t]===i&&(e[t]=o)}}}function Oe(e,t,n){if(typeof e!="object"||e===null)return JSON.stringify(e);const r=he(Object.prototype),o=he(Array.prototype),s=he(Object.getPrototypeOf(e)),i=he(e);try{return JSON.stringify(e,t,n)}catch(c){return"<error: unable to serialize object>"}finally{r(),o(),s(),i()}}function he(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):F}const Go=220*ie,Ko="$",jo=3;function P(e,t=Go){const n=he(Object.prototype),r=he(Array.prototype),o=[],s=new WeakMap,i=gt(e,Ko,void 0,o,s),c=JSON.stringify(i);let a=c?c.length:0;if(a>t){yt(t,"discarded",e);return}for(;o.length>0&&a<t;){const u=o.shift();let d=0;if(Array.isArray(u.source))for(let l=0;l<u.source.length;l++){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0?a+=JSON.stringify(f).length:a+=4,a+=d,d=1,a>t){yt(t,"truncated",e);break}u.target[l]=f}else for(const l in u.source)if(Object.prototype.hasOwnProperty.call(u.source,l)){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0&&(a+=JSON.stringify(f).length+d+l.length+jo,d=1),a>t){yt(t,"truncated",e);break}u.target[l]=f}}return n(),r(),i}function gt(e,t,n,r,o){const s=Vo(e);if(!s||typeof s!="object")return zo(s);const i=Et(s);if(i!=="[Object]"&&i!=="[Array]"&&i!=="[Error]")return i;const c=e;if(o.has(c))return`[Reference seen at ${o.get(c)}]`;const a=n!==void 0?`${t}.${n}`:t,u=Array.isArray(s)?[]:{};return o.set(c,a),r.push({source:s,target:u,path:a}),u}function zo(e){return typeof e=="bigint"?`[BigInt] ${e.toString()}`:typeof e=="function"?`[Function] ${e.name||"unknown"}`:typeof e=="symbol"?`[Symbol] ${e.description||e.toString()}`:e}function Et(e){try{if(e instanceof Event)return Yo(e);if(e instanceof RegExp)return`[RegExp] ${e.toString()}`;const n=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(n&&n[1])return`[${n[1]}]`}catch(t){}return"[Unserializable]"}function Yo(e){return{type:e.type,isTrusted:e.isTrusted,currentTarget:e.currentTarget?Et(e.currentTarget):null,target:e.target?Et(e.target):null}}function Vo(e){const t=e;if(t&&typeof t.toJSON=="function")try{return t.toJSON()}catch(n){}return e}function yt(e,t,n){y.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const Sn="No stack, consider using an instance of Error";function bt({stackTrace:e,originalError:t,handlingStack:n,componentStack:r,startClocks:o,nonErrorPrefix:s,useFallbackStack:i=!0,source:c,handling:a}){const u=X(t);return!e&&u&&(e=de(t)),{startClocks:o,source:c,handling:a,handlingStack:n,componentStack:r,originalError:t,type:e?e.name:void 0,message:qo(e,u,s,t),stack:e?me(e):i?Sn:void 0,causes:u?Zo(t,c):void 0,fingerprint:Wo(t),context:Jo(t)}}function qo(e,t,n,r){return e!=null&&e.message&&(e!=null&&e.name)?e.message:t?"Empty message":`${n} ${Oe(P(r))}`}function Wo(e){return X(e)&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function Jo(e){if(e!==null&&typeof e=="object"&&"dd_context"in e)return e.dd_context}function Xo(e){var t;return(t=/@ (.+)/.exec(e))===null||t===void 0?void 0:t[1]}function X(e){return e instanceof Error||Object.prototype.toString.call(e)==="[object Error]"}function Zo(e,t){let n=e;const r=[];for(;X(n==null?void 0:n.cause)&&r.length<10;){const o=de(n.cause);r.push({message:n.cause.message,source:t,type:o==null?void 0:o.name,stack:o&&me(o)}),n=n.cause}return r.length?r:void 0}const w={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"};function Qo(){return new S(e=>{const t=(o,s)=>{const i=bt({stackTrace:s,originalError:o,startClocks:k(),nonErrorPrefix:"Uncaught",source:w.SOURCE,handling:"unhandled"});e.notify(i)},{stop:n}=es(t),{stop:r}=ts(t);return()=>{n(),r()}})}function es(e){return J(I(),"onerror",({parameters:[t,n,r,o,s]})=>{let i;X(s)||(i=$o(t,n,r,o)),e(s!=null?s:t,i)})}function ts(e){return J(I(),"onunhandledrejection",({parameters:[t]})=>{e(t.reason||"Empty reason")})}function ns(e){const t={version:"6.22.0",onReady(n){n()},...e};return Object.defineProperty(t,"_setDebug",{get(){return gr},enumerable:!1}),t}function rs(e,t,n){const r=e[t];r&&!r.q&&r.version&&y.warn("SDK is loaded more than once. This is unsupported and might have unexpected behavior."),e[t]=n,r&&r.q&&r.q.forEach(o=>Dt(o,"onReady callback threw an error:")())}function _n(e,t){t.silentMultipleInit||y.error(`${e} is already initialized.`)}function Z(e,t,n,r,o){return St(e,t,[n],r,o)}function St(e,t,n,r,{once:o,capture:s,passive:i}={}){const c=b(f=>{!f.isTrusted&&!f.__ddIsTrusted&&!e.allowUntrustedEvents||(o&&l(),r(f))}),a=i?{capture:s,passive:i}:s,u=window.EventTarget&&t instanceof EventTarget?window.EventTarget.prototype:t,d=ce(u,"addEventListener");n.forEach(f=>d.call(t,f,c,a));function l(){const f=ce(u,"removeEventListener");n.forEach(h=>f.call(t,h,c,a))}return{stop:l}}const Be={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function os(e,t){const n=[];t.includes(Be.cspViolation)&&n.push(is(e));const r=t.filter(o=>o!==Be.cspViolation);return r.length&&n.push(ss(r)),qt(...n)}function ss(e){return new S(t=>{if(!window.ReportingObserver)return;const n=b((o,s)=>o.forEach(i=>t.notify(cs(i)))),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),()=>{r.disconnect()}})}function is(e){return new S(t=>{const{stop:n}=Z(e,document,"securitypolicyviolation",r=>{t.notify(as(r))});return n})}function cs(e){const{type:t,body:n}=e;return Tn({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:On(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)})}function as(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return Tn({type:e.effectiveDirective,message:`${Be.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:On(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${_r(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber)})}function Tn(e){return{startClocks:k(),source:w.REPORT,handling:"unhandled",...e}}function On(e,t,n,r,o){return n?me({name:e,message:t,stack:[{func:"?",url:n,line:r!=null?r:void 0,column:o!=null?o:void 0}]}):void 0}const us=200;function Cn(e){const{env:t,service:n,version:r,datacenter:o,sdkVersion:s,variant:i}=e,c=[Q("sdk_version",s!=null?s:"6.22.0")];return t&&c.push(Q("env",t)),n&&c.push(Q("service",n)),r&&c.push(Q("version",r)),o&&c.push(Q("datacenter",o)),i&&c.push(Q("variant",i)),c}function Q(e,t){const n=t?`${e}:${t}`:e;return(n.length>us||ls(n))&&y.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${Qe} ${Ze}/getting_started/tagging/#defining-tags`),vn(n)}function vn(e){return e.replace(/,/g,"_")}function ls(e){return ds()?new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e):!1}function ds(){try{return new RegExp("[\\p{Ll}]","u"),!0}catch(e){return!1}}function An(e,t){const n=L.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function Ge(e,t,n=fs()){if(t===void 0)return e;if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,o)}if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const o=Array.isArray(e)?e:[];for(let s=0;s<t.length;++s)o[s]=Ge(o[s],t[s],n);return o}const r=pn(e)==="object"?e:{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=Ge(r[o],t[o],n));return r}function wn(e){return Ge(void 0,e)}function ee(...e){let t;for(const n of e)n!=null&&(t=Ge(t,n));return t}function fs(){if(typeof WeakSet!="undefined"){const t=new WeakSet;return{hasAlreadyBeenSeen(n){const r=t.has(n);return r||t.add(n),r}}}const e=[];return{hasAlreadyBeenSeen(t){const n=e.indexOf(t)>=0;return n||e.push(t),n}}}function ms(){var e;const t=L.navigator;return{status:t.onLine?"connected":"not_connected",interfaces:t.connection&&t.connection.type?[t.connection.type]:void 0,effective_type:(e=t.connection)===null||e===void 0?void 0:e.effectiveType}}function Rn(e){return e>=500}function hs(e){try{return e.clone()}catch(t){return}}const ps=80*ie,gs=32,In=20*Bt,Es=D,Ln=se;function Nn(e,t,n,r,o,s){t.transportStatus===0&&t.queuedPayloads.size()===0&&t.bandwidthMonitor.canHandle(e)?xn(e,t,n,s,{onSuccess:()=>Un(0,t,n,r,o,s),onFailure:()=>{t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e}),kn(t,n,r,o,s)}}):t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e})}function kn(e,t,n,r,o){e.transportStatus===2&&Se(()=>{const s=e.queuedPayloads.first();xn(s,e,t,o,{onSuccess:()=>{e.queuedPayloads.dequeue(),e.currentBackoffTime=Ln,Un(1,e,t,n,r,o)},onFailure:()=>{e.currentBackoffTime=Math.min(Es,e.currentBackoffTime*2),kn(e,t,n,r,o)}})},e.currentBackoffTime)}function xn(e,t,n,r,{onSuccess:o,onFailure:s}){t.bandwidthMonitor.add(e),n(e,i=>{t.bandwidthMonitor.remove(e),ys(i)?(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:i.status},r.notify({type:"failure",bandwidth:t.bandwidthMonitor.stats(),payload:e}),s()):(t.transportStatus=0,r.notify({type:"success",bandwidth:t.bandwidthMonitor.stats(),payload:e}),o())})}function Un(e,t,n,r,o,s){e===0&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:`Reached max ${r} events size queued for upload: ${In/Bt}MiB`,source:w.AGENT,startClocks:k()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=Pn();i.size()>0;)Nn(i.dequeue(),t,n,r,o,s)}function ys(e){return e.type!=="opaque"&&(e.status===0&&!navigator.onLine||e.status===408||e.status===429||Rn(e.status))}function bs(){return{transportStatus:0,currentBackoffTime:Ln,bandwidthMonitor:Ss(),queuedPayloads:Pn(),queueFullReported:!1}}function Pn(){const e=[];return{bytesCount:0,enqueue(t){return this.isFull()?!1:(e.push(t),this.bytesCount+=t.bytesCount,!0)},first(){return e[0]},dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size(){return e.length},isFull(){return this.bytesCount>=In}}}function Ss(){return{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return this.ongoingRequestCount===0||this.ongoingByteCount+e.bytesCount<=ps&&this.ongoingRequestCount<gs},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount},stats(){return{ongoingByteCount:this.ongoingByteCount,ongoingRequestCount:this.ongoingRequestCount}}}}function Mn(e,t,n){const r=new S,o=bs();return{observable:r,send:s=>{for(const i of e)Nn(s,o,(c,a)=>Os(i,t,c,a),i.trackType,n,r)},sendOnExit:s=>{for(const i of e)_s(i,t,s)}}}function _s(e,t,n){if(!!navigator.sendBeacon&&n.bytesCount<t)try{const o=e.build("beacon",n);if(navigator.sendBeacon(o,n.data))return}catch(o){Ts(o)}_t(e,n)}let Dn=!1;function Ts(e){Dn||(Dn=!0,tt(e))}function Os(e,t,n,r){if(Cs()&&n.bytesCount<t){const s=e.build("fetch-keepalive",n);fetch(s,{method:"POST",body:n.data,keepalive:!0,mode:"cors"}).then(b(i=>r==null?void 0:r({status:i.status,type:i.type}))).catch(b(()=>_t(e,n,r)))}else _t(e,n,r)}function _t(e,t,n){const r=e.build("fetch",t);fetch(r,{method:"POST",body:t.data,mode:"cors"}).then(b(o=>n==null?void 0:n({status:o.status,type:o.type}))).catch(b(()=>n==null?void 0:n({status:0})))}function Cs(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}function Tt(){const e=vs();if(e)return{getCapabilities(){var t;return JSON.parse(((t=e.getCapabilities)===null||t===void 0?void 0:t.call(e))||"[]")},getPrivacyLevel(){var t;return(t=e.getPrivacyLevel)===null||t===void 0?void 0:t.call(e)},getAllowedWebViewHosts(){return JSON.parse(e.getAllowedWebViewHosts())},send(t,n,r){const o=r?{id:r}:void 0;e.send(JSON.stringify({eventType:t,event:n,view:o}))}}}function Ke(e){var t;e===void 0&&(e=(t=I().location)===null||t===void 0?void 0:t.hostname);const n=Tt();return!!n&&n.getAllowedWebViewHosts().some(r=>e===r||e.endsWith(`.${r}`))}function vs(){return I().DatadogEventBridge}const je={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function As(e){return new S(t=>{const{stop:n}=St(e,window,["visibilitychange","freeze"],o=>{o.type==="visibilitychange"&&document.visibilityState==="hidden"?t.notify({reason:je.HIDDEN}):o.type==="freeze"&&t.notify({reason:je.FROZEN})},{capture:!0}),r=Z(e,window,"beforeunload",()=>{t.notify({reason:je.UNLOADING})}).stop;return()=>{n(),r()}})}function ws(e){return xe(je).includes(e)}function $n({encoder:e,request:t,flushController:n,messageBytesLimit:r}){let o={};const s=n.flushObservable.subscribe(l=>d(l));function i(l,f,h){n.notifyBeforeAddMessage(f),h!==void 0?(o[h]=l,n.notifyAfterAddMessage()):e.write(e.isEmpty?l:`
|
|
10
|
-
${l}`,g=>{n.notifyAfterAddMessage(g-f)})}function c(l){return l!==void 0&&o[l]!==void 0}function a(l){const f=o[l];delete o[l];const
|
|
11
|
-
`);o={};const
|
|
6
|
+
Please fix these validation errors and try again.`),this.name=h.ErrorEnum.CHECKOUT_OPTIONS_VALIDATION_ERROR}}h.MessageTypeEnum=void 0,function(e){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"}(h.MessageTypeEnum||(h.MessageTypeEnum={}));class K{constructor(){this.environmentVariables={stargateUrl:{sandbox:"https://sandbox-stargate.montonio.com",production:"https://stargate.montonio.com","prelive-sandbox":"https://sandbox-stargate.prelive.montonio.com","prelive-production":"https://stargate.prelive.montonio.com",development:"https://api-stargate.montonio.dev"},datadogClientToken:"pubb5b1ffe19aeb16a90d1181fd3e866b83"}}static get instance(){return K._instance||(K._instance=new K),K._instance}getConfig(t,n){const r=this.environmentVariables[t];if(typeof r=="string")return r;if(!n)throw new Error(`Environment parameter required for config key: ${t}`);return r[n]}}class se{constructor(){this.timeout=3e4}static get instance(){return se._instance||(se._instance=new se),se._instance}async get(t){return this.request(t,"GET")}async post(t,n){return this.request(t,"POST",n)}async patch(t,n){return this.request(t,"PATCH",n)}async request(t,n,r){const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout);try{const i={Accept:"application/json","X-Montonio-Js-Version":"1.1.7"};r&&(i["Content-Type"]="application/json");const c={method:n,headers:i,credentials:"include",mode:"cors",signal:o.signal};r&&(c.body=JSON.stringify(r));const a=await fetch(t,c);if(!a.ok)throw new Error(`HTTP error ${a.status}: ${a.statusText}`);return await a.json()}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request timeout after ${this.timeout}ms`):i}finally{clearTimeout(s)}}}const T={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},x=console,j={};Object.keys(T).forEach(e=>{j[e]=x[e]});const be="Datadog Browser SDK:",y={debug:j.debug.bind(x,be),log:j.log.bind(x,be),info:j.info.bind(x,be),warn:j.warn.bind(x,be),error:j.error.bind(x,be)},Ze="https://docs.datadoghq.com",cr=`${Ze}/real_user_monitoring/browser/troubleshooting`,Qe="More details:";function Mt(e,t){return(...n)=>{try{return e(...n)}catch(r){y.error(t,r)}}}function Se(e){return e!==0&&Math.random()*100<=e}function ar(e){return ur(e)&&e>=0&&e<=100}function ur(e){return typeof e=="number"}const ie=1e3,M=60*ie,$t=60*M,lr=365*(24*$t);function $(){return new Date().getTime()}function U(){return $()}function Re(){return performance.now()}function k(){return{relative:Re(),timeStamp:U()}}function dr(){return{relative:0,timeStamp:Ht()}}function Ft(e,t){return t-e}function fr(e,t){return e+t}function hr(e){return e-Ht()}let et;function Ht(){var e,t;return et===void 0&&(et=(t=(e=performance.timing)===null||e===void 0?void 0:e.navigationStart)!==null&&t!==void 0?t:performance.timeOrigin),et}const ce=1024,Bt=1024*ce,mr=/[^\u0000-\u007F]/;function Gt(e){return mr.test(e)?window.TextEncoder!==void 0?new TextEncoder().encode(e).length:new Blob([e]).size:e.length}function pr(e){return{...e}}function Kt(e,t){return Object.keys(e).some(n=>e[n]===t)}function Ie(e){return Object.keys(e).length===0}function I(){if(typeof globalThis=="object")return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,typeof e!="object"&&(typeof self=="object"?e=self:typeof window=="object"?e=window:e={}),e}const L=I(),Y="WorkerGlobalScope"in L;function ae(e,t){const n=I();let r;return n.Zone&&typeof n.Zone.__symbol__=="function"&&(r=e[n.Zone.__symbol__(t)]),r||(r=e[t]),r}let Le,jt=!1;function gr(e){Le=e}function Er(e){jt=e}function yr(e,t,n){const r=n.value;n.value=function(...o){return(Le?b(r):r).apply(this,o)}}function b(e){return function(){return ue(e,this,arguments)}}function ue(e,t,n){try{return e.apply(t,n)}catch(r){tt(r)}}function tt(e){if(nt(e),Le)try{Le(e)}catch(t){nt(t)}}function nt(...e){jt&&y.error("[MONITOR]",...e)}function _e(e,t){return ae(I(),"setTimeout")(b(e),t)}function Yt(e){ae(I(),"clearTimeout")(e)}function rt(e,t){return ae(I(),"setInterval")(b(e),t)}function Vt(e){ae(I(),"clearInterval")(e)}function zt(e){var t;const n=(t=L.queueMicrotask)===null||t===void 0?void 0:t.bind(L);typeof n=="function"?n(b(e)):Promise.resolve().then(b(e))}class S{constructor(t){this.onFirstSubscribe=t,this.observers=[]}subscribe(t){return this.addObserver(t),{unsubscribe:()=>this.removeObserver(t)}}notify(t){this.observers.forEach(n=>n(t))}addObserver(t){this.observers.push(t),this.observers.length===1&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(t){this.observers=this.observers.filter(n=>t!==n),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function qt(...e){return new S(t=>{const n=e.map(r=>r.subscribe(o=>t.notify(o)));return()=>n.forEach(r=>r.unsubscribe())})}class Wt extends S{constructor(t){super(),this.maxBufferSize=t,this.buffer=[]}notify(t){this.buffer.push(t),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(t)}subscribe(t){let n=!1;const r={unsubscribe:()=>{n=!0,this.removeObserver(t)}};return zt(()=>{for(const o of this.buffer){if(n)return;t(o)}n||this.addObserver(t)}),r}unbuffer(){zt(()=>{this.maxBufferSize=this.buffer.length=0})}}function br(e,t,n){let r=!1,o,s;return{throttled:(...i)=>{if(r){o=i;return}e(...i),r=!0,s=_e(()=>{o&&e(...o),r=!1,o=void 0},t)},cancel:()=>{Yt(s),r=!1,o=void 0}}}function F(){}function H(e){return e?(parseInt(e,10)^Math.random()*16>>parseInt(e,10)/4).toString(16):`10000000-1000-4000-8000-${1e11}`.replace(/[018]/g,H)}const xe=/([\w-]+)\s*=\s*([^;]+)/g;function Sr(e,t){for(xe.lastIndex=0;;){const n=xe.exec(e);if(n){if(n[1]===t)return n[2]}else break}}function _r(e){const t=new Map;for(xe.lastIndex=0;;){const n=xe.exec(e);if(n)t.set(n[1],n[2]);else break}return t}function Tr(e,t,n=""){const r=e.charCodeAt(t-1),s=r>=55296&&r<=56319?t+1:t;return e.length<=s?e:`${e.slice(0,s)}${n}`}function Cr(){return vr()===0}let ke;function vr(){return ke!=null?ke:ke=Or()}function Or(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:((t=e.navigator.vendor)===null||t===void 0?void 0:t.indexOf("Apple"))===0||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}function ot(e){return Xt(e,location.href).href}function Xt(e,t){const{URL:n}=wr();try{return t!==void 0?new n(e,t):new n(e)}catch(r){throw new Error(`Failed to construct URL: ${String(r)}`)}}let st;function wr(){if(!st){let e,t;try{e=document.createElement("iframe"),e.style.display="none",document.body.appendChild(e),t=e.contentWindow}catch(n){t=L}st={URL:t.URL},e==null||e.remove()}return st}function Ne(e,t,n=0,r){const o=new Date;o.setTime(o.getTime()+n);const s=`expires=${o.toUTCString()}`,i=r&&r.crossSite?"none":"strict",c=r&&r.domain?`;domain=${r.domain}`:"",a=r&&r.secure?";secure":"",u=r&&r.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${c}${a}${u}`}function it(e){return Sr(document.cookie,e)}let ct;function V(e){return ct||(ct=_r(document.cookie)),ct.get(e)}function Jt(e,t){Ne(e,"",0,t)}function Ar(e){if(document.cookie===void 0||document.cookie===null)return!1;try{const t=`dd_cookie_test_${H()}`,n="test";Ne(t,n,M,e);const r=it(t)===n;return Jt(t,e),r}catch(t){return y.error(t),!1}}let at;function Zt(e=location.hostname,t=document.referrer){if(at===void 0){const n=Rr(e,t);if(n){const r=`dd_site_test_${H()}`,o="test",s=n.split(".");let i=s.pop();for(;s.length&&!it(r);)i=`${s.pop()}.${i}`,Ne(r,o,ie,{domain:i});Jt(r,{domain:i}),at=i}}return at}function Rr(e,t){try{return e||Xt(t).hostname}catch(n){}}const B="_dd_s";function Ir(e,t){for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(t(r,n,e))return r}}function Ue(e){return Object.values(e)}function Lr(e){return Object.entries(e)}const ut=4*$t,Qt=15*M,xr=lr,en="0",Te={COOKIE:"cookie",LOCAL_STORAGE:"local-storage"},tn=/^([a-zA-Z]+)=([a-z0-9-]+)$/,lt="&";function kr(e){return!!e&&(e.indexOf(lt)!==-1||tn.test(e))}const Nr="1";function z(e,t){const n={isExpired:Nr};return t.trackAnonymousUser&&(e!=null&&e.anonymousId?n.anonymousId=e==null?void 0:e.anonymousId:n.anonymousId=H()),n}function Pe(e){return Ie(e)}function nn(e){return!Pe(e)}function Ce(e){return e.isExpired!==void 0||!Ur(e)}function Ur(e){return(e.created===void 0||$()-Number(e.created)<ut)&&(e.expire===void 0||$()<Number(e.expire))}function rn(e){e.expire=String($()+Qt)}function on(e){return Lr(e).map(([t,n])=>t==="anonymousId"?`aid=${n}`:`${t}=${n}`).join(lt)}function dt(e){const t={};return kr(e)&&e.split(lt).forEach(n=>{const r=tn.exec(n);if(r!==null){const[,o,s]=r;o==="aid"?t.anonymousId=s:t[o]=s}}),t}const Pr="_dd",Dr="_dd_r",Mr="_dd_l",$r="rum",Fr="logs";function Hr(e){if(!V(B)){const n=V(Pr),r=V(Dr),o=V(Mr),s={};n&&(s.id=n),o&&/^[01]$/.test(o)&&(s[Fr]=o),r&&/^[012]$/.test(r)&&(s[$r]=r),nn(s)&&(rn(s),e.persistSession(s))}}function sn(e){const t=Gr(e);return t&&Ar(t)?{type:Te.COOKIE,cookieOptions:t}:void 0}function Br(e,t){const n={isLockEnabled:Cr(),persistSession:r=>cn(t,e,r,Qt),retrieveSession:an,expireSession:r=>cn(t,e,z(r,e),ut)};return Hr(n),n}function cn(e,t,n,r){Ne(B,on(n),t.trackAnonymousUser?xr:r,e)}function an(){const e=it(B);return dt(e)}function Gr(e){const t={};if(t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains){const n=Zt();if(!n)return;t.domain=n}return t}const Kr="_dd_test_";function un(){try{const e=H(),t=`${Kr}${e}`;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:Te.LOCAL_STORAGE}:void 0}catch(e){return}}function jr(e){return{isLockEnabled:!1,persistSession:ln,retrieveSession:Yr,expireSession:t=>Vr(t,e)}}function ln(e){localStorage.setItem(B,on(e))}function Yr(){const e=localStorage.getItem(B);return dt(e)}function Vr(e,t){ln(z(e,t))}const zr=10,qr=100,Wr=ie,dn="--",fn=[];let De;function q(e,t,n=0){var r;const{isLockEnabled:o,persistSession:s,expireSession:i}=t,c=f=>s({...f,lock:u}),a=()=>{const{lock:f,...m}=t.retrieveSession();return{session:m,lock:f&&!Jr(f)?f:void 0}};if(De||(De=e),e!==De){fn.push(e);return}if(o&&n>=qr){hn(t);return}let u,d=a();if(o){if(d.lock){Me(e,t,n);return}if(u=Xr(),c(d.session),d=a(),d.lock!==u){Me(e,t,n);return}}let l=e.process(d.session);if(o&&(d=a(),d.lock!==u)){Me(e,t,n);return}if(l&&(Ce(l)?i(l):(rn(l),o?c(l):s(l))),o&&!(l&&Ce(l))){if(d=a(),d.lock!==u){Me(e,t,n);return}s(d.session),l=d.session}(r=e.after)===null||r===void 0||r.call(e,l||d.session),hn(t)}function Me(e,t,n){_e(()=>{q(e,t,n+1)},zr)}function hn(e){De=void 0;const t=fn.shift();t&&q(t,e)}function Xr(){return H()+dn+U()}function Jr(e){const[,t]=e.split(dn);return!t||Ft(Number(t),U())>Wr}const mn=ie;function Zr(e){switch(e.sessionPersistence){case Te.COOKIE:return sn(e);case Te.LOCAL_STORAGE:return un();case void 0:{let t=sn(e);return!t&&e.allowFallbackToLocalStorage&&(t=un()),t}default:y.error(`Invalid session persistence '${String(e.sessionPersistence)}'`)}}function Qr(e,t){return e.type===Te.COOKIE?Br(t,e.cookieOptions):jr(t)}function eo(e,t,n,r,o=Qr(e,t)){const s=new S,i=new S,c=new S,a=rt(m,mn);let u;C();const{throttled:d,cancel:l}=br(()=>{q({process:E=>{if(Pe(E))return;const N=g(E);return _(N),N},after:E=>{nn(E)&&!G()&&wc(E),u=E}},o)},mn);function f(){q({process:E=>G()?g(E):void 0},o)}function m(){const E=o.retrieveSession();Ce(E)?q({process:N=>Ce(N)?z(N,t):void 0,after:g},o):g(E)}function g(E){return Ce(E)&&(E=z(E,t)),G()&&(ye(E)?Oc():(c.notify({previousState:u,newState:E}),u=E)),E}function C(){q({process:E=>{if(Pe(E))return z(E,t)},after:E=>{u=E}},o)}function _(E){if(Pe(E))return!1;const N=r(E[n]);E[n]=N,delete E.isExpired,N!==en&&!E.id&&(E.id=H(),E.created=String($()))}function G(){return(u==null?void 0:u[n])!==void 0}function ye(E){return u.id!==E.id||u[n]!==E[n]}function Oc(){u=z(u,t),i.notify()}function wc(E){u=E,s.notify()}function Ac(E){q({process:N=>({...N,...E}),after:g},o)}return{expandOrRenewSession:d,expandSession:f,getSession:()=>u,renewObservable:s,expireObservable:i,sessionStateUpdateObservable:c,restartSession:C,expire:()=>{l(),o.expireSession(u),g(z(u,t))},stop:()=>{Vt(a)},updateSessionState:Ac}}const ft={GRANTED:"granted",NOT_GRANTED:"not-granted"};function to(e){const t=new S;return{tryToInit(n){e||(e=n)},update(n){e=n,t.notify()},isGranted(){return e===ft.GRANTED},observable:t}}function pn(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function no(e,t,n=!1){return e.some(r=>{try{if(typeof r=="function")return r(t);if(r instanceof RegExp)return r.test(t);if(typeof r=="string")return n?t.startsWith(r):r===t}catch(o){y.error(o)}return!1})}const ro=["chrome-extension://","moz-extension://"];function gn(e){return ro.some(t=>e.includes(t))}function oo(e,t=""){if(gn(e))return!1;const r=t.split(`
|
|
7
|
+
`).filter(o=>{const s=o.trim();return s.length&&/^at\s+|@/.test(s)})[1]||"";return gn(r)}const so="Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided.",io="SDK initialized on a non-allowed domain.";function co(e,t,n=typeof location!="undefined"?location.origin:""){const r=e.allowedTrackingOrigins;if(!r)return oo(n,t)?(y.error(so),!1):!0;const o=no(r,n);return o||y.error(io),o}const ao="datad0g.com",uo="dd0g-gov.com",le="datadoghq.com",lo="ddog-gov.com",fo="pci.browser-intake-datadoghq.com",ho=["ddsource","dd-api-key","dd-request-id"];function W(e,t,n){const r=mo(e,t);return{build(o,s){const i=go(e,t,o,s,n);return r(i)},trackType:t}}function mo(e,t){const n=`/api/v2/${t}`,r=e.proxy;if(typeof r=="string"){const s=ot(r);return i=>`${s}?ddforward=${encodeURIComponent(`${n}?${i}`)}`}if(typeof r=="function")return s=>r({path:n,parameters:s});const o=po(t,e);return s=>`https://${o}${n}?${s}`}function po(e,t){const{site:n=le,internalAnalyticsSubdomain:r}=t;if(e==="logs"&&t.usePciIntake&&n===le)return fo;if(r&&n===le)return`${r}.${le}`;if(n===uo)return`http-intake.logs.${n}`;const o=n.split("."),s=o.pop();return`browser-intake-${o.join("-")}.${s}`}function go({clientToken:e,internalAnalyticsSubdomain:t,source:n="browser"},r,o,{retry:s,encoding:i},c=[]){const a=[`ddsource=${n}`,`dd-api-key=${e}`,`dd-evp-origin-version=${encodeURIComponent("6.22.0")}`,"dd-evp-origin=browser",`dd-request-id=${H()}`].concat(c);return i&&a.push(`dd-evp-encoding=${i}`),r==="rum"&&(a.push(`batch_time=${U()}`,`_dd.api=${o}`),s&&a.push(`_dd.retry_count=${s.count}`,`_dd.retry_after=${s.lastFailureStatus}`)),t&&a.reverse(),a.join("&")}function Eo(e){const t=e.site||le,n=yo(e.source),r=bo({...e,site:t,source:n});return{replica:So({...e,site:t,source:n}),site:t,source:n,...r}}function yo(e){return e==="flutter"||e==="unity"?e:"browser"}function bo(e){return{logsEndpointBuilder:W(e,"logs"),rumEndpointBuilder:W(e,"rum"),profilingEndpointBuilder:W(e,"profile"),sessionReplayEndpointBuilder:W(e,"replay"),exposuresEndpointBuilder:W(e,"exposures")}}function So(e){if(!e.replica)return;const t={...e,site:le,clientToken:e.replica.clientToken};return{logsEndpointBuilder:W(t,"logs"),rumEndpointBuilder:W(t,"rum",[`application.id=${e.replica.applicationId}`])}}function _o(e){return ho.every(t=>e.includes(t))}function ht(e,t){return e!=null&&typeof e!="string"?(y.error(`${t} must be defined as a string`),!1):!0}function To(e){return e&&typeof e=="string"&&!/(datadog|ddog|datad0g|dd0g)/.test(e)?(y.error(`Site should be a valid Datadog site. ${Qe} ${Ze}/getting_started/site/.`),!1):!0}function $e(e,t){return e!==void 0&&!ar(e)?(y.error(`${t} Sample Rate should be a number between 0 and 100`),!1):!0}function Co(e,t){var n,r,o,s,i,c,a,u,d,l;if(!e||!e.clientToken){y.error("Client Token is not configured, we will not send any data.");return}if(e.allowedTrackingOrigins!==void 0&&!Array.isArray(e.allowedTrackingOrigins)){y.error("Allowed Tracking Origins must be an array");return}if(!(!To(e.site)||!$e(e.sessionSampleRate,"Session")||!$e(e.telemetrySampleRate,"Telemetry")||!$e(e.telemetryConfigurationSampleRate,"Telemetry Configuration")||!$e(e.telemetryUsageSampleRate,"Telemetry Usage")||!ht(e.version,"Version")||!ht(e.env,"Env")||!ht(e.service,"Service")||!co(e,t!=null?t:""))){if(e.trackingConsent!==void 0&&!Kt(ft,e.trackingConsent)){y.error('Tracking Consent should be either "granted" or "not-granted"');return}return{beforeSend:e.beforeSend&&Mt(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:Y?void 0:Zr(e),sessionSampleRate:(n=e.sessionSampleRate)!==null&&n!==void 0?n:100,telemetrySampleRate:(r=e.telemetrySampleRate)!==null&&r!==void 0?r:20,telemetryConfigurationSampleRate:(o=e.telemetryConfigurationSampleRate)!==null&&o!==void 0?o:5,telemetryUsageSampleRate:(s=e.telemetryUsageSampleRate)!==null&&s!==void 0?s:5,service:(i=e.service)!==null&&i!==void 0?i:void 0,env:(c=e.env)!==null&&c!==void 0?c:void 0,version:(a=e.version)!==null&&a!==void 0?a:void 0,datacenter:(u=e.datacenter)!==null&&u!==void 0?u:void 0,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,trackingConsent:(d=e.trackingConsent)!==null&&d!==void 0?d:ft.GRANTED,trackAnonymousUser:(l=e.trackAnonymousUser)!==null&&l!==void 0?l:!0,storeContextsAcrossPages:!!e.storeContextsAcrossPages,batchBytesLimit:16*ce,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:30*ie,batchMessagesLimit:Y?1:50,messageBytesLimit:256*ce,variant:e.variant,sdkVersion:e.sdkVersion,...Eo(e)}}}function vo(e){return{session_sample_rate:e.sessionSampleRate,telemetry_sample_rate:e.telemetrySampleRate,telemetry_configuration_sample_rate:e.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:e.telemetryUsageSampleRate,use_before_send:!!e.beforeSend,use_partitioned_cross_site_session_cookie:e.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:e.useSecureSessionCookie,use_proxy:!!e.proxy,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_anonymous_user:e.trackAnonymousUser,session_persistence:e.sessionPersistence,allow_fallback_to_local_storage:!!e.allowFallbackToLocalStorage,store_contexts_across_pages:!!e.storeContextsAcrossPages,allow_untrusted_events:!!e.allowUntrustedEvents,tracking_consent:e.trackingConsent,use_allowed_tracking_origins:Array.isArray(e.allowedTrackingOrigins),source:e.source,sdk_version:e.sdkVersion,variant:e.variant}}var Fe;(function(e){e.TRACK_INTAKE_REQUESTS="track_intake_requests",e.USE_TREE_WALKER_FOR_ACTION_NAME="use_tree_walker_for_action_name",e.FEATURE_OPERATION_VITAL="feature_operation_vital",e.SHORT_SESSION_INVESTIGATION="short_session_investigation"})(Fe||(Fe={}));const mt=new Set;function Oo(e){Array.isArray(e)&&wo(e.filter(t=>Kt(Fe,t)))}function wo(e){e.forEach(t=>{mt.add(t)})}function Ao(e){return mt.has(e)}function Ro(){return mt}const de="?";function fe(e){var t,n;const r=[];let o=pt(e,"stack");const s=String(e);if(o&&o.startsWith(s)&&(o=o.slice(s.length)),o&&o.split(`
|
|
8
|
+
`).forEach(i=>{const c=xo(i)||No(i)||Po(i)||$o(i);c&&(!c.func&&c.line&&(c.func=de),r.push(c))}),r.length>0&&Go()&&e instanceof Error){const i=[];let c=e;for(;(c=Object.getPrototypeOf(c))&&yn(c);){const a=((t=c.constructor)===null||t===void 0?void 0:t.name)||de;i.push(a)}for(let a=i.length-1;a>=0&&((n=r[0])===null||n===void 0?void 0:n.func)===i[a];a--)r.shift()}return{message:pt(e,"message"),name:pt(e,"name"),stack:r}}const En="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",he="(?::(\\d+))",Io=new RegExp(`^\\s*at (.*?) ?\\(${En}${he}?${he}?\\)?\\s*$`,"i"),Lo=new RegExp(`\\((\\S*)${he}${he}\\)`);function xo(e){const t=Io.exec(e);if(!t)return;const n=t[2]&&t[2].indexOf("native")===0,r=t[2]&&t[2].indexOf("eval")===0,o=Lo.exec(t[2]);return r&&o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]),{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||de,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}const ko=new RegExp(`^\\s*at ?${En}${he}?${he}??\\s*$`,"i");function No(e){const t=ko.exec(e);if(t)return{args:[],column:t[3]?+t[3]:void 0,func:de,line:t[2]?+t[2]:void 0,url:t[1]}}const Uo=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;function Po(e){const t=Uo.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||de,line:+t[3],url:t[2]}}const Do=/^\s*(.*?)(?:\((.*?)\))?(?:(?:(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?)|@)\s*$/i,Mo=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function $o(e){const t=Do.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,r=Mo.exec(t[3]);return n&&r&&(t[3]=r[1],t[4]=r[2],t[5]=void 0),{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||de,line:t[4]?+t[4]:void 0,url:t[3]}}function pt(e,t){if(typeof e!="object"||!e||!(t in e))return;const n=e[t];return typeof n=="string"?n:void 0}function Fo(e,t,n,r){if(t===void 0)return;const{name:o,message:s}=Bo(e);return{name:o,message:s,stack:[{url:t,column:r,line:n}]}}const Ho=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function Bo(e){let t,n;return{}.toString.call(e)==="[object String]"&&([,t,n]=Ho.exec(e)),{name:t,message:n}}function yn(e){return String(e.constructor).startsWith("class ")}let He;function Go(){if(He!==void 0)return He;class e extends Error{constructor(){super(),this.name="Error"}}const[t,n]=[e,Error].map(r=>new r);return He=yn(Object.getPrototypeOf(t))&&n.stack!==t.stack,He}function Be(e){const n=new Error(e);n.name="HandlingStack";let r;return ue(()=>{const o=fe(n);o.stack=o.stack.slice(2),r=me(o)}),r}function me(e){let t=bn(e);return e.stack.forEach(n=>{const r=n.func==="?"?"<anonymous>":n.func,o=n.args&&n.args.length>0?`(${n.args.join(", ")})`:"",s=n.line?`:${n.line}`:"",i=n.line&&n.column?`:${n.column}`:"";t+=`
|
|
9
|
+
at ${r}${o} @ ${n.url}${s}${i}`}),t}function bn(e){return`${e.name||"Error"}: ${e.message}`}function X(e,t,n,{computeHandlingStack:r}={}){let o=e[t];if(typeof o!="function")if(t in e&&t.startsWith("on"))o=F;else return{stop:F};let s=!1;const i=function(){if(s)return o.apply(this,arguments);const c=Array.from(arguments);let a;ue(n,null,[{target:this,parameters:c,onPostCall:d=>{a=d},handlingStack:r?Be("instrumented method"):void 0}]);const u=o.apply(this,c);return a&&ue(a,null,[u]),u};return e[t]=i,{stop:()=>{s=!0,e[t]===i&&(e[t]=o)}}}function ve(e,t,n){if(typeof e!="object"||e===null)return JSON.stringify(e);const r=pe(Object.prototype),o=pe(Array.prototype),s=pe(Object.getPrototypeOf(e)),i=pe(e);try{return JSON.stringify(e,t,n)}catch(c){return"<error: unable to serialize object>"}finally{r(),o(),s(),i()}}function pe(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):F}const Ko=220*ce,jo="$",Yo=3;function P(e,t=Ko){const n=pe(Object.prototype),r=pe(Array.prototype),o=[],s=new WeakMap,i=gt(e,jo,void 0,o,s),c=JSON.stringify(i);let a=c?c.length:0;if(a>t){yt(t,"discarded",e);return}for(;o.length>0&&a<t;){const u=o.shift();let d=0;if(Array.isArray(u.source))for(let l=0;l<u.source.length;l++){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0?a+=JSON.stringify(f).length:a+=4,a+=d,d=1,a>t){yt(t,"truncated",e);break}u.target[l]=f}else for(const l in u.source)if(Object.prototype.hasOwnProperty.call(u.source,l)){const f=gt(u.source[l],u.path,l,o,s);if(f!==void 0&&(a+=JSON.stringify(f).length+d+l.length+Yo,d=1),a>t){yt(t,"truncated",e);break}u.target[l]=f}}return n(),r(),i}function gt(e,t,n,r,o){const s=qo(e);if(!s||typeof s!="object")return Vo(s);const i=Et(s);if(i!=="[Object]"&&i!=="[Array]"&&i!=="[Error]")return i;const c=e;if(o.has(c))return`[Reference seen at ${o.get(c)}]`;const a=n!==void 0?`${t}.${n}`:t,u=Array.isArray(s)?[]:{};return o.set(c,a),r.push({source:s,target:u,path:a}),u}function Vo(e){return typeof e=="bigint"?`[BigInt] ${e.toString()}`:typeof e=="function"?`[Function] ${e.name||"unknown"}`:typeof e=="symbol"?`[Symbol] ${e.description||e.toString()}`:e}function Et(e){try{if(e instanceof Event)return zo(e);if(e instanceof RegExp)return`[RegExp] ${e.toString()}`;const n=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(n&&n[1])return`[${n[1]}]`}catch(t){}return"[Unserializable]"}function zo(e){return{type:e.type,isTrusted:e.isTrusted,currentTarget:e.currentTarget?Et(e.currentTarget):null,target:e.target?Et(e.target):null}}function qo(e){const t=e;if(t&&typeof t.toJSON=="function")try{return t.toJSON()}catch(n){}return e}function yt(e,t,n){y.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const Sn="No stack, consider using an instance of Error";function bt({stackTrace:e,originalError:t,handlingStack:n,componentStack:r,startClocks:o,nonErrorPrefix:s,useFallbackStack:i=!0,source:c,handling:a}){const u=J(t);return!e&&u&&(e=fe(t)),{startClocks:o,source:c,handling:a,handlingStack:n,componentStack:r,originalError:t,type:e?e.name:void 0,message:Wo(e,u,s,t),stack:e?me(e):i?Sn:void 0,causes:u?Qo(t,c):void 0,fingerprint:Xo(t),context:Jo(t)}}function Wo(e,t,n,r){return e!=null&&e.message&&(e!=null&&e.name)?e.message:t?"Empty message":`${n} ${ve(P(r))}`}function Xo(e){return J(e)&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function Jo(e){if(e!==null&&typeof e=="object"&&"dd_context"in e)return e.dd_context}function Zo(e){var t;return(t=/@ (.+)/.exec(e))===null||t===void 0?void 0:t[1]}function J(e){return e instanceof Error||Object.prototype.toString.call(e)==="[object Error]"}function Qo(e,t){let n=e;const r=[];for(;J(n==null?void 0:n.cause)&&r.length<10;){const o=fe(n.cause);r.push({message:n.cause.message,source:t,type:o==null?void 0:o.name,stack:o&&me(o)}),n=n.cause}return r.length?r:void 0}const A={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"};function es(){return new S(e=>{const t=(o,s)=>{const i=bt({stackTrace:s,originalError:o,startClocks:k(),nonErrorPrefix:"Uncaught",source:A.SOURCE,handling:"unhandled"});e.notify(i)},{stop:n}=ts(t),{stop:r}=ns(t);return()=>{n(),r()}})}function ts(e){return X(I(),"onerror",({parameters:[t,n,r,o,s]})=>{let i;J(s)||(i=Fo(t,n,r,o)),e(s!=null?s:t,i)})}function ns(e){return X(I(),"onunhandledrejection",({parameters:[t]})=>{e(t.reason||"Empty reason")})}function rs(e){const t={version:"6.22.0",onReady(n){n()},...e};return Object.defineProperty(t,"_setDebug",{get(){return Er},enumerable:!1}),t}function os(e,t,n){const r=e[t];r&&!r.q&&r.version&&y.warn("SDK is loaded more than once. This is unsupported and might have unexpected behavior."),e[t]=n,r&&r.q&&r.q.forEach(o=>Mt(o,"onReady callback threw an error:")())}function _n(e,t){t.silentMultipleInit||y.error(`${e} is already initialized.`)}function Z(e,t,n,r,o){return St(e,t,[n],r,o)}function St(e,t,n,r,{once:o,capture:s,passive:i}={}){const c=b(f=>{!f.isTrusted&&!f.__ddIsTrusted&&!e.allowUntrustedEvents||(o&&l(),r(f))}),a=i?{capture:s,passive:i}:s,u=window.EventTarget&&t instanceof EventTarget?window.EventTarget.prototype:t,d=ae(u,"addEventListener");n.forEach(f=>d.call(t,f,c,a));function l(){const f=ae(u,"removeEventListener");n.forEach(m=>f.call(t,m,c,a))}return{stop:l}}const Ge={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function ss(e,t){const n=[];t.includes(Ge.cspViolation)&&n.push(cs(e));const r=t.filter(o=>o!==Ge.cspViolation);return r.length&&n.push(is(r)),qt(...n)}function is(e){return new S(t=>{if(!window.ReportingObserver)return;const n=b((o,s)=>o.forEach(i=>t.notify(as(i)))),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),()=>{r.disconnect()}})}function cs(e){return new S(t=>{const{stop:n}=Z(e,document,"securitypolicyviolation",r=>{t.notify(us(r))});return n})}function as(e){const{type:t,body:n}=e;return Tn({type:n.id,message:`${t}: ${n.message}`,originalError:e,stack:Cn(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)})}function us(e){const t=`'${e.blockedURI}' blocked by '${e.effectiveDirective}' directive`;return Tn({type:e.effectiveDirective,message:`${Ge.cspViolation}: ${t}`,originalError:e,csp:{disposition:e.disposition},stack:Cn(e.effectiveDirective,e.originalPolicy?`${t} of the policy "${Tr(e.originalPolicy,100,"...")}"`:"no policy",e.sourceFile,e.lineNumber,e.columnNumber)})}function Tn(e){return{startClocks:k(),source:A.REPORT,handling:"unhandled",...e}}function Cn(e,t,n,r,o){return n?me({name:e,message:t,stack:[{func:"?",url:n,line:r!=null?r:void 0,column:o!=null?o:void 0}]}):void 0}const ls=200;function vn(e){const{env:t,service:n,version:r,datacenter:o,sdkVersion:s,variant:i}=e,c=[Q("sdk_version",s!=null?s:"6.22.0")];return t&&c.push(Q("env",t)),n&&c.push(Q("service",n)),r&&c.push(Q("version",r)),o&&c.push(Q("datacenter",o)),i&&c.push(Q("variant",i)),c}function Q(e,t){const n=t?`${e}:${t}`:e;return(n.length>ls||ds(n))&&y.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${Qe} ${Ze}/getting_started/tagging/#defining-tags`),On(n)}function On(e){return e.replace(/,/g,"_")}function ds(e){return fs()?new RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e):!1}function fs(){try{return new RegExp("[\\p{Ll}]","u"),!0}catch(e){return!1}}function wn(e,t){const n=L.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function Ke(e,t,n=hs()){if(t===void 0)return e;if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,o)}if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const o=Array.isArray(e)?e:[];for(let s=0;s<t.length;++s)o[s]=Ke(o[s],t[s],n);return o}const r=pn(e)==="object"?e:{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=Ke(r[o],t[o],n));return r}function An(e){return Ke(void 0,e)}function ee(...e){let t;for(const n of e)n!=null&&(t=Ke(t,n));return t}function hs(){if(typeof WeakSet!="undefined"){const t=new WeakSet;return{hasAlreadyBeenSeen(n){const r=t.has(n);return r||t.add(n),r}}}const e=[];return{hasAlreadyBeenSeen(t){const n=e.indexOf(t)>=0;return n||e.push(t),n}}}function ms(){var e;const t=L.navigator;return{status:t.onLine?"connected":"not_connected",interfaces:t.connection&&t.connection.type?[t.connection.type]:void 0,effective_type:(e=t.connection)===null||e===void 0?void 0:e.effectiveType}}function Rn(e){return e>=500}function ps(e){try{return e.clone()}catch(t){return}}const gs=80*ce,Es=32,In=20*Bt,ys=M,Ln=ie;function xn(e,t,n,r,o,s){t.transportStatus===0&&t.queuedPayloads.size()===0&&t.bandwidthMonitor.canHandle(e)?Nn(e,t,n,s,{onSuccess:()=>Un(0,t,n,r,o,s),onFailure:()=>{t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e}),kn(t,n,r,o,s)}}):t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e})}function kn(e,t,n,r,o){e.transportStatus===2&&_e(()=>{const s=e.queuedPayloads.first();Nn(s,e,t,o,{onSuccess:()=>{e.queuedPayloads.dequeue(),e.currentBackoffTime=Ln,Un(1,e,t,n,r,o)},onFailure:()=>{e.currentBackoffTime=Math.min(ys,e.currentBackoffTime*2),kn(e,t,n,r,o)}})},e.currentBackoffTime)}function Nn(e,t,n,r,{onSuccess:o,onFailure:s}){t.bandwidthMonitor.add(e),n(e,i=>{t.bandwidthMonitor.remove(e),bs(i)?(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:i.status},r.notify({type:"failure",bandwidth:t.bandwidthMonitor.stats(),payload:e}),s()):(t.transportStatus=0,r.notify({type:"success",bandwidth:t.bandwidthMonitor.stats(),payload:e}),o())})}function Un(e,t,n,r,o,s){e===0&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:`Reached max ${r} events size queued for upload: ${In/Bt}MiB`,source:A.AGENT,startClocks:k()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=Pn();i.size()>0;)xn(i.dequeue(),t,n,r,o,s)}function bs(e){return e.type!=="opaque"&&(e.status===0&&!navigator.onLine||e.status===408||e.status===429||Rn(e.status))}function Ss(){return{transportStatus:0,currentBackoffTime:Ln,bandwidthMonitor:_s(),queuedPayloads:Pn(),queueFullReported:!1}}function Pn(){const e=[];return{bytesCount:0,enqueue(t){return this.isFull()?!1:(e.push(t),this.bytesCount+=t.bytesCount,!0)},first(){return e[0]},dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size(){return e.length},isFull(){return this.bytesCount>=In}}}function _s(){return{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return this.ongoingRequestCount===0||this.ongoingByteCount+e.bytesCount<=gs&&this.ongoingRequestCount<Es},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount},stats(){return{ongoingByteCount:this.ongoingByteCount,ongoingRequestCount:this.ongoingRequestCount}}}}function Dn(e,t,n){const r=new S,o=Ss();return{observable:r,send:s=>{for(const i of e)xn(s,o,(c,a)=>vs(i,t,c,a),i.trackType,n,r)},sendOnExit:s=>{for(const i of e)Ts(i,t,s)}}}function Ts(e,t,n){if(!!navigator.sendBeacon&&n.bytesCount<t)try{const o=e.build("beacon",n);if(navigator.sendBeacon(o,n.data))return}catch(o){Cs(o)}_t(e,n)}let Mn=!1;function Cs(e){Mn||(Mn=!0,tt(e))}function vs(e,t,n,r){if(Os()&&n.bytesCount<t){const s=e.build("fetch-keepalive",n);fetch(s,{method:"POST",body:n.data,keepalive:!0,mode:"cors"}).then(b(i=>r==null?void 0:r({status:i.status,type:i.type}))).catch(b(()=>_t(e,n,r)))}else _t(e,n,r)}function _t(e,t,n){const r=e.build("fetch",t);fetch(r,{method:"POST",body:t.data,mode:"cors"}).then(b(o=>n==null?void 0:n({status:o.status,type:o.type}))).catch(b(()=>n==null?void 0:n({status:0})))}function Os(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}function Tt(){const e=ws();if(e)return{getCapabilities(){var t;return JSON.parse(((t=e.getCapabilities)===null||t===void 0?void 0:t.call(e))||"[]")},getPrivacyLevel(){var t;return(t=e.getPrivacyLevel)===null||t===void 0?void 0:t.call(e)},getAllowedWebViewHosts(){return JSON.parse(e.getAllowedWebViewHosts())},send(t,n,r){const o=r?{id:r}:void 0;e.send(JSON.stringify({eventType:t,event:n,view:o}))}}}function je(e){var t;e===void 0&&(e=(t=I().location)===null||t===void 0?void 0:t.hostname);const n=Tt();return!!n&&n.getAllowedWebViewHosts().some(r=>e===r||e.endsWith(`.${r}`))}function ws(){return I().DatadogEventBridge}const Ye={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function As(e){return new S(t=>{const{stop:n}=St(e,window,["visibilitychange","freeze"],o=>{o.type==="visibilitychange"&&document.visibilityState==="hidden"?t.notify({reason:Ye.HIDDEN}):o.type==="freeze"&&t.notify({reason:Ye.FROZEN})},{capture:!0}),r=Z(e,window,"beforeunload",()=>{t.notify({reason:Ye.UNLOADING})}).stop;return()=>{n(),r()}})}function Rs(e){return Ue(Ye).includes(e)}function $n({encoder:e,request:t,flushController:n,messageBytesLimit:r}){let o={};const s=n.flushObservable.subscribe(l=>d(l));function i(l,f,m){n.notifyBeforeAddMessage(f),m!==void 0?(o[m]=l,n.notifyAfterAddMessage()):e.write(e.isEmpty?l:`
|
|
10
|
+
${l}`,g=>{n.notifyAfterAddMessage(g-f)})}function c(l){return l!==void 0&&o[l]!==void 0}function a(l){const f=o[l];delete o[l];const m=e.estimateEncodedBytesCount(f);n.notifyAfterRemoveMessage(m)}function u(l,f){const m=ve(l),g=e.estimateEncodedBytesCount(m);if(g>=r){y.warn(`Discarded a message whose size was bigger than the maximum allowed size ${r}KB. ${Qe} ${cr}/#technical-limitations`);return}c(f)&&a(f),i(m,g,f)}function d(l){const f=Ue(o).join(`
|
|
11
|
+
`);o={};const m=Rs(l.reason),g=m?t.sendOnExit:t.send;if(m&&e.isAsync){const C=e.finishSync();C.outputBytesCount&&g(Fn(C));const _=[C.pendingData,f].filter(Boolean).join(`
|
|
12
12
|
`);_&&g({data:_,bytesCount:Gt(_)})}else f&&e.write(e.isEmpty?f:`
|
|
13
|
-
${f}`),e.finish(O=>{g(Fn(O))})}return{flushController:n,add:u,upsert:u,stop:s.unsubscribe}}function Fn(e){let t;return typeof e.output=="string"?t=e.output:t=new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function Hn({messagesLimit:e,bytesLimit:t,durationLimit:n,pageMayExitObservable:r,sessionExpireObservable:o}){const s=r.subscribe(g=>d(g.reason)),i=o.subscribe(()=>d("session_expire")),c=new S(()=>()=>{s.unsubscribe(),i.unsubscribe()});let a=0,u=0;function d(g){if(u===0)return;const O=u,_=a;u=0,a=0,h(),c.notify({reason:g,messagesCount:O,bytesCount:_})}let l;function f(){l===void 0&&(l=Se(()=>{d("duration_limit")},n))}function h(){zt(l),l=void 0}return{flushObservable:c,get messagesCount(){return u},notifyBeforeAddMessage(g){a+g>=t&&d("bytes_limit"),u+=1,a+=g,f()},notifyAfterAddMessage(g=0){a+=g,u>=e?d("messages_limit"):a>=t&&d("bytes_limit")},notifyAfterRemoveMessage(g){a-=g,u-=1,u===0&&h()}}}const pe="DISCARDED",te="SKIPPED";function Rs(){const e={};return{register(t,n){return e[t]||(e[t]=[]),e[t].push(n),{unregister:()=>{e[t]=e[t].filter(r=>r!==n)}}},triggerHook(t,n){const r=e[t]||[],o=[];for(const s of r){const i=s(n);if(i===pe)return pe;i!==te&&o.push(i)}return ee(...o)}}}const ne={LOG:"log",CONFIGURATION:"configuration",USAGE:"usage"},Is=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Ls=1,Ns=[uo];let Ot;function Ce(){return Ot||(Ot=new Wt(100)),Ot}function ks(e,t,n,r,o,s){const i=new S,{stop:c}=Us(t,r,o,s,i),{enabled:a,metricsEnabled:u}=xs(e,t,n,i);return{stop:c,enabled:a,metricsEnabled:u}}function xs(e,t,n,r,o=Ls){const s={},i=!Ns.includes(t.site)&&be(t.telemetrySampleRate),c={[ne.LOG]:i,[ne.CONFIGURATION]:i&&be(t.telemetryConfigurationSampleRate),[ne.USAGE]:i&&be(t.telemetryUsageSampleRate),metric:i&&be(o)},a=Ps(),u=Ce();return u.subscribe(({rawEvent:l,metricName:f})=>{if(f&&!c.metric||!c[l.type])return;const h=f||l.status||l.type;let g=s[h];if(g||(g=s[h]=new Set),g.size>=t.maxTelemetryEventsPerPage)return;const O=Oe(l);if(g.has(O))return;const _=n.triggerHook(1,{startTime:k().relative});if(_===pe)return;const G=d(_,e,l,a);r.notify(G),An("telemetry",G),g.add(O)}),u.unbuffer(),pr(Ds),{enabled:i,metricsEnabled:c.metric};function d(l,f,h,g){const _={type:"telemetry",date:k().timeStamp,service:f,version:"6.22.0",source:"browser",_dd:{format_version:2},telemetry:ee(h,{runtime_env:g,connectivity:ms(),sdk_setup:"npm"}),ddtags:Cn(t).join(","),experimental_features:Array.from(wo())};return ee(_,l)}}function Us(e,t,n,r,o){const s=[];if(Ke()){const i=Tt(),c=o.subscribe(a=>i.send("internal_telemetry",a));s.push(c.unsubscribe)}else{const i=[e.rumEndpointBuilder];e.replica&&Ms(e)&&i.push(e.replica.rumEndpointBuilder);const c=$n({encoder:r(4),request:Mn(i,e.batchBytesLimit,t),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:n,sessionExpireObservable:new S}),messageBytesLimit:e.messageBytesLimit});s.push(c.stop);const a=o.subscribe(c.add);s.push(a.unsubscribe)}return{stop:()=>s.forEach(i=>i())}}function Ps(){var e;return{is_local_file:((e=L.location)===null||e===void 0?void 0:e.protocol)==="file:",is_worker:z}}function Ms(e){return e.site===co}function Ct(e,t){nt(T.debug,e,t),Ce().notify({rawEvent:{type:ne.LOG,message:e,status:"debug",...t}})}function Ds(e,t){Ce().notify({rawEvent:{type:ne.LOG,status:"error",...Hs(e),...t}})}function $s(e){Ce().notify({rawEvent:{type:ne.CONFIGURATION,configuration:e}})}function Fs(e){Ce().notify({rawEvent:{type:ne.USAGE,usage:e}})}function Hs(e){if(X(e)){const t=de(e);return{error:{kind:t.name,stack:me(Bs(t))},message:t.message}}return{error:{stack:Sn},message:`Uncaught ${Oe(e)}`}}function Bs(e){return e.stack=e.stack.filter(t=>!t.url||Is.some(n=>t.url.startsWith(n))),e}function Gs(e){const t=new Set;return e.forEach(n=>t.add(n)),Array.from(t)}function Bn(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}const ze=1/0,Ks=D;let ve=null;const Ye=new Set;function js(){Ye.forEach(e=>e())}function zs({expireDelay:e,maxEntries:t}){let n=[];ve||(ve=rt(()=>js(),Ks));const r=()=>{const d=we()-e;for(;n.length>0&&n[n.length-1].endTime<d;)n.pop()};Ye.add(r);function o(d,l){const f={value:d,startTime:l,endTime:ze,remove:()=>{Bn(n,f)},close:h=>{f.endTime=h}};return t&&n.length>=t&&n.pop(),n.unshift(f),f}function s(d=ze,l={returnInactive:!1}){for(const f of n)if(f.startTime<=d){if(l.returnInactive||d<=f.endTime)return f.value;break}}function i(d){const l=n[0];l&&l.endTime===ze&&l.close(d)}function c(d=ze,l=0){const f=dr(d,l);return n.filter(h=>h.startTime<=f&&d<=h.endTime).map(h=>h.value)}function a(){n=[]}function u(){Ye.delete(r),Ye.size===0&&ve&&(Yt(ve),ve=null)}return{add:o,find:s,closeActive:i,findAll:c,reset:a,stop:u}}const Ys="datadog-synthetics-public-id",Vs="datadog-synthetics-result-id",qs="datadog-synthetics-injects-rum";function Gn(){return z?!1:!!(L._DATADOG_SYNTHETICS_INJECTS_RUM||Y(qs))}function Ws(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y(Ys);return typeof e=="string"?e:void 0}function Js(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||Y(Vs);return typeof e=="string"?e:void 0}function Xs(){return!!(Ws()&&Js())}const Zs=D,Qs=ut;function ei(e,t,n,r){const o=new S,s=new S,i=Qr(e.sessionStoreStrategyType,e,t,n),c=zs({expireDelay:Qs});if(i.renewObservable.subscribe(()=>{c.add(a(),we()),o.notify()}),i.expireObservable.subscribe(()=>{s.notify(),c.closeActive(we())}),i.expandOrRenewSession(),c.add(a(),lr().relative),Ao($e.SHORT_SESSION_INVESTIGATION)){const u=i.getSession();u&&si(e,u)}r.observable.subscribe(()=>{r.isGranted()?i.expandOrRenewSession():i.expire()}),ti(e,()=>{r.isGranted()&&i.expandOrRenewSession()}),ni(e,()=>i.expandSession()),ri(e,()=>i.restartSession());function a(){const u=i.getSession();return u?{id:u.id,trackingType:u[t],isReplayForced:!!u.forcedReplay,anonymousId:u.anonymousId}:(oi().catch(()=>{}),{id:"invalid",trackingType:en,isReplayForced:!1,anonymousId:void 0})}return{findSession:(u,d)=>c.find(u,d),renewObservable:o,expireObservable:s,sessionStateUpdateObservable:i.sessionStateUpdateObservable,expire:i.expire,updateSessionState:i.updateSessionState}}function ti(e,t){const{stop:n}=St(e,window,["click","touchstart","keydown","scroll"],t,{capture:!0,passive:!0})}function ni(e,t){const n=()=>{document.visibilityState==="visible"&&t()},{stop:r}=Z(e,document,"visibilitychange",n);rt(n,Zs)}function ri(e,t){const{stop:n}=Z(e,window,"resume",t,{capture:!0})}async function oi(){const e=an();Ct("Unexpected session state",{session:e,isSyntheticsTest:Xs(),createdTimestamp:e==null?void 0:e.created,expireTimestamp:e==null?void 0:e.expire,cookie:await Kn(),currentDomain:`${window.location.protocol}//${window.location.hostname}`})}function si(e,t){if(!window.cookieStore||!t.created)return;const n=Number(t.created),r=$(),{stop:o}=Z(e,cookieStore,"change",s);function s(i){const c=Rr(i.changed,u=>u.name===B);if(!c)return;const a=$()-n;if(a>14*D)o();else{const u=dt(c.value);if(u.id&&u.id!==t.id){o();const d=$()-r;Kn().then(l=>{Ct("Session cookie changed",{time:d,session_age:a,old:t,new:u,cookie:l})}).catch(tt)}}}}async function Kn(){let e;return"cookieStore"in window?e=await window.cookieStore.getAll(B):e=document.cookie.split(/\s*;\s*/).filter(t=>t.startsWith(B)),{count:e.length,domain:Zt()||"undefined",...e}}function jn(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,r){const o=Gt(n);t+=o,e+=n,r&&r(o)},finish(n){n(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(n){return n.length}}}class ii{constructor(){this.callbacks={}}notify(t,n){const r=this.callbacks[t];r&&r.forEach(o=>o(n))}subscribe(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),{unsubscribe:()=>{this.callbacks[t]=this.callbacks[t].filter(r=>n!==r)}}}}function ci(e,t,n){let r=0,o=!1;return{isLimitReached(){if(r===0&&Se(()=>{r=0},D),r+=1,r<=t||o)return o=!1,!1;if(r===t+1){o=!0;try{n({message:`Reached max number of ${e}s by minute: ${t}`,source:w.AGENT,startClocks:k()})}finally{o=!1}}return!0}}}let vt;const At=new WeakMap;function ai(e){return vt||(vt=ui(e)),vt}function ui(e){return new S(t=>{const{stop:n}=J(XMLHttpRequest.prototype,"open",li),{stop:r}=J(XMLHttpRequest.prototype,"send",s=>{di(s,e,t)},{computeHandlingStack:!0}),{stop:o}=J(XMLHttpRequest.prototype,"abort",fi);return()=>{n(),r(),o()}})}function li({target:e,parameters:[t,n]}){At.set(e,{state:"open",method:String(t).toUpperCase(),url:ot(String(n))})}function di({target:e,parameters:[t],handlingStack:n},r,o){const s=At.get(e);if(!s)return;const i=s;i.state="start",i.startClocks=k(),i.isAborted=!1,i.xhr=e,i.handlingStack=n,i.body=t;let c=!1;const{stop:a}=J(e,"onreadystatechange",()=>{e.readyState===XMLHttpRequest.DONE&&u()}),u=()=>{if(d(),a(),c)return;c=!0;const l=s;l.state="complete",l.duration=Ft(i.startClocks.timeStamp,U()),l.status=e.status,o.notify(hr(l))},{stop:d}=Z(r,e,"loadend",u);o.notify(i)}function fi({target:e}){const t=At.get(e);t&&(t.isAborted=!0)}let wt;function zn(){return wt||(wt=mi()),wt}function mi(){return new S(e=>{if(!L.fetch)return;const{stop:t}=J(L,"fetch",n=>hi(n,e),{computeHandlingStack:!0});return t})}function hi({parameters:e,onPostCall:t,handlingStack:n},r){const[o,s]=e;let i=s&&s.method;i===void 0&&o instanceof Request&&(i=o.method);const c=i!==void 0?String(i).toUpperCase():"GET",a=o instanceof Request?o.url:ot(String(o)),u=k(),d={state:"start",init:s,input:o,method:c,startClocks:u,url:a,handlingStack:n};r.notify(d),e[0]=d.input,e[1]=d.init,t(l=>pi(r,l,d))}function pi(e,t,n){const r=n;function o(s){r.state="resolve",Object.assign(r,s),e.notify(r)}t.then(b(s=>{o({response:s,responseType:s.type,status:s.status,isAborted:!1})}),b(s=>{var i,c;o({status:0,isAborted:((c=(i=r.init)===null||i===void 0?void 0:i.signal)===null||c===void 0?void 0:c.aborted)||s instanceof DOMException&&s.code===DOMException.ABORT_ERR,error:s})}))}let Rt={};function gi(e){const t=e.map(n=>(Rt[n]||(Rt[n]=Ei(n)),Rt[n]));return qt(...t)}function Ei(e){return new S(t=>{const n=N[e];return N[e]=(...r)=>{n.apply(console,r);const o=He("console error");ae(()=>{t.notify(yi(r,e,o))})},()=>{N[e]=n}})}function yi(e,t,n){const r=e.map(o=>bi(o)).join(" ");if(t===T.error){const o=e.find(X),s=bt({originalError:o,handlingStack:n,startClocks:k(),source:w.CONSOLE,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return s.message=r,{api:t,message:r,handlingStack:n,error:s}}return{api:t,message:r,error:void 0,handlingStack:n}}function bi(e){return typeof e=="string"?P(e):X(e)?bn(de(e)):Oe(P(e),void 0,2)}const Si=500;function _i(){const e=[];return{add:o=>{e.push(o)>Si&&e.splice(0,1)},remove:o=>{Bn(e,o)},drain:o=>{e.forEach(s=>s(o)),e.length=0}}}function Ti(e){const t=pn(e)==="object";return t||y.error("Unsupported context:",e),t}function It(e,t,n){const r={...e};for(const[o,{required:s,type:i}]of Object.entries(t))i==="string"&&!Yn(r[o])&&(r[o]=String(r[o])),s&&Yn(r[o])&&y.warn(`The property ${o} of ${n} is required; context will not be sent to the intake.`);return r}function Yn(e){return e==null||e===""}function Ve(e="",{propertiesConfig:t={}}={}){let n={};const r=new S,o={getContext:()=>wn(n),setContext:s=>{Ti(s)?n=P(It(s,t,e)):o.clearContext(),r.notify()},setContextProperty:(s,i)=>{n=P(It({...n,[s]:i},t,e)),r.notify()},removeContextProperty:s=>{delete n[s],It(n,t,e),r.notify()},clearContext:()=>{n={},r.notify()},changeObservable:r};return o}function v(e,t,n,r){return b((...o)=>e()[t][n](...o))}function Lt(e,t,n){e.changeObservable.subscribe(()=>{const r=e.getContext();n.add(o=>o[t].setContext(r))})}const Oi="_dd_c",Ci=[];function Nt(e,t,n,r){const o=vi(n,r);Ci.push(Z(e,window,"storage",({key:u})=>{o===u&&i()})),t.changeObservable.subscribe(c);const s=ee(a(),t.getContext());Re(s)||t.setContext(s);function i(){t.setContext(a())}function c(){localStorage.setItem(o,JSON.stringify(t.getContext()))}function a(){const u=localStorage.getItem(o);return u?JSON.parse(u):{}}}function vi(e,t){return`${Oi}_${e}_${t}`}function Ai(e,t,n){const r=Vn();return t.storeContextsAcrossPages&&Nt(t,r,n,4),e.register(0,()=>{const o=r.getContext();return Re(o)||!o.id?te:{account:o}}),r}function Vn(){return Ve("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}function wi(e,t,n,r){const o=qn();return t.storeContextsAcrossPages&&Nt(t,o,n,2),e.register(0,()=>o.getContext()),o}function qn(){return Ve("global context")}function Ri(e,t,n,r){const o=Wn();return t.storeContextsAcrossPages&&Nt(t,o,r,1),e.register(0,({eventType:s,startTime:i})=>{const c=o.getContext(),a=n.findTrackedSession(i);return a&&a.anonymousId&&!c.anonymous_id&&t.trackAnonymousUser&&(c.anonymous_id=a.anonymousId),Re(c)?te:{type:s,usr:c}}),e.register(1,({startTime:s})=>{var i;return{anonymous_id:(i=n.findTrackedSession(s))===null||i===void 0?void 0:i.anonymousId}}),o}function Wn(){return Ve("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}const C={userContext:"userContext",globalContext:"globalContext",accountContext:"accountContext"},A={getContext:"getContext",setContext:"setContext",setContextProperty:"setContextProperty",removeContextProperty:"removeContextProperty",clearContext:"clearContext"};function Ii(e,t,n){const r=e.getReader(),o=[];let s=0;i();function i(){r.read().then(b(a=>{if(a.done){c();return}o.push(a.value),s+=a.value.length,s>n.bytesLimit?c():i()}),b(a=>t(a)))}function c(){r.cancel().catch(F);let a,u;{let d;if(o.length===1)d=o[0];else{d=new Uint8Array(s);let l=0;o.forEach(f=>{d.set(f,l),l+=f.length})}a=d.slice(0,n.bytesLimit),u=d.length>n.bytesLimit}t(void 0,a,u)}}const Jn={XHR:"xhr",FETCH:"fetch"},kt={FETCH:Jn.FETCH,XHR:Jn.XHR},Li=500;function Ni(e=Qo){const t=new Wt(Li),n=e().subscribe(r=>{t.notify({type:0,error:r})});return{observable:t,stop:()=>{n.unsubscribe()}}}function qe(e,t,n){const r=n.getHandler(),o=Array.isArray(r)?r:[r];return Xn[e]>=Xn[n.getLevel()]&&o.includes(t)}const p={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Xn={[p.ok]:0,[p.debug]:1,[p.info]:2,[p.notice]:4,[p.warn]:5,[p.error]:6,[p.critical]:7,[p.alert]:8,[p.emerg]:9};function We(e,{includeMessage:t=!1}={}){return{stack:e.stack,kind:e.type,message:t?e.message:void 0,causes:e.causes,fingerprint:e.fingerprint,handling:e.handling}}var ki=function(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};const Ae={console:"console",http:"http"},xi=Object.keys(p);class R{constructor(t,n,r=Ae.http,o=p.debug,s={}){this.handleLogStrategy=t,this.handlerType=r,this.level=o,this.contextManager=Ve("logger"),this.tags=[],this.contextManager.setContext(s),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(t,n,r=p.info,o,s){const i=P(n);let c;if(o!=null){const a=bt({originalError:o,nonErrorPrefix:"Provided",source:w.LOGGER,handling:"handled",startClocks:k()});c=ee({error:We(a,{includeMessage:!0})},a.context,i)}else c=i;this.handleLogStrategy({message:P(t),context:c,status:r},this,s)}log(t,n,r=p.info,o){let s;qe(r,Ae.http,this)&&(s=He("log")),this.logImplementation(t,n,r,o,s)}setContext(t){this.contextManager.setContext(t)}getContext(){return this.contextManager.getContext()}setContextProperty(t,n){this.contextManager.setContextProperty(t,n)}removeContextProperty(t){this.contextManager.removeContextProperty(t)}clearContext(){this.contextManager.clearContext()}addTag(t,n){this.tags.push(Q(t,n))}removeTagsWithKey(t){const n=vn(t);this.tags=this.tags.filter(r=>r!==n&&!r.startsWith(`${n}:`))}getTags(){return this.tags.slice()}setHandler(t){this.handlerType=t}getHandler(){return this.handlerType}setLevel(t){this.level=t}getLevel(){return this.level}}ki([Er],R.prototype,"logImplementation",null),R.prototype.ok=M(p.ok),R.prototype.debug=M(p.debug),R.prototype.info=M(p.info),R.prototype.notice=M(p.notice),R.prototype.warn=M(p.warn),R.prototype.error=M(p.error),R.prototype.critical=M(p.critical),R.prototype.alert=M(p.alert),R.prototype.emerg=M(p.emerg);function M(e){return function(t,n,r){let o;qe(e,Ae.http,this)&&(o=He("log")),this.logImplementation(t,n,e,r,o)}}function Zn(){return z?{}:{view:{referrer:document.referrer,url:window.location.href}}}const Ui=32*ie;function Pi(e,t){e.usePciIntake===!0&&e.site&&e.site!=="datadoghq.com"&&y.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=To(e,t),r=Qn(e.forwardConsoleLogs,xe(T),"Forward Console Logs"),o=Qn(e.forwardReports,xe(Be),"Forward Reports");if(!(!n||!r||!o))return e.forwardErrorsToLogs&&!r.includes(T.error)&&r.push(T.error),{forwardErrorsToLogs:e.forwardErrorsToLogs!==!1,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Ui,...n}}function Qn(e,t,n){if(e===void 0)return[];if(!(e==="all"||Array.isArray(e)&&e.every(r=>t.includes(r)))){y.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`);return}return e==="all"?t:Gs(e)}function Mi(e){const t=Oo(e);return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}function Di(e,t,n){const r=_i(),o=qn();Lt(o,C.globalContext,r);const s=Vn();Lt(s,C.accountContext,r);const i=Wn();Lt(i,C.userContext,r);let c,a;const u=t.observable.subscribe(d);function d(){if(!a||!c||!t.isGranted())return;u.unsubscribe();const l=n(c,a);r.drain(l)}return{init(l,f){if(!l){y.error("Missing configuration");return}if(Co(l.enableExperimentalFeatures),Ke()&&(l=$i(l)),c=l,$s(Mi(l)),a){_n("DD_LOGS",l);return}const h=Pi(l,f);h&&(a=h,zn().subscribe(F),t.tryToInit(h.trackingConsent),d())},get initConfiguration(){return c},globalContext:o,accountContext:s,userContext:i,getInternalContext:F,handleLog(l,f,h,g=e(),O=U()){r.add(_=>_.handleLog(l,f,h,g,O))}}}function $i(e){return{...e,clientToken:"empty"}}function Fi(e){const t=eo(),n=Ni().observable;let r=Di(Zn,t,(c,a)=>{const u=e(a,Zn,t,n);return r=Hi(c,u),u});const o=()=>r,s={},i=new R((...c)=>r.handleLog(...c));return ns({logger:i,init:c=>{const a=new Error().stack;ae(()=>r.init(c,a))},setTrackingConsent:b(c=>{t.update(c),Fs({feature:"set-tracking-consent",tracking_consent:c})}),getGlobalContext:v(o,C.globalContext,A.getContext),setGlobalContext:v(o,C.globalContext,A.setContext),setGlobalContextProperty:v(o,C.globalContext,A.setContextProperty),removeGlobalContextProperty:v(o,C.globalContext,A.removeContextProperty),clearGlobalContext:v(o,C.globalContext,A.clearContext),createLogger:b((c,a={})=>(s[c]=new R((...u)=>r.handleLog(...u),P(c),a.handler,a.level,P(a.context)),s[c])),getLogger:b(c=>s[c]),getInitConfiguration:b(()=>wn(r.initConfiguration)),getInternalContext:b(c=>r.getInternalContext(c)),setUser:v(o,C.userContext,A.setContext),getUser:v(o,C.userContext,A.getContext),setUserProperty:v(o,C.userContext,A.setContextProperty),removeUserProperty:v(o,C.userContext,A.removeContextProperty),clearUser:v(o,C.userContext,A.clearContext),setAccount:v(o,C.accountContext,A.setContext),getAccount:v(o,C.accountContext,A.getContext),setAccountProperty:v(o,C.accountContext,A.setContextProperty),removeAccountProperty:v(o,C.accountContext,A.removeContextProperty),clearAccount:v(o,C.accountContext,A.clearContext)})}function Hi(e,t){return{init:n=>{_n("DD_LOGS",n)},initConfiguration:e,...t}}const Bi="logs";function Gi(e,t){const n=ei(e,Bi,r=>er(e,r),t);return{findTrackedSession:(r,o={returnInactive:!1})=>{const s=n.findSession(r,o);return s&&s.trackingType==="1"?{id:s.id,anonymousId:s.anonymousId}:void 0},expireObservable:n.expireObservable}}function Ki(e){const n=er(e)==="1"?{}:void 0;return{findTrackedSession:()=>n,expireObservable:new S}}function er(e,t){return ji(t)?t:be(e.sessionSampleRate)?"1":"0"}function ji(e){return e==="0"||e==="1"}function zi(e,t,n,r,o){const s=xi.concat(["custom"]),i={};s.forEach(c=>{i[c]=ci(c,e.eventRateLimiterThreshold,o)}),t.subscribe(0,({rawLogsEvent:c,messageContext:a=void 0,savedCommonContext:u=void 0,domainContext:d,ddtags:l=[]})=>{var f,h;const g=fr(c.date),O=u||r(),_=n.triggerHook(0,{startTime:g});if(_===pe)return;const G=Cn(e),Ee=ee({view:O.view},_,c,a,{ddtags:G.concat(l).join(",")});((f=e.beforeSend)===null||f===void 0?void 0:f.call(e,Ee,d))===!1||Ee.origin!==w.AGENT&&((h=i[Ee.status])!==null&&h!==void 0?h:i.custom).isLimitReached()||t.notify(1,Ee)})}const Yi={[T.log]:p.info,[T.debug]:p.debug,[T.info]:p.info,[T.warn]:p.warn,[T.error]:p.error};function Vi(e,t){const n=gi(e.forwardConsoleLogs).subscribe(r=>{var o;const s={rawLogsEvent:{date:U(),message:r.message,origin:w.CONSOLE,error:r.error&&We(r.error),status:Yi[r.api]},messageContext:(o=r.error)===null||o===void 0?void 0:o.context,domainContext:{handlingStack:r.handlingStack}};t.notify(0,s)});return{stop:()=>{n.unsubscribe()}}}function qi(e,t){const n=os(e,e.forwardReports).subscribe(r=>{let o=r.message,s;const i=r.originalError.type==="deprecation"?p.warn:p.error;i===p.error?s=We(r):r.stack&&(o+=` Found in ${Xo(r.stack)}`),t.notify(0,{rawLogsEvent:{date:U(),message:o,origin:w.REPORT,error:s,status:i}})});return{stop:()=>{n.unsubscribe()}}}function Wi(e,t){if(!e.forwardErrorsToLogs)return{stop:F};const n=(z?new S:ai(e)).subscribe(s=>{s.state==="complete"&&o(kt.XHR,s)}),r=zn().subscribe(s=>{s.state==="resolve"&&o(kt.FETCH,s)});function o(s,i){!So(i.url)&&(Qi(i)||Rn(i.status))&&("xhr"in i?Ji(i.xhr,e,c):i.response?Zi(i.response,e,c):i.error&&Xi(i.error,e,c));function c(a){const u={isAborted:i.isAborted,handlingStack:i.handlingStack};t.notify(0,{rawLogsEvent:{message:`${ec(s)} error ${i.method} ${i.url}`,date:i.startClocks.timeStamp,error:{stack:a||"Failed to load",handling:void 0},http:{method:i.method,status_code:i.status,url:i.url},status:p.error,origin:w.NETWORK},domainContext:u})}}return{stop:()=>{n.unsubscribe(),r.unsubscribe()}}}function Ji(e,t,n){typeof e.response=="string"?n(xt(e.response,t)):n(e.response)}function Xi(e,t,n){n(xt(me(de(e)),t))}function Zi(e,t,n){const r=hs(e);!r||!r.body?n():window.TextDecoder?tc(r.body,t.requestErrorResponseLengthLimit,(o,s)=>{n(o?`Unable to retrieve response: ${o}`:s)}):r.text().then(b(o=>n(xt(o,t))),b(o=>n(`Unable to retrieve response: ${o}`)))}function Qi(e){return e.status===0&&e.responseType!=="opaque"}function xt(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function ec(e){return kt.XHR===e?"XHR":"Fetch"}function tc(e,t,n){Ii(e,(r,o,s)=>{if(r)n(r);else{let i=new TextDecoder().decode(o);s&&(i+="..."),n(void 0,i)}},{bytesLimit:t})}function nc(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};const r=n.subscribe(o=>{if(o.type===0){const s=o.error;t.notify(0,{rawLogsEvent:{message:s.message,date:s.startClocks.timeStamp,error:We(s),origin:w.SOURCE,status:p.error},messageContext:s.context})}});return{stop:()=>{r.unsubscribe()}}}const rc=ii;function oc(e){function t(n,r,o,s,i){const c=ee(r.getContext(),n.context);if(qe(n.status,Ae.console,r)&&ic(n,c),qe(n.status,Ae.http,r)){const a={rawLogsEvent:{date:i||U(),message:n.message,status:n.status,origin:w.LOGGER},messageContext:c,savedCommonContext:s,ddtags:r.getTags()};o&&(a.domainContext={handlingStack:o}),e.notify(0,a)}}return{handleLog:t}}const sc={[p.ok]:T.debug,[p.debug]:T.debug,[p.info]:T.info,[p.notice]:T.info,[p.warn]:T.warn,[p.error]:T.error,[p.critical]:T.error,[p.alert]:T.error,[p.emerg]:T.error};function ic({status:e,message:t},n){j[sc[e]].call(N,t,n)}function cc(e,t,n,r,o){const s=[e.logsEndpointBuilder];e.replica&&s.push(e.replica.logsEndpointBuilder);const i=$n({encoder:jn(),request:Mn(s,e.batchBytesLimit,n),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:r,sessionExpireObservable:o.expireObservable}),messageBytesLimit:e.messageBytesLimit});return t.subscribe(1,c=>{i.add(c)}),i}function ac(e){const t=Tt();e.subscribe(1,n=>{t.send("log",n)})}function uc(e){return{get:t=>{const n=e.findTrackedSession(t);if(n)return{session_id:n.id}}}}function lc(e){return t=>{e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:w.AGENT,status:p.error}}),Ct("Error reported to customer",{"error.message":t.message})}}const dc=Rs;function fc(e){const t=L;e.register(0,({startTime:o})=>{const s=n(o);return s||te}),e.register(1,({startTime:o})=>{var s,i;const c=n(o);return c?{application:{id:c.application_id},view:{id:(s=c.view)===null||s===void 0?void 0:s.id},action:{id:(i=c.user_action)===null||i===void 0?void 0:i.id}}:te});function n(o){const i=Gn()?t.DD_RUM_SYNTHETICS:t.DD_RUM,c=r(o,i);if(c)return c}function r(o,s){if(s&&s.getInternalContext)return s.getInternalContext(o)}}function mc(e,t,n){e.register(0,({startTime:r})=>{const o=n.findTrackedSession(r);return n.findTrackedSession(r,{returnInactive:!0})?{service:t.service,session_id:o?o.id:void 0,session:o?{id:o.id}:void 0}:pe}),e.register(1,({startTime:r})=>{const o=n.findTrackedSession(r);return!o||!o.id?te:{session:{id:o.id}}})}function hc(e,t){function n(){return t.isGranted()?te:pe}e.register(0,n),e.register(1,n)}const Ut="logs";function pc(e,t,n,r){const o=new rc,s=dc(),i=[];o.subscribe(1,_=>An("logs",_));const c=lc(o),a=z?new S:As(e),u=ks("browser-logs-sdk",e,s,c,a,jn);i.push(u.stop);const d=e.sessionStoreStrategyType&&!Ke()&&!Gn()?Gi(e,n):Ki(e);hc(s,n),mc(s,e,d);const l=Ai(s,e,Ut),f=Ri(s,e,d,Ut),h=wi(s,e,Ut);fc(s),Wi(e,o),nc(e,o,r),r.unbuffer(),Vi(e,o),qi(e,o);const{handleLog:g}=oc(o);if(zi(e,o,s,t,c),Ke())ac(o);else{const{stop:_}=cc(e,o,c,a,d);i.push(()=>_())}const O=uc(d);return{handleLog:g,getInternalContext:O.get,accountContext:l,globalContext:h,userContext:f,stop:()=>{i.forEach(_=>_())}}}const Je=Fi(pc);rs(I(),"DD_LOGS",Je),m.Environment=void 0,function(e){e.DEVELOPMENT="development",e.PRODUCTION="production",e.SANDBOX="sandbox",e.PRELIVE_SANDBOX="prelive-sandbox",e.PRELIVE_PRODUCTION="prelive-production"}(m.Environment||(m.Environment={}));class ge{constructor(){this.initialized=!1,this.configService=K.instance}static get instance(){return ge._instance||(ge._instance=new ge),ge._instance}initialize(t,n){if(this.initialized){try{Je.setGlobalContextProperty("sessionUuid",n),console.log("MONTONIO-JS: LoggingService: Session UUID updated:",n)}catch(r){console.error("MONTONIO-JS: LoggingService: Error updating sessionUuid:",r)}return}try{const r=this.configService.getConfig("datadogClientToken");Je.init({clientToken:r,site:"datadoghq.eu",env:t===m.Environment.PRODUCTION?"live-production":"live-sandbox",forwardErrorsToLogs:!0,service:"montonio-js",version:"1.1.6",silentMultipleInit:!0,forwardConsoleLogs:"all"}),Je.setGlobalContext({sessionUuid:n}),this.initialized=!0}catch(r){console.error("MONTONIO-JS: LoggingService: Error initializing Datadog Logs:",r)}}}class tr{constructor(t){var n;this.defaultStyles={border:"none",display:"block",width:"100%",height:"100%"},this.options=t,this.resizeOnHeightChange=(n=t.resizeOnHeightChange)!==null&&n!==void 0?n:!0,this.element=document.createElement("iframe"),this.messagingService=new Mt,this.setupIframe()}mount(){return this.options.mountElement.appendChild(this.element),this.resizeOnHeightChange&&this.startResizing(this.element),this.element}unmount(){this.element.contentWindow&&this.messagingService.clearAllSubscriptions(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}getContentWindow(){if(!this.element.contentWindow)throw new Error("Iframe contentWindow is not available. Make sure the iframe is mounted and loaded.");return this.element.contentWindow}startResizing(t){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_HEIGHT_CHANGED,n=>{t.style.height=n.payload.height+"px"},this)}setupIframe(){const{src:t,allow:n="camera; microphone; geolocation; payment",styles:r={}}=this.options;this.element.src=t,this.element.allow=n;const o={...this.defaultStyles,...r};Object.assign(this.element.style,o)}}class nr{constructor(){this.loaded=!1,this.mountElement=null,this._iframe=null,this.messagingService=new Mt,this.httpService=oe.instance,this.configService=K.instance}get iframe(){if(!this._iframe)throw new Error("Iframe not initialized");return this._iframe}set iframe(t){this._iframe=t}cleanup(){this.iframe&&(this.iframe.unmount(),this.iframe=null)}}function gc(e){if(typeof e=="string"){const t=document.querySelector(e);if(!t||!(t instanceof HTMLElement))throw new Error(`Element not found: ${e}`);return t}return e}function Ec(){const e=document.body.style.overflow||null;return document.body.style.overflow="hidden",{originalOverflow:e}}function yc(e){e?document.body.style.overflow=e:document.body.style.removeProperty("overflow")}m.ActionRequiredActionEnum=void 0,function(e){e.SCROLL_INTO_VIEW="scrollIntoView"}(m.ActionRequiredActionEnum||(m.ActionRequiredActionEnum={})),m.LocaleEnum=void 0,function(e){e.EN="en",e.ET="et",e.LT="lt",e.LV="lv",e.PL="pl",e.RU="ru",e.FI="fi"}(m.LocaleEnum||(m.LocaleEnum={}));var rr;(function(e){e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.PAID="PAID",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.REFUNDED="REFUNDED",e.VOIDED="VOIDED",e.ABANDONED="ABANDONED"})(rr||(rr={}));const bc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Sc(e){const t=[];if(!e)throw new Xe(["CheckoutOptions object is required"]);if(e.sessionUuid===void 0||e.sessionUuid===null?t.push("sessionUuid is required"):typeof e.sessionUuid!="string"?t.push("sessionUuid must be a string"):bc.test(e.sessionUuid)||t.push(`sessionUuid must be a valid UUID format. Received: '${e.sessionUuid}'`),e.onSuccess?typeof e.onSuccess!="function"&&t.push("onSuccess must be a function"):t.push("onSuccess callback is required"),e.onError?typeof e.onError!="function"&&t.push("onError must be a function"):t.push("onError callback is required"),e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(e.environment!==void 0&&e.environment!==null&&(Object.values(m.Environment).includes(e.environment)||t.push(`environment must be one of: production, sandbox. Received: '${e.environment}'`)),t.length>0)throw new Xe(t)}function _c(e){const t=[];if(e.locale!==void 0&&e.locale!==null){const n=Object.values(m.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(t.length>0)throw new Xe(t)}class Tc extends nr{constructor(t){super(),this.originalBodyOverflow=null,this.options=t,this.mountElement=t.mountElement||document.body}async initialize(){try{if(this.options.paymentAuthData.type==="redirect"){await this.redirectViaPost(this.options.paymentAuthData);return}if(!this.options.paymentAuthData.embeddedUrl)throw new Error("Embedded URL is not set in paymentAuthData");const{originalOverflow:t}=Ec();this.originalBodyOverflow=t,this.iframe=new tr({src:this.options.paymentAuthData.embeddedUrl,mountElement:this.mountElement,styles:{width:"100dvw",height:"100dvh",position:"fixed",top:"0",left:"0",zIndex:"2147483647"},resizeOnHeightChange:!1}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY,this.iframe),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_AUTH_DATA,payload:{paymentAuthData:this.options.paymentAuthData}}),this.loaded=!0}catch(t){throw this.cleanup(),t}}cleanup(){this.loaded&&yc(this.originalBodyOverflow),super.cleanup()}async redirectViaPost(t){if(!t.redirectUrl)throw new Error("Redirect URL is not set in paymentAuthData");const n=document.createElement("form");if(n.method=t.redirectMethod||"get",n.action=t.redirectUrl,n.style.display="none",t.formData)for(const[r,o]of Object.entries(t.formData)){const s=document.createElement("input");s.type="hidden",s.name=r,s.value=o,n.appendChild(s)}throw document.body.appendChild(n),n.submit(),await new Promise(r=>setTimeout(r,3e4)),new Error("Redirect timeout: Expected redirect to occur within 30 seconds")}}class Oc extends nr{constructor(t){super(),this.isValid=!1,this.paymentAuth=null,this.options=t,this.environment=t.environment||m.Environment.PRODUCTION,ge.instance.initialize(this.environment,this.options.sessionUuid),console.log("MONTONIO-JS: MontonioCheckout: class created with options:",t),Sc(t)}async initialize(t){try{console.log("MONTONIO-JS: initialize: Initializing MontonioCheckout with mountTo:",t),this.mountElement=gc(t);const n=await this.fetchSession();return this.iframe=new tr({src:n.url,mountElement:this.mountElement}),this.iframe.mount(),await this.messagingService.waitForMessage(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPONENT_READY,this.iframe),this.setUpListeners(),this.loaded=!0,console.log("MONTONIO-JS: initialize: MontonioCheckout initialized successfully"),!0}catch(n){throw console.error("MONTONIO-JS: initialize: Error initializing MontonioCheckout:",n),this.cleanup(),n}}updateOptions(t){if(console.log("MONTONIO-JS: updateOptions: Updating options to:",t),!this.loaded)throw new re;_c(t),t.locale!==void 0&&(this.options.locale=t.locale,this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_CHANGE_LOCALE,payload:{locale:t.locale}}))}validateOrReject(){if(console.log("MONTONIO-JS: validateOrReject: Called validateOrReject, isValid:",this.isValid),!this.isValid)throw this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS}),new Pt}submitPayment(){if(!this.loaded)throw new re;this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SUBMIT_PAYMENT})}async fetchSession(){const n=`${this.configService.getConfig("stargateUrl",this.environment)}/api/sessions/${this.options.sessionUuid}/gateway-url${this.options.locale?`?preferredLocale=${this.options.locale}`:""}`;return console.log("MONTONIO-JS: fetchSession: Fetching iframe URL from:",n),await this.httpService.get(n)}setUpListeners(){console.log("MONTONIO-JS: setUpListeners: Setting up listeners"),this.setUpFormChangeListener(),this.setUpPaymentCompletedListener(),this.setUpPaymentFailedListener(),this.setUpValidationListener(),this.setUpActionRequiredListener(),this.setUpPaymentAuthListener(),this.setUpRedirectListener()}setUpRedirectListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_REDIRECT,t=>{window.location.href=t.payload.redirectUrl},this.iframe)}setUpActionRequiredListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_ACTION_REQUIRED,t=>{this.handleActionRequired(t.payload)},this.iframe)}setUpFormChangeListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FORM_CHANGED,t=>{this.isValid=t.payload.isValid},this.iframe)}setUpPaymentCompletedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,async t=>{console.log("MONTONIO-JS: CHECKOUT_PAYMENT_COMPLETED (from main iframe)",t),this.cleanupPaymentAuth();try{const n=await this.getPaymentResult(t.payload.paymentIntentUuid);this.handlePaymentSuccess(n)}catch(n){this.handlePaymentError(n)}},this.iframe)}setUpPaymentFailedListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,t=>{console.error("MONTONIO-JS: CHECKOUT_PAYMENT_FAILED (from main iframe)",t),this.cleanupPaymentAuth(),this.messagingService.postMessage(this.iframe,{name:m.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_FAILED_DATA,payload:t.payload}),this.handlePaymentError(new or(t.payload))},this.iframe)}setUpValidationListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS_RESULT,t=>{console.log("MONTONIO-JS: CHECKOUT_VALIDATE_FIELDS_RESULT",t),t.payload.isValid||this.handlePaymentError(new Pt)},this.iframe)}setUpPaymentAuthListener(){this.messagingService.subscribe(m.MessageTypeEnum.CHECKOUT_START_PAYMENT_AUTH,async t=>{try{console.log("MONTONIO-JS: PAYMENT_AUTH_STARTED",t),this.paymentAuth=new Tc({paymentAuthData:t.payload.paymentAuthData}),await this.paymentAuth.initialize();const n=this.paymentAuth.iframe;this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,n),this.messagingService.addIframeToSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,n)}catch(n){this.handlePaymentError(n)}},this.iframe)}async getPaymentResult(t){const r=`${this.configService.getConfig("stargateUrl",this.environment)}/api/payment-intents/${t}/return-url`,o=10,s=1e3;let i=0;for(;i<o;){try{console.log("MONTONIO-JS: getPaymentResult: Fetching return URL from:",r);const c=await this.httpService.get(r);if(i++,c!=null&&c.merchantReturnUrl)return{returnUrl:c.merchantReturnUrl,orderToken:c.orderToken,paymentStatus:c.paymentStatus}}catch(c){console.error("MONTONIO-JS: getPaymentResult: Error fetching return URL:",c)}i<o&&await new Promise(c=>setTimeout(c,s))}throw new sr({attempts:i})}cleanupPaymentAuth(){this.paymentAuth&&(this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,this.paymentAuth.iframe),this.messagingService.removeIframeFromSubscription(m.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,this.paymentAuth.iframe),this.paymentAuth.cleanup(),this.paymentAuth=null)}handlePaymentSuccess(t){this.options.onSuccess(t),console.log("MONTONIO-JS: handlePaymentSuccess: onSuccess callback called with result:",t)}handlePaymentError(t){this.options.onError(t),console.error("MONTONIO-JS: handlePaymentError: onError callback called with error:",t)}handleActionRequired(t){this.options.onActionRequired&&(this.options.onActionRequired(t),console.log("MONTONIO-JS: handleActionRequired: onActionRequired callback called with payload:",t))}}m.MontonioCheckout=Oc,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
|
13
|
+
${f}`),e.finish(C=>{g(Fn(C))})}return{flushController:n,add:u,upsert:u,stop:s.unsubscribe}}function Fn(e){let t;return typeof e.output=="string"?t=e.output:t=new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function Hn({messagesLimit:e,bytesLimit:t,durationLimit:n,pageMayExitObservable:r,sessionExpireObservable:o}){const s=r.subscribe(g=>d(g.reason)),i=o.subscribe(()=>d("session_expire")),c=new S(()=>()=>{s.unsubscribe(),i.unsubscribe()});let a=0,u=0;function d(g){if(u===0)return;const C=u,_=a;u=0,a=0,m(),c.notify({reason:g,messagesCount:C,bytesCount:_})}let l;function f(){l===void 0&&(l=_e(()=>{d("duration_limit")},n))}function m(){Yt(l),l=void 0}return{flushObservable:c,get messagesCount(){return u},notifyBeforeAddMessage(g){a+g>=t&&d("bytes_limit"),u+=1,a+=g,f()},notifyAfterAddMessage(g=0){a+=g,u>=e?d("messages_limit"):a>=t&&d("bytes_limit")},notifyAfterRemoveMessage(g){a-=g,u-=1,u===0&&m()}}}const ge="DISCARDED",te="SKIPPED";function Is(){const e={};return{register(t,n){return e[t]||(e[t]=[]),e[t].push(n),{unregister:()=>{e[t]=e[t].filter(r=>r!==n)}}},triggerHook(t,n){const r=e[t]||[],o=[];for(const s of r){const i=s(n);if(i===ge)return ge;i!==te&&o.push(i)}return ee(...o)}}}const ne={LOG:"log",CONFIGURATION:"configuration",USAGE:"usage"},Ls=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],xs=1,ks=[lo];let Ct;function Oe(){return Ct||(Ct=new Wt(100)),Ct}function Ns(e,t,n,r,o,s){const i=new S,{stop:c}=Ps(t,r,o,s,i),{enabled:a,metricsEnabled:u}=Us(e,t,n,i);return{stop:c,enabled:a,metricsEnabled:u}}function Us(e,t,n,r,o=xs){const s={},i=!ks.includes(t.site)&&Se(t.telemetrySampleRate),c={[ne.LOG]:i,[ne.CONFIGURATION]:i&&Se(t.telemetryConfigurationSampleRate),[ne.USAGE]:i&&Se(t.telemetryUsageSampleRate),metric:i&&Se(o)},a=Ds(),u=Oe();return u.subscribe(({rawEvent:l,metricName:f})=>{if(f&&!c.metric||!c[l.type])return;const m=f||l.status||l.type;let g=s[m];if(g||(g=s[m]=new Set),g.size>=t.maxTelemetryEventsPerPage)return;const C=ve(l);if(g.has(C))return;const _=n.triggerHook(1,{startTime:k().relative});if(_===ge)return;const G=d(_,e,l,a);r.notify(G),wn("telemetry",G),g.add(C)}),u.unbuffer(),gr($s),{enabled:i,metricsEnabled:c.metric};function d(l,f,m,g){const _={type:"telemetry",date:k().timeStamp,service:f,version:"6.22.0",source:"browser",_dd:{format_version:2},telemetry:ee(m,{runtime_env:g,connectivity:ms(),sdk_setup:"npm"}),ddtags:vn(t).join(","),experimental_features:Array.from(Ro())};return ee(_,l)}}function Ps(e,t,n,r,o){const s=[];if(je()){const i=Tt(),c=o.subscribe(a=>i.send("internal_telemetry",a));s.push(c.unsubscribe)}else{const i=[e.rumEndpointBuilder];e.replica&&Ms(e)&&i.push(e.replica.rumEndpointBuilder);const c=$n({encoder:r(4),request:Dn(i,e.batchBytesLimit,t),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:n,sessionExpireObservable:new S}),messageBytesLimit:e.messageBytesLimit});s.push(c.stop);const a=o.subscribe(c.add);s.push(a.unsubscribe)}return{stop:()=>s.forEach(i=>i())}}function Ds(){var e;return{is_local_file:((e=L.location)===null||e===void 0?void 0:e.protocol)==="file:",is_worker:Y}}function Ms(e){return e.site===ao}function vt(e,t){nt(T.debug,e,t),Oe().notify({rawEvent:{type:ne.LOG,message:e,status:"debug",...t}})}function $s(e,t){Oe().notify({rawEvent:{type:ne.LOG,status:"error",...Bs(e),...t}})}function Fs(e){Oe().notify({rawEvent:{type:ne.CONFIGURATION,configuration:e}})}function Hs(e){Oe().notify({rawEvent:{type:ne.USAGE,usage:e}})}function Bs(e){if(J(e)){const t=fe(e);return{error:{kind:t.name,stack:me(Gs(t))},message:t.message}}return{error:{stack:Sn},message:`Uncaught ${ve(e)}`}}function Gs(e){return e.stack=e.stack.filter(t=>!t.url||Ls.some(n=>t.url.startsWith(n))),e}function Ks(e){const t=new Set;return e.forEach(n=>t.add(n)),Array.from(t)}function Bn(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}const Ve=1/0,js=M;let we=null;const ze=new Set;function Ys(){ze.forEach(e=>e())}function Vs({expireDelay:e,maxEntries:t}){let n=[];we||(we=rt(()=>Ys(),js));const r=()=>{const d=Re()-e;for(;n.length>0&&n[n.length-1].endTime<d;)n.pop()};ze.add(r);function o(d,l){const f={value:d,startTime:l,endTime:Ve,remove:()=>{Bn(n,f)},close:m=>{f.endTime=m}};return t&&n.length>=t&&n.pop(),n.unshift(f),f}function s(d=Ve,l={returnInactive:!1}){for(const f of n)if(f.startTime<=d){if(l.returnInactive||d<=f.endTime)return f.value;break}}function i(d){const l=n[0];l&&l.endTime===Ve&&l.close(d)}function c(d=Ve,l=0){const f=fr(d,l);return n.filter(m=>m.startTime<=f&&d<=m.endTime).map(m=>m.value)}function a(){n=[]}function u(){ze.delete(r),ze.size===0&&we&&(Vt(we),we=null)}return{add:o,find:s,closeActive:i,findAll:c,reset:a,stop:u}}const zs="datadog-synthetics-public-id",qs="datadog-synthetics-result-id",Ws="datadog-synthetics-injects-rum";function Gn(){return Y?!1:!!(L._DATADOG_SYNTHETICS_INJECTS_RUM||V(Ws))}function Xs(){const e=window._DATADOG_SYNTHETICS_PUBLIC_ID||V(zs);return typeof e=="string"?e:void 0}function Js(){const e=window._DATADOG_SYNTHETICS_RESULT_ID||V(qs);return typeof e=="string"?e:void 0}function Zs(){return!!(Xs()&&Js())}const Qs=M,ei=ut;function ti(e,t,n,r){const o=new S,s=new S,i=eo(e.sessionStoreStrategyType,e,t,n),c=Vs({expireDelay:ei});if(i.renewObservable.subscribe(()=>{c.add(a(),Re()),o.notify()}),i.expireObservable.subscribe(()=>{s.notify(),c.closeActive(Re())}),i.expandOrRenewSession(),c.add(a(),dr().relative),Ao(Fe.SHORT_SESSION_INVESTIGATION)){const u=i.getSession();u&&ii(e,u)}r.observable.subscribe(()=>{r.isGranted()?i.expandOrRenewSession():i.expire()}),ni(e,()=>{r.isGranted()&&i.expandOrRenewSession()}),ri(e,()=>i.expandSession()),oi(e,()=>i.restartSession());function a(){const u=i.getSession();return u?{id:u.id,trackingType:u[t],isReplayForced:!!u.forcedReplay,anonymousId:u.anonymousId}:(si().catch(()=>{}),{id:"invalid",trackingType:en,isReplayForced:!1,anonymousId:void 0})}return{findSession:(u,d)=>c.find(u,d),renewObservable:o,expireObservable:s,sessionStateUpdateObservable:i.sessionStateUpdateObservable,expire:i.expire,updateSessionState:i.updateSessionState}}function ni(e,t){const{stop:n}=St(e,window,["click","touchstart","keydown","scroll"],t,{capture:!0,passive:!0})}function ri(e,t){const n=()=>{document.visibilityState==="visible"&&t()},{stop:r}=Z(e,document,"visibilitychange",n);rt(n,Qs)}function oi(e,t){const{stop:n}=Z(e,window,"resume",t,{capture:!0})}async function si(){const e=an();vt("Unexpected session state",{session:e,isSyntheticsTest:Zs(),createdTimestamp:e==null?void 0:e.created,expireTimestamp:e==null?void 0:e.expire,cookie:await Kn(),currentDomain:`${window.location.protocol}//${window.location.hostname}`})}function ii(e,t){if(!window.cookieStore||!t.created)return;const n=Number(t.created),r=$(),{stop:o}=Z(e,cookieStore,"change",s);function s(i){const c=Ir(i.changed,u=>u.name===B);if(!c)return;const a=$()-n;if(a>14*M)o();else{const u=dt(c.value);if(u.id&&u.id!==t.id){o();const d=$()-r;Kn().then(l=>{vt("Session cookie changed",{time:d,session_age:a,old:t,new:u,cookie:l})}).catch(tt)}}}}async function Kn(){let e;return"cookieStore"in window?e=await window.cookieStore.getAll(B):e=document.cookie.split(/\s*;\s*/).filter(t=>t.startsWith(B)),{count:e.length,domain:Zt()||"undefined",...e}}function jn(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,r){const o=Gt(n);t+=o,e+=n,r&&r(o)},finish(n){n(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(n){return n.length}}}class ci{constructor(){this.callbacks={}}notify(t,n){const r=this.callbacks[t];r&&r.forEach(o=>o(n))}subscribe(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),{unsubscribe:()=>{this.callbacks[t]=this.callbacks[t].filter(r=>n!==r)}}}}function ai(e,t,n){let r=0,o=!1;return{isLimitReached(){if(r===0&&_e(()=>{r=0},M),r+=1,r<=t||o)return o=!1,!1;if(r===t+1){o=!0;try{n({message:`Reached max number of ${e}s by minute: ${t}`,source:A.AGENT,startClocks:k()})}finally{o=!1}}return!0}}}let Ot;const wt=new WeakMap;function ui(e){return Ot||(Ot=li(e)),Ot}function li(e){return new S(t=>{const{stop:n}=X(XMLHttpRequest.prototype,"open",di),{stop:r}=X(XMLHttpRequest.prototype,"send",s=>{fi(s,e,t)},{computeHandlingStack:!0}),{stop:o}=X(XMLHttpRequest.prototype,"abort",hi);return()=>{n(),r(),o()}})}function di({target:e,parameters:[t,n]}){wt.set(e,{state:"open",method:String(t).toUpperCase(),url:ot(String(n))})}function fi({target:e,parameters:[t],handlingStack:n},r,o){const s=wt.get(e);if(!s)return;const i=s;i.state="start",i.startClocks=k(),i.isAborted=!1,i.xhr=e,i.handlingStack=n,i.body=t;let c=!1;const{stop:a}=X(e,"onreadystatechange",()=>{e.readyState===XMLHttpRequest.DONE&&u()}),u=()=>{if(d(),a(),c)return;c=!0;const l=s;l.state="complete",l.duration=Ft(i.startClocks.timeStamp,U()),l.status=e.status,o.notify(pr(l))},{stop:d}=Z(r,e,"loadend",u);o.notify(i)}function hi({target:e}){const t=wt.get(e);t&&(t.isAborted=!0)}let At;function Yn(){return At||(At=mi()),At}function mi(){return new S(e=>{if(!L.fetch)return;const{stop:t}=X(L,"fetch",n=>pi(n,e),{computeHandlingStack:!0});return t})}function pi({parameters:e,onPostCall:t,handlingStack:n},r){const[o,s]=e;let i=s&&s.method;i===void 0&&o instanceof Request&&(i=o.method);const c=i!==void 0?String(i).toUpperCase():"GET",a=o instanceof Request?o.url:ot(String(o)),u=k(),d={state:"start",init:s,input:o,method:c,startClocks:u,url:a,handlingStack:n};r.notify(d),e[0]=d.input,e[1]=d.init,t(l=>gi(r,l,d))}function gi(e,t,n){const r=n;function o(s){r.state="resolve",Object.assign(r,s),e.notify(r)}t.then(b(s=>{o({response:s,responseType:s.type,status:s.status,isAborted:!1})}),b(s=>{var i,c;o({status:0,isAborted:((c=(i=r.init)===null||i===void 0?void 0:i.signal)===null||c===void 0?void 0:c.aborted)||s instanceof DOMException&&s.code===DOMException.ABORT_ERR,error:s})}))}let Rt={};function Ei(e){const t=e.map(n=>(Rt[n]||(Rt[n]=yi(n)),Rt[n]));return qt(...t)}function yi(e){return new S(t=>{const n=x[e];return x[e]=(...r)=>{n.apply(console,r);const o=Be("console error");ue(()=>{t.notify(bi(r,e,o))})},()=>{x[e]=n}})}function bi(e,t,n){const r=e.map(o=>Si(o)).join(" ");if(t===T.error){const o=e.find(J),s=bt({originalError:o,handlingStack:n,startClocks:k(),source:A.CONSOLE,handling:"handled",nonErrorPrefix:"Provided",useFallbackStack:!1});return s.message=r,{api:t,message:r,handlingStack:n,error:s}}return{api:t,message:r,error:void 0,handlingStack:n}}function Si(e){return typeof e=="string"?P(e):J(e)?bn(fe(e)):ve(P(e),void 0,2)}const _i=500;function Ti(){const e=[];return{add:o=>{e.push(o)>_i&&e.splice(0,1)},remove:o=>{Bn(e,o)},drain:o=>{e.forEach(s=>s(o)),e.length=0}}}function Ci(e){const t=pn(e)==="object";return t||y.error("Unsupported context:",e),t}function It(e,t,n){const r={...e};for(const[o,{required:s,type:i}]of Object.entries(t))i==="string"&&!Vn(r[o])&&(r[o]=String(r[o])),s&&Vn(r[o])&&y.warn(`The property ${o} of ${n} is required; context will not be sent to the intake.`);return r}function Vn(e){return e==null||e===""}function qe(e="",{propertiesConfig:t={}}={}){let n={};const r=new S,o={getContext:()=>An(n),setContext:s=>{Ci(s)?n=P(It(s,t,e)):o.clearContext(),r.notify()},setContextProperty:(s,i)=>{n=P(It({...n,[s]:i},t,e)),r.notify()},removeContextProperty:s=>{delete n[s],It(n,t,e),r.notify()},clearContext:()=>{n={},r.notify()},changeObservable:r};return o}function O(e,t,n,r){return b((...o)=>e()[t][n](...o))}function Lt(e,t,n){e.changeObservable.subscribe(()=>{const r=e.getContext();n.add(o=>o[t].setContext(r))})}const vi="_dd_c",Oi=[];function xt(e,t,n,r){const o=wi(n,r);Oi.push(Z(e,window,"storage",({key:u})=>{o===u&&i()})),t.changeObservable.subscribe(c);const s=ee(a(),t.getContext());Ie(s)||t.setContext(s);function i(){t.setContext(a())}function c(){localStorage.setItem(o,JSON.stringify(t.getContext()))}function a(){const u=localStorage.getItem(o);return u?JSON.parse(u):{}}}function wi(e,t){return`${vi}_${e}_${t}`}function Ai(e,t,n){const r=zn();return t.storeContextsAcrossPages&&xt(t,r,n,4),e.register(0,()=>{const o=r.getContext();return Ie(o)||!o.id?te:{account:o}}),r}function zn(){return qe("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}function Ri(e,t,n,r){const o=qn();return t.storeContextsAcrossPages&&xt(t,o,n,2),e.register(0,()=>o.getContext()),o}function qn(){return qe("global context")}function Ii(e,t,n,r){const o=Wn();return t.storeContextsAcrossPages&&xt(t,o,r,1),e.register(0,({eventType:s,startTime:i})=>{const c=o.getContext(),a=n.findTrackedSession(i);return a&&a.anonymousId&&!c.anonymous_id&&t.trackAnonymousUser&&(c.anonymous_id=a.anonymousId),Ie(c)?te:{type:s,usr:c}}),e.register(1,({startTime:s})=>{var i;return{anonymous_id:(i=n.findTrackedSession(s))===null||i===void 0?void 0:i.anonymousId}}),o}function Wn(){return qe("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}const v={userContext:"userContext",globalContext:"globalContext",accountContext:"accountContext"},w={getContext:"getContext",setContext:"setContext",setContextProperty:"setContextProperty",removeContextProperty:"removeContextProperty",clearContext:"clearContext"};function Li(e,t,n){const r=e.getReader(),o=[];let s=0;i();function i(){r.read().then(b(a=>{if(a.done){c();return}o.push(a.value),s+=a.value.length,s>n.bytesLimit?c():i()}),b(a=>t(a)))}function c(){r.cancel().catch(F);let a,u;{let d;if(o.length===1)d=o[0];else{d=new Uint8Array(s);let l=0;o.forEach(f=>{d.set(f,l),l+=f.length})}a=d.slice(0,n.bytesLimit),u=d.length>n.bytesLimit}t(void 0,a,u)}}const Xn={XHR:"xhr",FETCH:"fetch"},kt={FETCH:Xn.FETCH,XHR:Xn.XHR},xi=500;function ki(e=es){const t=new Wt(xi),n=e().subscribe(r=>{t.notify({type:0,error:r})});return{observable:t,stop:()=>{n.unsubscribe()}}}function We(e,t,n){const r=n.getHandler(),o=Array.isArray(r)?r:[r];return Jn[e]>=Jn[n.getLevel()]&&o.includes(t)}const p={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Jn={[p.ok]:0,[p.debug]:1,[p.info]:2,[p.notice]:4,[p.warn]:5,[p.error]:6,[p.critical]:7,[p.alert]:8,[p.emerg]:9};function Xe(e,{includeMessage:t=!1}={}){return{stack:e.stack,kind:e.type,message:t?e.message:void 0,causes:e.causes,fingerprint:e.fingerprint,handling:e.handling}}var Ni=function(e,t,n,r){var o=arguments.length,s=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};const Ae={console:"console",http:"http"},Ui=Object.keys(p);class R{constructor(t,n,r=Ae.http,o=p.debug,s={}){this.handleLogStrategy=t,this.handlerType=r,this.level=o,this.contextManager=qe("logger"),this.tags=[],this.contextManager.setContext(s),n&&this.contextManager.setContextProperty("logger",{name:n})}logImplementation(t,n,r=p.info,o,s){const i=P(n);let c;if(o!=null){const a=bt({originalError:o,nonErrorPrefix:"Provided",source:A.LOGGER,handling:"handled",startClocks:k()});c=ee({error:Xe(a,{includeMessage:!0})},a.context,i)}else c=i;this.handleLogStrategy({message:P(t),context:c,status:r},this,s)}log(t,n,r=p.info,o){let s;We(r,Ae.http,this)&&(s=Be("log")),this.logImplementation(t,n,r,o,s)}setContext(t){this.contextManager.setContext(t)}getContext(){return this.contextManager.getContext()}setContextProperty(t,n){this.contextManager.setContextProperty(t,n)}removeContextProperty(t){this.contextManager.removeContextProperty(t)}clearContext(){this.contextManager.clearContext()}addTag(t,n){this.tags.push(Q(t,n))}removeTagsWithKey(t){const n=On(t);this.tags=this.tags.filter(r=>r!==n&&!r.startsWith(`${n}:`))}getTags(){return this.tags.slice()}setHandler(t){this.handlerType=t}getHandler(){return this.handlerType}setLevel(t){this.level=t}getLevel(){return this.level}}Ni([yr],R.prototype,"logImplementation",null),R.prototype.ok=D(p.ok),R.prototype.debug=D(p.debug),R.prototype.info=D(p.info),R.prototype.notice=D(p.notice),R.prototype.warn=D(p.warn),R.prototype.error=D(p.error),R.prototype.critical=D(p.critical),R.prototype.alert=D(p.alert),R.prototype.emerg=D(p.emerg);function D(e){return function(t,n,r){let o;We(e,Ae.http,this)&&(o=Be("log")),this.logImplementation(t,n,e,r,o)}}function Zn(){return Y?{}:{view:{referrer:document.referrer,url:window.location.href}}}const Pi=32*ce;function Di(e,t){e.usePciIntake===!0&&e.site&&e.site!=="datadoghq.com"&&y.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const n=Co(e,t),r=Qn(e.forwardConsoleLogs,Ue(T),"Forward Console Logs"),o=Qn(e.forwardReports,Ue(Ge),"Forward Reports");if(!(!n||!r||!o))return e.forwardErrorsToLogs&&!r.includes(T.error)&&r.push(T.error),{forwardErrorsToLogs:e.forwardErrorsToLogs!==!1,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Pi,...n}}function Qn(e,t,n){if(e===void 0)return[];if(!(e==="all"||Array.isArray(e)&&e.every(r=>t.includes(r)))){y.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`);return}return e==="all"?t:Ks(e)}function Mi(e){const t=vo(e);return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}function $i(e,t,n){const r=Ti(),o=qn();Lt(o,v.globalContext,r);const s=zn();Lt(s,v.accountContext,r);const i=Wn();Lt(i,v.userContext,r);let c,a;const u=t.observable.subscribe(d);function d(){if(!a||!c||!t.isGranted())return;u.unsubscribe();const l=n(c,a);r.drain(l)}return{init(l,f){if(!l){y.error("Missing configuration");return}if(Oo(l.enableExperimentalFeatures),je()&&(l=Fi(l)),c=l,Fs(Mi(l)),a){_n("DD_LOGS",l);return}const m=Di(l,f);m&&(a=m,Yn().subscribe(F),t.tryToInit(m.trackingConsent),d())},get initConfiguration(){return c},globalContext:o,accountContext:s,userContext:i,getInternalContext:F,handleLog(l,f,m,g=e(),C=U()){r.add(_=>_.handleLog(l,f,m,g,C))}}}function Fi(e){return{...e,clientToken:"empty"}}function Hi(e){const t=to(),n=ki().observable;let r=$i(Zn,t,(c,a)=>{const u=e(a,Zn,t,n);return r=Bi(c,u),u});const o=()=>r,s={},i=new R((...c)=>r.handleLog(...c));return rs({logger:i,init:c=>{const a=new Error().stack;ue(()=>r.init(c,a))},setTrackingConsent:b(c=>{t.update(c),Hs({feature:"set-tracking-consent",tracking_consent:c})}),getGlobalContext:O(o,v.globalContext,w.getContext),setGlobalContext:O(o,v.globalContext,w.setContext),setGlobalContextProperty:O(o,v.globalContext,w.setContextProperty),removeGlobalContextProperty:O(o,v.globalContext,w.removeContextProperty),clearGlobalContext:O(o,v.globalContext,w.clearContext),createLogger:b((c,a={})=>(s[c]=new R((...u)=>r.handleLog(...u),P(c),a.handler,a.level,P(a.context)),s[c])),getLogger:b(c=>s[c]),getInitConfiguration:b(()=>An(r.initConfiguration)),getInternalContext:b(c=>r.getInternalContext(c)),setUser:O(o,v.userContext,w.setContext),getUser:O(o,v.userContext,w.getContext),setUserProperty:O(o,v.userContext,w.setContextProperty),removeUserProperty:O(o,v.userContext,w.removeContextProperty),clearUser:O(o,v.userContext,w.clearContext),setAccount:O(o,v.accountContext,w.setContext),getAccount:O(o,v.accountContext,w.getContext),setAccountProperty:O(o,v.accountContext,w.setContextProperty),removeAccountProperty:O(o,v.accountContext,w.removeContextProperty),clearAccount:O(o,v.accountContext,w.clearContext)})}function Bi(e,t){return{init:n=>{_n("DD_LOGS",n)},initConfiguration:e,...t}}const Gi="logs";function Ki(e,t){const n=ti(e,Gi,r=>er(e,r),t);return{findTrackedSession:(r,o={returnInactive:!1})=>{const s=n.findSession(r,o);return s&&s.trackingType==="1"?{id:s.id,anonymousId:s.anonymousId}:void 0},expireObservable:n.expireObservable}}function ji(e){const n=er(e)==="1"?{}:void 0;return{findTrackedSession:()=>n,expireObservable:new S}}function er(e,t){return Yi(t)?t:Se(e.sessionSampleRate)?"1":"0"}function Yi(e){return e==="0"||e==="1"}function Vi(e,t,n,r,o){const s=Ui.concat(["custom"]),i={};s.forEach(c=>{i[c]=ai(c,e.eventRateLimiterThreshold,o)}),t.subscribe(0,({rawLogsEvent:c,messageContext:a=void 0,savedCommonContext:u=void 0,domainContext:d,ddtags:l=[]})=>{var f,m;const g=hr(c.date),C=u||r(),_=n.triggerHook(0,{startTime:g});if(_===ge)return;const G=vn(e),ye=ee({view:C.view},_,c,a,{ddtags:G.concat(l).join(",")});((f=e.beforeSend)===null||f===void 0?void 0:f.call(e,ye,d))===!1||ye.origin!==A.AGENT&&((m=i[ye.status])!==null&&m!==void 0?m:i.custom).isLimitReached()||t.notify(1,ye)})}const zi={[T.log]:p.info,[T.debug]:p.debug,[T.info]:p.info,[T.warn]:p.warn,[T.error]:p.error};function qi(e,t){const n=Ei(e.forwardConsoleLogs).subscribe(r=>{var o;const s={rawLogsEvent:{date:U(),message:r.message,origin:A.CONSOLE,error:r.error&&Xe(r.error),status:zi[r.api]},messageContext:(o=r.error)===null||o===void 0?void 0:o.context,domainContext:{handlingStack:r.handlingStack}};t.notify(0,s)});return{stop:()=>{n.unsubscribe()}}}function Wi(e,t){const n=ss(e,e.forwardReports).subscribe(r=>{let o=r.message,s;const i=r.originalError.type==="deprecation"?p.warn:p.error;i===p.error?s=Xe(r):r.stack&&(o+=` Found in ${Zo(r.stack)}`),t.notify(0,{rawLogsEvent:{date:U(),message:o,origin:A.REPORT,error:s,status:i}})});return{stop:()=>{n.unsubscribe()}}}function Xi(e,t){if(!e.forwardErrorsToLogs)return{stop:F};const n=(Y?new S:ui(e)).subscribe(s=>{s.state==="complete"&&o(kt.XHR,s)}),r=Yn().subscribe(s=>{s.state==="resolve"&&o(kt.FETCH,s)});function o(s,i){!_o(i.url)&&(ec(i)||Rn(i.status))&&("xhr"in i?Ji(i.xhr,e,c):i.response?Qi(i.response,e,c):i.error&&Zi(i.error,e,c));function c(a){const u={isAborted:i.isAborted,handlingStack:i.handlingStack};t.notify(0,{rawLogsEvent:{message:`${tc(s)} error ${i.method} ${i.url}`,date:i.startClocks.timeStamp,error:{stack:a||"Failed to load",handling:void 0},http:{method:i.method,status_code:i.status,url:i.url},status:p.error,origin:A.NETWORK},domainContext:u})}}return{stop:()=>{n.unsubscribe(),r.unsubscribe()}}}function Ji(e,t,n){typeof e.response=="string"?n(Nt(e.response,t)):n(e.response)}function Zi(e,t,n){n(Nt(me(fe(e)),t))}function Qi(e,t,n){const r=ps(e);!r||!r.body?n():window.TextDecoder?nc(r.body,t.requestErrorResponseLengthLimit,(o,s)=>{n(o?`Unable to retrieve response: ${o}`:s)}):r.text().then(b(o=>n(Nt(o,t))),b(o=>n(`Unable to retrieve response: ${o}`)))}function ec(e){return e.status===0&&e.responseType!=="opaque"}function Nt(e,t){return e.length>t.requestErrorResponseLengthLimit?`${e.substring(0,t.requestErrorResponseLengthLimit)}...`:e}function tc(e){return kt.XHR===e?"XHR":"Fetch"}function nc(e,t,n){Li(e,(r,o,s)=>{if(r)n(r);else{let i=new TextDecoder().decode(o);s&&(i+="..."),n(void 0,i)}},{bytesLimit:t})}function rc(e,t,n){if(!e.forwardErrorsToLogs)return{stop:F};const r=n.subscribe(o=>{if(o.type===0){const s=o.error;t.notify(0,{rawLogsEvent:{message:s.message,date:s.startClocks.timeStamp,error:Xe(s),origin:A.SOURCE,status:p.error},messageContext:s.context})}});return{stop:()=>{r.unsubscribe()}}}const oc=ci;function sc(e){function t(n,r,o,s,i){const c=ee(r.getContext(),n.context);if(We(n.status,Ae.console,r)&&cc(n,c),We(n.status,Ae.http,r)){const a={rawLogsEvent:{date:i||U(),message:n.message,status:n.status,origin:A.LOGGER},messageContext:c,savedCommonContext:s,ddtags:r.getTags()};o&&(a.domainContext={handlingStack:o}),e.notify(0,a)}}return{handleLog:t}}const ic={[p.ok]:T.debug,[p.debug]:T.debug,[p.info]:T.info,[p.notice]:T.info,[p.warn]:T.warn,[p.error]:T.error,[p.critical]:T.error,[p.alert]:T.error,[p.emerg]:T.error};function cc({status:e,message:t},n){j[ic[e]].call(x,t,n)}function ac(e,t,n,r,o){const s=[e.logsEndpointBuilder];e.replica&&s.push(e.replica.logsEndpointBuilder);const i=$n({encoder:jn(),request:Dn(s,e.batchBytesLimit,n),flushController:Hn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageMayExitObservable:r,sessionExpireObservable:o.expireObservable}),messageBytesLimit:e.messageBytesLimit});return t.subscribe(1,c=>{i.add(c)}),i}function uc(e){const t=Tt();e.subscribe(1,n=>{t.send("log",n)})}function lc(e){return{get:t=>{const n=e.findTrackedSession(t);if(n)return{session_id:n.id}}}}function dc(e){return t=>{e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:A.AGENT,status:p.error}}),vt("Error reported to customer",{"error.message":t.message})}}const fc=Is;function hc(e){const t=L;e.register(0,({startTime:o})=>{const s=n(o);return s||te}),e.register(1,({startTime:o})=>{var s,i;const c=n(o);return c?{application:{id:c.application_id},view:{id:(s=c.view)===null||s===void 0?void 0:s.id},action:{id:(i=c.user_action)===null||i===void 0?void 0:i.id}}:te});function n(o){const i=Gn()?t.DD_RUM_SYNTHETICS:t.DD_RUM,c=r(o,i);if(c)return c}function r(o,s){if(s&&s.getInternalContext)return s.getInternalContext(o)}}function mc(e,t,n){e.register(0,({startTime:r})=>{const o=n.findTrackedSession(r);return n.findTrackedSession(r,{returnInactive:!0})?{service:t.service,session_id:o?o.id:void 0,session:o?{id:o.id}:void 0}:ge}),e.register(1,({startTime:r})=>{const o=n.findTrackedSession(r);return!o||!o.id?te:{session:{id:o.id}}})}function pc(e,t){function n(){return t.isGranted()?te:ge}e.register(0,n),e.register(1,n)}const Ut="logs";function gc(e,t,n,r){const o=new oc,s=fc(),i=[];o.subscribe(1,_=>wn("logs",_));const c=dc(o),a=Y?new S:As(e),u=Ns("browser-logs-sdk",e,s,c,a,jn);i.push(u.stop);const d=e.sessionStoreStrategyType&&!je()&&!Gn()?Ki(e,n):ji(e);pc(s,n),mc(s,e,d);const l=Ai(s,e,Ut),f=Ii(s,e,d,Ut),m=Ri(s,e,Ut);hc(s),Xi(e,o),rc(e,o,r),r.unbuffer(),qi(e,o),Wi(e,o);const{handleLog:g}=sc(o);if(Vi(e,o,s,t,c),je())uc(o);else{const{stop:_}=ac(e,o,c,a,d);i.push(()=>_())}const C=lc(d);return{handleLog:g,getInternalContext:C.get,accountContext:l,globalContext:m,userContext:f,stop:()=>{i.forEach(_=>_())}}}const re=Hi(gc);os(I(),"DD_LOGS",re),h.Environment=void 0,function(e){e.DEVELOPMENT="development",e.PRODUCTION="production",e.SANDBOX="sandbox",e.PRELIVE_SANDBOX="prelive-sandbox",e.PRELIVE_PRODUCTION="prelive-production"}(h.Environment||(h.Environment={}));class Pt{constructor(t){this.context=t,this.logPrefix="MONTONIO-JS"}info(t,n){console.log(`${this.logPrefix}, ${this.context}: ${t}`,...n?[n]:[]),re.logger.info(t,{context:this.context,...n})}warn(t,n){console.warn(`${this.logPrefix}, ${this.context}: ${t}`,...n?[n]:[]),re.logger.warn(t,{context:this.context,...n})}error(t,n){console.error(`${this.logPrefix}, ${this.context}: ${t}`,...n?[n]:[]),re.logger.error(t,{context:this.context,...n})}}class Ee{constructor(){this.initialized=!1,this.logger=new Pt("LoggingService"),this.configService=K.instance}static get instance(){return Ee._instance||(Ee._instance=new Ee),Ee._instance}initialize(t,n){if(this.initialized){try{re.setGlobalContextProperty("sessionUuid",n),this.logger.info(`Updated sessionUuid to [${n}]`,{sessionUuid:n})}catch(r){this.logger.error(`Error updating sessionUuid to [${n}]`,{error:r})}return}try{const r=this.configService.getConfig("datadogClientToken");re.init({clientToken:r,site:"datadoghq.eu",env:t===h.Environment.PRODUCTION?"live-production":"live-sandbox",service:"montonio-js",version:"1.1.7",silentMultipleInit:!0,forwardErrorsToLogs:!1,forwardConsoleLogs:[]}),re.setGlobalContext({sessionUuid:n}),this.logger.info(`Set sessionUuid to [${n}]`,{sessionUuid:n}),this.initialized=!0}catch(r){console.error("Error initializing Datadog logs",r)}}}class tr{constructor(){this.logger=new Pt("MessagingService"),this.subscriptions=new Map,this.setupMessageListener()}subscribe(t,n,r){if(this.subscriptions.has(t))throw new Error(`Subscription for '${t}' already exists`);this.subscriptions.set(t,{handler:n,sources:[r]})}addIframeToSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);r.sources.includes(n)||r.sources.push(n)}waitForMessage(t,n,r=3e4){return new Promise((o,s)=>{const i=setTimeout(()=>{this.removeIframeFromSubscription(t,n),s(new Error(`Message ${t} timeout after ${r}ms`))},r);this.subscribe(t,c=>{clearTimeout(i),this.removeIframeFromSubscription(t,n),o(c)},n)})}postMessage(t,n,r="*"){t.getContentWindow().postMessage(n,r)}clearAllSubscriptions(){this.subscriptions.clear()}clearSubscriptionsExcept(t){for(const n of[...this.subscriptions.keys()])t.includes(n)||this.subscriptions.delete(n)}removeIframeFromSubscription(t,n){const r=this.subscriptions.get(t);if(!r)throw new Error(`Subscription for '${t}' not found`);r.sources=r.sources.filter(o=>o!==n),r.sources.length===0&&this.subscriptions.delete(t)}setupMessageListener(){window.addEventListener("message",t=>{try{if(!t.data||typeof t.data!="object"||!t.data.name)return;const n=t.data;this.subscriptions.forEach((r,o)=>{if(!(o!==n.name||!r.sources.some(i=>{try{return i.getContentWindow()===t.source}catch(c){return this.logger.error("Failed to resolve contentWindow for source",{error:c}),!1}})))try{r.handler(n)}catch(i){this.logger.error("Error in message handler",{error:i})}})}catch(n){this.logger.error("Error processing iframe message",{error:n})}})}}class nr{constructor(t){var n;this.defaultStyles={border:"none",display:"block",width:"100%",height:"100%"},this.options=t,this.resizeOnHeightChange=(n=t.resizeOnHeightChange)!==null&&n!==void 0?n:!0,this.element=document.createElement("iframe"),this.messagingService=new tr,this.setupIframe()}mount(){return this.options.mountElement.appendChild(this.element),this.resizeOnHeightChange&&this.startResizing(this.element),this.element}unmount(){this.element.contentWindow&&this.messagingService.clearAllSubscriptions(),this.element.parentNode&&this.element.parentNode.removeChild(this.element)}getContentWindow(){if(!this.element.contentWindow)throw new Error("Iframe contentWindow is not available. Make sure the iframe is mounted and loaded.");return this.element.contentWindow}startResizing(t){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_HEIGHT_CHANGED,n=>{t.style.height=n.payload.height+"px"},this)}setupIframe(){const{src:t,allow:n="camera; microphone; geolocation; payment",styles:r={}}=this.options;this.element.src=t,this.element.allow=n;const o={...this.defaultStyles,...r};Object.assign(this.element.style,o)}}class rr{constructor(){this.loaded=!1,this.mountElement=null,this._iframe=null,this.messagingService=new tr,this.httpService=se.instance,this.configService=K.instance}get iframe(){if(!this._iframe)throw new Error("Iframe not initialized");return this._iframe}set iframe(t){this._iframe=t}cleanup(){this.iframe&&(this.iframe.unmount(),this.iframe=null)}}function Ec(e){if(typeof e=="string"){const t=document.querySelector(e);if(!t||!(t instanceof HTMLElement))throw new Error(`Element not found: ${e}`);return t}return e}function yc(){const e=document.body.style.overflow||null;return document.body.style.overflow="hidden",{originalOverflow:e}}function bc(e){e?document.body.style.overflow=e:document.body.style.removeProperty("overflow")}h.ActionRequiredActionEnum=void 0,function(e){e.SCROLL_INTO_VIEW="scrollIntoView"}(h.ActionRequiredActionEnum||(h.ActionRequiredActionEnum={})),h.LocaleEnum=void 0,function(e){e.EN="en",e.ET="et",e.LT="lt",e.LV="lv",e.PL="pl",e.RU="ru",e.FI="fi"}(h.LocaleEnum||(h.LocaleEnum={}));var or;(function(e){e.PENDING="PENDING",e.AUTHORIZED="AUTHORIZED",e.PAID="PAID",e.PARTIALLY_REFUNDED="PARTIALLY_REFUNDED",e.REFUNDED="REFUNDED",e.VOIDED="VOIDED",e.ABANDONED="ABANDONED"})(or||(or={}));const Sc=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function _c(e){const t=[];if(!e)throw new Je(["CheckoutOptions object is required"]);if(e.sessionUuid===void 0||e.sessionUuid===null?t.push("sessionUuid is required"):typeof e.sessionUuid!="string"?t.push("sessionUuid must be a string"):Sc.test(e.sessionUuid)||t.push(`sessionUuid must be a valid UUID format. Received: '${e.sessionUuid}'`),e.onSuccess?typeof e.onSuccess!="function"&&t.push("onSuccess must be a function"):t.push("onSuccess callback is required"),e.onError?typeof e.onError!="function"&&t.push("onError must be a function"):t.push("onError callback is required"),e.locale!==void 0&&e.locale!==null){const n=Object.values(h.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(e.environment!==void 0&&e.environment!==null&&(Object.values(h.Environment).includes(e.environment)||t.push(`environment must be one of: production, sandbox. Received: '${e.environment}'`)),t.length>0)throw new Je(t)}function Tc(e){const t=[];if(e.locale!==void 0&&e.locale!==null){const n=Object.values(h.LocaleEnum);n.includes(e.locale)||t.push(`locale must be one of: ${n.join(", ")}. Received: '${e.locale}'`)}if(t.length>0)throw new Je(t)}class Cc extends rr{constructor(t){super(),this.originalBodyOverflow=null,this.options=t,this.mountElement=t.mountElement||document.body}async initialize(){try{if(this.options.paymentAuthData.type==="redirect"){await this.redirectViaPost(this.options.paymentAuthData);return}if(!this.options.paymentAuthData.embeddedUrl)throw new Error("Embedded URL is not set in paymentAuthData");const{originalOverflow:t}=yc();this.originalBodyOverflow=t,this.iframe=new nr({src:this.options.paymentAuthData.embeddedUrl,mountElement:this.mountElement,styles:{width:"100dvw",height:"100dvh",position:"fixed",top:"0",left:"0",zIndex:"2147483647"},resizeOnHeightChange:!1}),this.iframe.mount(),await this.messagingService.waitForMessage(h.MessageTypeEnum.CHECKOUT_PAYMENT_AUTH_COMPONENT_READY,this.iframe),this.messagingService.postMessage(this.iframe,{name:h.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_AUTH_DATA,payload:{paymentAuthData:this.options.paymentAuthData}}),this.loaded=!0}catch(t){throw this.cleanup(),t}}cleanup(){this.loaded&&bc(this.originalBodyOverflow),super.cleanup()}async redirectViaPost(t){if(!t.redirectUrl)throw new Error("Redirect URL is not set in paymentAuthData");const n=document.createElement("form");if(n.method=t.redirectMethod||"get",n.action=t.redirectUrl,n.style.display="none",t.formData)for(const[r,o]of Object.entries(t.formData)){const s=document.createElement("input");s.type="hidden",s.name=r,s.value=o,n.appendChild(s)}throw document.body.appendChild(n),n.submit(),await new Promise(r=>setTimeout(r,3e4)),new Error("Redirect timeout: Expected redirect to occur within 30 seconds")}}class vc extends rr{constructor(t){super(),this.isValid=!1,this.logger=new Pt("MontonioCheckout"),this.paymentAuth=null,this.options=t,this.environment=t.environment||h.Environment.PRODUCTION,Ee.instance.initialize(this.environment,this.options.sessionUuid),this.logger.info("Checkout created",t),_c(t)}async initialize(t){try{this.logger.info(`Mounting checkout to [${t}]`),this.mountElement=Ec(t);const n=await this.fetchSession();return this.iframe=new nr({src:n.url,mountElement:this.mountElement}),this.iframe.mount(),await this.messagingService.waitForMessage(h.MessageTypeEnum.CHECKOUT_PAYMENT_COMPONENT_READY,this.iframe),this.setUpListeners(),this.loaded=!0,this.logger.info(`Successfully mounted checkout to [${t}]`),!0}catch(n){throw this.logger.error(`Error mounting checkout to [${t}]`,{error:n}),this.cleanup(),n}}updateOptions(t){if(this.logger.info("Updating checkout options",t),!this.loaded)throw new oe;Tc(t),t.locale!==void 0&&(this.options.locale=t.locale,this.messagingService.postMessage(this.iframe,{name:h.MessageTypeEnum.CHECKOUT_CHANGE_LOCALE,payload:{locale:t.locale}}))}validateOrReject(){if(!this.isValid)throw this.messagingService.postMessage(this.iframe,{name:h.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS}),new Dt}submitPayment(){if(!this.loaded)throw new oe;this.messagingService.postMessage(this.iframe,{name:h.MessageTypeEnum.CHECKOUT_SUBMIT_PAYMENT})}async fetchSession(){const n=`${this.configService.getConfig("stargateUrl",this.environment)}/api/sessions/${this.options.sessionUuid}/gateway-url${this.options.locale?`?preferredLocale=${this.options.locale}`:""}`;return this.logger.info(`Fetching iframe URL from [${n}]`),await this.httpService.get(n)}setUpListeners(){this.logger.info("setUpListeners: Setting up listeners"),this.setUpFormChangeListener(),this.setUpPaymentCompletedListener(),this.setUpPaymentFailedListener(),this.setUpValidationListener(),this.setUpActionRequiredListener(),this.setUpPaymentAuthListener(),this.setUpRedirectListener()}setUpRedirectListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_REDIRECT,t=>{window.location.href=t.payload.redirectUrl},this.iframe)}setUpActionRequiredListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_ACTION_REQUIRED,t=>{this.handleActionRequired(t.payload)},this.iframe)}setUpFormChangeListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_PAYMENT_FORM_CHANGED,t=>{this.isValid=t.payload.isValid},this.iframe)}setUpPaymentCompletedListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,async t=>{this.logger.info("Checkout payment completed",t),this.cleanupPaymentAuth();try{const n=await this.getPaymentResult(t.payload.paymentIntentUuid);this.handlePaymentSuccess(n)}catch(n){this.handlePaymentError(n)}},this.iframe)}setUpPaymentFailedListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,t=>{this.logger.warn("Checkout payment failed",t),this.cleanupPaymentAuth(),this.messagingService.postMessage(this.iframe,{name:h.MessageTypeEnum.CHECKOUT_SEND_PAYMENT_FAILED_DATA,payload:t.payload}),this.handlePaymentError(new sr(t.payload))},this.iframe)}setUpValidationListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_VALIDATE_FIELDS_RESULT,t=>{this.logger.info("Checkout validate fields result",t),t.payload.isValid||this.handlePaymentError(new Dt)},this.iframe)}setUpPaymentAuthListener(){this.messagingService.subscribe(h.MessageTypeEnum.CHECKOUT_START_PAYMENT_AUTH,async t=>{try{this.logger.info("Payment auth started",t),this.paymentAuth=new Cc({paymentAuthData:t.payload.paymentAuthData}),await this.paymentAuth.initialize();const n=this.paymentAuth.iframe;this.messagingService.addIframeToSubscription(h.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,n),this.messagingService.addIframeToSubscription(h.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,n)}catch(n){this.handlePaymentError(n)}},this.iframe)}async getPaymentResult(t){const r=`${this.configService.getConfig("stargateUrl",this.environment)}/api/payment-intents/${t}/return-url`,o=10,s=1e3;let i=0;for(;i<o;){try{this.logger.info(`Fetching return URL from [${r}]`);const c=await this.httpService.get(r);if(i++,c!=null&&c.merchantReturnUrl)return{returnUrl:c.merchantReturnUrl,orderToken:c.orderToken,paymentStatus:c.paymentStatus}}catch(c){this.logger.error(`Error fetching return URL from [${r}]`,{error:c})}i<o&&await new Promise(c=>setTimeout(c,s))}throw new ir({attempts:i})}cleanupPaymentAuth(){this.paymentAuth&&(this.messagingService.removeIframeFromSubscription(h.MessageTypeEnum.CHECKOUT_PAYMENT_COMPLETED,this.paymentAuth.iframe),this.messagingService.removeIframeFromSubscription(h.MessageTypeEnum.CHECKOUT_PAYMENT_FAILED,this.paymentAuth.iframe),this.paymentAuth.cleanup(),this.paymentAuth=null)}handlePaymentSuccess(t){this.options.onSuccess(t),this.logger.info("Triggered onSuccess callback",t)}handlePaymentError(t){this.options.onError(t),this.logger.warn("Triggered onError callback",{error:t})}handleActionRequired(t){this.options.onActionRequired&&(this.options.onActionRequired(t),this.logger.info("Triggered onActionRequired callback",t))}}h.MontonioCheckout=vc,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
14
14
|
//# sourceMappingURL=montonio.umd.js.map
|