mqtt-plus 1.4.13 → 1.4.14
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 +5 -0
- package/dst-stage1/mqtt-plus-sink.js +10 -2
- package/dst-stage1/mqtt-plus-source.js +26 -16
- package/dst-stage2/mqtt-plus.cjs.js +35 -18
- package/dst-stage2/mqtt-plus.esm.js +35 -18
- package/dst-stage2/mqtt-plus.umd.js +9 -9
- package/package.json +1 -1
- package/src/mqtt-plus-sink.ts +10 -2
- package/src/mqtt-plus-source.ts +27 -16
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
(function(et,Yt){typeof exports=="object"&&typeof module<"u"?module.exports=Yt():typeof define=="function"&&define.amd?define(Yt):(et=typeof globalThis<"u"?globalThis:et||self,et.MQTTp=Yt())})(this,(function(){"use strict";var et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yt(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function n(){var s=!1;try{s=this instanceof n}catch{}return s?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(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var lr={exports:{}},qn;function hr(){if(qn)return lr.exports;qn=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,k,M){return Function.prototype.apply.call(v,k,M)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function n(_){console&&console.warn&&console.warn(_)}var s=Number.isNaN||function(v){return v!==v};function i(){i.init.call(this)}lr.exports=i,lr.exports.once=S,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var c=10;function l(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(_){if(typeof _!="number"||_<0||s(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");c=_}}),i.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||s(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function h(_){return _._maxListeners===void 0?i.defaultMaxListeners:_._maxListeners}i.prototype.getMaxListeners=function(){return h(this)},i.prototype.emit=function(v){for(var k=[],M=1;M<arguments.length;M++)k.push(arguments[M]);var U=v==="error",W=this._events;if(W!==void 0)U=U&&W.error===void 0;else if(!U)return!1;if(U){var G;if(k.length>0&&(G=k[0]),G instanceof Error)throw G;var Y=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw Y.context=G,Y}var N=W[v];if(N===void 0)return!1;if(typeof N=="function")e(N,this,k);else for(var Z=N.length,re=B(N,Z),M=0;M<Z;++M)e(re[M],this,k);return!0};function w(_,v,k,M){var U,W,G;if(l(k),W=_._events,W===void 0?(W=_._events=Object.create(null),_._eventsCount=0):(W.newListener!==void 0&&(_.emit("newListener",v,k.listener?k.listener:k),W=_._events),G=W[v]),G===void 0)G=W[v]=k,++_._eventsCount;else if(typeof G=="function"?G=W[v]=M?[k,G]:[G,k]:M?G.unshift(k):G.push(k),U=h(_),U>0&&G.length>U&&!G.warned){G.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=_,Y.type=v,Y.count=G.length,n(Y)}return _}i.prototype.addListener=function(v,k){return w(this,v,k,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(v,k){return w(this,v,k,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(_,v,k){var M={fired:!1,wrapFn:void 0,target:_,type:v,listener:k},U=d.bind(M);return U.listener=k,M.wrapFn=U,U}i.prototype.once=function(v,k){return l(k),this.on(v,I(this,v,k)),this},i.prototype.prependOnceListener=function(v,k){return l(k),this.prependListener(v,I(this,v,k)),this},i.prototype.removeListener=function(v,k){var M,U,W,G,Y;if(l(k),U=this._events,U===void 0)return this;if(M=U[v],M===void 0)return this;if(M===k||M.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete U[v],U.removeListener&&this.emit("removeListener",v,M.listener||k));else if(typeof M!="function"){for(W=-1,G=M.length-1;G>=0;G--)if(M[G]===k||M[G].listener===k){Y=M[G].listener,W=G;break}if(W<0)return this;W===0?M.shift():q(M,W),M.length===1&&(U[v]=M[0]),U.removeListener!==void 0&&this.emit("removeListener",v,Y||k)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(v){var k,M,U;if(M=this._events,M===void 0)return this;if(M.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):M[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete M[v]),this;if(arguments.length===0){var W=Object.keys(M),G;for(U=0;U<W.length;++U)G=W[U],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=M[v],typeof k=="function")this.removeListener(v,k);else if(k!==void 0)for(U=k.length-1;U>=0;U--)this.removeListener(v,k[U]);return this};function T(_,v,k){var M=_._events;if(M===void 0)return[];var U=M[v];return U===void 0?[]:typeof U=="function"?k?[U.listener||U]:[U]:k?$(U):B(U,U.length)}i.prototype.listeners=function(v){return T(this,v,!0)},i.prototype.rawListeners=function(v){return T(this,v,!1)},i.listenerCount=function(_,v){return typeof _.listenerCount=="function"?_.listenerCount(v):L.call(_,v)},i.prototype.listenerCount=L;function L(_){var v=this._events;if(v!==void 0){var k=v[_];if(typeof k=="function")return 1;if(k!==void 0)return k.length}return 0}i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function B(_,v){for(var k=new Array(v),M=0;M<v;++M)k[M]=_[M];return k}function q(_,v){for(;v+1<_.length;v++)_[v]=_[v+1];_.pop()}function $(_){for(var v=new Array(_.length),k=0;k<v.length;++k)v[k]=_[k].listener||_[k];return v}function S(_,v){return new Promise(function(k,M){function U(G){_.removeListener(v,W),M(G)}function W(){typeof _.removeListener=="function"&&_.removeListener("error",U),k([].slice.call(arguments))}F(_,v,W,{once:!0}),v!=="error"&&x(_,U,{once:!0})})}function x(_,v,k){typeof _.on=="function"&&F(_,"error",v,k)}function F(_,v,k,M){if(typeof _.on=="function")M.once?_.once(v,k):_.on(v,k);else if(typeof _.addEventListener=="function")_.addEventListener(v,function U(W){M.once&&_.removeEventListener(v,U),k(W)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return lr.exports}var dr={exports:{}},jn;function Pt(){return jn||(jn=1,typeof Object.create=="function"?dr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:dr.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),dr.exports}function Xs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}},Ie=Hn.exports={},tt,rt;function Hr(){throw new Error("setTimeout has not been defined")}function Wr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?tt=setTimeout:tt=Hr}catch{tt=Hr}try{typeof clearTimeout=="function"?rt=clearTimeout:rt=Wr}catch{rt=Wr}})();function Wn(t){if(tt===setTimeout)return setTimeout(t,0);if((tt===Hr||!tt)&&setTimeout)return tt=setTimeout,setTimeout(t,0);try{return tt(t,0)}catch{try{return tt.call(null,t,0)}catch{return tt.call(this,t,0)}}}function Zs(t){if(rt===clearTimeout)return clearTimeout(t);if((rt===Wr||!rt)&&clearTimeout)return rt=clearTimeout,clearTimeout(t);try{return rt(t)}catch{try{return rt.call(null,t)}catch{return rt.call(this,t)}}}var ft=[],Dt=!1,Bt,pr=-1;function eo(){!Dt||!Bt||(Dt=!1,Bt.length?ft=Bt.concat(ft):pr=-1,ft.length&&Kn())}function Kn(){if(!Dt){var t=Wn(eo);Dt=!0;for(var e=ft.length;e;){for(Bt=ft,ft=[];++pr<e;)Bt&&Bt[pr].run();pr=-1,e=ft.length}Bt=null,Dt=!1,Zs(t)}}Ie.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ft.push(new Gn(t,e)),ft.length===1&&!Dt&&Wn(Kn)};function Gn(t,e){this.fun=t,this.array=e}Gn.prototype.run=function(){this.fun.apply(null,this.array)},Ie.title="browser",Ie.browser=!0,Ie.env={},Ie.argv=[],Ie.version="",Ie.versions={};function lt(){}Ie.on=lt,Ie.addListener=lt,Ie.once=lt,Ie.off=lt,Ie.removeListener=lt,Ie.removeAllListeners=lt,Ie.emit=lt,Ie.prependListener=lt,Ie.prependOnceListener=lt,Ie.listeners=function(t){return[]},Ie.binding=function(t){throw new Error("process.binding is not supported")},Ie.cwd=function(){return"/"},Ie.chdir=function(t){throw new Error("process.chdir is not supported")},Ie.umask=function(){return 0};var to=Hn.exports;const pe=Xs(to);var Kr,Jn;function zn(){return Jn||(Jn=1,Kr=hr().EventEmitter),Kr}var Gr={},Vn;function yr(){return Vn||(Vn=1,(function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},r={};r.byteLength=d,r.toByteArray=T,r.fromByteArray=q;for(var n=[],s=[],i=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,h=c.length;l<h;++l)n[l]=c[l],s[c.charCodeAt(l)]=l;s[45]=62,s[95]=63;function w(x){var F=x.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=x.indexOf("=");_===-1&&(_=F);var v=_===F?0:4-_%4;return[_,v]}function d(x){var F=w(x),_=F[0],v=F[1];return(_+v)*3/4-v}function I(x,F,_){return(F+_)*3/4-_}function T(x){var F,_=w(x),v=_[0],k=_[1],M=new i(I(x,v,k)),U=0,W=k>0?v-4:v,G;for(G=0;G<W;G+=4)F=s[x.charCodeAt(G)]<<18|s[x.charCodeAt(G+1)]<<12|s[x.charCodeAt(G+2)]<<6|s[x.charCodeAt(G+3)],M[U++]=F>>16&255,M[U++]=F>>8&255,M[U++]=F&255;return k===2&&(F=s[x.charCodeAt(G)]<<2|s[x.charCodeAt(G+1)]>>4,M[U++]=F&255),k===1&&(F=s[x.charCodeAt(G)]<<10|s[x.charCodeAt(G+1)]<<4|s[x.charCodeAt(G+2)]>>2,M[U++]=F>>8&255,M[U++]=F&255),M}function L(x){return n[x>>18&63]+n[x>>12&63]+n[x>>6&63]+n[x&63]}function B(x,F,_){for(var v,k=[],M=F;M<_;M+=3)v=(x[M]<<16&16711680)+(x[M+1]<<8&65280)+(x[M+2]&255),k.push(L(v));return k.join("")}function q(x){for(var F,_=x.length,v=_%3,k=[],M=16383,U=0,W=_-v;U<W;U+=M)k.push(B(x,U,U+M>W?W:U+M));return v===1?(F=x[_-1],k.push(n[F>>2]+n[F<<4&63]+"==")):v===2&&(F=(x[_-2]<<8)+x[_-1],k.push(n[F>>10]+n[F>>4&63]+n[F<<2&63]+"=")),k.join("")}var $={};$.read=function(x,F,_,v,k){var M,U,W=k*8-v-1,G=(1<<W)-1,Y=G>>1,N=-7,Z=_?k-1:0,re=_?-1:1,Q=x[F+Z];for(Z+=re,M=Q&(1<<-N)-1,Q>>=-N,N+=W;N>0;M=M*256+x[F+Z],Z+=re,N-=8);for(U=M&(1<<-N)-1,M>>=-N,N+=v;N>0;U=U*256+x[F+Z],Z+=re,N-=8);if(M===0)M=1-Y;else{if(M===G)return U?NaN:(Q?-1:1)*(1/0);U=U+Math.pow(2,v),M=M-Y}return(Q?-1:1)*U*Math.pow(2,M-v)},$.write=function(x,F,_,v,k,M){var U,W,G,Y=M*8-k-1,N=(1<<Y)-1,Z=N>>1,re=k===23?Math.pow(2,-24)-Math.pow(2,-77):0,Q=v?0:M-1,se=v?1:-1,fe=F<0||F===0&&1/F<0?1:0;for(F=Math.abs(F),isNaN(F)||F===1/0?(W=isNaN(F)?1:0,U=N):(U=Math.floor(Math.log(F)/Math.LN2),F*(G=Math.pow(2,-U))<1&&(U--,G*=2),U+Z>=1?F+=re/G:F+=re*Math.pow(2,1-Z),F*G>=2&&(U++,G/=2),U+Z>=N?(W=0,U=N):U+Z>=1?(W=(F*G-1)*Math.pow(2,k),U=U+Z):(W=F*Math.pow(2,Z-1)*Math.pow(2,k),U=0));k>=8;x[_+Q]=W&255,Q+=se,W/=256,k-=8);for(U=U<<k|W,Y+=k;Y>0;x[_+Q]=U&255,Q+=se,U/=256,Y-=8);x[_+Q-se]|=fe*128};(function(x){const F=r,_=$,v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;x.Buffer=N,x.SlowBuffer=Qe,x.INSPECT_MAX_BYTES=50;const k=2147483647;x.kMaxLength=k;const{Uint8Array:M,ArrayBuffer:U,SharedArrayBuffer:W}=globalThis;N.TYPED_ARRAY_SUPPORT=G(),!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function G(){try{const y=new M(1),a={foo:function(){return 42}};return Object.setPrototypeOf(a,M.prototype),Object.setPrototypeOf(y,a),y.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}}),Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function Y(y){if(y>k)throw new RangeError('The value "'+y+'" is invalid for option "size"');const a=new M(y);return Object.setPrototypeOf(a,N.prototype),a}function N(y,a,f){if(typeof y=="number"){if(typeof a=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return se(y)}return Z(y,a,f)}N.poolSize=8192;function Z(y,a,f){if(typeof y=="string")return fe(y,a);if(U.isView(y))return Ce(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(ut(y,U)||y&&ut(y.buffer,U)||typeof W<"u"&&(ut(y,W)||y&&ut(y.buffer,W)))return Oe(y,a,f);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=y.valueOf&&y.valueOf();if(m!=null&&m!==y)return N.from(m,a,f);const R=wt(y);if(R)return R;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return N.from(y[Symbol.toPrimitive]("string"),a,f);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y)}N.from=function(y,a,f){return Z(y,a,f)},Object.setPrototypeOf(N.prototype,M.prototype),Object.setPrototypeOf(N,M);function re(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function Q(y,a,f){return re(y),y<=0?Y(y):a!==void 0?typeof f=="string"?Y(y).fill(a,f):Y(y).fill(a):Y(y)}N.alloc=function(y,a,f){return Q(y,a,f)};function se(y){return re(y),Y(y<0?0:at(y)|0)}N.allocUnsafe=function(y){return se(y)},N.allocUnsafeSlow=function(y){return se(y)};function fe(y,a){if((typeof a!="string"||a==="")&&(a="utf8"),!N.isEncoding(a))throw new TypeError("Unknown encoding: "+a);const f=be(y,a)|0;let m=Y(f);const R=m.write(y,a);return R!==f&&(m=m.slice(0,R)),m}function ye(y){const a=y.length<0?0:at(y.length)|0,f=Y(a);for(let m=0;m<a;m+=1)f[m]=y[m]&255;return f}function Ce(y){if(ut(y,M)){const a=new M(y);return Oe(a.buffer,a.byteOffset,a.byteLength)}return ye(y)}function Oe(y,a,f){if(a<0||y.byteLength<a)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<a+(f||0))throw new RangeError('"length" is outside of buffer bounds');let m;return a===void 0&&f===void 0?m=new M(y):f===void 0?m=new M(y,a):m=new M(y,a,f),Object.setPrototypeOf(m,N.prototype),m}function wt(y){if(N.isBuffer(y)){const a=at(y.length)|0,f=Y(a);return f.length===0||y.copy(f,0,0,a),f}if(y.length!==void 0)return typeof y.length!="number"||$n(y.length)?Y(0):ye(y);if(y.type==="Buffer"&&Array.isArray(y.data))return ye(y.data)}function at(y){if(y>=k)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+k.toString(16)+" bytes");return y|0}function Qe(y){return+y!=y&&(y=0),N.alloc(+y)}N.isBuffer=function(a){return a!=null&&a._isBuffer===!0&&a!==N.prototype},N.compare=function(a,f){if(ut(a,M)&&(a=N.from(a,a.offset,a.byteLength)),ut(f,M)&&(f=N.from(f,f.offset,f.byteLength)),!N.isBuffer(a)||!N.isBuffer(f))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===f)return 0;let m=a.length,R=f.length;for(let O=0,H=Math.min(m,R);O<H;++O)if(a[O]!==f[O]){m=a[O],R=f[O];break}return m<R?-1:R<m?1:0},N.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},N.concat=function(a,f){if(!Array.isArray(a))throw new TypeError('"list" argument must be an Array of Buffers');if(a.length===0)return N.alloc(0);let m;if(f===void 0)for(f=0,m=0;m<a.length;++m)f+=a[m].length;const R=N.allocUnsafe(f);let O=0;for(m=0;m<a.length;++m){let H=a[m];if(ut(H,M))O+H.length>R.length?(N.isBuffer(H)||(H=N.from(H)),H.copy(R,O)):M.prototype.set.call(R,H,O);else if(N.isBuffer(H))H.copy(R,O);else throw new TypeError('"list" argument must be an Array of Buffers');O+=H.length}return R};function be(y,a){if(N.isBuffer(y))return y.length;if(U.isView(y)||ut(y,U))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const f=y.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&f===0)return 0;let R=!1;for(;;)switch(a){case"ascii":case"latin1":case"binary":return f;case"utf8":case"utf-8":return ge(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return f*2;case"hex":return f>>>1;case"base64":return le(y).length;default:if(R)return m?-1:ge(y).length;a=(""+a).toLowerCase(),R=!0}}N.byteLength=be;function ke(y,a,f){let m=!1;if((a===void 0||a<0)&&(a=0),a>this.length||((f===void 0||f>this.length)&&(f=this.length),f<=0)||(f>>>=0,a>>>=0,f<=a))return"";for(y||(y="utf8");;)switch(y){case"hex":return At(this,a,f);case"utf8":case"utf-8":return de(this,a,f);case"ascii":return ct(this,a,f);case"latin1":case"binary":return xt(this,a,f);case"base64":return V(this,a,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fr(this,a,f);default:if(m)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),m=!0}}N.prototype._isBuffer=!0;function D(y,a,f){const m=y[a];y[a]=y[f],y[f]=m}N.prototype.swap16=function(){const a=this.length;if(a%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let f=0;f<a;f+=2)D(this,f,f+1);return this},N.prototype.swap32=function(){const a=this.length;if(a%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let f=0;f<a;f+=4)D(this,f,f+3),D(this,f+1,f+2);return this},N.prototype.swap64=function(){const a=this.length;if(a%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let f=0;f<a;f+=8)D(this,f,f+7),D(this,f+1,f+6),D(this,f+2,f+5),D(this,f+3,f+4);return this},N.prototype.toString=function(){const a=this.length;return a===0?"":arguments.length===0?de(this,0,a):ke.apply(this,arguments)},N.prototype.toLocaleString=N.prototype.toString,N.prototype.equals=function(a){if(!N.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:N.compare(this,a)===0},N.prototype.inspect=function(){let a="";const f=x.INSPECT_MAX_BYTES;return a=this.toString("hex",0,f).replace(/(.{2})/g,"$1 ").trim(),this.length>f&&(a+=" ... "),"<Buffer "+a+">"},v&&(N.prototype[v]=N.prototype.inspect),N.prototype.compare=function(a,f,m,R,O){if(ut(a,M)&&(a=N.from(a,a.offset,a.byteLength)),!N.isBuffer(a))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof a);if(f===void 0&&(f=0),m===void 0&&(m=a?a.length:0),R===void 0&&(R=0),O===void 0&&(O=this.length),f<0||m>a.length||R<0||O>this.length)throw new RangeError("out of range index");if(R>=O&&f>=m)return 0;if(R>=O)return-1;if(f>=m)return 1;if(f>>>=0,m>>>=0,R>>>=0,O>>>=0,this===a)return 0;let H=O-R,ae=m-f;const Ae=Math.min(H,ae),Se=this.slice(R,O),Re=a.slice(f,m);for(let we=0;we<Ae;++we)if(Se[we]!==Re[we]){H=Se[we],ae=Re[we];break}return H<ae?-1:ae<H?1:0};function P(y,a,f,m,R){if(y.length===0)return-1;if(typeof f=="string"?(m=f,f=0):f>2147483647?f=2147483647:f<-2147483648&&(f=-2147483648),f=+f,$n(f)&&(f=R?0:y.length-1),f<0&&(f=y.length+f),f>=y.length){if(R)return-1;f=y.length-1}else if(f<0)if(R)f=0;else return-1;if(typeof a=="string"&&(a=N.from(a,m)),N.isBuffer(a))return a.length===0?-1:J(y,a,f,m,R);if(typeof a=="number")return a=a&255,typeof M.prototype.indexOf=="function"?R?M.prototype.indexOf.call(y,a,f):M.prototype.lastIndexOf.call(y,a,f):J(y,[a],f,m,R);throw new TypeError("val must be string, number or Buffer")}function J(y,a,f,m,R){let O=1,H=y.length,ae=a.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(y.length<2||a.length<2)return-1;O=2,H/=2,ae/=2,f/=2}function Ae(Re,we){return O===1?Re[we]:Re.readUInt16BE(we*O)}let Se;if(R){let Re=-1;for(Se=f;Se<H;Se++)if(Ae(y,Se)===Ae(a,Re===-1?0:Se-Re)){if(Re===-1&&(Re=Se),Se-Re+1===ae)return Re*O}else Re!==-1&&(Se-=Se-Re),Re=-1}else for(f+ae>H&&(f=H-ae),Se=f;Se>=0;Se--){let Re=!0;for(let we=0;we<ae;we++)if(Ae(y,Se+we)!==Ae(a,we)){Re=!1;break}if(Re)return Se}return-1}N.prototype.includes=function(a,f,m){return this.indexOf(a,f,m)!==-1},N.prototype.indexOf=function(a,f,m){return P(this,a,f,m,!0)},N.prototype.lastIndexOf=function(a,f,m){return P(this,a,f,m,!1)};function X(y,a,f,m){f=Number(f)||0;const R=y.length-f;m?(m=Number(m),m>R&&(m=R)):m=R;const O=a.length;m>O/2&&(m=O/2);let H;for(H=0;H<m;++H){const ae=parseInt(a.substr(H*2,2),16);if($n(ae))return H;y[f+H]=ae}return H}function ie(y,a,f,m){return $r(ge(a,y.length-f),y,f,m)}function b(y,a,f,m){return $r(me(a),y,f,m)}function E(y,a,f,m){return $r(le(a),y,f,m)}function K(y,a,f,m){return $r(Ee(a,y.length-f),y,f,m)}N.prototype.write=function(a,f,m,R){if(f===void 0)R="utf8",m=this.length,f=0;else if(m===void 0&&typeof f=="string")R=f,m=this.length,f=0;else if(isFinite(f))f=f>>>0,isFinite(m)?(m=m>>>0,R===void 0&&(R="utf8")):(R=m,m=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const O=this.length-f;if((m===void 0||m>O)&&(m=O),a.length>0&&(m<0||f<0)||f>this.length)throw new RangeError("Attempt to write outside buffer bounds");R||(R="utf8");let H=!1;for(;;)switch(R){case"hex":return X(this,a,f,m);case"utf8":case"utf-8":return ie(this,a,f,m);case"ascii":case"latin1":case"binary":return b(this,a,f,m);case"base64":return E(this,a,f,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,a,f,m);default:if(H)throw new TypeError("Unknown encoding: "+R);R=(""+R).toLowerCase(),H=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function V(y,a,f){return a===0&&f===y.length?F.fromByteArray(y):F.fromByteArray(y.slice(a,f))}function de(y,a,f){f=Math.min(y.length,f);const m=[];let R=a;for(;R<f;){const O=y[R];let H=null,ae=O>239?4:O>223?3:O>191?2:1;if(R+ae<=f){let Ae,Se,Re,we;switch(ae){case 1:O<128&&(H=O);break;case 2:Ae=y[R+1],(Ae&192)===128&&(we=(O&31)<<6|Ae&63,we>127&&(H=we));break;case 3:Ae=y[R+1],Se=y[R+2],(Ae&192)===128&&(Se&192)===128&&(we=(O&15)<<12|(Ae&63)<<6|Se&63,we>2047&&(we<55296||we>57343)&&(H=we));break;case 4:Ae=y[R+1],Se=y[R+2],Re=y[R+3],(Ae&192)===128&&(Se&192)===128&&(Re&192)===128&&(we=(O&15)<<18|(Ae&63)<<12|(Se&63)<<6|Re&63,we>65535&&we<1114112&&(H=we))}}H===null?(H=65533,ae=1):H>65535&&(H-=65536,m.push(H>>>10&1023|55296),H=56320|H&1023),m.push(H),R+=ae}return ue(m)}const ee=4096;function ue(y){const a=y.length;if(a<=ee)return String.fromCharCode.apply(String,y);let f="",m=0;for(;m<a;)f+=String.fromCharCode.apply(String,y.slice(m,m+=ee));return f}function ct(y,a,f){let m="";f=Math.min(y.length,f);for(let R=a;R<f;++R)m+=String.fromCharCode(y[R]&127);return m}function xt(y,a,f){let m="";f=Math.min(y.length,f);for(let R=a;R<f;++R)m+=String.fromCharCode(y[R]);return m}function At(y,a,f){const m=y.length;(!a||a<0)&&(a=0),(!f||f<0||f>m)&&(f=m);let R="";for(let O=a;O<f;++O)R+=Oc[y[O]];return R}function fr(y,a,f){const m=y.slice(a,f);let R="";for(let O=0;O<m.length-1;O+=2)R+=String.fromCharCode(m[O]+m[O+1]*256);return R}N.prototype.slice=function(a,f){const m=this.length;a=~~a,f=f===void 0?m:~~f,a<0?(a+=m,a<0&&(a=0)):a>m&&(a=m),f<0?(f+=m,f<0&&(f=0)):f>m&&(f=m),f<a&&(f=a);const R=this.subarray(a,f);return Object.setPrototypeOf(R,N.prototype),R};function ve(y,a,f){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+a>f)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(a,f,m){a=a>>>0,f=f>>>0,m||ve(a,f,this.length);let R=this[a],O=1,H=0;for(;++H<f&&(O*=256);)R+=this[a+H]*O;return R},N.prototype.readUintBE=N.prototype.readUIntBE=function(a,f,m){a=a>>>0,f=f>>>0,m||ve(a,f,this.length);let R=this[a+--f],O=1;for(;f>0&&(O*=256);)R+=this[a+--f]*O;return R},N.prototype.readUint8=N.prototype.readUInt8=function(a,f){return a=a>>>0,f||ve(a,1,this.length),this[a]},N.prototype.readUint16LE=N.prototype.readUInt16LE=function(a,f){return a=a>>>0,f||ve(a,2,this.length),this[a]|this[a+1]<<8},N.prototype.readUint16BE=N.prototype.readUInt16BE=function(a,f){return a=a>>>0,f||ve(a,2,this.length),this[a]<<8|this[a+1]},N.prototype.readUint32LE=N.prototype.readUInt32LE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+this[a+3]*16777216},N.prototype.readUint32BE=N.prototype.readUInt32BE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),this[a]*16777216+(this[a+1]<<16|this[a+2]<<8|this[a+3])},N.prototype.readBigUInt64LE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&C(a,this.length-8);const R=f+this[++a]*2**8+this[++a]*2**16+this[++a]*2**24,O=this[++a]+this[++a]*2**8+this[++a]*2**16+m*2**24;return BigInt(R)+(BigInt(O)<<BigInt(32))}),N.prototype.readBigUInt64BE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&C(a,this.length-8);const R=f*2**24+this[++a]*2**16+this[++a]*2**8+this[++a],O=this[++a]*2**24+this[++a]*2**16+this[++a]*2**8+m;return(BigInt(R)<<BigInt(32))+BigInt(O)}),N.prototype.readIntLE=function(a,f,m){a=a>>>0,f=f>>>0,m||ve(a,f,this.length);let R=this[a],O=1,H=0;for(;++H<f&&(O*=256);)R+=this[a+H]*O;return O*=128,R>=O&&(R-=Math.pow(2,8*f)),R},N.prototype.readIntBE=function(a,f,m){a=a>>>0,f=f>>>0,m||ve(a,f,this.length);let R=f,O=1,H=this[a+--R];for(;R>0&&(O*=256);)H+=this[a+--R]*O;return O*=128,H>=O&&(H-=Math.pow(2,8*f)),H},N.prototype.readInt8=function(a,f){return a=a>>>0,f||ve(a,1,this.length),this[a]&128?(255-this[a]+1)*-1:this[a]},N.prototype.readInt16LE=function(a,f){a=a>>>0,f||ve(a,2,this.length);const m=this[a]|this[a+1]<<8;return m&32768?m|4294901760:m},N.prototype.readInt16BE=function(a,f){a=a>>>0,f||ve(a,2,this.length);const m=this[a+1]|this[a]<<8;return m&32768?m|4294901760:m},N.prototype.readInt32LE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},N.prototype.readInt32BE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},N.prototype.readBigInt64LE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&C(a,this.length-8);const R=this[a+4]+this[a+5]*2**8+this[a+6]*2**16+(m<<24);return(BigInt(R)<<BigInt(32))+BigInt(f+this[++a]*2**8+this[++a]*2**16+this[++a]*2**24)}),N.prototype.readBigInt64BE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&C(a,this.length-8);const R=(f<<24)+this[++a]*2**16+this[++a]*2**8+this[++a];return(BigInt(R)<<BigInt(32))+BigInt(this[++a]*2**24+this[++a]*2**16+this[++a]*2**8+m)}),N.prototype.readFloatLE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),_.read(this,a,!0,23,4)},N.prototype.readFloatBE=function(a,f){return a=a>>>0,f||ve(a,4,this.length),_.read(this,a,!1,23,4)},N.prototype.readDoubleLE=function(a,f){return a=a>>>0,f||ve(a,8,this.length),_.read(this,a,!0,52,8)},N.prototype.readDoubleBE=function(a,f){return a=a>>>0,f||ve(a,8,this.length),_.read(this,a,!1,52,8)};function Be(y,a,f,m,R,O){if(!N.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(a>R||a<O)throw new RangeError('"value" argument is out of bounds');if(f+m>y.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(a,f,m,R){if(a=+a,f=f>>>0,m=m>>>0,!R){const ae=Math.pow(2,8*m)-1;Be(this,a,f,m,ae,0)}let O=1,H=0;for(this[f]=a&255;++H<m&&(O*=256);)this[f+H]=a/O&255;return f+m},N.prototype.writeUintBE=N.prototype.writeUIntBE=function(a,f,m,R){if(a=+a,f=f>>>0,m=m>>>0,!R){const ae=Math.pow(2,8*m)-1;Be(this,a,f,m,ae,0)}let O=m-1,H=1;for(this[f+O]=a&255;--O>=0&&(H*=256);)this[f+O]=a/H&255;return f+m},N.prototype.writeUint8=N.prototype.writeUInt8=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,1,255,0),this[f]=a&255,f+1},N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,2,65535,0),this[f]=a&255,this[f+1]=a>>>8,f+2},N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,2,65535,0),this[f]=a>>>8,this[f+1]=a&255,f+2},N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,4,4294967295,0),this[f+3]=a>>>24,this[f+2]=a>>>16,this[f+1]=a>>>8,this[f]=a&255,f+4},N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,4,4294967295,0),this[f]=a>>>24,this[f+1]=a>>>16,this[f+2]=a>>>8,this[f+3]=a&255,f+4};function Xe(y,a,f,m,R){g(a,m,R,y,f,7);let O=Number(a&BigInt(4294967295));y[f++]=O,O=O>>8,y[f++]=O,O=O>>8,y[f++]=O,O=O>>8,y[f++]=O;let H=Number(a>>BigInt(32)&BigInt(4294967295));return y[f++]=H,H=H>>8,y[f++]=H,H=H>>8,y[f++]=H,H=H>>8,y[f++]=H,f}function Le(y,a,f,m,R){g(a,m,R,y,f,7);let O=Number(a&BigInt(4294967295));y[f+7]=O,O=O>>8,y[f+6]=O,O=O>>8,y[f+5]=O,O=O>>8,y[f+4]=O;let H=Number(a>>BigInt(32)&BigInt(4294967295));return y[f+3]=H,H=H>>8,y[f+2]=H,H=H>>8,y[f+1]=H,H=H>>8,y[f]=H,f+8}N.prototype.writeBigUInt64LE=It(function(a,f=0){return Xe(this,a,f,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeBigUInt64BE=It(function(a,f=0){return Le(this,a,f,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeIntLE=function(a,f,m,R){if(a=+a,f=f>>>0,!R){const Ae=Math.pow(2,8*m-1);Be(this,a,f,m,Ae-1,-Ae)}let O=0,H=1,ae=0;for(this[f]=a&255;++O<m&&(H*=256);)a<0&&ae===0&&this[f+O-1]!==0&&(ae=1),this[f+O]=(a/H>>0)-ae&255;return f+m},N.prototype.writeIntBE=function(a,f,m,R){if(a=+a,f=f>>>0,!R){const Ae=Math.pow(2,8*m-1);Be(this,a,f,m,Ae-1,-Ae)}let O=m-1,H=1,ae=0;for(this[f+O]=a&255;--O>=0&&(H*=256);)a<0&&ae===0&&this[f+O+1]!==0&&(ae=1),this[f+O]=(a/H>>0)-ae&255;return f+m},N.prototype.writeInt8=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,1,127,-128),a<0&&(a=255+a+1),this[f]=a&255,f+1},N.prototype.writeInt16LE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,2,32767,-32768),this[f]=a&255,this[f+1]=a>>>8,f+2},N.prototype.writeInt16BE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,2,32767,-32768),this[f]=a>>>8,this[f+1]=a&255,f+2},N.prototype.writeInt32LE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,4,2147483647,-2147483648),this[f]=a&255,this[f+1]=a>>>8,this[f+2]=a>>>16,this[f+3]=a>>>24,f+4},N.prototype.writeInt32BE=function(a,f,m){return a=+a,f=f>>>0,m||Be(this,a,f,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),this[f]=a>>>24,this[f+1]=a>>>16,this[f+2]=a>>>8,this[f+3]=a&255,f+4},N.prototype.writeBigInt64LE=It(function(a,f=0){return Xe(this,a,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),N.prototype.writeBigInt64BE=It(function(a,f=0){return Le(this,a,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Je(y,a,f,m,R,O){if(f+m>y.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("Index out of range")}function Ze(y,a,f,m,R){return a=+a,f=f>>>0,R||Je(y,a,f,4),_.write(y,a,f,m,23,4),f+4}N.prototype.writeFloatLE=function(a,f,m){return Ze(this,a,f,!0,m)},N.prototype.writeFloatBE=function(a,f,m){return Ze(this,a,f,!1,m)};function Fe(y,a,f,m,R){return a=+a,f=f>>>0,R||Je(y,a,f,8),_.write(y,a,f,m,52,8),f+8}N.prototype.writeDoubleLE=function(a,f,m){return Fe(this,a,f,!0,m)},N.prototype.writeDoubleBE=function(a,f,m){return Fe(this,a,f,!1,m)},N.prototype.copy=function(a,f,m,R){if(!N.isBuffer(a))throw new TypeError("argument should be a Buffer");if(m||(m=0),!R&&R!==0&&(R=this.length),f>=a.length&&(f=a.length),f||(f=0),R>0&&R<m&&(R=m),R===m||a.length===0||this.length===0)return 0;if(f<0)throw new RangeError("targetStart out of bounds");if(m<0||m>=this.length)throw new RangeError("Index out of range");if(R<0)throw new RangeError("sourceEnd out of bounds");R>this.length&&(R=this.length),a.length-f<R-m&&(R=a.length-f+m);const O=R-m;return this===a&&typeof M.prototype.copyWithin=="function"?this.copyWithin(f,m,R):M.prototype.set.call(a,this.subarray(m,R),f),O},N.prototype.fill=function(a,f,m,R){if(typeof a=="string"){if(typeof f=="string"?(R=f,f=0,m=this.length):typeof m=="string"&&(R=m,m=this.length),R!==void 0&&typeof R!="string")throw new TypeError("encoding must be a string");if(typeof R=="string"&&!N.isEncoding(R))throw new TypeError("Unknown encoding: "+R);if(a.length===1){const H=a.charCodeAt(0);(R==="utf8"&&H<128||R==="latin1")&&(a=H)}}else typeof a=="number"?a=a&255:typeof a=="boolean"&&(a=Number(a));if(f<0||this.length<f||this.length<m)throw new RangeError("Out of range index");if(m<=f)return this;f=f>>>0,m=m===void 0?this.length:m>>>0,a||(a=0);let O;if(typeof a=="number")for(O=f;O<m;++O)this[O]=a;else{const H=N.isBuffer(a)?a:N.from(a,R),ae=H.length;if(ae===0)throw new TypeError('The value "'+a+'" is invalid for argument "value"');for(O=0;O<m-f;++O)this[O+f]=H[O%ae]}return this};const Rt={};function p(y,a,f){Rt[y]=class extends f{constructor(){super(),Object.defineProperty(this,"message",{value:a.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(R){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:R,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}p("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),p("ERR_INVALID_ARG_TYPE",function(y,a){return`The "${y}" argument must be of type number. Received type ${typeof a}`},TypeError),p("ERR_OUT_OF_RANGE",function(y,a,f){let m=`The value of "${y}" is out of range.`,R=f;return Number.isInteger(f)&&Math.abs(f)>2**32?R=o(String(f)):typeof f=="bigint"&&(R=String(f),(f>BigInt(2)**BigInt(32)||f<-(BigInt(2)**BigInt(32)))&&(R=o(R)),R+="n"),m+=` It must be ${a}. Received ${R}`,m},RangeError);function o(y){let a="",f=y.length;const m=y[0]==="-"?1:0;for(;f>=m+4;f-=3)a=`_${y.slice(f-3,f)}${a}`;return`${y.slice(0,f)}${a}`}function u(y,a,f){A(a,"offset"),(y[a]===void 0||y[a+f]===void 0)&&C(a,y.length-(f+1))}function g(y,a,f,m,R,O){if(y>f||y<a){const H=typeof a=="bigint"?"n":"";let ae;throw a===0||a===BigInt(0)?ae=`>= 0${H} and < 2${H} ** ${(O+1)*8}${H}`:ae=`>= -(2${H} ** ${(O+1)*8-1}${H}) and < 2 ** ${(O+1)*8-1}${H}`,new Rt.ERR_OUT_OF_RANGE("value",ae,y)}u(m,R,O)}function A(y,a){if(typeof y!="number")throw new Rt.ERR_INVALID_ARG_TYPE(a,"number",y)}function C(y,a,f){throw Math.floor(y)!==y?(A(y,f),new Rt.ERR_OUT_OF_RANGE("offset","an integer",y)):a<0?new Rt.ERR_BUFFER_OUT_OF_BOUNDS:new Rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${a}`,y)}const j=/[^+/0-9A-Za-z-_]/g;function oe(y){if(y=y.split("=")[0],y=y.trim().replace(j,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function ge(y,a){a=a||1/0;let f;const m=y.length;let R=null;const O=[];for(let H=0;H<m;++H){if(f=y.charCodeAt(H),f>55295&&f<57344){if(!R){if(f>56319){(a-=3)>-1&&O.push(239,191,189);continue}else if(H+1===m){(a-=3)>-1&&O.push(239,191,189);continue}R=f;continue}if(f<56320){(a-=3)>-1&&O.push(239,191,189),R=f;continue}f=(R-55296<<10|f-56320)+65536}else R&&(a-=3)>-1&&O.push(239,191,189);if(R=null,f<128){if((a-=1)<0)break;O.push(f)}else if(f<2048){if((a-=2)<0)break;O.push(f>>6|192,f&63|128)}else if(f<65536){if((a-=3)<0)break;O.push(f>>12|224,f>>6&63|128,f&63|128)}else if(f<1114112){if((a-=4)<0)break;O.push(f>>18|240,f>>12&63|128,f>>6&63|128,f&63|128)}else throw new Error("Invalid code point")}return O}function me(y){const a=[];for(let f=0;f<y.length;++f)a.push(y.charCodeAt(f)&255);return a}function Ee(y,a){let f,m,R;const O=[];for(let H=0;H<y.length&&!((a-=2)<0);++H)f=y.charCodeAt(H),m=f>>8,R=f%256,O.push(R),O.push(m);return O}function le(y){return F.toByteArray(oe(y))}function $r(y,a,f,m){let R;for(R=0;R<m&&!(R+f>=a.length||R>=y.length);++R)a[R+f]=y[R];return R}function ut(y,a){return y instanceof a||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===a.name}function $n(y){return y!==y}const Oc=(function(){const y="0123456789abcdef",a=new Array(256);for(let f=0;f<16;++f){const m=f*16;for(let R=0;R<16;++R)a[m+R]=y[f]+y[R]}return a})();function It(y){return typeof BigInt>"u"?$c:y}function $c(){throw new Error("BigInt not supported")}})(e);const S=e.Buffer;t.Blob=e.Blob,t.BlobOptions=e.BlobOptions,t.Buffer=e.Buffer,t.File=e.File,t.FileOptions=e.FileOptions,t.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,t.SlowBuffer=e.SlowBuffer,t.TranscodeEncoding=e.TranscodeEncoding,t.atob=e.atob,t.btoa=e.btoa,t.constants=e.constants,t.default=S,t.isAscii=e.isAscii,t.isUtf8=e.isUtf8,t.kMaxLength=e.kMaxLength,t.kStringMaxLength=e.kStringMaxLength,t.resolveObjectURL=e.resolveObjectURL,t.transcode=e.transcode})(Gr)),Gr}const Yn=Yt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Jr,Qn;function ro(){if(Qn)return Jr;Qn=1;function t(B,q){var $=Object.keys(B);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(B);q&&(S=S.filter(function(x){return Object.getOwnPropertyDescriptor(B,x).enumerable})),$.push.apply($,S)}return $}function e(B){for(var q=1;q<arguments.length;q++){var $=arguments[q]!=null?arguments[q]:{};q%2?t(Object($),!0).forEach(function(S){r(B,S,$[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(B,Object.getOwnPropertyDescriptors($)):t(Object($)).forEach(function(S){Object.defineProperty(B,S,Object.getOwnPropertyDescriptor($,S))})}return B}function r(B,q,$){return q=c(q),q in B?Object.defineProperty(B,q,{value:$,enumerable:!0,configurable:!0,writable:!0}):B[q]=$,B}function n(B,q){if(!(B instanceof q))throw new TypeError("Cannot call a class as a function")}function s(B,q){for(var $=0;$<q.length;$++){var S=q[$];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(B,c(S.key),S)}}function i(B,q,$){return q&&s(B.prototype,q),Object.defineProperty(B,"prototype",{writable:!1}),B}function c(B){var q=l(B,"string");return typeof q=="symbol"?q:String(q)}function l(B,q){if(typeof B!="object"||B===null)return B;var $=B[Symbol.toPrimitive];if($!==void 0){var S=$.call(B,q);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(B)}var h=yr(),w=h.Buffer,d=Yn,I=d.inspect,T=I&&I.custom||"inspect";function L(B,q,$){w.prototype.copy.call(B,q,$)}return Jr=(function(){function B(){n(this,B),this.head=null,this.tail=null,this.length=0}return i(B,[{key:"push",value:function($){var S={data:$,next:null};this.length>0?this.tail.next=S:this.head=S,this.tail=S,++this.length}},{key:"unshift",value:function($){var S={data:$,next:this.head};this.length===0&&(this.tail=S),this.head=S,++this.length}},{key:"shift",value:function(){if(this.length!==0){var $=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,$}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function($){if(this.length===0)return"";for(var S=this.head,x=""+S.data;S=S.next;)x+=$+S.data;return x}},{key:"concat",value:function($){if(this.length===0)return w.alloc(0);for(var S=w.allocUnsafe($>>>0),x=this.head,F=0;x;)L(x.data,S,F),F+=x.data.length,x=x.next;return S}},{key:"consume",value:function($,S){var x;return $<this.head.data.length?(x=this.head.data.slice(0,$),this.head.data=this.head.data.slice($)):$===this.head.data.length?x=this.shift():x=S?this._getString($):this._getBuffer($),x}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function($){var S=this.head,x=1,F=S.data;for($-=F.length;S=S.next;){var _=S.data,v=$>_.length?_.length:$;if(v===_.length?F+=_:F+=_.slice(0,$),$-=v,$===0){v===_.length?(++x,S.next?this.head=S.next:this.head=this.tail=null):(this.head=S,S.data=_.slice(v));break}++x}return this.length-=x,F}},{key:"_getBuffer",value:function($){var S=w.allocUnsafe($),x=this.head,F=1;for(x.data.copy(S),$-=x.data.length;x=x.next;){var _=x.data,v=$>_.length?_.length:$;if(_.copy(S,S.length-$,0,v),$-=v,$===0){v===_.length?(++F,x.next?this.head=x.next:this.head=this.tail=null):(this.head=x,x.data=_.slice(v));break}++F}return this.length-=F,S}},{key:T,value:function($,S){return I(this,e(e({},S),{},{depth:0,customInspect:!1}))}}]),B})(),Jr}var zr,Xn;function Zn(){if(Xn)return zr;Xn=1;function t(c,l){var h=this,w=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return w||d?(l?l(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,pe.nextTick(s,this,c)):pe.nextTick(s,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(I){!l&&I?h._writableState?h._writableState.errorEmitted?pe.nextTick(r,h):(h._writableState.errorEmitted=!0,pe.nextTick(e,h,I)):pe.nextTick(e,h,I):l?(pe.nextTick(r,h),l(I)):pe.nextTick(r,h)}),this)}function e(c,l){s(c,l),r(c)}function r(c){c._writableState&&!c._writableState.emitClose||c._readableState&&!c._readableState.emitClose||c.emit("close")}function n(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(c,l){c.emit("error",l)}function i(c,l){var h=c._readableState,w=c._writableState;h&&h.autoDestroy||w&&w.autoDestroy?c.destroy(l):c.emit("error",l)}return zr={destroy:t,undestroy:n,errorOrDestroy:i},zr}var Vr={},ei;function Ct(){if(ei)return Vr;ei=1;function t(l,h){l.prototype=Object.create(h.prototype),l.prototype.constructor=l,l.__proto__=h}var e={};function r(l,h,w){w||(w=Error);function d(T,L,B){return typeof h=="string"?h:h(T,L,B)}var I=(function(T){t(L,T);function L(B,q,$){return T.call(this,d(B,q,$))||this}return L})(w);I.prototype.name=w.name,I.prototype.code=l,e[l]=I}function n(l,h){if(Array.isArray(l)){var w=l.length;return l=l.map(function(d){return String(d)}),w>2?"one of ".concat(h," ").concat(l.slice(0,w-1).join(", "),", or ")+l[w-1]:w===2?"one of ".concat(h," ").concat(l[0]," or ").concat(l[1]):"of ".concat(h," ").concat(l[0])}else return"of ".concat(h," ").concat(String(l))}function s(l,h,w){return l.substr(0,h.length)===h}function i(l,h,w){return(w===void 0||w>l.length)&&(w=l.length),l.substring(w-h.length,w)===h}function c(l,h,w){return typeof w!="number"&&(w=0),w+h.length>l.length?!1:l.indexOf(h,w)!==-1}return r("ERR_INVALID_OPT_VALUE",function(l,h){return'The value "'+h+'" is invalid for option "'+l+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(l,h,w){var d;typeof h=="string"&&s(h,"not ")?(d="must not be",h=h.replace(/^not /,"")):d="must be";var I;if(i(l," argument"))I="The ".concat(l," ").concat(d," ").concat(n(h,"type"));else{var T=c(l,".")?"property":"argument";I='The "'.concat(l,'" ').concat(T," ").concat(d," ").concat(n(h,"type"))}return I+=". Received type ".concat(typeof w),I},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Vr.codes=e,Vr}var Yr,ti;function ri(){if(ti)return Yr;ti=1;var t=Ct().codes.ERR_INVALID_OPT_VALUE;function e(n,s,i){return n.highWaterMark!=null?n.highWaterMark:s?n[i]:null}function r(n,s,i,c){var l=e(s,c,i);if(l!=null){if(!(isFinite(l)&&Math.floor(l)===l)||l<0){var h=c?i:"highWaterMark";throw new t(h,l)}return Math.floor(l)}return n.objectMode?16:16*1024}return Yr={getHighWaterMark:r},Yr}var Qr,ni;function no(){if(ni)return Qr;ni=1,Qr=t;function t(r,n){if(e("noDeprecation"))return r;var s=!1;function i(){if(!s){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),s=!0}return r.apply(this,arguments)}return i}function e(r){try{if(!et.localStorage)return!1}catch{return!1}var n=et.localStorage[r];return n==null?!1:String(n).toLowerCase()==="true"}return Qr}var Xr,ii;function si(){if(ii)return Xr;ii=1,Xr=U;function t(D){var P=this;this.next=null,this.entry=null,this.finish=function(){ke(P,D)}}var e;U.WritableState=k;var r={deprecate:no()},n=zn(),s=yr().Buffer,i=(typeof et<"u"?et:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(D){return s.from(D)}function l(D){return s.isBuffer(D)||D instanceof i}var h=Zn(),w=ri(),d=w.getHighWaterMark,I=Ct().codes,T=I.ERR_INVALID_ARG_TYPE,L=I.ERR_METHOD_NOT_IMPLEMENTED,B=I.ERR_MULTIPLE_CALLBACK,q=I.ERR_STREAM_CANNOT_PIPE,$=I.ERR_STREAM_DESTROYED,S=I.ERR_STREAM_NULL_VALUES,x=I.ERR_STREAM_WRITE_AFTER_END,F=I.ERR_UNKNOWN_ENCODING,_=h.errorOrDestroy;Pt()(U,n);function v(){}function k(D,P,J){e=e||Ot(),D=D||{},typeof J!="boolean"&&(J=P instanceof e),this.objectMode=!!D.objectMode,J&&(this.objectMode=this.objectMode||!!D.writableObjectMode),this.highWaterMark=d(this,D,"writableHighWaterMark",J),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var X=D.decodeStrings===!1;this.decodeStrings=!X,this.defaultEncoding=D.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ie){se(P,ie)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=D.emitClose!==!1,this.autoDestroy=!!D.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}k.prototype.getBuffer=function(){for(var P=this.bufferedRequest,J=[];P;)J.push(P),P=P.next;return J},(function(){try{Object.defineProperty(k.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var M;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(M=Function.prototype[Symbol.hasInstance],Object.defineProperty(U,Symbol.hasInstance,{value:function(P){return M.call(this,P)?!0:this!==U?!1:P&&P._writableState instanceof k}})):M=function(P){return P instanceof this};function U(D){e=e||Ot();var P=this instanceof e;if(!P&&!M.call(U,this))return new U(D);this._writableState=new k(D,this,P),this.writable=!0,D&&(typeof D.write=="function"&&(this._write=D.write),typeof D.writev=="function"&&(this._writev=D.writev),typeof D.destroy=="function"&&(this._destroy=D.destroy),typeof D.final=="function"&&(this._final=D.final)),n.call(this)}U.prototype.pipe=function(){_(this,new q)};function W(D,P){var J=new x;_(D,J),pe.nextTick(P,J)}function G(D,P,J,X){var ie;return J===null?ie=new S:typeof J!="string"&&!P.objectMode&&(ie=new T("chunk",["string","Buffer"],J)),ie?(_(D,ie),pe.nextTick(X,ie),!1):!0}U.prototype.write=function(D,P,J){var X=this._writableState,ie=!1,b=!X.objectMode&&l(D);return b&&!s.isBuffer(D)&&(D=c(D)),typeof P=="function"&&(J=P,P=null),b?P="buffer":P||(P=X.defaultEncoding),typeof J!="function"&&(J=v),X.ending?W(this,J):(b||G(this,X,D,J))&&(X.pendingcb++,ie=N(this,X,b,D,P,J)),ie},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var D=this._writableState;D.corked&&(D.corked--,!D.writing&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&Ce(this,D))},U.prototype.setDefaultEncoding=function(P){if(typeof P=="string"&&(P=P.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((P+"").toLowerCase())>-1))throw new F(P);return this._writableState.defaultEncoding=P,this},Object.defineProperty(U.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Y(D,P,J){return!D.objectMode&&D.decodeStrings!==!1&&typeof P=="string"&&(P=s.from(P,J)),P}Object.defineProperty(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function N(D,P,J,X,ie,b){if(!J){var E=Y(P,X,ie);X!==E&&(J=!0,ie="buffer",X=E)}var K=P.objectMode?1:X.length;P.length+=K;var V=P.length<P.highWaterMark;if(V||(P.needDrain=!0),P.writing||P.corked){var de=P.lastBufferedRequest;P.lastBufferedRequest={chunk:X,encoding:ie,isBuf:J,callback:b,next:null},de?de.next=P.lastBufferedRequest:P.bufferedRequest=P.lastBufferedRequest,P.bufferedRequestCount+=1}else Z(D,P,!1,K,X,ie,b);return V}function Z(D,P,J,X,ie,b,E){P.writelen=X,P.writecb=E,P.writing=!0,P.sync=!0,P.destroyed?P.onwrite(new $("write")):J?D._writev(ie,P.onwrite):D._write(ie,b,P.onwrite),P.sync=!1}function re(D,P,J,X,ie){--P.pendingcb,J?(pe.nextTick(ie,X),pe.nextTick(Qe,D,P),D._writableState.errorEmitted=!0,_(D,X)):(ie(X),D._writableState.errorEmitted=!0,_(D,X),Qe(D,P))}function Q(D){D.writing=!1,D.writecb=null,D.length-=D.writelen,D.writelen=0}function se(D,P){var J=D._writableState,X=J.sync,ie=J.writecb;if(typeof ie!="function")throw new B;if(Q(J),P)re(D,J,X,P,ie);else{var b=Oe(J)||D.destroyed;!b&&!J.corked&&!J.bufferProcessing&&J.bufferedRequest&&Ce(D,J),X?pe.nextTick(fe,D,J,b,ie):fe(D,J,b,ie)}}function fe(D,P,J,X){J||ye(D,P),P.pendingcb--,X(),Qe(D,P)}function ye(D,P){P.length===0&&P.needDrain&&(P.needDrain=!1,D.emit("drain"))}function Ce(D,P){P.bufferProcessing=!0;var J=P.bufferedRequest;if(D._writev&&J&&J.next){var X=P.bufferedRequestCount,ie=new Array(X),b=P.corkedRequestsFree;b.entry=J;for(var E=0,K=!0;J;)ie[E]=J,J.isBuf||(K=!1),J=J.next,E+=1;ie.allBuffers=K,Z(D,P,!0,P.length,ie,"",b.finish),P.pendingcb++,P.lastBufferedRequest=null,b.next?(P.corkedRequestsFree=b.next,b.next=null):P.corkedRequestsFree=new t(P),P.bufferedRequestCount=0}else{for(;J;){var V=J.chunk,de=J.encoding,ee=J.callback,ue=P.objectMode?1:V.length;if(Z(D,P,!1,ue,V,de,ee),J=J.next,P.bufferedRequestCount--,P.writing)break}J===null&&(P.lastBufferedRequest=null)}P.bufferedRequest=J,P.bufferProcessing=!1}U.prototype._write=function(D,P,J){J(new L("_write()"))},U.prototype._writev=null,U.prototype.end=function(D,P,J){var X=this._writableState;return typeof D=="function"?(J=D,D=null,P=null):typeof P=="function"&&(J=P,P=null),D!=null&&this.write(D,P),X.corked&&(X.corked=1,this.uncork()),X.ending||be(this,X,J),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Oe(D){return D.ending&&D.length===0&&D.bufferedRequest===null&&!D.finished&&!D.writing}function wt(D,P){D._final(function(J){P.pendingcb--,J&&_(D,J),P.prefinished=!0,D.emit("prefinish"),Qe(D,P)})}function at(D,P){!P.prefinished&&!P.finalCalled&&(typeof D._final=="function"&&!P.destroyed?(P.pendingcb++,P.finalCalled=!0,pe.nextTick(wt,D,P)):(P.prefinished=!0,D.emit("prefinish")))}function Qe(D,P){var J=Oe(P);if(J&&(at(D,P),P.pendingcb===0&&(P.finished=!0,D.emit("finish"),P.autoDestroy))){var X=D._readableState;(!X||X.autoDestroy&&X.endEmitted)&&D.destroy()}return J}function be(D,P,J){P.ending=!0,Qe(D,P),J&&(P.finished?pe.nextTick(J):D.once("finish",J)),P.ended=!0,D.writable=!1}function ke(D,P,J){var X=D.entry;for(D.entry=null;X;){var ie=X.callback;P.pendingcb--,ie(J),X=X.next}P.corkedRequestsFree.next=D}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(P){this._writableState&&(this._writableState.destroyed=P)}}),U.prototype.destroy=h.destroy,U.prototype._undestroy=h.undestroy,U.prototype._destroy=function(D,P){P(D)},Xr}var Zr,oi;function Ot(){if(oi)return Zr;oi=1;var t=Object.keys||function(w){var d=[];for(var I in w)d.push(I);return d};Zr=c;var e=pi(),r=si();Pt()(c,e);for(var n=t(r.prototype),s=0;s<n.length;s++){var i=n[s];c.prototype[i]||(c.prototype[i]=r.prototype[i])}function c(w){if(!(this instanceof c))return new c(w);e.call(this,w),r.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",l)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function l(){this._writableState.ended||pe.nextTick(h,this)}function h(w){w.end()}return Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),Zr}var en={},wr={exports:{}};var ai;function io(){return ai||(ai=1,(function(t,e){var r=yr(),n=r.Buffer;function s(c,l){for(var h in c)l[h]=c[h]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=i);function i(c,l,h){return n(c,l,h)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(c,l,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return n(c,l,h)},i.alloc=function(c,l,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var w=n(c);return l!==void 0?typeof h=="string"?w.fill(l,h):w.fill(l):w.fill(0),w},i.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return n(c)},i.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(wr,wr.exports)),wr.exports}var ci;function ui(){if(ci)return en;ci=1;var t=io().Buffer,e=t.isEncoding||function(S){switch(S=""+S,S&&S.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(S){if(!S)return"utf8";for(var x;;)switch(S){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return S;default:if(x)return;S=(""+S).toLowerCase(),x=!0}}function n(S){var x=r(S);if(typeof x!="string"&&(t.isEncoding===e||!e(S)))throw new Error("Unknown encoding: "+S);return x||S}en.StringDecoder=s;function s(S){this.encoding=n(S);var x;switch(this.encoding){case"utf16le":this.text=I,this.end=T,x=4;break;case"utf8":this.fillLast=h,x=4;break;case"base64":this.text=L,this.end=B,x=3;break;default:this.write=q,this.end=$;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(x)}s.prototype.write=function(S){if(S.length===0)return"";var x,F;if(this.lastNeed){if(x=this.fillLast(S),x===void 0)return"";F=this.lastNeed,this.lastNeed=0}else F=0;return F<S.length?x?x+this.text(S,F):this.text(S,F):x||""},s.prototype.end=d,s.prototype.text=w,s.prototype.fillLast=function(S){if(this.lastNeed<=S.length)return S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,S.length),this.lastNeed-=S.length};function i(S){return S<=127?0:S>>5===6?2:S>>4===14?3:S>>3===30?4:S>>6===2?-1:-2}function c(S,x,F){var _=x.length-1;if(_<F)return 0;var v=i(x[_]);return v>=0?(v>0&&(S.lastNeed=v-1),v):--_<F||v===-2?0:(v=i(x[_]),v>=0?(v>0&&(S.lastNeed=v-2),v):--_<F||v===-2?0:(v=i(x[_]),v>=0?(v>0&&(v===2?v=0:S.lastNeed=v-3),v):0))}function l(S,x,F){if((x[0]&192)!==128)return S.lastNeed=0,"�";if(S.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return S.lastNeed=1,"�";if(S.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return S.lastNeed=2,"�"}}function h(S){var x=this.lastTotal-this.lastNeed,F=l(this,S);if(F!==void 0)return F;if(this.lastNeed<=S.length)return S.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);S.copy(this.lastChar,x,0,S.length),this.lastNeed-=S.length}function w(S,x){var F=c(this,S,x);if(!this.lastNeed)return S.toString("utf8",x);this.lastTotal=F;var _=S.length-(F-this.lastNeed);return S.copy(this.lastChar,0,_),S.toString("utf8",x,_)}function d(S){var x=S&&S.length?this.write(S):"";return this.lastNeed?x+"�":x}function I(S,x){if((S.length-x)%2===0){var F=S.toString("utf16le",x);if(F){var _=F.charCodeAt(F.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1],F.slice(0,-1)}return F}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=S[S.length-1],S.toString("utf16le",x,S.length-1)}function T(S){var x=S&&S.length?this.write(S):"";if(this.lastNeed){var F=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,F)}return x}function L(S,x){var F=(S.length-x)%3;return F===0?S.toString("base64",x):(this.lastNeed=3-F,this.lastTotal=3,F===1?this.lastChar[0]=S[S.length-1]:(this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1]),S.toString("base64",x,S.length-F))}function B(S){var x=S&&S.length?this.write(S):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function q(S){return S.toString(this.encoding)}function $(S){return S&&S.length?this.write(S):""}return en}var tn,fi;function rn(){if(fi)return tn;fi=1;var t=Ct().codes.ERR_STREAM_PREMATURE_CLOSE;function e(i){var c=!1;return function(){if(!c){c=!0;for(var l=arguments.length,h=new Array(l),w=0;w<l;w++)h[w]=arguments[w];i.apply(this,h)}}}function r(){}function n(i){return i.setHeader&&typeof i.abort=="function"}function s(i,c,l){if(typeof c=="function")return s(i,null,c);c||(c={}),l=e(l||r);var h=c.readable||c.readable!==!1&&i.readable,w=c.writable||c.writable!==!1&&i.writable,d=function(){i.writable||T()},I=i._writableState&&i._writableState.finished,T=function(){w=!1,I=!0,h||l.call(i)},L=i._readableState&&i._readableState.endEmitted,B=function(){h=!1,L=!0,w||l.call(i)},q=function(F){l.call(i,F)},$=function(){var F;if(h&&!L)return(!i._readableState||!i._readableState.ended)&&(F=new t),l.call(i,F);if(w&&!I)return(!i._writableState||!i._writableState.ended)&&(F=new t),l.call(i,F)},S=function(){i.req.on("finish",T)};return n(i)?(i.on("complete",T),i.on("abort",$),i.req?S():i.on("request",S)):w&&!i._writableState&&(i.on("end",d),i.on("close",d)),i.on("end",B),i.on("finish",T),c.error!==!1&&i.on("error",q),i.on("close",$),function(){i.removeListener("complete",T),i.removeListener("abort",$),i.removeListener("request",S),i.req&&i.req.removeListener("finish",T),i.removeListener("end",d),i.removeListener("close",d),i.removeListener("finish",T),i.removeListener("end",B),i.removeListener("error",q),i.removeListener("close",$)}}return tn=s,tn}var nn,li;function so(){if(li)return nn;li=1;var t;function e(F,_,v){return _=r(_),_ in F?Object.defineProperty(F,_,{value:v,enumerable:!0,configurable:!0,writable:!0}):F[_]=v,F}function r(F){var _=n(F,"string");return typeof _=="symbol"?_:String(_)}function n(F,_){if(typeof F!="object"||F===null)return F;var v=F[Symbol.toPrimitive];if(v!==void 0){var k=v.call(F,_);if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(F)}var s=rn(),i=Symbol("lastResolve"),c=Symbol("lastReject"),l=Symbol("error"),h=Symbol("ended"),w=Symbol("lastPromise"),d=Symbol("handlePromise"),I=Symbol("stream");function T(F,_){return{value:F,done:_}}function L(F){var _=F[i];if(_!==null){var v=F[I].read();v!==null&&(F[w]=null,F[i]=null,F[c]=null,_(T(v,!1)))}}function B(F){pe.nextTick(L,F)}function q(F,_){return function(v,k){F.then(function(){if(_[h]){v(T(void 0,!0));return}_[d](v,k)},k)}}var $=Object.getPrototypeOf(function(){}),S=Object.setPrototypeOf((t={get stream(){return this[I]},next:function(){var _=this,v=this[l];if(v!==null)return Promise.reject(v);if(this[h])return Promise.resolve(T(void 0,!0));if(this[I].destroyed)return new Promise(function(W,G){pe.nextTick(function(){_[l]?G(_[l]):W(T(void 0,!0))})});var k=this[w],M;if(k)M=new Promise(q(k,this));else{var U=this[I].read();if(U!==null)return Promise.resolve(T(U,!1));M=new Promise(this[d])}return this[w]=M,M}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var _=this;return new Promise(function(v,k){_[I].destroy(null,function(M){if(M){k(M);return}v(T(void 0,!0))})})}),t),$),x=function(_){var v,k=Object.create(S,(v={},e(v,I,{value:_,writable:!0}),e(v,i,{value:null,writable:!0}),e(v,c,{value:null,writable:!0}),e(v,l,{value:null,writable:!0}),e(v,h,{value:_._readableState.endEmitted,writable:!0}),e(v,d,{value:function(U,W){var G=k[I].read();G?(k[w]=null,k[i]=null,k[c]=null,U(T(G,!1))):(k[i]=U,k[c]=W)},writable:!0}),v));return k[w]=null,s(_,function(M){if(M&&M.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=k[c];U!==null&&(k[w]=null,k[i]=null,k[c]=null,U(M)),k[l]=M;return}var W=k[i];W!==null&&(k[w]=null,k[i]=null,k[c]=null,W(T(void 0,!0))),k[h]=!0}),_.on("readable",B.bind(null,k)),k};return nn=x,nn}var sn,hi;function oo(){return hi||(hi=1,sn=function(){throw new Error("Readable.from is not available in the browser")}),sn}var on,di;function pi(){if(di)return on;di=1,on=W;var t;W.ReadableState=U,hr().EventEmitter;var e=function(E,K){return E.listeners(K).length},r=zn(),n=yr().Buffer,s=(typeof et<"u"?et:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function i(b){return n.from(b)}function c(b){return n.isBuffer(b)||b instanceof s}var l=Yn,h;l&&l.debuglog?h=l.debuglog("stream"):h=function(){};var w=ro(),d=Zn(),I=ri(),T=I.getHighWaterMark,L=Ct().codes,B=L.ERR_INVALID_ARG_TYPE,q=L.ERR_STREAM_PUSH_AFTER_EOF,$=L.ERR_METHOD_NOT_IMPLEMENTED,S=L.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,x,F,_;Pt()(W,r);var v=d.errorOrDestroy,k=["error","close","destroy","pause","resume"];function M(b,E,K){if(typeof b.prependListener=="function")return b.prependListener(E,K);!b._events||!b._events[E]?b.on(E,K):Array.isArray(b._events[E])?b._events[E].unshift(K):b._events[E]=[K,b._events[E]]}function U(b,E,K){t=t||Ot(),b=b||{},typeof K!="boolean"&&(K=E instanceof t),this.objectMode=!!b.objectMode,K&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.highWaterMark=T(this,b,"readableHighWaterMark",K),this.buffer=new w,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=b.emitClose!==!1,this.autoDestroy=!!b.autoDestroy,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(x||(x=ui().StringDecoder),this.decoder=new x(b.encoding),this.encoding=b.encoding)}function W(b){if(t=t||Ot(),!(this instanceof W))return new W(b);var E=this instanceof t;this._readableState=new U(b,this,E),this.readable=!0,b&&(typeof b.read=="function"&&(this._read=b.read),typeof b.destroy=="function"&&(this._destroy=b.destroy)),r.call(this)}Object.defineProperty(W.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(E){this._readableState&&(this._readableState.destroyed=E)}}),W.prototype.destroy=d.destroy,W.prototype._undestroy=d.undestroy,W.prototype._destroy=function(b,E){E(b)},W.prototype.push=function(b,E){var K=this._readableState,V;return K.objectMode?V=!0:typeof b=="string"&&(E=E||K.defaultEncoding,E!==K.encoding&&(b=n.from(b,E),E=""),V=!0),G(this,b,E,!1,V)},W.prototype.unshift=function(b){return G(this,b,null,!0,!1)};function G(b,E,K,V,de){h("readableAddChunk",E);var ee=b._readableState;if(E===null)ee.reading=!1,se(b,ee);else{var ue;if(de||(ue=N(ee,E)),ue)v(b,ue);else if(ee.objectMode||E&&E.length>0)if(typeof E!="string"&&!ee.objectMode&&Object.getPrototypeOf(E)!==n.prototype&&(E=i(E)),V)ee.endEmitted?v(b,new S):Y(b,ee,E,!0);else if(ee.ended)v(b,new q);else{if(ee.destroyed)return!1;ee.reading=!1,ee.decoder&&!K?(E=ee.decoder.write(E),ee.objectMode||E.length!==0?Y(b,ee,E,!1):Ce(b,ee)):Y(b,ee,E,!1)}else V||(ee.reading=!1,Ce(b,ee))}return!ee.ended&&(ee.length<ee.highWaterMark||ee.length===0)}function Y(b,E,K,V){E.flowing&&E.length===0&&!E.sync?(E.awaitDrain=0,b.emit("data",K)):(E.length+=E.objectMode?1:K.length,V?E.buffer.unshift(K):E.buffer.push(K),E.needReadable&&fe(b)),Ce(b,E)}function N(b,E){var K;return!c(E)&&typeof E!="string"&&E!==void 0&&!b.objectMode&&(K=new B("chunk",["string","Buffer","Uint8Array"],E)),K}W.prototype.isPaused=function(){return this._readableState.flowing===!1},W.prototype.setEncoding=function(b){x||(x=ui().StringDecoder);var E=new x(b);this._readableState.decoder=E,this._readableState.encoding=this._readableState.decoder.encoding;for(var K=this._readableState.buffer.head,V="";K!==null;)V+=E.write(K.data),K=K.next;return this._readableState.buffer.clear(),V!==""&&this._readableState.buffer.push(V),this._readableState.length=V.length,this};var Z=1073741824;function re(b){return b>=Z?b=Z:(b--,b|=b>>>1,b|=b>>>2,b|=b>>>4,b|=b>>>8,b|=b>>>16,b++),b}function Q(b,E){return b<=0||E.length===0&&E.ended?0:E.objectMode?1:b!==b?E.flowing&&E.length?E.buffer.head.data.length:E.length:(b>E.highWaterMark&&(E.highWaterMark=re(b)),b<=E.length?b:E.ended?E.length:(E.needReadable=!0,0))}W.prototype.read=function(b){h("read",b),b=parseInt(b,10);var E=this._readableState,K=b;if(b!==0&&(E.emittedReadable=!1),b===0&&E.needReadable&&((E.highWaterMark!==0?E.length>=E.highWaterMark:E.length>0)||E.ended))return h("read: emitReadable",E.length,E.ended),E.length===0&&E.ended?J(this):fe(this),null;if(b=Q(b,E),b===0&&E.ended)return E.length===0&&J(this),null;var V=E.needReadable;h("need readable",V),(E.length===0||E.length-b<E.highWaterMark)&&(V=!0,h("length less than watermark",V)),E.ended||E.reading?(V=!1,h("reading or ended",V)):V&&(h("do read"),E.reading=!0,E.sync=!0,E.length===0&&(E.needReadable=!0),this._read(E.highWaterMark),E.sync=!1,E.reading||(b=Q(K,E)));var de;return b>0?de=P(b,E):de=null,de===null?(E.needReadable=E.length<=E.highWaterMark,b=0):(E.length-=b,E.awaitDrain=0),E.length===0&&(E.ended||(E.needReadable=!0),K!==b&&E.ended&&J(this)),de!==null&&this.emit("data",de),de};function se(b,E){if(h("onEofChunk"),!E.ended){if(E.decoder){var K=E.decoder.end();K&&K.length&&(E.buffer.push(K),E.length+=E.objectMode?1:K.length)}E.ended=!0,E.sync?fe(b):(E.needReadable=!1,E.emittedReadable||(E.emittedReadable=!0,ye(b)))}}function fe(b){var E=b._readableState;h("emitReadable",E.needReadable,E.emittedReadable),E.needReadable=!1,E.emittedReadable||(h("emitReadable",E.flowing),E.emittedReadable=!0,pe.nextTick(ye,b))}function ye(b){var E=b._readableState;h("emitReadable_",E.destroyed,E.length,E.ended),!E.destroyed&&(E.length||E.ended)&&(b.emit("readable"),E.emittedReadable=!1),E.needReadable=!E.flowing&&!E.ended&&E.length<=E.highWaterMark,D(b)}function Ce(b,E){E.readingMore||(E.readingMore=!0,pe.nextTick(Oe,b,E))}function Oe(b,E){for(;!E.reading&&!E.ended&&(E.length<E.highWaterMark||E.flowing&&E.length===0);){var K=E.length;if(h("maybeReadMore read 0"),b.read(0),K===E.length)break}E.readingMore=!1}W.prototype._read=function(b){v(this,new $("_read()"))},W.prototype.pipe=function(b,E){var K=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=b;break;case 1:V.pipes=[V.pipes,b];break;default:V.pipes.push(b);break}V.pipesCount+=1,h("pipe count=%d opts=%j",V.pipesCount,E);var de=(!E||E.end!==!1)&&b!==pe.stdout&&b!==pe.stderr,ee=de?ct:Je;V.endEmitted?pe.nextTick(ee):K.once("end",ee),b.on("unpipe",ue);function ue(Ze,Fe){h("onunpipe"),Ze===K&&Fe&&Fe.hasUnpiped===!1&&(Fe.hasUnpiped=!0,fr())}function ct(){h("onend"),b.end()}var xt=wt(K);b.on("drain",xt);var At=!1;function fr(){h("cleanup"),b.removeListener("close",Xe),b.removeListener("finish",Le),b.removeListener("drain",xt),b.removeListener("error",Be),b.removeListener("unpipe",ue),K.removeListener("end",ct),K.removeListener("end",Je),K.removeListener("data",ve),At=!0,V.awaitDrain&&(!b._writableState||b._writableState.needDrain)&&xt()}K.on("data",ve);function ve(Ze){h("ondata");var Fe=b.write(Ze);h("dest.write",Fe),Fe===!1&&((V.pipesCount===1&&V.pipes===b||V.pipesCount>1&&ie(V.pipes,b)!==-1)&&!At&&(h("false write response, pause",V.awaitDrain),V.awaitDrain++),K.pause())}function Be(Ze){h("onerror",Ze),Je(),b.removeListener("error",Be),e(b,"error")===0&&v(b,Ze)}M(b,"error",Be);function Xe(){b.removeListener("finish",Le),Je()}b.once("close",Xe);function Le(){h("onfinish"),b.removeListener("close",Xe),Je()}b.once("finish",Le);function Je(){h("unpipe"),K.unpipe(b)}return b.emit("pipe",K),V.flowing||(h("pipe resume"),K.resume()),b};function wt(b){return function(){var K=b._readableState;h("pipeOnDrain",K.awaitDrain),K.awaitDrain&&K.awaitDrain--,K.awaitDrain===0&&e(b,"data")&&(K.flowing=!0,D(b))}}W.prototype.unpipe=function(b){var E=this._readableState,K={hasUnpiped:!1};if(E.pipesCount===0)return this;if(E.pipesCount===1)return b&&b!==E.pipes?this:(b||(b=E.pipes),E.pipes=null,E.pipesCount=0,E.flowing=!1,b&&b.emit("unpipe",this,K),this);if(!b){var V=E.pipes,de=E.pipesCount;E.pipes=null,E.pipesCount=0,E.flowing=!1;for(var ee=0;ee<de;ee++)V[ee].emit("unpipe",this,{hasUnpiped:!1});return this}var ue=ie(E.pipes,b);return ue===-1?this:(E.pipes.splice(ue,1),E.pipesCount-=1,E.pipesCount===1&&(E.pipes=E.pipes[0]),b.emit("unpipe",this,K),this)},W.prototype.on=function(b,E){var K=r.prototype.on.call(this,b,E),V=this._readableState;return b==="data"?(V.readableListening=this.listenerCount("readable")>0,V.flowing!==!1&&this.resume()):b==="readable"&&!V.endEmitted&&!V.readableListening&&(V.readableListening=V.needReadable=!0,V.flowing=!1,V.emittedReadable=!1,h("on readable",V.length,V.reading),V.length?fe(this):V.reading||pe.nextTick(Qe,this)),K},W.prototype.addListener=W.prototype.on,W.prototype.removeListener=function(b,E){var K=r.prototype.removeListener.call(this,b,E);return b==="readable"&&pe.nextTick(at,this),K},W.prototype.removeAllListeners=function(b){var E=r.prototype.removeAllListeners.apply(this,arguments);return(b==="readable"||b===void 0)&&pe.nextTick(at,this),E};function at(b){var E=b._readableState;E.readableListening=b.listenerCount("readable")>0,E.resumeScheduled&&!E.paused?E.flowing=!0:b.listenerCount("data")>0&&b.resume()}function Qe(b){h("readable nexttick read 0"),b.read(0)}W.prototype.resume=function(){var b=this._readableState;return b.flowing||(h("resume"),b.flowing=!b.readableListening,be(this,b)),b.paused=!1,this};function be(b,E){E.resumeScheduled||(E.resumeScheduled=!0,pe.nextTick(ke,b,E))}function ke(b,E){h("resume",E.reading),E.reading||b.read(0),E.resumeScheduled=!1,b.emit("resume"),D(b),E.flowing&&!E.reading&&b.read(0)}W.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function D(b){var E=b._readableState;for(h("flow",E.flowing);E.flowing&&b.read()!==null;);}W.prototype.wrap=function(b){var E=this,K=this._readableState,V=!1;b.on("end",function(){if(h("wrapped end"),K.decoder&&!K.ended){var ue=K.decoder.end();ue&&ue.length&&E.push(ue)}E.push(null)}),b.on("data",function(ue){if(h("wrapped data"),K.decoder&&(ue=K.decoder.write(ue)),!(K.objectMode&&ue==null)&&!(!K.objectMode&&(!ue||!ue.length))){var ct=E.push(ue);ct||(V=!0,b.pause())}});for(var de in b)this[de]===void 0&&typeof b[de]=="function"&&(this[de]=(function(ct){return function(){return b[ct].apply(b,arguments)}})(de));for(var ee=0;ee<k.length;ee++)b.on(k[ee],this.emit.bind(this,k[ee]));return this._read=function(ue){h("wrapped _read",ue),V&&(V=!1,b.resume())},this},typeof Symbol=="function"&&(W.prototype[Symbol.asyncIterator]=function(){return F===void 0&&(F=so()),F(this)}),Object.defineProperty(W.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(W.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(W.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(E){this._readableState&&(this._readableState.flowing=E)}}),W._fromList=P,Object.defineProperty(W.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function P(b,E){if(E.length===0)return null;var K;return E.objectMode?K=E.buffer.shift():!b||b>=E.length?(E.decoder?K=E.buffer.join(""):E.buffer.length===1?K=E.buffer.first():K=E.buffer.concat(E.length),E.buffer.clear()):K=E.buffer.consume(b,E.decoder),K}function J(b){var E=b._readableState;h("endReadable",E.endEmitted),E.endEmitted||(E.ended=!0,pe.nextTick(X,E,b))}function X(b,E){if(h("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,E.readable=!1,E.emit("end"),b.autoDestroy)){var K=E._writableState;(!K||K.autoDestroy&&K.finished)&&E.destroy()}}typeof Symbol=="function"&&(W.from=function(b,E){return _===void 0&&(_=oo()),_(W,b,E)});function ie(b,E){for(var K=0,V=b.length;K<V;K++)if(b[K]===E)return K;return-1}return on}var an,yi;function wi(){if(yi)return an;yi=1,an=l;var t=Ct().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,n=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=t.ERR_TRANSFORM_WITH_LENGTH_0,i=Ot();Pt()(l,i);function c(d,I){var T=this._transformState;T.transforming=!1;var L=T.writecb;if(L===null)return this.emit("error",new r);T.writechunk=null,T.writecb=null,I!=null&&this.push(I),L(d);var B=this._readableState;B.reading=!1,(B.needReadable||B.length<B.highWaterMark)&&this._read(B.highWaterMark)}function l(d){if(!(this instanceof l))return new l(d);i.call(this,d),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",h)}function h(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(I,T){w(d,I,T)}):w(this,null,null)}l.prototype.push=function(d,I){return this._transformState.needTransform=!1,i.prototype.push.call(this,d,I)},l.prototype._transform=function(d,I,T){T(new e("_transform()"))},l.prototype._write=function(d,I,T){var L=this._transformState;if(L.writecb=T,L.writechunk=d,L.writeencoding=I,!L.transforming){var B=this._readableState;(L.needTransform||B.needReadable||B.length<B.highWaterMark)&&this._read(B.highWaterMark)}},l.prototype._read=function(d){var I=this._transformState;I.writechunk!==null&&!I.transforming?(I.transforming=!0,this._transform(I.writechunk,I.writeencoding,I.afterTransform)):I.needTransform=!0},l.prototype._destroy=function(d,I){i.prototype._destroy.call(this,d,function(T){I(T)})};function w(d,I,T){if(I)return d.emit("error",I);if(T!=null&&d.push(T),d._writableState.length)throw new s;if(d._transformState.transforming)throw new n;return d.push(null)}return an}var cn,gi;function ao(){if(gi)return cn;gi=1,cn=e;var t=wi();Pt()(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,n,s){s(null,r)},cn}var un,mi;function co(){if(mi)return un;mi=1;var t;function e(T){var L=!1;return function(){L||(L=!0,T.apply(void 0,arguments))}}var r=Ct().codes,n=r.ERR_MISSING_ARGS,s=r.ERR_STREAM_DESTROYED;function i(T){if(T)throw T}function c(T){return T.setHeader&&typeof T.abort=="function"}function l(T,L,B,q){q=e(q);var $=!1;T.on("close",function(){$=!0}),t===void 0&&(t=rn()),t(T,{readable:L,writable:B},function(x){if(x)return q(x);$=!0,q()});var S=!1;return function(x){if(!$&&!S){if(S=!0,c(T))return T.abort();if(typeof T.destroy=="function")return T.destroy();q(x||new s("pipe"))}}}function h(T){T()}function w(T,L){return T.pipe(L)}function d(T){return!T.length||typeof T[T.length-1]!="function"?i:T.pop()}function I(){for(var T=arguments.length,L=new Array(T),B=0;B<T;B++)L[B]=arguments[B];var q=d(L);if(Array.isArray(L[0])&&(L=L[0]),L.length<2)throw new n("streams");var $,S=L.map(function(x,F){var _=F<L.length-1,v=F>0;return l(x,_,v,function(k){$||($=k),k&&S.forEach(h),!_&&(S.forEach(h),q($))})});return L.reduce(w)}return un=I,un}var fn,bi;function uo(){if(bi)return fn;bi=1,fn=r;var t=hr().EventEmitter,e=Pt();e(r,t),r.Readable=pi(),r.Writable=si(),r.Duplex=Ot(),r.Transform=wi(),r.PassThrough=ao(),r.finished=rn(),r.pipeline=co(),r.Stream=r;function r(){t.call(this)}return r.prototype.pipe=function(n,s){var i=this;function c(L){n.writable&&n.write(L)===!1&&i.pause&&i.pause()}i.on("data",c);function l(){i.readable&&i.resume&&i.resume()}n.on("drain",l),!n._isStdio&&(!s||s.end!==!1)&&(i.on("end",w),i.on("close",d));var h=!1;function w(){h||(h=!0,n.end())}function d(){h||(h=!0,typeof n.destroy=="function"&&n.destroy())}function I(L){if(T(),t.listenerCount(this,"error")===0)throw L}i.on("error",I),n.on("error",I);function T(){i.removeListener("data",c),n.removeListener("drain",l),i.removeListener("end",w),i.removeListener("close",d),i.removeListener("error",I),n.removeListener("error",I),i.removeListener("end",T),i.removeListener("close",T),n.removeListener("close",T)}return i.on("end",T),i.on("close",T),n.on("close",T),n.emit("pipe",i),n},fn}var ht=uo();const fo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let gt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=fo[r[t]&63];return e};var ln={},gr={};gr.byteLength=po,gr.toByteArray=wo,gr.fromByteArray=bo;for(var nt=[],je=[],lo=typeof Uint8Array<"u"?Uint8Array:Array,hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$t=0,ho=hn.length;$t<ho;++$t)nt[$t]=hn[$t],je[hn.charCodeAt($t)]=$t;je[45]=62,je[95]=63;function Ei(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function po(t){var e=Ei(t),r=e[0],n=e[1];return(r+n)*3/4-n}function yo(t,e,r){return(e+r)*3/4-r}function wo(t){var e,r=Ei(t),n=r[0],s=r[1],i=new lo(yo(t,n,s)),c=0,l=s>0?n-4:n,h;for(h=0;h<l;h+=4)e=je[t.charCodeAt(h)]<<18|je[t.charCodeAt(h+1)]<<12|je[t.charCodeAt(h+2)]<<6|je[t.charCodeAt(h+3)],i[c++]=e>>16&255,i[c++]=e>>8&255,i[c++]=e&255;return s===2&&(e=je[t.charCodeAt(h)]<<2|je[t.charCodeAt(h+1)]>>4,i[c++]=e&255),s===1&&(e=je[t.charCodeAt(h)]<<10|je[t.charCodeAt(h+1)]<<4|je[t.charCodeAt(h+2)]>>2,i[c++]=e>>8&255,i[c++]=e&255),i}function go(t){return nt[t>>18&63]+nt[t>>12&63]+nt[t>>6&63]+nt[t&63]}function mo(t,e,r){for(var n,s=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(go(n));return s.join("")}function bo(t){for(var e,r=t.length,n=r%3,s=[],i=16383,c=0,l=r-n;c<l;c+=i)s.push(mo(t,c,c+i>l?l:c+i));return n===1?(e=t[r-1],s.push(nt[e>>2]+nt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],s.push(nt[e>>10]+nt[e>>4&63]+nt[e<<2&63]+"=")),s.join("")}var dn={};dn.read=function(t,e,r,n,s){var i,c,l=s*8-n-1,h=(1<<l)-1,w=h>>1,d=-7,I=r?s-1:0,T=r?-1:1,L=t[e+I];for(I+=T,i=L&(1<<-d)-1,L>>=-d,d+=l;d>0;i=i*256+t[e+I],I+=T,d-=8);for(c=i&(1<<-d)-1,i>>=-d,d+=n;d>0;c=c*256+t[e+I],I+=T,d-=8);if(i===0)i=1-w;else{if(i===h)return c?NaN:(L?-1:1)*(1/0);c=c+Math.pow(2,n),i=i-w}return(L?-1:1)*c*Math.pow(2,i-n)},dn.write=function(t,e,r,n,s,i){var c,l,h,w=i*8-s-1,d=(1<<w)-1,I=d>>1,T=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=n?0:i-1,B=n?1:-1,q=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,c=d):(c=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+I>=1?e+=T/h:e+=T*Math.pow(2,1-I),e*h>=2&&(c++,h/=2),c+I>=d?(l=0,c=d):c+I>=1?(l=(e*h-1)*Math.pow(2,s),c=c+I):(l=e*Math.pow(2,I-1)*Math.pow(2,s),c=0));s>=8;t[r+L]=l&255,L+=B,l/=256,s-=8);for(c=c<<s|l,w+=s;w>0;t[r+L]=c&255,L+=B,c/=256,w-=8);t[r+L-B]|=q*128};(function(t){const e=gr,r=dn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:i,ArrayBuffer:c,SharedArrayBuffer:l}=globalThis;d.TYPED_ARRAY_SUPPORT=h(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const p=new i(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,i.prototype),Object.setPrototypeOf(p,o),p.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function w(p){if(p>s)throw new RangeError('The value "'+p+'" is invalid for option "size"');const o=new i(p);return Object.setPrototypeOf(o,d.prototype),o}function d(p,o,u){if(typeof p=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(p)}return I(p,o,u)}d.poolSize=8192;function I(p,o,u){if(typeof p=="string")return q(p,o);if(c.isView(p))return S(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(Le(p,c)||p&&Le(p.buffer,c)||typeof l<"u"&&(Le(p,l)||p&&Le(p.buffer,l)))return x(p,o,u);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=p.valueOf&&p.valueOf();if(g!=null&&g!==p)return d.from(g,o,u);const A=F(p);if(A)return A;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return d.from(p[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}d.from=function(p,o,u){return I(p,o,u)},Object.setPrototypeOf(d.prototype,i.prototype),Object.setPrototypeOf(d,i);function T(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function L(p,o,u){return T(p),p<=0?w(p):o!==void 0?typeof u=="string"?w(p).fill(o,u):w(p).fill(o):w(p)}d.alloc=function(p,o,u){return L(p,o,u)};function B(p){return T(p),w(p<0?0:_(p)|0)}d.allocUnsafe=function(p){return B(p)},d.allocUnsafeSlow=function(p){return B(p)};function q(p,o){if((typeof o!="string"||o==="")&&(o="utf8"),!d.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=k(p,o)|0;let g=w(u);const A=g.write(p,o);return A!==u&&(g=g.slice(0,A)),g}function $(p){const o=p.length<0?0:_(p.length)|0,u=w(o);for(let g=0;g<o;g+=1)u[g]=p[g]&255;return u}function S(p){if(Le(p,i)){const o=new i(p);return x(o.buffer,o.byteOffset,o.byteLength)}return $(p)}function x(p,o,u){if(o<0||p.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let g;return o===void 0&&u===void 0?g=new i(p):u===void 0?g=new i(p,o):g=new i(p,o,u),Object.setPrototypeOf(g,d.prototype),g}function F(p){if(d.isBuffer(p)){const o=_(p.length)|0,u=w(o);return u.length===0||p.copy(u,0,0,o),u}if(p.length!==void 0)return typeof p.length!="number"||Je(p.length)?w(0):$(p);if(p.type==="Buffer"&&Array.isArray(p.data))return $(p.data)}function _(p){if(p>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return p|0}function v(p){return+p!=p&&(p=0),d.alloc(+p)}d.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==d.prototype},d.compare=function(o,u){if(Le(o,i)&&(o=d.from(o,o.offset,o.byteLength)),Le(u,i)&&(u=d.from(u,u.offset,u.byteLength)),!d.isBuffer(o)||!d.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let g=o.length,A=u.length;for(let C=0,j=Math.min(g,A);C<j;++C)if(o[C]!==u[C]){g=o[C],A=u[C];break}return g<A?-1:A<g?1:0},d.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return d.alloc(0);let g;if(u===void 0)for(u=0,g=0;g<o.length;++g)u+=o[g].length;const A=d.allocUnsafe(u);let C=0;for(g=0;g<o.length;++g){let j=o[g];if(Le(j,i))C+j.length>A.length?(d.isBuffer(j)||(j=d.from(j)),j.copy(A,C)):i.prototype.set.call(A,j,C);else if(d.isBuffer(j))j.copy(A,C);else throw new TypeError('"list" argument must be an Array of Buffers');C+=j.length}return A};function k(p,o){if(d.isBuffer(p))return p.length;if(c.isView(p)||Le(p,c))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const u=p.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&u===0)return 0;let A=!1;for(;;)switch(o){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return At(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return Be(p).length;default:if(A)return g?-1:At(p).length;o=(""+o).toLowerCase(),A=!0}}d.byteLength=k;function M(p,o,u){let g=!1;if((o===void 0||o<0)&&(o=0),o>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,o>>>=0,u<=o))return"";for(p||(p="utf8");;)switch(p){case"hex":return at(this,o,u);case"utf8":case"utf-8":return fe(this,o,u);case"ascii":return Oe(this,o,u);case"latin1":case"binary":return wt(this,o,u);case"base64":return se(this,o,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qe(this,o,u);default:if(g)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),g=!0}}d.prototype._isBuffer=!0;function U(p,o,u){const g=p[o];p[o]=p[u],p[u]=g}d.prototype.swap16=function(){const o=this.length;if(o%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<o;u+=2)U(this,u,u+1);return this},d.prototype.swap32=function(){const o=this.length;if(o%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<o;u+=4)U(this,u,u+3),U(this,u+1,u+2);return this},d.prototype.swap64=function(){const o=this.length;if(o%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<o;u+=8)U(this,u,u+7),U(this,u+1,u+6),U(this,u+2,u+5),U(this,u+3,u+4);return this},d.prototype.toString=function(){const o=this.length;return o===0?"":arguments.length===0?fe(this,0,o):M.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(o){if(!d.isBuffer(o))throw new TypeError("Argument must be a Buffer");return this===o?!0:d.compare(this,o)===0},d.prototype.inspect=function(){let o="";const u=t.INSPECT_MAX_BYTES;return o=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(o+=" ... "),"<Buffer "+o+">"},n&&(d.prototype[n]=d.prototype.inspect),d.prototype.compare=function(o,u,g,A,C){if(Le(o,i)&&(o=d.from(o,o.offset,o.byteLength)),!d.isBuffer(o))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof o);if(u===void 0&&(u=0),g===void 0&&(g=o?o.length:0),A===void 0&&(A=0),C===void 0&&(C=this.length),u<0||g>o.length||A<0||C>this.length)throw new RangeError("out of range index");if(A>=C&&u>=g)return 0;if(A>=C)return-1;if(u>=g)return 1;if(u>>>=0,g>>>=0,A>>>=0,C>>>=0,this===o)return 0;let j=C-A,oe=g-u;const ge=Math.min(j,oe),me=this.slice(A,C),Ee=o.slice(u,g);for(let le=0;le<ge;++le)if(me[le]!==Ee[le]){j=me[le],oe=Ee[le];break}return j<oe?-1:oe<j?1:0};function W(p,o,u,g,A){if(p.length===0)return-1;if(typeof u=="string"?(g=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Je(u)&&(u=A?0:p.length-1),u<0&&(u=p.length+u),u>=p.length){if(A)return-1;u=p.length-1}else if(u<0)if(A)u=0;else return-1;if(typeof o=="string"&&(o=d.from(o,g)),d.isBuffer(o))return o.length===0?-1:G(p,o,u,g,A);if(typeof o=="number")return o=o&255,typeof i.prototype.indexOf=="function"?A?i.prototype.indexOf.call(p,o,u):i.prototype.lastIndexOf.call(p,o,u):G(p,[o],u,g,A);throw new TypeError("val must be string, number or Buffer")}function G(p,o,u,g,A){let C=1,j=p.length,oe=o.length;if(g!==void 0&&(g=String(g).toLowerCase(),g==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(p.length<2||o.length<2)return-1;C=2,j/=2,oe/=2,u/=2}function ge(Ee,le){return C===1?Ee[le]:Ee.readUInt16BE(le*C)}let me;if(A){let Ee=-1;for(me=u;me<j;me++)if(ge(p,me)===ge(o,Ee===-1?0:me-Ee)){if(Ee===-1&&(Ee=me),me-Ee+1===oe)return Ee*C}else Ee!==-1&&(me-=me-Ee),Ee=-1}else for(u+oe>j&&(u=j-oe),me=u;me>=0;me--){let Ee=!0;for(let le=0;le<oe;le++)if(ge(p,me+le)!==ge(o,le)){Ee=!1;break}if(Ee)return me}return-1}d.prototype.includes=function(o,u,g){return this.indexOf(o,u,g)!==-1},d.prototype.indexOf=function(o,u,g){return W(this,o,u,g,!0)},d.prototype.lastIndexOf=function(o,u,g){return W(this,o,u,g,!1)};function Y(p,o,u,g){u=Number(u)||0;const A=p.length-u;g?(g=Number(g),g>A&&(g=A)):g=A;const C=o.length;g>C/2&&(g=C/2);let j;for(j=0;j<g;++j){const oe=parseInt(o.substr(j*2,2),16);if(Je(oe))return j;p[u+j]=oe}return j}function N(p,o,u,g){return Xe(At(o,p.length-u),p,u,g)}function Z(p,o,u,g){return Xe(fr(o),p,u,g)}function re(p,o,u,g){return Xe(Be(o),p,u,g)}function Q(p,o,u,g){return Xe(ve(o,p.length-u),p,u,g)}d.prototype.write=function(o,u,g,A){if(u===void 0)A="utf8",g=this.length,u=0;else if(g===void 0&&typeof u=="string")A=u,g=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(g)?(g=g>>>0,A===void 0&&(A="utf8")):(A=g,g=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const C=this.length-u;if((g===void 0||g>C)&&(g=C),o.length>0&&(g<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");let j=!1;for(;;)switch(A){case"hex":return Y(this,o,u,g);case"utf8":case"utf-8":return N(this,o,u,g);case"ascii":case"latin1":case"binary":return Z(this,o,u,g);case"base64":return re(this,o,u,g);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,o,u,g);default:if(j)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),j=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function se(p,o,u){return o===0&&u===p.length?e.fromByteArray(p):e.fromByteArray(p.slice(o,u))}function fe(p,o,u){u=Math.min(p.length,u);const g=[];let A=o;for(;A<u;){const C=p[A];let j=null,oe=C>239?4:C>223?3:C>191?2:1;if(A+oe<=u){let ge,me,Ee,le;switch(oe){case 1:C<128&&(j=C);break;case 2:ge=p[A+1],(ge&192)===128&&(le=(C&31)<<6|ge&63,le>127&&(j=le));break;case 3:ge=p[A+1],me=p[A+2],(ge&192)===128&&(me&192)===128&&(le=(C&15)<<12|(ge&63)<<6|me&63,le>2047&&(le<55296||le>57343)&&(j=le));break;case 4:ge=p[A+1],me=p[A+2],Ee=p[A+3],(ge&192)===128&&(me&192)===128&&(Ee&192)===128&&(le=(C&15)<<18|(ge&63)<<12|(me&63)<<6|Ee&63,le>65535&&le<1114112&&(j=le))}}j===null?(j=65533,oe=1):j>65535&&(j-=65536,g.push(j>>>10&1023|55296),j=56320|j&1023),g.push(j),A+=oe}return Ce(g)}const ye=4096;function Ce(p){const o=p.length;if(o<=ye)return String.fromCharCode.apply(String,p);let u="",g=0;for(;g<o;)u+=String.fromCharCode.apply(String,p.slice(g,g+=ye));return u}function Oe(p,o,u){let g="";u=Math.min(p.length,u);for(let A=o;A<u;++A)g+=String.fromCharCode(p[A]&127);return g}function wt(p,o,u){let g="";u=Math.min(p.length,u);for(let A=o;A<u;++A)g+=String.fromCharCode(p[A]);return g}function at(p,o,u){const g=p.length;(!o||o<0)&&(o=0),(!u||u<0||u>g)&&(u=g);let A="";for(let C=o;C<u;++C)A+=Ze[p[C]];return A}function Qe(p,o,u){const g=p.slice(o,u);let A="";for(let C=0;C<g.length-1;C+=2)A+=String.fromCharCode(g[C]+g[C+1]*256);return A}d.prototype.slice=function(o,u){const g=this.length;o=~~o,u=u===void 0?g:~~u,o<0?(o+=g,o<0&&(o=0)):o>g&&(o=g),u<0?(u+=g,u<0&&(u=0)):u>g&&(u=g),u<o&&(u=o);const A=this.subarray(o,u);return Object.setPrototypeOf(A,d.prototype),A};function be(p,o,u){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+o>u)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o],C=1,j=0;for(;++j<u&&(C*=256);)A+=this[o+j]*C;return A},d.prototype.readUintBE=d.prototype.readUIntBE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o+--u],C=1;for(;u>0&&(C*=256);)A+=this[o+--u]*C;return A},d.prototype.readUint8=d.prototype.readUInt8=function(o,u){return o=o>>>0,u||be(o,1,this.length),this[o]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(o,u){return o=o>>>0,u||be(o,2,this.length),this[o]|this[o+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(o,u){return o=o>>>0,u||be(o,2,this.length),this[o]<<8|this[o+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(o,u){return o=o>>>0,u||be(o,4,this.length),(this[o]|this[o+1]<<8|this[o+2]<<16)+this[o+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]*16777216+(this[o+1]<<16|this[o+2]<<8|this[o+3])},d.prototype.readBigUInt64LE=Fe(function(o){o=o>>>0,ee(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ue(o,this.length-8);const A=u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24,C=this[++o]+this[++o]*2**8+this[++o]*2**16+g*2**24;return BigInt(A)+(BigInt(C)<<BigInt(32))}),d.prototype.readBigUInt64BE=Fe(function(o){o=o>>>0,ee(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ue(o,this.length-8);const A=u*2**24+this[++o]*2**16+this[++o]*2**8+this[++o],C=this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+g;return(BigInt(A)<<BigInt(32))+BigInt(C)}),d.prototype.readIntLE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o],C=1,j=0;for(;++j<u&&(C*=256);)A+=this[o+j]*C;return C*=128,A>=C&&(A-=Math.pow(2,8*u)),A},d.prototype.readIntBE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=u,C=1,j=this[o+--A];for(;A>0&&(C*=256);)j+=this[o+--A]*C;return C*=128,j>=C&&(j-=Math.pow(2,8*u)),j},d.prototype.readInt8=function(o,u){return o=o>>>0,u||be(o,1,this.length),this[o]&128?(255-this[o]+1)*-1:this[o]},d.prototype.readInt16LE=function(o,u){o=o>>>0,u||be(o,2,this.length);const g=this[o]|this[o+1]<<8;return g&32768?g|4294901760:g},d.prototype.readInt16BE=function(o,u){o=o>>>0,u||be(o,2,this.length);const g=this[o+1]|this[o]<<8;return g&32768?g|4294901760:g},d.prototype.readInt32LE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]|this[o+1]<<8|this[o+2]<<16|this[o+3]<<24},d.prototype.readInt32BE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]<<24|this[o+1]<<16|this[o+2]<<8|this[o+3]},d.prototype.readBigInt64LE=Fe(function(o){o=o>>>0,ee(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ue(o,this.length-8);const A=this[o+4]+this[o+5]*2**8+this[o+6]*2**16+(g<<24);return(BigInt(A)<<BigInt(32))+BigInt(u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24)}),d.prototype.readBigInt64BE=Fe(function(o){o=o>>>0,ee(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ue(o,this.length-8);const A=(u<<24)+this[++o]*2**16+this[++o]*2**8+this[++o];return(BigInt(A)<<BigInt(32))+BigInt(this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+g)}),d.prototype.readFloatLE=function(o,u){return o=o>>>0,u||be(o,4,this.length),r.read(this,o,!0,23,4)},d.prototype.readFloatBE=function(o,u){return o=o>>>0,u||be(o,4,this.length),r.read(this,o,!1,23,4)},d.prototype.readDoubleLE=function(o,u){return o=o>>>0,u||be(o,8,this.length),r.read(this,o,!0,52,8)},d.prototype.readDoubleBE=function(o,u){return o=o>>>0,u||be(o,8,this.length),r.read(this,o,!1,52,8)};function ke(p,o,u,g,A,C){if(!d.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(o>A||o<C)throw new RangeError('"value" argument is out of bounds');if(u+g>p.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(o,u,g,A){if(o=+o,u=u>>>0,g=g>>>0,!A){const oe=Math.pow(2,8*g)-1;ke(this,o,u,g,oe,0)}let C=1,j=0;for(this[u]=o&255;++j<g&&(C*=256);)this[u+j]=o/C&255;return u+g},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(o,u,g,A){if(o=+o,u=u>>>0,g=g>>>0,!A){const oe=Math.pow(2,8*g)-1;ke(this,o,u,g,oe,0)}let C=g-1,j=1;for(this[u+C]=o&255;--C>=0&&(j*=256);)this[u+C]=o/j&255;return u+g},d.prototype.writeUint8=d.prototype.writeUInt8=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,1,255,0),this[u]=o&255,u+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,2,65535,0),this[u]=o&255,this[u+1]=o>>>8,u+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,2,65535,0),this[u]=o>>>8,this[u+1]=o&255,u+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,4,4294967295,0),this[u+3]=o>>>24,this[u+2]=o>>>16,this[u+1]=o>>>8,this[u]=o&255,u+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,4,4294967295,0),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4};function D(p,o,u,g,A){de(o,g,A,p,u,7);let C=Number(o&BigInt(4294967295));p[u++]=C,C=C>>8,p[u++]=C,C=C>>8,p[u++]=C,C=C>>8,p[u++]=C;let j=Number(o>>BigInt(32)&BigInt(4294967295));return p[u++]=j,j=j>>8,p[u++]=j,j=j>>8,p[u++]=j,j=j>>8,p[u++]=j,u}function P(p,o,u,g,A){de(o,g,A,p,u,7);let C=Number(o&BigInt(4294967295));p[u+7]=C,C=C>>8,p[u+6]=C,C=C>>8,p[u+5]=C,C=C>>8,p[u+4]=C;let j=Number(o>>BigInt(32)&BigInt(4294967295));return p[u+3]=j,j=j>>8,p[u+2]=j,j=j>>8,p[u+1]=j,j=j>>8,p[u]=j,u+8}d.prototype.writeBigUInt64LE=Fe(function(o,u=0){return D(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Fe(function(o,u=0){return P(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(o,u,g,A){if(o=+o,u=u>>>0,!A){const ge=Math.pow(2,8*g-1);ke(this,o,u,g,ge-1,-ge)}let C=0,j=1,oe=0;for(this[u]=o&255;++C<g&&(j*=256);)o<0&&oe===0&&this[u+C-1]!==0&&(oe=1),this[u+C]=(o/j>>0)-oe&255;return u+g},d.prototype.writeIntBE=function(o,u,g,A){if(o=+o,u=u>>>0,!A){const ge=Math.pow(2,8*g-1);ke(this,o,u,g,ge-1,-ge)}let C=g-1,j=1,oe=0;for(this[u+C]=o&255;--C>=0&&(j*=256);)o<0&&oe===0&&this[u+C+1]!==0&&(oe=1),this[u+C]=(o/j>>0)-oe&255;return u+g},d.prototype.writeInt8=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,1,127,-128),o<0&&(o=255+o+1),this[u]=o&255,u+1},d.prototype.writeInt16LE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,2,32767,-32768),this[u]=o&255,this[u+1]=o>>>8,u+2},d.prototype.writeInt16BE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,2,32767,-32768),this[u]=o>>>8,this[u+1]=o&255,u+2},d.prototype.writeInt32LE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,4,2147483647,-2147483648),this[u]=o&255,this[u+1]=o>>>8,this[u+2]=o>>>16,this[u+3]=o>>>24,u+4},d.prototype.writeInt32BE=function(o,u,g){return o=+o,u=u>>>0,g||ke(this,o,u,4,2147483647,-2147483648),o<0&&(o=4294967295+o+1),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4},d.prototype.writeBigInt64LE=Fe(function(o,u=0){return D(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Fe(function(o,u=0){return P(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(p,o,u,g,A,C){if(u+g>p.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function X(p,o,u,g,A){return o=+o,u=u>>>0,A||J(p,o,u,4),r.write(p,o,u,g,23,4),u+4}d.prototype.writeFloatLE=function(o,u,g){return X(this,o,u,!0,g)},d.prototype.writeFloatBE=function(o,u,g){return X(this,o,u,!1,g)};function ie(p,o,u,g,A){return o=+o,u=u>>>0,A||J(p,o,u,8),r.write(p,o,u,g,52,8),u+8}d.prototype.writeDoubleLE=function(o,u,g){return ie(this,o,u,!0,g)},d.prototype.writeDoubleBE=function(o,u,g){return ie(this,o,u,!1,g)},d.prototype.copy=function(o,u,g,A){if(!d.isBuffer(o))throw new TypeError("argument should be a Buffer");if(g||(g=0),!A&&A!==0&&(A=this.length),u>=o.length&&(u=o.length),u||(u=0),A>0&&A<g&&(A=g),A===g||o.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(g<0||g>=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),o.length-u<A-g&&(A=o.length-u+g);const C=A-g;return this===o&&typeof i.prototype.copyWithin=="function"?this.copyWithin(u,g,A):i.prototype.set.call(o,this.subarray(g,A),u),C},d.prototype.fill=function(o,u,g,A){if(typeof o=="string"){if(typeof u=="string"?(A=u,u=0,g=this.length):typeof g=="string"&&(A=g,g=this.length),A!==void 0&&typeof A!="string")throw new TypeError("encoding must be a string");if(typeof A=="string"&&!d.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(o.length===1){const j=o.charCodeAt(0);(A==="utf8"&&j<128||A==="latin1")&&(o=j)}}else typeof o=="number"?o=o&255:typeof o=="boolean"&&(o=Number(o));if(u<0||this.length<u||this.length<g)throw new RangeError("Out of range index");if(g<=u)return this;u=u>>>0,g=g===void 0?this.length:g>>>0,o||(o=0);let C;if(typeof o=="number")for(C=u;C<g;++C)this[C]=o;else{const j=d.isBuffer(o)?o:d.from(o,A),oe=j.length;if(oe===0)throw new TypeError('The value "'+o+'" is invalid for argument "value"');for(C=0;C<g-u;++C)this[C+u]=j[C%oe]}return this};const b={};function E(p,o,u){b[p]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:o.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(A){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:A,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}E("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),E("ERR_INVALID_ARG_TYPE",function(p,o){return`The "${p}" argument must be of type number. Received type ${typeof o}`},TypeError),E("ERR_OUT_OF_RANGE",function(p,o,u){let g=`The value of "${p}" is out of range.`,A=u;return Number.isInteger(u)&&Math.abs(u)>2**32?A=K(String(u)):typeof u=="bigint"&&(A=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(A=K(A)),A+="n"),g+=` It must be ${o}. Received ${A}`,g},RangeError);function K(p){let o="",u=p.length;const g=p[0]==="-"?1:0;for(;u>=g+4;u-=3)o=`_${p.slice(u-3,u)}${o}`;return`${p.slice(0,u)}${o}`}function V(p,o,u){ee(o,"offset"),(p[o]===void 0||p[o+u]===void 0)&&ue(o,p.length-(u+1))}function de(p,o,u,g,A,C){if(p>u||p<o){const j=typeof o=="bigint"?"n":"";let oe;throw o===0||o===BigInt(0)?oe=`>= 0${j} and < 2${j} ** ${(C+1)*8}${j}`:oe=`>= -(2${j} ** ${(C+1)*8-1}${j}) and < 2 ** ${(C+1)*8-1}${j}`,new b.ERR_OUT_OF_RANGE("value",oe,p)}V(g,A,C)}function ee(p,o){if(typeof p!="number")throw new b.ERR_INVALID_ARG_TYPE(o,"number",p)}function ue(p,o,u){throw Math.floor(p)!==p?(ee(p,u),new b.ERR_OUT_OF_RANGE("offset","an integer",p)):o<0?new b.ERR_BUFFER_OUT_OF_BOUNDS:new b.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${o}`,p)}const ct=/[^+/0-9A-Za-z-_]/g;function xt(p){if(p=p.split("=")[0],p=p.trim().replace(ct,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function At(p,o){o=o||1/0;let u;const g=p.length;let A=null;const C=[];for(let j=0;j<g;++j){if(u=p.charCodeAt(j),u>55295&&u<57344){if(!A){if(u>56319){(o-=3)>-1&&C.push(239,191,189);continue}else if(j+1===g){(o-=3)>-1&&C.push(239,191,189);continue}A=u;continue}if(u<56320){(o-=3)>-1&&C.push(239,191,189),A=u;continue}u=(A-55296<<10|u-56320)+65536}else A&&(o-=3)>-1&&C.push(239,191,189);if(A=null,u<128){if((o-=1)<0)break;C.push(u)}else if(u<2048){if((o-=2)<0)break;C.push(u>>6|192,u&63|128)}else if(u<65536){if((o-=3)<0)break;C.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((o-=4)<0)break;C.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return C}function fr(p){const o=[];for(let u=0;u<p.length;++u)o.push(p.charCodeAt(u)&255);return o}function ve(p,o){let u,g,A;const C=[];for(let j=0;j<p.length&&!((o-=2)<0);++j)u=p.charCodeAt(j),g=u>>8,A=u%256,C.push(A),C.push(g);return C}function Be(p){return e.toByteArray(xt(p))}function Xe(p,o,u,g){let A;for(A=0;A<g&&!(A+u>=o.length||A>=p.length);++A)o[A+u]=p[A];return A}function Le(p,o){return p instanceof o||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===o.name}function Je(p){return p!==p}const Ze=(function(){const p="0123456789abcdef",o=new Array(256);for(let u=0;u<16;++u){const g=u*16;for(let A=0;A<16;++A)o[g+A]=p[u]+p[A]}return o})();function Fe(p){return typeof BigInt>"u"?Rt:p}function Rt(){throw new Error("BigInt not supported")}})(ln);const Si=ln.Buffer,Nt=ln.Buffer;let _i=class qr extends Promise{#e;#t;constructor(e){super(r=>{r()}),this.#e=e}static from(e){return new qr(r=>{r(e())})}static resolve(e){return new qr(r=>{r(e)})}static reject(e){return new qr((r,n)=>{n(e)})}then(e,r){return this.#t??=new Promise(this.#e),this.#t.then(e,r)}catch(e){return this.#t??=new Promise(this.#e),this.#t.catch(e)}finally(e){return this.#t??=new Promise(this.#e),this.#t.finally(e)}};const vi=_i.default??_i;class Ti{constructor(e){this.waiters=[],this.aborted=!1,this.remaining=e}async acquire(e){if(this.aborted)throw new Error("credit gate aborted");if(e?.aborted)throw e.reason??new Error("aborted");this.remaining>0?this.remaining--:await new Promise((r,n)=>{const s=()=>{const c=this.waiters.indexOf(i);c!==-1&&this.waiters.splice(c,1),n(e?.reason??new Error("aborted"))};e&&e.addEventListener("abort",s,{once:!0});const i=c=>{if(e&&e.removeEventListener("abort",s),c){n(new Error("credit gate aborted"));return}this.remaining--,r()};this.waiters.push(i)})}replenish(e){for(this.remaining+=e;this.waiters.length>0&&this.remaining>0;)this.waiters.shift()(!1)}abort(){for(this.aborted=!0;this.waiters.length>0;)this.waiters.shift()(!0)}}const Eo=new TextEncoder;function So(t){const e=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(e);let n=0;for(const s of t)r.set(s,n),n+=s.byteLength;return r}function xi(t){let e;if(t instanceof Nt)e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(t instanceof Uint8Array)e=t;else if(typeof t=="string")e=Eo.encode(t);else throw new Error("invalid chunk type: expected Buffer, Uint8Array, or string");return e}function Ai(t){return new vi((e,r)=>{const n=[];t.on("data",s=>{const i=xi(s);n.push(i)}),t.on("end",()=>{e(So(n))}),t.on("error",s=>{r(s)})})}async function Ri(t,e,r,n,s){if(t.byteLength===0)await r(void 0,void 0,!0);else for(let i=0;i<t.byteLength;i+=e){if(s?.aborted)throw s.reason??new Error("aborted");const c=Math.min(t.byteLength-i,e),l=t.subarray(i,i+c),h=i+c>=t.byteLength;n&&await n.acquire(s),await r(l,void 0,h)}}async function Ii(t,e,r,n,s){let i;for await(const c of t){if(s?.aborted)throw s.reason??new Error("aborted");const l=xi(c);if(l.byteLength!==0)for(let h=0;h<l.byteLength;h+=e){if(s?.aborted)throw s.reason??new Error("aborted");const w=Math.min(l.byteLength-h,e),d=l.subarray(h,h+w);i!==void 0&&(n&&await n.acquire(s),await r(i,void 0,!1)),i=d}}if(s?.aborted)throw s.reason??new Error("aborted");i!==void 0?(n&&await n.acquire(s),await r(i,void 0,!0)):await r(void 0,void 0,!0)}function Bi(t,e,r){if(!(typeof t=="object"&&t!==null))throw new Error("invalid object");let n;const s=t[e],i=t[r];Object.defineProperty(t,e,{get:()=>{if(n==="f2")throw new Error(`field "${e}" is mutually exclusive with field "${r}" and "${r}" was already consumed`);return n="f1",s},enumerable:!0,configurable:!0}),Object.defineProperty(t,r,{get:()=>{if(n==="f1")throw new Error(`field "${r}" is mutually exclusive with field "${e}" and "${e}" was already consumed`);return n="f2",i},enumerable:!0,configurable:!0})}class De{constructor(){this.resources=[]}roll(...e){let r,n;if(e.length===1)r=void 0,n=e[0];else if(e.length===2)r=e[0],n=e[1];else throw new Error("invalid number of arguments");this.resources.push({resource:r,cleanup:n})}sub(){const e=new De;return this.roll(e,()=>{}),e}unroll(e=!0){try{let r;for(;this.resources.length>0;){const n=this.resources.pop(),s=n.resource,i=n.cleanup;if(r)s instanceof De?r=r.then(()=>s.unroll()):r=r.then(()=>i(s));else{let c;s instanceof De?c=s.unroll():c=i(s),c instanceof Promise&&(r=c)}}return r?e?r.catch(()=>{}):r:void 0}catch(r){if(e)return;throw r}}}function Ne(t,e,r=!1){if(t instanceof Error&&e===void 0&&r===!1)return t;let n=t instanceof Error?t.message:String(t);if(e&&(n=`${e}: ${n}`),r&&t instanceof Error&&(n=`${n}
|
|
2
|
-
${t.stack}`),t instanceof Error){const s=new Error(n,{cause:t});return s.stack=t.stack,s}else return new Error(n)}function mt(t,e){if(!e)return t?Promise.resolve():void 0;let r;try{r=e()}catch(n){if(t)return Promise.reject(n);throw n}if(!t&&r instanceof Promise)throw new Error("onfinally callback returned Promise in non-async context");return t&&!(r instanceof Promise)&&(r=Promise.resolve(r)),r}function mr(t,e){if(!e)return t?Promise.resolve():void 0;let r=e.unroll();if(!t&&r instanceof Promise)throw new Error("spool unroll returned Promise in non-async context");return t&&!(r instanceof Promise)&&(r=Promise.resolve(r)),r}function br(...t){let e,r,n,s,i,c;if(t.length===1&&typeof t[0]=="object"&&t[0]!==null?(e=t[0].description,r=t[0].spool,n=t[0].action,s=t[0].oncatch,i=t[0].onfinally,c=t[0].oncleanup):typeof t[0]=="string"?(e=t[0],t[1]instanceof De||t[1]===void 0&&typeof t[2]=="function"?(r=t[1],n=t[2],s=t[3],i=t[4],c=t[5]):(n=t[1],s=t[2],i=t[3],c=t[4])):t[0]instanceof De||t[0]===void 0&&typeof t[1]=="function"?(r=t[0],n=t[1],s=t[2],i=t[3],c=t[4]):(n=t[0],s=t[1],i=t[2],c=t[3]),c&&!r)throw new Error("oncleanup requires a spool");let l;try{l=n()}catch(h){let w=Ne(h,e);if(s){try{l=s(w)}catch(d){throw w=Ne(d,e),mt(!1,i),mr(!1,r),w}return mt(!1,i),l}throw mt(!1,i),mr(!1,r),w}return l instanceof Promise?l.then(async h=>(await mt(!0,i),r&&c&&r.roll(h,c),h),async h=>{let w=Ne(h,e);if(s)try{const d=s(w);return await mt(!0,i),d}catch(d){throw w=Ne(d,e),await mt(!0,i),await mr(!0,r),w}throw await mt(!0,i),await mr(!0,r),w}):(mt(!1,i),r&&c&&r.roll(l,c),l)}const Er=new TextEncoder,Qt=new TextDecoder;function Ni(...t){const e=t.reduce((s,{length:i})=>s+i,0),r=new Uint8Array(e);let n=0;for(const s of t)r.set(s,n),n+=s.length;return r}function qt(t){const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++){const n=t.charCodeAt(r);if(n>127)throw new TypeError("non-ASCII string encountered in encode()");e[r]=n}return e}function _o(t){if(Uint8Array.prototype.toBase64)return t.toBase64();const e=32768,r=[];for(let n=0;n<t.length;n+=e)r.push(String.fromCharCode.apply(null,t.subarray(n,n+e)));return btoa(r.join(""))}function vo(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t);const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function pn(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof t=="string"?t:Qt.decode(t),{alphabet:"base64url"});let e=t;e instanceof Uint8Array&&(e=Qt.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/");try{return vo(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}function yn(t){let e=t;return typeof e=="string"&&(e=Er.encode(e)),Uint8Array.prototype.toBase64?e.toBase64({alphabet:"base64url",omitPadding:!0}):_o(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}class jt extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,r){super(e,r),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class it extends jt{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.claim=n,this.reason=s,this.payload=r}}class ki extends jt{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.claim=n,this.reason=s,this.payload=r}}class kt extends jt{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class Te extends jt{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class wn extends jt{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class To extends jt{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",r){super(e,r)}}const bt=(t,e="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`),Ht=(t,e)=>t.name===e;function xo(t){return parseInt(t.name.slice(4),10)}function gn(t,e){if(xo(t.hash)!==e)throw bt(`SHA-${e}`,"algorithm.hash")}function Ao(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Ro(t,e){if(e&&!t.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function Io(t,e,r){switch(e){case"HS256":case"HS384":case"HS512":{if(!Ht(t.algorithm,"HMAC"))throw bt("HMAC");gn(t.algorithm,parseInt(e.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!Ht(t.algorithm,"RSASSA-PKCS1-v1_5"))throw bt("RSASSA-PKCS1-v1_5");gn(t.algorithm,parseInt(e.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!Ht(t.algorithm,"RSA-PSS"))throw bt("RSA-PSS");gn(t.algorithm,parseInt(e.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!Ht(t.algorithm,"Ed25519"))throw bt("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!Ht(t.algorithm,e))throw bt(e);break}case"ES256":case"ES384":case"ES512":{if(!Ht(t.algorithm,"ECDSA"))throw bt("ECDSA");const n=Ao(e);if(t.algorithm.namedCurve!==n)throw bt(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Ro(t,r)}function Fi(t,e,...r){if(r=r.filter(Boolean),r.length>2){const n=r.pop();t+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const Bo=(t,...e)=>Fi("Key must be ",t,...e),Li=(t,e,...r)=>Fi(`Key for the ${t} algorithm must be `,e,...r);function Ui(t,e){if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}function Mi(t,e){const r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(t.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:t};default:throw new kt(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function Pi(t,e,r){if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(Bo(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}return Io(e,t,r),e}async function No(t,e,r){const n=await Pi(t,e,"sign");Ui(t,n);const s=await crypto.subtle.sign(Mi(t,n.algorithm),n,r);return new Uint8Array(s)}async function ko(t,e,r,n){const s=await Pi(t,e,"verify");Ui(t,s);const i=Mi(t,s.algorithm);try{return await crypto.subtle.verify(i,s,r,n)}catch{return!1}}const Fo=t=>typeof t=="object"&&t!==null;function Xt(t){if(!Fo(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Di(...t){const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const n of e){const s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(const i of s){if(r.has(i))return!1;r.add(i)}}return!0}const mn=t=>Xt(t)&&typeof t.kty=="string",Lo=t=>t.kty!=="oct"&&(t.kty==="AKP"&&typeof t.priv=="string"||typeof t.d=="string"),Uo=t=>t.kty!=="oct"&&t.d===void 0&&t.priv===void 0,Mo=t=>t.kty==="oct"&&typeof t.k=="string",Ci=t=>{if(t?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return t instanceof CryptoKey}catch{return!1}},Oi=t=>t?.[Symbol.toStringTag]==="KeyObject",$i=t=>Ci(t)||Oi(t),Wt=t=>t?.[Symbol.toStringTag],bn=(t,e,r)=>{if(e.use!==void 0){let n;switch(r){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, its "alg" must be "${t}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(r==="sign"||r==="verify"):case t==="dir":case t.includes("CBC-HS"):n=r;break;case t.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(t):!t.includes("GCM")&&t.endsWith("KW")?n=r==="encrypt"?"wrapKey":"unwrapKey":n=r;break;case(r==="encrypt"&&t.startsWith("RSA")):n="wrapKey";break;case r==="decrypt":n=t.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},Po=(t,e,r)=>{if(!(e instanceof Uint8Array)){if(mn(e)){if(Mo(e)&&bn(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!$i(e))throw new TypeError(Li(t,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Wt(e)} instances for symmetric algorithms must be of type "secret"`)}},Do=(t,e,r)=>{if(mn(e))switch(r){case"decrypt":case"sign":if(Lo(e)&&bn(t,e,r))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if(Uo(e)&&bn(t,e,r))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!$i(e))throw new TypeError(Li(t,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Wt(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(r){case"sign":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm decryption must be of type "private"`)}if(e.type==="private")switch(r){case"verify":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm encryption must be of type "public"`)}};function qi(t,e,r){switch(t.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":Po(t,e,r);break;default:Do(t,e,r)}}function ji(t,e,r,n,s){if(s.crit!==void 0&&n?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(c=>typeof c!="string"||c.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;r!==void 0?i=new Map([...Object.entries(r),...e.entries()]):i=e;for(const c of n.crit){if(!i.has(c))throw new kt(`Extension Header Parameter "${c}" is not recognized`);if(s[c]===void 0)throw new t(`Extension Header Parameter "${c}" is missing`);if(i.get(c)&&n[c]===void 0)throw new t(`Extension Header Parameter "${c}" MUST be integrity protected`)}return new Set(n.crit)}const Sr='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Co(t){let e,r;switch(t.kty){case"AKP":{switch(t.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":e={name:t.alg},r=t.priv?["sign"]:["verify"];break;default:throw new kt(Sr)}break}case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new kt(Sr)}break}case"EC":{switch(t.alg){case"ES256":case"ES384":case"ES512":e={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[t.alg]},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new kt(Sr)}break}case"OKP":{switch(t.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new kt(Sr)}break}default:throw new kt('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}async function Oo(t){if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=Co(t),n={...t};return n.kty!=="AKP"&&delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,t.ext??!(t.d||t.priv),t.key_ops??r)}const Kt="given KeyObject instance cannot be used for this algorithm";let Gt;const Hi=async(t,e,r,n=!1)=>{Gt||=new WeakMap;let s=Gt.get(t);if(s?.[r])return s[r];const i=await Oo({...e,alg:r});return n&&Object.freeze(t),s?s[r]=i:Gt.set(t,{[r]:i}),i},$o=(t,e)=>{Gt||=new WeakMap;let r=Gt.get(t);if(r?.[e])return r[e];const n=t.type==="public",s=!!n;let i;if(t.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(Kt)}i=t.toCryptoKey(t.asymmetricKeyType,s,n?[]:["deriveBits"])}if(t.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError(Kt);i=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}switch(t.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(e!==t.asymmetricKeyType.toUpperCase())throw new TypeError(Kt);i=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}}if(t.asymmetricKeyType==="rsa"){let c;switch(e){case"RSA-OAEP":c="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":c="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":c="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":c="SHA-512";break;default:throw new TypeError(Kt)}if(e.startsWith("RSA-OAEP"))return t.toCryptoKey({name:"RSA-OAEP",hash:c},s,n?["encrypt"]:["decrypt"]);i=t.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:c},s,[n?"verify":"sign"])}if(t.asymmetricKeyType==="ec"){const l=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(t.asymmetricKeyDetails?.namedCurve);if(!l)throw new TypeError(Kt);const h={ES256:"P-256",ES384:"P-384",ES512:"P-521"};h[e]&&l===h[e]&&(i=t.toCryptoKey({name:"ECDSA",namedCurve:l},s,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(i=t.toCryptoKey({name:"ECDH",namedCurve:l},s,n?[]:["deriveBits"]))}if(!i)throw new TypeError(Kt);return r?r[e]=i:Gt.set(t,{[e]:i}),i};async function Wi(t,e){if(t instanceof Uint8Array||Ci(t))return t;if(Oi(t)){if(t.type==="secret")return t.export();if("toCryptoKey"in t&&typeof t.toCryptoKey=="function")try{return $o(t,e)}catch(n){if(n instanceof TypeError)throw n}let r=t.export({format:"jwk"});return Hi(t,r,e)}if(mn(t))return t.k?pn(t.k):Hi(t,t,e,!0);throw new Error("unreachable")}function Ki(t,e){if(t)throw new TypeError(`${e} can only be called once`)}function Gi(t,e,r){try{return pn(t)}catch{throw new r(`Failed to base64url decode the ${e}`)}}class qo{#e;#t;#r;constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this.#e=e}setProtectedHeader(e){return Ki(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return Ki(this.#r,"setUnprotectedHeader"),this.#r=e,this}async sign(e,r){if(!this.#t&&!this.#r)throw new Te("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Di(this.#t,this.#r))throw new Te("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n={...this.#t,...this.#r},s=ji(Te,new Map([["b64",!0]]),r?.crit,this.#t,n);let i=!0;if(s.has("b64")&&(i=this.#t.b64,typeof i!="boolean"))throw new Te('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:c}=n;if(typeof c!="string"||!c)throw new Te('JWS "alg" (Algorithm) Header Parameter missing or invalid');qi(c,e,"sign");let l,h;i?(l=yn(this.#e),h=qt(l)):(h=this.#e,l="");let w,d;this.#t?(w=yn(JSON.stringify(this.#t)),d=qt(w)):(w="",d=new Uint8Array);const I=Ni(d,qt("."),h),T=await Wi(e,c),L=await No(c,T,I),B={signature:yn(L),payload:l};return this.#r&&(B.header=this.#r),this.#t&&(B.protected=w),B}}class jo{#e;constructor(e){this.#e=new qo(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}async sign(e,r){const n=await this.#e.sign(e,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}}const Et=t=>Math.floor(t.getTime()/1e3),Ji=60,zi=Ji*60,En=zi*24,Ho=En*7,Wo=En*365.25,Ko=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Zt(t){const e=Ko.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const r=parseFloat(e[2]),n=e[3].toLowerCase();let s;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(r*Ji);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(r*zi);break;case"day":case"days":case"d":s=Math.round(r*En);break;case"week":case"weeks":case"w":s=Math.round(r*Ho);break;default:s=Math.round(r*Wo);break}return e[1]==="-"||e[4]==="ago"?-s:s}function Ft(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}const Vi=t=>t.includes("/")?t.toLowerCase():`application/${t.toLowerCase()}`,Go=(t,e)=>typeof t=="string"?e.includes(t):Array.isArray(t)?e.some(Set.prototype.has.bind(new Set(t))):!1;function Jo(t,e,r={}){let n;try{n=JSON.parse(Qt.decode(e))}catch{}if(!Xt(n))throw new wn("JWT Claims Set must be a top-level JSON object");const{typ:s}=r;if(s&&(typeof t.typ!="string"||Vi(t.typ)!==Vi(s)))throw new it('unexpected "typ" JWT header value',n,"typ","check_failed");const{requiredClaims:i=[],issuer:c,subject:l,audience:h,maxTokenAge:w}=r,d=[...i];w!==void 0&&d.push("iat"),h!==void 0&&d.push("aud"),l!==void 0&&d.push("sub"),c!==void 0&&d.push("iss");for(const B of new Set(d.reverse()))if(!(B in n))throw new it(`missing required "${B}" claim`,n,B,"missing");if(c&&!(Array.isArray(c)?c:[c]).includes(n.iss))throw new it('unexpected "iss" claim value',n,"iss","check_failed");if(l&&n.sub!==l)throw new it('unexpected "sub" claim value',n,"sub","check_failed");if(h&&!Go(n.aud,typeof h=="string"?[h]:h))throw new it('unexpected "aud" claim value',n,"aud","check_failed");let I;switch(typeof r.clockTolerance){case"string":I=Zt(r.clockTolerance);break;case"number":I=r.clockTolerance;break;case"undefined":I=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:T}=r,L=Et(T||new Date);if((n.iat!==void 0||w)&&typeof n.iat!="number")throw new it('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new it('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>L+I)throw new it('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new it('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=L-I)throw new ki('"exp" claim timestamp check failed',n,"exp","check_failed")}if(w){const B=L-n.iat,q=typeof w=="number"?w:Zt(w);if(B-I>q)throw new ki('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(B<0-I)throw new it('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}class zo{#e;constructor(e){if(!Xt(e))throw new TypeError("JWT Claims Set MUST be an object");this.#e=structuredClone(e)}data(){return Er.encode(JSON.stringify(this.#e))}get iss(){return this.#e.iss}set iss(e){this.#e.iss=e}get sub(){return this.#e.sub}set sub(e){this.#e.sub=e}get aud(){return this.#e.aud}set aud(e){this.#e.aud=e}set jti(e){this.#e.jti=e}set nbf(e){typeof e=="number"?this.#e.nbf=Ft("setNotBefore",e):e instanceof Date?this.#e.nbf=Ft("setNotBefore",Et(e)):this.#e.nbf=Et(new Date)+Zt(e)}set exp(e){typeof e=="number"?this.#e.exp=Ft("setExpirationTime",e):e instanceof Date?this.#e.exp=Ft("setExpirationTime",Et(e)):this.#e.exp=Et(new Date)+Zt(e)}set iat(e){e===void 0?this.#e.iat=Et(new Date):e instanceof Date?this.#e.iat=Ft("setIssuedAt",Et(e)):typeof e=="string"?this.#e.iat=Ft("setIssuedAt",Et(new Date)+Zt(e)):this.#e.iat=Ft("setIssuedAt",e)}}class Vo{#e;#t;constructor(e={}){this.#t=new zo(e)}setIssuer(e){return this.#t.iss=e,this}setSubject(e){return this.#t.sub=e,this}setAudience(e){return this.#t.aud=e,this}setJti(e){return this.#t.jti=e,this}setNotBefore(e){return this.#t.nbf=e,this}setExpirationTime(e){return this.#t.exp=e,this}setIssuedAt(e){return this.#t.iat=e,this}setProtectedHeader(e){return this.#e=e,this}async sign(e,r){const n=new jo(this.#t.data());if(n.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes("b64")&&this.#e.b64===!1)throw new wn("JWTs MUST NOT use unencoded payload");return n.sign(e,r)}}async function Yo(t,e,r){if(!Xt(t))throw new Te("Flattened JWS must be an object");if(t.protected===void 0&&t.header===void 0)throw new Te('Flattened JWS must have either of the "protected" or "header" members');if(t.protected!==void 0&&typeof t.protected!="string")throw new Te("JWS Protected Header incorrect type");if(t.payload===void 0)throw new Te("JWS Payload missing");if(typeof t.signature!="string")throw new Te("JWS Signature missing or incorrect type");if(t.header!==void 0&&!Xt(t.header))throw new Te("JWS Unprotected Header incorrect type");let n={};if(t.protected)try{const q=pn(t.protected);n=JSON.parse(Qt.decode(q))}catch{throw new Te("JWS Protected Header is invalid")}if(!Di(n,t.header))throw new Te("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...n,...t.header},i=ji(Te,new Map([["b64",!0]]),r?.crit,n,s);let c=!0;if(i.has("b64")&&(c=n.b64,typeof c!="boolean"))throw new Te('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:l}=s;if(typeof l!="string"||!l)throw new Te('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(c){if(typeof t.payload!="string")throw new Te("JWS Payload must be a string")}else if(typeof t.payload!="string"&&!(t.payload instanceof Uint8Array))throw new Te("JWS Payload must be a string or an Uint8Array instance");let h=!1;typeof e=="function"&&(e=await e(n,t),h=!0),qi(l,e,"verify");const w=Ni(t.protected!==void 0?qt(t.protected):new Uint8Array,qt("."),typeof t.payload=="string"?c?qt(t.payload):Er.encode(t.payload):t.payload),d=Gi(t.signature,"signature",Te),I=await Wi(e,l);if(!await ko(l,I,d,w))throw new To;let L;c?L=Gi(t.payload,"payload",Te):typeof t.payload=="string"?L=Er.encode(t.payload):L=t.payload;const B={payload:L};return t.protected!==void 0&&(B.protectedHeader=n),t.header!==void 0&&(B.unprotectedHeader=t.header),h?{...B,key:I}:B}async function Qo(t,e,r){if(t instanceof Uint8Array&&(t=Qt.decode(t)),typeof t!="string")throw new Te("Compact JWS must be a string or Uint8Array");const{0:n,1:s,2:i,length:c}=t.split(".");if(c!==3)throw new Te("Invalid Compact JWS");const l=await Yo({payload:s,protected:n,signature:i},e,r),h={payload:l.payload,protectedHeader:l.protectedHeader};return typeof e=="function"?{...h,key:l.key}:h}async function Xo(t,e,r){const n=await Qo(t,e,r);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new wn("JWTs MUST NOT use unencoded payload");const i={payload:Jo(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return typeof e=="function"?{...i,key:n.key}:i}function st(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}function St(t){for(let e=0;e<t.length;e++)t[e]=0;return t}class Zo{blockSize;digestLength;_inner;_outer;_finished=!1;_innerKeyedState;_outerKeyedState;constructor(e,r){this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;const n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(let s=0;s<n.length;s++)n[s]^=54;this._inner.update(n);for(let s=0;s<n.length;s++)n[s]^=106;this._outer.update(n),st(this._inner)&&st(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),St(n)}reset(){if(!st(this._inner)||!st(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this}clean(){st(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),st(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()}update(e){return this._inner.update(e),this}finish(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)}digest(){const e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(!st(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()}restoreState(e){if(!st(this._inner)||!st(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this}cleanSavedState(e){if(!st(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)}}function ea(t,e=0){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function _r(t,e=new Uint8Array(4),r=0){return e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}function ta(t,e,r,n,s){const i=new Zo(t,e),c=i.digestLength,l=new Uint8Array(4),h=new Uint8Array(c),w=new Uint8Array(c),d=new Uint8Array(s),I=i.update(r).saveState();for(let T=0;T*c<s;T++){_r(T+1,l),i.restoreState(I).update(l).finish(w);for(let L=0;L<c;L++)h[L]=w[L];for(let L=2;L<=n;L++){i.reset().update(w).finish(w);for(let B=0;B<c;B++)h[B]^=w[B]}for(let L=0;L<c&&T*c+L<s;L++)d[T*c+L]=h[L]}return St(h),St(w),St(l),i.cleanSavedState(I),i.clean(),d}const ra=32,na=64;class ia{digestLength=ra;blockSize=na;_state=new Int32Array(8);_temp=new Int32Array(64);_buffer=new Uint8Array(128);_bufferLength=0;_bytesHashed=0;_finished=!1;constructor(){this.reset()}_initState(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225}reset(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this}clean(){St(this._buffer),St(this._temp),this.reset()}update(e,r=e.length){if(this._finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&r>0;)this._buffer[this._bufferLength++]=e[n++],r--;this._bufferLength===this.blockSize&&(Sn(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=Sn(this._temp,this._state,e,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[n++],r--;return this}finish(e){if(!this._finished){const r=this._bytesHashed,n=this._bufferLength,s=r/536870912|0,i=r<<3,c=r%64<56?64:128;this._buffer[n]=128;for(let l=n+1;l<c-8;l++)this._buffer[l]=0;_r(s,this._buffer,c-8),_r(i,this._buffer,c-4),Sn(this._temp,this._state,this._buffer,0,c),this._finished=!0}for(let r=0;r<this.digestLength/4;r++)_r(this._state[r],e,r*4);return this}digest(){const e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}}restoreState(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this}cleanSavedState(e){St(e.state),e.buffer&&St(e.buffer),e.bufferLength=0,e.bytesHashed=0}}const sa=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Sn(t,e,r,n,s){for(;s>=64;){let i=e[0],c=e[1],l=e[2],h=e[3],w=e[4],d=e[5],I=e[6],T=e[7];for(let L=0;L<16;L++){let B=n+L*4;t[L]=ea(r,B)}for(let L=16;L<64;L++){let B=t[L-2],q=(B>>>17|B<<15)^(B>>>19|B<<13)^B>>>10;B=t[L-15];let $=(B>>>7|B<<25)^(B>>>18|B<<14)^B>>>3;t[L]=(q+t[L-7]|0)+($+t[L-16]|0)}for(let L=0;L<64;L++){let B=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&d^~w&I)|0)+(T+(sa[L]+t[L]|0)|0)|0,q=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&c^i&l^c&l)|0;T=I,I=d,d=w,w=h+B|0,h=l,l=c,c=i,i=B+q|0}e[0]+=i,e[1]+=c,e[2]+=l,e[3]+=h,e[4]+=w,e[5]+=d,e[6]+=I,e[7]+=T,n+=64,s-=64}return n}var oa=hr();let _n;function Yi(t){return{lang:t?.lang??_n?.lang,message:t?.message,abortEarly:t?.abortEarly??_n?.abortEarly,abortPipeEarly:t?.abortPipeEarly??_n?.abortPipeEarly}}let aa;function ca(t){return aa?.get(t)}let ua;function fa(t){return ua?.get(t)}let la;function ha(t,e){return la?.get(t)?.get(e)}function vr(t){const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function Pe(t,e,r,n,s){const i=s&&"input"in s?s.input:r.value,c=s?.expected??t.expects??null,l=s?.received??vr(i),h={kind:t.kind,type:t.type,input:i,expected:c,received:l,message:`Invalid ${e}: ${c?`Expected ${c} but r`:"R"}eceived ${l}`,requirement:t.requirement,path:s?.path,issues:s?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},w=t.kind==="schema",d=s?.message??t.message??ha(t.reference,h.lang)??(w?fa(h.lang):null)??n.message??ca(h.lang);d!==void 0&&(h.message=typeof d=="function"?d(h):d),w&&(r.typed=!1),r.issues?r.issues.push(h):r.issues=[h]}function ze(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Yi())}}}function da(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function Qi(t,e){return{kind:"validation",type:"check",reference:Qi,async:!1,expects:null,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&Pe(this,"input",r,n),r}}}function er(t){return{kind:"validation",type:"integer",reference:er,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,r){return e.typed&&!this.requirement(e.value)&&Pe(this,"integer",e,r),e}}}function Lt(t,e){return{kind:"validation",type:"max_length",reference:Lt,async:!1,expects:`<=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&Pe(this,"length",r,n,{received:`${r.value.length}`}),r}}}function tr(t,e){return{kind:"validation",type:"min_value",reference:tr,async:!1,expects:`>=${t instanceof Date?t.toJSON():vr(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value>=this.requirement)&&Pe(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():vr(r.value)}),r}}}function Xi(t,e){return{kind:"validation",type:"regex",reference:Xi,async:!1,expects:`${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement.test(r.value)&&Pe(this,"format",r,n),r}}}function pa(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function Zi(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function Jt(t,e){return{kind:"schema",type:"array",reference:Jt,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){const s=r.value;if(Array.isArray(s)){r.typed=!0,r.value=[];for(let i=0;i<s.length;i++){const c=s[i],l=this.item["~run"]({value:c},n);if(l.issues){const h={type:"array",origin:"value",input:s,key:i,value:c};for(const w of l.issues)w.path?w.path.unshift(h):w.path=[h],r.issues?.push(w);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else Pe(this,"type",r,n);return r}}}function vn(t){return{kind:"schema",type:"boolean",reference:vn,expects:"boolean",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:Pe(this,"type",e,r),e}}}function Tn(t,e){return{kind:"schema",type:"instance",reference:Tn,expects:t.name,async:!1,class:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value instanceof this.class?r.typed=!0:Pe(this,"type",r,n),r}}}function He(t,e){return{kind:"schema",type:"literal",reference:He,expects:vr(t),async:!1,literal:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value===this.literal?r.typed=!0:Pe(this,"type",r,n),r}}}function rr(t){return{kind:"schema",type:"number",reference:rr,expects:"number",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Pe(this,"type",e,r),e}}}function he(t,e){return{kind:"schema",type:"optional",reference:he,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=Zi(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function es(t,e,r){return{kind:"schema",type:"record",reference:es,expects:"Object",async:!1,key:t,value:e,message:r,get"~standard"(){return ze(this)},"~run"(n,s){const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const c in i)if(da(i,c)){const l=i[c],h=this.key["~run"]({value:c},s);if(h.issues){const d={type:"object",origin:"key",input:i,key:c,value:l};for(const I of h.issues)I.path=[d],n.issues?.push(I);if(n.issues||(n.issues=h.issues),s.abortEarly){n.typed=!1;break}}const w=this.value["~run"]({value:l},s);if(w.issues){const d={type:"object",origin:"value",input:i,key:c,value:l};for(const I of w.issues)I.path?I.path.unshift(d):I.path=[d],n.issues?.push(I);if(n.issues||(n.issues=w.issues),s.abortEarly){n.typed=!1;break}}(!h.typed||!w.typed)&&(n.typed=!1),h.typed&&(n.value[h.value]=w.value)}}else Pe(this,"type",n,s);return n}}}function We(t,e){return{kind:"schema",type:"strict_object",reference:We,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const i in this.entries){const c=this.entries[i];if(i in s||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){const l=i in s?s[i]:Zi(c),h=c["~run"]({value:l},n);if(h.issues){const w={type:"object",origin:"value",input:s,key:i,value:l};for(const d of h.issues)d.path?d.path.unshift(w):d.path=[w],r.issues?.push(d);if(r.issues||(r.issues=h.issues),n.abortEarly){r.typed=!1;break}}h.typed||(r.typed=!1),r.value[i]=h.value}else if(c.fallback!==void 0)r.value[i]=pa(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(Pe(this,"key",r,n,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]}),n.abortEarly))break}if(!r.issues||!n.abortEarly){for(const i in s)if(!(i in this.entries)){Pe(this,"key",r,n,{input:i,expected:"never",path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]});break}}}else Pe(this,"type",r,n);return r}}}function _e(t){return{kind:"schema",type:"string",reference:_e,expects:"string",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:Pe(this,"type",e,r),e}}}function Ut(){return{kind:"schema",type:"unknown",reference:Ut,expects:"unknown",async:!1,get"~standard"(){return ze(this)},"~run"(t){return t.typed=!0,t}}}function Ke(...t){return{...t[0],pipe:t,get"~standard"(){return ze(this)},"~run"(e,r){for(const n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function ya(t,e,r){const n=t["~run"]({value:e},Yi(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const z={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},ce={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,CBOR:24,URI:32,BASE64URL:33,BASE64:34,DATE_EPOCH_DAYS:100,SET:258,JSON:262,WTF8:273,SYMBOL:280,DATE_FULL:1004,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},ne={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},_t={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ue=class{static BREAK=Symbol.for("github.com/hildjj/cbor2/break");static ENCODED=Symbol.for("github.com/hildjj/cbor2/cbor-encoded");static LENGTH=Symbol.for("github.com/hildjj/cbor2/length")};const Tr={MIN:-(2n**63n),MAX:2n**64n-1n};let te=class jr{static#e=new Map;tag;contents;constructor(e,r=void 0){this.tag=e,this.contents=r}get noChildren(){return!!jr.#e.get(this.tag)?.noChildren}static registerDecoder(e,r,n){const s=this.#e.get(e);return this.#e.set(e,r),s&&("comment"in r||(r.comment=s.comment),"noChildren"in r||(r.noChildren=s.noChildren)),n&&!r.comment&&(r.comment=()=>`(${n})`),s}static clearDecoder(e){const r=this.#e.get(e);return this.#e.delete(e),r}static getDecoder(e){return this.#e.get(e)}static getAllDecoders(){return new Map(this.#e)}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const r=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:jr.#e.get(this.tag));return r?r(this,e):this}comment(e,r){const n=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:jr.#e.get(this.tag));if(n?.comment)return n.comment(this,e,r)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return`${this.tag}(${n(this.contents,r)})`}};function xr(t){if(t!=null&&typeof t=="object")return t[Ue.ENCODED]}function wa(t){if(t!=null&&typeof t=="object")return t[Ue.LENGTH]}function nr(t,e){Object.defineProperty(t,Ue.ENCODED,{configurable:!0,enumerable:!1,value:e})}function ir(t,e){const r=Object(t);return nr(r,e),r}const xn=Symbol("CBOR_RANGES");function ts(t,e){Object.defineProperty(t,xn,{configurable:!1,enumerable:!1,writable:!1,value:e})}function Ar(t){return t[xn]}function ga(t){return Ar(t)!==void 0}function An(t,e=0,r=t.length-1){const n=t.subarray(e,r),s=Ar(t);if(s){const i=[];for(const c of s)if(c[0]>=e&&c[0]+c[1]<=r){const l=[...c];l[0]-=e,i.push(l)}i.length&&ts(n,i)}return n}function rs(t){let e=Math.ceil(t.length/2);const r=new Uint8Array(e);e--;for(let n=t.length,s=n-2;n>=0;n=s,s-=2,e--)r[e]=parseInt(t.substring(s,n),16);return r}function $e(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function ma(t){const e=t.reduce((c,l)=>c+l.length,0),r=t.some(c=>ga(c)),n=[],s=new Uint8Array(e);let i=0;for(const c of t){if(!(c instanceof Uint8Array))throw new TypeError(`Invalid array: ${c}`);if(s.set(c,i),r){const l=c[xn]??[[0,c.length]];for(const h of l)h[0]+=i;n.push(...l)}i+=c.length}return r&&ts(s,n),s}function Rn(t){const e=atob(t);return Uint8Array.from(e,r=>r.codePointAt(0))}const ba={"-":"+",_:"/"};function Ea(t){const e=t.replace(/[_-]/g,r=>ba[r]);return Rn(e.padEnd(Math.ceil(e.length/4)*4,"="))}function Sa(){const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])}function ns(t){let e="";for(const r of t){const n=r.codePointAt(0)?.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${n}`}return e}class is{#e=new Map;registerEncoder(e,r){const n=this.#e.get(e);return this.#e.set(e,r),n}get(e){return this.#e.get(e)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}}function ss(t,e){const[r,n,s]=t,[i,c,l]=e,h=Math.min(s.length,l.length);for(let w=0;w<h;w++){const d=s[w]-l[w];if(d!==0)return d}return 0}class Rr{static defaultOptions={chunkSize:4096};#e;#t=[];#r=null;#n=0;#i=0;constructor(e={}){if(this.#e={...Rr.defaultOptions,...e},this.#e.chunkSize<8)throw new RangeError(`Expected size >= 8, got ${this.#e.chunkSize}`);this.#s()}get length(){return this.#i}read(){this.#c();const e=new Uint8Array(this.#i);let r=0;for(const n of this.#t)e.set(n,r),r+=n.length;return this.#s(),e}write(e){const r=e.length;r>this.#u()?(this.#c(),r>this.#e.chunkSize?(this.#t.push(e),this.#s()):(this.#s(),this.#t[this.#t.length-1].set(e),this.#n=r)):(this.#t[this.#t.length-1].set(e,this.#n),this.#n+=r),this.#i+=r}writeUint8(e){this.#o(1),this.#r.setUint8(this.#n,e),this.#a(1)}writeUint16(e,r=!1){this.#o(2),this.#r.setUint16(this.#n,e,r),this.#a(2)}writeUint32(e,r=!1){this.#o(4),this.#r.setUint32(this.#n,e,r),this.#a(4)}writeBigUint64(e,r=!1){this.#o(8),this.#r.setBigUint64(this.#n,e,r),this.#a(8)}writeInt16(e,r=!1){this.#o(2),this.#r.setInt16(this.#n,e,r),this.#a(2)}writeInt32(e,r=!1){this.#o(4),this.#r.setInt32(this.#n,e,r),this.#a(4)}writeBigInt64(e,r=!1){this.#o(8),this.#r.setBigInt64(this.#n,e,r),this.#a(8)}writeFloat32(e,r=!1){this.#o(4),this.#r.setFloat32(this.#n,e,r),this.#a(4)}writeFloat64(e,r=!1){this.#o(8),this.#r.setFloat64(this.#n,e,r),this.#a(8)}clear(){this.#i=0,this.#t=[],this.#s()}#s(){const e=new Uint8Array(this.#e.chunkSize);this.#t.push(e),this.#n=0,this.#r=new DataView(e.buffer,e.byteOffset,e.byteLength)}#c(){if(this.#n===0){this.#t.pop();return}const e=this.#t.length-1;this.#t[e]=this.#t[e].subarray(0,this.#n),this.#n=0,this.#r=null}#u(){const e=this.#t.length-1;return this.#t[e].length-this.#n}#o(e){this.#u()<e&&(this.#c(),this.#s())}#a(e){this.#n+=e,this.#i+=e}}const In=1n<<15n,sr=0b11111n<<10n,os=1n<<9n,as=os-1n,cs=os|as,Bn=1n<<31n,or=0b11111111n<<23n,us=1n<<22n,fs=us-1n,ls=us|fs,Ir=1n<<63n,dt=0b11111111111n<<52n,ar=1n<<51n,Br=ar-1n,hs=ar|Br,ds=Br-(as<<42n),ps=Br-(fs<<29n),_a={2:"0b",8:"0o",16:"0x"};var va=(t=>(t[t.NATURAL=-2]="NATURAL",t[t.UNKNOWN=-1]="UNKNOWN",t[t.F16=2]="F16",t[t.F32=4]="F32",t[t.F64=8]="F64",t))(va||{});function ys(t,e,r,n){let s="nan'";return t.quiet||(s+="!"),t.sign===-1&&(s+="-"),s+=n(Math.abs(t.payload),r),s+="'",s+=t.encodingIndicator,s}let Ta=class extends Number{#e;#t=-1;constructor(e,r=!0,n=-1){super(NaN);const s=e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid NAN payload: ${e}`);e=BigInt(e);let i=0n;if(e<0&&(i=Ir,e=-e),e>=ar)throw new Error(`Payload too large: ${s}`);const c=r?ar:0n;switch(this.#e=i|dt|c|e,n){case-2:throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");case-1:n=this.preferredSize;break;case 2:if(this.#e&ds)throw new Error("Invalid size for payload");break;case 4:if(this.#e&ps)throw new Error("Invalid size for payload");break;case 8:break;default:throw new Error(`Invalid size: ${n}`)}this.#t=n}else if(typeof e=="bigint"){let i=-1;if((e&dt)===dt)this.#e=e,i=8;else if((e&or)===or){const c=(e&Bn)<<32n;this.#e=c|dt|(e&ls)<<29n,i=4}else if((e&sr)===sr){const c=(e&In)<<48n;this.#e=c|dt|(e&cs)<<42n,i=2}else throw new Error(`Invalid raw NaN value: ${e}`);if(n===-1)this.#t=this.preferredSize;else if(n===-2)this.#t=i;else{if(n<i)throw new Error("Invalid bigint NaN size");this.#t=n}}else{const i=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw new Error("Invalid CBOR encoding for half float");const c=BigInt(i.getUint16(1,!1));if((c&sr)!==sr)throw new Error("Not a NaN");const l=(c&In)<<48n;this.#e=l|dt|(c&cs)<<42n,this.#t=2;break}case 5:{if(e[0]!==250)throw new Error("Invalid CBOR encoding for single float");const c=BigInt(i.getUint32(1,!1));if((c&or)!==or)throw new Error("Not a NaN");const l=(c&Bn)<<32n;this.#e=l|dt|(c&ls)<<29n,this.#t=4;break}case 9:{if(e[0]!==251)throw new Error("Invalid CBOR encoding for double float");if(this.#e=i.getBigUint64(1,!1),(this.#e&dt)!==dt)throw new Error("Not a NaN (NaNaN)");this.#t=8;break}default:throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${e.length-1}`)}}if(!this.payload&&!this.quiet)throw new Error("Signalling NaN with zero payload")}get bytes(){const e=new ArrayBuffer(this.#t+1),r=new DataView(e);switch(this.#t){case 2:{r.setUint8(0,249);const n=(this.#e&Ir?In:0n)|sr|(this.#e&hs)>>42n;r.setUint16(1,Number(n),!1);break}case 4:{r.setUint8(0,250);const n=(this.#e&Ir?Bn:0n)|or|(this.#e&hs)>>29n;r.setUint32(1,Number(n),!1);break}case 8:r.setUint8(0,251),r.setBigUint64(1,this.#e);break}return new Uint8Array(e)}get quiet(){return!!(this.#e&ar)}get sign(){return this.#e&Ir?-1:1}get payload(){return Number(this.#e&Br)*this.sign}get raw(){return this.#e}get encodingIndicator(){switch(this.#t){case 2:return"_1";case 4:return"_2"}return"_3"}get size(){return this.#t}get preferredSize(){return(this.#e&ds)===0n?2:(this.#e&ps)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return ys(this,1,{},r=>(_a[e]??"")+r.toString(e))}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return ys(this,e,r,n)}};function ws(t,e=0,r=!1){const n=t[e]&128?-1:1,s=(t[e]&124)>>2,i=(t[e]&3)<<8|t[e+1];if(s===0){if(r&&i!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*i}`);return n*5960464477539063e-23*i}else if(s===31)return i?NaN:n*(1/0);return n*2**(s-25)*(1024+i)}function gs(t){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,t,!1);const r=e.getUint32(0,!1);if((r&8191)!==0)return null;let n=r>>16&32768;const s=r>>23&255,i=r&8388607;if(!(s===0&&i===0))if(s>=113&&s<=142)n+=(s-112<<10)+(i>>13);else if(s>=103&&s<113){if(i&(1<<126-s)-1)return null;n+=i+8388608>>126-s}else if(s===255)n|=31744,n|=i>>13;else return null;return n}function xa(t){if(t!==0){const e=new ArrayBuffer(8),r=new DataView(e);r.setFloat64(0,t,!1);const n=r.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return t}function Aa(t){switch(t.length){case 2:ws(t,0,!0);break;case 4:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint32(0,!1);if((r&2139095040)===0&&r&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getBigUint64(0,!1);if((r&0x7ff0000000000000n)===0n&&r&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${t}`)}}class Ra extends TypeError{code="ERR_ENCODING_INVALID_ENCODED_DATA";constructor(){super("The encoded data was not valid for encoding wtf-8")}}class Ia extends RangeError{code="ERR_ENCODING_NOT_SUPPORTED";constructor(e){super(`Invalid encoding: "${e}"`)}}const Ba=65279,ms=new Uint8Array(0),Na=55296,ka=56320,Fa=65533,bs="wtf-8";function La(t){return t&&typeof t=="object"&&!(t instanceof ArrayBuffer)&&!(t instanceof SharedArrayBuffer)&&t.buffer instanceof ArrayBuffer}function Ua(t){return t?t instanceof Uint8Array?t:La(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t):ms}const Ma=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3];class Nr{static DEFAULT_BUFFERSIZE=4096;encoding=bs;fatal;ignoreBOM;bufferSize;#e=0;#t=0;#r=0;#n=!0;#i;constructor(e="wtf8",r=void 0){if(e.toLowerCase().replace("-","")!=="wtf8")throw new Ia(e);if(this.fatal=!!r?.fatal,this.ignoreBOM=!!r?.ignoreBOM,this.bufferSize=Math.floor(r?.bufferSize??Nr.DEFAULT_BUFFERSIZE),isNaN(this.bufferSize)||this.bufferSize<1)throw new RangeError(`Invalid buffer size: ${r?.bufferSize}`);this.#i=new Uint16Array(this.bufferSize)}decode(e,r){const n=!!r?.stream,s=Ua(e),i=[],c=this.#i,l=this.bufferSize-3;let h=0;const w=()=>{if(this.#t=0,this.#e=0,this.#r=0,this.fatal)throw new Ra;c[h++]=Fa},d=()=>{const T=this.#r;for(let L=0;L<T;L++)w()},I=T=>{if(this.#e===0)switch(Ma[T>>4]){case-1:w();break;case 0:c[h++]=T;break;case 1:this.#t=T&31,(this.#t&30)===0?w():(this.#e=1,this.#r=1);break;case 2:this.#t=T&15,this.#e=2,this.#r=1;break;case 3:T&8?w():(this.#t=T&7,this.#e=3,this.#r=1);break}else{if((T&192)!==128||this.#r===1&&this.#e===2&&this.#t===0&&(T&32)===0||this.#e===3&&this.#t===0&&(T&48)===0)return d(),I(T);if(this.#t=this.#t<<6|T&63,this.#r++,--this.#e===0){if(this.ignoreBOM||!this.#n||this.#t!==Ba)if(this.#t<65536)c[h++]=this.#t;else{const L=this.#t-65536;c[h++]=L>>>10&1023|Na,c[h++]=L&1023|ka}this.#t=0,this.#r=0,this.#n=!1}}};for(const T of s)h>=l&&(i.push(String.fromCharCode.apply(null,c.subarray(0,h))),h=0),I(T);return n||(this.#n=!0,(this.#t||this.#e)&&d()),h>0&&i.push(String.fromCharCode.apply(null,c.subarray(0,h))),i.join("")}}function Pa(t){let e=0;for(const r of t){const n=r.codePointAt(0);n<128?e++:n<2048?e+=2:n<65536?e+=3:e+=4}return e}class Da{encoding=bs;encode(e){if(!e)return ms;const r=new Uint8Array(Pa(String(e)));return this.encodeInto(e,r),r}encodeInto(e,r){const n=String(e),s=n.length,i=r.length;let c=0,l=0;for(l=0;l<s;l++){const h=n.codePointAt(l);if(h<128){if(c>=i)break;r[c++]=h}else if(h<2048){if(c>=i-1)break;r[c++]=192|h>>6,r[c++]=128|h&63}else if(h<65536){if(c>=i-2)break;r[c++]=224|h>>12,r[c++]=128|h>>6&63,r[c++]=128|h&63}else{if(c>=i-3)break;r[c++]=240|h>>18,r[c++]=128|h>>12&63,r[c++]=128|h>>6&63,r[c++]=128|h&63,l++}}return{read:l,written:c}}}const Es=z.SIMPLE_FLOAT<<5|ne.TWO,Ca=z.SIMPLE_FLOAT<<5|ne.FOUR,Oa=z.SIMPLE_FLOAT<<5|ne.EIGHT,$a=z.SIMPLE_FLOAT<<5|_t.TRUE,qa=z.SIMPLE_FLOAT<<5|_t.FALSE,ja=z.SIMPLE_FLOAT<<5|_t.UNDEFINED,Ha=z.SIMPLE_FLOAT<<5|_t.NULL,Wa=new TextEncoder,Ka=new Da,Ss={...Rr.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:ce.DATE_EPOCH,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null,types:null,wtf8:!1,ignoreGlobalTags:!1},_s={cde:!0,ignoreOriginalEncoding:!0,sortKeys:ss},Ga={..._s,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function vs(t){const e=t<0;return typeof t=="bigint"?[e?-t-1n:t,e]:[e?-t-1:t,e]}function Nn(t,e,r){if(r.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${t}`);if(isNaN(t))e.writeUint8(Es),e.writeUint16(32256);else if(!r.float64&&Math.fround(t)===t){const n=gs(t);n===null?(e.writeUint8(Ca),e.writeFloat32(t)):(e.writeUint8(Es),e.writeUint16(n))}else e.writeUint8(Oa),e.writeFloat64(t)}function Ge(t,e,r){const[n,s]=vs(t);if(s&&r)throw new TypeError(`Negative size: ${t}`);r??=s?z.NEG_INT:z.POS_INT,r<<=5,n<24?e.writeUint8(r|n):n<=255?(e.writeUint8(r|ne.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(r|ne.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(r|ne.FOUR),e.writeUint32(n)):(e.writeUint8(r|ne.EIGHT),e.writeBigUint64(BigInt(n)))}function zt(t,e,r){typeof t=="number"?Ge(t,e,z.TAG):typeof t=="object"&&!r.ignoreOriginalEncoding&&Ue.ENCODED in t?e.write(t[Ue.ENCODED]):t<=Number.MAX_SAFE_INTEGER?Ge(Number(t),e,z.TAG):(e.writeUint8(z.TAG<<5|ne.EIGHT),e.writeBigUint64(BigInt(t)))}function Ts(t,e,r){const[n,s]=vs(t);if(r.collapseBigInts&&(!r.largeNegativeAsBigInt||t>=-0x8000000000000000n)){if(n<=0xffffffffn){Ge(Number(t),e);return}if(n<=0xffffffffffffffffn){const w=(s?z.NEG_INT:z.POS_INT)<<5;e.writeUint8(w|ne.EIGHT),e.writeBigUint64(n);return}}if(r.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${t}`);const i=s?ce.NEG_BIGINT:ce.POS_BIGINT,c=n.toString(16),l=c.length%2?"0":"";zt(i,e,r);const h=rs(l+c);Ge(h.length,e,z.BYTE_STRING),e.write(h)}function Ja(t,e,r){r.flushToZero&&(t=xa(t)),Object.is(t,-0)?r.simplifyNegativeZero?r.avoidInts?Nn(0,e,r):Ge(0,e):Nn(t,e,r):!r.avoidInts&&Number.isSafeInteger(t)?Ge(t,e):r.reduceUnsafeNumbers&&Math.floor(t)===t&&t>=Tr.MIN&&t<=Tr.MAX?Ts(BigInt(t),e,r):Nn(t,e,r)}function xs(t,e,r){const n=r.stringNormalization?t.normalize(r.stringNormalization):t;if(r.wtf8&&!t.isWellFormed()){const s=Ka.encode(n);zt(ce.WTF8,e,r),Ge(s.length,e,z.BYTE_STRING),e.write(s)}else{const s=Wa.encode(n);Ge(s.length,e,z.UTF8_STRING),e.write(s)}}function za(t,e,r){const n=t;kn(n,n.length,z.ARRAY,e,r);for(const s of n)Mt(s,e,r)}function Va(t,e){Ge(t.length,e,z.BYTE_STRING),e.write(t)}const kr=new is;kr.registerEncoder(Array,za),kr.registerEncoder(Uint8Array,Va);function xe(t,e){return kr.registerEncoder(t,e)}function kn(t,e,r,n,s){const i=wa(t);i&&!s.ignoreOriginalEncoding?n.write(i):Ge(e,n,r)}function Ya(t,e,r){if(t===null){e.writeUint8(Ha);return}if(!r.ignoreOriginalEncoding&&Ue.ENCODED in t){e.write(t[Ue.ENCODED]);return}const n=t.constructor;if(n){const i=r.types?.get(n)??(r.ignoreGlobalTags?void 0:kr.get(n));if(i){const c=i(t,e,r);if(c!==void 0){if(!Array.isArray(c)||c.length!==2)throw new Error("Invalid encoder return value");(typeof c[0]=="bigint"||isFinite(Number(c[0])))&&zt(c[0],e,r),Mt(c[1],e,r)}return}}if(typeof t.toCBOR=="function"){const i=t.toCBOR(e,r);i&&((typeof i[0]=="bigint"||isFinite(Number(i[0])))&&zt(i[0],e,r),Mt(i[1],e,r));return}if(typeof t.toJSON=="function"){Mt(t.toJSON(),e,r);return}const s=Object.entries(t).map(i=>[i[0],i[1],Vt(i[0],r)]);r.sortKeys&&s.sort(r.sortKeys),kn(t,s.length,z.MAP,e,r);for(const[i,c,l]of s)e.write(l),Mt(c,e,r)}function Qa(t,e,r){if(!t.description||t!==Symbol.for(t.description))throw new TypeError(`Private or empty symbol: ${t.toString()}`);zt(280,e,r),xs(t.description,e,r)}function Mt(t,e,r){switch(typeof t){case"number":Ja(t,e,r);break;case"bigint":Ts(t,e,r);break;case"string":xs(t,e,r);break;case"boolean":e.writeUint8(t?$a:qa);break;case"undefined":if(r.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(ja);break;case"object":Ya(t,e,r);break;case"symbol":Qa(t,e,r);break;default:throw new TypeError(`Unknown type: ${typeof t}, ${String(t)}`)}}function Vt(t,e={}){const r={...Ss};e.dcbor?Object.assign(r,Ga):e.cde&&Object.assign(r,_s),Object.assign(r,e);const n=new Rr(r);return Mt(t,n,r),n.read()}var Fr=(t=>(t[t.NEVER=-1]="NEVER",t[t.PREFERRED=0]="PREFERRED",t[t.ALWAYS=1]="ALWAYS",t))(Fr||{});class ot{static KnownSimple=new Map([[_t.FALSE,!1],[_t.TRUE,!0],[_t.NULL,null],[_t.UNDEFINED,void 0]]);value;constructor(e){this.value=e}static create(e){return ot.KnownSimple.has(e)?ot.KnownSimple.get(e):new ot(e)}toCBOR(e,r){if(r.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Ge(this.value,e,z.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return ot.KnownSimple.has(this.value)?ot.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return`simple(${n(this.value,r)})`}}const Xa=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});let Lr=class Ys{static defaultOptions={maxDepth:1024,encoding:"hex",requirePreferred:!1};#e;#t;#r=0;#n;constructor(e,r){if(this.#n={...Ys.defaultOptions,...r},typeof e=="string")switch(this.#n.encoding){case"hex":this.#e=rs(e);break;case"base64":this.#e=Rn(e);break;default:throw new TypeError(`Encoding not implemented: "${this.#n.encoding}"`)}else this.#e=e;this.#t=new DataView(this.#e.buffer,this.#e.byteOffset,this.#e.byteLength)}toHere(e){return An(this.#e,e,this.#r)}*[Symbol.iterator](){if(yield*this.#i(0),this.#r!==this.#e.length)throw new Error("Extra data in input")}*seq(){for(;this.#r<this.#e.length;)yield*this.#i(0)}*#i(e){if(e++>this.#n.maxDepth)throw new Error(`Maximum depth ${this.#n.maxDepth} exceeded`);const r=this.#r,n=this.#t.getUint8(this.#r++),s=n>>5,i=n&31;let c=i,l=!1,h=0;switch(i){case ne.ONE:if(h=1,c=this.#t.getUint8(this.#r),s===z.SIMPLE_FLOAT){if(c<32)throw new Error(`Invalid simple encoding in extra byte: ${c}`);l=!0}else if(this.#n.requirePreferred&&c<24)throw new Error(`Unexpectedly long integer encoding (1) for ${c}`);break;case ne.TWO:if(h=2,s===z.SIMPLE_FLOAT)c=ws(this.#e,this.#r);else if(c=this.#t.getUint16(this.#r,!1),this.#n.requirePreferred&&c<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${c}`);break;case ne.FOUR:if(h=4,s===z.SIMPLE_FLOAT)c=this.#t.getFloat32(this.#r,!1);else if(c=this.#t.getUint32(this.#r,!1),this.#n.requirePreferred&&c<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${c}`);break;case ne.EIGHT:{if(h=8,s===z.SIMPLE_FLOAT)c=this.#t.getFloat64(this.#r,!1);else if(c=this.#t.getBigUint64(this.#r,!1),c<=Number.MAX_SAFE_INTEGER&&(c=Number(c)),this.#n.requirePreferred&&c<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${c}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${i}`);case ne.INDEFINITE:switch(s){case z.POS_INT:case z.NEG_INT:case z.TAG:throw new Error(`Invalid indefinite encoding for MT ${s}`);case z.SIMPLE_FLOAT:yield[s,i,Ue.BREAK,r,0];return}c=1/0;break;default:l=!0}switch(this.#r+=h,s){case z.POS_INT:yield[s,i,c,r,h];break;case z.NEG_INT:yield[s,i,typeof c=="bigint"?-1n-c:-1-Number(c),r,h];break;case z.BYTE_STRING:c===1/0?yield*this.#c(s,e,r):yield[s,i,this.#s(c),r,c];break;case z.UTF8_STRING:c===1/0?yield*this.#c(s,e,r):yield[s,i,Xa.decode(this.#s(c)),r,c];break;case z.ARRAY:if(c===1/0)yield*this.#c(s,e,r,!1);else{const w=Number(c);yield[s,i,w,r,h];for(let d=0;d<w;d++)yield*this.#i(e+1)}break;case z.MAP:if(c===1/0)yield*this.#c(s,e,r,!1);else{const w=Number(c);yield[s,i,w,r,h];for(let d=0;d<w;d++)yield*this.#i(e),yield*this.#i(e)}break;case z.TAG:yield[s,i,c,r,h],yield*this.#i(e);break;case z.SIMPLE_FLOAT:{const w=c;l&&(c=ot.create(Number(c))),yield[s,i,c,r,w];break}}}#s(e){const r=An(this.#e,this.#r,this.#r+=e);if(r.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${r.length}`);return r}*#c(e,r,n,s=!0){for(yield[e,ne.INDEFINITE,1/0,n,1/0];;){const i=this.#i(r),c=i.next(),[l,h,w]=c.value;if(w===Ue.BREAK){yield c.value,i.next();return}if(s){if(l!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${l}.`);if(h===ne.INDEFINITE)throw new Error("New stream started in typed stream")}yield c.value,yield*i}}};const Za=new Map([[ne.ZERO,1],[ne.ONE,2],[ne.TWO,3],[ne.FOUR,5],[ne.EIGHT,9]]),ec=new Uint8Array(0);function tc(t,e){return!e.boxed&&!e.preferMap&&t.every(([r])=>typeof r=="string")?Object.fromEntries(t):new Map(t)}let qe=class Qs{static defaultDecodeOptions={...Lr.defaultOptions,ParentType:Qs,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Fr.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:tc,keepNanPayloads:!1,pretty:!1,preferBigInt:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null,tags:null,ignoreGlobalTags:!1};static cdeDecodeOptions={cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:ss};static dcborDecodeOptions={...this.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"};parent;mt;ai;left;offset;count=0;children=[];depth=0;#e;#t=null;constructor(e,r,n,s){if([this.mt,this.ai,,this.offset]=e,this.left=r,this.parent=n,this.#e=s,n&&(this.depth=n.depth+1),this.mt===z.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===ne.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,r,n,s){const[i,c,l,h]=e;switch(i){case z.POS_INT:case z.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${l}`);if(n.rejectLargeNegatives&&l<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${l}`);let w=l;return n.preferBigInt?w=BigInt(w):n.convertUnsafeIntsToFloat&&w>=Tr.MIN&&w<=Tr.MAX&&(w=Number(l)),n.boxed?ir(w,s.toHere(h)):w}case z.SIMPLE_FLOAT:if(c>ne.ONE){if(typeof l=="symbol")return l;if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${l}`);if(n.rejectNegativeZero&&Object.is(l,-0))throw new Error("Decoding negative zero");if(isNaN(l)){const w=s.toHere(h),d=new Ta(w);if(n.rejectLongLoundNaN){if(d.payload||w.length>3)throw new Error(`Invalid NaN encoding: "${$e(w)}"`)}else if(n.keepNanPayloads&&(d.payload||d.sign===-1)){if(n.rejectLongFloats&&!d.isShortestEncoding)throw new Error(`NaN should have been encoded shorter: ${l}`);return d}}if(n.rejectSubnormals&&Aa(s.toHere(h+1)),n.rejectLongFloats){const w=Vt(l,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(w[0]>>5!==i)throw new Error(`Should have been encoded as int, not float: ${l}`);if(w.length<Za.get(c))throw new Error(`Number should have been encoded shorter: ${l}`)}if(typeof l=="number"&&n.boxed)return ir(l,s.toHere(h))}else{if(n.rejectSimple&&l instanceof ot)throw new Error(`Invalid simple value: ${l}`);if(n.rejectUndefined&&l===void 0)throw new Error("Unexpected undefined")}return l;case z.BYTE_STRING:case z.UTF8_STRING:if(l===1/0)return new n.ParentType(e,1/0,r,n);if(n.rejectStringsNotNormalizedAs&&typeof l=="string"){const w=l.normalize(n.rejectStringsNotNormalizedAs);if(l!==w)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${ns(l)}] instead of [${ns(w)}]`)}return n.boxed?ir(l,s.toHere(h)):l;case z.ARRAY:return new n.ParentType(e,l,r,n);case z.MAP:return new n.ParentType(e,l*2,r,n);case z.TAG:{const w=new n.ParentType(e,1,r,n);return w.children=new te(l),w}}throw new TypeError(`Invalid major type: ${i}`)}static decodeToEncodeOpts(e){return{...Ss,avoidInts:e.rejectInts,float64:!e.rejectLongFloats,flushToZero:e.rejectSubnormals,largeNegativeAsBigInt:e.rejectLargeNegatives,sortKeys:e.sortKeys}}push(e,r,n){if(this.children.push(e),this.#t){const s=xr(e)||r.toHere(n);this.#t.push(s)}return--this.left}replaceLast(e,r,n){let s,i=-1/0;if(this.children instanceof te?(i=0,s=this.children.contents,this.children.contents=e):(i=this.children.length-1,s=this.children[i],this.children[i]=e),this.#t){const c=xr(e)||n.toHere(r.offset);this.#t[i]=c}return s}convert(e){let r;switch(this.mt){case z.ARRAY:r=this.children;break;case z.MAP:{const n=this.#r();if(this.#e.sortKeys){let s;for(const i of n){if(s&&this.#e.sortKeys(s,i)>=0)throw new Error(`Duplicate or out of order key: "0x${i[2]}"`);s=i}}else if(this.#e.rejectDuplicateKeys){const s=new Set;for(const[i,c,l]of n){const h=$e(l);if(s.has(h))throw new Error(`Duplicate key: "0x${h}"`);s.add(h)}}r=this.#e.createObject(n,this.#e);break}case z.BYTE_STRING:return ma(this.children);case z.UTF8_STRING:{const n=this.children.join("");r=this.#e.boxed?ir(n,e.toHere(this.offset)):n;break}case z.TAG:r=this.children.decode(this.#e);break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return this.#e.saveOriginal&&r&&typeof r=="object"&&nr(r,e.toHere(this.offset)),r}#r(){const e=this.children,r=e.length;if(r%2)throw new Error("Missing map value");const n=new Array(r/2);if(this.#t)for(let s=0;s<r;s+=2)n[s>>1]=[e[s],e[s+1],this.#t[s]];else for(let s=0;s<r;s+=2)n[s>>1]=[e[s],e[s+1],ec];return n}};const Fn=" ",rc=new TextEncoder;class As extends qe{close="";quote='"';get isEmptyStream(){return(this.mt===z.UTF8_STRING||this.mt===z.BYTE_STRING)&&this.count===0}}function vt(t,e,r,n){let s="";if(e===ne.INDEFINITE)s+="_";else{if(n.diagnosticSizes===Fr.NEVER)return"";{let i=n.diagnosticSizes===Fr.ALWAYS;if(!i){let c=ne.ZERO;if(Object.is(r,-0))c=ne.TWO;else if(t===z.POS_INT||t===z.NEG_INT){const l=r<0,h=typeof r=="bigint"?1n:1,w=l?-r-h:r;w<=23?c=Number(w):w<=255?c=ne.ONE:w<=65535?c=ne.TWO:w<=4294967295?c=ne.FOUR:c=ne.EIGHT}else isFinite(r)?Math.fround(r)===r?gs(r)==null?c=ne.FOUR:c=ne.TWO:c=ne.EIGHT:c=ne.TWO;i=c!==e}i&&(s+="_",e<ne.ONE?s+="i":s+=String(e-24))}}return s}function nc(t,e){const r={...qe.defaultDecodeOptions,...e,ParentType:As},n=new Lr(t,r);let s,i,c="";for(const l of n){const[h,w,d]=l;switch(s&&(s.count>0&&d!==Ue.BREAK&&(s.mt===z.MAP&&s.count%2?c+=": ":(c+=",",r.pretty||(c+=" "))),r.pretty&&(s.mt!==z.MAP||s.count%2===0)&&(c+=`
|
|
3
|
-
${Fn.repeat(s.depth+1)}`)),i=qe.create(l,s,r,n),h){case z.POS_INT:case z.NEG_INT:c+=String(d),c+=vt(h,w,d,r);break;case z.SIMPLE_FLOAT:if(d!==
|
|
1
|
+
(function(et,Yt){typeof exports=="object"&&typeof module<"u"?module.exports=Yt():typeof define=="function"&&define.amd?define(Yt):(et=typeof globalThis<"u"?globalThis:et||self,et.MQTTp=Yt())})(this,(function(){"use strict";var et=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yt(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function n(){var s=!1;try{s=this instanceof n}catch{}return s?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(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var lr={exports:{}},qn;function hr(){if(qn)return lr.exports;qn=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,k,U){return Function.prototype.apply.call(v,k,U)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function n(_){console&&console.warn&&console.warn(_)}var s=Number.isNaN||function(v){return v!==v};function i(){i.init.call(this)}lr.exports=i,lr.exports.once=S,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var c=10;function l(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(_){if(typeof _!="number"||_<0||s(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");c=_}}),i.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||s(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function h(_){return _._maxListeners===void 0?i.defaultMaxListeners:_._maxListeners}i.prototype.getMaxListeners=function(){return h(this)},i.prototype.emit=function(v){for(var k=[],U=1;U<arguments.length;U++)k.push(arguments[U]);var O=v==="error",q=this._events;if(q!==void 0)O=O&&q.error===void 0;else if(!O)return!1;if(O){var G;if(k.length>0&&(G=k[0]),G instanceof Error)throw G;var V=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw V.context=G,V}var N=q[v];if(N===void 0)return!1;if(typeof N=="function")e(N,this,k);else for(var X=N.length,fe=B(N,X),U=0;U<X;++U)e(fe[U],this,k);return!0};function w(_,v,k,U){var O,q,G;if(l(k),q=_._events,q===void 0?(q=_._events=Object.create(null),_._eventsCount=0):(q.newListener!==void 0&&(_.emit("newListener",v,k.listener?k.listener:k),q=_._events),G=q[v]),G===void 0)G=q[v]=k,++_._eventsCount;else if(typeof G=="function"?G=q[v]=U?[k,G]:[G,k]:U?G.unshift(k):G.push(k),O=h(_),O>0&&G.length>O&&!G.warned){G.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=_,V.type=v,V.count=G.length,n(V)}return _}i.prototype.addListener=function(v,k){return w(this,v,k,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(v,k){return w(this,v,k,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(_,v,k){var U={fired:!1,wrapFn:void 0,target:_,type:v,listener:k},O=d.bind(U);return O.listener=k,U.wrapFn=O,O}i.prototype.once=function(v,k){return l(k),this.on(v,I(this,v,k)),this},i.prototype.prependOnceListener=function(v,k){return l(k),this.prependListener(v,I(this,v,k)),this},i.prototype.removeListener=function(v,k){var U,O,q,G,V;if(l(k),O=this._events,O===void 0)return this;if(U=O[v],U===void 0)return this;if(U===k||U.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete O[v],O.removeListener&&this.emit("removeListener",v,U.listener||k));else if(typeof U!="function"){for(q=-1,G=U.length-1;G>=0;G--)if(U[G]===k||U[G].listener===k){V=U[G].listener,q=G;break}if(q<0)return this;q===0?U.shift():j(U,q),U.length===1&&(O[v]=U[0]),O.removeListener!==void 0&&this.emit("removeListener",v,V||k)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(v){var k,U,O;if(U=this._events,U===void 0)return this;if(U.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):U[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete U[v]),this;if(arguments.length===0){var q=Object.keys(U),G;for(O=0;O<q.length;++O)G=q[O],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=U[v],typeof k=="function")this.removeListener(v,k);else if(k!==void 0)for(O=k.length-1;O>=0;O--)this.removeListener(v,k[O]);return this};function T(_,v,k){var U=_._events;if(U===void 0)return[];var O=U[v];return O===void 0?[]:typeof O=="function"?k?[O.listener||O]:[O]:k?$(O):B(O,O.length)}i.prototype.listeners=function(v){return T(this,v,!0)},i.prototype.rawListeners=function(v){return T(this,v,!1)},i.listenerCount=function(_,v){return typeof _.listenerCount=="function"?_.listenerCount(v):L.call(_,v)},i.prototype.listenerCount=L;function L(_){var v=this._events;if(v!==void 0){var k=v[_];if(typeof k=="function")return 1;if(k!==void 0)return k.length}return 0}i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function B(_,v){for(var k=new Array(v),U=0;U<v;++U)k[U]=_[U];return k}function j(_,v){for(;v+1<_.length;v++)_[v]=_[v+1];_.pop()}function $(_){for(var v=new Array(_.length),k=0;k<v.length;++k)v[k]=_[k].listener||_[k];return v}function S(_,v){return new Promise(function(k,U){function O(G){_.removeListener(v,q),U(G)}function q(){typeof _.removeListener=="function"&&_.removeListener("error",O),k([].slice.call(arguments))}F(_,v,q,{once:!0}),v!=="error"&&x(_,O,{once:!0})})}function x(_,v,k){typeof _.on=="function"&&F(_,"error",v,k)}function F(_,v,k,U){if(typeof _.on=="function")U.once?_.once(v,k):_.on(v,k);else if(typeof _.addEventListener=="function")_.addEventListener(v,function O(q){U.once&&_.removeEventListener(v,O),k(q)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return lr.exports}var dr={exports:{}},jn;function Pt(){return jn||(jn=1,typeof Object.create=="function"?dr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:dr.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),dr.exports}function Xs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn={exports:{}},Be=Hn.exports={},tt,rt;function Hr(){throw new Error("setTimeout has not been defined")}function Wr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?tt=setTimeout:tt=Hr}catch{tt=Hr}try{typeof clearTimeout=="function"?rt=clearTimeout:rt=Wr}catch{rt=Wr}})();function Wn(t){if(tt===setTimeout)return setTimeout(t,0);if((tt===Hr||!tt)&&setTimeout)return tt=setTimeout,setTimeout(t,0);try{return tt(t,0)}catch{try{return tt.call(null,t,0)}catch{return tt.call(this,t,0)}}}function Zs(t){if(rt===clearTimeout)return clearTimeout(t);if((rt===Wr||!rt)&&clearTimeout)return rt=clearTimeout,clearTimeout(t);try{return rt(t)}catch{try{return rt.call(null,t)}catch{return rt.call(this,t)}}}var ft=[],Dt=!1,Bt,pr=-1;function eo(){!Dt||!Bt||(Dt=!1,Bt.length?ft=Bt.concat(ft):pr=-1,ft.length&&Kn())}function Kn(){if(!Dt){var t=Wn(eo);Dt=!0;for(var e=ft.length;e;){for(Bt=ft,ft=[];++pr<e;)Bt&&Bt[pr].run();pr=-1,e=ft.length}Bt=null,Dt=!1,Zs(t)}}Be.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];ft.push(new Gn(t,e)),ft.length===1&&!Dt&&Wn(Kn)};function Gn(t,e){this.fun=t,this.array=e}Gn.prototype.run=function(){this.fun.apply(null,this.array)},Be.title="browser",Be.browser=!0,Be.env={},Be.argv=[],Be.version="",Be.versions={};function lt(){}Be.on=lt,Be.addListener=lt,Be.once=lt,Be.off=lt,Be.removeListener=lt,Be.removeAllListeners=lt,Be.emit=lt,Be.prependListener=lt,Be.prependOnceListener=lt,Be.listeners=function(t){return[]},Be.binding=function(t){throw new Error("process.binding is not supported")},Be.cwd=function(){return"/"},Be.chdir=function(t){throw new Error("process.chdir is not supported")},Be.umask=function(){return 0};var to=Hn.exports;const pe=Xs(to);var Kr,Jn;function zn(){return Jn||(Jn=1,Kr=hr().EventEmitter),Kr}var Gr={},Vn;function yr(){return Vn||(Vn=1,(function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},r={};r.byteLength=d,r.toByteArray=T,r.fromByteArray=j;for(var n=[],s=[],i=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,h=c.length;l<h;++l)n[l]=c[l],s[c.charCodeAt(l)]=l;s[45]=62,s[95]=63;function w(x){var F=x.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=x.indexOf("=");_===-1&&(_=F);var v=_===F?0:4-_%4;return[_,v]}function d(x){var F=w(x),_=F[0],v=F[1];return(_+v)*3/4-v}function I(x,F,_){return(F+_)*3/4-_}function T(x){var F,_=w(x),v=_[0],k=_[1],U=new i(I(x,v,k)),O=0,q=k>0?v-4:v,G;for(G=0;G<q;G+=4)F=s[x.charCodeAt(G)]<<18|s[x.charCodeAt(G+1)]<<12|s[x.charCodeAt(G+2)]<<6|s[x.charCodeAt(G+3)],U[O++]=F>>16&255,U[O++]=F>>8&255,U[O++]=F&255;return k===2&&(F=s[x.charCodeAt(G)]<<2|s[x.charCodeAt(G+1)]>>4,U[O++]=F&255),k===1&&(F=s[x.charCodeAt(G)]<<10|s[x.charCodeAt(G+1)]<<4|s[x.charCodeAt(G+2)]>>2,U[O++]=F>>8&255,U[O++]=F&255),U}function L(x){return n[x>>18&63]+n[x>>12&63]+n[x>>6&63]+n[x&63]}function B(x,F,_){for(var v,k=[],U=F;U<_;U+=3)v=(x[U]<<16&16711680)+(x[U+1]<<8&65280)+(x[U+2]&255),k.push(L(v));return k.join("")}function j(x){for(var F,_=x.length,v=_%3,k=[],U=16383,O=0,q=_-v;O<q;O+=U)k.push(B(x,O,O+U>q?q:O+U));return v===1?(F=x[_-1],k.push(n[F>>2]+n[F<<4&63]+"==")):v===2&&(F=(x[_-2]<<8)+x[_-1],k.push(n[F>>10]+n[F>>4&63]+n[F<<2&63]+"=")),k.join("")}var $={};$.read=function(x,F,_,v,k){var U,O,q=k*8-v-1,G=(1<<q)-1,V=G>>1,N=-7,X=_?k-1:0,fe=_?-1:1,Q=x[F+X];for(X+=fe,U=Q&(1<<-N)-1,Q>>=-N,N+=q;N>0;U=U*256+x[F+X],X+=fe,N-=8);for(O=U&(1<<-N)-1,U>>=-N,N+=v;N>0;O=O*256+x[F+X],X+=fe,N-=8);if(U===0)U=1-V;else{if(U===G)return O?NaN:(Q?-1:1)*(1/0);O=O+Math.pow(2,v),U=U-V}return(Q?-1:1)*O*Math.pow(2,U-v)},$.write=function(x,F,_,v,k,U){var O,q,G,V=U*8-k-1,N=(1<<V)-1,X=N>>1,fe=k===23?Math.pow(2,-24)-Math.pow(2,-77):0,Q=v?0:U-1,ee=v?1:-1,ue=F<0||F===0&&1/F<0?1:0;for(F=Math.abs(F),isNaN(F)||F===1/0?(q=isNaN(F)?1:0,O=N):(O=Math.floor(Math.log(F)/Math.LN2),F*(G=Math.pow(2,-O))<1&&(O--,G*=2),O+X>=1?F+=fe/G:F+=fe*Math.pow(2,1-X),F*G>=2&&(O++,G/=2),O+X>=N?(q=0,O=N):O+X>=1?(q=(F*G-1)*Math.pow(2,k),O=O+X):(q=F*Math.pow(2,X-1)*Math.pow(2,k),O=0));k>=8;x[_+Q]=q&255,Q+=ee,q/=256,k-=8);for(O=O<<k|q,V+=k;V>0;x[_+Q]=O&255,Q+=ee,O/=256,V-=8);x[_+Q-ee]|=ue*128};(function(x){const F=r,_=$,v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;x.Buffer=N,x.SlowBuffer=Qe,x.INSPECT_MAX_BYTES=50;const k=2147483647;x.kMaxLength=k;const{Uint8Array:U,ArrayBuffer:O,SharedArrayBuffer:q}=globalThis;N.TYPED_ARRAY_SUPPORT=G(),!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function G(){try{const y=new U(1),a={foo:function(){return 42}};return Object.setPrototypeOf(a,U.prototype),Object.setPrototypeOf(y,a),y.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}}),Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function V(y){if(y>k)throw new RangeError('The value "'+y+'" is invalid for option "size"');const a=new U(y);return Object.setPrototypeOf(a,N.prototype),a}function N(y,a,f){if(typeof y=="number"){if(typeof a=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ee(y)}return X(y,a,f)}N.poolSize=8192;function X(y,a,f){if(typeof y=="string")return ue(y,a);if(O.isView(y))return Ee(y);if(y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y);if(ut(y,O)||y&&ut(y.buffer,O)||typeof q<"u"&&(ut(y,q)||y&&ut(y.buffer,q)))return Ce(y,a,f);if(typeof y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=y.valueOf&&y.valueOf();if(m!=null&&m!==y)return N.from(m,a,f);const R=wt(y);if(R)return R;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof y[Symbol.toPrimitive]=="function")return N.from(y[Symbol.toPrimitive]("string"),a,f);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof y)}N.from=function(y,a,f){return X(y,a,f)},Object.setPrototypeOf(N.prototype,U.prototype),Object.setPrototypeOf(N,U);function fe(y){if(typeof y!="number")throw new TypeError('"size" argument must be of type number');if(y<0)throw new RangeError('The value "'+y+'" is invalid for option "size"')}function Q(y,a,f){return fe(y),y<=0?V(y):a!==void 0?typeof f=="string"?V(y).fill(a,f):V(y).fill(a):V(y)}N.alloc=function(y,a,f){return Q(y,a,f)};function ee(y){return fe(y),V(y<0?0:at(y)|0)}N.allocUnsafe=function(y){return ee(y)},N.allocUnsafeSlow=function(y){return ee(y)};function ue(y,a){if((typeof a!="string"||a==="")&&(a="utf8"),!N.isEncoding(a))throw new TypeError("Unknown encoding: "+a);const f=be(y,a)|0;let m=V(f);const R=m.write(y,a);return R!==f&&(m=m.slice(0,R)),m}function we(y){const a=y.length<0?0:at(y.length)|0,f=V(a);for(let m=0;m<a;m+=1)f[m]=y[m]&255;return f}function Ee(y){if(ut(y,U)){const a=new U(y);return Ce(a.buffer,a.byteOffset,a.byteLength)}return we(y)}function Ce(y,a,f){if(a<0||y.byteLength<a)throw new RangeError('"offset" is outside of buffer bounds');if(y.byteLength<a+(f||0))throw new RangeError('"length" is outside of buffer bounds');let m;return a===void 0&&f===void 0?m=new U(y):f===void 0?m=new U(y,a):m=new U(y,a,f),Object.setPrototypeOf(m,N.prototype),m}function wt(y){if(N.isBuffer(y)){const a=at(y.length)|0,f=V(a);return f.length===0||y.copy(f,0,0,a),f}if(y.length!==void 0)return typeof y.length!="number"||$n(y.length)?V(0):we(y);if(y.type==="Buffer"&&Array.isArray(y.data))return we(y.data)}function at(y){if(y>=k)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+k.toString(16)+" bytes");return y|0}function Qe(y){return+y!=y&&(y=0),N.alloc(+y)}N.isBuffer=function(a){return a!=null&&a._isBuffer===!0&&a!==N.prototype},N.compare=function(a,f){if(ut(a,U)&&(a=N.from(a,a.offset,a.byteLength)),ut(f,U)&&(f=N.from(f,f.offset,f.byteLength)),!N.isBuffer(a)||!N.isBuffer(f))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(a===f)return 0;let m=a.length,R=f.length;for(let C=0,W=Math.min(m,R);C<W;++C)if(a[C]!==f[C]){m=a[C],R=f[C];break}return m<R?-1:R<m?1:0},N.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},N.concat=function(a,f){if(!Array.isArray(a))throw new TypeError('"list" argument must be an Array of Buffers');if(a.length===0)return N.alloc(0);let m;if(f===void 0)for(f=0,m=0;m<a.length;++m)f+=a[m].length;const R=N.allocUnsafe(f);let C=0;for(m=0;m<a.length;++m){let W=a[m];if(ut(W,U))C+W.length>R.length?(N.isBuffer(W)||(W=N.from(W)),W.copy(R,C)):U.prototype.set.call(R,W,C);else if(N.isBuffer(W))W.copy(R,C);else throw new TypeError('"list" argument must be an Array of Buffers');C+=W.length}return R};function be(y,a){if(N.isBuffer(y))return y.length;if(O.isView(y)||ut(y,O))return y.byteLength;if(typeof y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof y);const f=y.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&f===0)return 0;let R=!1;for(;;)switch(a){case"ascii":case"latin1":case"binary":return f;case"utf8":case"utf-8":return ge(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return f*2;case"hex":return f>>>1;case"base64":return le(y).length;default:if(R)return m?-1:ge(y).length;a=(""+a).toLowerCase(),R=!0}}N.byteLength=be;function Fe(y,a,f){let m=!1;if((a===void 0||a<0)&&(a=0),a>this.length||((f===void 0||f>this.length)&&(f=this.length),f<=0)||(f>>>=0,a>>>=0,f<=a))return"";for(y||(y="utf8");;)switch(y){case"hex":return At(this,a,f);case"utf8":case"utf-8":return de(this,a,f);case"ascii":return ct(this,a,f);case"latin1":case"binary":return xt(this,a,f);case"base64":return Y(this,a,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return fr(this,a,f);default:if(m)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),m=!0}}N.prototype._isBuffer=!0;function P(y,a,f){const m=y[a];y[a]=y[f],y[f]=m}N.prototype.swap16=function(){const a=this.length;if(a%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let f=0;f<a;f+=2)P(this,f,f+1);return this},N.prototype.swap32=function(){const a=this.length;if(a%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let f=0;f<a;f+=4)P(this,f,f+3),P(this,f+1,f+2);return this},N.prototype.swap64=function(){const a=this.length;if(a%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let f=0;f<a;f+=8)P(this,f,f+7),P(this,f+1,f+6),P(this,f+2,f+5),P(this,f+3,f+4);return this},N.prototype.toString=function(){const a=this.length;return a===0?"":arguments.length===0?de(this,0,a):Fe.apply(this,arguments)},N.prototype.toLocaleString=N.prototype.toString,N.prototype.equals=function(a){if(!N.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?!0:N.compare(this,a)===0},N.prototype.inspect=function(){let a="";const f=x.INSPECT_MAX_BYTES;return a=this.toString("hex",0,f).replace(/(.{2})/g,"$1 ").trim(),this.length>f&&(a+=" ... "),"<Buffer "+a+">"},v&&(N.prototype[v]=N.prototype.inspect),N.prototype.compare=function(a,f,m,R,C){if(ut(a,U)&&(a=N.from(a,a.offset,a.byteLength)),!N.isBuffer(a))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof a);if(f===void 0&&(f=0),m===void 0&&(m=a?a.length:0),R===void 0&&(R=0),C===void 0&&(C=this.length),f<0||m>a.length||R<0||C>this.length)throw new RangeError("out of range index");if(R>=C&&f>=m)return 0;if(R>=C)return-1;if(f>=m)return 1;if(f>>>=0,m>>>=0,R>>>=0,C>>>=0,this===a)return 0;let W=C-R,oe=m-f;const Re=Math.min(W,oe),_e=this.slice(R,C),Ie=a.slice(f,m);for(let ye=0;ye<Re;++ye)if(_e[ye]!==Ie[ye]){W=_e[ye],oe=Ie[ye];break}return W<oe?-1:oe<W?1:0};function M(y,a,f,m,R){if(y.length===0)return-1;if(typeof f=="string"?(m=f,f=0):f>2147483647?f=2147483647:f<-2147483648&&(f=-2147483648),f=+f,$n(f)&&(f=R?0:y.length-1),f<0&&(f=y.length+f),f>=y.length){if(R)return-1;f=y.length-1}else if(f<0)if(R)f=0;else return-1;if(typeof a=="string"&&(a=N.from(a,m)),N.isBuffer(a))return a.length===0?-1:J(y,a,f,m,R);if(typeof a=="number")return a=a&255,typeof U.prototype.indexOf=="function"?R?U.prototype.indexOf.call(y,a,f):U.prototype.lastIndexOf.call(y,a,f):J(y,[a],f,m,R);throw new TypeError("val must be string, number or Buffer")}function J(y,a,f,m,R){let C=1,W=y.length,oe=a.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(y.length<2||a.length<2)return-1;C=2,W/=2,oe/=2,f/=2}function Re(Ie,ye){return C===1?Ie[ye]:Ie.readUInt16BE(ye*C)}let _e;if(R){let Ie=-1;for(_e=f;_e<W;_e++)if(Re(y,_e)===Re(a,Ie===-1?0:_e-Ie)){if(Ie===-1&&(Ie=_e),_e-Ie+1===oe)return Ie*C}else Ie!==-1&&(_e-=_e-Ie),Ie=-1}else for(f+oe>W&&(f=W-oe),_e=f;_e>=0;_e--){let Ie=!0;for(let ye=0;ye<oe;ye++)if(Re(y,_e+ye)!==Re(a,ye)){Ie=!1;break}if(Ie)return _e}return-1}N.prototype.includes=function(a,f,m){return this.indexOf(a,f,m)!==-1},N.prototype.indexOf=function(a,f,m){return M(this,a,f,m,!0)},N.prototype.lastIndexOf=function(a,f,m){return M(this,a,f,m,!1)};function Z(y,a,f,m){f=Number(f)||0;const R=y.length-f;m?(m=Number(m),m>R&&(m=R)):m=R;const C=a.length;m>C/2&&(m=C/2);let W;for(W=0;W<m;++W){const oe=parseInt(a.substr(W*2,2),16);if($n(oe))return W;y[f+W]=oe}return W}function ie(y,a,f,m){return $r(ge(a,y.length-f),y,f,m)}function b(y,a,f,m){return $r(me(a),y,f,m)}function E(y,a,f,m){return $r(le(a),y,f,m)}function K(y,a,f,m){return $r(Se(a,y.length-f),y,f,m)}N.prototype.write=function(a,f,m,R){if(f===void 0)R="utf8",m=this.length,f=0;else if(m===void 0&&typeof f=="string")R=f,m=this.length,f=0;else if(isFinite(f))f=f>>>0,isFinite(m)?(m=m>>>0,R===void 0&&(R="utf8")):(R=m,m=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const C=this.length-f;if((m===void 0||m>C)&&(m=C),a.length>0&&(m<0||f<0)||f>this.length)throw new RangeError("Attempt to write outside buffer bounds");R||(R="utf8");let W=!1;for(;;)switch(R){case"hex":return Z(this,a,f,m);case"utf8":case"utf-8":return ie(this,a,f,m);case"ascii":case"latin1":case"binary":return b(this,a,f,m);case"base64":return E(this,a,f,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,a,f,m);default:if(W)throw new TypeError("Unknown encoding: "+R);R=(""+R).toLowerCase(),W=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Y(y,a,f){return a===0&&f===y.length?F.fromByteArray(y):F.fromByteArray(y.slice(a,f))}function de(y,a,f){f=Math.min(y.length,f);const m=[];let R=a;for(;R<f;){const C=y[R];let W=null,oe=C>239?4:C>223?3:C>191?2:1;if(R+oe<=f){let Re,_e,Ie,ye;switch(oe){case 1:C<128&&(W=C);break;case 2:Re=y[R+1],(Re&192)===128&&(ye=(C&31)<<6|Re&63,ye>127&&(W=ye));break;case 3:Re=y[R+1],_e=y[R+2],(Re&192)===128&&(_e&192)===128&&(ye=(C&15)<<12|(Re&63)<<6|_e&63,ye>2047&&(ye<55296||ye>57343)&&(W=ye));break;case 4:Re=y[R+1],_e=y[R+2],Ie=y[R+3],(Re&192)===128&&(_e&192)===128&&(Ie&192)===128&&(ye=(C&15)<<18|(Re&63)<<12|(_e&63)<<6|Ie&63,ye>65535&&ye<1114112&&(W=ye))}}W===null?(W=65533,oe=1):W>65535&&(W-=65536,m.push(W>>>10&1023|55296),W=56320|W&1023),m.push(W),R+=oe}return ce(m)}const te=4096;function ce(y){const a=y.length;if(a<=te)return String.fromCharCode.apply(String,y);let f="",m=0;for(;m<a;)f+=String.fromCharCode.apply(String,y.slice(m,m+=te));return f}function ct(y,a,f){let m="";f=Math.min(y.length,f);for(let R=a;R<f;++R)m+=String.fromCharCode(y[R]&127);return m}function xt(y,a,f){let m="";f=Math.min(y.length,f);for(let R=a;R<f;++R)m+=String.fromCharCode(y[R]);return m}function At(y,a,f){const m=y.length;(!a||a<0)&&(a=0),(!f||f<0||f>m)&&(f=m);let R="";for(let C=a;C<f;++C)R+=Cc[y[C]];return R}function fr(y,a,f){const m=y.slice(a,f);let R="";for(let C=0;C<m.length-1;C+=2)R+=String.fromCharCode(m[C]+m[C+1]*256);return R}N.prototype.slice=function(a,f){const m=this.length;a=~~a,f=f===void 0?m:~~f,a<0?(a+=m,a<0&&(a=0)):a>m&&(a=m),f<0?(f+=m,f<0&&(f=0)):f>m&&(f=m),f<a&&(f=a);const R=this.subarray(a,f);return Object.setPrototypeOf(R,N.prototype),R};function Te(y,a,f){if(y%1!==0||y<0)throw new RangeError("offset is not uint");if(y+a>f)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(a,f,m){a=a>>>0,f=f>>>0,m||Te(a,f,this.length);let R=this[a],C=1,W=0;for(;++W<f&&(C*=256);)R+=this[a+W]*C;return R},N.prototype.readUintBE=N.prototype.readUIntBE=function(a,f,m){a=a>>>0,f=f>>>0,m||Te(a,f,this.length);let R=this[a+--f],C=1;for(;f>0&&(C*=256);)R+=this[a+--f]*C;return R},N.prototype.readUint8=N.prototype.readUInt8=function(a,f){return a=a>>>0,f||Te(a,1,this.length),this[a]},N.prototype.readUint16LE=N.prototype.readUInt16LE=function(a,f){return a=a>>>0,f||Te(a,2,this.length),this[a]|this[a+1]<<8},N.prototype.readUint16BE=N.prototype.readUInt16BE=function(a,f){return a=a>>>0,f||Te(a,2,this.length),this[a]<<8|this[a+1]},N.prototype.readUint32LE=N.prototype.readUInt32LE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+this[a+3]*16777216},N.prototype.readUint32BE=N.prototype.readUInt32BE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),this[a]*16777216+(this[a+1]<<16|this[a+2]<<8|this[a+3])},N.prototype.readBigUInt64LE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&D(a,this.length-8);const R=f+this[++a]*2**8+this[++a]*2**16+this[++a]*2**24,C=this[++a]+this[++a]*2**8+this[++a]*2**16+m*2**24;return BigInt(R)+(BigInt(C)<<BigInt(32))}),N.prototype.readBigUInt64BE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&D(a,this.length-8);const R=f*2**24+this[++a]*2**16+this[++a]*2**8+this[++a],C=this[++a]*2**24+this[++a]*2**16+this[++a]*2**8+m;return(BigInt(R)<<BigInt(32))+BigInt(C)}),N.prototype.readIntLE=function(a,f,m){a=a>>>0,f=f>>>0,m||Te(a,f,this.length);let R=this[a],C=1,W=0;for(;++W<f&&(C*=256);)R+=this[a+W]*C;return C*=128,R>=C&&(R-=Math.pow(2,8*f)),R},N.prototype.readIntBE=function(a,f,m){a=a>>>0,f=f>>>0,m||Te(a,f,this.length);let R=f,C=1,W=this[a+--R];for(;R>0&&(C*=256);)W+=this[a+--R]*C;return C*=128,W>=C&&(W-=Math.pow(2,8*f)),W},N.prototype.readInt8=function(a,f){return a=a>>>0,f||Te(a,1,this.length),this[a]&128?(255-this[a]+1)*-1:this[a]},N.prototype.readInt16LE=function(a,f){a=a>>>0,f||Te(a,2,this.length);const m=this[a]|this[a+1]<<8;return m&32768?m|4294901760:m},N.prototype.readInt16BE=function(a,f){a=a>>>0,f||Te(a,2,this.length);const m=this[a+1]|this[a]<<8;return m&32768?m|4294901760:m},N.prototype.readInt32LE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},N.prototype.readInt32BE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},N.prototype.readBigInt64LE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&D(a,this.length-8);const R=this[a+4]+this[a+5]*2**8+this[a+6]*2**16+(m<<24);return(BigInt(R)<<BigInt(32))+BigInt(f+this[++a]*2**8+this[++a]*2**16+this[++a]*2**24)}),N.prototype.readBigInt64BE=It(function(a){a=a>>>0,A(a,"offset");const f=this[a],m=this[a+7];(f===void 0||m===void 0)&&D(a,this.length-8);const R=(f<<24)+this[++a]*2**16+this[++a]*2**8+this[++a];return(BigInt(R)<<BigInt(32))+BigInt(this[++a]*2**24+this[++a]*2**16+this[++a]*2**8+m)}),N.prototype.readFloatLE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),_.read(this,a,!0,23,4)},N.prototype.readFloatBE=function(a,f){return a=a>>>0,f||Te(a,4,this.length),_.read(this,a,!1,23,4)},N.prototype.readDoubleLE=function(a,f){return a=a>>>0,f||Te(a,8,this.length),_.read(this,a,!0,52,8)},N.prototype.readDoubleBE=function(a,f){return a=a>>>0,f||Te(a,8,this.length),_.read(this,a,!1,52,8)};function Ne(y,a,f,m,R,C){if(!N.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(a>R||a<C)throw new RangeError('"value" argument is out of bounds');if(f+m>y.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(a,f,m,R){if(a=+a,f=f>>>0,m=m>>>0,!R){const oe=Math.pow(2,8*m)-1;Ne(this,a,f,m,oe,0)}let C=1,W=0;for(this[f]=a&255;++W<m&&(C*=256);)this[f+W]=a/C&255;return f+m},N.prototype.writeUintBE=N.prototype.writeUIntBE=function(a,f,m,R){if(a=+a,f=f>>>0,m=m>>>0,!R){const oe=Math.pow(2,8*m)-1;Ne(this,a,f,m,oe,0)}let C=m-1,W=1;for(this[f+C]=a&255;--C>=0&&(W*=256);)this[f+C]=a/W&255;return f+m},N.prototype.writeUint8=N.prototype.writeUInt8=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,1,255,0),this[f]=a&255,f+1},N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,2,65535,0),this[f]=a&255,this[f+1]=a>>>8,f+2},N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,2,65535,0),this[f]=a>>>8,this[f+1]=a&255,f+2},N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,4,4294967295,0),this[f+3]=a>>>24,this[f+2]=a>>>16,this[f+1]=a>>>8,this[f]=a&255,f+4},N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,4,4294967295,0),this[f]=a>>>24,this[f+1]=a>>>16,this[f+2]=a>>>8,this[f+3]=a&255,f+4};function Xe(y,a,f,m,R){g(a,m,R,y,f,7);let C=Number(a&BigInt(4294967295));y[f++]=C,C=C>>8,y[f++]=C,C=C>>8,y[f++]=C,C=C>>8,y[f++]=C;let W=Number(a>>BigInt(32)&BigInt(4294967295));return y[f++]=W,W=W>>8,y[f++]=W,W=W>>8,y[f++]=W,W=W>>8,y[f++]=W,f}function Ue(y,a,f,m,R){g(a,m,R,y,f,7);let C=Number(a&BigInt(4294967295));y[f+7]=C,C=C>>8,y[f+6]=C,C=C>>8,y[f+5]=C,C=C>>8,y[f+4]=C;let W=Number(a>>BigInt(32)&BigInt(4294967295));return y[f+3]=W,W=W>>8,y[f+2]=W,W=W>>8,y[f+1]=W,W=W>>8,y[f]=W,f+8}N.prototype.writeBigUInt64LE=It(function(a,f=0){return Xe(this,a,f,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeBigUInt64BE=It(function(a,f=0){return Ue(this,a,f,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeIntLE=function(a,f,m,R){if(a=+a,f=f>>>0,!R){const Re=Math.pow(2,8*m-1);Ne(this,a,f,m,Re-1,-Re)}let C=0,W=1,oe=0;for(this[f]=a&255;++C<m&&(W*=256);)a<0&&oe===0&&this[f+C-1]!==0&&(oe=1),this[f+C]=(a/W>>0)-oe&255;return f+m},N.prototype.writeIntBE=function(a,f,m,R){if(a=+a,f=f>>>0,!R){const Re=Math.pow(2,8*m-1);Ne(this,a,f,m,Re-1,-Re)}let C=m-1,W=1,oe=0;for(this[f+C]=a&255;--C>=0&&(W*=256);)a<0&&oe===0&&this[f+C+1]!==0&&(oe=1),this[f+C]=(a/W>>0)-oe&255;return f+m},N.prototype.writeInt8=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,1,127,-128),a<0&&(a=255+a+1),this[f]=a&255,f+1},N.prototype.writeInt16LE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,2,32767,-32768),this[f]=a&255,this[f+1]=a>>>8,f+2},N.prototype.writeInt16BE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,2,32767,-32768),this[f]=a>>>8,this[f+1]=a&255,f+2},N.prototype.writeInt32LE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,4,2147483647,-2147483648),this[f]=a&255,this[f+1]=a>>>8,this[f+2]=a>>>16,this[f+3]=a>>>24,f+4},N.prototype.writeInt32BE=function(a,f,m){return a=+a,f=f>>>0,m||Ne(this,a,f,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),this[f]=a>>>24,this[f+1]=a>>>16,this[f+2]=a>>>8,this[f+3]=a&255,f+4},N.prototype.writeBigInt64LE=It(function(a,f=0){return Xe(this,a,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),N.prototype.writeBigInt64BE=It(function(a,f=0){return Ue(this,a,f,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Je(y,a,f,m,R,C){if(f+m>y.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("Index out of range")}function Ze(y,a,f,m,R){return a=+a,f=f>>>0,R||Je(y,a,f,4),_.write(y,a,f,m,23,4),f+4}N.prototype.writeFloatLE=function(a,f,m){return Ze(this,a,f,!0,m)},N.prototype.writeFloatBE=function(a,f,m){return Ze(this,a,f,!1,m)};function Le(y,a,f,m,R){return a=+a,f=f>>>0,R||Je(y,a,f,8),_.write(y,a,f,m,52,8),f+8}N.prototype.writeDoubleLE=function(a,f,m){return Le(this,a,f,!0,m)},N.prototype.writeDoubleBE=function(a,f,m){return Le(this,a,f,!1,m)},N.prototype.copy=function(a,f,m,R){if(!N.isBuffer(a))throw new TypeError("argument should be a Buffer");if(m||(m=0),!R&&R!==0&&(R=this.length),f>=a.length&&(f=a.length),f||(f=0),R>0&&R<m&&(R=m),R===m||a.length===0||this.length===0)return 0;if(f<0)throw new RangeError("targetStart out of bounds");if(m<0||m>=this.length)throw new RangeError("Index out of range");if(R<0)throw new RangeError("sourceEnd out of bounds");R>this.length&&(R=this.length),a.length-f<R-m&&(R=a.length-f+m);const C=R-m;return this===a&&typeof U.prototype.copyWithin=="function"?this.copyWithin(f,m,R):U.prototype.set.call(a,this.subarray(m,R),f),C},N.prototype.fill=function(a,f,m,R){if(typeof a=="string"){if(typeof f=="string"?(R=f,f=0,m=this.length):typeof m=="string"&&(R=m,m=this.length),R!==void 0&&typeof R!="string")throw new TypeError("encoding must be a string");if(typeof R=="string"&&!N.isEncoding(R))throw new TypeError("Unknown encoding: "+R);if(a.length===1){const W=a.charCodeAt(0);(R==="utf8"&&W<128||R==="latin1")&&(a=W)}}else typeof a=="number"?a=a&255:typeof a=="boolean"&&(a=Number(a));if(f<0||this.length<f||this.length<m)throw new RangeError("Out of range index");if(m<=f)return this;f=f>>>0,m=m===void 0?this.length:m>>>0,a||(a=0);let C;if(typeof a=="number")for(C=f;C<m;++C)this[C]=a;else{const W=N.isBuffer(a)?a:N.from(a,R),oe=W.length;if(oe===0)throw new TypeError('The value "'+a+'" is invalid for argument "value"');for(C=0;C<m-f;++C)this[C+f]=W[C%oe]}return this};const Rt={};function p(y,a,f){Rt[y]=class extends f{constructor(){super(),Object.defineProperty(this,"message",{value:a.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${y}]`,this.stack,delete this.name}get code(){return y}set code(R){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:R,writable:!0})}toString(){return`${this.name} [${y}]: ${this.message}`}}}p("ERR_BUFFER_OUT_OF_BOUNDS",function(y){return y?`${y} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),p("ERR_INVALID_ARG_TYPE",function(y,a){return`The "${y}" argument must be of type number. Received type ${typeof a}`},TypeError),p("ERR_OUT_OF_RANGE",function(y,a,f){let m=`The value of "${y}" is out of range.`,R=f;return Number.isInteger(f)&&Math.abs(f)>2**32?R=o(String(f)):typeof f=="bigint"&&(R=String(f),(f>BigInt(2)**BigInt(32)||f<-(BigInt(2)**BigInt(32)))&&(R=o(R)),R+="n"),m+=` It must be ${a}. Received ${R}`,m},RangeError);function o(y){let a="",f=y.length;const m=y[0]==="-"?1:0;for(;f>=m+4;f-=3)a=`_${y.slice(f-3,f)}${a}`;return`${y.slice(0,f)}${a}`}function u(y,a,f){A(a,"offset"),(y[a]===void 0||y[a+f]===void 0)&&D(a,y.length-(f+1))}function g(y,a,f,m,R,C){if(y>f||y<a){const W=typeof a=="bigint"?"n":"";let oe;throw a===0||a===BigInt(0)?oe=`>= 0${W} and < 2${W} ** ${(C+1)*8}${W}`:oe=`>= -(2${W} ** ${(C+1)*8-1}${W}) and < 2 ** ${(C+1)*8-1}${W}`,new Rt.ERR_OUT_OF_RANGE("value",oe,y)}u(m,R,C)}function A(y,a){if(typeof y!="number")throw new Rt.ERR_INVALID_ARG_TYPE(a,"number",y)}function D(y,a,f){throw Math.floor(y)!==y?(A(y,f),new Rt.ERR_OUT_OF_RANGE("offset","an integer",y)):a<0?new Rt.ERR_BUFFER_OUT_OF_BOUNDS:new Rt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${a}`,y)}const H=/[^+/0-9A-Za-z-_]/g;function se(y){if(y=y.split("=")[0],y=y.trim().replace(H,""),y.length<2)return"";for(;y.length%4!==0;)y=y+"=";return y}function ge(y,a){a=a||1/0;let f;const m=y.length;let R=null;const C=[];for(let W=0;W<m;++W){if(f=y.charCodeAt(W),f>55295&&f<57344){if(!R){if(f>56319){(a-=3)>-1&&C.push(239,191,189);continue}else if(W+1===m){(a-=3)>-1&&C.push(239,191,189);continue}R=f;continue}if(f<56320){(a-=3)>-1&&C.push(239,191,189),R=f;continue}f=(R-55296<<10|f-56320)+65536}else R&&(a-=3)>-1&&C.push(239,191,189);if(R=null,f<128){if((a-=1)<0)break;C.push(f)}else if(f<2048){if((a-=2)<0)break;C.push(f>>6|192,f&63|128)}else if(f<65536){if((a-=3)<0)break;C.push(f>>12|224,f>>6&63|128,f&63|128)}else if(f<1114112){if((a-=4)<0)break;C.push(f>>18|240,f>>12&63|128,f>>6&63|128,f&63|128)}else throw new Error("Invalid code point")}return C}function me(y){const a=[];for(let f=0;f<y.length;++f)a.push(y.charCodeAt(f)&255);return a}function Se(y,a){let f,m,R;const C=[];for(let W=0;W<y.length&&!((a-=2)<0);++W)f=y.charCodeAt(W),m=f>>8,R=f%256,C.push(R),C.push(m);return C}function le(y){return F.toByteArray(se(y))}function $r(y,a,f,m){let R;for(R=0;R<m&&!(R+f>=a.length||R>=y.length);++R)a[R+f]=y[R];return R}function ut(y,a){return y instanceof a||y!=null&&y.constructor!=null&&y.constructor.name!=null&&y.constructor.name===a.name}function $n(y){return y!==y}const Cc=(function(){const y="0123456789abcdef",a=new Array(256);for(let f=0;f<16;++f){const m=f*16;for(let R=0;R<16;++R)a[m+R]=y[f]+y[R]}return a})();function It(y){return typeof BigInt>"u"?$c:y}function $c(){throw new Error("BigInt not supported")}})(e);const S=e.Buffer;t.Blob=e.Blob,t.BlobOptions=e.BlobOptions,t.Buffer=e.Buffer,t.File=e.File,t.FileOptions=e.FileOptions,t.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,t.SlowBuffer=e.SlowBuffer,t.TranscodeEncoding=e.TranscodeEncoding,t.atob=e.atob,t.btoa=e.btoa,t.constants=e.constants,t.default=S,t.isAscii=e.isAscii,t.isUtf8=e.isUtf8,t.kMaxLength=e.kMaxLength,t.kStringMaxLength=e.kStringMaxLength,t.resolveObjectURL=e.resolveObjectURL,t.transcode=e.transcode})(Gr)),Gr}const Yn=Yt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Jr,Qn;function ro(){if(Qn)return Jr;Qn=1;function t(B,j){var $=Object.keys(B);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(B);j&&(S=S.filter(function(x){return Object.getOwnPropertyDescriptor(B,x).enumerable})),$.push.apply($,S)}return $}function e(B){for(var j=1;j<arguments.length;j++){var $=arguments[j]!=null?arguments[j]:{};j%2?t(Object($),!0).forEach(function(S){r(B,S,$[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(B,Object.getOwnPropertyDescriptors($)):t(Object($)).forEach(function(S){Object.defineProperty(B,S,Object.getOwnPropertyDescriptor($,S))})}return B}function r(B,j,$){return j=c(j),j in B?Object.defineProperty(B,j,{value:$,enumerable:!0,configurable:!0,writable:!0}):B[j]=$,B}function n(B,j){if(!(B instanceof j))throw new TypeError("Cannot call a class as a function")}function s(B,j){for(var $=0;$<j.length;$++){var S=j[$];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(B,c(S.key),S)}}function i(B,j,$){return j&&s(B.prototype,j),Object.defineProperty(B,"prototype",{writable:!1}),B}function c(B){var j=l(B,"string");return typeof j=="symbol"?j:String(j)}function l(B,j){if(typeof B!="object"||B===null)return B;var $=B[Symbol.toPrimitive];if($!==void 0){var S=$.call(B,j);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(B)}var h=yr(),w=h.Buffer,d=Yn,I=d.inspect,T=I&&I.custom||"inspect";function L(B,j,$){w.prototype.copy.call(B,j,$)}return Jr=(function(){function B(){n(this,B),this.head=null,this.tail=null,this.length=0}return i(B,[{key:"push",value:function($){var S={data:$,next:null};this.length>0?this.tail.next=S:this.head=S,this.tail=S,++this.length}},{key:"unshift",value:function($){var S={data:$,next:this.head};this.length===0&&(this.tail=S),this.head=S,++this.length}},{key:"shift",value:function(){if(this.length!==0){var $=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,$}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function($){if(this.length===0)return"";for(var S=this.head,x=""+S.data;S=S.next;)x+=$+S.data;return x}},{key:"concat",value:function($){if(this.length===0)return w.alloc(0);for(var S=w.allocUnsafe($>>>0),x=this.head,F=0;x;)L(x.data,S,F),F+=x.data.length,x=x.next;return S}},{key:"consume",value:function($,S){var x;return $<this.head.data.length?(x=this.head.data.slice(0,$),this.head.data=this.head.data.slice($)):$===this.head.data.length?x=this.shift():x=S?this._getString($):this._getBuffer($),x}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function($){var S=this.head,x=1,F=S.data;for($-=F.length;S=S.next;){var _=S.data,v=$>_.length?_.length:$;if(v===_.length?F+=_:F+=_.slice(0,$),$-=v,$===0){v===_.length?(++x,S.next?this.head=S.next:this.head=this.tail=null):(this.head=S,S.data=_.slice(v));break}++x}return this.length-=x,F}},{key:"_getBuffer",value:function($){var S=w.allocUnsafe($),x=this.head,F=1;for(x.data.copy(S),$-=x.data.length;x=x.next;){var _=x.data,v=$>_.length?_.length:$;if(_.copy(S,S.length-$,0,v),$-=v,$===0){v===_.length?(++F,x.next?this.head=x.next:this.head=this.tail=null):(this.head=x,x.data=_.slice(v));break}++F}return this.length-=F,S}},{key:T,value:function($,S){return I(this,e(e({},S),{},{depth:0,customInspect:!1}))}}]),B})(),Jr}var zr,Xn;function Zn(){if(Xn)return zr;Xn=1;function t(c,l){var h=this,w=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return w||d?(l?l(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,pe.nextTick(s,this,c)):pe.nextTick(s,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(I){!l&&I?h._writableState?h._writableState.errorEmitted?pe.nextTick(r,h):(h._writableState.errorEmitted=!0,pe.nextTick(e,h,I)):pe.nextTick(e,h,I):l?(pe.nextTick(r,h),l(I)):pe.nextTick(r,h)}),this)}function e(c,l){s(c,l),r(c)}function r(c){c._writableState&&!c._writableState.emitClose||c._readableState&&!c._readableState.emitClose||c.emit("close")}function n(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(c,l){c.emit("error",l)}function i(c,l){var h=c._readableState,w=c._writableState;h&&h.autoDestroy||w&&w.autoDestroy?c.destroy(l):c.emit("error",l)}return zr={destroy:t,undestroy:n,errorOrDestroy:i},zr}var Vr={},ei;function Ot(){if(ei)return Vr;ei=1;function t(l,h){l.prototype=Object.create(h.prototype),l.prototype.constructor=l,l.__proto__=h}var e={};function r(l,h,w){w||(w=Error);function d(T,L,B){return typeof h=="string"?h:h(T,L,B)}var I=(function(T){t(L,T);function L(B,j,$){return T.call(this,d(B,j,$))||this}return L})(w);I.prototype.name=w.name,I.prototype.code=l,e[l]=I}function n(l,h){if(Array.isArray(l)){var w=l.length;return l=l.map(function(d){return String(d)}),w>2?"one of ".concat(h," ").concat(l.slice(0,w-1).join(", "),", or ")+l[w-1]:w===2?"one of ".concat(h," ").concat(l[0]," or ").concat(l[1]):"of ".concat(h," ").concat(l[0])}else return"of ".concat(h," ").concat(String(l))}function s(l,h,w){return l.substr(0,h.length)===h}function i(l,h,w){return(w===void 0||w>l.length)&&(w=l.length),l.substring(w-h.length,w)===h}function c(l,h,w){return typeof w!="number"&&(w=0),w+h.length>l.length?!1:l.indexOf(h,w)!==-1}return r("ERR_INVALID_OPT_VALUE",function(l,h){return'The value "'+h+'" is invalid for option "'+l+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(l,h,w){var d;typeof h=="string"&&s(h,"not ")?(d="must not be",h=h.replace(/^not /,"")):d="must be";var I;if(i(l," argument"))I="The ".concat(l," ").concat(d," ").concat(n(h,"type"));else{var T=c(l,".")?"property":"argument";I='The "'.concat(l,'" ').concat(T," ").concat(d," ").concat(n(h,"type"))}return I+=". Received type ".concat(typeof w),I},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(l){return"The "+l+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(l){return"Unknown encoding: "+l},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Vr.codes=e,Vr}var Yr,ti;function ri(){if(ti)return Yr;ti=1;var t=Ot().codes.ERR_INVALID_OPT_VALUE;function e(n,s,i){return n.highWaterMark!=null?n.highWaterMark:s?n[i]:null}function r(n,s,i,c){var l=e(s,c,i);if(l!=null){if(!(isFinite(l)&&Math.floor(l)===l)||l<0){var h=c?i:"highWaterMark";throw new t(h,l)}return Math.floor(l)}return n.objectMode?16:16*1024}return Yr={getHighWaterMark:r},Yr}var Qr,ni;function no(){if(ni)return Qr;ni=1,Qr=t;function t(r,n){if(e("noDeprecation"))return r;var s=!1;function i(){if(!s){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),s=!0}return r.apply(this,arguments)}return i}function e(r){try{if(!et.localStorage)return!1}catch{return!1}var n=et.localStorage[r];return n==null?!1:String(n).toLowerCase()==="true"}return Qr}var Xr,ii;function si(){if(ii)return Xr;ii=1,Xr=O;function t(P){var M=this;this.next=null,this.entry=null,this.finish=function(){Fe(M,P)}}var e;O.WritableState=k;var r={deprecate:no()},n=zn(),s=yr().Buffer,i=(typeof et<"u"?et:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(P){return s.from(P)}function l(P){return s.isBuffer(P)||P instanceof i}var h=Zn(),w=ri(),d=w.getHighWaterMark,I=Ot().codes,T=I.ERR_INVALID_ARG_TYPE,L=I.ERR_METHOD_NOT_IMPLEMENTED,B=I.ERR_MULTIPLE_CALLBACK,j=I.ERR_STREAM_CANNOT_PIPE,$=I.ERR_STREAM_DESTROYED,S=I.ERR_STREAM_NULL_VALUES,x=I.ERR_STREAM_WRITE_AFTER_END,F=I.ERR_UNKNOWN_ENCODING,_=h.errorOrDestroy;Pt()(O,n);function v(){}function k(P,M,J){e=e||Ct(),P=P||{},typeof J!="boolean"&&(J=M instanceof e),this.objectMode=!!P.objectMode,J&&(this.objectMode=this.objectMode||!!P.writableObjectMode),this.highWaterMark=d(this,P,"writableHighWaterMark",J),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Z=P.decodeStrings===!1;this.decodeStrings=!Z,this.defaultEncoding=P.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ie){ee(M,ie)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=P.emitClose!==!1,this.autoDestroy=!!P.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}k.prototype.getBuffer=function(){for(var M=this.bufferedRequest,J=[];M;)J.push(M),M=M.next;return J},(function(){try{Object.defineProperty(k.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var U;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(U=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(M){return U.call(this,M)?!0:this!==O?!1:M&&M._writableState instanceof k}})):U=function(M){return M instanceof this};function O(P){e=e||Ct();var M=this instanceof e;if(!M&&!U.call(O,this))return new O(P);this._writableState=new k(P,this,M),this.writable=!0,P&&(typeof P.write=="function"&&(this._write=P.write),typeof P.writev=="function"&&(this._writev=P.writev),typeof P.destroy=="function"&&(this._destroy=P.destroy),typeof P.final=="function"&&(this._final=P.final)),n.call(this)}O.prototype.pipe=function(){_(this,new j)};function q(P,M){var J=new x;_(P,J),pe.nextTick(M,J)}function G(P,M,J,Z){var ie;return J===null?ie=new S:typeof J!="string"&&!M.objectMode&&(ie=new T("chunk",["string","Buffer"],J)),ie?(_(P,ie),pe.nextTick(Z,ie),!1):!0}O.prototype.write=function(P,M,J){var Z=this._writableState,ie=!1,b=!Z.objectMode&&l(P);return b&&!s.isBuffer(P)&&(P=c(P)),typeof M=="function"&&(J=M,M=null),b?M="buffer":M||(M=Z.defaultEncoding),typeof J!="function"&&(J=v),Z.ending?q(this,J):(b||G(this,Z,P,J))&&(Z.pendingcb++,ie=N(this,Z,b,P,M,J)),ie},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var P=this._writableState;P.corked&&(P.corked--,!P.writing&&!P.corked&&!P.bufferProcessing&&P.bufferedRequest&&Ee(this,P))},O.prototype.setDefaultEncoding=function(M){if(typeof M=="string"&&(M=M.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((M+"").toLowerCase())>-1))throw new F(M);return this._writableState.defaultEncoding=M,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function V(P,M,J){return!P.objectMode&&P.decodeStrings!==!1&&typeof M=="string"&&(M=s.from(M,J)),M}Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function N(P,M,J,Z,ie,b){if(!J){var E=V(M,Z,ie);Z!==E&&(J=!0,ie="buffer",Z=E)}var K=M.objectMode?1:Z.length;M.length+=K;var Y=M.length<M.highWaterMark;if(Y||(M.needDrain=!0),M.writing||M.corked){var de=M.lastBufferedRequest;M.lastBufferedRequest={chunk:Z,encoding:ie,isBuf:J,callback:b,next:null},de?de.next=M.lastBufferedRequest:M.bufferedRequest=M.lastBufferedRequest,M.bufferedRequestCount+=1}else X(P,M,!1,K,Z,ie,b);return Y}function X(P,M,J,Z,ie,b,E){M.writelen=Z,M.writecb=E,M.writing=!0,M.sync=!0,M.destroyed?M.onwrite(new $("write")):J?P._writev(ie,M.onwrite):P._write(ie,b,M.onwrite),M.sync=!1}function fe(P,M,J,Z,ie){--M.pendingcb,J?(pe.nextTick(ie,Z),pe.nextTick(Qe,P,M),P._writableState.errorEmitted=!0,_(P,Z)):(ie(Z),P._writableState.errorEmitted=!0,_(P,Z),Qe(P,M))}function Q(P){P.writing=!1,P.writecb=null,P.length-=P.writelen,P.writelen=0}function ee(P,M){var J=P._writableState,Z=J.sync,ie=J.writecb;if(typeof ie!="function")throw new B;if(Q(J),M)fe(P,J,Z,M,ie);else{var b=Ce(J)||P.destroyed;!b&&!J.corked&&!J.bufferProcessing&&J.bufferedRequest&&Ee(P,J),Z?pe.nextTick(ue,P,J,b,ie):ue(P,J,b,ie)}}function ue(P,M,J,Z){J||we(P,M),M.pendingcb--,Z(),Qe(P,M)}function we(P,M){M.length===0&&M.needDrain&&(M.needDrain=!1,P.emit("drain"))}function Ee(P,M){M.bufferProcessing=!0;var J=M.bufferedRequest;if(P._writev&&J&&J.next){var Z=M.bufferedRequestCount,ie=new Array(Z),b=M.corkedRequestsFree;b.entry=J;for(var E=0,K=!0;J;)ie[E]=J,J.isBuf||(K=!1),J=J.next,E+=1;ie.allBuffers=K,X(P,M,!0,M.length,ie,"",b.finish),M.pendingcb++,M.lastBufferedRequest=null,b.next?(M.corkedRequestsFree=b.next,b.next=null):M.corkedRequestsFree=new t(M),M.bufferedRequestCount=0}else{for(;J;){var Y=J.chunk,de=J.encoding,te=J.callback,ce=M.objectMode?1:Y.length;if(X(P,M,!1,ce,Y,de,te),J=J.next,M.bufferedRequestCount--,M.writing)break}J===null&&(M.lastBufferedRequest=null)}M.bufferedRequest=J,M.bufferProcessing=!1}O.prototype._write=function(P,M,J){J(new L("_write()"))},O.prototype._writev=null,O.prototype.end=function(P,M,J){var Z=this._writableState;return typeof P=="function"?(J=P,P=null,M=null):typeof M=="function"&&(J=M,M=null),P!=null&&this.write(P,M),Z.corked&&(Z.corked=1,this.uncork()),Z.ending||be(this,Z,J),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Ce(P){return P.ending&&P.length===0&&P.bufferedRequest===null&&!P.finished&&!P.writing}function wt(P,M){P._final(function(J){M.pendingcb--,J&&_(P,J),M.prefinished=!0,P.emit("prefinish"),Qe(P,M)})}function at(P,M){!M.prefinished&&!M.finalCalled&&(typeof P._final=="function"&&!M.destroyed?(M.pendingcb++,M.finalCalled=!0,pe.nextTick(wt,P,M)):(M.prefinished=!0,P.emit("prefinish")))}function Qe(P,M){var J=Ce(M);if(J&&(at(P,M),M.pendingcb===0&&(M.finished=!0,P.emit("finish"),M.autoDestroy))){var Z=P._readableState;(!Z||Z.autoDestroy&&Z.endEmitted)&&P.destroy()}return J}function be(P,M,J){M.ending=!0,Qe(P,M),J&&(M.finished?pe.nextTick(J):P.once("finish",J)),M.ended=!0,P.writable=!1}function Fe(P,M,J){var Z=P.entry;for(P.entry=null;Z;){var ie=Z.callback;M.pendingcb--,ie(J),Z=Z.next}M.corkedRequestsFree.next=P}return Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(M){this._writableState&&(this._writableState.destroyed=M)}}),O.prototype.destroy=h.destroy,O.prototype._undestroy=h.undestroy,O.prototype._destroy=function(P,M){M(P)},Xr}var Zr,oi;function Ct(){if(oi)return Zr;oi=1;var t=Object.keys||function(w){var d=[];for(var I in w)d.push(I);return d};Zr=c;var e=pi(),r=si();Pt()(c,e);for(var n=t(r.prototype),s=0;s<n.length;s++){var i=n[s];c.prototype[i]||(c.prototype[i]=r.prototype[i])}function c(w){if(!(this instanceof c))return new c(w);e.call(this,w),r.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",l)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function l(){this._writableState.ended||pe.nextTick(h,this)}function h(w){w.end()}return Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),Zr}var en={},wr={exports:{}};var ai;function io(){return ai||(ai=1,(function(t,e){var r=yr(),n=r.Buffer;function s(c,l){for(var h in c)l[h]=c[h]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=i);function i(c,l,h){return n(c,l,h)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(c,l,h){if(typeof c=="number")throw new TypeError("Argument must not be a number");return n(c,l,h)},i.alloc=function(c,l,h){if(typeof c!="number")throw new TypeError("Argument must be a number");var w=n(c);return l!==void 0?typeof h=="string"?w.fill(l,h):w.fill(l):w.fill(0),w},i.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return n(c)},i.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(wr,wr.exports)),wr.exports}var ci;function ui(){if(ci)return en;ci=1;var t=io().Buffer,e=t.isEncoding||function(S){switch(S=""+S,S&&S.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(S){if(!S)return"utf8";for(var x;;)switch(S){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return S;default:if(x)return;S=(""+S).toLowerCase(),x=!0}}function n(S){var x=r(S);if(typeof x!="string"&&(t.isEncoding===e||!e(S)))throw new Error("Unknown encoding: "+S);return x||S}en.StringDecoder=s;function s(S){this.encoding=n(S);var x;switch(this.encoding){case"utf16le":this.text=I,this.end=T,x=4;break;case"utf8":this.fillLast=h,x=4;break;case"base64":this.text=L,this.end=B,x=3;break;default:this.write=j,this.end=$;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(x)}s.prototype.write=function(S){if(S.length===0)return"";var x,F;if(this.lastNeed){if(x=this.fillLast(S),x===void 0)return"";F=this.lastNeed,this.lastNeed=0}else F=0;return F<S.length?x?x+this.text(S,F):this.text(S,F):x||""},s.prototype.end=d,s.prototype.text=w,s.prototype.fillLast=function(S){if(this.lastNeed<=S.length)return S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,S.length),this.lastNeed-=S.length};function i(S){return S<=127?0:S>>5===6?2:S>>4===14?3:S>>3===30?4:S>>6===2?-1:-2}function c(S,x,F){var _=x.length-1;if(_<F)return 0;var v=i(x[_]);return v>=0?(v>0&&(S.lastNeed=v-1),v):--_<F||v===-2?0:(v=i(x[_]),v>=0?(v>0&&(S.lastNeed=v-2),v):--_<F||v===-2?0:(v=i(x[_]),v>=0?(v>0&&(v===2?v=0:S.lastNeed=v-3),v):0))}function l(S,x,F){if((x[0]&192)!==128)return S.lastNeed=0,"�";if(S.lastNeed>1&&x.length>1){if((x[1]&192)!==128)return S.lastNeed=1,"�";if(S.lastNeed>2&&x.length>2&&(x[2]&192)!==128)return S.lastNeed=2,"�"}}function h(S){var x=this.lastTotal-this.lastNeed,F=l(this,S);if(F!==void 0)return F;if(this.lastNeed<=S.length)return S.copy(this.lastChar,x,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);S.copy(this.lastChar,x,0,S.length),this.lastNeed-=S.length}function w(S,x){var F=c(this,S,x);if(!this.lastNeed)return S.toString("utf8",x);this.lastTotal=F;var _=S.length-(F-this.lastNeed);return S.copy(this.lastChar,0,_),S.toString("utf8",x,_)}function d(S){var x=S&&S.length?this.write(S):"";return this.lastNeed?x+"�":x}function I(S,x){if((S.length-x)%2===0){var F=S.toString("utf16le",x);if(F){var _=F.charCodeAt(F.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1],F.slice(0,-1)}return F}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=S[S.length-1],S.toString("utf16le",x,S.length-1)}function T(S){var x=S&&S.length?this.write(S):"";if(this.lastNeed){var F=this.lastTotal-this.lastNeed;return x+this.lastChar.toString("utf16le",0,F)}return x}function L(S,x){var F=(S.length-x)%3;return F===0?S.toString("base64",x):(this.lastNeed=3-F,this.lastTotal=3,F===1?this.lastChar[0]=S[S.length-1]:(this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1]),S.toString("base64",x,S.length-F))}function B(S){var x=S&&S.length?this.write(S):"";return this.lastNeed?x+this.lastChar.toString("base64",0,3-this.lastNeed):x}function j(S){return S.toString(this.encoding)}function $(S){return S&&S.length?this.write(S):""}return en}var tn,fi;function rn(){if(fi)return tn;fi=1;var t=Ot().codes.ERR_STREAM_PREMATURE_CLOSE;function e(i){var c=!1;return function(){if(!c){c=!0;for(var l=arguments.length,h=new Array(l),w=0;w<l;w++)h[w]=arguments[w];i.apply(this,h)}}}function r(){}function n(i){return i.setHeader&&typeof i.abort=="function"}function s(i,c,l){if(typeof c=="function")return s(i,null,c);c||(c={}),l=e(l||r);var h=c.readable||c.readable!==!1&&i.readable,w=c.writable||c.writable!==!1&&i.writable,d=function(){i.writable||T()},I=i._writableState&&i._writableState.finished,T=function(){w=!1,I=!0,h||l.call(i)},L=i._readableState&&i._readableState.endEmitted,B=function(){h=!1,L=!0,w||l.call(i)},j=function(F){l.call(i,F)},$=function(){var F;if(h&&!L)return(!i._readableState||!i._readableState.ended)&&(F=new t),l.call(i,F);if(w&&!I)return(!i._writableState||!i._writableState.ended)&&(F=new t),l.call(i,F)},S=function(){i.req.on("finish",T)};return n(i)?(i.on("complete",T),i.on("abort",$),i.req?S():i.on("request",S)):w&&!i._writableState&&(i.on("end",d),i.on("close",d)),i.on("end",B),i.on("finish",T),c.error!==!1&&i.on("error",j),i.on("close",$),function(){i.removeListener("complete",T),i.removeListener("abort",$),i.removeListener("request",S),i.req&&i.req.removeListener("finish",T),i.removeListener("end",d),i.removeListener("close",d),i.removeListener("finish",T),i.removeListener("end",B),i.removeListener("error",j),i.removeListener("close",$)}}return tn=s,tn}var nn,li;function so(){if(li)return nn;li=1;var t;function e(F,_,v){return _=r(_),_ in F?Object.defineProperty(F,_,{value:v,enumerable:!0,configurable:!0,writable:!0}):F[_]=v,F}function r(F){var _=n(F,"string");return typeof _=="symbol"?_:String(_)}function n(F,_){if(typeof F!="object"||F===null)return F;var v=F[Symbol.toPrimitive];if(v!==void 0){var k=v.call(F,_);if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(F)}var s=rn(),i=Symbol("lastResolve"),c=Symbol("lastReject"),l=Symbol("error"),h=Symbol("ended"),w=Symbol("lastPromise"),d=Symbol("handlePromise"),I=Symbol("stream");function T(F,_){return{value:F,done:_}}function L(F){var _=F[i];if(_!==null){var v=F[I].read();v!==null&&(F[w]=null,F[i]=null,F[c]=null,_(T(v,!1)))}}function B(F){pe.nextTick(L,F)}function j(F,_){return function(v,k){F.then(function(){if(_[h]){v(T(void 0,!0));return}_[d](v,k)},k)}}var $=Object.getPrototypeOf(function(){}),S=Object.setPrototypeOf((t={get stream(){return this[I]},next:function(){var _=this,v=this[l];if(v!==null)return Promise.reject(v);if(this[h])return Promise.resolve(T(void 0,!0));if(this[I].destroyed)return new Promise(function(q,G){pe.nextTick(function(){_[l]?G(_[l]):q(T(void 0,!0))})});var k=this[w],U;if(k)U=new Promise(j(k,this));else{var O=this[I].read();if(O!==null)return Promise.resolve(T(O,!1));U=new Promise(this[d])}return this[w]=U,U}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var _=this;return new Promise(function(v,k){_[I].destroy(null,function(U){if(U){k(U);return}v(T(void 0,!0))})})}),t),$),x=function(_){var v,k=Object.create(S,(v={},e(v,I,{value:_,writable:!0}),e(v,i,{value:null,writable:!0}),e(v,c,{value:null,writable:!0}),e(v,l,{value:null,writable:!0}),e(v,h,{value:_._readableState.endEmitted,writable:!0}),e(v,d,{value:function(O,q){var G=k[I].read();G?(k[w]=null,k[i]=null,k[c]=null,O(T(G,!1))):(k[i]=O,k[c]=q)},writable:!0}),v));return k[w]=null,s(_,function(U){if(U&&U.code!=="ERR_STREAM_PREMATURE_CLOSE"){var O=k[c];O!==null&&(k[w]=null,k[i]=null,k[c]=null,O(U)),k[l]=U;return}var q=k[i];q!==null&&(k[w]=null,k[i]=null,k[c]=null,q(T(void 0,!0))),k[h]=!0}),_.on("readable",B.bind(null,k)),k};return nn=x,nn}var sn,hi;function oo(){return hi||(hi=1,sn=function(){throw new Error("Readable.from is not available in the browser")}),sn}var on,di;function pi(){if(di)return on;di=1,on=q;var t;q.ReadableState=O,hr().EventEmitter;var e=function(E,K){return E.listeners(K).length},r=zn(),n=yr().Buffer,s=(typeof et<"u"?et:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function i(b){return n.from(b)}function c(b){return n.isBuffer(b)||b instanceof s}var l=Yn,h;l&&l.debuglog?h=l.debuglog("stream"):h=function(){};var w=ro(),d=Zn(),I=ri(),T=I.getHighWaterMark,L=Ot().codes,B=L.ERR_INVALID_ARG_TYPE,j=L.ERR_STREAM_PUSH_AFTER_EOF,$=L.ERR_METHOD_NOT_IMPLEMENTED,S=L.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,x,F,_;Pt()(q,r);var v=d.errorOrDestroy,k=["error","close","destroy","pause","resume"];function U(b,E,K){if(typeof b.prependListener=="function")return b.prependListener(E,K);!b._events||!b._events[E]?b.on(E,K):Array.isArray(b._events[E])?b._events[E].unshift(K):b._events[E]=[K,b._events[E]]}function O(b,E,K){t=t||Ct(),b=b||{},typeof K!="boolean"&&(K=E instanceof t),this.objectMode=!!b.objectMode,K&&(this.objectMode=this.objectMode||!!b.readableObjectMode),this.highWaterMark=T(this,b,"readableHighWaterMark",K),this.buffer=new w,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=b.emitClose!==!1,this.autoDestroy=!!b.autoDestroy,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(x||(x=ui().StringDecoder),this.decoder=new x(b.encoding),this.encoding=b.encoding)}function q(b){if(t=t||Ct(),!(this instanceof q))return new q(b);var E=this instanceof t;this._readableState=new O(b,this,E),this.readable=!0,b&&(typeof b.read=="function"&&(this._read=b.read),typeof b.destroy=="function"&&(this._destroy=b.destroy)),r.call(this)}Object.defineProperty(q.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(E){this._readableState&&(this._readableState.destroyed=E)}}),q.prototype.destroy=d.destroy,q.prototype._undestroy=d.undestroy,q.prototype._destroy=function(b,E){E(b)},q.prototype.push=function(b,E){var K=this._readableState,Y;return K.objectMode?Y=!0:typeof b=="string"&&(E=E||K.defaultEncoding,E!==K.encoding&&(b=n.from(b,E),E=""),Y=!0),G(this,b,E,!1,Y)},q.prototype.unshift=function(b){return G(this,b,null,!0,!1)};function G(b,E,K,Y,de){h("readableAddChunk",E);var te=b._readableState;if(E===null)te.reading=!1,ee(b,te);else{var ce;if(de||(ce=N(te,E)),ce)v(b,ce);else if(te.objectMode||E&&E.length>0)if(typeof E!="string"&&!te.objectMode&&Object.getPrototypeOf(E)!==n.prototype&&(E=i(E)),Y)te.endEmitted?v(b,new S):V(b,te,E,!0);else if(te.ended)v(b,new j);else{if(te.destroyed)return!1;te.reading=!1,te.decoder&&!K?(E=te.decoder.write(E),te.objectMode||E.length!==0?V(b,te,E,!1):Ee(b,te)):V(b,te,E,!1)}else Y||(te.reading=!1,Ee(b,te))}return!te.ended&&(te.length<te.highWaterMark||te.length===0)}function V(b,E,K,Y){E.flowing&&E.length===0&&!E.sync?(E.awaitDrain=0,b.emit("data",K)):(E.length+=E.objectMode?1:K.length,Y?E.buffer.unshift(K):E.buffer.push(K),E.needReadable&&ue(b)),Ee(b,E)}function N(b,E){var K;return!c(E)&&typeof E!="string"&&E!==void 0&&!b.objectMode&&(K=new B("chunk",["string","Buffer","Uint8Array"],E)),K}q.prototype.isPaused=function(){return this._readableState.flowing===!1},q.prototype.setEncoding=function(b){x||(x=ui().StringDecoder);var E=new x(b);this._readableState.decoder=E,this._readableState.encoding=this._readableState.decoder.encoding;for(var K=this._readableState.buffer.head,Y="";K!==null;)Y+=E.write(K.data),K=K.next;return this._readableState.buffer.clear(),Y!==""&&this._readableState.buffer.push(Y),this._readableState.length=Y.length,this};var X=1073741824;function fe(b){return b>=X?b=X:(b--,b|=b>>>1,b|=b>>>2,b|=b>>>4,b|=b>>>8,b|=b>>>16,b++),b}function Q(b,E){return b<=0||E.length===0&&E.ended?0:E.objectMode?1:b!==b?E.flowing&&E.length?E.buffer.head.data.length:E.length:(b>E.highWaterMark&&(E.highWaterMark=fe(b)),b<=E.length?b:E.ended?E.length:(E.needReadable=!0,0))}q.prototype.read=function(b){h("read",b),b=parseInt(b,10);var E=this._readableState,K=b;if(b!==0&&(E.emittedReadable=!1),b===0&&E.needReadable&&((E.highWaterMark!==0?E.length>=E.highWaterMark:E.length>0)||E.ended))return h("read: emitReadable",E.length,E.ended),E.length===0&&E.ended?J(this):ue(this),null;if(b=Q(b,E),b===0&&E.ended)return E.length===0&&J(this),null;var Y=E.needReadable;h("need readable",Y),(E.length===0||E.length-b<E.highWaterMark)&&(Y=!0,h("length less than watermark",Y)),E.ended||E.reading?(Y=!1,h("reading or ended",Y)):Y&&(h("do read"),E.reading=!0,E.sync=!0,E.length===0&&(E.needReadable=!0),this._read(E.highWaterMark),E.sync=!1,E.reading||(b=Q(K,E)));var de;return b>0?de=M(b,E):de=null,de===null?(E.needReadable=E.length<=E.highWaterMark,b=0):(E.length-=b,E.awaitDrain=0),E.length===0&&(E.ended||(E.needReadable=!0),K!==b&&E.ended&&J(this)),de!==null&&this.emit("data",de),de};function ee(b,E){if(h("onEofChunk"),!E.ended){if(E.decoder){var K=E.decoder.end();K&&K.length&&(E.buffer.push(K),E.length+=E.objectMode?1:K.length)}E.ended=!0,E.sync?ue(b):(E.needReadable=!1,E.emittedReadable||(E.emittedReadable=!0,we(b)))}}function ue(b){var E=b._readableState;h("emitReadable",E.needReadable,E.emittedReadable),E.needReadable=!1,E.emittedReadable||(h("emitReadable",E.flowing),E.emittedReadable=!0,pe.nextTick(we,b))}function we(b){var E=b._readableState;h("emitReadable_",E.destroyed,E.length,E.ended),!E.destroyed&&(E.length||E.ended)&&(b.emit("readable"),E.emittedReadable=!1),E.needReadable=!E.flowing&&!E.ended&&E.length<=E.highWaterMark,P(b)}function Ee(b,E){E.readingMore||(E.readingMore=!0,pe.nextTick(Ce,b,E))}function Ce(b,E){for(;!E.reading&&!E.ended&&(E.length<E.highWaterMark||E.flowing&&E.length===0);){var K=E.length;if(h("maybeReadMore read 0"),b.read(0),K===E.length)break}E.readingMore=!1}q.prototype._read=function(b){v(this,new $("_read()"))},q.prototype.pipe=function(b,E){var K=this,Y=this._readableState;switch(Y.pipesCount){case 0:Y.pipes=b;break;case 1:Y.pipes=[Y.pipes,b];break;default:Y.pipes.push(b);break}Y.pipesCount+=1,h("pipe count=%d opts=%j",Y.pipesCount,E);var de=(!E||E.end!==!1)&&b!==pe.stdout&&b!==pe.stderr,te=de?ct:Je;Y.endEmitted?pe.nextTick(te):K.once("end",te),b.on("unpipe",ce);function ce(Ze,Le){h("onunpipe"),Ze===K&&Le&&Le.hasUnpiped===!1&&(Le.hasUnpiped=!0,fr())}function ct(){h("onend"),b.end()}var xt=wt(K);b.on("drain",xt);var At=!1;function fr(){h("cleanup"),b.removeListener("close",Xe),b.removeListener("finish",Ue),b.removeListener("drain",xt),b.removeListener("error",Ne),b.removeListener("unpipe",ce),K.removeListener("end",ct),K.removeListener("end",Je),K.removeListener("data",Te),At=!0,Y.awaitDrain&&(!b._writableState||b._writableState.needDrain)&&xt()}K.on("data",Te);function Te(Ze){h("ondata");var Le=b.write(Ze);h("dest.write",Le),Le===!1&&((Y.pipesCount===1&&Y.pipes===b||Y.pipesCount>1&&ie(Y.pipes,b)!==-1)&&!At&&(h("false write response, pause",Y.awaitDrain),Y.awaitDrain++),K.pause())}function Ne(Ze){h("onerror",Ze),Je(),b.removeListener("error",Ne),e(b,"error")===0&&v(b,Ze)}U(b,"error",Ne);function Xe(){b.removeListener("finish",Ue),Je()}b.once("close",Xe);function Ue(){h("onfinish"),b.removeListener("close",Xe),Je()}b.once("finish",Ue);function Je(){h("unpipe"),K.unpipe(b)}return b.emit("pipe",K),Y.flowing||(h("pipe resume"),K.resume()),b};function wt(b){return function(){var K=b._readableState;h("pipeOnDrain",K.awaitDrain),K.awaitDrain&&K.awaitDrain--,K.awaitDrain===0&&e(b,"data")&&(K.flowing=!0,P(b))}}q.prototype.unpipe=function(b){var E=this._readableState,K={hasUnpiped:!1};if(E.pipesCount===0)return this;if(E.pipesCount===1)return b&&b!==E.pipes?this:(b||(b=E.pipes),E.pipes=null,E.pipesCount=0,E.flowing=!1,b&&b.emit("unpipe",this,K),this);if(!b){var Y=E.pipes,de=E.pipesCount;E.pipes=null,E.pipesCount=0,E.flowing=!1;for(var te=0;te<de;te++)Y[te].emit("unpipe",this,{hasUnpiped:!1});return this}var ce=ie(E.pipes,b);return ce===-1?this:(E.pipes.splice(ce,1),E.pipesCount-=1,E.pipesCount===1&&(E.pipes=E.pipes[0]),b.emit("unpipe",this,K),this)},q.prototype.on=function(b,E){var K=r.prototype.on.call(this,b,E),Y=this._readableState;return b==="data"?(Y.readableListening=this.listenerCount("readable")>0,Y.flowing!==!1&&this.resume()):b==="readable"&&!Y.endEmitted&&!Y.readableListening&&(Y.readableListening=Y.needReadable=!0,Y.flowing=!1,Y.emittedReadable=!1,h("on readable",Y.length,Y.reading),Y.length?ue(this):Y.reading||pe.nextTick(Qe,this)),K},q.prototype.addListener=q.prototype.on,q.prototype.removeListener=function(b,E){var K=r.prototype.removeListener.call(this,b,E);return b==="readable"&&pe.nextTick(at,this),K},q.prototype.removeAllListeners=function(b){var E=r.prototype.removeAllListeners.apply(this,arguments);return(b==="readable"||b===void 0)&&pe.nextTick(at,this),E};function at(b){var E=b._readableState;E.readableListening=b.listenerCount("readable")>0,E.resumeScheduled&&!E.paused?E.flowing=!0:b.listenerCount("data")>0&&b.resume()}function Qe(b){h("readable nexttick read 0"),b.read(0)}q.prototype.resume=function(){var b=this._readableState;return b.flowing||(h("resume"),b.flowing=!b.readableListening,be(this,b)),b.paused=!1,this};function be(b,E){E.resumeScheduled||(E.resumeScheduled=!0,pe.nextTick(Fe,b,E))}function Fe(b,E){h("resume",E.reading),E.reading||b.read(0),E.resumeScheduled=!1,b.emit("resume"),P(b),E.flowing&&!E.reading&&b.read(0)}q.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function P(b){var E=b._readableState;for(h("flow",E.flowing);E.flowing&&b.read()!==null;);}q.prototype.wrap=function(b){var E=this,K=this._readableState,Y=!1;b.on("end",function(){if(h("wrapped end"),K.decoder&&!K.ended){var ce=K.decoder.end();ce&&ce.length&&E.push(ce)}E.push(null)}),b.on("data",function(ce){if(h("wrapped data"),K.decoder&&(ce=K.decoder.write(ce)),!(K.objectMode&&ce==null)&&!(!K.objectMode&&(!ce||!ce.length))){var ct=E.push(ce);ct||(Y=!0,b.pause())}});for(var de in b)this[de]===void 0&&typeof b[de]=="function"&&(this[de]=(function(ct){return function(){return b[ct].apply(b,arguments)}})(de));for(var te=0;te<k.length;te++)b.on(k[te],this.emit.bind(this,k[te]));return this._read=function(ce){h("wrapped _read",ce),Y&&(Y=!1,b.resume())},this},typeof Symbol=="function"&&(q.prototype[Symbol.asyncIterator]=function(){return F===void 0&&(F=so()),F(this)}),Object.defineProperty(q.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(q.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(q.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(E){this._readableState&&(this._readableState.flowing=E)}}),q._fromList=M,Object.defineProperty(q.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function M(b,E){if(E.length===0)return null;var K;return E.objectMode?K=E.buffer.shift():!b||b>=E.length?(E.decoder?K=E.buffer.join(""):E.buffer.length===1?K=E.buffer.first():K=E.buffer.concat(E.length),E.buffer.clear()):K=E.buffer.consume(b,E.decoder),K}function J(b){var E=b._readableState;h("endReadable",E.endEmitted),E.endEmitted||(E.ended=!0,pe.nextTick(Z,E,b))}function Z(b,E){if(h("endReadableNT",b.endEmitted,b.length),!b.endEmitted&&b.length===0&&(b.endEmitted=!0,E.readable=!1,E.emit("end"),b.autoDestroy)){var K=E._writableState;(!K||K.autoDestroy&&K.finished)&&E.destroy()}}typeof Symbol=="function"&&(q.from=function(b,E){return _===void 0&&(_=oo()),_(q,b,E)});function ie(b,E){for(var K=0,Y=b.length;K<Y;K++)if(b[K]===E)return K;return-1}return on}var an,yi;function wi(){if(yi)return an;yi=1,an=l;var t=Ot().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,n=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=t.ERR_TRANSFORM_WITH_LENGTH_0,i=Ct();Pt()(l,i);function c(d,I){var T=this._transformState;T.transforming=!1;var L=T.writecb;if(L===null)return this.emit("error",new r);T.writechunk=null,T.writecb=null,I!=null&&this.push(I),L(d);var B=this._readableState;B.reading=!1,(B.needReadable||B.length<B.highWaterMark)&&this._read(B.highWaterMark)}function l(d){if(!(this instanceof l))return new l(d);i.call(this,d),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",h)}function h(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(I,T){w(d,I,T)}):w(this,null,null)}l.prototype.push=function(d,I){return this._transformState.needTransform=!1,i.prototype.push.call(this,d,I)},l.prototype._transform=function(d,I,T){T(new e("_transform()"))},l.prototype._write=function(d,I,T){var L=this._transformState;if(L.writecb=T,L.writechunk=d,L.writeencoding=I,!L.transforming){var B=this._readableState;(L.needTransform||B.needReadable||B.length<B.highWaterMark)&&this._read(B.highWaterMark)}},l.prototype._read=function(d){var I=this._transformState;I.writechunk!==null&&!I.transforming?(I.transforming=!0,this._transform(I.writechunk,I.writeencoding,I.afterTransform)):I.needTransform=!0},l.prototype._destroy=function(d,I){i.prototype._destroy.call(this,d,function(T){I(T)})};function w(d,I,T){if(I)return d.emit("error",I);if(T!=null&&d.push(T),d._writableState.length)throw new s;if(d._transformState.transforming)throw new n;return d.push(null)}return an}var cn,gi;function ao(){if(gi)return cn;gi=1,cn=e;var t=wi();Pt()(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,n,s){s(null,r)},cn}var un,mi;function co(){if(mi)return un;mi=1;var t;function e(T){var L=!1;return function(){L||(L=!0,T.apply(void 0,arguments))}}var r=Ot().codes,n=r.ERR_MISSING_ARGS,s=r.ERR_STREAM_DESTROYED;function i(T){if(T)throw T}function c(T){return T.setHeader&&typeof T.abort=="function"}function l(T,L,B,j){j=e(j);var $=!1;T.on("close",function(){$=!0}),t===void 0&&(t=rn()),t(T,{readable:L,writable:B},function(x){if(x)return j(x);$=!0,j()});var S=!1;return function(x){if(!$&&!S){if(S=!0,c(T))return T.abort();if(typeof T.destroy=="function")return T.destroy();j(x||new s("pipe"))}}}function h(T){T()}function w(T,L){return T.pipe(L)}function d(T){return!T.length||typeof T[T.length-1]!="function"?i:T.pop()}function I(){for(var T=arguments.length,L=new Array(T),B=0;B<T;B++)L[B]=arguments[B];var j=d(L);if(Array.isArray(L[0])&&(L=L[0]),L.length<2)throw new n("streams");var $,S=L.map(function(x,F){var _=F<L.length-1,v=F>0;return l(x,_,v,function(k){$||($=k),k&&S.forEach(h),!_&&(S.forEach(h),j($))})});return L.reduce(w)}return un=I,un}var fn,bi;function uo(){if(bi)return fn;bi=1,fn=r;var t=hr().EventEmitter,e=Pt();e(r,t),r.Readable=pi(),r.Writable=si(),r.Duplex=Ct(),r.Transform=wi(),r.PassThrough=ao(),r.finished=rn(),r.pipeline=co(),r.Stream=r;function r(){t.call(this)}return r.prototype.pipe=function(n,s){var i=this;function c(L){n.writable&&n.write(L)===!1&&i.pause&&i.pause()}i.on("data",c);function l(){i.readable&&i.resume&&i.resume()}n.on("drain",l),!n._isStdio&&(!s||s.end!==!1)&&(i.on("end",w),i.on("close",d));var h=!1;function w(){h||(h=!0,n.end())}function d(){h||(h=!0,typeof n.destroy=="function"&&n.destroy())}function I(L){if(T(),t.listenerCount(this,"error")===0)throw L}i.on("error",I),n.on("error",I);function T(){i.removeListener("data",c),n.removeListener("drain",l),i.removeListener("end",w),i.removeListener("close",d),i.removeListener("error",I),n.removeListener("error",I),i.removeListener("end",T),i.removeListener("close",T),n.removeListener("close",T)}return i.on("end",T),i.on("close",T),n.on("close",T),n.emit("pipe",i),n},fn}var ht=uo();const fo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let gt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=fo[r[t]&63];return e};var ln={},gr={};gr.byteLength=po,gr.toByteArray=wo,gr.fromByteArray=bo;for(var nt=[],je=[],lo=typeof Uint8Array<"u"?Uint8Array:Array,hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",$t=0,ho=hn.length;$t<ho;++$t)nt[$t]=hn[$t],je[hn.charCodeAt($t)]=$t;je[45]=62,je[95]=63;function Ei(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function po(t){var e=Ei(t),r=e[0],n=e[1];return(r+n)*3/4-n}function yo(t,e,r){return(e+r)*3/4-r}function wo(t){var e,r=Ei(t),n=r[0],s=r[1],i=new lo(yo(t,n,s)),c=0,l=s>0?n-4:n,h;for(h=0;h<l;h+=4)e=je[t.charCodeAt(h)]<<18|je[t.charCodeAt(h+1)]<<12|je[t.charCodeAt(h+2)]<<6|je[t.charCodeAt(h+3)],i[c++]=e>>16&255,i[c++]=e>>8&255,i[c++]=e&255;return s===2&&(e=je[t.charCodeAt(h)]<<2|je[t.charCodeAt(h+1)]>>4,i[c++]=e&255),s===1&&(e=je[t.charCodeAt(h)]<<10|je[t.charCodeAt(h+1)]<<4|je[t.charCodeAt(h+2)]>>2,i[c++]=e>>8&255,i[c++]=e&255),i}function go(t){return nt[t>>18&63]+nt[t>>12&63]+nt[t>>6&63]+nt[t&63]}function mo(t,e,r){for(var n,s=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),s.push(go(n));return s.join("")}function bo(t){for(var e,r=t.length,n=r%3,s=[],i=16383,c=0,l=r-n;c<l;c+=i)s.push(mo(t,c,c+i>l?l:c+i));return n===1?(e=t[r-1],s.push(nt[e>>2]+nt[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],s.push(nt[e>>10]+nt[e>>4&63]+nt[e<<2&63]+"=")),s.join("")}var dn={};dn.read=function(t,e,r,n,s){var i,c,l=s*8-n-1,h=(1<<l)-1,w=h>>1,d=-7,I=r?s-1:0,T=r?-1:1,L=t[e+I];for(I+=T,i=L&(1<<-d)-1,L>>=-d,d+=l;d>0;i=i*256+t[e+I],I+=T,d-=8);for(c=i&(1<<-d)-1,i>>=-d,d+=n;d>0;c=c*256+t[e+I],I+=T,d-=8);if(i===0)i=1-w;else{if(i===h)return c?NaN:(L?-1:1)*(1/0);c=c+Math.pow(2,n),i=i-w}return(L?-1:1)*c*Math.pow(2,i-n)},dn.write=function(t,e,r,n,s,i){var c,l,h,w=i*8-s-1,d=(1<<w)-1,I=d>>1,T=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,L=n?0:i-1,B=n?1:-1,j=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,c=d):(c=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-c))<1&&(c--,h*=2),c+I>=1?e+=T/h:e+=T*Math.pow(2,1-I),e*h>=2&&(c++,h/=2),c+I>=d?(l=0,c=d):c+I>=1?(l=(e*h-1)*Math.pow(2,s),c=c+I):(l=e*Math.pow(2,I-1)*Math.pow(2,s),c=0));s>=8;t[r+L]=l&255,L+=B,l/=256,s-=8);for(c=c<<s|l,w+=s;w>0;t[r+L]=c&255,L+=B,c/=256,w-=8);t[r+L-B]|=j*128};(function(t){const e=gr,r=dn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:i,ArrayBuffer:c,SharedArrayBuffer:l}=globalThis;d.TYPED_ARRAY_SUPPORT=h(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function h(){try{const p=new i(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,i.prototype),Object.setPrototypeOf(p,o),p.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function w(p){if(p>s)throw new RangeError('The value "'+p+'" is invalid for option "size"');const o=new i(p);return Object.setPrototypeOf(o,d.prototype),o}function d(p,o,u){if(typeof p=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(p)}return I(p,o,u)}d.poolSize=8192;function I(p,o,u){if(typeof p=="string")return j(p,o);if(c.isView(p))return S(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(Ue(p,c)||p&&Ue(p.buffer,c)||typeof l<"u"&&(Ue(p,l)||p&&Ue(p.buffer,l)))return x(p,o,u);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=p.valueOf&&p.valueOf();if(g!=null&&g!==p)return d.from(g,o,u);const A=F(p);if(A)return A;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return d.from(p[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}d.from=function(p,o,u){return I(p,o,u)},Object.setPrototypeOf(d.prototype,i.prototype),Object.setPrototypeOf(d,i);function T(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function L(p,o,u){return T(p),p<=0?w(p):o!==void 0?typeof u=="string"?w(p).fill(o,u):w(p).fill(o):w(p)}d.alloc=function(p,o,u){return L(p,o,u)};function B(p){return T(p),w(p<0?0:_(p)|0)}d.allocUnsafe=function(p){return B(p)},d.allocUnsafeSlow=function(p){return B(p)};function j(p,o){if((typeof o!="string"||o==="")&&(o="utf8"),!d.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=k(p,o)|0;let g=w(u);const A=g.write(p,o);return A!==u&&(g=g.slice(0,A)),g}function $(p){const o=p.length<0?0:_(p.length)|0,u=w(o);for(let g=0;g<o;g+=1)u[g]=p[g]&255;return u}function S(p){if(Ue(p,i)){const o=new i(p);return x(o.buffer,o.byteOffset,o.byteLength)}return $(p)}function x(p,o,u){if(o<0||p.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let g;return o===void 0&&u===void 0?g=new i(p):u===void 0?g=new i(p,o):g=new i(p,o,u),Object.setPrototypeOf(g,d.prototype),g}function F(p){if(d.isBuffer(p)){const o=_(p.length)|0,u=w(o);return u.length===0||p.copy(u,0,0,o),u}if(p.length!==void 0)return typeof p.length!="number"||Je(p.length)?w(0):$(p);if(p.type==="Buffer"&&Array.isArray(p.data))return $(p.data)}function _(p){if(p>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return p|0}function v(p){return+p!=p&&(p=0),d.alloc(+p)}d.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==d.prototype},d.compare=function(o,u){if(Ue(o,i)&&(o=d.from(o,o.offset,o.byteLength)),Ue(u,i)&&(u=d.from(u,u.offset,u.byteLength)),!d.isBuffer(o)||!d.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let g=o.length,A=u.length;for(let D=0,H=Math.min(g,A);D<H;++D)if(o[D]!==u[D]){g=o[D],A=u[D];break}return g<A?-1:A<g?1:0},d.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return d.alloc(0);let g;if(u===void 0)for(u=0,g=0;g<o.length;++g)u+=o[g].length;const A=d.allocUnsafe(u);let D=0;for(g=0;g<o.length;++g){let H=o[g];if(Ue(H,i))D+H.length>A.length?(d.isBuffer(H)||(H=d.from(H)),H.copy(A,D)):i.prototype.set.call(A,H,D);else if(d.isBuffer(H))H.copy(A,D);else throw new TypeError('"list" argument must be an Array of Buffers');D+=H.length}return A};function k(p,o){if(d.isBuffer(p))return p.length;if(c.isView(p)||Ue(p,c))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const u=p.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&u===0)return 0;let A=!1;for(;;)switch(o){case"ascii":case"latin1":case"binary":return u;case"utf8":case"utf-8":return At(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u*2;case"hex":return u>>>1;case"base64":return Ne(p).length;default:if(A)return g?-1:At(p).length;o=(""+o).toLowerCase(),A=!0}}d.byteLength=k;function U(p,o,u){let g=!1;if((o===void 0||o<0)&&(o=0),o>this.length||((u===void 0||u>this.length)&&(u=this.length),u<=0)||(u>>>=0,o>>>=0,u<=o))return"";for(p||(p="utf8");;)switch(p){case"hex":return at(this,o,u);case"utf8":case"utf-8":return ue(this,o,u);case"ascii":return Ce(this,o,u);case"latin1":case"binary":return wt(this,o,u);case"base64":return ee(this,o,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qe(this,o,u);default:if(g)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),g=!0}}d.prototype._isBuffer=!0;function O(p,o,u){const g=p[o];p[o]=p[u],p[u]=g}d.prototype.swap16=function(){const o=this.length;if(o%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let u=0;u<o;u+=2)O(this,u,u+1);return this},d.prototype.swap32=function(){const o=this.length;if(o%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let u=0;u<o;u+=4)O(this,u,u+3),O(this,u+1,u+2);return this},d.prototype.swap64=function(){const o=this.length;if(o%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let u=0;u<o;u+=8)O(this,u,u+7),O(this,u+1,u+6),O(this,u+2,u+5),O(this,u+3,u+4);return this},d.prototype.toString=function(){const o=this.length;return o===0?"":arguments.length===0?ue(this,0,o):U.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(o){if(!d.isBuffer(o))throw new TypeError("Argument must be a Buffer");return this===o?!0:d.compare(this,o)===0},d.prototype.inspect=function(){let o="";const u=t.INSPECT_MAX_BYTES;return o=this.toString("hex",0,u).replace(/(.{2})/g,"$1 ").trim(),this.length>u&&(o+=" ... "),"<Buffer "+o+">"},n&&(d.prototype[n]=d.prototype.inspect),d.prototype.compare=function(o,u,g,A,D){if(Ue(o,i)&&(o=d.from(o,o.offset,o.byteLength)),!d.isBuffer(o))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof o);if(u===void 0&&(u=0),g===void 0&&(g=o?o.length:0),A===void 0&&(A=0),D===void 0&&(D=this.length),u<0||g>o.length||A<0||D>this.length)throw new RangeError("out of range index");if(A>=D&&u>=g)return 0;if(A>=D)return-1;if(u>=g)return 1;if(u>>>=0,g>>>=0,A>>>=0,D>>>=0,this===o)return 0;let H=D-A,se=g-u;const ge=Math.min(H,se),me=this.slice(A,D),Se=o.slice(u,g);for(let le=0;le<ge;++le)if(me[le]!==Se[le]){H=me[le],se=Se[le];break}return H<se?-1:se<H?1:0};function q(p,o,u,g,A){if(p.length===0)return-1;if(typeof u=="string"?(g=u,u=0):u>2147483647?u=2147483647:u<-2147483648&&(u=-2147483648),u=+u,Je(u)&&(u=A?0:p.length-1),u<0&&(u=p.length+u),u>=p.length){if(A)return-1;u=p.length-1}else if(u<0)if(A)u=0;else return-1;if(typeof o=="string"&&(o=d.from(o,g)),d.isBuffer(o))return o.length===0?-1:G(p,o,u,g,A);if(typeof o=="number")return o=o&255,typeof i.prototype.indexOf=="function"?A?i.prototype.indexOf.call(p,o,u):i.prototype.lastIndexOf.call(p,o,u):G(p,[o],u,g,A);throw new TypeError("val must be string, number or Buffer")}function G(p,o,u,g,A){let D=1,H=p.length,se=o.length;if(g!==void 0&&(g=String(g).toLowerCase(),g==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(p.length<2||o.length<2)return-1;D=2,H/=2,se/=2,u/=2}function ge(Se,le){return D===1?Se[le]:Se.readUInt16BE(le*D)}let me;if(A){let Se=-1;for(me=u;me<H;me++)if(ge(p,me)===ge(o,Se===-1?0:me-Se)){if(Se===-1&&(Se=me),me-Se+1===se)return Se*D}else Se!==-1&&(me-=me-Se),Se=-1}else for(u+se>H&&(u=H-se),me=u;me>=0;me--){let Se=!0;for(let le=0;le<se;le++)if(ge(p,me+le)!==ge(o,le)){Se=!1;break}if(Se)return me}return-1}d.prototype.includes=function(o,u,g){return this.indexOf(o,u,g)!==-1},d.prototype.indexOf=function(o,u,g){return q(this,o,u,g,!0)},d.prototype.lastIndexOf=function(o,u,g){return q(this,o,u,g,!1)};function V(p,o,u,g){u=Number(u)||0;const A=p.length-u;g?(g=Number(g),g>A&&(g=A)):g=A;const D=o.length;g>D/2&&(g=D/2);let H;for(H=0;H<g;++H){const se=parseInt(o.substr(H*2,2),16);if(Je(se))return H;p[u+H]=se}return H}function N(p,o,u,g){return Xe(At(o,p.length-u),p,u,g)}function X(p,o,u,g){return Xe(fr(o),p,u,g)}function fe(p,o,u,g){return Xe(Ne(o),p,u,g)}function Q(p,o,u,g){return Xe(Te(o,p.length-u),p,u,g)}d.prototype.write=function(o,u,g,A){if(u===void 0)A="utf8",g=this.length,u=0;else if(g===void 0&&typeof u=="string")A=u,g=this.length,u=0;else if(isFinite(u))u=u>>>0,isFinite(g)?(g=g>>>0,A===void 0&&(A="utf8")):(A=g,g=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const D=this.length-u;if((g===void 0||g>D)&&(g=D),o.length>0&&(g<0||u<0)||u>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");let H=!1;for(;;)switch(A){case"hex":return V(this,o,u,g);case"utf8":case"utf-8":return N(this,o,u,g);case"ascii":case"latin1":case"binary":return X(this,o,u,g);case"base64":return fe(this,o,u,g);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,o,u,g);default:if(H)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),H=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ee(p,o,u){return o===0&&u===p.length?e.fromByteArray(p):e.fromByteArray(p.slice(o,u))}function ue(p,o,u){u=Math.min(p.length,u);const g=[];let A=o;for(;A<u;){const D=p[A];let H=null,se=D>239?4:D>223?3:D>191?2:1;if(A+se<=u){let ge,me,Se,le;switch(se){case 1:D<128&&(H=D);break;case 2:ge=p[A+1],(ge&192)===128&&(le=(D&31)<<6|ge&63,le>127&&(H=le));break;case 3:ge=p[A+1],me=p[A+2],(ge&192)===128&&(me&192)===128&&(le=(D&15)<<12|(ge&63)<<6|me&63,le>2047&&(le<55296||le>57343)&&(H=le));break;case 4:ge=p[A+1],me=p[A+2],Se=p[A+3],(ge&192)===128&&(me&192)===128&&(Se&192)===128&&(le=(D&15)<<18|(ge&63)<<12|(me&63)<<6|Se&63,le>65535&&le<1114112&&(H=le))}}H===null?(H=65533,se=1):H>65535&&(H-=65536,g.push(H>>>10&1023|55296),H=56320|H&1023),g.push(H),A+=se}return Ee(g)}const we=4096;function Ee(p){const o=p.length;if(o<=we)return String.fromCharCode.apply(String,p);let u="",g=0;for(;g<o;)u+=String.fromCharCode.apply(String,p.slice(g,g+=we));return u}function Ce(p,o,u){let g="";u=Math.min(p.length,u);for(let A=o;A<u;++A)g+=String.fromCharCode(p[A]&127);return g}function wt(p,o,u){let g="";u=Math.min(p.length,u);for(let A=o;A<u;++A)g+=String.fromCharCode(p[A]);return g}function at(p,o,u){const g=p.length;(!o||o<0)&&(o=0),(!u||u<0||u>g)&&(u=g);let A="";for(let D=o;D<u;++D)A+=Ze[p[D]];return A}function Qe(p,o,u){const g=p.slice(o,u);let A="";for(let D=0;D<g.length-1;D+=2)A+=String.fromCharCode(g[D]+g[D+1]*256);return A}d.prototype.slice=function(o,u){const g=this.length;o=~~o,u=u===void 0?g:~~u,o<0?(o+=g,o<0&&(o=0)):o>g&&(o=g),u<0?(u+=g,u<0&&(u=0)):u>g&&(u=g),u<o&&(u=o);const A=this.subarray(o,u);return Object.setPrototypeOf(A,d.prototype),A};function be(p,o,u){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+o>u)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o],D=1,H=0;for(;++H<u&&(D*=256);)A+=this[o+H]*D;return A},d.prototype.readUintBE=d.prototype.readUIntBE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o+--u],D=1;for(;u>0&&(D*=256);)A+=this[o+--u]*D;return A},d.prototype.readUint8=d.prototype.readUInt8=function(o,u){return o=o>>>0,u||be(o,1,this.length),this[o]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(o,u){return o=o>>>0,u||be(o,2,this.length),this[o]|this[o+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(o,u){return o=o>>>0,u||be(o,2,this.length),this[o]<<8|this[o+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(o,u){return o=o>>>0,u||be(o,4,this.length),(this[o]|this[o+1]<<8|this[o+2]<<16)+this[o+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]*16777216+(this[o+1]<<16|this[o+2]<<8|this[o+3])},d.prototype.readBigUInt64LE=Le(function(o){o=o>>>0,te(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ce(o,this.length-8);const A=u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24,D=this[++o]+this[++o]*2**8+this[++o]*2**16+g*2**24;return BigInt(A)+(BigInt(D)<<BigInt(32))}),d.prototype.readBigUInt64BE=Le(function(o){o=o>>>0,te(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ce(o,this.length-8);const A=u*2**24+this[++o]*2**16+this[++o]*2**8+this[++o],D=this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+g;return(BigInt(A)<<BigInt(32))+BigInt(D)}),d.prototype.readIntLE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=this[o],D=1,H=0;for(;++H<u&&(D*=256);)A+=this[o+H]*D;return D*=128,A>=D&&(A-=Math.pow(2,8*u)),A},d.prototype.readIntBE=function(o,u,g){o=o>>>0,u=u>>>0,g||be(o,u,this.length);let A=u,D=1,H=this[o+--A];for(;A>0&&(D*=256);)H+=this[o+--A]*D;return D*=128,H>=D&&(H-=Math.pow(2,8*u)),H},d.prototype.readInt8=function(o,u){return o=o>>>0,u||be(o,1,this.length),this[o]&128?(255-this[o]+1)*-1:this[o]},d.prototype.readInt16LE=function(o,u){o=o>>>0,u||be(o,2,this.length);const g=this[o]|this[o+1]<<8;return g&32768?g|4294901760:g},d.prototype.readInt16BE=function(o,u){o=o>>>0,u||be(o,2,this.length);const g=this[o+1]|this[o]<<8;return g&32768?g|4294901760:g},d.prototype.readInt32LE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]|this[o+1]<<8|this[o+2]<<16|this[o+3]<<24},d.prototype.readInt32BE=function(o,u){return o=o>>>0,u||be(o,4,this.length),this[o]<<24|this[o+1]<<16|this[o+2]<<8|this[o+3]},d.prototype.readBigInt64LE=Le(function(o){o=o>>>0,te(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ce(o,this.length-8);const A=this[o+4]+this[o+5]*2**8+this[o+6]*2**16+(g<<24);return(BigInt(A)<<BigInt(32))+BigInt(u+this[++o]*2**8+this[++o]*2**16+this[++o]*2**24)}),d.prototype.readBigInt64BE=Le(function(o){o=o>>>0,te(o,"offset");const u=this[o],g=this[o+7];(u===void 0||g===void 0)&&ce(o,this.length-8);const A=(u<<24)+this[++o]*2**16+this[++o]*2**8+this[++o];return(BigInt(A)<<BigInt(32))+BigInt(this[++o]*2**24+this[++o]*2**16+this[++o]*2**8+g)}),d.prototype.readFloatLE=function(o,u){return o=o>>>0,u||be(o,4,this.length),r.read(this,o,!0,23,4)},d.prototype.readFloatBE=function(o,u){return o=o>>>0,u||be(o,4,this.length),r.read(this,o,!1,23,4)},d.prototype.readDoubleLE=function(o,u){return o=o>>>0,u||be(o,8,this.length),r.read(this,o,!0,52,8)},d.prototype.readDoubleBE=function(o,u){return o=o>>>0,u||be(o,8,this.length),r.read(this,o,!1,52,8)};function Fe(p,o,u,g,A,D){if(!d.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(o>A||o<D)throw new RangeError('"value" argument is out of bounds');if(u+g>p.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(o,u,g,A){if(o=+o,u=u>>>0,g=g>>>0,!A){const se=Math.pow(2,8*g)-1;Fe(this,o,u,g,se,0)}let D=1,H=0;for(this[u]=o&255;++H<g&&(D*=256);)this[u+H]=o/D&255;return u+g},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(o,u,g,A){if(o=+o,u=u>>>0,g=g>>>0,!A){const se=Math.pow(2,8*g)-1;Fe(this,o,u,g,se,0)}let D=g-1,H=1;for(this[u+D]=o&255;--D>=0&&(H*=256);)this[u+D]=o/H&255;return u+g},d.prototype.writeUint8=d.prototype.writeUInt8=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,1,255,0),this[u]=o&255,u+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,2,65535,0),this[u]=o&255,this[u+1]=o>>>8,u+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,2,65535,0),this[u]=o>>>8,this[u+1]=o&255,u+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,4,4294967295,0),this[u+3]=o>>>24,this[u+2]=o>>>16,this[u+1]=o>>>8,this[u]=o&255,u+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,4,4294967295,0),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4};function P(p,o,u,g,A){de(o,g,A,p,u,7);let D=Number(o&BigInt(4294967295));p[u++]=D,D=D>>8,p[u++]=D,D=D>>8,p[u++]=D,D=D>>8,p[u++]=D;let H=Number(o>>BigInt(32)&BigInt(4294967295));return p[u++]=H,H=H>>8,p[u++]=H,H=H>>8,p[u++]=H,H=H>>8,p[u++]=H,u}function M(p,o,u,g,A){de(o,g,A,p,u,7);let D=Number(o&BigInt(4294967295));p[u+7]=D,D=D>>8,p[u+6]=D,D=D>>8,p[u+5]=D,D=D>>8,p[u+4]=D;let H=Number(o>>BigInt(32)&BigInt(4294967295));return p[u+3]=H,H=H>>8,p[u+2]=H,H=H>>8,p[u+1]=H,H=H>>8,p[u]=H,u+8}d.prototype.writeBigUInt64LE=Le(function(o,u=0){return P(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Le(function(o,u=0){return M(this,o,u,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(o,u,g,A){if(o=+o,u=u>>>0,!A){const ge=Math.pow(2,8*g-1);Fe(this,o,u,g,ge-1,-ge)}let D=0,H=1,se=0;for(this[u]=o&255;++D<g&&(H*=256);)o<0&&se===0&&this[u+D-1]!==0&&(se=1),this[u+D]=(o/H>>0)-se&255;return u+g},d.prototype.writeIntBE=function(o,u,g,A){if(o=+o,u=u>>>0,!A){const ge=Math.pow(2,8*g-1);Fe(this,o,u,g,ge-1,-ge)}let D=g-1,H=1,se=0;for(this[u+D]=o&255;--D>=0&&(H*=256);)o<0&&se===0&&this[u+D+1]!==0&&(se=1),this[u+D]=(o/H>>0)-se&255;return u+g},d.prototype.writeInt8=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,1,127,-128),o<0&&(o=255+o+1),this[u]=o&255,u+1},d.prototype.writeInt16LE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,2,32767,-32768),this[u]=o&255,this[u+1]=o>>>8,u+2},d.prototype.writeInt16BE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,2,32767,-32768),this[u]=o>>>8,this[u+1]=o&255,u+2},d.prototype.writeInt32LE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,4,2147483647,-2147483648),this[u]=o&255,this[u+1]=o>>>8,this[u+2]=o>>>16,this[u+3]=o>>>24,u+4},d.prototype.writeInt32BE=function(o,u,g){return o=+o,u=u>>>0,g||Fe(this,o,u,4,2147483647,-2147483648),o<0&&(o=4294967295+o+1),this[u]=o>>>24,this[u+1]=o>>>16,this[u+2]=o>>>8,this[u+3]=o&255,u+4},d.prototype.writeBigInt64LE=Le(function(o,u=0){return P(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Le(function(o,u=0){return M(this,o,u,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function J(p,o,u,g,A,D){if(u+g>p.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("Index out of range")}function Z(p,o,u,g,A){return o=+o,u=u>>>0,A||J(p,o,u,4),r.write(p,o,u,g,23,4),u+4}d.prototype.writeFloatLE=function(o,u,g){return Z(this,o,u,!0,g)},d.prototype.writeFloatBE=function(o,u,g){return Z(this,o,u,!1,g)};function ie(p,o,u,g,A){return o=+o,u=u>>>0,A||J(p,o,u,8),r.write(p,o,u,g,52,8),u+8}d.prototype.writeDoubleLE=function(o,u,g){return ie(this,o,u,!0,g)},d.prototype.writeDoubleBE=function(o,u,g){return ie(this,o,u,!1,g)},d.prototype.copy=function(o,u,g,A){if(!d.isBuffer(o))throw new TypeError("argument should be a Buffer");if(g||(g=0),!A&&A!==0&&(A=this.length),u>=o.length&&(u=o.length),u||(u=0),A>0&&A<g&&(A=g),A===g||o.length===0||this.length===0)return 0;if(u<0)throw new RangeError("targetStart out of bounds");if(g<0||g>=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),o.length-u<A-g&&(A=o.length-u+g);const D=A-g;return this===o&&typeof i.prototype.copyWithin=="function"?this.copyWithin(u,g,A):i.prototype.set.call(o,this.subarray(g,A),u),D},d.prototype.fill=function(o,u,g,A){if(typeof o=="string"){if(typeof u=="string"?(A=u,u=0,g=this.length):typeof g=="string"&&(A=g,g=this.length),A!==void 0&&typeof A!="string")throw new TypeError("encoding must be a string");if(typeof A=="string"&&!d.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(o.length===1){const H=o.charCodeAt(0);(A==="utf8"&&H<128||A==="latin1")&&(o=H)}}else typeof o=="number"?o=o&255:typeof o=="boolean"&&(o=Number(o));if(u<0||this.length<u||this.length<g)throw new RangeError("Out of range index");if(g<=u)return this;u=u>>>0,g=g===void 0?this.length:g>>>0,o||(o=0);let D;if(typeof o=="number")for(D=u;D<g;++D)this[D]=o;else{const H=d.isBuffer(o)?o:d.from(o,A),se=H.length;if(se===0)throw new TypeError('The value "'+o+'" is invalid for argument "value"');for(D=0;D<g-u;++D)this[D+u]=H[D%se]}return this};const b={};function E(p,o,u){b[p]=class extends u{constructor(){super(),Object.defineProperty(this,"message",{value:o.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(A){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:A,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}E("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),E("ERR_INVALID_ARG_TYPE",function(p,o){return`The "${p}" argument must be of type number. Received type ${typeof o}`},TypeError),E("ERR_OUT_OF_RANGE",function(p,o,u){let g=`The value of "${p}" is out of range.`,A=u;return Number.isInteger(u)&&Math.abs(u)>2**32?A=K(String(u)):typeof u=="bigint"&&(A=String(u),(u>BigInt(2)**BigInt(32)||u<-(BigInt(2)**BigInt(32)))&&(A=K(A)),A+="n"),g+=` It must be ${o}. Received ${A}`,g},RangeError);function K(p){let o="",u=p.length;const g=p[0]==="-"?1:0;for(;u>=g+4;u-=3)o=`_${p.slice(u-3,u)}${o}`;return`${p.slice(0,u)}${o}`}function Y(p,o,u){te(o,"offset"),(p[o]===void 0||p[o+u]===void 0)&&ce(o,p.length-(u+1))}function de(p,o,u,g,A,D){if(p>u||p<o){const H=typeof o=="bigint"?"n":"";let se;throw o===0||o===BigInt(0)?se=`>= 0${H} and < 2${H} ** ${(D+1)*8}${H}`:se=`>= -(2${H} ** ${(D+1)*8-1}${H}) and < 2 ** ${(D+1)*8-1}${H}`,new b.ERR_OUT_OF_RANGE("value",se,p)}Y(g,A,D)}function te(p,o){if(typeof p!="number")throw new b.ERR_INVALID_ARG_TYPE(o,"number",p)}function ce(p,o,u){throw Math.floor(p)!==p?(te(p,u),new b.ERR_OUT_OF_RANGE("offset","an integer",p)):o<0?new b.ERR_BUFFER_OUT_OF_BOUNDS:new b.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${o}`,p)}const ct=/[^+/0-9A-Za-z-_]/g;function xt(p){if(p=p.split("=")[0],p=p.trim().replace(ct,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function At(p,o){o=o||1/0;let u;const g=p.length;let A=null;const D=[];for(let H=0;H<g;++H){if(u=p.charCodeAt(H),u>55295&&u<57344){if(!A){if(u>56319){(o-=3)>-1&&D.push(239,191,189);continue}else if(H+1===g){(o-=3)>-1&&D.push(239,191,189);continue}A=u;continue}if(u<56320){(o-=3)>-1&&D.push(239,191,189),A=u;continue}u=(A-55296<<10|u-56320)+65536}else A&&(o-=3)>-1&&D.push(239,191,189);if(A=null,u<128){if((o-=1)<0)break;D.push(u)}else if(u<2048){if((o-=2)<0)break;D.push(u>>6|192,u&63|128)}else if(u<65536){if((o-=3)<0)break;D.push(u>>12|224,u>>6&63|128,u&63|128)}else if(u<1114112){if((o-=4)<0)break;D.push(u>>18|240,u>>12&63|128,u>>6&63|128,u&63|128)}else throw new Error("Invalid code point")}return D}function fr(p){const o=[];for(let u=0;u<p.length;++u)o.push(p.charCodeAt(u)&255);return o}function Te(p,o){let u,g,A;const D=[];for(let H=0;H<p.length&&!((o-=2)<0);++H)u=p.charCodeAt(H),g=u>>8,A=u%256,D.push(A),D.push(g);return D}function Ne(p){return e.toByteArray(xt(p))}function Xe(p,o,u,g){let A;for(A=0;A<g&&!(A+u>=o.length||A>=p.length);++A)o[A+u]=p[A];return A}function Ue(p,o){return p instanceof o||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===o.name}function Je(p){return p!==p}const Ze=(function(){const p="0123456789abcdef",o=new Array(256);for(let u=0;u<16;++u){const g=u*16;for(let A=0;A<16;++A)o[g+A]=p[u]+p[A]}return o})();function Le(p){return typeof BigInt>"u"?Rt:p}function Rt(){throw new Error("BigInt not supported")}})(ln);const Si=ln.Buffer,Nt=ln.Buffer;let _i=class qr extends Promise{#e;#t;constructor(e){super(r=>{r()}),this.#e=e}static from(e){return new qr(r=>{r(e())})}static resolve(e){return new qr(r=>{r(e)})}static reject(e){return new qr((r,n)=>{n(e)})}then(e,r){return this.#t??=new Promise(this.#e),this.#t.then(e,r)}catch(e){return this.#t??=new Promise(this.#e),this.#t.catch(e)}finally(e){return this.#t??=new Promise(this.#e),this.#t.finally(e)}};const vi=_i.default??_i;class Ti{constructor(e){this.waiters=[],this.aborted=!1,this.remaining=e}async acquire(e){if(this.aborted)throw new Error("credit gate aborted");if(e?.aborted)throw e.reason??new Error("aborted");this.remaining>0?this.remaining--:await new Promise((r,n)=>{const s=()=>{const c=this.waiters.indexOf(i);c!==-1&&this.waiters.splice(c,1),n(e?.reason??new Error("aborted"))};e&&e.addEventListener("abort",s,{once:!0});const i=c=>{if(e&&e.removeEventListener("abort",s),c){n(new Error("credit gate aborted"));return}this.remaining--,r()};this.waiters.push(i)})}replenish(e){for(this.remaining+=e;this.waiters.length>0&&this.remaining>0;)this.waiters.shift()(!1)}abort(){for(this.aborted=!0;this.waiters.length>0;)this.waiters.shift()(!0)}}const Eo=new TextEncoder;function So(t){const e=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(e);let n=0;for(const s of t)r.set(s,n),n+=s.byteLength;return r}function xi(t){let e;if(t instanceof Nt)e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else if(t instanceof Uint8Array)e=t;else if(typeof t=="string")e=Eo.encode(t);else throw new Error("invalid chunk type: expected Buffer, Uint8Array, or string");return e}function Ai(t){return new vi((e,r)=>{const n=[];t.on("data",s=>{const i=xi(s);n.push(i)}),t.on("end",()=>{e(So(n))}),t.on("error",s=>{r(s)})})}async function Ri(t,e,r,n,s){if(t.byteLength===0)await r(void 0,void 0,!0);else for(let i=0;i<t.byteLength;i+=e){if(s?.aborted)throw s.reason??new Error("aborted");const c=Math.min(t.byteLength-i,e),l=t.subarray(i,i+c),h=i+c>=t.byteLength;n&&await n.acquire(s),await r(l,void 0,h)}}async function Ii(t,e,r,n,s){let i;for await(const c of t){if(s?.aborted)throw s.reason??new Error("aborted");const l=xi(c);if(l.byteLength!==0)for(let h=0;h<l.byteLength;h+=e){if(s?.aborted)throw s.reason??new Error("aborted");const w=Math.min(l.byteLength-h,e),d=l.subarray(h,h+w);i!==void 0&&(n&&await n.acquire(s),await r(i,void 0,!1)),i=d}}if(s?.aborted)throw s.reason??new Error("aborted");i!==void 0?(n&&await n.acquire(s),await r(i,void 0,!0)):await r(void 0,void 0,!0)}function Bi(t,e,r){if(!(typeof t=="object"&&t!==null))throw new Error("invalid object");let n;const s=t[e],i=t[r];Object.defineProperty(t,e,{get:()=>{if(n==="f2")throw new Error(`field "${e}" is mutually exclusive with field "${r}" and "${r}" was already consumed`);return n="f1",s},enumerable:!0,configurable:!0}),Object.defineProperty(t,r,{get:()=>{if(n==="f1")throw new Error(`field "${r}" is mutually exclusive with field "${e}" and "${e}" was already consumed`);return n="f2",i},enumerable:!0,configurable:!0})}class De{constructor(){this.resources=[]}roll(...e){let r,n;if(e.length===1)r=void 0,n=e[0];else if(e.length===2)r=e[0],n=e[1];else throw new Error("invalid number of arguments");this.resources.push({resource:r,cleanup:n})}sub(){const e=new De;return this.roll(e,()=>{}),e}unroll(e=!0){try{let r;for(;this.resources.length>0;){const n=this.resources.pop(),s=n.resource,i=n.cleanup;if(r)s instanceof De?r=r.then(()=>s.unroll()):r=r.then(()=>i(s));else{let c;s instanceof De?c=s.unroll():c=i(s),c instanceof Promise&&(r=c)}}return r?e?r.catch(()=>{}):r:void 0}catch(r){if(e)return;throw r}}}function ke(t,e,r=!1){if(t instanceof Error&&e===void 0&&r===!1)return t;let n=t instanceof Error?t.message:String(t);if(e&&(n=`${e}: ${n}`),r&&t instanceof Error&&(n=`${n}
|
|
2
|
+
${t.stack}`),t instanceof Error){const s=new Error(n,{cause:t});return s.stack=t.stack,s}else return new Error(n)}function mt(t,e){if(!e)return t?Promise.resolve():void 0;let r;try{r=e()}catch(n){if(t)return Promise.reject(n);throw n}if(!t&&r instanceof Promise)throw new Error("onfinally callback returned Promise in non-async context");return t&&!(r instanceof Promise)&&(r=Promise.resolve(r)),r}function mr(t,e){if(!e)return t?Promise.resolve():void 0;let r=e.unroll();if(!t&&r instanceof Promise)throw new Error("spool unroll returned Promise in non-async context");return t&&!(r instanceof Promise)&&(r=Promise.resolve(r)),r}function br(...t){let e,r,n,s,i,c;if(t.length===1&&typeof t[0]=="object"&&t[0]!==null?(e=t[0].description,r=t[0].spool,n=t[0].action,s=t[0].oncatch,i=t[0].onfinally,c=t[0].oncleanup):typeof t[0]=="string"?(e=t[0],t[1]instanceof De||t[1]===void 0&&typeof t[2]=="function"?(r=t[1],n=t[2],s=t[3],i=t[4],c=t[5]):(n=t[1],s=t[2],i=t[3],c=t[4])):t[0]instanceof De||t[0]===void 0&&typeof t[1]=="function"?(r=t[0],n=t[1],s=t[2],i=t[3],c=t[4]):(n=t[0],s=t[1],i=t[2],c=t[3]),c&&!r)throw new Error("oncleanup requires a spool");let l;try{l=n()}catch(h){let w=ke(h,e);if(s){try{l=s(w)}catch(d){throw w=ke(d,e),mt(!1,i),mr(!1,r),w}return mt(!1,i),l}throw mt(!1,i),mr(!1,r),w}return l instanceof Promise?l.then(async h=>(await mt(!0,i),r&&c&&r.roll(h,c),h),async h=>{let w=ke(h,e);if(s)try{const d=s(w);return await mt(!0,i),d}catch(d){throw w=ke(d,e),await mt(!0,i),await mr(!0,r),w}throw await mt(!0,i),await mr(!0,r),w}):(mt(!1,i),r&&c&&r.roll(l,c),l)}const Er=new TextEncoder,Qt=new TextDecoder;function Ni(...t){const e=t.reduce((s,{length:i})=>s+i,0),r=new Uint8Array(e);let n=0;for(const s of t)r.set(s,n),n+=s.length;return r}function qt(t){const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++){const n=t.charCodeAt(r);if(n>127)throw new TypeError("non-ASCII string encountered in encode()");e[r]=n}return e}function _o(t){if(Uint8Array.prototype.toBase64)return t.toBase64();const e=32768,r=[];for(let n=0;n<t.length;n+=e)r.push(String.fromCharCode.apply(null,t.subarray(n,n+e)));return btoa(r.join(""))}function vo(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(t);const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function pn(t){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof t=="string"?t:Qt.decode(t),{alphabet:"base64url"});let e=t;e instanceof Uint8Array&&(e=Qt.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/");try{return vo(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}function yn(t){let e=t;return typeof e=="string"&&(e=Er.encode(e)),Uint8Array.prototype.toBase64?e.toBase64({alphabet:"base64url",omitPadding:!0}):_o(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}class jt extends Error{static code="ERR_JOSE_GENERIC";code="ERR_JOSE_GENERIC";constructor(e,r){super(e,r),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}class it extends jt{static code="ERR_JWT_CLAIM_VALIDATION_FAILED";code="ERR_JWT_CLAIM_VALIDATION_FAILED";claim;reason;payload;constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.claim=n,this.reason=s,this.payload=r}}class ki extends jt{static code="ERR_JWT_EXPIRED";code="ERR_JWT_EXPIRED";claim;reason;payload;constructor(e,r,n="unspecified",s="unspecified"){super(e,{cause:{claim:n,reason:s,payload:r}}),this.claim=n,this.reason=s,this.payload=r}}class kt extends jt{static code="ERR_JOSE_NOT_SUPPORTED";code="ERR_JOSE_NOT_SUPPORTED"}class xe extends jt{static code="ERR_JWS_INVALID";code="ERR_JWS_INVALID"}class wn extends jt{static code="ERR_JWT_INVALID";code="ERR_JWT_INVALID"}class To extends jt{static code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";constructor(e="signature verification failed",r){super(e,r)}}const bt=(t,e="algorithm.name")=>new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`),Ht=(t,e)=>t.name===e;function xo(t){return parseInt(t.name.slice(4),10)}function gn(t,e){if(xo(t.hash)!==e)throw bt(`SHA-${e}`,"algorithm.hash")}function Ao(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Ro(t,e){if(e&&!t.usages.includes(e))throw new TypeError(`CryptoKey does not support this operation, its usages must include ${e}.`)}function Io(t,e,r){switch(e){case"HS256":case"HS384":case"HS512":{if(!Ht(t.algorithm,"HMAC"))throw bt("HMAC");gn(t.algorithm,parseInt(e.slice(2),10));break}case"RS256":case"RS384":case"RS512":{if(!Ht(t.algorithm,"RSASSA-PKCS1-v1_5"))throw bt("RSASSA-PKCS1-v1_5");gn(t.algorithm,parseInt(e.slice(2),10));break}case"PS256":case"PS384":case"PS512":{if(!Ht(t.algorithm,"RSA-PSS"))throw bt("RSA-PSS");gn(t.algorithm,parseInt(e.slice(2),10));break}case"Ed25519":case"EdDSA":{if(!Ht(t.algorithm,"Ed25519"))throw bt("Ed25519");break}case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":{if(!Ht(t.algorithm,e))throw bt(e);break}case"ES256":case"ES384":case"ES512":{if(!Ht(t.algorithm,"ECDSA"))throw bt("ECDSA");const n=Ao(e);if(t.algorithm.namedCurve!==n)throw bt(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Ro(t,r)}function Fi(t,e,...r){if(r=r.filter(Boolean),r.length>2){const n=r.pop();t+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&e.constructor?.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const Bo=(t,...e)=>Fi("Key must be ",t,...e),Li=(t,e,...r)=>Fi(`Key for the ${t} algorithm must be `,e,...r);function Ui(t,e){if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}}function Mi(t,e){const r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:parseInt(t.slice(-3),10)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":case"EdDSA":return{name:"Ed25519"};case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":return{name:t};default:throw new kt(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function Pi(t,e,r){if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(Bo(e,"CryptoKey","KeyObject","JSON Web Key"));return crypto.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}return Io(e,t,r),e}async function No(t,e,r){const n=await Pi(t,e,"sign");Ui(t,n);const s=await crypto.subtle.sign(Mi(t,n.algorithm),n,r);return new Uint8Array(s)}async function ko(t,e,r,n){const s=await Pi(t,e,"verify");Ui(t,s);const i=Mi(t,s.algorithm);try{return await crypto.subtle.verify(i,s,r,n)}catch{return!1}}const Fo=t=>typeof t=="object"&&t!==null;function Xt(t){if(!Fo(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Di(...t){const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const n of e){const s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(const i of s){if(r.has(i))return!1;r.add(i)}}return!0}const mn=t=>Xt(t)&&typeof t.kty=="string",Lo=t=>t.kty!=="oct"&&(t.kty==="AKP"&&typeof t.priv=="string"||typeof t.d=="string"),Uo=t=>t.kty!=="oct"&&t.d===void 0&&t.priv===void 0,Mo=t=>t.kty==="oct"&&typeof t.k=="string",Oi=t=>{if(t?.[Symbol.toStringTag]==="CryptoKey")return!0;try{return t instanceof CryptoKey}catch{return!1}},Ci=t=>t?.[Symbol.toStringTag]==="KeyObject",$i=t=>Oi(t)||Ci(t),Wt=t=>t?.[Symbol.toStringTag],bn=(t,e,r)=>{if(e.use!==void 0){let n;switch(r){case"sign":case"verify":n="sig";break;case"encrypt":case"decrypt":n="enc";break}if(e.use!==n)throw new TypeError(`Invalid key for this operation, its "use" must be "${n}" when present`)}if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, its "alg" must be "${t}" when present`);if(Array.isArray(e.key_ops)){let n;switch(!0){case(r==="sign"||r==="verify"):case t==="dir":case t.includes("CBC-HS"):n=r;break;case t.startsWith("PBES2"):n="deriveBits";break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(t):!t.includes("GCM")&&t.endsWith("KW")?n=r==="encrypt"?"wrapKey":"unwrapKey":n=r;break;case(r==="encrypt"&&t.startsWith("RSA")):n="wrapKey";break;case r==="decrypt":n=t.startsWith("RSA")?"unwrapKey":"deriveBits";break}if(n&&e.key_ops?.includes?.(n)===!1)throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${n}" when present`)}return!0},Po=(t,e,r)=>{if(!(e instanceof Uint8Array)){if(mn(e)){if(Mo(e)&&bn(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!$i(e))throw new TypeError(Li(t,e,"CryptoKey","KeyObject","JSON Web Key","Uint8Array"));if(e.type!=="secret")throw new TypeError(`${Wt(e)} instances for symmetric algorithms must be of type "secret"`)}},Do=(t,e,r)=>{if(mn(e))switch(r){case"decrypt":case"sign":if(Lo(e)&&bn(t,e,r))return;throw new TypeError("JSON Web Key for this operation must be a private JWK");case"encrypt":case"verify":if(Uo(e)&&bn(t,e,r))return;throw new TypeError("JSON Web Key for this operation must be a public JWK")}if(!$i(e))throw new TypeError(Li(t,e,"CryptoKey","KeyObject","JSON Web Key"));if(e.type==="secret")throw new TypeError(`${Wt(e)} instances for asymmetric algorithms must not be of type "secret"`);if(e.type==="public")switch(r){case"sign":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm signing must be of type "private"`);case"decrypt":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm decryption must be of type "private"`)}if(e.type==="private")switch(r){case"verify":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm verifying must be of type "public"`);case"encrypt":throw new TypeError(`${Wt(e)} instances for asymmetric algorithm encryption must be of type "public"`)}};function qi(t,e,r){switch(t.substring(0,2)){case"A1":case"A2":case"di":case"HS":case"PB":Po(t,e,r);break;default:Do(t,e,r)}}function ji(t,e,r,n,s){if(s.crit!==void 0&&n?.crit===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(c=>typeof c!="string"||c.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;r!==void 0?i=new Map([...Object.entries(r),...e.entries()]):i=e;for(const c of n.crit){if(!i.has(c))throw new kt(`Extension Header Parameter "${c}" is not recognized`);if(s[c]===void 0)throw new t(`Extension Header Parameter "${c}" is missing`);if(i.get(c)&&n[c]===void 0)throw new t(`Extension Header Parameter "${c}" MUST be integrity protected`)}return new Set(n.crit)}const Sr='Invalid or unsupported JWK "alg" (Algorithm) Parameter value';function Oo(t){let e,r;switch(t.kty){case"AKP":{switch(t.alg){case"ML-DSA-44":case"ML-DSA-65":case"ML-DSA-87":e={name:t.alg},r=t.priv?["sign"]:["verify"];break;default:throw new kt(Sr)}break}case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new kt(Sr)}break}case"EC":{switch(t.alg){case"ES256":case"ES384":case"ES512":e={name:"ECDSA",namedCurve:{ES256:"P-256",ES384:"P-384",ES512:"P-521"}[t.alg]},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new kt(Sr)}break}case"OKP":{switch(t.alg){case"Ed25519":case"EdDSA":e={name:"Ed25519"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new kt(Sr)}break}default:throw new kt('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}async function Co(t){if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=Oo(t),n={...t};return n.kty!=="AKP"&&delete n.alg,delete n.use,crypto.subtle.importKey("jwk",n,e,t.ext??!(t.d||t.priv),t.key_ops??r)}const Kt="given KeyObject instance cannot be used for this algorithm";let Gt;const Hi=async(t,e,r,n=!1)=>{Gt||=new WeakMap;let s=Gt.get(t);if(s?.[r])return s[r];const i=await Co({...e,alg:r});return n&&Object.freeze(t),s?s[r]=i:Gt.set(t,{[r]:i}),i},$o=(t,e)=>{Gt||=new WeakMap;let r=Gt.get(t);if(r?.[e])return r[e];const n=t.type==="public",s=!!n;let i;if(t.asymmetricKeyType==="x25519"){switch(e){case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":break;default:throw new TypeError(Kt)}i=t.toCryptoKey(t.asymmetricKeyType,s,n?[]:["deriveBits"])}if(t.asymmetricKeyType==="ed25519"){if(e!=="EdDSA"&&e!=="Ed25519")throw new TypeError(Kt);i=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}switch(t.asymmetricKeyType){case"ml-dsa-44":case"ml-dsa-65":case"ml-dsa-87":{if(e!==t.asymmetricKeyType.toUpperCase())throw new TypeError(Kt);i=t.toCryptoKey(t.asymmetricKeyType,s,[n?"verify":"sign"])}}if(t.asymmetricKeyType==="rsa"){let c;switch(e){case"RSA-OAEP":c="SHA-1";break;case"RS256":case"PS256":case"RSA-OAEP-256":c="SHA-256";break;case"RS384":case"PS384":case"RSA-OAEP-384":c="SHA-384";break;case"RS512":case"PS512":case"RSA-OAEP-512":c="SHA-512";break;default:throw new TypeError(Kt)}if(e.startsWith("RSA-OAEP"))return t.toCryptoKey({name:"RSA-OAEP",hash:c},s,n?["encrypt"]:["decrypt"]);i=t.toCryptoKey({name:e.startsWith("PS")?"RSA-PSS":"RSASSA-PKCS1-v1_5",hash:c},s,[n?"verify":"sign"])}if(t.asymmetricKeyType==="ec"){const l=new Map([["prime256v1","P-256"],["secp384r1","P-384"],["secp521r1","P-521"]]).get(t.asymmetricKeyDetails?.namedCurve);if(!l)throw new TypeError(Kt);const h={ES256:"P-256",ES384:"P-384",ES512:"P-521"};h[e]&&l===h[e]&&(i=t.toCryptoKey({name:"ECDSA",namedCurve:l},s,[n?"verify":"sign"])),e.startsWith("ECDH-ES")&&(i=t.toCryptoKey({name:"ECDH",namedCurve:l},s,n?[]:["deriveBits"]))}if(!i)throw new TypeError(Kt);return r?r[e]=i:Gt.set(t,{[e]:i}),i};async function Wi(t,e){if(t instanceof Uint8Array||Oi(t))return t;if(Ci(t)){if(t.type==="secret")return t.export();if("toCryptoKey"in t&&typeof t.toCryptoKey=="function")try{return $o(t,e)}catch(n){if(n instanceof TypeError)throw n}let r=t.export({format:"jwk"});return Hi(t,r,e)}if(mn(t))return t.k?pn(t.k):Hi(t,t,e,!0);throw new Error("unreachable")}function Ki(t,e){if(t)throw new TypeError(`${e} can only be called once`)}function Gi(t,e,r){try{return pn(t)}catch{throw new r(`Failed to base64url decode the ${e}`)}}class qo{#e;#t;#r;constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this.#e=e}setProtectedHeader(e){return Ki(this.#t,"setProtectedHeader"),this.#t=e,this}setUnprotectedHeader(e){return Ki(this.#r,"setUnprotectedHeader"),this.#r=e,this}async sign(e,r){if(!this.#t&&!this.#r)throw new xe("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Di(this.#t,this.#r))throw new xe("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const n={...this.#t,...this.#r},s=ji(xe,new Map([["b64",!0]]),r?.crit,this.#t,n);let i=!0;if(s.has("b64")&&(i=this.#t.b64,typeof i!="boolean"))throw new xe('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:c}=n;if(typeof c!="string"||!c)throw new xe('JWS "alg" (Algorithm) Header Parameter missing or invalid');qi(c,e,"sign");let l,h;i?(l=yn(this.#e),h=qt(l)):(h=this.#e,l="");let w,d;this.#t?(w=yn(JSON.stringify(this.#t)),d=qt(w)):(w="",d=new Uint8Array);const I=Ni(d,qt("."),h),T=await Wi(e,c),L=await No(c,T,I),B={signature:yn(L),payload:l};return this.#r&&(B.header=this.#r),this.#t&&(B.protected=w),B}}class jo{#e;constructor(e){this.#e=new qo(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}async sign(e,r){const n=await this.#e.sign(e,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}}const Et=t=>Math.floor(t.getTime()/1e3),Ji=60,zi=Ji*60,En=zi*24,Ho=En*7,Wo=En*365.25,Ko=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Zt(t){const e=Ko.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const r=parseFloat(e[2]),n=e[3].toLowerCase();let s;switch(n){case"sec":case"secs":case"second":case"seconds":case"s":s=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":s=Math.round(r*Ji);break;case"hour":case"hours":case"hr":case"hrs":case"h":s=Math.round(r*zi);break;case"day":case"days":case"d":s=Math.round(r*En);break;case"week":case"weeks":case"w":s=Math.round(r*Ho);break;default:s=Math.round(r*Wo);break}return e[1]==="-"||e[4]==="ago"?-s:s}function Ft(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}const Vi=t=>t.includes("/")?t.toLowerCase():`application/${t.toLowerCase()}`,Go=(t,e)=>typeof t=="string"?e.includes(t):Array.isArray(t)?e.some(Set.prototype.has.bind(new Set(t))):!1;function Jo(t,e,r={}){let n;try{n=JSON.parse(Qt.decode(e))}catch{}if(!Xt(n))throw new wn("JWT Claims Set must be a top-level JSON object");const{typ:s}=r;if(s&&(typeof t.typ!="string"||Vi(t.typ)!==Vi(s)))throw new it('unexpected "typ" JWT header value',n,"typ","check_failed");const{requiredClaims:i=[],issuer:c,subject:l,audience:h,maxTokenAge:w}=r,d=[...i];w!==void 0&&d.push("iat"),h!==void 0&&d.push("aud"),l!==void 0&&d.push("sub"),c!==void 0&&d.push("iss");for(const B of new Set(d.reverse()))if(!(B in n))throw new it(`missing required "${B}" claim`,n,B,"missing");if(c&&!(Array.isArray(c)?c:[c]).includes(n.iss))throw new it('unexpected "iss" claim value',n,"iss","check_failed");if(l&&n.sub!==l)throw new it('unexpected "sub" claim value',n,"sub","check_failed");if(h&&!Go(n.aud,typeof h=="string"?[h]:h))throw new it('unexpected "aud" claim value',n,"aud","check_failed");let I;switch(typeof r.clockTolerance){case"string":I=Zt(r.clockTolerance);break;case"number":I=r.clockTolerance;break;case"undefined":I=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:T}=r,L=Et(T||new Date);if((n.iat!==void 0||w)&&typeof n.iat!="number")throw new it('"iat" claim must be a number',n,"iat","invalid");if(n.nbf!==void 0){if(typeof n.nbf!="number")throw new it('"nbf" claim must be a number',n,"nbf","invalid");if(n.nbf>L+I)throw new it('"nbf" claim timestamp check failed',n,"nbf","check_failed")}if(n.exp!==void 0){if(typeof n.exp!="number")throw new it('"exp" claim must be a number',n,"exp","invalid");if(n.exp<=L-I)throw new ki('"exp" claim timestamp check failed',n,"exp","check_failed")}if(w){const B=L-n.iat,j=typeof w=="number"?w:Zt(w);if(B-I>j)throw new ki('"iat" claim timestamp check failed (too far in the past)',n,"iat","check_failed");if(B<0-I)throw new it('"iat" claim timestamp check failed (it should be in the past)',n,"iat","check_failed")}return n}class zo{#e;constructor(e){if(!Xt(e))throw new TypeError("JWT Claims Set MUST be an object");this.#e=structuredClone(e)}data(){return Er.encode(JSON.stringify(this.#e))}get iss(){return this.#e.iss}set iss(e){this.#e.iss=e}get sub(){return this.#e.sub}set sub(e){this.#e.sub=e}get aud(){return this.#e.aud}set aud(e){this.#e.aud=e}set jti(e){this.#e.jti=e}set nbf(e){typeof e=="number"?this.#e.nbf=Ft("setNotBefore",e):e instanceof Date?this.#e.nbf=Ft("setNotBefore",Et(e)):this.#e.nbf=Et(new Date)+Zt(e)}set exp(e){typeof e=="number"?this.#e.exp=Ft("setExpirationTime",e):e instanceof Date?this.#e.exp=Ft("setExpirationTime",Et(e)):this.#e.exp=Et(new Date)+Zt(e)}set iat(e){e===void 0?this.#e.iat=Et(new Date):e instanceof Date?this.#e.iat=Ft("setIssuedAt",Et(e)):typeof e=="string"?this.#e.iat=Ft("setIssuedAt",Et(new Date)+Zt(e)):this.#e.iat=Ft("setIssuedAt",e)}}class Vo{#e;#t;constructor(e={}){this.#t=new zo(e)}setIssuer(e){return this.#t.iss=e,this}setSubject(e){return this.#t.sub=e,this}setAudience(e){return this.#t.aud=e,this}setJti(e){return this.#t.jti=e,this}setNotBefore(e){return this.#t.nbf=e,this}setExpirationTime(e){return this.#t.exp=e,this}setIssuedAt(e){return this.#t.iat=e,this}setProtectedHeader(e){return this.#e=e,this}async sign(e,r){const n=new jo(this.#t.data());if(n.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes("b64")&&this.#e.b64===!1)throw new wn("JWTs MUST NOT use unencoded payload");return n.sign(e,r)}}async function Yo(t,e,r){if(!Xt(t))throw new xe("Flattened JWS must be an object");if(t.protected===void 0&&t.header===void 0)throw new xe('Flattened JWS must have either of the "protected" or "header" members');if(t.protected!==void 0&&typeof t.protected!="string")throw new xe("JWS Protected Header incorrect type");if(t.payload===void 0)throw new xe("JWS Payload missing");if(typeof t.signature!="string")throw new xe("JWS Signature missing or incorrect type");if(t.header!==void 0&&!Xt(t.header))throw new xe("JWS Unprotected Header incorrect type");let n={};if(t.protected)try{const j=pn(t.protected);n=JSON.parse(Qt.decode(j))}catch{throw new xe("JWS Protected Header is invalid")}if(!Di(n,t.header))throw new xe("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...n,...t.header},i=ji(xe,new Map([["b64",!0]]),r?.crit,n,s);let c=!0;if(i.has("b64")&&(c=n.b64,typeof c!="boolean"))throw new xe('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:l}=s;if(typeof l!="string"||!l)throw new xe('JWS "alg" (Algorithm) Header Parameter missing or invalid');if(c){if(typeof t.payload!="string")throw new xe("JWS Payload must be a string")}else if(typeof t.payload!="string"&&!(t.payload instanceof Uint8Array))throw new xe("JWS Payload must be a string or an Uint8Array instance");let h=!1;typeof e=="function"&&(e=await e(n,t),h=!0),qi(l,e,"verify");const w=Ni(t.protected!==void 0?qt(t.protected):new Uint8Array,qt("."),typeof t.payload=="string"?c?qt(t.payload):Er.encode(t.payload):t.payload),d=Gi(t.signature,"signature",xe),I=await Wi(e,l);if(!await ko(l,I,d,w))throw new To;let L;c?L=Gi(t.payload,"payload",xe):typeof t.payload=="string"?L=Er.encode(t.payload):L=t.payload;const B={payload:L};return t.protected!==void 0&&(B.protectedHeader=n),t.header!==void 0&&(B.unprotectedHeader=t.header),h?{...B,key:I}:B}async function Qo(t,e,r){if(t instanceof Uint8Array&&(t=Qt.decode(t)),typeof t!="string")throw new xe("Compact JWS must be a string or Uint8Array");const{0:n,1:s,2:i,length:c}=t.split(".");if(c!==3)throw new xe("Invalid Compact JWS");const l=await Yo({payload:s,protected:n,signature:i},e,r),h={payload:l.payload,protectedHeader:l.protectedHeader};return typeof e=="function"?{...h,key:l.key}:h}async function Xo(t,e,r){const n=await Qo(t,e,r);if(n.protectedHeader.crit?.includes("b64")&&n.protectedHeader.b64===!1)throw new wn("JWTs MUST NOT use unencoded payload");const i={payload:Jo(n.protectedHeader,n.payload,r),protectedHeader:n.protectedHeader};return typeof e=="function"?{...i,key:n.key}:i}function st(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}function St(t){for(let e=0;e<t.length;e++)t[e]=0;return t}class Zo{blockSize;digestLength;_inner;_outer;_finished=!1;_innerKeyedState;_outerKeyedState;constructor(e,r){this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;const n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(let s=0;s<n.length;s++)n[s]^=54;this._inner.update(n);for(let s=0;s<n.length;s++)n[s]^=106;this._outer.update(n),st(this._inner)&&st(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),St(n)}reset(){if(!st(this._inner)||!st(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this}clean(){st(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),st(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()}update(e){return this._inner.update(e),this}finish(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)}digest(){const e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(!st(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()}restoreState(e){if(!st(this._inner)||!st(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this}cleanSavedState(e){if(!st(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)}}function ea(t,e=0){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function _r(t,e=new Uint8Array(4),r=0){return e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}function ta(t,e,r,n,s){const i=new Zo(t,e),c=i.digestLength,l=new Uint8Array(4),h=new Uint8Array(c),w=new Uint8Array(c),d=new Uint8Array(s),I=i.update(r).saveState();for(let T=0;T*c<s;T++){_r(T+1,l),i.restoreState(I).update(l).finish(w);for(let L=0;L<c;L++)h[L]=w[L];for(let L=2;L<=n;L++){i.reset().update(w).finish(w);for(let B=0;B<c;B++)h[B]^=w[B]}for(let L=0;L<c&&T*c+L<s;L++)d[T*c+L]=h[L]}return St(h),St(w),St(l),i.cleanSavedState(I),i.clean(),d}const ra=32,na=64;class ia{digestLength=ra;blockSize=na;_state=new Int32Array(8);_temp=new Int32Array(64);_buffer=new Uint8Array(128);_bufferLength=0;_bytesHashed=0;_finished=!1;constructor(){this.reset()}_initState(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225}reset(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this}clean(){St(this._buffer),St(this._temp),this.reset()}update(e,r=e.length){if(this._finished)throw new Error("SHA256: can't update because hash was finished.");let n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&r>0;)this._buffer[this._bufferLength++]=e[n++],r--;this._bufferLength===this.blockSize&&(Sn(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=Sn(this._temp,this._state,e,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[n++],r--;return this}finish(e){if(!this._finished){const r=this._bytesHashed,n=this._bufferLength,s=r/536870912|0,i=r<<3,c=r%64<56?64:128;this._buffer[n]=128;for(let l=n+1;l<c-8;l++)this._buffer[l]=0;_r(s,this._buffer,c-8),_r(i,this._buffer,c-4),Sn(this._temp,this._state,this._buffer,0,c),this._finished=!0}for(let r=0;r<this.digestLength/4;r++)_r(this._state[r],e,r*4);return this}digest(){const e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}}restoreState(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this}cleanSavedState(e){St(e.state),e.buffer&&St(e.buffer),e.bufferLength=0,e.bytesHashed=0}}const sa=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Sn(t,e,r,n,s){for(;s>=64;){let i=e[0],c=e[1],l=e[2],h=e[3],w=e[4],d=e[5],I=e[6],T=e[7];for(let L=0;L<16;L++){let B=n+L*4;t[L]=ea(r,B)}for(let L=16;L<64;L++){let B=t[L-2],j=(B>>>17|B<<15)^(B>>>19|B<<13)^B>>>10;B=t[L-15];let $=(B>>>7|B<<25)^(B>>>18|B<<14)^B>>>3;t[L]=(j+t[L-7]|0)+($+t[L-16]|0)}for(let L=0;L<64;L++){let B=(((w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&d^~w&I)|0)+(T+(sa[L]+t[L]|0)|0)|0,j=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&c^i&l^c&l)|0;T=I,I=d,d=w,w=h+B|0,h=l,l=c,c=i,i=B+j|0}e[0]+=i,e[1]+=c,e[2]+=l,e[3]+=h,e[4]+=w,e[5]+=d,e[6]+=I,e[7]+=T,n+=64,s-=64}return n}var oa=hr();let _n;function Yi(t){return{lang:t?.lang??_n?.lang,message:t?.message,abortEarly:t?.abortEarly??_n?.abortEarly,abortPipeEarly:t?.abortPipeEarly??_n?.abortPipeEarly}}let aa;function ca(t){return aa?.get(t)}let ua;function fa(t){return ua?.get(t)}let la;function ha(t,e){return la?.get(t)?.get(e)}function vr(t){const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&Object.getPrototypeOf(t)?.constructor?.name)??"null":e}function Oe(t,e,r,n,s){const i=s&&"input"in s?s.input:r.value,c=s?.expected??t.expects??null,l=s?.received??vr(i),h={kind:t.kind,type:t.type,input:i,expected:c,received:l,message:`Invalid ${e}: ${c?`Expected ${c} but r`:"R"}eceived ${l}`,requirement:t.requirement,path:s?.path,issues:s?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},w=t.kind==="schema",d=s?.message??t.message??ha(t.reference,h.lang)??(w?fa(h.lang):null)??n.message??ca(h.lang);d!==void 0&&(h.message=typeof d=="function"?d(h):d),w&&(r.typed=!1),r.issues?r.issues.push(h):r.issues=[h]}function ze(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Yi())}}}function da(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function Qi(t,e){return{kind:"validation",type:"check",reference:Qi,async:!1,expects:null,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement(r.value)&&Oe(this,"input",r,n),r}}}function er(t){return{kind:"validation",type:"integer",reference:er,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,r){return e.typed&&!this.requirement(e.value)&&Oe(this,"integer",e,r),e}}}function Lt(t,e){return{kind:"validation",type:"max_length",reference:Lt,async:!1,expects:`<=${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&r.value.length>this.requirement&&Oe(this,"length",r,n,{received:`${r.value.length}`}),r}}}function tr(t,e){return{kind:"validation",type:"min_value",reference:tr,async:!1,expects:`>=${t instanceof Date?t.toJSON():vr(t)}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!(r.value>=this.requirement)&&Oe(this,"value",r,n,{received:r.value instanceof Date?r.value.toJSON():vr(r.value)}),r}}}function Xi(t,e){return{kind:"validation",type:"regex",reference:Xi,async:!1,expects:`${t}`,requirement:t,message:e,"~run"(r,n){return r.typed&&!this.requirement.test(r.value)&&Oe(this,"format",r,n),r}}}function pa(t,e,r){return typeof t.fallback=="function"?t.fallback(e,r):t.fallback}function Zi(t,e,r){return typeof t.default=="function"?t.default(e,r):t.default}function Jt(t,e){return{kind:"schema",type:"array",reference:Jt,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){const s=r.value;if(Array.isArray(s)){r.typed=!0,r.value=[];for(let i=0;i<s.length;i++){const c=s[i],l=this.item["~run"]({value:c},n);if(l.issues){const h={type:"array",origin:"value",input:s,key:i,value:c};for(const w of l.issues)w.path?w.path.unshift(h):w.path=[h],r.issues?.push(w);if(r.issues||(r.issues=l.issues),n.abortEarly){r.typed=!1;break}}l.typed||(r.typed=!1),r.value.push(l.value)}}else Oe(this,"type",r,n);return r}}}function vn(t){return{kind:"schema",type:"boolean",reference:vn,expects:"boolean",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="boolean"?e.typed=!0:Oe(this,"type",e,r),e}}}function Tn(t,e){return{kind:"schema",type:"instance",reference:Tn,expects:t.name,async:!1,class:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value instanceof this.class?r.typed=!0:Oe(this,"type",r,n),r}}}function He(t,e){return{kind:"schema",type:"literal",reference:He,expects:vr(t),async:!1,literal:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value===this.literal?r.typed=!0:Oe(this,"type",r,n),r}}}function rr(t){return{kind:"schema",type:"number",reference:rr,expects:"number",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Oe(this,"type",e,r),e}}}function he(t,e){return{kind:"schema",type:"optional",reference:he,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return ze(this)},"~run"(r,n){return r.value===void 0&&(this.default!==void 0&&(r.value=Zi(this,r,n)),r.value===void 0)?(r.typed=!0,r):this.wrapped["~run"](r,n)}}}function es(t,e,r){return{kind:"schema",type:"record",reference:es,expects:"Object",async:!1,key:t,value:e,message:r,get"~standard"(){return ze(this)},"~run"(n,s){const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const c in i)if(da(i,c)){const l=i[c],h=this.key["~run"]({value:c},s);if(h.issues){const d={type:"object",origin:"key",input:i,key:c,value:l};for(const I of h.issues)I.path=[d],n.issues?.push(I);if(n.issues||(n.issues=h.issues),s.abortEarly){n.typed=!1;break}}const w=this.value["~run"]({value:l},s);if(w.issues){const d={type:"object",origin:"value",input:i,key:c,value:l};for(const I of w.issues)I.path?I.path.unshift(d):I.path=[d],n.issues?.push(I);if(n.issues||(n.issues=w.issues),s.abortEarly){n.typed=!1;break}}(!h.typed||!w.typed)&&(n.typed=!1),h.typed&&(n.value[h.value]=w.value)}}else Oe(this,"type",n,s);return n}}}function We(t,e){return{kind:"schema",type:"strict_object",reference:We,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return ze(this)},"~run"(r,n){const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const i in this.entries){const c=this.entries[i];if(i in s||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){const l=i in s?s[i]:Zi(c),h=c["~run"]({value:l},n);if(h.issues){const w={type:"object",origin:"value",input:s,key:i,value:l};for(const d of h.issues)d.path?d.path.unshift(w):d.path=[w],r.issues?.push(d);if(r.issues||(r.issues=h.issues),n.abortEarly){r.typed=!1;break}}h.typed||(r.typed=!1),r.value[i]=h.value}else if(c.fallback!==void 0)r.value[i]=pa(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(Oe(this,"key",r,n,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]}),n.abortEarly))break}if(!r.issues||!n.abortEarly){for(const i in s)if(!(i in this.entries)){Oe(this,"key",r,n,{input:i,expected:"never",path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]});break}}}else Oe(this,"type",r,n);return r}}}function ve(t){return{kind:"schema",type:"string",reference:ve,expects:"string",async:!1,message:t,get"~standard"(){return ze(this)},"~run"(e,r){return typeof e.value=="string"?e.typed=!0:Oe(this,"type",e,r),e}}}function Ut(){return{kind:"schema",type:"unknown",reference:Ut,expects:"unknown",async:!1,get"~standard"(){return ze(this)},"~run"(t){return t.typed=!0,t}}}function Ke(...t){return{...t[0],pipe:t,get"~standard"(){return ze(this)},"~run"(e,r){for(const n of t)if(n.kind!=="metadata"){if(e.issues&&(n.kind==="schema"||n.kind==="transformation")){e.typed=!1;break}(!e.issues||!r.abortEarly&&!r.abortPipeEarly)&&(e=n["~run"](e,r))}return e}}}function ya(t,e,r){const n=t["~run"]({value:e},Yi(r));return{typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}const z={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},ae={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,CBOR:24,URI:32,BASE64URL:33,BASE64:34,DATE_EPOCH_DAYS:100,SET:258,JSON:262,WTF8:273,SYMBOL:280,DATE_FULL:1004,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},ne={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},_t={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Me=class{static BREAK=Symbol.for("github.com/hildjj/cbor2/break");static ENCODED=Symbol.for("github.com/hildjj/cbor2/cbor-encoded");static LENGTH=Symbol.for("github.com/hildjj/cbor2/length")};const Tr={MIN:-(2n**63n),MAX:2n**64n-1n};let re=class jr{static#e=new Map;tag;contents;constructor(e,r=void 0){this.tag=e,this.contents=r}get noChildren(){return!!jr.#e.get(this.tag)?.noChildren}static registerDecoder(e,r,n){const s=this.#e.get(e);return this.#e.set(e,r),s&&("comment"in r||(r.comment=s.comment),"noChildren"in r||(r.noChildren=s.noChildren)),n&&!r.comment&&(r.comment=()=>`(${n})`),s}static clearDecoder(e){const r=this.#e.get(e);return this.#e.delete(e),r}static getDecoder(e){return this.#e.get(e)}static getAllDecoders(){return new Map(this.#e)}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const r=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:jr.#e.get(this.tag));return r?r(this,e):this}comment(e,r){const n=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:jr.#e.get(this.tag));if(n?.comment)return n.comment(this,e,r)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return`${this.tag}(${n(this.contents,r)})`}};function xr(t){if(t!=null&&typeof t=="object")return t[Me.ENCODED]}function wa(t){if(t!=null&&typeof t=="object")return t[Me.LENGTH]}function nr(t,e){Object.defineProperty(t,Me.ENCODED,{configurable:!0,enumerable:!1,value:e})}function ir(t,e){const r=Object(t);return nr(r,e),r}const xn=Symbol("CBOR_RANGES");function ts(t,e){Object.defineProperty(t,xn,{configurable:!1,enumerable:!1,writable:!1,value:e})}function Ar(t){return t[xn]}function ga(t){return Ar(t)!==void 0}function An(t,e=0,r=t.length-1){const n=t.subarray(e,r),s=Ar(t);if(s){const i=[];for(const c of s)if(c[0]>=e&&c[0]+c[1]<=r){const l=[...c];l[0]-=e,i.push(l)}i.length&&ts(n,i)}return n}function rs(t){let e=Math.ceil(t.length/2);const r=new Uint8Array(e);e--;for(let n=t.length,s=n-2;n>=0;n=s,s-=2,e--)r[e]=parseInt(t.substring(s,n),16);return r}function $e(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function ma(t){const e=t.reduce((c,l)=>c+l.length,0),r=t.some(c=>ga(c)),n=[],s=new Uint8Array(e);let i=0;for(const c of t){if(!(c instanceof Uint8Array))throw new TypeError(`Invalid array: ${c}`);if(s.set(c,i),r){const l=c[xn]??[[0,c.length]];for(const h of l)h[0]+=i;n.push(...l)}i+=c.length}return r&&ts(s,n),s}function Rn(t){const e=atob(t);return Uint8Array.from(e,r=>r.codePointAt(0))}const ba={"-":"+",_:"/"};function Ea(t){const e=t.replace(/[_-]/g,r=>ba[r]);return Rn(e.padEnd(Math.ceil(e.length/4)*4,"="))}function Sa(){const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])}function ns(t){let e="";for(const r of t){const n=r.codePointAt(0)?.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${n}`}return e}class is{#e=new Map;registerEncoder(e,r){const n=this.#e.get(e);return this.#e.set(e,r),n}get(e){return this.#e.get(e)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}}function ss(t,e){const[r,n,s]=t,[i,c,l]=e,h=Math.min(s.length,l.length);for(let w=0;w<h;w++){const d=s[w]-l[w];if(d!==0)return d}return 0}class Rr{static defaultOptions={chunkSize:4096};#e;#t=[];#r=null;#n=0;#i=0;constructor(e={}){if(this.#e={...Rr.defaultOptions,...e},this.#e.chunkSize<8)throw new RangeError(`Expected size >= 8, got ${this.#e.chunkSize}`);this.#s()}get length(){return this.#i}read(){this.#c();const e=new Uint8Array(this.#i);let r=0;for(const n of this.#t)e.set(n,r),r+=n.length;return this.#s(),e}write(e){const r=e.length;r>this.#u()?(this.#c(),r>this.#e.chunkSize?(this.#t.push(e),this.#s()):(this.#s(),this.#t[this.#t.length-1].set(e),this.#n=r)):(this.#t[this.#t.length-1].set(e,this.#n),this.#n+=r),this.#i+=r}writeUint8(e){this.#o(1),this.#r.setUint8(this.#n,e),this.#a(1)}writeUint16(e,r=!1){this.#o(2),this.#r.setUint16(this.#n,e,r),this.#a(2)}writeUint32(e,r=!1){this.#o(4),this.#r.setUint32(this.#n,e,r),this.#a(4)}writeBigUint64(e,r=!1){this.#o(8),this.#r.setBigUint64(this.#n,e,r),this.#a(8)}writeInt16(e,r=!1){this.#o(2),this.#r.setInt16(this.#n,e,r),this.#a(2)}writeInt32(e,r=!1){this.#o(4),this.#r.setInt32(this.#n,e,r),this.#a(4)}writeBigInt64(e,r=!1){this.#o(8),this.#r.setBigInt64(this.#n,e,r),this.#a(8)}writeFloat32(e,r=!1){this.#o(4),this.#r.setFloat32(this.#n,e,r),this.#a(4)}writeFloat64(e,r=!1){this.#o(8),this.#r.setFloat64(this.#n,e,r),this.#a(8)}clear(){this.#i=0,this.#t=[],this.#s()}#s(){const e=new Uint8Array(this.#e.chunkSize);this.#t.push(e),this.#n=0,this.#r=new DataView(e.buffer,e.byteOffset,e.byteLength)}#c(){if(this.#n===0){this.#t.pop();return}const e=this.#t.length-1;this.#t[e]=this.#t[e].subarray(0,this.#n),this.#n=0,this.#r=null}#u(){const e=this.#t.length-1;return this.#t[e].length-this.#n}#o(e){this.#u()<e&&(this.#c(),this.#s())}#a(e){this.#n+=e,this.#i+=e}}const In=1n<<15n,sr=0b11111n<<10n,os=1n<<9n,as=os-1n,cs=os|as,Bn=1n<<31n,or=0b11111111n<<23n,us=1n<<22n,fs=us-1n,ls=us|fs,Ir=1n<<63n,dt=0b11111111111n<<52n,ar=1n<<51n,Br=ar-1n,hs=ar|Br,ds=Br-(as<<42n),ps=Br-(fs<<29n),_a={2:"0b",8:"0o",16:"0x"};var va=(t=>(t[t.NATURAL=-2]="NATURAL",t[t.UNKNOWN=-1]="UNKNOWN",t[t.F16=2]="F16",t[t.F32=4]="F32",t[t.F64=8]="F64",t))(va||{});function ys(t,e,r,n){let s="nan'";return t.quiet||(s+="!"),t.sign===-1&&(s+="-"),s+=n(Math.abs(t.payload),r),s+="'",s+=t.encodingIndicator,s}let Ta=class extends Number{#e;#t=-1;constructor(e,r=!0,n=-1){super(NaN);const s=e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid NAN payload: ${e}`);e=BigInt(e);let i=0n;if(e<0&&(i=Ir,e=-e),e>=ar)throw new Error(`Payload too large: ${s}`);const c=r?ar:0n;switch(this.#e=i|dt|c|e,n){case-2:throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");case-1:n=this.preferredSize;break;case 2:if(this.#e&ds)throw new Error("Invalid size for payload");break;case 4:if(this.#e&ps)throw new Error("Invalid size for payload");break;case 8:break;default:throw new Error(`Invalid size: ${n}`)}this.#t=n}else if(typeof e=="bigint"){let i=-1;if((e&dt)===dt)this.#e=e,i=8;else if((e&or)===or){const c=(e&Bn)<<32n;this.#e=c|dt|(e&ls)<<29n,i=4}else if((e&sr)===sr){const c=(e&In)<<48n;this.#e=c|dt|(e&cs)<<42n,i=2}else throw new Error(`Invalid raw NaN value: ${e}`);if(n===-1)this.#t=this.preferredSize;else if(n===-2)this.#t=i;else{if(n<i)throw new Error("Invalid bigint NaN size");this.#t=n}}else{const i=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw new Error("Invalid CBOR encoding for half float");const c=BigInt(i.getUint16(1,!1));if((c&sr)!==sr)throw new Error("Not a NaN");const l=(c&In)<<48n;this.#e=l|dt|(c&cs)<<42n,this.#t=2;break}case 5:{if(e[0]!==250)throw new Error("Invalid CBOR encoding for single float");const c=BigInt(i.getUint32(1,!1));if((c&or)!==or)throw new Error("Not a NaN");const l=(c&Bn)<<32n;this.#e=l|dt|(c&ls)<<29n,this.#t=4;break}case 9:{if(e[0]!==251)throw new Error("Invalid CBOR encoding for double float");if(this.#e=i.getBigUint64(1,!1),(this.#e&dt)!==dt)throw new Error("Not a NaN (NaNaN)");this.#t=8;break}default:throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${e.length-1}`)}}if(!this.payload&&!this.quiet)throw new Error("Signalling NaN with zero payload")}get bytes(){const e=new ArrayBuffer(this.#t+1),r=new DataView(e);switch(this.#t){case 2:{r.setUint8(0,249);const n=(this.#e&Ir?In:0n)|sr|(this.#e&hs)>>42n;r.setUint16(1,Number(n),!1);break}case 4:{r.setUint8(0,250);const n=(this.#e&Ir?Bn:0n)|or|(this.#e&hs)>>29n;r.setUint32(1,Number(n),!1);break}case 8:r.setUint8(0,251),r.setBigUint64(1,this.#e);break}return new Uint8Array(e)}get quiet(){return!!(this.#e&ar)}get sign(){return this.#e&Ir?-1:1}get payload(){return Number(this.#e&Br)*this.sign}get raw(){return this.#e}get encodingIndicator(){switch(this.#t){case 2:return"_1";case 4:return"_2"}return"_3"}get size(){return this.#t}get preferredSize(){return(this.#e&ds)===0n?2:(this.#e&ps)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return ys(this,1,{},r=>(_a[e]??"")+r.toString(e))}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return ys(this,e,r,n)}};function ws(t,e=0,r=!1){const n=t[e]&128?-1:1,s=(t[e]&124)>>2,i=(t[e]&3)<<8|t[e+1];if(s===0){if(r&&i!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*i}`);return n*5960464477539063e-23*i}else if(s===31)return i?NaN:n*(1/0);return n*2**(s-25)*(1024+i)}function gs(t){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,t,!1);const r=e.getUint32(0,!1);if((r&8191)!==0)return null;let n=r>>16&32768;const s=r>>23&255,i=r&8388607;if(!(s===0&&i===0))if(s>=113&&s<=142)n+=(s-112<<10)+(i>>13);else if(s>=103&&s<113){if(i&(1<<126-s)-1)return null;n+=i+8388608>>126-s}else if(s===255)n|=31744,n|=i>>13;else return null;return n}function xa(t){if(t!==0){const e=new ArrayBuffer(8),r=new DataView(e);r.setFloat64(0,t,!1);const n=r.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return t}function Aa(t){switch(t.length){case 2:ws(t,0,!0);break;case 4:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint32(0,!1);if((r&2139095040)===0&&r&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getBigUint64(0,!1);if((r&0x7ff0000000000000n)===0n&&r&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${t}`)}}class Ra extends TypeError{code="ERR_ENCODING_INVALID_ENCODED_DATA";constructor(){super("The encoded data was not valid for encoding wtf-8")}}class Ia extends RangeError{code="ERR_ENCODING_NOT_SUPPORTED";constructor(e){super(`Invalid encoding: "${e}"`)}}const Ba=65279,ms=new Uint8Array(0),Na=55296,ka=56320,Fa=65533,bs="wtf-8";function La(t){return t&&typeof t=="object"&&!(t instanceof ArrayBuffer)&&!(t instanceof SharedArrayBuffer)&&t.buffer instanceof ArrayBuffer}function Ua(t){return t?t instanceof Uint8Array?t:La(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t):ms}const Ma=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3];class Nr{static DEFAULT_BUFFERSIZE=4096;encoding=bs;fatal;ignoreBOM;bufferSize;#e=0;#t=0;#r=0;#n=!0;#i;constructor(e="wtf8",r=void 0){if(e.toLowerCase().replace("-","")!=="wtf8")throw new Ia(e);if(this.fatal=!!r?.fatal,this.ignoreBOM=!!r?.ignoreBOM,this.bufferSize=Math.floor(r?.bufferSize??Nr.DEFAULT_BUFFERSIZE),isNaN(this.bufferSize)||this.bufferSize<1)throw new RangeError(`Invalid buffer size: ${r?.bufferSize}`);this.#i=new Uint16Array(this.bufferSize)}decode(e,r){const n=!!r?.stream,s=Ua(e),i=[],c=this.#i,l=this.bufferSize-3;let h=0;const w=()=>{if(this.#t=0,this.#e=0,this.#r=0,this.fatal)throw new Ra;c[h++]=Fa},d=()=>{const T=this.#r;for(let L=0;L<T;L++)w()},I=T=>{if(this.#e===0)switch(Ma[T>>4]){case-1:w();break;case 0:c[h++]=T;break;case 1:this.#t=T&31,(this.#t&30)===0?w():(this.#e=1,this.#r=1);break;case 2:this.#t=T&15,this.#e=2,this.#r=1;break;case 3:T&8?w():(this.#t=T&7,this.#e=3,this.#r=1);break}else{if((T&192)!==128||this.#r===1&&this.#e===2&&this.#t===0&&(T&32)===0||this.#e===3&&this.#t===0&&(T&48)===0)return d(),I(T);if(this.#t=this.#t<<6|T&63,this.#r++,--this.#e===0){if(this.ignoreBOM||!this.#n||this.#t!==Ba)if(this.#t<65536)c[h++]=this.#t;else{const L=this.#t-65536;c[h++]=L>>>10&1023|Na,c[h++]=L&1023|ka}this.#t=0,this.#r=0,this.#n=!1}}};for(const T of s)h>=l&&(i.push(String.fromCharCode.apply(null,c.subarray(0,h))),h=0),I(T);return n||(this.#n=!0,(this.#t||this.#e)&&d()),h>0&&i.push(String.fromCharCode.apply(null,c.subarray(0,h))),i.join("")}}function Pa(t){let e=0;for(const r of t){const n=r.codePointAt(0);n<128?e++:n<2048?e+=2:n<65536?e+=3:e+=4}return e}class Da{encoding=bs;encode(e){if(!e)return ms;const r=new Uint8Array(Pa(String(e)));return this.encodeInto(e,r),r}encodeInto(e,r){const n=String(e),s=n.length,i=r.length;let c=0,l=0;for(l=0;l<s;l++){const h=n.codePointAt(l);if(h<128){if(c>=i)break;r[c++]=h}else if(h<2048){if(c>=i-1)break;r[c++]=192|h>>6,r[c++]=128|h&63}else if(h<65536){if(c>=i-2)break;r[c++]=224|h>>12,r[c++]=128|h>>6&63,r[c++]=128|h&63}else{if(c>=i-3)break;r[c++]=240|h>>18,r[c++]=128|h>>12&63,r[c++]=128|h>>6&63,r[c++]=128|h&63,l++}}return{read:l,written:c}}}const Es=z.SIMPLE_FLOAT<<5|ne.TWO,Oa=z.SIMPLE_FLOAT<<5|ne.FOUR,Ca=z.SIMPLE_FLOAT<<5|ne.EIGHT,$a=z.SIMPLE_FLOAT<<5|_t.TRUE,qa=z.SIMPLE_FLOAT<<5|_t.FALSE,ja=z.SIMPLE_FLOAT<<5|_t.UNDEFINED,Ha=z.SIMPLE_FLOAT<<5|_t.NULL,Wa=new TextEncoder,Ka=new Da,Ss={...Rr.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:ae.DATE_EPOCH,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null,types:null,wtf8:!1,ignoreGlobalTags:!1},_s={cde:!0,ignoreOriginalEncoding:!0,sortKeys:ss},Ga={..._s,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function vs(t){const e=t<0;return typeof t=="bigint"?[e?-t-1n:t,e]:[e?-t-1:t,e]}function Nn(t,e,r){if(r.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${t}`);if(isNaN(t))e.writeUint8(Es),e.writeUint16(32256);else if(!r.float64&&Math.fround(t)===t){const n=gs(t);n===null?(e.writeUint8(Oa),e.writeFloat32(t)):(e.writeUint8(Es),e.writeUint16(n))}else e.writeUint8(Ca),e.writeFloat64(t)}function Ge(t,e,r){const[n,s]=vs(t);if(s&&r)throw new TypeError(`Negative size: ${t}`);r??=s?z.NEG_INT:z.POS_INT,r<<=5,n<24?e.writeUint8(r|n):n<=255?(e.writeUint8(r|ne.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(r|ne.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(r|ne.FOUR),e.writeUint32(n)):(e.writeUint8(r|ne.EIGHT),e.writeBigUint64(BigInt(n)))}function zt(t,e,r){typeof t=="number"?Ge(t,e,z.TAG):typeof t=="object"&&!r.ignoreOriginalEncoding&&Me.ENCODED in t?e.write(t[Me.ENCODED]):t<=Number.MAX_SAFE_INTEGER?Ge(Number(t),e,z.TAG):(e.writeUint8(z.TAG<<5|ne.EIGHT),e.writeBigUint64(BigInt(t)))}function Ts(t,e,r){const[n,s]=vs(t);if(r.collapseBigInts&&(!r.largeNegativeAsBigInt||t>=-0x8000000000000000n)){if(n<=0xffffffffn){Ge(Number(t),e);return}if(n<=0xffffffffffffffffn){const w=(s?z.NEG_INT:z.POS_INT)<<5;e.writeUint8(w|ne.EIGHT),e.writeBigUint64(n);return}}if(r.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${t}`);const i=s?ae.NEG_BIGINT:ae.POS_BIGINT,c=n.toString(16),l=c.length%2?"0":"";zt(i,e,r);const h=rs(l+c);Ge(h.length,e,z.BYTE_STRING),e.write(h)}function Ja(t,e,r){r.flushToZero&&(t=xa(t)),Object.is(t,-0)?r.simplifyNegativeZero?r.avoidInts?Nn(0,e,r):Ge(0,e):Nn(t,e,r):!r.avoidInts&&Number.isSafeInteger(t)?Ge(t,e):r.reduceUnsafeNumbers&&Math.floor(t)===t&&t>=Tr.MIN&&t<=Tr.MAX?Ts(BigInt(t),e,r):Nn(t,e,r)}function xs(t,e,r){const n=r.stringNormalization?t.normalize(r.stringNormalization):t;if(r.wtf8&&!t.isWellFormed()){const s=Ka.encode(n);zt(ae.WTF8,e,r),Ge(s.length,e,z.BYTE_STRING),e.write(s)}else{const s=Wa.encode(n);Ge(s.length,e,z.UTF8_STRING),e.write(s)}}function za(t,e,r){const n=t;kn(n,n.length,z.ARRAY,e,r);for(const s of n)Mt(s,e,r)}function Va(t,e){Ge(t.length,e,z.BYTE_STRING),e.write(t)}const kr=new is;kr.registerEncoder(Array,za),kr.registerEncoder(Uint8Array,Va);function Ae(t,e){return kr.registerEncoder(t,e)}function kn(t,e,r,n,s){const i=wa(t);i&&!s.ignoreOriginalEncoding?n.write(i):Ge(e,n,r)}function Ya(t,e,r){if(t===null){e.writeUint8(Ha);return}if(!r.ignoreOriginalEncoding&&Me.ENCODED in t){e.write(t[Me.ENCODED]);return}const n=t.constructor;if(n){const i=r.types?.get(n)??(r.ignoreGlobalTags?void 0:kr.get(n));if(i){const c=i(t,e,r);if(c!==void 0){if(!Array.isArray(c)||c.length!==2)throw new Error("Invalid encoder return value");(typeof c[0]=="bigint"||isFinite(Number(c[0])))&&zt(c[0],e,r),Mt(c[1],e,r)}return}}if(typeof t.toCBOR=="function"){const i=t.toCBOR(e,r);i&&((typeof i[0]=="bigint"||isFinite(Number(i[0])))&&zt(i[0],e,r),Mt(i[1],e,r));return}if(typeof t.toJSON=="function"){Mt(t.toJSON(),e,r);return}const s=Object.entries(t).map(i=>[i[0],i[1],Vt(i[0],r)]);r.sortKeys&&s.sort(r.sortKeys),kn(t,s.length,z.MAP,e,r);for(const[i,c,l]of s)e.write(l),Mt(c,e,r)}function Qa(t,e,r){if(!t.description||t!==Symbol.for(t.description))throw new TypeError(`Private or empty symbol: ${t.toString()}`);zt(280,e,r),xs(t.description,e,r)}function Mt(t,e,r){switch(typeof t){case"number":Ja(t,e,r);break;case"bigint":Ts(t,e,r);break;case"string":xs(t,e,r);break;case"boolean":e.writeUint8(t?$a:qa);break;case"undefined":if(r.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(ja);break;case"object":Ya(t,e,r);break;case"symbol":Qa(t,e,r);break;default:throw new TypeError(`Unknown type: ${typeof t}, ${String(t)}`)}}function Vt(t,e={}){const r={...Ss};e.dcbor?Object.assign(r,Ga):e.cde&&Object.assign(r,_s),Object.assign(r,e);const n=new Rr(r);return Mt(t,n,r),n.read()}var Fr=(t=>(t[t.NEVER=-1]="NEVER",t[t.PREFERRED=0]="PREFERRED",t[t.ALWAYS=1]="ALWAYS",t))(Fr||{});class ot{static KnownSimple=new Map([[_t.FALSE,!1],[_t.TRUE,!0],[_t.NULL,null],[_t.UNDEFINED,void 0]]);value;constructor(e){this.value=e}static create(e){return ot.KnownSimple.has(e)?ot.KnownSimple.get(e):new ot(e)}toCBOR(e,r){if(r.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Ge(this.value,e,z.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return ot.KnownSimple.has(this.value)?ot.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return`simple(${n(this.value,r)})`}}const Xa=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});let Lr=class Ys{static defaultOptions={maxDepth:1024,encoding:"hex",requirePreferred:!1};#e;#t;#r=0;#n;constructor(e,r){if(this.#n={...Ys.defaultOptions,...r},typeof e=="string")switch(this.#n.encoding){case"hex":this.#e=rs(e);break;case"base64":this.#e=Rn(e);break;default:throw new TypeError(`Encoding not implemented: "${this.#n.encoding}"`)}else this.#e=e;this.#t=new DataView(this.#e.buffer,this.#e.byteOffset,this.#e.byteLength)}toHere(e){return An(this.#e,e,this.#r)}*[Symbol.iterator](){if(yield*this.#i(0),this.#r!==this.#e.length)throw new Error("Extra data in input")}*seq(){for(;this.#r<this.#e.length;)yield*this.#i(0)}*#i(e){if(e++>this.#n.maxDepth)throw new Error(`Maximum depth ${this.#n.maxDepth} exceeded`);const r=this.#r,n=this.#t.getUint8(this.#r++),s=n>>5,i=n&31;let c=i,l=!1,h=0;switch(i){case ne.ONE:if(h=1,c=this.#t.getUint8(this.#r),s===z.SIMPLE_FLOAT){if(c<32)throw new Error(`Invalid simple encoding in extra byte: ${c}`);l=!0}else if(this.#n.requirePreferred&&c<24)throw new Error(`Unexpectedly long integer encoding (1) for ${c}`);break;case ne.TWO:if(h=2,s===z.SIMPLE_FLOAT)c=ws(this.#e,this.#r);else if(c=this.#t.getUint16(this.#r,!1),this.#n.requirePreferred&&c<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${c}`);break;case ne.FOUR:if(h=4,s===z.SIMPLE_FLOAT)c=this.#t.getFloat32(this.#r,!1);else if(c=this.#t.getUint32(this.#r,!1),this.#n.requirePreferred&&c<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${c}`);break;case ne.EIGHT:{if(h=8,s===z.SIMPLE_FLOAT)c=this.#t.getFloat64(this.#r,!1);else if(c=this.#t.getBigUint64(this.#r,!1),c<=Number.MAX_SAFE_INTEGER&&(c=Number(c)),this.#n.requirePreferred&&c<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${c}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${i}`);case ne.INDEFINITE:switch(s){case z.POS_INT:case z.NEG_INT:case z.TAG:throw new Error(`Invalid indefinite encoding for MT ${s}`);case z.SIMPLE_FLOAT:yield[s,i,Me.BREAK,r,0];return}c=1/0;break;default:l=!0}switch(this.#r+=h,s){case z.POS_INT:yield[s,i,c,r,h];break;case z.NEG_INT:yield[s,i,typeof c=="bigint"?-1n-c:-1-Number(c),r,h];break;case z.BYTE_STRING:c===1/0?yield*this.#c(s,e,r):yield[s,i,this.#s(c),r,c];break;case z.UTF8_STRING:c===1/0?yield*this.#c(s,e,r):yield[s,i,Xa.decode(this.#s(c)),r,c];break;case z.ARRAY:if(c===1/0)yield*this.#c(s,e,r,!1);else{const w=Number(c);yield[s,i,w,r,h];for(let d=0;d<w;d++)yield*this.#i(e+1)}break;case z.MAP:if(c===1/0)yield*this.#c(s,e,r,!1);else{const w=Number(c);yield[s,i,w,r,h];for(let d=0;d<w;d++)yield*this.#i(e),yield*this.#i(e)}break;case z.TAG:yield[s,i,c,r,h],yield*this.#i(e);break;case z.SIMPLE_FLOAT:{const w=c;l&&(c=ot.create(Number(c))),yield[s,i,c,r,w];break}}}#s(e){const r=An(this.#e,this.#r,this.#r+=e);if(r.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${r.length}`);return r}*#c(e,r,n,s=!0){for(yield[e,ne.INDEFINITE,1/0,n,1/0];;){const i=this.#i(r),c=i.next(),[l,h,w]=c.value;if(w===Me.BREAK){yield c.value,i.next();return}if(s){if(l!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${l}.`);if(h===ne.INDEFINITE)throw new Error("New stream started in typed stream")}yield c.value,yield*i}}};const Za=new Map([[ne.ZERO,1],[ne.ONE,2],[ne.TWO,3],[ne.FOUR,5],[ne.EIGHT,9]]),ec=new Uint8Array(0);function tc(t,e){return!e.boxed&&!e.preferMap&&t.every(([r])=>typeof r=="string")?Object.fromEntries(t):new Map(t)}let qe=class Qs{static defaultDecodeOptions={...Lr.defaultOptions,ParentType:Qs,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Fr.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:tc,keepNanPayloads:!1,pretty:!1,preferBigInt:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null,tags:null,ignoreGlobalTags:!1};static cdeDecodeOptions={cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:ss};static dcborDecodeOptions={...this.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"};parent;mt;ai;left;offset;count=0;children=[];depth=0;#e;#t=null;constructor(e,r,n,s){if([this.mt,this.ai,,this.offset]=e,this.left=r,this.parent=n,this.#e=s,n&&(this.depth=n.depth+1),this.mt===z.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===ne.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,r,n,s){const[i,c,l,h]=e;switch(i){case z.POS_INT:case z.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${l}`);if(n.rejectLargeNegatives&&l<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${l}`);let w=l;return n.preferBigInt?w=BigInt(w):n.convertUnsafeIntsToFloat&&w>=Tr.MIN&&w<=Tr.MAX&&(w=Number(l)),n.boxed?ir(w,s.toHere(h)):w}case z.SIMPLE_FLOAT:if(c>ne.ONE){if(typeof l=="symbol")return l;if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${l}`);if(n.rejectNegativeZero&&Object.is(l,-0))throw new Error("Decoding negative zero");if(isNaN(l)){const w=s.toHere(h),d=new Ta(w);if(n.rejectLongLoundNaN){if(d.payload||w.length>3)throw new Error(`Invalid NaN encoding: "${$e(w)}"`)}else if(n.keepNanPayloads&&(d.payload||d.sign===-1)){if(n.rejectLongFloats&&!d.isShortestEncoding)throw new Error(`NaN should have been encoded shorter: ${l}`);return d}}if(n.rejectSubnormals&&Aa(s.toHere(h+1)),n.rejectLongFloats){const w=Vt(l,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(w[0]>>5!==i)throw new Error(`Should have been encoded as int, not float: ${l}`);if(w.length<Za.get(c))throw new Error(`Number should have been encoded shorter: ${l}`)}if(typeof l=="number"&&n.boxed)return ir(l,s.toHere(h))}else{if(n.rejectSimple&&l instanceof ot)throw new Error(`Invalid simple value: ${l}`);if(n.rejectUndefined&&l===void 0)throw new Error("Unexpected undefined")}return l;case z.BYTE_STRING:case z.UTF8_STRING:if(l===1/0)return new n.ParentType(e,1/0,r,n);if(n.rejectStringsNotNormalizedAs&&typeof l=="string"){const w=l.normalize(n.rejectStringsNotNormalizedAs);if(l!==w)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${ns(l)}] instead of [${ns(w)}]`)}return n.boxed?ir(l,s.toHere(h)):l;case z.ARRAY:return new n.ParentType(e,l,r,n);case z.MAP:return new n.ParentType(e,l*2,r,n);case z.TAG:{const w=new n.ParentType(e,1,r,n);return w.children=new re(l),w}}throw new TypeError(`Invalid major type: ${i}`)}static decodeToEncodeOpts(e){return{...Ss,avoidInts:e.rejectInts,float64:!e.rejectLongFloats,flushToZero:e.rejectSubnormals,largeNegativeAsBigInt:e.rejectLargeNegatives,sortKeys:e.sortKeys}}push(e,r,n){if(this.children.push(e),this.#t){const s=xr(e)||r.toHere(n);this.#t.push(s)}return--this.left}replaceLast(e,r,n){let s,i=-1/0;if(this.children instanceof re?(i=0,s=this.children.contents,this.children.contents=e):(i=this.children.length-1,s=this.children[i],this.children[i]=e),this.#t){const c=xr(e)||n.toHere(r.offset);this.#t[i]=c}return s}convert(e){let r;switch(this.mt){case z.ARRAY:r=this.children;break;case z.MAP:{const n=this.#r();if(this.#e.sortKeys){let s;for(const i of n){if(s&&this.#e.sortKeys(s,i)>=0)throw new Error(`Duplicate or out of order key: "0x${i[2]}"`);s=i}}else if(this.#e.rejectDuplicateKeys){const s=new Set;for(const[i,c,l]of n){const h=$e(l);if(s.has(h))throw new Error(`Duplicate key: "0x${h}"`);s.add(h)}}r=this.#e.createObject(n,this.#e);break}case z.BYTE_STRING:return ma(this.children);case z.UTF8_STRING:{const n=this.children.join("");r=this.#e.boxed?ir(n,e.toHere(this.offset)):n;break}case z.TAG:r=this.children.decode(this.#e);break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return this.#e.saveOriginal&&r&&typeof r=="object"&&nr(r,e.toHere(this.offset)),r}#r(){const e=this.children,r=e.length;if(r%2)throw new Error("Missing map value");const n=new Array(r/2);if(this.#t)for(let s=0;s<r;s+=2)n[s>>1]=[e[s],e[s+1],this.#t[s]];else for(let s=0;s<r;s+=2)n[s>>1]=[e[s],e[s+1],ec];return n}};const Fn=" ",rc=new TextEncoder;class As extends qe{close="";quote='"';get isEmptyStream(){return(this.mt===z.UTF8_STRING||this.mt===z.BYTE_STRING)&&this.count===0}}function vt(t,e,r,n){let s="";if(e===ne.INDEFINITE)s+="_";else{if(n.diagnosticSizes===Fr.NEVER)return"";{let i=n.diagnosticSizes===Fr.ALWAYS;if(!i){let c=ne.ZERO;if(Object.is(r,-0))c=ne.TWO;else if(t===z.POS_INT||t===z.NEG_INT){const l=r<0,h=typeof r=="bigint"?1n:1,w=l?-r-h:r;w<=23?c=Number(w):w<=255?c=ne.ONE:w<=65535?c=ne.TWO:w<=4294967295?c=ne.FOUR:c=ne.EIGHT}else isFinite(r)?Math.fround(r)===r?gs(r)==null?c=ne.FOUR:c=ne.TWO:c=ne.EIGHT:c=ne.TWO;i=c!==e}i&&(s+="_",e<ne.ONE?s+="i":s+=String(e-24))}}return s}function nc(t,e){const r={...qe.defaultDecodeOptions,...e,ParentType:As},n=new Lr(t,r);let s,i,c="";for(const l of n){const[h,w,d]=l;switch(s&&(s.count>0&&d!==Me.BREAK&&(s.mt===z.MAP&&s.count%2?c+=": ":(c+=",",r.pretty||(c+=" "))),r.pretty&&(s.mt!==z.MAP||s.count%2===0)&&(c+=`
|
|
3
|
+
${Fn.repeat(s.depth+1)}`)),i=qe.create(l,s,r,n),h){case z.POS_INT:case z.NEG_INT:c+=String(d),c+=vt(h,w,d,r);break;case z.SIMPLE_FLOAT:if(d!==Me.BREAK)if(typeof d=="number"){const I=Object.is(d,-0)?"-0.0":String(d);c+=I,isFinite(d)&&!/[.e]/.test(I)&&(c+=".0"),c+=vt(h,w,d,r)}else d instanceof ot?(c+="simple(",c+=String(d.value),c+=vt(z.POS_INT,w,d.value,r),c+=")"):c+=String(d);break;case z.BYTE_STRING:d===1/0?(c+="(_ ",i.close=")",i.quote="'"):(c+="h'",c+=$e(d),c+="'",c+=vt(z.POS_INT,w,d.length,r));break;case z.UTF8_STRING:d===1/0?(c+="(_ ",i.close=")"):(c+=JSON.stringify(d),c+=vt(z.POS_INT,w,rc.encode(d).length,r));break;case z.ARRAY:{c+="[";const I=vt(z.POS_INT,w,d,r);c+=I,I&&(c+=" "),r.pretty&&d?i.close=`
|
|
4
4
|
${Fn.repeat(i.depth)}]`:i.close="]";break}case z.MAP:{c+="{";const I=vt(z.POS_INT,w,d,r);c+=I,I&&(c+=" "),r.pretty&&d?i.close=`
|
|
5
|
-
${Fn.repeat(i.depth)}}`:i.close="}";break}case z.TAG:c+=String(d),c+=vt(z.POS_INT,w,d,r),c+="(",i.close=")";break}if(i===
|
|
6
|
-
`,s.length>i+1){const h=cr((t.depth+1)*2),w=Ar(s);if(w?.length){w.sort((I,T)=>I[0]-T[0]||T[1]-I[1]);let d=0;for(const[I,T,L]of w)if(!(I<d)){if(d=I+T,L==="<<"){n+=cr(e.minCol+1),n+="--",n+=h,n+="<< ";const B=An(s,I,I+T),
|
|
5
|
+
${Fn.repeat(i.depth)}}`:i.close="}";break}case z.TAG:c+=String(d),c+=vt(z.POS_INT,w,d,r),c+="(",i.close=")";break}if(i===Me.BREAK)if(s?.isStreaming)s.left=0;else throw new Error("Unexpected BREAK");else s&&(s.count++,s.left--);for(i instanceof As&&(s=i);s?.done;){if(s.isEmptyStream)c=c.slice(0,-3),c+=`${s.quote}${s.quote}_`;else{if(s.mt===z.MAP&&s.count%2!==0)throw new Error(`Odd streaming map size: ${s.count}`);c+=s.close}s=s.parent}}return c}const ic=new TextDecoder;class Ln extends qe{depth=0;leaf=!1;value;length;[Me.ENCODED];constructor(e,r,n,s){super(e,r,n,s),this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=e}numBytes(){switch(this.ai){case ne.ONE:return 1;case ne.TWO:return 2;case ne.FOUR:return 4;case ne.EIGHT:return 8}return 0}}function Rs(t){return t instanceof Ln}function Ur(t,e){return t===1/0?"Indefinite":e?`${t} ${e}${t!==1&&t!==1n?"s":""}`:String(t)}function cr(t){return"".padStart(t," ")}function Is(t,e,r){let n="";n+=cr(t.depth*2);const s=xr(t);n+=$e(s.subarray(0,1));const i=t.numBytes();i&&(n+=" ",n+=$e(s.subarray(1,i+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",r!==void 0&&(n+=cr(t.depth*2),r!==""&&(n+=`[${r}] `));let c=!1;const[l]=t.children;switch(t.mt){case z.POS_INT:n+=`Unsigned: ${l}`,typeof l=="bigint"&&(n+="n");break;case z.NEG_INT:n+=`Negative: ${l}`,typeof l=="bigint"&&(n+="n");break;case z.BYTE_STRING:n+=`Bytes (Length: ${Ur(t.length)})`;break;case z.UTF8_STRING:n+=`UTF8 (Length: ${Ur(t.length)})`,t.length!==1/0&&(n+=`: ${JSON.stringify(l)}`);break;case z.ARRAY:n+=`Array (Length: ${Ur(t.value,"item")})`;break;case z.MAP:n+=`Map (Length: ${Ur(t.value,"pair")})`;break;case z.TAG:{n+=`Tag #${t.value}`;const h=t.children,[w]=h.contents.children,d=new re(h.tag,w);nr(d,s);const I=d.comment(e,t.depth);I&&(n+=": ",n+=I),c||=d.noChildren;break}case z.SIMPLE_FLOAT:l===Me.BREAK?n+="BREAK":t.ai>ne.ONE?Object.is(l,-0)?n+="Float: -0":n+=`Float: ${l}`:(n+="Simple: ",l instanceof ot?n+=l.value:n+=l);break}if(!c)if(t.leaf){if(n+=`
|
|
6
|
+
`,s.length>i+1){const h=cr((t.depth+1)*2),w=Ar(s);if(w?.length){w.sort((I,T)=>I[0]-T[0]||T[1]-I[1]);let d=0;for(const[I,T,L]of w)if(!(I<d)){if(d=I+T,L==="<<"){n+=cr(e.minCol+1),n+="--",n+=h,n+="<< ";const B=An(s,I,I+T),j=Ar(B);if(j){const $=j.findIndex(([S,x,F])=>S===0&&x===T&&F==="<<");$>=0&&j.splice($,1)}n+=nc(B),n+=` >>
|
|
7
7
|
`,n+=Bs(B,{initialDepth:t.depth+1,minCol:e.minCol,noPrefixHex:!0});continue}else L==="'"&&(n+=cr(e.minCol+1),n+="--",n+=h,n+="'",n+=ic.decode(s.subarray(I,I+T)),n+=`'
|
|
8
|
-
`);if(I>i)for(let B=I;B<I+T;B+=8){const
|
|
8
|
+
`);if(I>i)for(let B=I;B<I+T;B+=8){const j=Math.min(B+8,I+T);n+=h,n+=$e(s.subarray(B,j)),n+=`
|
|
9
9
|
`}}}else for(let d=i+1;d<s.length;d+=8)n+=h,n+=$e(s.subarray(d,d+8)),n+=`
|
|
10
10
|
`}}else{n+=`
|
|
11
|
-
`;let h=0;for(const w of t.children){if(Rs(w)){let d=String(h);t.mt===z.MAP?d=h%2?`val ${(h-1)/2}`:`key ${h/2}`:t.mt===z.TAG&&(d=""),n+=Is(w,e,d)}h++}}return n}const sc={...qe.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Bs(t,e){const r={...sc,...e,ParentType:Ln,saveOriginal:!0},n=new Lr(t,r);let s,i;for(const l of n){if(i=qe.create(l,s,r,n),l[2]===
|
|
12
|
-
`;return c+=Is(i,r),c}const Ns=!Sa();function Mr(t){if(typeof t=="object"&&t){if(t.constructor!==Number)throw new Error(`Expected number: ${t}`)}else if(typeof t!="number")throw new Error(`Expected number: ${t}`)}function pt(t){if(typeof t=="object"&&t){if(t.constructor!==String)throw new Error(`Expected string: ${t}`)}else if(typeof t!="string")throw new Error(`Expected string: ${t}`)}function yt(t){if(!(t instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${t}`)}function ks(t){if(!Array.isArray(t))throw new Error(`Expected Array: ${t}`)}
|
|
11
|
+
`;let h=0;for(const w of t.children){if(Rs(w)){let d=String(h);t.mt===z.MAP?d=h%2?`val ${(h-1)/2}`:`key ${h/2}`:t.mt===z.TAG&&(d=""),n+=Is(w,e,d)}h++}}return n}const sc={...qe.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Bs(t,e){const r={...sc,...e,ParentType:Ln,saveOriginal:!0},n=new Lr(t,r);let s,i;for(const l of n){if(i=qe.create(l,s,r,n),l[2]===Me.BREAK)if(s?.isStreaming)s.left=1;else throw new Error("Unexpected BREAK");if(!Rs(i)){const d=new Ln(l,0,s,r);d.leaf=!0,d.children.push(i),nr(d,n.toHere(l[3])),i=d}let h=(i.depth+1)*2;const w=i.numBytes();for(w&&(h+=1,h+=w*2),r.minCol=Math.max(r.minCol,h),s&&s.push(i,n,l[3]),s=i;s?.done;)i=s,i.leaf||nr(i,n.toHere(i.offset)),{parent:s}=s}e&&(e.minCol=r.minCol);let c=r.noPrefixHex?"":`0x${$e(n.toHere(0))}
|
|
12
|
+
`;return c+=Is(i,r),c}const Ns=!Sa();function Mr(t){if(typeof t=="object"&&t){if(t.constructor!==Number)throw new Error(`Expected number: ${t}`)}else if(typeof t!="number")throw new Error(`Expected number: ${t}`)}function pt(t){if(typeof t=="object"&&t){if(t.constructor!==String)throw new Error(`Expected string: ${t}`)}else if(typeof t!="string")throw new Error(`Expected string: ${t}`)}function yt(t){if(!(t instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${t}`)}function ks(t){if(!Array.isArray(t))throw new Error(`Expected Array: ${t}`)}Ae(Map,(t,e,r)=>{const n=[...t.entries()].map(s=>[s[0],s[1],Vt(s[0],r)]);if(r.rejectDuplicateKeys){const s=new Set;for(const[i,c,l]of n){const h=$e(l);if(s.has(h))throw new Error(`Duplicate map key: 0x${h}`);s.add(h)}}r.sortKeys&&n.sort(r.sortKeys),kn(t,t.size,z.MAP,e,r);for(const[s,i,c]of n)e.write(c),Mt(i,e,r)});function Un(t){return pt(t.contents),new Date(t.contents)}Un.comment=t=>{pt(t.contents);const e=new Date(t.contents);return`(String ${t.tag===ae.DATE_FULL?"Full ":""}Date) ${e.toISOString()}`},re.registerDecoder(ae.DATE_STRING,Un),re.registerDecoder(ae.DATE_FULL,Un);function Fs(t){return Mr(t.contents),new Date(t.contents*1e3)}Fs.comment=t=>(Mr(t.contents),`(Epoch Date) ${new Date(t.contents*1e3).toISOString()}`),re.registerDecoder(ae.DATE_EPOCH,Fs);const Mn=1e3*60*60*24;function Ls(t){return Mr(t.contents),new Date(t.contents*Mn)}Ls.comment=t=>(Mr(t.contents),`(Epoch Date) ${new Date(t.contents*Mn).toISOString()}`),re.registerDecoder(ae.DATE_EPOCH_DAYS,Ls),Ae(Date,(t,e,r)=>{switch(r.dateTag){case ae.DATE_EPOCH:return[r.dateTag,t.valueOf()/1e3];case ae.DATE_STRING:return[r.dateTag,t.toISOString().replace(/\.000Z$/,"Z")];case ae.DATE_EPOCH_DAYS:return[r.dateTag,Math.floor(t.valueOf()/Mn)];case ae.DATE_FULL:return[r.dateTag,t.toISOString().split("T")[0]];default:throw new Error(`Unsupported date tag: ${r.dateTag}`)}});function Pr(t,e,r){if(yt(e.contents),r.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${$e(e.contents)}')`);if(r.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${$e(e.contents)})`);let n=e.contents.reduce((i,c)=>i<<8n|BigInt(c),0n);t&&(n=-1n-n);const s=n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER;if(r.requirePreferred&&s)throw new Error(`Decoding bigint that could have been int: ${n}n`);return r.collapseBigInts&&s&&(n=Number(n)),r.boxed?ir(n,e.contents):n}const Us=Pr.bind(null,!1),Ms=Pr.bind(null,!0);Us.comment=(t,e)=>`(Positive BigInt) ${Pr(!1,t,e)}n`,Ms.comment=(t,e)=>`(Negative BigInt) ${Pr(!0,t,e)}n`,re.registerDecoder(ae.POS_BIGINT,Us),re.registerDecoder(ae.NEG_BIGINT,Ms);function Pn(t,e){return yt(t.contents),t}Pn.comment=(t,e,r)=>{yt(t.contents);const n={...e,initialDepth:r+2,noPrefixHex:!0},s=xr(t);let i=2**((s[0]&31)-24)+1;const c=s[i]&31;let l=$e(s.subarray(i,++i));c>=24&&(l+=" ",l+=$e(s.subarray(i,i+2**(c-24)))),n.minCol=Math.max(n.minCol,(r+1)*2+l.length);const h=Bs(t.contents,n);let w=`Embedded CBOR
|
|
13
13
|
`;return w+=`${"".padStart((r+1)*2," ")}${l}`.padEnd(n.minCol+1," "),w+=`-- Bytes (Length: ${t.contents.length})
|
|
14
|
-
`,w+=h,w},Pn.noChildren=!0,te.registerDecoder(ce.CBOR,Pn),te.registerDecoder(ce.URI,t=>(pt(t.contents),new URL(t.contents)),"URI"),xe(URL,t=>[ce.URI,t.toString()]),te.registerDecoder(ce.BASE64URL,t=>(pt(t.contents),Ea(t.contents)),"Base64url-encoded"),te.registerDecoder(ce.BASE64,t=>(pt(t.contents),Rn(t.contents)),"Base64-encoded"),te.registerDecoder(35,t=>(pt(t.contents),new RegExp(t.contents)),"RegExp"),te.registerDecoder(21065,t=>{pt(t.contents);const e=`^(?:${t.contents})$`;return new RegExp(e,"u")},"I-RegExp"),te.registerDecoder(ce.REGEXP,t=>{if(ks(t.contents),t.contents.length<1||t.contents.length>2)throw new Error(`Invalid RegExp Array: ${t.contents}`);return new RegExp(t.contents[0],t.contents[1])},"RegExp"),xe(RegExp,t=>[ce.REGEXP,[t.source,t.flags]]),te.registerDecoder(64,t=>(yt(t.contents),t.contents),"uint8 Typed Array");function Me(t,e,r){yt(t.contents);let n=t.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const s=new e(n),i=new DataView(t.contents.buffer,t.contents.byteOffset,t.contents.byteLength),c=i[`get${e.name.replace(/Array/,"")}`].bind(i);for(let l=0;l<n;l++)s[l]=c(l*e.BYTES_PER_ELEMENT,r);return s}function Tt(t,e,r,n,s){const i=s.forceEndian??Ns;if(zt(i?e:r,t,s),Ge(n.byteLength,t,z.BYTE_STRING),Ns===i)t.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const c=`write${n.constructor.name.replace(/Array/,"")}`,l=t[c].bind(t);for(const h of n)l(h,i)}}te.registerDecoder(65,t=>Me(t,Uint16Array,!1),"uint16, big endian, Typed Array"),te.registerDecoder(66,t=>Me(t,Uint32Array,!1),"uint32, big endian, Typed Array"),te.registerDecoder(67,t=>Me(t,BigUint64Array,!1),"uint64, big endian, Typed Array"),te.registerDecoder(68,t=>(yt(t.contents),new Uint8ClampedArray(t.contents)),"uint8 Typed Array, clamped arithmetic"),xe(Uint8ClampedArray,t=>[68,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),te.registerDecoder(69,t=>Me(t,Uint16Array,!0),"uint16, little endian, Typed Array"),xe(Uint16Array,(t,e,r)=>Tt(e,69,65,t,r)),te.registerDecoder(70,t=>Me(t,Uint32Array,!0),"uint32, little endian, Typed Array"),xe(Uint32Array,(t,e,r)=>Tt(e,70,66,t,r)),te.registerDecoder(71,t=>Me(t,BigUint64Array,!0),"uint64, little endian, Typed Array"),xe(BigUint64Array,(t,e,r)=>Tt(e,71,67,t,r)),te.registerDecoder(72,t=>(yt(t.contents),new Int8Array(t.contents)),"sint8 Typed Array"),xe(Int8Array,t=>[72,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),te.registerDecoder(73,t=>Me(t,Int16Array,!1),"sint16, big endian, Typed Array"),te.registerDecoder(74,t=>Me(t,Int32Array,!1),"sint32, big endian, Typed Array"),te.registerDecoder(75,t=>Me(t,BigInt64Array,!1),"sint64, big endian, Typed Array"),te.registerDecoder(77,t=>Me(t,Int16Array,!0),"sint16, little endian, Typed Array"),xe(Int16Array,(t,e,r)=>Tt(e,77,73,t,r)),te.registerDecoder(78,t=>Me(t,Int32Array,!0),"sint32, little endian, Typed Array"),xe(Int32Array,(t,e,r)=>Tt(e,78,74,t,r)),te.registerDecoder(79,t=>Me(t,BigInt64Array,!0),"sint64, little endian, Typed Array"),xe(BigInt64Array,(t,e,r)=>Tt(e,79,75,t,r)),te.registerDecoder(81,t=>Me(t,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),te.registerDecoder(82,t=>Me(t,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),te.registerDecoder(85,t=>Me(t,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),xe(Float32Array,(t,e,r)=>Tt(e,85,81,t,r)),te.registerDecoder(86,t=>Me(t,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),xe(Float64Array,(t,e,r)=>Tt(e,86,82,t,r)),te.registerDecoder(ce.SET,(t,e)=>{if(ks(t.contents),e.sortKeys){const r=qe.decodeToEncodeOpts(e);let n=null;for(const s of t.contents){const i=[s,void 0,Vt(s,r)];if(n&&e.sortKeys(n,i)>=0)throw new Error(`Set items out of order in tag #${ce.SET}`);n=i}}return new Set(t.contents)},"Set"),xe(Set,(t,e,r)=>{let n=[...t];if(r.sortKeys){const s=n.map(i=>[i,void 0,Vt(i,r)]);s.sort(r.sortKeys),n=s.map(([i])=>i)}return[ce.SET,n]}),te.registerDecoder(ce.JSON,t=>(pt(t.contents),JSON.parse(t.contents)),"JSON-encoded");function Ps(t){return yt(t.contents),new Nr().decode(t.contents)}Ps.comment=t=>{yt(t.contents);const e=new Nr;return`(WTF8 string): ${JSON.stringify(e.decode(t.contents))}`},te.registerDecoder(ce.WTF8,Ps),te.registerDecoder(ce.SELF_DESCRIBED,t=>t.contents,"Self-Described"),te.registerDecoder(ce.INVALID_16,()=>{throw new Error(`Tag always invalid: ${ce.INVALID_16}`)},"Invalid"),te.registerDecoder(ce.INVALID_32,()=>{throw new Error(`Tag always invalid: ${ce.INVALID_32}`)},"Invalid"),te.registerDecoder(ce.INVALID_64,()=>{throw new Error(`Tag always invalid: ${ce.INVALID_64}`)},"Invalid"),te.registerDecoder(ce.SYMBOL,t=>{let e=t.contents;if(Array.isArray(t.contents)){if(t.contents.length!==1)throw new Error(`Expected Array of size 1: ${t.contents}`);[e]=t.contents}if(pt(e),!e.length)throw new Error(`Expected non-empty string: ${t.contents}`);return Symbol.for(e)},"Symbol");function Dn(t){throw new Error(`Encoding ${t.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}xe(ArrayBuffer,Dn),xe(DataView,Dn),typeof SharedArrayBuffer<"u"&&xe(SharedArrayBuffer,Dn);function Dr(t){return[NaN,t.valueOf()]}xe(Boolean,Dr),xe(Number,Dr),xe(String,Dr),xe(BigInt,Dr);function oc(t){const e={...qe.defaultDecodeOptions};if(t.dcbor?Object.assign(e,qe.dcborDecodeOptions):t.cde&&Object.assign(e,qe.cdeDecodeOptions),Object.assign(e,t),Object.hasOwn(e,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");return e.boxed&&(e.saveOriginal=!0),e}let ac=class{parent=void 0;ret=void 0;step(e,r,n){if(this.ret=qe.create(e,this.parent,r,n),e[2]===Ue.BREAK)if(this.parent?.isStreaming)this.parent.left=0;else throw new Error("Unexpected BREAK");else this.parent&&this.parent.push(this.ret,n,e[3]);for(this.ret instanceof qe&&(this.parent=this.ret);this.parent?.done;){this.ret=this.parent.convert(n);const s=this.parent.parent;s?.replaceLast(this.ret,this.parent,n),this.parent=s}}};function cc(t,e={}){const r=oc(e),n=new Lr(t,r),s=new ac;for(const i of n)s.step(i,r,n);return s.ret}const{cdeDecodeOptions:Hc,dcborDecodeOptions:Wc,defaultDecodeOptions:Kc}=qe;class uc{constructor(e={}){this.options={id:gt(),codec:"cbor",timeout:10*1e3,share:"",chunkSize:16*1024,chunkCredit:4,topicMake:(r,n,s)=>`${r}/${n}/${s??"any"}`,topicMatch:r=>{const n=r.match(/^(.+)\/([^/]+)\/([^/]+)$/);return n?{name:n[1],operation:n[2],peerId:n[3]==="any"?void 0:n[3]}:null},...e}}}class Cn{static uint8ArrayToBase64(e){return Nt.from(e.buffer,e.byteOffset,e.byteLength).toString("base64")}static base64ToUint8Array(e){return new Uint8Array(Nt.from(e,"base64"))}static stringify(e){return JSON.stringify(e,(r,n)=>n instanceof Uint8Array?{__Uint8Array:this.uint8ArrayToBase64(n)}:n)}static parse(e){return JSON.parse(e,(r,n)=>typeof n?.__Uint8Array=="string"?this.base64ToUint8Array(n.__Uint8Array):n)}}class fc{constructor(e){this.format=e,this.types=new is,this.tags=new Map;const r=64e3;this.types.registerEncoder(Nt,n=>[r,new Uint8Array(n.buffer,n.byteOffset,n.byteLength)]),this.tags.set(r,n=>Nt.from(n.contents))}encode(e){let r;if(this.format==="cbor")try{r=Vt(e,{types:this.types})}catch(n){throw new Error("failed to encode CBOR format",{cause:n})}else if(this.format==="json")try{r=Cn.stringify(e)}catch(n){throw new Error("failed to encode JSON format",{cause:n})}else throw new Error(`invalid format "${this.format}"`);return r}decode(e){let r;if(this.format==="cbor"){if(!(e instanceof Uint8Array))throw new Error("failed to decode CBOR format (data type is not Uint8Array)");if(e.byteLength===0)throw new Error("failed to decode CBOR format (data is empty)");try{r=cc(e,{tags:this.tags})}catch(n){throw new Error("failed to decode CBOR format",{cause:n})}}else if(this.format==="json"){if(typeof e!="string")throw new Error("failed to decode JSON format (data type is not string)");if(e.length===0)throw new Error("failed to decode JSON format (data is empty)");try{r=Cn.parse(e)}catch(n){throw new Error("failed to decode JSON format",{cause:n})}}else throw new Error(`invalid format "${this.format}"`);return r}}class lc extends uc{constructor(e={}){super(e),this.codec=new fc(this.options.codec)}}class Cr extends lc{static{this.encoder=new TextEncoder}static{this.decoder=new TextDecoder}str2buf(e){return Cr.encoder.encode(e)}buf2str(e){return Cr.decoder.decode(e)}arr2buf(e){let r;return e instanceof Uint8Array?r=e:r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r}buf2arr(e,r){let n;const s=r;if(s===Nt)n=Nt.from(e.buffer,e.byteOffset,e.byteLength);else if(s===Uint8Array)n=e;else if(s===Int8Array)n=new Int8Array(e.buffer,e.byteOffset,e.byteLength);else throw new Error("invalid data type");return n}}const Ds=t=>{const e=t.match(/^(\d+)\.(\d+)$/);if(e===null)throw new Error("invalid version string");const r=parseInt(e[2],10);if(r>99)throw new Error("invalid version string: minor version exceeds 99");return parseInt(e[1],10)*100+r},On="1.4",hc=Ds(On),ur=Ke(es(_e(),Ut()),Qi(t=>!Array.isArray(t))),Or=Ke(Jt(Ke(_e(),Lt(8192))),Lt(8));class Ve{constructor(e,r,n,s){this.type=e,this.id=r,this.sender=n,this.receiver=s,this.version=`MQTT+/${On}`}}const Ye={version:Ke(_e(),Xi(/^MQTT\+\/\d+\.\d+$/)),type:_e(),id:_e(),sender:he(_e()),receiver:he(_e())};class Cs extends Ve{constructor(e,r,n,s,i,c,l){super("event-emission",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const dc=We({...Ye,type:He("event-emission"),name:_e(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Or),meta:he(ur)});class Os extends Ve{constructor(e,r,n,s,i,c,l){super("service-call-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const pc=We({...Ye,type:He("service-call-request"),name:_e(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Or),meta:he(ur)});class $s extends Ve{constructor(e,r,n,s,i){super("service-call-response",e,s,i),this.result=r,this.error=n}}const yc=We({...Ye,type:He("service-call-response"),result:he(Ut()),error:he(_e())});class qs extends Ve{constructor(e,r,n,s,i,c,l){super("sink-push-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const wc=We({...Ye,type:He("sink-push-request"),name:_e(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Or),meta:he(ur)});class js extends Ve{constructor(e,r,n,s,i,c){super("sink-push-response",e,s,i),this.name=r,this.error=n,this.credit=c}}const gc=We({...Ye,type:He("sink-push-response"),name:_e(),error:he(_e()),credit:he(Ke(rr(),er(),tr(1)))});class Hs extends Ve{constructor(e,r,n,s,i,c,l){super("sink-push-chunk",e,c,l),this.name=r,this.chunk=n,this.error=s,this.final=i}}const mc=We({...Ye,type:He("sink-push-chunk"),name:_e(),chunk:he(Tn(Uint8Array)),error:he(_e()),final:he(vn())});class Ws extends Ve{constructor(e,r,n,s,i){super("sink-push-credit",e,s,i),this.name=r,this.credit=n}}const bc=We({...Ye,type:He("sink-push-credit"),name:_e(),credit:Ke(rr(),er(),tr(1))});class Ks extends Ve{constructor(e,r,n,s,i,c,l,h){super("source-fetch-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l,this.credit=h}}const Ec=We({...Ye,type:He("source-fetch-request"),name:_e(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Or),meta:he(ur),credit:he(Ke(rr(),er(),tr(1)))});class Gs extends Ve{constructor(e,r,n,s,i,c){super("source-fetch-response",e,s,i),this.name=r,this.error=n,this.meta=c}}const Sc=We({...Ye,type:He("source-fetch-response"),name:_e(),error:he(_e()),meta:he(ur)});class Js extends Ve{constructor(e,r,n,s,i,c,l){super("source-fetch-chunk",e,c,l),this.name=r,this.chunk=n,this.error=s,this.final=i}}const _c=We({...Ye,type:He("source-fetch-chunk"),name:_e(),chunk:he(Tn(Uint8Array)),error:he(_e()),final:he(vn())});class zs extends Ve{constructor(e,r,n,s,i){super("source-fetch-credit",e,s,i),this.name=r,this.credit=n}}const vc=We({...Ye,type:He("source-fetch-credit"),name:_e(),credit:Ke(rr(),er(),tr(0))});class Tc{makeEventEmission(e,r,n,s,i,c,l){return new Cs(e,r,n,s,i,c,l)}makeServiceCallRequest(e,r,n,s,i,c,l){return new Os(e,r,n,s,i,c,l)}makeServiceCallResponse(e,r,n,s,i){return new $s(e,r,n,s,i)}makeSinkPushRequest(e,r,n,s,i,c,l){return new qs(e,r,n,s,i,c,l)}makeSinkPushResponse(e,r,n,s,i,c){return new js(e,r,n,s,i,c)}makeSinkPushChunk(e,r,n,s,i,c,l){return new Hs(e,r,n,s,i,c,l)}makeSinkPushCredit(e,r,n,s,i){return new Ws(e,r,n,s,i)}makeSourceFetchRequest(e,r,n,s,i,c,l,h){return new Ks(e,r,n,s,i,c,l,h)}makeSourceFetchResponse(e,r,n,s,i,c){return new Gs(e,r,n,s,i,c)}makeSourceFetchChunk(e,r,n,s,i,c,l){return new Js(e,r,n,s,i,c,l)}makeSourceFetchCredit(e,r,n,s,i){return new zs(e,r,n,s,i)}parse(e){if(typeof e!="object"||e===null)throw new Error("invalid argument: not an object");if(typeof e.version!="string")throw new Error('invalid object: missing or invalid "version" field');const r=e.version.match(/^MQTT\+\/(\d+\.\d+)$/);if((r!==null?Ds(r[1]):0)!==hc)throw new Error(`protocol version mismatch (expected version ${On}, got version ${e.version})`);const s=(i,c,l)=>{const h=ya(l,i);if(!h.success){const w=h.issues.map(d=>d.message).join("; ");throw new Error(`invalid ${c} object: ${w}`)}return h.output};if(typeof e.type!="string")throw new Error('invalid object: missing or invalid "type" field');if(e.type==="event-emission"){const i=s(e,"EventEmission",dc);return this.makeEventEmission(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="service-call-request"){const i=s(e,"ServiceCallRequest",pc);return this.makeServiceCallRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="service-call-response"){const i=s(e,"ServiceCallResponse",yc);return this.makeServiceCallResponse(i.id,i.result,i.error,i.sender,i.receiver)}else if(e.type==="sink-push-request"){const i=s(e,"SinkPushRequest",wc);return this.makeSinkPushRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="sink-push-response"){const i=s(e,"SinkPushResponse",gc);return this.makeSinkPushResponse(i.id,i.name,i.error,i.sender,i.receiver,i.credit)}else if(e.type==="sink-push-chunk"){const i=s(e,"SinkPushChunk",mc);return this.makeSinkPushChunk(i.id,i.name,i.chunk,i.error,i.final,i.sender,i.receiver)}else if(e.type==="sink-push-credit"){const i=s(e,"SinkPushCredit",bc);return this.makeSinkPushCredit(i.id,i.name,i.credit,i.sender,i.receiver)}else if(e.type==="source-fetch-request"){const i=s(e,"SourceFetchRequest",Ec);return this.makeSourceFetchRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta,i.credit)}else if(e.type==="source-fetch-response"){const i=s(e,"SourceFetchResponse",Sc);return this.makeSourceFetchResponse(i.id,i.name,i.error,i.sender,i.receiver,i.meta)}else if(e.type==="source-fetch-chunk"){const i=s(e,"SourceFetchChunk",_c);return this.makeSourceFetchChunk(i.id,i.name,i.chunk,i.error,i.final,i.sender,i.receiver)}else if(e.type==="source-fetch-credit"){const i=s(e,"SourceFetchCredit",vc);return this.makeSourceFetchCredit(i.id,i.name,i.credit,i.sender,i.receiver)}else throw new Error("invalid object: not of any known type")}isRequest(e){return e instanceof Cs||e instanceof Os||e instanceof Ks||e instanceof qs}isResponse(e){return e instanceof $s||e instanceof js||e instanceof Hs||e instanceof Ws||e instanceof Gs||e instanceof Js||e instanceof zs}}class xc extends Cr{constructor(){super(...arguments),this.msg=new Tc}}class Ac{constructor(e,r,n,s){this.timestamp=e,this.level=r,this.msg=n,this.data=s}async resolve(){if(this.msg instanceof Promise&&(this.msg=await this.msg.catch(()=>"<resolve-failed>")),this.data)for(const e of Object.keys(this.data))this.data[e]instanceof Promise&&(this.data[e]=await this.data[e].catch(()=>"<resolve-failed>"))}toString(){const e=new Date(this.timestamp),r=e.getFullYear(),n=(e.getMonth()+1).toString().padStart(2,"0"),s=e.getDate().toString().padStart(2,"0"),i=e.getHours().toString().padStart(2,"0"),c=e.getMinutes().toString().padStart(2,"0"),l=e.getSeconds().toString().padStart(2,"0"),h=e.getMilliseconds().toString().padStart(3,"0"),w=`${r}-${n}-${s} ${i}:${c}:${l}.${h}`,d=this.msg instanceof Promise?"<unresolved>":this.msg;let I="";if(this.data!==void 0){const T=this.data;I=` (${Object.keys(T).map(B=>{const q=T[B]instanceof Promise?"<unresolved>":T[B];return`${B}: ${Cn.stringify(q)}`}).join(", ")})`}return`[${w}] ${this.level}: ${d}${I}`}}class Rc extends xc{constructor(){super(...arguments),this._events=new oa.EventEmitter}on(...e){this._events.on(...e)}off(...e){this._events.off(...e)}emitEvent(...e){return this._events.listenerCount(e[0])===0?!1:this._events.emit(...e)}log(e,r,n){const s=new Ac(Date.now(),e,r,n);this.emitEvent("log",s)}error(e,r){let n=e;r!==void 0&&(n=new Error(`${r}: ${e.message}`,{cause:e})),this.emitEvent("error",n),this.log("error",n.message)}}class Ic extends Rc{constructor(e,r={}){super(r),this.onRequest=new Map,this.onResponse=new Map,e===null&&(this.log("info","establishing proxy MQTT client"),e=new Proxy({},{get(n,s,i){return s==="isFakeProxy"?!0:typeof s=="string"&&["on","off","once"].includes(s)?()=>{}:()=>{throw new Error(`Underlying MQTT operation "${String(s)}" called on a null MQTT client -- only MQTT+ "emit({ ..., dry: true })" is supported in this special operation mode`)}}})),this.mqtt=e,this.log("info","hooking into MQTT client"),this.messageHandler=(n,s,i)=>{let c;if(this.options.codec==="json")c=s.toString();else if(this.options.codec==="cbor")c=Si.isBuffer(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):s;else throw new Error("invalid codec configured");this._onMessage(n,c,i)},this.mqtt.on("message",this.messageHandler)}async destroy(){this.log("info","un-hooking from MQTT client"),this.mqtt.off("message",this.messageHandler),this.onRequest.clear(),this.onResponse.clear()}makeRegistration(e,r,n,s){return{destroy:async()=>{if(!this.onRequest.has(s))throw new Error(`destroy: ${r} "${n}" not registered`);await e.unroll(!1)?.catch(i=>{const c=Ne(i,`destroy: ${r} "${n}" failed to cleanup`);throw this.error(c),c})}}}async subscribeTopic(e,r={}){return this.log("info",`subscribing to MQTT topic "${e}"`),new Promise((n,s)=>{this.mqtt.subscribe(e,{qos:2,...r},(i,c)=>{i?(this.error(i,`subscribing to MQTT topic "${e}" failed`),s(i)):n()})})}async unsubscribeTopic(e){return this.log("info",`unsubscribing from MQTT topic "${e}"`),new Promise((r,n)=>{this.mqtt.unsubscribe(e,(s,i)=>{s?(this.error(s,`unsubscribing from MQTT topic "${e}" failed`),n(s)):r()})})}async publishToTopic(e,r,n={}){typeof r=="string"?this.log("info",`publishing to MQTT topic "${e}" (type: string, length: ${r.length} chars)`):this.log("info",`publishing to MQTT topic "${e}" (type: buffer, length: ${r.byteLength} bytes)`);const s=new vi((i,c)=>{let l;try{const h=this.codec.decode(r);l=this.msg.parse(h)}catch(h){return c(h)}i(l)});return this.log("debug",`publishing to MQTT topic "${e}"`,{message:s}),new Promise((i,c)=>{const l=typeof r=="string"?r:Si.from(r.buffer,r.byteOffset,r.byteLength);this.mqtt.publish(e,l,n,h=>{h?(this.error(h,`publishing to MQTT topic "${e}" failed`),c(h)):i()})})}_onMessage(e,r,n){const s=this.options.topicMatch(e);if(s===null)return;typeof r=="string"?this.log("info",`received from MQTT topic "${e}" (type: string, length: ${r.length} chars)`):this.log("info",`received from MQTT topic "${e}" (type: buffer, length: ${r.byteLength} bytes)`);let i;try{i=this.codec.decode(r)}catch(l){this.error(Ne(l,"failed to parse message into object"));return}let c;try{c=this.msg.parse(i)}catch(l){this.error(Ne(l,"failed to parse object into typed message object"));return}if(this.log("debug",`received from MQTT topic "${e}"`,{message:c}),this.msg.isRequest(c)){const l=this.onRequest.get(`${c.type}:${c.name}`);l!==void 0&&Promise.resolve().then(()=>l(c,s.name)).catch(h=>{this.error(Ne(h,`dispatching request message from MQTT topic "${e}" failed`))})}else if(this.msg.isResponse(c)){const l=this.onResponse.get(`${c.type}:${c.id}`);l!==void 0&&Promise.resolve().then(()=>l(c,s.name)).catch(h=>{this.error(Ne(h,`dispatching response message from MQTT topic "${e}" failed`))})}}}class Bc{constructor(e,r,n=30*1e3){this.subscribeFn=e,this.unsubscribeFn=r,this.lingerMs=n,this.counts=new Map,this.pending=new Map,this.lingers=new Map,this.unsubbing=new Map}incrementCount(e){const r=this.counts.get(e)??0;return this.counts.set(e,r+1),r}decrementCount(e){const r=this.counts.get(e);if(r!==void 0)return r<=1?(this.counts.delete(e),0):(this.counts.set(e,r-1),r-1)}async subscribe(e,r={qos:2}){const n=this.incrementCount(e),s=this.lingers.get(e);if(s){clearTimeout(s),this.lingers.delete(e);return}if(n===0){let i,c;const l=new Promise((d,I)=>{i=d,c=I});l.catch(()=>{}),this.pending.set(e,l);const h=this.unsubbing.get(e);return h&&await h,this.subscribeFn(e,r).then(()=>{this.pending.delete(e),i()}).catch(d=>{throw this.pending.delete(e),this.decrementCount(e),c(d),d})}else{const i=this.pending.get(e);if(i)return i.catch(c=>{throw this.decrementCount(e),c})}}async unsubscribe(e){if(this.decrementCount(e)===0)if(this.lingerMs>0){const n=setTimeout(()=>{this.lingers.delete(e);const s=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,s)},this.lingerMs);this.lingers.set(e,n)}else{const n=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,n),await n}}async flush(){const e=new Set([...this.counts.keys(),...this.lingers.keys(),...this.pending.keys(),...this.unsubbing.keys()]);for(const r of this.lingers.values())clearTimeout(r);this.lingers.clear(),this.counts.clear(),await Promise.allSettled([...this.pending.values(),...this.unsubbing.values()]),await Promise.allSettled([...e].map(r=>this.unsubscribeFn(r).catch(()=>{}))),this.pending.clear(),this.unsubbing.clear()}}class Nc extends Ic{constructor(){super(...arguments),this.subscriptions=new Bc((e,r)=>this.subscribeTopic(e,r),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,r,n={}){await br(`subscribe to MQTT topic "${r}"`,e,()=>this.subscriptions.subscribe(r,{qos:2,...n})),e.roll(()=>this.subscriptions.unsubscribe(r))}async destroy(){await this.subscriptions.flush(),await super.destroy()}}class kc extends Nc{constructor(){super(...arguments),this.timers=new Map}async destroy(){for(const e of this.timers.values())clearTimeout(e);this.timers.clear(),await super.destroy()}timerRefresh(e,r){const n=this.timers.get(e);n!==void 0&&clearTimeout(n),this.timers.set(e,setTimeout(async()=>{this.timers.delete(e);try{await r()}catch(s){this.error(Ne(s),`timer "${e}" failed`)}},this.options.timeout))}timerClear(e){const r=this.timers.get(e);r!==void 0&&(clearTimeout(r),this.timers.delete(e))}}class Fc extends kc{constructor(){super(...arguments),this._meta=new Map}meta(...e){const[r,n]=e;if(e.length===0)return Object.fromEntries(this._meta);if(e.length===1)return this._meta.get(r);n==null?this._meta.delete(r):this._meta.set(r,n)}metaStore(e){const r=e===void 0||Object.keys(e).length===0;if(!(this._meta.size===0&&r))return this._meta.size>0&&r?Object.fromEntries(this._meta):this._meta.size===0&&!r?e:{...Object.fromEntries(this._meta),...e}}}const Vs=new TextEncoder;class Lc extends Fc{constructor(){super(...arguments),this._credential=null,this._tokens=new Set}credential(e){if(e.length===0)throw new Error("credential must not be empty");const r=Vs.encode(e),n=Vs.encode("mqtt-plus");this._credential=ta(ia,r,n,6e5,32)}async issue(e){if(this._credential===null)throw new Error("credential has to be provided before issuing tokens");if(e.roles.length===0)throw new Error("payload.roles must be a non-empty array");if(e.roles.length>64)throw new Error("payload.roles must not exceed 64 roles");const r=new Vo(e);return r.setProtectedHeader({alg:"HS256",typ:"JWT"}),await r.sign(this._credential)}authenticate(e,r){if(e===void 0){const n=Array.from(this._tokens).filter(s=>s.length<=8192).slice(0,8);return n.length>0?n:void 0}else if(r===!0)this._tokens.delete(e);else{if(e.length>8192)throw new Error("token must not exceed 8192 characters");if(!this._tokens.has(e)&&this._tokens.size>=8)throw new Error("at most 8 tokens can be authenticated at once");this._tokens.add(e)}}async validateToken(e){if(this._credential===null)throw new Error("credential has to be provided before validating tokens");return(await Xo(e,this._credential).catch(()=>null))?.payload??null}async authenticated(e,r,n){let s=!1,i,c;if(typeof n=="string"?(i="require",c=[n]):(i=n.mode,c=n.roles),r!==void 0)for(const l of r.slice(0,8)){if(l.length>8192)continue;const h=await this.validateToken(l);if(h!==null&&!(h.id&&h.id!==e)&&Array.isArray(h.roles)&&!(h.roles.length>64)){for(const w of c)if(h.roles.includes(w)){s=!0;break}if(s)break}}return!s&&i==="optional"&&(s=!0),s}}class Uc extends Lc{async event(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`event-emission:${n}`))throw new Error(`event: event "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"event-emission"),I=this.options.topicMake(n,"event-emission",this.options.id);return this.onRequest.set(`event-emission:${n}`,async(T,L)=>{const B=T.sender;if(B===void 0||B==="")throw new Error("invalid request: missing sender");const q=T.params??[],$={sender:B};T.receiver&&($.receiver=T.receiver),T.meta&&($.meta=T.meta);try{if(L!==T.name)throw new Error(`event name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&($.authenticated=await this.authenticated(B,T.auth,l)),$.authenticated!==void 0&&!$.authenticated)throw new Error(`event "${n}" failed authentication`);await s(...q,$)}catch(S){const x=Ne(S);this.error(x,`handler for event "${n}" failed`)}}),h.roll(()=>{this.onRequest.delete(`event-emission:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"event",n,`event-emission:${n}`)}emit(e,...r){let n,s,i,c={},l,h;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta,h=e.dry):(n=e,s=r);const w=gt(),d=this.authenticate(),I=this.metaStore(l),T=this.msg.makeEventEmission(w,n,s,this.options.id,i,d,I),L=this.codec.encode(T),B=this.options.topicMake(n,"event-emission",i);if(h)return{topic:B,payload:L,options:{qos:2,...c}};this.publishToTopic(B,L,{qos:2,...c}).catch(q=>{this.error(q,`emitting event "${n}" failed`)})}}class Mc extends Uc{async service(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`service-call-request:${n}`))throw new Error(`service: service "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"service-call-request"),I=this.options.topicMake(n,"service-call-request",this.options.id);return this.onRequest.set(`service-call-request:${n}`,async(T,L)=>{const B=T.id,q=T.sender;if(q===void 0||q==="")throw new Error("invalid request: missing sender");const $=T.params??[],S={sender:q};T.receiver&&(S.receiver=T.receiver),T.meta&&(S.meta=T.meta);try{if(L!==T.name)throw new Error(`service name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&(S.authenticated=await this.authenticated(q,T.auth,l)),S.authenticated!==void 0&&!S.authenticated)throw new Error(`service "${n}" failed authentication`);const x=await s(...$,S),F=this.msg.makeServiceCallResponse(B,x,void 0,this.options.id,q),_=this.codec.encode(F),v=this.options.topicMake(n,"service-call-response",q);await this.publishToTopic(v,_,{qos:i.qos??2})}catch(x){const F=Ne(x);this.error(F,`handler for service "${n}" failed`);const _=this.msg.makeServiceCallResponse(B,void 0,F.message,this.options.id,q);try{const v=this.codec.encode(_),k=this.options.topicMake(n,"service-call-response",q);await this.publishToTopic(k,v,{qos:i.qos??2})}catch(v){this.error(Ne(v),`sending error response for service "${n}" failed`)}}}),h.roll(()=>{this.onRequest.delete(`service-call-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"service",n,`service-call-request:${n}`)}async call(e,...r){let n,s,i,c={},l;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta):(n=e,s=r);const h=new De;let w=gt();for(;this.onResponse.has(`service-call-response:${w}`);)w=gt();const d=this.options.topicMake(n,"service-call-response",this.options.id);await this.subscribeTopicAndSpool(h,d,{qos:c.qos??2});const I=`service-call:${w}`;let T;const L=new Promise((F,_)=>{T=_,this.timerRefresh(I,async()=>{await h.unroll(),_(new Error("communication timeout"))}),h.roll(()=>{this.timerClear(I)}),this.onResponse.set(`service-call-response:${w}`,async v=>{await h.unroll(),v.error!==void 0?_(new Error(v.error)):F(v.result)}),h.roll(()=>{this.onResponse.delete(`service-call-response:${w}`)})}),B=this.authenticate(),q=this.metaStore(l),$=this.msg.makeServiceCallRequest(w,n,s,this.options.id,i,B,q),S=this.codec.encode($),x=this.options.topicMake(n,"service-call-request",i);try{await br(`publish service request as MQTT message to topic "${x}"`,h,()=>this.publishToTopic(x,S,{qos:2,...c}))}catch(F){return T(F),L}return L}}class Pc extends Mc{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map}async destroy(){for(const e of this.sourceControllers.values())e.abort(new Error("source destroyed"));this.sourceControllers.clear();for(const e of this.sourceCreditGates.values())e.abort();this.sourceCreditGates.clear(),await super.destroy()}async source(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`source-fetch-request:${n}`))throw new Error(`source: source "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"source-fetch-request"),I=this.options.topicMake(n,"source-fetch-request",this.options.id);return this.onRequest.set(`source-fetch-request:${n}`,async(T,L)=>{const B=T.id,q=T.params??[],$=T.sender;if($===void 0||$==="")throw new Error("invalid request: missing sender");const S=T.receiver,x={sender:$};S&&(x.receiver=S),T.meta&&(x.meta=T.meta);const F=this.options.topicMake(n,"source-fetch-response",$),_=async Z=>{const re=this.metaStore(x.meta),Q=this.msg.makeSourceFetchResponse(B,n,Z,this.options.id,$,re),se=this.codec.encode(Q);await this.publishToTopic(F,se,{qos:i.qos??2})},v=new AbortController;this.sourceControllers.set(B,v);const k=v.signal;k.addEventListener("abort",()=>{x.stream instanceof ht.Readable&&!x.stream.destroyed&&x.stream.destroy(Ne(k.reason))},{once:!0});const M=`source-fetch-send:${B}`,U=()=>this.timerRefresh(M,()=>{const Z=new Error(`source fetch "${n}" timed out`);v.abort(Z);const re=this.sourceCreditGates.get(B);re!==void 0&&(re.abort(),this.sourceCreditGates.delete(B)),this.sourceControllers.delete(B),this.onResponse.delete(`source-fetch-credit:${B}`)}),W=()=>this.timerClear(M);U();const G=async(Z,re,Q)=>{U();const se=this.msg.makeSourceFetchChunk(B,n,Z,re,Q,this.options.id,$),fe=this.codec.encode(se);await this.publishToTopic(F,fe,{qos:i.qos??2})};let Y=!1,N;try{if(L!==T.name)throw new Error(`source name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&(x.authenticated=await this.authenticated($,T.auth,l)),x.authenticated!==void 0&&!x.authenticated)throw new Error(`source "${n}" failed authentication`);const Z=T.credit;if(N=Z!==void 0&&Z>0?new Ti(Z):void 0,N&&this.sourceCreditGates.set(B,N),this.onResponse.set(`source-fetch-credit:${B}`,re=>{if(re.credit===0){v.abort(new Error(`source fetch "${n}" cancelled by fetcher`));return}N&&(N.replenish(re.credit),U())}),await s(...q,x),!(x.stream instanceof ht.Readable)&&!(x.buffer instanceof Promise))throw new Error("handler did not provide data via info.stream or info.buffer fields");if(x.stream instanceof ht.Readable&&x.buffer instanceof Promise)throw new Error("handler has set both info.stream and info.buffer fields");await _(),Y=!0,x.stream instanceof ht.Readable?await Ii(x.stream,this.options.chunkSize,G,N,k):x.buffer instanceof Promise&&await Ri(await x.buffer,this.options.chunkSize,G,N,k)}catch(Z){const re=Ne(Z,`handler for source "${n}" failed`);v.abort(re),this.error(re),Y?await G(void 0,re.message,!0).catch(()=>{}):await _(re.message).catch(()=>{})}finally{W(),N&&(N.abort(),this.sourceCreditGates.delete(B)),this.sourceControllers.delete(B),this.onResponse.delete(`source-fetch-credit:${B}`)}}),h.roll(()=>{this.onRequest.delete(`source-fetch-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"source",n,`source-fetch-request:${n}`)}async fetch(e,...r){let n,s,i,c={},l;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta):(n=e,s=r);const h=new De;let w=gt();for(;this.onResponse.has(`source-fetch-response:${w}`)||this.onResponse.has(`source-fetch-chunk:${w}`);)w=gt();const d=this.options.topicMake(n,"source-fetch-response",this.options.id);await this.subscribeTopicAndSpool(h,d,{qos:c.qos??2});const I=this.options.chunkCredit;let T=0,L=I,B,q=!1;const $=`source-fetch:${w}`;let S;const x=()=>{this.timerRefresh($,()=>{S?.destroy(new Error("communication timeout")),h.unroll()})};h.roll(()=>{this.timerClear($)}),S=new ht.Readable({highWaterMark:I>0?I*this.options.chunkSize:16*1024,read:Q=>{if(I<=0||!this.onResponse.has(`source-fetch-response:${w}`))return;const se=B??i;if(!se)return;const fe=Math.max(0,T+I-L);if(fe>0){L+=fe;const ye=this.msg.makeSourceFetchCredit(w,n,fe,this.options.id,se),Ce=this.codec.encode(ye),Oe=this.options.topicMake(n,"source-fetch-request",se);this.publishToTopic(Oe,Ce,{qos:c.qos??2}).catch(wt=>{this.error(wt,`sending credit for fetch "${n}" failed`)}),x()}}});const F=Ai(S);let _;const v=new Promise(Q=>{_=Q});h.roll(()=>{_(void 0)}),x();let k=!1;const M=()=>{if(!k&&!q){k=!0;const Q=B??i;if(Q){const se=this.msg.makeSourceFetchCredit(w,n,0,this.options.id,Q),fe=this.codec.encode(se),ye=this.options.topicMake(n,"source-fetch-request",Q);this.publishToTopic(ye,fe,{qos:c.qos??2}).catch(()=>{})}}h.unroll()};S.once("close",M),S.once("error",M),this.onResponse.set(`source-fetch-response:${w}`,Q=>{if(!q){if(Q.name!==n){q=!0,S.destroy(new Error(`source name mismatch (expected "${n}", got "${Q.name}")`)),h.unroll();return}Q.sender&&(B=Q.sender),Q.error?(q=!0,S.destroy(new Error(Q.error)),h.unroll()):(_(Q.meta),x())}}),this.onResponse.set(`source-fetch-chunk:${w}`,Q=>{q||(Q.error?(q=!0,S.destroy(new Error(Q.error)),h.unroll()):(x(),Q.chunk!==void 0&&(T++,S.push(Q.chunk)),Q.final&&(q=!0,S.push(null),h.unroll())))}),h.roll(()=>{this.onResponse.delete(`source-fetch-response:${w}`),this.onResponse.delete(`source-fetch-chunk:${w}`)});const U=this.authenticate(),W=this.metaStore(l),G=I>0?I:void 0,Y=this.msg.makeSourceFetchRequest(w,n,s,this.options.id,i,U,W,G),N=this.codec.encode(Y),Z=this.options.topicMake(n,"source-fetch-request",i);br(`publish fetch request as MQTT message to topic "${Z}"`,()=>this.publishToTopic(Z,N,{qos:2,...c})).catch(Q=>{S.destroy(Ne(Q))});const re={stream:S,buffer:F,meta:v};return Bi(re,"stream","buffer"),re}}class Dc extends Pc{constructor(){super(...arguments),this.pushStreams=new Map,this.pushSpools=new Map}async destroy(){for(const e of this.pushStreams.values())e.destroy(new Error("sink destroyed"));this.pushStreams.clear();for(const e of this.pushSpools.values())await e.unroll();this.pushSpools.clear(),await super.destroy()}async sink(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`sink-push-request:${n}`))throw new Error(`sink: sink "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"sink-push-request"),I=this.options.topicMake(n,"sink-push-request",this.options.id);return this.onRequest.set(`sink-push-request:${n}`,async(T,L)=>{const B=T.id,q=T.params??[],$=T.sender;if($===void 0||$==="")throw new Error("invalid request: missing sender");const S=T.receiver,x=this.options.topicMake(n,"sink-push-response",$),F=this.options.chunkCredit,_=async(k,M=!1)=>{const U=k===void 0&&M&&F>0?F:void 0,W=this.msg.makeSinkPushResponse(B,n,k,this.options.id,$,U),G=this.codec.encode(W);await this.publishToTopic(x,G,{qos:i.qos??2})},v=new De;this.pushSpools.set(B,v),v.roll(()=>{this.pushSpools.delete(B)});try{if(L!==T.name)throw new Error(`sink name mismatch (topic: "${L}", payload: "${T.name}")`);let k;if(l&&(k=await this.authenticated($,T.auth,l)),k!==void 0&&!k)throw new Error(`sink "${n}" failed authentication`);const M=F>0?{chunksReceived:0,creditGranted:F}:void 0,U=`sink-push-recv:${B}`,W=()=>this.timerRefresh(U,()=>{const se=this.pushStreams.get(B);se!==void 0&&se.destroy(new Error("push stream timeout")),this.pushSpools.get(B)?.unroll()}),G=()=>this.timerClear(U),Y=new ht.Readable({highWaterMark:F>0?F*this.options.chunkSize:16*1024,read:se=>{if(!M||!this.pushSpools.has(B))return;const fe=Math.max(0,M.chunksReceived+F-M.creditGranted);if(fe>0){M.creditGranted+=fe;const ye=this.msg.makeSinkPushCredit(B,n,fe,this.options.id,$),Ce=this.codec.encode(ye);this.publishToTopic(x,Ce,{qos:i.qos??2}).catch(Oe=>{this.error(Oe,`sending credit for push "${n}" failed`)}),W()}}});this.pushStreams.set(B,Y),v.roll(()=>{this.pushStreams.delete(B)}),Y.once("error",()=>{});let N=!1;this.onResponse.set(`sink-push-chunk:${B}`,async se=>{N||(se.error!==void 0?(N=!0,Y.destroy(new Error(se.error))):(W(),se.chunk!==void 0&&(M&&M.chunksReceived++,Y.push(se.chunk)),se.final&&(N=!0,Y.push(null))))}),v.roll(()=>{this.onResponse.delete(`sink-push-chunk:${B}`)}),W(),v.roll(()=>{G()});const Z=Ai(Y),re=new Promise((se,fe)=>{Y.once("end",()=>{se()}),Y.once("error",ye=>{fe(ye)})});re.catch(()=>{});const Q={sender:$,stream:Y,buffer:Z};S&&(Q.receiver=S),k!==void 0&&(Q.authenticated=k),T.meta&&(Q.meta=T.meta),Bi(Q,"stream","buffer"),await _(void 0,!0),await s(...q,Q),await re;try{await _()}catch(se){this.error(Ne(se),`sending terminal response for sink "${n}" failed`)}}catch(k){const M=Ne(k,`handler for sink "${n}" failed`);this.error(M),await _(M.message).catch(()=>{})}finally{const k=this.pushStreams.get(B);k!==void 0&&!k.destroyed&&k.destroy(),await v.unroll()}}),h.roll(()=>{this.onRequest.delete(`sink-push-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"sink",n,`sink-push-request:${n}`)}async push(e,...r){let n,s,i,c,l={},h;if(typeof e=="object"&&e!==null?(n=e.name,s=e.data,i=e.params,c=e.receiver,l=e.options??{},h=e.meta):(n=e,s=r[0],i=r.slice(1)),!(s instanceof ht.Readable)&&!(s instanceof Uint8Array))throw new Error("invalid data type: expected Readable or Uint8Array");const w=new De;let d=gt();for(;this.onResponse.has(`sink-push-response:${d}`)||this.onResponse.has(`sink-push-credit:${d}`);)d=gt();const I=this.options.topicMake(n,"sink-push-response",this.options.id);await this.subscribeTopicAndSpool(w,I,{qos:l.qos??2});const T=new AbortController,L=T.signal;if(s instanceof ht.Readable){const U=s;L.addEventListener("abort",()=>{U.destroyed||U.destroy(Ne(L.reason))},{once:!0})}const B=`sink-push-send:${d}`,q=()=>this.timerRefresh(B,()=>{const U=new Error(`push to sink "${n}" timed out`);T.abort(U),w.unroll()});w.roll(()=>{this.timerClear(B)}),q();let $,S,x=!1,F=!1,_=!1,v,k;const M=new Promise((U,W)=>{v=U,k=W});M.catch(()=>{});try{if(await new Promise((G,Y)=>{const N=()=>{Y(L.reason)};L.addEventListener("abort",N,{once:!0}),w.roll(()=>{L.removeEventListener("abort",N)}),this.onResponse.set(`sink-push-response:${d}`,ye=>{ye.error?Y(new Error(ye.error)):(ye.sender&&(c=ye.sender),$=ye.credit,F=!0,G())}),w.roll(()=>{this.onResponse.delete(`sink-push-response:${d}`)});const Z=this.authenticate(),re=this.metaStore(h),Q=this.msg.makeSinkPushRequest(d,n,i,this.options.id,c,Z,re),se=this.codec.encode(Q),fe=this.options.topicMake(n,"sink-push-request",c);br(`publish push request as MQTT message to topic "${fe}"`,w,()=>this.publishToTopic(fe,se,{qos:2,...l})).catch(ye=>{Y(ye)})}),this.onResponse.set(`sink-push-response:${d}`,G=>{G.error?(x=!0,k(new Error(G.error)),T.abort(new Error(G.error))):F&&!_&&(_=!0,v())}),$!==void 0&&$>0&&(S=new Ti($)),S){const G=S;w.roll(()=>{G.abort()}),this.onResponse.set(`sink-push-credit:${d}`,Y=>{G.replenish(Y.credit),q()}),w.roll(()=>{this.onResponse.delete(`sink-push-credit:${d}`)})}const U=this.options.topicMake(n,"sink-push-request",c),W=async(G,Y,N)=>{q();const Z=this.msg.makeSinkPushChunk(d,n,G,Y,N,this.options.id,c),re=this.codec.encode(Z);await this.publishToTopic(U,re,{qos:2,...l})};s instanceof ht.Readable?await Ii(s,this.options.chunkSize,W,S,L):s instanceof Uint8Array&&await Ri(s,this.options.chunkSize,W,S,L),_||await new Promise((G,Y)=>{const N=()=>{Y(L.reason)};L.addEventListener("abort",N,{once:!0}),M.then(G,Y).finally(()=>{L.removeEventListener("abort",N)})})}catch(U){const W=Ne(U);if(T.abort(W),F&&!x){const G=this.options.topicMake(n,"sink-push-request",c),Y=this.msg.makeSinkPushChunk(d,n,void 0,W.message,!0,this.options.id,c),N=this.codec.encode(Y);await this.publishToTopic(G,N,{qos:2,...l}).catch(()=>{})}throw U}finally{await w.unroll()}}}class Cc extends Dc{}return Cc}));
|
|
14
|
+
`,w+=h,w},Pn.noChildren=!0,re.registerDecoder(ae.CBOR,Pn),re.registerDecoder(ae.URI,t=>(pt(t.contents),new URL(t.contents)),"URI"),Ae(URL,t=>[ae.URI,t.toString()]),re.registerDecoder(ae.BASE64URL,t=>(pt(t.contents),Ea(t.contents)),"Base64url-encoded"),re.registerDecoder(ae.BASE64,t=>(pt(t.contents),Rn(t.contents)),"Base64-encoded"),re.registerDecoder(35,t=>(pt(t.contents),new RegExp(t.contents)),"RegExp"),re.registerDecoder(21065,t=>{pt(t.contents);const e=`^(?:${t.contents})$`;return new RegExp(e,"u")},"I-RegExp"),re.registerDecoder(ae.REGEXP,t=>{if(ks(t.contents),t.contents.length<1||t.contents.length>2)throw new Error(`Invalid RegExp Array: ${t.contents}`);return new RegExp(t.contents[0],t.contents[1])},"RegExp"),Ae(RegExp,t=>[ae.REGEXP,[t.source,t.flags]]),re.registerDecoder(64,t=>(yt(t.contents),t.contents),"uint8 Typed Array");function Pe(t,e,r){yt(t.contents);let n=t.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const s=new e(n),i=new DataView(t.contents.buffer,t.contents.byteOffset,t.contents.byteLength),c=i[`get${e.name.replace(/Array/,"")}`].bind(i);for(let l=0;l<n;l++)s[l]=c(l*e.BYTES_PER_ELEMENT,r);return s}function Tt(t,e,r,n,s){const i=s.forceEndian??Ns;if(zt(i?e:r,t,s),Ge(n.byteLength,t,z.BYTE_STRING),Ns===i)t.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const c=`write${n.constructor.name.replace(/Array/,"")}`,l=t[c].bind(t);for(const h of n)l(h,i)}}re.registerDecoder(65,t=>Pe(t,Uint16Array,!1),"uint16, big endian, Typed Array"),re.registerDecoder(66,t=>Pe(t,Uint32Array,!1),"uint32, big endian, Typed Array"),re.registerDecoder(67,t=>Pe(t,BigUint64Array,!1),"uint64, big endian, Typed Array"),re.registerDecoder(68,t=>(yt(t.contents),new Uint8ClampedArray(t.contents)),"uint8 Typed Array, clamped arithmetic"),Ae(Uint8ClampedArray,t=>[68,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),re.registerDecoder(69,t=>Pe(t,Uint16Array,!0),"uint16, little endian, Typed Array"),Ae(Uint16Array,(t,e,r)=>Tt(e,69,65,t,r)),re.registerDecoder(70,t=>Pe(t,Uint32Array,!0),"uint32, little endian, Typed Array"),Ae(Uint32Array,(t,e,r)=>Tt(e,70,66,t,r)),re.registerDecoder(71,t=>Pe(t,BigUint64Array,!0),"uint64, little endian, Typed Array"),Ae(BigUint64Array,(t,e,r)=>Tt(e,71,67,t,r)),re.registerDecoder(72,t=>(yt(t.contents),new Int8Array(t.contents)),"sint8 Typed Array"),Ae(Int8Array,t=>[72,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),re.registerDecoder(73,t=>Pe(t,Int16Array,!1),"sint16, big endian, Typed Array"),re.registerDecoder(74,t=>Pe(t,Int32Array,!1),"sint32, big endian, Typed Array"),re.registerDecoder(75,t=>Pe(t,BigInt64Array,!1),"sint64, big endian, Typed Array"),re.registerDecoder(77,t=>Pe(t,Int16Array,!0),"sint16, little endian, Typed Array"),Ae(Int16Array,(t,e,r)=>Tt(e,77,73,t,r)),re.registerDecoder(78,t=>Pe(t,Int32Array,!0),"sint32, little endian, Typed Array"),Ae(Int32Array,(t,e,r)=>Tt(e,78,74,t,r)),re.registerDecoder(79,t=>Pe(t,BigInt64Array,!0),"sint64, little endian, Typed Array"),Ae(BigInt64Array,(t,e,r)=>Tt(e,79,75,t,r)),re.registerDecoder(81,t=>Pe(t,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),re.registerDecoder(82,t=>Pe(t,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),re.registerDecoder(85,t=>Pe(t,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Ae(Float32Array,(t,e,r)=>Tt(e,85,81,t,r)),re.registerDecoder(86,t=>Pe(t,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Ae(Float64Array,(t,e,r)=>Tt(e,86,82,t,r)),re.registerDecoder(ae.SET,(t,e)=>{if(ks(t.contents),e.sortKeys){const r=qe.decodeToEncodeOpts(e);let n=null;for(const s of t.contents){const i=[s,void 0,Vt(s,r)];if(n&&e.sortKeys(n,i)>=0)throw new Error(`Set items out of order in tag #${ae.SET}`);n=i}}return new Set(t.contents)},"Set"),Ae(Set,(t,e,r)=>{let n=[...t];if(r.sortKeys){const s=n.map(i=>[i,void 0,Vt(i,r)]);s.sort(r.sortKeys),n=s.map(([i])=>i)}return[ae.SET,n]}),re.registerDecoder(ae.JSON,t=>(pt(t.contents),JSON.parse(t.contents)),"JSON-encoded");function Ps(t){return yt(t.contents),new Nr().decode(t.contents)}Ps.comment=t=>{yt(t.contents);const e=new Nr;return`(WTF8 string): ${JSON.stringify(e.decode(t.contents))}`},re.registerDecoder(ae.WTF8,Ps),re.registerDecoder(ae.SELF_DESCRIBED,t=>t.contents,"Self-Described"),re.registerDecoder(ae.INVALID_16,()=>{throw new Error(`Tag always invalid: ${ae.INVALID_16}`)},"Invalid"),re.registerDecoder(ae.INVALID_32,()=>{throw new Error(`Tag always invalid: ${ae.INVALID_32}`)},"Invalid"),re.registerDecoder(ae.INVALID_64,()=>{throw new Error(`Tag always invalid: ${ae.INVALID_64}`)},"Invalid"),re.registerDecoder(ae.SYMBOL,t=>{let e=t.contents;if(Array.isArray(t.contents)){if(t.contents.length!==1)throw new Error(`Expected Array of size 1: ${t.contents}`);[e]=t.contents}if(pt(e),!e.length)throw new Error(`Expected non-empty string: ${t.contents}`);return Symbol.for(e)},"Symbol");function Dn(t){throw new Error(`Encoding ${t.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Ae(ArrayBuffer,Dn),Ae(DataView,Dn),typeof SharedArrayBuffer<"u"&&Ae(SharedArrayBuffer,Dn);function Dr(t){return[NaN,t.valueOf()]}Ae(Boolean,Dr),Ae(Number,Dr),Ae(String,Dr),Ae(BigInt,Dr);function oc(t){const e={...qe.defaultDecodeOptions};if(t.dcbor?Object.assign(e,qe.dcborDecodeOptions):t.cde&&Object.assign(e,qe.cdeDecodeOptions),Object.assign(e,t),Object.hasOwn(e,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");return e.boxed&&(e.saveOriginal=!0),e}let ac=class{parent=void 0;ret=void 0;step(e,r,n){if(this.ret=qe.create(e,this.parent,r,n),e[2]===Me.BREAK)if(this.parent?.isStreaming)this.parent.left=0;else throw new Error("Unexpected BREAK");else this.parent&&this.parent.push(this.ret,n,e[3]);for(this.ret instanceof qe&&(this.parent=this.ret);this.parent?.done;){this.ret=this.parent.convert(n);const s=this.parent.parent;s?.replaceLast(this.ret,this.parent,n),this.parent=s}}};function cc(t,e={}){const r=oc(e),n=new Lr(t,r),s=new ac;for(const i of n)s.step(i,r,n);return s.ret}const{cdeDecodeOptions:Hc,dcborDecodeOptions:Wc,defaultDecodeOptions:Kc}=qe;class uc{constructor(e={}){this.options={id:gt(),codec:"cbor",timeout:10*1e3,share:"",chunkSize:16*1024,chunkCredit:4,topicMake:(r,n,s)=>`${r}/${n}/${s??"any"}`,topicMatch:r=>{const n=r.match(/^(.+)\/([^/]+)\/([^/]+)$/);return n?{name:n[1],operation:n[2],peerId:n[3]==="any"?void 0:n[3]}:null},...e}}}class On{static uint8ArrayToBase64(e){return Nt.from(e.buffer,e.byteOffset,e.byteLength).toString("base64")}static base64ToUint8Array(e){return new Uint8Array(Nt.from(e,"base64"))}static stringify(e){return JSON.stringify(e,(r,n)=>n instanceof Uint8Array?{__Uint8Array:this.uint8ArrayToBase64(n)}:n)}static parse(e){return JSON.parse(e,(r,n)=>typeof n?.__Uint8Array=="string"?this.base64ToUint8Array(n.__Uint8Array):n)}}class fc{constructor(e){this.format=e,this.types=new is,this.tags=new Map;const r=64e3;this.types.registerEncoder(Nt,n=>[r,new Uint8Array(n.buffer,n.byteOffset,n.byteLength)]),this.tags.set(r,n=>Nt.from(n.contents))}encode(e){let r;if(this.format==="cbor")try{r=Vt(e,{types:this.types})}catch(n){throw new Error("failed to encode CBOR format",{cause:n})}else if(this.format==="json")try{r=On.stringify(e)}catch(n){throw new Error("failed to encode JSON format",{cause:n})}else throw new Error(`invalid format "${this.format}"`);return r}decode(e){let r;if(this.format==="cbor"){if(!(e instanceof Uint8Array))throw new Error("failed to decode CBOR format (data type is not Uint8Array)");if(e.byteLength===0)throw new Error("failed to decode CBOR format (data is empty)");try{r=cc(e,{tags:this.tags})}catch(n){throw new Error("failed to decode CBOR format",{cause:n})}}else if(this.format==="json"){if(typeof e!="string")throw new Error("failed to decode JSON format (data type is not string)");if(e.length===0)throw new Error("failed to decode JSON format (data is empty)");try{r=On.parse(e)}catch(n){throw new Error("failed to decode JSON format",{cause:n})}}else throw new Error(`invalid format "${this.format}"`);return r}}class lc extends uc{constructor(e={}){super(e),this.codec=new fc(this.options.codec)}}class Or extends lc{static{this.encoder=new TextEncoder}static{this.decoder=new TextDecoder}str2buf(e){return Or.encoder.encode(e)}buf2str(e){return Or.decoder.decode(e)}arr2buf(e){let r;return e instanceof Uint8Array?r=e:r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r}buf2arr(e,r){let n;const s=r;if(s===Nt)n=Nt.from(e.buffer,e.byteOffset,e.byteLength);else if(s===Uint8Array)n=e;else if(s===Int8Array)n=new Int8Array(e.buffer,e.byteOffset,e.byteLength);else throw new Error("invalid data type");return n}}const Ds=t=>{const e=t.match(/^(\d+)\.(\d+)$/);if(e===null)throw new Error("invalid version string");const r=parseInt(e[2],10);if(r>99)throw new Error("invalid version string: minor version exceeds 99");return parseInt(e[1],10)*100+r},Cn="1.4",hc=Ds(Cn),ur=Ke(es(ve(),Ut()),Qi(t=>!Array.isArray(t))),Cr=Ke(Jt(Ke(ve(),Lt(8192))),Lt(8));class Ve{constructor(e,r,n,s){this.type=e,this.id=r,this.sender=n,this.receiver=s,this.version=`MQTT+/${Cn}`}}const Ye={version:Ke(ve(),Xi(/^MQTT\+\/\d+\.\d+$/)),type:ve(),id:ve(),sender:he(ve()),receiver:he(ve())};class Os extends Ve{constructor(e,r,n,s,i,c,l){super("event-emission",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const dc=We({...Ye,type:He("event-emission"),name:ve(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Cr),meta:he(ur)});class Cs extends Ve{constructor(e,r,n,s,i,c,l){super("service-call-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const pc=We({...Ye,type:He("service-call-request"),name:ve(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Cr),meta:he(ur)});class $s extends Ve{constructor(e,r,n,s,i){super("service-call-response",e,s,i),this.result=r,this.error=n}}const yc=We({...Ye,type:He("service-call-response"),result:he(Ut()),error:he(ve())});class qs extends Ve{constructor(e,r,n,s,i,c,l){super("sink-push-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l}}const wc=We({...Ye,type:He("sink-push-request"),name:ve(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Cr),meta:he(ur)});class js extends Ve{constructor(e,r,n,s,i,c){super("sink-push-response",e,s,i),this.name=r,this.error=n,this.credit=c}}const gc=We({...Ye,type:He("sink-push-response"),name:ve(),error:he(ve()),credit:he(Ke(rr(),er(),tr(1)))});class Hs extends Ve{constructor(e,r,n,s,i,c,l){super("sink-push-chunk",e,c,l),this.name=r,this.chunk=n,this.error=s,this.final=i}}const mc=We({...Ye,type:He("sink-push-chunk"),name:ve(),chunk:he(Tn(Uint8Array)),error:he(ve()),final:he(vn())});class Ws extends Ve{constructor(e,r,n,s,i){super("sink-push-credit",e,s,i),this.name=r,this.credit=n}}const bc=We({...Ye,type:He("sink-push-credit"),name:ve(),credit:Ke(rr(),er(),tr(1))});class Ks extends Ve{constructor(e,r,n,s,i,c,l,h){super("source-fetch-request",e,s,i),this.name=r,this.params=n,this.auth=c,this.meta=l,this.credit=h}}const Ec=We({...Ye,type:He("source-fetch-request"),name:ve(),params:he(Ke(Jt(Ut()),Lt(64))),auth:he(Cr),meta:he(ur),credit:he(Ke(rr(),er(),tr(1)))});class Gs extends Ve{constructor(e,r,n,s,i,c){super("source-fetch-response",e,s,i),this.name=r,this.error=n,this.meta=c}}const Sc=We({...Ye,type:He("source-fetch-response"),name:ve(),error:he(ve()),meta:he(ur)});class Js extends Ve{constructor(e,r,n,s,i,c,l){super("source-fetch-chunk",e,c,l),this.name=r,this.chunk=n,this.error=s,this.final=i}}const _c=We({...Ye,type:He("source-fetch-chunk"),name:ve(),chunk:he(Tn(Uint8Array)),error:he(ve()),final:he(vn())});class zs extends Ve{constructor(e,r,n,s,i){super("source-fetch-credit",e,s,i),this.name=r,this.credit=n}}const vc=We({...Ye,type:He("source-fetch-credit"),name:ve(),credit:Ke(rr(),er(),tr(0))});class Tc{makeEventEmission(e,r,n,s,i,c,l){return new Os(e,r,n,s,i,c,l)}makeServiceCallRequest(e,r,n,s,i,c,l){return new Cs(e,r,n,s,i,c,l)}makeServiceCallResponse(e,r,n,s,i){return new $s(e,r,n,s,i)}makeSinkPushRequest(e,r,n,s,i,c,l){return new qs(e,r,n,s,i,c,l)}makeSinkPushResponse(e,r,n,s,i,c){return new js(e,r,n,s,i,c)}makeSinkPushChunk(e,r,n,s,i,c,l){return new Hs(e,r,n,s,i,c,l)}makeSinkPushCredit(e,r,n,s,i){return new Ws(e,r,n,s,i)}makeSourceFetchRequest(e,r,n,s,i,c,l,h){return new Ks(e,r,n,s,i,c,l,h)}makeSourceFetchResponse(e,r,n,s,i,c){return new Gs(e,r,n,s,i,c)}makeSourceFetchChunk(e,r,n,s,i,c,l){return new Js(e,r,n,s,i,c,l)}makeSourceFetchCredit(e,r,n,s,i){return new zs(e,r,n,s,i)}parse(e){if(typeof e!="object"||e===null)throw new Error("invalid argument: not an object");if(typeof e.version!="string")throw new Error('invalid object: missing or invalid "version" field');const r=e.version.match(/^MQTT\+\/(\d+\.\d+)$/);if((r!==null?Ds(r[1]):0)!==hc)throw new Error(`protocol version mismatch (expected version ${Cn}, got version ${e.version})`);const s=(i,c,l)=>{const h=ya(l,i);if(!h.success){const w=h.issues.map(d=>d.message).join("; ");throw new Error(`invalid ${c} object: ${w}`)}return h.output};if(typeof e.type!="string")throw new Error('invalid object: missing or invalid "type" field');if(e.type==="event-emission"){const i=s(e,"EventEmission",dc);return this.makeEventEmission(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="service-call-request"){const i=s(e,"ServiceCallRequest",pc);return this.makeServiceCallRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="service-call-response"){const i=s(e,"ServiceCallResponse",yc);return this.makeServiceCallResponse(i.id,i.result,i.error,i.sender,i.receiver)}else if(e.type==="sink-push-request"){const i=s(e,"SinkPushRequest",wc);return this.makeSinkPushRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta)}else if(e.type==="sink-push-response"){const i=s(e,"SinkPushResponse",gc);return this.makeSinkPushResponse(i.id,i.name,i.error,i.sender,i.receiver,i.credit)}else if(e.type==="sink-push-chunk"){const i=s(e,"SinkPushChunk",mc);return this.makeSinkPushChunk(i.id,i.name,i.chunk,i.error,i.final,i.sender,i.receiver)}else if(e.type==="sink-push-credit"){const i=s(e,"SinkPushCredit",bc);return this.makeSinkPushCredit(i.id,i.name,i.credit,i.sender,i.receiver)}else if(e.type==="source-fetch-request"){const i=s(e,"SourceFetchRequest",Ec);return this.makeSourceFetchRequest(i.id,i.name,i.params,i.sender,i.receiver,i.auth,i.meta,i.credit)}else if(e.type==="source-fetch-response"){const i=s(e,"SourceFetchResponse",Sc);return this.makeSourceFetchResponse(i.id,i.name,i.error,i.sender,i.receiver,i.meta)}else if(e.type==="source-fetch-chunk"){const i=s(e,"SourceFetchChunk",_c);return this.makeSourceFetchChunk(i.id,i.name,i.chunk,i.error,i.final,i.sender,i.receiver)}else if(e.type==="source-fetch-credit"){const i=s(e,"SourceFetchCredit",vc);return this.makeSourceFetchCredit(i.id,i.name,i.credit,i.sender,i.receiver)}else throw new Error("invalid object: not of any known type")}isRequest(e){return e instanceof Os||e instanceof Cs||e instanceof Ks||e instanceof qs}isResponse(e){return e instanceof $s||e instanceof js||e instanceof Hs||e instanceof Ws||e instanceof Gs||e instanceof Js||e instanceof zs}}class xc extends Or{constructor(){super(...arguments),this.msg=new Tc}}class Ac{constructor(e,r,n,s){this.timestamp=e,this.level=r,this.msg=n,this.data=s}async resolve(){if(this.msg instanceof Promise&&(this.msg=await this.msg.catch(()=>"<resolve-failed>")),this.data)for(const e of Object.keys(this.data))this.data[e]instanceof Promise&&(this.data[e]=await this.data[e].catch(()=>"<resolve-failed>"))}toString(){const e=new Date(this.timestamp),r=e.getFullYear(),n=(e.getMonth()+1).toString().padStart(2,"0"),s=e.getDate().toString().padStart(2,"0"),i=e.getHours().toString().padStart(2,"0"),c=e.getMinutes().toString().padStart(2,"0"),l=e.getSeconds().toString().padStart(2,"0"),h=e.getMilliseconds().toString().padStart(3,"0"),w=`${r}-${n}-${s} ${i}:${c}:${l}.${h}`,d=this.msg instanceof Promise?"<unresolved>":this.msg;let I="";if(this.data!==void 0){const T=this.data;I=` (${Object.keys(T).map(B=>{const j=T[B]instanceof Promise?"<unresolved>":T[B];return`${B}: ${On.stringify(j)}`}).join(", ")})`}return`[${w}] ${this.level}: ${d}${I}`}}class Rc extends xc{constructor(){super(...arguments),this._events=new oa.EventEmitter}on(...e){this._events.on(...e)}off(...e){this._events.off(...e)}emitEvent(...e){return this._events.listenerCount(e[0])===0?!1:this._events.emit(...e)}log(e,r,n){const s=new Ac(Date.now(),e,r,n);this.emitEvent("log",s)}error(e,r){let n=e;r!==void 0&&(n=new Error(`${r}: ${e.message}`,{cause:e})),this.emitEvent("error",n),this.log("error",n.message)}}class Ic extends Rc{constructor(e,r={}){super(r),this.onRequest=new Map,this.onResponse=new Map,e===null&&(this.log("info","establishing proxy MQTT client"),e=new Proxy({},{get(n,s,i){return s==="isFakeProxy"?!0:typeof s=="string"&&["on","off","once"].includes(s)?()=>{}:()=>{throw new Error(`Underlying MQTT operation "${String(s)}" called on a null MQTT client -- only MQTT+ "emit({ ..., dry: true })" is supported in this special operation mode`)}}})),this.mqtt=e,this.log("info","hooking into MQTT client"),this.messageHandler=(n,s,i)=>{let c;if(this.options.codec==="json")c=s.toString();else if(this.options.codec==="cbor")c=Si.isBuffer(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):s;else throw new Error("invalid codec configured");this._onMessage(n,c,i)},this.mqtt.on("message",this.messageHandler)}async destroy(){this.log("info","un-hooking from MQTT client"),this.mqtt.off("message",this.messageHandler),this.onRequest.clear(),this.onResponse.clear()}makeRegistration(e,r,n,s){return{destroy:async()=>{if(!this.onRequest.has(s))throw new Error(`destroy: ${r} "${n}" not registered`);await e.unroll(!1)?.catch(i=>{const c=ke(i,`destroy: ${r} "${n}" failed to cleanup`);throw this.error(c),c})}}}async subscribeTopic(e,r={}){return this.log("info",`subscribing to MQTT topic "${e}"`),new Promise((n,s)=>{this.mqtt.subscribe(e,{qos:2,...r},(i,c)=>{i?(this.error(i,`subscribing to MQTT topic "${e}" failed`),s(i)):n()})})}async unsubscribeTopic(e){return this.log("info",`unsubscribing from MQTT topic "${e}"`),new Promise((r,n)=>{this.mqtt.unsubscribe(e,(s,i)=>{s?(this.error(s,`unsubscribing from MQTT topic "${e}" failed`),n(s)):r()})})}async publishToTopic(e,r,n={}){typeof r=="string"?this.log("info",`publishing to MQTT topic "${e}" (type: string, length: ${r.length} chars)`):this.log("info",`publishing to MQTT topic "${e}" (type: buffer, length: ${r.byteLength} bytes)`);const s=new vi((i,c)=>{let l;try{const h=this.codec.decode(r);l=this.msg.parse(h)}catch(h){return c(h)}i(l)});return this.log("debug",`publishing to MQTT topic "${e}"`,{message:s}),new Promise((i,c)=>{const l=typeof r=="string"?r:Si.from(r.buffer,r.byteOffset,r.byteLength);this.mqtt.publish(e,l,n,h=>{h?(this.error(h,`publishing to MQTT topic "${e}" failed`),c(h)):i()})})}_onMessage(e,r,n){const s=this.options.topicMatch(e);if(s===null)return;typeof r=="string"?this.log("info",`received from MQTT topic "${e}" (type: string, length: ${r.length} chars)`):this.log("info",`received from MQTT topic "${e}" (type: buffer, length: ${r.byteLength} bytes)`);let i;try{i=this.codec.decode(r)}catch(l){this.error(ke(l,"failed to parse message into object"));return}let c;try{c=this.msg.parse(i)}catch(l){this.error(ke(l,"failed to parse object into typed message object"));return}if(this.log("debug",`received from MQTT topic "${e}"`,{message:c}),this.msg.isRequest(c)){const l=this.onRequest.get(`${c.type}:${c.name}`);l!==void 0&&Promise.resolve().then(()=>l(c,s.name)).catch(h=>{this.error(ke(h,`dispatching request message from MQTT topic "${e}" failed`))})}else if(this.msg.isResponse(c)){const l=this.onResponse.get(`${c.type}:${c.id}`);l!==void 0&&Promise.resolve().then(()=>l(c,s.name)).catch(h=>{this.error(ke(h,`dispatching response message from MQTT topic "${e}" failed`))})}}}class Bc{constructor(e,r,n=30*1e3){this.subscribeFn=e,this.unsubscribeFn=r,this.lingerMs=n,this.counts=new Map,this.pending=new Map,this.lingers=new Map,this.unsubbing=new Map}incrementCount(e){const r=this.counts.get(e)??0;return this.counts.set(e,r+1),r}decrementCount(e){const r=this.counts.get(e);if(r!==void 0)return r<=1?(this.counts.delete(e),0):(this.counts.set(e,r-1),r-1)}async subscribe(e,r={qos:2}){const n=this.incrementCount(e),s=this.lingers.get(e);if(s){clearTimeout(s),this.lingers.delete(e);return}if(n===0){let i,c;const l=new Promise((d,I)=>{i=d,c=I});l.catch(()=>{}),this.pending.set(e,l);const h=this.unsubbing.get(e);return h&&await h,this.subscribeFn(e,r).then(()=>{this.pending.delete(e),i()}).catch(d=>{throw this.pending.delete(e),this.decrementCount(e),c(d),d})}else{const i=this.pending.get(e);if(i)return i.catch(c=>{throw this.decrementCount(e),c})}}async unsubscribe(e){if(this.decrementCount(e)===0)if(this.lingerMs>0){const n=setTimeout(()=>{this.lingers.delete(e);const s=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,s)},this.lingerMs);this.lingers.set(e,n)}else{const n=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,n),await n}}async flush(){const e=new Set([...this.counts.keys(),...this.lingers.keys(),...this.pending.keys(),...this.unsubbing.keys()]);for(const r of this.lingers.values())clearTimeout(r);this.lingers.clear(),this.counts.clear(),await Promise.allSettled([...this.pending.values(),...this.unsubbing.values()]),await Promise.allSettled([...e].map(r=>this.unsubscribeFn(r).catch(()=>{}))),this.pending.clear(),this.unsubbing.clear()}}class Nc extends Ic{constructor(){super(...arguments),this.subscriptions=new Bc((e,r)=>this.subscribeTopic(e,r),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,r,n={}){await br(`subscribe to MQTT topic "${r}"`,e,()=>this.subscriptions.subscribe(r,{qos:2,...n})),e.roll(()=>this.subscriptions.unsubscribe(r))}async destroy(){await this.subscriptions.flush(),await super.destroy()}}class kc extends Nc{constructor(){super(...arguments),this.timers=new Map}async destroy(){for(const e of this.timers.values())clearTimeout(e);this.timers.clear(),await super.destroy()}timerRefresh(e,r){const n=this.timers.get(e);n!==void 0&&clearTimeout(n),this.timers.set(e,setTimeout(async()=>{this.timers.delete(e);try{await r()}catch(s){this.error(ke(s),`timer "${e}" failed`)}},this.options.timeout))}timerClear(e){const r=this.timers.get(e);r!==void 0&&(clearTimeout(r),this.timers.delete(e))}}class Fc extends kc{constructor(){super(...arguments),this._meta=new Map}meta(...e){const[r,n]=e;if(e.length===0)return Object.fromEntries(this._meta);if(e.length===1)return this._meta.get(r);n==null?this._meta.delete(r):this._meta.set(r,n)}metaStore(e){const r=e===void 0||Object.keys(e).length===0;if(!(this._meta.size===0&&r))return this._meta.size>0&&r?Object.fromEntries(this._meta):this._meta.size===0&&!r?e:{...Object.fromEntries(this._meta),...e}}}const Vs=new TextEncoder;class Lc extends Fc{constructor(){super(...arguments),this._credential=null,this._tokens=new Set}credential(e){if(e.length===0)throw new Error("credential must not be empty");const r=Vs.encode(e),n=Vs.encode("mqtt-plus");this._credential=ta(ia,r,n,6e5,32)}async issue(e){if(this._credential===null)throw new Error("credential has to be provided before issuing tokens");if(e.roles.length===0)throw new Error("payload.roles must be a non-empty array");if(e.roles.length>64)throw new Error("payload.roles must not exceed 64 roles");const r=new Vo(e);return r.setProtectedHeader({alg:"HS256",typ:"JWT"}),await r.sign(this._credential)}authenticate(e,r){if(e===void 0){const n=Array.from(this._tokens).filter(s=>s.length<=8192).slice(0,8);return n.length>0?n:void 0}else if(r===!0)this._tokens.delete(e);else{if(e.length>8192)throw new Error("token must not exceed 8192 characters");if(!this._tokens.has(e)&&this._tokens.size>=8)throw new Error("at most 8 tokens can be authenticated at once");this._tokens.add(e)}}async validateToken(e){if(this._credential===null)throw new Error("credential has to be provided before validating tokens");return(await Xo(e,this._credential).catch(()=>null))?.payload??null}async authenticated(e,r,n){let s=!1,i,c;if(typeof n=="string"?(i="require",c=[n]):(i=n.mode,c=n.roles),r!==void 0)for(const l of r.slice(0,8)){if(l.length>8192)continue;const h=await this.validateToken(l);if(h!==null&&!(h.id&&h.id!==e)&&Array.isArray(h.roles)&&!(h.roles.length>64)){for(const w of c)if(h.roles.includes(w)){s=!0;break}if(s)break}}return!s&&i==="optional"&&(s=!0),s}}class Uc extends Lc{async event(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`event-emission:${n}`))throw new Error(`event: event "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"event-emission"),I=this.options.topicMake(n,"event-emission",this.options.id);return this.onRequest.set(`event-emission:${n}`,async(T,L)=>{const B=T.sender;if(B===void 0||B==="")throw new Error("invalid request: missing sender");const j=T.params??[],$={sender:B};T.receiver&&($.receiver=T.receiver),T.meta&&($.meta=T.meta);try{if(L!==T.name)throw new Error(`event name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&($.authenticated=await this.authenticated(B,T.auth,l)),$.authenticated!==void 0&&!$.authenticated)throw new Error(`event "${n}" failed authentication`);await s(...j,$)}catch(S){const x=ke(S);this.error(x,`handler for event "${n}" failed`)}}),h.roll(()=>{this.onRequest.delete(`event-emission:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"event",n,`event-emission:${n}`)}emit(e,...r){let n,s,i,c={},l,h;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta,h=e.dry):(n=e,s=r);const w=gt(),d=this.authenticate(),I=this.metaStore(l),T=this.msg.makeEventEmission(w,n,s,this.options.id,i,d,I),L=this.codec.encode(T),B=this.options.topicMake(n,"event-emission",i);if(h)return{topic:B,payload:L,options:{qos:2,...c}};this.publishToTopic(B,L,{qos:2,...c}).catch(j=>{this.error(j,`emitting event "${n}" failed`)})}}class Mc extends Uc{async service(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`service-call-request:${n}`))throw new Error(`service: service "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"service-call-request"),I=this.options.topicMake(n,"service-call-request",this.options.id);return this.onRequest.set(`service-call-request:${n}`,async(T,L)=>{const B=T.id,j=T.sender;if(j===void 0||j==="")throw new Error("invalid request: missing sender");const $=T.params??[],S={sender:j};T.receiver&&(S.receiver=T.receiver),T.meta&&(S.meta=T.meta);try{if(L!==T.name)throw new Error(`service name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&(S.authenticated=await this.authenticated(j,T.auth,l)),S.authenticated!==void 0&&!S.authenticated)throw new Error(`service "${n}" failed authentication`);const x=await s(...$,S),F=this.msg.makeServiceCallResponse(B,x,void 0,this.options.id,j),_=this.codec.encode(F),v=this.options.topicMake(n,"service-call-response",j);await this.publishToTopic(v,_,{qos:i.qos??2})}catch(x){const F=ke(x);this.error(F,`handler for service "${n}" failed`);const _=this.msg.makeServiceCallResponse(B,void 0,F.message,this.options.id,j);try{const v=this.codec.encode(_),k=this.options.topicMake(n,"service-call-response",j);await this.publishToTopic(k,v,{qos:i.qos??2})}catch(v){this.error(ke(v),`sending error response for service "${n}" failed`)}}}),h.roll(()=>{this.onRequest.delete(`service-call-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"service",n,`service-call-request:${n}`)}async call(e,...r){let n,s,i,c={},l;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta):(n=e,s=r);const h=new De;let w=gt();for(;this.onResponse.has(`service-call-response:${w}`);)w=gt();const d=this.options.topicMake(n,"service-call-response",this.options.id);await this.subscribeTopicAndSpool(h,d,{qos:c.qos??2});const I=`service-call:${w}`;let T;const L=new Promise((F,_)=>{T=_,this.timerRefresh(I,async()=>{await h.unroll(),_(new Error("communication timeout"))}),h.roll(()=>{this.timerClear(I)}),this.onResponse.set(`service-call-response:${w}`,async v=>{await h.unroll(),v.error!==void 0?_(new Error(v.error)):F(v.result)}),h.roll(()=>{this.onResponse.delete(`service-call-response:${w}`)})}),B=this.authenticate(),j=this.metaStore(l),$=this.msg.makeServiceCallRequest(w,n,s,this.options.id,i,B,j),S=this.codec.encode($),x=this.options.topicMake(n,"service-call-request",i);try{await br(`publish service request as MQTT message to topic "${x}"`,h,()=>this.publishToTopic(x,S,{qos:2,...c}))}catch(F){return T(F),L}return L}}class Pc extends Mc{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map}async destroy(){for(const e of this.sourceControllers.values())e.abort(new Error("source destroyed"));this.sourceControllers.clear();for(const e of this.sourceCreditGates.values())e.abort();this.sourceCreditGates.clear(),await super.destroy()}async source(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`source-fetch-request:${n}`))throw new Error(`source: source "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"source-fetch-request"),I=this.options.topicMake(n,"source-fetch-request",this.options.id);return this.onRequest.set(`source-fetch-request:${n}`,async(T,L)=>{const B=T.id,j=T.params??[],$=T.sender;if($===void 0||$==="")throw new Error("invalid request: missing sender");const S=T.receiver,x={sender:$};S&&(x.receiver=S),T.meta&&(x.meta=T.meta);const F=this.options.topicMake(n,"source-fetch-response",$),_=async Q=>{const ee=this.metaStore(x.meta),ue=this.msg.makeSourceFetchResponse(B,n,Q,this.options.id,$,ee),we=this.codec.encode(ue);await this.publishToTopic(F,we,{qos:i.qos??2})},v=new De;v.roll(()=>{this.onResponse.delete(`source-fetch-credit:${B}`),this.sourceControllers.delete(B)});const k=new AbortController;this.sourceControllers.set(B,k);const U=k.signal;U.addEventListener("abort",()=>{x.stream instanceof ht.Readable&&!x.stream.destroyed&&x.stream.destroy(ke(U.reason))},{once:!0});const O=`source-fetch-send:${B}`,q=()=>this.timerRefresh(O,()=>{const Q=new Error(`source fetch "${n}" timed out`);k.abort(Q);const ee=this.sourceCreditGates.get(B);ee!==void 0&&(ee.abort(),this.sourceCreditGates.delete(B)),v.unroll()}),G=()=>this.timerClear(O);q(),v.roll(()=>{G()});const V=async(Q,ee,ue)=>{q();const we=this.msg.makeSourceFetchChunk(B,n,Q,ee,ue,this.options.id,$),Ee=this.codec.encode(we);await this.publishToTopic(F,Ee,{qos:i.qos??2})};let N=!1,X,fe=!1;try{if(L!==T.name)throw new Error(`source name mismatch (topic: "${L}", payload: "${T.name}")`);if(l&&(x.authenticated=await this.authenticated($,T.auth,l)),x.authenticated!==void 0&&!x.authenticated)throw new Error(`source "${n}" failed authentication`);const Q=T.credit;if(X=Q!==void 0&&Q>0?new Ti(Q):void 0,X&&(this.sourceCreditGates.set(B,X),v.roll(()=>{X.abort(),this.sourceCreditGates.delete(B)})),this.onResponse.set(`source-fetch-credit:${B}`,ee=>{if(ee.credit===0){fe=!0,k.abort(new Error(`source fetch "${n}" cancelled by fetcher`));return}X&&(X.replenish(ee.credit),q())}),await s(...j,x),!(x.stream instanceof ht.Readable)&&!(x.buffer instanceof Promise))throw new Error("handler did not provide data via info.stream or info.buffer fields");if(x.stream instanceof ht.Readable&&x.buffer instanceof Promise)throw new Error("handler has set both info.stream and info.buffer fields");await _(),N=!0,x.stream instanceof ht.Readable?await Ii(x.stream,this.options.chunkSize,V,X,U):x.buffer instanceof Promise&&await Ri(await x.buffer,this.options.chunkSize,V,X,U)}catch(Q){const ee=ke(Q,`handler for source "${n}" failed`);k.abort(ee),fe||(this.error(ee),N?await V(void 0,ee.message,!0).catch(()=>{}):await _(ee.message).catch(()=>{}))}finally{await v.unroll()}}),h.roll(()=>{this.onRequest.delete(`source-fetch-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"source",n,`source-fetch-request:${n}`)}async fetch(e,...r){let n,s,i,c={},l;typeof e=="object"&&e!==null?(n=e.name,s=e.params,i=e.receiver,c=e.options??{},l=e.meta):(n=e,s=r);const h=new De;let w=gt();for(;this.onResponse.has(`source-fetch-response:${w}`)||this.onResponse.has(`source-fetch-chunk:${w}`);)w=gt();const d=this.options.topicMake(n,"source-fetch-response",this.options.id);await this.subscribeTopicAndSpool(h,d,{qos:c.qos??2});const I=this.options.chunkCredit;let T=0,L=I,B,j=!1;const $=`source-fetch:${w}`;let S;const x=()=>{this.timerRefresh($,()=>{S?.destroy(new Error("communication timeout")),h.unroll()})};h.roll(()=>{this.timerClear($)}),S=new ht.Readable({highWaterMark:I>0?I*this.options.chunkSize:16*1024,read:Q=>{if(I<=0||!this.onResponse.has(`source-fetch-response:${w}`))return;const ee=B??i;if(!ee)return;const ue=Math.max(0,T+I-L);if(ue>0){L+=ue;const we=this.msg.makeSourceFetchCredit(w,n,ue,this.options.id,ee),Ee=this.codec.encode(we),Ce=this.options.topicMake(n,"source-fetch-request",ee);this.publishToTopic(Ce,Ee,{qos:c.qos??2}).catch(wt=>{this.error(wt,`sending credit for fetch "${n}" failed`)}),x()}}});const F=Ai(S);let _;const v=new Promise(Q=>{_=Q});h.roll(()=>{_(void 0)}),x();let k=!1;const U=()=>{if(!k&&!j){k=!0;const Q=B??i;if(Q){const ee=this.msg.makeSourceFetchCredit(w,n,0,this.options.id,Q),ue=this.codec.encode(ee),we=this.options.topicMake(n,"source-fetch-request",Q);this.publishToTopic(we,ue,{qos:c.qos??2}).catch(()=>{})}}h.unroll()};S.once("close",U),S.once("error",U),this.onResponse.set(`source-fetch-response:${w}`,Q=>{if(!j){if(Q.name!==n){j=!0,S.destroy(new Error(`source name mismatch (expected "${n}", got "${Q.name}")`)),h.unroll();return}Q.sender&&(B=Q.sender),Q.error?(j=!0,S.destroy(new Error(Q.error)),h.unroll()):(_(Q.meta),x())}}),this.onResponse.set(`source-fetch-chunk:${w}`,Q=>{j||(Q.error?(j=!0,S.destroy(new Error(Q.error)),h.unroll()):(x(),Q.chunk!==void 0&&(T++,S.push(Q.chunk)),Q.final&&(j=!0,S.push(null),h.unroll())))}),h.roll(()=>{this.onResponse.delete(`source-fetch-response:${w}`),this.onResponse.delete(`source-fetch-chunk:${w}`)});const O=this.authenticate(),q=this.metaStore(l),G=I>0?I:void 0,V=this.msg.makeSourceFetchRequest(w,n,s,this.options.id,i,O,q,G),N=this.codec.encode(V),X=this.options.topicMake(n,"source-fetch-request",i);br(`publish fetch request as MQTT message to topic "${X}"`,()=>this.publishToTopic(X,N,{qos:2,...c})).catch(Q=>{S.destroy(ke(Q))});const fe={stream:S,buffer:F,meta:v};return Bi(fe,"stream","buffer"),fe}}class Dc extends Pc{constructor(){super(...arguments),this.pushStreams=new Map,this.pushSpools=new Map}async destroy(){for(const e of this.pushStreams.values())e.destroy(new Error("sink destroyed"));this.pushStreams.clear();for(const e of this.pushSpools.values())await e.unroll();this.pushSpools.clear(),await super.destroy()}async sink(e,...r){let n,s,i={},c=this.options.share,l;typeof e=="object"&&e!==null?(n=e.name,s=e.callback,i=e.options??{},c=e.share??this.options.share,l=e.auth):(n=e,s=r[0]);const h=new De;if(this.onRequest.has(`sink-push-request:${n}`))throw new Error(`sink: sink "${n}" already registered`);const w=c!==""?`$share/${c}/${n}`:n,d=this.options.topicMake(w,"sink-push-request"),I=this.options.topicMake(n,"sink-push-request",this.options.id);return this.onRequest.set(`sink-push-request:${n}`,async(T,L)=>{const B=T.id,j=T.params??[],$=T.sender;if($===void 0||$==="")throw new Error("invalid request: missing sender");const S=T.receiver,x=this.options.topicMake(n,"sink-push-response",$),F=this.options.chunkCredit,_=async(k,U=!1)=>{const O=k===void 0&&U&&F>0?F:void 0,q=this.msg.makeSinkPushResponse(B,n,k,this.options.id,$,O),G=this.codec.encode(q);await this.publishToTopic(x,G,{qos:i.qos??2})},v=new De;this.pushSpools.set(B,v),v.roll(()=>{this.pushSpools.delete(B)});try{if(L!==T.name)throw new Error(`sink name mismatch (topic: "${L}", payload: "${T.name}")`);let k;if(l&&(k=await this.authenticated($,T.auth,l)),k!==void 0&&!k)throw new Error(`sink "${n}" failed authentication`);const U=F>0?{chunksReceived:0,creditGranted:F}:void 0,O=`sink-push-recv:${B}`,q=()=>this.timerRefresh(O,()=>{if(N)return;const ee=this.pushStreams.get(B);ee!==void 0&&ee.destroy(new Error("push stream timeout")),this.pushSpools.get(B)?.unroll()}),G=()=>this.timerClear(O),V=new ht.Readable({highWaterMark:F>0?F*this.options.chunkSize:16*1024,read:ee=>{if(!U||!this.pushSpools.has(B))return;const ue=Math.max(0,U.chunksReceived+F-U.creditGranted);if(ue>0){U.creditGranted+=ue;const we=this.msg.makeSinkPushCredit(B,n,ue,this.options.id,$),Ee=this.codec.encode(we);this.publishToTopic(x,Ee,{qos:i.qos??2}).catch(Ce=>{this.error(Ce,`sending credit for push "${n}" failed`)}),q()}}});this.pushStreams.set(B,V),v.roll(()=>{this.pushStreams.delete(B)}),V.once("error",()=>{});let N=!1;this.onResponse.set(`sink-push-chunk:${B}`,async ee=>{N||(ee.error!==void 0?(N=!0,G(),V.destroy(new Error(ee.error))):(q(),ee.chunk!==void 0&&(U&&U.chunksReceived++,V.push(ee.chunk)),ee.final&&(N=!0,G(),V.push(null))))}),v.roll(()=>{this.onResponse.delete(`sink-push-chunk:${B}`)}),q(),v.roll(()=>{G()});const X=Ai(V),fe=new Promise((ee,ue)=>{V.once("end",()=>{ee()}),V.once("error",we=>{ue(we)})});fe.catch(()=>{});const Q={sender:$,stream:V,buffer:X};S&&(Q.receiver=S),k!==void 0&&(Q.authenticated=k),T.meta&&(Q.meta=T.meta),Bi(Q,"stream","buffer"),await _(void 0,!0),await s(...j,Q),await fe;try{await _()}catch(ee){this.error(ke(ee),`sending terminal response for sink "${n}" failed`)}}catch(k){const U=ke(k,`handler for sink "${n}" failed`);this.error(U),await _(U.message).catch(()=>{})}finally{const k=this.pushStreams.get(B);k!==void 0&&!k.destroyed&&k.destroy(),await v.unroll()}}),h.roll(()=>{this.onRequest.delete(`sink-push-request:${n}`)}),await this.subscribeTopicAndSpool(h,d,i),await this.subscribeTopicAndSpool(h,I,i),this.makeRegistration(h,"sink",n,`sink-push-request:${n}`)}async push(e,...r){let n,s,i,c,l={},h;if(typeof e=="object"&&e!==null?(n=e.name,s=e.data,i=e.params,c=e.receiver,l=e.options??{},h=e.meta):(n=e,s=r[0],i=r.slice(1)),!(s instanceof ht.Readable)&&!(s instanceof Uint8Array))throw new Error("invalid data type: expected Readable or Uint8Array");const w=new De;let d=gt();for(;this.onResponse.has(`sink-push-response:${d}`)||this.onResponse.has(`sink-push-credit:${d}`);)d=gt();const I=this.options.topicMake(n,"sink-push-response",this.options.id);await this.subscribeTopicAndSpool(w,I,{qos:l.qos??2});const T=new AbortController,L=T.signal;if(s instanceof ht.Readable){const q=s;L.addEventListener("abort",()=>{q.destroyed||q.destroy(ke(L.reason))},{once:!0})}const B=`sink-push-send:${d}`,j=()=>this.timerRefresh(B,()=>{const q=new Error(`push to sink "${n}" timed out`);T.abort(q),w.unroll()});w.roll(()=>{this.timerClear(B)}),j();let $,S,x=!1,F=!1,_=!1,v=!1,k,U;const O=new Promise((q,G)=>{k=q,U=G});O.catch(()=>{});try{if(await new Promise((V,N)=>{const X=()=>{N(L.reason)};L.addEventListener("abort",X,{once:!0}),w.roll(()=>{L.removeEventListener("abort",X)}),this.onResponse.set(`sink-push-response:${d}`,Ee=>{Ee.error?N(new Error(Ee.error)):(Ee.sender&&(c=Ee.sender),$=Ee.credit,F=!0,V())}),w.roll(()=>{this.onResponse.delete(`sink-push-response:${d}`)});const fe=this.authenticate(),Q=this.metaStore(h),ee=this.msg.makeSinkPushRequest(d,n,i,this.options.id,c,fe,Q),ue=this.codec.encode(ee),we=this.options.topicMake(n,"sink-push-request",c);br(`publish push request as MQTT message to topic "${we}"`,w,()=>this.publishToTopic(we,ue,{qos:2,...l})).catch(Ee=>{N(Ee)})}),this.onResponse.set(`sink-push-response:${d}`,V=>{V.error?(x=!0,U(new Error(V.error)),T.abort(new Error(V.error))):F&&!_&&(_=!0,k())}),$!==void 0&&$>0&&(S=new Ti($)),S){const V=S;w.roll(()=>{V.abort()}),this.onResponse.set(`sink-push-credit:${d}`,N=>{V.replenish(N.credit),j()}),w.roll(()=>{this.onResponse.delete(`sink-push-credit:${d}`)})}const q=this.options.topicMake(n,"sink-push-request",c),G=async(V,N,X)=>{j();const fe=this.msg.makeSinkPushChunk(d,n,V,N,X,this.options.id,c),Q=this.codec.encode(fe);await this.publishToTopic(q,Q,{qos:2,...l}),N===void 0&&X&&(v=!0)};s instanceof ht.Readable?await Ii(s,this.options.chunkSize,G,S,L):s instanceof Uint8Array&&await Ri(s,this.options.chunkSize,G,S,L),_||await new Promise((V,N)=>{const X=()=>{N(L.reason)};L.addEventListener("abort",X,{once:!0}),O.then(V,N).finally(()=>{L.removeEventListener("abort",X)})})}catch(q){const G=ke(q);if(T.abort(G),F&&!x&&!v){const V=this.options.topicMake(n,"sink-push-request",c),N=this.msg.makeSinkPushChunk(d,n,void 0,G.message,!0,this.options.id,c),X=this.codec.encode(N);await this.publishToTopic(V,X,{qos:2,...l}).catch(()=>{})}throw q}finally{await w.unroll()}}}class Oc extends Dc{}return Oc}));
|