@xysfe/bug-tap 0.1.0 → 0.1.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.
package/dist/config.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { BugTapConfig, ResolvedBugTapConfig, UserInfoInput } from './types'
2
2
  export declare const DEFAULT_EXCLUDE_URLS: Array<string | RegExp>;
3
3
  export declare const DEFAULT_ENDPOINT = "/go/SupportTools/logreport";
4
4
  export declare const DEFAULT_UPLOAD_URL = "/platform/file/uploadPicture";
5
- export declare const DEFAULT_UPLOAD_BIZ_ID = "1008";
5
+ export declare const DEFAULT_UPLOAD_BIZ_ID = "1086";
6
6
  /**
7
7
  * 用户信息只接受单层标量字段:
8
8
  * - 嵌套对象 / 数组会被丢弃,避免把整个 store 塞进上报
@@ -1,5 +1,5 @@
1
- "use strict";var Ar=Object.create;var Re=Object.defineProperty;var Pr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var Or=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Br(t))!$r.call(e,n)&&n!==r&&Re(e,n,{get:()=>t[n],enumerable:!(i=Pr(t,n))||i.enumerable});return e};var _r=(e,t,r)=>(r=e!=null?Ar(Ir(e)):{},Or(t||!e||!e.__esModule?Re(r,"default",{value:e,enumerable:!0}):r,e));/*! @xysfe/bug-tap v0.1.0 | MIT */const Hr=require("css-selector-generator"),Z=["x-request-id","x-trace-id","traceparent","tracestate","x-b3-traceid","x-b3-spanid","server-timing","content-length"];function H(e,t){try{return e instanceof RegExp?(e.lastIndex=0,e.test(t)):t.includes(e)}catch(r){return!1}}const Ur=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications\.$/,/^Cannot redefine property: googletag$/,/can't redefine non-configurable property "solana"/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/],sr=/^(?:<anonymous>|\[native code\]|data:|blob:|about:|chrome-extension:|moz-extension:)/i,jr=/\bat\s+(?:.*?\s+\()?([^\s()]+):(\d+):(\d+)\)?\s*$/;function Ct(e){if(e)for(const t of e.split(`
2
- `)){const r=jr.exec(t);if(!r)continue;const i=r[1];if(!i||sr.test(i))continue;const n=Number(r[2]),s=Number(r[3]);return{url:i,line:Number.isFinite(n)&&n>0?n:void 0,column:Number.isFinite(s)&&s>=0?s:void 0}}}function zr(e,t){const r=Ct(e);if(r)return r.url;if(t&&!sr.test(t))return t}const Dr=/^\[(?:setTimeout|setInterval|requestAnimationFrame)\] /,Nr=/^[A-Za-z]*Error: /;function qr(e){const t=new Set([e]),r=e.replace(Dr,"");t.add(r);const i=r.replace(Nr,"");return t.add(i),Array.from(t)}function Fr(e,t){return qr(e).some(r=>t.some(i=>H(i,r)))}function Wr(e){const t=(e.message||"").trim(),r=(e.stack||"").trim();return t.length===0&&r.length===0}function Xr(e,t,r){return!(t.length>0&&(!e||!t.some(i=>H(i,e)))||e&&r.some(i=>H(i,e)))}const Vr=/\.(?:js|css|map|png|jpe?g|gif|svg|webp|ico|bmp|woff2?|ttf|eot|otf|mp4|webm|mp3|wav|ogg|avi|mov|zip|gz|pdf)(?:[?#]|$)/i,Yr=[Vr],Te="/go/SupportTools/logreport",Me="/platform/file/uploadPicture",Ae="1008";function Kr(e){return(String(e!=null?e:"").trim()||Te).replace(/\/+$/,"")||Te}function bt(e){return Object.prototype.toString.call(e)==="[object Object]"}function or(e){if(typeof e=="function")return e;if(!bt(e))return;const t={};for(const r of Object.keys(e)){const i=e[r],n=typeof i;(n==="string"||n==="number"||n==="boolean")&&(t[r]=i)}return Object.keys(t).length>0?t:void 0}function y(e,t,r,i){return Math.round(cr(e,t,r,i))}function Gr(e){const t=String(e.release||"").trim();if(t)return t;const r=String(e.appVersion||"").trim(),i=String(e.buildId||"").trim();return r&&i?`${r}+${i}`:r||i}function ar(e){return e===!0?!0:Array.isArray(e)?Array.from(new Set(e.map(t=>String(t||"").trim().toLowerCase()).filter(t=>t.length>0))):[]}function Jr(e){if(e===!0)return!0;const t=ar(e);return Array.from(new Set([...Z,"content-type",...t]))}function cr(e,t,r,i){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?Math.min(r,Math.max(t,n)):i}function lr(e,t){if(!bt(e)||!bt(t))return t===void 0?e:t;const r={...e};for(const i of Object.keys(t))r[i]=lr(e[i],t[i]);return r}function Qr(e,t){return lr(e,t||{})}function it(e){var o,a,c,l,u,h,d,p,g,b,m,I,q,Pt,Bt,It,$t,Ot,_t,Ht,Ut,jt,zt,Dt,Nt,qt,Ft,Wt,Xt,Vt,Yt,Kt,Gt,Jt,Qt,Zt,te,ee,re,ie,ne,se,oe,ae,ce,le,ue,he,de,fe,pe,ge,me,be,ye,we,ve,xe,Ee,Se,ke,Ce,Le;const t={excludeUrls:Yr.concat(((o=e.privacy)==null?void 0:o.excludeUrls)||[]),excludeConsolePatterns:(((a=e.privacy)==null?void 0:a.excludeConsolePatterns)||[]).slice(),excludeBreadcrumbUrls:(((c=e.privacy)==null?void 0:c.excludeBreadcrumbUrls)||[]).slice()},r=e.filtering||{},i={ignoreErrors:(r.ignoreErrors||[]).slice().concat(r.disableErrorDefaults?[]:Ur),denyUrls:(r.denyUrls||[]).slice(),allowUrls:(r.allowUrls||[]).slice()},n=e.hooks||{},s={beforeSend:typeof n.beforeSend=="function"?n.beforeSend:void 0,beforeBreadcrumb:typeof n.beforeBreadcrumb=="function"?n.beforeBreadcrumb:void 0};return{project:String(e.project||"").trim(),endpoint:Kr(e.endpoint),environment:String(e.environment||"production").trim()||"production",appVersion:String(e.appVersion||"").trim(),buildId:String(e.buildId||"").trim(),release:Gr(e),debug:e.debug===!0,user:or(e.user),reporter:{enabled:((l=e.reporter)==null?void 0:l.enabled)!==!1,position:((u=e.reporter)==null?void 0:u.position)==="bottom-left"?"bottom-left":"bottom-right",theme:((h=e.reporter)==null?void 0:h.theme)==="light"||((d=e.reporter)==null?void 0:d.theme)==="dark"?e.reporter.theme:"auto",text:String(((p=e.reporter)==null?void 0:p.text)||"反馈").slice(0,20),zIndex:y((g=e.reporter)==null?void 0:g.zIndex,1,2147483647,2147483e3),visibility:{mode:((m=(b=e.reporter)==null?void 0:b.visibility)==null?void 0:m.mode)==="triggered"?"triggered":"always",queryParam:String(((q=(I=e.reporter)==null?void 0:I.visibility)==null?void 0:q.queryParam)||"bugtap").trim(),queryValue:((Bt=(Pt=e.reporter)==null?void 0:Pt.visibility)==null?void 0:Bt.queryValue)===void 0?"1":String(e.reporter.visibility.queryValue),closable:(($t=(It=e.reporter)==null?void 0:It.visibility)==null?void 0:$t.closable)!==!1}},collect:{console:((Ot=e.collect)==null?void 0:Ot.console)!==!1,error:((_t=e.collect)==null?void 0:_t.error)!==!1,network:((Ht=e.collect)==null?void 0:Ht.network)!==!1,networkBody:((Ut=e.collect)==null?void 0:Ut.networkBody)!==!1,realtime:((jt=e.collect)==null?void 0:jt.realtime)!==!1,resourceErrors:((zt=e.collect)==null?void 0:zt.resourceErrors)!==!1,environment:((Dt=e.collect)==null?void 0:Dt.environment)!==!1,trackIds:((Nt=e.collect)==null?void 0:Nt.trackIds)!==!1,breadcrumbs:((qt=e.collect)==null?void 0:qt.breadcrumbs)!==!1,maxBreadcrumbs:y((Ft=e.collect)==null?void 0:Ft.maxBreadcrumbs,1,200,100),maxConsoleLogs:y((Wt=e.collect)==null?void 0:Wt.maxConsoleLogs,1,500,100),maxNetworkRecords:y((Xt=e.collect)==null?void 0:Xt.maxNetworkRecords,1,500,200),maxErrors:y((Vt=e.collect)==null?void 0:Vt.maxErrors,1,200,50),maxNetworkBytes:y((Yt=e.collect)==null?void 0:Yt.maxNetworkBytes,8192,8e6,524288),maxCloneBytes:y((Kt=e.collect)==null?void 0:Kt.maxCloneBytes,1024,5e6,262144),requestHeaders:ar((Gt=e.collect)==null?void 0:Gt.requestHeaders),responseHeaders:Jr((Jt=e.collect)==null?void 0:Jt.responseHeaders),maxElements:y((Qt=e.collect)==null?void 0:Qt.maxElements,1,20,5),eventListenerErrors:((Zt=e.collect)==null?void 0:Zt.eventListenerErrors)!==!1},privacy:t,filtering:i,hooks:s,screenshot:{enabled:((te=e.screenshot)==null?void 0:te.enabled)!==!1,auto:((ee=e.screenshot)==null?void 0:ee.auto)!==!1,quality:cr((re=e.screenshot)==null?void 0:re.quality,.1,1,.8),maxWidth:y((ie=e.screenshot)==null?void 0:ie.maxWidth,320,4096,1600),maxSizeKB:y((ne=e.screenshot)==null?void 0:ne.maxSizeKB,50,2048,400),scriptUrl:String(((se=e.screenshot)==null?void 0:se.scriptUrl)||"").trim()},transport:{timeoutMs:y((oe=e.transport)==null?void 0:oe.timeoutMs,1e3,6e4,15e3),retries:y((ae=e.transport)==null?void 0:ae.retries,0,5,2),headers:{...((ce=e.transport)==null?void 0:ce.headers)||{}},maxItemBytes:y((le=e.transport)==null?void 0:le.maxItemBytes,5e4,5e6,8e5),totalTimeoutMs:y((ue=e.transport)==null?void 0:ue.totalTimeoutMs,3e3,6e4,3e4),maxConcurrent:y((he=e.transport)==null?void 0:he.maxConcurrent,1,50,10),logLevel:((de=e.transport)==null?void 0:de.logLevel)===1||((fe=e.transport)==null?void 0:fe.logLevel)===2||((pe=e.transport)==null?void 0:pe.logLevel)===3?e.transport.logLevel:void 0,offline:{enabled:((me=(ge=e.transport)==null?void 0:ge.offline)==null?void 0:me.enabled)!==!1,ttlMs:y((ye=(be=e.transport)==null?void 0:be.offline)==null?void 0:ye.ttlMs,6e4,168*36e5,24*36e5),maxItems:y((ve=(we=e.transport)==null?void 0:we.offline)==null?void 0:ve.maxItems,1,100,20)},maxReportsPerSession:y((xe=e.transport)==null?void 0:xe.maxReportsPerSession,0,1e3,0)},upload:{enabled:((Ee=e.upload)==null?void 0:Ee.enabled)!==!1,url:String(((Se=e.upload)==null?void 0:Se.url)||Me).trim()||Me,bizId:String((Ce=(ke=e.upload)==null?void 0:ke.bizId)!=null?Ce:Ae).trim()||Ae,timeoutMs:y((Le=e.upload)==null?void 0:Le.timeoutMs,1e3,12e4,3e4)}}}function yt(e){const t=[];if(!e||typeof e!="object")return t.push("配置不是对象"),t;if((!e.project||typeof e.project!="string")&&t.push("缺少 project"),e.endpoint!==void 0&&e.endpoint!==null&&String(e.endpoint).trim()!=="")try{const r=new URL(e.endpoint,location.href);r.protocol!=="http:"&&r.protocol!=="https:"&&t.push("endpoint 必须是 http/https 地址")}catch(r){t.push("endpoint 不是合法 URL")}return t}class Lt{constructor(t){this.start=0,this.length=0,this.evicted=0,this.capacity=Math.max(1,Math.floor(t)),this.items=new Array(this.capacity)}get size(){return this.length}get limit(){return this.capacity}get droppedCount(){return this.evicted}push(t){if(this.length<this.capacity){this.items[(this.start+this.length)%this.capacity]=t,this.length+=1;return}this.items[this.start]=t,this.start=(this.start+1)%this.capacity,this.evicted+=1}last(){if(this.length!==0)return this.items[(this.start+this.length-1)%this.capacity]}toArray(){const t=[];for(let r=0;r<this.length;r+=1){const i=this.items[(this.start+r)%this.capacity];i!==void 0&&t.push(i)}return t}includes(t){for(let r=0;r<this.length;r+=1)if(this.items[(this.start+r)%this.capacity]===t)return!0;return!1}update(t,r){for(let i=0;i<this.length;i+=1){const n=(this.start+i)%this.capacity,s=this.items[n];if(s!==void 0&&t(s))return this.items[n]=r(s),!0}return!1}updateLast(t){if(this.length===0)return!1;const r=(this.start+this.length-1)%this.capacity,i=this.items[r];return i===void 0?!1:(this.items[r]=t(i),!0)}clear(){this.items=new Array(this.capacity),this.start=0,this.length=0,this.evicted=0}}function ur(e){return e.ok===!1||!!e.error||(e.status||0)>=400}function Zr(e){return e.ok===!0}function hr(e){return e?e.droppedCount+e.evictedCount+(e.trimmedCount||0):0}const ti=60,ei=40;function Pe(e){var t,r,i,n;try{if(!e)return;const s=e.tagName?e.tagName.toLowerCase():"";if(!s)return;const o=e.id?`#${e.id}`:"",a=((t=e.getAttribute)==null?void 0:t.call(e,"data-testid"))||((r=e.getAttribute)==null?void 0:r.call(e,"data-test"))||((i=e.getAttribute)==null?void 0:i.call(e,"data-qa"))||"",c=!o&&a?`[data-testid="${a}"]`:"",l=((n=e.getAttribute)==null?void 0:n.call(e,"name"))||"",u=!o&&!c&&l?`[name="${l}"]`:"",h=typeof e.className=="string"?e.className.trim():"",d=!o&&!c&&!u&&h?`.${h.split(/\s+/).slice(0,2).join(".")}`:"";return`${s}${o}${c}${u}${d}`.slice(0,ti)}catch(s){return}}function ri(e,t=ei){try{const r=((e==null?void 0:e.textContent)||"").replace(/\s+/g," ").trim();return r?r.slice(0,t):void 0}catch(r){return}}function ii(e){var t;try{const r=(((t=e==null?void 0:e.getAttribute)==null?void 0:t.call(e,"type"))||"").toLowerCase();return r==="password"||r==="hidden"}catch(r){return!0}}function Be(e){var r,i;try{if(document.documentElement.hasAttribute("data-bug-tap-picking"))return!0}catch(n){}let t=e;for(;t;)try{if((r=t.hasAttribute)!=null&&r.call(t,"data-bug-tap")||(i=t.hasAttribute)!=null&&i.call(t,"data-bug-tap-picker"))return!0;const n=t.getRootNode?t.getRootNode():null;if(n&&n.host){t=n.host;continue}t=t.parentElement}catch(n){return!1}return!1}function nt(e){try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`.slice(0,300)}catch(t){return e.slice(0,300)}}function ni(e,t){if(e===t)return!0;if(!e||!t)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(r){return!1}}class si{constructor(t){this.options=t,this.started=!1,this.lastRoute="",this.lastVisibility="",this.navigationDisabled=!1,this.tailSignature="",this.onClick=r=>{if(!(!this.started||!this.options.dom))try{const i=r.target;if(Be(i))return;const n=Pe(i);if(!n)return;this.push({t:Date.now(),type:"click",selector:n,text:ri(i)})}catch(i){}},this.onChange=r=>{if(!(!this.started||!this.options.dom))try{const i=r.target;if(!i||Be(i)||ii(i))return;const n=Pe(i);if(!n)return;this.push({t:Date.now(),type:"input",selector:n})}catch(i){}},this.onVisibility=()=>{if(this.started)try{const r=document.visibilityState;if(r===this.lastVisibility)return;this.lastVisibility=r,this.push({t:Date.now(),type:"visibility",state:r})}catch(r){}},this.checkRoute=()=>{if(!(!this.started||!this.options.navigation||this.navigationDisabled))try{const r=location.href;if(r===this.lastRoute)return;const i=this.lastRoute;this.lastRoute=r,this.push({t:Date.now(),type:"route",from:nt(i),to:nt(r)})}catch(r){}},this.onHistory=()=>{this.navigationDisabled||setTimeout(this.checkRoute,0)},this.originalPush=null,this.originalReplace=null,this.wrappedPush=null,this.wrappedReplace=null,this.routeHook=null,this.buffer=new Lt(t.max)}get limit(){return this.buffer.limit}get size(){return this.buffer.size}get evicted(){return this.buffer.droppedCount}start(){if(!this.started){this.started=!0;try{this.lastRoute=location.href,this.lastVisibility=document.visibilityState}catch(t){}this.options.dom&&(window.addEventListener("click",this.onClick,!0),window.addEventListener("change",this.onChange,!0)),this.options.navigation&&!this.navigationDisabled&&(window.addEventListener("popstate",this.checkRoute),window.addEventListener("hashchange",this.checkRoute),window.addEventListener("visibilitychange",this.onVisibility),this.patchHistory())}}stop(){this.started&&(this.started=!1,window.removeEventListener("click",this.onClick,!0),window.removeEventListener("change",this.onChange,!0),window.removeEventListener("popstate",this.checkRoute),window.removeEventListener("hashchange",this.checkRoute),window.removeEventListener("visibilitychange",this.onVisibility),this.unpatchHistory())}getBreadcrumbs(){return this.buffer.toArray()}add(t){this.started&&this.push(t)}disableNavigationCapture(){this.options.navigation&&(this.navigationDisabled=!0,window.removeEventListener("popstate",this.checkRoute),window.removeEventListener("hashchange",this.checkRoute),this.unpatchHistory())}clear(){this.buffer.clear(),this.tailSignature=""}addNetwork(t){var o;if(!this.started||!this.options.network||this.options.excludeUrls&&this.options.excludeUrls.some(a=>H(a,t.url)))return;const r=nt(t.url),i=ur(t),n=`${t.method} ${r} ${(o=t.status)!=null?o:""} ${i?1:0}`,s=this.buffer.last();if(s&&s.type==="http"&&this.tailSignature===n){this.buffer.updateLast(a=>({...a,repeat:(a.repeat||1)+1,ref:t.id}));return}this.tailSignature=n,this.push({t:Date.now(),type:"http",method:t.method,url:r,status:t.status,durationMs:t.durationMs,httpError:t.error,ref:t.id})}addError(t){!this.started||!this.options.error||this.push({t:t.timestamp,type:"error",message:t.message.slice(0,200),count:t.count})}push(t){if(!this.started)return;const r=this.applyHook(t);if(!r)return;const i=r;i.type!=="http"&&(this.tailSignature="");const n=this.buffer.last();n&&n.type===i.type&&n.selector===i.selector&&n.to===i.to&&n.state===i.state&&n.ref===i.ref&&n.message===i.message&&ni(n.data,i.data)||this.buffer.push(i)}applyHook(t){const r=this.options.beforeBreadcrumb;if(!r)return t;try{const i=r(t);return i===null?null:i&&typeof i=="object"?i:t}catch(i){return t}}wrapHistory(t){const r=this,i=function(...n){var o;const s=t.apply(this,n);return(o=r.routeHook)==null||o.call(r),s};return i.__bugTap=!0,i}patchHistory(){try{if(typeof history=="undefined")return;const t=history.pushState,r=history.replaceState;this.originalPush=t,this.originalReplace=r,this.routeHook=()=>this.onHistory(),this.wrappedPush=this.wrapHistory(t),this.wrappedReplace=this.wrapHistory(r),history.pushState=this.wrappedPush,history.replaceState=this.wrappedReplace}catch(t){}}unpatchHistory(){try{this.wrappedPush&&history.pushState===this.wrappedPush&&this.originalPush&&(history.pushState=this.originalPush),this.wrappedReplace&&history.replaceState===this.wrappedReplace&&this.originalReplace&&(history.replaceState=this.originalReplace)}catch(t){}this.routeHook=null,this.originalPush=null,this.originalReplace=null,this.wrappedPush=null,this.wrappedReplace=null}}const dr="__bugTapCaptured";let D=0,F=0;function oi(e){try{e&&(typeof e=="object"||typeof e=="function")&&(e[dr]=!0)}catch(t){}}function Ie(e){try{return!!(e&&typeof e=="object"&&e[dr])}catch(t){return!1}}function ai(){return D<=0?!1:(D-=1,!0)}function ci(){D+=1;try{F&&clearTimeout(F),F=setTimeout(()=>{D=0,F=0},0)}catch(e){D=0}}const li="__bugTapWrapped",$e="__bugTapHandleEvent";class ui{constructor(t){this.options=t,this.patched=[],this.registry=new WeakMap,this.started=!1}start(){this.started||(this.started=!0,this.patchTimer("setTimeout","setTimeout"),this.patchTimer("setInterval","setInterval"),this.patchTimer("requestAnimationFrame","requestAnimationFrame"),this.options.eventListeners!==!1&&this.patchEventTarget())}stop(){if(this.started){this.started=!1;for(const{target:t,key:r,original:i}of this.patched)try{const n=t[r];typeof n=="function"&&n.__bugTap&&(t[r]=i)}catch(n){}this.patched.length=0}}patchTimer(t,r){try{const i=window,n=i[t];if(typeof n!="function"||n.__bugTap)return;this.patched.push({target:i,key:t,original:n});const s=this,o=function(a,...c){if(!s.started||typeof a!="function")return n.apply(this,[a,...c]);const l=s.wrapCallback(a,r);return n.apply(this,[l,...c])};o.__bugTap=!0,i[t]=o}catch(i){}}patchEventTarget(){try{if(typeof EventTarget=="undefined"||!EventTarget.prototype)return;const t=EventTarget.prototype,r=t.addEventListener,i=t.removeEventListener;if(typeof r!="function"||typeof i!="function"||r.__bugTap)return;this.patched.push({target:t,key:"addEventListener",original:r}),this.patched.push({target:t,key:"removeEventListener",original:i});const n=this,s=function(a,c,l){if(!n.started||!c)return r.call(this,a,c,l);if(typeof c=="object"){const h=c;if(typeof h.handleEvent=="function")try{h.handleEvent[$e]||(h.handleEvent=n.wrapCallback(h.handleEvent.bind(c),a,$e))}catch(d){}return r.call(this,a,c,l)}if(typeof c!="function")return r.call(this,a,c,l);const u=n.listenerFor(this,a,c,l);return r.call(this,a,u,l)},o=function(a,c,l){var u,h,d,p;try{const b=c&&(typeof c=="object"||typeof c=="function")?(h=(u=n.registry.get(this))==null?void 0:u.get(st(a,l)))==null?void 0:h.get(c):void 0;b&&b!==c&&(i.call(this,a,b,l),(p=(d=n.registry.get(this))==null?void 0:d.get(st(a,l)))==null||p.delete(c))}catch(g){}return i.call(this,a,c,l)};s.__bugTap=!0,o.__bugTap=!0,t.addEventListener=s,t.removeEventListener=o}catch(t){}}listenerFor(t,r,i,n){let s=this.registry.get(t);s||(s=new Map,this.registry.set(t,s));const o=st(r,n);let a=s.get(o);a||(a=new WeakMap,s.set(o,a));const c=a.get(i);if(c)return c;const l=this.wrapCallback(i,r);return a.set(i,l),l}wrapCallback(t,r,i=li){const n=this,s=function(...o){try{return t.apply(this,o)}catch(a){try{oi(a),ci(),n.options.capture(a,r)}catch(c){}throw a}};try{s[i]=t}catch(o){}return s}}function st(e,t){const r=typeof t=="boolean"?t:!!(t&&typeof t=="object"&&t.capture);return`${e}|${r?1:0}`}const hi=4,v=50,di=2e3,fr=4e3;function P(e,t=di){return e.length>t?`${e.slice(0,t)}…[${e.length-t} chars truncated]`:e}function fi(e){const t=typeof e;if(e===null)return"null";if(t==="undefined")return"undefined";if(t==="string")return P(e);if(t==="number")return Number.isFinite(e),String(e);if(t==="boolean")return String(e);if(t==="bigint")return`${String(e)}n`;if(t==="symbol")return String(e);if(t==="function"){const r=e.name;return`[Function${r?` ${r}`:""}]`}return null}function O(e,t=0,r){const i=fi(e);if(i!==null)return i;const n=r||new WeakSet,s=e;if(typeof s!="object"||s===null)return String(s);if(n.has(s))return"[Circular]";n.add(s);try{if(e instanceof Error){const c=typeof e.stack=="string"?e.stack.split(`
1
+ "use strict";var Ar=Object.create;var Re=Object.defineProperty;var Pr=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,$r=Object.prototype.hasOwnProperty;var Or=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Br(t))!$r.call(e,n)&&n!==r&&Re(e,n,{get:()=>t[n],enumerable:!(i=Pr(t,n))||i.enumerable});return e};var _r=(e,t,r)=>(r=e!=null?Ar(Ir(e)):{},Or(t||!e||!e.__esModule?Re(r,"default",{value:e,enumerable:!0}):r,e));/*! @xysfe/bug-tap v0.1.1 | MIT */const Hr=require("css-selector-generator"),Z=["x-request-id","x-trace-id","traceparent","tracestate","x-b3-traceid","x-b3-spanid","server-timing","content-length"];function H(e,t){try{return e instanceof RegExp?(e.lastIndex=0,e.test(t)):t.includes(e)}catch(r){return!1}}const Ur=[/^Script error\.?$/,/^Javascript error: Script error\.? on line 0$/,/^ResizeObserver loop completed with undelivered notifications\.$/,/^Cannot redefine property: googletag$/,/can't redefine non-configurable property "solana"/,/^Can't find variable: gmo$/,/^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/,/vv\(\)\.getRestrictions is not a function/,/Can't find variable: _AutofillCallbackHandler/,/Object Not Found Matching Id:\d+, MethodName:simulateEvent/],sr=/^(?:<anonymous>|\[native code\]|data:|blob:|about:|chrome-extension:|moz-extension:)/i,jr=/\bat\s+(?:.*?\s+\()?([^\s()]+):(\d+):(\d+)\)?\s*$/;function Ct(e){if(e)for(const t of e.split(`
2
+ `)){const r=jr.exec(t);if(!r)continue;const i=r[1];if(!i||sr.test(i))continue;const n=Number(r[2]),s=Number(r[3]);return{url:i,line:Number.isFinite(n)&&n>0?n:void 0,column:Number.isFinite(s)&&s>=0?s:void 0}}}function zr(e,t){const r=Ct(e);if(r)return r.url;if(t&&!sr.test(t))return t}const Dr=/^\[(?:setTimeout|setInterval|requestAnimationFrame)\] /,Nr=/^[A-Za-z]*Error: /;function qr(e){const t=new Set([e]),r=e.replace(Dr,"");t.add(r);const i=r.replace(Nr,"");return t.add(i),Array.from(t)}function Fr(e,t){return qr(e).some(r=>t.some(i=>H(i,r)))}function Wr(e){const t=(e.message||"").trim(),r=(e.stack||"").trim();return t.length===0&&r.length===0}function Xr(e,t,r){return!(t.length>0&&(!e||!t.some(i=>H(i,e)))||e&&r.some(i=>H(i,e)))}const Vr=/\.(?:js|css|map|png|jpe?g|gif|svg|webp|ico|bmp|woff2?|ttf|eot|otf|mp4|webm|mp3|wav|ogg|avi|mov|zip|gz|pdf)(?:[?#]|$)/i,Yr=[Vr],Te="/go/SupportTools/logreport",Me="/platform/file/uploadPicture",Ae="1086";function Kr(e){return(String(e!=null?e:"").trim()||Te).replace(/\/+$/,"")||Te}function bt(e){return Object.prototype.toString.call(e)==="[object Object]"}function or(e){if(typeof e=="function")return e;if(!bt(e))return;const t={};for(const r of Object.keys(e)){const i=e[r],n=typeof i;(n==="string"||n==="number"||n==="boolean")&&(t[r]=i)}return Object.keys(t).length>0?t:void 0}function y(e,t,r,i){return Math.round(cr(e,t,r,i))}function Gr(e){const t=String(e.release||"").trim();if(t)return t;const r=String(e.appVersion||"").trim(),i=String(e.buildId||"").trim();return r&&i?`${r}+${i}`:r||i}function ar(e){return e===!0?!0:Array.isArray(e)?Array.from(new Set(e.map(t=>String(t||"").trim().toLowerCase()).filter(t=>t.length>0))):[]}function Jr(e){if(e===!0)return!0;const t=ar(e);return Array.from(new Set([...Z,"content-type",...t]))}function cr(e,t,r,i){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?Math.min(r,Math.max(t,n)):i}function lr(e,t){if(!bt(e)||!bt(t))return t===void 0?e:t;const r={...e};for(const i of Object.keys(t))r[i]=lr(e[i],t[i]);return r}function Qr(e,t){return lr(e,t||{})}function it(e){var o,a,c,l,u,h,d,p,g,b,m,I,q,Pt,Bt,It,$t,Ot,_t,Ht,Ut,jt,zt,Dt,Nt,qt,Ft,Wt,Xt,Vt,Yt,Kt,Gt,Jt,Qt,Zt,te,ee,re,ie,ne,se,oe,ae,ce,le,ue,he,de,fe,pe,ge,me,be,ye,we,ve,xe,Ee,Se,ke,Ce,Le;const t={excludeUrls:Yr.concat(((o=e.privacy)==null?void 0:o.excludeUrls)||[]),excludeConsolePatterns:(((a=e.privacy)==null?void 0:a.excludeConsolePatterns)||[]).slice(),excludeBreadcrumbUrls:(((c=e.privacy)==null?void 0:c.excludeBreadcrumbUrls)||[]).slice()},r=e.filtering||{},i={ignoreErrors:(r.ignoreErrors||[]).slice().concat(r.disableErrorDefaults?[]:Ur),denyUrls:(r.denyUrls||[]).slice(),allowUrls:(r.allowUrls||[]).slice()},n=e.hooks||{},s={beforeSend:typeof n.beforeSend=="function"?n.beforeSend:void 0,beforeBreadcrumb:typeof n.beforeBreadcrumb=="function"?n.beforeBreadcrumb:void 0};return{project:String(e.project||"").trim(),endpoint:Kr(e.endpoint),environment:String(e.environment||"production").trim()||"production",appVersion:String(e.appVersion||"").trim(),buildId:String(e.buildId||"").trim(),release:Gr(e),debug:e.debug===!0,user:or(e.user),reporter:{enabled:((l=e.reporter)==null?void 0:l.enabled)!==!1,position:((u=e.reporter)==null?void 0:u.position)==="bottom-left"?"bottom-left":"bottom-right",theme:((h=e.reporter)==null?void 0:h.theme)==="light"||((d=e.reporter)==null?void 0:d.theme)==="dark"?e.reporter.theme:"auto",text:String(((p=e.reporter)==null?void 0:p.text)||"反馈").slice(0,20),zIndex:y((g=e.reporter)==null?void 0:g.zIndex,1,2147483647,2147483e3),visibility:{mode:((m=(b=e.reporter)==null?void 0:b.visibility)==null?void 0:m.mode)==="triggered"?"triggered":"always",queryParam:String(((q=(I=e.reporter)==null?void 0:I.visibility)==null?void 0:q.queryParam)||"bugtap").trim(),queryValue:((Bt=(Pt=e.reporter)==null?void 0:Pt.visibility)==null?void 0:Bt.queryValue)===void 0?"1":String(e.reporter.visibility.queryValue),closable:(($t=(It=e.reporter)==null?void 0:It.visibility)==null?void 0:$t.closable)!==!1}},collect:{console:((Ot=e.collect)==null?void 0:Ot.console)!==!1,error:((_t=e.collect)==null?void 0:_t.error)!==!1,network:((Ht=e.collect)==null?void 0:Ht.network)!==!1,networkBody:((Ut=e.collect)==null?void 0:Ut.networkBody)!==!1,realtime:((jt=e.collect)==null?void 0:jt.realtime)!==!1,resourceErrors:((zt=e.collect)==null?void 0:zt.resourceErrors)!==!1,environment:((Dt=e.collect)==null?void 0:Dt.environment)!==!1,trackIds:((Nt=e.collect)==null?void 0:Nt.trackIds)!==!1,breadcrumbs:((qt=e.collect)==null?void 0:qt.breadcrumbs)!==!1,maxBreadcrumbs:y((Ft=e.collect)==null?void 0:Ft.maxBreadcrumbs,1,200,100),maxConsoleLogs:y((Wt=e.collect)==null?void 0:Wt.maxConsoleLogs,1,500,100),maxNetworkRecords:y((Xt=e.collect)==null?void 0:Xt.maxNetworkRecords,1,500,200),maxErrors:y((Vt=e.collect)==null?void 0:Vt.maxErrors,1,200,50),maxNetworkBytes:y((Yt=e.collect)==null?void 0:Yt.maxNetworkBytes,8192,8e6,524288),maxCloneBytes:y((Kt=e.collect)==null?void 0:Kt.maxCloneBytes,1024,5e6,262144),requestHeaders:ar((Gt=e.collect)==null?void 0:Gt.requestHeaders),responseHeaders:Jr((Jt=e.collect)==null?void 0:Jt.responseHeaders),maxElements:y((Qt=e.collect)==null?void 0:Qt.maxElements,1,20,5),eventListenerErrors:((Zt=e.collect)==null?void 0:Zt.eventListenerErrors)!==!1},privacy:t,filtering:i,hooks:s,screenshot:{enabled:((te=e.screenshot)==null?void 0:te.enabled)!==!1,auto:((ee=e.screenshot)==null?void 0:ee.auto)!==!1,quality:cr((re=e.screenshot)==null?void 0:re.quality,.1,1,.8),maxWidth:y((ie=e.screenshot)==null?void 0:ie.maxWidth,320,4096,1600),maxSizeKB:y((ne=e.screenshot)==null?void 0:ne.maxSizeKB,50,2048,400),scriptUrl:String(((se=e.screenshot)==null?void 0:se.scriptUrl)||"").trim()},transport:{timeoutMs:y((oe=e.transport)==null?void 0:oe.timeoutMs,1e3,6e4,15e3),retries:y((ae=e.transport)==null?void 0:ae.retries,0,5,2),headers:{...((ce=e.transport)==null?void 0:ce.headers)||{}},maxItemBytes:y((le=e.transport)==null?void 0:le.maxItemBytes,5e4,5e6,8e5),totalTimeoutMs:y((ue=e.transport)==null?void 0:ue.totalTimeoutMs,3e3,6e4,3e4),maxConcurrent:y((he=e.transport)==null?void 0:he.maxConcurrent,1,50,10),logLevel:((de=e.transport)==null?void 0:de.logLevel)===1||((fe=e.transport)==null?void 0:fe.logLevel)===2||((pe=e.transport)==null?void 0:pe.logLevel)===3?e.transport.logLevel:void 0,offline:{enabled:((me=(ge=e.transport)==null?void 0:ge.offline)==null?void 0:me.enabled)!==!1,ttlMs:y((ye=(be=e.transport)==null?void 0:be.offline)==null?void 0:ye.ttlMs,6e4,168*36e5,24*36e5),maxItems:y((ve=(we=e.transport)==null?void 0:we.offline)==null?void 0:ve.maxItems,1,100,20)},maxReportsPerSession:y((xe=e.transport)==null?void 0:xe.maxReportsPerSession,0,1e3,0)},upload:{enabled:((Ee=e.upload)==null?void 0:Ee.enabled)!==!1,url:String(((Se=e.upload)==null?void 0:Se.url)||Me).trim()||Me,bizId:String((Ce=(ke=e.upload)==null?void 0:ke.bizId)!=null?Ce:Ae).trim()||Ae,timeoutMs:y((Le=e.upload)==null?void 0:Le.timeoutMs,1e3,12e4,3e4)}}}function yt(e){const t=[];if(!e||typeof e!="object")return t.push("配置不是对象"),t;if((!e.project||typeof e.project!="string")&&t.push("缺少 project"),e.endpoint!==void 0&&e.endpoint!==null&&String(e.endpoint).trim()!=="")try{const r=new URL(e.endpoint,location.href);r.protocol!=="http:"&&r.protocol!=="https:"&&t.push("endpoint 必须是 http/https 地址")}catch(r){t.push("endpoint 不是合法 URL")}return t}class Lt{constructor(t){this.start=0,this.length=0,this.evicted=0,this.capacity=Math.max(1,Math.floor(t)),this.items=new Array(this.capacity)}get size(){return this.length}get limit(){return this.capacity}get droppedCount(){return this.evicted}push(t){if(this.length<this.capacity){this.items[(this.start+this.length)%this.capacity]=t,this.length+=1;return}this.items[this.start]=t,this.start=(this.start+1)%this.capacity,this.evicted+=1}last(){if(this.length!==0)return this.items[(this.start+this.length-1)%this.capacity]}toArray(){const t=[];for(let r=0;r<this.length;r+=1){const i=this.items[(this.start+r)%this.capacity];i!==void 0&&t.push(i)}return t}includes(t){for(let r=0;r<this.length;r+=1)if(this.items[(this.start+r)%this.capacity]===t)return!0;return!1}update(t,r){for(let i=0;i<this.length;i+=1){const n=(this.start+i)%this.capacity,s=this.items[n];if(s!==void 0&&t(s))return this.items[n]=r(s),!0}return!1}updateLast(t){if(this.length===0)return!1;const r=(this.start+this.length-1)%this.capacity,i=this.items[r];return i===void 0?!1:(this.items[r]=t(i),!0)}clear(){this.items=new Array(this.capacity),this.start=0,this.length=0,this.evicted=0}}function ur(e){return e.ok===!1||!!e.error||(e.status||0)>=400}function Zr(e){return e.ok===!0}function hr(e){return e?e.droppedCount+e.evictedCount+(e.trimmedCount||0):0}const ti=60,ei=40;function Pe(e){var t,r,i,n;try{if(!e)return;const s=e.tagName?e.tagName.toLowerCase():"";if(!s)return;const o=e.id?`#${e.id}`:"",a=((t=e.getAttribute)==null?void 0:t.call(e,"data-testid"))||((r=e.getAttribute)==null?void 0:r.call(e,"data-test"))||((i=e.getAttribute)==null?void 0:i.call(e,"data-qa"))||"",c=!o&&a?`[data-testid="${a}"]`:"",l=((n=e.getAttribute)==null?void 0:n.call(e,"name"))||"",u=!o&&!c&&l?`[name="${l}"]`:"",h=typeof e.className=="string"?e.className.trim():"",d=!o&&!c&&!u&&h?`.${h.split(/\s+/).slice(0,2).join(".")}`:"";return`${s}${o}${c}${u}${d}`.slice(0,ti)}catch(s){return}}function ri(e,t=ei){try{const r=((e==null?void 0:e.textContent)||"").replace(/\s+/g," ").trim();return r?r.slice(0,t):void 0}catch(r){return}}function ii(e){var t;try{const r=(((t=e==null?void 0:e.getAttribute)==null?void 0:t.call(e,"type"))||"").toLowerCase();return r==="password"||r==="hidden"}catch(r){return!0}}function Be(e){var r,i;try{if(document.documentElement.hasAttribute("data-bug-tap-picking"))return!0}catch(n){}let t=e;for(;t;)try{if((r=t.hasAttribute)!=null&&r.call(t,"data-bug-tap")||(i=t.hasAttribute)!=null&&i.call(t,"data-bug-tap-picker"))return!0;const n=t.getRootNode?t.getRootNode():null;if(n&&n.host){t=n.host;continue}t=t.parentElement}catch(n){return!1}return!1}function nt(e){try{const t=new URL(e);return`${t.pathname}${t.search}${t.hash}`.slice(0,300)}catch(t){return e.slice(0,300)}}function ni(e,t){if(e===t)return!0;if(!e||!t)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(r){return!1}}class si{constructor(t){this.options=t,this.started=!1,this.lastRoute="",this.lastVisibility="",this.navigationDisabled=!1,this.tailSignature="",this.onClick=r=>{if(!(!this.started||!this.options.dom))try{const i=r.target;if(Be(i))return;const n=Pe(i);if(!n)return;this.push({t:Date.now(),type:"click",selector:n,text:ri(i)})}catch(i){}},this.onChange=r=>{if(!(!this.started||!this.options.dom))try{const i=r.target;if(!i||Be(i)||ii(i))return;const n=Pe(i);if(!n)return;this.push({t:Date.now(),type:"input",selector:n})}catch(i){}},this.onVisibility=()=>{if(this.started)try{const r=document.visibilityState;if(r===this.lastVisibility)return;this.lastVisibility=r,this.push({t:Date.now(),type:"visibility",state:r})}catch(r){}},this.checkRoute=()=>{if(!(!this.started||!this.options.navigation||this.navigationDisabled))try{const r=location.href;if(r===this.lastRoute)return;const i=this.lastRoute;this.lastRoute=r,this.push({t:Date.now(),type:"route",from:nt(i),to:nt(r)})}catch(r){}},this.onHistory=()=>{this.navigationDisabled||setTimeout(this.checkRoute,0)},this.originalPush=null,this.originalReplace=null,this.wrappedPush=null,this.wrappedReplace=null,this.routeHook=null,this.buffer=new Lt(t.max)}get limit(){return this.buffer.limit}get size(){return this.buffer.size}get evicted(){return this.buffer.droppedCount}start(){if(!this.started){this.started=!0;try{this.lastRoute=location.href,this.lastVisibility=document.visibilityState}catch(t){}this.options.dom&&(window.addEventListener("click",this.onClick,!0),window.addEventListener("change",this.onChange,!0)),this.options.navigation&&!this.navigationDisabled&&(window.addEventListener("popstate",this.checkRoute),window.addEventListener("hashchange",this.checkRoute),window.addEventListener("visibilitychange",this.onVisibility),this.patchHistory())}}stop(){this.started&&(this.started=!1,window.removeEventListener("click",this.onClick,!0),window.removeEventListener("change",this.onChange,!0),window.removeEventListener("popstate",this.checkRoute),window.removeEventListener("hashchange",this.checkRoute),window.removeEventListener("visibilitychange",this.onVisibility),this.unpatchHistory())}getBreadcrumbs(){return this.buffer.toArray()}add(t){this.started&&this.push(t)}disableNavigationCapture(){this.options.navigation&&(this.navigationDisabled=!0,window.removeEventListener("popstate",this.checkRoute),window.removeEventListener("hashchange",this.checkRoute),this.unpatchHistory())}clear(){this.buffer.clear(),this.tailSignature=""}addNetwork(t){var o;if(!this.started||!this.options.network||this.options.excludeUrls&&this.options.excludeUrls.some(a=>H(a,t.url)))return;const r=nt(t.url),i=ur(t),n=`${t.method} ${r} ${(o=t.status)!=null?o:""} ${i?1:0}`,s=this.buffer.last();if(s&&s.type==="http"&&this.tailSignature===n){this.buffer.updateLast(a=>({...a,repeat:(a.repeat||1)+1,ref:t.id}));return}this.tailSignature=n,this.push({t:Date.now(),type:"http",method:t.method,url:r,status:t.status,durationMs:t.durationMs,httpError:t.error,ref:t.id})}addError(t){!this.started||!this.options.error||this.push({t:t.timestamp,type:"error",message:t.message.slice(0,200),count:t.count})}push(t){if(!this.started)return;const r=this.applyHook(t);if(!r)return;const i=r;i.type!=="http"&&(this.tailSignature="");const n=this.buffer.last();n&&n.type===i.type&&n.selector===i.selector&&n.to===i.to&&n.state===i.state&&n.ref===i.ref&&n.message===i.message&&ni(n.data,i.data)||this.buffer.push(i)}applyHook(t){const r=this.options.beforeBreadcrumb;if(!r)return t;try{const i=r(t);return i===null?null:i&&typeof i=="object"?i:t}catch(i){return t}}wrapHistory(t){const r=this,i=function(...n){var o;const s=t.apply(this,n);return(o=r.routeHook)==null||o.call(r),s};return i.__bugTap=!0,i}patchHistory(){try{if(typeof history=="undefined")return;const t=history.pushState,r=history.replaceState;this.originalPush=t,this.originalReplace=r,this.routeHook=()=>this.onHistory(),this.wrappedPush=this.wrapHistory(t),this.wrappedReplace=this.wrapHistory(r),history.pushState=this.wrappedPush,history.replaceState=this.wrappedReplace}catch(t){}}unpatchHistory(){try{this.wrappedPush&&history.pushState===this.wrappedPush&&this.originalPush&&(history.pushState=this.originalPush),this.wrappedReplace&&history.replaceState===this.wrappedReplace&&this.originalReplace&&(history.replaceState=this.originalReplace)}catch(t){}this.routeHook=null,this.originalPush=null,this.originalReplace=null,this.wrappedPush=null,this.wrappedReplace=null}}const dr="__bugTapCaptured";let D=0,F=0;function oi(e){try{e&&(typeof e=="object"||typeof e=="function")&&(e[dr]=!0)}catch(t){}}function Ie(e){try{return!!(e&&typeof e=="object"&&e[dr])}catch(t){return!1}}function ai(){return D<=0?!1:(D-=1,!0)}function ci(){D+=1;try{F&&clearTimeout(F),F=setTimeout(()=>{D=0,F=0},0)}catch(e){D=0}}const li="__bugTapWrapped",$e="__bugTapHandleEvent";class ui{constructor(t){this.options=t,this.patched=[],this.registry=new WeakMap,this.started=!1}start(){this.started||(this.started=!0,this.patchTimer("setTimeout","setTimeout"),this.patchTimer("setInterval","setInterval"),this.patchTimer("requestAnimationFrame","requestAnimationFrame"),this.options.eventListeners!==!1&&this.patchEventTarget())}stop(){if(this.started){this.started=!1;for(const{target:t,key:r,original:i}of this.patched)try{const n=t[r];typeof n=="function"&&n.__bugTap&&(t[r]=i)}catch(n){}this.patched.length=0}}patchTimer(t,r){try{const i=window,n=i[t];if(typeof n!="function"||n.__bugTap)return;this.patched.push({target:i,key:t,original:n});const s=this,o=function(a,...c){if(!s.started||typeof a!="function")return n.apply(this,[a,...c]);const l=s.wrapCallback(a,r);return n.apply(this,[l,...c])};o.__bugTap=!0,i[t]=o}catch(i){}}patchEventTarget(){try{if(typeof EventTarget=="undefined"||!EventTarget.prototype)return;const t=EventTarget.prototype,r=t.addEventListener,i=t.removeEventListener;if(typeof r!="function"||typeof i!="function"||r.__bugTap)return;this.patched.push({target:t,key:"addEventListener",original:r}),this.patched.push({target:t,key:"removeEventListener",original:i});const n=this,s=function(a,c,l){if(!n.started||!c)return r.call(this,a,c,l);if(typeof c=="object"){const h=c;if(typeof h.handleEvent=="function")try{h.handleEvent[$e]||(h.handleEvent=n.wrapCallback(h.handleEvent.bind(c),a,$e))}catch(d){}return r.call(this,a,c,l)}if(typeof c!="function")return r.call(this,a,c,l);const u=n.listenerFor(this,a,c,l);return r.call(this,a,u,l)},o=function(a,c,l){var u,h,d,p;try{const b=c&&(typeof c=="object"||typeof c=="function")?(h=(u=n.registry.get(this))==null?void 0:u.get(st(a,l)))==null?void 0:h.get(c):void 0;b&&b!==c&&(i.call(this,a,b,l),(p=(d=n.registry.get(this))==null?void 0:d.get(st(a,l)))==null||p.delete(c))}catch(g){}return i.call(this,a,c,l)};s.__bugTap=!0,o.__bugTap=!0,t.addEventListener=s,t.removeEventListener=o}catch(t){}}listenerFor(t,r,i,n){let s=this.registry.get(t);s||(s=new Map,this.registry.set(t,s));const o=st(r,n);let a=s.get(o);a||(a=new WeakMap,s.set(o,a));const c=a.get(i);if(c)return c;const l=this.wrapCallback(i,r);return a.set(i,l),l}wrapCallback(t,r,i=li){const n=this,s=function(...o){try{return t.apply(this,o)}catch(a){try{oi(a),ci(),n.options.capture(a,r)}catch(c){}throw a}};try{s[i]=t}catch(o){}return s}}function st(e,t){const r=typeof t=="boolean"?t:!!(t&&typeof t=="object"&&t.capture);return`${e}|${r?1:0}`}const hi=4,v=50,di=2e3,fr=4e3;function P(e,t=di){return e.length>t?`${e.slice(0,t)}…[${e.length-t} chars truncated]`:e}function fi(e){const t=typeof e;if(e===null)return"null";if(t==="undefined")return"undefined";if(t==="string")return P(e);if(t==="number")return Number.isFinite(e),String(e);if(t==="boolean")return String(e);if(t==="bigint")return`${String(e)}n`;if(t==="symbol")return String(e);if(t==="function"){const r=e.name;return`[Function${r?` ${r}`:""}]`}return null}function O(e,t=0,r){const i=fi(e);if(i!==null)return i;const n=r||new WeakSet,s=e;if(typeof s!="object"||s===null)return String(s);if(n.has(s))return"[Circular]";n.add(s);try{if(e instanceof Error){const c=typeof e.stack=="string"?e.stack.split(`
3
3
  `).slice(0,6).join(`
4
4
  `):"";return P(`${e.name||"Error"}: ${e.message}${c?`
5
5
  ${c}`:""}`,fr)}if(e instanceof Date)try{return e.toISOString()}catch(c){return"[Invalid Date]"}if(e instanceof RegExp)return String(e);if(typeof Element!="undefined"&&e instanceof Element){const c=e.tagName.toLowerCase(),l=e.id?`#${e.id}`:"",u=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`<${c}${l}${u}>`}if(typeof Node!="undefined"&&e instanceof Node)return`[Node ${e.nodeName}]`;if(t>=hi)return"[MaxDepth]";if(Array.isArray(e)){const c=e.slice(0,v).map(l=>O(l,t+1,n));return e.length>v&&c.push(`…[${e.length-v} more]`),P(`[${c.join(", ")}]`)}if(e instanceof Map){const c=[];let l=0;return e.forEach((u,h)=>{l<v&&c.push(`${O(h,t+1,n)} => ${O(u,t+1,n)}`),l+=1}),l>v&&c.push(`…[${l-v} more]`),P(`Map(${e.size}) {${c.join(", ")}}`)}if(e instanceof Set){const c=[];let l=0;return e.forEach(u=>{l<v&&c.push(O(u,t+1,n)),l+=1}),l>v&&c.push(`…[${l-v} more]`),P(`Set(${e.size}) {${c.join(", ")}}`)}const o=Object.keys(e),a=[];for(const c of o.slice(0,v))try{const l=e[c];a.push(`${c}: ${O(l,t+1,n)}`)}catch(l){a.push(`${c}: [Thrown]`)}return o.length>v&&a.push(`…[${o.length-v} more keys]`),P(`{${a.join(", ")}}`)}catch(o){return"[Unserializable]"}finally{n.delete(s)}}function pi(e){const t=e.map(i=>O(i)),r=P(t.join(" "),fr);return{args:t,text:r}}const ot=["log","info","warn","error","debug","trace","assert"];class gi{constructor(t){this.options=t,this.originals=new Map,this.wrapped=new Map,this.originalClear=null,this.wrappedClear=null,this.started=!1,this.capturing=!1,this.dispatching=!1,this.buffer=new Lt(t.max)}start(){if(this.started)return;this.started=!0;const t=window.console;for(const i of ot){const n=t[i];if(typeof n!="function")continue;const s=n;this.originals.set(i,s);const o=this,a=function(...c){o.capture(i,c),o.dispatching=!0;try{return s.apply(this,c)}finally{o.dispatching=!1}};a.__bugTap=!0,this.wrapped.set(i,a);try{t[i]=a}catch(c){}}const r=t.clear;if(typeof r=="function"){this.originalClear=r;const i=this,n=function(){return i.buffer.clear(),i.originalClear.apply(this)};n.__bugTap=!0,this.wrappedClear=n;try{t.clear=n}catch(s){}}}stop(){if(!this.started)return;this.started=!1;const t=window.console;for(const r of ot){const i=this.wrapped.get(r),n=this.originals.get(r);if(!(!i||!n)&&t[r]===i)try{t[r]=n}catch(s){}}if(this.wrappedClear&&this.originalClear&&t.clear===this.wrappedClear)try{t.clear=this.originalClear}catch(r){}this.wrapped.clear(),this.originals.clear(),this.wrappedClear=null,this.originalClear=null}getLogs(){return this.buffer.toArray()}getPatchState(){if(!this.started)return!1;const t=window.console;for(const r of ot){const i=this.wrapped.get(r);if(i&&t[r]===i)return!0}return!1}clear(){this.buffer.clear()}capture(t,r){if(!(!this.started||this.capturing||this.dispatching)){this.capturing=!0;try{if(t==="assert"&&r[0])return;const{args:i,text:n}=pi(t==="assert"?r.slice(1):r);if(this.options.excludePatterns.some(o=>H(o,n)))return;const s=this.buffer.last();if(s&&s.level===t&&s.text===n){this.buffer.updateLast(o=>({...o,count:(o.count||1)+1,timestamp:Date.now()}));return}this.buffer.push({level:t,timestamp:Date.now(),args:i,text:n})}catch(i){}finally{this.capturing=!1}}}}const mi=1e3,Oe=200,bi=6e4,yi=20,wi=50,W=2e3;function _e(e){if(e!=null)try{if(e instanceof Error){const t=`${e.name||"Error"}: ${e.message}`,r=typeof e.stack=="string"?e.stack.split(`
@@ -8,7 +8,7 @@ ${c}`:""}`,fr)}if(e instanceof Date)try{return e.toISOString()}catch(c){return"[
8
8
  ${r}`:t).slice(0,W)}return typeof e=="string"?e.slice(0,W):JSON.stringify(e).slice(0,W)}catch(t){return String(e).slice(0,W)}}const vi=/(?:[\\/]src[\\/](?:core|ui|transport)[\\/](?:browser-api-errors|error-collector|console-collector|network-collector|breadcrumbs|collector|resource-timing|body|serialize|selector|user|tongji|error-noise|network-record|ring-buffer|byte-buffer|panel(?:-mount)?|screenshot|element-picker|floating-button|shadow-host|visibility|transport|payload|log-item|upload|offline-queue)\.(?:ts|vue)|[\\/]src[\\/](?:index|sdk|config|integrations)\.ts|@xysfe[\\/]bug-tap|[\\/]bug-tap(?:\.min)?\.js|\bsafeCallback\b)/i;function He(e){if(!e)return;const t=e.split(`
9
9
  `),r=t[0]||"",i=t.slice(1).filter(s=>!vi.test(s));return[r,...i].slice(0,yi).join(`
10
10
  `)}class xi{constructor(t){this.options=t,this.signatures=new Map,this.started=!1,this.listener=null,this.onError=r=>{try{if(r.target&&r.target!==window){this.options.resourceErrors!==!1&&this.pushResourceError(r);return}if(Ie(r.error)||r.error===void 0&&ai())return;const i=(r.message||"Script error.").replace(/^Uncaught\s+/,""),n=r.error,s=n&&typeof n.stack=="string"?n.stack:"";this.push({type:"error",message:this.sanitize(i),filename:r.filename?this.sanitize(r.filename):void 0,lineno:r.lineno||void 0,colno:r.colno||void 0,stack:s?this.sanitize(He(s)||""):void 0,cause:_e(n==null?void 0:n.cause),timestamp:Date.now(),count:1})}catch(i){}},this.onRejection=r=>{try{const i=r.reason;if(Ie(i))return;this.push({...this.fromUnknown(i),type:"unhandledrejection"})}catch(i){}},this.buffer=new Lt(t.max)}setListener(t){this.listener=t}pushResourceError(t){const r=t.target;if(!r||typeof r.tagName!="string")return;const i=r.tagName.toLowerCase(),n=r.currentSrc||r.getAttribute("src")||r.getAttribute("href")||"";this.push({type:"resource",message:this.sanitize(`Resource load failed: <${i}>${n?` ${n}`:""}`),filename:n?this.sanitize(n):void 0,timestamp:Date.now(),count:1})}captureFromBrowserApi(t,r){try{this.push(this.fromUnknown(t,`[${r}]`,r))}catch(i){}}captureException(t,r){try{this.push(this.fromUnknown(t,"",void 0,r),!1)}catch(i){}}captureMessage(t,r){try{this.push({type:"error",message:this.sanitize(String(t!=null?t:"")),context:r&&Object.keys(r).length>0?r:void 0,timestamp:Date.now(),count:1},!1)}catch(i){}}fromUnknown(t,r="",i,n){let s,o,a;if(t instanceof Error)s=`${t.name||"Error"}: ${t.message}`,o=t.stack,a=_e(t.cause);else if(typeof t=="string")s=t;else try{s=JSON.stringify(t)}catch(u){s=String(t)}const c=o?He(o):void 0,l=Ct(c);return{type:"error",message:this.sanitize(i?`${r} ${s}`:`${r}${s}`),filename:l!=null&&l.url?this.sanitize(l.url):void 0,lineno:l==null?void 0:l.line,colno:l==null?void 0:l.column,stack:c?this.sanitize(c):void 0,cause:a,context:n&&Object.keys(n).length>0?n:void 0,timestamp:Date.now(),count:1}}start(){if(!this.started){this.started=!0;try{this.previousStackTraceLimit=Error.stackTraceLimit,Error.stackTraceLimit=wi}catch(t){}window.addEventListener("error",this.onError,!0),window.addEventListener("unhandledrejection",this.onRejection)}}stop(){if(this.started&&(this.started=!1,window.removeEventListener("error",this.onError,!0),window.removeEventListener("unhandledrejection",this.onRejection),this.previousStackTraceLimit!==void 0)){try{Error.stackTraceLimit=this.previousStackTraceLimit}catch(t){}this.previousStackTraceLimit=void 0}}getErrors(){return this.buffer.toArray()}getPatchState(){return this.started}clear(){this.buffer.clear(),this.signatures.clear()}push(t,r=!0){if(r&&this.shouldDrop(t))return;const i=`${t.type}|${t.message}|${t.filename||""}|${t.lineno||""}`,n=this.signatures.get(i),s=t.timestamp;if(r&&n&&s-n.lastTs<mi){if(this.buffer.includes(n.record)){n.record.count+=1,n.lastTs=s;return}this.signatures.delete(i)}if(this.signatures.size>=Oe&&(this.pruneSignatures(s),this.signatures.size>=Oe&&this.signatures.clear()),this.signatures.set(i,{record:t,lastTs:s}),this.buffer.push(t),this.listener)try{this.listener(t)}catch(o){}}pruneSignatures(t){for(const[r,i]of this.signatures)(t-i.lastTs>=bi||!this.buffer.includes(i.record))&&this.signatures.delete(r)}shouldDrop(t){const r=this.options.ignoreErrors||[];if(r.length>0&&Fr(t.message,r)||Wr(t))return!0;const i=zr(t.stack,t.filename);return!Xr(i,this.options.allowUrls||[],this.options.denyUrls||[])}sanitize(t){return String(t).slice(0,4e3)}}class Ei{constructor(t,r,i){this.maxItems=t,this.maxBytes=r,this.sizeOf=i,this.items=[],this.sizes=[],this.head=0,this.total=0,this.droppedItems=0,this.droppedBytes=0,this.evictedItems=0,this.evictedBytes=0}get size(){return this.items.length-this.head}get bytes(){return this.total}get dropped(){return{count:this.droppedItems,bytes:this.droppedBytes}}get evicted(){return{count:this.evictedItems,bytes:this.evictedBytes}}push(t){const r=this.sizeOf(t);if(r>this.maxBytes)return this.droppedItems+=1,this.droppedBytes+=r,"dropped";let i=!1;for(;this.size>0&&(this.total+r>this.maxBytes||this.size>=this.maxItems);)this.shift(),i=!0;return this.items.push(t),this.sizes.push(r),this.total+=r,i?"evicted":"ok"}toArray(){return this.items.slice(this.head)}update(t,r){for(let i=this.head;i<this.items.length;i+=1){const n=this.items[i];if(!t(n))continue;const s=r(n),o=this.sizeOf(s),a=o-(this.sizes[i]||0);return this.total+a>this.maxBytes?"dropped":(this.items[i]=s,this.sizes[i]=o,this.total+=a,"ok")}return"missed"}clear(){this.items=[],this.sizes=[],this.head=0,this.total=0,this.droppedItems=0,this.droppedBytes=0,this.evictedItems=0,this.evictedBytes=0}shift(){const t=this.sizes[this.head]||0;this.items[this.head]=void 0,this.head+=1,this.total-=t,this.evictedItems+=1,this.evictedBytes+=t,this.head>=this.items.length?(this.items=[],this.sizes=[],this.head=0):this.head>64&&this.head*2>this.items.length&&(this.items=this.items.slice(this.head),this.sizes=this.sizes.slice(this.head),this.head=0)}}const Si=/text\/event-stream/i,ki=/^(?:image|video|audio|font)\/|^application\/(?:octet-stream|x-protobuf|protobuf|zip|gzip|x-zip-compressed|pdf|wasm|vnd\.ms-fontobject)/i;function wt(e,t){if(t<=0)return e;let r=0,i=0;for(;i<e.length;){const n=e.charCodeAt(i);let s,o=1;if(n<128?s=1:n<2048?s=2:n<55296||n>=57344?s=3:(s=4,o=n>=56320?1:2),r+s>t)break;r+=s,i+=o}return i>=e.length?e:`${e.slice(0,i)}…[truncated]`}function S(e){let t=0;for(let r=0;r<e.length;r+=1){const i=e.charCodeAt(r);i<128?t+=1:i<2048?t+=2:i<55296||i>=57344?t+=3:(t+=4,r+=1)}return t}function Ci(e){if(e!=null)try{if(typeof e=="string")return e;if(typeof URLSearchParams!="undefined"&&e instanceof URLSearchParams)return e.toString();if(typeof FormData!="undefined"&&e instanceof FormData){const t=[];return e.forEach((r,i)=>{if(typeof File!="undefined"&&r instanceof File){const n=r.name||"blob",s=r.type||"unknown";t.push(`${i}=[File ${n} ${r.size}B ${s}]`);return}if(typeof Blob!="undefined"&&r instanceof Blob){t.push(`${i}=[Blob ${r.size}B ${r.type||"unknown"}]`);return}t.push(`${i}=${String(r)}`)}),t.join("&")}return typeof Blob!="undefined"&&e instanceof Blob?`[Blob ${e.size}B ${e.type||"unknown"}]`:typeof ArrayBuffer!="undefined"&&e instanceof ArrayBuffer?`[Binary ${e.byteLength}B]`:typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView(e)?`[Binary ${e.byteLength}B]`:typeof ReadableStream!="undefined"&&e instanceof ReadableStream?"[ReadableStream]":`[${Object.prototype.toString.call(e).slice(8,-1)}]`}catch(t){return"[Unreadable]"}}function B(e,t=Number.MAX_SAFE_INTEGER){try{return S(JSON.stringify(e))}catch(r){return t}}function pr(e,t,r){const i=(e||"").toLowerCase();return!(Si.test(i)||ki.test(i)||t>0&&t>r)}function Ue(e,t){if(typeof e.getReader!="function"||typeof TextDecoder=="undefined")return new Response(e).text();const r=e.getReader(),i=new TextDecoder("utf-8",{fatal:!1}),n=[];let s=0,o=!1;const a=()=>{try{Promise.resolve(r.cancel()).catch(()=>{})}catch(u){}},c=()=>r.read().then(({done:u,value:h})=>u?(n.push(i.decode()),l()):h?(s+=h.byteLength,s>t?(o=!0,a(),l()):(n.push(i.decode(h,{stream:!0})),c())):c(),()=>(o=!0,a(),l())),l=()=>{const u=n.join("");return o?`${u}…[truncated]`:u};return c()}function Li(e,t){try{const r=e.getResponseHeader("content-type"),i=Number(e.getResponseHeader("content-length")||0);if(!pr(r,i,t))return;const n=e.responseType;if(n===""||n==="text"){const s=e.responseText;return s?wt(s,t):void 0}if(n==="json"){const s=e.response;if(s==null)return;try{return wt(JSON.stringify(s),t)}catch(o){return}}return`[${n}]`}catch(r){return}}const Ri=2e3,Ti=500,Mi=1e3;function U(e){return Number.isFinite(e)&&e>0?Math.round(e):0}function Ai(e){return{dns:U(e.domainLookupEnd-e.domainLookupStart),connect:U(e.connectEnd-e.connectStart),ttfb:U(e.responseStart-e.startTime),download:U(e.responseEnd-e.responseStart),total:U(e.responseEnd-e.startTime)}}class Pi{constructor(){this.started=new Map,this.enabled=!0}remember(t,r,i){if(!(!this.enabled||!Number.isFinite(i))&&(this.started.set(t,{url:r,start:i}),this.started.size>Mi)){const n=this.started.keys().next();n.done||this.started.delete(n.value)}}attach(t){if(t.timing)return t;const r=this.started.get(t.id);if(!r)return t;const i=this.find(r.url,r.start);return i?{...t,timing:i}:t}clear(){this.started.clear()}find(t,r){if(this.enabled)try{if(typeof performance=="undefined"||typeof performance.getEntriesByName!="function")return;const i=performance.getEntriesByName(t);if(!i.length||i.length>Ti)return;let n,s=1/0;for(const o of i){if(typeof o.responseEnd!="number"||o.responseEnd<=0)continue;const a=Math.abs(o.startTime-r);a<s&&(s=a,n=o)}return!n||s>Ri?void 0:Ai(n)}catch(i){this.enabled=!1;return}}}function N(e){try{return new URL(e,location.href).href}catch(t){return e}}const Bi=4096,Ii=40;function $i(e,t){return t===!0||t.indexOf(e)>=0}function T(e,t,r,i){const n=String(t||"").trim().toLowerCase();if(!n||!$i(n,i)||!(n in e)&&Object.keys(e).length>=Ii)return;const s=String(r!=null?r:"").slice(0,Bi);s&&(e[n]=s)}function at(e,t){if(!e)return;const r={};try{if(e&&typeof e.forEach=="function"&&(typeof Headers=="undefined"||e instanceof Headers||typeof e.get=="function"))e.forEach((i,n)=>T(r,n,i,t));else if(e&&typeof e.get=="function"){const i=t===!0?[...Z]:t;for(const n of i){const s=e.get(n);s&&T(r,n,s,!0)}}else if(Array.isArray(e))for(const i of e)Array.isArray(i)&&i.length>=2&&T(r,String(i[0]),i[1],t);else if(typeof e=="object")for(const[i,n]of Object.entries(e))Array.isArray(n)?n.forEach(s=>T(r,i,s,t)):T(r,i,n,t)}catch(i){}return Object.keys(r).length>0?r:void 0}function Oi(e,t){return e?t?{...e,...t}:e:t}function _i(e,t){const r={};return e.trim().split(/[\r\n]+/).forEach(i=>{const n=i.indexOf(":");n<=0||T(r,i.slice(0,n),i.slice(n+1).trim(),t)}),Object.keys(r).length>0?r:void 0}function R(){return typeof performance!="undefined"&&typeof performance.now=="function"?performance.now():Date.now()}function je(e){try{const t=new URL(e,location.href);return`${t.origin}${t.pathname.replace(/\/+$/,"")||"/"}`}catch(t){return null}}function Hi(e){return typeof e=="string"?e:typeof URL!="undefined"&&e instanceof URL?e.href:typeof Request!="undefined"&&e instanceof Request?e.url:String(e)}class Ui{constructor(t){this.options=t,this.timing=new Pi,this.pendingXhr=new WeakMap,this.originalFetch=null,this.wrappedFetch=null,this.originalOpen=null,this.wrappedOpen=null,this.originalSend=null,this.wrappedSend=null,this.originalSetRequestHeader=null,this.wrappedSetRequestHeader=null,this.originalWebSocket=null,this.wrappedWebSocket=null,this.originalEventSource=null,this.wrappedEventSource=null,this.started=!1,this.seq=0,this.listener=null,this.buffer=new Ei(t.max,t.maxBytes,r=>this.sizeOf(r)),this.selfUrls=(t.selfUrls||[]).filter(Boolean).map(r=>je(r)).filter(r=>r!==null),this.matchers=(t.excludeUrls||[]).slice(),this.requestHeaderAllow=t.requestHeaders===!0?!0:(t.requestHeaders||[]).map(r=>r.toLowerCase()),this.responseHeaderAllow=t.responseHeaders===!0?!0:Array.from(new Set([...Z,...(t.responseHeaders||[]).map(r=>r.toLowerCase())]))}setListener(t){this.listener=t}skipped(t){try{const r=je(t);if(r&&this.selfUrls.indexOf(r)>=0)return!0;for(const i of this.matchers)if(H(i,t))return!0;return!1}catch(r){return!1}}sizeOf(t){let r=0;for(const i of[t.reqHeaders,t.resHeaders])if(i)for(const n of Object.keys(i))r+=S(n)+S(i[n]||"")+6;return S(t.url||"")+S(t.reqBody||"")+S(t.resBody||"")+S(t.error||"")+S(t.contentType||"")+r+(t.timing?80:0)+96}start(){if(!this.started&&(this.started=!0,this.patchFetch(),this.patchXhr(),this.options.realtime!==!1))try{this.patchRealtime()}catch(t){}}stop(){if(this.started){if(this.started=!1,this.wrappedFetch&&typeof window.fetch=="function"&&window.fetch===this.wrappedFetch)try{window.fetch=this.originalFetch}catch(t){}if(this.wrappedOpen&&XMLHttpRequest.prototype.open===this.wrappedOpen)try{XMLHttpRequest.prototype.open=this.originalOpen}catch(t){}if(this.wrappedSend&&XMLHttpRequest.prototype.send===this.wrappedSend)try{XMLHttpRequest.prototype.send=this.originalSend}catch(t){}if(this.wrappedSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.wrappedSetRequestHeader)try{XMLHttpRequest.prototype.setRequestHeader=this.originalSetRequestHeader}catch(t){}if(this.wrappedWebSocket&&window.WebSocket===this.wrappedWebSocket)try{window.WebSocket=this.originalWebSocket}catch(t){}if(this.wrappedEventSource&&window.EventSource===this.wrappedEventSource)try{window.EventSource=this.originalEventSource}catch(t){}this.originalFetch=null,this.wrappedFetch=null,this.originalOpen=null,this.wrappedOpen=null,this.originalSend=null,this.wrappedSend=null,this.originalSetRequestHeader=null,this.wrappedSetRequestHeader=null,this.originalWebSocket=null,this.wrappedWebSocket=null,this.originalEventSource=null,this.wrappedEventSource=null}}getRecords(){return this.buffer.toArray().map(t=>this.timing.attach(t)).sort((t,r)=>t.timestamp-r.timestamp)}getPatchState(){return{fetch:!!this.wrappedFetch&&typeof window.fetch=="function"&&window.fetch===this.wrappedFetch,xhr:typeof XMLHttpRequest!="undefined"&&!!this.wrappedOpen&&!!this.wrappedSend&&XMLHttpRequest.prototype.open===this.wrappedOpen&&XMLHttpRequest.prototype.send===this.wrappedSend,websocket:!!this.wrappedWebSocket&&typeof window.WebSocket=="function"&&window.WebSocket===this.wrappedWebSocket,eventsource:!!this.wrappedEventSource&&typeof window.EventSource=="function"&&window.EventSource===this.wrappedEventSource}}getDropped(){const t=this.buffer.dropped,r=this.buffer.evicted;return{droppedCount:t.count,droppedBytes:t.bytes,evictedCount:r.count,evictedBytes:r.bytes}}clear(){this.buffer.clear(),this.timing.clear()}patchFetch(){if(typeof window.fetch!="function")return;const t=window.fetch;this.originalFetch=t;const r=this,i=function(n,s){if(!r.started)return t.apply(this,arguments);const o=R(),a=r.nextId(),c=Date.now(),l=Hi(n),u=N(l);if(r.skipped(u))return t.apply(this,arguments);r.timing.remember(a,u,o);const h=(s&&s.method||(typeof Request!="undefined"&&n instanceof Request?n.method:"GET")).toUpperCase(),d=r.requestHeadersOf(s&&s.headers,n),p=r.bodyOf(s&&s.body),g=p===void 0&&r.options.captureBody&&typeof Request!="undefined"&&n instanceof Request?r.requestBodyOf(n):Promise.resolve(p);let b;try{b=t.apply(this,arguments)}catch(m){throw r.record({id:a,type:"fetch",method:h,url:u,reqHeaders:d,reqBody:p,durationMs:Math.round(R()-o),error:m instanceof Error?m.message:String(m),timestamp:c}),m}return b.then(m=>(r.started&&r.observeResponse(m,{id:a,method:h,url:u,start:o,timestamp:c,reqHeaders:d,reqBody:p,reqBodyLater:g}),m),m=>{throw r.started&&r.recordWithBody({id:a,type:"fetch",method:h,url:u,reqHeaders:d,durationMs:Math.round(R()-o),error:m instanceof Error?m.message:String(m),timestamp:c},g),m})};i.__bugTap=!0,this.wrappedFetch=i;try{window.fetch=i}catch(n){}}patchXhr(){if(typeof XMLHttpRequest=="undefined")return;const t=this,r=XMLHttpRequest.prototype,i=r.open,n=r.send,s=r.setRequestHeader;this.originalOpen=i,this.originalSend=n,this.originalSetRequestHeader=s;const o=function(l,u){const h=t.requestHeaderAllow;if(t.started&&(h===!0||h.length>0))try{const d=t.pendingXhr.get(this);if(d){const p=d.reqHeaders||{};T(p,String(l),u,h),d.reqHeaders=Object.keys(p).length>0?p:void 0}}catch(d){}return s.call(this,l,u)},a=function(l,u,...h){if(!t.started)return i.apply(this,[l,u,...h]);try{t.pendingXhr.set(this,{id:t.nextId(),method:String(l||"GET").toUpperCase(),url:N(String(u)),start:0,timestamp:Date.now()})}catch(d){}return i.apply(this,[l,u,...h])},c=function(l){if(!t.started)return n.apply(this,[l]);const u=t.pendingXhr.get(this);if(u&&t.skipped(u.url))return t.pendingXhr.delete(this),n.apply(this,[l]);if(u){u.start=R(),u.timestamp=Date.now(),u.reqBody=t.bodyOf(l),t.timing.remember(u.id,u.url,u.start);try{this.addEventListener("abort",()=>{u.aborted=!0},{once:!0})}catch(h){}try{this.addEventListener("loadend",()=>{if(t.started)try{const h=this.status,d=u.aborted===!0;t.record({id:u.id,type:"xhr",method:u.method,url:u.url,reqHeaders:u.reqHeaders,reqBody:u.reqBody,resBody:t.options.captureBody?Li(this,t.options.maxCloneBytes):void 0,status:h||void 0,ok:d?void 0:h>=200&&h<400,durationMs:Math.round(R()-u.start),error:h===0&&!d?"Network Error":void 0,resHeaders:t.xhrResponseHeaders(this),timestamp:u.timestamp})}catch(h){}},{once:!0})}catch(h){}}return n.apply(this,[l])};this.wrappedOpen=a,this.wrappedSend=c,this.wrappedSetRequestHeader=o,this.wrappedOpen.__bugTap=!0,this.wrappedSend.__bugTap=!0,this.wrappedSetRequestHeader.__bugTap=!0;try{r.open=this.wrappedOpen,r.send=this.wrappedSend,r.setRequestHeader=this.wrappedSetRequestHeader}catch(l){}}patchRealtime(){this.patchWebSocket(),this.patchEventSource()}wrapRealtime(t,r,i){if(t.__bugTap)return null;const n=this,s=function(o,a){const c=i(o,a);try{n.observeRealtime(c,r,String(o))}catch(l){}return c};return Object.setPrototypeOf(s,t),s.prototype=t.prototype,s.__bugTap=!0,s}patchWebSocket(){if(typeof window=="undefined"||typeof window.WebSocket!="function")return;const t=window.WebSocket,r=this.wrapRealtime(t,"websocket",(i,n)=>n===void 0?new t(i):new t(i,n));if(r){this.originalWebSocket=t,this.wrappedWebSocket=r;try{window.WebSocket=this.wrappedWebSocket}catch(i){this.originalWebSocket=null,this.wrappedWebSocket=null}}}patchEventSource(){if(typeof window=="undefined"||typeof window.EventSource!="function")return;const t=window.EventSource,r=this.wrapRealtime(t,"eventsource",(i,n)=>n===void 0?new t(i):new t(i,n));if(r){this.originalEventSource=t,this.wrappedEventSource=r;try{window.EventSource=this.wrappedEventSource}catch(i){this.originalEventSource=null,this.wrappedEventSource=null}}}observeRealtime(t,r,i){if(this.started===!1)return;const n=N(i);if(this.skipped(n))return;const s=this.nextId(),o=R(),a=Date.now();this.pushRecord({id:s,type:r,method:r==="websocket"?"WS":"SSE",url:n,durationMs:0,timestamp:a});const c=l=>{if(this.started)try{this.buffer.update(u=>u.id===s,u=>({...u,...l,durationMs:Math.round(R()-o)}))}catch(u){}};try{t.addEventListener("open",()=>c({ok:!0,error:void 0})),t.addEventListener("error",()=>c({ok:!1,error:r==="websocket"?"WebSocket error":"EventSource error"})),t.addEventListener("close",l=>{const u=l,h=typeof u.code=="number"?u.code:void 0,d=typeof u.reason=="string"?u.reason:"";c({status:h,ok:h===1e3||h===1005,error:h!==void 0&&h!==1e3&&h!==1005?`closed (${h}${d?`: ${d}`:""})`:void 0})})}catch(l){}}bodyOf(t){if(this.options.captureBody)return Ci(t)}requestHeadersOf(t,r){if(this.requestHeaderAllow!==!0&&this.requestHeaderAllow.length===0)return;const i=at(t,this.requestHeaderAllow),n=typeof Request!="undefined"&&r instanceof Request?at(r.headers,this.requestHeaderAllow):void 0;return Oi(n,i)}xhrResponseHeaders(t){try{let r;if(this.responseHeaderAllow===!0){const n=t.getAllResponseHeaders?t.getAllResponseHeaders():"";if(n)return _i(n,!0);r=[...Z]}else r=this.responseHeaderAllow;const i={};for(const n of r){const s=t.getResponseHeader(n);s&&T(i,n,s,!0)}return Object.keys(i).length>0?i:void 0}catch(r){return}}textOf(t){return t||void 0}observeResponse(t,r){var n;const{reqBodyLater:i}=r;try{const s={id:r.id,type:"fetch",method:r.method,url:r.url,status:t.status,ok:t.ok,durationMs:Math.round(R()-r.start),timestamp:r.timestamp,contentType:t.headers.get("content-type")||void 0,reqHeaders:r.reqHeaders,resHeaders:at(t.headers,this.responseHeaderAllow)};if(!this.options.captureBody){this.recordWithBody(s,i);return}const o=Number(t.headers.get("content-length")||0);if(!pr((n=s.contentType)!=null?n:null,o,this.options.maxCloneBytes)){this.recordWithBody(s,i);return}let a;try{a=t.clone()}catch(l){this.recordWithBody(s,i);return}const c=a.body;if(!c||typeof TextDecoder=="undefined"){a.text().then(l=>this.recordWithBody({...s,resBody:this.textOf(wt(l,this.options.maxCloneBytes))},i),()=>this.recordWithBody(s,i));return}this.recordStreaming(s,i,Ue(c,this.options.maxCloneBytes))}catch(s){}}requestBodyOf(t){if(!t.body)return Promise.resolve(void 0);try{const r=t.clone().body;return!r||typeof TextDecoder=="undefined"?Promise.resolve(void 0):Ue(r,this.options.maxCloneBytes).then(i=>this.textOf(i),()=>{})}catch(r){return Promise.resolve(void 0)}}recordStreaming(t,r,i){const n=this.recordWithBody(t,r);Promise.all([n,i.catch(()=>"")]).then(([,s])=>{if(!this.started)return;const o=this.textOf(s);o&&this.buffer.update(a=>a.id===t.id,a=>a.resBody?a:{...a,resBody:o})}).catch(()=>{})}record(t){this.recordWithBody(t,Promise.resolve(t.reqBody))}recordWithBody(t,r){return r.catch(()=>{}).then(i=>{this.started&&this.pushRecord(i?{...t,reqBody:i}:t)})}pushRecord(t){try{if(!t.url||t.url.startsWith("data:")||t.url.startsWith("blob:")||this.skipped(t.url))return;if(this.buffer.push({...t}),this.listener)try{this.listener(t)}catch(r){}}catch(r){}}nextId(){return this.seq+=1,`n${Date.now().toString(36)}${this.seq}`}}function ji(){try{if(typeof performance=="undefined")return 0;const e=typeof performance.timeOrigin=="number"?performance.timeOrigin:0,t=typeof performance.getEntriesByType=="function"?performance.getEntriesByType("navigation")[0]:void 0;if(e>0){const r=t&&Number.isFinite(t.startTime)&&t.startTime>0?t.startTime:0;return e+r}if(typeof performance.now=="function"){const r=performance.now();if(Number.isFinite(r)&&r>=0)return Date.now()-r}}catch(e){}return 0}function zi(e){const t=Math.max(1024,Math.floor((e.transport.maxItemBytes-32768)/2));return Math.min(e.collect.maxCloneBytes,t)}class ze{constructor(t){this.config=t,this.consoleCollector=null,this.errorCollector=null,this.networkCollector=null,this.breadcrumbCollector=null,this.browserApiErrors=null,this.startedAt=0}start(){var r,i;const t=this.config;this.startedAt=Date.now(),t.collect.console&&(this.consoleCollector=new gi({max:t.collect.maxConsoleLogs,excludePatterns:t.privacy.excludeConsolePatterns}),this.consoleCollector.start()),this.errorCollector=new xi({max:t.collect.maxErrors,ignoreErrors:t.filtering.ignoreErrors,denyUrls:t.filtering.denyUrls,allowUrls:t.filtering.allowUrls,resourceErrors:t.collect.resourceErrors}),t.collect.error&&(this.errorCollector.start(),this.browserApiErrors=new ui({capture:(n,s)=>{var o;return(o=this.errorCollector)==null?void 0:o.captureFromBrowserApi(n,s)},eventListeners:t.collect.eventListenerErrors}),this.browserApiErrors.start()),t.collect.network&&(this.networkCollector=new Ui({max:t.collect.maxNetworkRecords,excludeUrls:t.privacy.excludeUrls,selfUrls:[t.endpoint,t.upload.url],captureBody:t.collect.networkBody,realtime:t.collect.realtime,requestHeaders:t.collect.requestHeaders,responseHeaders:t.collect.responseHeaders,maxBytes:t.collect.maxNetworkBytes,maxCloneBytes:zi(t)}),this.networkCollector.start()),t.collect.breadcrumbs&&(this.breadcrumbCollector=new si({max:t.collect.maxBreadcrumbs,dom:!0,navigation:!0,network:t.collect.network,error:t.collect.error,excludeUrls:t.privacy.excludeBreadcrumbUrls,beforeBreadcrumb:t.hooks.beforeBreadcrumb}),this.breadcrumbCollector.start(),(r=this.networkCollector)==null||r.setListener(n=>{var s;return(s=this.breadcrumbCollector)==null?void 0:s.addNetwork(n)}),(i=this.errorCollector)==null||i.setListener(n=>{var s;return(s=this.breadcrumbCollector)==null?void 0:s.addError({message:n.message,timestamp:n.timestamp,count:n.count})}))}stop(){var t,r,i,n,s;(t=this.consoleCollector)==null||t.stop(),(r=this.browserApiErrors)==null||r.stop(),(i=this.errorCollector)==null||i.stop(),(n=this.networkCollector)==null||n.stop(),(s=this.breadcrumbCollector)==null||s.stop(),this.consoleCollector=null,this.errorCollector=null,this.browserApiErrors=null,this.networkCollector=null,this.breadcrumbCollector=null}getData(){const t=this.networkCollector?this.networkCollector.getRecords():[],r=this.consoleCollector?this.consoleCollector.getLogs():[],i=this.errorCollector?this.errorCollector.getErrors():[],n=this.networkCollector?this.networkCollector.getPatchState():{fetch:!1,xhr:!1,websocket:!1,eventsource:!1},s=ji(),o=this.breadcrumbCollector?this.breadcrumbCollector.getBreadcrumbs():void 0;return{logs:r,errors:i,network:t,networkDropped:this.networkCollector?this.networkCollector.getDropped():void 0,collector:{startedAt:this.startedAt,earlyGapMs:s>0&&this.startedAt>s?Math.round(this.startedAt-s):0,patched:{console:this.consoleCollector?this.consoleCollector.getPatchState():!1,fetch:n.fetch,xhr:n.xhr,error:this.errorCollector?this.errorCollector.getPatchState():!1,websocket:n.websocket,eventsource:n.eventsource},counts:{logs:r.length,errors:i.length,network:t.length,breadcrumbs:o?o.length:0},breadcrumbLimit:this.breadcrumbCollector?this.breadcrumbCollector.limit:void 0,breadcrumbEvicted:this.breadcrumbCollector?this.breadcrumbCollector.evicted:void 0},breadcrumbs:o}}clear(){var t,r,i,n;(t=this.consoleCollector)==null||t.clear(),(r=this.errorCollector)==null||r.clear(),(i=this.networkCollector)==null||i.clear(),(n=this.breadcrumbCollector)==null||n.clear()}captureException(t,r){var i;(i=this.errorCollector)==null||i.captureException(t,r)}captureMessage(t,r){var i;(i=this.errorCollector)==null||i.captureMessage(t,r)}addBreadcrumb(t){var r;(r=this.breadcrumbCollector)==null||r.add(t)}disableRouteCapture(){var t;(t=this.breadcrumbCollector)==null||t.disableNavigationCapture()}}const De="__mcl_session_track__",ct="_xys_s_id",vt=2628e4,Ne="abcdefhijklmnopqrstuvwxyz1234567890",Di=/^cps.*\.(xinhulu|cxmuc)\.com$|^.+\.(kachabao|kachabao100)\.com$/;function gr(){try{return typeof location!="undefined"?location.host:""}catch(e){return""}}function mr(e){return/^niubao.*\.(xinhulu|cxmuc)\.com$/.test(e)||/^.+\.(niubao100|baichuan100)\.com$/.test(e)}function Ni(e){return Di.test(e)}function rt(e){try{const t=new RegExp("(?:^|;+|\\s+)"+e+"=([^;]*)"),r=document.cookie.match(t);return r&&r[1]?r[1]:""}catch(t){return""}}function xt(e,t,r){try{const i=new Date;i.setMinutes(i.getMinutes()+r),document.cookie=`${e}=${escape(t)};expires=${i.toUTCString()};path=/`}catch(i){}}function qi(e){try{if(typeof localStorage!="undefined")return localStorage.getItem(e)}catch(t){}return rt(e)}function Fi(e,t){try{if(typeof localStorage!="undefined"){localStorage.setItem(e,t);return}}catch(r){}xt(e,t,vt)}function qe(e){let t="";for(let r=0;r<e;r+=1)t+=Ne.charAt(Math.floor(Math.random()*Ne.length));return t}function Wi(){const e=gr();let t="xxid";return Ni(e)?t="cps_xxid":mr(e)&&(t="niubao_xxid"),rt(t)}function Xi(){return mr(gr())?rt("niubao_subid"):null}function Vi(){let e=qi(De);const t=rt(ct);return e?(e!==t&&xt(ct,e,vt),e):(t?e=t:(e=qe(24)+qe(8),xt(ct,e,vt)),Fi(De,e),e)}function br(){try{const e=window.tongji;return e&&typeof e=="object"?e:null}catch(e){return null}}function lt(e,t){let r;if(typeof e=="function")try{r=e.call(br())}catch(i){}if((r==null||r==="")&&(r=t()),!(r==null||r===""))return String(r)}let Et,J=0;const Yi=3e4;function Ki(){if(typeof document=="undefined")return;const e=Date.now();if(J>0&&e-J<Yi)return Et;try{const t=br(),r=lt(t==null?void 0:t.getXid,Wi),i=lt(t==null?void 0:t.getSubId,Xi),n=lt(t==null?void 0:t.getSessionId,Vi),s=r||i||n?{xid:r,subId:i,sessionId:n}:void 0;return Et=s,J=e,s}catch(t){return}}function Gi(){Et=void 0,J=0}function Fe(e,t){for(const[r,i]of t){const n=e.match(r);if(n)return{name:i,version:n[1]}}return null}function Ji(e){const t=String(e||""),r=Fe(t,[[/MicroMessenger\/([\d.]+)/i,"WeChat"],[/AlipayClient\/([\d.]+)/i,"Alipay"],[/Edg\/([\d.]+)/i,"Edge"],[/OPR\/([\d.]+)/i,"Opera"],[/Firefox\/([\d.]+)/i,"Firefox"],[/Chrome\/([\d.]+)/i,"Chrome"],[/Version\/([\d.]+).*Safari/i,"Safari"],[/MSIE ([\d.]+)/i,"IE"],[/Trident\/.*rv:([\d.]+)/i,"IE"]]),i=Fe(t,[[/HarmonyOS/i,"HarmonyOS"],[/Windows NT 10\.0/i,"Windows"],[/Windows NT/i,"Windows"],[/Android[ /]([\d.]+)/i,"Android"],[/(?:iPhone|iPad|iPod).*OS ([\d_]+)/i,"iOS"],[/Mac OS X/i,"macOS"],[/Linux/i,"Linux"]]);return{browser:r==null?void 0:r.name,browserVersion:r==null?void 0:r.version,os:i==null?void 0:i.name}}function yr(){return{url:location.href,referrer:document.referrer&&document.referrer!==location.href?document.referrer:void 0,title:document.title||void 0}}function wr(e){const t=Number.isFinite(e)&&e>0?e:1;return Math.round(t*100)/100}function Qi(e,t,r){return`${e||0}*${t||0} @ ${wr(r)}x`}function Zi(e){const t=navigator.userAgent,r=Ji(t);let i="";try{i=Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch(c){i=""}const n=typeof window.screen!="undefined"?window.screen:void 0,s=n&&(n.width||n.availWidth)||0,o=n&&(n.height||n.availHeight)||0,a=wr(window.devicePixelRatio||1);return{userAgent:t,platform:navigator.platform||void 0,browser:r.browser,browserVersion:r.browserVersion,os:r.os,screenWidth:s,screenHeight:o,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,dpr:a,device:Qi(s,o,a),language:navigator.language||"",timezone:i}}function tn(e){return{page:yr(),browser:Zi()}}const en=30,We=200;function rn(e){if(!e)return;let t=e;if(typeof e=="function")try{t=e()}catch(s){return}const r=or(t);if(!r||typeof r=="function")return;const i={};let n=0;for(const s of Object.keys(r)){if(n>=en)break;const o=String(r[s]).trim();o&&(i[s]=o.length>We?o.slice(0,We):o,n+=1)}return n>0?i:void 0}const nn=200,sn=5e3,x=15e5;function L(e,t){return e.length>t?e.slice(0,t):e}function vr(e){return((String(e||"").split(`
11
- `)[0]||"").trim()||"页面反馈").slice(0,60)}function on(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}return`r${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`}const an={userAgent:"",screenWidth:0,screenHeight:0,viewportWidth:0,viewportHeight:0,dpr:1,device:"0*0 @ 1x",language:"",timezone:""};function ut(e){return e&&e.length>0?e:void 0}function cn(e){const{values:t,data:r,config:i}=e,n=i.collect.environment?tn():{page:yr(),browser:{...an}},s=L(String(t.description||"").trim(),sn),o=L(String(t.title||"").trim()||vr(s),nn),a=ln(e.elements,i.collect.maxElements),c={project:i.project,environment:i.environment,title:o,description:s,category:t.category?L(String(t.category),40):void 0,severity:t.severity?L(String(t.severity),20):void 0,contact:t.contact?L(String(t.contact),200):void 0,user:rn(i.user),track:i.collect.trackIds?Ki():void 0,page:n.page,browser:n.browser,logs:r.logs,errors:r.errors,network:r.network,networkDropped:hn(r,i.collect.network),screenshots:ut(e.screenshots),elements:ut(a),breadcrumbs:ut(r.breadcrumbs),collector:r.collector,app:un(i),release:i.release||void 0,tags:ht(e.tags),extra:ht(e.extra),contexts:ht(e.contexts),timestamp:Date.now(),sdkVersion:"0.1.0",clientReportId:e.clientReportId||on()};return fn(c)}function ln(e,t){if(!(!e||e.length===0))return e.slice(-Math.max(1,t)).map(r=>{const i={};return Object.keys(r.attributes||{}).slice(0,20).forEach(n=>{var s;i[n]=L(String((s=r.attributes[n])!=null?s:""),200)}),{...r,selector:L(r.selector,300),text:r.text?L(r.text,200):void 0,attributes:i,path:L(r.path,300)}})}function ht(e){return e&&Object.keys(e).length>0?e:void 0}function un(e){if(!(!e.appVersion&&!e.buildId))return{version:e.appVersion||void 0,buildId:e.buildId||void 0}}function hn(e,t){if(!t)return{droppedCount:0,droppedBytes:0,evictedCount:0,evictedBytes:0,totalCount:null,sentCount:0};const r=e.networkDropped||{droppedCount:0,droppedBytes:0,evictedCount:0,evictedBytes:0},i=hr(r);return{...r,totalCount:i+e.network.length,sentCount:e.network.length}}function A(e){return B(e,x+1)}function dn(e){return e.map(t=>B(t,x+1)+1)}function j(e,t,r,i){const n=e[t];if(!n||n.length<=r)return;const s=dn(n),o=B({...e,[t]:[]},x+1),a=new Array(n.length+1);a[0]=0;for(let u=0;u<s.length;u+=1)a[u+1]=(a[u]||0)+(s[u]||0);const c=a[n.length]||0;let l=0;for(;n.length-l>r;){const u=n.length-l;if(o+(c-(a[l]||0))-1<=x)break;l+=Math.max(1,Math.min(i(u),u-r))}l>0&&(e[t]=n.slice(l))}function X(e){return t=>Math.ceil(t/e)}function Xe(e,t){return e.map(r=>t&&!t(r)?r:{...r,reqBody:void 0,resBody:void 0})}function fn(e){if(A(e)<=x)return e;const t=e.network.length;if(e.network=Xe(e.network,Zr),A(e)<=x||(e.network=Xe(e.network),A(e)<=x))return dt(e,t);if(j(e,"network",0,X(8)),j(e,"logs",0,X(4)),j(e,"errors",0,X(2)),e.screenshots&&A(e)>x){const i=e.screenshots.filter(n=>n.source==="manual");i.length>0?e.screenshots=i:delete e.screenshots}return Ve(e,"extra"),Ve(e,"contexts"),j(e,"elements",1,()=>1),e.elements&&A(e)>x&&delete e.elements,j(e,"breadcrumbs",10,X(2)),e.screenshots&&A(e)>x&&delete e.screenshots,pn(e),gn(e),dt(e,t)}function Ve(e,t){const r=e[t];if(!r)return;const i=Object.keys(r);for(;i.length>0&&A(e)>x;){const n=i.shift();if(n===void 0)break;delete r[n]}Object.keys(r).length===0&&delete e[t]}function pn(e){if(!e.breadcrumbs||e.breadcrumbs.length===0)return;const t=new Set(e.network.map(r=>r.id));e.breadcrumbs=e.breadcrumbs.map(r=>r.type!=="http"||!r.ref||t.has(r.ref)?r:{...r,ref:void 0,httpError:r.httpError||"[record trimmed]"})}function gn(e){e.collector&&(e.collector={...e.collector,counts:{logs:e.logs.length,errors:e.errors.length,network:e.network.length,breadcrumbs:e.breadcrumbs?e.breadcrumbs.length:0}})}function dt(e,t){const r=t-e.network.length;return e.networkDropped&&(e.networkDropped={...e.networkDropped,trimmedCount:r,sentCount:e.network.length}),e}const mn=200,bn=500,Ye=32,M=64,yn=512;function k(e,t){const r=String(e!=null?e:"").replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t)}…`:r}function wn(e){return e.severity==="normal"?2:3}function vn(e,t){return t===1||t===2||t===3?t:wn(e)}function xn(e){return(e.clientReportId.replace(/[^0-9a-zA-Z]/g,"")+"0".repeat(Ye)).slice(0,Ye)}function En(e){let t=e.browser.userAgent;return!t&&typeof navigator!="undefined"&&(t=navigator.userAgent),`H5, ${t||"unknown userAgent"}`}function xr(e){return e.page.url?e.page.url:typeof location!="undefined"?location.href:""}function Sn(e){var a;const t=e.errors;let r=t.findIndex(c=>c.type!=="resource"&&!!c.stack);r<0&&(r=t.findIndex(c=>c.type!=="resource")),r<0&&(r=t.length>0?0:-1);const i=r>=0?t[r]:void 0,n=i&&(((a=Ct(i.stack))==null?void 0:a.url)||i.filename)||"",s=i?`${i.type}|${i.message}|${n}`:`feedback|${e.project}|${e.title}`;let o=2166136261;for(let c=0;c<s.length;c+=1)o^=s.charCodeAt(c),o=Math.imul(o,16777619);return{primaryIndex:r,fingerprint:`bt-${(o>>>0).toString(16).padStart(8,"0")}`}}function kn(e){if(!e)return"";const t=Object.keys(e).slice(0,5).map(r=>`${r}=${k(e[r],M)}`);return t.length>0?` ${t.join(" ")}`:""}function Cn(e,t,r){var g,b;const i=k(e.title,mn),n=k(e.description,bn),s=n&&n===i?"":n,o=hr(e.networkDropped),a=Tn(e.user),c=Ln(e.track),l=e.collector?Math.round(e.collector.earlyGapMs):0,u=Rn(e),h=((g=e.collector)==null?void 0:g.breadcrumbEvicted)||0,d=((b=e.networkDropped)==null?void 0:b.totalCount)===null,p=["【Bug反馈】",i||"(无标题)",s?` | ${s}`:"",e.elements&&e.elements.length>0?` | element=${e.elements.map(m=>m.selector).join(",")}`:"",` | project=${e.project}`,` env=${e.environment}`,a?` user=${a}`:"",c,e.release?` release=${k(e.release,M)}`:"",` fp=${t.fingerprint}`,kn(e.tags),` reportId=${e.clientReportId}`,d?" | networkDisabled":"",o>0?` | networkDropped=${o}`:"",l>0?` | earlyGap=${l}ms`:"",h>0?` | timelineEvicted=${h}`:"",u?` | ${u}`:""].join("");return!r||r.total<=1?p:`${p} | part=${r.index}/${r.total}`}function Ln(e){if(!e)return"";const t=[];return e.xid&&t.push(`xid=${k(e.xid,M)}`),e.subId&&t.push(`subId=${k(e.subId,M)}`),e.sessionId&&t.push(`si=${k(e.sessionId,M)}`),t.length>0?` ${t.join(" ")}`:""}function Rn(e){if(!e.app)return"";const t=[];return e.app.version&&t.push(`app=${k(e.app.version,M)}`),e.app.buildId&&t.push(`build=${k(e.app.buildId,M)}`),t.join(" ")}function Tn(e){var r,i,n,s;if(!e)return"";const t=(s=(n=(i=(r=e.id)!=null?r:e.name)!=null?i:e.userId)!=null?n:e.account)!=null?s:Object.values(e)[0];return t===void 0?"":k(t,M)}function Mn(e){const t={...e.page};return(!t.url||t.url===xr(e))&&delete t.url,t}function An(e,t){return{project:e.project,environment:e.environment,sdkVersion:e.sdkVersion,clientReportId:e.clientReportId,release:e.release,fingerprint:t.fingerprint,primaryErrorIndex:t.primaryIndex,title:e.title,description:e.description,category:e.category,severity:e.severity,contact:e.contact,user:e.user,track:e.track,page:Mn(e),browser:e.browser,networkDropped:e.networkDropped,collector:e.collector,app:e.app,breadcrumbs:e.breadcrumbs,tags:e.tags,extra:e.extra,contexts:e.contexts}}function Pn(e){return B(e)+1}function tt(){return{network:[],errors:[],logs:[],bytes:0}}function Bn(e,t){const r=[tt()];let i=t;const n=(a,c)=>{for(const l of a){const u=Pn(l),h=r[r.length-1],d=h.network.length+h.errors.length+h.logs.length;u>i&&d>0&&(r.push(tt()),i=t);const p=r[r.length-1];p[c].push(l),p.bytes+=u,i-=u}},s=[],o=[];for(const a of e.network)(ur(a)?s:o).push(a);return n(s,"network"),n(e.errors,"errors"),n(o,"network"),n(e.logs,"logs"),r}function In(e,t,r){const i=Sn(e),n=An(e,i),s=e.screenshots&&e.screenshots.length>0?e.screenshots:void 0,o=e.elements&&e.elements.length>0?e.elements:void 0,a=o?B(o):0,c=B(n)+yn+(s?B(s):0),l=Math.max(1024,t-c),u=Bn(e,l),h=u.length>0?u:[tt()];let d=-1;return o&&(c+h[0].bytes+a+1<=t?d=0:(h.push(tt()),d=h.length-1)),h.map((p,g)=>{const b={...n};return b.network=p.network.slice().sort((m,I)=>m.timestamp-I.timestamp),b.errors=p.errors,b.logs=p.logs,h.length>1&&(b.part={index:g+1,total:h.length}),g===0&&s&&(b.screenshots=s),g===d&&o&&(b.elements=o),{timestamp:e.timestamp,logLevel:vn(e,r),userAgent:En(e),url:xr(e),content:Cn(e,i,{index:g+1,total:h.length}),traceId:xn(e),ext:JSON.stringify(b)}})}const $n="bug-tap",E="pending",On=1;function _n(){return typeof indexedDB=="undefined"?Promise.resolve(null):new Promise(e=>{try{const t=indexedDB.open($n,On);t.onupgradeneeded=()=>{const r=t.result;r.objectStoreNames.contains(E)||r.createObjectStore(E,{keyPath:"id"})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch(t){e(null)}})}class Hn{constructor(t){this.options=t,this.memory=[],this.db=null}database(){return this.db||(this.db=_n()),this.db}enqueue(t){return this.database().then(r=>{if(!r){this.putMemory(t);return}return this.put(r,t).then(i=>(i||this.putMemory(t),this.prune(r)))})}put(t,r){return new Promise(i=>{try{const n=t.transaction(E,"readwrite");n.objectStore(E).put(r),n.oncomplete=()=>i(!0),n.onerror=()=>i(!1),n.onabort=()=>i(!1)}catch(n){i(!1)}})}prune(t){return new Promise(r=>{try{const i=t.transaction(E,"readwrite"),n=i.objectStore(E),s=n.getAll();s.onsuccess=()=>{const o=(s.result||[]).sort((u,h)=>u.createdAt-h.createdAt),a=[],c=[];for(const u of o)(this.isExpired(u)?a:c).push(u);const l=Math.max(0,c.length-this.options.maxItems);a.concat(c.slice(0,l)).forEach(u=>{try{n.delete(u.id)}catch(h){}})},s.onerror=()=>r(),i.oncomplete=()=>r(),i.onerror=()=>r(),i.onabort=()=>r()}catch(i){r()}})}peek(){return this.database().then(t=>t?new Promise(r=>{try{const n=t.transaction(E,"readonly").objectStore(E).getAll();n.onsuccess=()=>{const s=n.result||[],o=new Set(s.map(c=>c.id)),a=s.concat(this.memory.filter(c=>!o.has(c.id)));r(a.filter(c=>!this.isExpired(c)).sort((c,l)=>c.createdAt-l.createdAt))},n.onerror=()=>r(this.memoryItems())}catch(i){r(this.memoryItems())}}):this.memoryItems())}memoryItems(){return this.memory.filter(t=>!this.isExpired(t)).sort((t,r)=>t.createdAt-r.createdAt)}remove(t){const r=this.memory.findIndex(i=>i.id===t);return r>=0&&this.memory.splice(r,1),this.database().then(i=>{if(i)return new Promise(n=>{try{const s=i.transaction(E,"readwrite");s.objectStore(E).delete(t),s.oncomplete=()=>n(),s.onerror=()=>n(),s.onabort=()=>n()}catch(s){n()}})})}size(){return this.peek().then(t=>t.length)}isExpired(t){return Date.now()-t.createdAt>this.options.ttlMs}trimMemory(){const t=this.memory.filter(r=>!this.isExpired(r));this.memory.length=0,this.memory.push(...t.slice(-this.options.maxItems))}putMemory(t){const r=this.memory.findIndex(i=>i.id===t.id);r>=0&&this.memory.splice(r,1),this.memory.push(t),this.trimMemory()}}class w extends Error{constructor(t,r){super(t),this.name="TransportError",this.failure=r.failure,this.status=r.status,this.retryable=r.retryable,this.details=r.details,this.retryAfterMs=r.retryAfterMs,this.queued=r.queued}asQueued(){return new w(this.message,{failure:this.failure,status:this.status,retryable:this.retryable,details:this.details,retryAfterMs:this.retryAfterMs,queued:!0})}}const Un=6e4,jn=15,zn=6e4;function Dn(e){return new Promise(t=>setTimeout(t,e))}function Nn(e){return 1e3*Math.pow(3,e)+Math.floor(Math.random()*250)}function qn(e,t=Date.now()){if(!e)return;const r=parseInt(e,10);if(!isNaN(r))return r*1e3;const i=Date.parse(e);return isNaN(i)?6e4:Math.max(0,i-t)}class Ke{constructor(t){this.config=t,this.pendingCount=0,this.pendingBytes=0,this.successCount=0,this.flushing=null,this.started=!1,this.onOnline=()=>{this.flush()},this.onVisibility=()=>{document.visibilityState==="hidden"&&this.beacon()},this.onPageHide=()=>{this.beacon()};const r=t.transport.offline;this.queue=r.enabled?new Hn({ttlMs:r.ttlMs,maxItems:r.maxItems}):null}start(){this.started||typeof window=="undefined"||(this.started=!0,window.addEventListener("online",this.onOnline),window.addEventListener("pagehide",this.onPageHide),document.addEventListener("visibilitychange",this.onVisibility),this.flush())}stop(){this.started&&(this.started=!1,window.removeEventListener("online",this.onOnline),window.removeEventListener("pagehide",this.onPageHide),document.removeEventListener("visibilitychange",this.onVisibility))}send(t){const r=this.config.transport;if(r.maxReportsPerSession>0&&this.successCount>=r.maxReportsPerSession)return Promise.reject(new w(`本次会话反馈次数已达上限(${r.maxReportsPerSession} 次)`,{failure:"limited",retryable:!1}));if(this.pendingCount>=r.maxConcurrent)return Promise.reject(new w("正在提交中,请稍后重试",{failure:"busy",retryable:!1}));let i;try{i=JSON.stringify(In(t,r.maxItemBytes,r.logLevel))}catch(o){return Promise.reject(new w(`报告序列化失败:${o instanceof Error?o.message:String(o)}`,{failure:"protocol",retryable:!1,details:o}))}const n=Date.now()+r.totalTimeoutMs,s=S(i);return this.attempt(i,s,t.clientReportId,0,n,this.config.endpoint).then(o=>(this.successCount+=1,o)).catch(o=>{const a=o instanceof w?o:this.toTransportError(o);if(!this.shouldQueue(a)||!this.queue)throw a;return this.enqueue(i,s,t.clientReportId).then(()=>{throw a.asQueued()})})}flush(){return this.queue?this.flushing?this.flushing:(this.flushing=this.queue.peek().then(t=>this.flushItems(t,0)).catch(()=>0).finally(()=>{this.flushing=null}),this.flushing):Promise.resolve(0)}flushItems(t,r){var o;const i=t[r];if(!i)return Promise.resolve(0);const n=Date.now()+this.config.transport.timeoutMs,s=(o=i.size)!=null?o:S(i.body);return this.once(i.body,s,i.id,n,i.endpoint).then(()=>this.queue.remove(i.id).then(()=>this.flushItems(t,r+1).then(a=>a+1))).catch(a=>{const c=a instanceof w?a:this.toTransportError(a);return this.shouldQueue(c)?0:this.queue.remove(i.id).then(()=>this.flushItems(t,r+1))})}beacon(){if(this.queue)try{if(typeof navigator=="undefined"||typeof navigator.sendBeacon!="function")return;this.queue.peek().then(t=>{t.forEach(r=>{var i;try{const n=new Blob([r.body],{type:"application/json"});if(n.size>zn)return;navigator.sendBeacon(r.endpoint,n)&&((i=this.queue)==null||i.remove(r.id))}catch(n){}})}).catch(()=>{})}catch(t){}}enqueue(t,r,i){return this.queue?this.queue.enqueue({id:i,endpoint:N(this.config.endpoint),body:t,size:r,createdAt:Date.now()}):Promise.resolve()}shouldQueue(t){return t.failure==="network"||t.failure==="timeout"?!0:t.failure==="http"&&(t.status===429||(t.status||0)>=500)}attempt(t,r,i,n,s,o){return this.once(t,r,i,s,o).catch(a=>{const c=a instanceof w?a:this.toTransportError(a),l=this.config.transport.retries;if(n<l&&c.retryable){const u=c.retryAfterMs!==void 0?c.retryAfterMs:Nn(n);if(Date.now()+u>=s)throw this.deadlineError(s);return Dn(u).then(()=>this.attempt(t,r,i,n+1,s,o))}throw c})}deadlineError(t){return new w(`提交超时(${Math.round(this.config.transport.totalTimeoutMs/1e3)}s)`,{failure:"timeout",retryable:!1,details:{deadline:t}})}once(t,r,i,n,s){const o=n-Date.now();if(o<=0)return Promise.reject(this.deadlineError(n));const a=new AbortController,c=Math.min(this.config.transport.timeoutMs,o),l=setTimeout(()=>a.abort(),c),u={"Content-Type":"application/json",...this.config.transport.headers};this.pendingCount+=1,this.pendingBytes+=r;const h=this.pendingBytes<=Un&&this.pendingCount<jn;return fetch(s,{method:"POST",headers:u,body:t,signal:a.signal,mode:"cors",credentials:"omit",keepalive:h}).then(d=>d.text().then(p=>({response:d,text:p}))).then(({response:d,text:p})=>{let g=null;if(p)try{g=JSON.parse(p)}catch(m){g=p}if(!d.ok){const m=d.status===429||d.status>=500,I=d.status===429?qn(d.headers.get("retry-after")):void 0,q=this.extractMessage(g)||`服务端返回 HTTP ${d.status}`;throw new w(q,{failure:"http",status:d.status,retryable:m,details:g,retryAfterMs:I})}if(!g||typeof g!="object")throw new w("服务端响应不是合法 JSON",{failure:"protocol",retryable:!1,details:g});if(g.errCode!==0)throw new w(this.extractMessage(g)||"上报接口返回失败",{failure:"protocol",retryable:!1,details:g});return{success:!0,reportId:i}}).catch(d=>{throw d instanceof w?d:d instanceof DOMException&&d.name==="AbortError"?new w(`请求超时(${Math.round(c/1e3)}s)`,{failure:"timeout",retryable:!0}):new w(d instanceof Error?d.message:String(d),{failure:"network",retryable:!0})}).finally(()=>{clearTimeout(l),this.pendingCount-=1,this.pendingBytes-=r})}toTransportError(t){return new w(t instanceof Error?t.message:String(t),{failure:"network",retryable:!0})}extractMessage(t){if(!t||typeof t!="object")return"";const r=t;if(typeof r.errMsg=="string"&&r.errMsg)return r.errMsg;if(typeof r.message=="string")return r.message;const i=r.error;if(i&&typeof i=="object"){const n=i;if(typeof n.message=="string")return n.message}return""}}function Fn(e){return Object.keys(e).map(t=>{var r;return`${encodeURIComponent(t)}=${encodeURIComponent((r=e[t])!=null?r:"")}`}).join("&")}function _(e){return e instanceof Error?e.message:String(e)}function Wn(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(typeof t.url=="string")return t.url;if(typeof t.file_url=="string")return t.file_url}return""}function Xn(e,t){if(!e.dataBase64)return Promise.resolve(e.url||"");const r=new AbortController,i=setTimeout(()=>r.abort(),t.timeoutMs),n=`data:${e.mime};base64,${e.dataBase64}`,s=Fn({imgdata:n,bizid:t.bizId,name:`bug-report-${Date.now()}.jpg`});return fetch(t.url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s,credentials:"include",signal:r.signal}).then(o=>o.text().then(a=>({response:o,text:a}))).then(({response:o,text:a})=>{let c=null;try{c=JSON.parse(a)}catch(h){c=null}if(!o.ok)throw new Error(`图片上传失败:HTTP ${o.status}`);if(!c||typeof c!="object")throw new Error("图片上传接口响应不是合法 JSON");const l=c;if(l.ret!==0){const h=typeof l.errmsg=="string"?l.errmsg:"";throw new Error(h||"图片上传失败")}const u=Wn(l.data);if(!u)throw new Error("图片上传接口未返回 url");return u}).catch(o=>{throw o instanceof DOMException&&o.name==="AbortError"?new Error(`图片上传超时(${Math.round(t.timeoutMs/1e3)}s)`):new Error(_(o))}).finally(()=>clearTimeout(i))}const Ge=`
11
+ `)[0]||"").trim()||"页面反馈").slice(0,60)}function on(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}return`r${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`}const an={userAgent:"",screenWidth:0,screenHeight:0,viewportWidth:0,viewportHeight:0,dpr:1,device:"0*0 @ 1x",language:"",timezone:""};function ut(e){return e&&e.length>0?e:void 0}function cn(e){const{values:t,data:r,config:i}=e,n=i.collect.environment?tn():{page:yr(),browser:{...an}},s=L(String(t.description||"").trim(),sn),o=L(String(t.title||"").trim()||vr(s),nn),a=ln(e.elements,i.collect.maxElements),c={project:i.project,environment:i.environment,title:o,description:s,category:t.category?L(String(t.category),40):void 0,severity:t.severity?L(String(t.severity),20):void 0,contact:t.contact?L(String(t.contact),200):void 0,user:rn(i.user),track:i.collect.trackIds?Ki():void 0,page:n.page,browser:n.browser,logs:r.logs,errors:r.errors,network:r.network,networkDropped:hn(r,i.collect.network),screenshots:ut(e.screenshots),elements:ut(a),breadcrumbs:ut(r.breadcrumbs),collector:r.collector,app:un(i),release:i.release||void 0,tags:ht(e.tags),extra:ht(e.extra),contexts:ht(e.contexts),timestamp:Date.now(),sdkVersion:"0.1.1",clientReportId:e.clientReportId||on()};return fn(c)}function ln(e,t){if(!(!e||e.length===0))return e.slice(-Math.max(1,t)).map(r=>{const i={};return Object.keys(r.attributes||{}).slice(0,20).forEach(n=>{var s;i[n]=L(String((s=r.attributes[n])!=null?s:""),200)}),{...r,selector:L(r.selector,300),text:r.text?L(r.text,200):void 0,attributes:i,path:L(r.path,300)}})}function ht(e){return e&&Object.keys(e).length>0?e:void 0}function un(e){if(!(!e.appVersion&&!e.buildId))return{version:e.appVersion||void 0,buildId:e.buildId||void 0}}function hn(e,t){if(!t)return{droppedCount:0,droppedBytes:0,evictedCount:0,evictedBytes:0,totalCount:null,sentCount:0};const r=e.networkDropped||{droppedCount:0,droppedBytes:0,evictedCount:0,evictedBytes:0},i=hr(r);return{...r,totalCount:i+e.network.length,sentCount:e.network.length}}function A(e){return B(e,x+1)}function dn(e){return e.map(t=>B(t,x+1)+1)}function j(e,t,r,i){const n=e[t];if(!n||n.length<=r)return;const s=dn(n),o=B({...e,[t]:[]},x+1),a=new Array(n.length+1);a[0]=0;for(let u=0;u<s.length;u+=1)a[u+1]=(a[u]||0)+(s[u]||0);const c=a[n.length]||0;let l=0;for(;n.length-l>r;){const u=n.length-l;if(o+(c-(a[l]||0))-1<=x)break;l+=Math.max(1,Math.min(i(u),u-r))}l>0&&(e[t]=n.slice(l))}function X(e){return t=>Math.ceil(t/e)}function Xe(e,t){return e.map(r=>t&&!t(r)?r:{...r,reqBody:void 0,resBody:void 0})}function fn(e){if(A(e)<=x)return e;const t=e.network.length;if(e.network=Xe(e.network,Zr),A(e)<=x||(e.network=Xe(e.network),A(e)<=x))return dt(e,t);if(j(e,"network",0,X(8)),j(e,"logs",0,X(4)),j(e,"errors",0,X(2)),e.screenshots&&A(e)>x){const i=e.screenshots.filter(n=>n.source==="manual");i.length>0?e.screenshots=i:delete e.screenshots}return Ve(e,"extra"),Ve(e,"contexts"),j(e,"elements",1,()=>1),e.elements&&A(e)>x&&delete e.elements,j(e,"breadcrumbs",10,X(2)),e.screenshots&&A(e)>x&&delete e.screenshots,pn(e),gn(e),dt(e,t)}function Ve(e,t){const r=e[t];if(!r)return;const i=Object.keys(r);for(;i.length>0&&A(e)>x;){const n=i.shift();if(n===void 0)break;delete r[n]}Object.keys(r).length===0&&delete e[t]}function pn(e){if(!e.breadcrumbs||e.breadcrumbs.length===0)return;const t=new Set(e.network.map(r=>r.id));e.breadcrumbs=e.breadcrumbs.map(r=>r.type!=="http"||!r.ref||t.has(r.ref)?r:{...r,ref:void 0,httpError:r.httpError||"[record trimmed]"})}function gn(e){e.collector&&(e.collector={...e.collector,counts:{logs:e.logs.length,errors:e.errors.length,network:e.network.length,breadcrumbs:e.breadcrumbs?e.breadcrumbs.length:0}})}function dt(e,t){const r=t-e.network.length;return e.networkDropped&&(e.networkDropped={...e.networkDropped,trimmedCount:r,sentCount:e.network.length}),e}const mn=200,bn=500,Ye=32,M=64,yn=512;function k(e,t){const r=String(e!=null?e:"").replace(/\s+/g," ").trim();return r.length>t?`${r.slice(0,t)}…`:r}function wn(e){return e.severity==="normal"?2:3}function vn(e,t){return t===1||t===2||t===3?t:wn(e)}function xn(e){return(e.clientReportId.replace(/[^0-9a-zA-Z]/g,"")+"0".repeat(Ye)).slice(0,Ye)}function En(e){let t=e.browser.userAgent;return!t&&typeof navigator!="undefined"&&(t=navigator.userAgent),`H5, ${t||"unknown userAgent"}`}function xr(e){return e.page.url?e.page.url:typeof location!="undefined"?location.href:""}function Sn(e){var a;const t=e.errors;let r=t.findIndex(c=>c.type!=="resource"&&!!c.stack);r<0&&(r=t.findIndex(c=>c.type!=="resource")),r<0&&(r=t.length>0?0:-1);const i=r>=0?t[r]:void 0,n=i&&(((a=Ct(i.stack))==null?void 0:a.url)||i.filename)||"",s=i?`${i.type}|${i.message}|${n}`:`feedback|${e.project}|${e.title}`;let o=2166136261;for(let c=0;c<s.length;c+=1)o^=s.charCodeAt(c),o=Math.imul(o,16777619);return{primaryIndex:r,fingerprint:`bt-${(o>>>0).toString(16).padStart(8,"0")}`}}function kn(e){if(!e)return"";const t=Object.keys(e).slice(0,5).map(r=>`${r}=${k(e[r],M)}`);return t.length>0?` ${t.join(" ")}`:""}function Cn(e,t,r){var g,b;const i=k(e.title,mn),n=k(e.description,bn),s=n&&n===i?"":n,o=hr(e.networkDropped),a=Tn(e.user),c=Ln(e.track),l=e.collector?Math.round(e.collector.earlyGapMs):0,u=Rn(e),h=((g=e.collector)==null?void 0:g.breadcrumbEvicted)||0,d=((b=e.networkDropped)==null?void 0:b.totalCount)===null,p=["【Bug反馈】",i||"(无标题)",s?` | ${s}`:"",e.elements&&e.elements.length>0?` | element=${e.elements.map(m=>m.selector).join(",")}`:"",` | project=${e.project}`,` env=${e.environment}`,a?` user=${a}`:"",c,e.release?` release=${k(e.release,M)}`:"",` fp=${t.fingerprint}`,kn(e.tags),` reportId=${e.clientReportId}`,d?" | networkDisabled":"",o>0?` | networkDropped=${o}`:"",l>0?` | earlyGap=${l}ms`:"",h>0?` | timelineEvicted=${h}`:"",u?` | ${u}`:""].join("");return!r||r.total<=1?p:`${p} | part=${r.index}/${r.total}`}function Ln(e){if(!e)return"";const t=[];return e.xid&&t.push(`xid=${k(e.xid,M)}`),e.subId&&t.push(`subId=${k(e.subId,M)}`),e.sessionId&&t.push(`si=${k(e.sessionId,M)}`),t.length>0?` ${t.join(" ")}`:""}function Rn(e){if(!e.app)return"";const t=[];return e.app.version&&t.push(`app=${k(e.app.version,M)}`),e.app.buildId&&t.push(`build=${k(e.app.buildId,M)}`),t.join(" ")}function Tn(e){var r,i,n,s;if(!e)return"";const t=(s=(n=(i=(r=e.id)!=null?r:e.name)!=null?i:e.userId)!=null?n:e.account)!=null?s:Object.values(e)[0];return t===void 0?"":k(t,M)}function Mn(e){const t={...e.page};return(!t.url||t.url===xr(e))&&delete t.url,t}function An(e,t){return{project:e.project,environment:e.environment,sdkVersion:e.sdkVersion,clientReportId:e.clientReportId,release:e.release,fingerprint:t.fingerprint,primaryErrorIndex:t.primaryIndex,title:e.title,description:e.description,category:e.category,severity:e.severity,contact:e.contact,user:e.user,track:e.track,page:Mn(e),browser:e.browser,networkDropped:e.networkDropped,collector:e.collector,app:e.app,breadcrumbs:e.breadcrumbs,tags:e.tags,extra:e.extra,contexts:e.contexts}}function Pn(e){return B(e)+1}function tt(){return{network:[],errors:[],logs:[],bytes:0}}function Bn(e,t){const r=[tt()];let i=t;const n=(a,c)=>{for(const l of a){const u=Pn(l),h=r[r.length-1],d=h.network.length+h.errors.length+h.logs.length;u>i&&d>0&&(r.push(tt()),i=t);const p=r[r.length-1];p[c].push(l),p.bytes+=u,i-=u}},s=[],o=[];for(const a of e.network)(ur(a)?s:o).push(a);return n(s,"network"),n(e.errors,"errors"),n(o,"network"),n(e.logs,"logs"),r}function In(e,t,r){const i=Sn(e),n=An(e,i),s=e.screenshots&&e.screenshots.length>0?e.screenshots:void 0,o=e.elements&&e.elements.length>0?e.elements:void 0,a=o?B(o):0,c=B(n)+yn+(s?B(s):0),l=Math.max(1024,t-c),u=Bn(e,l),h=u.length>0?u:[tt()];let d=-1;return o&&(c+h[0].bytes+a+1<=t?d=0:(h.push(tt()),d=h.length-1)),h.map((p,g)=>{const b={...n};return b.network=p.network.slice().sort((m,I)=>m.timestamp-I.timestamp),b.errors=p.errors,b.logs=p.logs,h.length>1&&(b.part={index:g+1,total:h.length}),g===0&&s&&(b.screenshots=s),g===d&&o&&(b.elements=o),{timestamp:e.timestamp,logLevel:vn(e,r),userAgent:En(e),url:xr(e),content:Cn(e,i,{index:g+1,total:h.length}),traceId:xn(e),ext:JSON.stringify(b)}})}const $n="bug-tap",E="pending",On=1;function _n(){return typeof indexedDB=="undefined"?Promise.resolve(null):new Promise(e=>{try{const t=indexedDB.open($n,On);t.onupgradeneeded=()=>{const r=t.result;r.objectStoreNames.contains(E)||r.createObjectStore(E,{keyPath:"id"})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch(t){e(null)}})}class Hn{constructor(t){this.options=t,this.memory=[],this.db=null}database(){return this.db||(this.db=_n()),this.db}enqueue(t){return this.database().then(r=>{if(!r){this.putMemory(t);return}return this.put(r,t).then(i=>(i||this.putMemory(t),this.prune(r)))})}put(t,r){return new Promise(i=>{try{const n=t.transaction(E,"readwrite");n.objectStore(E).put(r),n.oncomplete=()=>i(!0),n.onerror=()=>i(!1),n.onabort=()=>i(!1)}catch(n){i(!1)}})}prune(t){return new Promise(r=>{try{const i=t.transaction(E,"readwrite"),n=i.objectStore(E),s=n.getAll();s.onsuccess=()=>{const o=(s.result||[]).sort((u,h)=>u.createdAt-h.createdAt),a=[],c=[];for(const u of o)(this.isExpired(u)?a:c).push(u);const l=Math.max(0,c.length-this.options.maxItems);a.concat(c.slice(0,l)).forEach(u=>{try{n.delete(u.id)}catch(h){}})},s.onerror=()=>r(),i.oncomplete=()=>r(),i.onerror=()=>r(),i.onabort=()=>r()}catch(i){r()}})}peek(){return this.database().then(t=>t?new Promise(r=>{try{const n=t.transaction(E,"readonly").objectStore(E).getAll();n.onsuccess=()=>{const s=n.result||[],o=new Set(s.map(c=>c.id)),a=s.concat(this.memory.filter(c=>!o.has(c.id)));r(a.filter(c=>!this.isExpired(c)).sort((c,l)=>c.createdAt-l.createdAt))},n.onerror=()=>r(this.memoryItems())}catch(i){r(this.memoryItems())}}):this.memoryItems())}memoryItems(){return this.memory.filter(t=>!this.isExpired(t)).sort((t,r)=>t.createdAt-r.createdAt)}remove(t){const r=this.memory.findIndex(i=>i.id===t);return r>=0&&this.memory.splice(r,1),this.database().then(i=>{if(i)return new Promise(n=>{try{const s=i.transaction(E,"readwrite");s.objectStore(E).delete(t),s.oncomplete=()=>n(),s.onerror=()=>n(),s.onabort=()=>n()}catch(s){n()}})})}size(){return this.peek().then(t=>t.length)}isExpired(t){return Date.now()-t.createdAt>this.options.ttlMs}trimMemory(){const t=this.memory.filter(r=>!this.isExpired(r));this.memory.length=0,this.memory.push(...t.slice(-this.options.maxItems))}putMemory(t){const r=this.memory.findIndex(i=>i.id===t.id);r>=0&&this.memory.splice(r,1),this.memory.push(t),this.trimMemory()}}class w extends Error{constructor(t,r){super(t),this.name="TransportError",this.failure=r.failure,this.status=r.status,this.retryable=r.retryable,this.details=r.details,this.retryAfterMs=r.retryAfterMs,this.queued=r.queued}asQueued(){return new w(this.message,{failure:this.failure,status:this.status,retryable:this.retryable,details:this.details,retryAfterMs:this.retryAfterMs,queued:!0})}}const Un=6e4,jn=15,zn=6e4;function Dn(e){return new Promise(t=>setTimeout(t,e))}function Nn(e){return 1e3*Math.pow(3,e)+Math.floor(Math.random()*250)}function qn(e,t=Date.now()){if(!e)return;const r=parseInt(e,10);if(!isNaN(r))return r*1e3;const i=Date.parse(e);return isNaN(i)?6e4:Math.max(0,i-t)}class Ke{constructor(t){this.config=t,this.pendingCount=0,this.pendingBytes=0,this.successCount=0,this.flushing=null,this.started=!1,this.onOnline=()=>{this.flush()},this.onVisibility=()=>{document.visibilityState==="hidden"&&this.beacon()},this.onPageHide=()=>{this.beacon()};const r=t.transport.offline;this.queue=r.enabled?new Hn({ttlMs:r.ttlMs,maxItems:r.maxItems}):null}start(){this.started||typeof window=="undefined"||(this.started=!0,window.addEventListener("online",this.onOnline),window.addEventListener("pagehide",this.onPageHide),document.addEventListener("visibilitychange",this.onVisibility),this.flush())}stop(){this.started&&(this.started=!1,window.removeEventListener("online",this.onOnline),window.removeEventListener("pagehide",this.onPageHide),document.removeEventListener("visibilitychange",this.onVisibility))}send(t){const r=this.config.transport;if(r.maxReportsPerSession>0&&this.successCount>=r.maxReportsPerSession)return Promise.reject(new w(`本次会话反馈次数已达上限(${r.maxReportsPerSession} 次)`,{failure:"limited",retryable:!1}));if(this.pendingCount>=r.maxConcurrent)return Promise.reject(new w("正在提交中,请稍后重试",{failure:"busy",retryable:!1}));let i;try{i=JSON.stringify(In(t,r.maxItemBytes,r.logLevel))}catch(o){return Promise.reject(new w(`报告序列化失败:${o instanceof Error?o.message:String(o)}`,{failure:"protocol",retryable:!1,details:o}))}const n=Date.now()+r.totalTimeoutMs,s=S(i);return this.attempt(i,s,t.clientReportId,0,n,this.config.endpoint).then(o=>(this.successCount+=1,o)).catch(o=>{const a=o instanceof w?o:this.toTransportError(o);if(!this.shouldQueue(a)||!this.queue)throw a;return this.enqueue(i,s,t.clientReportId).then(()=>{throw a.asQueued()})})}flush(){return this.queue?this.flushing?this.flushing:(this.flushing=this.queue.peek().then(t=>this.flushItems(t,0)).catch(()=>0).finally(()=>{this.flushing=null}),this.flushing):Promise.resolve(0)}flushItems(t,r){var o;const i=t[r];if(!i)return Promise.resolve(0);const n=Date.now()+this.config.transport.timeoutMs,s=(o=i.size)!=null?o:S(i.body);return this.once(i.body,s,i.id,n,i.endpoint).then(()=>this.queue.remove(i.id).then(()=>this.flushItems(t,r+1).then(a=>a+1))).catch(a=>{const c=a instanceof w?a:this.toTransportError(a);return this.shouldQueue(c)?0:this.queue.remove(i.id).then(()=>this.flushItems(t,r+1))})}beacon(){if(this.queue)try{if(typeof navigator=="undefined"||typeof navigator.sendBeacon!="function")return;this.queue.peek().then(t=>{t.forEach(r=>{var i;try{const n=new Blob([r.body],{type:"application/json"});if(n.size>zn)return;navigator.sendBeacon(r.endpoint,n)&&((i=this.queue)==null||i.remove(r.id))}catch(n){}})}).catch(()=>{})}catch(t){}}enqueue(t,r,i){return this.queue?this.queue.enqueue({id:i,endpoint:N(this.config.endpoint),body:t,size:r,createdAt:Date.now()}):Promise.resolve()}shouldQueue(t){return t.failure==="network"||t.failure==="timeout"?!0:t.failure==="http"&&(t.status===429||(t.status||0)>=500)}attempt(t,r,i,n,s,o){return this.once(t,r,i,s,o).catch(a=>{const c=a instanceof w?a:this.toTransportError(a),l=this.config.transport.retries;if(n<l&&c.retryable){const u=c.retryAfterMs!==void 0?c.retryAfterMs:Nn(n);if(Date.now()+u>=s)throw this.deadlineError(s);return Dn(u).then(()=>this.attempt(t,r,i,n+1,s,o))}throw c})}deadlineError(t){return new w(`提交超时(${Math.round(this.config.transport.totalTimeoutMs/1e3)}s)`,{failure:"timeout",retryable:!1,details:{deadline:t}})}once(t,r,i,n,s){const o=n-Date.now();if(o<=0)return Promise.reject(this.deadlineError(n));const a=new AbortController,c=Math.min(this.config.transport.timeoutMs,o),l=setTimeout(()=>a.abort(),c),u={"Content-Type":"application/json",...this.config.transport.headers};this.pendingCount+=1,this.pendingBytes+=r;const h=this.pendingBytes<=Un&&this.pendingCount<jn;return fetch(s,{method:"POST",headers:u,body:t,signal:a.signal,mode:"cors",credentials:"omit",keepalive:h}).then(d=>d.text().then(p=>({response:d,text:p}))).then(({response:d,text:p})=>{let g=null;if(p)try{g=JSON.parse(p)}catch(m){g=p}if(!d.ok){const m=d.status===429||d.status>=500,I=d.status===429?qn(d.headers.get("retry-after")):void 0,q=this.extractMessage(g)||`服务端返回 HTTP ${d.status}`;throw new w(q,{failure:"http",status:d.status,retryable:m,details:g,retryAfterMs:I})}if(!g||typeof g!="object")throw new w("服务端响应不是合法 JSON",{failure:"protocol",retryable:!1,details:g});if(g.errCode!==0)throw new w(this.extractMessage(g)||"上报接口返回失败",{failure:"protocol",retryable:!1,details:g});return{success:!0,reportId:i}}).catch(d=>{throw d instanceof w?d:d instanceof DOMException&&d.name==="AbortError"?new w(`请求超时(${Math.round(c/1e3)}s)`,{failure:"timeout",retryable:!0}):new w(d instanceof Error?d.message:String(d),{failure:"network",retryable:!0})}).finally(()=>{clearTimeout(l),this.pendingCount-=1,this.pendingBytes-=r})}toTransportError(t){return new w(t instanceof Error?t.message:String(t),{failure:"network",retryable:!0})}extractMessage(t){if(!t||typeof t!="object")return"";const r=t;if(typeof r.errMsg=="string"&&r.errMsg)return r.errMsg;if(typeof r.message=="string")return r.message;const i=r.error;if(i&&typeof i=="object"){const n=i;if(typeof n.message=="string")return n.message}return""}}function Fn(e){return Object.keys(e).map(t=>{var r;return`${encodeURIComponent(t)}=${encodeURIComponent((r=e[t])!=null?r:"")}`}).join("&")}function _(e){return e instanceof Error?e.message:String(e)}function Wn(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;if(typeof t.url=="string")return t.url;if(typeof t.file_url=="string")return t.file_url}return""}function Xn(e,t){if(!e.dataBase64)return Promise.resolve(e.url||"");const r=new AbortController,i=setTimeout(()=>r.abort(),t.timeoutMs),n=`data:${e.mime};base64,${e.dataBase64}`,s=Fn({imgdata:n,bizid:t.bizId,name:`bug-report-${Date.now()}.jpg`});return fetch(t.url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s,credentials:"include",signal:r.signal}).then(o=>o.text().then(a=>({response:o,text:a}))).then(({response:o,text:a})=>{let c=null;try{c=JSON.parse(a)}catch(h){c=null}if(!o.ok)throw new Error(`图片上传失败:HTTP ${o.status}`);if(!c||typeof c!="object")throw new Error("图片上传接口响应不是合法 JSON");const l=c;if(l.ret!==0){const h=typeof l.errmsg=="string"?l.errmsg:"";throw new Error(h||"图片上传失败")}const u=Wn(l.data);if(!u)throw new Error("图片上传接口未返回 url");return u}).catch(o=>{throw o instanceof DOMException&&o.name==="AbortError"?new Error(`图片上传超时(${Math.round(t.timeoutMs/1e3)}s)`):new Error(_(o))}).finally(()=>clearTimeout(i))}const Ge=`
12
12
  :host {
13
13
  all: initial;
14
14
  --br-bg: #ffffff;
@@ -484,5 +484,5 @@ ${r}`:t).slice(0,W)}return typeof e=="string"?e.slice(0,W):JSON.stringify(e).sli
484
484
  }
