@ihyeon/browser-error-log 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ko.md CHANGED
@@ -203,6 +203,20 @@ currentAppSection = 'account'; // 이후 이벤트에는 현재 값을 사용
203
203
 
204
204
  사용자 지정 `transport(batch, { signal })`에서는 요청에 `signal`을 전달하고 전송 실패 시 reject하세요. 자동 네트워크 오류 수집이나 요청 기록을 원하면 자기 전송을 제외할 `endpoint`를 지정해야 합니다. 없으면 사용자 지정 transport에서 두 경로를 모두 끕니다. 기본 전송은 credentials를 보내지 않습니다.
205
205
 
206
+ ## 전역 JavaScript 자동 수집 제어
207
+
208
+ ```ts
209
+ const errorLog = init({
210
+ project: 'my-web',
211
+ endpoint: '/api/events',
212
+ captureGlobalErrors: false,
213
+ });
214
+ ```
215
+
216
+ 전역 JavaScript 오류 자동 수집의 기본값은 켜짐입니다. 앱에서 이 실패를 별도로 보고한다면 `captureGlobalErrors: false`로 설정할 수 있습니다. 클라이언트마다 초기화 때 설정을 고정하고 리스너 해제에도 같은 값을 사용합니다. 전역 수집을 켠 다른 클라이언트는 같은 브라우저 이벤트를 계속 수집합니다.
217
+
218
+ 수집하지 않은 전역 오류는 수집 콜백·큐 진입 한도·`filtered`·`dropped`를 사용하지 않습니다. `captureException(error, { type: 'javascript' })`로 직접 보고할 수 있습니다. Promise 수집은 `captureUnhandledRejections`, 리소스 요소 오류는 독립적인 `captureResourceErrors`를 따르고 다른 오류도 각자의 설정을 유지합니다. 브라우저의 기본 처리와 앱 리스너도 그대로 동작합니다. 전송 필드와 수집기 요구 사항은 바뀌지 않습니다.
219
+
206
220
  ## Promise 자동 수집 제어
207
221
 
208
222
  ```ts
@@ -215,7 +229,7 @@ const errorLog = init({
215
229
 
216
230
  `unhandledrejection` 자동 수집의 기본값은 켜짐입니다. 앱에서 이 실패를 별도로 보고한다면 `captureUnhandledRejections: false`로 설정할 수 있습니다. 클라이언트마다 초기화 시 설정을 고정하므로 나중에 원래 옵션을 바꿔도 수집·해제 동작이 달라지지 않습니다. 자동 수집을 켠 다른 클라이언트는 같은 브라우저 이벤트를 계속 수집합니다.
217
231
 
218
- 자동 수집을 끈 클라이언트는 해당 거부 리스너를 등록하지 않아 이 이벤트의 수집 콜백·큐 진입 한도·`filtered`·`dropped`를 사용하지 않습니다. `captureException(error, { type: 'promise' })`로 직접 보고할 수 있으며 전역 JavaScript 오류와 다른 설정된 오류 수집은 계속 동작합니다. 브라우저의 기본 처리와 앱의 리스너도 그대로 실행됩니다. 전송 필드나 수집기 요구 사항은 바뀌지 않습니다.
232
+ 자동 수집을 끈 클라이언트는 해당 거부 리스너를 등록하지 않아 이 이벤트의 수집 콜백·큐 진입 한도·`filtered`·`dropped`를 사용하지 않습니다. `captureException(error, { type: 'promise' })`로 직접 보고할 수 있으며 다른 오류 유형은 각자의 수집 옵션을 따릅니다. 브라우저의 기본 처리와 앱의 리스너도 그대로 실행됩니다. 전송 필드나 수집기 요구 사항은 바뀌지 않습니다.
219
233
 
220
234
  ## 예상된 메시지 제외
221
235
 
package/README.md CHANGED
@@ -203,6 +203,20 @@ By default, HTTP capture records 5xx responses and network failures, excludes in
203
203
 
204
204
  For a custom `transport(batch, { signal })`, pass `signal` to your request and reject on delivery failure. Include `endpoint` for collector exclusion when using automatic network error capture or network breadcrumbs; otherwise both are disabled for a custom transport. The default transport omits credentials.
205
205
 
206
+ ## Control automatic JavaScript capture
207
+
208
+ ```ts
209
+ const errorLog = init({
210
+ project: 'my-web',
211
+ endpoint: '/api/events',
212
+ captureGlobalErrors: false,
213
+ });
214
+ ```
215
+
216
+ Global JavaScript error capture is on by default. Set `captureGlobalErrors: false` when your application reports these failures separately. Each client snapshots the setting at initialization and uses it for listener cleanup. Other clients with global capture enabled continue to receive the same browser event.
217
+
218
+ An uncaptured global error invokes no capture hooks, spends no admission capacity, and increments neither `filtered` nor `dropped`. Explicit `captureException(error, { type: 'javascript' })` remains available. Promise capture follows `captureUnhandledRejections`, and resource-element errors follow the independent `captureResourceErrors` option; other sources keep their own settings. Browser default handling and application listeners continue normally. This changes no wire fields or collector requirements.
219
+
206
220
  ## Control automatic promise capture
207
221
 
208
222
  ```ts
