sentry-miniapp 1.12.0 → 1.12.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 Ws=Object.defineProperty,Gs=Object.defineProperties;var Js=Object.getOwnPropertyDescriptors;var xe=Object.getOwnPropertySymbols;var Dn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable;var Pt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ks=t=>{throw TypeError(t)};var On=(t,e,n)=>e in t?Ws(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e)=>{for(var n in e||(e={}))Dn.call(e,n)&&On(t,n,e[n]);if(xe)for(var n of xe(e))Mn.call(e,n)&&On(t,n,e[n]);return t},E=(t,e)=>Gs(t,Js(e));var Fn=(t,e)=>{var n={};for(var r in t)Dn.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&xe)for(var r of xe(t))e.indexOf(r)<0&&Mn.call(t,r)&&(n[r]=t[r]);return n};var O=(t,e,n)=>new Promise((r,s)=>{var i=c=>{try{a(n.next(c))}catch(u){s(u)}},o=c=>{try{a(n.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);a((n=n.apply(t,e)).next())}),Vs=function(t,e){this[0]=t,this[1]=e};var Ln=t=>{var e=t[Pt("asyncIterator")],n=!1,r,s={};return e==null?(e=t[Pt("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 Vs(new Promise(a=>{var c=e[i](o);c instanceof Object||Ks("Object expected"),a(c)}),1)}}),s[Pt("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 ge{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 ge)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*Ln(this.entries())}}function Ys(){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 Xs(){try{const t=Ys();if(!t){console.warn("[sentry-miniapp] Unable to detect global object, polyfills may not work correctly");return}typeof t.URLSearchParams=="undefined"&&(t.URLSearchParams=ge);const e=Function("return this")();e&&typeof e.URLSearchParams=="undefined"&&(e.URLSearchParams=ge),typeof globalThis!="undefined"&&typeof globalThis.URLSearchParams=="undefined"&&(globalThis.URLSearchParams=ge)}catch(t){console.warn("[sentry-miniapp] Failed to install polyfills:",t)}}function Ar(){Xs()}Ar();const g=typeof __SENTRY_DEBUG__=="undefined"||__SENTRY_DEBUG__,P=globalThis,ye="10.57.0";function V(){return bt(P),P}function bt(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||ye,e[ye]=e[ye]||{}}function ue(t,e,n=P){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[ye]=r[ye]||{};return s[t]||(s[t]=e())}const Zs="Sentry Logger ",$n={};function Ae(t){if(!("console"in P))return t();const e=P.console,n={},r=Object.keys($n);r.forEach(s=>{const i=$n[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function Qs(){pn().enabled=!0}function ei(){pn().enabled=!1}function Rr(){return pn().enabled}function ti(...t){fn("log",...t)}function ni(...t){fn("warn",...t)}function ri(...t){fn("error",...t)}function fn(t,...e){g&&Rr()&&Ae(()=>{P.console[t](`${Zs}[${t}]:`,...e)})}function pn(){return g?ue("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const m={enable:Qs,disable:ei,isEnabled:Rr,log:ti,warn:ni,error:ri},Cr=50,Et="?",jn=/\(error: (.*)\)/,Bn=/captureMessage|captureException/;function si(...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 a=r;a<o.length;a++){let c=o[a];c.length>1024&&(c=c.slice(0,1024));const u=jn.test(c)?c.replace(jn,"$1"):c;if(!u.includes("Error: ")){for(const p of e){const f=p(u);if(f){i.push(f);break}}if(i.length>=Cr+s)break}}return ii(i.slice(s))}}function ii(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Oe(e).function||"")&&e.pop(),e.reverse(),Bn.test(Oe(e).function||"")&&(e.pop(),Bn.test(Oe(e).function||"")&&e.pop()),e.slice(0,Cr).map(n=>E(l({},n),{filename:n.filename||Oe(e).filename,function:n.function||Et}))}function Oe(t){return t[t.length-1]||{}}const Nt="<anonymous>";function oi(t){try{return!t||typeof t!="function"?Nt:t.name||Nt}catch(e){return Nt}}const Pr=Object.prototype.toString;function Nr(t){switch(Pr.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return Dr(t,Error)}}function dn(t,e){return Pr.call(t)===`[object ${e}]`}function Gt(t){return dn(t,"String")}function xr(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Or(t){return t===null||xr(t)||typeof t!="object"&&typeof t!="function"}function Jt(t){return dn(t,"Object")}function ai(t){return typeof Event!="undefined"&&Dr(t,Event)}function ci(t){return dn(t,"RegExp")}function le(t){return!!(t!=null&&t.then&&typeof t.then=="function")}function Dr(t,e){try{return t instanceof e}catch(n){return!1}}function J(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch(r){g&&m.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}function ui(t){if(Nr(t))return l({message:t.message,name:t.name,stack:t.stack},Hn(t));if(ai(t)){const{type:e,target:n,currentTarget:r,detail:s}=t;return l(l({type:e,target:n,currentTarget:r},s?{detail:s}:{}),Hn(t))}return t}function Hn(t){return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}let Z;function Tt(t){if(Z!==void 0)return Z?Z(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=P;return e in n&&typeof n[e]=="function"?(Z=n[e],Z(t)):(Z=null,t())}function je(){return Tt(()=>Math.random())}function G(){return Tt(()=>Date.now())}const li=Symbol.for("sentry.skipNormalization"),fi=Symbol.for("sentry.overrideNormalizationDepth");function pi(t){return!!t[li]}function di(t){const e=t[fi];return typeof e=="number"?e:void 0}let hi;function z(t,e=100,n=1/0){try{return Kt("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function Kt(t,e,n=1/0,r=1/0,s=gi()){const[i,o]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const a=_i(t,e);if(!a.startsWith("[object "))return a;if(pi(e))return e;const c=di(e),u=c!==void 0?c:n;if(u===0)return a.replace("object ","");if(i(e))return"[Circular ~]";const p=e;if(p&&typeof p.toJSON=="function")try{const _=p.toJSON();return Kt("",_,u-1,r,s)}catch(_){}const f=Array.isArray(e)?[]:{};let h=0;const d=ui(e);for(const _ in d){if(!Object.prototype.hasOwnProperty.call(d,_))continue;if(h>=r){f[_]="[MaxProperties ~]";break}const y=d[_];f[_]=Kt(_,y,u-1,r,s),h++}return o(e),f}function _i(t,e){try{return typeof global!="undefined"&&e===global?"[Global]":typeof e=="number"&&!Number.isFinite(e)?`[${e}]`:typeof e=="function"?`[Function: ${oi(e)}]`:typeof e=="symbol"?`[${String(e)}]`:typeof e=="bigint"?`[BigInt: ${String(e)}]`:`[object ${mi(e)}]`}catch(n){return`**non-serializable** (${n})`}}function mi(t){const e=Object.getPrototypeOf(t);return e!=null&&e.constructor?e.constructor.name:"null prototype"}function gi(){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 Vt(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function Se(t,e,n=!1){return Gt(t)?ci(e)?e.test(t):Gt(e)?n?t===e:t.includes(e):typeof e=="function"?e(t):!1:!1}function vt(t,e=[],n=!1){for(const r of e)if(Se(t,r,n))return!0;return!1}function yi(){const t=P;return t.crypto||t.msCrypto}let xt;function Si(){return je()*16}function M(t=yi()){try{if(t!=null&&t.randomUUID)return Tt(()=>t.randomUUID()).replace(/-/g,"")}catch(e){}return xt||(xt="10000000100040008000"+1e11),xt.replace(/[018]/g,e=>(e^(Si()&15)>>e/4).toString(16))}function Mr(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)==null?void 0:n[0]}function Q(t){const{message:e,event_id:n}=t;if(e)return e;const r=Mr(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function bi(t,e){const n=Mr(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 Un(t){if(Ei(t))return!0;try{J(t,"__sentry_captured__",!0)}catch(e){}return!1}function Ei(t){try{return t.__sentry_captured__}catch(e){}}const Fr=1e3;function Re(){return G()/Fr}function Ti(){const{performance:t}=P;if(!(t!=null&&t.now)||!t.timeOrigin)return Re;const e=t.timeOrigin;return()=>(e+Tt(()=>t.now()))/Fr}let De;function ve(){return(De!=null?De:De=Ti())()}function Lr(t){const e=ve(),n={sid:M(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>vi(n)};return t&&K(n,t),n}function K(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||ve(),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:M()),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 $r(t,e){let n={};e?n={status:e}:t.status==="ok"&&(n={status:"exited"}),K(t,n)}function vi(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 Ce(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]=Ce(r[s],e[s],n-1));return r}function re(){return M()}function fe(){return M().substring(16)}function jr(t){try{const e=P.WeakRef;if(typeof e=="function")return new e(t)}catch(e){}return t}function Br(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch(e){return}return t}}const Yt="_sentrySpan";function Be(t,e){e?J(t,Yt,jr(e)):delete t[Yt]}function He(t){return Br(t[Yt])}const Ii=100;class ${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:re(),sampleRand:je()}}clone(){const e=new $;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,Be(e,He(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&&K(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=E(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 $?n.getScopeData():Jt(n)?e:void 0,{tags:s,attributes:i,extra:o,user:a,contexts:c,level:u,fingerprint:p=[],propagationContext:f,conversationId:h}=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),c),a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),p.length&&(this._fingerprint=p),f&&(this._propagationContext=f),h&&(this._conversationId=h),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,Be(this,void 0),this._attachments=[],this.setPropagationContext({traceId:re(),sampleRand:je()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){var i;const r=typeof n=="number"?n:Ii;if(r<=0)return this;const s=E(l({timestamp:Re()},e),{message:e.message?Vt(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:He(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Ce(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)||M();if(!this._client)return g&&m.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,E(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)||M();if(!this._client)return g&&m.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,E(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)||M();return this._client?(this._client.captureEvent(e,E(l({},n),{event_id:r}),this),r):(g&&m.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 wi(){return ue("defaultCurrentScope",()=>new $)}function ki(){return ue("defaultIsolationScope",()=>new $)}const zn=t=>t instanceof Promise&&!t[Hr],Hr=Symbol("chained PromiseLike"),Ur=(t,e,n)=>{const r=t.then(s=>(e(s),s),s=>{throw n(s),s});return zn(r)&&zn(t)?r:Ai(t,r)},Ai=(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,{[Hr]:!0}),e};class Ri{constructor(e,n){let r;e?r=e:r=new $;let s;n?s=n:s=new $,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 le(r)?Ur(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 se(){const t=V(),e=bt(t);return e.stack=e.stack||new Ri(wi(),ki())}function Ci(t){return se().withScope(t)}function Pi(t,e){const n=se();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function qn(t){return se().withScope(()=>t(se().getIsolationScope()))}function Ni(){return{withIsolationScope:qn,withScope:Ci,withSetScope:Pi,withSetIsolationScope:(t,e)=>qn(e),getCurrentScope:()=>se().getScope(),getIsolationScope:()=>se().getIsolationScope()}}function pe(t){const e=bt(t);return e.acs?e.acs:Ni()}function xi(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)&&Object.keys(t).includes("value")}function Oi(t,e){var a;const{value:n,unit:r}=xi(t)?t:{value:t,unit:void 0},s=Di(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=(a=JSON.stringify(n))!=null?a:""}catch(c){}return l({value:o,type:"string"},i)}function Wn(t,e=!1){const n={};for(const[r,s]of Object.entries(t!=null?t:{})){const i=Oi(s,e);i&&(n[r]=i)}return n}function Di(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=V();return pe(t).getCurrentScope()}function A(){const t=V();return pe(t).getIsolationScope()}function Mi(){return ue("globalScope",()=>new $)}function Pe(...t){const e=V(),n=pe(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 Fi(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||fe()};return r&&(i.parent_span_id=r),i}const Ue="sentry.source",zr="sentry.sample_rate",Li="sentry.previous_trace_sample_rate",ze="sentry.op",Xt="sentry.origin",qr="sentry.measurement_unit",Wr="sentry.measurement_value",Gn="sentry.custom_span_name",hn="sentry.profile_id",_n="sentry.exclusive_time",Gr=0,It=1,C=2;function $i(t){if(t<400&&t>=100)return{code:It};if(t>=400&&t<500)switch(t){case 401:return{code:C,message:"unauthenticated"};case 403:return{code:C,message:"permission_denied"};case 404:return{code:C,message:"not_found"};case 409:return{code:C,message:"already_exists"};case 413:return{code:C,message:"failed_precondition"};case 429:return{code:C,message:"resource_exhausted"};case 499:return{code:C,message:"cancelled"};default:return{code:C,message:"invalid_argument"}}if(t>=500&&t<600)switch(t){case 501:return{code:C,message:"unimplemented"};case 503:return{code:C,message:"unavailable"};case 504:return{code:C,message:"deadline_exceeded"};default:return{code:C,message:"internal_error"}}return{code:C,message:"internal_error"}}function ji(t,e){t.setAttribute("http.response.status_code",e);const n=$i(e);n.message!=="unknown_error"&&t.setStatus(n)}const Jr="_sentryScope",Kr="_sentryIsolationScope";function Bi(t,e,n){t&&(J(t,Kr,jr(n)),J(t,Jr,e))}function qe(t){const e=t;return{scope:e[Jr],isolationScope:Br(e[Kr])}}const Zt="sentry-",Hi=8192;function Ui(t){const e=qi(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.startsWith(Zt)){const o=s.slice(Zt.length);r[o]=i}return r},{});if(Object.keys(n).length>0)return n}function zi(t){if(!t)return;const e=Object.entries(t).reduce((n,[r,s])=>(s&&(n[`${Zt}${r}`]=s),n),{});return Wi(e)}function qi(t){if(!(!t||!Gt(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=Jn(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):Jn(t)}function Jn(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 Wi(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>Hi?(g&&m.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const Gi=/^o(\d+)\./,Ji=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Ki(t){return t==="http"||t==="https"}function de(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:o,protocol:a,publicKey:c}=t;return`${a}://${c}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${o}`}function Vi(t){const e=Ji.exec(t);if(!e){Ae(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",o="",a=""]=e.slice(1);let c="",u=a;const p=u.split("/");if(p.length>1&&(c=p.slice(0,-1).join("/"),u=p.pop()),u){const f=u.match(/^\d+/);f&&(u=f[0])}return Vr({host:i,pass:s,path:c,projectId:u,port:o,protocol:n,publicKey:r})}function Vr(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function Yi(t){if(!g)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(o=>t[o]?!1:(m.error(`Invalid Sentry Dsn: ${o} missing`),!0))?!1:n.match(/^\d+$/)?Ki(r)?e&&isNaN(parseInt(e,10))?(m.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(m.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(m.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Xi(t){const e=t.match(Gi);return e==null?void 0:e[1]}function Zi(t){const e=t.getOptions(),{host:n}=t.getDsn()||{};let r;return e.orgId?r=String(e.orgId):n&&(r=Xi(n)),r}function Qi(t){const e=typeof t=="string"?Vi(t):Vr(t);if(!(!e||!Yi(e)))return e}function mn(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 eo=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function Yr(t=re(),e=fe(),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}function Xr(t=re(),e=fe(),n){return`00-${t}-${e}-${n?"01":"00"}`}const Zr=0,wt=1;let Kn=!1;function to(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:s,parent_span_id:i,status:o,origin:a,links:c}=N(t);return{parent_span_id:i,span_id:e,trace_id:n,data:r,op:s,status:o,origin:a,links:c}}function no(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:N(t).parent_span_id,i=qe(t).scope,o=r?(i==null?void 0:i.getPropagationContext().propagationSpanId)||fe():e;return{parent_span_id:s,span_id:o,trace_id:n}}function ro(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return Yr(e,n,r)}function so(t){const{traceId:e,spanId:n}=t.spanContext(),r=Y(t);return Xr(e,n,r)}function Qr(t){if(t&&t.length>0)return t.map(o=>{var a=o,{context:c}=a,u=c,{spanId:e,traceId:n,traceFlags:r}=u,s=Fn(u,["spanId","traceId","traceFlags"]),{attributes:i}=a;return l({span_id:e,trace_id:n,sampled:r===wt,attributes:i},s)})}function io(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===wt,attributes:s}))}function ne(t){return typeof t=="number"?Vn(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Vn(t.getTime()):ve()}function Vn(t){return t>9999999999?t/1e3:t}function N(t){if(uo(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(co(t)){const{attributes:r,startTime:s,name:i,endTime:o,status:a,links:c}=t;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:oo(t),start_timestamp:ne(s),timestamp:ne(o)||void 0,status:es(a),op:r[ze],origin:r[Xt],links:Qr(c)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function oo(t){var e;return"parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?(e=t.parentSpanContext)==null?void 0:e.spanId:void 0}function ao(t){var e;return E(l({},t),{attributes:Wn(t.attributes),links:(e=t.links)==null?void 0:e.map(n=>E(l({},n),{attributes:Wn(n.attributes)}))})}function co(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function uo(t){return typeof t.getSpanJSON=="function"}function Y(t){const{traceFlags:e}=t.spanContext();return e===wt}function es(t){if(!(!t||t.code===Gr))return t.code===It?"ok":t.message||"internal_error"}function lo(t){return!t||t.code===It||t.code===Gr||t.message==="cancelled"?"ok":"error"}const be="_sentryChildSpans",Qt="_sentryRootSpan";function ts(t,e){const n=t[Qt]||t;J(e,Qt,n),t[be]?t[be].add(e):J(t,be,new Set([e]))}function fo(t){const e=new Set;function n(r){if(!e.has(r)&&Y(r)){e.add(r);const s=r[be]?Array.from(r[be]):[];for(const i of s)n(i)}}return n(t),Array.from(e)}const L=po;function po(t){return t[Qt]||t}function ns(){const t=V(),e=pe(t);return e.getActiveSpan?e.getActiveSpan():He(b())}function en(){Kn||(Ae(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),Kn=!0)}function gn(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 Yn(t){m.log(`Ignoring span ${t.op} - ${t.description} because it matches \`ignoreSpans\`.`)}function We(t,e){if(!(e!=null&&e.length))return!1;for(const n of e){if(mo(n)){if(t.description&&Se(t.description,n))return g&&Yn(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&&Se(t.description,n.name):!0,i=n.op?t.op&&Se(t.op,n.op):!0,o=n.attributes?Object.entries(n.attributes).every(([a,c])=>{var u;return ho((u=t.attributes)==null?void 0:u[a],c)}):!0;if(s&&i&&o)return g&&Yn(t),!0}return!1}function ho(t,e){return typeof t=="string"&&(typeof e=="string"||e instanceof RegExp)?Se(t,e):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((n,r)=>n===e[r]):t===e}function _o(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 mo(t){return typeof t=="string"||t instanceof RegExp}const yn="production",rs="_frozenDsc";function Ot(t,e){J(t,rs,e)}function ss(t,e){const n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s={environment:n.environment||yn,release:n.release,public_key:r,trace_id:t,org_id:Zi(e)};return e.emit("createDsc",s),s}function is(t,e){const n=e.getPropagationContext();return n.dsc||ss(n.traceId,t)}function ie(t){var _,y,T,I,j;const e=w();if(!e)return{};const n=L(t),r=N(n),s=r.data,i=n.spanContext().traceState,o=(y=(_=i==null?void 0:i.get("sentry.sample_rate"))!=null?_:s[zr])!=null?y:s[Li];function a(F){return(typeof o=="number"||typeof o=="string")&&(F.sample_rate=`${o}`),F}const c=n[rs];if(c)return a(c);const u=i==null?void 0:i.get("sentry.dsc"),p=u&&Ui(u);if(p)return a(p);const f=ss(t.spanContext().traceId,e),h=(T=s[Ue])!=null?T:s["sentry.span.source"],d=r.description;return h!=="url"&&d&&(f.transaction=d),gn()&&(f.sampled=String(Y(n)),f.sample_rand=(j=i==null?void 0:i.get("sentry.sample_rand"))!=null?j:(I=qe(n).scope)==null?void 0:I.getPropagationContext().sampleRand.toString()),a(f),e.emit("createDsc",f,n),f}class q{constructor(e={}){this._traceId=e.traceId||re(),this._spanId=e.spanId||fe(),this.dropReason=e.dropReason}spanContext(){return{spanId:this._spanId,traceId:this._traceId,traceFlags:Zr}}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 os(t){return!!t&&typeof t=="function"&&"_streamed"in t&&!!t._streamed}function X(t,e=[]){return[t,e]}function Xn(t,e){const[n,r]=t;return[n,[...r,e]]}function tn(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 nn(t,e){return tn(t,(n,r)=>e.includes(r))}function rn(t){const e=bt(P);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function go(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[rn(r),i]:r.push(typeof i=="string"?rn(i):i)}for(const i of n){const[o,a]=i;if(s(`
1
+ "use strict";var Gs=Object.defineProperty,Js=Object.defineProperties;var Ks=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var jn=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable;var Nt=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ys=t=>{throw TypeError(t)};var $n=(t,e,n)=>e in t?Gs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))jn.call(e,n)&&$n(t,n,e[n]);if(Oe)for(var n of Oe(e))Bn.call(e,n)&&$n(t,n,e[n]);return t},E=(t,e)=>Js(t,Ks(e));var Hn=(t,e)=>{var n={};for(var r in t)jn.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Oe)for(var r of Oe(t))e.indexOf(r)<0&&Bn.call(t,r)&&(n[r]=t[r]);return n};var O=(t,e,n)=>new Promise((r,s)=>{var i=c=>{try{a(n.next(c))}catch(u){s(u)}},o=c=>{try{a(n.throw(c))}catch(u){s(u)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);a((n=n.apply(t,e)).next())}),Vs=function(t,e){this[0]=t,this[1]=e};var Un=t=>{var e=t[Nt("asyncIterator")],n=!1,r,s={};return e==null?(e=t[Nt("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 Vs(new Promise(a=>{var c=e[i](o);c instanceof Object||Ys("Object expected"),a(c)}),1)}}),s[Nt("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 ye{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 ye)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*Un(this.entries())}}function Xs(){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 Zs(){try{const t=Xs();if(!t){console.warn("[sentry-miniapp] Unable to detect global object, polyfills may not work correctly");return}typeof t.URLSearchParams=="undefined"&&(t.URLSearchParams=ye);const e=Function("return this")();e&&typeof e.URLSearchParams=="undefined"&&(e.URLSearchParams=ye),typeof globalThis!="undefined"&&typeof globalThis.URLSearchParams=="undefined"&&(globalThis.URLSearchParams=ye)}catch(t){console.warn("[sentry-miniapp] Failed to install polyfills:",t)}}function Pr(){Zs()}Pr();const g=typeof __SENTRY_DEBUG__=="undefined"||__SENTRY_DEBUG__,P=globalThis,Se="10.57.0";function Y(){return Et(P),P}function Et(t){const e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||Se,e[Se]=e[Se]||{}}function ue(t,e,n=P){const r=n.__SENTRY__=n.__SENTRY__||{},s=r[Se]=r[Se]||{};return s[t]||(s[t]=e())}const Qs="Sentry Logger ",zn={};function Ce(t){if(!("console"in P))return t();const e=P.console,n={},r=Object.keys(zn);r.forEach(s=>{const i=zn[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function ei(){_n().enabled=!0}function ti(){_n().enabled=!1}function Nr(){return _n().enabled}function ni(...t){hn("log",...t)}function ri(...t){hn("warn",...t)}function si(...t){hn("error",...t)}function hn(t,...e){g&&Nr()&&Ce(()=>{P.console[t](`${Qs}[${t}]:`,...e)})}function _n(){return g?ue("loggerSettings",()=>({enabled:!1})):{enabled:!1}}const m={enable:ei,disable:ti,isEnabled:Nr,log:ni,warn:ri,error:si},xr=50,vt="?",qn=/\(error: (.*)\)/,Wn=/captureMessage|captureException/;function ii(...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 a=r;a<o.length;a++){let c=o[a];c.length>1024&&(c=c.slice(0,1024));const u=qn.test(c)?c.replace(qn,"$1"):c;if(!u.includes("Error: ")){for(const d of e){const l=d(u);if(l){i.push(l);break}}if(i.length>=xr+s)break}}return oi(i.slice(s))}}function oi(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(De(e).function||"")&&e.pop(),e.reverse(),Wn.test(De(e).function||"")&&(e.pop(),Wn.test(De(e).function||"")&&e.pop()),e.slice(0,xr).map(n=>E(p({},n),{filename:n.filename||De(e).filename,function:n.function||vt}))}function De(t){return t[t.length-1]||{}}const xt="<anonymous>";function ai(t){try{return!t||typeof t!="function"?xt:t.name||xt}catch(e){return xt}}const Or=Object.prototype.toString;function Dr(t){switch(Or.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return Lr(t,Error)}}function mn(t,e){return Or.call(t)===`[object ${e}]`}function Kt(t){return mn(t,"String")}function Mr(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Fr(t){return t===null||Mr(t)||typeof t!="object"&&typeof t!="function"}function Yt(t){return mn(t,"Object")}function ci(t){return typeof Event!="undefined"&&Lr(t,Event)}function ui(t){return mn(t,"RegExp")}function le(t){return!!(t!=null&&t.then&&typeof t.then=="function")}function Lr(t,e){try{return t instanceof e}catch(n){return!1}}function J(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch(r){g&&m.log(`Failed to add non-enumerable property "${String(e)}" to object`,t)}}function li(t){if(Dr(t))return p({message:t.message,name:t.name,stack:t.stack},Gn(t));if(ci(t)){const{type:e,target:n,currentTarget:r,detail:s}=t;return p(p({type:e,target:n,currentTarget:r},s?{detail:s}:{}),Gn(t))}return t}function Gn(t){return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}let Z;function Tt(t){if(Z!==void 0)return Z?Z(t):t();const e=Symbol.for("__SENTRY_SAFE_RANDOM_ID_WRAPPER__"),n=P;return e in n&&typeof n[e]=="function"?(Z=n[e],Z(t)):(Z=null,t())}function Be(){return Tt(()=>Math.random())}function G(){return Tt(()=>Date.now())}const pi=Symbol.for("sentry.skipNormalization"),fi=Symbol.for("sentry.overrideNormalizationDepth");function di(t){return!!t[pi]}function hi(t){const e=t[fi];return typeof e=="number"?e:void 0}let _i;function z(t,e=100,n=1/0){try{return Vt("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function Vt(t,e,n=1/0,r=1/0,s=yi()){const[i,o]=s;if(e==null||["boolean","string"].includes(typeof e)||typeof e=="number"&&Number.isFinite(e))return e;const a=mi(t,e);if(!a.startsWith("[object "))return a;if(di(e))return e;const c=hi(e),u=c!==void 0?c:n;if(u===0)return a.replace("object ","");if(i(e))return"[Circular ~]";const d=e;if(d&&typeof d.toJSON=="function")try{const _=d.toJSON();return Vt("",_,u-1,r,s)}catch(_){}const l=Array.isArray(e)?[]:{};let h=0;const f=li(e);for(const _ in f){if(!Object.prototype.hasOwnProperty.call(f,_))continue;if(h>=r){l[_]="[MaxProperties ~]";break}const y=f[_];l[_]=Vt(_,y,u-1,r,s),h++}return o(e),l}function mi(t,e){try{return typeof global!="undefined"&&e===global?"[Global]":typeof e=="number"&&!Number.isFinite(e)?`[${e}]`:typeof e=="function"?`[Function: ${ai(e)}]`:typeof e=="symbol"?`[${String(e)}]`:typeof e=="bigint"?`[BigInt: ${String(e)}]`:`[object ${gi(e)}]`}catch(n){return`**non-serializable** (${n})`}}function gi(t){const e=Object.getPrototypeOf(t);return e!=null&&e.constructor?e.constructor.name:"null prototype"}function yi(){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 Xt(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function be(t,e,n=!1){return Kt(t)?ui(e)?e.test(t):Kt(e)?n?t===e:t.includes(e):typeof e=="function"?e(t):!1:!1}function It(t,e=[],n=!1){for(const r of e)if(be(t,r,n))return!0;return!1}function Si(){const t=P;return t.crypto||t.msCrypto}let Ot;function bi(){return Be()*16}function M(t=Si()){try{if(t!=null&&t.randomUUID)return Tt(()=>t.randomUUID()).replace(/-/g,"")}catch(e){}return Ot||(Ot="10000000100040008000"+1e11),Ot.replace(/[018]/g,e=>(e^(bi()&15)>>e/4).toString(16))}function $r(t){var e,n;return(n=(e=t.exception)==null?void 0:e.values)==null?void 0:n[0]}function Q(t){const{message:e,event_id:n}=t;if(e)return e;const r=$r(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function Ei(t,e){const n=$r(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism=p(p(p({},r),s),e),e&&"data"in e){const i=p(p({},s==null?void 0:s.data),e.data);n.mechanism.data=i}}function Jn(t){if(vi(t))return!0;try{J(t,"__sentry_captured__",!0)}catch(e){}return!1}function vi(t){try{return t.__sentry_captured__}catch(e){}}const jr=1e3;function Pe(){return G()/jr}function Ti(){const{performance:t}=P;if(!(t!=null&&t.now)||!t.timeOrigin)return Pe;const e=t.timeOrigin;return()=>(e+Tt(()=>t.now()))/jr}let Me;function we(){return(Me!=null?Me:Me=Ti())()}function Br(t){const e=we(),n={sid:M(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>Ii(n)};return t&&K(n,t),n}function K(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||we(),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:M()),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 Hr(t,e){let n={};e?n={status:e}:t.status==="ok"&&(n={status:"exited"}),K(t,n)}function Ii(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 Ne(t,e,n=2){if(!e||typeof e!="object"||n<=0)return e;if(t&&Object.keys(e).length===0)return t;const r=p({},t);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[s]=Ne(r[s],e[s],n-1));return r}function re(){return M()}function pe(){return M().substring(16)}function Ur(t){try{const e=P.WeakRef;if(typeof e=="function")return new e(t)}catch(e){}return t}function zr(t){if(t){if(typeof t=="object"&&"deref"in t&&typeof t.deref=="function")try{return t.deref()}catch(e){return}return t}}const Zt="_sentrySpan";function He(t,e){e?J(t,Zt,Ur(e)):delete t[Zt]}function Ue(t){return zr(t[Zt])}const wi=100;class ${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:re(),sampleRand:Be()}}clone(){const e=new $;return e._breadcrumbs=[...this._breadcrumbs],e._tags=p({},this._tags),e._attributes=p({},this._attributes),e._extra=p({},this._extra),e._contexts=p({},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=p({},this._sdkProcessingMetadata),e._propagationContext=p({},this._propagationContext),e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,He(e,Ue(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&&K(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=p(p({},this._tags),e),this._notifyScopeListeners(),this}setTag(e,n){return this.setTags({[e]:n})}setAttributes(e){return this._attributes=p(p({},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=p(p({},this._extra),e),this._notifyScopeListeners(),this}setExtra(e,n){return this._extra=E(p({},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 $?n.getScopeData():Yt(n)?e:void 0,{tags:s,attributes:i,extra:o,user:a,contexts:c,level:u,fingerprint:d=[],propagationContext:l,conversationId:h}=r||{};return this._tags=p(p({},this._tags),s),this._attributes=p(p({},this._attributes),i),this._extra=p(p({},this._extra),o),this._contexts=p(p({},this._contexts),c),a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),d.length&&(this._fingerprint=d),l&&(this._propagationContext=l),h&&(this._conversationId=h),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,He(this,void 0),this._attachments=[],this.setPropagationContext({traceId:re(),sampleRand:Be()}),this._notifyScopeListeners(),this}addBreadcrumb(e,n){var i;const r=typeof n=="number"?n:wi;if(r<=0)return this;const s=E(p({timestamp:Pe()},e),{message:e.message?Xt(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:Ue(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Ne(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)||M();if(!this._client)return g&&m.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,E(p({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)||M();if(!this._client)return g&&m.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,E(p({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)||M();return this._client?(this._client.captureEvent(e,E(p({},n),{event_id:r}),this),r):(g&&m.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 ki(){return ue("defaultCurrentScope",()=>new $)}function Ai(){return ue("defaultIsolationScope",()=>new $)}const Kn=t=>t instanceof Promise&&!t[qr],qr=Symbol("chained PromiseLike"),Wr=(t,e,n)=>{const r=t.then(s=>(e(s),s),s=>{throw n(s),s});return Kn(r)&&Kn(t)?r:Ri(t,r)},Ri=(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,{[qr]:!0}),e};class Ci{constructor(e,n){let r;e?r=e:r=new $;let s;n?s=n:s=new $,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 le(r)?Wr(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 se(){const t=Y(),e=Et(t);return e.stack=e.stack||new Ci(ki(),Ai())}function Pi(t){return se().withScope(t)}function Ni(t,e){const n=se();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function Yn(t){return se().withScope(()=>t(se().getIsolationScope()))}function xi(){return{withIsolationScope:Yn,withScope:Pi,withSetScope:Ni,withSetIsolationScope:(t,e)=>Yn(e),getCurrentScope:()=>se().getScope(),getIsolationScope:()=>se().getIsolationScope()}}function fe(t){const e=Et(t);return e.acs?e.acs:xi()}function Oi(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)&&Object.keys(t).includes("value")}function Di(t,e){var a;const{value:n,unit:r}=Oi(t)?t:{value:t,unit:void 0},s=Mi(n),i=r&&typeof r=="string"?{unit:r}:{};if(s)return p(p({},s),i);if(!e||e==="skip-undefined"&&n===void 0)return;let o="";try{o=(a=JSON.stringify(n))!=null?a:""}catch(c){}return p({value:o,type:"string"},i)}function Vn(t,e=!1){const n={};for(const[r,s]of Object.entries(t!=null?t:{})){const i=Di(s,e);i&&(n[r]=i)}return n}function Mi(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 S(){const t=Y();return fe(t).getCurrentScope()}function A(){const t=Y();return fe(t).getIsolationScope()}function Fi(){return ue("globalScope",()=>new $)}function de(...t){const e=Y(),n=fe(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 S().getClient()}function Li(t){const e=t.getPropagationContext(),{traceId:n,parentSpanId:r,propagationSpanId:s}=e,i={trace_id:n,span_id:s||pe()};return r&&(i.parent_span_id=r),i}const ze="sentry.source",Gr="sentry.sample_rate",$i="sentry.previous_trace_sample_rate",qe="sentry.op",Qt="sentry.origin",Jr="sentry.measurement_unit",Kr="sentry.measurement_value",Xn="sentry.custom_span_name",gn="sentry.profile_id",yn="sentry.exclusive_time",Yr=0,wt=1,C=2;function ji(t){if(t<400&&t>=100)return{code:wt};if(t>=400&&t<500)switch(t){case 401:return{code:C,message:"unauthenticated"};case 403:return{code:C,message:"permission_denied"};case 404:return{code:C,message:"not_found"};case 409:return{code:C,message:"already_exists"};case 413:return{code:C,message:"failed_precondition"};case 429:return{code:C,message:"resource_exhausted"};case 499:return{code:C,message:"cancelled"};default:return{code:C,message:"invalid_argument"}}if(t>=500&&t<600)switch(t){case 501:return{code:C,message:"unimplemented"};case 503:return{code:C,message:"unavailable"};case 504:return{code:C,message:"deadline_exceeded"};default:return{code:C,message:"internal_error"}}return{code:C,message:"internal_error"}}function Bi(t,e){t.setAttribute("http.response.status_code",e);const n=ji(e);n.message!=="unknown_error"&&t.setStatus(n)}const Vr="_sentryScope",Xr="_sentryIsolationScope";function Hi(t,e,n){t&&(J(t,Xr,Ur(n)),J(t,Vr,e))}function We(t){const e=t;return{scope:e[Vr],isolationScope:zr(e[Xr])}}const en="sentry-",Ui=8192;function zi(t){const e=Wi(t);if(!e)return;const n=Object.entries(e).reduce((r,[s,i])=>{if(s.startsWith(en)){const o=s.slice(en.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[`${en}${r}`]=s),n),{});return Gi(e)}function Wi(t){if(!(!t||!Kt(t)&&!Array.isArray(t)))return Array.isArray(t)?t.reduce((e,n)=>{const r=Zn(n);return Object.entries(r).forEach(([s,i])=>{e[s]=i}),e},{}):Zn(t)}function Zn(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 Gi(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>Ui?(g&&m.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const Ji=/^o(\d+)\./,Ki=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function Yi(t){return t==="http"||t==="https"}function he(t,e=!1){const{host:n,path:r,pass:s,port:i,projectId:o,protocol:a,publicKey:c}=t;return`${a}://${c}${e&&s?`:${s}`:""}@${n}${i?`:${i}`:""}/${r&&`${r}/`}${o}`}function Vi(t){const e=Ki.exec(t);if(!e){Ce(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}const[n,r,s="",i="",o="",a=""]=e.slice(1);let c="",u=a;const d=u.split("/");if(d.length>1&&(c=d.slice(0,-1).join("/"),u=d.pop()),u){const l=u.match(/^\d+/);l&&(u=l[0])}return Zr({host:i,pass:s,path:c,projectId:u,port:o,protocol:n,publicKey:r})}function Zr(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function Xi(t){if(!g)return!0;const{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(o=>t[o]?!1:(m.error(`Invalid Sentry Dsn: ${o} missing`),!0))?!1:n.match(/^\d+$/)?Yi(r)?e&&isNaN(parseInt(e,10))?(m.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(m.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(m.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function Zi(t){const e=t.match(Ji);return e==null?void 0:e[1]}function Qi(t){const e=t.getOptions(),{host:n}=t.getDsn()||{};let r;return e.orgId?r=String(e.orgId):n&&(r=Zi(n)),r}function eo(t){const e=typeof t=="string"?Vi(t):Zr(t);if(!(!e||!Xi(e)))return e}function Sn(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 to=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function Qr(t=re(),e=pe(),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}function es(t=re(),e=pe(),n){return`00-${t}-${e}-${n?"01":"00"}`}const ts=0,kt=1;let Qn=!1;function no(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:s,parent_span_id:i,status:o,origin:a,links:c}=N(t);return{parent_span_id:i,span_id:e,trace_id:n,data:r,op:s,status:o,origin:a,links:c}}function ro(t){const{spanId:e,traceId:n,isRemote:r}=t.spanContext(),s=r?e:N(t).parent_span_id,i=We(t).scope,o=r?(i==null?void 0:i.getPropagationContext().propagationSpanId)||pe():e;return{parent_span_id:s,span_id:o,trace_id:n}}function so(t){const{traceId:e,spanId:n}=t.spanContext(),r=V(t);return Qr(e,n,r)}function io(t){const{traceId:e,spanId:n}=t.spanContext(),r=V(t);return es(e,n,r)}function ns(t){if(t&&t.length>0)return t.map(o=>{var a=o,{context:c}=a,u=c,{spanId:e,traceId:n,traceFlags:r}=u,s=Hn(u,["spanId","traceId","traceFlags"]),{attributes:i}=a;return p({span_id:e,trace_id:n,sampled:r===kt,attributes:i},s)})}function oo(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===kt,attributes:s}))}function ne(t){return typeof t=="number"?er(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?er(t.getTime()):we()}function er(t){return t>9999999999?t/1e3:t}function N(t){if(lo(t))return t.getSpanJSON();const{spanId:e,traceId:n}=t.spanContext();if(uo(t)){const{attributes:r,startTime:s,name:i,endTime:o,status:a,links:c}=t;return{span_id:e,trace_id:n,data:r,description:i,parent_span_id:ao(t),start_timestamp:ne(s),timestamp:ne(o)||void 0,status:rs(a),op:r[qe],origin:r[Qt],links:ns(c)}}return{span_id:e,trace_id:n,start_timestamp:0,data:{}}}function ao(t){var e;return"parentSpanId"in t?t.parentSpanId:"parentSpanContext"in t?(e=t.parentSpanContext)==null?void 0:e.spanId:void 0}function co(t){var e;return E(p({},t),{attributes:Vn(t.attributes),links:(e=t.links)==null?void 0:e.map(n=>E(p({},n),{attributes:Vn(n.attributes)}))})}function uo(t){const e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function lo(t){return typeof t.getSpanJSON=="function"}function V(t){const{traceFlags:e}=t.spanContext();return e===kt}function rs(t){if(!(!t||t.code===Yr))return t.code===wt?"ok":t.message||"internal_error"}function po(t){return!t||t.code===wt||t.code===Yr||t.message==="cancelled"?"ok":"error"}const Ee="_sentryChildSpans",tn="_sentryRootSpan";function ss(t,e){const n=t[tn]||t;J(e,tn,n),t[Ee]?t[Ee].add(e):J(t,Ee,new Set([e]))}function fo(t){const e=new Set;function n(r){if(!e.has(r)&&V(r)){e.add(r);const s=r[Ee]?Array.from(r[Ee]):[];for(const i of s)n(i)}}return n(t),Array.from(e)}const L=ho;function ho(t){return t[tn]||t}function is(){const t=Y(),e=fe(t);return e.getActiveSpan?e.getActiveSpan():Ue(S())}function nn(){Qn||(Ce(()=>{console.warn("[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.")}),Qn=!0)}function bn(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 tr(t){m.log(`Ignoring span ${t.op} - ${t.description} because it matches \`ignoreSpans\`.`)}function Ge(t,e){if(!(e!=null&&e.length))return!1;for(const n of e){if(go(n)){if(t.description&&be(t.description,n))return g&&tr(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&&be(t.description,n.name):!0,i=n.op?t.op&&be(t.op,n.op):!0,o=n.attributes?Object.entries(n.attributes).every(([a,c])=>{var u;return _o((u=t.attributes)==null?void 0:u[a],c)}):!0;if(s&&i&&o)return g&&tr(t),!0}return!1}function _o(t,e){return typeof t=="string"&&(typeof e=="string"||e instanceof RegExp)?be(t,e):Array.isArray(t)&&Array.isArray(e)?t.length===e.length&&t.every((n,r)=>n===e[r]):t===e}function mo(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 go(t){return typeof t=="string"||t instanceof RegExp}const En="production",os="_frozenDsc";function Dt(t,e){J(t,os,e)}function as(t,e){const n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s={environment:n.environment||En,release:n.release,public_key:r,trace_id:t,org_id:Qi(e)};return e.emit("createDsc",s),s}function cs(t,e){const n=e.getPropagationContext();return n.dsc||as(n.traceId,t)}function ie(t){var _,y,v,I,j;const e=w();if(!e)return{};const n=L(t),r=N(n),s=r.data,i=n.spanContext().traceState,o=(y=(_=i==null?void 0:i.get("sentry.sample_rate"))!=null?_:s[Gr])!=null?y:s[$i];function a(F){return(typeof o=="number"||typeof o=="string")&&(F.sample_rate=`${o}`),F}const c=n[os];if(c)return a(c);const u=i==null?void 0:i.get("sentry.dsc"),d=u&&zi(u);if(d)return a(d);const l=as(t.spanContext().traceId,e),h=(v=s[ze])!=null?v:s["sentry.span.source"],f=r.description;return h!=="url"&&f&&(l.transaction=f),bn()&&(l.sampled=String(V(n)),l.sample_rand=(j=i==null?void 0:i.get("sentry.sample_rand"))!=null?j:(I=We(n).scope)==null?void 0:I.getPropagationContext().sampleRand.toString()),a(l),e.emit("createDsc",l,n),l}class q{constructor(e={}){this._traceId=e.traceId||re(),this._spanId=e.spanId||pe(),this.dropReason=e.dropReason}spanContext(){return{spanId:this._spanId,traceId:this._traceId,traceFlags:ts}}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 us(t){return!!t&&typeof t=="function"&&"_streamed"in t&&!!t._streamed}function X(t,e=[]){return[t,e]}function nr(t,e){const[n,r]=t;return[n,[...r,e]]}function rn(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 sn(t,e){return rn(t,(n,r)=>e.includes(r))}function on(t){const e=Et(P);return e.encodePolyfill?e.encodePolyfill(t):new TextEncoder().encode(t)}function yo(t){const[e,n]=t;let r=JSON.stringify(e);function s(i){typeof r=="string"?r=typeof i=="string"?r+i:[on(r),i]:r.push(typeof i=="string"?on(i):i)}for(const i of n){const[o,a]=i;if(s(`
3
3
  ${JSON.stringify(o)}
4
- `),typeof a=="string"||a instanceof Uint8Array)s(a);else{let c;try{c=JSON.stringify(a)}catch(u){c=JSON.stringify(z(a))}s(c)}}return typeof r=="string"?r:yo(r)}function yo(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 So(t){return[{type:"span"},t]}function bo(t){const e=typeof t.data=="string"?rn(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const as={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 Eo(t){return t in as}function Zn(t){return Eo(t)?as[t]:t}function cs(t){if(!(t!=null&&t.sdk))return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function To(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:de(r)}),s&&{trace:s})}function vo(t,e){var r,s,i,o;if(!e)return t;const n=t.sdk||{};return t.sdk=E(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 Io(t,e,n,r){const s=cs(n),i=l(l({sent_at:new Date(G()).toISOString()},s&&{sdk:s}),!!r&&e&&{dsn:de(e)}),o="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return X(i,[o])}function wo(t,e,n,r){const s=cs(n),i=t.type&&t.type!=="replay_event"?t.type:"event";vo(t,n==null?void 0:n.sdk);const o=To(t,s,r,e);return delete t.sdkProcessingMetadata,X(o,[[{type:i},t]])}function ko(t,e){function n(d){return!!d.trace_id&&!!d.public_key}const r=ie(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:de(s)}),{beforeSendSpan:a,ignoreSpans:c}=(e==null?void 0:e.getOptions())||{},u=c!=null&&c.length?t.filter(d=>{const _=N(d);return!We({description:_.description,op:_.op,attributes:_.data},c)}):t,p=t.length-u.length;p&&(e==null||e.recordDroppedEvent("before_send","span",p));const f=a?d=>{const _=N(d),y=os(a)?_:a(_);return y||(en(),_)}:N,h=[];for(const d of u){const _=f(d);_&&h.push(So(_))}return X(o,h)}function Ao(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >",parent_span_id:r}=N(t),{spanId:s}=t.spanContext(),i=Y(t),o=L(t),a=o===t,c=`[Tracing] Starting ${i?"sampled":"unsampled"} ${a?"root ":""}span`,u=[`op: ${n}`,`name: ${e}`,`ID: ${s}`];if(r&&u.push(`parent ID: ${r}`),!a){const{op:p,description:f}=N(o);u.push(`root ID: ${o.spanContext().spanId}`),p&&u.push(`root op: ${p}`),f&&u.push(`root description: ${f}`)}m.log(`${c}
4
+ `),typeof a=="string"||a instanceof Uint8Array)s(a);else{let c;try{c=JSON.stringify(a)}catch(u){c=JSON.stringify(z(a))}s(c)}}return typeof r=="string"?r:So(r)}function So(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 bo(t){return[{type:"span"},t]}function Eo(t){const e=typeof t.data=="string"?on(t.data):t.data;return[{type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType},e]}const ls={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 vo(t){return t in ls}function rr(t){return vo(t)?ls[t]:t}function ps(t){if(!(t!=null&&t.sdk))return;const{name:e,version:n}=t.sdk;return{name:e,version:n}}function To(t,e,n,r){var i;const s=(i=t.sdkProcessingMetadata)==null?void 0:i.dynamicSamplingContext;return p(p(p({event_id:t.event_id,sent_at:new Date(G()).toISOString()},e&&{sdk:e}),!!n&&r&&{dsn:he(r)}),s&&{trace:s})}function Io(t,e){var r,s,i,o;if(!e)return t;const n=t.sdk||{};return t.sdk=E(p({},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?p(p({},(o=t.sdk)==null?void 0:o.settings),e.settings):void 0}),t}function wo(t,e,n,r){const s=ps(n),i=p(p({sent_at:new Date(G()).toISOString()},s&&{sdk:s}),!!r&&e&&{dsn:he(e)}),o="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return X(i,[o])}function ko(t,e,n,r){const s=ps(n),i=t.type&&t.type!=="replay_event"?t.type:"event";Io(t,n==null?void 0:n.sdk);const o=To(t,s,r,e);return delete t.sdkProcessingMetadata,X(o,[[{type:i},t]])}function Ao(t,e){function n(f){return!!f.trace_id&&!!f.public_key}const r=ie(t[0]),s=e==null?void 0:e.getDsn(),i=e==null?void 0:e.getOptions().tunnel,o=p(p({sent_at:new Date(G()).toISOString()},n(r)&&{trace:r}),!!i&&s&&{dsn:he(s)}),{beforeSendSpan:a,ignoreSpans:c}=(e==null?void 0:e.getOptions())||{},u=c!=null&&c.length?t.filter(f=>{const _=N(f);return!Ge({description:_.description,op:_.op,attributes:_.data},c)}):t,d=t.length-u.length;d&&(e==null||e.recordDroppedEvent("before_send","span",d));const l=a?f=>{const _=N(f),y=us(a)?_:a(_);return y||(nn(),_)}:N,h=[];for(const f of u){const _=l(f);_&&h.push(bo(_))}return X(o,h)}function Ro(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >",parent_span_id:r}=N(t),{spanId:s}=t.spanContext(),i=V(t),o=L(t),a=o===t,c=`[Tracing] Starting ${i?"sampled":"unsampled"} ${a?"root ":""}span`,u=[`op: ${n}`,`name: ${e}`,`ID: ${s}`];if(r&&u.push(`parent ID: ${r}`),!a){const{op:d,description:l}=N(o);u.push(`root ID: ${o.spanContext().spanId}`),d&&u.push(`root op: ${d}`),l&&u.push(`root description: ${l}`)}m.log(`${c}
5
5
  ${u.join(`
6
- `)}`)}function Ro(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >"}=N(t),{spanId:r}=t.spanContext(),i=L(t)===t,o=`[Tracing] Finishing "${n}" ${i?"root ":""}span "${e}" with ID ${r}`;m.log(o)}function ee(t,e,n,r=ns()){const s=r&&L(r);s&&(g&&m.log(`[Measurement] Setting measurement on root span: ${t} = ${e} ${n}`),s.addEvent(t,{[Wr]:e,[qr]:n}))}function Qn(t){if(!t||t.length===0)return;const e={};return t.forEach(n=>{const r=n.attributes||{},s=r[qr],i=r[Wr];typeof s=="string"&&typeof i=="number"&&(e[n.name]={value:i,unit:s})}),e}function Ne(t){return t.getOptions().traceLifecycle==="stream"}const er=1e3;class Sn{constructor(e={}){this._traceId=e.traceId||re(),this._spanId=e.spanId||fe(),this._startTime=e.startTimestamp||ve(),this._links=e.links,this._attributes={},this.setAttributes(l({[Xt]:"manual",[ze]: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?wt:Zr}}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=ne(e)}setStatus(e){return this._status=e,this}updateName(e){return this._name=e,this.setAttribute(Ue,"custom"),this}end(e){this._endTime||(this._endTime=ne(e),Ro(this),this._onSpanEnded())}getSpanJSON(){return{data:this._attributes,description:this._name,op:this._attributes[ze],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:es(this._status),timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[Xt],profile_id:this._attributes[hn],exclusive_time:this._attributes[_n],measurements:Qn(this._events),is_segment:this._isStandaloneSpan&&L(this)===this||void 0,segment_id:this._isStandaloneSpan?L(this).spanContext().spanId:void 0,links:Qr(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===L(this),status:lo(this._status),attributes:this._attributes,links:io(this._links)}}isRecording(){return!this._endTime&&!!this._sampled}addEvent(e,n,r){g&&m.log("[Tracing] Adding an event to span:",e);const s=tr(n)?n:r||ve(),i=tr(n)?{}:n||{},o={name:e,time:ne(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===L(this)))return;if(this._isStandaloneSpan){this._sampled?Po(ko([this],e)):(g&&m.log("[Tracing] Discarding standalone span because its trace was not chosen to be sampled."),e&&e.recordDroppedEvent("sample_rate","span"));return}else if(e&&Ne(e)){e.emit("afterSegmentSpanEnd",this);return}const r=this._convertSpanToTransaction();r&&(qe(this).scope||b()).captureEvent(r)}_convertSpanToTransaction(){var f;if(!nr(N(this)))return;this._name||(g&&m.warn("Transaction has no name, falling back to `<unlabeled transaction>`."),this._name="<unlabeled transaction>");const{scope:e,isolationScope:n}=qe(this),r=(f=e==null?void 0:e.getScopeData().sdkProcessingMetadata)==null?void 0:f.normalizedRequest;if(this._sampled!==!0)return;const i=fo(this).filter(h=>h!==this&&!Co(h)).map(h=>N(h)).filter(nr),o=this._attributes[Ue];delete this._attributes[Gn];let a=!1;i.forEach(h=>{var d;delete h.data[Gn],(d=h.op)!=null&&d.startsWith("gen_ai.")&&(a=!0)});const c=l({contexts:{trace:to(this)},spans:i.length>er?i.sort((h,d)=>h.start_timestamp-d.start_timestamp).slice(0,er):i,start_timestamp:this._startTime,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{capturedSpanScope:e,capturedSpanIsolationScope:n,dynamicSamplingContext:ie(this),hasGenAiSpans:a},request:r},o&&{transaction_info:{source:o}}),u=Qn(this._events);return u&&Object.keys(u).length&&(g&&m.log("[Measurements] Adding measurements to transaction event",JSON.stringify(u,void 0,2)),c.measurements=u),c}}function tr(t){return t&&typeof t=="number"||t instanceof Date||Array.isArray(t)}function nr(t){return!!t.start_timestamp&&!!t.timestamp&&!!t.span_id&&!!t.trace_id}function Co(t){return t instanceof Sn&&t.isStandaloneSpan()}function Po(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 No(t,e,n=()=>{},r=()=>{}){let s;try{s=t()}catch(i){throw e(i),n(),i}return xo(s,e,n,r)}function xo(t,e,n,r){return le(t)?Ur(t,s=>{n(),r(s)},s=>{e(s),n()}):(n(),r(t),t)}function Oo(t,e,n){if(!gn(t))return[!1];let r,s;typeof t.tracesSampler=="function"?(s=t.tracesSampler(E(l({},e),{inheritOrSampleWith:a=>typeof e.parentSampleRate=="number"?e.parentSampleRate:typeof e.parentSampled=="boolean"?Number(e.parentSampled):a})),r=!0):e.parentSampled!==void 0?s=e.parentSampled:typeof t.tracesSampleRate!="undefined"&&(s=t.tracesSampleRate,r=!0);const i=mn(s);if(i===void 0)return g&&m.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 g&&m.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||g&&m.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(s)})`),[o,i,r]}const Do="__SENTRY_SUPPRESS_TRACING__";function me(t,e){const n=bn();if(n.startSpan)return n.startSpan(t,e);const r=fs(t),{forceTransaction:s,parentSpan:i,scope:o}=t,a=o==null?void 0:o.clone();return Pe(a,()=>Fo(i)(()=>{const u=b(),p=ps(u,i),f=w(),h=t.onlyIfParent&&!p,d=h?new q:ls({parentSpan:p,spanArguments:r,forceTransaction:s,scope:u});return h&&(f==null||f.recordDroppedEvent("no_parent_span","span")),(!$o(d)||!p)&&Be(u,d),No(()=>e(d),()=>{const{status:_}=N(d);d.isRecording()&&(!_||_==="ok")&&d.setStatus({code:C,message:"internal_error"})},()=>{d.end()})}))}function kt(t){const e=bn();if(e.startInactiveSpan)return e.startInactiveSpan(t);const n=fs(t),{forceTransaction:r,parentSpan:s}=t;return(t.scope?o=>Pe(t.scope,o):s!==void 0?o=>us(s,o):o=>o())(()=>{const o=b(),a=ps(o,s),c=w();return t.onlyIfParent&&!a?(c==null||c.recordDroppedEvent("no_parent_span","span"),new q):ls({parentSpan:a,spanArguments:n,forceTransaction:r,scope:o})})}function us(t,e){const n=bn();return n.withActiveSpan?n.withActiveSpan(t,e):Pe(r=>(Be(r,t||void 0),e(r)))}function ls({parentSpan:t,spanArguments:e,forceTransaction:n,scope:r}){var a;if(!gn()){const c=new q;if(n||!t){const u=l({sampled:"false",sample_rate:"0",transaction:e.name},ie(c));Ot(c,u)}return c}const s=w();if(Lo(s,e))return En(r)||s==null||s.recordDroppedEvent("ignored","span"),new q({dropReason:"ignored",traceId:(a=t==null?void 0:t.spanContext().traceId)!=null?a:r.getPropagationContext().traceId});const i=A();let o;if(t&&!n)o=Mo(t,r,e),ts(t,o);else if(t){const c=ie(t),{traceId:u,spanId:p}=t.spanContext(),f=Y(t);o=rr(l({traceId:u,parentSpanId:p},e),r,f),Ot(o,c)}else{const{traceId:c,dsc:u,parentSpanId:p,sampled:f}=l(l({},i.getPropagationContext()),r.getPropagationContext());o=rr(l({traceId:c,parentSpanId:p},e),r,f),u&&Ot(o,u)}return Ao(o),Bi(o,r,i),o}function fs(t){const e=t.experimental||{},n=l({isStandalone:e.standalone},t);if(t.startTime){const r=l({},n);return r.startTimestamp=ne(t.startTime),delete r.startTime,r}return n}function bn(){const t=V();return pe(t)}function rr(t,e,n){var y,T;const r=w(),s=(r==null?void 0:r.getOptions())||{},{name:i=""}=t,o={spanAttributes:l({},t.attributes),spanName:i,parentSampled:n};r==null||r.emit("beforeSampling",o,{decision:!1});const a=(y=o.parentSampled)!=null?y:n,c=o.spanAttributes,u=e.getPropagationContext(),p=En(e),[f,h,d]=p?[!1]:Oo(s,{name:i,parentSampled:a,attributes:c,parentSampleRate:mn((T=u.dsc)==null?void 0:T.sample_rate)},u.sampleRand),_=new Sn(E(l({},t),{attributes:l({[Ue]:"custom",[zr]:h!==void 0&&d?h:void 0},c),sampled:f}));return!f&&r&&!p&&(g&&m.log("[Tracing] Discarding root span because its trace was not chosen to be sampled."),r.recordDroppedEvent("sample_rate",Ne(r)?"span":"transaction")),r&&r.emit("spanStart",_),_}function Mo(t,e,n){const{spanId:r,traceId:s}=t.spanContext(),i=En(e),o=i?!1:Y(t),a=o?new Sn(E(l({},n),{parentSpanId:r,traceId:s,sampled:o})):new q({traceId:s});ts(t,a);const c=w();return c&&(Ne(c)&&a instanceof q&&(t instanceof q&&t.dropReason?(a.dropReason=t.dropReason,c.recordDroppedEvent(t.dropReason,"span")):i||(a.dropReason="sample_rate",c.recordDroppedEvent("sample_rate","span"))),c.emit("spanStart",a),n.endTimestamp&&(c.emit("spanEnd",a),c.emit("afterSpanEnd",a))),a}function ps(t,e){if(e)return e;if(e===null)return;const n=He(t);if(!n)return;const r=w();return(r?r.getOptions():{}).parentSpanIsAlwaysRootSpan?L(n):n}function Fo(t){return t!==void 0?e=>us(t,e):e=>e()}function Lo(t,e){var r;const n=t==null?void 0:t.getOptions().ignoreSpans;return!t||!Ne(t)||!(n!=null&&n.length)?!1:We({description:e.name||"",op:((r=e.attributes)==null?void 0:r[ze])||e.op,attributes:e.attributes},n)}function $o(t){return t instanceof q&&t.dropReason==="ignored"}function En(t){return t.getScopeData().sdkProcessingMetadata[Do]===!0}function jo(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;Bo(t,e),r&&zo(t,r),qo(t,n),Ho(t,s),Uo(t,i)}function sr(t,e){const{extra:n,tags:r,attributes:s,user:i,contexts:o,level:a,sdkProcessingMetadata:c,breadcrumbs:u,fingerprint:p,eventProcessors:f,attachments:h,propagationContext:d,transactionName:_,span:y}=e;_e(t,"extra",n),_e(t,"tags",r),_e(t,"attributes",s),_e(t,"user",i),_e(t,"contexts",o),t.sdkProcessingMetadata=Ce(t.sdkProcessingMetadata,c,2),a&&(t.level=a),_&&(t.transactionName=_),y&&(t.span=y),u.length&&(t.breadcrumbs=[...t.breadcrumbs,...u]),p.length&&(t.fingerprint=[...t.fingerprint,...p]),f.length&&(t.eventProcessors=[...t.eventProcessors,...f]),h.length&&(t.attachments=[...t.attachments,...h]),t.propagationContext=l(l({},t.propagationContext),d)}function _e(t,e,n){t[e]=Ce(t[e],n,1)}function ds(t,e){const n=Mi().getScopeData();return t&&sr(n,t.getScopeData()),e&&sr(n,e.getScopeData()),n}function Bo(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:a}=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),a&&t.type!=="transaction"&&(t.transaction=a)}function Ho(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Uo(t,e){t.sdkProcessingMetadata=l(l({},t.sdkProcessingMetadata),e)}function zo(t,e){t.contexts=l({trace:no(e)},t.contexts),t.sdkProcessingMetadata=l({dynamicSamplingContext:ie(e)},t.sdkProcessingMetadata);const n=L(e),r=N(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function qo(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 Dt=0,ir=1,or=2;function Tn(t){return new Ie(e=>{e(t)})}function vn(t){return new Ie((e,n)=>{n(t)})}class Ie{constructor(e){this._state=Dt,this._handlers=[],this._runExecutor(e)}then(e,n){return new Ie((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 Ie((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===Dt)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===ir&&n[1](this._value),this._state===or&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,o)=>{if(this._state===Dt){if(le(o)){o.then(r,s);return}this._state=i,this._value=o,this._executeHandlers()}},r=i=>{n(ir,i)},s=i=>{n(or,i)};try{e(r,s)}catch(i){s(i)}}}function Wo(t,e,n,r=0){try{const s=sn(e,n,t,r);return le(s)?s:Tn(s)}catch(s){return vn(s)}}function sn(t,e,n,r){const s=n[r];if(!t||!s)return t;const i=s(l({},t),e);return g&&i===null&&m.log(`Event processor "${s.id||"?"}" dropped event`),le(i)?i.then(o=>sn(o,e,n,r+1)):sn(i,e,n,r+1)}let H,ar,cr,U;function Go(t){const e=P._sentryDebugIds,n=P._debugIds;if(!e&&!n)return{};const r=e?Object.keys(e):[],s=n?Object.keys(n):[];if(U&&r.length===ar&&s.length===cr)return U;ar=r.length,cr=s.length,U={},H||(H={});const i=(o,a)=>{for(const c of o){const u=a[c],p=H==null?void 0:H[c];if(p&&U&&u)U[p[0]]=u,H&&(H[c]=[p[0],u]);else if(u){const f=t(c);for(let h=f.length-1;h>=0;h--){const d=f[h],_=d==null?void 0:d.filename;if(_&&U&&H){U[_]=u,H[c]=[_,u];break}}}}};return e&&i(r,e),n&&i(s,n),U}function Jo(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=t,c=E(l({},e),{event_id:e.event_id||n.event_id||M(),timestamp:e.timestamp||Re()}),u=n.integrations||t.integrations.map(I=>I.name);Ko(c,t),Xo(c,u),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&Vo(c,t.stackParser);const p=Qo(r,n.captureContext);n.mechanism&&bi(c,n.mechanism);const f=s?s.getEventProcessors():[],h=ds(i,p),d=[...n.attachments||[],...h.attachments];d.length&&(n.attachments=d),jo(c,h);const _=[...f,...h.eventProcessors];return(n.data&&n.data.__sentry__===!0?Tn(c):Wo(_,c,n)).then(I=>(I&&Yo(I),typeof o=="number"&&o>0?Zo(I,o,a):I))}function Ko(t,e){var a,c;const{environment:n,release:r,dist:s,maxValueLength:i}=e;t.environment=t.environment||n||yn,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const o=t.request;o!=null&&o.url&&i&&(o.url=Vt(o.url,i)),i&&((c=(a=t.exception)==null?void 0:a.values)==null||c.forEach(u=>{u.value&&(u.value=Vt(u.value,i))}))}function Vo(t,e){var r,s;const n=Go(e);(s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.filename&&(c.debug_id=n[c.filename])})})}function Yo(t){var r,s;const e={};if((s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.debug_id&&(c.abs_path?e[c.abs_path]=c.debug_id:c.filename&&(e[c.filename]=c.debug_id),delete c.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 Xo(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function Zo(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 Qo(t,e){if(!e)return t;const n=t?t.clone():new $;return n.update(e),n}function ea(t){if(t)return ta(t)?{captureContext:t}:ra(t)?{captureContext:t}:t}function ta(t){return t instanceof $||typeof t=="function"}const na=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function ra(t){return Object.keys(t).some(e=>na.includes(e))}function te(t,e){return b().captureException(t,ea(e))}function sa(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 ia(t,e){return b().captureEvent(t,e)}function W(t,e){A().setContext(t,e)}function oa(t){A().setExtras(t)}function aa(t,e){A().setExtra(t,e)}function ca(t){A().setTags(t)}function ua(t,e){A().setTag(t,e)}function la(t){A().setUser(t)}function fa(){return A().lastEventId()}function hs(t){return O(this,null,function*(){const e=w();return e?e.flush(t):(g&&m.warn("Cannot flush events. No client defined."),Promise.resolve(!1))})}function pa(t){return O(this,null,function*(){const e=w();return e?e.close(t):(g&&m.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))})}function _s(){const t=w();return(t==null?void 0:t.getOptions().enabled)!==!1&&!!(t!=null&&t.getTransport())}function da(t){A().addEventProcessor(t)}function ms(t){const e=A(),{user:n}=ds(e,b()),{userAgent:r}=P.navigator||{},s=Lr(l(l({user:n},r&&{userAgent:r}),t)),i=e.getSession();return(i==null?void 0:i.status)==="ok"&&K(i,{status:"exited"}),At(),e.setSession(s),s}function At(){const t=A(),n=b().getSession()||t.getSession();n&&$r(n),gs(),t.setSession()}function gs(){const t=A(),e=w(),n=t.getSession();n&&e&&e.captureSession(n)}function on(t=!1){if(t){At();return}gs()}const ha="7";function _a(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function ma(t){return`${_a(t)}${t.projectId}/envelope/`}function ga(t,e){const n={sentry_version:ha};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function ya(t,e,n){return e||`${ma(t)}?${ga(t,n)}`}const ur=[];function Sa(t,e){const n={};return e.forEach(r=>{r!=null&&r.beforeSetup&&r.beforeSetup(t)}),e.forEach(r=>{r&&ys(t,r,n)}),n}function lr(t,e){for(const n of e)n!=null&&n.afterAllSetup&&n.afterAllSetup(t)}function ys(t,e,n){if(n[e.name]){g&&m.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,!ur.includes(e.name)&&typeof e.setupOnce=="function"&&(e.setupOnce(),ur.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))}),g&&m.log(`Integration installed: ${e.name}`)}function ba(t){const e=w();if(!e){g&&m.warn(`Cannot add integration "${t.name}" because no SDK Client is available.`);return}e.addIntegration(t)}function Ea(){return typeof __SENTRY_BROWSER_BUNDLE__!="undefined"&&!!__SENTRY_BROWSER_BUNDLE__}function Ta(){return!Ea()&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]"}function In(){return typeof window!="undefined"&&(!Ta()||va())}function va(){const t=P.process;return(t==null?void 0:t.type)==="renderer"}function Ia(t,e){const n=e?"auto":"never";return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},E(l({version:2},In()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function wa(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=de(r)),X(i,[Ia(t,s)])}function fr(t,e){var i;const n=(i=e!=null?e:ka(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=wa(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Ss().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function ka(t){return Ss().get(t)}function Ss(){return ue("clientToLogBufferMap",()=>new WeakMap)}function Aa(t,e){const n=e?"auto":"never";return[{type:"trace_metric",item_count:t.length,content_type:"application/vnd.sentry.items.trace-metric+json"},E(l({version:2},In()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function Ra(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=de(r)),X(i,[Aa(t,s)])}function Ca(t,e){var i;const n=(i=e!=null?e:Pa(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=Ra(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);bs().set(t,[]),t.emit("flushMetrics"),t.sendEnvelope(s)}function Pa(t){return bs().get(t)}function bs(){return ue("clientToMetricBufferMap",()=>new WeakMap)}function Na(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 ao(e)}function xa(t,e){var i,o,a;if(t.type!=="transaction"||!((i=t.spans)!=null&&i.length)||!((o=t.sdkProcessingMetadata)!=null&&o.hasGenAiSpans)||!e.getOptions().streamGenAiSpans||Ne(e))return;const n=[],r=[];for(const c of t.spans)(a=c.op)!=null&&a.startsWith("gen_ai.")?n.push(Na(c)):r.push(c);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"},E(l({version:2},In()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}}),{items:n})]}function wn(t){return typeof t=="object"&&typeof t.unref=="function"&&t.unref(),t}const kn=Symbol.for("SentryBufferFullError");function Es(t=100){const e=new Set;function n(){return e.size<t}function r(o){e.delete(o)}function s(o){if(!n())return vn(kn);const a=o();return e.add(a),a.then(()=>r(a),()=>r(a)),a}function i(o){if(!e.size)return Tn(!0);const a=Promise.allSettled(Array.from(e)).then(()=>!0);if(!o)return a;const c=[a,new Promise(u=>wn(setTimeout(()=>u(!1),o)))];return Promise.race(c)}return{get $(){return Array.from(e)},add:s,drain:i}}const Oa=60*1e3;function Ts(t,e=G()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?Oa:r-e}function Da(t,e){return t[e]||t.all||0}function Ma(t,e,n=G()){return Da(t,e)>n}function Fa(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 a of i.trim().split(",")){const[c,u,,,p]=a.split(":",5),f=parseInt(c,10),h=(isNaN(f)?60:f)*1e3;if(!u)s.all=r+h;else for(const d of u.split(";"))d==="metric_bucket"?(!p||p.split(";").includes("custom"))&&(s[d]=r+h):s[d]=r+h}else o?s.all=r+Ts(o,r):e===429&&(s.all=r+60*1e3);return s}const vs=64;function La(t,e,n=Es(t.bufferSize||vs)){let r={};const s=o=>n.drain(o);function i(o){const a=[];if(tn(o,(f,h)=>{const d=Zn(h);Ma(r,d)?t.recordDroppedEvent("ratelimit_backoff",d):a.push(f)}),a.length===0)return Promise.resolve({});const c=X(o[0],a),u=f=>{if(nn(c,["client_report"])){g&&m.warn(`Dropping client report. Will not send outcomes (reason: ${f}).`);return}tn(c,(h,d)=>{t.recordDroppedEvent(f,Zn(d))})},p=()=>e({body:go(c)}).then(f=>f.statusCode===413?(g&&m.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),u("send_error"),f):(g&&f.statusCode!==void 0&&(f.statusCode<200||f.statusCode>=300)&&m.warn(`Sentry responded with status code ${f.statusCode} to sent event.`),r=Fa(r,f),f),f=>{throw u("network_error"),g&&m.error("Encountered error running transport request:",f),f});return n.add(p).then(f=>f,f=>{if(f===kn)return g&&m.error("Skipped sending event because buffer is full."),u("queue_overflow"),Promise.resolve({});throw f})}return{send:i,flush:s}}function $a(t,e,n){const r=[{type:"client_report"},{timestamp:Re(),discarded_events:t}];return X(e?{dsn:e}:{},[r])}function Is(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 c,u,p;const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:o,op:a}=(u=(c=t.contexts)==null?void 0:c.trace)!=null?u:{};return{data:o!=null?o:{},description:t.transaction,op:a,parent_span_id:n,span_id:r!=null?r:"",start_timestamp:(p=t.start_timestamp)!=null?p:0,status:s,timestamp:t.timestamp,trace_id:e!=null?e:"",origin:i,profile_id:o==null?void 0:o[hn],exclusive_time:o==null?void 0:o[_n],measurements:t.measurements,is_segment:!0}}function Ba(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&&{[hn]:t.profile_id}),t.exclusive_time&&{[_n]:t.exclusive_time})}},measurements:t.measurements}}const Me=["forwarded","-ip","remote-","via","-user"];function Ha(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:Me},httpHeaders:{request:{deny:Me},response:{deny:Me}},httpBodies:[],queryParams:{deny:Me},genAI:{inputs:!1,outputs:!1},stackFrameVariables:!0,frameContextLines:7}}const Ua={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 za(t){var r,s,i,o,a,c,u,p,f,h,d,_,y,T,I;const e=t.dataCollection!=null?Ua:Ha(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:(a=(o=n.httpHeaders)==null?void 0:o.request)!=null?a:e.httpHeaders.request,response:(u=(c=n.httpHeaders)==null?void 0:c.response)!=null?u:e.httpHeaders.response},httpBodies:(p=n.httpBodies)!=null?p:e.httpBodies,queryParams:(f=n.queryParams)!=null?f:e.queryParams,genAI:{inputs:(d=(h=n.genAI)==null?void 0:h.inputs)!=null?d:e.genAI.inputs,outputs:(y=(_=n.genAI)==null?void 0:_.outputs)!=null?y:e.genAI.outputs},stackFrameVariables:(T=n.stackFrameVariables)!=null?T:e.stackFrameVariables,frameContextLines:(I=n.frameContextLines)!=null?I:e.frameContextLines}}const pr="Not capturing exception because it's already been captured.",dr="Discarded session because of missing or non-string release",ws=Symbol.for("SentryInternalError"),ks=Symbol.for("SentryDoNotSendEventError"),qa=5e3;function Fe(t){return{message:t,[ws]:!0}}function Mt(t){return{message:t,[ks]:!0}}function hr(t){return!!t&&typeof t=="object"&&ws in t}function _r(t){return!!t&&typeof t=="object"&&ks in t}function mr(t,e,n,r,s){let i=0,o,a=!1;t.on(n,()=>{i=0,clearTimeout(o),a=!1}),t.on(e,c=>{var u;if(i+=r(c),i>=8e5)s(t);else if(!a){const p=(u=t.getOptions()._flushInterval)!=null?u:qa;p>0&&(a=!0,o=wn(setTimeout(()=>{s(t)},p)))}}),t.on("flush",()=>{s(t)})}class Wa{constructor(e){var r,s,i,o,a,c,u;if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Es((s=(r=e.transportOptions)==null?void 0:r.bufferSize)!=null?s:vs),this._dataCollection=za(e),e.dsn?this._dsn=Qi(e.dsn):g&&m.warn("No DSN provided, client will not send events."),this._dsn){const p=ya(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport(E(l({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this)},e.transportOptions),{url:p}))}this._options.enableLogs=(o=this._options.enableLogs)!=null?o:(i=this._options._experiments)==null?void 0:i.enableLogs,this._options.enableLogs&&mr(this,"afterCaptureLog","flushLogs",Va,fr),((u=(c=this._options.enableMetrics)!=null?c:(a=this._options._experiments)==null?void 0:a.enableMetrics)!=null?u:!0)&&mr(this,"afterCaptureMetric","flushMetrics",Ka,Ca)}captureException(e,n,r){const s=M();if(Un(e))return g&&m.log(pr),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:M()},r),o=xr(e)?e:String(e),a=Or(e),c=a?this.eventFromMessage(o,n,i):this.eventFromException(e,i);return this._process(()=>c.then(u=>this._captureEvent(u,i,s)),a?"unknown":"error"),i.event_id}captureEvent(e,n,r){const s=M();if(n!=null&&n.originalException&&Un(n.originalException))return g&&m.log(pr),s;const i=l({event_id:s},n),o=e.sdkProcessingMetadata||{},a=o.capturedSpanScope,c=o.capturedSpanIsolationScope,u=gr(e.type);return this._process(()=>this._captureEvent(e,i,a||r,c),u),i.event_id}captureSession(e){this.sendSession(e),K(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*(){fr(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),ys(this,e,this._integrations),n||lr(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);const r=xa(e,this);let s=wo(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])s=Xn(s,bo(i));r&&(s=Xn(s,r)),this.sendEnvelope(s).then(i=>this.emit("afterSendEvent",e,i))}sendSession(e){const{release:n,environment:r=yn}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){g&&m.warn(dr);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){g&&m.warn(dr);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=Io(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}`;g&&m.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 g&&m.error("Error while sending envelope:",n),{}}return g&&m.error("Transport disabled"),{}})}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=Sa(this,e),lr(this,e)}_updateSessionFromEvent(e,n){var c,u;let r=n.level==="fatal",s=!1;const i=(c=n.exception)==null?void 0:c.values;if(i){s=!0,r=!1;for(const p of i)if(((u=p.mechanism)==null?void 0:u.handled)===!1){r=!0;break}}const o=e.status==="ok";(o&&e.errors===0||o&&r)&&(K(e,E(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),Jo(i,e,n,r,this,s).then(a=>{var u;if(a===null)return a;this.emit("postprocessEvent",a,n),a.contexts=l({trace:l(l({},(u=a.contexts)==null?void 0:u.trace),Fi(r))},a.contexts);const c=is(this,r);return a.sdkProcessingMetadata=l({dynamicSamplingContext:c},a.sdkProcessingMetadata),a})}_captureEvent(e,n={},r=b(),s=A()){return g&&an(e)&&m.log(`Captured error event \`${Is(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{g&&(_r(i)?m.log(i.message):hr(i)?m.warn(i.message):m.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:o}=i,a=As(e),c=an(e),p=`before send for type \`${e.type||"error"}\``,f=typeof o=="undefined"?void 0:mn(o);if(c&&typeof f=="number"&&je()>f)return this.recordDroppedEvent("sample_rate","error"),vn(Mt(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const h=gr(e.type);return this._prepareEvent(e,n,r,s).then(d=>{var T;if(d===null)throw this.recordDroppedEvent("event_processor",h),Mt("An event processor returned `null`, will not send event.");if(((T=n.data)==null?void 0:T.__sentry__)===!0)return d;const y=Ja(this,i,d,n);return Ga(y,p)}).then(d=>{var T;if(d===null){if(this.recordDroppedEvent("before_send",h),a){const j=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",j)}throw Mt(`${p} returned \`null\`, will not send event.`)}const _=r.getSession()||s.getSession();if(c&&_&&this._updateSessionFromEvent(_,d),a){const I=((T=d.sdkProcessingMetadata)==null?void 0:T.spanCountBeforeProcessing)||0,j=d.spans?d.spans.length:0,F=I-j;F>0&&this.recordDroppedEvent("before_send","span",F)}const y=d.transaction_info;if(a&&y&&d.transaction!==e.transaction){const I="custom";d.transaction_info=E(l({},y),{source:I})}return this.sendEvent(d,n),d}).then(null,d=>{throw _r(d)||hr(d)?d:(this.captureException(d,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:d}),Fe(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
7
- Reason: ${d}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===kn&&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(){g&&m.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){g&&m.log("No outcomes to send");return}if(!this._dsn){g&&m.log("No dsn provided, will not send outcomes");return}g&&m.log("Sending outcomes:",e);const n=$a(e,this._options.tunnel&&de(this._dsn));this.sendEnvelope(n)}}function gr(t){return t==="replay_event"?"replay":t||"error"}function Ga(t,e){const n=`${e} must return \`null\` or a valid event.`;if(le(t))return t.then(r=>{if(!Jt(r)&&r!==null)throw Fe(n);return r},r=>{throw Fe(`${e} rejected with ${r}`)});if(!Jt(t)&&t!==null)throw Fe(n);return t}function Ja(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,a=!os(e.beforeSendSpan)&&e.beforeSendSpan;let c=n;if(an(c)&&s)return s(c,r);if(As(c)){if(a||o){const u=ja(c);if(o!=null&&o.length&&We({description:u.description,op:u.op,attributes:u.data},o))return null;if(a){const p=a(u);p?c=Ce(n,Ba(p)):en()}if(c.spans){const p=[],f=c.spans;for(const d of f){if(o!=null&&o.length&&We({description:d.description,op:d.op,attributes:d.data},o)){_o(f,d);continue}if(a){const _=a(d);_?p.push(_):(en(),p.push(d))}else p.push(d)}const h=c.spans.length-p.length;h&&t.recordDroppedEvent("before_send","span",h),c.spans=p}}if(i){if(c.spans){const u=c.spans.length;c.sdkProcessingMetadata=E(l({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(c,r)}}return c}function an(t){return t.type===void 0}function As(t){return t.type==="transaction"}function Ka(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+Rs(t.attributes)}function Va(t){let e=0;return t.message&&(e+=t.message.length*2),e+Rs(t.attributes)}function Rs(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*yr(n[0]):Or(n)?e+=yr(n):e+=100}),e}function yr(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function Ya(t,e){e.debug===!0&&(g?m.enable():Ae(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),b().update(e.initialScope);const r=new t(e);return Xa(r),r.init(),r}function Xa(t){b().setClient(t)}const Ft=100,Lt=5e3,Za=36e5;function Qa(t){function e(...n){g&&m.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=Lt,o;function a(f,h,d){return nn(f,["client_report"])?!1:n.shouldStore?n.shouldStore(f,h,d):!0}function c(f){o&&clearTimeout(o),o=wn(setTimeout(()=>O(null,null,function*(){o=void 0;const h=yield s.shift();h&&(e("Attempting to send previously queued event"),h[0].sent_at=new Date(G()).toISOString(),p(h,!0).catch(d=>{e("Failed to retry sending",d)}))}),f))}function u(){o||(c(i),i=Math.min(i*2,Za))}function p(f,h=!1){return O(this,null,function*(){var d,_;if(!h&&nn(f,["replay_event","replay_recording"]))return yield s.push(f),c(Ft),{};try{if(n.shouldSend&&(yield n.shouldSend(f))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const y=yield r.send(f);let T=Ft;if(y){if((d=y.headers)!=null&&d["retry-after"])T=Ts(y.headers["retry-after"]);else if((_=y.headers)!=null&&_["x-sentry-rate-limits"])T=6e4;else if((y.statusCode||0)>=400)return y}return c(T),i=Lt,y}catch(y){if(yield a(f,y,i))return h?yield s.unshift(f):yield s.push(f),u(),e("Error sending. Event queued.",y),{};throw y}})}return n.flushAtStartup&&u(),{send:p,flush:f=>(f===void 0&&(i=Lt,c(Ft)),r.flush(f))}}}function ec(t={}){const e=t.client||w();if(!_s()||!e)return{};const n=V(),r=pe(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||b(),i=t.span||ns(),o=i?ro(i):tc(s),a=i?ie(i):is(e,s),c=zi(a);if(!eo.test(o))return m.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const p={"sentry-trace":o,baggage:c};return t.propagateTraceparent&&(p.traceparent=i?so(i):nc(s)),p}function tc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return Yr(e,r,n)}function nc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return Xr(e,r,n)}const rc=100;function k(t,e){const n=w(),r=A();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=rc}=n.getOptions();if(i<=0)return;const o=Re(),a=l({timestamp:o},t),c=s?Ae(()=>s(a,e)):a;c!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",c,e),r.addBreadcrumb(c,i))}const sc=[/^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$/],ic="EventFilters",oc=(t={})=>{let e;return{name:ic,setup(n){const r=n.getOptions();e=Sr(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=Sr(t,i)}return ac(n,e)?null:n}}};function Sr(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:sc],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function ac(t,e){if(t.type){if(t.type==="transaction"&&uc(t,e.ignoreTransactions))return g&&m.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
8
- Event: ${Q(t)}`),!0}else{if(cc(t,e.ignoreErrors))return g&&m.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
9
- Event: ${Q(t)}`),!0;if(dc(t))return g&&m.warn(`Event dropped due to not having an error message, error type or stacktrace.
10
- Event: ${Q(t)}`),!0;if(lc(t,e.denyUrls))return g&&m.warn(`Event dropped due to being matched by \`denyUrls\` option.
6
+ `)}`)}function Co(t){if(!g)return;const{description:e="< unknown name >",op:n="< unknown op >"}=N(t),{spanId:r}=t.spanContext(),i=L(t)===t,o=`[Tracing] Finishing "${n}" ${i?"root ":""}span "${e}" with ID ${r}`;m.log(o)}function ee(t,e,n,r=is()){const s=r&&L(r);s&&(g&&m.log(`[Measurement] Setting measurement on root span: ${t} = ${e} ${n}`),s.addEvent(t,{[Kr]:e,[Jr]:n}))}function sr(t){if(!t||t.length===0)return;const e={};return t.forEach(n=>{const r=n.attributes||{},s=r[Jr],i=r[Kr];typeof s=="string"&&typeof i=="number"&&(e[n.name]={value:i,unit:s})}),e}function xe(t){return t.getOptions().traceLifecycle==="stream"}const ir=1e3;class vn{constructor(e={}){this._traceId=e.traceId||re(),this._spanId=e.spanId||pe(),this._startTime=e.startTimestamp||we(),this._links=e.links,this._attributes={},this.setAttributes(p({[Qt]:"manual",[qe]: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?kt:ts}}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=ne(e)}setStatus(e){return this._status=e,this}updateName(e){return this._name=e,this.setAttribute(ze,"custom"),this}end(e){this._endTime||(this._endTime=ne(e),Co(this),this._onSpanEnded())}getSpanJSON(){return{data:this._attributes,description:this._name,op:this._attributes[qe],parent_span_id:this._parentSpanId,span_id:this._spanId,start_timestamp:this._startTime,status:rs(this._status),timestamp:this._endTime,trace_id:this._traceId,origin:this._attributes[Qt],profile_id:this._attributes[gn],exclusive_time:this._attributes[yn],measurements:sr(this._events),is_segment:this._isStandaloneSpan&&L(this)===this||void 0,segment_id:this._isStandaloneSpan?L(this).spanContext().spanId:void 0,links:ns(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===L(this),status:po(this._status),attributes:this._attributes,links:oo(this._links)}}isRecording(){return!this._endTime&&!!this._sampled}addEvent(e,n,r){g&&m.log("[Tracing] Adding an event to span:",e);const s=or(n)?n:r||we(),i=or(n)?{}:n||{},o={name:e,time:ne(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===L(this)))return;if(this._isStandaloneSpan){this._sampled?No(Ao([this],e)):(g&&m.log("[Tracing] Discarding standalone span because its trace was not chosen to be sampled."),e&&e.recordDroppedEvent("sample_rate","span"));return}else if(e&&xe(e)){e.emit("afterSegmentSpanEnd",this);return}const r=this._convertSpanToTransaction();r&&(We(this).scope||S()).captureEvent(r)}_convertSpanToTransaction(){var l;if(!ar(N(this)))return;this._name||(g&&m.warn("Transaction has no name, falling back to `<unlabeled transaction>`."),this._name="<unlabeled transaction>");const{scope:e,isolationScope:n}=We(this),r=(l=e==null?void 0:e.getScopeData().sdkProcessingMetadata)==null?void 0:l.normalizedRequest;if(this._sampled!==!0)return;const i=fo(this).filter(h=>h!==this&&!Po(h)).map(h=>N(h)).filter(ar),o=this._attributes[ze];delete this._attributes[Xn];let a=!1;i.forEach(h=>{var f;delete h.data[Xn],(f=h.op)!=null&&f.startsWith("gen_ai.")&&(a=!0)});const c=p({contexts:{trace:no(this)},spans:i.length>ir?i.sort((h,f)=>h.start_timestamp-f.start_timestamp).slice(0,ir):i,start_timestamp:this._startTime,timestamp:this._endTime,transaction:this._name,type:"transaction",sdkProcessingMetadata:{capturedSpanScope:e,capturedSpanIsolationScope:n,dynamicSamplingContext:ie(this),hasGenAiSpans:a},request:r},o&&{transaction_info:{source:o}}),u=sr(this._events);return u&&Object.keys(u).length&&(g&&m.log("[Measurements] Adding measurements to transaction event",JSON.stringify(u,void 0,2)),c.measurements=u),c}}function or(t){return t&&typeof t=="number"||t instanceof Date||Array.isArray(t)}function ar(t){return!!t.start_timestamp&&!!t.timestamp&&!!t.span_id&&!!t.trace_id}function Po(t){return t instanceof vn&&t.isStandaloneSpan()}function No(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 xo(t,e,n=()=>{},r=()=>{}){let s;try{s=t()}catch(i){throw e(i),n(),i}return Oo(s,e,n,r)}function Oo(t,e,n,r){return le(t)?Wr(t,s=>{n(),r(s)},s=>{e(s),n()}):(n(),r(t),t)}function Do(t,e,n){if(!bn(t))return[!1];let r,s;typeof t.tracesSampler=="function"?(s=t.tracesSampler(E(p({},e),{inheritOrSampleWith:a=>typeof e.parentSampleRate=="number"?e.parentSampleRate:typeof e.parentSampled=="boolean"?Number(e.parentSampled):a})),r=!0):e.parentSampled!==void 0?s=e.parentSampled:typeof t.tracesSampleRate!="undefined"&&(s=t.tracesSampleRate,r=!0);const i=Sn(s);if(i===void 0)return g&&m.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 g&&m.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||g&&m.log(`[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = ${Number(s)})`),[o,i,r]}const Mo="__SENTRY_SUPPRESS_TRACING__";function ge(t,e){const n=Tn();if(n.startSpan)return n.startSpan(t,e);const r=hs(t),{forceTransaction:s,parentSpan:i,scope:o}=t,a=o==null?void 0:o.clone();return de(a,()=>Lo(i)(()=>{const u=S(),d=_s(u,i),l=w(),h=t.onlyIfParent&&!d,f=h?new q:ds({parentSpan:d,spanArguments:r,forceTransaction:s,scope:u});return h&&(l==null||l.recordDroppedEvent("no_parent_span","span")),(!jo(f)||!d)&&He(u,f),xo(()=>e(f),()=>{const{status:_}=N(f);f.isRecording()&&(!_||_==="ok")&&f.setStatus({code:C,message:"internal_error"})},()=>{f.end()})}))}function At(t){const e=Tn();if(e.startInactiveSpan)return e.startInactiveSpan(t);const n=hs(t),{forceTransaction:r,parentSpan:s}=t;return(t.scope?o=>de(t.scope,o):s!==void 0?o=>fs(s,o):o=>o())(()=>{const o=S(),a=_s(o,s),c=w();return t.onlyIfParent&&!a?(c==null||c.recordDroppedEvent("no_parent_span","span"),new q):ds({parentSpan:a,spanArguments:n,forceTransaction:r,scope:o})})}function fs(t,e){const n=Tn();return n.withActiveSpan?n.withActiveSpan(t,e):de(r=>(He(r,t||void 0),e(r)))}function ds({parentSpan:t,spanArguments:e,forceTransaction:n,scope:r}){var a;if(!bn()){const c=new q;if(n||!t){const u=p({sampled:"false",sample_rate:"0",transaction:e.name},ie(c));Dt(c,u)}return c}const s=w();if($o(s,e))return In(r)||s==null||s.recordDroppedEvent("ignored","span"),new q({dropReason:"ignored",traceId:(a=t==null?void 0:t.spanContext().traceId)!=null?a:r.getPropagationContext().traceId});const i=A();let o;if(t&&!n)o=Fo(t,r,e),ss(t,o);else if(t){const c=ie(t),{traceId:u,spanId:d}=t.spanContext(),l=V(t);o=cr(p({traceId:u,parentSpanId:d},e),r,l),Dt(o,c)}else{const{traceId:c,dsc:u,parentSpanId:d,sampled:l}=p(p({},i.getPropagationContext()),r.getPropagationContext());o=cr(p({traceId:c,parentSpanId:d},e),r,l),u&&Dt(o,u)}return Ro(o),Hi(o,r,i),o}function hs(t){const e=t.experimental||{},n=p({isStandalone:e.standalone},t);if(t.startTime){const r=p({},n);return r.startTimestamp=ne(t.startTime),delete r.startTime,r}return n}function Tn(){const t=Y();return fe(t)}function cr(t,e,n){var y,v;const r=w(),s=(r==null?void 0:r.getOptions())||{},{name:i=""}=t,o={spanAttributes:p({},t.attributes),spanName:i,parentSampled:n};r==null||r.emit("beforeSampling",o,{decision:!1});const a=(y=o.parentSampled)!=null?y:n,c=o.spanAttributes,u=e.getPropagationContext(),d=In(e),[l,h,f]=d?[!1]:Do(s,{name:i,parentSampled:a,attributes:c,parentSampleRate:Sn((v=u.dsc)==null?void 0:v.sample_rate)},u.sampleRand),_=new vn(E(p({},t),{attributes:p({[ze]:"custom",[Gr]:h!==void 0&&f?h:void 0},c),sampled:l}));return!l&&r&&!d&&(g&&m.log("[Tracing] Discarding root span because its trace was not chosen to be sampled."),r.recordDroppedEvent("sample_rate",xe(r)?"span":"transaction")),r&&r.emit("spanStart",_),_}function Fo(t,e,n){const{spanId:r,traceId:s}=t.spanContext(),i=In(e),o=i?!1:V(t),a=o?new vn(E(p({},n),{parentSpanId:r,traceId:s,sampled:o})):new q({traceId:s});ss(t,a);const c=w();return c&&(xe(c)&&a instanceof q&&(t instanceof q&&t.dropReason?(a.dropReason=t.dropReason,c.recordDroppedEvent(t.dropReason,"span")):i||(a.dropReason="sample_rate",c.recordDroppedEvent("sample_rate","span"))),c.emit("spanStart",a),n.endTimestamp&&(c.emit("spanEnd",a),c.emit("afterSpanEnd",a))),a}function _s(t,e){if(e)return e;if(e===null)return;const n=Ue(t);if(!n)return;const r=w();return(r?r.getOptions():{}).parentSpanIsAlwaysRootSpan?L(n):n}function Lo(t){return t!==void 0?e=>fs(t,e):e=>e()}function $o(t,e){var r;const n=t==null?void 0:t.getOptions().ignoreSpans;return!t||!xe(t)||!(n!=null&&n.length)?!1:Ge({description:e.name||"",op:((r=e.attributes)==null?void 0:r[qe])||e.op,attributes:e.attributes},n)}function jo(t){return t instanceof q&&t.dropReason==="ignored"}function In(t){return t.getScopeData().sdkProcessingMetadata[Mo]===!0}function Bo(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;Ho(t,e),r&&qo(t,r),Wo(t,n),Uo(t,s),zo(t,i)}function ur(t,e){const{extra:n,tags:r,attributes:s,user:i,contexts:o,level:a,sdkProcessingMetadata:c,breadcrumbs:u,fingerprint:d,eventProcessors:l,attachments:h,propagationContext:f,transactionName:_,span:y}=e;me(t,"extra",n),me(t,"tags",r),me(t,"attributes",s),me(t,"user",i),me(t,"contexts",o),t.sdkProcessingMetadata=Ne(t.sdkProcessingMetadata,c,2),a&&(t.level=a),_&&(t.transactionName=_),y&&(t.span=y),u.length&&(t.breadcrumbs=[...t.breadcrumbs,...u]),d.length&&(t.fingerprint=[...t.fingerprint,...d]),l.length&&(t.eventProcessors=[...t.eventProcessors,...l]),h.length&&(t.attachments=[...t.attachments,...h]),t.propagationContext=p(p({},t.propagationContext),f)}function me(t,e,n){t[e]=Ne(t[e],n,1)}function ms(t,e){const n=Fi().getScopeData();return t&&ur(n,t.getScopeData()),e&&ur(n,e.getScopeData()),n}function Ho(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:a}=e;Object.keys(n).length&&(t.extra=p(p({},n),t.extra)),Object.keys(r).length&&(t.tags=p(p({},r),t.tags)),Object.keys(s).length&&(t.user=p(p({},s),t.user)),Object.keys(i).length&&(t.contexts=p(p({},i),t.contexts)),o&&(t.level=o),a&&t.type!=="transaction"&&(t.transaction=a)}function Uo(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function zo(t,e){t.sdkProcessingMetadata=p(p({},t.sdkProcessingMetadata),e)}function qo(t,e){t.contexts=p({trace:ro(e)},t.contexts),t.sdkProcessingMetadata=p({dynamicSamplingContext:ie(e)},t.sdkProcessingMetadata);const n=L(e),r=N(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function Wo(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 Mt=0,lr=1,pr=2;function wn(t){return new ke(e=>{e(t)})}function kn(t){return new ke((e,n)=>{n(t)})}class ke{constructor(e){this._state=Mt,this._handlers=[],this._runExecutor(e)}then(e,n){return new ke((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 ke((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===Mt)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===lr&&n[1](this._value),this._state===pr&&n[2](this._value),n[0]=!0)})}_runExecutor(e){const n=(i,o)=>{if(this._state===Mt){if(le(o)){o.then(r,s);return}this._state=i,this._value=o,this._executeHandlers()}},r=i=>{n(lr,i)},s=i=>{n(pr,i)};try{e(r,s)}catch(i){s(i)}}}function Go(t,e,n,r=0){try{const s=an(e,n,t,r);return le(s)?s:wn(s)}catch(s){return kn(s)}}function an(t,e,n,r){const s=n[r];if(!t||!s)return t;const i=s(p({},t),e);return g&&i===null&&m.log(`Event processor "${s.id||"?"}" dropped event`),le(i)?i.then(o=>an(o,e,n,r+1)):an(i,e,n,r+1)}let H,fr,dr,U;function Jo(t){const e=P._sentryDebugIds,n=P._debugIds;if(!e&&!n)return{};const r=e?Object.keys(e):[],s=n?Object.keys(n):[];if(U&&r.length===fr&&s.length===dr)return U;fr=r.length,dr=s.length,U={},H||(H={});const i=(o,a)=>{for(const c of o){const u=a[c],d=H==null?void 0:H[c];if(d&&U&&u)U[d[0]]=u,H&&(H[c]=[d[0],u]);else if(u){const l=t(c);for(let h=l.length-1;h>=0;h--){const f=l[h],_=f==null?void 0:f.filename;if(_&&U&&H){U[_]=u,H[c]=[_,u];break}}}}};return e&&i(r,e),n&&i(s,n),U}function Ko(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=t,c=E(p({},e),{event_id:e.event_id||n.event_id||M(),timestamp:e.timestamp||Pe()}),u=n.integrations||t.integrations.map(I=>I.name);Yo(c,t),Zo(c,u),s&&s.emit("applyFrameMetadata",e),e.type===void 0&&Vo(c,t.stackParser);const d=ea(r,n.captureContext);n.mechanism&&Ei(c,n.mechanism);const l=s?s.getEventProcessors():[],h=ms(i,d),f=[...n.attachments||[],...h.attachments];f.length&&(n.attachments=f),Bo(c,h);const _=[...l,...h.eventProcessors];return(n.data&&n.data.__sentry__===!0?wn(c):Go(_,c,n)).then(I=>(I&&Xo(I),typeof o=="number"&&o>0?Qo(I,o,a):I))}function Yo(t,e){var a,c;const{environment:n,release:r,dist:s,maxValueLength:i}=e;t.environment=t.environment||n||En,!t.release&&r&&(t.release=r),!t.dist&&s&&(t.dist=s);const o=t.request;o!=null&&o.url&&i&&(o.url=Xt(o.url,i)),i&&((c=(a=t.exception)==null?void 0:a.values)==null||c.forEach(u=>{u.value&&(u.value=Xt(u.value,i))}))}function Vo(t,e){var r,s;const n=Jo(e);(s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.filename&&(c.debug_id=n[c.filename])})})}function Xo(t){var r,s;const e={};if((s=(r=t.exception)==null?void 0:r.values)==null||s.forEach(i=>{var o,a;(a=(o=i.stacktrace)==null?void 0:o.frames)==null||a.forEach(c=>{c.debug_id&&(c.abs_path?e[c.abs_path]=c.debug_id:c.filename&&(e[c.filename]=c.debug_id),delete c.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 Zo(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function Qo(t,e,n){var s,i;if(!t)return null;const r=p(p(p(p(p({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(o=>p(p({},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=>p(p({},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 ea(t,e){if(!e)return t;const n=t?t.clone():new $;return n.update(e),n}function ta(t){if(t)return na(t)?{captureContext:t}:sa(t)?{captureContext:t}:t}function na(t){return t instanceof $||typeof t=="function"}const ra=["user","level","extra","contexts","tags","fingerprint","propagationContext"];function sa(t){return Object.keys(t).some(e=>ra.includes(e))}function te(t,e){return S().captureException(t,ta(e))}function ia(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return S().captureMessage(t,n,r)}function oa(t,e){return S().captureEvent(t,e)}function W(t,e){A().setContext(t,e)}function aa(t){A().setExtras(t)}function ca(t,e){A().setExtra(t,e)}function ua(t){A().setTags(t)}function la(t,e){A().setTag(t,e)}function pa(t){A().setUser(t)}function fa(){return A().lastEventId()}function gs(t){return O(this,null,function*(){const e=w();return e?e.flush(t):(g&&m.warn("Cannot flush events. No client defined."),Promise.resolve(!1))})}function da(t){return O(this,null,function*(){const e=w();return e?e.close(t):(g&&m.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))})}function ys(){const t=w();return(t==null?void 0:t.getOptions().enabled)!==!1&&!!(t!=null&&t.getTransport())}function ha(t){A().addEventProcessor(t)}function Ss(t){const e=A(),{user:n}=ms(e,S()),{userAgent:r}=P.navigator||{},s=Br(p(p({user:n},r&&{userAgent:r}),t)),i=e.getSession();return(i==null?void 0:i.status)==="ok"&&K(i,{status:"exited"}),Rt(),e.setSession(s),s}function Rt(){const t=A(),n=S().getSession()||t.getSession();n&&Hr(n),bs(),t.setSession()}function bs(){const t=A(),e=w(),n=t.getSession();n&&e&&e.captureSession(n)}function cn(t=!1){if(t){Rt();return}bs()}const _a="7";function ma(t){const e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function ga(t){return`${ma(t)}${t.projectId}/envelope/`}function ya(t,e){const n={sentry_version:_a};return t.publicKey&&(n.sentry_key=t.publicKey),e&&(n.sentry_client=`${e.name}/${e.version}`),new URLSearchParams(n).toString()}function Sa(t,e,n){return e||`${ga(t)}?${ya(t,n)}`}const ve=[];function ba(t,e){const n={};return e.forEach(r=>{r!=null&&r.beforeSetup&&r.beforeSetup(t)}),e.forEach(r=>{r&&Es(t,r,n)}),n}function hr(t,e){for(const n of e)n!=null&&n.afterAllSetup&&n.afterAllSetup(t)}function Es(t,e,n){if(n[e.name]){g&&m.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,!ve.includes(e.name)&&typeof e.setupOnce=="function"&&(e.setupOnce(),ve.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))}),g&&m.log(`Integration installed: ${e.name}`)}function Ea(t){const e=w();if(!e){g&&m.warn(`Cannot add integration "${t.name}" because no SDK Client is available.`);return}e.addIntegration(t)}function va(){return typeof __SENTRY_BROWSER_BUNDLE__!="undefined"&&!!__SENTRY_BROWSER_BUNDLE__}function Ta(){return!va()&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]"}function An(){return typeof window!="undefined"&&(!Ta()||Ia())}function Ia(){const t=P.process;return(t==null?void 0:t.type)==="renderer"}function wa(t,e){const n=e?"auto":"never";return[{type:"log",item_count:t.length,content_type:"application/vnd.sentry.items.log+json"},E(p({version:2},An()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function ka(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=he(r)),X(i,[wa(t,s)])}function _r(t,e){var i;const n=(i=e!=null?e:Aa(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=ka(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);vs().set(t,[]),t.emit("flushLogs"),t.sendEnvelope(s)}function Aa(t){return vs().get(t)}function vs(){return ue("clientToLogBufferMap",()=>new WeakMap)}function Ra(t,e){const n=e?"auto":"never";return[{type:"trace_metric",item_count:t.length,content_type:"application/vnd.sentry.items.trace-metric+json"},E(p({version:2},An()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}}),{items:t})]}function Ca(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=he(r)),X(i,[Ra(t,s)])}function Pa(t,e){var i;const n=(i=e!=null?e:Na(t))!=null?i:[];if(n.length===0)return;const r=t.getOptions(),s=Ca(n,r._metadata,r.tunnel,t.getDsn(),t.getDataCollectionOptions().userInfo);Ts().set(t,[]),t.emit("flushMetrics"),t.sendEnvelope(s)}function Na(t){return Ts().get(t)}function Ts(){return ue("clientToMetricBufferMap",()=>new WeakMap)}function xa(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:p({},t.data),links:t.links};return co(e)}function Oa(t,e){var i,o,a;if(t.type!=="transaction"||!((i=t.spans)!=null&&i.length)||!((o=t.sdkProcessingMetadata)!=null&&o.hasGenAiSpans)||!e.getOptions().streamGenAiSpans||xe(e))return;const n=[],r=[];for(const c of t.spans)(a=c.op)!=null&&a.startsWith("gen_ai.")?n.push(xa(c)):r.push(c);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"},E(p({version:2},An()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}}),{items:n})]}function Rn(t){return typeof t=="object"&&typeof t.unref=="function"&&t.unref(),t}const Cn=Symbol.for("SentryBufferFullError");function Is(t=100){const e=new Set;function n(){return e.size<t}function r(o){e.delete(o)}function s(o){if(!n())return kn(Cn);const a=o();return e.add(a),a.then(()=>r(a),()=>r(a)),a}function i(o){if(!e.size)return wn(!0);const a=Promise.allSettled(Array.from(e)).then(()=>!0);if(!o)return a;const c=[a,new Promise(u=>Rn(setTimeout(()=>u(!1),o)))];return Promise.race(c)}return{get $(){return Array.from(e)},add:s,drain:i}}const Da=60*1e3;function ws(t,e=G()){const n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;const r=Date.parse(`${t}`);return isNaN(r)?Da:r-e}function Ma(t,e){return t[e]||t.all||0}function Fa(t,e,n=G()){return Ma(t,e)>n}function La(t,{statusCode:e,headers:n},r=G()){const s=p({},t),i=n==null?void 0:n["x-sentry-rate-limits"],o=n==null?void 0:n["retry-after"];if(i)for(const a of i.trim().split(",")){const[c,u,,,d]=a.split(":",5),l=parseInt(c,10),h=(isNaN(l)?60:l)*1e3;if(!u)s.all=r+h;else for(const f of u.split(";"))f==="metric_bucket"?(!d||d.split(";").includes("custom"))&&(s[f]=r+h):s[f]=r+h}else o?s.all=r+ws(o,r):e===429&&(s.all=r+60*1e3);return s}const ks=64;function $a(t,e,n=Is(t.bufferSize||ks)){let r={};const s=o=>n.drain(o);function i(o){const a=[];if(rn(o,(l,h)=>{const f=rr(h);Fa(r,f)?t.recordDroppedEvent("ratelimit_backoff",f):a.push(l)}),a.length===0)return Promise.resolve({});const c=X(o[0],a),u=l=>{if(sn(c,["client_report"])){g&&m.warn(`Dropping client report. Will not send outcomes (reason: ${l}).`);return}rn(c,(h,f)=>{t.recordDroppedEvent(l,rr(f))})},d=()=>e({body:yo(c)}).then(l=>l.statusCode===413?(g&&m.error("Sentry responded with status code 413. Envelope was discarded due to exceeding size limits."),u("send_error"),l):(g&&l.statusCode!==void 0&&(l.statusCode<200||l.statusCode>=300)&&m.warn(`Sentry responded with status code ${l.statusCode} to sent event.`),r=La(r,l),l),l=>{throw u("network_error"),g&&m.error("Encountered error running transport request:",l),l});return n.add(d).then(l=>l,l=>{if(l===Cn)return g&&m.error("Skipped sending event because buffer is full."),u("queue_overflow"),Promise.resolve({});throw l})}return{send:i,flush:s}}function ja(t,e,n){const r=[{type:"client_report"},{timestamp:Pe(),discarded_events:t}];return X(e?{dsn:e}:{},[r])}function As(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 Ba(t){var c,u,d;const{trace_id:e,parent_span_id:n,span_id:r,status:s,origin:i,data:o,op:a}=(u=(c=t.contexts)==null?void 0:c.trace)!=null?u:{};return{data:o!=null?o:{},description:t.transaction,op:a,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[gn],exclusive_time:o==null?void 0:o[yn],measurements:t.measurements,is_segment:!0}}function Ha(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:p(p(p({},t.data),t.profile_id&&{[gn]:t.profile_id}),t.exclusive_time&&{[yn]:t.exclusive_time})}},measurements:t.measurements}}const Fe=["forwarded","-ip","remote-","via","-user"];function Ua(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:Fe},httpHeaders:{request:{deny:Fe},response:{deny:Fe}},httpBodies:[],queryParams:{deny:Fe},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,a,c,u,d,l,h,f,_,y,v,I;const e=t.dataCollection!=null?za:Ua(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:(a=(o=n.httpHeaders)==null?void 0:o.request)!=null?a:e.httpHeaders.request,response:(u=(c=n.httpHeaders)==null?void 0:c.response)!=null?u:e.httpHeaders.response},httpBodies:(d=n.httpBodies)!=null?d:e.httpBodies,queryParams:(l=n.queryParams)!=null?l:e.queryParams,genAI:{inputs:(f=(h=n.genAI)==null?void 0:h.inputs)!=null?f:e.genAI.inputs,outputs:(y=(_=n.genAI)==null?void 0:_.outputs)!=null?y:e.genAI.outputs},stackFrameVariables:(v=n.stackFrameVariables)!=null?v:e.stackFrameVariables,frameContextLines:(I=n.frameContextLines)!=null?I:e.frameContextLines}}const mr="Not capturing exception because it's already been captured.",gr="Discarded session because of missing or non-string release",Rs=Symbol.for("SentryInternalError"),Cs=Symbol.for("SentryDoNotSendEventError"),Wa=5e3;function Le(t){return{message:t,[Rs]:!0}}function Ft(t){return{message:t,[Cs]:!0}}function yr(t){return!!t&&typeof t=="object"&&Rs in t}function Sr(t){return!!t&&typeof t=="object"&&Cs in t}function br(t,e,n,r,s){let i=0,o,a=!1;t.on(n,()=>{i=0,clearTimeout(o),a=!1}),t.on(e,c=>{var u;if(i+=r(c),i>=8e5)s(t);else if(!a){const d=(u=t.getOptions()._flushInterval)!=null?u:Wa;d>0&&(a=!0,o=Rn(setTimeout(()=>{s(t)},d)))}}),t.on("flush",()=>{s(t)})}class Ga{constructor(e){var r,s,i,o,a,c,u;if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=Is((s=(r=e.transportOptions)==null?void 0:r.bufferSize)!=null?s:ks),this._dataCollection=qa(e),e.dsn?this._dsn=eo(e.dsn):g&&m.warn("No DSN provided, client will not send events."),this._dsn){const d=Sa(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport(E(p({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&&br(this,"afterCaptureLog","flushLogs",Va,_r),((u=(c=this._options.enableMetrics)!=null?c:(a=this._options._experiments)==null?void 0:a.enableMetrics)!=null?u:!0)&&br(this,"afterCaptureMetric","flushMetrics",Ya,Pa)}captureException(e,n,r){const s=M();if(Jn(e))return g&&m.log(mr),s;const i=p({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=p({event_id:M()},r),o=Mr(e)?e:String(e),a=Fr(e),c=a?this.eventFromMessage(o,n,i):this.eventFromException(e,i);return this._process(()=>c.then(u=>this._captureEvent(u,i,s)),a?"unknown":"error"),i.event_id}captureEvent(e,n,r){const s=M();if(n!=null&&n.originalException&&Jn(n.originalException))return g&&m.log(mr),s;const i=p({event_id:s},n),o=e.sdkProcessingMetadata||{},a=o.capturedSpanScope,c=o.capturedSpanIsolationScope,u=Er(e.type);return this._process(()=>this._captureEvent(e,i,a||r,c),u),i.event_id}captureSession(e){this.sendSession(e),K(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*(){_r(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),Es(this,e,this._integrations),n||hr(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);const r=Oa(e,this);let s=ko(e,this._dsn,this._options._metadata,this._options.tunnel);for(const i of n.attachments||[])s=nr(s,Eo(i));r&&(s=nr(s,r)),this.sendEnvelope(s).then(i=>this.emit("afterSendEvent",e,i))}sendSession(e){const{release:n,environment:r=En}=this._options;if("aggregates"in e){const i=e.attrs||{};if(!i.release&&!n){g&&m.warn(gr);return}i.release=i.release||n,i.environment=i.environment||r,e.attrs=i}else{if(!e.release&&!n){g&&m.warn(gr);return}e.release=e.release||n,e.environment=e.environment||r}this.emit("beforeSendSession",e);const s=wo(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}`;g&&m.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 g&&m.error("Error while sending envelope:",n),{}}return g&&m.error("Transport disabled"),{}})}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=ba(this,e),hr(this,e)}_updateSessionFromEvent(e,n){var c,u;let r=n.level==="fatal",s=!1;const i=(c=n.exception)==null?void 0:c.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)&&(K(e,E(p({},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),Ko(i,e,n,r,this,s).then(a=>{var u;if(a===null)return a;this.emit("postprocessEvent",a,n),a.contexts=p({trace:p(p({},(u=a.contexts)==null?void 0:u.trace),Li(r))},a.contexts);const c=cs(this,r);return a.sdkProcessingMetadata=p({dynamicSamplingContext:c},a.sdkProcessingMetadata),a})}_captureEvent(e,n={},r=S(),s=A()){return g&&un(e)&&m.log(`Captured error event \`${As(e)[0]||"<unknown>"}\``),this._processEvent(e,n,r,s).then(i=>i.event_id,i=>{g&&(Sr(i)?m.log(i.message):yr(i)?m.warn(i.message):m.warn(i))})}_processEvent(e,n,r,s){const i=this.getOptions(),{sampleRate:o}=i,a=Ps(e),c=un(e),d=`before send for type \`${e.type||"error"}\``,l=typeof o=="undefined"?void 0:Sn(o);if(c&&typeof l=="number"&&Be()>l)return this.recordDroppedEvent("sample_rate","error"),kn(Ft(`Discarding event because it's not included in the random sample (sampling rate = ${o})`));const h=Er(e.type);return this._prepareEvent(e,n,r,s).then(f=>{var v;if(f===null)throw this.recordDroppedEvent("event_processor",h),Ft("An event processor returned `null`, will not send event.");if(((v=n.data)==null?void 0:v.__sentry__)===!0)return f;const y=Ka(this,i,f,n);return Ja(y,d)}).then(f=>{var v;if(f===null){if(this.recordDroppedEvent("before_send",h),a){const j=1+(e.spans||[]).length;this.recordDroppedEvent("before_send","span",j)}throw Ft(`${d} returned \`null\`, will not send event.`)}const _=r.getSession()||s.getSession();if(c&&_&&this._updateSessionFromEvent(_,f),a){const I=((v=f.sdkProcessingMetadata)==null?void 0:v.spanCountBeforeProcessing)||0,j=f.spans?f.spans.length:0,F=I-j;F>0&&this.recordDroppedEvent("before_send","span",F)}const y=f.transaction_info;if(a&&y&&f.transaction!==e.transaction){const I="custom";f.transaction_info=E(p({},y),{source:I})}return this.sendEvent(f,n),f}).then(null,f=>{throw Sr(f)||yr(f)?f:(this.captureException(f,{mechanism:{handled:!1,type:"internal"},data:{__sentry__:!0},originalException:f}),Le(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.
7
+ Reason: ${f}`))})}_process(e,n){this._numProcessing++,this._promiseBuffer.add(e).then(r=>(this._numProcessing--,r),r=>(this._numProcessing--,r===Cn&&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(){g&&m.log("Flushing outcomes...");const e=this._clearOutcomes();if(e.length===0){g&&m.log("No outcomes to send");return}if(!this._dsn){g&&m.log("No dsn provided, will not send outcomes");return}g&&m.log("Sending outcomes:",e);const n=ja(e,this._options.tunnel&&he(this._dsn));this.sendEnvelope(n)}}function Er(t){return t==="replay_event"?"replay":t||"error"}function Ja(t,e){const n=`${e} must return \`null\` or a valid event.`;if(le(t))return t.then(r=>{if(!Yt(r)&&r!==null)throw Le(n);return r},r=>{throw Le(`${e} rejected with ${r}`)});if(!Yt(t)&&t!==null)throw Le(n);return t}function Ka(t,e,n,r){const{beforeSend:s,beforeSendTransaction:i,ignoreSpans:o}=e,a=!us(e.beforeSendSpan)&&e.beforeSendSpan;let c=n;if(un(c)&&s)return s(c,r);if(Ps(c)){if(a||o){const u=Ba(c);if(o!=null&&o.length&&Ge({description:u.description,op:u.op,attributes:u.data},o))return null;if(a){const d=a(u);d?c=Ne(n,Ha(d)):nn()}if(c.spans){const d=[],l=c.spans;for(const f of l){if(o!=null&&o.length&&Ge({description:f.description,op:f.op,attributes:f.data},o)){mo(l,f);continue}if(a){const _=a(f);_?d.push(_):(nn(),d.push(f))}else d.push(f)}const h=c.spans.length-d.length;h&&t.recordDroppedEvent("before_send","span",h),c.spans=d}}if(i){if(c.spans){const u=c.spans.length;c.sdkProcessingMetadata=E(p({},n.sdkProcessingMetadata),{spanCountBeforeProcessing:u})}return i(c,r)}}return c}function un(t){return t.type===void 0}function Ps(t){return t.type==="transaction"}function Ya(t){let e=0;return t.name&&(e+=t.name.length*2),e+=8,e+Ns(t.attributes)}function Va(t){let e=0;return t.message&&(e+=t.message.length*2),e+Ns(t.attributes)}function Ns(t){if(!t)return 0;let e=0;return Object.values(t).forEach(n=>{Array.isArray(n)?e+=n.length*vr(n[0]):Fr(n)?e+=vr(n):e+=100}),e}function vr(t){return typeof t=="string"?t.length*2:typeof t=="number"?8:typeof t=="boolean"?4:0}function Xa(t,e){e.debug===!0&&(g?m.enable():Ce(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),S().update(e.initialScope);const r=new t(e);return Za(r),r.init(),r}function Za(t){S().setClient(t)}const Lt=100,$t=5e3,Qa=36e5;function ec(t){function e(...n){g&&m.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=$t,o;function a(l,h,f){return sn(l,["client_report"])?!1:n.shouldStore?n.shouldStore(l,h,f):!0}function c(l){o&&clearTimeout(o),o=Rn(setTimeout(()=>O(null,null,function*(){o=void 0;const h=yield s.shift();h&&(e("Attempting to send previously queued event"),h[0].sent_at=new Date(G()).toISOString(),d(h,!0).catch(f=>{e("Failed to retry sending",f)}))}),l))}function u(){o||(c(i),i=Math.min(i*2,Qa))}function d(l,h=!1){return O(this,null,function*(){var f,_;if(!h&&sn(l,["replay_event","replay_recording"]))return yield s.push(l),c(Lt),{};try{if(n.shouldSend&&(yield n.shouldSend(l))===!1)throw new Error("Envelope not sent because `shouldSend` callback returned false");const y=yield r.send(l);let v=Lt;if(y){if((f=y.headers)!=null&&f["retry-after"])v=ws(y.headers["retry-after"]);else if((_=y.headers)!=null&&_["x-sentry-rate-limits"])v=6e4;else if((y.statusCode||0)>=400)return y}return c(v),i=$t,y}catch(y){if(yield a(l,y,i))return h?yield s.unshift(l):yield s.push(l),u(),e("Error sending. Event queued.",y),{};throw y}})}return n.flushAtStartup&&u(),{send:d,flush:l=>(l===void 0&&(i=$t,c(Lt)),r.flush(l))}}}function tc(t={}){const e=t.client||w();if(!ys()||!e)return{};const n=Y(),r=fe(n);if(r.getTraceData)return r.getTraceData(t);const s=t.scope||S(),i=t.span||is(),o=i?so(i):nc(s),a=i?ie(i):cs(e,s),c=qi(a);if(!to.test(o))return m.warn("Invalid sentry-trace data. Cannot generate trace data"),{};const d={"sentry-trace":o,baggage:c};return t.propagateTraceparent&&(d.traceparent=i?io(i):rc(s)),d}function nc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return Qr(e,r,n)}function rc(t){const{traceId:e,sampled:n,propagationSpanId:r}=t.getPropagationContext();return es(e,r,n)}const sc=100;function k(t,e){const n=w(),r=A();if(!n)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:i=sc}=n.getOptions();if(i<=0)return;const o=Pe(),a=p({timestamp:o},t),c=s?Ce(()=>s(a,e)):a;c!==null&&(n.emit&&n.emit("beforeAddBreadcrumb",c,e),r.addBreadcrumb(c,i))}const ic=[/^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$/],oc="EventFilters",ac=(t={})=>{let e;return{name:oc,setup(n){const r=n.getOptions();e=Tr(t,r)},processEvent(n,r,s){if(!e){const i=s.getOptions();e=Tr(t,i)}return cc(n,e)?null:n}}};function Tr(t={},e={}){return{allowUrls:[...t.allowUrls||[],...e.allowUrls||[]],denyUrls:[...t.denyUrls||[],...e.denyUrls||[]],ignoreErrors:[...t.ignoreErrors||[],...e.ignoreErrors||[],...t.disableErrorDefaults?[]:ic],ignoreTransactions:[...t.ignoreTransactions||[],...e.ignoreTransactions||[]]}}function cc(t,e){if(t.type){if(t.type==="transaction"&&lc(t,e.ignoreTransactions))return g&&m.warn(`Event dropped due to being matched by \`ignoreTransactions\` option.
8
+ Event: ${Q(t)}`),!0}else{if(uc(t,e.ignoreErrors))return g&&m.warn(`Event dropped due to being matched by \`ignoreErrors\` option.
9
+ Event: ${Q(t)}`),!0;if(hc(t))return g&&m.warn(`Event dropped due to not having an error message, error type or stacktrace.
10
+ Event: ${Q(t)}`),!0;if(pc(t,e.denyUrls))return g&&m.warn(`Event dropped due to being matched by \`denyUrls\` option.
11
11
  Event: ${Q(t)}.
12
- Url: ${Ge(t)}`),!0;if(!fc(t,e.allowUrls))return g&&m.warn(`Event dropped due to not being matched by \`allowUrls\` option.
12
+ Url: ${Je(t)}`),!0;if(!fc(t,e.allowUrls))return g&&m.warn(`Event dropped due to not being matched by \`allowUrls\` option.
13
13
  Event: ${Q(t)}.
14
- Url: ${Ge(t)}`),!0}return!1}function cc(t,e){return e!=null&&e.length?Is(t).some(n=>vt(n,e)):!1}function uc(t,e){if(!(e!=null&&e.length))return!1;const n=t.transaction;return n?vt(n,e):!1}function lc(t,e){if(!(e!=null&&e.length))return!1;const n=Ge(t);return n?vt(n,e):!1}function fc(t,e){if(!(e!=null&&e.length))return!0;const n=Ge(t);return n?vt(n,e):!0}function pc(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 Ge(t){var e,n,r;try{const s=[...(n=(e=t.exception)==null?void 0:e.values)!=null?n:[]].reverse().find(o=>{var a,c,u;return((a=o.mechanism)==null?void 0:a.parent_id)===void 0&&((u=(c=o.stacktrace)==null?void 0:c.frames)==null?void 0:u.length)}),i=(r=s==null?void 0:s.stacktrace)==null?void 0:r.frames;return i?pc(i):null}catch(s){return g&&m.error(`Cannot extract url for event ${Q(t)}`),null}}function dc(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 hc(t,e){return t(e.stack||"",1)}function _c(t){return Nr(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function mc(t){return _c(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function gc(t,e){const n={type:e.name||e.constructor.name,value:mc(e)},r=hc(t,e);return r.length&&(n.stacktrace={frames:r}),n}const Le="1.12.0",Cs="sentry.javascript.miniapp",yc=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,Sc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,bc=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function oe(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function Ec(t){const e=yc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||Et,in_app:An(r)},a=oe(s),c=oe(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function Tc(t){const e=Sc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||Et,in_app:An(r)},a=oe(s),c=oe(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function vc(t){const e=bc.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:Et,in_app:An(n)},o=oe(r),a=oe(s);return o&&(i.lineno=o),a&&(i.colno=a),i}function An(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const Ps=si([90,Ec],[80,Tc],[70,vc]),Ic=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,wc=[{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"}],Ns=()=>{const t=globalThis;for(const e of wc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},xs=()=>{const t=Ns();if(!t)return Ic()?console.warn(`[sentry-miniapp] 检测到当前运行在浏览器/H5 环境(如 uni-app H5、Taro H5)。
14
+ Url: ${Je(t)}`),!0}return!1}function uc(t,e){return e!=null&&e.length?As(t).some(n=>It(n,e)):!1}function lc(t,e){if(!(e!=null&&e.length))return!1;const n=t.transaction;return n?It(n,e):!1}function pc(t,e){if(!(e!=null&&e.length))return!1;const n=Je(t);return n?It(n,e):!1}function fc(t,e){if(!(e!=null&&e.length))return!0;const n=Je(t);return n?It(n,e):!0}function dc(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 Je(t){var e,n,r;try{const s=[...(n=(e=t.exception)==null?void 0:e.values)!=null?n:[]].reverse().find(o=>{var a,c,u;return((a=o.mechanism)==null?void 0:a.parent_id)===void 0&&((u=(c=o.stacktrace)==null?void 0:c.frames)==null?void 0:u.length)}),i=(r=s==null?void 0:s.stacktrace)==null?void 0:r.frames;return i?dc(i):null}catch(s){return g&&m.error(`Cannot extract url for event ${Q(t)}`),null}}function hc(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 _c(t,e){return t(e.stack||"",1)}function mc(t){return Dr(t)&&"__sentry_fetch_url_host__"in t&&typeof t.__sentry_fetch_url_host__=="string"}function gc(t){return mc(t)?`${t.message} (${t.__sentry_fetch_url_host__})`:t.message}function yc(t,e){const n={type:e.name||e.constructor.name,value:gc(e)},r=_c(t,e);return r.length&&(n.stacktrace={frames:r}),n}const $e="1.12.1",xs="sentry.javascript.miniapp",Sc=/^\s*at\s+(?:(.+?)\s+\()?([^\s():]+):(\d+):(\d+)\)?$/,bc=/^\s*(?:([^@]*)@)?([^\s@:]+(?:\.[a-z]+)+):(\d+)(?::(\d+))?\s*$/,Ec=/^\s*((?:pages|utils|components|subpackages|app-service|appservice)\/[^\s:]+):(\d+):(\d+)\s*$/;function oe(t){if(!t)return 0;const e=parseInt(t,10);return isNaN(e)?0:e}function vc(t){const e=Sc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||vt,in_app:Pn(r)},a=oe(s),c=oe(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function Tc(t){const e=bc.exec(t);if(!e)return;const[,n,r,s,i]=e,o={filename:r||"<anonymous>",function:n||vt,in_app:Pn(r)},a=oe(s),c=oe(i);return a&&(o.lineno=a),c&&(o.colno=c),o}function Ic(t){const e=Ec.exec(t);if(!e)return;const[,n,r,s]=e,i={filename:n||"<anonymous>",function:vt,in_app:Pn(n)},o=oe(r),a=oe(s);return o&&(i.lineno=o),a&&(i.colno=a),i}function Pn(t){return t?!(t.includes("sentry-miniapp")||t.includes("@sentry")||t.includes("WAService")||t.includes("WASubContext")||t.includes("aframeworkx")||t.includes("__dev__")):!0}const Os=ii([90,vc],[80,Tc],[70,Ic]),wc=()=>typeof window!="undefined"&&window!==null&&typeof document!="undefined"&&document!==null,kc=[{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"}],Ds=()=>{const t=globalThis;for(const e of kc){const n=t[e.global];if(typeof n=="object"&&n!==null)return{sdk:n,name:e.name}}return null},Nn=()=>{const t=Ds();if(!t)return wc()?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;if(t.name==="alipay"&&!e.request&&e.httpRequest&&(e.request=e.httpRequest),t.name==="alipay"||t.name==="dingtalk"){if(e.getStorageSync){const n=e.getStorageSync;e.getStorageSync=r=>{const s=n.call(e,{key:r});return s?s.data:null}}if(e.setStorageSync){const n=e.setStorageSync;e.setStorageSync=(r,s)=>{n.call(e,{key:r,data:s})}}if(e.removeStorageSync){const n=e.removeStorageSync;e.removeStorageSync=r=>{n.call(e,{key:r})}}}return e},Os=()=>{var t,e;return(e=(t=Ns())==null?void 0:t.name)!=null?e:"unknown"},kc=()=>{try{const t=xs(),e={};let n=!1;if(t.getAppBaseInfo){const r=t.getAppBaseInfo();Object.assign(e,r),n=!0}if(t.getWindowInfo){const r=t.getWindowInfo();Object.assign(e,r),n=!0}if(t.getDeviceInfo){const r=t.getDeviceInfo();Object.assign(e,r),n=!0}if(t.getAppAuthorizeSetting){const r=t.getAppAuthorizeSetting();e.albumAuthorized=r.albumAuthorized==="authorized",e.cameraAuthorized=r.cameraAuthorized==="authorized",e.locationAuthorized=r.locationAuthorized==="authorized",e.microphoneAuthorized=r.microphoneAuthorized==="authorized",e.notificationAuthorized=r.notificationAuthorized==="authorized"}if(t.getSystemSetting){const r=t.getSystemSetting();Object.assign(e,r)}if(n)return e;if(t.getSystemInfoSync){const r=t.getSystemInfoSync();return!r.SDKVersion&&r.version&&(r.SDKVersion=r.version),r}return null}catch(t){return console.warn("[sentry-miniapp] Failed to get system info:",t),null}};let $t=null;const Rt=()=>($t===null&&($t=kc()),$t),Ds=()=>Os()!=="unknown";let jt=null,Bt=null;const S=()=>(jt===null&&(jt=xs()),jt),Ms=()=>(Bt===null&&(Bt=Os()),Bt);let Ht=null;const Ac=()=>{if(Ht===null){const t=globalThis,e=typeof t.GameGlobal!="undefined",n=typeof t.App!="function"&&typeof t.Page!="function"&&typeof t.getCurrentPages!="function";Ht=Ds()&&(e||n)}return Ht},Fs=()=>{try{const t=S();if(t.getPerformance&&typeof t.getPerformance=="function")return t.getPerformance()}catch(t){console.warn("Failed to get performance manager:",t)}return null},Ee=()=>Date.now(),cn=()=>Date.now();function Ls(t){const e=t.url;function n(r){return new Promise((s,i)=>{var a,c,u,p;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 h=f.statusCode||f.status,d=f.header||f.headers||{};s({statusCode:h,headers:{"x-sentry-rate-limits":d["x-sentry-rate-limits"],"retry-after":d["retry-after"]}})},fail:f=>{i(new Error(`Network request failed: ${f.errMsg||f.errorMessage||f.message||"Unknown error"}`))}};S().request?(c=(a=S()).request)==null||c.call(a,o):S().httpRequest?(p=(u=S()).httpRequest)==null||p.call(u,o):i(new Error("No request method available in current miniapp environment"))})}return La(t,n)}const Rc=30,Cc=864e5,$s="sentry_offline_store";function js(t){var r,s;const e=(r=t.offlineCacheLimit)!=null?r:Rc,n=(s=t.offlineCacheMaxAge)!=null?s:Cc;return{push:i=>O(null,null,function*(){try{let o=zt();for(o=Ut(o,n),o.push({envelope:i,timestamp:Date.now()});o.length>e;){const a=o.findIndex(c=>!br(c.envelope));a>=0?o.splice(a,1):o.shift()}qt(o)}catch(o){console.warn("[sentry-miniapp] Failed to push to offline store",o)}}),unshift:i=>O(null,null,function*(){try{let o=zt();for(o=Ut(o,n),o.unshift({envelope:i,timestamp:Date.now()});o.length>e;){const a=Pc(o,c=>!br(c.envelope));a>=0?o.splice(a,1):o.pop()}qt(o)}catch(o){console.warn("[sentry-miniapp] Failed to unshift to offline store",o)}}),shift:()=>O(null,null,function*(){try{let i=zt();if(i=Ut(i,n),i.length===0)return;const o=i.shift();return qt(i),o==null?void 0:o.envelope}catch(i){console.warn("[sentry-miniapp] Failed to shift from offline store",i);return}})}}function br(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 Ut(t,e){const n=Date.now();return t.filter(r=>n-r.timestamp<e)}function Pc(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}function zt(){try{const t=S().getStorageSync;if(t){const e=t($s);if(e){const n=typeof e=="string"?JSON.parse(e):e;if(Array.isArray(n)&&n.length>0)return n[0]&&"envelope"in n[0]&&"timestamp"in n[0]?n:n.map(r=>({envelope:r,timestamp:Date.now()}))}}}catch(t){}return[]}function qt(t){try{const e=S().setStorageSync;e&&e($s,JSON.stringify(t))}catch(e){}}const Nc=Object.freeze(Object.defineProperty({__proto__:null,createMiniappOfflineStore:js,createMiniappTransport:Ls},Symbol.toStringTag,{value:"Module"}));class Bs extends Wa{constructor(e={}){super(E(l({},e),{transport:e.transport||(n=>{const r=Ls(E(l({},n),{headers:{}}));return e.enableOfflineCache!==!1?Qa(()=>r)(E(l({},n),{createStore:s=>js(E(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){if(e.platform=e.platform||this.getOptions().platform||"javascript",e.sdk=E(l({},e.sdk),{name:Cs,packages:[...e.sdk&&e.sdk.packages||[],{name:"npm:@sentry/miniapp",version:Le}],version:Le}),e.contexts||(e.contexts={}),e.contexts.miniapp={platform:Ms(),sdk_version:Le},this.getOptions().enableSystemInfo!==!1){const s=Rt();s?(e.contexts.device={brand:s.brand||"unknown",model:s.model||"unknown",screen_resolution:`${s.screenWidth||0}x${s.screenHeight||0}`,language:s.language||"unknown",version:s.version||"unknown",system:s.system||"unknown",platform:s.platform||"unknown"},e.contexts.os={name:s.system||"unknown",version:s.version||"unknown"},e.contexts.app={app_version:s.SDKVersion||"unknown"}):(e.contexts.device={brand:"unknown",model:"unknown",screen_resolution:"0x0",language:"unknown",version:"unknown",system:"unknown",platform:"unknown"},e.contexts.os={name:"unknown",version:"unknown"},e.contexts.app={app_version:"unknown"})}try{const s=r||b(),i=A();return super._prepareEvent(e,n||{},s,i)}catch(s){return this.getOptions().debug&&console.warn("[sentry-miniapp] _prepareEvent 兜底(scope 未就绪):",s),Promise.resolve(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)}}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 it=class it{constructor(e){this.name=it.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||(S().onError&&(this._errorHandler=r=>{const s=typeof r=="string"?new Error(r):r;te(s,{mechanism:{type:"onerror",handled:!1}})},(n=(e=S()).onError)==null||n.call(e,this._errorHandler)),this._onErrorHandlerInstalled=!0)}_installGlobalOnUnhandledRejectionHandler(){var e,n;this._onUnhandledRejectionHandlerInstalled||(S().onUnhandledRejection&&(this._rejectionHandler=({reason:r,promise:s})=>{const i=typeof r=="string"?new Error(r):r;te(i,{mechanism:{type:"onunhandledrejection",handled:!1},data:{promise:s}})},(n=(e=S()).onUnhandledRejection)==null||n.call(e,this._rejectionHandler)),this._onUnhandledRejectionHandlerInstalled=!0)}_installGlobalOnPageNotFoundHandler(){var e,n;this._onPageNotFoundHandlerInstalled||(S().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}),te(new Error(`页面无法找到: ${i}`),{mechanism:{type:"onpagenotfound",handled:!0}})},(n=(e=S()).onPageNotFound)==null||n.call(e,this._pageNotFoundHandler)),this._onPageNotFoundHandlerInstalled=!0)}_installGlobalOnMemoryWarningHandler(){var e,n;this._onMemoryWarningHandlerInstalled||(S().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}),te(new Error("内存不足告警"),{mechanism:{type:"onmemorywarning",handled:!0}})},(n=(e=S()).onMemoryWarning)==null||n.call(e,this._memoryWarningHandler)),this._onMemoryWarningHandlerInstalled=!0)}cleanup(){try{const e=S();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}};it.id="GlobalHandlers";let Je=it;function Er(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 b().addEventProcessor(a=>{const c=l({},a);return e.mechanism&&(c.exception=c.exception||{},c.exception.mechanism=e.mechanism),c.extra=E(l({},c.extra),{arguments:s}),c}),te(i),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 Tr(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 ot=class ot{constructor(){this.name=ot.id}_wrapTimeFunction(e){return function(...n){const r=n[0];return n[0]=Er(r,{mechanism:{data:{function:Tr(e)},handled:!0,type:"instrument"}}),e.apply(this,n)}}_wrapRAF(e){return function(n){return e(Er(n,{mechanism:{data:{function:"requestAnimationFrame",handler:Tr(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))}};ot.id="TryCatch";let Ke=ot;const xc="cause",Oc=5,at=class at{constructor(e={}){this.name=at.id,this._key=e.key||xc,this._limit=e.limit||Oc}setupOnce(){}processEvent(e,n){return b().getClient()?this._handler(e,n):e}_handler(e,n){if(!e.exception||!e.exception.values||!n||!vr(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(!vr(e[n],Error)||r.length+1>=this._limit)return r;const s=gc(()=>[],e[n]);return this._walkErrorTree(e[n],n,[s,...r])}};at.id="LinkedErrors";let Ve=at;function vr(t,e){try{return t instanceof e}catch(n){return!1}}const ct=class ct{constructor(){this.name=ct.id}setupOnce(){}processEvent(e){var i,o;const n=this._getMiniappVersion(),r=this._getAppName(),s=this._getAppVersion();return e.contexts=E(l({},e.contexts),{runtime:E(l({},((i=e.contexts)==null?void 0:i.runtime)||{}),{name:"miniapp",version:n}),app:E(l({},((o=e.contexts)==null?void 0:o.app)||{}),{name:r,version:s})}),e}_getMiniappVersion(){const e=Rt();return(e==null?void 0:e.version)||(e==null?void 0:e.SDKVersion)||"unknown"}_getAppName(){var e,n,r;try{if(S().getAccountInfoSync)return((r=((n=(e=S()).getAccountInfoSync)==null?void 0:n.call(e)).miniProgram)==null?void 0:r.appId)||"unknown"}catch(s){}return"unknown"}_getAppVersion(){var e,n,r;try{if(S().getAccountInfoSync){const s=(n=(e=S()).getAccountInfoSync)==null?void 0:n.call(e);return((r=s==null?void 0:s.miniProgram)==null?void 0:r.version)||"unknown"}}catch(s){}return"unknown"}};ct.id="HttpContext";let Ye=ct;const ut=class ut{constructor(e={}){this.name=ut.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(!Dc(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],a=r[i];if(o.filename!==a.filename||o.lineno!==a.lineno||o.colno!==a.colno||o.function!==a.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){}}};ut.id="Dedupe";let Xe=ut;const Ir=/\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 Dc(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.replace(Ir,"<dynamic>"),r=e.replace(Ir,"<dynamic>");return n===r}const lt=class lt{constructor(){this.name=lt.id}setupOnce(){this._addSystemContext(),this._addNetworkContext(),this._addLocationContext(),this._addStorageContext(),this._checkAppUpdate()}_addSystemContext(){var e,n,r,s;try{const i=Rt();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{S().getNetworkType&&S().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{S().getLocation&&S().getLocation({type:"gcj02",success:e=>{b().setContext("location",{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy})},fail:()=>{}})}catch(e){}}_addStorageContext(){try{const e=S();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=S();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){}}};lt.id="System";let un=lt;const ft=class ft{constructor(){this.name=ft.id,this._lastRoute="",this._monitorTimer=null}setupOnce(){this._instrumentNavigation(),this._startRouteMonitoring()}_instrumentNavigation(){let e;try{e=S()}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()})}};ft.id="Router";let ln=ft;const pt=class pt{constructor(e={}){this.name=pt.id,this._performanceManager=null,this._observers=[],this._entryBuffer=[],this._reportTimer=null,this._options=E(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=Fs(),!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=Rt();if(i&&i.platform==="devtools"&&(n=!1),n){const a=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{}).PerformanceObserver,c=a&&Array.isArray(a.supportedEntryTypes)?a.supportedEntryTypes:void 0;(!c||!c.includes("measure")||!c.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(a=>a!=="measure"&&a!=="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}}),me({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;me({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){me({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"?me({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,a)=>o+a,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)}}if(n.length>0){const i=n.map(a=>a.duration);s.render_stats={avg_duration:i.reduce((a,c)=>a+c,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)};const o=n.filter(a=>{var c,u;return a.duration>((u=(c=this._options.thresholds)==null?void 0:c.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(a=>a.duration),o=r.map(a=>a.transferSize||0).filter(a=>a>0);s.resource_stats={avg_load_time:i.reduce((a,c)=>a+c,0)/i.length,max_load_time:Math.max(...i),total_transfer_size:o.reduce((a,c)=>a+c,0),avg_transfer_size:o.length>0?o.reduce((a,c)=>a+c,0)/o.length:0}}return s}_checkPerformanceThresholds(e){var o,a,c,u,p,f,h,d,_;const n=b(),r=(a=(o=this._options.thresholds)==null?void 0:o.navigation)!=null?a:3e3;((c=e.navigation_stats)==null?void 0:c.avg_duration)>r&&n.addBreadcrumb({message:"页面导航性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.navigation_stats.avg_duration,threshold:r}});const s=(p=(u=this._options.thresholds)==null?void 0:u.render)!=null?p: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=(d=(h=this._options.thresholds)==null?void 0:h.resource)!=null?d:2e3;((_=e.resource_stats)==null?void 0:_.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=S();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=S();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=S(),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()}};pt.id="PerformanceAPI";let Ze=pt;const Rn=t=>()=>new Ze(t),dt=class dt{constructor(e={}){this.name=dt.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}`}};dt.id="RewriteFrames";let Qe=dt;const ht=class ht{constructor(e={}){this.name=ht.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=S();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=S();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(a){if(!a||typeof a!="object")return e.call(this,a);const c=Hc(a.url),u=w();let p="";if(u){const v=u.getOptions().dsn;if(v)try{const R=v.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n]+)/i);R&&R[1]&&(p=R[1])}catch(R){}}const f=c.match(/^https?:\/\/([^:/\n]+)/i),h=f&&f[1]?f[1]:"";if(p&&h===p||h==="sentry.io"||h.endsWith(".sentry.io"))return e.call(this,a);const _=Uc(a.method),y=a.data,T=Date.now(),I=Mc(_,c);let j=!1;const F=v=>{j||(j=!0,Bc(I,v))};i&&o(c)&&jc(a,I);const x={url:c,method:_};if(n&&y&&!s(c))try{const v=typeof y=="string"?y:JSON.stringify(y);x.request_body=r(v),x.request_size=v.length}catch(v){x.request_body="[Cannot serialize request body]"}const Pn=a.success,Nn=a.fail,xn=a.complete;a.success=function(...v){const R=v[0]||{},B=wr(R),he=Date.now()-T;if(x.status_code=B,x.duration=he,F({statusCode:B,status:Wt(B)?"error":"ok"}),n&&R.data&&!s(c))try{const Ct=typeof R.data=="string"?R.data:JSON.stringify(R.data);x.response_body=r(Ct),x.response_size=Ct.length}catch(Ct){x.response_body="[Cannot serialize response body]"}const qs=Wt(B)||he>3e3?"warning":"info";if(k({type:"http",category:"xhr",data:x,level:qs}),typeof Pn=="function")return Pn.apply(this,v)},a.fail=function(...v){const R=v[0]||{},B=Date.now()-T,he=R.errMsg||R.errorMessage||"Network request failed";if(x.error=he,x.duration=B,F({status:"error",errorMessage:he}),k({type:"http",category:"xhr",data:x,level:"error"}),typeof Nn=="function")return Nn.apply(this,v)},a.complete=function(...v){const R=v[0]||{},B=wr(R);if(F({statusCode:B,status:Wt(B)?"error":"ok"}),typeof xn=="function")return xn.apply(this,v)};try{return e.call(this,a)}catch(v){throw F({status:"error",errorMessage:v instanceof Error?v.message:String(v)}),v}}}_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])}};ht.id="NetworkBreadcrumbs";let et=ht;function Mc(t,e){try{const n=qc(e);return kt({name:`${t} ${Fc(e)}`,op:"http.client",kind:2,attributes:{"http.request.method":t,"url.full":e,"server.address":n||void 0}})}catch(n){return null}}function Fc(t){return t.startsWith("data:")?$c(t):Lc(t).replace(/^([a-z][a-z0-9+.-]*:\/\/)([^/?#@]+@)/i,"$1[filtered]:[filtered]@")}function Lc(t){const e=t.split(/[?#]/,1)[0];return e===void 0?t:e}function $c(t){const e=t.match(/^data:([^;,]+)/);return`data:${e&&e[1]?e[1]:"text/plain"}`}function jc(t,e){if(e)try{const n=ec({span:e}),r=n["sentry-trace"];if(!r)return;const s=l(l({},kr(t.headers)?t.headers:{}),kr(t.header)?t.header:{});s["sentry-trace"]||(s["sentry-trace"]=r),n.baggage&&(s.baggage=zc(s.baggage,n.baggage)),t.header=s,t.headers=s}catch(n){}}function Bc(t,e){if(t)try{const n=Hs(e.statusCode);n!==void 0?ji(t,n):t.setStatus({code:e.status==="error"?C:It,message:e.status==="error"?e.errorMessage||"error":"ok"}),e.errorMessage&&t.setAttribute("error.message",e.errorMessage),t.end()}catch(n){}}function Hc(t){return typeof t=="string"?t:t==null?"":String(t)}function Uc(t){return typeof t=="string"&&t.trim()!==""?t.toUpperCase():"GET"}function wr(t){if(!(!t||typeof t!="object"))return t.statusCode!==void 0&&t.statusCode!==null?t.statusCode:t.status}function Wt(t){const e=Hs(t);return e!==void 0&&e>=400}function kr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function zc(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 Hs(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 qc(t){try{const e=t.match(/^https?:\/\/([^:/\n]+)/i);return e&&e[1]?e[1]:""}catch(e){return""}}const Wc=["onLaunch","onShow","onHide","onError"],tt=new Set;let $e=null,nt=!1;function Gc(t,e){for(const n of[...tt]){const r=n[t];if(typeof r=="function")try{r(e)}catch(s){}}}function Jc(){const t=globalThis;if(nt||typeof t.App!="function")return;const e=t.App;$e=e;const n=function(r={}){if(r&&typeof r=="object")for(const s of Wc){const i=r[s];r[s]=function(...o){if(Gc(s,o[0]),typeof i=="function")return i.apply(this,o)}}return e.call(this,r)};n.__sentryAppWrapper=!0,t.App=n,nt=!0}function Kc(){if(!nt||tt.size>0)return;const t=globalThis;t.App&&t.App.__sentryAppWrapper&&$e&&(t.App=$e),$e=null,nt=!1}function Us(t){if(typeof globalThis.App!="function")return()=>{};tt.add(t),Jc();let e=!0;return()=>{e&&(e=!1,tt.delete(t),Kc())}}const zs=["onLoad","onShow","onHide","onUnload","onReady"];function Vc(t){return zs.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 _t=class _t{constructor(e={}){this.name=_t.id,this._originalPage=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")return;this._originalPage=e.Page;const n=e.Page,r=this._options,s=()=>this._firstPageReady,i=a=>{this._firstPageReady=a},o=()=>this._launchTime;e.Page=function(a){if(a&&typeof a=="object"){if(r.enableLifecycle){for(const c of zs)if(typeof a[c]=="function"){const u=a[c];a[c]=function(...p){const f=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",h={action:c,page:f};if(c==="onLoad"&&p[0]&&typeof p[0]=="object"&&(h.query=p[0]),c==="onReady"&&!s()&&o()>0){i(!0);const d=Date.now()-o();h.coldStartDuration=d,W("startup",{coldStartDuration:d,firstPage:f})}return k({category:"page.lifecycle",message:`${c}: ${f}`,level:"info",data:h}),u.apply(this,p)}}}if(r.enableUserInteraction){for(const c of Object.keys(a))if(typeof a[c]=="function"&&Vc(c)){const u=a[c];a[c]=function(p,...f){const h=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",d={handler:c,page:h};if(p&&typeof p=="object"&&(p.target&&(p.target.id&&(d.targetId=p.target.id),p.target.dataset&&(d.dataset=p.target.dataset)),p.type&&(d.eventType=p.type),p.detail&&(typeof p.detail.x=="number"&&(d.x=p.detail.x),typeof p.detail.y=="number"&&(d.y=p.detail.y)),p.touches&&p.touches.length>0)){const _=p.touches[0];_&&(d.touchX=_.pageX,d.touchY=_.pageY)}return k({category:"user.interaction",message:`${c} on ${h}`,level:"info",data:d}),u.apply(this,[p,...f])}}}}return n(a)}}_subscribeApp(){this._options.enableLifecycle&&(this._unsubscribeApp=Us({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._originalPage,this._originalPage=null),this._unsubscribeApp&&(this._unsubscribeApp(),this._unsubscribeApp=null)}};_t.id="PageBreadcrumbs";let we=_t;const Yc=t=>new we(t),Xc=["debug","info","warn","error","log"],Zc={debug:"debug",info:"info",log:"info",warn:"warning",error:"error"},mt=class mt{constructor(e={}){this.name=mt.id,this._originalMethods={},this._levels=e.levels||[...Xc]}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:Zc[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={}}};mt.id="ConsoleBreadcrumbs";let ke=mt;const Qc=t=>new ke(t),gt=class gt{constructor(){this.name=gt.id,this._isSessionActive=!1,this._unsubscribe=null}setupOnce(){this._unsubscribe=Us({onLaunch:()=>this._startSession(),onShow:()=>{this._isSessionActive||this._startSession()},onHide:()=>this._endSession()})}_startSession(){try{ms({ignoreDuration:!0}),on(),this._isSessionActive=!0}catch(e){}}_endSession(){try{At(),on(),this._isSessionActive=!1}catch(e){}}cleanup(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null),this._isSessionActive=!1}};gt.id="Session";let rt=gt;const yt=class yt{constructor(){this.name=yt.id,this._statusChangeHandler=null,this._lastConnected=null}setupOnce(){const e=S();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=S();if(e&&typeof e.offNetworkStatusChange=="function")try{e.offNetworkStatusChange(this._statusChangeHandler)}catch(n){}this._statusChangeHandler=null}}};yt.id="NetworkStatus";let st=yt;const St=class St{constructor(){this.name=St.id,this._initTs=Ee(),this._initEpoch=cn(),this._showHandler=null,this._hideHandler=null,this._coldStartReported=!1,this._minigameContext={runtime:"minigame"}}setupOnce(){const e=S();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=Ee(),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=kt({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}),ee("cold_start",r,"millisecond",s),s.end((this._initEpoch+r)/1e3)})}cleanup(){const e=S();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}}};St.id="Minigame";let ae=St;const eu=()=>new ae,tu=["minor","major","severe"];function nu(t){if(!t)return[];const e=[];for(const n of tu){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 ru(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 D=class D{constructor(e={}){var r,s,i,o;this.name=D.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=nu(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=Ee();this._lastFrameTs=n,this._sessionEpochStart=cn();const r=()=>{if(!this._running)return;const i=Ee();this._onFrame(i-this._lastFrameTs),this._lastFrameTs=i,e(r)};e(r);const s=S();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>D._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?ru(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>D._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>D._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=cn(),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=Ee();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,a=this._sessionFrames,c=kt({name:"minigame.framerate.summary",op:"ui.framerate",forceTransaction:!0,startTime:this._sessionEpochStart/1e3});if(c.setAttributes({"fps.avg":n,"fps.p95":s,"fps.min":r,"frames.total":a,"jank.count":o,"frame.worst_ms":i}),ee("fps_avg",n,"none",c),ee("fps_p95",s,"none",c),ee("fps_min",r,"none",c),ee("jank_count",o,"none",c),this._tiered){const u={};for(const p of this._tiers){const f=this._sessionJankByTier[p.name];u[`jank.${p.name}`]=f,ee(`jank_${p.name}_count`,f,"none",c)}c.setAttributes(u)}return c.end((this._sessionEpochStart+Math.max(0,e))/1e3),this._resetSession(),!0}_flushPendingEvents(){Promise.resolve(hs(D._HIDE_FLUSH_TIMEOUT_MS)).catch(()=>{})}cleanup(){this._running=!1,this._flushSummary()&&this._flushPendingEvents();const e=S();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}};D.id="MinigameFrameRate",D._MAX_FPS_SAMPLES=2e3,D._MAX_REASONABLE_FRAME_DELTA_MS=5e3,D._HIDE_FLUSH_TIMEOUT_MS=2e3;let ce=D;const iu=t=>()=>new ce(t),ou=Object.freeze(Object.defineProperty({__proto__:null,ConsoleBreadcrumbs:ke,Dedupe:Xe,GlobalHandlers:Je,HttpContext:Ye,LinkedErrors:Ve,MinigameFrameRateIntegration:ce,MinigameIntegration:ae,NetworkBreadcrumbs:et,NetworkStatusIntegration:st,PageBreadcrumbs:we,PerformanceIntegration:Ze,RewriteFrames:Qe,Router:ln,SessionIntegration:rt,System:un,TryCatch:Ke,consoleBreadcrumbsIntegration:Qc,minigameFrameRateIntegration:iu,minigameIntegration:eu,pageBreadcrumbsIntegration:Yc,performanceIntegration:Rn},Symbol.toStringTag,{value:"Module"})),Cn=[new Ye,new Xe,new Je,new Ke,new Ve,Rn({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!0,sampleRate:1,reportInterval:3e4})];function au(){return[...Cn]}function cu(t={}){if(!Ds()){console.warn("[sentry-miniapp] Not running in a supported miniapp environment");return}const e=[...t.integrations||Cn],n=E(l({},t),{integrations:e,stackParser:Ps,transport:t.transport});n.enableSourceMap!==!1&&n.integrations.push(new Qe);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 et(r)),n.enableAutoSessionTracking!==!1&&n.integrations.push(new rt);const s=n.enableNavigationBreadcrumbs!==!1,i=n.enableUserInteractionBreadcrumbs!==!1;(s||i)&&n.integrations.push(new we({enableLifecycle:s,enableUserInteraction:i})),n.enableNetworkStatusMonitoring!==!1&&n.integrations.push(new st),n.enableConsoleBreadcrumbs&&n.integrations.push(new ke);const o=Ac(),a=c=>n.integrations.some(u=>u&&u.name===c);if(!a("EventFilters")&&!a("InboundFilters")){const c={};n.allowUrls&&(c.allowUrls=n.allowUrls),n.denyUrls&&(c.denyUrls=n.denyUrls),n.ignoreErrors&&(c.ignoreErrors=n.ignoreErrors),n.integrations.push(oc(c))}return!a(ae.id)&&(n.enableMinigameLifecycle===!0||o&&n.enableMinigameLifecycle!==!1)&&n.integrations.push(new ae),!a(ce.id)&&(n.enableMinigameFrameRate===!0||o&&n.enableMinigameFrameRate!==!1)&&n.integrations.push(new ce(n.minigameFrameRateOptions)),W("miniapp",{platform:Ms(),environment:"miniapp"}),Ya(Bs,n),b().getClient()}function uu(t={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}function lu(t){return function(...e){return Pe(()=>{try{return t.apply(this,e)}catch(n){throw b().captureException(n),n}})}}function fu(t){const e=b().getClient();return e?e.captureFeedback(t):(console.warn("[sentry-miniapp] No client available for captureFeedback"),"")}Ar();exports.Integrations=ou;exports.MiniappClient=Bs;exports.SDK_NAME=Cs;exports.SDK_VERSION=Le;exports.Transports=Nc;exports.addBreadcrumb=k;exports.addEventProcessor=da;exports.addIntegration=ba;exports.captureEvent=ia;exports.captureException=te;exports.captureFeedback=fu;exports.captureMessage=sa;exports.captureSession=on;exports.close=pa;exports.closeSession=$r;exports.defaultIntegrations=Cn;exports.endSession=At;exports.flush=hs;exports.getClient=w;exports.getCurrentScope=b;exports.getDefaultIntegrations=au;exports.getIsolationScope=A;exports.getPerformanceManager=Fs;exports.init=cu;exports.isEnabled=_s;exports.lastEventId=fa;exports.makeSession=Lr;exports.miniappStackParser=Ps;exports.performanceIntegration=Rn;exports.setContext=W;exports.setExtra=aa;exports.setExtras=oa;exports.setTag=ua;exports.setTags=ca;exports.setUser=la;exports.showReportDialog=uu;exports.startInactiveSpan=kt;exports.startSession=ms;exports.startSpan=me;exports.updateSession=K;exports.withScope=Pe;exports.wrap=lu;
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},Ms=()=>{var t,e;return(e=(t=Ds())==null?void 0:t.name)!=null?e:"unknown"},Ac=()=>{try{const t=Nn(),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 jt=null;const Ct=()=>(jt===null&&(jt=Ac()),jt),Rc=()=>{var t,e;try{const n=Nn();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 Bt=null;const Cc=()=>{if(Bt===null){const t=Rc();return(t.appId!=="unknown"||t.version!=="unknown")&&(Bt=t),t}return Bt},Fs=()=>Ms()!=="unknown";let Ht=null,Ut=null;const b=()=>(Ht===null&&(Ht=Nn()),Ht),Ls=()=>(Ut===null&&(Ut=Ms()),Ut);let zt=null;const Pc=()=>{if(zt===null){const t=globalThis,e=typeof t.GameGlobal!="undefined",n=typeof t.App!="function"&&typeof t.Page!="function"&&typeof t.getCurrentPages!="function";zt=Fs()&&(e||n)}return zt},$s=()=>{try{const t=b();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(),ln=()=>Date.now();function js(t){const e=t.url;function n(r){return new Promise((s,i)=>{var a,c,u,d;const o={url:e,method:"POST",data:r.body,header:p({"Content-Type":"application/json"},r.headers),headers:p({"Content-Type":"application/json"},r.headers),timeout:1e4,success:l=>{const h=l.statusCode||l.status,f=l.header||l.headers||{};s({statusCode:h,headers:{"x-sentry-rate-limits":f["x-sentry-rate-limits"],"retry-after":f["retry-after"]}})},fail:l=>{i(new Error(`Network request failed: ${l.errMsg||l.errorMessage||l.message||"Unknown error"}`))}};b().request?(c=(a=b()).request)==null||c.call(a,o):b().httpRequest?(d=(u=b()).httpRequest)==null||d.call(u,o):i(new Error("No request method available in current miniapp environment"))})}return $a(t,n)}const Nc=30,xc=864e5,xn="sentry_offline_store",Oc=900*1024;function Bs(t){var r,s;const e=(r=t.offlineCacheLimit)!=null?r:Nc,n=(s=t.offlineCacheMaxAge)!=null?s:xc;return{push:i=>O(null,null,function*(){try{let o=Wt();for(o=qt(o,n),o.push({envelope:i,timestamp:Date.now()});o.length>e;){const a=o.findIndex(c=>!pn(c.envelope));a>=0?o.splice(a,1):o.shift()}Gt(o)}catch(o){console.warn("[sentry-miniapp] Failed to push to offline store",o)}}),unshift:i=>O(null,null,function*(){try{let o=Wt();for(o=qt(o,n),o.unshift({envelope:i,timestamp:Date.now()});o.length>e;){const a=Dc(o,c=>!pn(c.envelope));a>=0?o.splice(a,1):o.pop()}Gt(o)}catch(o){console.warn("[sentry-miniapp] Failed to unshift to offline store",o)}}),shift:()=>O(null,null,function*(){try{let i=Wt();if(i=qt(i,n),i.length===0)return;const o=i.shift();return Gt(i),o==null?void 0:o.envelope}catch(i){console.warn("[sentry-miniapp] Failed to shift from offline store",i);return}})}}function pn(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 qt(t,e){const n=Date.now();return t.filter(r=>n-r.timestamp<e)}function Dc(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}function Wt(){const t=b().getStorageSync;if(!t)return[];let e;try{e=t(xn)}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 Mc(),[]}}function Mc(){try{const t=b().removeStorageSync;t&&t(xn)}catch(t){}}function Gt(t){const e=b().setStorageSync;if(!e)return;let n=t,r=JSON.stringify(n);for(;n.length>0&&Fc(r)>Oc;){const s=n.findIndex(o=>!pn(o.envelope)),i=s>=0?s:0;n=n.slice(0,i).concat(n.slice(i+1)),r=JSON.stringify(n)}try{e(xn,r)}catch(s){}}function Fc(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 Lc=Object.freeze(Object.defineProperty({__proto__:null,createMiniappOfflineStore:Bs,createMiniappTransport:js},Symbol.toStringTag,{value:"Module"}));class Hs extends Ga{constructor(e={}){super(E(p({},e),{transport:e.transport||(n=>{const r=js(E(p({},n),{headers:{}}));return e.enableOfflineCache!==!1?ec(()=>r)(E(p({},n),{createStore:s=>Bs(E(p({},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=E(p({},e.sdk),{name:xs,packages:[...e.sdk&&e.sdk.packages||[],{name:"npm:@sentry/miniapp",version:$e}],version:$e}),e.contexts||(e.contexts={}),e.contexts.miniapp={platform:Ls(),sdk_version:$e};try{const s=r||S(),i=A();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=Ct();e.contexts||(e.contexts={});const r=e.contexts;return r.device=p({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=p({name:(n==null?void 0:n.system)||"unknown",version:(n==null?void 0:n.version)||"unknown"},r.os),r.app=p({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(ve)){const i=ve.indexOf(r.name);i!==-1&&ve.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 S().captureEvent(n)}}const ot=class ot{constructor(e){this.name=ot.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=p({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||(b().onError&&(this._errorHandler=r=>{const s=typeof r=="string"?new Error(r):r;te(s,{mechanism:{type:"onerror",handled:!1}})},(n=(e=b()).onError)==null||n.call(e,this._errorHandler)),this._onErrorHandlerInstalled=!0)}_installGlobalOnUnhandledRejectionHandler(){var e,n;this._onUnhandledRejectionHandlerInstalled||(b().onUnhandledRejection&&(this._rejectionHandler=({reason:r,promise:s})=>{const i=typeof r=="string"?new Error(r):r;te(i,{mechanism:{type:"onunhandledrejection",handled:!1},data:{promise:s}})},(n=(e=b()).onUnhandledRejection)==null||n.call(e,this._rejectionHandler)),this._onUnhandledRejectionHandlerInstalled=!0)}_installGlobalOnPageNotFoundHandler(){var e,n;this._onPageNotFoundHandlerInstalled||(b().onPageNotFound&&(this._pageNotFoundHandler=r=>{const s=S(),i=r.path.split("?")[0];s.setTag("pagenotfound",i),s.setContext("page_not_found",{path:r.path,query:r.query,isEntryPage:r.isEntryPage}),te(new Error(`页面无法找到: ${i}`),{mechanism:{type:"onpagenotfound",handled:!0}})},(n=(e=b()).onPageNotFound)==null||n.call(e,this._pageNotFoundHandler)),this._onPageNotFoundHandlerInstalled=!0)}_installGlobalOnMemoryWarningHandler(){var e,n;this._onMemoryWarningHandlerInstalled||(b().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=S();i.setTag("memory-warning",String(r)),i.setContext("memory_warning",{level:r,message:s}),te(new Error("内存不足告警"),{mechanism:{type:"onmemorywarning",handled:!0}})},(n=(e=b()).onMemoryWarning)==null||n.call(e,this._memoryWarningHandler)),this._onMemoryWarningHandlerInstalled=!0)}cleanup(){try{const e=b();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}};ot.id="GlobalHandlers";let Ke=ot;function Ir(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 de(o=>{o.addEventProcessor(a=>E(p({},a),{extra:E(p({},a.extra),{arguments:s})})),te(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 wr(t){try{return t&&t.name||"<anonymous>"}catch(e){return"<anonymous>"}}function Ie(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 at=class at{constructor(){this.name=at.id}_wrapTimeFunction(e){return function(...n){const r=n[0];return n[0]=Ir(r,{mechanism:{data:{function:wr(e)},handled:!0,type:"instrument"}}),e.apply(this,n)}}_wrapRAF(e){return function(n){return e(Ir(n,{mechanism:{data:{function:"requestAnimationFrame",handler:wr(e)},handled:!0,type:"instrument"}}))}}setupOnce(){const e=globalThis;e.setTimeout&&Ie(e,"setTimeout",this._wrapTimeFunction.bind(this)),e.setInterval&&Ie(e,"setInterval",this._wrapTimeFunction.bind(this)),e.requestAnimationFrame&&Ie(e,"requestAnimationFrame",this._wrapRAF.bind(this))}};at.id="TryCatch";let Ye=at;const $c="cause",jc=5,ct=class ct{constructor(e={}){this.name=ct.id,this._key=e.key||$c,this._limit=e.limit||jc}setupOnce(){}processEvent(e,n){return S().getClient()?this._handler(e,n):e}_handler(e,n){if(!e.exception||!e.exception.values||!n||!kr(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(!kr(e[n],Error)||r.length+1>=this._limit)return r;const s=yc(()=>[],e[n]);return this._walkErrorTree(e[n],n,[s,...r])}};ct.id="LinkedErrors";let Ve=ct;function kr(t,e){try{return t instanceof e}catch(n){return!1}}const ut=class ut{constructor(){this.name=ut.id}setupOnce(){}processEvent(e){var s,i;const n=this._getMiniappVersion(),r=Cc();return e.contexts=E(p({},e.contexts),{runtime:E(p({},((s=e.contexts)==null?void 0:s.runtime)||{}),{name:"miniapp",version:n}),app:E(p({},((i=e.contexts)==null?void 0:i.app)||{}),{name:r.appId,version:r.version})}),e}_getMiniappVersion(){const e=Ct();return(e==null?void 0:e.version)||(e==null?void 0:e.SDKVersion)||"unknown"}};ut.id="HttpContext";let Xe=ut;const lt=class lt{constructor(e={}){this.name=lt.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(!Bc(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],a=r[i];if(o.filename!==a.filename||o.lineno!==a.lineno||o.colno!==a.colno||o.function!==a.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=>p({},i))}:void 0}})}:void 0}}_getFramesFromEvent(e){const n=e.exception;if(n)try{return n.values[0].stacktrace.frames}catch(r){}}};lt.id="Dedupe";let Ze=lt;const Ar=/\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 Bc(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=t.replace(Ar,"<dynamic>"),r=e.replace(Ar,"<dynamic>");return n===r}const pt=class pt{constructor(){this.name=pt.id}setupOnce(){this._addSystemContext(),this._addNetworkContext(),this._addLocationContext(),this._addStorageContext(),this._checkAppUpdate()}_addSystemContext(){var e,n,r,s;try{const i=Ct();if(i){const o=S();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{b().getNetworkType&&b().getNetworkType({success:e=>{const n=S();n.setContext("network",{type:e.networkType,connected:e.isConnected!==!1}),n.setTag("network.type",e.networkType)},fail:()=>{}})}catch(e){}}_addLocationContext(){try{b().getLocation&&b().getLocation({type:"gcj02",success:e=>{S().setContext("location",{latitude:e.latitude,longitude:e.longitude,accuracy:e.accuracy})},fail:()=>{}})}catch(e){}}_addStorageContext(){try{const e=b();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;S().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=b();if(e&&typeof e.getUpdateManager=="function"){const n=e.getUpdateManager();n&&(typeof n.onCheckForUpdate=="function"&&n.onCheckForUpdate(r=>{r&&r.hasUpdate&&(S().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){}}};pt.id="System";let fn=pt;const ft=class ft{constructor(){this.name=ft.id,this._lastRoute="",this._monitorTimer=null}setupOnce(){this._instrumentNavigation(),this._startRouteMonitoring()}_instrumentNavigation(){let e;try{e=b()}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=S();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=S();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()})}};ft.id="Router";let dn=ft;const dt=class dt{constructor(e={}){this.name=dt.id,this._performanceManager=null,this._observers=[],this._entryBuffer=[],this._reportTimer=null,this._options=E(p({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!1,sampleRate:1,bufferSize:100,reportInterval:3e4,enableMemory:!1},e),{thresholds:p({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=$s(),!this._performanceManager){console.warn("[sentry-miniapp] Performance API not available");return}const e=S();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=Ct();if(i&&i.platform==="devtools"&&(n=!1),n){const a=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{}).PerformanceObserver,c=a&&Array.isArray(a.supportedEntryTypes)?a.supportedEntryTypes:void 0;(!c||!c.includes("measure")||!c.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(a=>a!=="measure"&&a!=="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){S().addBreadcrumb({message:`页面导航: ${e.name}`,category:"performance.navigation",level:"info",data:{duration:e.duration,appLaunchTime:e.appLaunchTime,pageReadyTime:e.pageReadyTime}}),ge({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;ge({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&&S().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){ge({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"?ge({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"&&S().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=S(),n=this._calculatePerformanceStats(),r=this._collectMemoryInfo();r&&(n.memory=r),e.setContext("performance_summary",p({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,a)=>o+a,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)}}if(n.length>0){const i=n.map(a=>a.duration);s.render_stats={avg_duration:i.reduce((a,c)=>a+c,0)/i.length,max_duration:Math.max(...i),min_duration:Math.min(...i)};const o=n.filter(a=>{var c,u;return a.duration>((u=(c=this._options.thresholds)==null?void 0:c.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(a=>a.duration),o=r.map(a=>a.transferSize||0).filter(a=>a>0);s.resource_stats={avg_load_time:i.reduce((a,c)=>a+c,0)/i.length,max_load_time:Math.max(...i),total_transfer_size:o.reduce((a,c)=>a+c,0),avg_transfer_size:o.length>0?o.reduce((a,c)=>a+c,0)/o.length:0}}return s}_checkPerformanceThresholds(e){var o,a,c,u,d,l,h,f,_;const n=S(),r=(a=(o=this._options.thresholds)==null?void 0:o.navigation)!=null?a:3e3;((c=e.navigation_stats)==null?void 0:c.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;((l=e.render_stats)==null?void 0:l.avg_duration)>s&&n.addBreadcrumb({message:"页面渲染性能较慢",category:"performance.warning",level:"warning",data:{avg_duration:e.render_stats.avg_duration,threshold:s}});const i=(f=(h=this._options.thresholds)==null?void 0:h.resource)!=null?f:2e3;((_=e.resource_stats)==null?void 0:_.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=b();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=b();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=S(),n=b(),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()}};dt.id="PerformanceAPI";let Qe=dt;const On=t=>()=>new Qe(t),ht=class ht{constructor(e={}){this.name=ht.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}`}};ht.id="RewriteFrames";let et=ht;const _t=class _t{constructor(e={}){this.name=_t.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=b();e&&typeof e.request=="function"&&(this._originalRequest=e.request,Ie(e,"request",this._createRequestWrapper.bind(this))),e&&typeof e.httpRequest=="function"&&(this._originalHttpRequest=e.httpRequest,Ie(e,"httpRequest",this._createRequestWrapper.bind(this)))}cleanup(){const e=b();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(a){if(!a||typeof a!="object")return e.call(this,a);const c=Jc(a.url),u=w();let d="";if(u){const T=u.getOptions().dsn;if(T)try{const R=T.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?([^:/\n]+)/i);R&&R[1]&&(d=R[1])}catch(R){}}const l=c.match(/^https?:\/\/([^:/\n]+)/i),h=l&&l[1]?l[1]:"";if(d&&h===d||h==="sentry.io"||h.endsWith(".sentry.io"))return e.call(this,a);const _=Kc(a.method),y=a.data,v=Date.now(),I=Hc(_,c);let j=!1;const F=T=>{j||(j=!0,Gc(I,T))};i&&o(c)&&Wc(a,I);const x={url:c,method:_};if(n&&y&&!s(c))try{const T=typeof y=="string"?y:JSON.stringify(y);x.request_body=r(T),x.request_size=T.length}catch(T){x.request_body="[Cannot serialize request body]"}const Mn=a.success,Fn=a.fail,Ln=a.complete;a.success=function(...T){const R=T[0]||{},B=Rr(R),_e=Date.now()-v;if(x.status_code=B,x.duration=_e,F({statusCode:B,status:Jt(B)?"error":"ok"}),n&&R.data&&!s(c))try{const Pt=typeof R.data=="string"?R.data:JSON.stringify(R.data);x.response_body=r(Pt),x.response_size=Pt.length}catch(Pt){x.response_body="[Cannot serialize response body]"}const Ws=Jt(B)||_e>3e3?"warning":"info";if(k({type:"http",category:"xhr",data:x,level:Ws}),typeof Mn=="function")return Mn.apply(this,T)},a.fail=function(...T){const R=T[0]||{},B=Date.now()-v,_e=R.errMsg||R.errorMessage||"Network request failed";if(x.error=_e,x.duration=B,F({status:"error",errorMessage:_e}),k({type:"http",category:"xhr",data:x,level:"error"}),typeof Fn=="function")return Fn.apply(this,T)},a.complete=function(...T){const R=T[0]||{},B=Rr(R);if(F({statusCode:B,status:Jt(B)?"error":"ok"}),typeof Ln=="function")return Ln.apply(this,T)};try{return e.call(this,a)}catch(T){throw F({status:"error",errorMessage:T instanceof Error?T.message:String(T)}),T}}}_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])}};_t.id="NetworkBreadcrumbs";let tt=_t;function Hc(t,e){try{const n=Vc(e);return At({name:`${t} ${Uc(e)}`,op:"http.client",kind:2,attributes:{"http.request.method":t,"url.full":e,"server.address":n||void 0}})}catch(n){return null}}function Uc(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 Wc(t,e){if(e)try{const n=tc({span:e}),r=n["sentry-trace"];if(!r)return;const s=p(p({},Cr(t.headers)?t.headers:{}),Cr(t.header)?t.header:{});s["sentry-trace"]||(s["sentry-trace"]=r),n.baggage&&(s.baggage=Yc(s.baggage,n.baggage)),t.header=s,t.headers=s}catch(n){}}function Gc(t,e){if(t)try{const n=Us(e.statusCode);n!==void 0?Bi(t,n):t.setStatus({code:e.status==="error"?C:wt,message:e.status==="error"?e.errorMessage||"error":"ok"}),e.errorMessage&&t.setAttribute("error.message",e.errorMessage),t.end()}catch(n){}}function Jc(t){return typeof t=="string"?t:t==null?"":String(t)}function Kc(t){return typeof t=="string"&&t.trim()!==""?t.toUpperCase():"GET"}function Rr(t){if(!(!t||typeof t!="object"))return t.statusCode!==void 0&&t.statusCode!==null?t.statusCode:t.status}function Jt(t){const e=Us(t);return e!==void 0&&e>=400}function Cr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Yc(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 Us(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 Vc(t){try{const e=t.match(/^https?:\/\/([^:/\n]+)/i);return e&&e[1]?e[1]:""}catch(e){return""}}const Xc=["onLaunch","onShow","onHide","onError"],nt=new Set;let je=null,rt=!1;function Zc(t,e){for(const n of[...nt]){const r=n[t];if(typeof r=="function")try{r(e)}catch(s){}}}function Qc(){const t=globalThis;if(rt||typeof t.App!="function")return;const e=t.App;je=e;const n=function(r={}){if(r&&typeof r=="object")for(const s of Xc){const i=r[s];r[s]=function(...o){if(Zc(s,o[0]),typeof i=="function")return i.apply(this,o)}}return e.call(this,r)};n.__sentryAppWrapper=!0,t.App=n,rt=!0}function eu(){if(!rt||nt.size>0)return;const t=globalThis;t.App&&t.App.__sentryAppWrapper&&je&&(t.App=je),je=null,rt=!1}function zs(t){if(typeof globalThis.App!="function")return()=>{};nt.add(t),Qc();let e=!0;return()=>{e&&(e=!1,nt.delete(t),eu())}}const qs=["onLoad","onShow","onHide","onUnload","onReady"];function tu(t){return qs.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 mt=class mt{constructor(e={}){this.name=mt.id,this._originalPage=null,this._wrappedPage=null,this._unsubscribeApp=null,this._launchTime=0,this._firstPageReady=!1,this._options=p({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=c=>{this._firstPageReady=c},o=()=>this._launchTime,a=function(c){if(c&&typeof c=="object"){if(r.enableLifecycle){for(const u of qs)if(typeof c[u]=="function"){const d=c[u];c[u]=function(...l){const h=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",f={action:u,page:h};if(u==="onLoad"&&l[0]&&typeof l[0]=="object"&&(f.query=l[0]),u==="onReady"&&!s()&&o()>0){i(!0);const _=Date.now()-o();f.coldStartDuration=_,W("startup",{coldStartDuration:_,firstPage:h})}return k({category:"page.lifecycle",message:`${u}: ${h}`,level:"info",data:f}),d.apply(this,l)}}}if(r.enableUserInteraction){for(const u of Object.keys(c))if(typeof c[u]=="function"&&tu(u)){const d=c[u];c[u]=function(l,...h){const f=(this==null?void 0:this.route)||(this==null?void 0:this.__route__)||"unknown",_={handler:u,page:f};if(l&&typeof l=="object"&&(l.target&&(l.target.id&&(_.targetId=l.target.id),l.target.dataset&&(_.dataset=l.target.dataset)),l.type&&(_.eventType=l.type),l.detail&&(typeof l.detail.x=="number"&&(_.x=l.detail.x),typeof l.detail.y=="number"&&(_.y=l.detail.y)),l.touches&&l.touches.length>0)){const y=l.touches[0];y&&(_.touchX=y.pageX,_.touchY=y.pageY)}return k({category:"user.interaction",message:`${u} on ${f}`,level:"info",data:_}),d.apply(this,[l,...h])}}}}return n(c)};Object.defineProperty(a,"__sentryPageWrapper",{value:!0,configurable:!0}),this._wrappedPage=a,e.Page=a}_subscribeApp(){this._options.enableLifecycle&&(this._unsubscribeApp=zs({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)}};mt.id="PageBreadcrumbs";let Ae=mt;const nu=t=>new Ae(t),ru=["debug","info","warn","error","log"],su={debug:"debug",info:"info",log:"info",warn:"warning",error:"error"},gt=class gt{constructor(e={}){this.name=gt.id,this._originalMethods={},this._levels=e.levels||[...ru]}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:su[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={}}};gt.id="ConsoleBreadcrumbs";let Re=gt;const iu=t=>new Re(t),yt=class yt{constructor(){this.name=yt.id,this._isSessionActive=!1,this._unsubscribe=null}setupOnce(){this._unsubscribe=zs({onLaunch:()=>this._startSession(),onShow:()=>{this._isSessionActive||this._startSession()},onHide:()=>this._endSession()})}_startSession(){try{Ss({ignoreDuration:!0}),cn(),this._isSessionActive=!0}catch(e){}}_endSession(){try{Rt(),cn(),this._isSessionActive=!1}catch(e){}}cleanup(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null),this._isSessionActive=!1}};yt.id="Session";let st=yt;const St=class St{constructor(){this.name=St.id,this._statusChangeHandler=null,this._lastConnected=null}setupOnce(){const e=b();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=b();if(e&&typeof e.offNetworkStatusChange=="function")try{e.offNetworkStatusChange(this._statusChangeHandler)}catch(n){}this._statusChangeHandler=null}}};St.id="NetworkStatus";let it=St;const bt=class bt{constructor(){this.name=bt.id,this._initTs=Te(),this._initEpoch=ln(),this._showHandler=null,this._hideHandler=null,this._coldStartReported=!1,this._minigameContext={runtime:"minigame"}}setupOnce(){const e=b();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",p({},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",p({},this._minigameContext)),k({category:"minigame.performance",message:`SDK 初始化到首帧耗时: ${r}ms`,level:"info",data:{coldStartMs:r}});const s=At({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}),ee("cold_start",r,"millisecond",s),s.end((this._initEpoch+r)/1e3)})}cleanup(){const e=b();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}}};bt.id="Minigame";let ae=bt;const ou=()=>new ae,au=["minor","major","severe"];function cu(t){if(!t)return[];const e=[];for(const n of au){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 uu(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 lu(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 D=class D{constructor(e={}){var r,s,i,o;this.name=D.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=cu(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=ln();const r=()=>{if(!this._running)return;const i=Te();this._onFrame(i-this._lastFrameTs),this._lastFrameTs=i,e(r)};e(r);const s=b();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>D._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?uu(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>D._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>D._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=ln(),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=lu(this._fpsSamples,n),i=Math.round(this._sessionWorstFrame),o=this._sessionJank,a=this._sessionFrames,c=At({name:"minigame.framerate.summary",op:"ui.framerate",forceTransaction:!0,startTime:this._sessionEpochStart/1e3});if(c.setAttributes({"fps.avg":n,"fps.p95":s,"fps.min":r,"frames.total":a,"jank.count":o,"frame.worst_ms":i}),ee("fps_avg",n,"none",c),ee("fps_p95",s,"none",c),ee("fps_min",r,"none",c),ee("jank_count",o,"none",c),this._tiered){const u={};for(const d of this._tiers){const l=this._sessionJankByTier[d.name];u[`jank.${d.name}`]=l,ee(`jank_${d.name}_count`,l,"none",c)}c.setAttributes(u)}return c.end((this._sessionEpochStart+Math.max(0,e))/1e3),this._resetSession(),!0}_flushPendingEvents(){Promise.resolve(gs(D._HIDE_FLUSH_TIMEOUT_MS)).catch(()=>{})}cleanup(){this._running=!1,this._flushSummary()&&this._flushPendingEvents();const e=b();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}};D.id="MinigameFrameRate",D._MAX_FPS_SAMPLES=2e3,D._MAX_REASONABLE_FRAME_DELTA_MS=5e3,D._HIDE_FLUSH_TIMEOUT_MS=2e3;let ce=D;const pu=t=>()=>new ce(t),fu=Object.freeze(Object.defineProperty({__proto__:null,ConsoleBreadcrumbs:Re,Dedupe:Ze,GlobalHandlers:Ke,HttpContext:Xe,LinkedErrors:Ve,MinigameFrameRateIntegration:ce,MinigameIntegration:ae,NetworkBreadcrumbs:tt,NetworkStatusIntegration:it,PageBreadcrumbs:Ae,PerformanceIntegration:Qe,RewriteFrames:et,Router:dn,SessionIntegration:st,System:fn,TryCatch:Ye,consoleBreadcrumbsIntegration:iu,minigameFrameRateIntegration:pu,minigameIntegration:ou,pageBreadcrumbsIntegration:nu,performanceIntegration:On},Symbol.toStringTag,{value:"Module"}));function Dn(){return[new Xe,new Ze,new Ke,new Ye,new Ve,On({enableNavigation:!0,enableRender:!0,enableResource:!0,enableUserTiming:!0,sampleRate:1,reportInterval:3e4})]}const du=Dn();function hu(t={}){if(!Fs()){console.warn("[sentry-miniapp] Not running in a supported miniapp environment");return}const e=[...t.integrations||Dn()],n=E(p({},t),{integrations:e,stackParser:Os,transport:t.transport});n.enableSourceMap!==!1&&n.integrations.push(new et);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 tt(r)),n.enableAutoSessionTracking!==!1&&n.integrations.push(new st);const s=n.enableNavigationBreadcrumbs!==!1,i=n.enableUserInteractionBreadcrumbs!==!1;(s||i)&&n.integrations.push(new Ae({enableLifecycle:s,enableUserInteraction:i})),n.enableNetworkStatusMonitoring!==!1&&n.integrations.push(new it),n.enableConsoleBreadcrumbs&&n.integrations.push(new Re);const o=Pc(),a=c=>n.integrations.some(u=>u&&u.name===c);if(!a("EventFilters")&&!a("InboundFilters")){const c={};n.allowUrls&&(c.allowUrls=n.allowUrls),n.denyUrls&&(c.denyUrls=n.denyUrls),n.ignoreErrors&&(c.ignoreErrors=n.ignoreErrors),n.integrations.push(ac(c))}return!a(ae.id)&&(n.enableMinigameLifecycle===!0||o&&n.enableMinigameLifecycle!==!1)&&n.integrations.push(new ae),!a(ce.id)&&(n.enableMinigameFrameRate===!0||o&&n.enableMinigameFrameRate!==!1)&&n.integrations.push(new ce(n.minigameFrameRateOptions)),W("miniapp",{platform:Ls(),environment:"miniapp"}),Xa(Hs,n),S().getClient()}function _u(t={}){console.warn("[sentry-miniapp] showReportDialog is deprecated and does nothing. Please build your own UI and use `Sentry.captureFeedback()` instead.")}function mu(t){return function(...e){return de(()=>{try{return t.apply(this,e)}catch(n){throw S().captureException(n),n}})}}function gu(t){const e=S().getClient();return e?e.captureFeedback(t):(console.warn("[sentry-miniapp] No client available for captureFeedback"),"")}Pr();exports.Integrations=fu;exports.MiniappClient=Hs;exports.SDK_NAME=xs;exports.SDK_VERSION=$e;exports.Transports=Lc;exports.addBreadcrumb=k;exports.addEventProcessor=ha;exports.addIntegration=Ea;exports.captureEvent=oa;exports.captureException=te;exports.captureFeedback=gu;exports.captureMessage=ia;exports.captureSession=cn;exports.close=da;exports.closeSession=Hr;exports.defaultIntegrations=du;exports.endSession=Rt;exports.flush=gs;exports.getClient=w;exports.getCurrentScope=S;exports.getDefaultIntegrations=Dn;exports.getIsolationScope=A;exports.getPerformanceManager=$s;exports.init=hu;exports.isEnabled=ys;exports.lastEventId=fa;exports.makeSession=Br;exports.miniappStackParser=Os;exports.performanceIntegration=On;exports.setContext=W;exports.setExtra=ca;exports.setExtras=aa;exports.setTag=la;exports.setTags=ua;exports.setUser=pa;exports.showReportDialog=_u;exports.startInactiveSpan=At;exports.startSession=Ss;exports.startSpan=ge;exports.updateSession=K;exports.withScope=de;exports.wrap=mu;
19
19
  //# sourceMappingURL=sentry-miniapp.cjs.js.map