485
485
  .confirm .ok { background: #fff; color: #1d64e0; font-weight: 600; }
486
486
  .confirm .no { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .5); }
487
- `;class gs{constructor(){this.host=null,this.root=null,this.box=null,this.badge=null,this.confirmBar=null,this.confirmText=null,this.hovered=null,this.pending=null,this.raf=0,this.active=!1,this.lastX=0,this.lastY=0,this.pointerKnown=!1,this.resolve=null,this.previousCursor="",this.altPressed=!1,this.coarsePointer=!1,this.touchStartX=0,this.touchStartY=0,this.touchMoved=!1,this.ignoreElements=[],this.onMouseMove=t=>{this.active&&(this.lastX=t.clientX,this.lastY=t.clientY,this.pointerKnown=!0,!(this.coarsePointer||this.pending)&&this.scheduleUpdate())},this.onScroll=()=>{if(!this.active)return;const t=this.pending||this.hovered;if(t){if(!t.isConnected){this.pending?this.clearPending():this.updateHighlight(null);return}this.scheduleUpdate(t);return}this.pointerKnown&&!this.coarsePointer&&this.scheduleUpdate()},this.onClick=t=>{if(!this.active)return;const r=this.hitTest(t.clientX,t.clientY);if(r){if(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),this.coarsePointer){this.setPending(r);return}this.finish(pt(r))}},this.onMousePress=t=>{this.active&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onPointerPress=t=>{this.active&&t.pointerType!=="touch"&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onSuppress=t=>{this.active&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onTouchStart=t=>{if(!this.active||this.isOwnUi(t.target))return;t.stopPropagation();const r=t.touches&&t.touches[0];r&&(this.touchStartX=r.clientX,this.touchStartY=r.clientY,this.touchMoved=!1)},this.onTouchEnd=t=>{if(!this.active||this.isOwnUi(t.target))return;const r=t.changedTouches&&t.changedTouches[0];if(!r||this.touchMoved||Math.abs(r.clientX-this.touchStartX)>K||Math.abs(r.clientY-this.touchStartY)>K)return;t.preventDefault(),t.stopPropagation();const n=this.hitTest(r.clientX,r.clientY);n&&this.setPending(n)},this.onTouchMove=t=>{if(!this.active)return;const r=t.touches&&t.touches[0];r&&(Math.abs(r.clientX-this.touchStartX)>K||Math.abs(r.clientY-this.touchStartY)>K)&&(this.touchMoved=!0)},this.onKeyDown=t=>{if(this.active){if(t.key==="Escape"){if(t.preventDefault(),t.stopPropagation(),this.pending){this.clearPending();return}this.finish(null);return}t.key==="Alt"&&(this.altPressed=!0)}},this.onKeyUp=t=>{t.key==="Alt"&&(this.altPressed=!1)}}start(t={}){return this.active?Promise.resolve(null):(this.active=!0,this.coarsePointer=this.detectCoarsePointer(),this.mount(t),new Promise(r=>{this.resolve=r,window.addEventListener("mousemove",this.onMouseMove,!0),window.addEventListener("click",this.onClick,!0),window.addEventListener("dblclick",this.onSuppress,!0),window.addEventListener("contextmenu",this.onSuppress,!0),window.addEventListener("mousedown",this.onMousePress,!0),window.addEventListener("pointerdown",this.onPointerPress,!0),window.addEventListener("touchstart",this.onTouchStart,{capture:!0,passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{capture:!0,passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{capture:!0,passive:!1}),window.addEventListener("keydown",this.onKeyDown,!0),window.addEventListener("keyup",this.onKeyUp,!0),window.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScroll,{passive:!0})}))}detectCoarsePointer(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?!0:window.innerWidth<=560}catch(t){return!1}}stop(){this.finish(null)}mount(t){const r=document.createElement("div");r.setAttribute("data-bug-tap-picker",""),this.host=r;const i=r.attachShadow({mode:"open"});this.root=i;let n=null;try{if(typeof CSSStyleSheet!="undefined"&&"adoptedStyleSheets"in i){const g=new CSSStyleSheet;g.replaceSync(gt),i.adoptedStyleSheets=[...i.adoptedStyleSheets,g]}else n=document.createElement("style"),n.textContent=gt}catch(g){n=document.createElement("style"),n.textContent=gt}const s=document.createElement("div");s.className="box",s.style.display="none",this.box=s;const o=document.createElement("div");o.className="badge",o.style.display="none",this.badge=o;const a=document.createElement("div");a.className="bar";const c=document.createElement("span");c.innerHTML=this.coarsePointer?"轻点要反馈的页面元素":`${t.hint||"点击要反馈的页面元素"} <kbd>Alt</kbd> 选中父级 <kbd>Esc</kbd> 取消`;const l=document.createElement("button");l.type="button",l.textContent="取消",l.addEventListener("click",()=>this.finish(null)),a.append(c,l);const u=document.createElement("div");u.className="confirm";const h=document.createElement("div");h.className="confirm-text";const d=document.createElement("button");d.type="button",d.className="no",d.textContent="重选",d.addEventListener("click",()=>this.clearPending());const p=document.createElement("button");p.type="button",p.className="ok",p.textContent="确认",p.addEventListener("click",()=>{this.pending&&this.finish(pt(this.pending))}),u.append(h,d,p),this.confirmBar=u,this.confirmText=h,i.append(a,s,o,u),n&&i.append(n),document.documentElement.appendChild(r),this.previousCursor=document.documentElement.style.cursor,document.documentElement.style.cursor=this.coarsePointer?"default":"crosshair";try{document.documentElement.setAttribute("data-bug-tap-picking","")}catch(g){}this.ignoreElements=t.ignoreElements||[]}isIgnored(t){if(!t)return!0;let r=t;for(;r;){if(this.ignoreElements.indexOf(r)>=0||r.hasAttribute&&r.hasAttribute("data-bug-tap-picker"))return!0;const i=r.getRootNode?r.getRootNode():null;if(i&&i.host){r=i.host;continue}r=r.parentElement}return!1}hitTest(t,r){const i=document.elementFromPoint(t,r);if(!i||this.isIgnored(i))return null;if(this.altPressed&&i.parentElement){const n=i.parentElement;if(!this.isIgnored(n))return n}return i}scheduleUpdate(t){this.raf||(this.raf=requestAnimationFrame(()=>{if(this.raf=0,t){this.updateHighlight(t);return}this.updateHighlight(this.hitTest(this.lastX,this.lastY))}))}updateHighlight(t){if(!this.box||!this.badge)return;if(!t){this.box.style.display="none",this.badge.style.display="none",this.hovered=null;return}this.hovered=t;const r=t.getBoundingClientRect();this.box.style.display="block",this.box.style.top=`${r.top}px`,this.box.style.left=`${r.left}px`,this.box.style.width=`${r.width}px`,this.box.style.height=`${r.height}px`;const i=`${t.tagName.toLowerCase()}${t.id?`#${t.id}`:""}`;this.badge.style.display="block",this.badge.textContent=i,this.badge.style.left=`${Math.max(4,r.left)}px`,this.badge.style.top=`${r.top>26?r.top-24:r.bottom+4}px`}isOwnUi(t){if(!t)return!0;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-bug-tap-picker"))return!0;const i=r.getRootNode?r.getRootNode():null;if(i&&i.host){r=i.host;continue}r=r.parentElement}return!1}setPending(t){this.pending=t,this.updateHighlight(t),this.confirmBar&&this.confirmText&&(this.confirmText.textContent=pt(t).selector,this.confirmBar.classList.add("confirm--show"))}clearPending(){var t;this.pending=null,(t=this.confirmBar)==null||t.classList.remove("confirm--show"),this.updateHighlight(null)}finish(t){var i;if(!this.active)return;this.active=!1,window.removeEventListener("mousemove",this.onMouseMove,!0),window.removeEventListener("click",this.onClick,!0),window.removeEventListener("dblclick",this.onSuppress,!0),window.removeEventListener("contextmenu",this.onSuppress,!0),window.removeEventListener("mousedown",this.onMousePress,!0),window.removeEventListener("pointerdown",this.onPointerPress,!0),window.removeEventListener("touchstart",this.onTouchStart,{capture:!0}),window.removeEventListener("touchmove",this.onTouchMove,{capture:!0}),window.removeEventListener("touchend",this.onTouchEnd,{capture:!0}),window.removeEventListener("keydown",this.onKeyDown,!0),window.removeEventListener("keyup",this.onKeyUp,!0),window.removeEventListener("scroll",this.onScroll,{capture:!0}),window.removeEventListener("resize",this.onScroll),this.raf&&(cancelAnimationFrame(this.raf),this.raf=0),document.documentElement.style.cursor=this.previousCursor;try{document.documentElement.removeAttribute("data-bug-tap-picking")}catch(n){}(i=this.host)==null||i.remove(),this.host=null,this.root=null,this.box=null,this.badge=null,this.confirmBar=null,this.confirmText=null,this.hovered=null,this.pending=null,this.altPressed=!1,this.ignoreElements=[],this.pointerKnown=!1;const r=this.resolve;this.resolve=null,r&&r(t)}}const kr="bug-tap-enabled";function ms(){try{const e=localStorage.getItem(kr);return e==="1"||e==="0"?e:null}catch(e){return null}}function Cr(e){try{localStorage.setItem(kr,e?"1":"0")}catch(t){}}function bs(e){if(typeof location=="undefined")return null;try{const t=new URLSearchParams(location.search);if(!t.has(e.queryParam)){const r=location.hash.includes("?")?location.hash.slice(location.hash.indexOf("?")+1):"";if(!r)return null;const i=new URLSearchParams(r);return i.has(e.queryParam)?rr(i.get(e.queryParam),e.queryValue):null}return rr(t.get(e.queryParam),e.queryValue)}catch(t){return null}}function rr(e,t){return t?e===t||e==="1"||e==="true":!0}function ys(e){const t=bs(e);if(t===!0)return Cr(!0),!0;if(t===!1)return!1;const r=ms();return r==="0"?!1:e.mode==="triggered"?r==="1":!0}function ws(){if(typeof window=="undefined")return null;const e=window.BugTap;return e&&typeof e.captureException=="function"?e:null}function z(e){if(!e||typeof e!="object")return;const t=e,r=typeof t.fullPath=="string"?t.fullPath:t.path;return typeof r=="string"?r.slice(0,500):void 0}function vs(e){if(!e||typeof e!="object")return;const t=e.name;return typeof t=="string"?t.slice(0,100):void 0}function xs(){try{return`${location.pathname}${location.search}${location.hash}`.slice(0,500)}catch(e){return}}function Es(e){var s,o,a,c,l,u,h,d,p,g;if(!e||typeof e!="object")return;const t=e,r=(o=(s=t.$)==null?void 0:s.type)!=null?o:t.type,i=t.$options,n=(g=(p=(h=(l=(c=(a=i==null?void 0:i.name)!=null?a:i==null?void 0:i.__name)!=null?c:r==null?void 0:r.name)!=null?l:r==null?void 0:r.__name)!=null?h:(u=t.type)==null?void 0:u.name)!=null?p:(d=t.type)==null?void 0:d.__name)!=null?g:i==null?void 0:i._componentTag;return typeof n=="string"&&n?n:void 0}function Ss(e){if(!(!e||typeof e!="object"))return z(e.$route)}function ks(e){var t;return(t=Ss(e))!=null?t:xs()}function Rt(e){return{install(t,r={}){const i=r.client||e||ws();if(!i)return()=>{};const n=t.config,s=[];if(r.captureErrors!==!1&&n){const o=n.errorHandler,a=(c,l,u)=>{try{i.captureException(c,{source:"vue",info:u,component:Es(l),route:ks(l)})}catch(h){}typeof o=="function"&&o(c,l,u)};n.errorHandler=a,s.push(()=>{n.errorHandler===a&&(n.errorHandler=o||null)})}if(r.router&&typeof r.router.afterEach=="function"){try{i.disableRouteCapture()}catch(a){}const o=r.router.afterEach((a,c,l)=>{try{if(l){i.captureException(l instanceof Error?l:new Error(String(l)),{source:"vue-router",from:z(c),to:z(a)});return}i.addBreadcrumb({type:"route",from:z(c),to:z(a),data:{name:vs(a),source:"vue-router"}})}catch(u){}});s.push(()=>{typeof o=="function"&&o()})}return()=>{s.forEach(o=>{try{o()}catch(a){}})}}}}const Cs=Rt();function Lr(e,t){return!e||!e.config?()=>{}:Rt(t).install(e,{client:t,captureErrors:!0})}function Rr(e){const t=(r,i)=>{try{e.captureException(r,{source:"react",componentStack:i&&i.componentStack?i.componentStack.slice(0,4e3):void 0})}catch(n){}};return{onUncaughtError:t,onCaughtError:t,onRecoverableError:t}}const Ls=typeof window!="undefined"&&window.console&&typeof window.console.debug=="function"?window.console.debug.bind(window.console):()=>{};class Tt{constructor(t){this.host=null,this.fab=null,this.panel=null,this.panelLoading=null,this.openCancelled=!1,this.picker=null,this.lastClientReportId=null,this.pendingMount=0,this.configErrors=[],this.tags=new Map,this.extras=new Map,this.contexts=new Map,this.initialized=!1,this.routeCaptureOwned=!1,this.rawConfig=t,this.config=it(t),this.collector=new ze(this.config),this.transport=new Ke(this.config),Qe(this.config.screenshot.scriptUrl),this.configErrors=yt(t),this.configErrors.length>0&&this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`)}init(){this.initialized||(this.initialized=!0,this.collector.start(),this.transport.start(),this.config.reporter.enabled&&this.isConfigured()&&(this.mountFab(),this.applyFabVisibility()))}open(){this.openReporter()}close(){this.closeReporter()}openReporter(){var t,r;if(!this.config.reporter.enabled){this.warn("上报入口已被 reporter.enabled=false 关闭");return}if(!this.isConfigured()){this.warn("缺少 project,无法打开上报面板");return}if(this.panel!==null){this.panel.open(this.config.screenshot.enabled&&this.config.screenshot.auto);return}if(this.panelLoading){this.openCancelled=!1;const i=this.panelLoading;(t=this.fab)==null||t.setLoading(!0),i.then(n=>{var s,o;!n||this.openCancelled||((s=this.panel)==null||s.open(this.config.screenshot.enabled&&this.config.screenshot.auto),(o=this.fab)==null||o.setLoading(!1))});return}this.openCancelled=!1,(r=this.fab)==null||r.setLoading(!0),this.cancelPendingMount(),this.pendingMount=requestAnimationFrame(()=>{this.pendingMount=0;const i=this.mountPanel();this.panelLoading=i,i.then(n=>{var s;!n||this.openCancelled||(s=this.panel)==null||s.open(this.config.screenshot.enabled&&this.config.screenshot.auto)}).catch(n=>{this.warn(`面板挂载失败:${_(n)}`)}).finally(()=>{var n;this.panelLoading===i&&(this.panelLoading=null),(n=this.fab)==null||n.setLoading(!1)})})}cancelPendingMount(){this.pendingMount&&(cancelAnimationFrame(this.pendingMount),this.pendingMount=0)}closeReporter(){var t,r;this.cancelPendingMount(),this.openCancelled=!0,(t=this.fab)==null||t.setLoading(!1),(r=this.panel)==null||r.close()}setConfig(t){const r=Qr(this.rawConfig,t),i=this.config;this.rawConfig=r,this.config=it(r),Qe(this.config.screenshot.scriptUrl),this.initialized&&this.transport.stop(),this.transport=new Ke(this.config),this.initialized&&this.transport.start(),this.configErrors=yt(r),this.configErrors.length>0&&this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`),(JSON.stringify(i.collect)!==JSON.stringify(this.config.collect)||!$(i.privacy.excludeUrls,this.config.privacy.excludeUrls)||!$(i.privacy.excludeConsolePatterns,this.config.privacy.excludeConsolePatterns)||!$(i.privacy.excludeBreadcrumbUrls,this.config.privacy.excludeBreadcrumbUrls)||!$(i.filtering.ignoreErrors,this.config.filtering.ignoreErrors)||!$(i.filtering.denyUrls,this.config.filtering.denyUrls)||!$(i.filtering.allowUrls,this.config.filtering.allowUrls)||i.hooks.beforeBreadcrumb!==this.config.hooks.beforeBreadcrumb||i.endpoint!==this.config.endpoint||i.upload.url!==this.config.upload.url||i.transport.maxItemBytes!==this.config.transport.maxItemBytes)&&(this.collector.stop(),this.collector=new ze(this.config),this.routeCaptureOwned&&this.collector.disableRouteCapture(),this.initialized&&this.collector.start()),this.cancelPendingMount(),this.panelLoading=null;const s=this.panel!==null;this.unmountUi(),this.initialized&&this.config.reporter.enabled&&this.isConfigured()&&(this.mountFab(),s&&this.mountPanel(),this.applyFabVisibility())}setUser(t){this.rawConfig={...this.rawConfig,user:t||void 0},this.config=it(this.rawConfig),Gi()}setTag(t,r){mt(this.tags,t,typeof r=="string"?r.slice(0,64):r)}setExtra(t,r){mt(this.extras,t,et(r))}setContext(t,r){mt(this.contexts,t,et(r))}addBreadcrumb(t){const r={...t,t:Date.now(),type:t.type||"manual"};this.collector.addBreadcrumb(r)}captureException(t,r){this.collector.captureException(t,r)}captureMessage(t,r){this.collector.captureMessage(t,r)}disableRouteCapture(){this.routeCaptureOwned=!0,this.collector.disableRouteCapture()}installVueErrorHandler(t){return Lr(t,this)}reactErrorHandlers(){return Rr(this)}flush(){return this.transport.flush()}destroy(){var t,r;this.cancelPendingMount(),(t=this.panel)==null||t.close(),(r=this.picker)==null||r.stop(),this.picker=null,this.unmountUi(),this.collector.stop(),this.transport.stop(),this.initialized=!1,this.tags.clear(),this.extras.clear(),this.contexts.clear(),this.lastClientReportId=null}getReport(){const t=this.buildWithHooks({values:{title:"",description:""},data:this.collector.getData(),config:this.config,clientReportId:this.lastClientReportId||void 0,...this.runtimeContext()});if(ir(t))throw new Error("hooks.beforeSend 返回了 Promise,getReport 只支持同步钩子");if(!t)throw new Error("报告已被 hooks.beforeSend 丢弃");return t}buildWithHooks(t){const r=cn(t),i=this.config.hooks.beforeSend;if(!i)return r;const n=s=>s===null?null:s&&typeof s=="object"?s:r;try{const s=i(r);return ir(s)?s.then(n,o=>(this.warn(`beforeSend 执行失败:${_(o)}`),r)):n(s)}catch(s){return this.warn(`beforeSend 执行失败:${_(s)}`),r}}runtimeContext(){const t=r=>r.size>0?Object.fromEntries(r):void 0;return{tags:t(this.tags),extra:t(this.extras),contexts:t(this.contexts)}}mountFab(){this.fab||(this.host=new Vn(this.config.reporter.theme,this.config.reporter.zIndex),this.fab=new Qn({text:this.config.reporter.text,position:this.config.reporter.position,onClick:()=>this.openReporter()}),this.host.root.append(this.fab.element),this.host.mount(),this.fab.restorePosition())}mountPanel(){if(this.panel)return Promise.resolve(this.panel);this.host||this.mountFab();const t=this.host;return t?Promise.resolve().then(()=>require("./panel-mount-Dia21VuZ.cjs")).then(r=>new r.ReporterPanel({onSubmit:(i,n,s)=>this.submit(i,n,s),onCapture:()=>this.capture(),onUpload:i=>this.upload(i),onPickElement:()=>this.pickElement(),canUploadScreenshot:this.config.screenshot.enabled,maxElements:this.config.collect.maxElements,onDisable:this.config.reporter.visibility.closable?()=>{var i;Cr(!1),(i=this.fab)==null||i.hide()}:void 0})).then(r=>this.host!==t?(r.unmount(),null):this.panel?(r.unmount(),this.panel):(this.panel=r,t.root.append(r.overlay),r)):Promise.resolve(null)}applyFabVisibility(){if(!this.fab)return;ys(this.config.reporter.visibility)?this.fab.show():this.fab.hide()}unmountUi(){var t,r,i,n,s;(t=this.picker)==null||t.stop(),this.picker=null,(r=this.panel)==null||r.close(),(i=this.panel)==null||i.unmount(),(n=this.fab)==null||n.destroy(),(s=this.host)==null||s.unmount(),this.host=null,this.fab=null,this.panel=null}capture(){return this.config.screenshot.enabled?this.host?os({ignoreElement:this.host.host,quality:this.config.screenshot.quality,maxWidth:this.config.screenshot.maxWidth,maxSizeKB:this.config.screenshot.maxSizeKB,source:"auto"}):Promise.reject(new Error("上报面板未初始化")):Promise.reject(new Error("截图功能已关闭"))}upload(t){return this.config.screenshot.enabled?as(t,{quality:this.config.screenshot.quality,maxWidth:this.config.screenshot.maxWidth,maxSizeKB:this.config.screenshot.maxSizeKB,source:"manual"}):Promise.reject(new Error("截图功能已关闭"))}submit(t,r,i){return this.isConfigured()?this.prepareScreenshots(r).then(n=>{const s=this.collector.getData(),o=this.buildWithHooks({values:t,data:s,config:this.config,clientReportId:this.lastClientReportId||void 0,screenshots:n.length>0?n:void 0,elements:i.length>0?i:void 0,...this.runtimeContext()});return Promise.resolve(o).then(a=>{if(!a)throw new Error("报告已被 hooks.beforeSend 丢弃");return this.lastClientReportId=a.clientReportId,this.transport.send(a).catch(c=>{if(c instanceof w&&c.queued)return{success:!0,queued:!0,reportId:a.clientReportId,message:"网络异常,反馈已保存,恢复后会自动提交"};throw c}).finally(()=>{this.lastClientReportId=null})})}):Promise.reject(new Error("缺少 project,无法提交"))}pickElement(){return this.host?(this.picker||(this.picker=new gs),this.picker.start({ignoreElements:[this.host.host]})):Promise.reject(new Error("上报面板未初始化"))}prepareScreenshots(t){return t.length===0?Promise.resolve([]):Promise.all(t.map(r=>this.prepareScreenshot(r)))}prepareScreenshot(t){return this.config.upload.enabled?Xn(t,this.config.upload).then(r=>({...t,url:r,dataBase64:void 0})).catch(r=>(this.warn(`截图上传失败,改为内联提交:${_(r)}`),t)):Promise.resolve(t)}isConfigured(){return this.configErrors.length===0}warn(t){this.config.debug&&Ls(`[bug-tap] ${t}`)}}function ir(e){return!!(e&&typeof e.then=="function")}const Rs=6,G=50,Ts=50;function mt(e,t,r){const i=String(t||"").slice(0,64);if(i){if(e.delete(i),e.size>=Ts){const n=e.keys().next();n.done||e.delete(n.value)}e.set(i,r)}}function et(e,t=0,r){const i=typeof e;if(e===null||i==="string"||i==="number"||i==="boolean")return e;if(i==="undefined"||i==="function"||i==="symbol"||i==="bigint")return i==="bigint"?String(e):void 0;if(e instanceof Date)try{return e.toISOString()}catch(o){return}if(e instanceof Error)return`[Error] ${e.name}: ${e.message}`.slice(0,500);if(e instanceof RegExp)return String(e);if(t>=Rs)return"[MaxDepth]";const n=r||new WeakSet,s=e;if(n.has(s))return"[Circular]";n.add(s);try{if(Array.isArray(e)){const c=e.slice(0,G).map(l=>{const u=et(l,t+1,n);return u===void 0?null:u});return e.length>G&&c.push(`…[${e.length-G} more]`),c}const o={},a=Object.keys(s).slice(0,G);for(const c of a){let l;try{l=s[c]}catch(h){continue}const u=et(l,t+1,n);u!==void 0&&(o[c]=u)}return o}catch(o){return"[Unserializable]"}finally{n.delete(s)}}function $(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){const i=e[r],n=t[r];if(i instanceof RegExp||n instanceof RegExp){if(!(i instanceof RegExp)||!(n instanceof RegExp)||i.source!==n.source||i.flags!==n.flags)return!1}else if(i!==n)return!1}return!0}const Tr="0.1.0";let f=null;function Mr(e){if(typeof window=="undefined")return null;try{const t=new Tt(e);return t.init(),t}catch(t){return Q(`初始化失败:${t instanceof Error?t.message:String(t)}`),null}}function Mt(e){if(typeof window=="undefined")return null;if(f)return f;const t=e||window.BugTapConfig||At();if(!t)return Q("缺少配置:请在引入脚本前设置 window.BugTapConfig,或调用 BugTap.init(config)"),null;const r=yt(t);if(r.length>0)return Q(`配置不完整:${r.join(";")}。未初始化。`),null;try{const i=new Tt(t);return f=i,i.init(),i}catch(i){try{f==null||f.destroy()}catch(n){}return Q(`初始化失败:${i instanceof Error?i.message:String(i)}`),f=null,null}}function At(){try{if(typeof document=="undefined")return null;const e=document.currentScript,t=e&&e.dataset&&e.dataset.project?e:document.querySelector("script[data-project]");if(!t||!t.dataset)return null;const r=t.dataset;return r.project?{project:r.project,endpoint:r.endpoint,environment:r.environment,appVersion:r.appVersion,buildId:r.buildId,release:r.release,debug:r.debug==="true"}:null}catch(e){return null}}const Ms={version:Tr,init:Mt,createClient:Mr,open(){f==null||f.open()},close(){f==null||f.close()},openReporter(){f==null||f.openReporter()},closeReporter(){f==null||f.closeReporter()},setConfig(e){f==null||f.setConfig(e)},setUser(e){f==null||f.setUser(e)},setTag(e,t){f==null||f.setTag(e,t)},setExtra(e,t){f==null||f.setExtra(e,t)},setContext(e,t){f==null||f.setContext(e,t)},addBreadcrumb(e){f==null||f.addBreadcrumb(e)},captureException(e,t){f==null||f.captureException(e,t)},captureMessage(e,t){f==null||f.captureMessage(e,t)},disableRouteCapture(){f==null||f.disableRouteCapture()},installVueErrorHandler(e){return f?f.installVueErrorHandler(e):()=>{}},reactErrorHandlers(){if(f)return f.reactErrorHandlers();const e=()=>{};return{onUncaughtError:e,onCaughtError:e,onRecoverableError:e}},flush(){return f?f.flush():Promise.resolve(0)},destroy(){f==null||f.destroy(),f=null},getReport(){if(!f)throw new Error("[bug-tap] 尚未初始化");return f.getReport()}};function Q(e){try{window.console&&typeof window.console.warn=="function"&&window.console.warn(`[bug-tap] ${e}`)}catch(t){}}function nr(){if(window.__BUG_TAP__)return;const e=window.BugTapConfig||At();e&&Mt(e)&&(window.__BUG_TAP__=!0)}typeof window!="undefined"&&(window.BugTap=Ms,window.BugTapConfig||At()?nr():document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",nr,{once:!0}));exports.BugTap=Tt;exports.createClient=Mr;exports.createVuePlugin=Rt;exports.deriveTitle=vr;exports.init=Mt;exports.installVueErrorHandler=Lr;exports.messageOf=_;exports.plugin=Cs;exports.reactErrorHandlers=Rr;exports.version=Tr;
488
- //# sourceMappingURL=index-DCLLRJxX.cjs.map
487
+ `;class gs{constructor(){this.host=null,this.root=null,this.box=null,this.badge=null,this.confirmBar=null,this.confirmText=null,this.hovered=null,this.pending=null,this.raf=0,this.active=!1,this.lastX=0,this.lastY=0,this.pointerKnown=!1,this.resolve=null,this.previousCursor="",this.altPressed=!1,this.coarsePointer=!1,this.touchStartX=0,this.touchStartY=0,this.touchMoved=!1,this.ignoreElements=[],this.onMouseMove=t=>{this.active&&(this.lastX=t.clientX,this.lastY=t.clientY,this.pointerKnown=!0,!(this.coarsePointer||this.pending)&&this.scheduleUpdate())},this.onScroll=()=>{if(!this.active)return;const t=this.pending||this.hovered;if(t){if(!t.isConnected){this.pending?this.clearPending():this.updateHighlight(null);return}this.scheduleUpdate(t);return}this.pointerKnown&&!this.coarsePointer&&this.scheduleUpdate()},this.onClick=t=>{if(!this.active)return;const r=this.hitTest(t.clientX,t.clientY);if(r){if(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),this.coarsePointer){this.setPending(r);return}this.finish(pt(r))}},this.onMousePress=t=>{this.active&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onPointerPress=t=>{this.active&&t.pointerType!=="touch"&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onSuppress=t=>{this.active&&(this.isOwnUi(t.target)||(t.preventDefault(),t.stopPropagation()))},this.onTouchStart=t=>{if(!this.active||this.isOwnUi(t.target))return;t.stopPropagation();const r=t.touches&&t.touches[0];r&&(this.touchStartX=r.clientX,this.touchStartY=r.clientY,this.touchMoved=!1)},this.onTouchEnd=t=>{if(!this.active||this.isOwnUi(t.target))return;const r=t.changedTouches&&t.changedTouches[0];if(!r||this.touchMoved||Math.abs(r.clientX-this.touchStartX)>K||Math.abs(r.clientY-this.touchStartY)>K)return;t.preventDefault(),t.stopPropagation();const n=this.hitTest(r.clientX,r.clientY);n&&this.setPending(n)},this.onTouchMove=t=>{if(!this.active)return;const r=t.touches&&t.touches[0];r&&(Math.abs(r.clientX-this.touchStartX)>K||Math.abs(r.clientY-this.touchStartY)>K)&&(this.touchMoved=!0)},this.onKeyDown=t=>{if(this.active){if(t.key==="Escape"){if(t.preventDefault(),t.stopPropagation(),this.pending){this.clearPending();return}this.finish(null);return}t.key==="Alt"&&(this.altPressed=!0)}},this.onKeyUp=t=>{t.key==="Alt"&&(this.altPressed=!1)}}start(t={}){return this.active?Promise.resolve(null):(this.active=!0,this.coarsePointer=this.detectCoarsePointer(),this.mount(t),new Promise(r=>{this.resolve=r,window.addEventListener("mousemove",this.onMouseMove,!0),window.addEventListener("click",this.onClick,!0),window.addEventListener("dblclick",this.onSuppress,!0),window.addEventListener("contextmenu",this.onSuppress,!0),window.addEventListener("mousedown",this.onMousePress,!0),window.addEventListener("pointerdown",this.onPointerPress,!0),window.addEventListener("touchstart",this.onTouchStart,{capture:!0,passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{capture:!0,passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{capture:!0,passive:!1}),window.addEventListener("keydown",this.onKeyDown,!0),window.addEventListener("keyup",this.onKeyUp,!0),window.addEventListener("scroll",this.onScroll,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScroll,{passive:!0})}))}detectCoarsePointer(){try{return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches?!0:window.innerWidth<=560}catch(t){return!1}}stop(){this.finish(null)}mount(t){const r=document.createElement("div");r.setAttribute("data-bug-tap-picker",""),this.host=r;const i=r.attachShadow({mode:"open"});this.root=i;let n=null;try{if(typeof CSSStyleSheet!="undefined"&&"adoptedStyleSheets"in i){const g=new CSSStyleSheet;g.replaceSync(gt),i.adoptedStyleSheets=[...i.adoptedStyleSheets,g]}else n=document.createElement("style"),n.textContent=gt}catch(g){n=document.createElement("style"),n.textContent=gt}const s=document.createElement("div");s.className="box",s.style.display="none",this.box=s;const o=document.createElement("div");o.className="badge",o.style.display="none",this.badge=o;const a=document.createElement("div");a.className="bar";const c=document.createElement("span");c.innerHTML=this.coarsePointer?"轻点要反馈的页面元素":`${t.hint||"点击要反馈的页面元素"} <kbd>Alt</kbd> 选中父级 <kbd>Esc</kbd> 取消`;const l=document.createElement("button");l.type="button",l.textContent="取消",l.addEventListener("click",()=>this.finish(null)),a.append(c,l);const u=document.createElement("div");u.className="confirm";const h=document.createElement("div");h.className="confirm-text";const d=document.createElement("button");d.type="button",d.className="no",d.textContent="重选",d.addEventListener("click",()=>this.clearPending());const p=document.createElement("button");p.type="button",p.className="ok",p.textContent="确认",p.addEventListener("click",()=>{this.pending&&this.finish(pt(this.pending))}),u.append(h,d,p),this.confirmBar=u,this.confirmText=h,i.append(a,s,o,u),n&&i.append(n),document.documentElement.appendChild(r),this.previousCursor=document.documentElement.style.cursor,document.documentElement.style.cursor=this.coarsePointer?"default":"crosshair";try{document.documentElement.setAttribute("data-bug-tap-picking","")}catch(g){}this.ignoreElements=t.ignoreElements||[]}isIgnored(t){if(!t)return!0;let r=t;for(;r;){if(this.ignoreElements.indexOf(r)>=0||r.hasAttribute&&r.hasAttribute("data-bug-tap-picker"))return!0;const i=r.getRootNode?r.getRootNode():null;if(i&&i.host){r=i.host;continue}r=r.parentElement}return!1}hitTest(t,r){const i=document.elementFromPoint(t,r);if(!i||this.isIgnored(i))return null;if(this.altPressed&&i.parentElement){const n=i.parentElement;if(!this.isIgnored(n))return n}return i}scheduleUpdate(t){this.raf||(this.raf=requestAnimationFrame(()=>{if(this.raf=0,t){this.updateHighlight(t);return}this.updateHighlight(this.hitTest(this.lastX,this.lastY))}))}updateHighlight(t){if(!this.box||!this.badge)return;if(!t){this.box.style.display="none",this.badge.style.display="none",this.hovered=null;return}this.hovered=t;const r=t.getBoundingClientRect();this.box.style.display="block",this.box.style.top=`${r.top}px`,this.box.style.left=`${r.left}px`,this.box.style.width=`${r.width}px`,this.box.style.height=`${r.height}px`;const i=`${t.tagName.toLowerCase()}${t.id?`#${t.id}`:""}`;this.badge.style.display="block",this.badge.textContent=i,this.badge.style.left=`${Math.max(4,r.left)}px`,this.badge.style.top=`${r.top>26?r.top-24:r.bottom+4}px`}isOwnUi(t){if(!t)return!0;let r=t;for(;r;){if(r.hasAttribute&&r.hasAttribute("data-bug-tap-picker"))return!0;const i=r.getRootNode?r.getRootNode():null;if(i&&i.host){r=i.host;continue}r=r.parentElement}return!1}setPending(t){this.pending=t,this.updateHighlight(t),this.confirmBar&&this.confirmText&&(this.confirmText.textContent=pt(t).selector,this.confirmBar.classList.add("confirm--show"))}clearPending(){var t;this.pending=null,(t=this.confirmBar)==null||t.classList.remove("confirm--show"),this.updateHighlight(null)}finish(t){var i;if(!this.active)return;this.active=!1,window.removeEventListener("mousemove",this.onMouseMove,!0),window.removeEventListener("click",this.onClick,!0),window.removeEventListener("dblclick",this.onSuppress,!0),window.removeEventListener("contextmenu",this.onSuppress,!0),window.removeEventListener("mousedown",this.onMousePress,!0),window.removeEventListener("pointerdown",this.onPointerPress,!0),window.removeEventListener("touchstart",this.onTouchStart,{capture:!0}),window.removeEventListener("touchmove",this.onTouchMove,{capture:!0}),window.removeEventListener("touchend",this.onTouchEnd,{capture:!0}),window.removeEventListener("keydown",this.onKeyDown,!0),window.removeEventListener("keyup",this.onKeyUp,!0),window.removeEventListener("scroll",this.onScroll,{capture:!0}),window.removeEventListener("resize",this.onScroll),this.raf&&(cancelAnimationFrame(this.raf),this.raf=0),document.documentElement.style.cursor=this.previousCursor;try{document.documentElement.removeAttribute("data-bug-tap-picking")}catch(n){}(i=this.host)==null||i.remove(),this.host=null,this.root=null,this.box=null,this.badge=null,this.confirmBar=null,this.confirmText=null,this.hovered=null,this.pending=null,this.altPressed=!1,this.ignoreElements=[],this.pointerKnown=!1;const r=this.resolve;this.resolve=null,r&&r(t)}}const kr="bug-tap-enabled";function ms(){try{const e=localStorage.getItem(kr);return e==="1"||e==="0"?e:null}catch(e){return null}}function Cr(e){try{localStorage.setItem(kr,e?"1":"0")}catch(t){}}function bs(e){if(typeof location=="undefined")return null;try{const t=new URLSearchParams(location.search);if(!t.has(e.queryParam)){const r=location.hash.includes("?")?location.hash.slice(location.hash.indexOf("?")+1):"";if(!r)return null;const i=new URLSearchParams(r);return i.has(e.queryParam)?rr(i.get(e.queryParam),e.queryValue):null}return rr(t.get(e.queryParam),e.queryValue)}catch(t){return null}}function rr(e,t){return t?e===t||e==="1"||e==="true":!0}function ys(e){const t=bs(e);if(t===!0)return Cr(!0),!0;if(t===!1)return!1;const r=ms();return r==="0"?!1:e.mode==="triggered"?r==="1":!0}function ws(){if(typeof window=="undefined")return null;const e=window.BugTap;return e&&typeof e.captureException=="function"?e:null}function z(e){if(!e||typeof e!="object")return;const t=e,r=typeof t.fullPath=="string"?t.fullPath:t.path;return typeof r=="string"?r.slice(0,500):void 0}function vs(e){if(!e||typeof e!="object")return;const t=e.name;return typeof t=="string"?t.slice(0,100):void 0}function xs(){try{return`${location.pathname}${location.search}${location.hash}`.slice(0,500)}catch(e){return}}function Es(e){var s,o,a,c,l,u,h,d,p,g;if(!e||typeof e!="object")return;const t=e,r=(o=(s=t.$)==null?void 0:s.type)!=null?o:t.type,i=t.$options,n=(g=(p=(h=(l=(c=(a=i==null?void 0:i.name)!=null?a:i==null?void 0:i.__name)!=null?c:r==null?void 0:r.name)!=null?l:r==null?void 0:r.__name)!=null?h:(u=t.type)==null?void 0:u.name)!=null?p:(d=t.type)==null?void 0:d.__name)!=null?g:i==null?void 0:i._componentTag;return typeof n=="string"&&n?n:void 0}function Ss(e){if(!(!e||typeof e!="object"))return z(e.$route)}function ks(e){var t;return(t=Ss(e))!=null?t:xs()}function Rt(e){return{install(t,r={}){const i=r.client||e||ws();if(!i)return()=>{};const n=t.config,s=[];if(r.captureErrors!==!1&&n){const o=n.errorHandler,a=(c,l,u)=>{try{i.captureException(c,{source:"vue",info:u,component:Es(l),route:ks(l)})}catch(h){}typeof o=="function"&&o(c,l,u)};n.errorHandler=a,s.push(()=>{n.errorHandler===a&&(n.errorHandler=o||null)})}if(r.router&&typeof r.router.afterEach=="function"){try{i.disableRouteCapture()}catch(a){}const o=r.router.afterEach((a,c,l)=>{try{if(l){i.captureException(l instanceof Error?l:new Error(String(l)),{source:"vue-router",from:z(c),to:z(a)});return}i.addBreadcrumb({type:"route",from:z(c),to:z(a),data:{name:vs(a),source:"vue-router"}})}catch(u){}});s.push(()=>{typeof o=="function"&&o()})}return()=>{s.forEach(o=>{try{o()}catch(a){}})}}}}const Cs=Rt();function Lr(e,t){return!e||!e.config?()=>{}:Rt(t).install(e,{client:t,captureErrors:!0})}function Rr(e){const t=(r,i)=>{try{e.captureException(r,{source:"react",componentStack:i&&i.componentStack?i.componentStack.slice(0,4e3):void 0})}catch(n){}};return{onUncaughtError:t,onCaughtError:t,onRecoverableError:t}}const Ls=typeof window!="undefined"&&window.console&&typeof window.console.debug=="function"?window.console.debug.bind(window.console):()=>{};class Tt{constructor(t){this.host=null,this.fab=null,this.panel=null,this.panelLoading=null,this.openCancelled=!1,this.picker=null,this.lastClientReportId=null,this.pendingMount=0,this.configErrors=[],this.tags=new Map,this.extras=new Map,this.contexts=new Map,this.initialized=!1,this.routeCaptureOwned=!1,this.rawConfig=t,this.config=it(t),this.collector=new ze(this.config),this.transport=new Ke(this.config),Qe(this.config.screenshot.scriptUrl),this.configErrors=yt(t),this.configErrors.length>0&&this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`)}init(){this.initialized||(this.initialized=!0,this.collector.start(),this.transport.start(),this.config.reporter.enabled&&this.isConfigured()&&(this.mountFab(),this.applyFabVisibility()))}open(){this.openReporter()}close(){this.closeReporter()}openReporter(){var t,r;if(!this.config.reporter.enabled){this.warn("上报入口已被 reporter.enabled=false 关闭");return}if(!this.isConfigured()){this.warn("缺少 project,无法打开上报面板");return}if(this.panel!==null){this.panel.open(this.config.screenshot.enabled&&this.config.screenshot.auto);return}if(this.panelLoading){this.openCancelled=!1;const i=this.panelLoading;(t=this.fab)==null||t.setLoading(!0),i.then(n=>{var s,o;!n||this.openCancelled||((s=this.panel)==null||s.open(this.config.screenshot.enabled&&this.config.screenshot.auto),(o=this.fab)==null||o.setLoading(!1))});return}this.openCancelled=!1,(r=this.fab)==null||r.setLoading(!0),this.cancelPendingMount(),this.pendingMount=requestAnimationFrame(()=>{this.pendingMount=0;const i=this.mountPanel();this.panelLoading=i,i.then(n=>{var s;!n||this.openCancelled||(s=this.panel)==null||s.open(this.config.screenshot.enabled&&this.config.screenshot.auto)}).catch(n=>{this.warn(`面板挂载失败:${_(n)}`)}).finally(()=>{var n;this.panelLoading===i&&(this.panelLoading=null),(n=this.fab)==null||n.setLoading(!1)})})}cancelPendingMount(){this.pendingMount&&(cancelAnimationFrame(this.pendingMount),this.pendingMount=0)}closeReporter(){var t,r;this.cancelPendingMount(),this.openCancelled=!0,(t=this.fab)==null||t.setLoading(!1),(r=this.panel)==null||r.close()}setConfig(t){const r=Qr(this.rawConfig,t),i=this.config;this.rawConfig=r,this.config=it(r),Qe(this.config.screenshot.scriptUrl),this.initialized&&this.transport.stop(),this.transport=new Ke(this.config),this.initialized&&this.transport.start(),this.configErrors=yt(r),this.configErrors.length>0&&this.warn(`配置不完整:${this.configErrors.join(";")}。上报按钮不会显示。`),(JSON.stringify(i.collect)!==JSON.stringify(this.config.collect)||!$(i.privacy.excludeUrls,this.config.privacy.excludeUrls)||!$(i.privacy.excludeConsolePatterns,this.config.privacy.excludeConsolePatterns)||!$(i.privacy.excludeBreadcrumbUrls,this.config.privacy.excludeBreadcrumbUrls)||!$(i.filtering.ignoreErrors,this.config.filtering.ignoreErrors)||!$(i.filtering.denyUrls,this.config.filtering.denyUrls)||!$(i.filtering.allowUrls,this.config.filtering.allowUrls)||i.hooks.beforeBreadcrumb!==this.config.hooks.beforeBreadcrumb||i.endpoint!==this.config.endpoint||i.upload.url!==this.config.upload.url||i.transport.maxItemBytes!==this.config.transport.maxItemBytes)&&(this.collector.stop(),this.collector=new ze(this.config),this.routeCaptureOwned&&this.collector.disableRouteCapture(),this.initialized&&this.collector.start()),this.cancelPendingMount(),this.panelLoading=null;const s=this.panel!==null;this.unmountUi(),this.initialized&&this.config.reporter.enabled&&this.isConfigured()&&(this.mountFab(),s&&this.mountPanel(),this.applyFabVisibility())}setUser(t){this.rawConfig={...this.rawConfig,user:t||void 0},this.config=it(this.rawConfig),Gi()}setTag(t,r){mt(this.tags,t,typeof r=="string"?r.slice(0,64):r)}setExtra(t,r){mt(this.extras,t,et(r))}setContext(t,r){mt(this.contexts,t,et(r))}addBreadcrumb(t){const r={...t,t:Date.now(),type:t.type||"manual"};this.collector.addBreadcrumb(r)}captureException(t,r){this.collector.captureException(t,r)}captureMessage(t,r){this.collector.captureMessage(t,r)}disableRouteCapture(){this.routeCaptureOwned=!0,this.collector.disableRouteCapture()}installVueErrorHandler(t){return Lr(t,this)}reactErrorHandlers(){return Rr(this)}flush(){return this.transport.flush()}destroy(){var t,r;this.cancelPendingMount(),(t=this.panel)==null||t.close(),(r=this.picker)==null||r.stop(),this.picker=null,this.unmountUi(),this.collector.stop(),this.transport.stop(),this.initialized=!1,this.tags.clear(),this.extras.clear(),this.contexts.clear(),this.lastClientReportId=null}getReport(){const t=this.buildWithHooks({values:{title:"",description:""},data:this.collector.getData(),config:this.config,clientReportId:this.lastClientReportId||void 0,...this.runtimeContext()});if(ir(t))throw new Error("hooks.beforeSend 返回了 Promise,getReport 只支持同步钩子");if(!t)throw new Error("报告已被 hooks.beforeSend 丢弃");return t}buildWithHooks(t){const r=cn(t),i=this.config.hooks.beforeSend;if(!i)return r;const n=s=>s===null?null:s&&typeof s=="object"?s:r;try{const s=i(r);return ir(s)?s.then(n,o=>(this.warn(`beforeSend 执行失败:${_(o)}`),r)):n(s)}catch(s){return this.warn(`beforeSend 执行失败:${_(s)}`),r}}runtimeContext(){const t=r=>r.size>0?Object.fromEntries(r):void 0;return{tags:t(this.tags),extra:t(this.extras),contexts:t(this.contexts)}}mountFab(){this.fab||(this.host=new Vn(this.config.reporter.theme,this.config.reporter.zIndex),this.fab=new Qn({text:this.config.reporter.text,position:this.config.reporter.position,onClick:()=>this.openReporter()}),this.host.root.append(this.fab.element),this.host.mount(),this.fab.restorePosition())}mountPanel(){if(this.panel)return Promise.resolve(this.panel);this.host||this.mountFab();const t=this.host;return t?Promise.resolve().then(()=>require("./panel-mount-CjRBibNV.cjs")).then(r=>new r.ReporterPanel({onSubmit:(i,n,s)=>this.submit(i,n,s),onCapture:()=>this.capture(),onUpload:i=>this.upload(i),onPickElement:()=>this.pickElement(),canUploadScreenshot:this.config.screenshot.enabled,maxElements:this.config.collect.maxElements,onDisable:this.config.reporter.visibility.closable?()=>{var i;Cr(!1),(i=this.fab)==null||i.hide()}:void 0})).then(r=>this.host!==t?(r.unmount(),null):this.panel?(r.unmount(),this.panel):(this.panel=r,t.root.append(r.overlay),r)):Promise.resolve(null)}applyFabVisibility(){if(!this.fab)return;ys(this.config.reporter.visibility)?this.fab.show():this.fab.hide()}unmountUi(){var t,r,i,n,s;(t=this.picker)==null||t.stop(),this.picker=null,(r=this.panel)==null||r.close(),(i=this.panel)==null||i.unmount(),(n=this.fab)==null||n.destroy(),(s=this.host)==null||s.unmount(),this.host=null,this.fab=null,this.panel=null}capture(){return this.config.screenshot.enabled?this.host?os({ignoreElement:this.host.host,quality:this.config.screenshot.quality,maxWidth:this.config.screenshot.maxWidth,maxSizeKB:this.config.screenshot.maxSizeKB,source:"auto"}):Promise.reject(new Error("上报面板未初始化")):Promise.reject(new Error("截图功能已关闭"))}upload(t){return this.config.screenshot.enabled?as(t,{quality:this.config.screenshot.quality,maxWidth:this.config.screenshot.maxWidth,maxSizeKB:this.config.screenshot.maxSizeKB,source:"manual"}):Promise.reject(new Error("截图功能已关闭"))}submit(t,r,i){return this.isConfigured()?this.prepareScreenshots(r).then(n=>{const s=this.collector.getData(),o=this.buildWithHooks({values:t,data:s,config:this.config,clientReportId:this.lastClientReportId||void 0,screenshots:n.length>0?n:void 0,elements:i.length>0?i:void 0,...this.runtimeContext()});return Promise.resolve(o).then(a=>{if(!a)throw new Error("报告已被 hooks.beforeSend 丢弃");return this.lastClientReportId=a.clientReportId,this.transport.send(a).catch(c=>{if(c instanceof w&&c.queued)return{success:!0,queued:!0,reportId:a.clientReportId,message:"网络异常,反馈已保存,恢复后会自动提交"};throw c}).finally(()=>{this.lastClientReportId=null})})}):Promise.reject(new Error("缺少 project,无法提交"))}pickElement(){return this.host?(this.picker||(this.picker=new gs),this.picker.start({ignoreElements:[this.host.host]})):Promise.reject(new Error("上报面板未初始化"))}prepareScreenshots(t){return t.length===0?Promise.resolve([]):Promise.all(t.map(r=>this.prepareScreenshot(r)))}prepareScreenshot(t){return this.config.upload.enabled?Xn(t,this.config.upload).then(r=>({...t,url:r,dataBase64:void 0})).catch(r=>(this.warn(`截图上传失败,改为内联提交:${_(r)}`),t)):Promise.resolve(t)}isConfigured(){return this.configErrors.length===0}warn(t){this.config.debug&&Ls(`[bug-tap] ${t}`)}}function ir(e){return!!(e&&typeof e.then=="function")}const Rs=6,G=50,Ts=50;function mt(e,t,r){const i=String(t||"").slice(0,64);if(i){if(e.delete(i),e.size>=Ts){const n=e.keys().next();n.done||e.delete(n.value)}e.set(i,r)}}function et(e,t=0,r){const i=typeof e;if(e===null||i==="string"||i==="number"||i==="boolean")return e;if(i==="undefined"||i==="function"||i==="symbol"||i==="bigint")return i==="bigint"?String(e):void 0;if(e instanceof Date)try{return e.toISOString()}catch(o){return}if(e instanceof Error)return`[Error] ${e.name}: ${e.message}`.slice(0,500);if(e instanceof RegExp)return String(e);if(t>=Rs)return"[MaxDepth]";const n=r||new WeakSet,s=e;if(n.has(s))return"[Circular]";n.add(s);try{if(Array.isArray(e)){const c=e.slice(0,G).map(l=>{const u=et(l,t+1,n);return u===void 0?null:u});return e.length>G&&c.push(`…[${e.length-G} more]`),c}const o={},a=Object.keys(s).slice(0,G);for(const c of a){let l;try{l=s[c]}catch(h){continue}const u=et(l,t+1,n);u!==void 0&&(o[c]=u)}return o}catch(o){return"[Unserializable]"}finally{n.delete(s)}}function $(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){const i=e[r],n=t[r];if(i instanceof RegExp||n instanceof RegExp){if(!(i instanceof RegExp)||!(n instanceof RegExp)||i.source!==n.source||i.flags!==n.flags)return!1}else if(i!==n)return!1}return!0}const Tr="0.1.1";let f=null;function Mr(e){if(typeof window=="undefined")return null;try{const t=new Tt(e);return t.init(),t}catch(t){return Q(`初始化失败:${t instanceof Error?t.message:String(t)}`),null}}function Mt(e){if(typeof window=="undefined")return null;if(f)return f;const t=e||window.BugTapConfig||At();if(!t)return Q("缺少配置:请在引入脚本前设置 window.BugTapConfig,或调用 BugTap.init(config)"),null;const r=yt(t);if(r.length>0)return Q(`配置不完整:${r.join(";")}。未初始化。`),null;try{const i=new Tt(t);return f=i,i.init(),i}catch(i){try{f==null||f.destroy()}catch(n){}return Q(`初始化失败:${i instanceof Error?i.message:String(i)}`),f=null,null}}function At(){try{if(typeof document=="undefined")return null;const e=document.currentScript,t=e&&e.dataset&&e.dataset.project?e:document.querySelector("script[data-project]");if(!t||!t.dataset)return null;const r=t.dataset;return r.project?{project:r.project,endpoint:r.endpoint,environment:r.environment,appVersion:r.appVersion,buildId:r.buildId,release:r.release,debug:r.debug==="true"}:null}catch(e){return null}}const Ms={version:Tr,init:Mt,createClient:Mr,open(){f==null||f.open()},close(){f==null||f.close()},openReporter(){f==null||f.openReporter()},closeReporter(){f==null||f.closeReporter()},setConfig(e){f==null||f.setConfig(e)},setUser(e){f==null||f.setUser(e)},setTag(e,t){f==null||f.setTag(e,t)},setExtra(e,t){f==null||f.setExtra(e,t)},setContext(e,t){f==null||f.setContext(e,t)},addBreadcrumb(e){f==null||f.addBreadcrumb(e)},captureException(e,t){f==null||f.captureException(e,t)},captureMessage(e,t){f==null||f.captureMessage(e,t)},disableRouteCapture(){f==null||f.disableRouteCapture()},installVueErrorHandler(e){return f?f.installVueErrorHandler(e):()=>{}},reactErrorHandlers(){if(f)return f.reactErrorHandlers();const e=()=>{};return{onUncaughtError:e,onCaughtError:e,onRecoverableError:e}},flush(){return f?f.flush():Promise.resolve(0)},destroy(){f==null||f.destroy(),f=null},getReport(){if(!f)throw new Error("[bug-tap] 尚未初始化");return f.getReport()}};function Q(e){try{window.console&&typeof window.console.warn=="function"&&window.console.warn(`[bug-tap] ${e}`)}catch(t){}}function nr(){if(window.__BUG_TAP__)return;const e=window.BugTapConfig||At();e&&Mt(e)&&(window.__BUG_TAP__=!0)}typeof window!="undefined"&&(window.BugTap=Ms,window.BugTapConfig||At()?nr():document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",nr,{once:!0}));exports.BugTap=Tt;exports.createClient=Mr;exports.createVuePlugin=Rt;exports.deriveTitle=vr;exports.init=Mt;exports.installVueErrorHandler=Lr;exports.messageOf=_;exports.plugin=Cs;exports.reactErrorHandlers=Rr;exports.version=Tr;
488
+ //# sourceMappingURL=index-BbRyzCzY.cjs.map