UNPKG

@cloudflare/workers-shared

Version:

Package that is used at Cloudflare to power some internal features of Cloudflare Workers.

8 lines • 74.2 kB
import{WorkerEntrypoint as lo}from"cloudflare:workers";var K=class{constructor(e){this.performanceTimer=e}now(){return this.performanceTimer?this.performanceTimer.timeOrigin+this.performanceTimer.now():Date.now()}};var Wt=Object.prototype.toString;function j(t){switch(Wt.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return w(t,Error)}}function nt(t,e){return Wt.call(t)===`[object ${e}]`}function rt(t){return nt(t,"ErrorEvent")}function st(t){return nt(t,"String")}function Z(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function be(t){return t===null||Z(t)||typeof t!="object"&&typeof t!="function"}function R(t){return nt(t,"Object")}function ot(t){return typeof Event<"u"&&w(t,Event)}function it(t){return typeof Element<"u"&&w(t,Element)}function O(t){return!!(t&&t.then&&typeof t.then=="function")}function at(t){return R(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function w(t,e){try{return t instanceof e}catch{return!1}}function ct(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function M(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}var P="8.9.2";var g=globalThis;function X(t,e,n){let r=n||g,s=r.__SENTRY__=r.__SENTRY__||{},o=s[P]=s[P]||{};return o[t]||(o[t]=e())}var mr=g,hr=80;function Kt(t,e={}){if(!t)return"<unknown>";try{let n=t,r=5,s=[],o=0,i=0,a=" > ",c=a.length,u,l=Array.isArray(e)?e:e.keyAttrs,p=!Array.isArray(e)&&e.maxStringLength||hr;for(;n&&o++<r&&(u=gr(n,l),!(u==="html"||o>1&&i+s.length*c+u.length>=p));)s.push(u),i+=u.length,n=n.parentNode;return s.reverse().join(a)}catch{return"<unknown>"}}function gr(t,e){let n=t,r=[],s,o,i,a,c;if(!n||!n.tagName)return"";if(mr.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());let u=e&&e.length?e.filter(p=>n.getAttribute(p)).map(p=>[p,n.getAttribute(p)]):null;if(u&&u.length)u.forEach(p=>{r.push(`[${p[0]}="${p[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),s=n.className,s&&st(s))for(o=s.split(/\s+/),c=0;c<o.length;c++)r.push(`.${o[c]}`);let l=["aria-label","type","name","title","alt"];for(c=0;c<l.length;c++)i=l[c],a=n.getAttribute(i),a&&r.push(`[${i}="${a}"]`);return r.join("")}var L=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var _r="Sentry Logger ",ut=["debug","info","warn","error","log","assert","trace"],lt={};function Re(t){if(!("console"in g))return t();let e=g.console,n={},r=Object.keys(lt);r.forEach(s=>{let o=lt[s];n[s]=e[s],e[s]=o});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function Er(){let t=!1,e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return L?ut.forEach(n=>{e[n]=(...r)=>{t&&Re(()=>{g.console[n](`${_r}[${n}]:`,...r)})}}):ut.forEach(n=>{e[n]=()=>{}}),e}var h=Er();var Sr=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function yr(t){return t==="http"||t==="https"}function k(t,e=!1){let{host:n,path:r,pass:s,port:o,projectId:i,protocol:a,publicKey:c}=t;return`${a}://${c}${e&&s?`:${s}`:""}@${n}${o?`:${o}`:""}/${r&&`${r}/`}${i}`}function Zt(t){let e=Sr.exec(t);if(!e){Re(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}let[n,r,s="",o,i="",a]=e.slice(1),c="",u=a,l=u.split("/");if(l.length>1&&(c=l.slice(0,-1).join("/"),u=l.pop()),u){let p=u.match(/^\d+/);p&&(u=p[0])}return Xt({host:o,pass:s,path:c,projectId:u,port:i,protocol:n,publicKey:r})}function Xt(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function Tr(t){if(!L)return!0;let{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(i=>t[i]?!1:(h.error(`Invalid Sentry Dsn: ${i} missing`),!0))?!1:n.match(/^\d+$/)?yr(r)?e&&isNaN(parseInt(e,10))?(h.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(h.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(h.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Ce(t){let e=typeof t=="string"?Zt(t):Xt(t);if(!(!e||!Tr(e)))return e}var I=class extends Error{constructor(e,n="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=n}};function G(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{L&&h.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function dt(t){return Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&")}function Ne(t){if(j(t))return{message:t.message,name:t.name,stack:t.stack,...en(t)};if(ot(t)){let e={type:t.type,target:Qt(t.target),currentTarget:Qt(t.currentTarget),...en(t)};return typeof CustomEvent<"u"&&w(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function Qt(t){try{return it(t)?Kt(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function en(t){if(typeof t=="object"&&t!==null){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function re(t,e=40){let n=Object.keys(Ne(t));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=e)return M(n[0],e);for(let r=n.length;r>0;r--){let s=n.slice(0,r).join(", ");if(!(s.length>e))return r===n.length?s:M(s,e)}return""}function S(t){return pt(t,new Map)}function pt(t,e){if(Ir(t)){let n=e.get(t);if(n!==void 0)return n;let r={};e.set(t,r);for(let s of Object.keys(t))typeof t[s]<"u"&&(r[s]=pt(t[s],e));return r}if(Array.isArray(t)){let n=e.get(t);if(n!==void 0)return n;let r=[];return e.set(t,r),t.forEach(s=>{r.push(pt(s,e))}),r}return t}function Ir(t){if(!R(t))return!1;try{let e=Object.getPrototypeOf(t).constructor.name;return!e||e==="Object"}catch{return!0}}var ve="?",tn=/\(error: (.*)\)/,nn=/captureMessage|captureException/;function Oe(...t){let e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{let o=[],i=n.split(` `);for(let a=r;a<i.length;a++){let c=i[a];if(c.length>1024)continue;let u=tn.test(c)?c.replace(tn,"$1"):c;if(!u.match(/\S*Error: /)){for(let l of e){let p=l(u);if(p){o.push(p);break}}if(o.length>=50+s)break}}return rn(o.slice(s))}}function mt(t){return Array.isArray(t)?Oe(...t):t}function rn(t){if(!t.length)return[];let e=Array.from(t);return/sentryWrapped/.test(e[e.length-1].function||"")&&e.pop(),e.reverse(),nn.test(e[e.length-1].function||"")&&(e.pop(),nn.test(e[e.length-1].function||"")&&e.pop()),e.slice(0,50).map(n=>({...n,filename:n.filename||e[e.length-1].filename,function:n.function||ve}))}var ft="<anonymous>";function se(t){try{return!t||typeof t!="function"?ft:t.name||ft}catch{return ft}}var we={},sn={};function De(t,e){we[t]=we[t]||[],we[t].push(e)}function Me(t,e){sn[t]||(e(),sn[t]=!0)}function Pe(t,e){let n=t&&we[t];if(n)for(let r of n)try{r(e)}catch(s){L&&h.error(`Error while triggering instrumentation handler. Type: ${t} Name: ${se(r)} Error:`,s)}}var on=1e3;function Q(){return Date.now()/on}function Ar(){let{performance:t}=g;if(!t||!t.now)return Q;let e=Date.now()-t.now(),n=t.timeOrigin==null?e:t.timeOrigin;return()=>(n+t.now())/on}var ie=Ar(),oe,xr=(()=>{let{performance:t}=g;if(!t||!t.now){oe="none";return}let e=3600*1e3,n=t.now(),r=Date.now(),s=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,o=s<e,i=t.timing&&t.timing.navigationStart,c=typeof i=="number"?Math.abs(i+n-r):e,u=c<e;return o||u?s<=c?(oe="timeOrigin",t.timeOrigin):(oe="navigationStart",i):(oe="dateNow",r)})();var Le=null;function ht(t){let e="error";De(e,t),Me(e,br)}function br(){Le=g.onerror,g.onerror=function(t,e,n,r,s){return Pe("error",{column:r,error:s,line:n,msg:t,url:e}),Le&&!Le.__SENTRY_LOADER__?Le.apply(this,arguments):!1},g.onerror.__SENTRY_INSTRUMENTED__=!0}var ke=null;function gt(t){let e="unhandledrejection";De(e,t),Me(e,Rr)}function Rr(){ke=g.onunhandledrejection,g.onunhandledrejection=function(t){return Pe("unhandledrejection",t),ke&&!ke.__SENTRY_LOADER__?ke.apply(this,arguments):!0},g.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}function an(){let t=typeof WeakSet=="function",e=t?new WeakSet:[];function n(s){if(t)return e.has(s)?!0:(e.add(s),!1);for(let o=0;o<e.length;o++)if(e[o]===s)return!0;return e.push(s),!1}function r(s){if(t)e.delete(s);else for(let o=0;o<e.length;o++)if(e[o]===s){e.splice(o,1);break}}return[n,r]}function T(){let t=g,e=t.crypto||t.msCrypto,n=()=>Math.random()*16;try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{let r=new Uint8Array(1);return e.getRandomValues(r),r[0]})}catch{}return("10000000100040008000"+1e11).replace(/[018]/g,r=>(r^(n()&15)>>r/4).toString(16))}function Cr(t){return t.exception&&t.exception.values?t.exception.values[0]:void 0}function ae(t,e,n){let r=t.exception=t.exception||{},s=r.values=r.values||[],o=s[0]=s[0]||{};o.value||(o.value=e||""),o.type||(o.type=n||"Error")}function Y(t,e){let n=Cr(t);if(!n)return;let r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism={...r,...s,...e},e&&"data"in e){let o={...s&&s.data,...e.data};n.mechanism.data=o}}function Fe(t){if(t&&t.__sentry_captured__)return!0;try{G(t,"__sentry_captured__",!0)}catch{}return!1}function ce(t){return Array.isArray(t)?t:[t]}function C(t,e=100,n=1/0){try{return _t("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function ee(t,e=3,n=100*1024){let r=C(t,e);return wr(r)>n?ee(t,e-1,n):r}function _t(t,e,n=1/0,r=1/0,s=an()){let[o,i]=s;if(e==null||["number","boolean","string"].includes(typeof e)&&!Number.isNaN(e))return e;let a=Nr(t,e);if(!a.startsWith("[object "))return a;if(e.__sentry_skip_normalization__)return e;let c=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(c===0)return a.replace("object ","");if(o(e))return"[Circular ~]";let u=e;if(u&&typeof u.toJSON=="function")try{let d=u.toJSON();return _t("",d,c-1,r,s)}catch{}let l=Array.isArray(e)?[]:{},p=0,f=Ne(e);for(let d in f){if(!Object.prototype.hasOwnProperty.call(f,d))continue;if(p>=r){l[d]="[MaxProperties ~]";break}let m=f[d];l[d]=_t(d,m,c-1,r,s),p++}return i(e),l}function Nr(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(ct(e))return"[VueViewModel]";if(at(e))return"[SyntheticEvent]";if(typeof e=="number"&&e!==e)return"[NaN]";if(typeof e=="function")return`[Function: ${se(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;let n=vr(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function vr(t){let e=Object.getPrototypeOf(t);return e?e.constructor.name:"null prototype"}function Or(t){return~-encodeURI(t).split(/%..|./).length}function wr(t){return Or(JSON.stringify(t))}function Dr(t,e){let n=0;for(let r=t.length-1;r>=0;r--){let s=t[r];s==="."?t.splice(r,1):s===".."?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var Mr=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function Pr(t){let e=t.length>1024?`<truncated>${t.slice(-1024)}`:t,n=Mr.exec(e);return n?n.slice(1):[]}function Et(...t){let e="",n=!1;for(let r=t.length-1;r>=-1&&!n;r--){let s=r>=0?t[r]:"/";s&&(e=`${s}/${e}`,n=s.charAt(0)==="/")}return e=Dr(e.split("/").filter(r=>!!r),!n).join("/"),(n?"/":"")+e||"."}function cn(t){let e=0;for(;e<t.length&&t[e]==="";e++);let n=t.length-1;for(;n>=0&&t[n]==="";n--);return e>n?[]:t.slice(e,n-e+1)}function St(t,e){t=Et(t).slice(1),e=Et(e).slice(1);let n=cn(t.split("/")),r=cn(e.split("/")),s=Math.min(n.length,r.length),o=s;for(let a=0;a<s;a++)if(n[a]!==r[a]){o=a;break}let i=[];for(let a=o;a<n.length;a++)i.push("..");return i=i.concat(r.slice(o)),i.join("/")}function ue(t,e){let n=Pr(t)[2];return e&&n.slice(e.length*-1)===e&&(n=n.slice(0,n.length-e.length)),n}var D;(function(t){t[t.PENDING=0]="PENDING";let n=1;t[t.RESOLVED=n]="RESOLVED";let r=2;t[t.REJECTED=r]="REJECTED"})(D||(D={}));function x(t){return new N(e=>{e(t)})}function z(t){return new N((e,n)=>{n(t)})}var N=class t{constructor(e){t.prototype.__init.call(this),t.prototype.__init2.call(this),t.prototype.__init3.call(this),t.prototype.__init4.call(this),this._state=D.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(n){this._reject(n)}}then(e,n){return new t((r,s)=>{this._handlers.push([!1,o=>{if(!e)r(o);else try{r(e(o))}catch(i){s(i)}},o=>{if(!n)s(o);else try{r(n(o))}catch(i){s(i)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new t((n,r)=>{let s,o;return this.then(i=>{o=!1,s=i,e&&e()},i=>{o=!0,s=i,e&&e()}).then(()=>{if(o){r(s);return}n(s)})})}__init(){this._resolve=e=>{this._setResult(D.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(D.REJECTED,e)}}__init3(){this._setResult=(e,n)=>{if(this._state===D.PENDING){if(O(n)){n.then(this._resolve,this._reject);return}this._state=e,this._value=n,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===D.PENDING)return;let e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===D.RESOLVED&&n[1](this._value),this._state===D.REJECTED&&n[2](this._value),n[0]=!0)})}}};function yt(t){let e=[];function n(){return t===void 0||e.length<t}function r(i){return e.splice(e.indexOf(i),1)[0]}function s(i){if(!n())return z(new I("Not adding Promise because buffer limit was reached."));let a=i();return e.indexOf(a)===-1&&e.push(a),a.then(()=>r(a)).then(null,()=>r(a).then(null,()=>{})),a}function o(i){return new N((a,c)=>{let u=e.length;if(!u)return a(!0);let l=setTimeout(()=>{i&&i>0&&a(!1)},i);e.forEach(p=>{x(p).then(()=>{--u||(clearTimeout(l),a(!0))},c)})})}return{$:e,add:s,drain:o}}function un(t,e=!1){return!(e||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&t!==void 0&&!t.includes("node_modules/")}function ln(t){let e=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return r=>{let s=r.match(n);if(s){let o,i,a,c,u;if(s[1]){a=s[1];let f=a.lastIndexOf(".");if(a[f-1]==="."&&f--,f>0){o=a.slice(0,f),i=a.slice(f+1);let d=o.indexOf(".Module");d>0&&(a=a.slice(d+1),o=o.slice(0,d))}c=void 0}i&&(c=o,u=i),i==="<anonymous>"&&(u=void 0,a=void 0),a===void 0&&(u=u||ve,a=c?`${c}.${u}`:u);let l=s[2]&&s[2].startsWith("file://")?s[2].slice(7):s[2],p=s[5]==="native";return l&&l.match(/\/[A-Z]:/)&&(l=l.slice(1)),!l&&s[5]&&!p&&(l=s[5]),{filename:l,module:t?t(l):void 0,function:a,lineno:parseInt(s[3],10)||void 0,colno:parseInt(s[4],10)||void 0,in_app:un(l,p)}}if(r.match(e))return{filename:r}}}function Tt(t){return[90,ln(t)]}function F(t,e=[]){return[t,e]}function At(t,e){let[n,r]=t;return[n,[...r,e]]}function Ue(t,e){let n=t[1];for(let r of n){let s=r[0].type;if(e(r,s))return!0}return!1}function It(t){return g.__SENTRY__&&g.__SENTRY__.encodePolyfill?g.__SENTRY__.encodePolyfill(t):new TextEncoder().encode(t)}function xt(t){let[e,n]=t,r=JSON.stringify(e);function s(o){typeof r=="string"?r=typeof o=="string"?r+o:[It(r),o]:r.push(typeof o=="string"?It(o):o)}for(let o of n){let[i,a]=o;if(s(` ${JSON.stringify(i)} `),typeof a=="string"||a instanceof Uint8Array)s(a);else{let c;try{c=JSON.stringify(a)}catch{c=JSON.stringify(C(a))}s(c)}}return typeof r=="string"?r:Lr(r)}function Lr(t){let e=t.reduce((s,o)=>s+o.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}function bt(t){let e=typeof t.data=="string"?It(t.data):t.data;return[S({type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType}),e]}var kr={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",statsd:"metric_bucket"};function $e(t){return kr[t]}function Be(t){if(!t||!t.sdk)return;let{name:e,version:n}=t.sdk;return{name:e,version:n}}function Rt(t,e,n,r){let s=t.sdkProcessingMetadata&&t.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date().toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:k(r)},...s&&{trace:S({...s})}}}function pn(t,e=Date.now()){let n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;let r=Date.parse(`${t}`);return isNaN(r)?6e4:r-e}function dn(t,e){return t[e]||t.all||0}function Ct(t,e,n=Date.now()){return dn(t,e)>n}function Nt(t,{statusCode:e,headers:n},r=Date.now()){let s={...t},o=n&&n["x-sentry-rate-limits"],i=n&&n["retry-after"];if(o)for(let a of o.trim().split(",")){let[c,u,,,l]=a.split(":",5),p=parseInt(c,10),f=(isNaN(p)?60:p)*1e3;if(!u)s.all=r+f;else for(let d of u.split(";"))d==="metric_bucket"?(!l||l.split(";").includes("custom"))&&(s[d]=r+f):s[d]=r+f}else i?s.all=r+pn(i,r):e===429&&(s.all=r+60*1e3);return s}function vt(t,e){return t(e.stack||"",1)}function fn(t,e){let n={type:e.name||e.constructor.name,value:e.message},r=vt(t,e);return r.length&&(n.stacktrace={frames:r}),n}function Fr(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];if(n instanceof Error)return n}}function Ur(t){if("name"in t&&typeof t.name=="string"){let r=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(r+=` with message '${t.message}'`),r}else if("message"in t&&typeof t.message=="string")return t.message;let e=re(t);if(rt(t))return`Event \`ErrorEvent\` captured as exception with message \`${t.message}\``;let n=$r(t);return`${n&&n!=="Object"?`'${n}'`:"Object"} captured as exception with keys: ${e}`}function $r(t){try{let e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{}}function Br(t,e,n,r){if(j(n))return[n,void 0];if(e.synthetic=!0,R(n)){let o=t&&t.getOptions().normalizeDepth,i={__serialized__:ee(n,o)},a=Fr(n);if(a)return[a,i];let c=Ur(n),u=r&&r.syntheticException||new Error(c);return u.message=c,[u,i]}let s=r&&r.syntheticException||new Error(n);return s.message=`${n}`,[s,void 0]}function Ot(t,e,n,r){let o=r&&r.data&&r.data.mechanism||{handled:!0,type:"generic"},[i,a]=Br(t,o,n,r),c={exception:{values:[fn(e,i)]}};return a&&(c.extra=a),ae(c,void 0,void 0),Y(c,o),{...c,event_id:r&&r.event_id}}function wt(t,e,n="info",r,s){let o={event_id:r&&r.event_id,level:n};if(s&&r&&r.syntheticException){let i=vt(t,r.syntheticException);i.length&&(o.exception={values:[{value:e,stacktrace:{frames:i}}]})}if(Z(e)){let{__sentry_template_string__:i,__sentry_template_values__:a}=e;return o.logentry={message:i,params:a},o}return o.message=e,o}function He(){return{traceId:T(),spanId:T().substring(16)}}var _=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;function U(){return le(g),g}function le(t){let e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||P,e[P]=e[P]||{}}function pe(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||ie(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:T()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{let n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}var Dt="_sentrySpan";function Mt(t,e){e?G(t,Dt,e):delete t[Dt]}function J(t){return t[Dt]}var jr=100,Pt=class t{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=He()}clone(){let e=new t;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,Mt(e,J(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&pe(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;let n=typeof e=="function"?e(this):e,[r,s]=n instanceof b?[n.getScopeData(),n.getRequestSession()]:R(n)?[e,e.requestSession]:[],{tags:o,extra:i,user:a,contexts:c,level:u,fingerprint:l=[],propagationContext:p}=r||{};return this._tags={...this._tags,...o},this._extra={...this._extra,...i},this._contexts={...this._contexts,...c},a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),l.length&&(this._fingerprint=l),p&&(this._propagationContext=p),s&&(this._requestSession=s),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,Mt(this,void 0),this._attachments=[],this._propagationContext=He(),this._notifyScopeListeners(),this}addBreadcrumb(e,n){let r=typeof n=="number"?n:jr;if(r<=0)return this;let s={timestamp:Q(),...e},o=this._breadcrumbs;return o.push(s),this._breadcrumbs=o.length>r?o.slice(-r):o,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:J(this)}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){let r=n&&n.event_id?n.event_id:T();if(!this._client)return h.warn("No client configured on scope - will not capture exception!"),r;let s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...n,event_id:r},this),r}captureMessage(e,n,r){let s=r&&r.event_id?r.event_id:T();if(!this._client)return h.warn("No client configured on scope - will not capture message!"),s;let o=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:o,...r,event_id:s},this),s}captureEvent(e,n){let r=n&&n.event_id?n.event_id:T();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(h.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}},b=Pt;function mn(){return X("defaultCurrentScope",()=>new b)}function hn(){return X("defaultIsolationScope",()=>new b)}var Lt=class{constructor(e,n){let r;e?r=e:r=new b;let s;n?s=n:s=new b,this._stack=[{scope:r}],this._isolationScope=s}withScope(e){let n=this._pushScope(),r;try{r=e(n)}catch(s){throw this._popScope(),s}return O(r)?r.then(s=>(this._popScope(),s),s=>{throw this._popScope(),s}):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}_popScope(){return this.getStack().length<=1?!1:!!this.getStack().pop()}};function te(){let t=U(),e=le(t);return e.stack=e.stack||new Lt(mn(),hn())}function Gr(t){return te().withScope(t)}function Yr(t,e){let n=te();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function gn(t){return te().withScope(()=>t(te().getIsolationScope()))}function _n(){return{withIsolationScope:gn,withScope:Gr,withSetScope:Yr,withSetIsolationScope:(t,e)=>gn(e),getCurrentScope:()=>te().getScope(),getIsolationScope:()=>te().getIsolationScope()}}function de(t){let e=le(t);return e.acs?e.acs:_n()}function kt(){let t=U();return de(t).getCurrentScope()}function V(){let t=U();return de(t).getIsolationScope()}function En(){return X("globalScope",()=>new b)}function Sn(){return kt().getClient()}var zr="_sentryMetrics";function yn(t){let e=t[zr];if(!e)return;let n={};for(let[,[r,s]]of e)n[r]||(n[r]=[]),n[r].push(S(s));return n}var Tn="sentry.source",In="sentry.sample_rate",An="sentry.op",xn="sentry.origin";var Jr=1;function je(t){let{spanId:e,traceId:n}=t.spanContext(),{parent_span_id:r}=ne(t);return S({parent_span_id:r,span_id:e,trace_id:n})}function bn(t){return typeof t=="number"?Rn(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Rn(t.getTime()):ie()}function Rn(t){return t>9999999999?t/1e3:t}function ne(t){if(qr(t))return t.getSpanJSON();try{let{spanId:e,traceId:n}=t.spanContext();if(Vr(t)){let{attributes:r,startTime:s,name:o,endTime:i,parentSpanId:a,status:c}=t;return S({span_id:e,trace_id:n,data:r,description:o,parent_span_id:a,start_timestamp:bn(s),timestamp:bn(i)||void 0,status:Wr(c),op:r[An],origin:r[xn],_metrics_summary:yn(t)})}return{span_id:e,trace_id:n}}catch{return{}}}function Vr(t){let e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function qr(t){return typeof t.getSpanJSON=="function"}function Cn(t){let{traceFlags:e}=t.spanContext();return e===Jr}function Wr(t){if(!(!t||t.code===0))return t.code===1?"ok":t.message||"unknown_error"}var Kr="_sentryRootSpan";function $(t){return t[Kr]||t}function Nn(){let t=U(),e=de(t);return e.getActiveSpan?e.getActiveSpan():J(kt())}var vn=!1;function On(){vn||(vn=!0,ht(Ft),gt(Ft))}function Ft(){let t=Nn(),e=t&&$(t);if(e){let n="internal_error";_&&h.log(`[Tracing] Root span: ${n} -> Global error occured`),e.setStatus({code:2,message:n})}}Ft.tag="sentry_tracingErrorCallback";var Ge="production";var Zr="_frozenDsc";function fe(t,e){let n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s=S({environment:n.environment||Ge,release:n.release,public_key:r,trace_id:t});return e.emit("createDsc",s),s}function Ye(t){let e=Sn();if(!e)return{};let n=fe(ne(t).trace_id||"",e),r=$(t);if(!r)return n;let s=r[Zr];if(s)return s;let o=ne(r),i=o.data||{},a=i[In];a!=null&&(n.sample_rate=`${a}`);let c=i[Tn];return c&&c!=="url"&&(n.transaction=o.description),n.sampled=String(Cn(r)),e.emit("createDsc",n),n}function wn(t){if(typeof t=="boolean")return Number(t);let e=typeof t=="string"?parseFloat(t):t;if(typeof e!="number"||isNaN(e)||e<0||e>1){_&&h.warn(`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(t)} of type ${JSON.stringify(typeof t)}.`);return}return e}function Xr(t,e){return e&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||e.name,t.sdk.version=t.sdk.version||e.version,t.sdk.integrations=[...t.sdk.integrations||[],...e.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...e.packages||[]]),t}function Dn(t,e,n,r){let s=Be(n),o={sent_at:new Date().toISOString(),...s&&{sdk:s},...!!r&&e&&{dsn:k(e)}},i="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return F(o,[i])}function Mn(t,e,n,r){let s=Be(n),o=t.type&&t.type!=="replay_event"?t.type:"event";Xr(t,n&&n.sdk);let i=Rt(t,s,r,e);return delete t.sdkProcessingMetadata,F(i,[[{type:o},t]])}function ze(t,e,n,r=0){return new N((s,o)=>{let i=t[r];if(e===null||typeof i!="function")s(e);else{let a=i({...e},n);_&&i.id&&a===null&&h.log(`Event processor "${i.id}" dropped event`),O(a)?a.then(c=>ze(t,c,n,r+1).then(s)).then(null,o):ze(t,a,n,r+1).then(s).then(null,o)}})}function Pn(t,e){let{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:o}=e;Qr(t,e),r&&ns(t,r),rs(t,n),es(t,s),ts(t,o)}function Ut(t,e){let{extra:n,tags:r,user:s,contexts:o,level:i,sdkProcessingMetadata:a,breadcrumbs:c,fingerprint:u,eventProcessors:l,attachments:p,propagationContext:f,transactionName:d,span:m}=e;me(t,"extra",n),me(t,"tags",r),me(t,"user",s),me(t,"contexts",o),me(t,"sdkProcessingMetadata",a),i&&(t.level=i),d&&(t.transactionName=d),m&&(t.span=m),c.length&&(t.breadcrumbs=[...t.breadcrumbs,...c]),u.length&&(t.fingerprint=[...t.fingerprint,...u]),l.length&&(t.eventProcessors=[...t.eventProcessors,...l]),p.length&&(t.attachments=[...t.attachments,...p]),t.propagationContext={...t.propagationContext,...f}}function me(t,e,n){if(n&&Object.keys(n).length){t[e]={...t[e]};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[e][r]=n[r])}}function Qr(t,e){let{extra:n,tags:r,user:s,contexts:o,level:i,transactionName:a}=e,c=S(n);c&&Object.keys(c).length&&(t.extra={...c,...t.extra});let u=S(r);u&&Object.keys(u).length&&(t.tags={...u,...t.tags});let l=S(s);l&&Object.keys(l).length&&(t.user={...l,...t.user});let p=S(o);p&&Object.keys(p).length&&(t.contexts={...p,...t.contexts}),i&&(t.level=i),a&&t.type!=="transaction"&&(t.transaction=a)}function es(t,e){let n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function ts(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function ns(t,e){t.contexts={trace:je(e),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Ye(e),...t.sdkProcessingMetadata};let n=$(e),r=ne(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function rs(t,e){t.fingerprint=t.fingerprint?ce(t.fingerprint):[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint}function kn(t,e,n,r,s,o){let{normalizeDepth:i=3,normalizeMaxBreadth:a=1e3}=t,c={...e,event_id:e.event_id||n.event_id||T(),timestamp:e.timestamp||Q()},u=n.integrations||t.integrations.map(A=>A.name);ss(c,t),as(c,u),e.type===void 0&&os(c,t.stackParser);let l=us(r,n.captureContext);n.mechanism&&Y(c,n.mechanism);let p=s?s.getEventProcessors():[],f=En().getScopeData();if(o){let A=o.getScopeData();Ut(f,A)}if(l){let A=l.getScopeData();Ut(f,A)}let d=[...n.attachments||[],...f.attachments];d.length&&(n.attachments=d),Pn(c,f);let m=[...p,...f.eventProcessors];return ze(m,c,n).then(A=>(A&&is(A),typeof i=="number"&&i>0?cs(A,i,a):A))}function ss(t,e){let{environment:n,release:r,dist:s,maxValueLength:o=250}=e;"environment"in t||(t.environment="environment"in e?n:Ge),t.release===void 0&&r!==void 0&&(t.release=r),t.dist===void 0&&s!==void 0&&(t.dist=s),t.message&&(t.message=M(t.message,o));let i=t.exception&&t.exception.values&&t.exception.values[0];i&&i.value&&(i.value=M(i.value,o));let a=t.request;a&&a.url&&(a.url=M(a.url,o))}var Ln=new WeakMap;function os(t,e){let n=g._sentryDebugIds;if(!n)return;let r,s=Ln.get(e);s?r=s:(r=new Map,Ln.set(e,r));let o=Object.keys(n).reduce((i,a)=>{let c,u=r.get(a);u?c=u:(c=e(a),r.set(a,c));for(let l=c.length-1;l>=0;l--){let p=c[l];if(p.filename){i[p.filename]=n[a];break}}return i},{});try{t.exception.values.forEach(i=>{i.stacktrace.frames.forEach(a=>{a.filename&&(a.debug_id=o[a.filename])})})}catch{}}function is(t){let e={};try{t.exception.values.forEach(r=>{r.stacktrace.frames.forEach(s=>{s.debug_id&&(s.abs_path?e[s.abs_path]=s.debug_id:s.filename&&(e[s.filename]=s.debug_id),delete s.debug_id)})})}catch{}if(Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];let n=t.debug_meta.images;Object.keys(e).forEach(r=>{n.push({type:"sourcemap",code_file:r,debug_id:e[r]})})}function as(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function cs(t,e,n){if(!t)return null;let r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(s=>({...s,...s.data&&{data:C(s.data,e,n)}}))},...t.user&&{user:C(t.user,e,n)},...t.contexts&&{contexts:C(t.contexts,e,n)},...t.extra&&{extra:C(t.extra,e,n)}};return t.contexts&&t.contexts.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=C(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(s=>({...s,...s.data&&{data:C(s.data,e,n)}}))),r}function us(t,e){if(!e)return t;let n=t?t.clone():new b;return n.update(e),n}var Je=class{constructor(e,n){this._client=e,this.flushTimeout=60,this._pendingAggregates={},this._isEnabled=!0,this._intervalId=setInterval(()=>this.flush(),this.flushTimeout*1e3),this._intervalId.unref&&this._intervalId.unref(),this._sessionAttrs=n}flush(){let e=this.getSessionAggregates();e.aggregates.length!==0&&(this._pendingAggregates={},this._client.sendSession(e))}getSessionAggregates(){let e=Object.keys(this._pendingAggregates).map(r=>this._pendingAggregates[parseInt(r)]),n={attrs:this._sessionAttrs,aggregates:e};return S(n)}close(){clearInterval(this._intervalId),this._isEnabled=!1,this.flush()}incrementSessionStatusCount(){if(!this._isEnabled)return;let e=V(),n=e.getRequestSession();n&&n.status&&(this._incrementSessionStatusCount(n.status,new Date),e.setRequestSession(void 0))}_incrementSessionStatusCount(e,n){let r=new Date(n).setSeconds(0,0);this._pendingAggregates[r]=this._pendingAggregates[r]||{};let s=this._pendingAggregates[r];switch(s.started||(s.started=new Date(r).toISOString()),e){case"errored":return s.errored=(s.errored||0)+1,s.errored;case"ok":return s.exited=(s.exited||0)+1,s.exited;default:return s.crashed=(s.crashed||0)+1,s.crashed}}};var ls="7";function ps(t){let e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function ds(t){return`${ps(t)}${t.projectId}/envelope/`}function fs(t,e){return dt({sentry_key:t.publicKey,sentry_version:ls,...e&&{sentry_client:`${e.name}/${e.version}`}})}function Fn(t,e,n){return e||`${ds(t)}?${fs(t,n)}`}var Un=[];function ms(t){let e={};return t.forEach(n=>{let{name:r}=n,s=e[r];s&&!s.isDefaultInstance&&n.isDefaultInstance||(e[r]=n)}),Object.keys(e).map(n=>e[n])}function $t(t){let e=t.defaultIntegrations||[],n=t.integrations;e.forEach(i=>{i.isDefaultInstance=!0});let r;Array.isArray(n)?r=[...e,...n]:typeof n=="function"?r=ce(n(e)):r=e;let s=ms(r),o=hs(s,i=>i.name==="Debug");if(o!==-1){let[i]=s.splice(o,1);s.push(i)}return s}function $n(t,e){let n={};return e.forEach(r=>{r&&Ht(t,r,n)}),n}function Bt(t,e){for(let n of e)n&&n.afterAllSetup&&n.afterAllSetup(t)}function Ht(t,e,n){if(n[e.name]){_&&h.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,Un.indexOf(e.name)===-1&&typeof e.setupOnce=="function"&&(e.setupOnce(),Un.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){let r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,o)=>r(s,o,t))}if(typeof e.processEvent=="function"){let r=e.processEvent.bind(e),s=Object.assign((o,i)=>r(o,i,t),{id:e.name});t.addEventProcessor(s)}_&&h.log(`Integration installed: ${e.name}`)}function hs(t,e){for(let n=0;n<t.length;n++)if(e(t[n])===!0)return n;return-1}var Bn="Not capturing exception because it's already been captured.",Ve=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=Ce(e.dsn):_&&h.warn("No DSN provided, client will not send events."),this._dsn){let n=Fn(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:n})}}captureException(e,n,r){let s=T();if(Fe(e))return _&&h.log(Bn),s;let o={event_id:s,...n};return this._process(this.eventFromException(e,o).then(i=>this._captureEvent(i,o,r))),o.event_id}captureMessage(e,n,r,s){let o={event_id:T(),...r},i=Z(e)?e:String(e),a=be(e)?this.eventFromMessage(i,n,o):this.eventFromException(e,o);return this._process(a.then(c=>this._captureEvent(c,o,s))),o.event_id}captureEvent(e,n,r){let s=T();if(n&&n.originalException&&Fe(n.originalException))return _&&h.log(Bn),s;let o={event_id:s,...n},a=(e.sdkProcessingMetadata||{}).capturedSpanScope;return this._process(this._captureEvent(e,o,a||r)),o.event_id}captureSession(e){typeof e.release!="string"?_&&h.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),pe(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){let n=this._transport;return n?(this.emit("flush"),this._isClientDoneProcessing(e).then(r=>n.flush(e).then(s=>r&&s))):x(!0)}close(e){return this.flush(e).then(n=>(this.getOptions().enabled=!1,this.emit("close"),n))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){this._isEnabled()&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){let n=this._integrations[e.name];Ht(this,e,this._integrations),n||Bt(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);let r=Mn(e,this._dsn,this._options._metadata,this._options.tunnel);for(let o of n.attachments||[])r=At(r,bt(o));let s=this.sendEnvelope(r);s&&s.then(o=>this.emit("afterSendEvent",e,o),null)}sendSession(e){let n=Dn(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(n)}recordDroppedEvent(e,n,r){if(this._options.sendClientReports){let s=`${e}:${n}`;_&&h.log(`Adding outcome: "${s}"`),this._outcomes[s]=this._outcomes[s]+1||1}}on(e,n){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(n)}emit(e,...n){this._hooks[e]&&this._hooks[e].forEach(r=>r(...n))}sendEnvelope(e){return this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport?this._transport.send(e).then(null,n=>(_&&h.error("Error while sending event:",n),n)):(_&&h.error("Transport disabled"),x({}))}_setupIntegrations(){let{integrations:e}=this._options;this._integrations=$n(this,e),Bt(this,e)}_updateSessionFromEvent(e,n){let r=!1,s=!1,o=n.exception&&n.exception.values;if(o){s=!0;for(let c of o){let u=c.mechanism;if(u&&u.handled===!1){r=!0;break}}}let i=e.status==="ok";(i&&e.errors===0||i&&r)&&(pe(e,{...r&&{status:"crashed"},errors:e.errors||Number(s||r)}),this.captureSession(e))}_isClientDoneProcessing(e){return new N(n=>{let r=0,s=1,o=setInterval(()=>{this._numProcessing==0?(clearInterval(o),n(!0)):(r+=s,e&&r>=e&&(clearInterval(o),n(!1)))},s)})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s=V()){let o=this.getOptions(),i=Object.keys(this._integrations);return!n.integrations&&i.length>0&&(n.integrations=i),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),kn(o,e,n,r,this,s).then(a=>{if(a===null)return a;let c={...s.getPropagationContext(),...r?r.getPropagationContext():void 0};if(!(a.contexts&&a.contexts.trace)&&c){let{traceId:l,spanId:p,parentSpanId:f,dsc:d}=c;a.contexts={trace:S({trace_id:l,span_id:p,parent_span_id:f}),...a.contexts};let m=d||fe(l,this);a.sdkProcessingMetadata={dynamicSamplingContext:m,...a.sdkProcessingMetadata}}return a})}_captureEvent(e,n={},r){return this._processEvent(e,n,r).then(s=>s.event_id,s=>{if(_){let o=s;o.logLevel==="log"?h.log(o.message):h.warn(o)}})}_processEvent(e,n,r){let s=this.getOptions(),{sampleRate:o}=s,i=jn(e),a=Hn(e),c=e.type||"error",u=`before send for type \`${c}\``,l=typeof o>"u"?void 0:wn(o);if(a&&typeof l=="number"&&Math.random()>l)return this.recordDroppedEvent("sample_rate","error",e),z(new I(`Discarding event because it's not included in the random sample (sampling rate = ${o})`,"log"));let p=c==="replay_event"?"replay":c,d=(e.sdkProcessingMetadata||{}).capturedSpanIsolationScope;return this._prepareEvent(e,n,r,d).then(m=>{if(m===null)throw this.recordDroppedEvent("event_processor",p,e),new I("An event processor returned `null`, will not send event.","log");if(n.data&&n.data.__sentry__===!0)return m;let A=_s(s,m,n);return gs(A,u)}).then(m=>{if(m===null)throw this.recordDroppedEvent("before_send",p,e),new I(`${u} returned \`null\`, will not send event.`,"log");let W=r&&r.getSession();!i&&W&&this._updateSessionFromEvent(W,m);let A=m.transaction_info;if(i&&A&&m.transaction!==e.transaction){let fr="custom";m.transaction_info={...A,source:fr}}return this.sendEvent(m,n),m}).then(null,m=>{throw m instanceof I?m:(this.captureException(m,{data:{__sentry__:!0},originalException:m}),new I(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event. Reason: ${m}`))})}_process(e){this._numProcessing++,e.then(n=>(this._numProcessing--,n),n=>(this._numProcessing--,n))}_clearOutcomes(){let e=this._outcomes;return this._outcomes={},Object.keys(e).map(n=>{let[r,s]=n.split(":");return{reason:r,category:s,quantity:e[n]}})}};function gs(t,e){let n=`${e} must return \`null\` or a valid event.`;if(O(t))return t.then(r=>{if(!R(r)&&r!==null)throw new I(n);return r},r=>{throw new I(`${e} rejected with ${r}`)});if(!R(t)&&t!==null)throw new I(n);return t}function _s(t,e,n){let{beforeSend:r,beforeSendTransaction:s,beforeSendSpan:o}=t;if(Hn(e)&&r)return r(e,n);if(jn(e)){if(e.spans&&o){let i=[];for(let a of e.spans){let c=o(a);c&&i.push(c)}e.spans=i}if(s)return s(e,n)}return e}function Hn(t){return t.type===void 0}function jn(t){return t.type==="transaction"}function Gn(t,e,n,r,s){let o={sent_at:new Date().toISOString()};n&&n.sdk&&(o.sdk={name:n.sdk.name,version:n.sdk.version}),r&&s&&(o.dsn=k(s)),e&&(o.trace=S(e));let i=Es(t);return F(o,[i])}function Es(t){return[{type:"check_in"},t]}var he=class extends Ve{constructor(e){On(),super(e)}eventFromException(e,n){return x(Ot(this,this._options.stackParser,e,n))}eventFromMessage(e,n="info",r){return x(wt(this._options.stackParser,e,n,r,this._options.attachStacktrace))}captureException(e,n,r){if(this._options.autoSessionTracking&&this._sessionFlusher){let s=V().getRequestSession();s&&s.status==="ok"&&(s.status="errored")}return super.captureException(e,n,r)}captureEvent(e,n,r){if(this._options.autoSessionTracking&&this._sessionFlusher&&(e.type||"exception")==="exception"&&e.exception&&e.exception.values&&e.exception.values.length>0){let i=V().getRequestSession();i&&i.status==="ok"&&(i.status="errored")}return super.captureEvent(e,n,r)}close(e){return this._sessionFlusher&&this._sessionFlusher.close(),super.close(e)}initSessionFlusher(){let{release:e,environment:n}=this._options;e?this._sessionFlusher=new Je(this,{release:e,environment:n}):_&&h.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")}captureCheckIn(e,n,r){let s="checkInId"in e&&e.checkInId?e.checkInId:T();if(!this._isEnabled())return _&&h.warn("SDK not enabled, will not capture checkin."),s;let o=this.getOptions(),{release:i,environment:a,tunnel:c}=o,u={check_in_id:s,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:a};"duration"in e&&(u.duration=e.duration),n&&(u.monitor_config={schedule:n.schedule,checkin_margin:n.checkinMargin,max_runtime:n.maxRuntime,timezone:n.timezone,failure_issue_threshold:n.failureIssueThreshold,recovery_threshold:n.recoveryThreshold});let[l,p]=this._getTraceInfoFromScope(r);p&&(u.contexts={trace:p});let f=Gn(u,l,this.getSdkMetadata(),c,this.getDsn());return _&&h.info("Sending checkin:",e.monitorSlug,e.status),this.sendEnvelope(f),s}_captureRequestSession(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():_&&h.warn("Discarded request mode session because autoSessionTracking option was disabled")}_prepareEvent(e,n,r,s){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:(e.contexts||{}).runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,n,r,s)}_getTraceInfoFromScope(e){if(!e)return[void 0,void 0];let n=J(e);if(n){let c=$(n);return[Ye(c),je(c)]}let{traceId:r,spanId:s,parentSpanId:o,dsc:i}=e.getPropagationContext(),a={trace_id:r,span_id:s,parent_span_id:o};return i?[i,a]:[fe(r,this),a]}};var Ss=64;function jt(t,e,n=yt(t.bufferSize||Ss)){let r={},s=i=>n.drain(i);function o(i){let a=[];if(Ue(i,(p,f)=>{let d=$e(f);if(Ct(r,d)){let m=Yn(p,f);t.recordDroppedEvent("ratelimit_backoff",d,m)}else a.push(p)}),a.length===0)return x({});let c=F(i[0],a),u=p=>{Ue(c,(f,d)=>{let m=Yn(f,d);t.recordDroppedEvent(p,$e(d),m)})},l=()=>e({body:xt(c)}).then(p=>(p.statusCode!==void 0&&(p.statusCode<200||p.statusCode>=300)&&_&&h.warn(`Sentry responded with status code ${p.statusCode} to sent event.`),r=Nt(r,p),p),p=>{throw u("network_error"),p});return n.add(l).then(p=>p,p=>{if(p instanceof I)return _&&h.error("Skipped sending event because buffer is full."),u("queue_overflow"),x({});throw p})}return{send:o,flush:s}}function Yn(t,e){if(!(e!=="event"&&e!=="transaction"))return Array.isArray(t)?t[1]:void 0}var ys="RewriteFrames",qe=(t={})=>{let e=t.root,n=t.prefix||"app:///",r="window"in g&&g.window!==void 0,s=t.iteratee||Ts({isBrowser:r,root:e,prefix:n});function o(a){try{return{...a,exception:{...a.exception,values:a.exception.values.map(c=>({...c,...c.stacktrace&&{stacktrace:i(c.stacktrace)}}))}}}catch{return a}}function i(a){return{...a,frames:a&&a.frames&&a.frames.map(c=>s(c))}}return{name:ys,processEvent(a){let c=a;return a.exception&&Array.isArray(a.exception.values)&&(c=o(c)),c}}};function Ts({isBrowser:t,root:e,prefix:n}){return r=>{if(!r.filename)return r;let s=/^[a-zA-Z]:\\/.test(r.filename)||r.filename.includes("\\")&&!r.filename.includes("/"),o=/^\//.test(r.filename);if(t){if(e){let i=r.filename;i.indexOf(e)===0&&(r.filename=i.replace(e,n))}}else if(s||o){let i=s?r.filename.replace(/^[a-zA-Z]:/,"").replace(/\\/g,"/"):r.filename,a=e?St(e,i):ue(i);r.filename=`${n}${a}`}return r}}function Jn(t){return typeof t=="object"&&t!==null}function As(t){return Jn(t)&&"handled"in t&&typeof t.handled=="boolean"&&"type"in t&&typeof t.type=="string"}function xs(t){return Jn(t)&&"mechanism"in t&&As(t.mechanism)}function bs(){if(g.SENTRY_RELEASE&&g.SENTRY_RELEASE.id)return g.SENTRY_RELEASE.id}function zn(t,e){return t!==void 0?(t[e[0]]=e[1],t):{[e[0]]:e[1]}}function Vn(t,e){return t(e.stack||"",1)}function Rs(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function qn(t,e){let n={type:e.name||e.constructor.name,value:Rs(e)},r=Vn(t,e);return r.length&&(n.stacktrace={frames:r}),n.type===void 0&&n.value===""&&(n.value="Unrecoverable error caught"),n}function Cs(t,e,n,r){let s,i=(r&&r.data&&xs(r.data)?r.data.mechanism:void 0)??{handled:!0,type:"generic"};if(j(n))s=n;else{if(R(n)){let c=`Non-Error exception captured with keys: ${re(n)}`,u=t?.getClient(),l=u&&u.getOptions().normalizeDepth;t?.setExtra("__serialized__",ee(n,l)),s=r&&r.syntheticException||new Error(c),s.message=c}else s=r&&r.syntheticException||new Error(n),s.message=n;i.synthetic=!0}let a={exception:{values:[qn(e,s)]}};return ae(a,void 0,void 0),Y(a,i),{...a,event_id:r&&r.event_id}}function Ns(t,e,n="info",r,s){let o={event_id:r&&r.event_id,level:n,message:e};if(s&&r&&r.syntheticException){let i=Vn(t,r.syntheticException);i.length&&(o.exception={values:[{value:e,stacktrace:{frames:i}}]})}return o}var vs=5,Os=(t={limit:vs})=>({name:"LinkedErrors",processEvent:(e,n,r)=>ws(r.getOptions().stackParser,t.limit,e,n)});function ws(t,e,n,r){if(!n.exception||!n.exception.values||!r||!w(r.originalException,Error))return n;let s=Wn(t,e,r.originalException);return n.exception.values=[...s,...n.exception.values],n}function Wn(t,e,n,r=[]){if(!w(n.cause,Error)||r.length+1>=e)return r;let s=qn(t,n.cause);return Wn(t,e,n.cause,[s,...r])}var Ds={allowedHeaders:["CF-RAY","CF-Worker"]},Ms=(t={})=>{let e={...Ds,...t};return{name:"RequestData",preprocessEvent:n=>{let{sdkProcessingMetadata:r}=n;return r&&("request"in r&&r.request instanceof Request&&(n.request=Ls(r.request,e),n.user=Ps(n.user??{},r.request,e)),"requestData"in r&&(n.request?n.request.data=r.requestData:n.request={data:r.reques