@king-one/monitor 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @king-one/monitor
2
2
 
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - feat:优化自动上报的逻辑
8
+
9
+ ## 1.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - feat:正式发布
14
+
3
15
  ## 1.0.5
4
16
 
5
17
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- (function(A,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A.KingMonitor={}))})(this,function(A){"use strict";var Qe=Object.defineProperty;var We=(A,N,Q)=>N in A?Qe(A,N,{enumerable:!0,configurable:!0,writable:!0,value:Q}):A[N]=Q;var D=(A,N,Q)=>We(A,typeof N!="symbol"?N+"":N,Q);class N{constructor(){D(this,"events",new Map)}on(e,r){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(r)}off(e,r){const n=this.events.get(e);n&&(n.delete(r),n.size===0&&this.events.delete(e))}emit(e,...r){const n=this.events.get(e);n&&n.forEach(t=>{try{t(...r)}catch(i){console.error(`Error in event handler for ${e}:`,i)}})}clear(){this.events.clear()}getSubscriberCount(e){const r=this.events.get(e);return r?r.size:0}hasSubscribers(e){return this.getSubscriberCount(e)>0}}var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function me(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function qe(o){return o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Je(o){return o&&Object.prototype.hasOwnProperty.call(o,"default")&&Object.keys(o).length===1?o.default:o}function Ke(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var t=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return o[n]}})}),r}var oe={},ie={},X={},se={},ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Xe=se.encode=function(o){if(0<=o&&o<ve.length)return ve[o];throw new TypeError("Must be between 0 and 63: "+o)},Ze=se.decode=function(o){var e=65,r=90,n=97,t=122,i=48,s=57,f=43,c=47,h=26,d=52;return e<=o&&o<=r?o-e:n<=o&&o<=t?o-n+h:i<=o&&o<=s?o-i+d:o==f?62:o==c?63:-1},_e=se,ue=5,Se=1<<ue,ye=Se-1,Ce=Se;function Re(o){return o<0?(-o<<1)+1:(o<<1)+0}function Ne(o){var e=(o&1)===1,r=o>>1;return e?-r:r}var Ye=X.encode=function(e){var r="",n,t=Re(e);do n=t&ye,t>>>=ue,t>0&&(n|=Ce),r+=_e.encode(n);while(t>0);return r},He=X.decode=function(e,r,n){var t=e.length,i=0,s=0,f,c;do{if(r>=t)throw new Error("Expected more digits in base 64 VLQ value.");if(c=_e.decode(e.charCodeAt(r++)),c===-1)throw new Error("Invalid base64 digit: "+e.charAt(r-1));f=!!(c&Ce),c&=ye,i=i+(c<<s),s+=ue}while(f);n.value=Ne(i),n.rest=r},x={};(function(o){function e(u,l,g){if(l in u)return u[l];if(arguments.length===3)return g;throw new Error('"'+l+'" is a required argument.')}o.getArg=e;var r=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,n=/^data:.+\,.+$/;function t(u){var l=u.match(r);return l?{scheme:l[1],auth:l[2],host:l[3],port:l[4],path:l[5]}:null}o.urlParse=t;function i(u){var l="";return u.scheme&&(l+=u.scheme+":"),l+="//",u.auth&&(l+=u.auth+"@"),u.host&&(l+=u.host),u.port&&(l+=":"+u.port),u.path&&(l+=u.path),l}o.urlGenerate=i;var s=32;function f(u){var l=[];return function(g){for(var a=0;a<l.length;a++)if(l[a].input===g){var F=l[0];return l[0]=l[a],l[a]=F,l[0].result}var P=u(g);return l.unshift({input:g,result:P}),l.length>s&&l.pop(),P}}var c=f(function(l){var g=l,a=t(l);if(a){if(!a.path)return l;g=a.path}for(var F=o.isAbsolute(g),P=[],ne=0,R=0;;)if(ne=R,R=g.indexOf("/",ne),R===-1){P.push(g.slice(ne));break}else for(P.push(g.slice(ne,R));R<g.length&&g[R]==="/";)R++;for(var te,K=0,R=P.length-1;R>=0;R--)te=P[R],te==="."?P.splice(R,1):te===".."?K++:K>0&&(te===""?(P.splice(R+1,K),K=0):(P.splice(R,2),K--));return g=P.join("/"),g===""&&(g=F?"/":"."),a?(a.path=g,i(a)):g});o.normalize=c;function h(u,l){u===""&&(u="."),l===""&&(l=".");var g=t(l),a=t(u);if(a&&(u=a.path||"/"),g&&!g.scheme)return a&&(g.scheme=a.scheme),i(g);if(g||l.match(n))return l;if(a&&!a.host&&!a.path)return a.host=l,i(a);var F=l.charAt(0)==="/"?l:c(u.replace(/\/+$/,"")+"/"+l);return a?(a.path=F,i(a)):F}o.join=h,o.isAbsolute=function(u){return u.charAt(0)==="/"||r.test(u)};function d(u,l){u===""&&(u="."),u=u.replace(/\/$/,"");for(var g=0;l.indexOf(u+"/")!==0;){var a=u.lastIndexOf("/");if(a<0||(u=u.slice(0,a),u.match(/^([^\/]+:\/)?\/*$/)))return l;++g}return Array(g+1).join("../")+l.substr(u.length+1)}o.relative=d;var v=function(){var u=Object.create(null);return!("__proto__"in u)}();function m(u){return u}function _(u){return S(u)?"$"+u:u}o.toSetString=v?m:_;function C(u){return S(u)?u.slice(1):u}o.fromSetString=v?m:C;function S(u){if(!u)return!1;var l=u.length;if(l<9||u.charCodeAt(l-1)!==95||u.charCodeAt(l-2)!==95||u.charCodeAt(l-3)!==111||u.charCodeAt(l-4)!==116||u.charCodeAt(l-5)!==111||u.charCodeAt(l-6)!==114||u.charCodeAt(l-7)!==112||u.charCodeAt(l-8)!==95||u.charCodeAt(l-9)!==95)return!1;for(var g=l-10;g>=0;g--)if(u.charCodeAt(g)!==36)return!1;return!0}function J(u,l,g){var a=L(u.source,l.source);return a!==0||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0||g)||(a=u.generatedColumn-l.generatedColumn,a!==0)||(a=u.generatedLine-l.generatedLine,a!==0)?a:L(u.name,l.name)}o.compareByOriginalPositions=J;function E(u,l,g){var a;return a=u.originalLine-l.originalLine,a!==0||(a=u.originalColumn-l.originalColumn,a!==0||g)||(a=u.generatedColumn-l.generatedColumn,a!==0)||(a=u.generatedLine-l.generatedLine,a!==0)?a:L(u.name,l.name)}o.compareByOriginalPositionsNoSource=E;function I(u,l,g){var a=u.generatedLine-l.generatedLine;return a!==0||(a=u.generatedColumn-l.generatedColumn,a!==0||g)||(a=L(u.source,l.source),a!==0)||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0)?a:L(u.name,l.name)}o.compareByGeneratedPositionsDeflated=I;function z(u,l,g){var a=u.generatedColumn-l.generatedColumn;return a!==0||g||(a=L(u.source,l.source),a!==0)||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0)?a:L(u.name,l.name)}o.compareByGeneratedPositionsDeflatedNoLine=z;function L(u,l){return u===l?0:u===null?1:l===null?-1:u>l?1:-1}function O(u,l){var g=u.generatedLine-l.generatedLine;return g!==0||(g=u.generatedColumn-l.generatedColumn,g!==0)||(g=L(u.source,l.source),g!==0)||(g=u.originalLine-l.originalLine,g!==0)||(g=u.originalColumn-l.originalColumn,g!==0)?g:L(u.name,l.name)}o.compareByGeneratedPositionsInflated=O;function y(u){return JSON.parse(u.replace(/^\)]}'[^\n]*\n/,""))}o.parseSourceMapInput=y;function re(u,l,g){if(l=l||"",u&&(u[u.length-1]!=="/"&&l[0]!=="/"&&(u+="/"),l=u+l),g){var a=t(g);if(!a)throw new Error("sourceMapURL could not be parsed");if(a.path){var F=a.path.lastIndexOf("/");F>=0&&(a.path=a.path.substring(0,F+1))}l=h(i(a),l)}return c(l)}o.computeSourceURL=re})(x);const er=me(x);var le={},ae=x,ce=Object.prototype.hasOwnProperty,U=typeof Map<"u";function k(){this._array=[],this._set=U?new Map:Object.create(null)}k.fromArray=function(e,r){for(var n=new k,t=0,i=e.length;t<i;t++)n.add(e[t],r);return n},k.prototype.size=function(){return U?this._set.size:Object.getOwnPropertyNames(this._set).length},k.prototype.add=function(e,r){var n=U?e:ae.toSetString(e),t=U?this.has(e):ce.call(this._set,n),i=this._array.length;(!t||r)&&this._array.push(e),t||(U?this._set.set(e,i):this._set[n]=i)},k.prototype.has=function(e){if(U)return this._set.has(e);var r=ae.toSetString(e);return ce.call(this._set,r)},k.prototype.indexOf=function(e){if(U){var r=this._set.get(e);if(r>=0)return r}else{var n=ae.toSetString(e);if(ce.call(this._set,n))return this._set[n]}throw new Error('"'+e+'" is not in the set.')},k.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},k.prototype.toArray=function(){return this._array.slice()};var rr=le.ArraySet=k,we={},Ee=x;function $e(o,e){var r=o.generatedLine,n=e.generatedLine,t=o.generatedColumn,i=e.generatedColumn;return n>r||n==r&&i>=t||Ee.compareByGeneratedPositionsInflated(o,e)<=0}function Z(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Z.prototype.unsortedForEach=function(e,r){this._array.forEach(e,r)},Z.prototype.add=function(e){$e(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},Z.prototype.toArray=function(){return this._sorted||(this._array.sort(Ee.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};var nr=we.MappingList=Z,W=X,M=x,Y=le.ArraySet,Ge=we.MappingList;function j(o){o||(o={}),this._file=M.getArg(o,"file",null),this._sourceRoot=M.getArg(o,"sourceRoot",null),this._skipValidation=M.getArg(o,"skipValidation",!1),this._ignoreInvalidMapping=M.getArg(o,"ignoreInvalidMapping",!1),this._sources=new Y,this._names=new Y,this._mappings=new Ge,this._sourcesContents=null}j.prototype._version=3,j.fromSourceMap=function(e,r){var n=e.sourceRoot,t=new j(Object.assign(r||{},{file:e.file,sourceRoot:n}));return e.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,n!=null&&(s.source=M.relative(n,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),t.addMapping(s)}),e.sources.forEach(function(i){var s=i;n!==null&&(s=M.relative(n,i)),t._sources.has(s)||t._sources.add(s);var f=e.sourceContentFor(i);f!=null&&t.setSourceContent(i,f)}),t},j.prototype.addMapping=function(e){var r=M.getArg(e,"generated"),n=M.getArg(e,"original",null),t=M.getArg(e,"source",null),i=M.getArg(e,"name",null);!this._skipValidation&&this._validateMapping(r,n,t,i)===!1||(t!=null&&(t=String(t),this._sources.has(t)||this._sources.add(t)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i}))},j.prototype.setSourceContent=function(e,r){var n=e;this._sourceRoot!=null&&(n=M.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[M.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[M.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},j.prototype.applySourceMap=function(e,r,n){var t=r;if(r==null){if(e.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);t=e.file}var i=this._sourceRoot;i!=null&&(t=M.relative(i,t));var s=new Y,f=new Y;this._mappings.unsortedForEach(function(c){if(c.source===t&&c.originalLine!=null){var h=e.originalPositionFor({line:c.originalLine,column:c.originalColumn});h.source!=null&&(c.source=h.source,n!=null&&(c.source=M.join(n,c.source)),i!=null&&(c.source=M.relative(i,c.source)),c.originalLine=h.line,c.originalColumn=h.column,h.name!=null&&(c.name=h.name))}var d=c.source;d!=null&&!s.has(d)&&s.add(d);var v=c.name;v!=null&&!f.has(v)&&f.add(v)},this),this._sources=s,this._names=f,e.sources.forEach(function(c){var h=e.sourceContentFor(c);h!=null&&(n!=null&&(c=M.join(n,c)),i!=null&&(c=M.relative(i,c)),this.setSourceContent(c,h))},this)},j.prototype._validateMapping=function(e,r,n,t){if(r&&typeof r.line!="number"&&typeof r.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t)){if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n)return;var i="Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}},j.prototype._serializeMappings=function(){for(var e=0,r=1,n=0,t=0,i=0,s=0,f="",c,h,d,v,m=this._mappings.toArray(),_=0,C=m.length;_<C;_++){if(h=m[_],c="",h.generatedLine!==r)for(e=0;h.generatedLine!==r;)c+=";",r++;else if(_>0){if(!M.compareByGeneratedPositionsInflated(h,m[_-1]))continue;c+=","}c+=W.encode(h.generatedColumn-e),e=h.generatedColumn,h.source!=null&&(v=this._sources.indexOf(h.source),c+=W.encode(v-s),s=v,c+=W.encode(h.originalLine-1-t),t=h.originalLine-1,c+=W.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(d=this._names.indexOf(h.name),c+=W.encode(d-i),i=d)),f+=c}return f},j.prototype._generateSourcesContent=function(e,r){return e.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=M.relative(r,n));var t=M.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,t)?this._sourcesContents[t]:null},this)},j.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(e.file=this._file),this._sourceRoot!=null&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},j.prototype.toString=function(){return JSON.stringify(this.toJSON())};var tr=ie.SourceMapGenerator=j,H={},fe={};(function(o){o.GREATEST_LOWER_BOUND=1,o.LEAST_UPPER_BOUND=2;function e(r,n,t,i,s,f){var c=Math.floor((n-r)/2)+r,h=s(t,i[c],!0);return h===0?c:h>0?n-c>1?e(c,n,t,i,s,f):f==o.LEAST_UPPER_BOUND?n<i.length?n:-1:c:c-r>1?e(r,c,t,i,s,f):f==o.LEAST_UPPER_BOUND?c:r<0?-1:r}o.search=function(n,t,i,s){if(t.length===0)return-1;var f=e(-1,t.length,n,t,i,s||o.GREATEST_LOWER_BOUND);if(f<0)return-1;for(;f-1>=0&&i(t[f],t[f-1],!0)===0;)--f;return f}})(fe);const or=me(fe);var Me={};function je(o){function e(t,i,s){var f=t[i];t[i]=t[s],t[s]=f}function r(t,i){return Math.round(t+Math.random()*(i-t))}function n(t,i,s,f){if(s<f){var c=r(s,f),h=s-1;e(t,c,f);for(var d=t[f],v=s;v<f;v++)i(t[v],d,!1)<=0&&(h+=1,e(t,h,v));e(t,h+1,v);var m=h+1;n(t,i,s,m-1),n(t,i,m+1,f)}}return n}function De(o){let e=je.toString();return new Function(`return ${e}`)()(o)}let Le=new WeakMap;var ir=Me.quickSort=function(o,e,r=0){let n=Le.get(e);n===void 0&&(n=De(e),Le.set(e,n)),n(o,e,r,o.length-1)},p=x,he=fe,B=le.ArraySet,Te=X,q=Me.quickSort;function w(o,e){var r=o;return typeof o=="string"&&(r=p.parseSourceMapInput(o)),r.sections!=null?new T(r,e):new b(r,e)}w.fromSourceMap=function(o,e){return b.fromSourceMap(o,e)},w.prototype._version=3,w.prototype.__generatedMappings=null,Object.defineProperty(w.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),w.prototype.__originalMappings=null,Object.defineProperty(w.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),w.prototype._charIsMappingSeparator=function(e,r){var n=e.charAt(r);return n===";"||n===","},w.prototype._parseMappings=function(e,r){throw new Error("Subclasses must implement _parseMappings")},w.GENERATED_ORDER=1,w.ORIGINAL_ORDER=2,w.GREATEST_LOWER_BOUND=1,w.LEAST_UPPER_BOUND=2,w.prototype.eachMapping=function(e,r,n){var t=r||null,i=n||w.GENERATED_ORDER,s;switch(i){case w.GENERATED_ORDER:s=this._generatedMappings;break;case w.ORIGINAL_ORDER:s=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var f=this.sourceRoot,c=e.bind(t),h=this._names,d=this._sources,v=this._sourceMapURL,m=0,_=s.length;m<_;m++){var C=s[m],S=C.source===null?null:d.at(C.source);S!==null&&(S=p.computeSourceURL(f,S,v)),c({source:S,generatedLine:C.generatedLine,generatedColumn:C.generatedColumn,originalLine:C.originalLine,originalColumn:C.originalColumn,name:C.name===null?null:h.at(C.name)})}},w.prototype.allGeneratedPositionsFor=function(e){var r=p.getArg(e,"line"),n={source:p.getArg(e,"source"),originalLine:r,originalColumn:p.getArg(e,"column",0)};if(n.source=this._findSourceIndex(n.source),n.source<0)return[];var t=[],i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",p.compareByOriginalPositions,he.LEAST_UPPER_BOUND);if(i>=0){var s=this._originalMappings[i];if(e.column===void 0)for(var f=s.originalLine;s&&s.originalLine===f;)t.push({line:p.getArg(s,"generatedLine",null),column:p.getArg(s,"generatedColumn",null),lastColumn:p.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i];else for(var c=s.originalColumn;s&&s.originalLine===r&&s.originalColumn==c;)t.push({line:p.getArg(s,"generatedLine",null),column:p.getArg(s,"generatedColumn",null),lastColumn:p.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i]}return t};var sr=H.SourceMapConsumer=w;function b(o,e){var r=o;typeof o=="string"&&(r=p.parseSourceMapInput(o));var n=p.getArg(r,"version"),t=p.getArg(r,"sources"),i=p.getArg(r,"names",[]),s=p.getArg(r,"sourceRoot",null),f=p.getArg(r,"sourcesContent",null),c=p.getArg(r,"mappings"),h=p.getArg(r,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);s&&(s=p.normalize(s)),t=t.map(String).map(p.normalize).map(function(d){return s&&p.isAbsolute(s)&&p.isAbsolute(d)?p.relative(s,d):d}),this._names=B.fromArray(i.map(String),!0),this._sources=B.fromArray(t,!0),this._absoluteSources=this._sources.toArray().map(function(d){return p.computeSourceURL(s,d,e)}),this.sourceRoot=s,this.sourcesContent=f,this._mappings=c,this._sourceMapURL=e,this.file=h}b.prototype=Object.create(w.prototype),b.prototype.consumer=w,b.prototype._findSourceIndex=function(o){var e=o;if(this.sourceRoot!=null&&(e=p.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);var r;for(r=0;r<this._absoluteSources.length;++r)if(this._absoluteSources[r]==o)return r;return-1},b.fromSourceMap=function(e,r){var n=Object.create(b.prototype),t=n._names=B.fromArray(e._names.toArray(),!0),i=n._sources=B.fromArray(e._sources.toArray(),!0);n.sourceRoot=e._sourceRoot,n.sourcesContent=e._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=e._file,n._sourceMapURL=r,n._absoluteSources=n._sources.toArray().map(function(_){return p.computeSourceURL(n.sourceRoot,_,r)});for(var s=e._mappings.toArray().slice(),f=n.__generatedMappings=[],c=n.__originalMappings=[],h=0,d=s.length;h<d;h++){var v=s[h],m=new be;m.generatedLine=v.generatedLine,m.generatedColumn=v.generatedColumn,v.source&&(m.source=i.indexOf(v.source),m.originalLine=v.originalLine,m.originalColumn=v.originalColumn,v.name&&(m.name=t.indexOf(v.name)),c.push(m)),f.push(m)}return q(n.__originalMappings,p.compareByOriginalPositions),n},b.prototype._version=3,Object.defineProperty(b.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function be(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}const de=p.compareByGeneratedPositionsDeflatedNoLine;function Oe(o,e){let r=o.length,n=o.length-e;if(!(n<=1))if(n==2){let t=o[e],i=o[e+1];de(t,i)>0&&(o[e]=i,o[e+1]=t)}else if(n<20)for(let t=e;t<r;t++)for(let i=t;i>e;i--){let s=o[i-1],f=o[i];if(de(s,f)<=0)break;o[i-1]=f,o[i]=s}else q(o,de,e)}b.prototype._parseMappings=function(e,r){var n=1,t=0,i=0,s=0,f=0,c=0,h=e.length,d=0,v={},m={},_=[],C=[],S,J,E,I,z;let L=0;for(;d<h;)if(e.charAt(d)===";")n++,d++,t=0,Oe(C,L),L=C.length;else if(e.charAt(d)===",")d++;else{for(S=new be,S.generatedLine=n,I=d;I<h&&!this._charIsMappingSeparator(e,I);I++);for(J=e.slice(d,I),E=[];d<I;)Te.decode(e,d,m),z=m.value,d=m.rest,E.push(z);if(E.length===2)throw new Error("Found a source, but no line and column");if(E.length===3)throw new Error("Found a source and line, but no column");if(S.generatedColumn=t+E[0],t=S.generatedColumn,E.length>1&&(S.source=f+E[1],f+=E[1],S.originalLine=i+E[2],i=S.originalLine,S.originalLine+=1,S.originalColumn=s+E[3],s=S.originalColumn,E.length>4&&(S.name=c+E[4],c+=E[4])),C.push(S),typeof S.originalLine=="number"){let y=S.source;for(;_.length<=y;)_.push(null);_[y]===null&&(_[y]=[]),_[y].push(S)}}Oe(C,L),this.__generatedMappings=C;for(var O=0;O<_.length;O++)_[O]!=null&&q(_[O],p.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(..._)},b.prototype._findMapping=function(e,r,n,t,i,s){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[t]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[t]);return he.search(e,r,i,s)},b.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var r=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var n=this._generatedMappings[e+1];if(r.generatedLine===n.generatedLine){r.lastGeneratedColumn=n.generatedColumn-1;continue}}r.lastGeneratedColumn=1/0}},b.prototype.originalPositionFor=function(e){var r={generatedLine:p.getArg(e,"line"),generatedColumn:p.getArg(e,"column")},n=this._findMapping(r,this._generatedMappings,"generatedLine","generatedColumn",p.compareByGeneratedPositionsDeflated,p.getArg(e,"bias",w.GREATEST_LOWER_BOUND));if(n>=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=p.getArg(t,"source",null);i!==null&&(i=this._sources.at(i),i=p.computeSourceURL(this.sourceRoot,i,this._sourceMapURL));var s=p.getArg(t,"name",null);return s!==null&&(s=this._names.at(s)),{source:i,line:p.getArg(t,"originalLine",null),column:p.getArg(t,"originalColumn",null),name:s}}}return{source:null,line:null,column:null,name:null}},b.prototype.hasContentsOfAllSources=function(){return this.sourcesContent?this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return e==null}):!1},b.prototype.sourceContentFor=function(e,r){if(!this.sourcesContent)return null;var n=this._findSourceIndex(e);if(n>=0)return this.sourcesContent[n];var t=e;this.sourceRoot!=null&&(t=p.relative(this.sourceRoot,t));var i;if(this.sourceRoot!=null&&(i=p.urlParse(this.sourceRoot))){var s=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(s))return this.sourcesContent[this._sources.indexOf(s)];if((!i.path||i.path=="/")&&this._sources.has("/"+t))return this.sourcesContent[this._sources.indexOf("/"+t)]}if(r)return null;throw new Error('"'+t+'" is not in the SourceMap.')},b.prototype.generatedPositionFor=function(e){var r=p.getArg(e,"source");if(r=this._findSourceIndex(r),r<0)return{line:null,column:null,lastColumn:null};var n={source:r,originalLine:p.getArg(e,"line"),originalColumn:p.getArg(e,"column")},t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",p.compareByOriginalPositions,p.getArg(e,"bias",w.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source)return{line:p.getArg(i,"generatedLine",null),column:p.getArg(i,"generatedColumn",null),lastColumn:p.getArg(i,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}};var ur=H.BasicSourceMapConsumer=b;function T(o,e){var r=o;typeof o=="string"&&(r=p.parseSourceMapInput(o));var n=p.getArg(r,"version"),t=p.getArg(r,"sections");if(n!=this._version)throw new Error("Unsupported version: "+n);this._sources=new B,this._names=new B;var i={line:-1,column:0};this._sections=t.map(function(s){if(s.url)throw new Error("Support for url field in sections not implemented.");var f=p.getArg(s,"offset"),c=p.getArg(f,"line"),h=p.getArg(f,"column");if(c<i.line||c===i.line&&h<i.column)throw new Error("Section offsets must be ordered and non-overlapping.");return i=f,{generatedOffset:{generatedLine:c+1,generatedColumn:h+1},consumer:new w(p.getArg(s,"map"),e)}})}T.prototype=Object.create(w.prototype),T.prototype.constructor=w,T.prototype._version=3,Object.defineProperty(T.prototype,"sources",{get:function(){for(var o=[],e=0;e<this._sections.length;e++)for(var r=0;r<this._sections[e].consumer.sources.length;r++)o.push(this._sections[e].consumer.sources[r]);return o}}),T.prototype.originalPositionFor=function(e){var r={generatedLine:p.getArg(e,"line"),generatedColumn:p.getArg(e,"column")},n=he.search(r,this._sections,function(i,s){var f=i.generatedLine-s.generatedOffset.generatedLine;return f||i.generatedColumn-s.generatedOffset.generatedColumn}),t=this._sections[n];return t?t.consumer.originalPositionFor({line:r.generatedLine-(t.generatedOffset.generatedLine-1),column:r.generatedColumn-(t.generatedOffset.generatedLine===r.generatedLine?t.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}},T.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},T.prototype.sourceContentFor=function(e,r){for(var n=0;n<this._sections.length;n++){var t=this._sections[n],i=t.consumer.sourceContentFor(e,!0);if(i||i==="")return i}if(r)return null;throw new Error('"'+e+'" is not in the SourceMap.')},T.prototype.generatedPositionFor=function(e){for(var r=0;r<this._sections.length;r++){var n=this._sections[r];if(n.consumer._findSourceIndex(p.getArg(e,"source"))!==-1){var t=n.consumer.generatedPositionFor(e);if(t){var i={line:t.line+(n.generatedOffset.generatedLine-1),column:t.column+(n.generatedOffset.generatedLine===t.line?n.generatedOffset.generatedColumn-1:0)};return i}}}return{line:null,column:null}},T.prototype._parseMappings=function(e,r){this.__generatedMappings=[],this.__originalMappings=[];for(var n=0;n<this._sections.length;n++)for(var t=this._sections[n],i=t.consumer._generatedMappings,s=0;s<i.length;s++){var f=i[s],c=t.consumer._sources.at(f.source);c!==null&&(c=p.computeSourceURL(t.consumer.sourceRoot,c,this._sourceMapURL)),this._sources.add(c),c=this._sources.indexOf(c);var h=null;f.name&&(h=t.consumer._names.at(f.name),this._names.add(h),h=this._names.indexOf(h));var d={source:c,generatedLine:f.generatedLine+(t.generatedOffset.generatedLine-1),generatedColumn:f.generatedColumn+(t.generatedOffset.generatedLine===f.generatedLine?t.generatedOffset.generatedColumn-1:0),originalLine:f.originalLine,originalColumn:f.originalColumn,name:h};this.__generatedMappings.push(d),typeof d.originalLine=="number"&&this.__originalMappings.push(d)}q(this.__generatedMappings,p.compareByGeneratedPositionsDeflated),q(this.__originalMappings,p.compareByOriginalPositions)};var lr=H.IndexedSourceMapConsumer=T,Ae={},Pe=ie.SourceMapGenerator,ee=x,ke=/(\r?\n)/,Fe=10,V="$$$isSourceNode$$$";function $(o,e,r,n,t){this.children=[],this.sourceContents={},this.line=o??null,this.column=e??null,this.source=r??null,this.name=t??null,this[V]=!0,n!=null&&this.add(n)}$.fromStringWithSourceMap=function(e,r,n){var t=new $,i=e.split(ke),s=0,f=function(){var m=C(),_=C()||"";return m+_;function C(){return s<i.length?i[s++]:void 0}},c=1,h=0,d=null;return r.eachMapping(function(m){if(d!==null)if(c<m.generatedLine)v(d,f()),c++,h=0;else{var _=i[s]||"",C=_.substr(0,m.generatedColumn-h);i[s]=_.substr(m.generatedColumn-h),h=m.generatedColumn,v(d,C),d=m;return}for(;c<m.generatedLine;)t.add(f()),c++;if(h<m.generatedColumn){var _=i[s]||"";t.add(_.substr(0,m.generatedColumn)),i[s]=_.substr(m.generatedColumn),h=m.generatedColumn}d=m},this),s<i.length&&(d&&v(d,f()),t.add(i.splice(s).join(""))),r.sources.forEach(function(m){var _=r.sourceContentFor(m);_!=null&&(n!=null&&(m=ee.join(n,m)),t.setSourceContent(m,_))}),t;function v(m,_){if(m===null||m.source===void 0)t.add(_);else{var C=n?ee.join(n,m.source):m.source;t.add(new $(m.originalLine,m.originalColumn,C,_,m.name))}}},$.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(r){this.add(r)},this);else if(e[V]||typeof e=="string")e&&this.children.push(e);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);return this},$.prototype.prepend=function(e){if(Array.isArray(e))for(var r=e.length-1;r>=0;r--)this.prepend(e[r]);else if(e[V]||typeof e=="string")this.children.unshift(e);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);return this},$.prototype.walk=function(e){for(var r,n=0,t=this.children.length;n<t;n++)r=this.children[n],r[V]?r.walk(e):r!==""&&e(r,{source:this.source,line:this.line,column:this.column,name:this.name})},$.prototype.join=function(e){var r,n,t=this.children.length;if(t>0){for(r=[],n=0;n<t-1;n++)r.push(this.children[n]),r.push(e);r.push(this.children[n]),this.children=r}return this},$.prototype.replaceRight=function(e,r){var n=this.children[this.children.length-1];return n[V]?n.replaceRight(e,r):typeof n=="string"?this.children[this.children.length-1]=n.replace(e,r):this.children.push("".replace(e,r)),this},$.prototype.setSourceContent=function(e,r){this.sourceContents[ee.toSetString(e)]=r},$.prototype.walkSourceContents=function(e){for(var r=0,n=this.children.length;r<n;r++)this.children[r][V]&&this.children[r].walkSourceContents(e);for(var t=Object.keys(this.sourceContents),r=0,n=t.length;r<n;r++)e(ee.fromSetString(t[r]),this.sourceContents[t[r]])},$.prototype.toString=function(){var e="";return this.walk(function(r){e+=r}),e},$.prototype.toStringWithSourceMap=function(e){var r={code:"",line:1,column:0},n=new Pe(e),t=!1,i=null,s=null,f=null,c=null;return this.walk(function(h,d){r.code+=h,d.source!==null&&d.line!==null&&d.column!==null?((i!==d.source||s!==d.line||f!==d.column||c!==d.name)&&n.addMapping({source:d.source,original:{line:d.line,column:d.column},generated:{line:r.line,column:r.column},name:d.name}),i=d.source,s=d.line,f=d.column,c=d.name,t=!0):t&&(n.addMapping({generated:{line:r.line,column:r.column}}),i=null,t=!1);for(var v=0,m=h.length;v<m;v++)h.charCodeAt(v)===Fe?(r.line++,r.column=0,v+1===m?(i=null,t=!1):t&&n.addMapping({source:d.source,original:{line:d.line,column:d.column},generated:{line:r.line,column:r.column},name:d.name})):r.column++}),this.walkSourceContents(function(h,d){n.setSourceContent(h,d)}),{code:r.code,map:n}};var ar=Ae.SourceNode=$,cr=oe.SourceMapGenerator=ie.SourceMapGenerator,ze=oe.SourceMapConsumer=H.SourceMapConsumer,fr=oe.SourceNode=Ae.SourceNode;class Ie{constructor(e){D(this,"options",null);e&&(this.options=e)}parseStackTrace(e){const n=e.split(`
1
+ (function(A,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(A=typeof globalThis<"u"?globalThis:A||self,R(A.KingMonitor={}))})(this,function(A){"use strict";var We=Object.defineProperty;var qe=(A,R,Q)=>R in A?We(A,R,{enumerable:!0,configurable:!0,writable:!0,value:Q}):A[R]=Q;var D=(A,R,Q)=>qe(A,typeof R!="symbol"?R+"":R,Q);class R{constructor(){D(this,"events",new Map)}on(e,r){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(r)}off(e,r){const n=this.events.get(e);n&&(n.delete(r),n.size===0&&this.events.delete(e))}emit(e,...r){const n=this.events.get(e);n&&n.forEach(t=>{try{t(...r)}catch(i){console.error(`Error in event handler for ${e}:`,i)}})}clear(){this.events.clear()}getSubscriberCount(e){const r=this.events.get(e);return r?r.size:0}hasSubscribers(e){return this.getSubscriberCount(e)>0}}var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function me(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Je(o){return o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Ke(o){return o&&Object.prototype.hasOwnProperty.call(o,"default")&&Object.keys(o).length===1?o.default:o}function Xe(o){if(o.__esModule)return o;var e=o.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(o).forEach(function(n){var t=Object.getOwnPropertyDescriptor(o,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return o[n]}})}),r}var oe={},ie={},X={},se={},ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ze=se.encode=function(o){if(0<=o&&o<ve.length)return ve[o];throw new TypeError("Must be between 0 and 63: "+o)},Ye=se.decode=function(o){var e=65,r=90,n=97,t=122,i=48,s=57,f=43,c=47,h=26,d=52;return e<=o&&o<=r?o-e:n<=o&&o<=t?o-n+h:i<=o&&o<=s?o-i+d:o==f?62:o==c?63:-1},_e=se,ue=5,Se=1<<ue,ye=Se-1,Ce=Se;function Ne(o){return o<0?(-o<<1)+1:(o<<1)+0}function Re(o){var e=(o&1)===1,r=o>>1;return e?-r:r}var He=X.encode=function(e){var r="",n,t=Ne(e);do n=t&ye,t>>>=ue,t>0&&(n|=Ce),r+=_e.encode(n);while(t>0);return r},er=X.decode=function(e,r,n){var t=e.length,i=0,s=0,f,c;do{if(r>=t)throw new Error("Expected more digits in base 64 VLQ value.");if(c=_e.decode(e.charCodeAt(r++)),c===-1)throw new Error("Invalid base64 digit: "+e.charAt(r-1));f=!!(c&Ce),c&=ye,i=i+(c<<s),s+=ue}while(f);n.value=Re(i),n.rest=r},x={};(function(o){function e(u,l,g){if(l in u)return u[l];if(arguments.length===3)return g;throw new Error('"'+l+'" is a required argument.')}o.getArg=e;var r=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,n=/^data:.+\,.+$/;function t(u){var l=u.match(r);return l?{scheme:l[1],auth:l[2],host:l[3],port:l[4],path:l[5]}:null}o.urlParse=t;function i(u){var l="";return u.scheme&&(l+=u.scheme+":"),l+="//",u.auth&&(l+=u.auth+"@"),u.host&&(l+=u.host),u.port&&(l+=":"+u.port),u.path&&(l+=u.path),l}o.urlGenerate=i;var s=32;function f(u){var l=[];return function(g){for(var a=0;a<l.length;a++)if(l[a].input===g){var F=l[0];return l[0]=l[a],l[a]=F,l[0].result}var P=u(g);return l.unshift({input:g,result:P}),l.length>s&&l.pop(),P}}var c=f(function(l){var g=l,a=t(l);if(a){if(!a.path)return l;g=a.path}for(var F=o.isAbsolute(g),P=[],ne=0,N=0;;)if(ne=N,N=g.indexOf("/",ne),N===-1){P.push(g.slice(ne));break}else for(P.push(g.slice(ne,N));N<g.length&&g[N]==="/";)N++;for(var te,K=0,N=P.length-1;N>=0;N--)te=P[N],te==="."?P.splice(N,1):te===".."?K++:K>0&&(te===""?(P.splice(N+1,K),K=0):(P.splice(N,2),K--));return g=P.join("/"),g===""&&(g=F?"/":"."),a?(a.path=g,i(a)):g});o.normalize=c;function h(u,l){u===""&&(u="."),l===""&&(l=".");var g=t(l),a=t(u);if(a&&(u=a.path||"/"),g&&!g.scheme)return a&&(g.scheme=a.scheme),i(g);if(g||l.match(n))return l;if(a&&!a.host&&!a.path)return a.host=l,i(a);var F=l.charAt(0)==="/"?l:c(u.replace(/\/+$/,"")+"/"+l);return a?(a.path=F,i(a)):F}o.join=h,o.isAbsolute=function(u){return u.charAt(0)==="/"||r.test(u)};function d(u,l){u===""&&(u="."),u=u.replace(/\/$/,"");for(var g=0;l.indexOf(u+"/")!==0;){var a=u.lastIndexOf("/");if(a<0||(u=u.slice(0,a),u.match(/^([^\/]+:\/)?\/*$/)))return l;++g}return Array(g+1).join("../")+l.substr(u.length+1)}o.relative=d;var v=function(){var u=Object.create(null);return!("__proto__"in u)}();function m(u){return u}function _(u){return S(u)?"$"+u:u}o.toSetString=v?m:_;function C(u){return S(u)?u.slice(1):u}o.fromSetString=v?m:C;function S(u){if(!u)return!1;var l=u.length;if(l<9||u.charCodeAt(l-1)!==95||u.charCodeAt(l-2)!==95||u.charCodeAt(l-3)!==111||u.charCodeAt(l-4)!==116||u.charCodeAt(l-5)!==111||u.charCodeAt(l-6)!==114||u.charCodeAt(l-7)!==112||u.charCodeAt(l-8)!==95||u.charCodeAt(l-9)!==95)return!1;for(var g=l-10;g>=0;g--)if(u.charCodeAt(g)!==36)return!1;return!0}function J(u,l,g){var a=L(u.source,l.source);return a!==0||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0||g)||(a=u.generatedColumn-l.generatedColumn,a!==0)||(a=u.generatedLine-l.generatedLine,a!==0)?a:L(u.name,l.name)}o.compareByOriginalPositions=J;function E(u,l,g){var a;return a=u.originalLine-l.originalLine,a!==0||(a=u.originalColumn-l.originalColumn,a!==0||g)||(a=u.generatedColumn-l.generatedColumn,a!==0)||(a=u.generatedLine-l.generatedLine,a!==0)?a:L(u.name,l.name)}o.compareByOriginalPositionsNoSource=E;function I(u,l,g){var a=u.generatedLine-l.generatedLine;return a!==0||(a=u.generatedColumn-l.generatedColumn,a!==0||g)||(a=L(u.source,l.source),a!==0)||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0)?a:L(u.name,l.name)}o.compareByGeneratedPositionsDeflated=I;function z(u,l,g){var a=u.generatedColumn-l.generatedColumn;return a!==0||g||(a=L(u.source,l.source),a!==0)||(a=u.originalLine-l.originalLine,a!==0)||(a=u.originalColumn-l.originalColumn,a!==0)?a:L(u.name,l.name)}o.compareByGeneratedPositionsDeflatedNoLine=z;function L(u,l){return u===l?0:u===null?1:l===null?-1:u>l?1:-1}function O(u,l){var g=u.generatedLine-l.generatedLine;return g!==0||(g=u.generatedColumn-l.generatedColumn,g!==0)||(g=L(u.source,l.source),g!==0)||(g=u.originalLine-l.originalLine,g!==0)||(g=u.originalColumn-l.originalColumn,g!==0)?g:L(u.name,l.name)}o.compareByGeneratedPositionsInflated=O;function y(u){return JSON.parse(u.replace(/^\)]}'[^\n]*\n/,""))}o.parseSourceMapInput=y;function re(u,l,g){if(l=l||"",u&&(u[u.length-1]!=="/"&&l[0]!=="/"&&(u+="/"),l=u+l),g){var a=t(g);if(!a)throw new Error("sourceMapURL could not be parsed");if(a.path){var F=a.path.lastIndexOf("/");F>=0&&(a.path=a.path.substring(0,F+1))}l=h(i(a),l)}return c(l)}o.computeSourceURL=re})(x);const rr=me(x);var le={},ae=x,ce=Object.prototype.hasOwnProperty,B=typeof Map<"u";function k(){this._array=[],this._set=B?new Map:Object.create(null)}k.fromArray=function(e,r){for(var n=new k,t=0,i=e.length;t<i;t++)n.add(e[t],r);return n},k.prototype.size=function(){return B?this._set.size:Object.getOwnPropertyNames(this._set).length},k.prototype.add=function(e,r){var n=B?e:ae.toSetString(e),t=B?this.has(e):ce.call(this._set,n),i=this._array.length;(!t||r)&&this._array.push(e),t||(B?this._set.set(e,i):this._set[n]=i)},k.prototype.has=function(e){if(B)return this._set.has(e);var r=ae.toSetString(e);return ce.call(this._set,r)},k.prototype.indexOf=function(e){if(B){var r=this._set.get(e);if(r>=0)return r}else{var n=ae.toSetString(e);if(ce.call(this._set,n))return this._set[n]}throw new Error('"'+e+'" is not in the set.')},k.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},k.prototype.toArray=function(){return this._array.slice()};var nr=le.ArraySet=k,we={},Ee=x;function $e(o,e){var r=o.generatedLine,n=e.generatedLine,t=o.generatedColumn,i=e.generatedColumn;return n>r||n==r&&i>=t||Ee.compareByGeneratedPositionsInflated(o,e)<=0}function Z(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Z.prototype.unsortedForEach=function(e,r){this._array.forEach(e,r)},Z.prototype.add=function(e){$e(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},Z.prototype.toArray=function(){return this._sorted||(this._array.sort(Ee.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};var tr=we.MappingList=Z,W=X,M=x,Y=le.ArraySet,Ge=we.MappingList;function T(o){o||(o={}),this._file=M.getArg(o,"file",null),this._sourceRoot=M.getArg(o,"sourceRoot",null),this._skipValidation=M.getArg(o,"skipValidation",!1),this._ignoreInvalidMapping=M.getArg(o,"ignoreInvalidMapping",!1),this._sources=new Y,this._names=new Y,this._mappings=new Ge,this._sourcesContents=null}T.prototype._version=3,T.fromSourceMap=function(e,r){var n=e.sourceRoot,t=new T(Object.assign(r||{},{file:e.file,sourceRoot:n}));return e.eachMapping(function(i){var s={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(s.source=i.source,n!=null&&(s.source=M.relative(n,s.source)),s.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(s.name=i.name)),t.addMapping(s)}),e.sources.forEach(function(i){var s=i;n!==null&&(s=M.relative(n,i)),t._sources.has(s)||t._sources.add(s);var f=e.sourceContentFor(i);f!=null&&t.setSourceContent(i,f)}),t},T.prototype.addMapping=function(e){var r=M.getArg(e,"generated"),n=M.getArg(e,"original",null),t=M.getArg(e,"source",null),i=M.getArg(e,"name",null);!this._skipValidation&&this._validateMapping(r,n,t,i)===!1||(t!=null&&(t=String(t),this._sources.has(t)||this._sources.add(t)),i!=null&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i}))},T.prototype.setSourceContent=function(e,r){var n=e;this._sourceRoot!=null&&(n=M.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[M.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[M.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},T.prototype.applySourceMap=function(e,r,n){var t=r;if(r==null){if(e.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);t=e.file}var i=this._sourceRoot;i!=null&&(t=M.relative(i,t));var s=new Y,f=new Y;this._mappings.unsortedForEach(function(c){if(c.source===t&&c.originalLine!=null){var h=e.originalPositionFor({line:c.originalLine,column:c.originalColumn});h.source!=null&&(c.source=h.source,n!=null&&(c.source=M.join(n,c.source)),i!=null&&(c.source=M.relative(i,c.source)),c.originalLine=h.line,c.originalColumn=h.column,h.name!=null&&(c.name=h.name))}var d=c.source;d!=null&&!s.has(d)&&s.add(d);var v=c.name;v!=null&&!f.has(v)&&f.add(v)},this),this._sources=s,this._names=f,e.sources.forEach(function(c){var h=e.sourceContentFor(c);h!=null&&(n!=null&&(c=M.join(n,c)),i!=null&&(c=M.relative(i,c)),this.setSourceContent(c,h))},this)},T.prototype._validateMapping=function(e,r,n,t){if(r&&typeof r.line!="number"&&typeof r.column!="number"){var i="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t)){if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n)return;var i="Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t});if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(i),!1;throw new Error(i)}},T.prototype._serializeMappings=function(){for(var e=0,r=1,n=0,t=0,i=0,s=0,f="",c,h,d,v,m=this._mappings.toArray(),_=0,C=m.length;_<C;_++){if(h=m[_],c="",h.generatedLine!==r)for(e=0;h.generatedLine!==r;)c+=";",r++;else if(_>0){if(!M.compareByGeneratedPositionsInflated(h,m[_-1]))continue;c+=","}c+=W.encode(h.generatedColumn-e),e=h.generatedColumn,h.source!=null&&(v=this._sources.indexOf(h.source),c+=W.encode(v-s),s=v,c+=W.encode(h.originalLine-1-t),t=h.originalLine-1,c+=W.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(d=this._names.indexOf(h.name),c+=W.encode(d-i),i=d)),f+=c}return f},T.prototype._generateSourcesContent=function(e,r){return e.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=M.relative(r,n));var t=M.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,t)?this._sourcesContents[t]:null},this)},T.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(e.file=this._file),this._sourceRoot!=null&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},T.prototype.toString=function(){return JSON.stringify(this.toJSON())};var or=ie.SourceMapGenerator=T,H={},fe={};(function(o){o.GREATEST_LOWER_BOUND=1,o.LEAST_UPPER_BOUND=2;function e(r,n,t,i,s,f){var c=Math.floor((n-r)/2)+r,h=s(t,i[c],!0);return h===0?c:h>0?n-c>1?e(c,n,t,i,s,f):f==o.LEAST_UPPER_BOUND?n<i.length?n:-1:c:c-r>1?e(r,c,t,i,s,f):f==o.LEAST_UPPER_BOUND?c:r<0?-1:r}o.search=function(n,t,i,s){if(t.length===0)return-1;var f=e(-1,t.length,n,t,i,s||o.GREATEST_LOWER_BOUND);if(f<0)return-1;for(;f-1>=0&&i(t[f],t[f-1],!0)===0;)--f;return f}})(fe);const ir=me(fe);var Me={};function Te(o){function e(t,i,s){var f=t[i];t[i]=t[s],t[s]=f}function r(t,i){return Math.round(t+Math.random()*(i-t))}function n(t,i,s,f){if(s<f){var c=r(s,f),h=s-1;e(t,c,f);for(var d=t[f],v=s;v<f;v++)i(t[v],d,!1)<=0&&(h+=1,e(t,h,v));e(t,h+1,v);var m=h+1;n(t,i,s,m-1),n(t,i,m+1,f)}}return n}function De(o){let e=Te.toString();return new Function(`return ${e}`)()(o)}let Le=new WeakMap;var sr=Me.quickSort=function(o,e,r=0){let n=Le.get(e);n===void 0&&(n=De(e),Le.set(e,n)),n(o,e,r,o.length-1)},p=x,he=fe,U=le.ArraySet,je=X,q=Me.quickSort;function w(o,e){var r=o;return typeof o=="string"&&(r=p.parseSourceMapInput(o)),r.sections!=null?new j(r,e):new b(r,e)}w.fromSourceMap=function(o,e){return b.fromSourceMap(o,e)},w.prototype._version=3,w.prototype.__generatedMappings=null,Object.defineProperty(w.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),w.prototype.__originalMappings=null,Object.defineProperty(w.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),w.prototype._charIsMappingSeparator=function(e,r){var n=e.charAt(r);return n===";"||n===","},w.prototype._parseMappings=function(e,r){throw new Error("Subclasses must implement _parseMappings")},w.GENERATED_ORDER=1,w.ORIGINAL_ORDER=2,w.GREATEST_LOWER_BOUND=1,w.LEAST_UPPER_BOUND=2,w.prototype.eachMapping=function(e,r,n){var t=r||null,i=n||w.GENERATED_ORDER,s;switch(i){case w.GENERATED_ORDER:s=this._generatedMappings;break;case w.ORIGINAL_ORDER:s=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var f=this.sourceRoot,c=e.bind(t),h=this._names,d=this._sources,v=this._sourceMapURL,m=0,_=s.length;m<_;m++){var C=s[m],S=C.source===null?null:d.at(C.source);S!==null&&(S=p.computeSourceURL(f,S,v)),c({source:S,generatedLine:C.generatedLine,generatedColumn:C.generatedColumn,originalLine:C.originalLine,originalColumn:C.originalColumn,name:C.name===null?null:h.at(C.name)})}},w.prototype.allGeneratedPositionsFor=function(e){var r=p.getArg(e,"line"),n={source:p.getArg(e,"source"),originalLine:r,originalColumn:p.getArg(e,"column",0)};if(n.source=this._findSourceIndex(n.source),n.source<0)return[];var t=[],i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",p.compareByOriginalPositions,he.LEAST_UPPER_BOUND);if(i>=0){var s=this._originalMappings[i];if(e.column===void 0)for(var f=s.originalLine;s&&s.originalLine===f;)t.push({line:p.getArg(s,"generatedLine",null),column:p.getArg(s,"generatedColumn",null),lastColumn:p.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i];else for(var c=s.originalColumn;s&&s.originalLine===r&&s.originalColumn==c;)t.push({line:p.getArg(s,"generatedLine",null),column:p.getArg(s,"generatedColumn",null),lastColumn:p.getArg(s,"lastGeneratedColumn",null)}),s=this._originalMappings[++i]}return t};var ur=H.SourceMapConsumer=w;function b(o,e){var r=o;typeof o=="string"&&(r=p.parseSourceMapInput(o));var n=p.getArg(r,"version"),t=p.getArg(r,"sources"),i=p.getArg(r,"names",[]),s=p.getArg(r,"sourceRoot",null),f=p.getArg(r,"sourcesContent",null),c=p.getArg(r,"mappings"),h=p.getArg(r,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);s&&(s=p.normalize(s)),t=t.map(String).map(p.normalize).map(function(d){return s&&p.isAbsolute(s)&&p.isAbsolute(d)?p.relative(s,d):d}),this._names=U.fromArray(i.map(String),!0),this._sources=U.fromArray(t,!0),this._absoluteSources=this._sources.toArray().map(function(d){return p.computeSourceURL(s,d,e)}),this.sourceRoot=s,this.sourcesContent=f,this._mappings=c,this._sourceMapURL=e,this.file=h}b.prototype=Object.create(w.prototype),b.prototype.consumer=w,b.prototype._findSourceIndex=function(o){var e=o;if(this.sourceRoot!=null&&(e=p.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);var r;for(r=0;r<this._absoluteSources.length;++r)if(this._absoluteSources[r]==o)return r;return-1},b.fromSourceMap=function(e,r){var n=Object.create(b.prototype),t=n._names=U.fromArray(e._names.toArray(),!0),i=n._sources=U.fromArray(e._sources.toArray(),!0);n.sourceRoot=e._sourceRoot,n.sourcesContent=e._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=e._file,n._sourceMapURL=r,n._absoluteSources=n._sources.toArray().map(function(_){return p.computeSourceURL(n.sourceRoot,_,r)});for(var s=e._mappings.toArray().slice(),f=n.__generatedMappings=[],c=n.__originalMappings=[],h=0,d=s.length;h<d;h++){var v=s[h],m=new be;m.generatedLine=v.generatedLine,m.generatedColumn=v.generatedColumn,v.source&&(m.source=i.indexOf(v.source),m.originalLine=v.originalLine,m.originalColumn=v.originalColumn,v.name&&(m.name=t.indexOf(v.name)),c.push(m)),f.push(m)}return q(n.__originalMappings,p.compareByOriginalPositions),n},b.prototype._version=3,Object.defineProperty(b.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function be(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}const de=p.compareByGeneratedPositionsDeflatedNoLine;function Oe(o,e){let r=o.length,n=o.length-e;if(!(n<=1))if(n==2){let t=o[e],i=o[e+1];de(t,i)>0&&(o[e]=i,o[e+1]=t)}else if(n<20)for(let t=e;t<r;t++)for(let i=t;i>e;i--){let s=o[i-1],f=o[i];if(de(s,f)<=0)break;o[i-1]=f,o[i]=s}else q(o,de,e)}b.prototype._parseMappings=function(e,r){var n=1,t=0,i=0,s=0,f=0,c=0,h=e.length,d=0,v={},m={},_=[],C=[],S,J,E,I,z;let L=0;for(;d<h;)if(e.charAt(d)===";")n++,d++,t=0,Oe(C,L),L=C.length;else if(e.charAt(d)===",")d++;else{for(S=new be,S.generatedLine=n,I=d;I<h&&!this._charIsMappingSeparator(e,I);I++);for(J=e.slice(d,I),E=[];d<I;)je.decode(e,d,m),z=m.value,d=m.rest,E.push(z);if(E.length===2)throw new Error("Found a source, but no line and column");if(E.length===3)throw new Error("Found a source and line, but no column");if(S.generatedColumn=t+E[0],t=S.generatedColumn,E.length>1&&(S.source=f+E[1],f+=E[1],S.originalLine=i+E[2],i=S.originalLine,S.originalLine+=1,S.originalColumn=s+E[3],s=S.originalColumn,E.length>4&&(S.name=c+E[4],c+=E[4])),C.push(S),typeof S.originalLine=="number"){let y=S.source;for(;_.length<=y;)_.push(null);_[y]===null&&(_[y]=[]),_[y].push(S)}}Oe(C,L),this.__generatedMappings=C;for(var O=0;O<_.length;O++)_[O]!=null&&q(_[O],p.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(..._)},b.prototype._findMapping=function(e,r,n,t,i,s){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[t]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[t]);return he.search(e,r,i,s)},b.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var r=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var n=this._generatedMappings[e+1];if(r.generatedLine===n.generatedLine){r.lastGeneratedColumn=n.generatedColumn-1;continue}}r.lastGeneratedColumn=1/0}},b.prototype.originalPositionFor=function(e){var r={generatedLine:p.getArg(e,"line"),generatedColumn:p.getArg(e,"column")},n=this._findMapping(r,this._generatedMappings,"generatedLine","generatedColumn",p.compareByGeneratedPositionsDeflated,p.getArg(e,"bias",w.GREATEST_LOWER_BOUND));if(n>=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=p.getArg(t,"source",null);i!==null&&(i=this._sources.at(i),i=p.computeSourceURL(this.sourceRoot,i,this._sourceMapURL));var s=p.getArg(t,"name",null);return s!==null&&(s=this._names.at(s)),{source:i,line:p.getArg(t,"originalLine",null),column:p.getArg(t,"originalColumn",null),name:s}}}return{source:null,line:null,column:null,name:null}},b.prototype.hasContentsOfAllSources=function(){return this.sourcesContent?this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return e==null}):!1},b.prototype.sourceContentFor=function(e,r){if(!this.sourcesContent)return null;var n=this._findSourceIndex(e);if(n>=0)return this.sourcesContent[n];var t=e;this.sourceRoot!=null&&(t=p.relative(this.sourceRoot,t));var i;if(this.sourceRoot!=null&&(i=p.urlParse(this.sourceRoot))){var s=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(s))return this.sourcesContent[this._sources.indexOf(s)];if((!i.path||i.path=="/")&&this._sources.has("/"+t))return this.sourcesContent[this._sources.indexOf("/"+t)]}if(r)return null;throw new Error('"'+t+'" is not in the SourceMap.')},b.prototype.generatedPositionFor=function(e){var r=p.getArg(e,"source");if(r=this._findSourceIndex(r),r<0)return{line:null,column:null,lastColumn:null};var n={source:r,originalLine:p.getArg(e,"line"),originalColumn:p.getArg(e,"column")},t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",p.compareByOriginalPositions,p.getArg(e,"bias",w.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source)return{line:p.getArg(i,"generatedLine",null),column:p.getArg(i,"generatedColumn",null),lastColumn:p.getArg(i,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}};var lr=H.BasicSourceMapConsumer=b;function j(o,e){var r=o;typeof o=="string"&&(r=p.parseSourceMapInput(o));var n=p.getArg(r,"version"),t=p.getArg(r,"sections");if(n!=this._version)throw new Error("Unsupported version: "+n);this._sources=new U,this._names=new U;var i={line:-1,column:0};this._sections=t.map(function(s){if(s.url)throw new Error("Support for url field in sections not implemented.");var f=p.getArg(s,"offset"),c=p.getArg(f,"line"),h=p.getArg(f,"column");if(c<i.line||c===i.line&&h<i.column)throw new Error("Section offsets must be ordered and non-overlapping.");return i=f,{generatedOffset:{generatedLine:c+1,generatedColumn:h+1},consumer:new w(p.getArg(s,"map"),e)}})}j.prototype=Object.create(w.prototype),j.prototype.constructor=w,j.prototype._version=3,Object.defineProperty(j.prototype,"sources",{get:function(){for(var o=[],e=0;e<this._sections.length;e++)for(var r=0;r<this._sections[e].consumer.sources.length;r++)o.push(this._sections[e].consumer.sources[r]);return o}}),j.prototype.originalPositionFor=function(e){var r={generatedLine:p.getArg(e,"line"),generatedColumn:p.getArg(e,"column")},n=he.search(r,this._sections,function(i,s){var f=i.generatedLine-s.generatedOffset.generatedLine;return f||i.generatedColumn-s.generatedOffset.generatedColumn}),t=this._sections[n];return t?t.consumer.originalPositionFor({line:r.generatedLine-(t.generatedOffset.generatedLine-1),column:r.generatedColumn-(t.generatedOffset.generatedLine===r.generatedLine?t.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}},j.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},j.prototype.sourceContentFor=function(e,r){for(var n=0;n<this._sections.length;n++){var t=this._sections[n],i=t.consumer.sourceContentFor(e,!0);if(i||i==="")return i}if(r)return null;throw new Error('"'+e+'" is not in the SourceMap.')},j.prototype.generatedPositionFor=function(e){for(var r=0;r<this._sections.length;r++){var n=this._sections[r];if(n.consumer._findSourceIndex(p.getArg(e,"source"))!==-1){var t=n.consumer.generatedPositionFor(e);if(t){var i={line:t.line+(n.generatedOffset.generatedLine-1),column:t.column+(n.generatedOffset.generatedLine===t.line?n.generatedOffset.generatedColumn-1:0)};return i}}}return{line:null,column:null}},j.prototype._parseMappings=function(e,r){this.__generatedMappings=[],this.__originalMappings=[];for(var n=0;n<this._sections.length;n++)for(var t=this._sections[n],i=t.consumer._generatedMappings,s=0;s<i.length;s++){var f=i[s],c=t.consumer._sources.at(f.source);c!==null&&(c=p.computeSourceURL(t.consumer.sourceRoot,c,this._sourceMapURL)),this._sources.add(c),c=this._sources.indexOf(c);var h=null;f.name&&(h=t.consumer._names.at(f.name),this._names.add(h),h=this._names.indexOf(h));var d={source:c,generatedLine:f.generatedLine+(t.generatedOffset.generatedLine-1),generatedColumn:f.generatedColumn+(t.generatedOffset.generatedLine===f.generatedLine?t.generatedOffset.generatedColumn-1:0),originalLine:f.originalLine,originalColumn:f.originalColumn,name:h};this.__generatedMappings.push(d),typeof d.originalLine=="number"&&this.__originalMappings.push(d)}q(this.__generatedMappings,p.compareByGeneratedPositionsDeflated),q(this.__originalMappings,p.compareByOriginalPositions)};var ar=H.IndexedSourceMapConsumer=j,Ae={},Pe=ie.SourceMapGenerator,ee=x,ke=/(\r?\n)/,Fe=10,V="$$$isSourceNode$$$";function $(o,e,r,n,t){this.children=[],this.sourceContents={},this.line=o??null,this.column=e??null,this.source=r??null,this.name=t??null,this[V]=!0,n!=null&&this.add(n)}$.fromStringWithSourceMap=function(e,r,n){var t=new $,i=e.split(ke),s=0,f=function(){var m=C(),_=C()||"";return m+_;function C(){return s<i.length?i[s++]:void 0}},c=1,h=0,d=null;return r.eachMapping(function(m){if(d!==null)if(c<m.generatedLine)v(d,f()),c++,h=0;else{var _=i[s]||"",C=_.substr(0,m.generatedColumn-h);i[s]=_.substr(m.generatedColumn-h),h=m.generatedColumn,v(d,C),d=m;return}for(;c<m.generatedLine;)t.add(f()),c++;if(h<m.generatedColumn){var _=i[s]||"";t.add(_.substr(0,m.generatedColumn)),i[s]=_.substr(m.generatedColumn),h=m.generatedColumn}d=m},this),s<i.length&&(d&&v(d,f()),t.add(i.splice(s).join(""))),r.sources.forEach(function(m){var _=r.sourceContentFor(m);_!=null&&(n!=null&&(m=ee.join(n,m)),t.setSourceContent(m,_))}),t;function v(m,_){if(m===null||m.source===void 0)t.add(_);else{var C=n?ee.join(n,m.source):m.source;t.add(new $(m.originalLine,m.originalColumn,C,_,m.name))}}},$.prototype.add=function(e){if(Array.isArray(e))e.forEach(function(r){this.add(r)},this);else if(e[V]||typeof e=="string")e&&this.children.push(e);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);return this},$.prototype.prepend=function(e){if(Array.isArray(e))for(var r=e.length-1;r>=0;r--)this.prepend(e[r]);else if(e[V]||typeof e=="string")this.children.unshift(e);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);return this},$.prototype.walk=function(e){for(var r,n=0,t=this.children.length;n<t;n++)r=this.children[n],r[V]?r.walk(e):r!==""&&e(r,{source:this.source,line:this.line,column:this.column,name:this.name})},$.prototype.join=function(e){var r,n,t=this.children.length;if(t>0){for(r=[],n=0;n<t-1;n++)r.push(this.children[n]),r.push(e);r.push(this.children[n]),this.children=r}return this},$.prototype.replaceRight=function(e,r){var n=this.children[this.children.length-1];return n[V]?n.replaceRight(e,r):typeof n=="string"?this.children[this.children.length-1]=n.replace(e,r):this.children.push("".replace(e,r)),this},$.prototype.setSourceContent=function(e,r){this.sourceContents[ee.toSetString(e)]=r},$.prototype.walkSourceContents=function(e){for(var r=0,n=this.children.length;r<n;r++)this.children[r][V]&&this.children[r].walkSourceContents(e);for(var t=Object.keys(this.sourceContents),r=0,n=t.length;r<n;r++)e(ee.fromSetString(t[r]),this.sourceContents[t[r]])},$.prototype.toString=function(){var e="";return this.walk(function(r){e+=r}),e},$.prototype.toStringWithSourceMap=function(e){var r={code:"",line:1,column:0},n=new Pe(e),t=!1,i=null,s=null,f=null,c=null;return this.walk(function(h,d){r.code+=h,d.source!==null&&d.line!==null&&d.column!==null?((i!==d.source||s!==d.line||f!==d.column||c!==d.name)&&n.addMapping({source:d.source,original:{line:d.line,column:d.column},generated:{line:r.line,column:r.column},name:d.name}),i=d.source,s=d.line,f=d.column,c=d.name,t=!0):t&&(n.addMapping({generated:{line:r.line,column:r.column}}),i=null,t=!1);for(var v=0,m=h.length;v<m;v++)h.charCodeAt(v)===Fe?(r.line++,r.column=0,v+1===m?(i=null,t=!1):t&&n.addMapping({source:d.source,original:{line:d.line,column:d.column},generated:{line:r.line,column:r.column},name:d.name})):r.column++}),this.walkSourceContents(function(h,d){n.setSourceContent(h,d)}),{code:r.code,map:n}};var cr=Ae.SourceNode=$,fr=oe.SourceMapGenerator=ie.SourceMapGenerator,ze=oe.SourceMapConsumer=H.SourceMapConsumer,hr=oe.SourceNode=Ae.SourceNode;class Ie{constructor(e){D(this,"options",null);e&&(this.options=e)}parseStackTrace(e){const n=e.split(`
2
2
  `).find(h=>h.includes(".js:")||h.includes(".ts:"));if(!n)return null;const t=n.match(/(?:at(?:\s+\S.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])|\s{2,})\()?([^\s(]+):(\d+):(\d+)/);if(!t)return null;const[i,s,f,c]=t;return{fileName:s,lineNumber:Number.parseInt(f,10),columnNumber:Number.parseInt(c,10)}}async fetchSourceMap(e){try{const r=`${e}.map`,n=await fetch(r);return n.ok?await n.json():null}catch(r){return console.error("获取 source map 失败:",r),null}}async getErrorSource(e){if(!(e!=null&&e.stack))return null;try{const r=this.parseStackTrace(e.stack);if(!r)return null;const n=await this.fetchSourceMap(r.fileName);if(!n)return r;const t=new ze(n),i=t.originalPositionFor({line:r.lineNumber,column:r.columnNumber});if(!i.source)return r;const s=t.sourceContentFor(i.source),f=(s==null?void 0:s.split(`
3
3
  `))||[],c=(i.line||1)-1,h=Math.max(0,c-5),d=Math.min(f.length-1,c+5),v=f.slice(h,d+1).join(`
4
- `);return{fileName:i.source,lineNumber:i.line||0,columnNumber:i.column||0,sourceContent:v}}catch(r){return console.error("分析错误源码失败:",r),null}}}function ge(){return{url:window.location.href,userAgent:navigator.userAgent,screenSize:`${window.screen.width}x${window.screen.height}`,timestamp:Date.now()}}function xe(o,e={}){const{encode:r=!0,encodeValuesOnly:n=!1,arrayFormat:t="indices",skipNulls:i=!1,delimiter:s="&",strictNullHandling:f=!1,sort:c,filter:h,allowDots:d=!1,serializeDate:v=O=>O.toISOString(),format:m="RFC3986",addQueryPrefix:_=!1,charset:C="utf-8"}=e,S=[],J=C==="iso-8859-1"?Ue:encodeURIComponent,E=O=>r?J(O):O,I=(O,y,re=null)=>{const u=re?`${re}[${O}]`:O;if(h){const l=h(u,y);if(l===void 0)return;y=l}if(y===null){f?S.push(E(u)+(n?"":"=")):i||S.push(`${E(u)}=`);return}if((typeof y=="boolean"||typeof y=="number")&&(y=String(y)),y instanceof Date&&(y=v(y)),Array.isArray(y)){if(y.length===0&&i)return;switch(t){case"indices":y.forEach((g,a)=>{I(String(a),g,u)});break;case"brackets":y.forEach(g=>{I("",g,u)});break;case"repeat":y.forEach(g=>{I(u,g)});break;case"comma":const l=y.join(",");l.length>0&&S.push(`${E(u)}=${E(l)}`);break}}else if(typeof y=="object")Object.keys(y).forEach(l=>{const g=d?".":"[",a=d?"":"]";I(l,y[l],`${u}${g}${l}${a}`)});else{const l=r&&!n?E(u):u,g=E(String(y));S.push(`${l}=${g}`)}};let z=Object.keys(o);c&&(z=z.sort(c)),z.forEach(O=>{const y=o[O];I(O,y)});let L=S.join(s);return _&&L.length>0&&(L=`?${L}`),L}function Ue(o){return encodeURIComponent(o).replace(/%[0-9A-F]{2}/g,e=>{const r=Number.parseInt(e.substring(1),16);return r>=128&&r<=255?String.fromCharCode(r):e})}const G=class G{constructor(e){D(this,"options");D(this,"event");D(this,"source");D(this,"ERROR_REPORTED","error-reported");this.options=this.validateOptions(e),this.event=new N,this.source=new Ie,this.init(),e.integrations&&this.initIntegrations()}onErrorReported(e){this.event.on(this.ERROR_REPORTED,e)}initIntegrations(){var e;(e=this.options.integrations)==null||e.forEach(r=>{try{r.install(this)}catch(n){console.error(`Failed to initialize integration ${r.name}:`,n)}})}static getInstance(){if(!G.instance)throw new Error("ErrorMonitor未初始化,请先调用initialize方法");return G.instance}validateOptions(e){if(!e.url)throw new Error("上报地址url不能为空");if(!e.appId)throw new Error("应用标识appId不能为空");return{env:"development",sampleRate:1,...e}}init(){this.onErrorReported(e=>{this.reportError(e)})}getClientInfo(){return{url:window.location.href,userAgent:navigator.userAgent,screenSize:`${window.screen.width}x${window.screen.height}`,timestamp:Date.now()}}report(e){if(Math.random()>(this.options.sampleRate||1))return;let r={...e,appId:this.options.appId,env:this.options.env},n=this.options.url;if(this.options.paramsSerializer){const t=this.options.paramsSerializer();n=`${n}?${xe(t)}`}if(this.options.beforeSend){const t=this.options.beforeSend(r);if(!t)return;r=t}navigator.sendBeacon?navigator.sendBeacon(n,JSON.stringify(r)):fetch(n,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json"},keepalive:!0}).catch(()=>{})}normalizeError(e){return this.isErrorInfo(e)?{...e,extraInfo:this.options.extraInfo,...this.getClientInfo()}:e instanceof Error?{type:e.name,message:e.message,stack:e.stack,extraInfo:this.options.extraInfo,...this.getClientInfo()}:{type:"Error",message:e,extraInfo:this.options.extraInfo,...this.getClientInfo()}}isErrorInfo(e){return typeof e=="object"&&e!==null&&"type"in e&&"message"in e}reportError(e){if(!G.instance)throw new Error("ErrorMonitor未初始化,请先调用initialize方法");const r=this.normalizeError(e);console.log("errorInfo",r),this.report(r)}static initialize(e){if(G.instance)throw new Error("ErrorMonitor已经初始化,请勿重复初始化");return G.instance=new G(e),G.instance}static destroy(){G.instance&&(G.instance=null)}static captureError(e){G.getInstance().reportError(e)}emitError(e){this.event.emit(this.ERROR_REPORTED,e)}async getErrorSource(e){return this.source.getErrorSource(e)}get env(){return this.options.env}};D(G,"instance",null);let pe=G;class Be{constructor(e){D(this,"name","VueError");D(this,"app");this.app=e}install(e){e.env==="production"&&(this.app.config.errorHandler=async r=>{const n=await e.getErrorSource(r);console.log(n),e.emitError({type:r.name,message:r.message,stack:r.stack,source:n})})}}class Ve{constructor(){D(this,"name","BrowserError");D(this,"monitor",null)}install(e){this.monitor=e,window.addEventListener("error",r=>{this.handleJsError(r)},!0),window.addEventListener("unhandledrejection",r=>{this.handlePromiseError(r)}),window.addEventListener("error",r=>{r.target&&r.target.tagName&&this.handleResourceError(r)},!0)}handleJsError(e){var n,t;const r={type:(n=e.error)==null?void 0:n.name,message:e.message,source:{fileName:e.filename,lineNumber:e.lineno,columnNumber:e.colno},stack:(t=e.error)==null?void 0:t.stack,...ge()};this.monitor&&this.monitor.emitError(r)}handlePromiseError(e){var n,t;const r={type:"NetworkError",message:((n=e.reason)==null?void 0:n.message)||"Promise Error",stack:(t=e.reason)==null?void 0:t.stack,...ge()};this.monitor&&this.monitor.emitError(r)}handleResourceError(e){const r=e.target,n={type:"ResourceError",message:`资源加载失败: ${r.tagName} ${r.src||r.href}`,...ge()};this.monitor&&this.monitor.emitError(n)}}A.BrowserError=Ve,A.ErrorMonitor=pe,A.SourceError=Ie,A.VueError=Be,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
4
+ `);return{fileName:i.source,lineNumber:i.line||0,columnNumber:i.column||0,sourceContent:v}}catch(r){return console.error("分析错误源码失败:",r),null}}}function ge(){return{url:window.location.href,userAgent:navigator.userAgent,screenSize:`${window.screen.width}x${window.screen.height}`,timestamp:Date.now()}}function xe(o,e={}){const{encode:r=!0,encodeValuesOnly:n=!1,arrayFormat:t="indices",skipNulls:i=!1,delimiter:s="&",strictNullHandling:f=!1,sort:c,filter:h,allowDots:d=!1,serializeDate:v=O=>O.toISOString(),format:m="RFC3986",addQueryPrefix:_=!1,charset:C="utf-8"}=e,S=[],J=C==="iso-8859-1"?Be:encodeURIComponent,E=O=>r?J(O):O,I=(O,y,re=null)=>{const u=re?`${re}[${O}]`:O;if(h){const l=h(u,y);if(l===void 0)return;y=l}if(y===null){f?S.push(E(u)+(n?"":"=")):i||S.push(`${E(u)}=`);return}if((typeof y=="boolean"||typeof y=="number")&&(y=String(y)),y instanceof Date&&(y=v(y)),Array.isArray(y)){if(y.length===0&&i)return;switch(t){case"indices":y.forEach((g,a)=>{I(String(a),g,u)});break;case"brackets":y.forEach(g=>{I("",g,u)});break;case"repeat":y.forEach(g=>{I(u,g)});break;case"comma":const l=y.join(",");l.length>0&&S.push(`${E(u)}=${E(l)}`);break}}else if(typeof y=="object")Object.keys(y).forEach(l=>{const g=d?".":"[",a=d?"":"]";I(l,y[l],`${u}${g}${l}${a}`)});else{const l=r&&!n?E(u):u,g=E(String(y));S.push(`${l}=${g}`)}};let z=Object.keys(o);c&&(z=z.sort(c)),z.forEach(O=>{const y=o[O];I(O,y)});let L=S.join(s);return _&&L.length>0&&(L=`?${L}`),L}function Be(o){return encodeURIComponent(o).replace(/%[0-9A-F]{2}/g,e=>{const r=Number.parseInt(e.substring(1),16);return r>=128&&r<=255?String.fromCharCode(r):e})}function Ue(o,e=Date.now()){if(o.length!==66)throw new Error("BASE66_CHARS must contain exactly 66 characters");let r=e,n="";if(r===0)return o[0];for(;r>0;){const t=r%66;n=o[t]+n,r=Math.floor(r/66)}return n}const G=class G{constructor(e){D(this,"options");D(this,"event");D(this,"source");D(this,"ERROR_REPORTED","error-reported");this.options=this.validateOptions(e),this.event=new R,this.source=new Ie,this.init(),e.integrations&&this.initIntegrations()}onErrorReported(e){this.event.on(this.ERROR_REPORTED,e)}initIntegrations(){var e;(e=this.options.integrations)==null||e.forEach(r=>{try{r.install(this)}catch(n){console.error(`Failed to initialize integration ${r.name}:`,n)}})}static getInstance(){if(!G.instance)throw new Error("ErrorMonitor未初始化,请先调用initialize方法");return G.instance}validateOptions(e){if(!e.url)throw new Error("上报地址url不能为空");if(!e.appId)throw new Error("平台标识appId不能为空");return{env:"development",sampleRate:1,...e}}init(){this.onErrorReported(e=>{this.reportError(e)})}getClientInfo(){return{url:window.location.href,userAgent:navigator.userAgent,screenSize:`${window.screen.width}x${window.screen.height}`,timestamp:Date.now()}}report(e){if(Math.random()>(this.options.sampleRate||1))return;let r={...e,appId:this.options.appId,env:this.options.env},n=this.options.url;if(this.options.paramsSerializer){const t=this.options.paramsSerializer();n=`${n}?${xe(t)}`}if(this.options.beforeSend){const t=this.options.beforeSend(r);if(!t)return;r=t}navigator.sendBeacon?navigator.sendBeacon(n,JSON.stringify(r)):fetch(n,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"text/plain"},keepalive:!0}).catch(()=>{})}normalizeError(e){return this.isErrorInfo(e)?{...e,extraInfo:{...this.options.extraInfo,...e.extraInfo},...this.getClientInfo()}:e instanceof Error?{type:e.name,message:e.message,stack:e.stack,extraInfo:this.options.extraInfo,...this.getClientInfo()}:{type:"Error",message:e,extraInfo:this.options.extraInfo,...this.getClientInfo()}}isErrorInfo(e){return typeof e=="object"&&e!==null&&"type"in e&&"message"in e}reportError(e){if(!G.instance)throw new Error("ErrorMonitor未初始化,请先调用initialize方法");const r=this.normalizeError(e);this.report(r)}static initialize(e){if(G.instance)throw new Error("ErrorMonitor已经初始化,请勿重复初始化");return G.instance=new G(e),G.instance}static destroy(){G.instance&&(G.instance=null)}static captureError(e){G.getInstance().reportError(e)}emitError(e){this.event.emit(this.ERROR_REPORTED,e)}async getErrorSource(e){return this.source.getErrorSource(e)}get env(){return this.options.env}};D(G,"instance",null);let pe=G;class Ve{constructor(e){D(this,"name","VueError");D(this,"app");this.app=e}install(e){e.env==="production"&&(this.app.config.errorHandler=async r=>{const n=await e.getErrorSource(r);e.emitError({type:r.name,message:r.message,stack:r.stack,source:n,level:"error"})})}}class Qe{constructor(){D(this,"name","BrowserError");D(this,"monitor",null)}install(e){this.monitor=e,window.addEventListener("error",r=>{this.handleJsError(r)},!0),window.addEventListener("unhandledrejection",r=>{this.handlePromiseError(r)}),window.addEventListener("error",r=>{r.target&&r.target.tagName&&this.handleResourceError(r)},!0)}handleJsError(e){var n,t;const r={type:(n=e.error)==null?void 0:n.name,message:e.message,source:{fileName:e.filename,lineNumber:e.lineno,columnNumber:e.colno},stack:(t=e.error)==null?void 0:t.stack,...ge()};this.monitor&&this.monitor.emitError(r)}handlePromiseError(e){var n,t;const r={type:"NetworkError",message:((n=e.reason)==null?void 0:n.message)||"Promise Error",stack:(t=e.reason)==null?void 0:t.stack,...ge()};this.monitor&&this.monitor.emitError(r)}handleResourceError(e){const r=e.target,n={type:"ResourceError",message:`资源加载失败: ${r.tagName} ${r.src||r.href}`,...ge()};this.monitor&&this.monitor.emitError(n)}}A.BrowserError=Qe,A.ErrorMonitor=pe,A.SourceError=Ie,A.VueError=Ve,A.timestampToBase66=Ue,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/dist/es/index.mjs CHANGED
@@ -1,11 +1,13 @@
1
1
  import "./src/index.mjs";
2
- import { ErrorMonitor } from "./src/core.mjs";
3
- import { SourceError } from "./src/SourceError.mjs";
4
- import { VueError } from "./src/integrations/VueError.mjs";
5
- import { BrowserError } from "./src/integrations/BrowserError.mjs";
2
+ import { timestampToBase66 as t } from "./src/utils.mjs";
3
+ import { ErrorMonitor as p } from "./src/core.mjs";
4
+ import { SourceError as x } from "./src/SourceError.mjs";
5
+ import { VueError as i } from "./src/integrations/VueError.mjs";
6
+ import { BrowserError as a } from "./src/integrations/BrowserError.mjs";
6
7
  export {
7
- BrowserError,
8
- ErrorMonitor,
9
- SourceError,
10
- VueError
8
+ a as BrowserError,
9
+ p as ErrorMonitor,
10
+ x as SourceError,
11
+ i as VueError,
12
+ t as timestampToBase66
11
13
  };
@@ -1,52 +1,41 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- class EventEmitter {
1
+ var o = Object.defineProperty;
2
+ var c = (r, e, t) => e in r ? o(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var n = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
4
+ class a {
5
5
  constructor() {
6
- __publicField(this, "events", /* @__PURE__ */ new Map());
6
+ n(this, "events", /* @__PURE__ */ new Map());
7
7
  }
8
8
  /**
9
9
  * 订阅事件
10
10
  * @param eventName 事件名称
11
11
  * @param handler 事件处理函数
12
12
  */
13
- on(eventName, handler) {
14
- if (!this.events.has(eventName)) {
15
- this.events.set(eventName, /* @__PURE__ */ new Set());
16
- }
17
- const handlers = this.events.get(eventName);
18
- handlers.add(handler);
13
+ on(e, t) {
14
+ this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
19
15
  }
20
16
  /**
21
17
  * 取消订阅事件
22
18
  * @param eventName 事件名称
23
19
  * @param handler 事件处理函数
24
20
  */
25
- off(eventName, handler) {
26
- const handlers = this.events.get(eventName);
27
- if (handlers) {
28
- handlers.delete(handler);
29
- if (handlers.size === 0) {
30
- this.events.delete(eventName);
31
- }
32
- }
21
+ off(e, t) {
22
+ const s = this.events.get(e);
23
+ s && (s.delete(t), s.size === 0 && this.events.delete(e));
33
24
  }
34
25
  /**
35
26
  * 触发事件
36
27
  * @param eventName 事件名称
37
28
  * @param args 事件参数
38
29
  */
39
- emit(eventName, ...args) {
40
- const handlers = this.events.get(eventName);
41
- if (handlers) {
42
- handlers.forEach((handler) => {
43
- try {
44
- handler(...args);
45
- } catch (error) {
46
- console.error(`Error in event handler for ${eventName}:`, error);
47
- }
48
- });
49
- }
30
+ emit(e, ...t) {
31
+ const s = this.events.get(e);
32
+ s && s.forEach((i) => {
33
+ try {
34
+ i(...t);
35
+ } catch (h) {
36
+ console.error(`Error in event handler for ${e}:`, h);
37
+ }
38
+ });
50
39
  }
51
40
  /**
52
41
  * 清除所有订阅
@@ -59,19 +48,19 @@ class EventEmitter {
59
48
  * @param eventName 事件名称
60
49
  * @returns 订阅者数量
61
50
  */
62
- getSubscriberCount(eventName) {
63
- const handlers = this.events.get(eventName);
64
- return handlers ? handlers.size : 0;
51
+ getSubscriberCount(e) {
52
+ const t = this.events.get(e);
53
+ return t ? t.size : 0;
65
54
  }
66
55
  /**
67
56
  * 检查是否有订阅者
68
57
  * @param eventName 事件名称
69
58
  * @returns 是否有订阅者
70
59
  */
71
- hasSubscribers(eventName) {
72
- return this.getSubscriberCount(eventName) > 0;
60
+ hasSubscribers(e) {
61
+ return this.getSubscriberCount(e) > 0;
73
62
  }
74
63
  }
75
64
  export {
76
- EventEmitter
65
+ a as EventEmitter
77
66
  };
@@ -1,83 +1,66 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { SourceMapConsumer } from "source-map-js";
5
- class SourceError {
6
- constructor(options) {
7
- __publicField(this, "options", null);
8
- if (options)
9
- this.options = options;
1
+ var p = Object.defineProperty;
2
+ var h = (o, n, e) => n in o ? p(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
3
+ var a = (o, n, e) => h(o, typeof n != "symbol" ? n + "" : n, e);
4
+ import { SourceMapConsumer as N } from "source-map-js";
5
+ class b {
6
+ constructor(n) {
7
+ a(this, "options", null);
8
+ n && (this.options = n);
10
9
  }
11
- parseStackTrace(stack) {
12
- const lines = stack.split("\n");
13
- const errorLine = lines.find((line) => line.includes(".js:") || line.includes(".ts:"));
14
- if (!errorLine) {
10
+ parseStackTrace(n) {
11
+ const r = n.split(`
12
+ `).find((l) => l.includes(".js:") || l.includes(".ts:"));
13
+ if (!r)
15
14
  return null;
16
- }
17
- const match = errorLine.match(/(?:at(?:\s+\S.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])|\s{2,})\()?([^\s(]+):(\d+):(\d+)/);
18
- if (!match) {
15
+ const s = r.match(/(?:at(?:\s+\S.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])|\s{2,})\()?([^\s(]+):(\d+):(\d+)/);
16
+ if (!s)
19
17
  return null;
20
- }
21
- const [_, fileName, lineStr, columnStr] = match;
18
+ const [t, c, u, i] = s;
22
19
  return {
23
- fileName,
24
- lineNumber: Number.parseInt(lineStr, 10),
25
- columnNumber: Number.parseInt(columnStr, 10)
20
+ fileName: c,
21
+ lineNumber: Number.parseInt(u, 10),
22
+ columnNumber: Number.parseInt(i, 10)
26
23
  };
27
24
  }
28
- async fetchSourceMap(fileName) {
25
+ async fetchSourceMap(n) {
29
26
  try {
30
- const sourceMapUrl = `${fileName}.map`;
31
- const response = await fetch(sourceMapUrl);
32
- if (!response.ok) {
33
- return null;
34
- }
35
- return await response.json();
36
- } catch (error) {
37
- console.error("获取 source map 失败:", error);
38
- return null;
27
+ const e = `${n}.map`, r = await fetch(e);
28
+ return r.ok ? await r.json() : null;
29
+ } catch (e) {
30
+ return console.error("获取 source map 失败:", e), null;
39
31
  }
40
32
  }
41
33
  // 通过 source map 获取原始错误位置和源码内容
42
- async getErrorSource(error) {
43
- if (!(error == null ? void 0 : error.stack)) {
34
+ async getErrorSource(n) {
35
+ if (!(n != null && n.stack))
44
36
  return null;
45
- }
46
37
  try {
47
- const stackInfo = this.parseStackTrace(error.stack);
48
- if (!stackInfo) {
38
+ const e = this.parseStackTrace(n.stack);
39
+ if (!e)
49
40
  return null;
50
- }
51
- const sourceMapData = await this.fetchSourceMap(stackInfo.fileName);
52
- if (!sourceMapData) {
53
- return stackInfo;
54
- }
55
- const consumer = new SourceMapConsumer(sourceMapData);
56
- const originalPosition = consumer.originalPositionFor({
57
- line: stackInfo.lineNumber,
58
- column: stackInfo.columnNumber
41
+ const r = await this.fetchSourceMap(e.fileName);
42
+ if (!r)
43
+ return e;
44
+ const s = new N(r), t = s.originalPositionFor({
45
+ line: e.lineNumber,
46
+ column: e.columnNumber
59
47
  });
60
- if (!originalPosition.source) {
61
- return stackInfo;
62
- }
63
- const sourceContent = consumer.sourceContentFor(originalPosition.source);
64
- const sourceLines = (sourceContent == null ? void 0 : sourceContent.split("\n")) || [];
65
- const errorLineIndex = (originalPosition.line || 1) - 1;
66
- const startLineIndex = Math.max(0, errorLineIndex - 5);
67
- const endLineIndex = Math.min(sourceLines.length - 1, errorLineIndex + 5);
68
- const relevantCode = sourceLines.slice(startLineIndex, endLineIndex + 1).join("\n");
48
+ if (!t.source)
49
+ return e;
50
+ const c = s.sourceContentFor(t.source), u = (c == null ? void 0 : c.split(`
51
+ `)) || [], i = (t.line || 1) - 1, l = Math.max(0, i - 5), m = Math.min(u.length - 1, i + 5), f = u.slice(l, m + 1).join(`
52
+ `);
69
53
  return {
70
- fileName: originalPosition.source,
71
- lineNumber: originalPosition.line || 0,
72
- columnNumber: originalPosition.column || 0,
73
- sourceContent: relevantCode
54
+ fileName: t.source,
55
+ lineNumber: t.line || 0,
56
+ columnNumber: t.column || 0,
57
+ sourceContent: f
74
58
  };
75
- } catch (error2) {
76
- console.error("分析错误源码失败:", error2);
77
- return null;
59
+ } catch (e) {
60
+ return console.error("分析错误源码失败:", e), null;
78
61
  }
79
62
  }
80
63
  }
81
64
  export {
82
- SourceError
65
+ b as SourceError
83
66
  };