sentry-miniapp 1.13.0 → 1.13.1

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.
@@ -1,19 +1,19 @@
1
- "use strict";var Zs=Object.defineProperty,Qs=Object.defineProperties;var ei=Object.getOwnPropertyDescriptors;var $e=Object.getOwnPropertySymbols;var zn=Object.prototype.hasOwnProperty,qn=Object.prototype.propertyIsEnumerable;var Ft=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ti=t=>{throw TypeError(t)};var Un=(t,e,n)=>e in t?Zs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e)=>{for(var n in e||(e={}))zn.call(e,n)&&Un(t,n,e[n]);if($e)for(var n of $e(e))qn.call(e,n)&&Un(t,n,e[n]);return t},v=(t,e)=>Qs(t,ei(e));var Wn=(t,e)=>{var n={};for(var r in t)zn.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&$e)for(var r of $e(t))e.indexOf(r)<0&&qn.call(t,r)&&(n[r]=t[r]);return n};var O=(t,e,n)=>new Promise((r,s)=>{var i=a=>{try{c(n.next(a))}catch(u){s(u)}},o=a=>{try{c(n.throw(a))}catch(u){s(u)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,o);c((n=n.apply(t,e)).next())}),ni=function(t,e){this[0]=t,this[1]=e};var Gn=t=>{var e=t[Ft("asyncIterator")],n=!1,r,s={};return e==null?(e=t[Ft("iterator")](),r=i=>s[i]=o=>e[i](o)):(e=e.call(t),r=i=>s[i]=o=>{if(n){if(n=!1,i==="throw")throw o;return o}return n=!0,{done:!1,value:new ni(new Promise(c=>{var a=e[i](o);a instanceof Object||ti("Object expected"),c(a)}),1)}}),s[Ft("iterator")]=()=>s,r("next"),"throw"in e?r("throw"):s.throw=i=>{throw i},"return"in e&&r("return"),s};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class me{constructor(e){if(this._entries=[],typeof e=="string")this._parseString(e);else if(Array.isArray(e))for(const n of e)Array.isArray(n)&&n.length>=2&&this._entries.push([n[0]||"",n[1]||""]);else if(e&&typeof e=="object")if(e instanceof me)this._entries=e._entries.map(([n,r])=>[n,r]);else for(const[n,r]of Object.entries(e))this._entries.push([n,r])}get size(){return this._entries.length}_parseString(e){if(e.startsWith("?")&&(e=e.slice(1)),!e)return;const n=e.split("&");for(const r of n){const s=r.indexOf("=");if(s===-1)r&&this._entries.push([decodeURIComponent(r),""]);else{const i=r.slice(0,s),o=r.slice(s+1);i&&this._entries.push([decodeURIComponent(i),decodeURIComponent(o)])}}}append(e,n){this._entries.push([e,String(n)])}delete(e){this._entries=this._entries.filter(([n])=>n!==e)}get(e){const n=this._entries.find(([r])=>r===e);return n?n[1]:null}getAll(e){return this._entries.filter(([n])=>n===e).map(([,n])=>n)}has(e){return this._entries.some(([n])=>n===e)}set(e,n){const r=String(n);let s=!1;if(this._entries=this._entries.filter(([i])=>i===e?s?!1:(s=!0,!0):!0),s){const i=this._entries.findIndex(([o])=>o===e);i!==-1&&(this._entries[i]=[e,r])}else this._entries.push([e,r])}sort(){this._entries.sort(([e],[n])=>e<n?-1:e>n?1:0)}toString(){return this._entries.map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&")}forEach(e){for(const[n,r]of this._entries)e(r,n,this)}*keys(){for(const[e]of this._entries)yield e}*values(){for(const[,e]of this._entries)yield e}*entries(){for(const e of this._entries)yield e}*[Symbol.iterator](){yield*Gn(this.entries())}}function ri(){if(typeof globalThis!="undefined")return globalThis;try{return Function("return this")()}catch(t){}if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;if(typeof self!="undefined")return self}function si(){try{const t=ri();if(!t){console.warn("[sentry-miniapp] Unable to detect global object, polyfills may not work correctly");return}typeof t.URLSearchParams=="undefined"&&(t.URLSearchParams=me);const e=Function("return this")();e&&typeof e.URLSearchParams=="undefined"&&(e.URLSearchParams=me),typeof globalThis!="undefined"&&typeof globalThis.URLSearchParams=="undefined"&&(globalThis.URLSearchParams=me)}catch(t){console.warn("[sentry-miniapp] Failed to install polyfills:",t)}}function Fr(){si()}Fr();const y=typeof __SENTRY_DEBUG__=="undefined"||__SENTRY_DEBUG__,D=globalThis,ge="10.62.0";function K(){return kt(D),D}function kt(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||ge,e[ge]=e[ge]||{}}function ae(t,e,n=D){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[ge]=r[ge]||{};return s[t]||(s[t]=e())}const ii="Sentry Logger ",Jn={};function Ne(t){if(!("console"in D))return t();const e=D.console,n={},r=Object.keys(Jn);r.forEach(s=>{const i=Jn[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function oi(){Sn().enabled=!0}function ai(){Sn().enabled=!1}function Lr(){return Sn().enabled}function ci(...t){yn("log",...t)}function ui(...t){yn("warn",...t)}function li(...t){yn("error",...t)}function yn(t,...e){y&&Lr()&&Ne(()=>{D.console[t](`${ii}[${t}]:`,...e)})}function Sn(){return y?ae("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const g={enable:oi,disable:ai,isEnabled:Lr,log:ci,warn:ui,error:li},$r=50,At="?",Kn=/\(error: (.*)\)/,Yn=/captureMessage|captureException/;function fi(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{const i=[],o=n.split(`
2
- `);for(let c=r;c<o.length;c++){let a=o[c];a.length>1024&&(a=a.slice(0,1024));const u=Kn.test(a)?a.replace(Kn,"$1"):a;if(!u.includes("Error: ")){for(const d of e){const f=d(u);if(f){i.push(f);break}}if(i.length>=$r+s)break}}return pi(i.slice(s))}}function pi(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Be(e).function||"")&&e.pop(),e.reverse(),Yn.test(Be(e).function||"")&&(e.pop(),Yn.test(Be(e).function||"")&&e.pop()),e.slice(0,$r).map(n=>v(l({},n),{filename:n.filename||Be(e).filename,function:n.function||At}))}function Be(t){return t[t.length-1]||{}}const Lt="<anonymous>";function di(t){try{return!t||typeof t!="function"?Lt:t.name||Lt}catch(e){return Lt}}const Br=Object.prototype.toString;function jr(t){switch(Br.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return zr(t,Error)}}function bn(t,e){return Br.call(t)===`[object ${e}]`}function Xt(t){return bn(t,"String")}function Hr(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Ur(t){return t===null||Hr(t)||typeof t!="object"&&typeof t!="function"}function Zt(t){return bn(t,"Object")}function hi(t){return typeof Event!="undefined"&&zr(t,Event)}function _i(t){return bn(t,"RegExp")}function ce(t){return!!(t!=null&&t.then&&typeof t.then=="function")}function zr(t,e){try{return t instanceof e}catch(n){return!1}}function q(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch(r){y&&g.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}function mi(t){if(jr(t))return l({message:t.message,name:t.name,stack:t.stack},Vn(t));if(hi(t)){const{type:e,target:n,currentTarget:r,detail:s}=t;return l(l({type:e,target:n,currentTarget:r},s?{detail:s}:{}),Vn(t))}return t}function Vn(t){return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}function qr(t){try{const e=D.WeakRef;if(typeof e=="function")return new e(t)}catch(e){}return t}function Wr(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch(e){return}return t}}const Qt="_sentrySpan";function We(t,e){e?q(t,Qt,qr(e)):delete t[Qt]}function Ge(t){return Wr(t[Qt])}let X;function Rt(t){if(X!==void 0)return X?X(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=D;return e in n&&typeof n[e]=="function"?(X=n[e],X(t)):(X=null,t())}function Je(){return Rt(()=>Math.random())}function G(){return Rt(()=>Date.now())}const gi=Symbol.for("sentry.skipNormalization"),yi=Symbol.for("sentry.overrideNormalizationDepth");function Si(t){return!!t[gi]}function bi(t){const e=t[yi];return typeof e=="number"?e:void 0}let Ei;function z(t,e=100,n=1/0){try{return en("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function en(t,e,n=1/0,r=1/0,s=Ii()){const[i,o]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const c=vi(t,e);if(!c.startsWith("[object "))return c;if(Si(e))return e;const a=bi(e),u=a!==void 0?a:n;if(u===0)return c.replace("object ","");if(i(e))return"[Circular ~]";const d=e;if(d&&typeof d.toJSON=="function")try{const h=d.toJSON();return en("",h,u-1,r,s)}catch(h){}const f=Array.isArray(e)?[]:{};let _=0;const p=mi(e);for(const h in p){if(!Object.prototype.hasOwnProperty.call(p,h))continue;if(_>=r){f[h]="[MaxProperties ~]";break}const m=p[h];f[h]=en(h,m,u-1,r,s),_++}return o(e),f}function vi(t,e){try{return typeof global!="undefined"&&e===global?"[Global]":typeof e=="number"&&!Number.isFinite(e)?`[${e}]`:typeof e=="function"?`[Function: ${di(e)}]`:typeof e=="symbol"?`[${String(e)}]`:typeof e=="bigint"?`[BigInt: ${String(e)}]`:`[object ${Ti(e)}]`}catch(n){return`**non-serializable** (${n})`}}function Ti(t){const e=Object.getPrototypeOf(t);return e!=null&&e.constructor?e.constructor.name:"null prototype"}function Ii(){const t=new WeakSet;function e(r){return t.has(r)?!0:(t.add(r),!1)}function n(r){t.delete(r)}return[e,n]}function tn(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function ye(t,e,n=!1){return Xt(t)?_i(e)?e.test(t):Xt(e)?n?t===e:t.includes(e):typeof e=="function"?e(t):!1:!1}function Ct(t,e=[],n=!1){for(const r of e)if(ye(t,r,n))return!0;return!1}function wi(){const t=D;return t.crypto||t.msCrypto}let $t;function ki(){return Je()*16}function L(t=wi()){try{if(t!=null&&t.randomUUID)return Rt(()=>t.randomUUID()).replace(/-/g,"")}catch(e){}return $t||($t="10000000100040008000"+1e11),$t.replace(/[018]/g,e=>(e^(ki()&15)>>e/4).toString(16))}function Gr(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)==null?void 0:n[0]}function Z(t){const{message:e,event_id:n}=t;if(e)return e;const r=Gr(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function Ai(t,e){const n=Gr(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism=l(l(l({},r),s),e),e&&"data"in e){const i=l(l({},s==null?void 0:s.data),e.data);n.mechanism.data=i}}function Xn(t){if(Ri(t))return!0;try{q(t,"__sentry_captured__",!0)}catch(e){}return!1}function Ri(t){try{return t.__sentry_captured__}catch(e){}}const Jr=1e3;function De(){return G()/Jr}function Ci(){const{performance:t}=D;if(!(t!=null&&t.now)||!t.timeOrigin)return De;const e=t.timeOrigin;return()=>(e+Rt(()=>t.now()))/Jr}let je;function Ie(){return(je!=null?je:je=Ci())()}function Kr(t){const e=Ie(),n={sid:L(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>Pi(n)};return t&&J(n,t),n}function J(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:L()),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{const 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)}function Yr(t,e){let n={};e?n={status:e}:t.status==="ok"&&(n={status:"exited"}),J(t,n)}function Pi(t){return{sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}function Me(t,e,n=2){if(!e||typeof e!="object"||n<=0)return e;if(t&&Object.keys(e).length===0)return t;const r=l({},t);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=Me(r[s],e[s],n-1));return r}function ne(){return L()}function ue(){return L().substring(16)}const xi=100;class B{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:ne(),sampleRand:Je()}}clone(){const e=new B;return e._breadcrumbs=[...this._breadcrumbs],e._tags=l({},this._tags),e._attributes=l({},this._attributes),e._extra=l({},this._extra),e._contexts=l({},this._contexts),this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),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._attachments=[...this._attachments],e._sdkProcessingMetadata=l({},this._sdkProcessingMetadata),e._propagationContext=l({},this._propagationContext),e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,We(e,Ge(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&&J(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags=l(l({},this._tags),e),this._notifyScopeListeners(),this}setTag(e,n){return this.setTags({[e]:n})}setAttributes(e){return this._attributes=l(l({},this._attributes),e),this._notifyScopeListeners(),this}setAttribute(e,n){return this.setAttributes({[e]:n})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra=l(l({},this._extra),e),this._notifyScopeListeners(),this}setExtra(e,n){return this._extra=v(l({},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;const n=typeof e=="function"?e(this):e,r=n instanceof B?n.getScopeData():Zt(n)?e:void 0,{tags:s,attributes:i,extra:o,user:c,contexts:a,level:u,fingerprint:d=[],propagationContext:f,conversationId:_}=r||{};return this._tags=l(l({},this._tags),s),this._attributes=l(l({},this._attributes),i),this._extra=l(l({},this._extra),o),this._contexts=l(l({},this._contexts),a),c&&Object.keys(c).length&&(this._user=c),u&&(this._level=u),d.length&&(this._fingerprint=d),f&&(this._propagationContext=f),_&&(this._conversationId=_),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,We(this,void 0),this._attachments=[],this.setPropagationContext({traceId:ne(),sampleRand:Je()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){var i;const r=typeof n=="number"?n:xi;if(r<=0)return this;const s=v(l({timestamp:De()},e),{message:e.message?tn(e.message,2048):e.message});return this._breadcrumbs.push(s),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),(i=this._client)==null||i.recordDroppedEvent("buffer_overflow","log_item")),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,attributes:this._attributes,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:Ge(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Me(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=(n==null?void 0:n.event_id)||L();if(!this._client)return y&&g.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,v(l({originalException:e,syntheticException:s},n),{event_id:r}),this),r}captureMessage(e,n,r){var o;const s=(r==null?void 0:r.event_id)||L();if(!this._client)return y&&g.warn("No client configured on scope - will not capture message!"),s;const i=(o=r==null?void 0:r.syntheticException)!=null?o:new Error(e);return this._client.captureMessage(e,n,v(l({originalException:e,syntheticException:i},r),{event_id:s}),this),s}captureEvent(e,n){const r=e.event_id||(n==null?void 0:n.event_id)||L();return this._client?(this._client.captureEvent(e,v(l({},n),{event_id:r}),this),r):(y&&g.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)}}function Ni(){return ae("defaultCurrentScope",()=>new B)}function Di(){return ae("defaultIsolationScope",()=>new B)}const Zn=t=>t instanceof Promise&&!t[Vr],Vr=Symbol("chained PromiseLike"),Xr=(t,e,n)=>{const r=t.then(s=>(e(s),s),s=>{throw n(s),s});return Zn(r)&&Zn(t)?r:Mi(t,r)},Mi=(t,e)=>{if(!e)return t;let n=!1;for(const r in t){if(r in e)continue;n=!0;const s=t[r];typeof s=="function"?Object.defineProperty(e,r,{value:(...i)=>s.apply(t,i),enumerable:!0,configurable:!0,writable:!0}):e[r]=s}return n&&Object.assign(e,{[Vr]:!0}),e};class Oi{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){const n=this._pushScope();let r;try{r=e(n)}catch(s){throw this._popScope(),s}return ce(r)?Xr(r,()=>this._popScope(),()=>this._popScope()):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function re(){const t=K(),e=kt(t);return e.stack=e.stack||new Oi(Ni(),Di())}function Fi(t){return re().withScope(t)}function Li(t,e){const n=re();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function Qn(t){return re().withScope(()=>t(re().getIsolationScope()))}function $i(){return{withIsolationScope:Qn,withScope:Fi,withSetScope:Li,withSetIsolationScope:(t,e)=>Qn(e),getCurrentScope:()=>re().getScope(),getIsolationScope:()=>re().getIsolationScope()}}function le(t){const e=kt(t);return e.acs?e.acs:$i()}function Bi(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)&&Object.keys(t).includes("value")}function ji(t,e){var c;const{value:n,unit:r}=Bi(t)?t:{value:t,unit:void 0},s=Hi(n),i=r&&typeof r=="string"?{unit:r}:{};if(s)return l(l({},s),i);if(!e||e==="skip-undefined"&&n===void 0)return;let o="";try{o=(c=JSON.stringify(n))!=null?c:""}catch(a){}return l({value:o,type:"string"},i)}function er(t,e=!1){const n={};for(const[r,s]of Object.entries(t!=null?t:{})){const i=ji(s,e);i&&(n[r]=i)}return n}function Hi(t){if(Array.isArray(t))return{value:t,type:"array"};const e=typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t=="number"&&!Number.isNaN(t)?Number.isInteger(t)?"integer":"double":null;if(e)return{value:t,type:e}}function b(){const t=K();return le(t).getCurrentScope()}function R(){const t=K();return le(t).getIsolationScope()}function Ui(){return ae("globalScope",()=>new B)}function fe(...t){const e=K(),n=le(e);if(t.length===2){const[r,s]=t;return r?n.withSetScope(r,s):n.withScope(s)}return n.withScope(t[0])}function w(){return b().getClient()}function zi(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||ue()};return r&&(i.parent_span_id=r),i}const Ke="sentry.source",Zr="sentry.sample_rate",qi="sentry.previous_trace_sample_rate",Ye="sentry.op",nn="sentry.origin",Qr="sentry.measurement_unit",es="sentry.measurement_value",tr="sentry.custom_span_name",En="sentry.profile_id",vn="sentry.exclusive_time",ts=0,Pt=1,N=2;function Wi(t){if(t<400&&t>=100)return{code:Pt};if(t>=400&&t<500)switch(t){case 401:return{code:N,message:"unauthenticated"};case 403:return{code:N,message:"permission_denied"};case 404:return{code:N,message:"not_found"};case 409:return{code:N,message:"already_exists"};case 413:return{code:N,message:"failed_precondition"};case 429:return{code:N,message:"resource_exhausted"};case 499:return{code:N,message:"cancelled"};default:return{code:N,message:"invalid_argument"}}if(t>=500&&t<600)switch(t){case 501:return{code:N,message:"unimplemented"};case 503:return{code:N,message:"unavailable"};case 504:return{code:N,message:"deadline_exceeded"};default:return{code:N,message:"internal_error"}}return{code:N,message:"internal_error"}}function Gi(t,e){t.setAttribute("http.response.status_code",e);const n=Wi(e);n.message!=="unknown_error"&&t.setStatus(n)}const ns="_sentryScope",rs="_sentryIsolationScope",Ji=Symbol.for("sentry.otelSourceInference");function we(t,e,n){t&&(q(t,rs,qr(n)),q(t,ns,e))}function ke(t){const e=t;return{scope:e[ns],isolationScope:Wr(e[rs])}}function Ki(t){return t[Ji]===!0}const rn="sentry-",Yi=8192;function Vi(t){const e=Zi(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.startsWith(rn)){const o=s.slice(rn.length);r[o]=i}return r},{});if(Object.keys(n).length>0)return n}function Xi(t){if(!t)return;const e=Object.entries(t).reduce((n,[r,s])=>(s&&(n[`${rn}${r}`]=s),n),{});return Qi(e)}function Zi(t){if(!(!t||!Xt(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=nr(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):nr(t)}function nr(t){return t.split(",").map(e=>{const n=e.indexOf("=");if(n===-1)return[];const r=e.slice(0,n),s=e.slice(n+1);return[r,s].map(i=>{try{return decodeURIComponent(i.trim())}catch(o){return}})}).reduce((e,[n,r])=>(n&&r&&(e[n]=r),e),{})}function Qi(t){if(Object.keys(t).length!==0)return Object.entries(t).reduce((e,[n,r],s)=>{const i=`${encodeURIComponent(n)}=${encodeURIComponent(r)}`,o=s===0?i:`${e},${i}`;return o.length>Yi?(y&&g.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const eo=/^o(\d+)\./,to=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function no(t){return t==="http"||t==="https"}function pe(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:o,protocol:c,publicKey:a}=t;return`${c}://${a}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${o}`}function ro(t){const e=to.exec(t);if(!e){Ne(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",o="",c=""]=e.slice(1);let a="",u=c;const d=u.split("/");if(d.length>1&&(a=d.slice(0,-1).join("/"),u=d.pop()),u){const f=u.match(/^\d+/);f&&(u=f[0])}return ss({host:i,pass:s,path:a,projectId:u,port:o,protocol:n,publicKey:r})}function ss(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function so(t){if(!y)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(o=>t[o]?!1:(g.error(`Invalid Sentry Dsn: ${o} missing`),!0))?!1:n.match(/^\d+$/)?no(r)?e&&isNaN(parseInt(e,10))?(g.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(g.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(g.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function io(t){const e=t.match(eo);return e==null?void 0:e[1]}function oo(t){const e=t.getOptions(),{host:n}=t.getDsn()||{};let r;return e.orgId?r=String(e.orgId):n&&(r=io(n)),r}function ao(t){const e=typeof t=="string"?ro(t):ss(t);if(!(!e||!so(e)))return e}function Tn(t){if(typeof t=="boolean")return Number(t);const e=typeof t=="string"?parseFloat(t):t;if(!(typeof e!="number"||isNaN(e)||e<0||e>1))return e}const co=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function is(t=ne(),e=ue(),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}function os(t=ne(),e=ue(),n){return`00-${t}-${e}-${n?"01":"00"}`}const as=0,xt=1;let rr=!1;function uo(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:s,parent_span_id:i,status:o,origin:c,links:a}=M(t);return{parent_span_id:i,span_id:e,trace_id:n,data:r,op:s,status:o,origin:c,links:a}}function lo(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:M(t).parent_span_id,i=ke(t).scope,o=r?(i==null?void 0:i.getPropagationContext().propagationSpanId)||ue():e;return{parent_span_id:s,span_id:o,trace_id:n}}function fo(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return is(e,n,r)}function po(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return os(e,n,r)}function cs(t){if(t&&t.length>0)return t.map(o=>{var c=o,{context:a}=c,u=a,{spanId:e,traceId:n,traceFlags:r}=u,s=Wn(u,["spanId","traceId","traceFlags"]),{attributes:i}=c;return l({span_id:e,trace_id:n,sampled:r===xt,attributes:i},s)})}function ho(t){if(t!=null&&t.length)return t.map(({context:{spanId:e,traceId:n,traceFlags:r},attributes:s})=>({span_id:e,trace_id:n,sampled:r===xt,attributes:s}))}function te(t){return typeof t=="number"?sr(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?sr(t.getTime()):Ie()}function sr(t){return t>9999999999?t/1e3:t}function M(t){if(yo(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(go(t)){const{attributes:r,startTime:s,name:i,endTime:o,status:c,links:a}=t;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:_o(t),start_timestamp:te(s),timestamp:te(o)||void 0,status:us(c),op:r[Ye],origin:r[nn],links:cs(a)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function _o(t){var e;return"parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?(e=t.parentSpanContext)==null?void 0:e.spanId:void 0}function mo(t){var e;return v(l({},t),{attributes:er(t.attributes),links:(e=t.links)==null?void 0:e.map(n=>v(l({},n),{attributes:er(n.attributes)}))})}function go(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function yo(t){return typeof t.getSpanJSON=="function"}function Y(t){const{traceFlags:e}=t.spanContext();return e===xt}function us(t){if(!(!t||t.code===ts))return t.code===Pt?"ok":t.message||"internal_error"}function So(t){return!t||t.code===Pt||t.code===ts||t.message==="cancelled"?"ok":"error"}const Se="_sentryChildSpans",sn="_sentryRootSpan";function on(t,e){const n=t[sn]||t;q(e,sn,n),t[Se]?t[Se].add(e):q(t,Se,new Set([e]))}function bo(t){const e=new Set;function n(r){if(!e.has(r)&&Y(r)){e.add(r);const s=r[Se]?Array.from(r[Se]):[];for(const i of s)n(i)}}return n(t),Array.from(e)}const $=Eo;function Eo(t){return t[sn]||t}function ls(){const t=K(),e=le(t);return e.getActiveSpan?e.getActiveSpan():Ge(b())}function an(){rr||(Ne(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),rr=!0)}function Ae(t){var n;if(typeof __SENTRY_TRACING__=="boolean"&&!__SENTRY_TRACING__)return!1;const e=t||((n=w())==null?void 0:n.getOptions());return!!e&&(e.tracesSampleRate!=null||!!e.tracesSampler)}function ir(t){g.log(`Ignoring span ${t.op} - ${t.description} because it matches \`ignoreSpans\`.`)}function Ve(t,e){if(!(e!=null&&e.length))return!1;for(const n of e){if(Io(n)){if(t.description&&ye(t.description,n))return y&&ir(t),!0;continue}const r=!!n.attributes&&Object.keys(n.attributes).length>0;if(!n.name&&!n.op&&!r)continue;const s=n.name?t.description&&ye(t.description,n.name):!0,i=n.op?t.op&&ye(t.op,n.op):!0,o=n.attributes?Object.entries(n.attributes).every(([c,a])=>{var u;return vo((u=t.attributes)==null?void 0:u[c],a)}):!0;if(s&&i&&o)return y&&ir(t),!0}return!1}function vo(t,e){return typeof t=="string"&&(typeof e=="string"||e instanceof RegExp)?ye(t,e):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((n,r)=>n===e[r]):t===e}function To(t,e){const n=e.parent_span_id,r=e.span_id;if(n)for(const s of t)s.parent_span_id===r&&(s.parent_span_id=n)}function Io(t){return typeof t=="string"||t instanceof RegExp}const fs=Symbol.for("sentry.nonRecordingSpan");class Xe{constructor(e={}){this._traceId=e.traceId||ne(),this._spanId=e.spanId||ue(),this.dropReason=e.dropReason,q(this,fs,!0)}spanContext(){return{spanId:this._spanId,traceId:this._traceId,traceFlags:as}}end(e){}setAttribute(e,n){return this}setAttributes(e){return this}setStatus(e){return this}updateName(e){return this}isRecording(){return!1}addEvent(e,n,r){return this}addLink(e){return this}addLinks(e){return this}recordException(e,n){}}function Re(t){return!!t&&t[fs]===!0}const In="production",ps="_frozenDsc";function or(t,e){q(t,ps,e)}function ds(t,e){const n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s={environment:n.environment||In,release:n.release,public_key:r,trace_id:t,org_id:oo(e)};return e.emit("createDsc",s),s}function wn(t,e){const n=e.getPropagationContext();return n.dsc||ds(n.traceId,t)}function Oe(t){var h,m,S,E,C;const e=w();if(!e)return{};const n=$(t),r=M(n),s=r.data,i=n.spanContext().traceState,o=(m=(h=i==null?void 0:i.get("sentry.sample_rate"))!=null?h:s[Zr])!=null?m:s[qi];function c(A){return(typeof o=="number"||typeof o=="string")&&(A.sample_rate=`${o}`),A}const a=n[ps];if(a)return c(a);if(Re(n)&&!Ae(e.getOptions())){const A=ke(n).scope;if(A)return c(l({},wn(e,A)))}const u=i==null?void 0:i.get("sentry.dsc"),d=u&&Vi(u);if(d)return c(d);const f=ds(t.spanContext().traceId,e),_=(S=s[Ke])!=null?S:s["sentry.span.source"],p=r.description;return _!=="url"&&p&&(f.transaction=p),Ae()&&(f.sampled=String(Y(n)),f.sample_rand=(C=i==null?void 0:i.get("sentry.sample_rand"))!=null?C:(E=ke(n).scope)==null?void 0:E.getPropagationContext().sampleRand.toString()),c(f),e.emit("createDsc",f,n),f}function hs(t){return!!t&&typeof t=="function"&&"_streamed"in t&&!!t._streamed}function V(t,e=[]){return[t,e]}function ar(t,e){const[n,r]=t;return[n,[...r,e]]}function cn(t,e){const n=t[1];for(const r of n){const s=r[0].type;if(e(r,s))return!0}return!1}function un(t,e){return cn(t,(n,r)=>e.includes(r))}function ln(t){const e=kt(D);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function wo(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[ln(r),i]:r.push(typeof i=="string"?ln(i):i)}for(const i of n){const[o,c]=i;if(s(`
1
+ "use strict";var Qs=Object.defineProperty,ei=Object.defineProperties;var ti=Object.getOwnPropertyDescriptors;var $e=Object.getOwnPropertySymbols;var zn=Object.prototype.hasOwnProperty,qn=Object.prototype.propertyIsEnumerable;var Lt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ni=t=>{throw TypeError(t)};var Hn=(t,e,n)=>e in t?Qs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e)=>{for(var n in e||(e={}))zn.call(e,n)&&Hn(t,n,e[n]);if($e)for(var n of $e(e))qn.call(e,n)&&Hn(t,n,e[n]);return t},T=(t,e)=>ei(t,ti(e));var Wn=(t,e)=>{var n={};for(var r in t)zn.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&$e)for(var r of $e(t))e.indexOf(r)<0&&qn.call(t,r)&&(n[r]=t[r]);return n};var O=(t,e,n)=>new Promise((r,s)=>{var i=a=>{try{c(n.next(a))}catch(u){s(u)}},o=a=>{try{c(n.throw(a))}catch(u){s(u)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,o);c((n=n.apply(t,e)).next())}),ri=function(t,e){this[0]=t,this[1]=e};var Gn=t=>{var e=t[Lt("asyncIterator")],n=!1,r,s={};return e==null?(e=t[Lt("iterator")](),r=i=>s[i]=o=>e[i](o)):(e=e.call(t),r=i=>s[i]=o=>{if(n){if(n=!1,i==="throw")throw o;return o}return n=!0,{done:!1,value:new ri(new Promise(c=>{var a=e[i](o);a instanceof Object||ni("Object expected"),c(a)}),1)}}),s[Lt("iterator")]=()=>s,r("next"),"throw"in e?r("throw"):s.throw=i=>{throw i},"return"in e&&r("return"),s};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class me{constructor(e){if(this._entries=[],typeof e=="string")this._parseString(e);else if(Array.isArray(e))for(const n of e)Array.isArray(n)&&n.length>=2&&this._entries.push([n[0]||"",n[1]||""]);else if(e&&typeof e=="object")if(e instanceof me)this._entries=e._entries.map(([n,r])=>[n,r]);else for(const[n,r]of Object.entries(e))this._entries.push([n,r])}get size(){return this._entries.length}_parseString(e){if(e.startsWith("?")&&(e=e.slice(1)),!e)return;const n=e.split("&");for(const r of n){const s=r.indexOf("=");if(s===-1)r&&this._entries.push([decodeURIComponent(r),""]);else{const i=r.slice(0,s),o=r.slice(s+1);i&&this._entries.push([decodeURIComponent(i),decodeURIComponent(o)])}}}append(e,n){this._entries.push([e,String(n)])}delete(e){this._entries=this._entries.filter(([n])=>n!==e)}get(e){const n=this._entries.find(([r])=>r===e);return n?n[1]:null}getAll(e){return this._entries.filter(([n])=>n===e).map(([,n])=>n)}has(e){return this._entries.some(([n])=>n===e)}set(e,n){const r=String(n);let s=!1;if(this._entries=this._entries.filter(([i])=>i===e?s?!1:(s=!0,!0):!0),s){const i=this._entries.findIndex(([o])=>o===e);i!==-1&&(this._entries[i]=[e,r])}else this._entries.push([e,r])}sort(){this._entries.sort(([e],[n])=>e<n?-1:e>n?1:0)}toString(){return this._entries.map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&")}forEach(e){for(const[n,r]of this._entries)e(r,n,this)}*keys(){for(const[e]of this._entries)yield e}*values(){for(const[,e]of this._entries)yield e}*entries(){for(const e of this._entries)yield e}*[Symbol.iterator](){yield*Gn(this.entries())}}function si(){if(typeof globalThis!="undefined")return globalThis;try{return Function("return this")()}catch(t){}if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;if(typeof self!="undefined")return self}function ii(){try{const t=si();if(!t){console.warn("[sentry-miniapp] Unable to detect global object, polyfills may not work correctly");return}typeof t.URLSearchParams=="undefined"&&(t.URLSearchParams=me);const e=Function("return this")();e&&typeof e.URLSearchParams=="undefined"&&(e.URLSearchParams=me),typeof globalThis!="undefined"&&typeof globalThis.URLSearchParams=="undefined"&&(globalThis.URLSearchParams=me)}catch(t){console.warn("[sentry-miniapp] Failed to install polyfills:",t)}}function Fr(){ii()}Fr();const y=typeof __SENTRY_DEBUG__=="undefined"||__SENTRY_DEBUG__,D=globalThis,ge="10.63.0";function K(){return kt(D),D}function kt(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||ge,e[ge]=e[ge]||{}}function ae(t,e,n=D){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[ge]=r[ge]||{};return s[t]||(s[t]=e())}const oi="Sentry Logger ",Jn={};function xe(t){if(!("console"in D))return t();const e=D.console,n={},r=Object.keys(Jn);r.forEach(s=>{const i=Jn[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function ai(){bn().enabled=!0}function ci(){bn().enabled=!1}function Lr(){return bn().enabled}function ui(...t){Sn("log",...t)}function li(...t){Sn("warn",...t)}function fi(...t){Sn("error",...t)}function Sn(t,...e){y&&Lr()&&xe(()=>{D.console[t](`${oi}[${t}]:`,...e)})}function bn(){return y?ae("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const g={enable:ai,disable:ci,isEnabled:Lr,log:ui,warn:li,error:fi},$r=50,At="?",Kn=/\(error: (.*)\)/,Yn=/captureMessage|captureException/;function pi(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{const i=[],o=n.split(`
2
+ `);for(let c=r;c<o.length;c++){let a=o[c];a.length>1024&&(a=a.slice(0,1024));const u=Kn.test(a)?a.replace(Kn,"$1"):a;if(!u.includes("Error: ")){for(const d of e){const f=d(u);if(f){i.push(f);break}}if(i.length>=$r+s)break}}return di(i.slice(s))}}function di(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Be(e).function||"")&&e.pop(),e.reverse(),Yn.test(Be(e).function||"")&&(e.pop(),Yn.test(Be(e).function||"")&&e.pop()),e.slice(0,$r).map(n=>T(l({},n),{filename:n.filename||Be(e).filename,function:n.function||At}))}function Be(t){return t[t.length-1]||{}}const $t="<anonymous>";function hi(t){try{return!t||typeof t!="function"?$t:t.name||$t}catch(e){return $t}}const Br=Object.prototype.toString;function jr(t){switch(Br.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return zr(t,Error)}}function En(t,e){return Br.call(t)===`[object ${e}]`}function Zt(t){return En(t,"String")}function Ur(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Hr(t){return t===null||Ur(t)||typeof t!="object"&&typeof t!="function"}function Qt(t){return En(t,"Object")}function _i(t){return typeof Event!="undefined"&&zr(t,Event)}function mi(t){return En(t,"RegExp")}function ce(t){return!!(t!=null&&t.then&&typeof t.then=="function")}function zr(t,e){try{return t instanceof e}catch(n){return!1}}function q(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch(r){y&&g.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}function gi(t){if(jr(t))return l({message:t.message,name:t.name,stack:t.stack},Vn(t));if(_i(t)){const{type:e,target:n,currentTarget:r,detail:s}=t;return l(l({type:e,target:n,currentTarget:r},s?{detail:s}:{}),Vn(t))}return t}function Vn(t){return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}let X;function Rt(t){if(X!==void 0)return X?X(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=D;return e in n&&typeof n[e]=="function"?(X=n[e],X(t)):(X=null,t())}function We(){return Rt(()=>Math.random())}function G(){return Rt(()=>Date.now())}const yi=Symbol.for("sentry.skipNormalization"),Si=Symbol.for("sentry.overrideNormalizationDepth");function bi(t){return!!t[yi]}function Ei(t){const e=t[Si];return typeof e=="number"?e:void 0}let Ti;function z(t,e=100,n=1/0){try{return en("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function en(t,e,n=1/0,r=1/0,s=wi()){const[i,o]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const c=vi(t,e);if(!c.startsWith("[object "))return c;if(bi(e))return e;const a=Ei(e),u=a!==void 0?a:n;if(u===0)return c.replace("object ","");if(i(e))return"[Circular ~]";const d=e;if(d&&typeof d.toJSON=="function")try{const h=d.toJSON();return en("",h,u-1,r,s)}catch(h){}const f=Array.isArray(e)?[]:{};let _=0;const p=gi(e);for(const h in p){if(!Object.prototype.hasOwnProperty.call(p,h))continue;if(_>=r){f[h]="[MaxProperties ~]";break}const m=p[h];f[h]=en(h,m,u-1,r,s),_++}return o(e),f}function vi(t,e){try{return typeof global!="undefined"&&e===global?"[Global]":typeof e=="number"&&!Number.isFinite(e)?`[${e}]`:typeof e=="function"?`[Function: ${hi(e)}]`:typeof e=="symbol"?`[${String(e)}]`:typeof e=="bigint"?`[BigInt: ${String(e)}]`:`[object ${Ii(e)}]`}catch(n){return`**non-serializable** (${n})`}}function Ii(t){const e=Object.getPrototypeOf(t);return e!=null&&e.constructor?e.constructor.name:"null prototype"}function wi(){const t=new WeakSet;function e(r){return t.has(r)?!0:(t.add(r),!1)}function n(r){t.delete(r)}return[e,n]}function tn(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function ye(t,e,n=!1){return Zt(t)?mi(e)?e.test(t):Zt(e)?n?t===e:t.includes(e):typeof e=="function"?e(t):!1:!1}function Ct(t,e=[],n=!1){for(const r of e)if(ye(t,r,n))return!0;return!1}function ki(){const t=D;return t.crypto||t.msCrypto}let Bt;function Ai(){return We()*16}function L(t=ki()){try{if(t!=null&&t.randomUUID)return Rt(()=>t.randomUUID()).replace(/-/g,"")}catch(e){}return Bt||(Bt="10000000100040008000"+1e11),Bt.replace(/[018]/g,e=>(e^(Ai()&15)>>e/4).toString(16))}function qr(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)==null?void 0:n[0]}function Z(t){const{message:e,event_id:n}=t;if(e)return e;const r=qr(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function Ri(t,e){const n=qr(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism=l(l(l({},r),s),e),e&&"data"in e){const i=l(l({},s==null?void 0:s.data),e.data);n.mechanism.data=i}}function Xn(t){if(Ci(t))return!0;try{q(t,"__sentry_captured__",!0)}catch(e){}return!1}function Ci(t){try{return t.__sentry_captured__}catch(e){}}const Wr=1e3;function De(){return G()/Wr}function Pi(){const{performance:t}=D;if(!(t!=null&&t.now)||!t.timeOrigin)return De;const e=t.timeOrigin;return()=>(e+Rt(()=>t.now()))/Wr}let je;function Ie(){return(je!=null?je:je=Pi())()}function Gr(t){const e=Ie(),n={sid:L(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>Ni(n)};return t&&J(n,t),n}function J(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:L()),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{const 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)}function Jr(t,e){let n={};e?n={status:e}:t.status==="ok"&&(n={status:"exited"}),J(t,n)}function Ni(t){return{sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}}}function Me(t,e,n=2){if(!e||typeof e!="object"||n<=0)return e;if(t&&Object.keys(e).length===0)return t;const r=l({},t);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=Me(r[s],e[s],n-1));return r}function ne(){return L()}function ue(){return L().substring(16)}function Kr(t){try{const e=D.WeakRef;if(typeof e=="function")return new e(t)}catch(e){}return t}function Yr(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch(e){return}return t}}const nn="_sentrySpan";function Ge(t,e){e?q(t,nn,Kr(e)):delete t[nn]}function Je(t){return Yr(t[nn])}const xi=100;class B{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:ne(),sampleRand:We()}}clone(){const e=new B;return e._breadcrumbs=[...this._breadcrumbs],e._tags=l({},this._tags),e._attributes=l({},this._attributes),e._extra=l({},this._extra),e._contexts=l({},this._contexts),this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),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._attachments=[...this._attachments],e._sdkProcessingMetadata=l({},this._sdkProcessingMetadata),e._propagationContext=l({},this._propagationContext),e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,Ge(e,Je(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&&J(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags=l(l({},this._tags),e),this._notifyScopeListeners(),this}setTag(e,n){return this.setTags({[e]:n})}setAttributes(e){return this._attributes=l(l({},this._attributes),e),this._notifyScopeListeners(),this}setAttribute(e,n){return this.setAttributes({[e]:n})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra=l(l({},this._extra),e),this._notifyScopeListeners(),this}setExtra(e,n){return this._extra=T(l({},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;const n=typeof e=="function"?e(this):e,r=n instanceof B?n.getScopeData():Qt(n)?e:void 0,{tags:s,attributes:i,extra:o,user:c,contexts:a,level:u,fingerprint:d=[],propagationContext:f,conversationId:_}=r||{};return this._tags=l(l({},this._tags),s),this._attributes=l(l({},this._attributes),i),this._extra=l(l({},this._extra),o),this._contexts=l(l({},this._contexts),a),c&&Object.keys(c).length&&(this._user=c),u&&(this._level=u),d.length&&(this._fingerprint=d),f&&(this._propagationContext=f),_&&(this._conversationId=_),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,Ge(this,void 0),this._attachments=[],this.setPropagationContext({traceId:ne(),sampleRand:We()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){var i;const r=typeof n=="number"?n:xi;if(r<=0)return this;const s=T(l({timestamp:De()},e),{message:e.message?tn(e.message,2048):e.message});return this._breadcrumbs.push(s),this._breadcrumbs.length>r&&(this._breadcrumbs=this._breadcrumbs.slice(-r),(i=this._client)==null||i.recordDroppedEvent("buffer_overflow","log_item")),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,attributes:this._attributes,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:Je(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Me(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=(n==null?void 0:n.event_id)||L();if(!this._client)return y&&g.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,T(l({originalException:e,syntheticException:s},n),{event_id:r}),this),r}captureMessage(e,n,r){var o;const s=(r==null?void 0:r.event_id)||L();if(!this._client)return y&&g.warn("No client configured on scope - will not capture message!"),s;const i=(o=r==null?void 0:r.syntheticException)!=null?o:new Error(e);return this._client.captureMessage(e,n,T(l({originalException:e,syntheticException:i},r),{event_id:s}),this),s}captureEvent(e,n){const r=e.event_id||(n==null?void 0:n.event_id)||L();return this._client?(this._client.captureEvent(e,T(l({},n),{event_id:r}),this),r):(y&&g.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)}}function Di(){return ae("defaultCurrentScope",()=>new B)}function Mi(){return ae("defaultIsolationScope",()=>new B)}const Zn=t=>t instanceof Promise&&!t[Vr],Vr=Symbol("chained PromiseLike"),Xr=(t,e,n)=>{const r=t.then(s=>(e(s),s),s=>{throw n(s),s});return Zn(r)&&Zn(t)?r:Oi(t,r)},Oi=(t,e)=>{if(!e)return t;let n=!1;for(const r in t){if(r in e)continue;n=!0;const s=t[r];typeof s=="function"?Object.defineProperty(e,r,{value:(...i)=>s.apply(t,i),enumerable:!0,configurable:!0,writable:!0}):e[r]=s}return n&&Object.assign(e,{[Vr]:!0}),e};class Fi{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){const n=this._pushScope();let r;try{r=e(n)}catch(s){throw this._popScope(),s}return ce(r)?Xr(r,()=>this._popScope(),()=>this._popScope()):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return this._stack.length<=1?!1:!!this._stack.pop()}}function re(){const t=K(),e=kt(t);return e.stack=e.stack||new Fi(Di(),Mi())}function Li(t){return re().withScope(t)}function $i(t,e){const n=re();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function Qn(t){return re().withScope(()=>t(re().getIsolationScope()))}function Bi(){return{withIsolationScope:Qn,withScope:Li,withSetScope:$i,withSetIsolationScope:(t,e)=>Qn(e),getCurrentScope:()=>re().getScope(),getIsolationScope:()=>re().getIsolationScope()}}function le(t){const e=kt(t);return e.acs?e.acs:Bi()}function ji(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)&&Object.keys(t).includes("value")}function Ui(t,e){var c;const{value:n,unit:r}=ji(t)?t:{value:t,unit:void 0},s=Hi(n),i=r&&typeof r=="string"?{unit:r}:{};if(s)return l(l({},s),i);if(!e||e==="skip-undefined"&&n===void 0)return;let o="";try{o=(c=JSON.stringify(n))!=null?c:""}catch(a){}return l({value:o,type:"string"},i)}function er(t,e=!1){const n={};for(const[r,s]of Object.entries(t!=null?t:{})){const i=Ui(s,e);i&&(n[r]=i)}return n}function Hi(t){if(Array.isArray(t))return{value:t,type:"array"};const e=typeof t=="string"?"string":typeof t=="boolean"?"boolean":typeof t=="number"&&!Number.isNaN(t)?Number.isInteger(t)?"integer":"double":null;if(e)return{value:t,type:e}}function b(){const t=K();return le(t).getCurrentScope()}function R(){const t=K();return le(t).getIsolationScope()}function zi(){return ae("globalScope",()=>new B)}function fe(...t){const e=K(),n=le(e);if(t.length===2){const[r,s]=t;return r?n.withSetScope(r,s):n.withScope(s)}return n.withScope(t[0])}function w(){return b().getClient()}function qi(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||ue()};return r&&(i.parent_span_id=r),i}const Ke="sentry.source",Zr="sentry.sample_rate",Wi="sentry.previous_trace_sample_rate",Ye="sentry.op",rn="sentry.origin",Gi="sentry.status.message",Qr="sentry.measurement_unit",es="sentry.measurement_value",tr="sentry.custom_span_name",Tn="sentry.profile_id",vn="sentry.exclusive_time",ts=0,Pt=1,x=2;function Ji(t){if(t<400&&t>=100)return{code:Pt};if(t>=400&&t<500)switch(t){case 401:return{code:x,message:"unauthenticated"};case 403:return{code:x,message:"permission_denied"};case 404:return{code:x,message:"not_found"};case 409:return{code:x,message:"already_exists"};case 413:return{code:x,message:"failed_precondition"};case 429:return{code:x,message:"resource_exhausted"};case 499:return{code:x,message:"cancelled"};default:return{code:x,message:"invalid_argument"}}if(t>=500&&t<600)switch(t){case 501:return{code:x,message:"unimplemented"};case 503:return{code:x,message:"unavailable"};case 504:return{code:x,message:"deadline_exceeded"};default:return{code:x,message:"internal_error"}}return{code:x,message:"internal_error"}}function Ki(t,e){t.setAttribute("http.response.status_code",e);const n=Ji(e);n.message!=="unknown_error"&&t.setStatus(n)}const ns="_sentryScope",rs="_sentryIsolationScope",Yi=Symbol.for("sentry.otelSourceInference");function we(t,e,n){t&&(q(t,rs,Kr(n)),q(t,ns,e))}function ke(t){const e=t;return{scope:e[ns],isolationScope:Yr(e[rs])}}function Vi(t){return t[Yi]===!0}const sn="sentry-",Xi=8192;function Zi(t){const e=eo(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.startsWith(sn)){const o=s.slice(sn.length);r[o]=i}return r},{});if(Object.keys(n).length>0)return n}function Qi(t){if(!t)return;const e=Object.entries(t).reduce((n,[r,s])=>(s&&(n[`${sn}${r}`]=s),n),{});return to(e)}function eo(t){if(!(!t||!Zt(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=nr(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):nr(t)}function nr(t){return t.split(",").map(e=>{const n=e.indexOf("=");if(n===-1)return[];const r=e.slice(0,n),s=e.slice(n+1);return[r,s].map(i=>{try{return decodeURIComponent(i.trim())}catch(o){return}})}).reduce((e,[n,r])=>(n&&r&&(e[n]=r),e),{})}function to(t){if(Object.keys(t).length!==0)return Object.entries(t).reduce((e,[n,r],s)=>{const i=`${encodeURIComponent(n)}=${encodeURIComponent(r)}`,o=s===0?i:`${e},${i}`;return o.length>Xi?(y&&g.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const no=/^o(\d+)\./,ro=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function so(t){return t==="http"||t==="https"}function pe(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:o,protocol:c,publicKey:a}=t;return`${c}://${a}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${o}`}function io(t){const e=ro.exec(t);if(!e){xe(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",o="",c=""]=e.slice(1);let a="",u=c;const d=u.split("/");if(d.length>1&&(a=d.slice(0,-1).join("/"),u=d.pop()),u){const f=u.match(/^\d+/);f&&(u=f[0])}return ss({host:i,pass:s,path:a,projectId:u,port:o,protocol:n,publicKey:r})}function ss(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function oo(t){if(!y)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(o=>t[o]?!1:(g.error(`Invalid Sentry Dsn: ${o} missing`),!0))?!1:n.match(/^\d+$/)?so(r)?e&&isNaN(parseInt(e,10))?(g.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(g.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(g.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function ao(t){const e=t.match(no);return e==null?void 0:e[1]}function co(t){const e=t.getOptions(),{host:n}=t.getDsn()||{};let r;return e.orgId?r=String(e.orgId):n&&(r=ao(n)),r}function uo(t){const e=typeof t=="string"?io(t):ss(t);if(!(!e||!oo(e)))return e}function In(t){if(typeof t=="boolean")return Number(t);const e=typeof t=="string"?parseFloat(t):t;if(!(typeof e!="number"||isNaN(e)||e<0||e>1))return e}const lo=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function is(t=ne(),e=ue(),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}function os(t=ne(),e=ue(),n){return`00-${t}-${e}-${n?"01":"00"}`}const as=0,Nt=1;let rr=!1;function fo(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:s,parent_span_id:i,status:o,origin:c,links:a}=M(t);return{parent_span_id:i,span_id:e,trace_id:n,data:r,op:s,status:o,origin:c,links:a}}function po(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:M(t).parent_span_id,i=ke(t).scope,o=r?(i==null?void 0:i.getPropagationContext().propagationSpanId)||ue():e;return{parent_span_id:s,span_id:o,trace_id:n}}function ho(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return is(e,n,r)}function _o(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return os(e,n,r)}function cs(t){if(t&&t.length>0)return t.map(o=>{var c=o,{context:a}=c,u=a,{spanId:e,traceId:n,traceFlags:r}=u,s=Wn(u,["spanId","traceId","traceFlags"]),{attributes:i}=c;return l({span_id:e,trace_id:n,sampled:r===Nt,attributes:i},s)})}function mo(t){if(t!=null&&t.length)return t.map(({context:{spanId:e,traceId:n,traceFlags:r},attributes:s})=>({span_id:e,trace_id:n,sampled:r===Nt,attributes:s}))}function te(t){return typeof t=="number"?sr(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?sr(t.getTime()):Ie()}function sr(t){return t>9999999999?t/1e3:t}function M(t){if(bo(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(So(t)){const{attributes:r,startTime:s,name:i,endTime:o,status:c,links:a}=t;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:go(t),start_timestamp:te(s),timestamp:te(o)||void 0,status:us(c),op:r[Ye],origin:r[rn],links:cs(a)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function go(t){var e;return"parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?(e=t.parentSpanContext)==null?void 0:e.spanId:void 0}function yo(t){var e;return T(l({},t),{attributes:er(t.attributes),links:(e=t.links)==null?void 0:e.map(n=>T(l({},n),{attributes:er(n.attributes)}))})}function So(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function bo(t){return typeof t.getSpanJSON=="function"}function Y(t){const{traceFlags:e}=t.spanContext();return e===Nt}function us(t){if(!(!t||t.code===ts))return t.code===Pt?"ok":t.message||"internal_error"}function ls(t){return!t||t.code===Pt||t.code===ts||t.message==="cancelled"?"ok":"error"}function Eo(t,e){const n=ls(e)==="error"?e==null?void 0:e.message:void 0;return l(l({},n&&{[Gi]:n}),t)}const Se="_sentryChildSpans",on="_sentryRootSpan";function an(t,e){const n=t[on]||t;q(e,on,n),t[Se]?t[Se].add(e):q(t,Se,new Set([e]))}function To(t){const e=new Set;function n(r){if(!e.has(r)&&Y(r)){e.add(r);const s=r[Se]?Array.from(r[Se]):[];for(const i of s)n(i)}}return n(t),Array.from(e)}const $=vo;function vo(t){return t[on]||t}function fs(){const t=K(),e=le(t);return e.getActiveSpan?e.getActiveSpan():Je(b())}function cn(){rr||(xe(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),rr=!0)}function Ae(t){var n;if(typeof __SENTRY_TRACING__=="boolean"&&!__SENTRY_TRACING__)return!1;const e=t||((n=w())==null?void 0:n.getOptions());return!!e&&(e.tracesSampleRate!=null||!!e.tracesSampler)}function ir(t){g.log(`Ignoring span ${t.op} - ${t.description} because it matches \`ignoreSpans\`.`)}function Ve(t,e){if(!(e!=null&&e.length))return!1;for(const n of e){if(ko(n)){if(t.description&&ye(t.description,n))return y&&ir(t),!0;continue}const r=!!n.attributes&&Object.keys(n.attributes).length>0;if(!n.name&&!n.op&&!r)continue;const s=n.name?t.description&&ye(t.description,n.name):!0,i=n.op?t.op&&ye(t.op,n.op):!0,o=n.attributes?Object.entries(n.attributes).every(([c,a])=>{var u;return Io((u=t.attributes)==null?void 0:u[c],a)}):!0;if(s&&i&&o)return y&&ir(t),!0}return!1}function Io(t,e){return typeof t=="string"&&(typeof e=="string"||e instanceof RegExp)?ye(t,e):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((n,r)=>n===e[r]):t===e}function wo(t,e){const n=e.parent_span_id,r=e.span_id;if(n)for(const s of t)s.parent_span_id===r&&(s.parent_span_id=n)}function ko(t){return typeof t=="string"||t instanceof RegExp}const ps=Symbol.for("sentry.nonRecordingSpan");class Xe{constructor(e={}){this._traceId=e.traceId||ne(),this._spanId=e.spanId||ue(),this.dropReason=e.dropReason,q(this,ps,!0)}spanContext(){return{spanId:this._spanId,traceId:this._traceId,traceFlags:as}}end(e){}setAttribute(e,n){return this}setAttributes(e){return this}setStatus(e){return this}updateName(e){return this}isRecording(){return!1}addEvent(e,n,r){return this}addLink(e){return this}addLinks(e){return this}recordException(e,n){}}function Re(t){return!!t&&t[ps]===!0}const wn="production",ds="_frozenDsc";function or(t,e){q(t,ds,e)}function hs(t,e){const n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s={environment:n.environment||wn,release:n.release,public_key:r,trace_id:t,org_id:co(e)};return e.emit("createDsc",s),s}function kn(t,e){const n=e.getPropagationContext();return n.dsc||hs(n.traceId,t)}function Oe(t){var h,m,S,E,C;const e=w();if(!e)return{};const n=$(t),r=M(n),s=r.data,i=n.spanContext().traceState,o=(m=(h=i==null?void 0:i.get("sentry.sample_rate"))!=null?h:s[Zr])!=null?m:s[Wi];function c(A){return(typeof o=="number"||typeof o=="string")&&(A.sample_rate=`${o}`),A}const a=n[ds];if(a)return c(a);if(Re(n)&&!Ae(e.getOptions())){const A=ke(n).scope;if(A)return c(l({},kn(e,A)))}const u=i==null?void 0:i.get("sentry.dsc"),d=u&&Zi(u);if(d)return c(d);const f=hs(t.spanContext().traceId,e),_=(S=s[Ke])!=null?S:s["sentry.span.source"],p=r.description;return _!=="url"&&p&&(f.transaction=p),Ae()&&(f.sampled=String(Y(n)),f.sample_rand=(C=i==null?void 0:i.get("sentry.sample_rand"))!=null?C:(E=ke(n).scope)==null?void 0:E.getPropagationContext().sampleRand.toString()),c(f),e.emit("createDsc",f,n),f}function _s(t){return!!t&&typeof t=="function"&&"_streamed"in t&&!!t._streamed}function V(t,e=[]){return[t,e]}function ar(t,e){const[n,r]=t;return[n,[...r,e]]}function un(t,e){const n=t[1];for(const r of n){const s=r[0].type;if(e(r,s))return!0}return!1}function ln(t,e){return un(t,(n,r)=>e.includes(r))}function fn(t){const e=kt(D);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function Ao(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[fn(r),i]:r.push(typeof i=="string"?fn(i):i)}for(const i of n){const[o,c]=i;if(s(`
3
3
  ${JSON.stringify(o)}
4
- `),typeof c=="string"||c instanceof Uint8Array)s(c);else{let a;try{a=JSON.stringify(c)}catch(u){a=JSON.stringify(z(c))}s(a)}}return typeof r=="string"?r:ko(r)}function ko(t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Ao(t){return[{type:"span"},t]}function Ro(t){const e=typeof t.data=="string"?ln(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const _s={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function Co(t){return t in _s}function cr(t){return Co(t)?_s[t]:t}function ms(t){if(!(t!=null&&t.sdk))return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function Po(t,e,n,r){var i;const s=(i=t.sdkProcessingMetadata)==null?void 0:i.dynamicSamplingContext;return l(l(l({event_id:t.event_id,sent_at:new Date(G()).toISOString()},e&&{sdk:e}),!!n&&r&&{dsn:pe(r)}),s&&{trace:s})}function xo(t,e){var r,s,i,o;if(!e)return t;const n=t.sdk||{};return t.sdk=v(l({},n),{name:n.name||e.name,version:n.version||e.version,integrations:[...((r=t.sdk)==null?void 0:r.integrations)||[],...e.integrations||[]],packages:[...((s=t.sdk)==null?void 0:s.packages)||[],...e.packages||[]],settings:(i=t.sdk)!=null&&i.settings||e.settings?l(l({},(o=t.sdk)==null?void 0:o.settings),e.settings):void 0}),t}function No(t,e,n,r){const s=ms(n),i=l(l({sent_at:new Date(G()).toISOString()},s&&{sdk:s}),!!r&&e&&{dsn:pe(e)}),o="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return V(i,[o])}function Do(t,e,n,r){const s=ms(n),i=t.type&&t.type!=="replay_event"?t.type:"event";xo(t,n==null?void 0:n.sdk);const o=Po(t,s,r,e);return delete t.sdkProcessingMetadata,V(o,[[{type:i},t]])}function Mo(t,e){function n(p){return!!p.trace_id&&!!p.public_key}const r=Oe(t[0]),s=e==null?void 0:e.getDsn(),i=e==null?void 0:e.getOptions().tunnel,o=l(l({sent_at:new Date(G()).toISOString()},n(r)&&{trace:r}),!!i&&s&&{dsn:pe(s)}),{beforeSendSpan:c,ignoreSpans:a}=(e==null?void 0:e.getOptions())||{},u=a!=null&&a.length?t.filter(p=>{const h=M(p);return!Ve({description:h.description,op:h.op,attributes:h.data},a)}):t,d=t.length-u.length;d&&(e==null||e.recordDroppedEvent("before_send","span",d));const f=c?p=>{const h=M(p),m=hs(c)?h:c(h);return m||(an(),h)}:M,_=[];for(const p of u){const h=f(p);h&&_.push(Ao(h))}return V(o,_)}function Oo(t){if(!y)return;const{description:e="< unknown name >",op:n="< unknown op >",parent_span_id:r}=M(t),{spanId:s}=t.spanContext(),i=Y(t),o=$(t),c=o===t,a=`[Tracing] Starting ${i?"sampled":"unsampled"} ${c?"root ":""}span`,u=[`op: ${n}`,`name: ${e}`,`ID: ${s}`];if(r&&u.push(`parent ID: ${r}`),!c){const{op:d,description:f}=M(o);u.push(`root ID: ${o.spanContext().spanId}`),d&&u.push(`root op: ${d}`),f&&u.push(`root description: ${f}`)}g.log(`${a}
4
+ `),typeof c=="string"||c instanceof Uint8Array)s(c);else{let a;try{a=JSON.stringify(c)}catch(u){a=JSON.stringify(z(c))}s(a)}}return typeof r=="string"?r:Ro(r)}function Ro(t){const e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Co(t){return[{type:"span"},t]}function Po(t){const e=typeof t.data=="string"?fn(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const ms={sessions:"session",event:"error",client_report:"internal",user_report:"default",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",raw_security:"security",log:"log_item",trace_metric:"metric"};function No(t){return t in ms}function cr(t){return No(t)?ms[t]:t}function gs(t){if(!(t!=null&&t.sdk))return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function xo(t,e,n,r){var i;const s=(i=t.sdkProcessingMetadata)==null?void 0:i.dynamicSamplingContext;return l(l(l({event_id:t.event_id,sent_at:new Date(G()).toISOString()},e&&{sdk:e}),!!n&&r&&{dsn:pe(r)}),s&&{trace:s})}function Do(t,e){var r,s,i,o;if(!e)return t;const n=t.sdk||{};return t.sdk=T(l({},n),{name:n.name||e.name,version:n.version||e.version,integrations:[...((r=t.sdk)==null?void 0:r.integrations)||[],...e.integrations||[]],packages:[...((s=t.sdk)==null?void 0:s.packages)||[],...e.packages||[]],settings:(i=t.sdk)!=null&&i.settings||e.settings?l(l({},(o=t.sdk)==null?void 0:o.settings),e.settings):void 0}),t}function Mo(t,e,n,r){const s=gs(n),i=l(l({sent_at:new Date(G()).toISOString()},s&&{sdk:s}),!!r&&e&&{dsn:pe(e)}),o="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return V(i,[o])}function Oo(t,e,n,r){const s=gs(n),i=t.type&&t.type!=="replay_event"?t.type:"event";Do(t,n==null?void 0:n.sdk);const o=xo(t,s,r,e);return delete t.sdkProcessingMetadata,V(o,[[{type:i},t]])}function Fo(t,e){function n(p){return!!p.trace_id&&!!p.public_key}const r=Oe(t[0]),s=e==null?void 0:e.getDsn(),i=e==null?void 0:e.getOptions().tunnel,o=l(l({sent_at:new Date(G()).toISOString()},n(r)&&{trace:r}),!!i&&s&&{dsn:pe(s)}),{beforeSendSpan:c,ignoreSpans:a}=(e==null?void 0:e.getOptions())||{},u=a!=null&&a.length?t.filter(p=>{const h=M(p);return!Ve({description:h.description,op:h.op,attributes:h.data},a)}):t,d=t.length-u.length;d&&(e==null||e.recordDroppedEvent("before_send","span",d));const f=c?p=>{const h=M(p),m=_s(c)?h:c(h);return m||(cn(),h)}:M,_=[];for(const p of u){const h=f(p);h&&_.push(Co(h))}return V(o,_)}function Lo(t){if(!y)return;const{description:e="< unknown name >",op:n="< unknown op >",parent_span_id:r}=M(t),{spanId:s}=t.spanContext(),i=Y(t),o=$(t),c=o===t,a=`[Tracing] Starting ${i?"sampled":"unsampled"} ${c?"root ":""}span`,u=[`op: ${n}`,`name: ${e}`,`ID: ${s}`];if(r&&u.push(`parent ID: ${r}`),!c){const{op:d,description:f}=M(o);u.push(`root ID: ${o.spanContext().spanId}`),d&&u.push(`root op: ${d}`),f&&u.push(`root description: ${f}`)}g.log(`${a}
5
5
  ${u.join(`
6
- `)}`)}function Fo(t){if(!y)return;const{description:e="< unknown name >",op:n="< unknown op >"}=M(t),{spanId:r}=t.spanContext(),i=$(t)===t,o=`[Tracing] Finishing "${n}" ${i?"root ":""}span "${e}" with ID ${r}`;g.log(o)}function Q(t,e,n,r=ls()){const s=r&&$(r);s&&(y&&g.log(`[Measurement] Setting measurement on root span: ${t} = ${e} ${n}`),s.addEvent(t,{[es]:e,[Qr]:n}))}function ur(t){if(!t||t.length===0)return;const e={};return t.forEach(n=>{const r=n.attributes||{},s=r[Qr],i=r[es];typeof s=="string"&&typeof i=="number"&&(e[n.name]={value:i,unit:s})}),e}function Fe(t){return t.getOptions().traceLifecycle==="stream"}const lr=1e3;class kn{constructor(e={}){this._traceId=e.traceId||ne(),this._spanId=e.spanId||ue(),this._startTime=e.startTimestamp||Ie(),this._links=e.links,this._attributes={},this.setAttributes(l({[nn]:"manual",[Ye]:e.op},e.attributes)),this._name=e.name,e.parentSpanId&&(this._parentSpanId=e.parentSpanId),"sampled"in e&&(this._sampled=e.sampled),e.endTimestamp&&(this._endTime=e.endTimestamp),this._events=[],this._isStandaloneSpan=e.isStandalone,this._endTime&&this._onSpanEnded()}addLink(e){return this._links?this._links.push(e):this._links=[e],this}addLinks(e){return this._links?this._links.push(...e):this._links=e,this}recordException(e,n){}spanContext(){const{_spanId:e,_traceId:n,_sampled:r}=this;return{spanId:e,traceId:n,traceFlags:r?xt:as}}setAttribute(e,n){return n===void 0?delete this._attributes[e]:this._attributes[e]=n,this}setAttributes(e){return Object.keys(e).forEach(n=>this.setAttribute(n,e[n])),this}updateStartTime(e){this._startTime=te(e)}setStatus(e){return this._status=e,this}updateName(e){return this._name=e,Ki(this)||this.setAttribute(Ke,"custom"),this}end(e){this._endTime||(this._endTime=te(e),Fo(this),this._onSpanEnded())}getSpanJSON(){return{data:this._attributes,description:this._name,op:this._attributes[Ye],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:us(this._status),timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[nn],profile_id:this._attributes[En],exclusive_time:this._attributes[vn],measurements:ur(this._events),is_segment:this._isStandaloneSpan&&$(this)===this||void 0,segment_id:this._isStandaloneSpan?$(this).spanContext().spanId:void 0,links:cs(this._links)}}getStreamedSpanJSON(){var e,n;return{name:(e=this._name)!=null?e:"",span_id:this._spanId,trace_id:this._traceId,parent_span_id:this._parentSpanId,start_timestamp:this._startTime,end_timestamp:(n=this._endTime)!=null?n:this._startTime,is_segment:this._isStandaloneSpan||this===$(this),status:So(this._status),attributes:this._attributes,links:ho(this._links)}}isRecording(){return!this._endTime&&!!this._sampled}addEvent(e,n,r){y&&g.log("[Tracing] Adding an event to span:",e);const s=fr(n)?n:r||Ie(),i=fr(n)?{}:n||{},o={name:e,time:te(s),attributes:i};return this._events.push(o),this}isStandaloneSpan(){return!!this._isStandaloneSpan}_onSpanEnded(){const e=w();if(e&&(e.emit("spanEnd",this),this._isStandaloneSpan||e.emit("afterSpanEnd",this)),!(this._isStandaloneSpan||this===$(this)))return;if(this._isStandaloneSpan){this._sampled?$o(Mo([this],e)):(y&&g.log("[Tracing] Discarding standalone span because its trace was not chosen to be sampled."),e&&e.recordDroppedEvent("sample_rate","span"));return}else if(e&&Fe(e)){e.emit("afterSegmentSpanEnd",this);return}const r=this._convertSpanToTransaction();r&&(ke(this).scope||b()).captureEvent(r)}_convertSpanToTransaction(){var f;if(!pr(M(this)))return;this._name||(y&&g.warn("Transaction has no name, falling back to `<unlabeled transaction>`."),this._name="<unlabeled transaction>");const{scope:e,isolationScope:n}=ke(this),r=(f=e==null?void 0:e.getScopeData().sdkProcessingMetadata)==null?void 0:f.normalizedRequest;if(this._sampled!==!0)return;const i=bo(this).filter(_=>_!==this&&!Lo(_)).map(_=>M(_)).filter(pr),o=this._attributes[Ke];delete this._attributes[tr];let c=!1;i.forEach(_=>{var p;delete _.data[tr],(p=_.op)!=null&&p.startsWith("gen_ai.")&&(c=!0)});const a=l({contexts:{trace:uo(this)},spans:i.length>lr?i.sort((_,p)=>_.start_timestamp-p.start_timestamp).slice(0,lr):i,start_timestamp:this._startTime,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{capturedSpanScope:e,capturedSpanIsolationScope:n,dynamicSamplingContext:Oe(this),hasGenAiSpans:c},request:r},o&&{transaction_info:{source:o}}),u=ur(this._events);return u&&Object.keys(u).length&&(y&&g.log("[Measurements] Adding measurements to transaction event",JSON.stringify(u,void 0,2)),a.measurements=u),a}}function fr(t){return t&&typeof t=="number"||t instanceof Date||Array.isArray(t)}function pr(t){return!!t.start_timestamp&&!!t.timestamp&&!!t.span_id&&!!t.trace_id}function Lo(t){return t instanceof kn&&t.isStandaloneSpan()}function $o(t){const e=w();if(!e)return;const n=t[1];if(!n||n.length===0){e.recordDroppedEvent("before_send","span");return}e.sendEnvelope(t)}function Bo(t,e,n=()=>{},r=()=>{}){let s;try{s=t()}catch(i){throw e(i),n(),i}return jo(s,e,n,r)}function jo(t,e,n,r){return ce(t)?Xr(t,s=>{n(),r(s)},s=>{e(s),n()}):(n(),r(t),t)}function Ho(t,e,n){if(!Ae(t))return[!1];let r,s;typeof t.tracesSampler=="function"?(s=t.tracesSampler(v(l({},e),{inheritOrSampleWith:c=>typeof e.parentSampleRate=="number"?e.parentSampleRate:typeof e.parentSampled=="boolean"?Number(e.parentSampled):c})),r=!0):e.parentSampled!==void 0?s=e.parentSampled:typeof t.tracesSampleRate!="undefined"&&(s=t.tracesSampleRate,r=!0);const i=Tn(s);if(i===void 0)return y&&g.warn(`[Tracing] Discarding root span because of invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(s)} of type ${JSON.stringify(typeof s)}.`),[!1];if(!i)return y&&g.log(`[Tracing] Discarding transaction because ${typeof t.tracesSampler=="function"?"tracesSampler returned 0 or false":"a negative sampling decision was inherited or tracesSampleRate is set to 0"}`),[!1,i,r];const o=n<i;return o||y&&g.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(s)})`),[o,i,r]}const Uo="__SENTRY_SUPPRESS_TRACING__";function _e(t,e){const n=An();if(n.startSpan)return n.startSpan(t,e);const r=bs(t),{forceTransaction:s,parentSpan:i,scope:o}=t,c=o==null?void 0:o.clone();return fe(c,()=>qo(i)(()=>{const u=b(),d=Es(u,i),f=w(),p=t.onlyIfParent&&!d?ys(u,f):Ss({parentSpan:d,spanArguments:r,forceTransaction:s,scope:u});return(!Go(p)||!d)&&We(u,p),Bo(()=>e(p),()=>{const{status:h}=M(p);p.isRecording()&&(!h||h==="ok")&&p.setStatus({code:N,message:"internal_error"})},()=>{p.end()})}))}function Nt(t){const e=An();if(e.startInactiveSpan)return e.startInactiveSpan(t);const n=bs(t),{forceTransaction:r,parentSpan:s}=t;return(t.scope?o=>fe(t.scope,o):s!==void 0?o=>gs(s,o):o=>o())(()=>{const o=b(),c=Es(o,s),a=w();return t.onlyIfParent&&!c?ys(o,a):Ss({parentSpan:c,spanArguments:n,forceTransaction:r,scope:o})})}function gs(t,e){const n=An();return n.withActiveSpan?n.withActiveSpan(t,e):fe(r=>(We(r,t||void 0),e(r)))}function ys(t,e){e==null||e.recordDroppedEvent("no_parent_span","span");const n=new Xe({traceId:t.getPropagationContext().traceId});return we(n,t,R()),n}function Ss({parentSpan:t,spanArguments:e,forceTransaction:n,scope:r}){var c;const s=R();if(!Ae()){const a=l(l({},s.getPropagationContext()),r.getPropagationContext()),u=t?t.spanContext().traceId:a.traceId,d=new Xe({traceId:u});return t&&!n&&on(t,d),we(d,r,s),d}const i=w();if(Wo(i,e)){Rn(r)||i==null||i.recordDroppedEvent("ignored","span");const a=new Xe({dropReason:"ignored",traceId:(c=t==null?void 0:t.spanContext().traceId)!=null?c:r.getPropagationContext().traceId});return we(a,r,s),a}let o;if(t&&!n)o=zo(t,r,e,s),on(t,o);else if(t){const a=Oe(t),{traceId:u,spanId:d}=t.spanContext(),f=Y(t);o=dr(l({traceId:u,parentSpanId:d},e),r,s,f),or(o,a)}else{const{traceId:a,dsc:u,parentSpanId:d,sampled:f}=l(l({},s.getPropagationContext()),r.getPropagationContext());o=dr(l({traceId:a,parentSpanId:d},e),r,s,f),u&&or(o,u)}return Oo(o),o}function bs(t){const e=t.experimental||{},n=l({isStandalone:e.standalone},t);if(t.startTime){const r=l({},n);return r.startTimestamp=te(t.startTime),delete r.startTime,r}return n}function An(){const t=K();return le(t)}function dr(t,e,n,r){var S,E;const s=w(),i=(s==null?void 0:s.getOptions())||{},{name:o=""}=t,c={spanAttributes:l({},t.attributes),spanName:o,parentSampled:r};s==null||s.emit("beforeSampling",c,{decision:!1});const a=(S=c.parentSampled)!=null?S:r,u=c.spanAttributes,d=e.getPropagationContext(),f=Rn(e),[_,p,h]=f?[!1]:Ho(i,{name:o,parentSampled:a,attributes:u,parentSampleRate:Tn((E=d.dsc)==null?void 0:E.sample_rate)},d.sampleRand),m=new kn(v(l({},t),{attributes:l({[Ke]:"custom",[Zr]:p!==void 0&&h?p:void 0},u),sampled:_}));return!_&&s&&!f&&(y&&g.log("[Tracing] Discarding root span because its trace was not chosen to be sampled."),s.recordDroppedEvent("sample_rate",Fe(s)?"span":"transaction")),we(m,e,n),s&&s.emit("spanStart",m),m}function zo(t,e,n,r){const{spanId:s,traceId:i}=t.spanContext(),o=Rn(e),c=o?!1:Y(t),a=c?new kn(v(l({},n),{parentSpanId:s,traceId:i,sampled:c})):new Xe({traceId:i});on(t,a),we(a,e,r);const u=w();return u&&(Fe(u)&&Re(a)&&(Re(t)&&t.dropReason?(a.dropReason=t.dropReason,u.recordDroppedEvent(t.dropReason,"span")):o||(a.dropReason="sample_rate",u.recordDroppedEvent("sample_rate","span"))),u.emit("spanStart",a),n.endTimestamp&&(u.emit("spanEnd",a),u.emit("afterSpanEnd",a))),a}function Es(t,e){if(e)return e;if(e===null)return;const n=Ge(t);if(!n)return;const r=w();return(r?r.getOptions():{}).parentSpanIsAlwaysRootSpan?$(n):n}function qo(t){return t!==void 0?e=>gs(t,e):e=>e()}function Wo(t,e){var r;const n=t==null?void 0:t.getOptions().ignoreSpans;return!t||!Fe(t)||!(n!=null&&n.length)?!1:Ve({description:e.name||"",op:((r=e.attributes)==null?void 0:r[Ye])||e.op,attributes:e.attributes},n)}function Go(t){return Re(t)&&t.dropReason==="ignored"}function Rn(t){return t.getScopeData().sdkProcessingMetadata[Uo]===!0}function Jo(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;Ko(t,e),r&&Xo(t,r),Zo(t,n),Yo(t,s),Vo(t,i)}function hr(t,e){const{extra:n,tags:r,attributes:s,user:i,contexts:o,level:c,sdkProcessingMetadata:a,breadcrumbs:u,fingerprint:d,eventProcessors:f,attachments:_,propagationContext:p,transactionName:h,span:m}=e;he(t,"extra",n),he(t,"tags",r),he(t,"attributes",s),he(t,"user",i),he(t,"contexts",o),t.sdkProcessingMetadata=Me(t.sdkProcessingMetadata,a,2),c&&(t.level=c),h&&(t.transactionName=h),m&&(t.span=m),u.length&&(t.breadcrumbs=[...t.breadcrumbs,...u]),d.length&&(t.fingerprint=[...t.fingerprint,...d]),f.length&&(t.eventProcessors=[...t.eventProcessors,...f]),_.length&&(t.attachments=[...t.attachments,..._]),t.propagationContext=l(l({},t.propagationContext),p)}function he(t,e,n){t[e]=Me(t[e],n,1)}function vs(t,e){const n=Ui().getScopeData();return t&&hr(n,t.getScopeData()),e&&hr(n,e.getScopeData()),n}function Ko(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:c}=e;Object.keys(n).length&&(t.extra=l(l({},n),t.extra)),Object.keys(r).length&&(t.tags=l(l({},r),t.tags)),Object.keys(s).length&&(t.user=l(l({},s),t.user)),Object.keys(i).length&&(t.contexts=l(l({},i),t.contexts)),o&&(t.level=o),c&&t.type!=="transaction"&&(t.transaction=c)}function Yo(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Vo(t,e){t.sdkProcessingMetadata=l(l({},t.sdkProcessingMetadata),e)}function Xo(t,e){t.contexts=l({trace:lo(e)},t.contexts),t.sdkProcessingMetadata=l({dynamicSamplingContext:Oe(e)},t.sdkProcessingMetadata);const n=$(e),r=M(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function Zo(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint.length||delete t.fingerprint}const Bt=0,_r=1,mr=2;function Cn(t){return new Ce(e=>{e(t)})}function Pn(t){return new Ce((e,n)=>{n(t)})}class Ce{constructor(e){this._state=Bt,this._handlers=[],this._runExecutor(e)}then(e,n){return new Ce((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(o){s(o)}},i=>{if(!n)s(i);else try{r(n(i))}catch(o){s(o)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new Ce((n,r)=>{let s,i;return this.then(o=>{i=!1,s=o,e&&e()},o=>{i=!0,s=o,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}_executeHandlers(){if(this._state===Bt)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===_r&&n[1](this._value),this._state===mr&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,o)=>{if(this._state===Bt){if(ce(o)){o.then(r,s);return}this._state=i,this._value=o,this._executeHandlers()}},r=i=>{n(_r,i)},s=i=>{n(mr,i)};try{e(r,s)}catch(i){s(i)}}}function Qo(t,e,n,r=0){try{const s=fn(e,n,t,r);return ce(s)?s:Cn(s)}catch(s){return Pn(s)}}function fn(t,e,n,r){const s=n[r];if(!t||!s)return t;const i=s(l({},t),e);return y&&i===null&&g.log(`Event processor "${s.id||"?"}" dropped event`),ce(i)?i.then(o=>fn(o,e,n,r+1)):fn(i,e,n,r+1)}let H,gr,yr,U;function ea(t){const e=D._sentryDebugIds,n=D._debugIds;if(!e&&!n)return{};const r=e?Object.keys(e):[],s=n?Object.keys(n):[];if(U&&r.length===gr&&s.length===yr)return U;gr=r.length,yr=s.length,U={},H||(H={});const i=(o,c)=>{for(const a of o){const u=c[a],d=H==null?void 0:H[a];if(d&&U&&u)U[d[0]]=u,H&&(H[a]=[d[0],u]);else if(u){const f=t(a);for(let _=f.length-1;_>=0;_--){const p=f[_],h=p==null?void 0:p.filename;if(h&&U&&H){U[h]=u,H[a]=[h,u];break}}}}};return e&&i(r,e),n&&i(s,n),U}function ta(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:c=1e3}=t,a=v(l({},e),{event_id:e.event_id||n.event_id||L(),timestamp:e.timestamp||De()}),u=n.integrations||t.integrations.map(E=>E.name);na(a,t),ia(a,u),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&ra(a,t.stackParser);const d=aa(r,n.captureContext);n.mechanism&&Ai(a,n.mechanism);const f=s?s.getEventProcessors():[],_=vs(i,d),p=[...n.attachments||[],..._.attachments];p.length&&(n.attachments=p),Jo(a,_);const h=[...f,..._.eventProcessors];return(n.data&&n.data.__sentry__===!0?Cn(a):Qo(h,a,n)).then(E=>(E&&sa(E),typeof o=="number"&&o>0?oa(E,o,c):E))}function na(t,e){var c,a;const{environment:n,release:r,dist:s,maxValueLength:i}=e;t.environment=t.environment||n||In,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const o=t.request;o!=null&&o.url&&i&&(o.url=tn(o.url,i)),i&&((a=(c=t.exception)==null?void 0:c.values)==null||a.forEach(u=>{u.value&&(u.value=tn(u.value,i))}))}function ra(t,e){var r,s;const n=ea(e);(s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,c;(c=(o=i.stacktrace)==null?void 0:o.frames)==null||c.forEach(a=>{a.filename&&(a.debug_id=n[a.filename])})})}function sa(t){var r,s;const e={};if((s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,c;(c=(o=i.stacktrace)==null?void 0:o.frames)==null||c.forEach(a=>{a.debug_id&&(a.abs_path?e[a.abs_path]=a.debug_id:a.filename&&(e[a.filename]=a.debug_id),delete a.debug_id)})}),Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.entries(e).forEach(([i,o])=>{n.push({type:"sourcemap",code_file:i,debug_id:o})})}function ia(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function oa(t,e,n){var s,i;if(!t)return null;const r=l(l(l(l(l({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(o=>l(l({},o),o.data&&{data:z(o.data,e,n)}))}),t.user&&{user:z(t.user,e,n)}),t.contexts&&{contexts:z(t.contexts,e,n)}),t.extra&&{extra:z(t.extra,e,n)});return(s=t.contexts)!=null&&s.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=z(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(o=>l(l({},o),o.data&&{data:z(o.data,e,n)}))),(i=t.contexts)!=null&&i.flags&&r.contexts&&(r.contexts.flags=z(t.contexts.flags,3,n)),r}function aa(t,e){if(!e)return t;const n=t?t.clone():new B;return n.update(e),n}function ca(t){if(t)return ua(t)?{captureContext:t}:fa(t)?{captureContext:t}:t}function ua(t){return t instanceof B||typeof t=="function"}const la=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function fa(t){return Object.keys(t).some(e=>la.includes(e))}function ee(t,e){return b().captureException(t,ca(e))}function pa(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return b().captureMessage(t,n,r)}function da(t,e){return b().captureEvent(t,e)}function W(t,e){R().setContext(t,e)}function ha(t){R().setExtras(t)}function _a(t,e){R().setExtra(t,e)}function ma(t){R().setTags(t)}function ga(t,e){R().setTag(t,e)}function ya(t){R().setUser(t)}function Sa(){return R().lastEventId()}function Ts(t){return O(this,null,function*(){const e=w();return e?e.flush(t):(y&&g.warn("Cannot flush events. No client defined."),Promise.resolve(!1))})}function ba(t){return O(this,null,function*(){const e=w();return e?e.close(t):(y&&g.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))})}function Is(){const t=w();return(t==null?void 0:t.getOptions().enabled)!==!1&&!!(t!=null&&t.getTransport())}function Ea(t){R().addEventProcessor(t)}function ws(t){const e=R(),{user:n}=vs(e,b()),{userAgent:r}=D.navigator||{},s=Kr(l(l({user:n},r&&{userAgent:r}),t)),i=e.getSession();return(i==null?void 0:i.status)==="ok"&&J(i,{status:"exited"}),Dt(),e.setSession(s),s}function Dt(){const t=R(),n=b().getSession()||t.getSession();n&&Yr(n),ks(),t.setSession()}function ks(){const t=R(),e=w(),n=t.getSession();n&&e&&e.captureSession(n)}function pn(t=!1){if(t){Dt();return}ks()}const va="7";function Ta(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function Ia(t){return`${Ta(t)}${t.projectId}/envelope/`}function wa(t,e){const n={sentry_version:va};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function ka(t,e,n){return e||`${Ia(t)}?${wa(t,n)}`}const be=[];function Aa(t,e){const n={};return e.forEach(r=>{r!=null&&r.beforeSetup&&r.beforeSetup(t)}),e.forEach(r=>{r&&As(t,r,n)}),n}function Sr(t,e){for(const n of e)n!=null&&n.afterAllSetup&&n.afterAllSetup(t)}function As(t,e,n){if(n[e.name]){y&&g.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,!be.includes(e.name)&&typeof e.setupOnce=="function"&&(e.setupOnce(),be.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){const r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,i)=>r(s,i,t))}if(typeof e.processEvent=="function"){const r=e.processEvent.bind(e),s=Object.assign((i,o)=>r(i,o,t),{id:e.name});t.addEventProcessor(s)}["processSpan","processSegmentSpan"].forEach(r=>{const s=e[r];typeof s=="function"&&t.on(r,i=>s.call(e,i,t))}),y&&g.log(`Integration installed: ${e.name}`)}function Ra(t){const e=w();if(!e){y&&g.warn(`Cannot add integration "${t.name}" because no SDK Client is available.`);return}e.addIntegration(t)}function Ca(){return typeof __SENTRY_BROWSER_BUNDLE__!="undefined"&&!!__SENTRY_BROWSER_BUNDLE__}function Pa(){return!Ca()&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]"}function xn(){return typeof window!="undefined"&&(!Pa()||xa())}function xa(){const t=D.process;return(t==null?void 0:t.type)==="renderer"}function Na(t,e){const n=e?"auto":"never";return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},v(l({version:2},xn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function Da(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=pe(r)),V(i,[Na(t,s)])}function br(t,e){var i;const n=(i=e!=null?e:Ma(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=Da(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Rs().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function Ma(t){return Rs().get(t)}function Rs(){return ae("clientToLogBufferMap",()=>new WeakMap)}function Oa(t,e){const n=e?"auto":"never";return[{type:"trace_metric",item_count:t.length,content_type:"application/vnd.sentry.items.trace-metric+json"},v(l({version:2},xn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function Fa(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=pe(r)),V(i,[Oa(t,s)])}function La(t,e){var i;const n=(i=e!=null?e:$a(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=Fa(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Cs().set(t,[]),t.emit("flushMetrics"),t.sendEnvelope(s)}function $a(t){return Cs().get(t)}function Cs(){return ae("clientToMetricBufferMap",()=>new WeakMap)}function Ba(t){const e={trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,name:t.description||"",start_timestamp:t.start_timestamp,end_timestamp:t.timestamp||t.start_timestamp,status:!t.status||t.status==="ok"||t.status==="cancelled"?"ok":"error",is_segment:!1,attributes:l({},t.data),links:t.links};return mo(e)}function ja(t,e){var i,o,c;if(t.type!=="transaction"||!((i=t.spans)!=null&&i.length)||!((o=t.sdkProcessingMetadata)!=null&&o.hasGenAiSpans)||e.getOptions().streamGenAiSpans===!1||Fe(e))return;const n=[],r=[];for(const a of t.spans)(c=a.op)!=null&&c.startsWith("gen_ai.")?n.push(Ba(a)):r.push(a);if(n.length===0)return;t.spans=r;const s=e.getDataCollectionOptions().userInfo?"auto":"never";return[{type:"span",item_count:n.length,content_type:"application/vnd.sentry.items.span.v2+json"},v(l({version:2},xn()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}}),{items:n})]}function Nn(t){return typeof t=="object"&&typeof t.unref=="function"&&t.unref(),t}const Dn=Symbol.for("SentryBufferFullError");function Ps(t=100){const e=new Set;function n(){return e.size<t}function r(o){e.delete(o)}function s(o){if(!n())return Pn(Dn);const c=o();return e.add(c),c.then(()=>r(c),()=>r(c)),c}function i(o){if(!e.size)return Cn(!0);const c=Promise.allSettled(Array.from(e)).then(()=>!0);if(!o)return c;const a=[c,new Promise(u=>Nn(setTimeout(()=>u(!1),o)))];return Promise.race(a)}return{get $(){return Array.from(e)},add:s,drain:i}}const Ha=60*1e3;function xs(t,e=G()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?Ha:r-e}function Ua(t,e){return t[e]||t.all||0}function za(t,e,n=G()){return Ua(t,e)>n}function qa(t,{statusCode:e,headers:n},r=G()){const s=l({},t),i=n==null?void 0:n["x-sentry-rate-limits"],o=n==null?void 0:n["retry-after"];if(i)for(const c of i.trim().split(",")){const[a,u,,,d]=c.split(":",5),f=parseInt(a,10),_=(isNaN(f)?60:f)*1e3;if(!u)s.all=r+_;else for(const p of u.split(";"))p==="metric_bucket"?(!d||d.split(";").includes("custom"))&&(s[p]=r+_):s[p]=r+_}else o?s.all=r+xs(o,r):e===429&&(s.all=r+60*1e3);return s}const Ns=64;function Wa(t,e,n=Ps(t.bufferSize||Ns)){let r={};const s=o=>n.drain(o);function i(o){const c=[];if(cn(o,(f,_)=>{const p=cr(_);za(r,p)?t.recordDroppedEvent("ratelimit_backoff",p):c.push(f)}),c.length===0)return Promise.resolve({});const a=V(o[0],c),u=f=>{if(un(a,["client_report"])){y&&g.warn(`Dropping client report. Will not send outcomes (reason: ${f}).`);return}cn(a,(_,p)=>{t.recordDroppedEvent(f,cr(p))})},d=()=>e({body:wo(a)}).then(f=>f.statusCode===413?(y&&g.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),u("send_error"),f):(y&&f.statusCode!==void 0&&(f.statusCode<200||f.statusCode>=300)&&g.warn(`Sentry responded with status code ${f.statusCode} to sent event.`),r=qa(r,f),f),f=>{throw u("network_error"),y&&g.error("Encountered error running transport request:",f),f});return n.add(d).then(f=>f,f=>{if(f===Dn)return y&&g.error("Skipped sending event because buffer is full."),u("queue_overflow"),Promise.resolve({});throw f})}return{send:i,flush:s}}function Ga(t,e,n){const r=[{type:"client_report"},{timestamp:De(),discarded_events:t}];return V(e?{dsn:e}:{},[r])}function Ds(t){const e=[];t.message&&e.push(t.message);try{const n=t.exception.values[t.exception.values.length-1];n!=null&&n.value&&(e.push(n.value),n.type&&e.push(`${n.type}: ${n.value}`))}catch(n){}return e}function Ja(t){var a,u,d;const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:o,op:c}=(u=(a=t.contexts)==null?void 0:a.trace)!=null?u:{};return{data:o!=null?o:{},description:t.transaction,op:c,parent_span_id:n,span_id:r!=null?r:"",start_timestamp:(d=t.start_timestamp)!=null?d:0,status:s,timestamp:t.timestamp,trace_id:e!=null?e:"",origin:i,profile_id:o==null?void 0:o[En],exclusive_time:o==null?void 0:o[vn],measurements:t.measurements,is_segment:!0}}function Ka(t){return{type:"transaction",timestamp:t.timestamp,start_timestamp:t.start_timestamp,transaction:t.description,contexts:{trace:{trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,op:t.op,status:t.status,origin:t.origin,data:l(l(l({},t.data),t.profile_id&&{[En]:t.profile_id}),t.exclusive_time&&{[vn]:t.exclusive_time})}},measurements:t.measurements}}const He=["forwarded","-ip","remote-","via","-user"];function Ya(t){return t===!0?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:7}:{userInfo:!1,cookies:{deny:He},httpHeaders:{request:{deny:He},response:{deny:He}},httpBodies:[],queryParams:{deny:He},genAI:{inputs:!1,outputs:!1},stackFrameVariables:!0,frameContextLines:7}}const Va={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:5};function Xa(t){var r,s,i,o,c,a,u,d,f,_,p,h,m,S,E;const e=t.dataCollection!=null?Va:Ya(t.sendDefaultPii),n=(r=t.dataCollection)!=null?r:{};return{userInfo:(s=n.userInfo)!=null?s:e.userInfo,cookies:(i=n.cookies)!=null?i:e.cookies,httpHeaders:{request:(c=(o=n.httpHeaders)==null?void 0:o.request)!=null?c:e.httpHeaders.request,response:(u=(a=n.httpHeaders)==null?void 0:a.response)!=null?u:e.httpHeaders.response},httpBodies:(d=n.httpBodies)!=null?d:e.httpBodies,queryParams:(f=n.queryParams)!=null?f:e.queryParams,genAI:{inputs:(p=(_=n.genAI)==null?void 0:_.inputs)!=null?p:e.genAI.inputs,outputs:(m=(h=n.genAI)==null?void 0:h.outputs)!=null?m:e.genAI.outputs},stackFrameVariables:(S=n.stackFrameVariables)!=null?S:e.stackFrameVariables,frameContextLines:(E=n.frameContextLines)!=null?E:e.frameContextLines}}const Er="Not capturing exception because it's already been captured.",vr="Discarded session because of missing or non-string release",Ms=Symbol.for("SentryInternalError"),Os=Symbol.for("SentryDoNotSendEventError"),Za=5e3;function Ue(t){return{message:t,[Ms]:!0}}function jt(t){return{message:t,[Os]:!0}}function Tr(t){return!!t&&typeof t=="object"&&Ms in t}function Ir(t){return!!t&&typeof t=="object"&&Os in t}function wr(t,e,n,r,s){let i=0,o,c=!1;t.on(n,()=>{i=0,clearTimeout(o),c=!1}),t.on(e,a=>{var u;if(i+=r(a),i>=8e5)s(t);else if(!c){const d=(u=t.getOptions()._flushInterval)!=null?u:Za;d>0&&(c=!0,o=Nn(setTimeout(()=>{s(t)},d)))}}),t.on("flush",()=>{s(t)})}class Qa{constructor(e){var r,s,i,o,c,a,u;if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Ps((s=(r=e.transportOptions)==null?void 0:r.bufferSize)!=null?s:Ns),this._dataCollection=Xa(e),e.dsn?this._dsn=ao(e.dsn):y&&g.warn("No DSN provided, client will not send events."),this._dsn){const d=ka(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport(v(l({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this)},e.transportOptions),{url:d}))}this._options.enableLogs=(o=this._options.enableLogs)!=null?o:(i=this._options._experiments)==null?void 0:i.enableLogs,this._options.enableLogs&&wr(this,"afterCaptureLog","flushLogs",rc,br),((u=(a=this._options.enableMetrics)!=null?a:(c=this._options._experiments)==null?void 0:c.enableMetrics)!=null?u:!0)&&wr(this,"afterCaptureMetric","flushMetrics",nc,La)}captureException(e,n,r){const s=L();if(Xn(e))return y&&g.log(Er),s;const i=l({event_id:s},n);return this._process(()=>this.eventFromException(e,i).then(o=>this._captureEvent(o,i,r)).then(o=>o),"error"),i.event_id}captureMessage(e,n,r,s){const i=l({event_id:L()},r),o=Hr(e)?e:String(e),c=Ur(e),a=c?this.eventFromMessage(o,n,i):this.eventFromException(e,i);return this._process(()=>a.then(u=>this._captureEvent(u,i,s)),c?"unknown":"error"),i.event_id}captureEvent(e,n,r){const s=L();if(n!=null&&n.originalException&&Xn(n.originalException))return y&&g.log(Er),s;const i=l({event_id:s},n),o=e.sdkProcessingMetadata||{},c=o.capturedSpanScope,a=o.capturedSpanIsolationScope,u=kr(e.type);return this._process(()=>this._captureEvent(e,i,c||r,a),u),i.event_id}captureSession(e){this.sendSession(e),J(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){return O(this,null,function*(){const n=this._transport;if(this.emit("flush"),!n)return!0;const r=yield this._isClientDoneProcessing(e),s=yield n.flush(e);return r&&s})}close(e){return O(this,null,function*(){br(this);const n=yield this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),n})}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const n=this._integrations[e.name];!n&&e.beforeSetup&&e.beforeSetup(this),As(this,e,this._integrations),n||Sr(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);const r=ja(e,this);let s=Do(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])s=ar(s,Ro(i));r&&(s=ar(s,r)),this.sendEnvelope(s).then(i=>this.emit("afterSendEvent",e,i))}sendSession(e){const{release:n,environment:r=In}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){y&&g.warn(vr);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){y&&g.warn(vr);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=No(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(s)}recordDroppedEvent(e,n,r=1){if(this._options.sendClientReports){const s=`${e}:${n}`;y&&g.log(`Recording outcome: "${s}"${r>1?` (${r} times)`:""}`),this._outcomes[s]=(this._outcomes[s]||0)+r}}on(e,n){const r=this._hooks[e]=this._hooks[e]||new Set,s=(...i)=>n(...i);return r.add(s),()=>{r.delete(s)}}emit(e,...n){const r=this._hooks[e];r&&r.forEach(s=>s(...n))}sendEnvelope(e){return O(this,null,function*(){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)try{return yield this._transport.send(e)}catch(n){return y&&g.error("Error while sending envelope:",n),{}}return y&&g.error("Transport disabled"),{}})}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=Aa(this,e),Sr(this,e)}_updateSessionFromEvent(e,n){var a,u;let r=n.level==="fatal",s=!1;const i=(a=n.exception)==null?void 0:a.values;if(i){s=!0,r=!1;for(const d of i)if(((u=d.mechanism)==null?void 0:u.handled)===!1){r=!0;break}}const o=e.status==="ok";(o&&e.errors===0||o&&r)&&(J(e,v(l({},r&&{status:"crashed"}),{errors:e.errors||Number(s||r)})),this.captureSession(e))}_isClientDoneProcessing(e){return O(this,null,function*(){let n=0;for(;!e||n<e;){if(yield new Promise(r=>setTimeout(r,1)),!this._numProcessing)return!0;n++}return!1})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s){const i=this.getOptions(),o=this.getIntegrationNames();return!n.integrations&&o.length&&(n.integrations=o),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),ta(i,e,n,r,this,s).then(c=>{var u;if(c===null)return c;this.emit("postprocessEvent",c,n),c.contexts=l({trace:l(l({},(u=c.contexts)==null?void 0:u.trace),zi(r))},c.contexts);const a=wn(this,r);return c.sdkProcessingMetadata=l({dynamicSamplingContext:a},c.sdkProcessingMetadata),c})}_captureEvent(e,n={},r=b(),s=R()){return y&&dn(e)&&g.log(`Captured error event \`${Ds(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{y&&(Ir(i)?g.log(i.message):Tr(i)?g.warn(i.message):g.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:o}=i,c=Fs(e),a=dn(e),d=`before send for type \`${e.type||"error"}\``,f=typeof o=="undefined"?void 0:Tn(o);if(a&&typeof f=="number"&&Je()>f)return this.recordDroppedEvent("sample_rate","error"),Pn(jt(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const _=kr(e.type);return this._prepareEvent(e,n,r,s).then(p=>{var S;if(p===null)throw this.recordDroppedEvent("event_processor",_),jt("An event processor returned `null`, will not send event.");if(((S=n.data)==null?void 0:S.__sentry__)===!0)return p;const m=tc(this,i,p,n);return ec(m,d)}).then(p=>{var S;if(p===null){if(this.recordDroppedEvent("before_send",_),c){const C=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",C)}throw jt(`${d} returned \`null\`, will not send event.`)}const h=r.getSession()||s.getSession();if(a&&h&&this._updateSessionFromEvent(h,p),c){const E=((S=p.sdkProcessingMetadata)==null?void 0:S.spanCountBeforeProcessing)||0,C=p.spans?p.spans.length:0,A=E-C;A>0&&this.recordDroppedEvent("before_send","span",A)}const m=p.transaction_info;if(c&&m&&p.transaction!==e.transaction){const E="custom";p.transaction_info=v(l({},m),{source:E})}return this.sendEvent(p,n),p}).then(null,p=>{throw Ir(p)||Tr(p)?p:(this.captureException(p,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:p}),Ue(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
7
- Reason: ${p}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===Dn&&this.recordDroppedEvent("queue_overflow",n),r))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){y&&g.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){y&&g.log("No outcomes to send");return}if(!this._dsn){y&&g.log("No dsn provided, will not send outcomes");return}y&&g.log("Sending outcomes:",e);const n=Ga(e,this._options.tunnel&&pe(this._dsn));this.sendEnvelope(n)}}function kr(t){return t==="replay_event"?"replay":t||"error"}function ec(t,e){const n=`${e} must return \`null\` or a valid event.`;if(ce(t))return t.then(r=>{if(!Zt(r)&&r!==null)throw Ue(n);return r},r=>{throw Ue(`${e} rejected with ${r}`)});if(!Zt(t)&&t!==null)throw Ue(n);return t}function tc(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,c=!hs(e.beforeSendSpan)&&e.beforeSendSpan;let a=n;if(dn(a)&&s)return s(a,r);if(Fs(a)){if(c||o){const u=Ja(a);if(o!=null&&o.length&&Ve({description:u.description,op:u.op,attributes:u.data},o))return null;if(c){const d=c(u);d?a=Me(n,Ka(d)):an()}if(a.spans){const d=[],f=a.spans;for(const p of f){if(o!=null&&o.length&&Ve({description:p.description,op:p.op,attributes:p.data},o)){To(f,p);continue}if(c){const h=c(p);h?d.push(h):(an(),d.push(p))}else d.push(p)}const _=a.spans.length-d.length;_&&t.recordDroppedEvent("before_send","span",_),a.spans=d}}if(i){if(a.spans){const u=a.spans.length;a.sdkProcessingMetadata=v(l({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(a,r)}}return a}function dn(t){return t.type===void 0}function Fs(t){return t.type==="transaction"}function nc(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+Ls(t.attributes)}function rc(t){let e=0;return t.message&&(e+=t.message.length*2),e+Ls(t.attributes)}function Ls(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*Ar(n[0]):Ur(n)?e+=Ar(n):e+=100}),e}function Ar(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function sc(t,e){e.debug===!0&&(y?g.enable():Ne(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),b().update(e.initialScope);const r=new t(e);return ic(r),r.init(),r}function ic(t){b().setClient(t)}const Ht=100,Ut=5e3,oc=36e5;function Rr(t){function e(...n){y&&g.log("[Offline]:",...n)}return n=>{const r=t(n);if(!n.createStore)throw new Error("No `createStore` function was provided");const s=n.createStore(n);let i=Ut,o;function c(f,_,p){return un(f,["client_report"])?!1:n.shouldStore?n.shouldStore(f,_,p):!0}function a(f){o&&clearTimeout(o),o=Nn(setTimeout(()=>O(null,null,function*(){o=void 0;const _=yield s.shift();_&&(e("Attempting to send previously queued event"),_[0].sent_at=new Date(G()).toISOString(),d(_,!0).catch(p=>{e("Failed to retry sending",p)}))}),f))}function u(){o||(a(i),i=Math.min(i*2,oc))}function d(f,_=!1){return O(this,null,function*(){var p,h;if(!_&&un(f,["replay_event","replay_recording"]))return yield s.push(f),a(Ht),{};try{if(n.shouldSend&&(yield n.shouldSend(f))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const m=yield r.send(f);let S=Ht;if(m){if((p=m.headers)!=null&&p["retry-after"])S=xs(m.headers["retry-after"]);else if((h=m.headers)!=null&&h["x-sentry-rate-limits"])S=6e4;else if((m.statusCode||0)>=400)return m}return a(S),i=Ut,m}catch(m){if(yield c(f,m,i))return _?yield s.unshift(f):yield s.push(f),u(),e("Error sending. Event queued.",m),{};throw m}})}return n.flushAtStartup&&u(),{send:d,flush:f=>(f===void 0&&(i=Ut,a(Ht)),r.flush(f))}}}function ac(t={}){const e=t.client||w();if(!Is()||!e)return{};const n=K(),r=le(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||b(),i=t.span||ls(),o=Re(i)&&!Ae(e.getOptions()),c=i&&!o?fo(i):cc(s),a=i?Oe(i):wn(e,s),u=Xi(a);if(!co.test(c))return g.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const f={"sentry-trace":c,baggage:u};return t.propagateTraceparent&&(f.traceparent=i&&!o?po(i):uc(s)),f}function cc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return is(e,r,n)}function uc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return os(e,r,n)}const lc=100;function k(t,e){const n=w(),r=R();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=lc}=n.getOptions();if(i<=0)return;const o=De(),c=l({timestamp:o},t),a=s?Ne(()=>s(c,e)):c;a!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",a,e),r.addBreadcrumb(a,i))}const fc=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],pc="EventFilters",dc=(t={})=>{let e;return{name:pc,setup(n){const r=n.getOptions();e=Cr(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=Cr(t,i)}return hc(n,e)?null:n}}};function Cr(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:fc],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function hc(t,e){if(t.type){if(t.type==="transaction"&&mc(t,e.ignoreTransactions))return y&&g.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
8
- Event: ${Z(t)}`),!0}else{if(_c(t,e.ignoreErrors))return y&&g.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
9
- Event: ${Z(t)}`),!0;if(bc(t))return y&&g.warn(`Event dropped due to not having an error message, error type or stacktrace.
10
- Event: ${Z(t)}`),!0;if(gc(t,e.denyUrls))return y&&g.warn(`Event dropped due to being matched by \`denyUrls\` option.
6
+ `)}`)}function $o(t){if(!y)return;const{description:e="< unknown name >",op:n="< unknown op >"}=M(t),{spanId:r}=t.spanContext(),i=$(t)===t,o=`[Tracing] Finishing "${n}" ${i?"root ":""}span "${e}" with ID ${r}`;g.log(o)}function Q(t,e,n,r=fs()){const s=r&&$(r);s&&(y&&g.log(`[Measurement] Setting measurement on root span: ${t} = ${e} ${n}`),s.addEvent(t,{[es]:e,[Qr]:n}))}function ur(t){if(!t||t.length===0)return;const e={};return t.forEach(n=>{const r=n.attributes||{},s=r[Qr],i=r[es];typeof s=="string"&&typeof i=="number"&&(e[n.name]={value:i,unit:s})}),e}function Fe(t){return t.getOptions().traceLifecycle==="stream"}const lr=1e3;class An{constructor(e={}){this._traceId=e.traceId||ne(),this._spanId=e.spanId||ue(),this._startTime=e.startTimestamp||Ie(),this._links=e.links,this._attributes={},this.setAttributes(l({[rn]:"manual",[Ye]:e.op},e.attributes)),this._name=e.name,e.parentSpanId&&(this._parentSpanId=e.parentSpanId),"sampled"in e&&(this._sampled=e.sampled),e.endTimestamp&&(this._endTime=e.endTimestamp),this._events=[],this._isStandaloneSpan=e.isStandalone,this._endTime&&this._onSpanEnded()}addLink(e){return this._links?this._links.push(e):this._links=[e],this}addLinks(e){return this._links?this._links.push(...e):this._links=e,this}recordException(e,n){}spanContext(){const{_spanId:e,_traceId:n,_sampled:r}=this;return{spanId:e,traceId:n,traceFlags:r?Nt:as}}setAttribute(e,n){return n===void 0?delete this._attributes[e]:this._attributes[e]=n,this}setAttributes(e){return Object.keys(e).forEach(n=>this.setAttribute(n,e[n])),this}updateStartTime(e){this._startTime=te(e)}setStatus(e){return this._status=e,this}updateName(e){return this._name=e,Vi(this)||this.setAttribute(Ke,"custom"),this}end(e){this._endTime||(this._endTime=te(e),$o(this),this._onSpanEnded())}getSpanJSON(){return{data:this._attributes,description:this._name,op:this._attributes[Ye],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:us(this._status),timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[rn],profile_id:this._attributes[Tn],exclusive_time:this._attributes[vn],measurements:ur(this._events),is_segment:this._isStandaloneSpan&&$(this)===this||void 0,segment_id:this._isStandaloneSpan?$(this).spanContext().spanId:void 0,links:cs(this._links)}}getStreamedSpanJSON(){var e,n;return{name:(e=this._name)!=null?e:"",span_id:this._spanId,trace_id:this._traceId,parent_span_id:this._parentSpanId,start_timestamp:this._startTime,end_timestamp:(n=this._endTime)!=null?n:this._startTime,is_segment:this._isStandaloneSpan||this===$(this),status:ls(this._status),attributes:Eo(this._attributes,this._status),links:mo(this._links)}}isRecording(){return!this._endTime&&!!this._sampled}addEvent(e,n,r){y&&g.log("[Tracing] Adding an event to span:",e);const s=fr(n)?n:r||Ie(),i=fr(n)?{}:n||{},o={name:e,time:te(s),attributes:i};return this._events.push(o),this}isStandaloneSpan(){return!!this._isStandaloneSpan}_onSpanEnded(){const e=w();if(e&&(e.emit("spanEnd",this),this._isStandaloneSpan||e.emit("afterSpanEnd",this)),!(this._isStandaloneSpan||this===$(this)))return;if(this._isStandaloneSpan){this._sampled?jo(Fo([this],e)):(y&&g.log("[Tracing] Discarding standalone span because its trace was not chosen to be sampled."),e&&e.recordDroppedEvent("sample_rate","span"));return}else if(e&&Fe(e)){e.emit("afterSegmentSpanEnd",this);return}const r=this._convertSpanToTransaction();r&&(ke(this).scope||b()).captureEvent(r)}_convertSpanToTransaction(){var f;if(!pr(M(this)))return;this._name||(y&&g.warn("Transaction has no name, falling back to `<unlabeled transaction>`."),this._name="<unlabeled transaction>");const{scope:e,isolationScope:n}=ke(this),r=(f=e==null?void 0:e.getScopeData().sdkProcessingMetadata)==null?void 0:f.normalizedRequest;if(this._sampled!==!0)return;const i=To(this).filter(_=>_!==this&&!Bo(_)).map(_=>M(_)).filter(pr),o=this._attributes[Ke];delete this._attributes[tr];let c=!1;i.forEach(_=>{var p;delete _.data[tr],(p=_.op)!=null&&p.startsWith("gen_ai.")&&(c=!0)});const a=l({contexts:{trace:fo(this)},spans:i.length>lr?i.sort((_,p)=>_.start_timestamp-p.start_timestamp).slice(0,lr):i,start_timestamp:this._startTime,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{capturedSpanScope:e,capturedSpanIsolationScope:n,dynamicSamplingContext:Oe(this),hasGenAiSpans:c},request:r},o&&{transaction_info:{source:o}}),u=ur(this._events);return u&&Object.keys(u).length&&(y&&g.log("[Measurements] Adding measurements to transaction event",JSON.stringify(u,void 0,2)),a.measurements=u),a}}function fr(t){return t&&typeof t=="number"||t instanceof Date||Array.isArray(t)}function pr(t){return!!t.start_timestamp&&!!t.timestamp&&!!t.span_id&&!!t.trace_id}function Bo(t){return t instanceof An&&t.isStandaloneSpan()}function jo(t){const e=w();if(!e)return;const n=t[1];if(!n||n.length===0){e.recordDroppedEvent("before_send","span");return}e.sendEnvelope(t)}function Uo(t,e,n=()=>{},r=()=>{}){let s;try{s=t()}catch(i){throw e(i),n(),i}return Ho(s,e,n,r)}function Ho(t,e,n,r){return ce(t)?Xr(t,s=>{n(),r(s)},s=>{e(s),n()}):(n(),r(t),t)}function zo(t,e,n){if(!Ae(t))return[!1];let r,s;typeof t.tracesSampler=="function"?(s=t.tracesSampler(T(l({},e),{inheritOrSampleWith:c=>typeof e.parentSampleRate=="number"?e.parentSampleRate:typeof e.parentSampled=="boolean"?Number(e.parentSampled):c})),r=!0):e.parentSampled!==void 0?s=e.parentSampled:typeof t.tracesSampleRate!="undefined"&&(s=t.tracesSampleRate,r=!0);const i=In(s);if(i===void 0)return y&&g.warn(`[Tracing] Discarding root span because of invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(s)} of type ${JSON.stringify(typeof s)}.`),[!1];if(!i)return y&&g.log(`[Tracing] Discarding transaction because ${typeof t.tracesSampler=="function"?"tracesSampler returned 0 or false":"a negative sampling decision was inherited or tracesSampleRate is set to 0"}`),[!1,i,r];const o=n<i;return o||y&&g.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(s)})`),[o,i,r]}const qo="__SENTRY_SUPPRESS_TRACING__";function _e(t,e){const n=Dt();if(n.startSpan)return n.startSpan(t,e);const r=Es(t),{forceTransaction:s,parentSpan:i,scope:o}=t,c=o==null?void 0:o.clone();return fe(c,()=>Go(i)(()=>{const u=b(),d=Ts(u,i),f=w(),p=t.onlyIfParent&&!d?Ss(u,f):bs({parentSpan:d,spanArguments:r,forceTransaction:s,scope:u});return(!Ko(p)||!d)&&Ge(u,p),Uo(()=>e(p),()=>{const{status:h}=M(p);p.isRecording()&&(!h||h==="ok")&&p.setStatus({code:x,message:"internal_error"})},()=>{p.end()})}))}function xt(t){const e=Dt();if(e.startInactiveSpan)return e.startInactiveSpan(t);const n=Es(t),{forceTransaction:r,parentSpan:s}=t;return(t.scope?o=>fe(t.scope,o):s!==void 0?o=>ys(s,o):o=>o())(()=>{const o=b(),c=Ts(o,s),a=w();return t.onlyIfParent&&!c?Ss(o,a):bs({parentSpan:c,spanArguments:n,forceTransaction:r,scope:o})})}function ys(t,e){const n=Dt();return n.withActiveSpan?n.withActiveSpan(t,e):fe(r=>(Ge(r,t||void 0),e(r)))}function Rn(t=b()){const e=Dt();return e.isTracingSuppressed?e.isTracingSuppressed(t):t.getScopeData().sdkProcessingMetadata[qo]===!0}function Ss(t,e){e==null||e.recordDroppedEvent("no_parent_span","span");const n=new Xe({traceId:t.getPropagationContext().traceId});return we(n,t,R()),n}function bs({parentSpan:t,spanArguments:e,forceTransaction:n,scope:r}){var c;const s=R();if(!Ae()){const a=l(l({},s.getPropagationContext()),r.getPropagationContext()),u=t?t.spanContext().traceId:a.traceId,d=new Xe({traceId:u});return t&&!n&&an(t,d),we(d,r,s),d}const i=w();if(Jo(i,e)){Rn(r)||i==null||i.recordDroppedEvent("ignored","span");const a=new Xe({dropReason:"ignored",traceId:(c=t==null?void 0:t.spanContext().traceId)!=null?c:r.getPropagationContext().traceId});return we(a,r,s),a}let o;if(t&&!n)o=Wo(t,r,e,s),an(t,o);else if(t){const a=Oe(t),{traceId:u,spanId:d}=t.spanContext(),f=Y(t);o=dr(l({traceId:u,parentSpanId:d},e),r,s,f),or(o,a)}else{const{traceId:a,dsc:u,parentSpanId:d,sampled:f}=l(l({},s.getPropagationContext()),r.getPropagationContext());o=dr(l({traceId:a,parentSpanId:d},e),r,s,f),u&&or(o,u)}return Lo(o),o}function Es(t){const e=t.experimental||{},n=l({isStandalone:e.standalone},t);if(t.startTime){const r=l({},n);return r.startTimestamp=te(t.startTime),delete r.startTime,r}return n}function Dt(){const t=K();return le(t)}function dr(t,e,n,r){var S,E;const s=w(),i=(s==null?void 0:s.getOptions())||{},{name:o=""}=t,c={spanAttributes:l({},t.attributes),spanName:o,parentSampled:r};s==null||s.emit("beforeSampling",c,{decision:!1});const a=(S=c.parentSampled)!=null?S:r,u=c.spanAttributes,d=e.getPropagationContext(),f=Rn(e),[_,p,h]=f?[!1]:zo(i,{name:o,parentSampled:a,attributes:u,normalizedRequest:n.getScopeData().sdkProcessingMetadata.normalizedRequest,parentSampleRate:In((E=d.dsc)==null?void 0:E.sample_rate)},d.sampleRand),m=new An(T(l({},t),{attributes:l({[Ke]:"custom",[Zr]:p!==void 0&&h?p:void 0},u),sampled:_}));return!_&&s&&!f&&(y&&g.log("[Tracing] Discarding root span because its trace was not chosen to be sampled."),s.recordDroppedEvent("sample_rate",Fe(s)?"span":"transaction")),we(m,e,n),s&&s.emit("spanStart",m),m}function Wo(t,e,n,r){const{spanId:s,traceId:i}=t.spanContext(),o=Rn(e),c=o?!1:Y(t),a=c?new An(T(l({},n),{parentSpanId:s,traceId:i,sampled:c})):new Xe({traceId:i});an(t,a),we(a,e,r);const u=w();return u&&(Fe(u)&&Re(a)&&(Re(t)&&t.dropReason?(a.dropReason=t.dropReason,u.recordDroppedEvent(t.dropReason,"span")):o||(a.dropReason="sample_rate",u.recordDroppedEvent("sample_rate","span"))),u.emit("spanStart",a),n.endTimestamp&&(u.emit("spanEnd",a),u.emit("afterSpanEnd",a))),a}function Ts(t,e){if(e)return e;if(e===null)return;const n=Je(t);if(!n)return;const r=w();return(r?r.getOptions():{}).parentSpanIsAlwaysRootSpan?$(n):n}function Go(t){return t!==void 0?e=>ys(t,e):e=>e()}function Jo(t,e){var r;const n=t==null?void 0:t.getOptions().ignoreSpans;return!t||!Fe(t)||!(n!=null&&n.length)?!1:Ve({description:e.name||"",op:((r=e.attributes)==null?void 0:r[Ye])||e.op,attributes:e.attributes},n)}function Ko(t){return Re(t)&&t.dropReason==="ignored"}function Yo(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;Vo(t,e),r&&Qo(t,r),ea(t,n),Xo(t,s),Zo(t,i)}function hr(t,e){const{extra:n,tags:r,attributes:s,user:i,contexts:o,level:c,sdkProcessingMetadata:a,breadcrumbs:u,fingerprint:d,eventProcessors:f,attachments:_,propagationContext:p,transactionName:h,span:m}=e;he(t,"extra",n),he(t,"tags",r),he(t,"attributes",s),he(t,"user",i),he(t,"contexts",o),t.sdkProcessingMetadata=Me(t.sdkProcessingMetadata,a,2),c&&(t.level=c),h&&(t.transactionName=h),m&&(t.span=m),u.length&&(t.breadcrumbs=[...t.breadcrumbs,...u]),d.length&&(t.fingerprint=[...t.fingerprint,...d]),f.length&&(t.eventProcessors=[...t.eventProcessors,...f]),_.length&&(t.attachments=[...t.attachments,..._]),t.propagationContext=l(l({},t.propagationContext),p)}function he(t,e,n){t[e]=Me(t[e],n,1)}function vs(t,e){const n=zi().getScopeData();return t&&hr(n,t.getScopeData()),e&&hr(n,e.getScopeData()),n}function Vo(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:c}=e;Object.keys(n).length&&(t.extra=l(l({},n),t.extra)),Object.keys(r).length&&(t.tags=l(l({},r),t.tags)),Object.keys(s).length&&(t.user=l(l({},s),t.user)),Object.keys(i).length&&(t.contexts=l(l({},i),t.contexts)),o&&(t.level=o),c&&t.type!=="transaction"&&(t.transaction=c)}function Xo(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Zo(t,e){t.sdkProcessingMetadata=l(l({},t.sdkProcessingMetadata),e)}function Qo(t,e){t.contexts=l({trace:po(e)},t.contexts),t.sdkProcessingMetadata=l({dynamicSamplingContext:Oe(e)},t.sdkProcessingMetadata);const n=$(e),r=M(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function ea(t,e){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint.length||delete t.fingerprint}const jt=0,_r=1,mr=2;function Cn(t){return new Ce(e=>{e(t)})}function Pn(t){return new Ce((e,n)=>{n(t)})}class Ce{constructor(e){this._state=jt,this._handlers=[],this._runExecutor(e)}then(e,n){return new Ce((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(o){s(o)}},i=>{if(!n)s(i);else try{r(n(i))}catch(o){s(o)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new Ce((n,r)=>{let s,i;return this.then(o=>{i=!1,s=o,e&&e()},o=>{i=!0,s=o,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}_executeHandlers(){if(this._state===jt)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===_r&&n[1](this._value),this._state===mr&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,o)=>{if(this._state===jt){if(ce(o)){o.then(r,s);return}this._state=i,this._value=o,this._executeHandlers()}},r=i=>{n(_r,i)},s=i=>{n(mr,i)};try{e(r,s)}catch(i){s(i)}}}function ta(t,e,n,r=0){try{const s=pn(e,n,t,r);return ce(s)?s:Cn(s)}catch(s){return Pn(s)}}function pn(t,e,n,r){const s=n[r];if(!t||!s)return t;const i=s(l({},t),e);return y&&i===null&&g.log(`Event processor "${s.id||"?"}" dropped event`),ce(i)?i.then(o=>pn(o,e,n,r+1)):pn(i,e,n,r+1)}let U,gr,yr,H;function na(t){const e=D._sentryDebugIds,n=D._debugIds;if(!e&&!n)return{};const r=e?Object.keys(e):[],s=n?Object.keys(n):[];if(H&&r.length===gr&&s.length===yr)return H;gr=r.length,yr=s.length,H={},U||(U={});const i=(o,c)=>{for(const a of o){const u=c[a],d=U==null?void 0:U[a];if(d&&H&&u)H[d[0]]=u,U&&(U[a]=[d[0],u]);else if(u){const f=t(a);for(let _=f.length-1;_>=0;_--){const p=f[_],h=p==null?void 0:p.filename;if(h&&H&&U){H[h]=u,U[a]=[h,u];break}}}}};return e&&i(r,e),n&&i(s,n),H}function ra(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:c=1e3}=t,a=T(l({},e),{event_id:e.event_id||n.event_id||L(),timestamp:e.timestamp||De()}),u=n.integrations||t.integrations.map(E=>E.name);sa(a,t),aa(a,u),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&ia(a,t.stackParser);const d=ua(r,n.captureContext);n.mechanism&&Ri(a,n.mechanism);const f=s?s.getEventProcessors():[],_=vs(i,d),p=[...n.attachments||[],..._.attachments];p.length&&(n.attachments=p),Yo(a,_);const h=[...f,..._.eventProcessors];return(n.data&&n.data.__sentry__===!0?Cn(a):ta(h,a,n)).then(E=>(E&&oa(E),typeof o=="number"&&o>0?ca(E,o,c):E))}function sa(t,e){var c,a;const{environment:n,release:r,dist:s,maxValueLength:i}=e;t.environment=t.environment||n||wn,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const o=t.request;o!=null&&o.url&&i&&(o.url=tn(o.url,i)),i&&((a=(c=t.exception)==null?void 0:c.values)==null||a.forEach(u=>{u.value&&(u.value=tn(u.value,i))}))}function ia(t,e){var r,s;const n=na(e);(s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,c;(c=(o=i.stacktrace)==null?void 0:o.frames)==null||c.forEach(a=>{a.filename&&(a.debug_id=n[a.filename])})})}function oa(t){var r,s;const e={};if((s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,c;(c=(o=i.stacktrace)==null?void 0:o.frames)==null||c.forEach(a=>{a.debug_id&&(a.abs_path?e[a.abs_path]=a.debug_id:a.filename&&(e[a.filename]=a.debug_id),delete a.debug_id)})}),Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.entries(e).forEach(([i,o])=>{n.push({type:"sourcemap",code_file:i,debug_id:o})})}function aa(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function ca(t,e,n){var s,i;if(!t)return null;const r=l(l(l(l(l({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(o=>l(l({},o),o.data&&{data:z(o.data,e,n)}))}),t.user&&{user:z(t.user,e,n)}),t.contexts&&{contexts:z(t.contexts,e,n)}),t.extra&&{extra:z(t.extra,e,n)});return(s=t.contexts)!=null&&s.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=z(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(o=>l(l({},o),o.data&&{data:z(o.data,e,n)}))),(i=t.contexts)!=null&&i.flags&&r.contexts&&(r.contexts.flags=z(t.contexts.flags,3,n)),r}function ua(t,e){if(!e)return t;const n=t?t.clone():new B;return n.update(e),n}function la(t){if(t)return fa(t)?{captureContext:t}:da(t)?{captureContext:t}:t}function fa(t){return t instanceof B||typeof t=="function"}const pa=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function da(t){return Object.keys(t).some(e=>pa.includes(e))}function ee(t,e){return b().captureException(t,la(e))}function ha(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return b().captureMessage(t,n,r)}function _a(t,e){return b().captureEvent(t,e)}function W(t,e){R().setContext(t,e)}function ma(t){R().setExtras(t)}function ga(t,e){R().setExtra(t,e)}function ya(t){R().setTags(t)}function Sa(t,e){R().setTag(t,e)}function ba(t){R().setUser(t)}function Ea(){return R().lastEventId()}function Is(t){return O(this,null,function*(){const e=w();return e?e.flush(t):(y&&g.warn("Cannot flush events. No client defined."),Promise.resolve(!1))})}function Ta(t){return O(this,null,function*(){const e=w();return e?e.close(t):(y&&g.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))})}function ws(){const t=w();return(t==null?void 0:t.getOptions().enabled)!==!1&&!!(t!=null&&t.getTransport())}function va(t){R().addEventProcessor(t)}function ks(t){const e=R(),{user:n}=vs(e,b()),{userAgent:r}=D.navigator||{},s=Gr(l(l({user:n},r&&{userAgent:r}),t)),i=e.getSession();return(i==null?void 0:i.status)==="ok"&&J(i,{status:"exited"}),Mt(),e.setSession(s),s}function Mt(){const t=R(),n=b().getSession()||t.getSession();n&&Jr(n),As(),t.setSession()}function As(){const t=R(),e=w(),n=t.getSession();n&&e&&e.captureSession(n)}function dn(t=!1){if(t){Mt();return}As()}function Nn(t){return typeof t=="object"&&typeof t.unref=="function"&&t.unref(),t}const Ia="7";function wa(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function ka(t){return`${wa(t)}${t.projectId}/envelope/`}function Aa(t,e){const n={sentry_version:Ia};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function Ra(t,e,n){return e||`${ka(t)}?${Aa(t,n)}`}const be=[];function Ca(t,e){const n={};return e.forEach(r=>{r!=null&&r.beforeSetup&&r.beforeSetup(t)}),e.forEach(r=>{r&&Rs(t,r,n)}),n}function Sr(t,e){for(const n of e)n!=null&&n.afterAllSetup&&n.afterAllSetup(t)}function Rs(t,e,n){if(n[e.name]){y&&g.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,!be.includes(e.name)&&typeof e.setupOnce=="function"&&(e.setupOnce(),be.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){const r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,i)=>r(s,i,t))}if(typeof e.processEvent=="function"){const r=e.processEvent.bind(e),s=Object.assign((i,o)=>r(i,o,t),{id:e.name});t.addEventProcessor(s)}["processSpan","processSegmentSpan"].forEach(r=>{const s=e[r];typeof s=="function"&&t.on(r,i=>s.call(e,i,t))}),y&&g.log(`Integration installed: ${e.name}`)}function Pa(t){const e=w();if(!e){y&&g.warn(`Cannot add integration "${t.name}" because no SDK Client is available.`);return}e.addIntegration(t)}function Na(){return typeof __SENTRY_BROWSER_BUNDLE__!="undefined"&&!!__SENTRY_BROWSER_BUNDLE__}function xa(){return!Na()&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]"}function xn(){return typeof window!="undefined"&&(!xa()||Da())}function Da(){const t=D.process;return(t==null?void 0:t.type)==="renderer"}function Ma(t,e){const n=e?"auto":"never";return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},T(l({version:2},xn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function Oa(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=pe(r)),V(i,[Ma(t,s)])}function br(t,e){var i;const n=(i=e!=null?e:Fa(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=Oa(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Cs().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function Fa(t){return Cs().get(t)}function Cs(){return ae("clientToLogBufferMap",()=>new WeakMap)}function La(t,e){const n=e?"auto":"never";return[{type:"trace_metric",item_count:t.length,content_type:"application/vnd.sentry.items.trace-metric+json"},T(l({version:2},xn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function $a(t,e,n,r,s){const i={};return e!=null&&e.sdk&&(i.sdk={name:e.sdk.name,version:e.sdk.version}),n&&r&&(i.dsn=pe(r)),V(i,[La(t,s)])}function Ba(t,e){var i;const n=(i=e!=null?e:ja(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=$a(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Ps().set(t,[]),t.emit("flushMetrics"),t.sendEnvelope(s)}function ja(t){return Ps().get(t)}function Ps(){return ae("clientToMetricBufferMap",()=>new WeakMap)}function Ua(t){const e={trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,name:t.description||"",start_timestamp:t.start_timestamp,end_timestamp:t.timestamp||t.start_timestamp,status:!t.status||t.status==="ok"||t.status==="cancelled"?"ok":"error",is_segment:!1,attributes:l({},t.data),links:t.links};return yo(e)}function Ha(t,e){var i,o,c;if(t.type!=="transaction"||!((i=t.spans)!=null&&i.length)||!((o=t.sdkProcessingMetadata)!=null&&o.hasGenAiSpans)||e.getOptions().streamGenAiSpans===!1||Fe(e))return;const n=[],r=[];for(const a of t.spans)(c=a.op)!=null&&c.startsWith("gen_ai.")?n.push(Ua(a)):r.push(a);if(n.length===0)return;t.spans=r;const s=e.getDataCollectionOptions().userInfo?"auto":"never";return[{type:"span",item_count:n.length,content_type:"application/vnd.sentry.items.span.v2+json"},T(l({version:2},xn()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}}),{items:n})]}const Dn=Symbol.for("SentryBufferFullError");function Ns(t=100){const e=new Set;function n(){return e.size<t}function r(o){e.delete(o)}function s(o){if(!n())return Pn(Dn);const c=o();return e.add(c),c.then(()=>r(c),()=>r(c)),c}function i(o){if(!e.size)return Cn(!0);const c=Promise.allSettled(Array.from(e)).then(()=>!0);if(!o)return c;const a=[c,new Promise(u=>Nn(setTimeout(()=>u(!1),o)))];return Promise.race(a)}return{get $(){return Array.from(e)},add:s,drain:i}}const za=60*1e3;function xs(t,e=G()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?za:r-e}function qa(t,e){return t[e]||t.all||0}function Wa(t,e,n=G()){return qa(t,e)>n}function Ga(t,{statusCode:e,headers:n},r=G()){const s=l({},t),i=n==null?void 0:n["x-sentry-rate-limits"],o=n==null?void 0:n["retry-after"];if(i)for(const c of i.trim().split(",")){const[a,u,,,d]=c.split(":",5),f=parseInt(a,10),_=(isNaN(f)?60:f)*1e3;if(!u)s.all=r+_;else for(const p of u.split(";"))p==="metric_bucket"?(!d||d.split(";").includes("custom"))&&(s[p]=r+_):s[p]=r+_}else o?s.all=r+xs(o,r):e===429&&(s.all=r+60*1e3);return s}const Ds=64;function Ja(t,e,n=Ns(t.bufferSize||Ds)){let r={};const s=o=>n.drain(o);function i(o){const c=[];if(un(o,(f,_)=>{const p=cr(_);Wa(r,p)?t.recordDroppedEvent("ratelimit_backoff",p):c.push(f)}),c.length===0)return Promise.resolve({});const a=V(o[0],c),u=f=>{if(ln(a,["client_report"])){y&&g.warn(`Dropping client report. Will not send outcomes (reason: ${f}).`);return}un(a,(_,p)=>{t.recordDroppedEvent(f,cr(p))})},d=()=>e({body:Ao(a)}).then(f=>f.statusCode===413?(y&&g.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),u("send_error"),f):(y&&f.statusCode!==void 0&&(f.statusCode<200||f.statusCode>=300)&&g.warn(`Sentry responded with status code ${f.statusCode} to sent event.`),r=Ga(r,f),f),f=>{throw u("network_error"),y&&g.error("Encountered error running transport request:",f),f});return n.add(d).then(f=>f,f=>{if(f===Dn)return y&&g.error("Skipped sending event because buffer is full."),u("queue_overflow"),Promise.resolve({});throw f})}return{send:i,flush:s}}function Ka(t,e,n){const r=[{type:"client_report"},{timestamp:De(),discarded_events:t}];return V(e?{dsn:e}:{},[r])}function Ms(t){const e=[];t.message&&e.push(t.message);try{const n=t.exception.values[t.exception.values.length-1];n!=null&&n.value&&(e.push(n.value),n.type&&e.push(`${n.type}: ${n.value}`))}catch(n){}return e}function Ya(t){var a,u,d;const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:o,op:c}=(u=(a=t.contexts)==null?void 0:a.trace)!=null?u:{};return{data:o!=null?o:{},description:t.transaction,op:c,parent_span_id:n,span_id:r!=null?r:"",start_timestamp:(d=t.start_timestamp)!=null?d:0,status:s,timestamp:t.timestamp,trace_id:e!=null?e:"",origin:i,profile_id:o==null?void 0:o[Tn],exclusive_time:o==null?void 0:o[vn],measurements:t.measurements,is_segment:!0}}function Va(t){return{type:"transaction",timestamp:t.timestamp,start_timestamp:t.start_timestamp,transaction:t.description,contexts:{trace:{trace_id:t.trace_id,span_id:t.span_id,parent_span_id:t.parent_span_id,op:t.op,status:t.status,origin:t.origin,data:l(l(l({},t.data),t.profile_id&&{[Tn]:t.profile_id}),t.exclusive_time&&{[vn]:t.exclusive_time})}},measurements:t.measurements}}const Ue=["forwarded","-ip","remote-","via","-user"];function Xa(t){return t===!0?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:7}:{userInfo:!1,cookies:{deny:Ue},httpHeaders:{request:{deny:Ue},response:{deny:Ue}},httpBodies:[],queryParams:{deny:Ue},genAI:{inputs:!1,outputs:!1},stackFrameVariables:!0,frameContextLines:7}}const Za={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:["incomingRequest","outgoingRequest","incomingResponse","outgoingResponse"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:5};function Qa(t){var r,s,i,o,c,a,u,d,f,_,p,h,m,S,E;const e=t.dataCollection!=null?Za:Xa(t.sendDefaultPii),n=(r=t.dataCollection)!=null?r:{};return{userInfo:(s=n.userInfo)!=null?s:e.userInfo,cookies:(i=n.cookies)!=null?i:e.cookies,httpHeaders:{request:(c=(o=n.httpHeaders)==null?void 0:o.request)!=null?c:e.httpHeaders.request,response:(u=(a=n.httpHeaders)==null?void 0:a.response)!=null?u:e.httpHeaders.response},httpBodies:(d=n.httpBodies)!=null?d:e.httpBodies,queryParams:(f=n.queryParams)!=null?f:e.queryParams,genAI:{inputs:(p=(_=n.genAI)==null?void 0:_.inputs)!=null?p:e.genAI.inputs,outputs:(m=(h=n.genAI)==null?void 0:h.outputs)!=null?m:e.genAI.outputs},stackFrameVariables:(S=n.stackFrameVariables)!=null?S:e.stackFrameVariables,frameContextLines:(E=n.frameContextLines)!=null?E:e.frameContextLines}}const Er="Not capturing exception because it's already been captured.",Tr="Discarded session because of missing or non-string release",Os=Symbol.for("SentryInternalError"),Fs=Symbol.for("SentryDoNotSendEventError"),ec=5e3;function He(t){return{message:t,[Os]:!0}}function Ut(t){return{message:t,[Fs]:!0}}function vr(t){return!!t&&typeof t=="object"&&Os in t}function Ir(t){return!!t&&typeof t=="object"&&Fs in t}function wr(t,e,n,r,s){let i=0,o,c=!1;t.on(n,()=>{i=0,clearTimeout(o),c=!1}),t.on(e,a=>{var u;if(i+=r(a),i>=8e5)s(t);else if(!c){const d=(u=t.getOptions()._flushInterval)!=null?u:ec;d>0&&(c=!0,o=Nn(setTimeout(()=>{s(t)},d)))}}),t.on("flush",()=>{s(t)})}class tc{constructor(e){var r,s,i,o,c,a,u;if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Ns((s=(r=e.transportOptions)==null?void 0:r.bufferSize)!=null?s:Ds),this._dataCollection=Qa(e),e.dsn?this._dsn=uo(e.dsn):y&&g.warn("No DSN provided, client will not send events."),this._dsn){const d=Ra(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport(T(l({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this)},e.transportOptions),{url:d}))}this._options.enableLogs=(o=this._options.enableLogs)!=null?o:(i=this._options._experiments)==null?void 0:i.enableLogs,this._options.enableLogs&&wr(this,"afterCaptureLog","flushLogs",ic,br),((u=(a=this._options.enableMetrics)!=null?a:(c=this._options._experiments)==null?void 0:c.enableMetrics)!=null?u:!0)&&wr(this,"afterCaptureMetric","flushMetrics",sc,Ba)}captureException(e,n,r){const s=L();if(Xn(e))return y&&g.log(Er),s;const i=l({event_id:s},n);return this._process(()=>this.eventFromException(e,i).then(o=>this._captureEvent(o,i,r)).then(o=>o),"error"),i.event_id}captureMessage(e,n,r,s){const i=l({event_id:L()},r),o=Ur(e)?e:String(e),c=Hr(e),a=c?this.eventFromMessage(o,n,i):this.eventFromException(e,i);return this._process(()=>a.then(u=>this._captureEvent(u,i,s)),c?"unknown":"error"),i.event_id}captureEvent(e,n,r){const s=L();if(n!=null&&n.originalException&&Xn(n.originalException))return y&&g.log(Er),s;const i=l({event_id:s},n),o=e.sdkProcessingMetadata||{},c=o.capturedSpanScope,a=o.capturedSpanIsolationScope,u=kr(e.type);return this._process(()=>this._captureEvent(e,i,c||r,a),u),i.event_id}captureSession(e){this.sendSession(e),J(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){return O(this,null,function*(){const n=this._transport;if(this.emit("flush"),!n)return!0;const r=yield this._isClientDoneProcessing(e),s=yield n.flush(e);return r&&s})}close(e){return O(this,null,function*(){br(this);const n=yield this.flush(e);return this.getOptions().enabled=!1,this.emit("close"),n})}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith("Spotlight")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const n=this._integrations[e.name];!n&&e.beforeSetup&&e.beforeSetup(this),Rs(this,e,this._integrations),n||Sr(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);const r=Ha(e,this);let s=Oo(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])s=ar(s,Po(i));r&&(s=ar(s,r)),this.sendEnvelope(s).then(i=>this.emit("afterSendEvent",e,i))}sendSession(e){const{release:n,environment:r=wn}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){y&&g.warn(Tr);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){y&&g.warn(Tr);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=Mo(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(s)}recordDroppedEvent(e,n,r=1){if(this._options.sendClientReports){const s=`${e}:${n}`;y&&g.log(`Recording outcome: "${s}"${r>1?` (${r} times)`:""}`),this._outcomes[s]=(this._outcomes[s]||0)+r}}on(e,n){const r=this._hooks[e]=this._hooks[e]||new Set,s=(...i)=>n(...i);return r.add(s),()=>{r.delete(s)}}emit(e,...n){const r=this._hooks[e];r&&r.forEach(s=>s(...n))}sendEnvelope(e){return O(this,null,function*(){if(this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport)try{return yield this._transport.send(e)}catch(n){return y&&g.error("Error while sending envelope:",n),{}}return y&&g.error("Transport disabled"),{}})}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=Ca(this,e),Sr(this,e)}_updateSessionFromEvent(e,n){var a,u;let r=n.level==="fatal",s=!1;const i=(a=n.exception)==null?void 0:a.values;if(i){s=!0,r=!1;for(const d of i)if(((u=d.mechanism)==null?void 0:u.handled)===!1){r=!0;break}}const o=e.status==="ok";(o&&e.errors===0||o&&r)&&(J(e,T(l({},r&&{status:"crashed"}),{errors:e.errors||Number(s||r)})),this.captureSession(e))}_isClientDoneProcessing(e){return O(this,null,function*(){let n=0;for(;!e||n<e;){if(yield new Promise(r=>setTimeout(r,1)),!this._numProcessing)return!0;n++}return!1})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s){const i=this.getOptions(),o=this.getIntegrationNames();return!n.integrations&&o.length&&(n.integrations=o),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),ra(i,e,n,r,this,s).then(c=>{var u;if(c===null)return c;this.emit("postprocessEvent",c,n),c.contexts=l({trace:l(l({},(u=c.contexts)==null?void 0:u.trace),qi(r))},c.contexts);const a=kn(this,r);return c.sdkProcessingMetadata=l({dynamicSamplingContext:a},c.sdkProcessingMetadata),c})}_captureEvent(e,n={},r=b(),s=R()){return y&&hn(e)&&g.log(`Captured error event \`${Ms(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{y&&(Ir(i)?g.log(i.message):vr(i)?g.warn(i.message):g.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:o}=i,c=Ls(e),a=hn(e),d=`before send for type \`${e.type||"error"}\``,f=typeof o=="undefined"?void 0:In(o);if(a&&typeof f=="number"&&We()>f)return this.recordDroppedEvent("sample_rate","error"),Pn(Ut(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const _=kr(e.type);return this._prepareEvent(e,n,r,s).then(p=>{var S;if(p===null)throw this.recordDroppedEvent("event_processor",_),Ut("An event processor returned `null`, will not send event.");if(((S=n.data)==null?void 0:S.__sentry__)===!0)return p;const m=rc(this,i,p,n);return nc(m,d)}).then(p=>{var S;if(p===null){if(this.recordDroppedEvent("before_send",_),c){const C=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",C)}throw Ut(`${d} returned \`null\`, will not send event.`)}const h=r.getSession()||s.getSession();if(a&&h&&this._updateSessionFromEvent(h,p),c){const E=((S=p.sdkProcessingMetadata)==null?void 0:S.spanCountBeforeProcessing)||0,C=p.spans?p.spans.length:0,A=E-C;A>0&&this.recordDroppedEvent("before_send","span",A)}const m=p.transaction_info;if(c&&m&&p.transaction!==e.transaction){const E="custom";p.transaction_info=T(l({},m),{source:E})}return this.sendEvent(p,n),p}).then(null,p=>{throw Ir(p)||vr(p)?p:(this.captureException(p,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:p}),He(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
7
+ Reason: ${p}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===Dn&&this.recordDroppedEvent("queue_overflow",n),r))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([n,r])=>{const[s,i]=n.split(":");return{reason:s,category:i,quantity:r}})}_flushOutcomes(){y&&g.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){y&&g.log("No outcomes to send");return}if(!this._dsn){y&&g.log("No dsn provided, will not send outcomes");return}y&&g.log("Sending outcomes:",e);const n=Ka(e,this._options.tunnel&&pe(this._dsn));this.sendEnvelope(n)}}function kr(t){return t==="replay_event"?"replay":t||"error"}function nc(t,e){const n=`${e} must return \`null\` or a valid event.`;if(ce(t))return t.then(r=>{if(!Qt(r)&&r!==null)throw He(n);return r},r=>{throw He(`${e} rejected with ${r}`)});if(!Qt(t)&&t!==null)throw He(n);return t}function rc(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,c=!_s(e.beforeSendSpan)&&e.beforeSendSpan;let a=n;if(hn(a)&&s)return s(a,r);if(Ls(a)){if(c||o){const u=Ya(a);if(o!=null&&o.length&&Ve({description:u.description,op:u.op,attributes:u.data},o))return null;if(c){const d=c(u);d?a=Me(n,Va(d)):cn()}if(a.spans){const d=[],f=a.spans;for(const p of f){if(o!=null&&o.length&&Ve({description:p.description,op:p.op,attributes:p.data},o)){wo(f,p);continue}if(c){const h=c(p);h?d.push(h):(cn(),d.push(p))}else d.push(p)}const _=a.spans.length-d.length;_&&t.recordDroppedEvent("before_send","span",_),a.spans=d}}if(i){if(a.spans){const u=a.spans.length;a.sdkProcessingMetadata=T(l({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(a,r)}}return a}function hn(t){return t.type===void 0}function Ls(t){return t.type==="transaction"}function sc(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+$s(t.attributes)}function ic(t){let e=0;return t.message&&(e+=t.message.length*2),e+$s(t.attributes)}function $s(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*Ar(n[0]):Hr(n)?e+=Ar(n):e+=100}),e}function Ar(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function oc(t,e){e.debug===!0&&(y?g.enable():xe(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),b().update(e.initialScope);const r=new t(e);return ac(r),r.init(),r}function ac(t){b().setClient(t)}const Ht=100,zt=5e3,cc=36e5;function Rr(t){function e(...n){y&&g.log("[Offline]:",...n)}return n=>{const r=t(n);if(!n.createStore)throw new Error("No `createStore` function was provided");const s=n.createStore(n);let i=zt,o;function c(f,_,p){return ln(f,["client_report"])?!1:n.shouldStore?n.shouldStore(f,_,p):!0}function a(f){o&&clearTimeout(o),o=Nn(setTimeout(()=>O(null,null,function*(){o=void 0;const _=yield s.shift();_&&(e("Attempting to send previously queued event"),_[0].sent_at=new Date(G()).toISOString(),d(_,!0).catch(p=>{e("Failed to retry sending",p)}))}),f))}function u(){o||(a(i),i=Math.min(i*2,cc))}function d(f,_=!1){return O(this,null,function*(){var p,h;if(!_&&ln(f,["replay_event","replay_recording"]))return yield s.push(f),a(Ht),{};try{if(n.shouldSend&&(yield n.shouldSend(f))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const m=yield r.send(f);let S=Ht;if(m){if((p=m.headers)!=null&&p["retry-after"])S=xs(m.headers["retry-after"]);else if((h=m.headers)!=null&&h["x-sentry-rate-limits"])S=6e4;else if((m.statusCode||0)>=400)return m}return a(S),i=zt,m}catch(m){if(yield c(f,m,i))return _?yield s.unshift(f):yield s.push(f),u(),e("Error sending. Event queued.",m),{};throw m}})}return n.flushAtStartup&&u(),{send:d,flush:f=>(f===void 0&&(i=zt,a(Ht)),r.flush(f))}}}function uc(t={}){const e=t.client||w();if(!ws()||!e)return{};const n=K(),r=le(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||b(),i=t.span||fs(),o=Re(i)&&!Ae(e.getOptions()),c=i&&!o?ho(i):lc(s),a=i?Oe(i):kn(e,s),u=Qi(a);if(!lo.test(c))return g.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const f={"sentry-trace":c,baggage:u};return t.propagateTraceparent&&(f.traceparent=i&&!o?_o(i):fc(s)),f}function lc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return is(e,r,n)}function fc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return os(e,r,n)}const pc=100;function k(t,e){const n=w(),r=R();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=pc}=n.getOptions();if(i<=0)return;const o=De(),c=l({timestamp:o},t),a=s?xe(()=>s(c,e)):c;a!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",a,e),r.addBreadcrumb(a,i))}const dc=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications.$/,/^Cannot redefine property: googletag$/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/can't redefine non-configurable property "solana"/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/,/^Java exception was raised during method invocation$/],hc="EventFilters",_c=(t={})=>{let e;return{name:hc,setup(n){const r=n.getOptions();e=Cr(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=Cr(t,i)}return mc(n,e)?null:n}}};function Cr(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:dc],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function mc(t,e){if(t.type){if(t.type==="transaction"&&yc(t,e.ignoreTransactions))return y&&g.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
8
+ Event: ${Z(t)}`),!0}else{if(gc(t,e.ignoreErrors))return y&&g.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
9
+ Event: ${Z(t)}`),!0;if(Tc(t))return y&&g.warn(`Event dropped due to not having an error message, error type or stacktrace.
10
+ Event: ${Z(t)}`),!0;if(Sc(t,e.denyUrls))return y&&g.warn(`Event dropped due to being matched by \`denyUrls\` option.
11
11
  Event: ${Z(t)}.
12
- Url: ${Ze(t)}`),!0;if(!yc(t,e.allowUrls))return y&&g.warn(`Event dropped due to not being matched by \`allowUrls\` option.
12
+ Url: ${Ze(t)}`),!0;if(!bc(t,e.allowUrls))return y&&g.warn(`Event dropped due to not being matched by \`allowUrls\` option.
13
13
  Event: ${Z(t)}.
14
- Url: ${Ze(t)}`),!0}return!1}function _c(t,e){return e!=null&&e.length?Ds(t).some(n=>Ct(n,e)):!1}function mc(t,e){if(!(e!=null&&e.length))return!1;const n=t.transaction;return n?Ct(n,e):!1}function gc(t,e){if(!(e!=null&&e.length))return!1;const n=Ze(t);return n?Ct(n,e):!1}function yc(t,e){if(!(e!=null&&e.length))return!0;const n=Ze(t);return n?Ct(n,e):!0}function Sc(t=[]){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n&&n.filename!=="<anonymous>"&&n.filename!=="[native code]")return n.filename||null}return null}function Ze(t){var e,n,r;try{const s=[...(n=(e=t.exception)==null?void 0:e.values)!=null?n:[]].reverse().find(o=>{var c,a,u;return((c=o.mechanism)==null?void 0:c.parent_id)===void 0&&((u=(a=o.stacktrace)==null?void 0:a.frames)==null?void 0:u.length)}),i=(r=s==null?void 0:s.stacktrace)==null?void 0:r.frames;return i?Sc(i):null}catch(s){return y&&g.error(`Cannot extract url for event ${Z(t)}`),null}}function bc(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)!=null&&n.length?!t.message&&!t.exception.values.some(r=>r.stacktrace||r.type&&r.type!=="Error"||r.value):!1}function Ec(t,e){return t(e.stack||"",1)}function vc(t){return jr(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function Tc(t){return vc(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function Ic(t,e){const n={type:e.name||e.constructor.name,value:Tc(e)},r=Ec(t,e);return r.length&&(n.stacktrace={frames:r}),n}const ze="1.13.0",$s="sentry.javascript.miniapp",wc=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,kc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,Ac=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function se(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function Rc(t){const e=wc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||At,in_app:Mn(r)},c=se(s),a=se(i);return c&&(o.lineno=c),a&&(o.colno=a),o}function Cc(t){const e=kc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||At,in_app:Mn(r)},c=se(s),a=se(i);return c&&(o.lineno=c),a&&(o.colno=a),o}function Pc(t){const e=Ac.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:At,in_app:Mn(n)},o=se(r),c=se(s);return o&&(i.lineno=o),c&&(i.colno=c),i}function Mn(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const Bs=fi([90,Rc],[80,Cc],[70,Pc]);let Ee={required:!1},On=!1;function xc(t){Ee=l({},t),On=!t.required}function Nc(t){On=t}function js(){return!Ee.required||On}function Dc(t,e){if(e>0&&Ee.required&&typeof Ee.onDrop=="function")try{Ee.onDrop({reason:t,dropped:e})}catch(n){}}const Mc=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,Oc=[{global:"wx",name:"wechat"},{global:"my",name:"alipay"},{global:"tt",name:"bytedance"},{global:"dd",name:"dingtalk"},{global:"qq",name:"qq"},{global:"swan",name:"swan"},{global:"ks",name:"kuaishou"}],Hs=()=>{const t=globalThis;for(const e of Oc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},Fn=()=>{const t=Hs();if(!t)return Mc()?console.warn(`[sentry-miniapp] 检测到当前运行在浏览器/H5 环境(如 uni-app H5、Taro H5)。
14
+ Url: ${Ze(t)}`),!0}return!1}function gc(t,e){return e!=null&&e.length?Ms(t).some(n=>Ct(n,e)):!1}function yc(t,e){if(!(e!=null&&e.length))return!1;const n=t.transaction;return n?Ct(n,e):!1}function Sc(t,e){if(!(e!=null&&e.length))return!1;const n=Ze(t);return n?Ct(n,e):!1}function bc(t,e){if(!(e!=null&&e.length))return!0;const n=Ze(t);return n?Ct(n,e):!0}function Ec(t=[]){for(let e=t.length-1;e>=0;e--){const n=t[e];if(n&&n.filename!=="<anonymous>"&&n.filename!=="[native code]")return n.filename||null}return null}function Ze(t){var e,n,r;try{const s=[...(n=(e=t.exception)==null?void 0:e.values)!=null?n:[]].reverse().find(o=>{var c,a,u;return((c=o.mechanism)==null?void 0:c.parent_id)===void 0&&((u=(a=o.stacktrace)==null?void 0:a.frames)==null?void 0:u.length)}),i=(r=s==null?void 0:s.stacktrace)==null?void 0:r.frames;return i?Ec(i):null}catch(s){return y&&g.error(`Cannot extract url for event ${Z(t)}`),null}}function Tc(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)!=null&&n.length?!t.message&&!t.exception.values.some(r=>r.stacktrace||r.type&&r.type!=="Error"||r.value):!1}function vc(t,e){return t(e.stack||"",1)}function Ic(t){return jr(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function wc(t){return Ic(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function kc(t,e){const n={type:e.name||e.constructor.name,value:wc(e)},r=vc(t,e);return r.length&&(n.stacktrace={frames:r}),n}const ze="1.13.1",Bs="sentry.javascript.miniapp",Ac=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,Rc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,Cc=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function se(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function Pc(t){const e=Ac.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||At,in_app:Mn(r)},c=se(s),a=se(i);return c&&(o.lineno=c),a&&(o.colno=a),o}function Nc(t){const e=Rc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||At,in_app:Mn(r)},c=se(s),a=se(i);return c&&(o.lineno=c),a&&(o.colno=a),o}function xc(t){const e=Cc.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:At,in_app:Mn(n)},o=se(r),c=se(s);return o&&(i.lineno=o),c&&(i.colno=c),i}function Mn(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const js=pi([90,Pc],[80,Nc],[70,xc]);let Ee={required:!1},On=!1;function Dc(t){Ee=l({},t),On=!t.required}function Mc(t){On=t}function Us(){return!Ee.required||On}function Oc(t,e){if(e>0&&Ee.required&&typeof Ee.onDrop=="function")try{Ee.onDrop({reason:t,dropped:e})}catch(n){}}const Fc=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,Lc=[{global:"wx",name:"wechat"},{global:"my",name:"alipay"},{global:"tt",name:"bytedance"},{global:"dd",name:"dingtalk"},{global:"qq",name:"qq"},{global:"swan",name:"swan"},{global:"ks",name:"kuaishou"}],Hs=()=>{const t=globalThis;for(const e of Lc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},Fn=()=>{const t=Hs();if(!t)return Fc()?console.warn(`[sentry-miniapp] 检测到当前运行在浏览器/H5 环境(如 uni-app H5、Taro H5)。
15
15
  本 SDK 仅适配各小程序平台,不支持浏览器原生信号(window.onerror、fetch/XHR 拦截、PerformanceObserver 等)。
16
16
  建议改用 Sentry 官方浏览器 SDK:@sentry/browser。
17
17
  若使用 uni-app/Taro,可结合条件编译按端引入:H5 用 @sentry/browser,小程序端用 sentry-miniapp。
18
- 详情参考:https://docs.sentry.io/platforms/javascript/`):console.warn("[sentry-miniapp] 未检测到已支持的小程序平台,SDK 将以降级模式运行"),{request:()=>{},httpRequest:()=>{},getSystemInfoSync:()=>({}),URLSearchParams:()=>{}};const e=t.sdk;t.name==="alipay"&&!e.request&&e.httpRequest&&(e.request=e.httpRequest);const n=e;if((t.name==="alipay"||t.name==="dingtalk")&&!n.__sentryStorageAdapted){if(e.getStorageSync){const r=e.getStorageSync;e.getStorageSync=s=>{const i=r.call(e,{key:s});return i?i.data:null}}if(e.setStorageSync){const r=e.setStorageSync;e.setStorageSync=(s,i)=>{r.call(e,{key:s,data:i})}}if(e.removeStorageSync){const r=e.removeStorageSync;e.removeStorageSync=s=>{r.call(e,{key:s})}}n.__sentryStorageAdapted=!0}return e},Us=()=>{var t,e;return(e=(t=Hs())==null?void 0:t.name)!=null?e:"unknown"},Fc=()=>{try{const t=Fn(),e={};let n=!1;if(t.getAppBaseInfo){const s=t.getAppBaseInfo();Object.assign(e,s),n=!0}if(t.getWindowInfo){const s=t.getWindowInfo();Object.assign(e,s),n=!0}if(t.getDeviceInfo){const s=t.getDeviceInfo();Object.assign(e,s),n=!0}if(t.getAppAuthorizeSetting){const s=t.getAppAuthorizeSetting();e.albumAuthorized=s.albumAuthorized==="authorized",e.cameraAuthorized=s.cameraAuthorized==="authorized",e.locationAuthorized=s.locationAuthorized==="authorized",e.microphoneAuthorized=s.microphoneAuthorized==="authorized",e.notificationAuthorized=s.notificationAuthorized==="authorized"}if(t.getSystemSetting){const s=t.getSystemSetting();Object.assign(e,s)}if(n&&!!(e.brand||e.model||e.system))return e;if(t.getSystemInfoSync){const s=t.getSystemInfoSync();return!s.SDKVersion&&s.version&&(s.SDKVersion=s.version),s}return n?e:null}catch(t){return console.warn("[sentry-miniapp] Failed to get system info:",t),null}};let zt=null;const Mt=()=>(zt===null&&(zt=Fc()),zt),Lc=()=>{var t,e;try{const n=Fn();if(n.getAccountInfoSync){const r=n.getAccountInfoSync();return{appId:((t=r==null?void 0:r.miniProgram)==null?void 0:t.appId)||"unknown",version:((e=r==null?void 0:r.miniProgram)==null?void 0:e.version)||"unknown"}}}catch(n){}return{appId:"unknown",version:"unknown"}};let qt=null;const $c=()=>{if(qt===null){const t=Lc();return(t.appId!=="unknown"||t.version!=="unknown")&&(qt=t),t}return qt},zs=()=>Us()!=="unknown";let Wt=null,Gt=null;const T=()=>(Wt===null&&(Wt=Fn()),Wt),qs=()=>(Gt===null&&(Gt=Us()),Gt);let Jt=null;const Bc=()=>{if(Jt===null){const t=globalThis,e=typeof t.GameGlobal!="undefined",n=typeof t.App!="function"&&typeof t.Page!="function"&&typeof t.getCurrentPages!="function";Jt=zs()&&(e||n)}return Jt},Ws=()=>{try{const t=T();if(t.getPerformance&&typeof t.getPerformance=="function")return t.getPerformance()}catch(t){console.warn("Failed to get performance manager:",t)}return null},ve=()=>Date.now(),hn=()=>Date.now();function Gs(t){const e=t.url;function n(r){return new Promise((s,i)=>{var c,a,u,d;const o={url:e,method:"POST",data:r.body,header:l({"Content-Type":"application/json"},r.headers),headers:l({"Content-Type":"application/json"},r.headers),timeout:1e4,success:f=>{const _=f.statusCode||f.status,p=f.header||f.headers||{};s({statusCode:_,headers:{"x-sentry-rate-limits":p["x-sentry-rate-limits"],"retry-after":p["retry-after"]}})},fail:f=>{i(new Error(`Network request failed: ${f.errMsg||f.errorMessage||f.message||"Unknown error"}`))}};T().request?(a=(c=T()).request)==null||a.call(c,o):T().httpRequest?(d=(u=T()).httpRequest)==null||d.call(u,o):i(new Error("No request method available in current miniapp environment"))})}return Wa(t,n)}const jc=30,Hc=864e5,Ln="sentry_offline_store",Uc=900*1024;function _n(t){var d,f,_,p;const e=(d=t.offlineCacheLimit)!=null?d:jc,n=(f=t.offlineCacheMaxAge)!=null?f:Hc,r=(_=t.maxBytes)!=null?_:Uc,s=(p=t.evictionMode)!=null?p:"error-priority",i=t.onDrop;function o(h,m){if(m>0&&typeof i=="function")try{i(h,m)}catch(S){}}function c(h){const m=Date.now(),S=h.filter(E=>m-E.timestamp<n);return o("age",h.length-S.length),S}function a(h,m){let S=0;for(;h.length>e;){if(s==="preserve-oldest")h.pop();else if(m==="push"){const E=h.findIndex(C=>!Kt(C.envelope));E>=0?h.splice(E,1):h.shift()}else{const E=zc(h,C=>!Kt(C.envelope));E>=0?h.splice(E,1):h.pop()}S++}return S}function u(h){const m=T().setStorageSync;if(!m)return;let S=h,E=JSON.stringify(S),C=0;for(;S.length>0&&Wc(E)>r;){if(s==="preserve-oldest")S=S.slice(0,S.length-1);else{const A=S.findIndex(Le=>!Kt(Le.envelope)),P=A>=0?A:0;S=S.slice(0,P).concat(S.slice(P+1))}C++,E=JSON.stringify(S)}o("bytes",C);try{m(Ln,E)}catch(A){}}return{push:h=>O(null,null,function*(){try{const m=c(Yt());m.push({envelope:h,timestamp:Date.now()}),o("count",a(m,"push")),u(m)}catch(m){console.warn("[sentry-miniapp] Failed to push to offline store",m)}}),unshift:h=>O(null,null,function*(){try{const m=c(Yt());m.unshift({envelope:h,timestamp:Date.now()}),o("count",a(m,"unshift")),u(m)}catch(m){console.warn("[sentry-miniapp] Failed to unshift to offline store",m)}}),shift:()=>O(null,null,function*(){try{const h=Yt(),m=c(h);if(m.length===0){h.length>0&&u(m);return}const S=m.shift();return u(m),S==null?void 0:S.envelope}catch(h){console.warn("[sentry-miniapp] Failed to shift from offline store",h);return}})}}function Kt(t){try{return(t[1]||[]).some(n=>{var s;const r=(s=n[0])==null?void 0:s.type;return r==="event"||r==="error"})}catch(e){return!0}}function zc(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}function Yt(){const t=T().getStorageSync;if(!t)return[];let e;try{e=t(Ln)}catch(n){return[]}if(!e)return[];try{const n=typeof e=="string"?JSON.parse(e):e;return Array.isArray(n)&&n.length>0?n[0]&&"envelope"in n[0]&&"timestamp"in n[0]?n:n.map(r=>({envelope:r,timestamp:Date.now()})):[]}catch(n){return qc(),[]}}function qc(){try{const t=T().removeStorageSync;t&&t(Ln)}catch(t){}}function Wc(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319?(e+=4,n++):e+=3}return e}const Gc=Object.freeze(Object.defineProperty({__proto__:null,createMiniappOfflineStore:_n,createMiniappTransport:Gs},Symbol.toStringTag,{value:"Module"}));class Js extends Qa{constructor(e={}){xc({required:e.requireConsent===!0,cacheLimit:e.consentCacheLimit,cacheMaxBytes:e.consentCacheMaxBytes,cacheMaxAge:e.consentCacheMaxAge,onDrop:e.onConsentCacheDrop}),super(v(l({},e),{transport:n=>{const r=e.transport?e.transport(n):Gs(v(l({},n),{headers:{}}));return e.requireConsent===!0?Rr(()=>r)(v(l({},n),{createStore:s=>{var i;return _n(v(l({},s),{offlineCacheLimit:(i=e.consentCacheLimit)!=null?i:100,offlineCacheMaxAge:e.consentCacheMaxAge,maxBytes:e.consentCacheMaxBytes,evictionMode:"preserve-oldest",onDrop:Dc}))},shouldSend:()=>js(),flushAtStartup:!0})):!e.transport&&e.enableOfflineCache!==!1?Rr(()=>r)(v(l({},n),{createStore:s=>_n(v(l({},s),{offlineCacheLimit:e.offlineCacheLimit,offlineCacheMaxAge:e.offlineCacheMaxAge})),flushAtStartup:!0})):r}}))}eventFromException(e){const n={type:e.name||"Error",value:e.message||String(e)};if(e.stack){const r=this.getOptions().stackParser;if(r&&typeof r=="function"){const s=r(e.stack,1);s.length&&(n.stacktrace={frames:s})}}return Promise.resolve({exception:{values:[n]},level:"error"})}eventFromMessage(e,n="info"){return Promise.resolve({message:e,level:n})}_prepareEvent(e,n,r){e.platform=e.platform||this.getOptions().platform||"javascript",e.sdk=v(l({},e.sdk),{name:$s,packages:[...e.sdk&&e.sdk.packages||[],{name:"npm:@sentry/miniapp",version:ze}],version:ze}),e.contexts||(e.contexts={}),e.contexts.miniapp={platform:qs(),sdk_version:ze};try{const s=r||b(),i=R();return Promise.resolve(super._prepareEvent(e,n||{},s,i)).then(o=>this._fillDefaultContexts(o))}catch(s){return this.getOptions().debug&&console.warn("[sentry-miniapp] _prepareEvent 兜底(scope 未就绪):",s),Promise.resolve(this._fillDefaultContexts(e))}}_fillDefaultContexts(e){if(!e||this.getOptions().enableSystemInfo===!1)return e;const n=Mt();e.contexts||(e.contexts={});const r=e.contexts;return r.device=l({brand:(n==null?void 0:n.brand)||"unknown",model:(n==null?void 0:n.model)||"unknown",screen_resolution:`${(n==null?void 0:n.screenWidth)||0}x${(n==null?void 0:n.screenHeight)||0}`,language:(n==null?void 0:n.language)||"unknown",version:(n==null?void 0:n.version)||"unknown",system:(n==null?void 0:n.system)||"unknown",platform:(n==null?void 0:n.platform)||"unknown"},r.device),r.os=l({name:(n==null?void 0:n.system)||"unknown",version:(n==null?void 0:n.version)||"unknown"},r.os),r.app=l({app_version:(n==null?void 0:n.SDKVersion)||"unknown"},r.app),e}close(e){const n=this.getOptions().integrations;if(Array.isArray(n))for(const r of n){const s=r.cleanup;if(typeof s=="function")try{s.call(r)}catch(i){this.getOptions().debug&&console.warn(`[sentry-miniapp] 集成 ${r.name} cleanup 失败:`,i)}if(Array.isArray(be)){const i=be.indexOf(r.name);i!==-1&&be.splice(i,1)}}return super.close(e)}showReportDialog(e={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}captureFeedback(e){const n={contexts:{feedback:{contact_email:e.email,name:e.name,message:e.message,url:e.url,source:e.source,associated_event_id:e.associatedEventId}},type:"feedback",level:"info",tags:e.tags||{}};return b().captureEvent(n)}}const ft=class ft{constructor(e){this.name=ft.id,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._onPageNotFoundHandlerInstalled=!1,this._onMemoryWarningHandlerInstalled=!1,this._errorHandler=null,this._rejectionHandler=null,this._pageNotFoundHandler=null,this._memoryWarningHandler=null,this._options=l({onerror:!0,onunhandledrejection:!0,onpagenotfound:!0,onmemorywarning:!0},e)}setupOnce(){Error.stackTraceLimit=50,this._options.onerror&&this._installGlobalOnErrorHandler(),this._options.onunhandledrejection&&this._installGlobalOnUnhandledRejectionHandler(),this._options.onpagenotfound&&this._installGlobalOnPageNotFoundHandler(),this._options.onmemorywarning&&this._installGlobalOnMemoryWarningHandler()}_installGlobalOnErrorHandler(){var e,n;this._onErrorHandlerInstalled||(T().onError&&(this._errorHandler=r=>{const s=typeof r=="string"?new Error(r):r;ee(s,{mechanism:{type:"onerror",handled:!1}})},(n=(e=T()).onError)==null||n.call(e,this._errorHandler)),this._onErrorHandlerInstalled=!0)}_installGlobalOnUnhandledRejectionHandler(){var e,n;this._onUnhandledRejectionHandlerInstalled||(T().onUnhandledRejection&&(this._rejectionHandler=({reason:r,promise:s})=>{const i=typeof r=="string"?new Error(r):r;ee(i,{mechanism:{type:"onunhandledrejection",handled:!1},data:{promise:s}})},(n=(e=T()).onUnhandledRejection)==null||n.call(e,this._rejectionHandler)),this._onUnhandledRejectionHandlerInstalled=!0)}_installGlobalOnPageNotFoundHandler(){var e,n;this._onPageNotFoundHandlerInstalled||(T().onPageNotFound&&(this._pageNotFoundHandler=r=>{const s=b(),i=r.path.split("?")[0];s.setTag("pagenotfound",i),s.setContext("page_not_found",{path:r.path,query:r.query,isEntryPage:r.isEntryPage}),ee(new Error(`页面无法找到: ${i}`),{mechanism:{type:"onpagenotfound",handled:!0}})},(n=(e=T()).onPageNotFound)==null||n.call(e,this._pageNotFoundHandler)),this._onPageNotFoundHandlerInstalled=!0)}_installGlobalOnMemoryWarningHandler(){var e,n;this._onMemoryWarningHandlerInstalled||(T().onMemoryWarning&&(this._memoryWarningHandler=({level:r=-1})=>{let s="没有获取到告警级别信息";switch(r){case 5:s="TRIM_MEMORY_RUNNING_MODERATE";break;case 10:s="TRIM_MEMORY_RUNNING_LOW";break;case 15:s="TRIM_MEMORY_RUNNING_CRITICAL";break;default:return}const i=b();i.setTag("memory-warning",String(r)),i.setContext("memory_warning",{level:r,message:s}),ee(new Error("内存不足告警"),{mechanism:{type:"onmemorywarning",handled:!0}})},(n=(e=T()).onMemoryWarning)==null||n.call(e,this._memoryWarningHandler)),this._onMemoryWarningHandlerInstalled=!0)}cleanup(){try{const e=T();this._errorHandler&&e.offError&&e.offError(this._errorHandler),this._rejectionHandler&&e.offUnhandledRejection&&e.offUnhandledRejection(this._rejectionHandler),this._pageNotFoundHandler&&e.offPageNotFound&&e.offPageNotFound(this._pageNotFoundHandler),this._memoryWarningHandler&&e.offMemoryWarning&&e.offMemoryWarning(this._memoryWarningHandler)}catch(e){}this._errorHandler=null,this._rejectionHandler=null,this._pageNotFoundHandler=null,this._memoryWarningHandler=null,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._onPageNotFoundHandlerInstalled=!1,this._onMemoryWarningHandlerInstalled=!1}};ft.id="GlobalHandlers";let Qe=ft;function Pr(t,e={},n){if(typeof t!="function")return t;try{if(t.__sentry__)return t;if(t.__sentry_wrapped__)return t.__sentry_wrapped__}catch(s){return t}const r=function(...s){try{return t.apply(this,s)}catch(i){throw fe(o=>{o.addEventProcessor(c=>v(l({},c),{extra:v(l({},c.extra),{arguments:s})})),ee(i,e.mechanism?{mechanism:e.mechanism}:void 0)}),i}};try{for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}catch(s){}t.prototype=t.prototype||{},r.prototype=t.prototype,Object.defineProperty(t,"__sentry_wrapped__",{enumerable:!1,value:r}),Object.defineProperties(r,{__sentry__:{enumerable:!1,value:!0},__sentry_original__:{enumerable:!1,value:t}});try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch(s){}return r}function xr(t){try{return t&&t.name||"<anonymous>"}catch(e){return"<anonymous>"}}function Te(t,e,n){if(!(e in t))return;const r=t[e],s=n(r);if(typeof s=="function")try{s.prototype=s.prototype||{},s.prototype.constructor=s}catch(i){}t[e]=s}const pt=class pt{constructor(){this.name=pt.id}_wrapTimeFunction(e){return function(...n){const r=n[0];return n[0]=Pr(r,{mechanism:{data:{function:xr(e)},handled:!0,type:"instrument"}}),e.apply(this,n)}}_wrapRAF(e){return function(n){return e(Pr(n,{mechanism:{data:{function:"requestAnimationFrame",handler:xr(e)},handled:!0,type:"instrument"}}))}}setupOnce(){const e=globalThis;e.setTimeout&&Te(e,"setTimeout",this._wrapTimeFunction.bind(this)),e.setInterval&&Te(e,"setInterval",this._wrapTimeFunction.bind(this)),e.requestAnimationFrame&&Te(e,"requestAnimationFrame",this._wrapRAF.bind(this))}};pt.id="TryCatch";let et=pt;const Jc="cause",Kc=5,dt=class dt{constructor(e={}){this.name=dt.id,this._key=e.key||Jc,this._limit=e.limit||Kc}setupOnce(){}processEvent(e,n){return b().getClient()?this._handler(e,n):e}_handler(e,n){if(!e.exception||!e.exception.values||!n||!Nr(n.originalException,Error))return e;const r=this._walkErrorTree(n.originalException,this._key);return e.exception.values=[...r,...e.exception.values],e}_walkErrorTree(e,n,r=[]){if(!Nr(e[n],Error)||r.length+1>=this._limit)return r;const s=Ic(()=>[],e[n]);return this._walkErrorTree(e[n],n,[s,...r])}};dt.id="LinkedErrors";let tt=dt;function Nr(t,e){try{return t instanceof e}catch(n){return!1}}const ht=class ht{constructor(){this.name=ht.id}setupOnce(){}processEvent(e){var s,i;const n=this._getMiniappVersion(),r=$c();return e.contexts=v(l({},e.contexts),{runtime:v(l({},((s=e.contexts)==null?void 0:s.runtime)||{}),{name:"miniapp",version:n}),app:v(l({},((i=e.contexts)==null?void 0:i.app)||{}),{name:r.appId,version:r.version})}),e}_getMiniappVersion(){const e=Mt();return(e==null?void 0:e.version)||(e==null?void 0:e.SDKVersion)||"unknown"}};ht.id="HttpContext";let nt=ht;const _t=class _t{constructor(e={}){this.name=_t.id,this._fuzzyMatch=!!e.fuzzyMatch}setupOnce(){}processEvent(e,n){if(e.type)return e;try{if(this._shouldDropEvent(e,this._previousEvent))return null}catch(r){return this._previousEvent=this._cloneEventForComparison(e),e}return this._previousEvent=this._cloneEventForComparison(e),e}_shouldDropEvent(e,n){return n?!!(this._isSameMessageEvent(e,n)||this._isSameExceptionEvent(e,n)):!1}_isSameMessageEvent(e,n){const r=e.message,s=n.message;return!(!r&&!s||r&&!s||!r&&s||r!==s||!this._isSameFingerprint(e,n)||!this._isSameStacktrace(e,n))}_isSameExceptionEvent(e,n){const r=this._getExceptionFromEvent(e),s=this._getExceptionFromEvent(n);if(!r||!s||r.type!==s.type)return!1;if(this._fuzzyMatch){if(!Yc(r.value,s.value))return!1}else if(r.value!==s.value)return!1;return!(!this._isSameFingerprint(e,n)||!this._isSameStacktrace(e,n))}_isSameStacktrace(e,n){let r=this._getFramesFromEvent(e),s=this._getFramesFromEvent(n);if(!r&&!s)return!0;if(r&&!s||!r&&s||(r=r,s=s,s.length!==r.length))return!1;for(let i=0;i<s.length;i++){const o=s[i],c=r[i];if(o.filename!==c.filename||o.lineno!==c.lineno||o.colno!==c.colno||o.function!==c.function)return!1}return!0}_isSameFingerprint(e,n){let r=e.fingerprint,s=n.fingerprint;if(!r&&!s)return!0;if(r&&!s||!r&&s)return!1;r=r,s=s;try{return r.join("")===s.join("")}catch(i){return!1}}_getExceptionFromEvent(e){return e.exception&&e.exception.values&&e.exception.values[0]}_cloneEventForComparison(e){var n;return{message:e.message,fingerprint:e.fingerprint?[...e.fingerprint]:void 0,exception:e.exception?{values:(n=e.exception.values)==null?void 0:n.map(r=>{var s;return{type:r.type,value:r.value,stacktrace:r.stacktrace?{frames:(s=r.stacktrace.frames)==null?void 0:s.map(i=>l({},i))}:void 0}})}:void 0}}_getFramesFromEvent(e){const n=e.exception;if(n)try{return n.values[0].stacktrace.frames}catch(r){}}};_t.id="Dedupe";let rt=_t;const Dr=/\d{10,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/g;function Yc(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.replace(Dr,"<dynamic>"),r=e.replace(Dr,"<dynamic>");return n===r}const mt=class mt{constructor(){this.name=mt.id}setupOnce(){this._addSystemContext(),this._addNetworkContext(),this._addLocationContext(),this._addStorageContext(),this._checkAppUpdate()}_addSystemContext(){var e,n,r,s;try{const i=Mt();if(i){const o=b();o.setContext("device",{name:i.model,model:i.model,brand:i.brand,family:i.platform,arch:i.platform}),o.setContext("os",{name:((e=i.system)==null?void 0:e.split(" ")[0])||"unknown",version:((n=i.system)==null?void 0:n.split(" ")[1])||"unknown",kernel_version:i.version}),o.setContext("app",{app_name:i.appName||"unknown",app_version:i.version}),o.setContext("screen",{screen_width:i.screenWidth,screen_height:i.screenHeight,screen_density:i.pixelRatio}),o.setTag("device.model",i.model),o.setTag("device.brand",i.brand),o.setTag("os.name",((r=i.system)==null?void 0:r.split(" ")[0])||"unknown"),o.setTag("os.version",((s=i.system)==null?void 0:s.split(" ")[1])||"unknown"),o.setTag("app.version",i.version),o.setTag("language",i.language)}}catch(i){}}_addNetworkContext(){try{T().getNetworkType&&T().getNetworkType({success:e=>{const n=b();n.setContext("network",{type:e.networkType,connected:e.isConnected!==!1}),n.setTag("network.type",e.networkType)},fail:()=>{}})}catch(e){}}_addLocationContext(){try{T().getLocation&&T().getLocation({type:"gcj02",success:e=>{b().setContext("location",{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy})},fail:()=>{}})}catch(e){}}_addStorageContext(){try{const e=T();if(e&&typeof e.getStorageInfoSync=="function"){const n=e.getStorageInfoSync();if(n){const r=n.currentSize||0,s=n.limitSize||0,i=s>0?Math.round(r/s*100):0;b().setContext("storage",{currentSize:r,limitSize:s,usagePercent:i}),i>=80&&k({category:"storage.warning",message:`存储使用率 ${i}%(${r}KB / ${s}KB)`,level:"warning",data:{currentSize:r,limitSize:s,usagePercent:i}})}}}catch(e){}}_checkAppUpdate(){try{const e=T();if(e&&typeof e.getUpdateManager=="function"){const n=e.getUpdateManager();n&&(typeof n.onCheckForUpdate=="function"&&n.onCheckForUpdate(r=>{r&&r.hasUpdate&&(b().setTag("has_update","true"),k({category:"app.update",message:"检测到新版本可用",level:"info",data:{hasUpdate:!0}}))}),typeof n.onUpdateReady=="function"&&n.onUpdateReady(()=>{k({category:"app.update",message:"新版本已下载完成",level:"info",data:{updateReady:!0}})}))}}catch(e){}}};mt.id="System";let mn=mt;const gt=class gt{constructor(){this.name=gt.id,this._lastRoute="",this._monitorTimer=null}setupOnce(){this._instrumentNavigation(),this._startRouteMonitoring()}_instrumentNavigation(){let e;try{e=T()}catch(r){return}const n=["navigateTo","redirectTo","switchTab","reLaunch"];for(const r of n)if(e[r]){const s=e[r];e[r]=i=>(this._recordNavigation(r,i.url,this._getCurrentRoute()),s.call(e,i))}if(e.navigateBack){const r=e.navigateBack;e.navigateBack=(s={})=>(this._recordNavigation("navigateBack","back",this._getCurrentRoute(),s.delta),r.call(e,s))}}_startRouteMonitoring(){this._monitorTimer=setInterval(()=>{const e=this._getCurrentRoute();e&&e!==this._lastRoute&&(this._recordRouteChange(this._lastRoute,e),this._lastRoute=e)},1e3)}cleanup(){this._monitorTimer&&(clearInterval(this._monitorTimer),this._monitorTimer=null)}_getCurrentRoute(){try{const e=globalThis;if(e.getCurrentPages){const n=e.getCurrentPages();if(n&&n.length>0){const r=n[n.length-1];return r.route||r.__route__||""}}}catch(e){}return""}_recordNavigation(e,n,r,s){const i=b();k({category:"navigation",data:{action:e,from:r,to:n,delta:s},message:`Navigation ${e}: ${r} -> ${n}`,type:"navigation"}),i.setTag("route",n==="back"?r:n),i.setContext("navigation",{action:e,from:r,to:n,delta:s,timestamp:Date.now()})}_recordRouteChange(e,n){const r=b();k({category:"navigation",data:{from:e,to:n},message:`Route changed: ${e} -> ${n}`,type:"navigation"}),r.setTag("route",n),r.setContext("route",{current:n,previous:e,timestamp:Date.now()})}};gt.id="Router";let gn=gt;const yt=class yt{constructor(e={}){this.name=yt.id,this._performanceManager=null,this._observers=[],this._entryBuffer=[],this._reportTimer=null,this._options=v(l({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!1,sampleRate:1,bufferSize:100,reportInterval:3e4,enableMemory:!1},e),{thresholds:l({navigation:3e3,render:1e3,resource:2e3,setData:50},e==null?void 0:e.thresholds)})}setupOnce(){this._initializePerformanceManager(),this._setupPerformanceObservers(),this._startAutoReporting(),this._addPerformanceContext()}_initializePerformanceManager(){try{if(this._performanceManager=Ws(),!this._performanceManager){console.warn("[sentry-miniapp] Performance API not available");return}const e=b();e.setTag("performance.api.available",!0),e.setContext("performance",{api_version:"miniapp-1.0",sample_rate:this._options.sampleRate,buffer_size:this._options.bufferSize})}catch(e){console.warn("[sentry-miniapp] Failed to initialize performance manager:",e)}}_setupPerformanceObservers(){if(this._performanceManager)try{const e=[];this._options.enableNavigation&&e.push("navigation"),this._options.enableRender&&e.push("render"),this._options.enableResource&&e.push("resource");let n=this._options.enableUserTiming;if(n)try{const i=Mt();if(i&&i.platform==="devtools"&&(n=!1),n){const c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{}).PerformanceObserver,a=c&&Array.isArray(c.supportedEntryTypes)?c.supportedEntryTypes:void 0;(!a||!a.includes("measure")||!a.includes("mark"))&&(n=!1)}}catch(i){n=!1}if(n&&e.push("measure","mark"),e.length===0)return;const r=this._performanceManager.createObserver(i=>{this._handlePerformanceEntries(i)});try{r.observe({entryTypes:e})}catch(i){const o=e.filter(c=>c!=="measure"&&c!=="mark");if(o.length<e.length&&o.length>0)r.observe({entryTypes:o}),console.warn("[sentry-miniapp] Failed to observe all types, falling back to:",o),e.length=0,e.push(...o);else throw i}this._observers.push(r);const s=typeof globalThis!="undefined"?globalThis.process:void 0;s&&s.env&&s.env.NODE_ENV!=="production"&&console.log("[sentry-miniapp] Performance observers setup for:",e)}catch(e){console.warn("[sentry-miniapp] Failed to setup performance observers:",e)}}_handlePerformanceEntries(e){if(!e)return;let n;if(Array.isArray(e))n=e;else if(typeof e=="object"&&e.getEntries)n=e.getEntries();else if(typeof e=="object")n=[e];else{console.warn("[sentry-miniapp] Invalid entries format:",typeof e);return}n.length!==0&&(Math.random()>this._options.sampleRate||n.forEach(r=>{try{this._processPerformanceEntry(r),this._addToBuffer(r)}catch(s){console.warn("[sentry-miniapp] Failed to process performance entry:",s)}}))}_processPerformanceEntry(e){switch(e.entryType){case"navigation":this._processNavigationEntry(e);break;case"render":this._processRenderEntry(e);break;case"resource":this._processResourceEntry(e);break;case"measure":case"mark":this._processUserTimingEntry(e);break;default:console.log("[sentry-miniapp] Unknown entry type:",e.entryType)}}_processNavigationEntry(e){b().addBreadcrumb({message:`页面导航: ${e.name}`,category:"performance.navigation",level:"info",data:{duration:e.duration,appLaunchTime:e.appLaunchTime,pageReadyTime:e.pageReadyTime}}),_e({name:`Navigation: ${e.name}`,op:"navigation",startTime:e.startTime/1e3},r=>{r.setAttributes({"navigation.name":e.name,"navigation.duration":e.duration,"navigation.app_launch_time":e.appLaunchTime||0,"navigation.page_ready_time":e.pageReadyTime||0,"navigation.first_render_time":e.firstRenderTime||0}),r.end((e.startTime+e.duration)/1e3)})}_processRenderEntry(e){var r,s;_e({name:`Render: ${e.name}`,op:"render",startTime:e.startTime/1e3},i=>{i.setAttributes({"render.name":e.name,"render.duration":e.duration,"render.start":e.renderStart||0,"render.end":e.renderEnd||0,"render.script_start":e.scriptStart||0,"render.script_end":e.scriptEnd||0}),i.end((e.startTime+e.duration)/1e3)});const n=(s=(r=this._options.thresholds)==null?void 0:r.setData)!=null?s:50;e.duration>n&&b().addBreadcrumb({message:`慢渲染检测: ${e.name} (${e.duration.toFixed(1)}ms)`,category:"performance.setData.slow",level:"warning",data:{name:e.name,duration:e.duration,threshold:n,renderStart:e.renderStart,renderEnd:e.renderEnd,scriptStart:e.scriptStart,scriptEnd:e.scriptEnd}})}_processResourceEntry(e){_e({name:`Resource: ${e.name}`,op:"resource",startTime:e.startTime/1e3},n=>{n.setAttributes({"resource.name":e.name,"resource.duration":e.duration,"resource.type":e.initiatorType||"unknown","resource.transfer_size":e.transferSize||0,"resource.encoded_size":e.encodedBodySize||0,"resource.decoded_size":e.decodedBodySize||0}),e.fetchStart&&e.responseEnd&&n.setAttributes({"resource.fetch_start":e.fetchStart,"resource.response_end":e.responseEnd,"resource.network_time":e.responseEnd-e.fetchStart}),n.end((e.startTime+e.duration)/1e3)})}_processUserTimingEntry(e){e.entryType==="measure"?_e({name:`Measure: ${e.name}`,op:"measure",startTime:e.startTime/1e3},n=>{n.setAttributes({"measure.name":e.name,"measure.duration":e.duration,"measure.detail":e.detail?JSON.stringify(e.detail):void 0}),n.end((e.startTime+e.duration)/1e3)}):e.entryType==="mark"&&b().addBreadcrumb({message:`性能标记: ${e.name}`,category:"performance.mark",level:"info",data:{timestamp:e.startTime,detail:e.detail}})}_addToBuffer(e){for(this._entryBuffer.push(e);this._entryBuffer.length>this._options.bufferSize;)this._entryBuffer.shift()}_startAutoReporting(){this._options.reportInterval<=0||(this._reportTimer=setInterval(()=>{this._reportBufferedEntries()},this._options.reportInterval))}_reportBufferedEntries(){if(this._entryBuffer.length!==0)try{const e=b(),n=this._calculatePerformanceStats(),r=this._collectMemoryInfo();r&&(n.memory=r),e.setContext("performance_summary",l({total_entries:this._entryBuffer.length,navigation_count:this._entryBuffer.filter(s=>s.entryType==="navigation").length,render_count:this._entryBuffer.filter(s=>s.entryType==="render").length,resource_count:this._entryBuffer.filter(s=>s.entryType==="resource").length,measure_count:this._entryBuffer.filter(s=>s.entryType==="measure").length,mark_count:this._entryBuffer.filter(s=>s.entryType==="mark").length,report_time:new Date().toISOString()},n)),this._checkPerformanceThresholds(n),this._reportToNativeAPI(),this._entryBuffer=[]}catch(e){console.warn("[sentry-miniapp] Failed to report buffered entries:",e)}}_calculatePerformanceStats(){const e=this._entryBuffer.filter(i=>i.entryType==="navigation"),n=this._entryBuffer.filter(i=>i.entryType==="render"),r=this._entryBuffer.filter(i=>i.entryType==="resource"),s={};if(e.length>0){const i=e.map(o=>o.duration);s.navigation_stats={avg_duration:i.reduce((o,c)=>o+c,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)}}if(n.length>0){const i=n.map(c=>c.duration);s.render_stats={avg_duration:i.reduce((c,a)=>c+a,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)};const o=n.filter(c=>{var a,u;return c.duration>((u=(a=this._options.thresholds)==null?void 0:a.setData)!=null?u:50)});s.render_stats.slow_render_count=o.length,s.render_stats.slow_render_ratio=o.length/n.length}if(r.length>0){const i=r.map(c=>c.duration),o=r.map(c=>c.transferSize||0).filter(c=>c>0);s.resource_stats={avg_load_time:i.reduce((c,a)=>c+a,0)/i.length,max_load_time:Math.max(...i),total_transfer_size:o.reduce((c,a)=>c+a,0),avg_transfer_size:o.length>0?o.reduce((c,a)=>c+a,0)/o.length:0}}return s}_checkPerformanceThresholds(e){var o,c,a,u,d,f,_,p,h;const n=b(),r=(c=(o=this._options.thresholds)==null?void 0:o.navigation)!=null?c:3e3;((a=e.navigation_stats)==null?void 0:a.avg_duration)>r&&n.addBreadcrumb({message:"页面导航性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.navigation_stats.avg_duration,threshold:r}});const s=(d=(u=this._options.thresholds)==null?void 0:u.render)!=null?d:1e3;((f=e.render_stats)==null?void 0:f.avg_duration)>s&&n.addBreadcrumb({message:"页面渲染性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.render_stats.avg_duration,threshold:s}});const i=(p=(_=this._options.thresholds)==null?void 0:_.resource)!=null?p:2e3;((h=e.resource_stats)==null?void 0:h.avg_load_time)>i&&n.addBreadcrumb({message:"资源加载性能较慢",category:"performance.warning",level:"warning",data:{avg_load_time:e.resource_stats.avg_load_time,threshold:i}})}_reportToNativeAPI(){try{const e=T();if(e.reportPerformance&&this._entryBuffer.length>0){const n={entries:this._entryBuffer.map(r=>({name:r.name,entryType:r.entryType,startTime:r.startTime,duration:r.duration})),timestamp:Date.now(),sampleRate:this._options.sampleRate};e.reportPerformance(n)}}catch(e){console.warn("[sentry-miniapp] Failed to report to native API:",e)}}_collectMemoryInfo(){if(!this._options.enableMemory)return null;try{const e=T();if(e.getPerformance){const n=e.getPerformance();if(n&&n.memory)return{jsHeapSizeUsed:n.memory.jsHeapSizeUsed,jsHeapSizeLimit:n.memory.jsHeapSizeLimit}}}catch(e){}return null}_addPerformanceContext(){try{const e=b(),n=T(),r=!!n.getPerformance,s=!!n.reportPerformance;e.setContext("performance_support",{has_performance_api:r,has_report_api:s,integration_enabled:!0,options:this._options}),e.setTag("performance.integration","enabled")}catch(e){console.warn("[sentry-miniapp] Failed to add performance context:",e)}}cleanup(){this._observers.forEach(e=>{try{e.disconnect()}catch(n){console.warn("[sentry-miniapp] Failed to disconnect observer:",n)}}),this._observers=[],this._reportTimer&&(clearInterval(this._reportTimer),this._reportTimer=null),this._reportBufferedEntries()}};yt.id="PerformanceAPI";let st=yt;const $n=t=>()=>new st(t),St=class St{constructor(e={}){this.name=St.id,this._prefix=e.prefix||"app:///"}setupOnce(){}processEvent(e){return e.exception&&e.exception.values&&e.exception.values.forEach(n=>{n.stacktrace&&n.stacktrace.frames&&n.stacktrace.frames.forEach(r=>{r.filename&&(r.filename=this._normalizeFilename(r.filename))})}),e}_normalizeFilename(e){let n=e;return n=n.replace(/^(appservice|app-service|WAService)\//i,"").replace(/^https?:\/\/[^/]+\//i,"").replace(/^[a-z]+:\/\//i,"").replace(/^\//,""),n.startsWith(this._prefix)?n:`${this._prefix}${n}`}};St.id="RewriteFrames";let it=St;const bt=class bt{constructor(e={}){this.name=bt.id,this._originalRequest=null,this._originalHttpRequest=null,this._traceNetworkBody=!!e.traceNetworkBody,this._sensitiveKeys=(e.sensitiveKeys||["password","passwd","secret","token","access_token","refresh_token","authorization","cookie","session","creditcard","credit_card","card_number","cvv","ssn","id_card"]).map(n=>n.toLowerCase()),this._denyUrls=(e.denyBodyUrls||[]).map(n=>typeof n=="string"?new RegExp(n):n),this._enableTracePropagation=e.enableTracePropagation!==!1,this._tracePropagationTargets=e.tracePropagationTargets||[]}setupOnce(){const e=T();e&&typeof e.request=="function"&&(this._originalRequest=e.request,Te(e,"request",this._createRequestWrapper.bind(this))),e&&typeof e.httpRequest=="function"&&(this._originalHttpRequest=e.httpRequest,Te(e,"httpRequest",this._createRequestWrapper.bind(this)))}cleanup(){const e=T();e&&(this._originalRequest&&typeof e.request=="function"&&(e.request=this._originalRequest),this._originalHttpRequest&&typeof e.httpRequest=="function"&&(e.httpRequest=this._originalHttpRequest)),this._originalRequest=null,this._originalHttpRequest=null}_createRequestWrapper(e){const n=this._traceNetworkBody,r=this._sanitizeBody.bind(this),s=this._shouldDenyBodyUrl.bind(this),i=this._enableTracePropagation,o=this._shouldPropagateTrace.bind(this);return function(c){if(!c||typeof c!="object")return e.call(this,c);const a=nu(c.url),u=w();let d="";if(u){const I=u.getOptions().dsn;if(I)try{const x=I.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n]+)/i);x&&x[1]&&(d=x[1])}catch(x){}}const f=a.match(/^https?:\/\/([^:/\n]+)/i),_=f&&f[1]?f[1]:"";if(d&&_===d||_==="sentry.io"||_.endsWith(".sentry.io"))return e.call(this,c);const h=ru(c.method),m=c.data,S=Date.now(),E=Vc(h,a);let C=!1;const A=I=>{C||(C=!0,tu(E,I))};i&&o(a)&&eu(c,E);const P={url:a,method:h};if(n&&m&&!s(a))try{const I=typeof m=="string"?m:JSON.stringify(m);P.request_body=r(I),P.request_size=I.length}catch(I){P.request_body="[Cannot serialize request body]"}const Le=c.success,jn=c.fail,Hn=c.complete;c.success=function(...I){const x=I[0]||{},j=Mr(x),de=Date.now()-S;if(P.status_code=j,P.duration=de,A({statusCode:j,status:Vt(j)?"error":"ok"}),n&&x.data&&!s(a))try{const Ot=typeof x.data=="string"?x.data:JSON.stringify(x.data);P.response_body=r(Ot),P.response_size=Ot.length}catch(Ot){P.response_body="[Cannot serialize response body]"}const Xs=Vt(j)||de>3e3?"warning":"info";if(k({type:"http",category:"xhr",data:P,level:Xs}),typeof Le=="function")return Le.apply(this,I)},c.fail=function(...I){const x=I[0]||{},j=Date.now()-S,de=x.errMsg||x.errorMessage||"Network request failed";if(P.error=de,P.duration=j,A({status:"error",errorMessage:de}),k({type:"http",category:"xhr",data:P,level:"error"}),typeof jn=="function")return jn.apply(this,I)},c.complete=function(...I){const x=I[0]||{},j=Mr(x);if(A({statusCode:j,status:Vt(j)?"error":"ok"}),typeof Hn=="function")return Hn.apply(this,I)};try{return e.call(this,c)}catch(I){throw A({status:"error",errorMessage:I instanceof Error?I.message:String(I)}),I}}}_shouldPropagateTrace(e){return this._tracePropagationTargets.length===0?!0:this._tracePropagationTargets.some(n=>{if(typeof n=="string")return e.includes(n);n.lastIndex=0;const r=n.test(e);return n.lastIndex=0,r})}_shouldDenyBodyUrl(e){return this._denyUrls.some(n=>n.test(e))}_sanitizeBody(e){if(this._sensitiveKeys.length===0)return e;try{const n=JSON.parse(e);if(typeof n=="object"&&n!==null)return this._sanitizeObject(n),JSON.stringify(n)}catch(n){for(const r of this._sensitiveKeys){const s=new RegExp(`(${r})=[^&]*`,"gi");e=e.replace(s,"$1=[Filtered]")}}return e}_sanitizeObject(e){for(const n of Object.keys(e))this._sensitiveKeys.includes(n.toLowerCase())?e[n]="[Filtered]":typeof e[n]=="object"&&e[n]!==null&&this._sanitizeObject(e[n])}};bt.id="NetworkBreadcrumbs";let ot=bt;function Vc(t,e){try{const n=iu(e);return Nt({name:`${t} ${Xc(e)}`,op:"http.client",kind:2,attributes:{"http.request.method":t,"url.full":e,"server.address":n||void 0}})}catch(n){return null}}function Xc(t){return t.startsWith("data:")?Qc(t):Zc(t).replace(/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]+@)/i,"$1[filtered]:[filtered]@")}function Zc(t){const e=t.split(/[?#]/,1)[0];return e===void 0?t:e}function Qc(t){const e=t.match(/^data:([^;,]+)/);return`data:${e&&e[1]?e[1]:"text/plain"}`}function eu(t,e){if(e)try{const n=ac({span:e}),r=n["sentry-trace"];if(!r)return;const s=l(l({},Or(t.headers)?t.headers:{}),Or(t.header)?t.header:{});s["sentry-trace"]||(s["sentry-trace"]=r),n.baggage&&(s.baggage=su(s.baggage,n.baggage)),t.header=s,t.headers=s}catch(n){}}function tu(t,e){if(t)try{const n=Ks(e.statusCode);n!==void 0?Gi(t,n):t.setStatus({code:e.status==="error"?N:Pt,message:e.status==="error"?e.errorMessage||"error":"ok"}),e.errorMessage&&t.setAttribute("error.message",e.errorMessage),t.end()}catch(n){}}function nu(t){return typeof t=="string"?t:t==null?"":String(t)}function ru(t){return typeof t=="string"&&t.trim()!==""?t.toUpperCase():"GET"}function Mr(t){if(!(!t||typeof t!="object"))return t.statusCode!==void 0&&t.statusCode!==null?t.statusCode:t.status}function Vt(t){const e=Ks(t);return e!==void 0&&e>=400}function Or(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function su(t,e){const n=typeof t=="string"?t:Array.isArray(t)?t.filter(s=>typeof s=="string").join(","):"";return n?n.split(",").some(s=>s.trim().startsWith("sentry-"))?n:`${n},${e}`:e}function Ks(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){const e=Number(t);if(Number.isFinite(e))return e}}function iu(t){try{const e=t.match(/^https?:\/\/([^:/\n]+)/i);return e&&e[1]?e[1]:""}catch(e){return""}}const ou=["onLaunch","onShow","onHide","onError"],at=new Set;let qe=null,ct=!1;function au(t,e){for(const n of[...at]){const r=n[t];if(typeof r=="function")try{r(e)}catch(s){}}}function cu(){const t=globalThis;if(ct||typeof t.App!="function")return;const e=t.App;qe=e;const n=function(r={}){if(r&&typeof r=="object")for(const s of ou){const i=r[s];r[s]=function(...o){if(au(s,o[0]),typeof i=="function")return i.apply(this,o)}}return e.call(this,r)};n.__sentryAppWrapper=!0,t.App=n,ct=!0}function uu(){if(!ct||at.size>0)return;const t=globalThis;t.App&&t.App.__sentryAppWrapper&&qe&&(t.App=qe),qe=null,ct=!1}function Ys(t){if(typeof globalThis.App!="function")return()=>{};at.add(t),cu();let e=!0;return()=>{e&&(e=!1,at.delete(t),uu())}}const Vs=["onLoad","onShow","onHide","onUnload","onReady"];function lu(t){return Vs.includes(t)||t.startsWith("_")?!1:/^(on|handle|bind)[A-Z]/.test(t)||/[Tt]ap$/.test(t)||/[Cc]lick$/.test(t)||/[Cc]hange$/.test(t)||/[Ss]ubmit$/.test(t)||/[Ss]croll$/.test(t)||/[Ii]nput$/.test(t)}const Et=class Et{constructor(e={}){this.name=Et.id,this._originalPage=null,this._wrappedPage=null,this._unsubscribeApp=null,this._launchTime=0,this._firstPageReady=!1,this._options=l({enableLifecycle:!0,enableUserInteraction:!0},e)}setupOnce(){this._wrapPage(),this._subscribeApp()}_wrapPage(){const e=globalThis;if(typeof e.Page!="function"||e.Page.__sentryPageWrapper)return;this._originalPage=e.Page;const n=e.Page,r=this._options,s=()=>this._firstPageReady,i=a=>{this._firstPageReady=a},o=()=>this._launchTime,c=function(a){if(a&&typeof a=="object"){if(r.enableLifecycle){for(const u of Vs)if(typeof a[u]=="function"){const d=a[u];a[u]=function(...f){const _=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",p={action:u,page:_};if(u==="onLoad"&&f[0]&&typeof f[0]=="object"&&(p.query=f[0]),u==="onReady"&&!s()&&o()>0){i(!0);const h=Date.now()-o();p.coldStartDuration=h,W("startup",{coldStartDuration:h,firstPage:_})}return k({category:"page.lifecycle",message:`${u}: ${_}`,level:"info",data:p}),d.apply(this,f)}}}if(r.enableUserInteraction){for(const u of Object.keys(a))if(typeof a[u]=="function"&&lu(u)){const d=a[u];a[u]=function(f,..._){const p=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",h={handler:u,page:p};if(f&&typeof f=="object"&&(f.target&&(f.target.id&&(h.targetId=f.target.id),f.target.dataset&&(h.dataset=f.target.dataset)),f.type&&(h.eventType=f.type),f.detail&&(typeof f.detail.x=="number"&&(h.x=f.detail.x),typeof f.detail.y=="number"&&(h.y=f.detail.y)),f.touches&&f.touches.length>0)){const m=f.touches[0];m&&(h.touchX=m.pageX,h.touchY=m.pageY)}return k({category:"user.interaction",message:`${u} on ${p}`,level:"info",data:h}),d.apply(this,[f,..._])}}}}return n(a)};Object.defineProperty(c,"__sentryPageWrapper",{value:!0,configurable:!0}),this._wrappedPage=c,e.Page=c}_subscribeApp(){this._options.enableLifecycle&&(this._unsubscribeApp=Ys({onLaunch:()=>{this._launchTime=Date.now(),this._appBreadcrumb("onLaunch")},onShow:()=>this._appBreadcrumb("onShow"),onHide:()=>this._appBreadcrumb("onHide")}))}_appBreadcrumb(e){k({category:"app.lifecycle",message:`App.${e}`,level:"info",data:{action:e}})}cleanup(){const e=globalThis;this._originalPage&&(e.Page===this._wrappedPage&&(e.Page=this._originalPage),this._originalPage=null,this._wrappedPage=null),this._unsubscribeApp&&(this._unsubscribeApp(),this._unsubscribeApp=null)}};Et.id="PageBreadcrumbs";let Pe=Et;const fu=t=>new Pe(t),pu=["debug","info","warn","error","log"],du={debug:"debug",info:"info",log:"info",warn:"warning",error:"error"},vt=class vt{constructor(e={}){this.name=vt.id,this._originalMethods={},this._levels=e.levels||[...pu]}setupOnce(){for(const e of this._levels){if(typeof console[e]!="function")continue;const n=console[e];this._originalMethods[e]=n,console[e]=function(...r){return k({category:"console",level:du[e],message:r.map(s=>{if(typeof s=="string")return s;try{return JSON.stringify(s)}catch(i){return String(s)}}).join(" ")}),n.apply(console,r)}}}cleanup(){for(const e of this._levels){const n=this._originalMethods[e];n&&(console[e]=n)}this._originalMethods={}}};vt.id="ConsoleBreadcrumbs";let xe=vt;const hu=t=>new xe(t),Tt=class Tt{constructor(){this.name=Tt.id,this._isSessionActive=!1,this._unsubscribe=null}setupOnce(){this._unsubscribe=Ys({onLaunch:()=>this._startSession(),onShow:()=>{this._isSessionActive||this._startSession()},onHide:()=>this._endSession()})}_startSession(){try{ws({ignoreDuration:!0}),pn(),this._isSessionActive=!0}catch(e){}}_endSession(){try{Dt(),pn(),this._isSessionActive=!1}catch(e){}}cleanup(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null),this._isSessionActive=!1}};Tt.id="Session";let ut=Tt;const It=class It{constructor(){this.name=It.id,this._statusChangeHandler=null,this._lastConnected=null}setupOnce(){const e=T();if(e){if(typeof e.getNetworkType=="function")try{e.getNetworkType({success:n=>{const r=n.networkType||"unknown";this._lastConnected=r!=="none",W("network",{type:r,isConnected:this._lastConnected})}})}catch(n){}typeof e.onNetworkStatusChange=="function"&&(this._statusChangeHandler=n=>{var i;const r=n.networkType||"unknown",s=n.isConnected!==void 0?n.isConnected:r!=="none";if(W("network",{type:r,isConnected:s}),k({category:"network.change",message:`网络状态变化: ${r}`,level:s?"info":"warning",data:{networkType:r,isConnected:s}}),s&&this._lastConnected===!1)try{(i=w())==null||i.flush()}catch(o){}this._lastConnected=s},e.onNetworkStatusChange(this._statusChangeHandler))}}cleanup(){if(this._statusChangeHandler){const e=T();if(e&&typeof e.offNetworkStatusChange=="function")try{e.offNetworkStatusChange(this._statusChangeHandler)}catch(n){}this._statusChangeHandler=null}}};It.id="NetworkStatus";let lt=It;const wt=class wt{constructor(){this.name=wt.id,this._initTs=ve(),this._initEpoch=hn(),this._showHandler=null,this._hideHandler=null,this._coldStartReported=!1,this._minigameContext={runtime:"minigame"}}setupOnce(){const e=T();if(e){if(typeof e.getLaunchOptionsSync=="function")try{const n=e.getLaunchOptionsSync()||{};this._minigameContext.scene=n.scene,this._minigameContext.path=n.path,this._minigameContext.query=n.query,W("minigame",l({},this._minigameContext)),k({category:"minigame.launch",message:"小游戏冷启动",level:"info",data:{scene:n.scene,path:n.path}})}catch(n){}this._measureColdStart(),typeof e.onShow=="function"&&(this._showHandler=n=>{k({category:"minigame.lifecycle",message:"小游戏 onShow(进入前台)",level:"info",data:{scene:n&&n.scene}})},e.onShow(this._showHandler)),typeof e.onHide=="function"&&(this._hideHandler=()=>{k({category:"minigame.lifecycle",message:"小游戏 onHide(退到后台)",level:"info"})},e.onHide(this._hideHandler))}}_measureColdStart(){const e=globalThis.requestAnimationFrame;typeof e=="function"&&e(()=>{if(this._coldStartReported)return;this._coldStartReported=!0;const n=ve(),r=Math.max(0,Math.round(n-this._initTs));this._minigameContext.coldStartMs=r,W("minigame",l({},this._minigameContext)),k({category:"minigame.performance",message:`SDK 初始化到首帧耗时: ${r}ms`,level:"info",data:{coldStartMs:r}});const s=Nt({name:"minigame.coldstart",op:"app.start",forceTransaction:!0,startTime:this._initEpoch/1e3});s.setAttributes({"minigame.scene":this._minigameContext.scene,"minigame.path":this._minigameContext.path,"minigame.cold_start_ms":r}),Q("cold_start",r,"millisecond",s),s.end((this._initEpoch+r)/1e3)})}cleanup(){const e=T();if(e){try{this._showHandler&&typeof e.offShow=="function"&&e.offShow(this._showHandler),this._hideHandler&&typeof e.offHide=="function"&&e.offHide(this._hideHandler)}catch(n){}this._showHandler=null,this._hideHandler=null}}};wt.id="Minigame";let ie=wt;const _u=()=>new ie,mu=["minor","major","severe"];function gu(t){if(!t)return[];const e=[];for(const n of mu){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&r>0&&e.push({name:n,threshold:r})}if(e.length===0)return[];for(let n=1;n<e.length;n++){const r=e[n-1],s=e[n];if(r&&s&&s.threshold<=r.threshold)return console.warn("[sentry-miniapp] jankLevels 阈值须按 minor < major < severe 严格递增,当前配置不满足,已忽略分级并回退到单档 longFrameThresholdMs。"),[]}return e}function yu(t,e){for(let n=t.length-1;n>=0;n--){const r=t[n];if(r&&e>r.threshold)return r.name}return null}function Su(t,e){var r;if(t.length===0)return e;const n=[...t].sort((s,i)=>s-i);return(r=n[Math.floor(.95*(n.length-1))])!=null?r:e}const F=class F{constructor(e={}){var r,s,i,o;this.name=F.id,this._running=!1,this._windowElapsed=0,this._lastFrameTs=0,this._frameCount=0,this._jankCount=0,this._jankBreadcrumbs=0,this._jankByTier={minor:0,major:0,severe:0},this._maxFrameDelta=0,this._sessionEpochStart=0,this._sessionElapsed=0,this._sessionFrames=0,this._sessionJank=0,this._sessionJankByTier={minor:0,major:0,severe:0},this._sessionWorstFrame=0,this._fpsSamples=[],this._showHandler=null,this._hideHandler=null,this._options={fpsWarningThreshold:(r=e.fpsWarningThreshold)!=null?r:30,longFrameThresholdMs:(s=e.longFrameThresholdMs)!=null?s:50,reportInterval:(i=e.reportInterval)!=null?i:1e4,maxJankBreadcrumbsPerWindow:(o=e.maxJankBreadcrumbsPerWindow)!=null?o:3},this._tiers=gu(e.jankLevels);const n=this._tiers[0];this._tiered=n!==void 0,this._jankEntryThreshold=n?n.threshold:this._options.longFrameThresholdMs}setupOnce(){const e=globalThis.requestAnimationFrame;if(typeof e!="function"){console.warn("[sentry-miniapp] requestAnimationFrame 不可用,小游戏帧率监控已跳过(小程序逻辑层不支持)");return}this._running=!0;const n=ve();this._lastFrameTs=n,this._sessionEpochStart=hn();const r=()=>{if(!this._running)return;const i=ve();this._onFrame(i-this._lastFrameTs),this._lastFrameTs=i,e(r)};e(r);const s=T();s&&typeof s.onHide=="function"&&(this._hideHandler=()=>{this._flushSummary()&&this._flushPendingEvents()},s.onHide(this._hideHandler)),s&&typeof s.onShow=="function"&&(this._showHandler=()=>this._restartOnResume(),s.onShow(this._showHandler))}_onFrame(e){const n=this._sanitizeFrameDelta(e);if(n===null){(!Number.isFinite(e)||e>F._MAX_REASONABLE_FRAME_DELTA_MS)&&this._rollupWindow();return}if(this._frameCount+=1,this._windowElapsed+=n,n>this._maxFrameDelta&&(this._maxFrameDelta=n),n>this._jankEntryThreshold){this._jankCount+=1;const r=this._tiered?yu(this._tiers,n):null;r&&(this._jankByTier[r]+=1),this._jankBreadcrumbs<this._options.maxJankBreadcrumbsPerWindow&&(this._jankBreadcrumbs+=1,k({category:"minigame.jank",message:`检测到卡顿帧: ${Math.round(n)}ms`,level:"warning",data:r?{frameDurationMs:Math.round(n),jankLevel:r}:{frameDurationMs:Math.round(n)}}))}this._windowElapsed>=this._options.reportInterval&&this._report()}_sanitizeFrameDelta(e){return!Number.isFinite(e)||e<=0||e>F._MAX_REASONABLE_FRAME_DELTA_MS?null:e}_report(){const e=this._rollupWindow();e&&(W("minigame.framerate",{fps:e.fps,minFps:e.minFps,worstFrameMs:e.worstFrameMs,jankCount:e.jankCount,frames:e.frames}),k({category:"minigame.framerate",message:`FPS: ${e.fps}(最低 ${e.minFps},卡顿 ${e.jankCount} 次)`,level:e.fps<this._options.fpsWarningThreshold?"warning":"info",data:e}))}_rollupWindow(){const e=this._windowElapsed;if(this._frameCount===0||e<=0)return this._resetWindow(),null;const n=Math.round(this._frameCount/e*1e3),r=this._maxFrameDelta>0?Math.round(1e3/this._maxFrameDelta):n,s={fps:n,minFps:r,worstFrameMs:Math.round(this._maxFrameDelta),jankCount:this._jankCount,frames:this._frameCount};return this._fpsSamples.push(n),this._fpsSamples.length>F._MAX_FPS_SAMPLES&&this._fpsSamples.shift(),this._sessionElapsed+=e,this._sessionFrames+=this._frameCount,this._sessionJank+=this._jankCount,this._sessionJankByTier.minor+=this._jankByTier.minor,this._sessionJankByTier.major+=this._jankByTier.major,this._sessionJankByTier.severe+=this._jankByTier.severe,this._maxFrameDelta>this._sessionWorstFrame&&(this._sessionWorstFrame=this._maxFrameDelta),this._resetWindow(),s}_resetWindow(){this._windowElapsed=0,this._frameCount=0,this._jankCount=0,this._jankBreadcrumbs=0,this._maxFrameDelta=0,this._jankByTier={minor:0,major:0,severe:0}}_resetSession(){this._sessionEpochStart=hn(),this._sessionElapsed=0,this._sessionFrames=0,this._sessionJank=0,this._sessionJankByTier={minor:0,major:0,severe:0},this._sessionWorstFrame=0,this._fpsSamples=[]}_restartOnResume(){this._resetSession();const e=ve();this._lastFrameTs=e,this._resetWindow()}_flushSummary(){if(this._rollupWindow(),this._sessionFrames===0)return!1;const e=this._sessionElapsed,n=e>0?Math.round(this._sessionFrames/e*1e3):0,r=this._sessionWorstFrame>0?Math.round(1e3/this._sessionWorstFrame):n,s=Su(this._fpsSamples,n),i=Math.round(this._sessionWorstFrame),o=this._sessionJank,c=this._sessionFrames,a=Nt({name:"minigame.framerate.summary",op:"ui.framerate",forceTransaction:!0,startTime:this._sessionEpochStart/1e3});if(a.setAttributes({"fps.avg":n,"fps.p95":s,"fps.min":r,"frames.total":c,"jank.count":o,"frame.worst_ms":i}),Q("fps_avg",n,"none",a),Q("fps_p95",s,"none",a),Q("fps_min",r,"none",a),Q("jank_count",o,"none",a),this._tiered){const u={};for(const d of this._tiers){const f=this._sessionJankByTier[d.name];u[`jank.${d.name}`]=f,Q(`jank_${d.name}_count`,f,"none",a)}a.setAttributes(u)}return a.end((this._sessionEpochStart+Math.max(0,e))/1e3),this._resetSession(),!0}_flushPendingEvents(){Promise.resolve(Ts(F._HIDE_FLUSH_TIMEOUT_MS)).catch(()=>{})}cleanup(){this._running=!1,this._flushSummary()&&this._flushPendingEvents();const e=T();if(e)try{this._hideHandler&&typeof e.offHide=="function"&&e.offHide(this._hideHandler),this._showHandler&&typeof e.offShow=="function"&&e.offShow(this._showHandler)}catch(n){}this._hideHandler=null,this._showHandler=null}};F.id="MinigameFrameRate",F._MAX_FPS_SAMPLES=2e3,F._MAX_REASONABLE_FRAME_DELTA_MS=5e3,F._HIDE_FLUSH_TIMEOUT_MS=2e3;let oe=F;const bu=t=>()=>new oe(t),Eu=Object.freeze(Object.defineProperty({__proto__:null,ConsoleBreadcrumbs:xe,Dedupe:rt,GlobalHandlers:Qe,HttpContext:nt,LinkedErrors:tt,MinigameFrameRateIntegration:oe,MinigameIntegration:ie,NetworkBreadcrumbs:ot,NetworkStatusIntegration:lt,PageBreadcrumbs:Pe,PerformanceIntegration:st,RewriteFrames:it,Router:gn,SessionIntegration:ut,System:mn,TryCatch:et,consoleBreadcrumbsIntegration:hu,minigameFrameRateIntegration:bu,minigameIntegration:_u,pageBreadcrumbsIntegration:fu,performanceIntegration:$n},Symbol.toStringTag,{value:"Module"}));function Bn(){return[new nt,new rt,new Qe,new et,new tt,$n({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!0,sampleRate:1,reportInterval:3e4})]}const vu=Bn();function Tu(t={}){if(!zs()){console.warn("[sentry-miniapp] Not running in a supported miniapp environment");return}const e=[...t.integrations||Bn()],n=v(l({},t),{integrations:e,stackParser:Bs,transport:t.transport});n.enableSourceMap!==!1&&n.integrations.push(new it);const r={traceNetworkBody:n.traceNetworkBody};n.enableTracePropagation!==void 0&&(r.enableTracePropagation=n.enableTracePropagation),n.tracePropagationTargets!==void 0&&(r.tracePropagationTargets=n.tracePropagationTargets),n.integrations.push(new ot(r)),n.enableAutoSessionTracking!==!1&&n.integrations.push(new ut);const s=n.enableNavigationBreadcrumbs!==!1,i=n.enableUserInteractionBreadcrumbs!==!1;(s||i)&&n.integrations.push(new Pe({enableLifecycle:s,enableUserInteraction:i})),n.enableNetworkStatusMonitoring!==!1&&n.integrations.push(new lt),n.enableConsoleBreadcrumbs&&n.integrations.push(new xe);const o=Bc(),c=a=>n.integrations.some(u=>u&&u.name===a);if(!c("EventFilters")&&!c("InboundFilters")){const a={};n.allowUrls&&(a.allowUrls=n.allowUrls),n.denyUrls&&(a.denyUrls=n.denyUrls),n.ignoreErrors&&(a.ignoreErrors=n.ignoreErrors),n.integrations.push(dc(a))}return!c(ie.id)&&(n.enableMinigameLifecycle===!0||o&&n.enableMinigameLifecycle!==!1)&&n.integrations.push(new ie),!c(oe.id)&&(n.enableMinigameFrameRate===!0||o&&n.enableMinigameFrameRate!==!1)&&n.integrations.push(new oe(n.minigameFrameRateOptions)),W("miniapp",{platform:qs(),environment:"miniapp"}),sc(Js,n),b().getClient()}function Iu(t={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}function wu(t){return function(...e){return fe(()=>{try{return t.apply(this,e)}catch(n){throw b().captureException(n),n}})}}function ku(t){var e,n,r;Nc(t),t&&((r=(n=(e=w())==null?void 0:e.getTransport())==null?void 0:n.flush)==null||r.call(n))}function Au(){return js()}function Ru(t){const e=b().getClient();return e?e.captureFeedback(t):(console.warn("[sentry-miniapp] No client available for captureFeedback"),"")}Fr();exports.Integrations=Eu;exports.MiniappClient=Js;exports.SDK_NAME=$s;exports.SDK_VERSION=ze;exports.Transports=Gc;exports.addBreadcrumb=k;exports.addEventProcessor=Ea;exports.addIntegration=Ra;exports.captureEvent=da;exports.captureException=ee;exports.captureFeedback=Ru;exports.captureMessage=pa;exports.captureSession=pn;exports.close=ba;exports.closeSession=Yr;exports.defaultIntegrations=vu;exports.endSession=Dt;exports.flush=Ts;exports.getClient=w;exports.getConsent=Au;exports.getCurrentScope=b;exports.getDefaultIntegrations=Bn;exports.getIsolationScope=R;exports.getPerformanceManager=Ws;exports.init=Tu;exports.isEnabled=Is;exports.lastEventId=Sa;exports.makeSession=Kr;exports.miniappStackParser=Bs;exports.performanceIntegration=$n;exports.setConsent=ku;exports.setContext=W;exports.setExtra=_a;exports.setExtras=ha;exports.setTag=ga;exports.setTags=ma;exports.setUser=ya;exports.showReportDialog=Iu;exports.startInactiveSpan=Nt;exports.startSession=ws;exports.startSpan=_e;exports.updateSession=J;exports.withScope=fe;exports.wrap=wu;
18
+ 详情参考:https://docs.sentry.io/platforms/javascript/`):console.warn("[sentry-miniapp] 未检测到已支持的小程序平台,SDK 将以降级模式运行"),{request:()=>{},httpRequest:()=>{},getSystemInfoSync:()=>({}),URLSearchParams:()=>{}};const e=t.sdk;t.name==="alipay"&&!e.request&&e.httpRequest&&(e.request=e.httpRequest);const n=e;if((t.name==="alipay"||t.name==="dingtalk")&&!n.__sentryStorageAdapted){if(e.getStorageSync){const r=e.getStorageSync;e.getStorageSync=s=>{const i=r.call(e,{key:s});return i?i.data:null}}if(e.setStorageSync){const r=e.setStorageSync;e.setStorageSync=(s,i)=>{r.call(e,{key:s,data:i})}}if(e.removeStorageSync){const r=e.removeStorageSync;e.removeStorageSync=s=>{r.call(e,{key:s})}}n.__sentryStorageAdapted=!0}return e},zs=()=>{var t,e;return(e=(t=Hs())==null?void 0:t.name)!=null?e:"unknown"},$c=()=>{try{const t=Fn(),e={};let n=!1;if(t.getAppBaseInfo){const s=t.getAppBaseInfo();Object.assign(e,s),n=!0}if(t.getWindowInfo){const s=t.getWindowInfo();Object.assign(e,s),n=!0}if(t.getDeviceInfo){const s=t.getDeviceInfo();Object.assign(e,s),n=!0}if(t.getAppAuthorizeSetting){const s=t.getAppAuthorizeSetting();e.albumAuthorized=s.albumAuthorized==="authorized",e.cameraAuthorized=s.cameraAuthorized==="authorized",e.locationAuthorized=s.locationAuthorized==="authorized",e.microphoneAuthorized=s.microphoneAuthorized==="authorized",e.notificationAuthorized=s.notificationAuthorized==="authorized"}if(t.getSystemSetting){const s=t.getSystemSetting();Object.assign(e,s)}if(n&&!!(e.brand||e.model||e.system))return e;if(t.getSystemInfoSync){const s=t.getSystemInfoSync();return!s.SDKVersion&&s.version&&(s.SDKVersion=s.version),s}return n?e:null}catch(t){return console.warn("[sentry-miniapp] Failed to get system info:",t),null}};let qt=null;const Ot=()=>(qt===null&&(qt=$c()),qt),Bc=()=>{var t,e;try{const n=Fn();if(n.getAccountInfoSync){const r=n.getAccountInfoSync();return{appId:((t=r==null?void 0:r.miniProgram)==null?void 0:t.appId)||"unknown",version:((e=r==null?void 0:r.miniProgram)==null?void 0:e.version)||"unknown"}}}catch(n){}return{appId:"unknown",version:"unknown"}};let Wt=null;const jc=()=>{if(Wt===null){const t=Bc();return(t.appId!=="unknown"||t.version!=="unknown")&&(Wt=t),t}return Wt},qs=()=>zs()!=="unknown";let Gt=null,Jt=null;const v=()=>(Gt===null&&(Gt=Fn()),Gt),Ws=()=>(Jt===null&&(Jt=zs()),Jt);let Kt=null;const Uc=()=>{if(Kt===null){const t=globalThis,e=typeof t.GameGlobal!="undefined",n=typeof t.App!="function"&&typeof t.Page!="function"&&typeof t.getCurrentPages!="function";Kt=qs()&&(e||n)}return Kt},Gs=()=>{try{const t=v();if(t.getPerformance&&typeof t.getPerformance=="function")return t.getPerformance()}catch(t){console.warn("Failed to get performance manager:",t)}return null},Te=()=>Date.now(),_n=()=>Date.now();function Js(t){const e=t.url;function n(r){return new Promise((s,i)=>{var c,a,u,d;const o={url:e,method:"POST",data:r.body,header:l({"Content-Type":"application/json"},r.headers),headers:l({"Content-Type":"application/json"},r.headers),timeout:1e4,success:f=>{const _=f.statusCode||f.status,p=f.header||f.headers||{};s({statusCode:_,headers:{"x-sentry-rate-limits":p["x-sentry-rate-limits"],"retry-after":p["retry-after"]}})},fail:f=>{i(new Error(`Network request failed: ${f.errMsg||f.errorMessage||f.message||"Unknown error"}`))}};v().request?(a=(c=v()).request)==null||a.call(c,o):v().httpRequest?(d=(u=v()).httpRequest)==null||d.call(u,o):i(new Error("No request method available in current miniapp environment"))})}return Ja(t,n)}const Hc=30,zc=864e5,Ln="sentry_offline_store",qc=900*1024;function mn(t){var d,f,_,p;const e=(d=t.offlineCacheLimit)!=null?d:Hc,n=(f=t.offlineCacheMaxAge)!=null?f:zc,r=(_=t.maxBytes)!=null?_:qc,s=(p=t.evictionMode)!=null?p:"error-priority",i=t.onDrop;function o(h,m){if(m>0&&typeof i=="function")try{i(h,m)}catch(S){}}function c(h){const m=Date.now(),S=h.filter(E=>m-E.timestamp<n);return o("age",h.length-S.length),S}function a(h,m){let S=0;for(;h.length>e;){if(s==="preserve-oldest")h.pop();else if(m==="push"){const E=h.findIndex(C=>!Yt(C.envelope));E>=0?h.splice(E,1):h.shift()}else{const E=Wc(h,C=>!Yt(C.envelope));E>=0?h.splice(E,1):h.pop()}S++}return S}function u(h){const m=v().setStorageSync;if(!m)return;let S=h,E=JSON.stringify(S),C=0;for(;S.length>0&&Jc(E)>r;){if(s==="preserve-oldest")S=S.slice(0,S.length-1);else{const A=S.findIndex(Le=>!Yt(Le.envelope)),P=A>=0?A:0;S=S.slice(0,P).concat(S.slice(P+1))}C++,E=JSON.stringify(S)}o("bytes",C);try{m(Ln,E)}catch(A){}}return{push:h=>O(null,null,function*(){try{const m=c(Vt());m.push({envelope:h,timestamp:Date.now()}),o("count",a(m,"push")),u(m)}catch(m){console.warn("[sentry-miniapp] Failed to push to offline store",m)}}),unshift:h=>O(null,null,function*(){try{const m=c(Vt());m.unshift({envelope:h,timestamp:Date.now()}),o("count",a(m,"unshift")),u(m)}catch(m){console.warn("[sentry-miniapp] Failed to unshift to offline store",m)}}),shift:()=>O(null,null,function*(){try{const h=Vt(),m=c(h);if(m.length===0){h.length>0&&u(m);return}const S=m.shift();return u(m),S==null?void 0:S.envelope}catch(h){console.warn("[sentry-miniapp] Failed to shift from offline store",h);return}})}}function Yt(t){try{return(t[1]||[]).some(n=>{var s;const r=(s=n[0])==null?void 0:s.type;return r==="event"||r==="error"})}catch(e){return!0}}function Wc(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}function Vt(){const t=v().getStorageSync;if(!t)return[];let e;try{e=t(Ln)}catch(n){return[]}if(!e)return[];try{const n=typeof e=="string"?JSON.parse(e):e;return Array.isArray(n)&&n.length>0?n[0]&&"envelope"in n[0]&&"timestamp"in n[0]?n:n.map(r=>({envelope:r,timestamp:Date.now()})):[]}catch(n){return Gc(),[]}}function Gc(){try{const t=v().removeStorageSync;t&&t(Ln)}catch(t){}}function Jc(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319?(e+=4,n++):e+=3}return e}const Kc=Object.freeze(Object.defineProperty({__proto__:null,createMiniappOfflineStore:mn,createMiniappTransport:Js},Symbol.toStringTag,{value:"Module"}));class Ks extends tc{constructor(e={}){Dc({required:e.requireConsent===!0,cacheLimit:e.consentCacheLimit,cacheMaxBytes:e.consentCacheMaxBytes,cacheMaxAge:e.consentCacheMaxAge,onDrop:e.onConsentCacheDrop}),super(T(l({},e),{transport:n=>{const r=e.transport?e.transport(n):Js(T(l({},n),{headers:{}}));return e.requireConsent===!0?Rr(()=>r)(T(l({},n),{createStore:s=>{var i;return mn(T(l({},s),{offlineCacheLimit:(i=e.consentCacheLimit)!=null?i:100,offlineCacheMaxAge:e.consentCacheMaxAge,maxBytes:e.consentCacheMaxBytes,evictionMode:"preserve-oldest",onDrop:Oc}))},shouldSend:()=>Us(),flushAtStartup:!0})):!e.transport&&e.enableOfflineCache!==!1?Rr(()=>r)(T(l({},n),{createStore:s=>mn(T(l({},s),{offlineCacheLimit:e.offlineCacheLimit,offlineCacheMaxAge:e.offlineCacheMaxAge})),flushAtStartup:!0})):r}}))}eventFromException(e){const n={type:e.name||"Error",value:e.message||String(e)};if(e.stack){const r=this.getOptions().stackParser;if(r&&typeof r=="function"){const s=r(e.stack,1);s.length&&(n.stacktrace={frames:s})}}return Promise.resolve({exception:{values:[n]},level:"error"})}eventFromMessage(e,n="info"){return Promise.resolve({message:e,level:n})}_prepareEvent(e,n,r){e.platform=e.platform||this.getOptions().platform||"javascript",e.sdk=T(l({},e.sdk),{name:Bs,packages:[...e.sdk&&e.sdk.packages||[],{name:"npm:@sentry/miniapp",version:ze}],version:ze}),e.contexts||(e.contexts={}),e.contexts.miniapp={platform:Ws(),sdk_version:ze};try{const s=r||b(),i=R();return Promise.resolve(super._prepareEvent(e,n||{},s,i)).then(o=>this._fillDefaultContexts(o))}catch(s){return this.getOptions().debug&&console.warn("[sentry-miniapp] _prepareEvent 兜底(scope 未就绪):",s),Promise.resolve(this._fillDefaultContexts(e))}}_fillDefaultContexts(e){if(!e||this.getOptions().enableSystemInfo===!1)return e;const n=Ot();e.contexts||(e.contexts={});const r=e.contexts;return r.device=l({brand:(n==null?void 0:n.brand)||"unknown",model:(n==null?void 0:n.model)||"unknown",screen_resolution:`${(n==null?void 0:n.screenWidth)||0}x${(n==null?void 0:n.screenHeight)||0}`,language:(n==null?void 0:n.language)||"unknown",version:(n==null?void 0:n.version)||"unknown",system:(n==null?void 0:n.system)||"unknown",platform:(n==null?void 0:n.platform)||"unknown"},r.device),r.os=l({name:(n==null?void 0:n.system)||"unknown",version:(n==null?void 0:n.version)||"unknown"},r.os),r.app=l({app_version:(n==null?void 0:n.SDKVersion)||"unknown"},r.app),e}close(e){const n=this.getOptions().integrations;if(Array.isArray(n))for(const r of n){const s=r.cleanup;if(typeof s=="function")try{s.call(r)}catch(i){this.getOptions().debug&&console.warn(`[sentry-miniapp] 集成 ${r.name} cleanup 失败:`,i)}if(Array.isArray(be)){const i=be.indexOf(r.name);i!==-1&&be.splice(i,1)}}return super.close(e)}showReportDialog(e={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}captureFeedback(e){const n={contexts:{feedback:{contact_email:e.email,name:e.name,message:e.message,url:e.url,source:e.source,associated_event_id:e.associatedEventId}},type:"feedback",level:"info",tags:e.tags||{}};return b().captureEvent(n)}}const ft=class ft{constructor(e){this.name=ft.id,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._onPageNotFoundHandlerInstalled=!1,this._onMemoryWarningHandlerInstalled=!1,this._errorHandler=null,this._rejectionHandler=null,this._pageNotFoundHandler=null,this._memoryWarningHandler=null,this._options=l({onerror:!0,onunhandledrejection:!0,onpagenotfound:!0,onmemorywarning:!0},e)}setupOnce(){Error.stackTraceLimit=50,this._options.onerror&&this._installGlobalOnErrorHandler(),this._options.onunhandledrejection&&this._installGlobalOnUnhandledRejectionHandler(),this._options.onpagenotfound&&this._installGlobalOnPageNotFoundHandler(),this._options.onmemorywarning&&this._installGlobalOnMemoryWarningHandler()}_installGlobalOnErrorHandler(){var e,n;this._onErrorHandlerInstalled||(v().onError&&(this._errorHandler=r=>{const s=typeof r=="string"?new Error(r):r;ee(s,{mechanism:{type:"onerror",handled:!1}})},(n=(e=v()).onError)==null||n.call(e,this._errorHandler)),this._onErrorHandlerInstalled=!0)}_installGlobalOnUnhandledRejectionHandler(){var e,n;this._onUnhandledRejectionHandlerInstalled||(v().onUnhandledRejection&&(this._rejectionHandler=({reason:r,promise:s})=>{const i=typeof r=="string"?new Error(r):r;ee(i,{mechanism:{type:"onunhandledrejection",handled:!1},data:{promise:s}})},(n=(e=v()).onUnhandledRejection)==null||n.call(e,this._rejectionHandler)),this._onUnhandledRejectionHandlerInstalled=!0)}_installGlobalOnPageNotFoundHandler(){var e,n;this._onPageNotFoundHandlerInstalled||(v().onPageNotFound&&(this._pageNotFoundHandler=r=>{const s=b(),i=r.path.split("?")[0];s.setTag("pagenotfound",i),s.setContext("page_not_found",{path:r.path,query:r.query,isEntryPage:r.isEntryPage}),ee(new Error(`页面无法找到: ${i}`),{mechanism:{type:"onpagenotfound",handled:!0}})},(n=(e=v()).onPageNotFound)==null||n.call(e,this._pageNotFoundHandler)),this._onPageNotFoundHandlerInstalled=!0)}_installGlobalOnMemoryWarningHandler(){var e,n;this._onMemoryWarningHandlerInstalled||(v().onMemoryWarning&&(this._memoryWarningHandler=({level:r=-1})=>{let s="没有获取到告警级别信息";switch(r){case 5:s="TRIM_MEMORY_RUNNING_MODERATE";break;case 10:s="TRIM_MEMORY_RUNNING_LOW";break;case 15:s="TRIM_MEMORY_RUNNING_CRITICAL";break;default:return}const i=b();i.setTag("memory-warning",String(r)),i.setContext("memory_warning",{level:r,message:s}),ee(new Error("内存不足告警"),{mechanism:{type:"onmemorywarning",handled:!0}})},(n=(e=v()).onMemoryWarning)==null||n.call(e,this._memoryWarningHandler)),this._onMemoryWarningHandlerInstalled=!0)}cleanup(){try{const e=v();this._errorHandler&&e.offError&&e.offError(this._errorHandler),this._rejectionHandler&&e.offUnhandledRejection&&e.offUnhandledRejection(this._rejectionHandler),this._pageNotFoundHandler&&e.offPageNotFound&&e.offPageNotFound(this._pageNotFoundHandler),this._memoryWarningHandler&&e.offMemoryWarning&&e.offMemoryWarning(this._memoryWarningHandler)}catch(e){}this._errorHandler=null,this._rejectionHandler=null,this._pageNotFoundHandler=null,this._memoryWarningHandler=null,this._onErrorHandlerInstalled=!1,this._onUnhandledRejectionHandlerInstalled=!1,this._onPageNotFoundHandlerInstalled=!1,this._onMemoryWarningHandlerInstalled=!1}};ft.id="GlobalHandlers";let Qe=ft;function Pr(t,e={},n){if(typeof t!="function")return t;try{if(t.__sentry__)return t;if(t.__sentry_wrapped__)return t.__sentry_wrapped__}catch(s){return t}const r=function(...s){try{return t.apply(this,s)}catch(i){throw fe(o=>{o.addEventProcessor(c=>T(l({},c),{extra:T(l({},c.extra),{arguments:s})})),ee(i,e.mechanism?{mechanism:e.mechanism}:void 0)}),i}};try{for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=t[s])}catch(s){}t.prototype=t.prototype||{},r.prototype=t.prototype,Object.defineProperty(t,"__sentry_wrapped__",{enumerable:!1,value:r}),Object.defineProperties(r,{__sentry__:{enumerable:!1,value:!0},__sentry_original__:{enumerable:!1,value:t}});try{Object.getOwnPropertyDescriptor(r,"name").configurable&&Object.defineProperty(r,"name",{get(){return t.name}})}catch(s){}return r}function Nr(t){try{return t&&t.name||"<anonymous>"}catch(e){return"<anonymous>"}}function ve(t,e,n){if(!(e in t))return;const r=t[e],s=n(r);if(typeof s=="function")try{s.prototype=s.prototype||{},s.prototype.constructor=s}catch(i){}t[e]=s}const pt=class pt{constructor(){this.name=pt.id}_wrapTimeFunction(e){return function(...n){const r=n[0];return n[0]=Pr(r,{mechanism:{data:{function:Nr(e)},handled:!0,type:"instrument"}}),e.apply(this,n)}}_wrapRAF(e){return function(n){return e(Pr(n,{mechanism:{data:{function:"requestAnimationFrame",handler:Nr(e)},handled:!0,type:"instrument"}}))}}setupOnce(){const e=globalThis;e.setTimeout&&ve(e,"setTimeout",this._wrapTimeFunction.bind(this)),e.setInterval&&ve(e,"setInterval",this._wrapTimeFunction.bind(this)),e.requestAnimationFrame&&ve(e,"requestAnimationFrame",this._wrapRAF.bind(this))}};pt.id="TryCatch";let et=pt;const Yc="cause",Vc=5,dt=class dt{constructor(e={}){this.name=dt.id,this._key=e.key||Yc,this._limit=e.limit||Vc}setupOnce(){}processEvent(e,n){return b().getClient()?this._handler(e,n):e}_handler(e,n){if(!e.exception||!e.exception.values||!n||!xr(n.originalException,Error))return e;const r=this._walkErrorTree(n.originalException,this._key);return e.exception.values=[...r,...e.exception.values],e}_walkErrorTree(e,n,r=[]){if(!xr(e[n],Error)||r.length+1>=this._limit)return r;const s=kc(()=>[],e[n]);return this._walkErrorTree(e[n],n,[s,...r])}};dt.id="LinkedErrors";let tt=dt;function xr(t,e){try{return t instanceof e}catch(n){return!1}}const ht=class ht{constructor(){this.name=ht.id}setupOnce(){}processEvent(e){var s,i;const n=this._getMiniappVersion(),r=jc();return e.contexts=T(l({},e.contexts),{runtime:T(l({},((s=e.contexts)==null?void 0:s.runtime)||{}),{name:"miniapp",version:n}),app:T(l({},((i=e.contexts)==null?void 0:i.app)||{}),{name:r.appId,version:r.version})}),e}_getMiniappVersion(){const e=Ot();return(e==null?void 0:e.version)||(e==null?void 0:e.SDKVersion)||"unknown"}};ht.id="HttpContext";let nt=ht;const _t=class _t{constructor(e={}){this.name=_t.id,this._fuzzyMatch=!!e.fuzzyMatch}setupOnce(){}processEvent(e,n){if(e.type)return e;try{if(this._shouldDropEvent(e,this._previousEvent))return null}catch(r){return this._previousEvent=this._cloneEventForComparison(e),e}return this._previousEvent=this._cloneEventForComparison(e),e}_shouldDropEvent(e,n){return n?!!(this._isSameMessageEvent(e,n)||this._isSameExceptionEvent(e,n)):!1}_isSameMessageEvent(e,n){const r=e.message,s=n.message;return!(!r&&!s||r&&!s||!r&&s||r!==s||!this._isSameFingerprint(e,n)||!this._isSameStacktrace(e,n))}_isSameExceptionEvent(e,n){const r=this._getExceptionFromEvent(e),s=this._getExceptionFromEvent(n);if(!r||!s||r.type!==s.type)return!1;if(this._fuzzyMatch){if(!Xc(r.value,s.value))return!1}else if(r.value!==s.value)return!1;return!(!this._isSameFingerprint(e,n)||!this._isSameStacktrace(e,n))}_isSameStacktrace(e,n){let r=this._getFramesFromEvent(e),s=this._getFramesFromEvent(n);if(!r&&!s)return!0;if(r&&!s||!r&&s||(r=r,s=s,s.length!==r.length))return!1;for(let i=0;i<s.length;i++){const o=s[i],c=r[i];if(o.filename!==c.filename||o.lineno!==c.lineno||o.colno!==c.colno||o.function!==c.function)return!1}return!0}_isSameFingerprint(e,n){let r=e.fingerprint,s=n.fingerprint;if(!r&&!s)return!0;if(r&&!s||!r&&s)return!1;r=r,s=s;try{return r.join("")===s.join("")}catch(i){return!1}}_getExceptionFromEvent(e){return e.exception&&e.exception.values&&e.exception.values[0]}_cloneEventForComparison(e){var n;return{message:e.message,fingerprint:e.fingerprint?[...e.fingerprint]:void 0,exception:e.exception?{values:(n=e.exception.values)==null?void 0:n.map(r=>{var s;return{type:r.type,value:r.value,stacktrace:r.stacktrace?{frames:(s=r.stacktrace.frames)==null?void 0:s.map(i=>l({},i))}:void 0}})}:void 0}}_getFramesFromEvent(e){const n=e.exception;if(n)try{return n.values[0].stacktrace.frames}catch(r){}}};_t.id="Dedupe";let rt=_t;const Dr=/\d{10,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/g;function Xc(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.replace(Dr,"<dynamic>"),r=e.replace(Dr,"<dynamic>");return n===r}const mt=class mt{constructor(){this.name=mt.id}setupOnce(){this._addSystemContext(),this._addNetworkContext(),this._addLocationContext(),this._addStorageContext(),this._checkAppUpdate()}_addSystemContext(){var e,n,r,s;try{const i=Ot();if(i){const o=b();o.setContext("device",{name:i.model,model:i.model,brand:i.brand,family:i.platform,arch:i.platform}),o.setContext("os",{name:((e=i.system)==null?void 0:e.split(" ")[0])||"unknown",version:((n=i.system)==null?void 0:n.split(" ")[1])||"unknown",kernel_version:i.version}),o.setContext("app",{app_name:i.appName||"unknown",app_version:i.version}),o.setContext("screen",{screen_width:i.screenWidth,screen_height:i.screenHeight,screen_density:i.pixelRatio}),o.setTag("device.model",i.model),o.setTag("device.brand",i.brand),o.setTag("os.name",((r=i.system)==null?void 0:r.split(" ")[0])||"unknown"),o.setTag("os.version",((s=i.system)==null?void 0:s.split(" ")[1])||"unknown"),o.setTag("app.version",i.version),o.setTag("language",i.language)}}catch(i){}}_addNetworkContext(){try{v().getNetworkType&&v().getNetworkType({success:e=>{const n=b();n.setContext("network",{type:e.networkType,connected:e.isConnected!==!1}),n.setTag("network.type",e.networkType)},fail:()=>{}})}catch(e){}}_addLocationContext(){try{v().getLocation&&v().getLocation({type:"gcj02",success:e=>{b().setContext("location",{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy})},fail:()=>{}})}catch(e){}}_addStorageContext(){try{const e=v();if(e&&typeof e.getStorageInfoSync=="function"){const n=e.getStorageInfoSync();if(n){const r=n.currentSize||0,s=n.limitSize||0,i=s>0?Math.round(r/s*100):0;b().setContext("storage",{currentSize:r,limitSize:s,usagePercent:i}),i>=80&&k({category:"storage.warning",message:`存储使用率 ${i}%(${r}KB / ${s}KB)`,level:"warning",data:{currentSize:r,limitSize:s,usagePercent:i}})}}}catch(e){}}_checkAppUpdate(){try{const e=v();if(e&&typeof e.getUpdateManager=="function"){const n=e.getUpdateManager();n&&(typeof n.onCheckForUpdate=="function"&&n.onCheckForUpdate(r=>{r&&r.hasUpdate&&(b().setTag("has_update","true"),k({category:"app.update",message:"检测到新版本可用",level:"info",data:{hasUpdate:!0}}))}),typeof n.onUpdateReady=="function"&&n.onUpdateReady(()=>{k({category:"app.update",message:"新版本已下载完成",level:"info",data:{updateReady:!0}})}))}}catch(e){}}};mt.id="System";let gn=mt;const gt=class gt{constructor(){this.name=gt.id,this._lastRoute="",this._monitorTimer=null}setupOnce(){this._instrumentNavigation(),this._startRouteMonitoring()}_instrumentNavigation(){let e;try{e=v()}catch(r){return}const n=["navigateTo","redirectTo","switchTab","reLaunch"];for(const r of n)if(e[r]){const s=e[r];e[r]=i=>(this._recordNavigation(r,i.url,this._getCurrentRoute()),s.call(e,i))}if(e.navigateBack){const r=e.navigateBack;e.navigateBack=(s={})=>(this._recordNavigation("navigateBack","back",this._getCurrentRoute(),s.delta),r.call(e,s))}}_startRouteMonitoring(){this._monitorTimer=setInterval(()=>{const e=this._getCurrentRoute();e&&e!==this._lastRoute&&(this._recordRouteChange(this._lastRoute,e),this._lastRoute=e)},1e3)}cleanup(){this._monitorTimer&&(clearInterval(this._monitorTimer),this._monitorTimer=null)}_getCurrentRoute(){try{const e=globalThis;if(e.getCurrentPages){const n=e.getCurrentPages();if(n&&n.length>0){const r=n[n.length-1];return r.route||r.__route__||""}}}catch(e){}return""}_recordNavigation(e,n,r,s){const i=b();k({category:"navigation",data:{action:e,from:r,to:n,delta:s},message:`Navigation ${e}: ${r} -> ${n}`,type:"navigation"}),i.setTag("route",n==="back"?r:n),i.setContext("navigation",{action:e,from:r,to:n,delta:s,timestamp:Date.now()})}_recordRouteChange(e,n){const r=b();k({category:"navigation",data:{from:e,to:n},message:`Route changed: ${e} -> ${n}`,type:"navigation"}),r.setTag("route",n),r.setContext("route",{current:n,previous:e,timestamp:Date.now()})}};gt.id="Router";let yn=gt;const yt=class yt{constructor(e={}){this.name=yt.id,this._performanceManager=null,this._observers=[],this._entryBuffer=[],this._reportTimer=null,this._options=T(l({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!1,sampleRate:1,bufferSize:100,reportInterval:3e4,enableMemory:!1},e),{thresholds:l({navigation:3e3,render:1e3,resource:2e3,setData:50},e==null?void 0:e.thresholds)})}setupOnce(){this._initializePerformanceManager(),this._setupPerformanceObservers(),this._startAutoReporting(),this._addPerformanceContext()}_initializePerformanceManager(){try{if(this._performanceManager=Gs(),!this._performanceManager){console.warn("[sentry-miniapp] Performance API not available");return}const e=b();e.setTag("performance.api.available",!0),e.setContext("performance",{api_version:"miniapp-1.0",sample_rate:this._options.sampleRate,buffer_size:this._options.bufferSize})}catch(e){console.warn("[sentry-miniapp] Failed to initialize performance manager:",e)}}_setupPerformanceObservers(){if(this._performanceManager)try{const e=[];this._options.enableNavigation&&e.push("navigation"),this._options.enableRender&&e.push("render"),this._options.enableResource&&e.push("resource");let n=this._options.enableUserTiming;if(n)try{const i=Ot();if(i&&i.platform==="devtools"&&(n=!1),n){const c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{}).PerformanceObserver,a=c&&Array.isArray(c.supportedEntryTypes)?c.supportedEntryTypes:void 0;(!a||!a.includes("measure")||!a.includes("mark"))&&(n=!1)}}catch(i){n=!1}if(n&&e.push("measure","mark"),e.length===0)return;const r=this._performanceManager.createObserver(i=>{this._handlePerformanceEntries(i)});try{r.observe({entryTypes:e})}catch(i){const o=e.filter(c=>c!=="measure"&&c!=="mark");if(o.length<e.length&&o.length>0)r.observe({entryTypes:o}),console.warn("[sentry-miniapp] Failed to observe all types, falling back to:",o),e.length=0,e.push(...o);else throw i}this._observers.push(r);const s=typeof globalThis!="undefined"?globalThis.process:void 0;s&&s.env&&s.env.NODE_ENV!=="production"&&console.log("[sentry-miniapp] Performance observers setup for:",e)}catch(e){console.warn("[sentry-miniapp] Failed to setup performance observers:",e)}}_handlePerformanceEntries(e){if(!e)return;let n;if(Array.isArray(e))n=e;else if(typeof e=="object"&&e.getEntries)n=e.getEntries();else if(typeof e=="object")n=[e];else{console.warn("[sentry-miniapp] Invalid entries format:",typeof e);return}n.length!==0&&(Math.random()>this._options.sampleRate||n.forEach(r=>{try{this._processPerformanceEntry(r),this._addToBuffer(r)}catch(s){console.warn("[sentry-miniapp] Failed to process performance entry:",s)}}))}_processPerformanceEntry(e){switch(e.entryType){case"navigation":this._processNavigationEntry(e);break;case"render":this._processRenderEntry(e);break;case"resource":this._processResourceEntry(e);break;case"measure":case"mark":this._processUserTimingEntry(e);break;default:console.log("[sentry-miniapp] Unknown entry type:",e.entryType)}}_processNavigationEntry(e){b().addBreadcrumb({message:`页面导航: ${e.name}`,category:"performance.navigation",level:"info",data:{duration:e.duration,appLaunchTime:e.appLaunchTime,pageReadyTime:e.pageReadyTime}}),_e({name:`Navigation: ${e.name}`,op:"navigation",startTime:e.startTime/1e3},r=>{r.setAttributes({"navigation.name":e.name,"navigation.duration":e.duration,"navigation.app_launch_time":e.appLaunchTime||0,"navigation.page_ready_time":e.pageReadyTime||0,"navigation.first_render_time":e.firstRenderTime||0}),r.end((e.startTime+e.duration)/1e3)})}_processRenderEntry(e){var r,s;_e({name:`Render: ${e.name}`,op:"render",startTime:e.startTime/1e3},i=>{i.setAttributes({"render.name":e.name,"render.duration":e.duration,"render.start":e.renderStart||0,"render.end":e.renderEnd||0,"render.script_start":e.scriptStart||0,"render.script_end":e.scriptEnd||0}),i.end((e.startTime+e.duration)/1e3)});const n=(s=(r=this._options.thresholds)==null?void 0:r.setData)!=null?s:50;e.duration>n&&b().addBreadcrumb({message:`慢渲染检测: ${e.name} (${e.duration.toFixed(1)}ms)`,category:"performance.setData.slow",level:"warning",data:{name:e.name,duration:e.duration,threshold:n,renderStart:e.renderStart,renderEnd:e.renderEnd,scriptStart:e.scriptStart,scriptEnd:e.scriptEnd}})}_processResourceEntry(e){_e({name:`Resource: ${e.name}`,op:"resource",startTime:e.startTime/1e3},n=>{n.setAttributes({"resource.name":e.name,"resource.duration":e.duration,"resource.type":e.initiatorType||"unknown","resource.transfer_size":e.transferSize||0,"resource.encoded_size":e.encodedBodySize||0,"resource.decoded_size":e.decodedBodySize||0}),e.fetchStart&&e.responseEnd&&n.setAttributes({"resource.fetch_start":e.fetchStart,"resource.response_end":e.responseEnd,"resource.network_time":e.responseEnd-e.fetchStart}),n.end((e.startTime+e.duration)/1e3)})}_processUserTimingEntry(e){e.entryType==="measure"?_e({name:`Measure: ${e.name}`,op:"measure",startTime:e.startTime/1e3},n=>{n.setAttributes({"measure.name":e.name,"measure.duration":e.duration,"measure.detail":e.detail?JSON.stringify(e.detail):void 0}),n.end((e.startTime+e.duration)/1e3)}):e.entryType==="mark"&&b().addBreadcrumb({message:`性能标记: ${e.name}`,category:"performance.mark",level:"info",data:{timestamp:e.startTime,detail:e.detail}})}_addToBuffer(e){for(this._entryBuffer.push(e);this._entryBuffer.length>this._options.bufferSize;)this._entryBuffer.shift()}_startAutoReporting(){this._options.reportInterval<=0||(this._reportTimer=setInterval(()=>{this._reportBufferedEntries()},this._options.reportInterval))}_reportBufferedEntries(){if(this._entryBuffer.length!==0)try{const e=b(),n=this._calculatePerformanceStats(),r=this._collectMemoryInfo();r&&(n.memory=r),e.setContext("performance_summary",l({total_entries:this._entryBuffer.length,navigation_count:this._entryBuffer.filter(s=>s.entryType==="navigation").length,render_count:this._entryBuffer.filter(s=>s.entryType==="render").length,resource_count:this._entryBuffer.filter(s=>s.entryType==="resource").length,measure_count:this._entryBuffer.filter(s=>s.entryType==="measure").length,mark_count:this._entryBuffer.filter(s=>s.entryType==="mark").length,report_time:new Date().toISOString()},n)),this._checkPerformanceThresholds(n),this._reportToNativeAPI(),this._entryBuffer=[]}catch(e){console.warn("[sentry-miniapp] Failed to report buffered entries:",e)}}_calculatePerformanceStats(){const e=this._entryBuffer.filter(i=>i.entryType==="navigation"),n=this._entryBuffer.filter(i=>i.entryType==="render"),r=this._entryBuffer.filter(i=>i.entryType==="resource"),s={};if(e.length>0){const i=e.map(o=>o.duration);s.navigation_stats={avg_duration:i.reduce((o,c)=>o+c,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)}}if(n.length>0){const i=n.map(c=>c.duration);s.render_stats={avg_duration:i.reduce((c,a)=>c+a,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)};const o=n.filter(c=>{var a,u;return c.duration>((u=(a=this._options.thresholds)==null?void 0:a.setData)!=null?u:50)});s.render_stats.slow_render_count=o.length,s.render_stats.slow_render_ratio=o.length/n.length}if(r.length>0){const i=r.map(c=>c.duration),o=r.map(c=>c.transferSize||0).filter(c=>c>0);s.resource_stats={avg_load_time:i.reduce((c,a)=>c+a,0)/i.length,max_load_time:Math.max(...i),total_transfer_size:o.reduce((c,a)=>c+a,0),avg_transfer_size:o.length>0?o.reduce((c,a)=>c+a,0)/o.length:0}}return s}_checkPerformanceThresholds(e){var o,c,a,u,d,f,_,p,h;const n=b(),r=(c=(o=this._options.thresholds)==null?void 0:o.navigation)!=null?c:3e3;((a=e.navigation_stats)==null?void 0:a.avg_duration)>r&&n.addBreadcrumb({message:"页面导航性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.navigation_stats.avg_duration,threshold:r}});const s=(d=(u=this._options.thresholds)==null?void 0:u.render)!=null?d:1e3;((f=e.render_stats)==null?void 0:f.avg_duration)>s&&n.addBreadcrumb({message:"页面渲染性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.render_stats.avg_duration,threshold:s}});const i=(p=(_=this._options.thresholds)==null?void 0:_.resource)!=null?p:2e3;((h=e.resource_stats)==null?void 0:h.avg_load_time)>i&&n.addBreadcrumb({message:"资源加载性能较慢",category:"performance.warning",level:"warning",data:{avg_load_time:e.resource_stats.avg_load_time,threshold:i}})}_reportToNativeAPI(){try{const e=v();if(e.reportPerformance&&this._entryBuffer.length>0){const n={entries:this._entryBuffer.map(r=>({name:r.name,entryType:r.entryType,startTime:r.startTime,duration:r.duration})),timestamp:Date.now(),sampleRate:this._options.sampleRate};e.reportPerformance(n)}}catch(e){console.warn("[sentry-miniapp] Failed to report to native API:",e)}}_collectMemoryInfo(){if(!this._options.enableMemory)return null;try{const e=v();if(e.getPerformance){const n=e.getPerformance();if(n&&n.memory)return{jsHeapSizeUsed:n.memory.jsHeapSizeUsed,jsHeapSizeLimit:n.memory.jsHeapSizeLimit}}}catch(e){}return null}_addPerformanceContext(){try{const e=b(),n=v(),r=!!n.getPerformance,s=!!n.reportPerformance;e.setContext("performance_support",{has_performance_api:r,has_report_api:s,integration_enabled:!0,options:this._options}),e.setTag("performance.integration","enabled")}catch(e){console.warn("[sentry-miniapp] Failed to add performance context:",e)}}cleanup(){this._observers.forEach(e=>{try{e.disconnect()}catch(n){console.warn("[sentry-miniapp] Failed to disconnect observer:",n)}}),this._observers=[],this._reportTimer&&(clearInterval(this._reportTimer),this._reportTimer=null),this._reportBufferedEntries()}};yt.id="PerformanceAPI";let st=yt;const $n=t=>()=>new st(t),St=class St{constructor(e={}){this.name=St.id,this._prefix=e.prefix||"app:///"}setupOnce(){}processEvent(e){return e.exception&&e.exception.values&&e.exception.values.forEach(n=>{n.stacktrace&&n.stacktrace.frames&&n.stacktrace.frames.forEach(r=>{r.filename&&(r.filename=this._normalizeFilename(r.filename))})}),e}_normalizeFilename(e){let n=e;return n=n.replace(/^(appservice|app-service|WAService)\//i,"").replace(/^https?:\/\/[^/]+\//i,"").replace(/^[a-z]+:\/\//i,"").replace(/^\//,""),n.startsWith(this._prefix)?n:`${this._prefix}${n}`}};St.id="RewriteFrames";let it=St;const bt=class bt{constructor(e={}){this.name=bt.id,this._originalRequest=null,this._originalHttpRequest=null,this._traceNetworkBody=!!e.traceNetworkBody,this._sensitiveKeys=(e.sensitiveKeys||["password","passwd","secret","token","access_token","refresh_token","authorization","cookie","session","creditcard","credit_card","card_number","cvv","ssn","id_card"]).map(n=>n.toLowerCase()),this._denyUrls=(e.denyBodyUrls||[]).map(n=>typeof n=="string"?new RegExp(n):n),this._enableTracePropagation=e.enableTracePropagation!==!1,this._tracePropagationTargets=e.tracePropagationTargets||[]}setupOnce(){const e=v();e&&typeof e.request=="function"&&(this._originalRequest=e.request,ve(e,"request",this._createRequestWrapper.bind(this))),e&&typeof e.httpRequest=="function"&&(this._originalHttpRequest=e.httpRequest,ve(e,"httpRequest",this._createRequestWrapper.bind(this)))}cleanup(){const e=v();e&&(this._originalRequest&&typeof e.request=="function"&&(e.request=this._originalRequest),this._originalHttpRequest&&typeof e.httpRequest=="function"&&(e.httpRequest=this._originalHttpRequest)),this._originalRequest=null,this._originalHttpRequest=null}_createRequestWrapper(e){const n=this._traceNetworkBody,r=this._sanitizeBody.bind(this),s=this._shouldDenyBodyUrl.bind(this),i=this._enableTracePropagation,o=this._shouldPropagateTrace.bind(this);return function(c){if(!c||typeof c!="object")return e.call(this,c);const a=su(c.url),u=w();let d="";if(u){const I=u.getOptions().dsn;if(I)try{const N=I.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n]+)/i);N&&N[1]&&(d=N[1])}catch(N){}}const f=a.match(/^https?:\/\/([^:/\n]+)/i),_=f&&f[1]?f[1]:"";if(d&&_===d||_==="sentry.io"||_.endsWith(".sentry.io"))return e.call(this,c);const h=iu(c.method),m=c.data,S=Date.now(),E=Zc(h,a);let C=!1;const A=I=>{C||(C=!0,ru(E,I))};i&&o(a)&&nu(c,E);const P={url:a,method:h};if(n&&m&&!s(a))try{const I=typeof m=="string"?m:JSON.stringify(m);P.request_body=r(I),P.request_size=I.length}catch(I){P.request_body="[Cannot serialize request body]"}const Le=c.success,jn=c.fail,Un=c.complete;c.success=function(...I){const N=I[0]||{},j=Mr(N),de=Date.now()-S;if(P.status_code=j,P.duration=de,A({statusCode:j,status:Xt(j)?"error":"ok"}),n&&N.data&&!s(a))try{const Ft=typeof N.data=="string"?N.data:JSON.stringify(N.data);P.response_body=r(Ft),P.response_size=Ft.length}catch(Ft){P.response_body="[Cannot serialize response body]"}const Zs=Xt(j)||de>3e3?"warning":"info";if(k({type:"http",category:"xhr",data:P,level:Zs}),typeof Le=="function")return Le.apply(this,I)},c.fail=function(...I){const N=I[0]||{},j=Date.now()-S,de=N.errMsg||N.errorMessage||"Network request failed";if(P.error=de,P.duration=j,A({status:"error",errorMessage:de}),k({type:"http",category:"xhr",data:P,level:"error"}),typeof jn=="function")return jn.apply(this,I)},c.complete=function(...I){const N=I[0]||{},j=Mr(N);if(A({statusCode:j,status:Xt(j)?"error":"ok"}),typeof Un=="function")return Un.apply(this,I)};try{return e.call(this,c)}catch(I){throw A({status:"error",errorMessage:I instanceof Error?I.message:String(I)}),I}}}_shouldPropagateTrace(e){return this._tracePropagationTargets.length===0?!0:this._tracePropagationTargets.some(n=>{if(typeof n=="string")return e.includes(n);n.lastIndex=0;const r=n.test(e);return n.lastIndex=0,r})}_shouldDenyBodyUrl(e){return this._denyUrls.some(n=>n.test(e))}_sanitizeBody(e){if(this._sensitiveKeys.length===0)return e;try{const n=JSON.parse(e);if(typeof n=="object"&&n!==null)return this._sanitizeObject(n),JSON.stringify(n)}catch(n){for(const r of this._sensitiveKeys){const s=new RegExp(`(${r})=[^&]*`,"gi");e=e.replace(s,"$1=[Filtered]")}}return e}_sanitizeObject(e){for(const n of Object.keys(e))this._sensitiveKeys.includes(n.toLowerCase())?e[n]="[Filtered]":typeof e[n]=="object"&&e[n]!==null&&this._sanitizeObject(e[n])}};bt.id="NetworkBreadcrumbs";let ot=bt;function Zc(t,e){try{const n=au(e);return xt({name:`${t} ${Qc(e)}`,op:"http.client",kind:2,attributes:{"http.request.method":t,"url.full":e,"server.address":n||void 0}})}catch(n){return null}}function Qc(t){return t.startsWith("data:")?tu(t):eu(t).replace(/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]+@)/i,"$1[filtered]:[filtered]@")}function eu(t){const e=t.split(/[?#]/,1)[0];return e===void 0?t:e}function tu(t){const e=t.match(/^data:([^;,]+)/);return`data:${e&&e[1]?e[1]:"text/plain"}`}function nu(t,e){if(e)try{const n=uc({span:e}),r=n["sentry-trace"];if(!r)return;const s=l(l({},Or(t.headers)?t.headers:{}),Or(t.header)?t.header:{});s["sentry-trace"]||(s["sentry-trace"]=r),n.baggage&&(s.baggage=ou(s.baggage,n.baggage)),t.header=s,t.headers=s}catch(n){}}function ru(t,e){if(t)try{const n=Ys(e.statusCode);n!==void 0?Ki(t,n):t.setStatus({code:e.status==="error"?x:Pt,message:e.status==="error"?e.errorMessage||"error":"ok"}),e.errorMessage&&t.setAttribute("error.message",e.errorMessage),t.end()}catch(n){}}function su(t){return typeof t=="string"?t:t==null?"":String(t)}function iu(t){return typeof t=="string"&&t.trim()!==""?t.toUpperCase():"GET"}function Mr(t){if(!(!t||typeof t!="object"))return t.statusCode!==void 0&&t.statusCode!==null?t.statusCode:t.status}function Xt(t){const e=Ys(t);return e!==void 0&&e>=400}function Or(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ou(t,e){const n=typeof t=="string"?t:Array.isArray(t)?t.filter(s=>typeof s=="string").join(","):"";return n?n.split(",").some(s=>s.trim().startsWith("sentry-"))?n:`${n},${e}`:e}function Ys(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""){const e=Number(t);if(Number.isFinite(e))return e}}function au(t){try{const e=t.match(/^https?:\/\/([^:/\n]+)/i);return e&&e[1]?e[1]:""}catch(e){return""}}const cu=["onLaunch","onShow","onHide","onError"],at=new Set;let qe=null,ct=!1;function uu(t,e){for(const n of[...at]){const r=n[t];if(typeof r=="function")try{r(e)}catch(s){}}}function lu(){const t=globalThis;if(ct||typeof t.App!="function")return;const e=t.App;qe=e;const n=function(r={}){if(r&&typeof r=="object")for(const s of cu){const i=r[s];r[s]=function(...o){if(uu(s,o[0]),typeof i=="function")return i.apply(this,o)}}return e.call(this,r)};n.__sentryAppWrapper=!0,t.App=n,ct=!0}function fu(){if(!ct||at.size>0)return;const t=globalThis;t.App&&t.App.__sentryAppWrapper&&qe&&(t.App=qe),qe=null,ct=!1}function Vs(t){if(typeof globalThis.App!="function")return()=>{};at.add(t),lu();let e=!0;return()=>{e&&(e=!1,at.delete(t),fu())}}const Xs=["onLoad","onShow","onHide","onUnload","onReady"];function pu(t){return Xs.includes(t)||t.startsWith("_")?!1:/^(on|handle|bind)[A-Z]/.test(t)||/[Tt]ap$/.test(t)||/[Cc]lick$/.test(t)||/[Cc]hange$/.test(t)||/[Ss]ubmit$/.test(t)||/[Ss]croll$/.test(t)||/[Ii]nput$/.test(t)}const Et=class Et{constructor(e={}){this.name=Et.id,this._originalPage=null,this._wrappedPage=null,this._unsubscribeApp=null,this._launchTime=0,this._firstPageReady=!1,this._options=l({enableLifecycle:!0,enableUserInteraction:!0},e)}setupOnce(){this._wrapPage(),this._subscribeApp()}_wrapPage(){const e=globalThis;if(typeof e.Page!="function"||e.Page.__sentryPageWrapper)return;this._originalPage=e.Page;const n=e.Page,r=this._options,s=()=>this._firstPageReady,i=a=>{this._firstPageReady=a},o=()=>this._launchTime,c=function(a){if(a&&typeof a=="object"){if(r.enableLifecycle){for(const u of Xs)if(typeof a[u]=="function"){const d=a[u];a[u]=function(...f){const _=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",p={action:u,page:_};if(u==="onLoad"&&f[0]&&typeof f[0]=="object"&&(p.query=f[0]),u==="onReady"&&!s()&&o()>0){i(!0);const h=Date.now()-o();p.coldStartDuration=h,W("startup",{coldStartDuration:h,firstPage:_})}return k({category:"page.lifecycle",message:`${u}: ${_}`,level:"info",data:p}),d.apply(this,f)}}}if(r.enableUserInteraction){for(const u of Object.keys(a))if(typeof a[u]=="function"&&pu(u)){const d=a[u];a[u]=function(f,..._){const p=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",h={handler:u,page:p};if(f&&typeof f=="object"&&(f.target&&(f.target.id&&(h.targetId=f.target.id),f.target.dataset&&(h.dataset=f.target.dataset)),f.type&&(h.eventType=f.type),f.detail&&(typeof f.detail.x=="number"&&(h.x=f.detail.x),typeof f.detail.y=="number"&&(h.y=f.detail.y)),f.touches&&f.touches.length>0)){const m=f.touches[0];m&&(h.touchX=m.pageX,h.touchY=m.pageY)}return k({category:"user.interaction",message:`${u} on ${p}`,level:"info",data:h}),d.apply(this,[f,..._])}}}}return n(a)};Object.defineProperty(c,"__sentryPageWrapper",{value:!0,configurable:!0}),this._wrappedPage=c,e.Page=c}_subscribeApp(){this._options.enableLifecycle&&(this._unsubscribeApp=Vs({onLaunch:()=>{this._launchTime=Date.now(),this._appBreadcrumb("onLaunch")},onShow:()=>this._appBreadcrumb("onShow"),onHide:()=>this._appBreadcrumb("onHide")}))}_appBreadcrumb(e){k({category:"app.lifecycle",message:`App.${e}`,level:"info",data:{action:e}})}cleanup(){const e=globalThis;this._originalPage&&(e.Page===this._wrappedPage&&(e.Page=this._originalPage),this._originalPage=null,this._wrappedPage=null),this._unsubscribeApp&&(this._unsubscribeApp(),this._unsubscribeApp=null)}};Et.id="PageBreadcrumbs";let Pe=Et;const du=t=>new Pe(t),hu=["debug","info","warn","error","log"],_u={debug:"debug",info:"info",log:"info",warn:"warning",error:"error"},Tt=class Tt{constructor(e={}){this.name=Tt.id,this._originalMethods={},this._levels=e.levels||[...hu]}setupOnce(){for(const e of this._levels){if(typeof console[e]!="function")continue;const n=console[e];this._originalMethods[e]=n,console[e]=function(...r){return k({category:"console",level:_u[e],message:r.map(s=>{if(typeof s=="string")return s;try{return JSON.stringify(s)}catch(i){return String(s)}}).join(" ")}),n.apply(console,r)}}}cleanup(){for(const e of this._levels){const n=this._originalMethods[e];n&&(console[e]=n)}this._originalMethods={}}};Tt.id="ConsoleBreadcrumbs";let Ne=Tt;const mu=t=>new Ne(t),vt=class vt{constructor(){this.name=vt.id,this._isSessionActive=!1,this._unsubscribe=null}setupOnce(){this._unsubscribe=Vs({onLaunch:()=>this._startSession(),onShow:()=>{this._isSessionActive||this._startSession()},onHide:()=>this._endSession()})}_startSession(){try{ks({ignoreDuration:!0}),dn(),this._isSessionActive=!0}catch(e){}}_endSession(){try{Mt(),dn(),this._isSessionActive=!1}catch(e){}}cleanup(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null),this._isSessionActive=!1}};vt.id="Session";let ut=vt;const It=class It{constructor(){this.name=It.id,this._statusChangeHandler=null,this._lastConnected=null}setupOnce(){const e=v();if(e){if(typeof e.getNetworkType=="function")try{e.getNetworkType({success:n=>{const r=n.networkType||"unknown";this._lastConnected=r!=="none",W("network",{type:r,isConnected:this._lastConnected})}})}catch(n){}typeof e.onNetworkStatusChange=="function"&&(this._statusChangeHandler=n=>{var i;const r=n.networkType||"unknown",s=n.isConnected!==void 0?n.isConnected:r!=="none";if(W("network",{type:r,isConnected:s}),k({category:"network.change",message:`网络状态变化: ${r}`,level:s?"info":"warning",data:{networkType:r,isConnected:s}}),s&&this._lastConnected===!1)try{(i=w())==null||i.flush()}catch(o){}this._lastConnected=s},e.onNetworkStatusChange(this._statusChangeHandler))}}cleanup(){if(this._statusChangeHandler){const e=v();if(e&&typeof e.offNetworkStatusChange=="function")try{e.offNetworkStatusChange(this._statusChangeHandler)}catch(n){}this._statusChangeHandler=null}}};It.id="NetworkStatus";let lt=It;const wt=class wt{constructor(){this.name=wt.id,this._initTs=Te(),this._initEpoch=_n(),this._showHandler=null,this._hideHandler=null,this._coldStartReported=!1,this._minigameContext={runtime:"minigame"}}setupOnce(){const e=v();if(e){if(typeof e.getLaunchOptionsSync=="function")try{const n=e.getLaunchOptionsSync()||{};this._minigameContext.scene=n.scene,this._minigameContext.path=n.path,this._minigameContext.query=n.query,W("minigame",l({},this._minigameContext)),k({category:"minigame.launch",message:"小游戏冷启动",level:"info",data:{scene:n.scene,path:n.path}})}catch(n){}this._measureColdStart(),typeof e.onShow=="function"&&(this._showHandler=n=>{k({category:"minigame.lifecycle",message:"小游戏 onShow(进入前台)",level:"info",data:{scene:n&&n.scene}})},e.onShow(this._showHandler)),typeof e.onHide=="function"&&(this._hideHandler=()=>{k({category:"minigame.lifecycle",message:"小游戏 onHide(退到后台)",level:"info"})},e.onHide(this._hideHandler))}}_measureColdStart(){const e=globalThis.requestAnimationFrame;typeof e=="function"&&e(()=>{if(this._coldStartReported)return;this._coldStartReported=!0;const n=Te(),r=Math.max(0,Math.round(n-this._initTs));this._minigameContext.coldStartMs=r,W("minigame",l({},this._minigameContext)),k({category:"minigame.performance",message:`SDK 初始化到首帧耗时: ${r}ms`,level:"info",data:{coldStartMs:r}});const s=xt({name:"minigame.coldstart",op:"app.start",forceTransaction:!0,startTime:this._initEpoch/1e3});s.setAttributes({"minigame.scene":this._minigameContext.scene,"minigame.path":this._minigameContext.path,"minigame.cold_start_ms":r}),Q("cold_start",r,"millisecond",s),s.end((this._initEpoch+r)/1e3)})}cleanup(){const e=v();if(e){try{this._showHandler&&typeof e.offShow=="function"&&e.offShow(this._showHandler),this._hideHandler&&typeof e.offHide=="function"&&e.offHide(this._hideHandler)}catch(n){}this._showHandler=null,this._hideHandler=null}}};wt.id="Minigame";let ie=wt;const gu=()=>new ie,yu=["minor","major","severe"];function Su(t){if(!t)return[];const e=[];for(const n of yu){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&r>0&&e.push({name:n,threshold:r})}if(e.length===0)return[];for(let n=1;n<e.length;n++){const r=e[n-1],s=e[n];if(r&&s&&s.threshold<=r.threshold)return console.warn("[sentry-miniapp] jankLevels 阈值须按 minor < major < severe 严格递增,当前配置不满足,已忽略分级并回退到单档 longFrameThresholdMs。"),[]}return e}function bu(t,e){for(let n=t.length-1;n>=0;n--){const r=t[n];if(r&&e>r.threshold)return r.name}return null}function Eu(t,e){var r;if(t.length===0)return e;const n=[...t].sort((s,i)=>s-i);return(r=n[Math.floor(.95*(n.length-1))])!=null?r:e}const F=class F{constructor(e={}){var r,s,i,o;this.name=F.id,this._running=!1,this._windowElapsed=0,this._lastFrameTs=0,this._frameCount=0,this._jankCount=0,this._jankBreadcrumbs=0,this._jankByTier={minor:0,major:0,severe:0},this._maxFrameDelta=0,this._sessionEpochStart=0,this._sessionElapsed=0,this._sessionFrames=0,this._sessionJank=0,this._sessionJankByTier={minor:0,major:0,severe:0},this._sessionWorstFrame=0,this._fpsSamples=[],this._showHandler=null,this._hideHandler=null,this._options={fpsWarningThreshold:(r=e.fpsWarningThreshold)!=null?r:30,longFrameThresholdMs:(s=e.longFrameThresholdMs)!=null?s:50,reportInterval:(i=e.reportInterval)!=null?i:1e4,maxJankBreadcrumbsPerWindow:(o=e.maxJankBreadcrumbsPerWindow)!=null?o:3},this._tiers=Su(e.jankLevels);const n=this._tiers[0];this._tiered=n!==void 0,this._jankEntryThreshold=n?n.threshold:this._options.longFrameThresholdMs}setupOnce(){const e=globalThis.requestAnimationFrame;if(typeof e!="function"){console.warn("[sentry-miniapp] requestAnimationFrame 不可用,小游戏帧率监控已跳过(小程序逻辑层不支持)");return}this._running=!0;const n=Te();this._lastFrameTs=n,this._sessionEpochStart=_n();const r=()=>{if(!this._running)return;const i=Te();this._onFrame(i-this._lastFrameTs),this._lastFrameTs=i,e(r)};e(r);const s=v();s&&typeof s.onHide=="function"&&(this._hideHandler=()=>{this._flushSummary()&&this._flushPendingEvents()},s.onHide(this._hideHandler)),s&&typeof s.onShow=="function"&&(this._showHandler=()=>this._restartOnResume(),s.onShow(this._showHandler))}_onFrame(e){const n=this._sanitizeFrameDelta(e);if(n===null){(!Number.isFinite(e)||e>F._MAX_REASONABLE_FRAME_DELTA_MS)&&this._rollupWindow();return}if(this._frameCount+=1,this._windowElapsed+=n,n>this._maxFrameDelta&&(this._maxFrameDelta=n),n>this._jankEntryThreshold){this._jankCount+=1;const r=this._tiered?bu(this._tiers,n):null;r&&(this._jankByTier[r]+=1),this._jankBreadcrumbs<this._options.maxJankBreadcrumbsPerWindow&&(this._jankBreadcrumbs+=1,k({category:"minigame.jank",message:`检测到卡顿帧: ${Math.round(n)}ms`,level:"warning",data:r?{frameDurationMs:Math.round(n),jankLevel:r}:{frameDurationMs:Math.round(n)}}))}this._windowElapsed>=this._options.reportInterval&&this._report()}_sanitizeFrameDelta(e){return!Number.isFinite(e)||e<=0||e>F._MAX_REASONABLE_FRAME_DELTA_MS?null:e}_report(){const e=this._rollupWindow();e&&(W("minigame.framerate",{fps:e.fps,minFps:e.minFps,worstFrameMs:e.worstFrameMs,jankCount:e.jankCount,frames:e.frames}),k({category:"minigame.framerate",message:`FPS: ${e.fps}(最低 ${e.minFps},卡顿 ${e.jankCount} 次)`,level:e.fps<this._options.fpsWarningThreshold?"warning":"info",data:e}))}_rollupWindow(){const e=this._windowElapsed;if(this._frameCount===0||e<=0)return this._resetWindow(),null;const n=Math.round(this._frameCount/e*1e3),r=this._maxFrameDelta>0?Math.round(1e3/this._maxFrameDelta):n,s={fps:n,minFps:r,worstFrameMs:Math.round(this._maxFrameDelta),jankCount:this._jankCount,frames:this._frameCount};return this._fpsSamples.push(n),this._fpsSamples.length>F._MAX_FPS_SAMPLES&&this._fpsSamples.shift(),this._sessionElapsed+=e,this._sessionFrames+=this._frameCount,this._sessionJank+=this._jankCount,this._sessionJankByTier.minor+=this._jankByTier.minor,this._sessionJankByTier.major+=this._jankByTier.major,this._sessionJankByTier.severe+=this._jankByTier.severe,this._maxFrameDelta>this._sessionWorstFrame&&(this._sessionWorstFrame=this._maxFrameDelta),this._resetWindow(),s}_resetWindow(){this._windowElapsed=0,this._frameCount=0,this._jankCount=0,this._jankBreadcrumbs=0,this._maxFrameDelta=0,this._jankByTier={minor:0,major:0,severe:0}}_resetSession(){this._sessionEpochStart=_n(),this._sessionElapsed=0,this._sessionFrames=0,this._sessionJank=0,this._sessionJankByTier={minor:0,major:0,severe:0},this._sessionWorstFrame=0,this._fpsSamples=[]}_restartOnResume(){this._resetSession();const e=Te();this._lastFrameTs=e,this._resetWindow()}_flushSummary(){if(this._rollupWindow(),this._sessionFrames===0)return!1;const e=this._sessionElapsed,n=e>0?Math.round(this._sessionFrames/e*1e3):0,r=this._sessionWorstFrame>0?Math.round(1e3/this._sessionWorstFrame):n,s=Eu(this._fpsSamples,n),i=Math.round(this._sessionWorstFrame),o=this._sessionJank,c=this._sessionFrames,a=xt({name:"minigame.framerate.summary",op:"ui.framerate",forceTransaction:!0,startTime:this._sessionEpochStart/1e3});if(a.setAttributes({"fps.avg":n,"fps.p95":s,"fps.min":r,"frames.total":c,"jank.count":o,"frame.worst_ms":i}),Q("fps_avg",n,"none",a),Q("fps_p95",s,"none",a),Q("fps_min",r,"none",a),Q("jank_count",o,"none",a),this._tiered){const u={};for(const d of this._tiers){const f=this._sessionJankByTier[d.name];u[`jank.${d.name}`]=f,Q(`jank_${d.name}_count`,f,"none",a)}a.setAttributes(u)}return a.end((this._sessionEpochStart+Math.max(0,e))/1e3),this._resetSession(),!0}_flushPendingEvents(){Promise.resolve(Is(F._HIDE_FLUSH_TIMEOUT_MS)).catch(()=>{})}cleanup(){this._running=!1,this._flushSummary()&&this._flushPendingEvents();const e=v();if(e)try{this._hideHandler&&typeof e.offHide=="function"&&e.offHide(this._hideHandler),this._showHandler&&typeof e.offShow=="function"&&e.offShow(this._showHandler)}catch(n){}this._hideHandler=null,this._showHandler=null}};F.id="MinigameFrameRate",F._MAX_FPS_SAMPLES=2e3,F._MAX_REASONABLE_FRAME_DELTA_MS=5e3,F._HIDE_FLUSH_TIMEOUT_MS=2e3;let oe=F;const Tu=t=>()=>new oe(t),vu=Object.freeze(Object.defineProperty({__proto__:null,ConsoleBreadcrumbs:Ne,Dedupe:rt,GlobalHandlers:Qe,HttpContext:nt,LinkedErrors:tt,MinigameFrameRateIntegration:oe,MinigameIntegration:ie,NetworkBreadcrumbs:ot,NetworkStatusIntegration:lt,PageBreadcrumbs:Pe,PerformanceIntegration:st,RewriteFrames:it,Router:yn,SessionIntegration:ut,System:gn,TryCatch:et,consoleBreadcrumbsIntegration:mu,minigameFrameRateIntegration:Tu,minigameIntegration:gu,pageBreadcrumbsIntegration:du,performanceIntegration:$n},Symbol.toStringTag,{value:"Module"}));function Bn(){return[new nt,new rt,new Qe,new et,new tt,$n({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!0,sampleRate:1,reportInterval:3e4})]}const Iu=Bn();function wu(t={}){if(!qs()){console.warn("[sentry-miniapp] Not running in a supported miniapp environment");return}const e=[...t.integrations||Bn()],n=T(l({},t),{integrations:e,stackParser:js,transport:t.transport});n.enableSourceMap!==!1&&n.integrations.push(new it);const r={traceNetworkBody:n.traceNetworkBody};n.enableTracePropagation!==void 0&&(r.enableTracePropagation=n.enableTracePropagation),n.tracePropagationTargets!==void 0&&(r.tracePropagationTargets=n.tracePropagationTargets),n.integrations.push(new ot(r)),n.enableAutoSessionTracking!==!1&&n.integrations.push(new ut);const s=n.enableNavigationBreadcrumbs!==!1,i=n.enableUserInteractionBreadcrumbs!==!1;(s||i)&&n.integrations.push(new Pe({enableLifecycle:s,enableUserInteraction:i})),n.enableNetworkStatusMonitoring!==!1&&n.integrations.push(new lt),n.enableConsoleBreadcrumbs&&n.integrations.push(new Ne);const o=Uc(),c=a=>n.integrations.some(u=>u&&u.name===a);if(!c("EventFilters")&&!c("InboundFilters")){const a={};n.allowUrls&&(a.allowUrls=n.allowUrls),n.denyUrls&&(a.denyUrls=n.denyUrls),n.ignoreErrors&&(a.ignoreErrors=n.ignoreErrors),n.integrations.push(_c(a))}return!c(ie.id)&&(n.enableMinigameLifecycle===!0||o&&n.enableMinigameLifecycle!==!1)&&n.integrations.push(new ie),!c(oe.id)&&(n.enableMinigameFrameRate===!0||o&&n.enableMinigameFrameRate!==!1)&&n.integrations.push(new oe(n.minigameFrameRateOptions)),W("miniapp",{platform:Ws(),environment:"miniapp"}),oc(Ks,n),b().getClient()}function ku(t={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}function Au(t){return function(...e){return fe(()=>{try{return t.apply(this,e)}catch(n){throw b().captureException(n),n}})}}function Ru(t){var e,n,r;Mc(t),t&&((r=(n=(e=w())==null?void 0:e.getTransport())==null?void 0:n.flush)==null||r.call(n))}function Cu(){return Us()}function Pu(t){const e=b().getClient();return e?e.captureFeedback(t):(console.warn("[sentry-miniapp] No client available for captureFeedback"),"")}Fr();exports.Integrations=vu;exports.MiniappClient=Ks;exports.SDK_NAME=Bs;exports.SDK_VERSION=ze;exports.Transports=Kc;exports.addBreadcrumb=k;exports.addEventProcessor=va;exports.addIntegration=Pa;exports.captureEvent=_a;exports.captureException=ee;exports.captureFeedback=Pu;exports.captureMessage=ha;exports.captureSession=dn;exports.close=Ta;exports.closeSession=Jr;exports.defaultIntegrations=Iu;exports.endSession=Mt;exports.flush=Is;exports.getClient=w;exports.getConsent=Cu;exports.getCurrentScope=b;exports.getDefaultIntegrations=Bn;exports.getIsolationScope=R;exports.getPerformanceManager=Gs;exports.init=wu;exports.isEnabled=ws;exports.lastEventId=Ea;exports.makeSession=Gr;exports.miniappStackParser=js;exports.performanceIntegration=$n;exports.setConsent=Ru;exports.setContext=W;exports.setExtra=ga;exports.setExtras=ma;exports.setTag=Sa;exports.setTags=ya;exports.setUser=ba;exports.showReportDialog=ku;exports.startInactiveSpan=xt;exports.startSession=ks;exports.startSpan=_e;exports.updateSession=J;exports.withScope=fe;exports.wrap=Au;
19
19
  //# sourceMappingURL=sentry-miniapp.cjs.js.map