@abyss-project/monitor-browser 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkLRYKS5XRjs = require('./chunk-LRYKS5XR.js');var _chunkTJIA62OAjs = require('./chunk-TJIA62OA.js');var _chunk2TDEJLQ7js = require('./chunk-2TDEJLQ7.js');var _chunkKD6VO7IKjs = require('./chunk-KD6VO7IK.js');var Se=t=>t===null?null:typeof t=="string"&&t.trim()!==""?t:void 0;var be=50,D=class{constructor(){this.session={};this.pageViewId=null;this.page={}}add(e,s,n){if(s==null)return n(),!1;let r=!1,o=()=>{r=!0,n()},i={[String(e)]:s};return this.session=_chunkTJIA62OAjs.a.call(void 0, this.session,i,o,be),r||(this.page=_chunkTJIA62OAjs.a.call(void 0, this.page,i,o,be)),!r}hasAny(){return Object.keys(this.session).length>0}annotate(e){e.id!==this.pageViewId&&(this.pageViewId!==null&&(this.page={}),this.pageViewId=e.id),Object.keys(this.page).length>0&&(e.featureFlags={...this.page})}};var ze=64,we=(t,e,s,n)=>{if(typeof t!="string"||t.length===0||t.length>ze)return n(),null;let r={id:_chunk2TDEJLQ7js.k.call(void 0, ),type:"action",pageViewId:s,occurredAt:_chunk2TDEJLQ7js.a.call(void 0, Date.now()),name:t};if(e!==void 0){let o=_chunkTJIA62OAjs.a.call(void 0, {},e,n);Object.keys(o).length>0&&(r.attributes=o)}return r};var Je=["id","type","sessionId"],Ze=(t,e)=>t==null?e==null||["string","number","boolean"].includes(typeof e):Array.isArray(t)?Array.isArray(e):e!==null&&typeof e==typeof t,te=(t,e,s)=>{if(!e)return t;let n;try{n=e(JSON.parse(JSON.stringify(t)))}catch (e2){return s(),t}if(n===null)return null;if(!n||typeof n!="object"||Array.isArray(n))return s(),null;let r=t,o=n,i={};for(let a of Object.keys(r))if(Je.includes(a))i[a]=r[a];else if(Ze(r[a],o[a]))o[a]!==void 0&&(i[a]=o[a]);else return s(),null;return i};var et=/^([a-z][a-z0-9+.-]*:)\/\//i,tt=["url","blockedUri","sourceFile"],st=["route","referrerRoute","entryPath"],se=t=>{let{host:e,path:s}=_chunkKD6VO7IKjs.d.call(void 0, t);if(e===null)return s;let n=et.exec(t.trim());return`${n?n[1].toLowerCase():"https:"}//${e}${s}`},x=t=>_chunkKD6VO7IKjs.d.call(void 0, t).path,ne=t=>{let e=t;for(let s of tt)typeof e[s]=="string"&&(e[s]=se(e[s]));for(let s of st)typeof e[s]=="string"&&(e[s]=x(e[s]));return t};var nt=20,rt=256,ke='[data-abyss-privacy="hidden"]',ot=`${ke},[data-testid],[aria-label],button,a,input,select,textarea,summary,[role="button"],[role="link"]`,Ie=(t,e)=>{let s=t.getAttribute(e);return s===null?null:s.slice(0,rt)},re=t=>{var s,n;let e=(n=((s=t.closest(ke))!=null?s:t).closest(ot))!=null?n:t;return{tag:e.tagName.toLowerCase().slice(0,64),testId:Ie(e,"data-testid"),ariaLabel:Ie(e,"aria-label")}},q=class{constructor(){this.items=[];this.lastPageViewId=null}observe(e){e.type==="pageView"&&e.id!==this.lastPageViewId?(this.lastPageViewId=e.id,this.add({kind:"NAVIGATION",route:x(e.route)})):e.type==="request"&&e.kind!=="WEBSOCKET"&&e.kind!=="SSE"&&this.add({kind:"REQUEST",method:e.method,url:se(e.url),status:e.status})}click(e){e instanceof Element&&this.add({kind:"CLICK",element:re(e)})}snapshot(){return this.items.map(e=>({...e}))}add(e){this.items.push({...e,occurredAt:_chunk2TDEJLQ7js.a.call(void 0, Date.now())}),this.items.length>nt&&this.items.shift()}};var it=/^\s*at\s|@\S+:\d+/,at=t=>{var e,s;return(s=(e=(t!=null?t:"").split(`
2
- `).find(n=>it.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${at(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var ut=/^ResizeObserver loop/,dt=/^Script error\.?$/,lt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:_chunk2TDEJLQ7js.c.call(void 0, t),stack:null}},ct=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},pt=t=>ut.test(t.message)||dt.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=lt(e);if(pt(n)){this.host.drop();return}this.host.captured();let r=ct(s);this.dedup.add({id:_chunk2TDEJLQ7js.k.call(void 0, ),type:"error",pageViewId:this.host.pageViewId(),occurredAt:_chunk2TDEJLQ7js.a.call(void 0, Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch (e3){this.host.drop()}},s=[_chunk2TDEJLQ7js.d.call(void 0, window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),_chunk2TDEJLQ7js.d.call(void 0, window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),_chunk2TDEJLQ7js.d.call(void 0, window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),_chunk2TDEJLQ7js.d.call(void 0, window,"pagehide",e(()=>this.dedup.flush())),_chunk2TDEJLQ7js.d.call(void 0, document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var ht=123,ie=(t,e,s)=>{let n=_chunkTJIA62OAjs.c.call(void 0, String(s));if(!n)return null;let r=n.href,o=null;_chunkTJIA62OAjs.e.call(void 0, t,n)&&(o=_chunk2TDEJLQ7js.k.call(void 0, ),n.searchParams.set(_chunkKD6VO7IKjs.g,o),n.searchParams.set(_chunkKD6VO7IKjs.h,t.sessionId()));let i=Date.now(),a=_chunkTJIA62OAjs.h.call(void 0, t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+_chunk2TDEJLQ7js.g.call(void 0, s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+_chunk2TDEJLQ7js.g.call(void 0, s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},Ae=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ft=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=_chunkTJIA62OAjs.f.call(void 0, );return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Te=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,Ae("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?_chunk2TDEJLQ7js.f.call(void 0, c.reason,ht):null,X(d,ft(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch (e4){t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,Ae("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Oe=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=_chunkTJIA62OAjs.f.call(void 0, );X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch (e5){t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var gt=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=_chunkTJIA62OAjs.c.call(void 0, n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(_chunkTJIA62OAjs.e.call(void 0, t,r)){a=_chunk2TDEJLQ7js.k.call(void 0, );let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(_chunkKD6VO7IKjs.e,a),h.set(_chunkKD6VO7IKjs.f,t.sessionId()),p={...s,headers:h}}let l=_chunkTJIA62OAjs.h.call(void 0, t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},Rt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=_chunkTJIA62OAjs.g.call(void 0, s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,_chunkTJIA62OAjs.b),t.record(n)},()=>t.record(n))},Ce=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=gt(t,n,r)}catch (e6){t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{Rt(t,a,p)}catch (e7){t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=_chunkTJIA62OAjs.f.call(void 0, p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var De=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch (e8){t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=_chunkTJIA62OAjs.c.call(void 0, d);if(!c)return;let h=Date.now(),y=null;_chunkTJIA62OAjs.e.call(void 0, t,c)&&(y=_chunk2TDEJLQ7js.k.call(void 0, ),l.setRequestHeader(_chunkKD6VO7IKjs.e,y),l.setRequestHeader(_chunkKD6VO7IKjs.f,t.sessionId()));let m=_chunkTJIA62OAjs.h.call(void 0, t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=_chunkTJIA62OAjs.f.call(void 0, )),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:_chunkTJIA62OAjs.f.call(void 0, ):_chunkTJIA62OAjs.g.call(void 0, m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,_chunkTJIA62OAjs.b)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch (e9){t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch (e10){this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var yt={reload:"RELOAD",back_forward:"BACK_FORWARD"},Me=()=>{try{return performance.getEntriesByType("navigation")[0]}catch (e11){return}},Pe=t=>({dnsMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?_chunk2TDEJLQ7js.b.call(void 0, t.secureConnectionStart,t.connectEnd):null,requestMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.requestStart,t.responseStart):null,responseMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.responseStart,t.responseEnd):null,domProcessingMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),xe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Qe)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:_chunk2TDEJLQ7js.k.call(void 0, ),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:_chunk2TDEJLQ7js.a.call(void 0, pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Qe}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch (e12){t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Pe(Me())),t.record({...e.event}))},a=Me(),p=document.readyState==="complete",l=(y=yt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Pe(a):void 0);let u=[_chunk2TDEJLQ7js.d.call(void 0, window,"popstate",o)];if(!p){let m;u.push(_chunk2TDEJLQ7js.d.call(void 0, window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var _e=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${_e(t.proxyUrl)}/rum`:`${_e(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Fe="abyss-rum-config",Et=600*1e3,Ve=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Ne=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:Ve(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:Ve(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[],maxSessionBytes:s.maxSessionBytes,defaultPrivacy:s.defaultPrivacy},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Le=(t,e)=>{let s=_chunk2TDEJLQ7js.h.call(void 0, Fe);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<Et?Ne(s.config):void 0},He=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Ne(await o.json()):null}catch (e13){r=null}return _chunk2TDEJLQ7js.i.call(void 0, Fe,{key:s,at:n,config:r}),r};var St=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,bt=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,wt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],Ue=t=>St.test(t)?"tablet":bt.test(t)?"mobile":"desktop",Be=t=>{var e,s;return(s=(e=wt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},qe=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch (e14){}return n(),s};var It=200,kt=(t,e,s)=>({session:t<e,replay:t<e*s}),We=(t,e,s,n)=>{let r=kt(t.random,t.sessionSampleRate,t.replaySampleRate),o=qe(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},At=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(At(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>It)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",Tt=1800*1e3,Ot=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=Tt||e-t.startedAt>=Ot,Ct=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Dt=()=>{let t=_chunk2TDEJLQ7js.h.call(void 0, ue);return!t||!_chunkKD6VO7IKjs.c.call(void 0, t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ct(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>_chunk2TDEJLQ7js.i.call(void 0, ue,t),je=()=>_chunk2TDEJLQ7js.j.call(void 0, ue),le=t=>{let e={id:_chunk2TDEJLQ7js.k.call(void 0, ),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},Ke=t=>{let e=Dt();return e&&!de(e,t)?e:le(t)};var Xe=64*1024,Mt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=_chunk2TDEJLQ7js.e.call(void 0, r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=_chunk2TDEJLQ7js.e.call(void 0, u);if(o+d>Xe){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Xe&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch (e15){return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Mt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch (e16){}this.handlers.onLiveWatched(n)}};var Pt=5e3,xt=50,Ge=200,_t=50,Vt=100,Ft=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(Vt,()=>this.drop());this.sockets=new V(Ft,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>_chunkTJIA62OAjs.d.call(void 0, String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=Ke(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Le(s,e);if(n!==void 0){this.configure(n);return}He(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),je()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new (0, _chunkLRYKS5XRjs.b)(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}guard(e){try{e()}catch (e17){this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return Promise.resolve().then(() => _interopRequireWildcard(require("./send-HJMK5WE5.js"))).then(s=>e(s,this.feedbackHost()),()=>{throw new (0, _chunkLRYKS5XRjs.b)("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./deferred-U3TO724B.js"))).then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadReplay(){var e;!this.replaying&&((e=this.session.decision)!=null&&e.replay)&&this.config.replay.enabled&&(this.replaying=Promise.resolve().then(() => _interopRequireWildcard(require("./replay-MELY6N37.js"))).then(({recordReplay:s})=>s(this)).catch(this.drop))}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./socket-messages-KEJ2WXMX.js"))).then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e),this.loadReplay();let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=We({route:x(this.resolveRoute()),deviceType:Ue(s),browserFamily:Be(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=xe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Pt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Ce(e),De(e),Te(e),Oe(e),_chunk2TDEJLQ7js.d.call(void 0, window,"click",n,!0),_chunk2TDEJLQ7js.d.call(void 0, window,"keydown",n,!0),this.errors.install(),_chunk2TDEJLQ7js.d.call(void 0, window,"pagehide",()=>this.guard(()=>this.onPageHide())),_chunk2TDEJLQ7js.d.call(void 0, window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),_chunk2TDEJLQ7js.d.call(void 0, document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch (e18){this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.loadReplay(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<_t?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch (e19){this.drop()}}enqueue(e){if(this.queue.length>=Ge){this.drop();return}this.queue.push(e),this.queue.length>=xt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:_chunk2TDEJLQ7js.a.call(void 0, this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,_chunkTJIA62OAjs.i.call(void 0, n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Ge-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},$e=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>$e,ce=t=>{$e=t};var Ye=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))(Ye||{});var S=t=>{try{t()}catch (e20){f.dropped+=1}},En= exports.AbyssRum ={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=_chunkTJIA62OAjs.a.call(void 0, f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new (0, _chunkLRYKS5XRjs.b)("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};exports.AbyssRum = En; exports.RumFeedbackError = _chunkLRYKS5XRjs.b; exports.RumFeedbackErrorCode = _chunkLRYKS5XRjs.a; exports.RumSocketCaptureMode = Ye;
2
+ `).find(n=>it.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${at(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var ut=/^ResizeObserver loop/,dt=/^Script error\.?$/,lt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:_chunk2TDEJLQ7js.c.call(void 0, t),stack:null}},ct=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},pt=t=>ut.test(t.message)||dt.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=lt(e);if(pt(n)){this.host.drop();return}this.host.captured();let r=ct(s);this.dedup.add({id:_chunk2TDEJLQ7js.k.call(void 0, ),type:"error",pageViewId:this.host.pageViewId(),occurredAt:_chunk2TDEJLQ7js.a.call(void 0, Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch (e3){this.host.drop()}},s=[_chunk2TDEJLQ7js.d.call(void 0, window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),_chunk2TDEJLQ7js.d.call(void 0, window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),_chunk2TDEJLQ7js.d.call(void 0, window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),_chunk2TDEJLQ7js.d.call(void 0, window,"pagehide",e(()=>this.dedup.flush())),_chunk2TDEJLQ7js.d.call(void 0, document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var ht=123,ie=(t,e,s)=>{let n=_chunkTJIA62OAjs.c.call(void 0, String(s));if(!n)return null;let r=n.href,o=null;_chunkTJIA62OAjs.e.call(void 0, t,n)&&(o=_chunk2TDEJLQ7js.k.call(void 0, ),n.searchParams.set(_chunkKD6VO7IKjs.g,o),n.searchParams.set(_chunkKD6VO7IKjs.h,t.sessionId()));let i=Date.now(),a=_chunkTJIA62OAjs.h.call(void 0, t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+_chunk2TDEJLQ7js.g.call(void 0, s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+_chunk2TDEJLQ7js.g.call(void 0, s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},Ae=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ft=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=_chunkTJIA62OAjs.f.call(void 0, );return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Te=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,Ae("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?_chunk2TDEJLQ7js.f.call(void 0, c.reason,ht):null,X(d,ft(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch (e4){t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,Ae("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Oe=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=_chunkTJIA62OAjs.f.call(void 0, );X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch (e5){t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var gt=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=_chunkTJIA62OAjs.c.call(void 0, n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(_chunkTJIA62OAjs.e.call(void 0, t,r)){a=_chunk2TDEJLQ7js.k.call(void 0, );let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(_chunkKD6VO7IKjs.e,a),h.set(_chunkKD6VO7IKjs.f,t.sessionId()),p={...s,headers:h}}let l=_chunkTJIA62OAjs.h.call(void 0, t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},Rt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=_chunkTJIA62OAjs.g.call(void 0, s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,_chunkTJIA62OAjs.b),t.record(n)},()=>t.record(n))},Ce=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=gt(t,n,r)}catch (e6){t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{Rt(t,a,p)}catch (e7){t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=_chunkTJIA62OAjs.f.call(void 0, p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var De=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch (e8){t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=_chunkTJIA62OAjs.c.call(void 0, d);if(!c)return;let h=Date.now(),y=null;_chunkTJIA62OAjs.e.call(void 0, t,c)&&(y=_chunk2TDEJLQ7js.k.call(void 0, ),l.setRequestHeader(_chunkKD6VO7IKjs.e,y),l.setRequestHeader(_chunkKD6VO7IKjs.f,t.sessionId()));let m=_chunkTJIA62OAjs.h.call(void 0, t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=_chunkTJIA62OAjs.f.call(void 0, )),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:_chunkTJIA62OAjs.f.call(void 0, ):_chunkTJIA62OAjs.g.call(void 0, m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,_chunkTJIA62OAjs.b)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch (e9){t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch (e10){this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var yt={reload:"RELOAD",back_forward:"BACK_FORWARD"},Me=()=>{try{return performance.getEntriesByType("navigation")[0]}catch (e11){return}},Pe=t=>({dnsMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?_chunk2TDEJLQ7js.b.call(void 0, t.secureConnectionStart,t.connectEnd):null,requestMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.requestStart,t.responseStart):null,responseMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.responseStart,t.responseEnd):null,domProcessingMs:t?_chunk2TDEJLQ7js.b.call(void 0, t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),xe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Qe)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:_chunk2TDEJLQ7js.k.call(void 0, ),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:_chunk2TDEJLQ7js.a.call(void 0, pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Qe}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch (e12){t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Pe(Me())),t.record({...e.event}))},a=Me(),p=document.readyState==="complete",l=(y=yt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Pe(a):void 0);let u=[_chunk2TDEJLQ7js.d.call(void 0, window,"popstate",o)];if(!p){let m;u.push(_chunk2TDEJLQ7js.d.call(void 0, window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var _e=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${_e(t.proxyUrl)}/rum`:`${_e(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Fe="abyss-rum-config",Et=600*1e3,Ve=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Ne=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:Ve(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:Ve(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[],maxSessionBytes:s.maxSessionBytes,defaultPrivacy:s.defaultPrivacy},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Le=(t,e)=>{let s=_chunk2TDEJLQ7js.h.call(void 0, Fe);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<Et?Ne(s.config):void 0},He=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Ne(await o.json()):null}catch (e13){r=null}return _chunk2TDEJLQ7js.i.call(void 0, Fe,{key:s,at:n,config:r}),r};var St=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,bt=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,wt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],Ue=t=>St.test(t)?"tablet":bt.test(t)?"mobile":"desktop",Be=t=>{var e,s;return(s=(e=wt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},qe=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch (e14){}return n(),s};var It=200,kt=(t,e,s)=>({session:t<e,replay:t<e*s}),We=(t,e,s,n)=>{let r=kt(t.random,t.sessionSampleRate,t.replaySampleRate),o=qe(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},At=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(At(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>It)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",Tt=1800*1e3,Ot=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=Tt||e-t.startedAt>=Ot,Ct=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Dt=()=>{let t=_chunk2TDEJLQ7js.h.call(void 0, ue);return!t||!_chunkKD6VO7IKjs.c.call(void 0, t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ct(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>_chunk2TDEJLQ7js.i.call(void 0, ue,t),je=()=>_chunk2TDEJLQ7js.j.call(void 0, ue),le=t=>{let e={id:_chunk2TDEJLQ7js.k.call(void 0, ),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},Ke=t=>{let e=Dt();return e&&!de(e,t)?e:le(t)};var Xe=64*1024,Mt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=_chunk2TDEJLQ7js.e.call(void 0, r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=_chunk2TDEJLQ7js.e.call(void 0, u);if(o+d>Xe){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Xe&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch (e15){return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Mt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch (e16){}this.handlers.onLiveWatched(n)}};var Pt=5e3,xt=50,Ge=200,_t=50,Vt=100,Ft=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(Vt,()=>this.drop());this.sockets=new V(Ft,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>_chunkTJIA62OAjs.d.call(void 0, String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=Ke(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Le(s,e);if(n!==void 0){this.configure(n);return}He(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),je()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new (0, _chunkLRYKS5XRjs.b)(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}guard(e){try{e()}catch (e17){this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return Promise.resolve().then(() => _interopRequireWildcard(require("./send-HJMK5WE5.js"))).then(s=>e(s,this.feedbackHost()),()=>{throw new (0, _chunkLRYKS5XRjs.b)("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./deferred-U3TO724B.js"))).then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadReplay(){var e;!this.replaying&&((e=this.session.decision)!=null&&e.replay)&&this.config.replay.enabled&&(this.replaying=Promise.resolve().then(() => _interopRequireWildcard(require("./replay-WQGBL5IM.js"))).then(({recordReplay:s})=>s(this)).catch(this.drop))}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(Promise.resolve().then(() => _interopRequireWildcard(require("./socket-messages-KEJ2WXMX.js"))).then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e),this.loadReplay();let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=We({route:x(this.resolveRoute()),deviceType:Ue(s),browserFamily:Be(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=xe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Pt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Ce(e),De(e),Te(e),Oe(e),_chunk2TDEJLQ7js.d.call(void 0, window,"click",n,!0),_chunk2TDEJLQ7js.d.call(void 0, window,"keydown",n,!0),this.errors.install(),_chunk2TDEJLQ7js.d.call(void 0, window,"pagehide",()=>this.guard(()=>this.onPageHide())),_chunk2TDEJLQ7js.d.call(void 0, window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),_chunk2TDEJLQ7js.d.call(void 0, document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch (e18){this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.loadReplay(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<_t?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch (e19){this.drop()}}enqueue(e){if(this.queue.length>=Ge){this.drop();return}this.queue.push(e),this.queue.length>=xt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:_chunk2TDEJLQ7js.a.call(void 0, this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,_chunkTJIA62OAjs.i.call(void 0, n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Ge-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},$e=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>$e,ce=t=>{$e=t};var Ye=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))(Ye||{});var S=t=>{try{t()}catch (e20){f.dropped+=1}},En= exports.AbyssRum ={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=_chunkTJIA62OAjs.a.call(void 0, f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new (0, _chunkLRYKS5XRjs.b)("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};exports.AbyssRum = En; exports.RumFeedbackError = _chunkLRYKS5XRjs.b; exports.RumFeedbackErrorCode = _chunkLRYKS5XRjs.a; exports.RumSocketCaptureMode = Ye;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import{a as z,b as A}from"./chunk-QEU2JJHJ.mjs";import{a as I,b as U,c as T,d as ye,e as O,f as w,g as B,h as C,i as Ee}from"./chunk-QL6P3CII.mjs";import{a as b,b as k,c as ge,d as g,e as Z,f as Re,g as ee,h as L,i as H,j as ve,k as R}from"./chunk-57O4BMUU.mjs";import{c as me,d as J,e as F,f as N,g as he,h as fe}from"./chunk-5S3SDOLF.mjs";var Se=t=>t===null?null:typeof t=="string"&&t.trim()!==""?t:void 0;var be=50,D=class{constructor(){this.session={};this.pageViewId=null;this.page={}}add(e,s,n){if(s==null)return n(),!1;let r=!1,o=()=>{r=!0,n()},i={[String(e)]:s};return this.session=I(this.session,i,o,be),r||(this.page=I(this.page,i,o,be)),!r}hasAny(){return Object.keys(this.session).length>0}annotate(e){e.id!==this.pageViewId&&(this.pageViewId!==null&&(this.page={}),this.pageViewId=e.id),Object.keys(this.page).length>0&&(e.featureFlags={...this.page})}};var ze=64,we=(t,e,s,n)=>{if(typeof t!="string"||t.length===0||t.length>ze)return n(),null;let r={id:R(),type:"action",pageViewId:s,occurredAt:b(Date.now()),name:t};if(e!==void 0){let o=I({},e,n);Object.keys(o).length>0&&(r.attributes=o)}return r};var Je=["id","type","sessionId"],Ze=(t,e)=>t==null?e==null||["string","number","boolean"].includes(typeof e):Array.isArray(t)?Array.isArray(e):e!==null&&typeof e==typeof t,te=(t,e,s)=>{if(!e)return t;let n;try{n=e(JSON.parse(JSON.stringify(t)))}catch{return s(),t}if(n===null)return null;if(!n||typeof n!="object"||Array.isArray(n))return s(),null;let r=t,o=n,i={};for(let a of Object.keys(r))if(Je.includes(a))i[a]=r[a];else if(Ze(r[a],o[a]))o[a]!==void 0&&(i[a]=o[a]);else return s(),null;return i};var et=/^([a-z][a-z0-9+.-]*:)\/\//i,tt=["url","blockedUri","sourceFile"],st=["route","referrerRoute","entryPath"],se=t=>{let{host:e,path:s}=J(t);if(e===null)return s;let n=et.exec(t.trim());return`${n?n[1].toLowerCase():"https:"}//${e}${s}`},x=t=>J(t).path,ne=t=>{let e=t;for(let s of tt)typeof e[s]=="string"&&(e[s]=se(e[s]));for(let s of st)typeof e[s]=="string"&&(e[s]=x(e[s]));return t};var nt=20,rt=256,ke='[data-abyss-privacy="hidden"]',ot=`${ke},[data-testid],[aria-label],button,a,input,select,textarea,summary,[role="button"],[role="link"]`,Ie=(t,e)=>{let s=t.getAttribute(e);return s===null?null:s.slice(0,rt)},re=t=>{var s,n;let e=(n=((s=t.closest(ke))!=null?s:t).closest(ot))!=null?n:t;return{tag:e.tagName.toLowerCase().slice(0,64),testId:Ie(e,"data-testid"),ariaLabel:Ie(e,"aria-label")}},q=class{constructor(){this.items=[];this.lastPageViewId=null}observe(e){e.type==="pageView"&&e.id!==this.lastPageViewId?(this.lastPageViewId=e.id,this.add({kind:"NAVIGATION",route:x(e.route)})):e.type==="request"&&e.kind!=="WEBSOCKET"&&e.kind!=="SSE"&&this.add({kind:"REQUEST",method:e.method,url:se(e.url),status:e.status})}click(e){e instanceof Element&&this.add({kind:"CLICK",element:re(e)})}snapshot(){return this.items.map(e=>({...e}))}add(e){this.items.push({...e,occurredAt:b(Date.now())}),this.items.length>nt&&this.items.shift()}};var it=/^\s*at\s|@\S+:\d+/,at=t=>{var e,s;return(s=(e=(t!=null?t:"").split(`
2
- `).find(n=>it.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${at(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var ut=/^ResizeObserver loop/,dt=/^Script error\.?$/,lt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:ge(t),stack:null}},ct=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},pt=t=>ut.test(t.message)||dt.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=lt(e);if(pt(n)){this.host.drop();return}this.host.captured();let r=ct(s);this.dedup.add({id:R(),type:"error",pageViewId:this.host.pageViewId(),occurredAt:b(Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch{this.host.drop()}},s=[g(window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),g(window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),g(window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),g(window,"pagehide",e(()=>this.dedup.flush())),g(document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var ht=123,ie=(t,e,s)=>{let n=T(String(s));if(!n)return null;let r=n.href,o=null;O(t,n)&&(o=R(),n.searchParams.set(he,o),n.searchParams.set(fe,t.sessionId()));let i=Date.now(),a=C(t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+ee(s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+ee(s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},Ae=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ft=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=w();return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Te=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,Ae("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?Re(c.reason,ht):null,X(d,ft(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch{t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,Ae("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Oe=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=w();X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch{t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var gt=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=T(n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(O(t,r)){a=R();let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(F,a),h.set(N,t.sessionId()),p={...s,headers:h}}let l=C(t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},Rt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=B(s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,U),t.record(n)},()=>t.record(n))},Ce=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=gt(t,n,r)}catch{t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{Rt(t,a,p)}catch{t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=w(p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var De=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch{t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=T(d);if(!c)return;let h=Date.now(),y=null;O(t,c)&&(y=R(),l.setRequestHeader(F,y),l.setRequestHeader(N,t.sessionId()));let m=C(t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=w()),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:w():B(m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,U)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch{t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch{this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var yt={reload:"RELOAD",back_forward:"BACK_FORWARD"},Me=()=>{try{return performance.getEntriesByType("navigation")[0]}catch{return}},Pe=t=>({dnsMs:t?k(t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?k(t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?k(t.secureConnectionStart,t.connectEnd):null,requestMs:t?k(t.requestStart,t.responseStart):null,responseMs:t?k(t.responseStart,t.responseEnd):null,domProcessingMs:t?k(t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),xe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Qe)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:R(),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:b(pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Qe}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch{t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Pe(Me())),t.record({...e.event}))},a=Me(),p=document.readyState==="complete",l=(y=yt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Pe(a):void 0);let u=[g(window,"popstate",o)];if(!p){let m;u.push(g(window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var _e=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${_e(t.proxyUrl)}/rum`:`${_e(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Fe="abyss-rum-config",Et=600*1e3,Ve=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Ne=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:Ve(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:Ve(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[],maxSessionBytes:s.maxSessionBytes,defaultPrivacy:s.defaultPrivacy},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Le=(t,e)=>{let s=L(Fe);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<Et?Ne(s.config):void 0},He=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Ne(await o.json()):null}catch{r=null}return H(Fe,{key:s,at:n,config:r}),r};var St=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,bt=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,wt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],Ue=t=>St.test(t)?"tablet":bt.test(t)?"mobile":"desktop",Be=t=>{var e,s;return(s=(e=wt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},qe=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch{}return n(),s};var It=200,kt=(t,e,s)=>({session:t<e,replay:t<e*s}),We=(t,e,s,n)=>{let r=kt(t.random,t.sessionSampleRate,t.replaySampleRate),o=qe(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},At=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(At(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>It)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",Tt=1800*1e3,Ot=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=Tt||e-t.startedAt>=Ot,Ct=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Dt=()=>{let t=L(ue);return!t||!me(t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ct(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>H(ue,t),je=()=>ve(ue),le=t=>{let e={id:R(),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},Ke=t=>{let e=Dt();return e&&!de(e,t)?e:le(t)};var Xe=64*1024,Mt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=Z(r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=Z(u);if(o+d>Xe){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Xe&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch{return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Mt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch{}this.handlers.onLiveWatched(n)}};var Pt=5e3,xt=50,Ge=200,_t=50,Vt=100,Ft=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(Vt,()=>this.drop());this.sockets=new V(Ft,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>ye(String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=Ke(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Le(s,e);if(n!==void 0){this.configure(n);return}He(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),je()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new A(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}guard(e){try{e()}catch{this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return import("./send-KNP5EOEZ.mjs").then(s=>e(s,this.feedbackHost()),()=>{throw new A("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(import("./deferred-P4QMIWWX.mjs").then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadReplay(){var e;!this.replaying&&((e=this.session.decision)!=null&&e.replay)&&this.config.replay.enabled&&(this.replaying=import("./replay-YGA3WVIJ.mjs").then(({recordReplay:s})=>s(this)).catch(this.drop))}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(import("./socket-messages-TSBDPTWJ.mjs").then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e),this.loadReplay();let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=We({route:x(this.resolveRoute()),deviceType:Ue(s),browserFamily:Be(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=xe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Pt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Ce(e),De(e),Te(e),Oe(e),g(window,"click",n,!0),g(window,"keydown",n,!0),this.errors.install(),g(window,"pagehide",()=>this.guard(()=>this.onPageHide())),g(window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),g(document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch{this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.loadReplay(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<_t?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch{this.drop()}}enqueue(e){if(this.queue.length>=Ge){this.drop();return}this.queue.push(e),this.queue.length>=xt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:b(this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,Ee(n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Ge-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},$e=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>$e,ce=t=>{$e=t};var Ye=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))(Ye||{});var S=t=>{try{t()}catch{f.dropped+=1}},En={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=I(f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new A("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};export{En as AbyssRum,A as RumFeedbackError,z as RumFeedbackErrorCode,Ye as RumSocketCaptureMode};
2
+ `).find(n=>it.test(n)))==null?void 0:e.trim())!=null?s:""},W=class{constructor(e){this.release=e;this.held=new Map}add(e){var r;let s=`${(r=e.pageViewId)!=null?r:""}${e.message}${at(e.stack)}`,n=this.held.get(s);if(n){n.event.repeat+=1;return}this.held.set(s,{event:e,timer:setTimeout(()=>this.releaseKey(s),1e4)})}flush(){[...this.held.keys()].forEach(e=>this.releaseKey(e))}clear(){this.held.forEach(e=>clearTimeout(e.timer)),this.held.clear()}releaseKey(e){let s=this.held.get(e);s&&(clearTimeout(s.timer),this.held.delete(e),this.release(s.event))}};var ut=/^ResizeObserver loop/,dt=/^Script error\.?$/,lt=t=>{let e=t;return e&&typeof e=="object"&&typeof e.message=="string"?{name:typeof e.name=="string"&&e.name?e.name:"Error",message:e.message,stack:typeof e.stack=="string"?e.stack:null}:{name:"Error",message:ge(t),stack:null}},ct=t=>{if(!t||typeof t!="object")return;let e=Object.entries(t).filter(([,s])=>typeof s=="string");return e.length>0?Object.fromEntries(e):void 0},pt=t=>ut.test(t.message)||dt.test(t.message)&&!t.stack,j=class{constructor(e){this.host=e;this.breadcrumbs=new q;this.pageViewId=null;this.dedup=new W(s=>e.record(s))}capture(e,s){let n=lt(e);if(pt(n)){this.host.drop();return}this.host.captured();let r=ct(s);this.dedup.add({id:R(),type:"error",pageViewId:this.host.pageViewId(),occurredAt:b(Date.now()),route:this.host.resolveRoute(),...n,breadcrumbs:this.breadcrumbs.snapshot(),repeat:1,...r?{context:r}:{}})}observe(e){this.breadcrumbs.observe(e),e.type==="pageView"&&e.id!==this.pageViewId&&(this.pageViewId!==null&&this.dedup.flush(),this.pageViewId=e.id)}install(){let e=n=>()=>{try{n()}catch{this.host.drop()}},s=[g(window,"error",n=>{n.target instanceof Element||e(()=>{var r;return this.capture((r=n.error)!=null?r:n.message)})()}),g(window,"unhandledrejection",n=>e(()=>this.capture(n.reason))()),g(window,"click",n=>e(()=>this.breadcrumbs.click(n.target))(),!0),g(window,"pagehide",e(()=>this.dedup.flush())),g(document,"visibilitychange",e(()=>{document.visibilityState==="hidden"&&this.dedup.flush()}))];return()=>{s.forEach(n=>n()),this.dedup.clear()}}};var ht=123,ie=(t,e,s)=>{let n=T(String(s));if(!n)return null;let r=n.href,o=null;O(t,n)&&(o=R(),n.searchParams.set(he,o),n.searchParams.set(fe,t.sessionId()));let i=Date.now(),a=C(t,e,"GET",r,i,o);Object.assign(a,{connectMs:null,messagesIn:0,messagesOut:0,bytesIn:0,bytesOut:0,droppedMessages:0});let p={event:a,startedAt:i,opened:!1,dirty:!0,done:!1};return t.trackConnection(p),{connection:p,nativeUrl:o===null?String(s):n.href}},ae=t=>{t.opened||(t.opened=!0,t.event.connectMs=Date.now()-t.startedAt,t.dirty=!0)},K=(t,e,s)=>{var r,o,i,a;let{event:n}=t;e==="in"?(n.messagesIn=((r=n.messagesIn)!=null?r:0)+1,n.bytesIn=((o=n.bytesIn)!=null?o:0)+ee(s)):(n.messagesOut=((i=n.messagesOut)!=null?i:0)+1,n.bytesOut=((a=n.bytesOut)!=null?a:0)+ee(s)),t.dirty=!0},X=(t,e)=>{t.done||(t.event.durationMs=Date.now()-t.startedAt,t.event.outcome=e,t.done=!0,t.dirty=!0)},Ae=(t,e)=>({direction:t,data:e,at:Date.now(),eventName:null,eventId:null}),ft=(t,e,s,n)=>{if(s)return"ABORTED";if(t&&(e===1e3||e===1001||n&&e===1005))return"SUCCESS";let r=w();return r==="OFFLINE"||!t?r:"HTTP_ERROR"},Te=t=>{let e=window.WebSocket;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.send,r=s.close,o=new WeakMap,i=(u,d)=>{o.set(u,d),u.addEventListener("open",()=>ae(d)),u.addEventListener("message",c=>{K(d,"in",c.data),t.socketMessage(d,Ae("IN",c.data))}),u.addEventListener("close",c=>{let h=o.get(u);d.event.closeCode=c.code,d.event.closeReason=c.reason?Re(c.reason,ht):null,X(d,ft(d.opened,c.code,(h==null?void 0:h.abortedByApp)===!0,(h==null?void 0:h.closedByApp)===!0)),t.socketClosed(d)})},a=new Proxy(e,{construct(u,d,c){let h=null;try{h=ie(t,"WEBSOCKET",d[0])}catch{t.drop()}let y=h?[h.nativeUrl,...d.slice(1)]:d,m=Reflect.construct(u,y,c===a?u:c);return h&&i(m,h.connection),m}}),p=function(u){n.call(this,u);let d=o.get(this);d&&(K(d,"out",u),t.socketMessage(d,Ae("OUT",u)))},l=function(u,d){let c=o.get(this);return c&&(c.abortedByApp=this.readyState===e.CONNECTING,c.closedByApp=!0),r.apply(this,arguments)};return window.WebSocket=a,s.send=p,s.close=l,()=>{window.WebSocket===a&&(window.WebSocket=e),s.send===p&&(s.send=n),s.close===l&&(s.close=r)}};var Oe=t=>{let e=window,s=e.EventSource;if(typeof s!="function")return()=>{};let n=s.prototype,r=n.close,o=new WeakMap,i=(l,u)=>{o.set(l,u),u.event.reconnectCount=0,l.addEventListener("open",()=>ae(u)),l.addEventListener("message",d=>{K(u,"in",d.data),t.socketMessage(u,{direction:"IN",data:d.data,at:Date.now(),eventName:d.type,eventId:d.lastEventId||null})}),l.addEventListener("error",()=>{var c;if(l.readyState===s.CONNECTING){u.event.reconnectCount=((c=u.event.reconnectCount)!=null?c:0)+1,u.dirty=!0;return}let d=w();X(u,u.opened&&d!=="OFFLINE"?"HTTP_ERROR":d),t.socketClosed(u)})},a=new Proxy(s,{construct(l,u,d){let c=null;try{c=ie(t,"SSE",u[0])}catch{t.drop()}let h=c?[c.nativeUrl,...u.slice(1)]:u,y=Reflect.construct(l,h,d===a?l:d);return c&&i(y,c.connection),y}}),p=function(){r.call(this);let l=o.get(this);l&&(X(l,l.opened?"SUCCESS":"ABORTED"),t.socketClosed(l))};return e.EventSource=a,n.close=p,()=>{e.EventSource===a&&(e.EventSource=s),n.close===p&&(n.close=r)}};var gt=(t,e,s)=>{var u,d,c;let n=typeof Request!="undefined"&&e instanceof Request?e:null,r=T(n?n.url:String(e));if(!r)return null;let o=((d=(u=s==null?void 0:s.method)!=null?u:n==null?void 0:n.method)!=null?d:"GET").toUpperCase(),i=Date.now(),a=null,p=s;if(O(t,r)){a=R();let h=new Headers((c=s==null?void 0:s.headers)!=null?c:n==null?void 0:n.headers);h.set(F,a),h.set(N,t.sessionId()),p={...s,headers:h}}let l=C(t,"FETCH",o,r.href,i,a);return t.trackTiming(l.id,r.href,i),{event:l,init:p,startedAt:i}},Rt=(t,e,s)=>{let{event:n}=e;if(n.durationMs=Date.now()-e.startedAt,n.status=s.status,n.outcome=B(s.status),n.instrumented||s.status<400){t.record(n);return}s.clone().text().then(r=>{n.responseBodyExcerpt=r.slice(0,U),t.record(n)},()=>t.record(n))},Ce=t=>{let e=window.fetch;if(typeof e!="function")return()=>{};let s=(n,r)=>{let o=null;try{o=gt(t,n,r)}catch{t.drop()}let i=e.call(window,n,o?o.init:r);if(o){let a=o;i.then(p=>{try{Rt(t,a,p)}catch{t.drop()}},p=>{a.event.durationMs=Date.now()-a.startedAt,a.event.outcome=w(p),t.record(a.event)})}return i};return window.fetch=s,()=>{window.fetch===s&&(window.fetch=e)}};var De=t=>{let e=window.XMLHttpRequest;if(typeof e!="function")return()=>{};let s=e.prototype,n=s.open,r=s.send,o=new WeakMap,i=function(l,u){try{o.set(this,{method:String(l).toUpperCase(),url:String(u)})}catch{t.drop()}return n.apply(this,arguments)},a=(l,u,d)=>{let c=T(d);if(!c)return;let h=Date.now(),y=null;O(t,c)&&(y=R(),l.setRequestHeader(F,y),l.setRequestHeader(N,t.sessionId()));let m=C(t,"XHR",u,c.href,h,y);t.trackTiming(m.id,c.href,h);let E=null;l.addEventListener("error",()=>E=w()),l.addEventListener("abort",()=>E="ABORTED"),l.addEventListener("timeout",()=>E="TIMEOUT"),l.addEventListener("loadend",()=>{m.durationMs=Date.now()-h,m.status=E===null&&l.status>0?l.status:null,m.outcome=m.status===null?E!=null?E:w():B(m.status),!m.instrumented&&m.status!==null&&m.status>=400&&(l.responseType===""||l.responseType==="text")&&(m.responseBodyExcerpt=l.responseText.slice(0,U)),t.record(m)})},p=function(l){let u=o.get(this);if(u)try{a(this,u.method,u.url)}catch{t.drop()}return r.call(this,l)};return s.open=i,s.send=p,()=>{s.open===i&&(s.open=n),s.send===p&&(s.send=r)}};var V=class{constructor(e,s){this.max=e;this.drop=s;this.value=null;this.calls=null;this.failed=!1}get(){return this.value}hold(){!this.value&&!this.calls&&(this.calls=[])}run(e){if(this.value)try{e(this.value)}catch{this.drop()}else this.calls&&this.calls.length<this.max?this.calls.push(e):(this.calls||this.failed)&&this.drop()}resolve(e){var n;let s=(n=this.calls)!=null?n:[];this.calls=null,this.value=e,s.forEach(r=>this.run(r))}fail(){var e;((e=this.calls)!=null?e:[]).forEach(()=>this.drop()),this.calls=null,this.failed=!0}close(){this.value=null,this.calls=null}};var yt={reload:"RELOAD",back_forward:"BACK_FORWARD"},Me=()=>{try{return performance.getEntriesByType("navigation")[0]}catch{return}},Pe=t=>({dnsMs:t?k(t.domainLookupStart,t.domainLookupEnd):null,tcpMs:t?k(t.connectStart,t.connectEnd):null,tlsMs:t&&t.secureConnectionStart>0?k(t.secureConnectionStart,t.connectEnd):null,requestMs:t?k(t.requestStart,t.responseStart):null,responseMs:t?k(t.responseStart,t.responseEnd):null,domProcessingMs:t?k(t.responseEnd,t.domComplete):null,loadMs:t&&t.loadEventEnd>0?Math.round(t.loadEventEnd-t.startTime):null}),xe=t=>{var h,y;let e=null,s=null,n=(m,E=null,Qe)=>{let pe=Date.now();return e={startedAt:pe,path:window.location.pathname,event:{id:R(),type:"pageView",route:t.resolveRoute(),referrerRoute:E,startedAt:b(pe),durationMs:null,navigationType:m,lcpMs:null,inpMs:null,cls:null,fcpMs:null,ttfbMs:null,dnsMs:null,tcpMs:null,tlsMs:null,requestMs:null,responseMs:null,domProcessingMs:null,loadMs:null,longTaskCount:0,longTaskTotalMs:0,...Qe}},t.record({...e.event}),e.event.id},r=()=>{e&&(e.event.durationMs=Date.now()-e.startedAt,t.record({...e.event}))},o=()=>{try{if(t.onNavigation(),e&&window.location.pathname!==e.path){let m=e.event.route;r(),n("SPA",m)}}catch{t.drop()}},i=()=>{e&&e.event.id===s&&(Object.assign(e.event,Pe(Me())),t.record({...e.event}))},a=Me(),p=document.readyState==="complete",l=(y=yt[(h=a==null?void 0:a.type)!=null?h:""])!=null?y:"NAVIGATE";s=n(l,null,p?Pe(a):void 0);let u=[g(window,"popstate",o)];if(!p){let m;u.push(g(window,"load",()=>{m=setTimeout(i,0)}),()=>clearTimeout(m))}let d=window.history.pushState,c=function(...m){let E=d.apply(this,m);return o(),E};return window.history.pushState=c,u.push(()=>{window.history.pushState===c&&(window.history.pushState=d)}),{currentId:()=>{var m;return(m=e==null?void 0:e.event.id)!=null?m:null},start:m=>{n(m)},end:r,stop:()=>u.forEach(m=>m())}};var _e=t=>t.replace(/\/+$/,""),G=(t,e)=>`${t.proxyUrl?`${_e(t.proxyUrl)}/rum`:`${_e(t.apiUrl)}/api/rum`}/${encodeURIComponent(t.applicationId)}/${e}?token=${encodeURIComponent(t.token)}`;var Fe="abyss-rum-config",Et=600*1e3,Ve=t=>typeof t=="number"&&t>=0&&t<=1?t:0,Ne=t=>{var n,r;let e=t;if(!e||typeof e.enabled!="boolean"||typeof e.sessionSampleRate!="number")return null;let s=(n=e.replay)!=null?n:{};return{enabled:e.enabled,sessionSampleRate:Ve(e.sessionSampleRate),sessionQuotaExhausted:e.sessionQuotaExhausted===!0,country:typeof e.country=="string"?e.country:null,feedbackEnabled:e.feedbackEnabled===!0,replay:{enabled:s.enabled===!0,sampleRate:Ve(s.sampleRate),unmaskSelectors:Array.isArray(s.unmaskSelectors)?s.unmaskSelectors.filter(o=>typeof o=="string"):[],maxSessionBytes:s.maxSessionBytes,defaultPrivacy:s.defaultPrivacy},socketMessages:{enabled:((r=e.socketMessages)==null?void 0:r.enabled)===!0}}},Le=(t,e)=>{let s=L(Fe);if(!s||s.key!==t||typeof s.at!="number")return;let n=e-s.at;return n>=0&&n<Et?Ne(s.config):void 0},He=async(t,e,s,n)=>{let r=null;try{let o=await e(t,{credentials:"omit"});r=o.ok?Ne(await o.json()):null}catch{r=null}return H(Fe,{key:s,at:n,config:r}),r};var St=/iPad|Tablet|PlayBook|Silk|Android(?!.*Mobile)/i,bt=/Mobi|iPhone|iPod|Android|Opera Mini|IEMobile/i,wt=[[/Edg(e|A|iOS)?\//,"Edge"],[/OPR\/|Opera/,"Opera"],[/SamsungBrowser\//,"Samsung Internet"],[/Firefox\/|FxiOS\//,"Firefox"],[/Chrome\/|CriOS\//,"Chrome"],[/Safari\//,"Safari"]],Ue=t=>St.test(t)?"tablet":bt.test(t)?"mobile":"desktop",Be=t=>{var e,s;return(s=(e=wt.find(([n])=>n.test(t)))==null?void 0:e[1])!=null?s:"Other"},qe=(t,e,s,n)=>{if(!t)return s;try{let r=t({...e,attributes:{...e.attributes}});if(typeof(r==null?void 0:r.session)=="boolean"&&typeof r.replay=="boolean")return{session:r.session,replay:r.replay}}catch{}return n(),s};var It=200,kt=(t,e,s)=>({session:t<e,replay:t<e*s}),We=(t,e,s,n)=>{let r=kt(t.random,t.sessionSampleRate,t.replaySampleRate),o=qe(e,t,r,n),i=o.session&&!s;return{session:i,replay:i&&o.replay}},At=t=>t.type==="request"&&(t.kind==="FETCH"||t.kind==="XHR")&&t.outcome==="SUCCESS",$=class{constructor(e){this.onDrop=e;this.held=null;this.released=new Set;this.successes=new Map}accept(e,s){var r,o,i;if(s){if(At(e)){let a=(r=e.pageViewId)!=null?r:"",p=((o=this.successes.get(a))!=null?o:0)+1;if(this.successes.set(a,p),p>It)return this.onDrop(),[]}return[e]}if(e.type==="pageView")return this.released.has(e.id)?[e]:(this.held=e,[]);if(e.type!=="error")return[];let n=[];return e.pageViewId!==null&&!this.released.has(e.pageViewId)&&(this.released.add(e.pageViewId),((i=this.held)==null?void 0:i.id)===e.pageViewId&&(n.push(this.held),this.held=null)),n.push(e),n}reset(){this.held=null,this.released.clear(),this.successes.clear()}};var ue="abyss-rum-session",Tt=1800*1e3,Ot=14400*1e3,de=(t,e)=>e-t.lastActivityAt>=Tt||e-t.startedAt>=Ot,Ct=t=>typeof(t==null?void 0:t.session)=="boolean"&&typeof t.replay=="boolean",Dt=()=>{let t=L(ue);return!t||!me(t.id)||typeof t.startedAt!="number"||typeof t.lastActivityAt!="number"||typeof t.random!="number"?null:{id:t.id,startedAt:t.startedAt,lastActivityAt:t.lastActivityAt,random:t.random,decision:Ct(t.decision)?t.decision:null,entryPath:typeof t.entryPath=="string"?t.entryPath:null,cut:t.cut===!0}},M=t=>H(ue,t),je=()=>ve(ue),le=t=>{let e={id:R(),startedAt:t,lastActivityAt:t,random:Math.random(),decision:null,entryPath:null,cut:!1};return M(e),e},Ke=t=>{let e=Dt();return e&&!de(e,t)?e:le(t)};var Xe=64*1024,Mt=60*1e3;var Y=class{constructor(e,s,n){this.url=e;this.fetchImpl=s;this.handlers=n;this.pausedUntil=0}isPaused(e){return e<this.pausedUntil}send(e,s,n){let r=JSON.stringify({...e,events:[]}).slice(0,-2),o=Z(r)+2,i=[],a=[],p=o;for(let l of s){let u=JSON.stringify(l),d=Z(u);if(o+d>Xe){this.handlers.onDrop(1);continue}let c=d+(i.length>0?1:0);p+c>Xe&&(this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId),i=[],a=[],p=o),p+=d+(i.length>0?1:0),i.push(u),a.push(l)}i.length>0&&this.post(`${r}${i.join(",")}]}`,a,n,e.sessionId)}post(e,s,n,r){let o=i=>this.handlers.onResult(s,i,r);if(n&&this.beacon(e)){o("OK");return}this.fetchImpl(this.url,{method:"POST",body:e,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(i=>this.handle(i,o),()=>o("FAIL")).catch(()=>this.handlers.onDrop(1))}beacon(e){try{return typeof navigator.sendBeacon=="function"&&navigator.sendBeacon(this.url,e)}catch{return!1}}async handle(e,s){if(e.status===429){this.pausedUntil=Date.now()+Mt,s("RETRY");return}if(e.status===401||e.status===403||e.status===404){s("CUT");return}if(!e.ok){s("FAIL");return}s("OK");let n=!1;try{n=(await e.json()).liveWatched===!0}catch{}this.handlers.onLiveWatched(n)}};var Pt=5e3,xt=50,Ge=200,_t=50,Vt=100,Ft=200,Q=class{constructor(e,s){this.options=e;this.shared=s;this.config=null;this.ready=!1;this.stopped=!1;this.flushing=!1;this.pending=[];this.queue=[];this.teardowns=[];this.pageViews=null;this.lastPageViewId=null;this.deferred=new V(Vt,()=>this.drop());this.sockets=new V(Ft,()=>this.drop());this.errors=new j({pageViewId:()=>this.pageViewId(),resolveRoute:()=>this.resolveRoute(),record:e=>this.record(e),drop:()=>this.drop(),captured:()=>{var s;let e=Date.now();(s=this.deferred.get())==null||s.frustration.notifyError(),this.sockets.run(n=>n.anomaly(e))}});this.connections=new Set;this.timings=new Map;this.sessionDirty=!0;this.closed=!1;this.liveWatched=!1;this.drop=()=>{this.shared.dropped+=1};this.pageViewId=()=>{var e,s;return(s=(e=this.pageViews)==null?void 0:e.currentId())!=null?s:null};var r;let n=window.fetch;this.nativeFetch=(o,i)=>n.call(window,o,i),this.instrumentedOrigins=((r=e.instrumentedOrigins)!=null?r:[]).map(o=>ye(String(o))).filter(o=>o!==null),this.filter=new $(this.drop),this.transport=new Y(G(e,"batch"),this.nativeFetch,{onResult:(o,i,a)=>this.guard(()=>this.onResult(o,i,a)),onLiveWatched:o=>{this.liveWatched=o},onDrop:o=>{this.shared.dropped+=o}}),this.session=Ke(Date.now()),this.deferred.hold()}start(){if(this.session.cut){this.stopped=!0;return}let e=Date.now(),s=`${this.options.applicationId}:${this.options.token}`,n=Le(s,e);if(n!==void 0){this.configure(n);return}He(G(this.options,"config"),this.nativeFetch,s,e).then(r=>this.guard(()=>this.configure(r)),this.drop)}stop(){this.shutdown(),je()}captureError(e,s){this.errors.capture(e,s)}addAction(e,s){let n=we(e,s,this.pageViewId(),this.drop);n&&this.record(n)}addTiming(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.addTiming(e,s))}startDuration(e,s){let n=Date.now();this.deferred.run(r=>r.perf.timings.startDuration(e,s,n))}stopDuration(e){let s=Date.now();this.deferred.run(n=>n.perf.timings.stopDuration(e,s))}sendFeedback(e){let s=this.feedbackState();return s!==null?Promise.reject(new A(s)):this.feedback((n,r)=>n.sendFeedback(r,e))}showReportDialog(e){this.feedbackState()===null&&this.feedback((s,n)=>s.showReportDialog(n,e!=null?e:{})).catch(this.drop)}markDirty(){this.sessionDirty=!0}guard(e){try{e()}catch{this.drop()}}load(e,s){e.catch(()=>{this.drop(),s()})}feedback(e){return import("./send-KNP5EOEZ.mjs").then(s=>e(s,this.feedbackHost()),()=>{throw new A("SEND_FAILED")})}feedbackState(){var e;return!this.ready||this.stopped?"NO_SESSION":((e=this.config)==null?void 0:e.feedbackEnabled)===!0?null:"FEEDBACK_DISABLED"}feedbackHost(){return{unavailable:()=>this.feedbackState(),sessionId:()=>this.session.id,sessionStartedAt:()=>this.session.startedAt,pageViewId:this.pageViewId,resolveRoute:()=>this.resolveRoute(),prepare:e=>{let s=te(e,this.options.beforeSend,this.drop);return s&&ne(s)},post:e=>(this.flush(!1),this.nativeFetch(G(this.options,"feedback"),{method:"POST",body:JSON.stringify({...this.header(),events:[e]}),keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain;charset=UTF-8"}}).then(s=>s.status)),sent:e=>this.guard(()=>{var s,n;return(n=(s=this.options).onFeedbackSent)==null?void 0:n.call(s,e)})}}loadDeferred(e){this.load(import("./deferred-P4QMIWWX.mjs").then(({installDeferred:s})=>this.guard(()=>{if(this.stopped)return;let n=s({instrument:e,resolveRoute:()=>this.resolveRoute(),captureConsole:this.options.captureConsole!==!1,describe:re});this.teardowns.push(n.teardown),this.deferred.resolve(n)})),()=>this.deferred.fail())}loadReplay(){var e;!this.replaying&&((e=this.session.decision)!=null&&e.replay)&&this.config.replay.enabled&&(this.replaying=import("./replay-JG4QNJJV.mjs").then(({recordReplay:s})=>s(this)).catch(this.drop))}loadSocketCapture(e){var n;let s=this.options.captureSocketMessages;!s||!e.socketMessages.enabled||((n=this.session.decision)==null?void 0:n.session)!==!0||(this.sockets.hold(),this.load(import("./socket-messages-TSBDPTWJ.mjs").then(({SocketMessageCapture:r})=>this.guard(()=>{this.stopped||this.sockets.resolve(new r(s,{sessionId:()=>this.session.id,record:o=>this.record(o),drop:this.drop}))})),()=>this.sockets.fail()))}onPageView(e){var s,n;this.shared.featureFlags.annotate(e),(s=this.deferred.get())==null||s.perf.annotate(e),this.record(e),e.id!==this.lastPageViewId&&(this.lastPageViewId=e.id,(n=this.deferred.get())==null||n.frustration.notifyActivity()),this.deferred.run(r=>r.perf.pageViewSent(e))}configure(e){if(this.stopped)return;if(!e||!e.enabled){this.shutdown();return}this.config=e,this.session.decision||this.decide(),this.ready=!0,this.install(),this.loadSocketCapture(e),this.loadReplay();let s=this.pending;this.pending=[];let n=this.pageViewId();for(let r of s)(r.type==="error"||r.type==="action")&&r.pageViewId===null&&(r.pageViewId=n),this.record(r)}decide(){let e=this.config,s=navigator.userAgent;this.session.decision=We({route:x(this.resolveRoute()),deviceType:Ue(s),browserFamily:Be(s),country:e.country,attributes:{...this.shared.attributes},random:this.session.random,sessionSampleRate:e.sessionSampleRate,replaySampleRate:e.replay.sampleRate},this.options.sampler,e.sessionQuotaExhausted,this.drop),M(this.session)}install(){let e={instrumentedOrigins:this.instrumentedOrigins,sessionId:()=>this.session.id,pageViewId:this.pageViewId,record:r=>this.record(r),drop:this.drop,trackTiming:(r,o,i)=>{var a;this.timings.set(r,{url:o,startedAt:i}),(a=this.deferred.get())==null||a.frustration.notifyActivity()},trackConnection:r=>this.connections.add(r),socketMessage:(r,o)=>this.sockets.run(i=>i.message(r,o)),socketClosed:r=>{let o=Date.now();this.sockets.run(i=>i.closed(r,o))}};this.pageViews=xe({resolveRoute:()=>this.resolveRoute(),record:r=>this.onPageView(r),onNavigation:()=>this.touch(),drop:this.drop});let s=setInterval(()=>this.guard(()=>this.flush(!1)),Pt),n=()=>this.guard(()=>this.touch());this.teardowns=[this.pageViews.stop,()=>clearInterval(s),Ce(e),De(e),Te(e),Oe(e),g(window,"click",n,!0),g(window,"keydown",n,!0),this.errors.install(),g(window,"pagehide",()=>this.guard(()=>this.onPageHide())),g(window,"pageshow",r=>this.guard(()=>{var o;r.persisted&&(this.closed=!1,this.sessionDirty=!0,(o=this.pageViews)==null||o.start("BACK_FORWARD"))})),g(document,"visibilitychange",()=>this.guard(()=>{var r;document.visibilityState==="hidden"&&((r=this.deferred.get())==null||r.perf.hidden(),this.flush(!0))}))],this.loadDeferred(e)}shutdown(){this.stopped=!0,this.ready=!1;let e=this.teardowns;this.teardowns=[],e.reverse().forEach(s=>this.guard(s)),this.deferred.close(),this.sockets.close(),this.pending=[],this.queue=[],this.connections.clear(),this.timings.clear()}resolveRoute(){let{routeResolver:e}=this.options;if(e)try{return String(e(window.location))}catch{this.drop()}return window.location.pathname}touch(){var s,n;if(!this.ready)return;let e=Date.now();if(!de(this.session,e)){this.session.lastActivityAt=e,M(this.session);return}(s=this.pageViews)==null||s.end(),this.flush(!1),this.shared.dropped+=this.queue.length,this.queue=[],this.session=le(e),this.decide(),this.loadReplay(),this.filter.reset(),this.sessionDirty=!0,this.closed=!1,(n=this.pageViews)==null||n.start("SPA")}onPageHide(){var e;(e=this.pageViews)==null||e.end();for(let s of this.connections)s.done||(s.event.durationMs=Date.now()-s.startedAt,s.done=!0,s.dirty=!0);this.closed=!0,this.sessionDirty=!0,this.flush(!0)}record(e){var s,n;try{if(this.stopped)return;if(this.errors.observe(e),!this.ready){this.pending.length<_t?this.pending.push(e):this.drop();return}(s=this.sockets.get())==null||s.observe(e);let r=((n=this.session.decision)==null?void 0:n.session)===!0;if(!r&&e.type!=="error"&&e.type!=="pageView")return;let o=te(e,this.options.beforeSend,this.drop);if(!o)return;ne(o),o.type==="pageView"&&this.session.entryPath===null&&(this.session.entryPath=o.route,M(this.session));for(let i of this.filter.accept(o,r))this.enqueue(i)}catch{this.drop()}}enqueue(e){if(this.queue.length>=Ge){this.drop();return}this.queue.push(e),this.queue.length>=xt&&!this.flushing&&this.flush(!1)}flush(e){var s,n;if(!(!this.ready||this.flushing||this.transport.isPaused(Date.now()))){this.flushing=!0;try{for(let p of this.connections)p.dirty&&(p.dirty=!1,this.record({...p.event})),p.done&&this.connections.delete(p);let r=this.queue;this.queue=[],this.fillTimings(r);let o=((s=this.session.decision)==null?void 0:s.session)===!0;if(r.length===0&&!(o&&this.sessionDirty))return;let a=this.sessionDirty||this.shared.dropped>0?{id:this.session.id,type:"session",entryPath:(n=this.session.entryPath)!=null?n:"/",sampled:o,closed:this.closed,droppedEvents:this.shared.dropped}:null;this.shared.dropped=0,this.sessionDirty=!1,this.transport.send(this.header(),a?[a,...r]:r,e)}finally{this.flushing=!1}}}header(){let e={sessionId:this.session.id,sessionStartedAt:b(this.session.startedAt)};return this.options.release&&(e.release=this.options.release),this.shared.actor!==void 0&&(e.actor=this.shared.actor),this.shared.attributesSet&&(e.attributes={...this.shared.attributes}),this.shared.featureFlags.hasAny()&&(e.featureFlags={...this.shared.featureFlags.session}),e}fillTimings(e){for(let s of e){let n=this.timings.get(s.id);n&&(this.timings.delete(s.id),Object.assign(s,Ee(n.url,n.startedAt)))}}onResult(e,s,n){if(s==="OK")return;if(s==="CUT"){this.session.cut=!0,M(this.session),this.shutdown();return}let r=e.filter(i=>i.type!=="session"),o=e.find(i=>i.type==="session");if(o&&(this.shared.dropped+=o.droppedEvents,this.sessionDirty=!0),s==="RETRY"&&n===this.session.id){let i=r.slice(0,Math.max(0,Ge-this.queue.length));this.shared.dropped+=r.length-i.length,this.queue=[...i,...this.queue];return}this.shared.dropped+=r.length}},$e=null,f={actor:void 0,attributes:{},attributesSet:!1,dropped:0,featureFlags:new D},v=()=>$e,ce=t=>{$e=t};var Ye=(s=>(s.ALL="ALL",s.ON_ANOMALY="ON_ANOMALY",s))(Ye||{});var S=t=>{try{t()}catch{f.dropped+=1}},En={init(t){S(()=>{if(v()||!(t!=null&&t.token)||!t.applicationId||!t.apiUrl&&!t.proxyUrl||typeof window=="undefined"||typeof window.fetch!="function")return;let e=new Q(t,f);ce(e),e.start()})},setActor(t){S(()=>{var s;let e=Se(t);if(e===void 0){f.dropped+=1;return}f.actor=e,(s=v())==null||s.markDirty()})},setAttributes(t){S(()=>{var e;f.attributes=I(f.attributes,t,()=>{f.dropped+=1}),f.attributesSet=!0,(e=v())==null||e.markDirty()})},captureError(t,e){S(()=>{var s;return(s=v())==null?void 0:s.captureError(t,e)})},addAction(t,e){S(()=>{var s;return(s=v())==null?void 0:s.addAction(t,e)})},addFeatureFlagEvaluation(t,e){S(()=>{var s;f.featureFlags.add(t,e,()=>f.dropped+=1)&&((s=v())==null||s.markDirty())})},sendFeedback(t){var e,s;return(s=(e=v())==null?void 0:e.sendFeedback(t))!=null?s:Promise.reject(new A("NO_SESSION"))},showReportDialog(t){S(()=>{var e;return(e=v())==null?void 0:e.showReportDialog(t)})},addTiming(t){S(()=>{var e;return(e=v())==null?void 0:e.addTiming(t)})},startDuration(t,e){S(()=>{var s;return(s=v())==null?void 0:s.startDuration(t,e)})},stopDuration(t){S(()=>{var e;return(e=v())==null?void 0:e.stopDuration(t)})},stop(){S(()=>{var t;(t=v())==null||t.stop(),ce(null),f.actor=void 0,f.attributes={},f.attributesSet=!1,f.dropped=0,f.featureFlags=new D})}};export{En as AbyssRum,A as RumFeedbackError,z as RumFeedbackErrorCode,Ye as RumSocketCaptureMode};