@@ -215,7 +229,7 @@ const errorLog = init({
215
229
 
216
230
  Automatic `unhandledrejection` capture is on by default. Set `captureUnhandledRejections: false` when your application reports these failures separately. The setting is copied at initialization for each client; changing the original options later does not change capture or cleanup. Other clients with automatic capture enabled continue to receive the same browser event.
217
231
 
218
- With automatic capture disabled, that client does not register its rejection listener, invoke capture hooks for the event, consume admission capacity, or increment `filtered`/`dropped`. You can still report an error explicitly with `captureException(error, { type: 'promise' })`, and global JavaScript and other configured error sources remain active. Browser default handling and application listeners continue normally. This changes no wire fields or collector requirements.
232
+ With automatic capture disabled, that client does not register its rejection listener, invoke capture hooks for the event, consume admission capacity, or increment `filtered`/`dropped`. You can still report an error explicitly with `captureException(error, { type: 'promise' })`, and other error sources follow their own capture settings. Browser default handling and application listeners continue normally. This changes no wire fields or collector requirements.
219
233
 
220
234
  ## Ignore expected messages
221
235
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var N=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Y=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Z=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},G=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of K(e))!J.call(n,i)&&i!==t&&N(n,i,{get:()=>e[i],enumerable:!(r=X(e,i))||r.enumerable});return n};var Q=n=>G(N({},"__esModule",{value:!0}),n);var u=(n,e,t)=>Y(n,typeof e!="symbol"?e+"":e,t);var ye={};Z(ye,{init:()=>ge});module.exports=Q(ye);var R={count:20,bytes:12e3,category:40,message:256,dataKeys:6,dataKey:80,dataString:200};var ee=20,U=48e3,te=10,re=24e3,P=[250,500],F=/(?:password|passwd|token|secret|authorization|cookie|session|api.?key|credential|bearer|private.?key)/i,_=new Set(["javascript","promise","react","console","http","network","manual","resource"]),H=new Set(["browser","webview-ios","webview-android","unknown"]),ne=0;function s(n,e){try{return n==null?void 0:Reflect.get(Object(n),e)}catch{return}}function w(n){try{return String(n)}catch{return"[unavailable]"}}function ie(n,e){return w(n).slice(0,e)}function k(){try{return performance.now()}catch{return Date.now()}}function z(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${(++ne).toString(36)}-${Math.random().toString(36).slice(2,10)}`}function M(n,e){try{if(e?.aborted)return!0}catch{}return s(n,"name")==="AbortError"||s(n,"code")===20}function $(n){if(n==null)return{message:"Unknown error"};let e=s(n,"message"),t=s(n,"name"),r=s(n,"stack");return{message:e==null?w(n):w(e),...t==null?{}:{name:w(t)},...r==null?{}:{stack:w(r)}}}function T(n){return new TextEncoder().encode(n).length}function S(n,e,t,r){return typeof n=="number"&&Number.isFinite(n)?Math.min(t,Math.max(e,Math.floor(n))):r}function oe(n){return JSON.stringify([n.type,n.name??null,n.message,n.stack??null,n.componentStack??null,n.project,n.environment,n.release,n.page,n.runtime,n.browser??null,n.context===void 0?null:Object.keys(n.context).sort().map(e=>[e,n.context[e]]),n.network===void 0?null:[n.network.method,n.network.url,n.network.status??null]])}var I=class extends Error{constructor(t){super(`Collector responded ${t}`);u(this,"status",t)}},x=class extends Error{},L=class extends Error{},q=class{constructor(e){u(this,"active");u(this,"endpoint");u(this,"options");u(this,"networkCaptureEnabled");u(this,"networkBreadcrumbCaptureEnabled");u(this,"navigationCaptureEnabled");u(this,"captureErrorCause");u(this,"captureUnhandledRejections");u(this,"resourceCaptureEnabled");u(this,"pauseWhileOffline");u(this,"transportTimeoutMs");u(this,"startedAt",k());u(this,"viewId",z());u(this,"seenErrors",new WeakSet);u(this,"queue",[]);u(this,"breadcrumbs",[]);u(this,"recordingBreadcrumb",!1);u(this,"maxQueueSize");u(this,"maxEventsPerMinute");u(this,"dedupeIntervalMs");u(this,"ignoreMessages");u(this,"dedupeCache",new Map);u(this,"lastDedupeClock");u(this,"admittedAt",[]);u(this,"cancelWaits",new Set);u(this,"controllers",new Set);u(this,"destroySignal");u(this,"resolveDestroy");u(this,"interval");u(this,"flushing");u(this,"onlineFlushRequested",!1);u(this,"sequence",0);u(this,"inFlight",0);u(this,"sent",0);u(this,"dropped",0);u(this,"filtered",0);u(this,"deduplicated",0);u(this,"droppedByReason",{rateLimit:0,queueOverflow:0,payloadTooLarge:0,processingError:0,deliveryError:0,destroyed:0});u(this,"destroyed",!1);u(this,"lastAdmissionClock");u(this,"onError",e=>{try{if(!(s(e,"target")instanceof Window))return;let t=s(e,"filename"),r=s(e,"lineno"),i=s(e,"colno"),o={};typeof t=="string"&&t.trim()&&(o.filename=this.cleanUrl(t)),typeof r=="number"&&Number.isFinite(r)&&r>0&&(o.lineno=r),typeof i=="number"&&Number.isFinite(i)&&i>0&&(o.colno=i),this.captureException(s(e,"error")??s(e,"message")??"Script error",{type:"javascript",...Object.keys(o).length?{context:o}:{}})}catch{this.recordDrop("processingError")}});u(this,"onResourceError",e=>{if(!(this.destroyed||!this.active))try{let t=s(e,"target");if(s(t,"ownerDocument")!==document||!document.contains(t)||s(t,"namespaceURI")!=="http://www.w3.org/1999/xhtml")return;let r=s(t,"localName");if(r!=="script"&&r!=="link"&&r!=="img")return;let i=s(t,"getAttribute");if(typeof i!="function")return;let o=l=>{try{return Reflect.apply(i,t,[l])}catch{return}},d=r,c;if(d==="script"){let l=o("src");if(typeof l!="string"||!l.trim())return;c=s(t,"src")}else if(d==="link"){let l=s(t,"rel");if(typeof l!="string"||!l.split(/\s+/).some(m=>m.toLowerCase()==="stylesheet"))return;let f=o("href");if(typeof f!="string"||!f.trim())return;c=s(t,"href")}else{let l=s(t,"currentSrc");if(typeof l=="string"&&l.trim())c=l;else{let f=o("src");if(typeof f!="string"||!f.trim())return;c=s(t,"src")}}if(typeof c!="string"||!c.trim())return;let a;try{a=new URL(c,window.location.href)}catch{return}if(a.protocol!=="http:"&&a.protocol!=="https:"||this.isCollectorUrl(a.href))return;let p=this.cleanUrl(a.href),h;try{h=new URL(p)}catch{throw new x("Invalid resource URL")}if(h.protocol!=="http:"&&h.protocol!=="https:"||h.username||h.password||h.search||h.hash)throw new x("Unsafe resource URL");this.enqueue(this.makeEvent("resource",`Failed to load ${d} resource`,{name:"ResourceLoadError",context:{resourceTag:d,resourceUrl:p}}))}catch(t){(t instanceof x||t instanceof L)&&this.recordDrop("processingError")}});u(this,"onRejection",e=>{this.captureException(e.reason,{type:"promise"})});u(this,"onVisibility",()=>{document.visibilityState==="hidden"&&this.tryBeacon()});u(this,"onPageHide",()=>{this.tryBeacon()});u(this,"onOnline",()=>{!this.active||this.destroyed||!this.queue.length||this.isExplicitlyOffline()||(this.flushing?this.onlineFlushRequested=!0:this.flush())});this.options=e,this.active=e.enabled!==!1&&typeof window<"u"&&typeof document<"u";let t=!e.transport||!!e.endpoint;if(this.networkCaptureEnabled=e.captureNetwork!==!1&&t,this.networkBreadcrumbCaptureEnabled=e.captureNetworkBreadcrumbs===!0&&t,this.navigationCaptureEnabled=e.captureNavigation===!0,this.captureErrorCause=e.captureErrorCause===!0,this.captureUnhandledRejections=e.captureUnhandledRejections!==!1,this.resourceCaptureEnabled=e.captureResourceErrors===!0,this.pauseWhileOffline=e.pauseWhileOffline===!0,this.maxQueueSize=S(e.maxQueueSize,1,100,50),this.maxEventsPerMinute=typeof e.maxEventsPerMinute=="number"&&Number.isFinite(e.maxEventsPerMinute)?S(e.maxEventsPerMinute,1,1e3,1):void 0,this.dedupeIntervalMs=S(e.dedupeIntervalMs,0,6e4,0),this.ignoreMessages=Array.isArray(e.ignoreMessages)?e.ignoreMessages.filter(r=>typeof r=="string"&&r.length>0):[],this.transportTimeoutMs=S(e.transportTimeoutMs,250,6e4,5e3),this.destroySignal=new Promise(r=>{this.resolveDestroy=r}),!!this.active){if(!e.project||typeof e.project!="string")throw new Error("project is required");if(!e.transport&&!e.endpoint)throw new Error("endpoint or transport is required");this.endpoint=e.endpoint?this.absoluteUrl(e.endpoint):void 0,window.addEventListener("error",this.onError),this.resourceCaptureEnabled&&window.addEventListener("error",this.onResourceError,!0),this.captureUnhandledRejections&&window.addEventListener("unhandledrejection",this.onRejection),document.addEventListener("visibilitychange",this.onVisibility),window.addEventListener("pagehide",this.onPageHide),this.pauseWhileOffline&&window.addEventListener("online",this.onOnline),(this.networkCaptureEnabled||this.networkBreadcrumbCaptureEnabled)&&ue(this),e.captureConsole===!0&&he(this),this.navigationCaptureEnabled&&se(this),this.interval=setInterval(()=>{this.flush()},S(e.flushIntervalMs,10,6e4,1e4))}}captureException(e,t={}){if(!(!this.active||this.destroyed||M(e)))try{if(e!==null&&(typeof e=="object"||typeof e=="function")&&this.seenErrors.has(e)){this.deduplicated++;return}let r=this.exceptionFields(e),i=_.has(t.type)?t.type:"manual",o=this.makeEvent(i,r.message,{name:r.name,stack:r.stack,componentStack:t.componentStack,context:t.context});this.enqueue(o)&&e!==null&&(typeof e=="object"||typeof e=="function")&&this.seenErrors.add(e)}catch(r){(r instanceof x||r instanceof L)&&this.recordDrop("processingError")}}reportNetwork(e,t,r,i,o,d=!0){if(this.destroyed||!this.active||this.isCollectorUrl(t)||M(o))return;let c=this.networkCaptureEnabled&&d;if(c&&r!==void 0)try{c=this.options.shouldCaptureHttp?this.options.shouldCaptureHttp(r,t,e):r>=500}catch{this.recordDrop("processingError");return}if(this.networkBreadcrumbCaptureEnabled)try{let a=this.cleanBreadcrumbUrl(t);if(a.url){let p={method:this.cleanNetworkBreadcrumbMethod(e),url:a.url,durationMs:S(i,0,36e5,0)};r!==void 0&&Number.isInteger(r)&&r>=0&&r<=599&&(p.status=r),this.appendBreadcrumb({occurredAt:new Date().toISOString(),category:r===void 0?"network":"http",message:r===void 0?"Network failure":"HTTP response",data:p})}else if(c&&!a.safeForError){this.recordDrop("processingError");return}}catch{c&&this.recordDrop("processingError");return}if(c)try{let a={method:ie(e||"GET",16).toUpperCase(),url:t,status:r,durationMs:i},p=o===void 0?void 0:$(o),h=this.makeEvent(r===void 0?"network":"http",r===void 0?p?.message||"Network request failed":`HTTP ${r}`,{name:p?.name,network:a});this.enqueue(h)}catch{this.recordDrop("processingError")}}reportZeroStatusCompletion(e,t,r){this.networkBreadcrumbCaptureEnabled&&this.reportNetwork(e,t,0,r,void 0,!1)}captureConsole(e){if(!(!this.active||this.destroyed))try{let t=e.map(w).join(" "),r;for(let i of e){let o=!1;try{o=i instanceof Error}catch{}if(o){r=this.exceptionFields(i);break}}this.enqueue(this.makeEvent("console",t,{name:r?.name,stack:r?.stack}))}catch{this.recordDrop("processingError")}}addBreadcrumb(e){if(!(!this.active||this.destroyed||this.recordingBreadcrumb))try{let t=this.cleanBreadcrumb(e,new Date().toISOString());if(!t)return;this.appendBreadcrumb(t)}catch{}}appendBreadcrumb(e){if(!(this.recordingBreadcrumb||this.destroyed)){if(!this.options.beforeBreadcrumb){this.breadcrumbs.push(e),this.boundBreadcrumbs(this.breadcrumbs);return}this.recordingBreadcrumb=!0;try{let t={...e,...e.data?{data:{...e.data}}:{}},r=this.options.beforeBreadcrumb(t);if(r===!1||r===null)return;let i=this.cleanBreadcrumb(r===void 0?t:r,e.occurredAt);if(!i||this.destroyed)return;this.breadcrumbs.push(i),this.boundBreadcrumbs(this.breadcrumbs)}catch{}finally{this.recordingBreadcrumb=!1}}}reportNavigation(e,t,r){if(!(!this.active||this.destroyed||!this.navigationCaptureEnabled))try{let i=this.cleanBreadcrumbUrl(e).url,o=this.cleanBreadcrumbUrl(t).url;if(!i||!o||i===o)return;this.appendBreadcrumb({occurredAt:new Date().toISOString(),category:"navigation",message:"Navigation",data:{from:i,to:o,trigger:r}})}catch{}}clearBreadcrumbs(){!this.active||this.destroyed||(this.breadcrumbs.length=0)}flush(){if(!this.active||this.destroyed)return Promise.resolve();if(this.flushing)return this.flushing;let e,t=new Promise(r=>{e=r});return this.flushing=t.finally(()=>{this.flushing=void 0,this.onlineFlushRequested&&(this.onlineFlushRequested=!1,!this.destroyed&&this.queue.length&&!this.isExplicitlyOffline()&&this.flush())}),e(this.drain()),this.flushing}destroy(){if(!this.destroyed){this.destroyed=!0,this.interval&&clearInterval(this.interval),this.active&&(window.removeEventListener("error",this.onError),this.resourceCaptureEnabled&&window.removeEventListener("error",this.onResourceError,!0),this.captureUnhandledRejections&&window.removeEventListener("unhandledrejection",this.onRejection),document.removeEventListener("visibilitychange",this.onVisibility),window.removeEventListener("pagehide",this.onPageHide),this.pauseWhileOffline&&window.removeEventListener("online",this.onOnline),(this.networkCaptureEnabled||this.networkBreadcrumbCaptureEnabled)&&de(this),this.options.captureConsole===!0&&fe(this),this.navigationCaptureEnabled&&ae(this)),this.recordDrop("destroyed",this.queue.length+this.inFlight),this.queue.length=0,this.breadcrumbs.length=0,this.admittedAt.length=0,this.lastAdmissionClock=void 0,this.dedupeCache.clear(),this.lastDedupeClock=void 0;for(let e of this.cancelWaits)e();for(let e of this.controllers)e.abort();this.resolveDestroy(W)}}getStats(){return{queued:this.queue.length,sent:this.sent,dropped:this.dropped}}getDiagnostics(){return{...this.getStats(),inFlight:this.destroyed?0:this.inFlight,filtered:this.filtered,deduplicated:this.deduplicated,droppedByReason:{...this.droppedByReason}}}recordDrop(e,t=1){this.dropped+=t,this.droppedByReason[e]+=t}isExplicitlyOffline(){if(!this.pauseWhileOffline)return!1;try{return typeof navigator<"u"&&navigator.onLine===!1}catch{return!1}}absoluteUrl(e){try{return new URL(e,window.location.href).href}catch{return e}}isCollectorUrl(e){if(!this.endpoint)return!1;try{let t=new URL(e,window.location.href),r=new URL(this.endpoint,window.location.href);return t.origin===r.origin&&t.pathname===r.pathname}catch{return e===this.endpoint}}cleanUrl(e){let t=w(e);if(this.options.sanitizeUrl){try{t=this.options.sanitizeUrl(t)}catch{throw new x("URL sanitizer failed")}if(typeof t!="string"||!t)throw new x("URL sanitizer returned no URL")}try{let r=new URL(t,window.location.href);return r.protocol!=="http:"&&r.protocol!=="https:"?"[unsupported URL]":(r.username="",r.password="",r.search="",r.hash="",this.cleanText(r.href,1024,!1))}catch{return this.cleanText(t,1024,!1).split(/[?#]/,1)[0]}}cleanBreadcrumbUrl(e){let t=this.cleanUrl(e);if(t==="[unsupported URL]")return{safeForError:!0};try{let r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password||r.search||r.hash?{safeForError:!1}:{url:t.slice(0,R.dataString),safeForError:!0}}catch{return{safeForError:!1}}}cleanNetworkBreadcrumbMethod(e){let t=w(e||"GET").trim().toUpperCase();return/^[A-Z0-9!#$%&'*+.^_`|~-]{1,16}$/.test(t)?t:"GET"}cleanText(e,t,r=!0){let i=w(e);return r&&(i=i.replace(/https?:\/\/[^\s<>"'()[\]]+/gi,o=>this.cleanUrl(o)),i=i.replace(/(^|[\s"'(\[=])((?:\/(?!\/)|\.{1,2}\/)[^\s<>"'()[\]?#]*[?#][^\s<>"'()[\]]+|[a-z][\w.-]*(?:\/[^\s<>"'()[\]?#]*)?(?:\?[a-z0-9_.-]+=[^\s<>"'()[\]]+|#[^\s<>"'()[\]]+)|\?[a-z0-9_.-]+=[^\s<>"'()[\]]+)/gi,(o,d,c)=>{let a=/[.,;!]+$/.exec(c)?.[0]??"",p=c.slice(0,c.length-a.length),h=this.options.sanitizeUrl?this.cleanUrl(p):p.startsWith("?")?"[redacted query]":this.cleanText(p.split(/[?#]/,1)[0],1024,!1);return`${d}${h}${a}`})),i.replace(/\bBearer\s+[A-Za-z0-9._~+\/-]+/gi,"Bearer [REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"[REDACTED_EMAIL]").slice(0,t)}exceptionFields(e){let t=$(e);if(!this.captureErrorCause||e===null||typeof e!="object"&&typeof e!="function")return t;let r=new WeakSet([e]),i=[],o=e;for(let c=0;c<4;c++){let a=s(o,"cause");if(a===null||typeof a!="object"&&typeof a!="function"||r.has(a))break;r.add(a);let p=s(a,"message"),h=s(a,"stack");if(typeof p!="string"&&typeof h!="string")break;let l=s(a,"name"),f=this.cleanText(typeof l=="string"?l:"Error",100),m=typeof p=="string"?this.cleanText(p,256):"",g=typeof h=="string"?this.cleanText(h,480):"";i.push(`Caused by: ${f}: ${m}${g?`
1
+ "use strict";var N=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var J=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Y=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},Z=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of G(e))!K.call(n,i)&&i!==t&&N(n,i,{get:()=>e[i],enumerable:!(r=X(e,i))||r.enumerable});return n};var Q=n=>Z(N({},"__esModule",{value:!0}),n);var u=(n,e,t)=>J(n,typeof e!="symbol"?e+"":e,t);var ye={};Y(ye,{init:()=>ge});module.exports=Q(ye);var R={count:20,bytes:12e3,category:40,message:256,dataKeys:6,dataKey:80,dataString:200};var ee=20,U=48e3,te=10,re=24e3,P=[250,500],F=/(?:password|passwd|token|secret|authorization|cookie|session|api.?key|credential|bearer|private.?key)/i,_=new Set(["javascript","promise","react","console","http","network","manual","resource"]),H=new Set(["browser","webview-ios","webview-android","unknown"]),ne=0;function s(n,e){try{return n==null?void 0:Reflect.get(Object(n),e)}catch{return}}function w(n){try{return String(n)}catch{return"[unavailable]"}}function ie(n,e){return w(n).slice(0,e)}function k(){try{return performance.now()}catch{return Date.now()}}function z(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${(++ne).toString(36)}-${Math.random().toString(36).slice(2,10)}`}function M(n,e){try{if(e?.aborted)return!0}catch{}return s(n,"name")==="AbortError"||s(n,"code")===20}function $(n){if(n==null)return{message:"Unknown error"};let e=s(n,"message"),t=s(n,"name"),r=s(n,"stack");return{message:e==null?w(n):w(e),...t==null?{}:{name:w(t)},...r==null?{}:{stack:w(r)}}}function T(n){return new TextEncoder().encode(n).length}function S(n,e,t,r){return typeof n=="number"&&Number.isFinite(n)?Math.min(t,Math.max(e,Math.floor(n))):r}function oe(n){return JSON.stringify([n.type,n.name??null,n.message,n.stack??null,n.componentStack??null,n.project,n.environment,n.release,n.page,n.runtime,n.browser??null,n.context===void 0?null:Object.keys(n.context).sort().map(e=>[e,n.context[e]]),n.network===void 0?null:[n.network.method,n.network.url,n.network.status??null]])}var I=class extends Error{constructor(t){super(`Collector responded ${t}`);u(this,"status",t)}},x=class extends Error{},L=class extends Error{},q=class{constructor(e){u(this,"active");u(this,"endpoint");u(this,"options");u(this,"networkCaptureEnabled");u(this,"networkBreadcrumbCaptureEnabled");u(this,"navigationCaptureEnabled");u(this,"captureErrorCause");u(this,"captureGlobalErrors");u(this,"captureUnhandledRejections");u(this,"resourceCaptureEnabled");u(this,"pauseWhileOffline");u(this,"transportTimeoutMs");u(this,"startedAt",k());u(this,"viewId",z());u(this,"seenErrors",new WeakSet);u(this,"queue",[]);u(this,"breadcrumbs",[]);u(this,"recordingBreadcrumb",!1);u(this,"maxQueueSize");u(this,"maxEventsPerMinute");u(this,"dedupeIntervalMs");u(this,"ignoreMessages");u(this,"dedupeCache",new Map);u(this,"lastDedupeClock");u(this,"admittedAt",[]);u(this,"cancelWaits",new Set);u(this,"controllers",new Set);u(this,"destroySignal");u(this,"resolveDestroy");u(this,"interval");u(this,"flushing");u(this,"onlineFlushRequested",!1);u(this,"sequence",0);u(this,"inFlight",0);u(this,"sent",0);u(this,"dropped",0);u(this,"filtered",0);u(this,"deduplicated",0);u(this,"droppedByReason",{rateLimit:0,queueOverflow:0,payloadTooLarge:0,processingError:0,deliveryError:0,destroyed:0});u(this,"destroyed",!1);u(this,"lastAdmissionClock");u(this,"onError",e=>{try{if(!(s(e,"target")instanceof Window))return;let t=s(e,"filename"),r=s(e,"lineno"),i=s(e,"colno"),o={};typeof t=="string"&&t.trim()&&(o.filename=this.cleanUrl(t)),typeof r=="number"&&Number.isFinite(r)&&r>0&&(o.lineno=r),typeof i=="number"&&Number.isFinite(i)&&i>0&&(o.colno=i),this.captureException(s(e,"error")??s(e,"message")??"Script error",{type:"javascript",...Object.keys(o).length?{context:o}:{}})}catch{this.recordDrop("processingError")}});u(this,"onResourceError",e=>{if(!(this.destroyed||!this.active))try{let t=s(e,"target");if(s(t,"ownerDocument")!==document||!document.contains(t)||s(t,"namespaceURI")!=="http://www.w3.org/1999/xhtml")return;let r=s(t,"localName");if(r!=="script"&&r!=="link"&&r!=="img")return;let i=s(t,"getAttribute");if(typeof i!="function")return;let o=l=>{try{return Reflect.apply(i,t,[l])}catch{return}},d=r,c;if(d==="script"){let l=o("src");if(typeof l!="string"||!l.trim())return;c=s(t,"src")}else if(d==="link"){let l=s(t,"rel");if(typeof l!="string"||!l.split(/\s+/).some(m=>m.toLowerCase()==="stylesheet"))return;let f=o("href");if(typeof f!="string"||!f.trim())return;c=s(t,"href")}else{let l=s(t,"currentSrc");if(typeof l=="string"&&l.trim())c=l;else{let f=o("src");if(typeof f!="string"||!f.trim())return;c=s(t,"src")}}if(typeof c!="string"||!c.trim())return;let a;try{a=new URL(c,window.location.href)}catch{return}if(a.protocol!=="http:"&&a.protocol!=="https:"||this.isCollectorUrl(a.href))return;let p=this.cleanUrl(a.href),h;try{h=new URL(p)}catch{throw new x("Invalid resource URL")}if(h.protocol!=="http:"&&h.protocol!=="https:"||h.username||h.password||h.search||h.hash)throw new x("Unsafe resource URL");this.enqueue(this.makeEvent("resource",`Failed to load ${d} resource`,{name:"ResourceLoadError",context:{resourceTag:d,resourceUrl:p}}))}catch(t){(t instanceof x||t instanceof L)&&this.recordDrop("processingError")}});u(this,"onRejection",e=>{this.captureException(e.reason,{type:"promise"})});u(this,"onVisibility",()=>{document.visibilityState==="hidden"&&this.tryBeacon()});u(this,"onPageHide",()=>{this.tryBeacon()});u(this,"onOnline",()=>{!this.active||this.destroyed||!this.queue.length||this.isExplicitlyOffline()||(this.flushing?this.onlineFlushRequested=!0:this.flush())});this.options=e,this.active=e.enabled!==!1&&typeof window<"u"&&typeof document<"u";let t=!e.transport||!!e.endpoint;if(this.networkCaptureEnabled=e.captureNetwork!==!1&&t,this.networkBreadcrumbCaptureEnabled=e.captureNetworkBreadcrumbs===!0&&t,this.navigationCaptureEnabled=e.captureNavigation===!0,this.captureErrorCause=e.captureErrorCause===!0,this.captureGlobalErrors=e.captureGlobalErrors!==!1,this.captureUnhandledRejections=e.captureUnhandledRejections!==!1,this.resourceCaptureEnabled=e.captureResourceErrors===!0,this.pauseWhileOffline=e.pauseWhileOffline===!0,this.maxQueueSize=S(e.maxQueueSize,1,100,50),this.maxEventsPerMinute=typeof e.maxEventsPerMinute=="number"&&Number.isFinite(e.maxEventsPerMinute)?S(e.maxEventsPerMinute,1,1e3,1):void 0,this.dedupeIntervalMs=S(e.dedupeIntervalMs,0,6e4,0),this.ignoreMessages=Array.isArray(e.ignoreMessages)?e.ignoreMessages.filter(r=>typeof r=="string"&&r.length>0):[],this.transportTimeoutMs=S(e.transportTimeoutMs,250,6e4,5e3),this.destroySignal=new Promise(r=>{this.resolveDestroy=r}),!!this.active){if(!e.project||typeof e.project!="string")throw new Error("project is required");if(!e.transport&&!e.endpoint)throw new Error("endpoint or transport is required");this.endpoint=e.endpoint?this.absoluteUrl(e.endpoint):void 0,this.captureGlobalErrors&&window.addEventListener("error",this.onError),this.resourceCaptureEnabled&&window.addEventListener("error",this.onResourceError,!0),this.captureUnhandledRejections&&window.addEventListener("unhandledrejection",this.onRejection),document.addEventListener("visibilitychange",this.onVisibility),window.addEventListener("pagehide",this.onPageHide),this.pauseWhileOffline&&window.addEventListener("online",this.onOnline),(this.networkCaptureEnabled||this.networkBreadcrumbCaptureEnabled)&&ue(this),e.captureConsole===!0&&he(this),this.navigationCaptureEnabled&&se(this),this.interval=setInterval(()=>{this.flush()},S(e.flushIntervalMs,10,6e4,1e4))}}captureException(e,t={}){if(!(!this.active||this.destroyed||M(e)))try{if(e!==null&&(typeof e=="object"||typeof e=="function")&&this.seenErrors.has(e)){this.deduplicated++;return}let r=this.exceptionFields(e),i=_.has(t.type)?t.type:"manual",o=this.makeEvent(i,r.message,{name:r.name,stack:r.stack,componentStack:t.componentStack,context:t.context});this.enqueue(o)&&e!==null&&(typeof e=="object"||typeof e=="function")&&this.seenErrors.add(e)}catch(r){(r instanceof x||r instanceof L)&&this.recordDrop("processingError")}}reportNetwork(e,t,r,i,o,d=!0){if(this.destroyed||!this.active||this.isCollectorUrl(t)||M(o))return;let c=this.networkCaptureEnabled&&d;if(c&&r!==void 0)try{c=this.options.shouldCaptureHttp?this.options.shouldCaptureHttp(r,t,e):r>=500}catch{this.recordDrop("processingError");return}if(this.networkBreadcrumbCaptureEnabled)try{let a=this.cleanBreadcrumbUrl(t);if(a.url){let p={method:this.cleanNetworkBreadcrumbMethod(e),url:a.url,durationMs:S(i,0,36e5,0)};r!==void 0&&Number.isInteger(r)&&r>=0&&r<=599&&(p.status=r),this.appendBreadcrumb({occurredAt:new Date().toISOString(),category:r===void 0?"network":"http",message:r===void 0?"Network failure":"HTTP response",data:p})}else if(c&&!a.safeForError){this.recordDrop("processingError");return}}catch{c&&this.recordDrop("processingError");return}if(c)try{let a={method:ie(e||"GET",16).toUpperCase(),url:t,status:r,durationMs:i},p=o===void 0?void 0:$(o),h=this.makeEvent(r===void 0?"network":"http",r===void 0?p?.message||"Network request failed":`HTTP ${r}`,{name:p?.name,network:a});this.enqueue(h)}catch{this.recordDrop("processingError")}}reportZeroStatusCompletion(e,t,r){this.networkBreadcrumbCaptureEnabled&&this.reportNetwork(e,t,0,r,void 0,!1)}captureConsole(e){if(!(!this.active||this.destroyed))try{let t=e.map(w).join(" "),r;for(let i of e){let o=!1;try{o=i instanceof Error}catch{}if(o){r=this.exceptionFields(i);break}}this.enqueue(this.makeEvent("console",t,{name:r?.name,stack:r?.stack}))}catch{this.recordDrop("processingError")}}addBreadcrumb(e){if(!(!this.active||this.destroyed||this.recordingBreadcrumb))try{let t=this.cleanBreadcrumb(e,new Date().toISOString());if(!t)return;this.appendBreadcrumb(t)}catch{}}appendBreadcrumb(e){if(!(this.recordingBreadcrumb||this.destroyed)){if(!this.options.beforeBreadcrumb){this.breadcrumbs.push(e),this.boundBreadcrumbs(this.breadcrumbs);return}this.recordingBreadcrumb=!0;try{let t={...e,...e.data?{data:{...e.data}}:{}},r=this.options.beforeBreadcrumb(t);if(r===!1||r===null)return;let i=this.cleanBreadcrumb(r===void 0?t:r,e.occurredAt);if(!i||this.destroyed)return;this.breadcrumbs.push(i),this.boundBreadcrumbs(this.breadcrumbs)}catch{}finally{this.recordingBreadcrumb=!1}}}reportNavigation(e,t,r){if(!(!this.active||this.destroyed||!this.navigationCaptureEnabled))try{let i=this.cleanBreadcrumbUrl(e).url,o=this.cleanBreadcrumbUrl(t).url;if(!i||!o||i===o)return;this.appendBreadcrumb({occurredAt:new Date().toISOString(),category:"navigation",message:"Navigation",data:{from:i,to:o,trigger:r}})}catch{}}clearBreadcrumbs(){!this.active||this.destroyed||(this.breadcrumbs.length=0)}flush(){if(!this.active||this.destroyed)return Promise.resolve();if(this.flushing)return this.flushing;let e,t=new Promise(r=>{e=r});return this.flushing=t.finally(()=>{this.flushing=void 0,this.onlineFlushRequested&&(this.onlineFlushRequested=!1,!this.destroyed&&this.queue.length&&!this.isExplicitlyOffline()&&this.flush())}),e(this.drain()),this.flushing}destroy(){if(!this.destroyed){this.destroyed=!0,this.interval&&clearInterval(this.interval),this.active&&(this.captureGlobalErrors&&window.removeEventListener("error",this.onError),this.resourceCaptureEnabled&&window.removeEventListener("error",this.onResourceError,!0),this.captureUnhandledRejections&&window.removeEventListener("unhandledrejection",this.onRejection),document.removeEventListener("visibilitychange",this.onVisibility),window.removeEventListener("pagehide",this.onPageHide),this.pauseWhileOffline&&window.removeEventListener("online",this.onOnline),(this.networkCaptureEnabled||this.networkBreadcrumbCaptureEnabled)&&de(this),this.options.captureConsole===!0&&fe(this),this.navigationCaptureEnabled&&ae(this)),this.recordDrop("destroyed",this.queue.length+this.inFlight),this.queue.length=0,this.breadcrumbs.length=0,this.admittedAt.length=0,this.lastAdmissionClock=void 0,this.dedupeCache.clear(),this.lastDedupeClock=void 0;for(let e of this.cancelWaits)e();for(let e of this.controllers)e.abort();this.resolveDestroy(W)}}getStats(){return{queued:this.queue.length,sent:this.sent,dropped:this.dropped}}getDiagnostics(){return{...this.getStats(),inFlight:this.destroyed?0:this.inFlight,filtered:this.filtered,deduplicated:this.deduplicated,droppedByReason:{...this.droppedByReason}}}recordDrop(e,t=1){this.dropped+=t,this.droppedByReason[e]+=t}isExplicitlyOffline(){if(!this.pauseWhileOffline)return!1;try{return typeof navigator<"u"&&navigator.onLine===!1}catch{return!1}}absoluteUrl(e){try{return new URL(e,window.location.href).href}catch{return e}}isCollectorUrl(e){if(!this.endpoint)return!1;try{let t=new URL(e,window.location.href),r=new URL(this.endpoint,window.location.href);return t.origin===r.origin&&t.pathname===r.pathname}catch{return e===this.endpoint}}cleanUrl(e){let t=w(e);if(this.options.sanitizeUrl){try{t=this.options.sanitizeUrl(t)}catch{throw new x("URL sanitizer failed")}if(typeof t!="string"||!t)throw new x("URL sanitizer returned no URL")}try{let r=new URL(t,window.location.href);return r.protocol!=="http:"&&r.protocol!=="https:"?"[unsupported URL]":(r.username="",r.password="",r.search="",r.hash="",this.cleanText(r.href,1024,!1))}catch{return this.cleanText(t,1024,!1).split(/[?#]/,1)[0]}}cleanBreadcrumbUrl(e){let t=this.cleanUrl(e);if(t==="[unsupported URL]")return{safeForError:!0};try{let r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password||r.search||r.hash?{safeForError:!1}:{url:t.slice(0,R.dataString),safeForError:!0}}catch{return{safeForError:!1}}}cleanNetworkBreadcrumbMethod(e){let t=w(e||"GET").trim().toUpperCase();return/^[A-Z0-9!#$%&'*+.^_`|~-]{1,16}$/.test(t)?t:"GET"}cleanText(e,t,r=!0){let i=w(e);return r&&(i=i.replace(/https?:\/\/[^\s<>"'()[\]]+/gi,o=>this.cleanUrl(o)),i=i.replace(/(^|[\s"'(\[=])((?:\/(?!\/)|\.{1,2}\/)[^\s<>"'()[\]?#]*[?#][^\s<>"'()[\]]+|[a-z][\w.-]*(?:\/[^\s<>"'()[\]?#]*)?(?:\?[a-z0-9_.-]+=[^\s<>"'()[\]]+|#[^\s<>"'()[\]]+)|\?[a-z0-9_.-]+=[^\s<>"'()[\]]+)/gi,(o,d,c)=>{let a=/[.,;!]+$/.exec(c)?.[0]??"",p=c.slice(0,c.length-a.length),h=this.options.sanitizeUrl?this.cleanUrl(p):p.startsWith("?")?"[redacted query]":this.cleanText(p.split(/[?#]/,1)[0],1024,!1);return`${d}${h}${a}`})),i.replace(/\bBearer\s+[A-Za-z0-9._~+\/-]+/gi,"Bearer [REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"[REDACTED_EMAIL]").slice(0,t)}exceptionFields(e){let t=$(e);if(!this.captureErrorCause||e===null||typeof e!="object"&&typeof e!="function")return t;let r=new WeakSet([e]),i=[],o=e;for(let c=0;c<4;c++){let a=s(o,"cause");if(a===null||typeof a!="object"&&typeof a!="function"||r.has(a))break;r.add(a);let p=s(a,"message"),h=s(a,"stack");if(typeof p!="string"&&typeof h!="string")break;let l=s(a,"name"),f=this.cleanText(typeof l=="string"?l:"Error",100),m=typeof p=="string"?this.cleanText(p,256):"",g=typeof h=="string"?this.cleanText(h,480):"";i.push(`Caused by: ${f}: ${m}${g?`
2
2
  ${g}`:""}`.slice(0,480)),o=a}if(!i.length)return t;let d=t.stack===void 0?`${this.cleanText(t.name??"Error",100)}: ${this.cleanText(t.message,256)}`:this.cleanText(t.stack,2048);return{...t,stack:`${d}
3
3
  ${i.join(`
4
- `)}`}}cleanContext(e){if(!e||typeof e!="object")return;let t={},r;try{r=Object.keys(e)}catch{return}for(let i of r){if(Object.keys(t).length>=12)break;if(F.test(i))continue;let o=s(e,i),d=this.cleanText(i,80);typeof o=="string"?t[d]=this.cleanText(o,500):(typeof o=="number"&&Number.isFinite(o)||typeof o=="boolean"||o===null)&&(t[d]=o)}return Object.keys(t).length?t:void 0}cleanBreadcrumb(e,t){if(!e||typeof e!="object")return;let r=t??s(e,"occurredAt");if(typeof r!="string")return;try{if(new Date(r).toISOString()!==r)return}catch{return}let i=s(e,"category"),o=s(e,"message");if(i!==void 0&&typeof i!="string"||typeof o!="string")return;let d=this.cleanText(i??(t?"manual":""),R.category),c=this.cleanText(o,R.message);if(!d.trim()||!c.trim())return;let a=s(e,"data"),p={};if(a&&typeof a=="object"){let h;try{h=Object.keys(a)}catch{h=[]}for(let l of h){if(Object.keys(p).length>=R.dataKeys)break;if(F.test(l))continue;let f=this.cleanText(l,R.dataKey),m=s(a,l);typeof m=="string"?p[f]=this.cleanText(m,R.dataString):(typeof m=="number"&&Number.isFinite(m)||typeof m=="boolean"||m===null)&&(p[f]=m)}}return{occurredAt:r,category:d,message:c,...Object.keys(p).length?{data:p}:{}}}boundBreadcrumbs(e){for(;e.length>R.count||T(JSON.stringify(e))>R.bytes;)e.shift()}cleanBreadcrumbTrail(e){let t;try{if(!Array.isArray(e))return;t=e.length}catch{return}if(!Number.isSafeInteger(t)||t<0)return;let r=[];for(let i=Math.max(0,t-R.count);i<t;i++){let o=this.cleanBreadcrumb(s(e,i));o&&(r.push(o),this.boundBreadcrumbs(r))}return r.length?r:void 0}cleanNetwork(e){if(!e||typeof e!="object")return;let t=s(e,"status"),r=typeof t=="number"&&Number.isInteger(t)&&t>=100&&t<=599?t:void 0;return{method:this.cleanText(s(e,"method")??"GET",16).toUpperCase(),url:this.cleanUrl(s(e,"url")??""),...r===void 0?{}:{status:r},durationMs:S(s(e,"durationMs"),0,36e5,0)}}makeEvent(e,t,r={}){let i=s(navigator,"userAgent"),o=this.cleanContext(r.context),d;try{d=this.options.getContext?.()}catch{throw new L("Context resolver failed")}let c=this.cleanContext(d),a=this.cleanContext(this.options.context),p=o;if(c||a){p={...o};for(let l of[c,a])if(l)for(let f of Object.keys(l)){if(Object.keys(p).length>=12)break;Object.prototype.hasOwnProperty.call(p,f)||(p[f]=l[f])}}let h=this.cleanNetwork(r.network);return{schemaVersion:1,eventId:z(),project:this.cleanText(this.options.project,80),environment:this.cleanText(this.options.environment??"development",80),release:this.cleanText(this.options.release??"unknown",120),sdkVersion:"0.2.6",occurredAt:new Date().toISOString(),viewId:this.viewId,sequence:++this.sequence,elapsedMs:S(k()-this.startedAt,0,36e5,0),type:e,message:this.cleanText(t,1024),...r.name===void 0?{}:{name:this.cleanText(r.name,100)},...r.stack===void 0?{}:{stack:this.cleanText(r.stack,4096)},...r.componentStack===void 0?{}:{componentStack:this.cleanText(r.componentStack,2048)},page:this.cleanUrl(window.location.href),runtime:H.has(this.options.runtime)?this.options.runtime:"browser",...typeof i=="string"?{browser:this.cleanText(i,300)}:{},...p?{context:p}:{},...this.breadcrumbs.length?{breadcrumbs:this.breadcrumbs.map(l=>({...l,...l.data?{data:{...l.data}}:{}}))}:{},...h?{network:h}:{}}}sanitizeReplacement(e,t){let r=s(e,"type"),i=s(e,"runtime"),o=s(e,"name"),d=s(e,"stack"),c=s(e,"componentStack"),a=s(e,"browser"),p=this.cleanContext(s(e,"context")),h=this.cleanBreadcrumbTrail(s(e,"breadcrumbs")),l=this.cleanNetwork(s(e,"network"));return{...t,type:_.has(r)?r:t.type,message:this.cleanText(s(e,"message")??t.message,1024),...o===void 0?{name:t.name}:{name:this.cleanText(o,100)},...d===void 0?{stack:void 0}:{stack:this.cleanText(d,4096)},...c===void 0?{componentStack:t.componentStack}:{componentStack:this.cleanText(c,2048)},page:this.cleanUrl(s(e,"page")??t.page),runtime:H.has(i)?i:t.runtime,...a===void 0?{browser:t.browser}:{browser:this.cleanText(a,300)},...p?{context:p}:{context:void 0},...h?{breadcrumbs:h}:{breadcrumbs:void 0},...l?{network:l}:{network:void 0}}}admissionTime(){let e=k(),t=Number.isFinite(e)?Math.max(0,e,this.lastAdmissionClock??0):this.lastAdmissionClock??0;for(this.lastAdmissionClock=t;this.admittedAt.length&&t-this.admittedAt[0]>=6e4;)this.admittedAt.shift();return this.admittedAt.length<this.maxEventsPerMinute?t:void 0}dedupeTime(){let e=k(),t=Number.isFinite(e)?Math.max(0,e,this.lastDedupeClock??0):this.lastDedupeClock??0;return this.lastDedupeClock=t,t}enqueue(e){if(this.destroyed)return!1;if(this.maxEventsPerMinute!==void 0&&this.admissionTime()===void 0)return this.recordDrop("rateLimit"),!1;let t=e;if(this.options.beforeSend)try{let d={...e,context:e.context&&{...e.context},breadcrumbs:e.breadcrumbs?.map(a=>({...a,data:a.data&&{...a.data}})),network:e.network&&{...e.network}},c=this.options.beforeSend(d);if(c===!1||c===null)return this.filtered++,!1;t=this.sanitizeReplacement(c===void 0?d:c,e)}catch{return this.recordDrop("processingError"),!1}if(this.destroyed)return!1;if(this.ignoreMessages.some(d=>t.message.includes(d)))return this.filtered++,!1;if(T(JSON.stringify(t))>U)return this.recordDrop("payloadTooLarge"),!1;let r,i;if(this.dedupeIntervalMs>0){i=this.dedupeTime();for(let[d,c]of this.dedupeCache)i-c>=this.dedupeIntervalMs&&this.dedupeCache.delete(d);if(r=oe(t),this.dedupeCache.has(r))return this.deduplicated++,!1}let o=this.maxEventsPerMinute===void 0?void 0:this.admissionTime();return this.maxEventsPerMinute!==void 0&&o===void 0?(this.recordDrop("rateLimit"),!1):(this.queue.length>=this.maxQueueSize&&(this.queue.shift(),this.recordDrop("queueOverflow")),this.queue.push(t),o!==void 0&&this.admittedAt.push(o),r!==void 0&&i!==void 0&&(this.dedupeCache.set(r,i),this.dedupeCache.size>50&&this.dedupeCache.delete(this.dedupeCache.keys().next().value)),this.queue.length>=this.maxQueueSize&&this.flush(),!0)}takeBatch(e=ee,t=U){let r=[],i=T('{"schemaVersion":1,"events":[]}');for(;this.queue.length&&r.length<e;){let o=this.queue[0],d=T(JSON.stringify(o))+(r.length?1:0);if(r.length&&i+d>t)break;if(!r.length&&i+d>t){this.queue.shift(),this.recordDrop("payloadTooLarge");continue}r.push(this.queue.shift()),i+=d}return{schemaVersion:1,events:r}}async drain(){for(;!this.destroyed&&this.queue.length&&!this.isExplicitlyOffline();){let e=this.takeBatch();if(e.events.length){this.inFlight+=e.events.length;try{await this.sendWithRetry(e)}finally{this.inFlight-=e.events.length}}}}async sendWithRetry(e){for(let t=0;t<=P.length&&!this.destroyed;t++){let r=new AbortController;this.controllers.add(r);let i,o=new Promise((c,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Collector transport timed out"))},this.transportTimeoutMs)}),d;try{if(await Promise.race([this.send(e,r.signal),o,this.destroySignal])===W||this.destroyed)return;this.sent+=e.events.length;return}catch(c){if(this.destroyed)return;let a=s(c,"status");if(!(typeof a!="number"||a===429||a>=500)||t===P.length)break;d=P[t]}finally{i&&clearTimeout(i),this.controllers.delete(r)}d!==void 0&&await this.wait(d)}this.destroyed||this.recordDrop("deliveryError",e.events.length)}async send(e,t){if(this.options.transport){await this.options.transport(e,{signal:t});return}let r=await window.fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"omit",signal:t});if(!r.ok)throw new I(r.status)}wait(e){return new Promise(t=>{let r=()=>{clearTimeout(i),this.cancelWaits.delete(r),t()},i=setTimeout(r,e);this.cancelWaits.add(r)})}tryBeacon(){if(!(this.destroyed||this.options.transport||!this.endpoint||!this.queue.length||this.isExplicitlyOffline()))try{let e=new URL(this.endpoint);if(e.origin!==window.location.origin||e.search||e.hash||e.username||e.password||typeof navigator.sendBeacon!="function")return;let t=this.queue.slice(0,te);for(;t.length>0;){let i=JSON.stringify({schemaVersion:1,events:t});if(T(i)<=re){navigator.sendBeacon(this.endpoint,new Blob([i],{type:"application/json"}))&&(this.queue.splice(0,t.length),this.sent+=t.length);return}t.pop()}}catch{}}},W=Symbol("destroyed"),A,O,D;function se(n){D||(D=ce()),D?.clients.add(n)}function ae(n){let e=D;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),D=void 0))}function V(n,e){let t=new Set,r=Object.getPrototypeOf(n);for(;r&&!t.has(r);){t.add(r);let i=Object.getOwnPropertyDescriptor(r,e);if(i)return i;r=Object.getPrototypeOf(r)}}function ce(){let n,e,t,r,i,o,d,c;try{if(n=window.history,e=window.location.href,i=Object.getOwnPropertyDescriptor(n,"pushState"),o=Object.getOwnPropertyDescriptor(n,"replaceState"),d=i?void 0:V(n,"pushState"),c=o?void 0:V(n,"replaceState"),i&&!("value"in i)||o&&!("value"in o)||!i&&(!d||!("value"in d)||d.writable!==!0)||!o&&(!c||!("value"in c)||c.writable!==!0)||(t=i?i.value:n.pushState,r=o?o.value:n.replaceState,typeof t!="function"||typeof r!="function"))return;let b=y=>y?y.configurable===!0||y.writable===!0:Object.isExtensible(n);if(!b(i)||!b(o))return}catch{return}let a=new Set,p=b=>{try{let y=window.location.href;if(y===e)return;let B=e;e=y;for(let v of a)try{v.reportNavigation(B,y,b)}catch{}}catch{}},h=function(...b){let y=Reflect.apply(t,this,b);return p("pushState"),y},l=function(...b){let y=Reflect.apply(r,this,b);return p("replaceState"),y},f=()=>{p("popstate")},m=()=>{p("hashchange")},g=(b,y,B)=>{try{let v=Object.getOwnPropertyDescriptor(n,b);if(!v||!("value"in v)||v.value!==y)return;B?Object.defineProperty(n,b,B):Reflect.deleteProperty(n,b)}catch{}},E=!1,C=!1;try{Object.defineProperty(n,"pushState",{configurable:i?.configurable??!0,enumerable:i?.enumerable??!1,writable:i?.writable??!0,value:h}),E=!0,Object.defineProperty(n,"replaceState",{configurable:o?.configurable??!0,enumerable:o?.enumerable??!1,writable:o?.writable??!0,value:l}),C=!0,window.addEventListener("popstate",f),window.addEventListener("hashchange",m)}catch{try{window.removeEventListener("hashchange",m)}catch{}try{window.removeEventListener("popstate",f)}catch{}C&&g("replaceState",l,o),E&&g("pushState",h,i);return}return{clients:a,cleanup(){try{window.removeEventListener("popstate",f)}catch{}try{window.removeEventListener("hashchange",m)}catch{}g("pushState",h,i),g("replaceState",l,o)}}}function ue(n){A||(A=pe()),A.clients.add(n)}function de(n){let e=A;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),A=void 0))}function le(n,e){let t;if(typeof Request<"u"&&n!==null&&typeof n=="object")if(n instanceof Request)t=s(n,"url");else try{t=Object.getOwnPropertyDescriptor(Request.prototype,"url")?.get?.call(n)}catch{}let r=s(e,"signal");return{url:t??w(n),method:w(s(e,"method")??(t===void 0?void 0:s(n,"method"))??"GET"),signal:r===void 0?t===void 0?void 0:s(n,"signal"):r}}function pe(){let n=new Set,e=window.fetch,t;typeof e=="function"&&(t=function(...h){if(!n.size)return Reflect.apply(e,this,h);let l=k(),f;try{f=le(h[0],h[1])}catch{f={url:"",method:"GET"}}let m;try{m=Reflect.apply(e,this,h)}catch(g){if(!M(g,f.signal))for(let E of n)E.reportNetwork(f.method,f.url,void 0,k()-l,g);throw g}return m.then(g=>{try{let E=g.status;for(let C of n)C.reportNetwork(f.method,f.url,E,k()-l)}catch{}return g},g=>{if(!M(g,f.signal))for(let E of n)E.reportNetwork(f.method,f.url,void 0,k()-l,g);throw g})},window.fetch=t);let r=typeof XMLHttpRequest>"u"?void 0:XMLHttpRequest.prototype,i=r?.open,o=r?.send,d=new WeakMap,c=new WeakMap,a,p;return r&&i&&o&&(a=(function(...h){let l=Reflect.apply(i,this,h);c.get(this)?.();try{d.set(this,{method:w(h[0]),url:w(h[1])})}catch{}return l}),p=function(...h){if(!n.size)return Reflect.apply(o,this,h);let l=d.get(this);if(!l)return Reflect.apply(o,this,h);let f=k(),m=!1,g=!1,E=!1,C=()=>{m=!0},b=()=>{g=!0},y=()=>{this.removeEventListener("abort",C),this.removeEventListener("error",b),this.removeEventListener("timeout",b),this.removeEventListener("loadend",B),c.get(this)===y&&c.delete(this)},B=()=>{if(E=!0,y(),!m)try{let v=this.status;if(v===0&&!g){for(let j of n)j.reportZeroStatusCompletion(l.method,l.url,k()-f);return}for(let j of n)j.reportNetwork(l.method,l.url,v===0?void 0:v,k()-f)}catch{}};try{this.addEventListener("abort",C),this.addEventListener("error",b),this.addEventListener("timeout",b),this.addEventListener("loadend",B)}catch{return y(),Reflect.apply(o,this,h)}try{let v=Reflect.apply(o,this,h);return E||c.set(this,y),v}catch(v){throw y(),v}},r.open=a,r.send=p),{clients:n,cleanup(){t&&window.fetch===t&&(window.fetch=e),r&&a&&r.open===a&&(r.open=i),r&&p&&r.send===p&&(r.send=o)}}}function he(n){O||(O=me()),O.clients.add(n)}function fe(n){let e=O;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),O=void 0))}function me(){let n=new Set,e=console.error,t=function(...r){try{return Reflect.apply(e,this,r)}finally{for(let i of n)i.captureConsole(r)}};return console.error=t,{clients:n,cleanup(){console.error===t&&(console.error=e)}}}function ge(n){return new q(n)}
4
+ `)}`}}cleanContext(e){if(!e||typeof e!="object")return;let t={},r;try{r=Object.keys(e)}catch{return}for(let i of r){if(Object.keys(t).length>=12)break;if(F.test(i))continue;let o=s(e,i),d=this.cleanText(i,80);typeof o=="string"?t[d]=this.cleanText(o,500):(typeof o=="number"&&Number.isFinite(o)||typeof o=="boolean"||o===null)&&(t[d]=o)}return Object.keys(t).length?t:void 0}cleanBreadcrumb(e,t){if(!e||typeof e!="object")return;let r=t??s(e,"occurredAt");if(typeof r!="string")return;try{if(new Date(r).toISOString()!==r)return}catch{return}let i=s(e,"category"),o=s(e,"message");if(i!==void 0&&typeof i!="string"||typeof o!="string")return;let d=this.cleanText(i??(t?"manual":""),R.category),c=this.cleanText(o,R.message);if(!d.trim()||!c.trim())return;let a=s(e,"data"),p={};if(a&&typeof a=="object"){let h;try{h=Object.keys(a)}catch{h=[]}for(let l of h){if(Object.keys(p).length>=R.dataKeys)break;if(F.test(l))continue;let f=this.cleanText(l,R.dataKey),m=s(a,l);typeof m=="string"?p[f]=this.cleanText(m,R.dataString):(typeof m=="number"&&Number.isFinite(m)||typeof m=="boolean"||m===null)&&(p[f]=m)}}return{occurredAt:r,category:d,message:c,...Object.keys(p).length?{data:p}:{}}}boundBreadcrumbs(e){for(;e.length>R.count||T(JSON.stringify(e))>R.bytes;)e.shift()}cleanBreadcrumbTrail(e){let t;try{if(!Array.isArray(e))return;t=e.length}catch{return}if(!Number.isSafeInteger(t)||t<0)return;let r=[];for(let i=Math.max(0,t-R.count);i<t;i++){let o=this.cleanBreadcrumb(s(e,i));o&&(r.push(o),this.boundBreadcrumbs(r))}return r.length?r:void 0}cleanNetwork(e){if(!e||typeof e!="object")return;let t=s(e,"status"),r=typeof t=="number"&&Number.isInteger(t)&&t>=100&&t<=599?t:void 0;return{method:this.cleanText(s(e,"method")??"GET",16).toUpperCase(),url:this.cleanUrl(s(e,"url")??""),...r===void 0?{}:{status:r},durationMs:S(s(e,"durationMs"),0,36e5,0)}}makeEvent(e,t,r={}){let i=s(navigator,"userAgent"),o=this.cleanContext(r.context),d;try{d=this.options.getContext?.()}catch{throw new L("Context resolver failed")}let c=this.cleanContext(d),a=this.cleanContext(this.options.context),p=o;if(c||a){p={...o};for(let l of[c,a])if(l)for(let f of Object.keys(l)){if(Object.keys(p).length>=12)break;Object.prototype.hasOwnProperty.call(p,f)||(p[f]=l[f])}}let h=this.cleanNetwork(r.network);return{schemaVersion:1,eventId:z(),project:this.cleanText(this.options.project,80),environment:this.cleanText(this.options.environment??"development",80),release:this.cleanText(this.options.release??"unknown",120),sdkVersion:"0.2.7",occurredAt:new Date().toISOString(),viewId:this.viewId,sequence:++this.sequence,elapsedMs:S(k()-this.startedAt,0,36e5,0),type:e,message:this.cleanText(t,1024),...r.name===void 0?{}:{name:this.cleanText(r.name,100)},...r.stack===void 0?{}:{stack:this.cleanText(r.stack,4096)},...r.componentStack===void 0?{}:{componentStack:this.cleanText(r.componentStack,2048)},page:this.cleanUrl(window.location.href),runtime:H.has(this.options.runtime)?this.options.runtime:"browser",...typeof i=="string"?{browser:this.cleanText(i,300)}:{},...p?{context:p}:{},...this.breadcrumbs.length?{breadcrumbs:this.breadcrumbs.map(l=>({...l,...l.data?{data:{...l.data}}:{}}))}:{},...h?{network:h}:{}}}sanitizeReplacement(e,t){let r=s(e,"type"),i=s(e,"runtime"),o=s(e,"name"),d=s(e,"stack"),c=s(e,"componentStack"),a=s(e,"browser"),p=this.cleanContext(s(e,"context")),h=this.cleanBreadcrumbTrail(s(e,"breadcrumbs")),l=this.cleanNetwork(s(e,"network"));return{...t,type:_.has(r)?r:t.type,message:this.cleanText(s(e,"message")??t.message,1024),...o===void 0?{name:t.name}:{name:this.cleanText(o,100)},...d===void 0?{stack:void 0}:{stack:this.cleanText(d,4096)},...c===void 0?{componentStack:t.componentStack}:{componentStack:this.cleanText(c,2048)},page:this.cleanUrl(s(e,"page")??t.page),runtime:H.has(i)?i:t.runtime,...a===void 0?{browser:t.browser}:{browser:this.cleanText(a,300)},...p?{context:p}:{context:void 0},...h?{breadcrumbs:h}:{breadcrumbs:void 0},...l?{network:l}:{network:void 0}}}admissionTime(){let e=k(),t=Number.isFinite(e)?Math.max(0,e,this.lastAdmissionClock??0):this.lastAdmissionClock??0;for(this.lastAdmissionClock=t;this.admittedAt.length&&t-this.admittedAt[0]>=6e4;)this.admittedAt.shift();return this.admittedAt.length<this.maxEventsPerMinute?t:void 0}dedupeTime(){let e=k(),t=Number.isFinite(e)?Math.max(0,e,this.lastDedupeClock??0):this.lastDedupeClock??0;return this.lastDedupeClock=t,t}enqueue(e){if(this.destroyed)return!1;if(this.maxEventsPerMinute!==void 0&&this.admissionTime()===void 0)return this.recordDrop("rateLimit"),!1;let t=e;if(this.options.beforeSend)try{let d={...e,context:e.context&&{...e.context},breadcrumbs:e.breadcrumbs?.map(a=>({...a,data:a.data&&{...a.data}})),network:e.network&&{...e.network}},c=this.options.beforeSend(d);if(c===!1||c===null)return this.filtered++,!1;t=this.sanitizeReplacement(c===void 0?d:c,e)}catch{return this.recordDrop("processingError"),!1}if(this.destroyed)return!1;if(this.ignoreMessages.some(d=>t.message.includes(d)))return this.filtered++,!1;if(T(JSON.stringify(t))>U)return this.recordDrop("payloadTooLarge"),!1;let r,i;if(this.dedupeIntervalMs>0){i=this.dedupeTime();for(let[d,c]of this.dedupeCache)i-c>=this.dedupeIntervalMs&&this.dedupeCache.delete(d);if(r=oe(t),this.dedupeCache.has(r))return this.deduplicated++,!1}let o=this.maxEventsPerMinute===void 0?void 0:this.admissionTime();return this.maxEventsPerMinute!==void 0&&o===void 0?(this.recordDrop("rateLimit"),!1):(this.queue.length>=this.maxQueueSize&&(this.queue.shift(),this.recordDrop("queueOverflow")),this.queue.push(t),o!==void 0&&this.admittedAt.push(o),r!==void 0&&i!==void 0&&(this.dedupeCache.set(r,i),this.dedupeCache.size>50&&this.dedupeCache.delete(this.dedupeCache.keys().next().value)),this.queue.length>=this.maxQueueSize&&this.flush(),!0)}takeBatch(e=ee,t=U){let r=[],i=T('{"schemaVersion":1,"events":[]}');for(;this.queue.length&&r.length<e;){let o=this.queue[0],d=T(JSON.stringify(o))+(r.length?1:0);if(r.length&&i+d>t)break;if(!r.length&&i+d>t){this.queue.shift(),this.recordDrop("payloadTooLarge");continue}r.push(this.queue.shift()),i+=d}return{schemaVersion:1,events:r}}async drain(){for(;!this.destroyed&&this.queue.length&&!this.isExplicitlyOffline();){let e=this.takeBatch();if(e.events.length){this.inFlight+=e.events.length;try{await this.sendWithRetry(e)}finally{this.inFlight-=e.events.length}}}}async sendWithRetry(e){for(let t=0;t<=P.length&&!this.destroyed;t++){let r=new AbortController;this.controllers.add(r);let i,o=new Promise((c,a)=>{i=setTimeout(()=>{r.abort(),a(new Error("Collector transport timed out"))},this.transportTimeoutMs)}),d;try{if(await Promise.race([this.send(e,r.signal),o,this.destroySignal])===W||this.destroyed)return;this.sent+=e.events.length;return}catch(c){if(this.destroyed)return;let a=s(c,"status");if(!(typeof a!="number"||a===429||a>=500)||t===P.length)break;d=P[t]}finally{i&&clearTimeout(i),this.controllers.delete(r)}d!==void 0&&await this.wait(d)}this.destroyed||this.recordDrop("deliveryError",e.events.length)}async send(e,t){if(this.options.transport){await this.options.transport(e,{signal:t});return}let r=await window.fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"omit",signal:t});if(!r.ok)throw new I(r.status)}wait(e){return new Promise(t=>{let r=()=>{clearTimeout(i),this.cancelWaits.delete(r),t()},i=setTimeout(r,e);this.cancelWaits.add(r)})}tryBeacon(){if(!(this.destroyed||this.options.transport||!this.endpoint||!this.queue.length||this.isExplicitlyOffline()))try{let e=new URL(this.endpoint);if(e.origin!==window.location.origin||e.search||e.hash||e.username||e.password||typeof navigator.sendBeacon!="function")return;let t=this.queue.slice(0,te);for(;t.length>0;){let i=JSON.stringify({schemaVersion:1,events:t});if(T(i)<=re){navigator.sendBeacon(this.endpoint,new Blob([i],{type:"application/json"}))&&(this.queue.splice(0,t.length),this.sent+=t.length);return}t.pop()}}catch{}}},W=Symbol("destroyed"),A,O,D;function se(n){D||(D=ce()),D?.clients.add(n)}function ae(n){let e=D;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),D=void 0))}function V(n,e){let t=new Set,r=Object.getPrototypeOf(n);for(;r&&!t.has(r);){t.add(r);let i=Object.getOwnPropertyDescriptor(r,e);if(i)return i;r=Object.getPrototypeOf(r)}}function ce(){let n,e,t,r,i,o,d,c;try{if(n=window.history,e=window.location.href,i=Object.getOwnPropertyDescriptor(n,"pushState"),o=Object.getOwnPropertyDescriptor(n,"replaceState"),d=i?void 0:V(n,"pushState"),c=o?void 0:V(n,"replaceState"),i&&!("value"in i)||o&&!("value"in o)||!i&&(!d||!("value"in d)||d.writable!==!0)||!o&&(!c||!("value"in c)||c.writable!==!0)||(t=i?i.value:n.pushState,r=o?o.value:n.replaceState,typeof t!="function"||typeof r!="function"))return;let b=y=>y?y.configurable===!0||y.writable===!0:Object.isExtensible(n);if(!b(i)||!b(o))return}catch{return}let a=new Set,p=b=>{try{let y=window.location.href;if(y===e)return;let B=e;e=y;for(let v of a)try{v.reportNavigation(B,y,b)}catch{}}catch{}},h=function(...b){let y=Reflect.apply(t,this,b);return p("pushState"),y},l=function(...b){let y=Reflect.apply(r,this,b);return p("replaceState"),y},f=()=>{p("popstate")},m=()=>{p("hashchange")},g=(b,y,B)=>{try{let v=Object.getOwnPropertyDescriptor(n,b);if(!v||!("value"in v)||v.value!==y)return;B?Object.defineProperty(n,b,B):Reflect.deleteProperty(n,b)}catch{}},E=!1,C=!1;try{Object.defineProperty(n,"pushState",{configurable:i?.configurable??!0,enumerable:i?.enumerable??!1,writable:i?.writable??!0,value:h}),E=!0,Object.defineProperty(n,"replaceState",{configurable:o?.configurable??!0,enumerable:o?.enumerable??!1,writable:o?.writable??!0,value:l}),C=!0,window.addEventListener("popstate",f),window.addEventListener("hashchange",m)}catch{try{window.removeEventListener("hashchange",m)}catch{}try{window.removeEventListener("popstate",f)}catch{}C&&g("replaceState",l,o),E&&g("pushState",h,i);return}return{clients:a,cleanup(){try{window.removeEventListener("popstate",f)}catch{}try{window.removeEventListener("hashchange",m)}catch{}g("pushState",h,i),g("replaceState",l,o)}}}function ue(n){A||(A=pe()),A.clients.add(n)}function de(n){let e=A;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),A=void 0))}function le(n,e){let t;if(typeof Request<"u"&&n!==null&&typeof n=="object")if(n instanceof Request)t=s(n,"url");else try{t=Object.getOwnPropertyDescriptor(Request.prototype,"url")?.get?.call(n)}catch{}let r=s(e,"signal");return{url:t??w(n),method:w(s(e,"method")??(t===void 0?void 0:s(n,"method"))??"GET"),signal:r===void 0?t===void 0?void 0:s(n,"signal"):r}}function pe(){let n=new Set,e=window.fetch,t;typeof e=="function"&&(t=function(...h){if(!n.size)return Reflect.apply(e,this,h);let l=k(),f;try{f=le(h[0],h[1])}catch{f={url:"",method:"GET"}}let m;try{m=Reflect.apply(e,this,h)}catch(g){if(!M(g,f.signal))for(let E of n)E.reportNetwork(f.method,f.url,void 0,k()-l,g);throw g}return m.then(g=>{try{let E=g.status;for(let C of n)C.reportNetwork(f.method,f.url,E,k()-l)}catch{}return g},g=>{if(!M(g,f.signal))for(let E of n)E.reportNetwork(f.method,f.url,void 0,k()-l,g);throw g})},window.fetch=t);let r=typeof XMLHttpRequest>"u"?void 0:XMLHttpRequest.prototype,i=r?.open,o=r?.send,d=new WeakMap,c=new WeakMap,a,p;return r&&i&&o&&(a=(function(...h){let l=Reflect.apply(i,this,h);c.get(this)?.();try{d.set(this,{method:w(h[0]),url:w(h[1])})}catch{}return l}),p=function(...h){if(!n.size)return Reflect.apply(o,this,h);let l=d.get(this);if(!l)return Reflect.apply(o,this,h);let f=k(),m=!1,g=!1,E=!1,C=()=>{m=!0},b=()=>{g=!0},y=()=>{this.removeEventListener("abort",C),this.removeEventListener("error",b),this.removeEventListener("timeout",b),this.removeEventListener("loadend",B),c.get(this)===y&&c.delete(this)},B=()=>{if(E=!0,y(),!m)try{let v=this.status;if(v===0&&!g){for(let j of n)j.reportZeroStatusCompletion(l.method,l.url,k()-f);return}for(let j of n)j.reportNetwork(l.method,l.url,v===0?void 0:v,k()-f)}catch{}};try{this.addEventListener("abort",C),this.addEventListener("error",b),this.addEventListener("timeout",b),this.addEventListener("loadend",B)}catch{return y(),Reflect.apply(o,this,h)}try{let v=Reflect.apply(o,this,h);return E||c.set(this,y),v}catch(v){throw y(),v}},r.open=a,r.send=p),{clients:n,cleanup(){t&&window.fetch===t&&(window.fetch=e),r&&a&&r.open===a&&(r.open=i),r&&p&&r.send===p&&(r.send=o)}}}function he(n){O||(O=me()),O.clients.add(n)}function fe(n){let e=O;e&&(e.clients.delete(n),e.clients.size||(e.cleanup(),O=void 0))}function me(){let n=new Set,e=console.error,t=function(...r){try{return Reflect.apply(e,this,r)}finally{for(let i of n)i.captureConsole(r)}};return console.error=t,{clients:n,cleanup(){console.error===t&&(console.error=e)}}}function ge(n){return new q(n)}
5
5
  //# sourceMappingURL=index.cjs.map