mqtt-plus 1.4.13 → 1.4.15
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/AGENTS.md +0 -1
- package/CHANGELOG.md +18 -0
- package/dst-stage1/mqtt-plus-api.js +1 -0
- package/dst-stage1/mqtt-plus-api.js.map +1 -0
- package/dst-stage1/mqtt-plus-auth.js +1 -0
- package/dst-stage1/mqtt-plus-auth.js.map +1 -0
- package/dst-stage1/mqtt-plus-base.js +1 -0
- package/dst-stage1/mqtt-plus-base.js.map +1 -0
- package/dst-stage1/mqtt-plus-codec.js +1 -0
- package/dst-stage1/mqtt-plus-codec.js.map +1 -0
- package/dst-stage1/mqtt-plus-encode.js +1 -0
- package/dst-stage1/mqtt-plus-encode.js.map +1 -0
- package/dst-stage1/mqtt-plus-error.js +1 -0
- package/dst-stage1/mqtt-plus-error.js.map +1 -0
- package/dst-stage1/mqtt-plus-event.js +1 -0
- package/dst-stage1/mqtt-plus-event.js.map +1 -0
- package/dst-stage1/mqtt-plus-info.js +1 -0
- package/dst-stage1/mqtt-plus-info.js.map +1 -0
- package/dst-stage1/mqtt-plus-meta.js +1 -0
- package/dst-stage1/mqtt-plus-meta.js.map +1 -0
- package/dst-stage1/mqtt-plus-msg.js +1 -0
- package/dst-stage1/mqtt-plus-msg.js.map +1 -0
- package/dst-stage1/mqtt-plus-options.js +1 -0
- package/dst-stage1/mqtt-plus-options.js.map +1 -0
- package/dst-stage1/mqtt-plus-service.js +1 -0
- package/dst-stage1/mqtt-plus-service.js.map +1 -0
- package/dst-stage1/mqtt-plus-sink.js +14 -2
- package/dst-stage1/mqtt-plus-sink.js.map +1 -0
- package/dst-stage1/mqtt-plus-source.js +27 -16
- package/dst-stage1/mqtt-plus-source.js.map +1 -0
- package/dst-stage1/mqtt-plus-subscription.js +1 -0
- package/dst-stage1/mqtt-plus-subscription.js.map +1 -0
- package/dst-stage1/mqtt-plus-timer.js +1 -0
- package/dst-stage1/mqtt-plus-timer.js.map +1 -0
- package/dst-stage1/mqtt-plus-trace.js +1 -0
- package/dst-stage1/mqtt-plus-trace.js.map +1 -0
- package/dst-stage1/mqtt-plus-util.js +1 -0
- package/dst-stage1/mqtt-plus-util.js.map +1 -0
- package/dst-stage1/mqtt-plus-version.d.ts +1 -1
- package/dst-stage1/mqtt-plus-version.js +3 -1
- package/dst-stage1/mqtt-plus-version.js.map +1 -0
- package/dst-stage1/mqtt-plus.js +1 -0
- package/dst-stage1/mqtt-plus.js.map +1 -0
- package/dst-stage2/mqtt-plus.cjs.js +1972 -2161
- package/dst-stage2/mqtt-plus.esm.js +1934 -2131
- package/dst-stage2/mqtt-plus.umd.js +13 -14
- package/etc/c8.json +16 -0
- package/etc/knip.jsonc +7 -1
- package/etc/stx.conf +36 -4
- package/etc/tsc.json +1 -1
- package/etc/vite.mts +11 -5
- package/package.d/vite+8.0.0.patch +12 -0
- package/package.json +12 -3
- package/src/mqtt-plus-sink.ts +14 -2
- package/src/mqtt-plus-source.ts +27 -16
- package/src/mqtt-plus-version.ts +2 -3
- package/tst/.c8/base.css +224 -0
- package/tst/.c8/block-navigation.js +87 -0
- package/tst/.c8/favicon.png +0 -0
- package/tst/.c8/index.html +371 -0
- package/tst/.c8/mqtt-plus-auth.ts.html +538 -0
- package/tst/.c8/mqtt-plus-base.ts.html +826 -0
- package/tst/.c8/mqtt-plus-codec.ts.html +457 -0
- package/tst/.c8/mqtt-plus-encode.ts.html +310 -0
- package/tst/.c8/mqtt-plus-error.ts.html +1186 -0
- package/tst/.c8/mqtt-plus-event.ts.html +733 -0
- package/tst/.c8/mqtt-plus-meta.ts.html +271 -0
- package/tst/.c8/mqtt-plus-msg.ts.html +1693 -0
- package/tst/.c8/mqtt-plus-options.ts.html +319 -0
- package/tst/.c8/mqtt-plus-service.ts.html +865 -0
- package/tst/.c8/mqtt-plus-sink.ts.html +1645 -0
- package/tst/.c8/mqtt-plus-source.ts.html +1585 -0
- package/tst/.c8/mqtt-plus-subscription.ts.html +706 -0
- package/tst/.c8/mqtt-plus-timer.ts.html +286 -0
- package/tst/.c8/mqtt-plus-trace.ts.html +463 -0
- package/tst/.c8/mqtt-plus-util.ts.html +823 -0
- package/tst/.c8/mqtt-plus-version.ts.html +205 -0
- package/tst/.c8/mqtt-plus.ts.html +193 -0
- package/tst/.c8/prettify.css +1 -0
- package/tst/.c8/prettify.js +2 -0
- package/tst/.c8/sort-arrow-sprite.png +0 -0
- package/tst/.c8/sorter.js +210 -0
- package/tst/.c8/tmp/coverage-6577-1773528098323-2.json +1 -0
- package/tst/.c8/tmp/coverage-6577-1773528098331-1.json +1 -0
- package/tst/.c8/tmp/coverage-6577-1773528098353-0.json +1 -0
- package/tst/.c8/tmp/coverage-6578-1773528089194-0.json +1 -0
- package/tst/mqtt-plus-2-event.spec.ts +29 -0
- package/tst/mqtt-plus-6-misc.spec.ts +79 -2
- package/tst/mqtt-plus-7-spool.spec.ts +101 -0
- package/tst/mqtt-plus-8-run.spec.ts +115 -0
- package/tst/{tsc.json → tsc.cov.json} +4 -3
- package/tst/tsc.std.json +31 -0
|
@@ -1,14 +1,13 @@
|
|
|
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
|
-
${
|
|
4
|
-
${
|
|
5
|
-
|
|
6
|
-
`,
|
|
7
|
-
|
|
8
|
-
`
|
|
9
|
-
`}}
|
|
10
|
-
|
|
11
|
-
`;
|
|
12
|
-
`;return
|
|
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}));
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.MQTTp=t())})(this,function(){var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),n=t(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.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},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){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 p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),r=t(((e,t)=>{typeof Object.create==`function`?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),i,a=e((()=>{i=globalThis||self}));function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function s(){throw Error(`setTimeout has not been defined`)}function c(){throw Error(`clearTimeout has not been defined`)}function l(e){if(_===setTimeout)return setTimeout(e,0);if((_===s||!_)&&setTimeout)return _=setTimeout,setTimeout(e,0);try{return _(e,0)}catch{try{return _.call(null,e,0)}catch{return _.call(this,e,0)}}}function u(e){if(v===clearTimeout)return clearTimeout(e);if((v===c||!v)&&clearTimeout)return v=clearTimeout,clearTimeout(e);try{return v(e)}catch{try{return v.call(null,e)}catch{return v.call(this,e)}}}function d(){!b||!x||(b=!1,x.length?y=x.concat(y):S=-1,y.length&&f())}function f(){if(!b){var e=l(d);b=!0;for(var t=y.length;t;){for(x=y,y=[];++S<t;)x&&x[S].run();S=-1,t=y.length}x=null,b=!1,u(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}var h,g,_,v,y,b,x,S,C,w,ee=e((()=>{h={exports:{}},g=h.exports={},(function(){try{_=typeof setTimeout==`function`?setTimeout:s}catch{_=s}try{v=typeof clearTimeout==`function`?clearTimeout:c}catch{v=c}})(),y=[],b=!1,S=-1,g.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];y.push(new p(e,t)),y.length===1&&!b&&l(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},g.title=`browser`,g.browser=!0,g.env={},g.argv=[],g.version=``,g.versions={},g.on=m,g.addListener=m,g.once=m,g.off=m,g.removeListener=m,g.removeAllListeners=m,g.emit=m,g.prependListener=m,g.prependOnceListener=m,g.listeners=function(e){return[]},g.binding=function(e){throw Error(`process.binding is not supported`)},g.cwd=function(){return`/`},g.chdir=function(e){throw Error(`process.chdir is not supported`)},g.umask=function(){return 0},C=h.exports,w=o(C)})),te=t(((e,t)=>{t.exports=n().EventEmitter})),ne=t((e=>{Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t={},n={};n.byteLength=u,n.toByteArray=f,n.fromByteArray=h;for(var r=[],i=[],a=typeof Uint8Array<`u`?Uint8Array:Array,o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,s=0,c=o.length;s<c;++s)r[s]=o[s],i[o.charCodeAt(s)]=s;i[45]=62,i[95]=63;function l(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function u(e){var t=l(e),n=t[0],r=t[1];return(n+r)*3/4-r}function d(e,t,n){return(t+n)*3/4-n}function f(e){var t,n=l(e),r=n[0],o=n[1],s=new a(d(e,r,o)),c=0,u=o>0?r-4:r,f;for(f=0;f<u;f+=4)t=i[e.charCodeAt(f)]<<18|i[e.charCodeAt(f+1)]<<12|i[e.charCodeAt(f+2)]<<6|i[e.charCodeAt(f+3)],s[c++]=t>>16&255,s[c++]=t>>8&255,s[c++]=t&255;return o===2&&(t=i[e.charCodeAt(f)]<<2|i[e.charCodeAt(f+1)]>>4,s[c++]=t&255),o===1&&(t=i[e.charCodeAt(f)]<<10|i[e.charCodeAt(f+1)]<<4|i[e.charCodeAt(f+2)]>>2,s[c++]=t>>8&255,s[c++]=t&255),s}function p(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[e&63]}function m(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(p(r));return i.join(``)}function h(e){for(var t,n=e.length,i=n%3,a=[],o=16383,s=0,c=n-i;s<c;s+=o)a.push(m(e,s,s+o>c?c:s+o));return i===1?(t=e[n-1],a.push(r[t>>2]+r[t<<4&63]+`==`)):i===2&&(t=(e[n-2]<<8)+e[n-1],a.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+`=`)),a.join(``)}var g={};g.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},g.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=n,r=g,i=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=d,e.SlowBuffer=C,e.INSPECT_MAX_BYTES=50;let a=2147483647;e.kMaxLength=a;let{Uint8Array:o,ArrayBuffer:s,SharedArrayBuffer:c}=globalThis;d.TYPED_ARRAY_SUPPORT=l(),!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 l(){try{let e=new o(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,o.prototype),Object.setPrototypeOf(e,t),e.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 u(e){if(e>a)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new o(e);return Object.setPrototypeOf(t,d.prototype),t}function d(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return h(e)}return f(e,t,n)}d.poolSize=8192;function f(e,t,n){if(typeof e==`string`)return _(e,t);if(s.isView(e))return y(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(z(e,s)||e&&z(e.buffer,s)||c!==void 0&&(z(e,c)||e&&z(e.buffer,c)))return b(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return d.from(r,t,n);let i=x(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return d.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}d.from=function(e,t,n){return f(e,t,n)},Object.setPrototypeOf(d.prototype,o.prototype),Object.setPrototypeOf(d,o);function p(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function m(e,t,n){return p(e),e<=0||t===void 0?u(e):typeof n==`string`?u(e).fill(t,n):u(e).fill(t)}d.alloc=function(e,t,n){return m(e,t,n)};function h(e){return p(e),u(e<0?0:S(e)|0)}d.allocUnsafe=function(e){return h(e)},d.allocUnsafeSlow=function(e){return h(e)};function _(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!d.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=w(e,t)|0,r=u(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function v(e){let t=e.length<0?0:S(e.length)|0,n=u(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function y(e){if(z(e,o)){let t=new o(e);return b(t.buffer,t.byteOffset,t.byteLength)}return v(e)}function b(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new o(e):n===void 0?new o(e,t):new o(e,t,n),Object.setPrototypeOf(r,d.prototype),r}function x(e){if(d.isBuffer(e)){let t=S(e.length)|0,n=u(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||we(e.length)?u(0):v(e);if(e.type===`Buffer`&&Array.isArray(e.data))return v(e.data)}function S(e){if(e>=a)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+a.toString(16)+` bytes`);return e|0}function C(e){return+e!=e&&(e=0),d.alloc(+e)}d.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==d.prototype},d.compare=function(e,t){if(z(e,o)&&(e=d.from(e,e.offset,e.byteLength)),z(t,o)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(e)||!d.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},d.isEncoding=function(e){switch(String(e).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(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return d.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=d.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(z(t,o))i+t.length>r.length?(d.isBuffer(t)||(t=d.from(t)),t.copy(r,i)):o.prototype.set.call(r,t,i);else if(d.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function w(e,t){if(d.isBuffer(e))return e.length;if(s.isView(e)||z(e,s))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return be(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Ce(e).length;default:if(i)return r?-1:be(e).length;t=(``+t).toLowerCase(),i=!0}}d.byteLength=w;function ee(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return E(this,t,n);case`utf8`:case`utf-8`:return ue(this,t,n);case`ascii`:return fe(this,t,n);case`latin1`:case`binary`:return pe(this,t,n);case`base64`:return le(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return D(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function te(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}d.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)te(this,t,t+1);return this},d.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)te(this,t,t+3),te(this,t+1,t+2);return this},d.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)te(this,t,t+7),te(this,t+1,t+6),te(this,t+2,t+5),te(this,t+3,t+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ue(this,0,e):ee.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(e){if(!d.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:d.compare(this,e)===0},d.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},i&&(d.prototype[i]=d.prototype.inspect),d.prototype.compare=function(e,t,n,r,i){if(z(e,o)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,s=n-t,c=Math.min(a,s),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],s=u[e];break}return a<s?-1:s<a?1:0};function ne(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:re(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof o.prototype.indexOf==`function`?i?o.prototype.indexOf.call(e,t,n):o.prototype.lastIndexOf.call(e,t,n):re(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function re(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}d.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},d.prototype.indexOf=function(e,t,n){return ne(this,e,t,n,!0)},d.prototype.lastIndexOf=function(e,t,n){return ne(this,e,t,n,!1)};function ie(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(we(r))return o;e[n+o]=r}return o}function ae(e,t,n,r){return R(be(t,e.length-n),e,n,r)}function oe(e,t,n,r){return R(xe(t),e,n,r)}function se(e,t,n,r){return R(Ce(t),e,n,r)}function ce(e,t,n,r){return R(Se(t,e.length-n),e,n,r)}d.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ie(this,e,t,n);case`utf8`:case`utf-8`:return ae(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return oe(this,e,t,n);case`base64`:return se(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ce(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},d.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function le(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ue(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return T(r)}let de=4096;function T(e){let t=e.length;if(t<=de)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=de));return n}function fe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function pe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function E(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=Te[e[r]];return i}function D(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}d.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,d.prototype),r};function O(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}d.prototype.readUintLE=d.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},d.prototype.readUintBE=d.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},d.prototype.readUint8=d.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=B(function(e){e>>>=0,L(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&_e(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),d.prototype.readBigUInt64BE=B(function(e){e>>>=0,L(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&_e(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),d.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},d.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},d.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},d.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},d.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=B(function(e){e>>>=0,L(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&_e(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),d.prototype.readBigInt64BE=B(function(e){e>>>=0,L(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&_e(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),d.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),r.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),r.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),r.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),r.read(this,e,!1,52,8)};function k(e,t,n,r,i,a){if(!d.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;k(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;k(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},d.prototype.writeUint8=d.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,1,255,0),this[t]=e&255,t+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function me(e,t,n,r,i){I(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function A(e,t,n,r,i){I(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}d.prototype.writeBigUInt64LE=B(function(e,t=0){return me(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=B(function(e,t=0){return A(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);k(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);k(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},d.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},d.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},d.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},d.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},d.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},d.prototype.writeBigInt64LE=B(function(e,t=0){return me(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=B(function(e,t=0){return A(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function he(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function j(e,t,n,i,a){return t=+t,n>>>=0,a||he(e,t,n,4),r.write(e,t,n,i,23,4),n+4}d.prototype.writeFloatLE=function(e,t,n){return j(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return j(this,e,t,!1,n)};function M(e,t,n,i,a){return t=+t,n>>>=0,a||he(e,t,n,8),r.write(e,t,n,i,52,8),n+8}d.prototype.writeDoubleLE=function(e,t,n){return M(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return M(this,e,t,!1,n)},d.prototype.copy=function(e,t,n,r){if(!d.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof o.prototype.copyWithin==`function`?this.copyWithin(t,n,r):o.prototype.set.call(e,this.subarray(n,r),t),i},d.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!d.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=d.isBuffer(e)?e:d.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let N={};function P(e,t,n){N[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}P(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),P(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),P(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=F(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=F(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function F(e){let t=``,n=e.length,r=e[0]===`-`?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function ge(e,t,n){L(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&_e(t,e.length-(n+1))}function I(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new N.ERR_OUT_OF_RANGE(`value`,i,e)}ge(r,i,a)}function L(e,t){if(typeof e!=`number`)throw new N.ERR_INVALID_ARG_TYPE(t,`number`,e)}function _e(e,t,n){throw Math.floor(e)===e?t<0?new N.ERR_BUFFER_OUT_OF_BOUNDS:new N.ERR_OUT_OF_RANGE(n||`offset`,`>= ${n?1:0} and <= ${t}`,e):(L(e,n),new N.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let ve=/[^+/0-9A-Za-z-_]/g;function ye(e){if(e=e.split(`=`)[0],e=e.trim().replace(ve,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function be(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function xe(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Se(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Ce(e){return t.toByteArray(ye(e))}function R(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function z(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function we(e){return e!==e}let Te=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function B(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})(t);var _=t.Buffer;e.Blob=t.Blob,e.BlobOptions=t.BlobOptions,e.Buffer=t.Buffer,e.File=t.File,e.FileOptions=t.FileOptions,e.INSPECT_MAX_BYTES=t.INSPECT_MAX_BYTES,e.SlowBuffer=t.SlowBuffer,e.TranscodeEncoding=t.TranscodeEncoding,e.atob=t.atob,e.btoa=t.btoa,e.constants=t.constants,e.default=_,e.isAscii=t.isAscii,e.isUtf8=t.isUtf8,e.kMaxLength=t.kMaxLength,e.kStringMaxLength=t.kStringMaxLength,e.resolveObjectURL=t.resolveObjectURL,e.transcode=t.transcode})),re=t(((e,t)=>{t.exports={}})),ie=t(((e,t)=>{function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t];t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,n){return t=c(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function c(e){var t=l(e,`string`);return typeof t==`symbol`?t:String(t)}function l(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var u=ne().Buffer,d=re().inspect,f=d&&d.custom||`inspect`;function p(e,t,n){u.prototype.copy.call(e,t,n)}t.exports=function(){function e(){a(this,e),this.head=null,this.tail=null,this.length=0}return s(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),n=this.head,r=0;n;)p(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=u.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:f,value:function(e,t){return d(this,r(r({},t),{},{depth:0,customInspect:!1}))}}]),e}()})),ae=t(((e,t)=>{ee();function n(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,w.nextTick(o,this,e)):w.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?w.nextTick(i,n):(n._writableState.errorEmitted=!0,w.nextTick(r,n,e)):w.nextTick(r,n,e):t?(w.nextTick(i,n),t(e)):w.nextTick(i,n)}),this)}function r(e,t){o(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function a(){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 o(e,t){e.emit(`error`,t)}function s(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:a,errorOrDestroy:s}})),oe=t(((e,t)=>{function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var r={};function i(e,t,i){i||=Error;function a(e,n,r){return typeof t==`string`?t:t(e,n,r)}var o=function(e){n(t,e);function t(t,n,r){return e.call(this,a(t,n,r))||this}return t}(i);o.prototype.name=i.name,o.prototype.code=e,r[e]=o}function a(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function o(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function s(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function c(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}i(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),i(`ERR_INVALID_ARG_TYPE`,function(e,t,n){var r;typeof t==`string`&&o(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;var i=s(e,` argument`)?`The ${e} ${r} ${a(t,`type`)}`:`The "${e}" ${c(e,`.`)?`property`:`argument`} ${r} ${a(t,`type`)}`;return i+=`. Received type ${typeof n}`,i},TypeError),i(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),i(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),i(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),i(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),i(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),i(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),i(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),i(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),i(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),i(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=r})),se=t(((e,t)=>{var n=oe().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16*1024}t.exports={getHighWaterMark:i}})),ce=t(((e,t)=>{a(),t.exports=n;function n(e,t){if(r(`noDeprecation`))return e;var n=!1;function i(){if(!n){if(r(`throwDeprecation`))throw Error(t);r(`traceDeprecation`)?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return i}function r(e){try{if(!i.localStorage)return!1}catch{return!1}var t=i.localStorage[e];return t==null?!1:String(t).toLowerCase()===`true`}})),le=t(((e,t)=>{a(),ee(),t.exports=T;function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){L(t,e)}}var o;T.WritableState=le;var s={deprecate:ce()},c=te(),l=ne().Buffer,u=(i===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:i).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=ae(),m=se().getHighWaterMark,h=oe().codes,g=h.ERR_INVALID_ARG_TYPE,_=h.ERR_METHOD_NOT_IMPLEMENTED,v=h.ERR_MULTIPLE_CALLBACK,y=h.ERR_STREAM_CANNOT_PIPE,b=h.ERR_STREAM_DESTROYED,x=h.ERR_STREAM_NULL_VALUES,S=h.ERR_STREAM_WRITE_AFTER_END,C=h.ERR_UNKNOWN_ENCODING,re=p.errorOrDestroy;r()(T,c);function ie(){}function le(e,t,r){o||=ue(),e||={},typeof r!=`boolean`&&(r=t instanceof o),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=m(this,e,`writableHighWaterMark`,r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1,this.decodeStrings=e.decodeStrings!==!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){A(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}le.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(le.prototype,`buffer`,{get:s.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var de;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(de=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return de.call(this,e)?!0:this===T?e&&e._writableState instanceof le:!1}})):de=function(e){return e instanceof this};function T(e){o||=ue();var t=this instanceof o;if(!t&&!de.call(T,this))return new T(e);this._writableState=new le(e,this,t),this.writable=!0,e&&(typeof e.write==`function`&&(this._write=e.write),typeof e.writev==`function`&&(this._writev=e.writev),typeof e.destroy==`function`&&(this._destroy=e.destroy),typeof e.final==`function`&&(this._final=e.final)),c.call(this)}T.prototype.pipe=function(){re(this,new y)};function fe(e,t){var n=new S;re(e,n),w.nextTick(t,n)}function pe(e,t,n,r){var i;return n===null?i=new x:typeof n!=`string`&&!t.objectMode&&(i=new g(`chunk`,[`string`,`Buffer`],n)),i?(re(e,i),w.nextTick(r,i),!1):!0}T.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&f(e);return a&&!l.isBuffer(e)&&(e=d(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=ie),r.ending?fe(this,n):(a||pe(this,r,e,n))&&(r.pendingcb++,i=D(this,r,a,e,t,n)),i},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&M(this,e))},T.prototype.setDefaultEncoding=function(e){if(typeof e==`string`&&(e=e.toLowerCase()),!([`hex`,`utf8`,`utf-8`,`ascii`,`binary`,`base64`,`ucs2`,`ucs-2`,`utf16le`,`utf-16le`,`raw`].indexOf((e+``).toLowerCase())>-1))throw new C(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function E(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(T.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function D(e,t,n,r,i,a){if(!n){var o=E(t,r,i);r!==o&&(n=!0,i=`buffer`,r=o)}var s=t.objectMode?1:r.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else O(e,t,!1,s,r,i,a);return c}function O(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new b(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function k(e,t,n,r,i){--t.pendingcb,n?(w.nextTick(i,r),w.nextTick(ge,e,t),e._writableState.errorEmitted=!0,re(e,r)):(i(r),e._writableState.errorEmitted=!0,re(e,r),ge(e,t))}function me(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function A(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new v;if(me(n),t)k(e,n,r,t,i);else{var a=N(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&M(e,n),r?w.nextTick(he,e,n,a,i):he(e,n,a,i)}}function he(e,t,n,r){n||j(e,t),t.pendingcb--,r(),ge(e,t)}function j(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function M(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,a=Array(i),o=t.corkedRequestsFree;o.entry=r;for(var s=0,c=!0;r;)a[s]=r,r.isBuf||(c=!1),r=r.next,s+=1;a.allBuffers=c,O(e,t,!0,t.length,a,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new n(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,u=r.encoding,d=r.callback;if(O(e,t,!1,t.objectMode?1:l.length,l,u,d),r=r.next,t.bufferedRequestCount--,t.writing)break}r===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}T.prototype._write=function(e,t,n){n(new _(`_write()`))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return typeof e==`function`?(n=e,e=null,t=null):typeof t==`function`&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||I(this,r,n),this},Object.defineProperty(T.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function N(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function P(e,t){e._final(function(n){t.pendingcb--,n&&re(e,n),t.prefinished=!0,e.emit(`prefinish`),ge(e,t)})}function F(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,w.nextTick(P,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function ge(e,t){var n=N(t);if(n&&(F(e,t),t.pendingcb===0&&(t.finished=!0,e.emit(`finish`),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function I(e,t,n){t.ending=!0,ge(e,t),n&&(t.finished?w.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function L(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}Object.defineProperty(T.prototype,`destroyed`,{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=p.destroy,T.prototype._undestroy=p.undestroy,T.prototype._destroy=function(e,t){t(e)}})),ue=t(((e,t)=>{ee();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var i=D(),a=le();r()(l,i);for(var o=n(a.prototype),s=0;s<o.length;s++){var c=o[s];l.prototype[c]||(l.prototype[c]=a.prototype[c])}function l(e){if(!(this instanceof l))return new l(e);i.call(this,e),a.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once(`end`,u)))}Object.defineProperty(l.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function u(){this._writableState.ended||w.nextTick(d,this)}function d(e){e.end()}Object.defineProperty(l.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})})),de=t(((e,t)=>{var n=ne(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),T=t((e=>{var t=de().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.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(e){if(!e)return`utf8`;for(var t;;)switch(e){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 e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}e.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),fe=t(((e,t)=>{var n=oe().codes.ERR_STREAM_PREMATURE_CLOSE;function r(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}function i(){}function a(e){return e.setHeader&&typeof e.abort==`function`}function o(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=r(s||i);var c=t.readable||t.readable!==!1&&e.readable,l=t.writable||t.writable!==!1&&e.writable,u=function(){e.writable||f()},d=e._writableState&&e._writableState.finished,f=function(){l=!1,d=!0,c||s.call(e)},p=e._readableState&&e._readableState.endEmitted,m=function(){c=!1,p=!0,l||s.call(e)},h=function(t){s.call(e,t)},g=function(){var t;if(c&&!p)return(!e._readableState||!e._readableState.ended)&&(t=new n),s.call(e,t);if(l&&!d)return(!e._writableState||!e._writableState.ended)&&(t=new n),s.call(e,t)},_=function(){e.req.on(`finish`,f)};return a(e)?(e.on(`complete`,f),e.on(`abort`,g),e.req?_():e.on(`request`,_)):l&&!e._writableState&&(e.on(`end`,u),e.on(`close`,u)),e.on(`end`,m),e.on(`finish`,f),t.error!==!1&&e.on(`error`,h),e.on(`close`,g),function(){e.removeListener(`complete`,f),e.removeListener(`abort`,g),e.removeListener(`request`,_),e.req&&e.req.removeListener(`finish`,f),e.removeListener(`end`,u),e.removeListener(`close`,u),e.removeListener(`finish`,f),e.removeListener(`end`,m),e.removeListener(`error`,h),e.removeListener(`close`,g)}}t.exports=o})),pe=t(((e,t)=>{ee();var n;function r(e,t,n){return t=i(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){var t=a(e,`string`);return typeof t==`symbol`?t:String(t)}function a(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var o=fe(),s=Symbol(`lastResolve`),c=Symbol(`lastReject`),l=Symbol(`error`),u=Symbol(`ended`),d=Symbol(`lastPromise`),f=Symbol(`handlePromise`),p=Symbol(`stream`);function m(e,t){return{value:e,done:t}}function h(e){var t=e[s];if(t!==null){var n=e[p].read();n!==null&&(e[d]=null,e[s]=null,e[c]=null,t(m(n,!1)))}}function g(e){w.nextTick(h,e)}function _(e,t){return function(n,r){e.then(function(){if(t[u]){n(m(void 0,!0));return}t[f](n,r)},r)}}var v=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((n={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(t!==null)return Promise.reject(t);if(this[u])return Promise.resolve(m(void 0,!0));if(this[p].destroyed)return new Promise(function(t,n){w.nextTick(function(){e[l]?n(e[l]):t(m(void 0,!0))})});var n=this[d],r;if(n)r=new Promise(_(n,this));else{var i=this[p].read();if(i!==null)return Promise.resolve(m(i,!1));r=new Promise(this[f])}return this[d]=r,r}},r(n,Symbol.asyncIterator,function(){return this}),r(n,`return`,function(){var e=this;return new Promise(function(t,n){e[p].destroy(null,function(e){if(e){n(e);return}t(m(void 0,!0))})})}),n),v);t.exports=function(e){var t,n=Object.create(y,(t={},r(t,p,{value:e,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,c,{value:null,writable:!0}),r(t,l,{value:null,writable:!0}),r(t,u,{value:e._readableState.endEmitted,writable:!0}),r(t,f,{value:function(e,t){var r=n[p].read();r?(n[d]=null,n[s]=null,n[c]=null,e(m(r,!1))):(n[s]=e,n[c]=t)},writable:!0}),t));return n[d]=null,o(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[c];t!==null&&(n[d]=null,n[s]=null,n[c]=null,t(e)),n[l]=e;return}var r=n[s];r!==null&&(n[d]=null,n[s]=null,n[c]=null,r(m(void 0,!0))),n[u]=!0}),e.on(`readable`,g.bind(null,n)),n}})),E=t(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),D=t(((e,t)=>{a(),ee(),t.exports=k;var o;k.ReadableState=O,n().EventEmitter;var s=function(e,t){return e.listeners(t).length},c=te(),l=ne().Buffer,u=(i===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:i).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=re(),m=p&&p.debuglog?p.debuglog(`stream`):function(){},h=ie(),g=ae(),_=se().getHighWaterMark,v=oe().codes,y=v.ERR_INVALID_ARG_TYPE,b=v.ERR_STREAM_PUSH_AFTER_EOF,x=v.ERR_METHOD_NOT_IMPLEMENTED,S=v.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,C,ce,le;r()(k,c);var de=g.errorOrDestroy,fe=[`error`,`close`,`destroy`,`pause`,`resume`];function D(e,t,n){if(typeof e.prependListener==`function`)return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function O(e,t,n){o||=ue(),e||={},typeof n!=`boolean`&&(n=t instanceof o),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=_(this,e,`readableHighWaterMark`,n),this.buffer=new h,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=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(C||=T().StringDecoder,this.decoder=new C(e.encoding),this.encoding=e.encoding)}function k(e){if(o||=ue(),!(this instanceof k))return new k(e);var t=this instanceof o;this._readableState=new O(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),c.call(this)}Object.defineProperty(k.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),k.prototype.destroy=g.destroy,k.prototype._undestroy=g.undestroy,k.prototype._destroy=function(e,t){t(e)},k.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:typeof e==`string`&&(t||=n.defaultEncoding,t!==n.encoding&&(e=l.from(e,t),t=``),r=!0),me(this,e,t,!1,r)},k.prototype.unshift=function(e){return me(this,e,null,!0,!1)};function me(e,t,n,r,i){m(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,P(e,a);else{var o;if(i||(o=he(a,t)),o)de(e,o);else if(a.objectMode||t&&t.length>0)if(typeof t!=`string`&&!a.objectMode&&Object.getPrototypeOf(t)!==l.prototype&&(t=d(t)),r)a.endEmitted?de(e,new S):A(e,a,t,!0);else if(a.ended)de(e,new b);else if(a.destroyed)return!1;else a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||t.length!==0?A(e,a,t,!1):I(e,a)):A(e,a,t,!1);else r||(a.reading=!1,I(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function A(e,t,n,r){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit(`data`,n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&F(e)),I(e,t)}function he(e,t){var n;return!f(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new y(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}k.prototype.isPaused=function(){return this._readableState.flowing===!1},k.prototype.setEncoding=function(e){C||=T().StringDecoder;var t=new C(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r=``;n!==null;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),r!==``&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var j=1073741824;function M(e){return e>=j?e=j:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function N(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=M(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}k.prototype.read=function(e){m(`read`,e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark===0?t.length>0:t.length>=t.highWaterMark)||t.ended))return m(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?R(this):F(this),null;if(e=N(e,t),e===0&&t.ended)return t.length===0&&R(this),null;var r=t.needReadable;m(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,m(`length less than watermark`,r)),t.ended||t.reading?(r=!1,m(`reading or ended`,r)):r&&(m(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=N(n,t)));var i=e>0?Ce(e,t):null;return i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&R(this)),i!==null&&this.emit(`data`,i),i};function P(e,t){if(m(`onEofChunk`),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?F(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,ge(e)))}}function F(e){var t=e._readableState;m(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(m(`emitReadable`,t.flowing),t.emittedReadable=!0,w.nextTick(ge,e))}function ge(e){var t=e._readableState;m(`emitReadable_`,t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit(`readable`),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Se(e)}function I(e,t){t.readingMore||(t.readingMore=!0,w.nextTick(L,e,t))}function L(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(m(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}k.prototype._read=function(e){de(this,new x(`_read()`))},k.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e);break}r.pipesCount+=1,m(`pipe count=%d opts=%j`,r.pipesCount,t);var i=(!t||t.end!==!1)&&e!==w.stdout&&e!==w.stderr?o:g;r.endEmitted?w.nextTick(i):n.once(`end`,i),e.on(`unpipe`,a);function a(e,t){m(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,u())}function o(){m(`onend`),e.end()}var c=_e(n);e.on(`drain`,c);var l=!1;function u(){m(`cleanup`),e.removeListener(`close`,p),e.removeListener(`finish`,h),e.removeListener(`drain`,c),e.removeListener(`error`,f),e.removeListener(`unpipe`,a),n.removeListener(`end`,o),n.removeListener(`end`,g),n.removeListener(`data`,d),l=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}n.on(`data`,d);function d(t){m(`ondata`);var i=e.write(t);m(`dest.write`,i),i===!1&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&we(r.pipes,e)!==-1)&&!l&&(m(`false write response, pause`,r.awaitDrain),r.awaitDrain++),n.pause())}function f(t){m(`onerror`,t),g(),e.removeListener(`error`,f),s(e,`error`)===0&&de(e,t)}D(e,`error`,f);function p(){e.removeListener(`finish`,h),g()}e.once(`close`,p);function h(){m(`onfinish`),e.removeListener(`close`,p),g()}e.once(`finish`,h);function g(){m(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),r.flowing||(m(`pipe resume`),n.resume()),e};function _e(e){return function(){var t=e._readableState;m(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&s(e,`data`)&&(t.flowing=!0,Se(e))}}k.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||=t.pipes,t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit(`unpipe`,this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)r[a].emit(`unpipe`,this,{hasUnpiped:!1});return this}var o=we(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n),this)},k.prototype.on=function(e,t){var n=c.prototype.on.call(this,e,t),r=this._readableState;return e===`data`?(r.readableListening=this.listenerCount(`readable`)>0,r.flowing!==!1&&this.resume()):e===`readable`&&!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,m(`on readable`,r.length,r.reading),r.length?F(this):r.reading||w.nextTick(ye,this)),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(e,t){var n=c.prototype.removeListener.call(this,e,t);return e===`readable`&&w.nextTick(ve,this),n},k.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&w.nextTick(ve,this),t};function ve(e){var t=e._readableState;t.readableListening=e.listenerCount(`readable`)>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(`data`)>0&&e.resume()}function ye(e){m(`readable nexttick read 0`),e.read(0)}k.prototype.resume=function(){var e=this._readableState;return e.flowing||(m(`resume`),e.flowing=!e.readableListening,be(this,e)),e.paused=!1,this};function be(e,t){t.resumeScheduled||(t.resumeScheduled=!0,w.nextTick(xe,e,t))}function xe(e,t){m(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),Se(e),t.flowing&&!t.reading&&e.read(0)}k.prototype.pause=function(){return m(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(m(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function Se(e){var t=e._readableState;for(m(`flow`,t.flowing);t.flowing&&e.read()!==null;);}k.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(m(`wrapped end`),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on(`data`,function(i){m(`wrapped data`),n.decoder&&(i=n.decoder.write(i)),!(n.objectMode&&i==null)&&(!n.objectMode&&(!i||!i.length)||t.push(i)||(r=!0,e.pause()))}),e)this[i]===void 0&&typeof e[i]==`function`&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<fe.length;a++)e.on(fe[a],this.emit.bind(this,fe[a]));return this._read=function(t){m(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(k.prototype[Symbol.asyncIterator]=function(){return ce===void 0&&(ce=pe()),ce(this)}),Object.defineProperty(k.prototype,`readableHighWaterMark`,{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,`readableBuffer`,{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,`readableFlowing`,{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),k._fromList=Ce,Object.defineProperty(k.prototype,`readableLength`,{enumerable:!1,get:function(){return this._readableState.length}});function Ce(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(``):t.buffer.length===1?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function R(e){var t=e._readableState;m(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,w.nextTick(z,t,e))}function z(e,t){if(m(`endReadableNT`,e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit(`end`),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}typeof Symbol==`function`&&(k.from=function(e,t){return le===void 0&&(le=E()),le(k,e,t)});function we(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),O=t(((e,t)=>{t.exports=u;var n=oe().codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,a=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,c=ue();r()(u,c);function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit(`error`,new a);n.writechunk=null,n.writecb=null,t!=null&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform==`function`&&(this._transform=e.transform),typeof e.flush==`function`&&(this._flush=e.flush)),this.on(`prefinish`,d)}function d(){var e=this;typeof this._flush==`function`&&!this._readableState.destroyed?this._flush(function(t,n){f(e,t,n)}):f(this,null,null)}u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new i(`_transform()`))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,function(e){t(e)})};function f(e,t,n){if(t)return e.emit(`error`,t);if(n!=null&&e.push(n),e._writableState.length)throw new s;if(e._transformState.transforming)throw new o;return e.push(null)}})),k=t(((e,t)=>{t.exports=i;var n=O();r()(i,n);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e)}i.prototype._transform=function(e,t,n){n(null,e)}})),me=t(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=oe().codes,a=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function c(e){return e.setHeader&&typeof e.abort==`function`}function l(e,t,i,a){a=r(a);var s=!1;e.on(`close`,function(){s=!0}),n===void 0&&(n=fe()),n(e,{readable:t,writable:i},function(e){if(e)return a(e);s=!0,a()});var l=!1;return function(t){if(!s&&!l){if(l=!0,c(e))return e.abort();if(typeof e.destroy==`function`)return e.destroy();a(t||new o(`pipe`))}}}function u(e){e()}function d(e,t){return e.pipe(t)}function f(e){return!e.length||typeof e[e.length-1]!=`function`?s:e.pop()}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new a(`streams`);var i,o=t.map(function(e,n){var a=n<t.length-1;return l(e,a,n>0,function(e){i||=e,e&&o.forEach(u),!a&&(o.forEach(u),r(i))})});return t.reduce(d)}t.exports=p})),A=t(((e,t)=>{t.exports=a;var i=n().EventEmitter;r()(a,i),a.Readable=D(),a.Writable=le(),a.Duplex=ue(),a.Transform=O(),a.PassThrough=k(),a.finished=fe(),a.pipeline=me(),a.Stream=a;function a(){i.call(this)}a.prototype.pipe=function(e,t){var n=this;function r(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}n.on(`data`,r);function a(){n.readable&&n.resume&&n.resume()}e.on(`drain`,a),!e._isStdio&&(!t||t.end!==!1)&&(n.on(`end`,s),n.on(`close`,c));var o=!1;function s(){o||(o=!0,e.end())}function c(){o||(o=!0,typeof e.destroy==`function`&&e.destroy())}function l(e){if(u(),i.listenerCount(this,`error`)===0)throw e}n.on(`error`,l),e.on(`error`,l);function u(){n.removeListener(`data`,r),e.removeListener(`drain`,a),n.removeListener(`end`,s),n.removeListener(`close`,c),n.removeListener(`error`,l),e.removeListener(`error`,l),n.removeListener(`end`,u),n.removeListener(`close`,u),e.removeListener(`close`,u)}return n.on(`end`,u),n.on(`close`,u),e.on(`close`,u),e.emit(`pipe`,n),e}}))(),he=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,j=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=he[n[e]&63];return t},M={},N={};N.byteLength=ye,N.toByteArray=xe,N.fromByteArray=R;for(var P=[],F=[],ge=typeof Uint8Array<`u`?Uint8Array:Array,I=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,L=0,_e=I.length;L<_e;++L)P[L]=I[L],F[I.charCodeAt(L)]=L;F[45]=62,F[95]=63;function ve(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function ye(e){var t=ve(e),n=t[0],r=t[1];return(n+r)*3/4-r}function be(e,t,n){return(t+n)*3/4-n}function xe(e){var t,n=ve(e),r=n[0],i=n[1],a=new ge(be(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=F[e.charCodeAt(c)]<<18|F[e.charCodeAt(c+1)]<<12|F[e.charCodeAt(c+2)]<<6|F[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=F[e.charCodeAt(c)]<<2|F[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=F[e.charCodeAt(c)]<<10|F[e.charCodeAt(c+1)]<<4|F[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function Se(e){return P[e>>18&63]+P[e>>12&63]+P[e>>6&63]+P[e&63]}function Ce(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Se(r));return i.join(``)}function R(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Ce(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(P[t>>2]+P[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(P[t>>10]+P[t>>4&63]+P[t<<2&63]+`=`)),i.join(``)}var z={};z.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},z.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=N,n=z,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=x,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.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 c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,`parent`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,`offset`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(R(e,o)||e&&R(e.buffer,o)||s!==void 0&&(R(e,s)||e&&R(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=S(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(R(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||we(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function x(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(R(e,a)&&(e=u.from(e,e.offset,e.byteLength)),R(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(e){switch(String(e).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}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(R(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function S(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||R(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return ye(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Se(e).length;default:if(i)return r?-1:ye(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=S;function C(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return fe(this,t,n);case`utf8`:case`utf-8`:return ce(this,t,n);case`ascii`:return de(this,t,n);case`latin1`:case`binary`:return T(this,t,n);case`base64`:return se(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return pe(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function w(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)w(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ce(this,0,e):C.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(R(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:s<o?1:0};function ee(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,we(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:te(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):te(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function te(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return ee(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return ee(this,e,t,n,!1)};function ne(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(we(r))return o;e[n+o]=r}return o}function re(e,t,n,r){return Ce(ye(t,e.length-n),e,n,r)}function ie(e,t,n,r){return Ce(be(t),e,n,r)}function ae(e,t,n,r){return Ce(Se(t),e,n,r)}function oe(e,t,n,r){return Ce(xe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ne(this,e,t,n);case`utf8`:case`utf-8`:return re(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return ie(this,e,t,n);case`base64`:return ae(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return oe(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function se(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ce(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return ue(r)}let le=4096;function ue(e){let t=e.length;if(t<=le)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=le));return n}function de(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function T(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function fe(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=Te[e[r]];return i}function pe(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function E(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||E(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||E(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||E(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||E(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||E(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||E(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||E(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=B(function(e){e>>>=0,I(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&L(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=B(function(e){e>>>=0,I(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&L(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||E(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||E(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||E(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||E(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||E(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||E(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||E(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=B(function(e){e>>>=0,I(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&L(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=B(function(e){e>>>=0,I(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&L(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||E(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||E(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||E(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||E(e,8,this.length),n.read(this,e,!1,52,8)};function D(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;D(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;D(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function O(e,t,n,r,i){ge(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function k(e,t,n,r,i){ge(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=B(function(e,t=0){return O(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=B(function(e,t=0){return k(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);D(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);D(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=B(function(e,t=0){return O(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=B(function(e,t=0){return k(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function me(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function A(e,t,r,i,a){return t=+t,r>>>=0,a||me(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return A(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return A(this,e,t,!1,n)};function he(e,t,r,i,a){return t=+t,r>>>=0,a||me(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return he(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return he(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let j={};function M(e,t,n){j[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}M(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),M(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),M(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=P(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=P(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function P(e){let t=``,n=e.length,r=e[0]===`-`?1:0;for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function F(e,t,n){I(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&L(t,e.length-(n+1))}function ge(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE(`value`,i,e)}F(r,i,a)}function I(e,t){if(typeof e!=`number`)throw new j.ERR_INVALID_ARG_TYPE(t,`number`,e)}function L(e,t,n){throw Math.floor(e)===e?t<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(n||`offset`,`>= ${n?1:0} and <= ${t}`,e):(I(e,n),new j.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let _e=/[^+/0-9A-Za-z-_]/g;function ve(e){if(e=e.split(`=`)[0],e=e.trim().replace(_e,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function ye(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function be(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function xe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Se(e){return t.toByteArray(ve(e))}function Ce(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function R(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function we(e){return e!==e}let Te=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function B(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})(M);var we=M.Buffer;M.Blob,M.BlobOptions;var Te=M.Buffer;M.File,M.FileOptions,M.INSPECT_MAX_BYTES,M.SlowBuffer,M.TranscodeEncoding,M.atob,M.btoa,M.constants,M.isAscii,M.isUtf8,M.kMaxLength,M.kStringMaxLength,M.resolveObjectURL,M.transcode;var B=class e extends Promise{#e;#t;constructor(e){super(e=>{e()}),this.#e=e}static from(t){return new e(e=>{e(t())})}static resolve(t){return new e(e=>{e(t)})}static reject(t){return new e((e,n)=>{n(t)})}then(e,t){return this.#t??=new Promise(this.#e),this.#t.then(e,t)}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)}},Ee=B.default??B,De=class{constructor(e){this.waiters=[],this.aborted=!1,this.remaining=e}async acquire(e){if(this.aborted)throw Error(`credit gate aborted`);if(e?.aborted)throw e.reason??Error(`aborted`);this.remaining>0?this.remaining--:await new Promise((t,n)=>{let r=()=>{let t=this.waiters.indexOf(i);t!==-1&&this.waiters.splice(t,1),n(e?.reason??Error(`aborted`))};e&&e.addEventListener(`abort`,r,{once:!0});let i=i=>{if(e&&e.removeEventListener(`abort`,r),i){n(Error(`credit gate aborted`));return}this.remaining--,t()};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)}},Oe=new TextEncoder;function ke(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function Ae(e){let t;if(e instanceof Te)t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=Oe.encode(e);else throw Error(`invalid chunk type: expected Buffer, Uint8Array, or string`);return t}function je(e){return new Ee((t,n)=>{let r=[];e.on(`data`,e=>{let t=Ae(e);r.push(t)}),e.on(`end`,()=>{t(ke(r))}),e.on(`error`,e=>{n(e)})})}async function Me(e,t,n,r,i){if(e.byteLength===0)await n(void 0,void 0,!0);else for(let a=0;a<e.byteLength;a+=t){if(i?.aborted)throw i.reason??Error(`aborted`);let o=Math.min(e.byteLength-a,t),s=e.subarray(a,a+o),c=a+o>=e.byteLength;r&&await r.acquire(i),await n(s,void 0,c)}}async function Ne(e,t,n,r,i){let a;for await(let o of e){if(i?.aborted)throw i.reason??Error(`aborted`);let e=Ae(o);if(e.byteLength!==0)for(let o=0;o<e.byteLength;o+=t){if(i?.aborted)throw i.reason??Error(`aborted`);let s=Math.min(e.byteLength-o,t),c=e.subarray(o,o+s);a!==void 0&&(r&&await r.acquire(i),await n(a,void 0,!1)),a=c}}if(i?.aborted)throw i.reason??Error(`aborted`);a===void 0?await n(void 0,void 0,!0):(r&&await r.acquire(i),await n(a,void 0,!0))}function Pe(e,t,n){if(!(typeof e==`object`&&e))throw Error(`invalid object`);let r,i=e[t],a=e[n];Object.defineProperty(e,t,{get:()=>{if(r===`f2`)throw Error(`field "${t}" is mutually exclusive with field "${n}" and "${n}" was already consumed`);return r=`f1`,i},enumerable:!0,configurable:!0}),Object.defineProperty(e,n,{get:()=>{if(r===`f1`)throw Error(`field "${n}" is mutually exclusive with field "${t}" and "${t}" was already consumed`);return r=`f2`,a},enumerable:!0,configurable:!0})}var Fe=class e{constructor(){this.resources=[]}roll(...e){let t,n;if(e.length===1)t=void 0,n=e[0];else if(e.length===2)t=e[0],n=e[1];else throw Error(`invalid number of arguments`);this.resources.push({resource:t,cleanup:n})}sub(){let t=new e;return this.roll(t,()=>{}),t}unroll(t=!0){try{let n;for(;this.resources.length>0;){let t=this.resources.pop(),r=t.resource,i=t.cleanup;if(n)n=r instanceof e?n.then(()=>r.unroll()):n.then(()=>i(r));else{let t;t=r instanceof e?r.unroll():i(r),t instanceof Promise&&(n=t)}}return n?t?n.catch(()=>{}):n:void 0}catch(e){if(t)return;throw e}}};function V(e,t,n=!1){if(e instanceof Error&&t===void 0&&n===!1)return e;let r=e instanceof Error?e.message:String(e);if(t&&(r=`${t}: ${r}`),n&&e instanceof Error&&(r=`${r}\n${e.stack}`),e instanceof Error){let t=Error(r,{cause:e});return t.stack=e.stack,t}else return Error(r)}function Ie(e,t){if(!t)return e?Promise.resolve():void 0;let n;try{n=t()}catch(t){if(e)return Promise.reject(t);throw t}if(!e&&n instanceof Promise)throw Error(`onfinally callback returned Promise in non-async context`);return e&&!(n instanceof Promise)&&(n=Promise.resolve(n)),n}function Le(e,t){if(!t)return e?Promise.resolve():void 0;let n=t.unroll();if(!e&&n instanceof Promise)throw Error(`spool unroll returned Promise in non-async context`);return e&&!(n instanceof Promise)&&(n=Promise.resolve(n)),n}function Re(...e){let t,n,r,i,a,o;if(e.length===1&&typeof e[0]==`object`&&e[0]!==null?(t=e[0].description,n=e[0].spool,r=e[0].action,i=e[0].oncatch,a=e[0].onfinally,o=e[0].oncleanup):typeof e[0]==`string`?(t=e[0],e[1]instanceof Fe||e[1]===void 0&&typeof e[2]==`function`?(n=e[1],r=e[2],i=e[3],a=e[4],o=e[5]):(r=e[1],i=e[2],a=e[3],o=e[4])):e[0]instanceof Fe||e[0]===void 0&&typeof e[1]==`function`?(n=e[0],r=e[1],i=e[2],a=e[3],o=e[4]):(r=e[0],i=e[1],a=e[2],o=e[3]),o&&!n)throw Error(`oncleanup requires a spool`);let s;try{s=r()}catch(e){let r=V(e,t);if(i){try{s=i(r)}catch(e){throw r=V(e,t),Ie(!1,a),Le(!1,n),r}return Ie(!1,a),s}throw Ie(!1,a),Le(!1,n),r}return s instanceof Promise?s.then(async e=>(await Ie(!0,a),n&&o&&n.roll(e,o),e),async e=>{let r=V(e,t);if(i)try{let e=i(r);return await Ie(!0,a),e}catch(e){throw r=V(e,t),await Ie(!0,a),await Le(!0,n),r}throw await Ie(!0,a),await Le(!0,n),r}):(Ie(!1,a),n&&o&&n.roll(s,o),s)}var ze=new TextEncoder,Be=new TextDecoder;function Ve(...e){let t=e.reduce((e,{length:t})=>e+t,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function He(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>127)throw TypeError(`non-ASCII string encountered in encode()`);t[n]=r}return t}function Ue(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function We(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Ge(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Be.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Be.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return We(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function Ke(e){let t=e;return typeof t==`string`&&(t=ze.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):Ue(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var qe=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},Je=class extends qe{static code=`ERR_JWT_CLAIM_VALIDATION_FAILED`;code=`ERR_JWT_CLAIM_VALIDATION_FAILED`;claim;reason;payload;constructor(e,t,n=`unspecified`,r=`unspecified`){super(e,{cause:{claim:n,reason:r,payload:t}}),this.claim=n,this.reason=r,this.payload=t}},Ye=class extends qe{static code=`ERR_JWT_EXPIRED`;code=`ERR_JWT_EXPIRED`;claim;reason;payload;constructor(e,t,n=`unspecified`,r=`unspecified`){super(e,{cause:{claim:n,reason:r,payload:t}}),this.claim=n,this.reason=r,this.payload=t}},Xe=class extends qe{static code=`ERR_JOSE_ALG_NOT_ALLOWED`;code=`ERR_JOSE_ALG_NOT_ALLOWED`},Ze=class extends qe{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},H=class extends qe{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},Qe=class extends qe{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`};Symbol.asyncIterator;var $e=class extends qe{static code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;constructor(e=`signature verification failed`,t){super(e,t)}},et=(e,t=`algorithm.name`)=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),tt=(e,t)=>e.name===t;function nt(e){return parseInt(e.name.slice(4),10)}function rt(e,t){if(nt(e.hash)!==t)throw et(`SHA-${t}`,`algorithm.hash`)}function it(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}function at(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function ot(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!tt(e.algorithm,`HMAC`))throw et(`HMAC`);rt(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!tt(e.algorithm,`RSASSA-PKCS1-v1_5`))throw et(`RSASSA-PKCS1-v1_5`);rt(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!tt(e.algorithm,`RSA-PSS`))throw et(`RSA-PSS`);rt(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!tt(e.algorithm,`Ed25519`))throw et(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!tt(e.algorithm,t))throw et(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!tt(e.algorithm,`ECDSA`))throw et(`ECDSA`);let n=it(t);if(e.algorithm.namedCurve!==n)throw et(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}at(e,n)}function st(e,t,...n){if(n=n.filter(Boolean),n.length>2){let t=n.pop();e+=`one of type ${n.join(`, `)}, or ${t}.`}else n.length===2?e+=`one of type ${n[0]} or ${n[1]}.`:e+=`of type ${n[0]}.`;return t==null?e+=` Received ${t}`:typeof t==`function`&&t.name?e+=` Received function ${t.name}`:typeof t==`object`&&t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}var ct=(e,...t)=>st(`Key must be `,e,...t),lt=(e,t,...n)=>st(`Key for the ${e} algorithm must be `,t,...n);function ut(e,t){if(e.startsWith(`RS`)||e.startsWith(`PS`)){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}function dt(e,t){let n=`SHA-${e.slice(-3)}`;switch(e){case`HS256`:case`HS384`:case`HS512`:return{hash:n,name:`HMAC`};case`PS256`:case`PS384`:case`PS512`:return{hash:n,name:`RSA-PSS`,saltLength:parseInt(e.slice(-3),10)>>3};case`RS256`:case`RS384`:case`RS512`:return{hash:n,name:`RSASSA-PKCS1-v1_5`};case`ES256`:case`ES384`:case`ES512`:return{hash:n,name:`ECDSA`,namedCurve:t.namedCurve};case`Ed25519`:case`EdDSA`:return{name:`Ed25519`};case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:return{name:e};default:throw new Ze(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function ft(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(ct(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return ot(t,e,n),t}async function pt(e,t,n){let r=await ft(e,t,`sign`);ut(e,r);let i=await crypto.subtle.sign(dt(e,r.algorithm),r,n);return new Uint8Array(i)}async function mt(e,t,n,r){let i=await ft(e,t,`verify`);ut(e,i);let a=dt(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var ht=e=>typeof e==`object`&&!!e;function gt(e){if(!ht(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function _t(...e){let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let n;for(let e of t){let t=Object.keys(e);if(!n||n.size===0){n=new Set(t);continue}for(let e of t){if(n.has(e))return!1;n.add(e)}}return!0}var vt=e=>gt(e)&&typeof e.kty==`string`,yt=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),bt=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,xt=e=>e.kty===`oct`&&typeof e.k==`string`,St=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},Ct=e=>e?.[Symbol.toStringTag]===`KeyObject`,wt=e=>St(e)||Ct(e),Tt=e=>e?.[Symbol.toStringTag],Et=(e,t,n)=>{if(t.use!==void 0){let e;switch(n){case`sign`:case`verify`:e=`sig`;break;case`encrypt`:case`decrypt`:e=`enc`;break}if(t.use!==e)throw TypeError(`Invalid key for this operation, its "use" must be "${e}" when present`)}if(t.alg!==void 0&&t.alg!==e)throw TypeError(`Invalid key for this operation, its "alg" must be "${e}" when present`);if(Array.isArray(t.key_ops)){let r;switch(!0){case n===`sign`||n===`verify`:case e===`dir`:case e.includes(`CBC-HS`):r=n;break;case e.startsWith(`PBES2`):r=`deriveBits`;break;case/^A\d{3}(?:GCM)?(?:KW)?$/.test(e):r=!e.includes(`GCM`)&&e.endsWith(`KW`)?n===`encrypt`?`wrapKey`:`unwrapKey`:n;break;case n===`encrypt`&&e.startsWith(`RSA`):r=`wrapKey`;break;case n===`decrypt`:r=e.startsWith(`RSA`)?`unwrapKey`:`deriveBits`;break}if(r&&t.key_ops?.includes?.(r)===!1)throw TypeError(`Invalid key for this operation, its "key_ops" must include "${r}" when present`)}return!0},Dt=(e,t,n)=>{if(!(t instanceof Uint8Array)){if(vt(t)){if(xt(t)&&Et(e,t,n))return;throw TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`)}if(!wt(t))throw TypeError(lt(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${Tt(t)} instances for symmetric algorithms must be of type "secret"`)}},Ot=(e,t,n)=>{if(vt(t))switch(n){case`decrypt`:case`sign`:if(yt(t)&&Et(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if(bt(t)&&Et(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!wt(t))throw TypeError(lt(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${Tt(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${Tt(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${Tt(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${Tt(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${Tt(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function kt(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:Dt(e,t,n);break;default:Ot(e,t,n)}}function At(e,t,n,r,i){if(i.crit!==void 0&&r?.crit===void 0)throw new e(`"crit" (Critical) Header Parameter MUST be integrity protected`);if(!r||r.crit===void 0)return new Set;if(!Array.isArray(r.crit)||r.crit.length===0||r.crit.some(e=>typeof e!=`string`||e.length===0))throw new e(`"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present`);let a;a=n===void 0?t:new Map([...Object.entries(n),...t.entries()]);for(let t of r.crit){if(!a.has(t))throw new Ze(`Extension Header Parameter "${t}" is not recognized`);if(i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a.get(t)&&r[t]===void 0)throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(r.crit)}var jt=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function Mt(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new Ze(jt)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new Ze(jt)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new Ze(jt)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new Ze(jt)}break;default:throw new Ze(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function Nt(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=Mt(e),r={...e};return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??!(e.d||e.priv),e.key_ops??n)}var Pt=`given KeyObject instance cannot be used for this algorithm`,Ft,It=async(e,t,n,r=!1)=>{Ft||=new WeakMap;let i=Ft.get(e);if(i?.[n])return i[n];let a=await Nt({...t,alg:n});return r&&Object.freeze(e),i?i[n]=a:Ft.set(e,{[n]:a}),a},Lt=(e,t)=>{Ft||=new WeakMap;let n=Ft.get(e);if(n?.[t])return n[t];let r=e.type===`public`,i=!!r,a;if(e.asymmetricKeyType===`x25519`){switch(t){case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:break;default:throw TypeError(Pt)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(Pt);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}switch(e.asymmetricKeyType){case`ml-dsa-44`:case`ml-dsa-65`:case`ml-dsa-87`:if(t!==e.asymmetricKeyType.toUpperCase())throw TypeError(Pt);a=e.toCryptoKey(e.asymmetricKeyType,i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`rsa`){let n;switch(t){case`RSA-OAEP`:n=`SHA-1`;break;case`RS256`:case`PS256`:case`RSA-OAEP-256`:n=`SHA-256`;break;case`RS384`:case`PS384`:case`RSA-OAEP-384`:n=`SHA-384`;break;case`RS512`:case`PS512`:case`RSA-OAEP-512`:n=`SHA-512`;break;default:throw TypeError(Pt)}if(t.startsWith(`RSA-OAEP`))return e.toCryptoKey({name:`RSA-OAEP`,hash:n},i,r?[`encrypt`]:[`decrypt`]);a=e.toCryptoKey({name:t.startsWith(`PS`)?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:n},i,[r?`verify`:`sign`])}if(e.asymmetricKeyType===`ec`){let n=new Map([[`prime256v1`,`P-256`],[`secp384r1`,`P-384`],[`secp521r1`,`P-521`]]).get(e.asymmetricKeyDetails?.namedCurve);if(!n)throw TypeError(Pt);let o={ES256:`P-256`,ES384:`P-384`,ES512:`P-521`};o[t]&&n===o[t]&&(a=e.toCryptoKey({name:`ECDSA`,namedCurve:n},i,[r?`verify`:`sign`])),t.startsWith(`ECDH-ES`)&&(a=e.toCryptoKey({name:`ECDH`,namedCurve:n},i,r?[]:[`deriveBits`]))}if(!a)throw TypeError(Pt);return n?n[t]=a:Ft.set(e,{[t]:a}),a};async function Rt(e,t){if(e instanceof Uint8Array||St(e))return e;if(Ct(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return Lt(e,t)}catch(e){if(e instanceof TypeError)throw e}return It(e,e.export({format:`jwk`}),t)}if(vt(e))return e.k?Ge(e.k):It(e,e,t,!0);throw Error(`unreachable`)}function zt(e,t){if(e)throw TypeError(`${t} can only be called once`)}function Bt(e,t,n){try{return Ge(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}var Vt=class{#e;#t;#n;constructor(e){if(!(e instanceof Uint8Array))throw TypeError(`payload must be an instance of Uint8Array`);this.#e=e}setProtectedHeader(e){return zt(this.#t,`setProtectedHeader`),this.#t=e,this}setUnprotectedHeader(e){return zt(this.#n,`setUnprotectedHeader`),this.#n=e,this}async sign(e,t){if(!this.#t&&!this.#n)throw new H(`either setProtectedHeader or setUnprotectedHeader must be called before #sign()`);if(!_t(this.#t,this.#n))throw new H(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let n={...this.#t,...this.#n},r=At(H,new Map([[`b64`,!0]]),t?.crit,this.#t,n),i=!0;if(r.has(`b64`)&&(i=this.#t.b64,typeof i!=`boolean`))throw new H(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:a}=n;if(typeof a!=`string`||!a)throw new H(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);kt(a,e,`sign`);let o,s;i?(o=Ke(this.#e),s=He(o)):(s=this.#e,o=``);let c,l;this.#t?(c=Ke(JSON.stringify(this.#t)),l=He(c)):(c=``,l=new Uint8Array);let u=Ve(l,He(`.`),s),d={signature:Ke(await pt(a,await Rt(e,a),u)),payload:o};return this.#n&&(d.header=this.#n),this.#t&&(d.protected=c),d}},Ht=class{#e;constructor(e){this.#e=new Vt(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this}async sign(e,t){let n=await this.#e.sign(e,t);if(n.payload===void 0)throw TypeError(`use the flattened module for creating JWS with b64: false`);return`${n.protected}.${n.payload}.${n.signature}`}},Ut=e=>Math.floor(e.getTime()/1e3),Wt=60,Gt=Wt*60,Kt=Gt*24,qt=Kt*7,Jt=Kt*365.25,Yt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Xt(e){let t=Yt.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r=t[3].toLowerCase(),i;switch(r){case`sec`:case`secs`:case`second`:case`seconds`:case`s`:i=Math.round(n);break;case`minute`:case`minutes`:case`min`:case`mins`:case`m`:i=Math.round(n*Wt);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:i=Math.round(n*Gt);break;case`day`:case`days`:case`d`:i=Math.round(n*Kt);break;case`week`:case`weeks`:case`w`:i=Math.round(n*qt);break;default:i=Math.round(n*Jt);break}return t[1]===`-`||t[4]===`ago`?-i:i}function Zt(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}var Qt=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`,$t=(e,t)=>typeof e==`string`?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1;function en(e,t,n={}){let r;try{r=JSON.parse(Be.decode(t))}catch{}if(!gt(r))throw new Qe(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=n;if(i&&(typeof e.typ!=`string`||Qt(e.typ)!==Qt(i)))throw new Je(`unexpected "typ" JWT header value`,r,`typ`,`check_failed`);let{requiredClaims:a=[],issuer:o,subject:s,audience:c,maxTokenAge:l}=n,u=[...a];l!==void 0&&u.push(`iat`),c!==void 0&&u.push(`aud`),s!==void 0&&u.push(`sub`),o!==void 0&&u.push(`iss`);for(let e of new Set(u.reverse()))if(!(e in r))throw new Je(`missing required "${e}" claim`,r,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(r.iss))throw new Je(`unexpected "iss" claim value`,r,`iss`,`check_failed`);if(s&&r.sub!==s)throw new Je(`unexpected "sub" claim value`,r,`sub`,`check_failed`);if(c&&!$t(r.aud,typeof c==`string`?[c]:c))throw new Je(`unexpected "aud" claim value`,r,`aud`,`check_failed`);let d;switch(typeof n.clockTolerance){case`string`:d=Xt(n.clockTolerance);break;case`number`:d=n.clockTolerance;break;case`undefined`:d=0;break;default:throw TypeError(`Invalid clockTolerance option type`)}let{currentDate:f}=n,p=Ut(f||new Date);if((r.iat!==void 0||l)&&typeof r.iat!=`number`)throw new Je(`"iat" claim must be a number`,r,`iat`,`invalid`);if(r.nbf!==void 0){if(typeof r.nbf!=`number`)throw new Je(`"nbf" claim must be a number`,r,`nbf`,`invalid`);if(r.nbf>p+d)throw new Je(`"nbf" claim timestamp check failed`,r,`nbf`,`check_failed`)}if(r.exp!==void 0){if(typeof r.exp!=`number`)throw new Je(`"exp" claim must be a number`,r,`exp`,`invalid`);if(r.exp<=p-d)throw new Ye(`"exp" claim timestamp check failed`,r,`exp`,`check_failed`)}if(l){let e=p-r.iat,t=typeof l==`number`?l:Xt(l);if(e-d>t)throw new Ye(`"iat" claim timestamp check failed (too far in the past)`,r,`iat`,`check_failed`);if(e<0-d)throw new Je(`"iat" claim timestamp check failed (it should be in the past)`,r,`iat`,`check_failed`)}return r}var tn=class{#e;constructor(e){if(!gt(e))throw TypeError(`JWT Claims Set MUST be an object`);this.#e=structuredClone(e)}data(){return ze.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=Zt(`setNotBefore`,e):e instanceof Date?this.#e.nbf=Zt(`setNotBefore`,Ut(e)):this.#e.nbf=Ut(new Date)+Xt(e)}set exp(e){typeof e==`number`?this.#e.exp=Zt(`setExpirationTime`,e):e instanceof Date?this.#e.exp=Zt(`setExpirationTime`,Ut(e)):this.#e.exp=Ut(new Date)+Xt(e)}set iat(e){e===void 0?this.#e.iat=Ut(new Date):e instanceof Date?this.#e.iat=Zt(`setIssuedAt`,Ut(e)):typeof e==`string`?this.#e.iat=Zt(`setIssuedAt`,Ut(new Date)+Xt(e)):this.#e.iat=Zt(`setIssuedAt`,e)}},nn=class{#e;#t;constructor(e={}){this.#t=new tn(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,t){let n=new Ht(this.#t.data());if(n.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes(`b64`)&&this.#e.b64===!1)throw new Qe(`JWTs MUST NOT use unencoded payload`);return n.sign(e,t)}};function rn(e,t){if(t!==void 0&&(!Array.isArray(t)||t.some(e=>typeof e!=`string`)))throw TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}async function an(e,t,n){if(!gt(e))throw new H(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new H(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new H(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new H(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new H(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!gt(e.header))throw new H(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=Ge(e.protected);r=JSON.parse(Be.decode(t))}catch{throw new H(`JWS Protected Header is invalid`)}if(!_t(r,e.header))throw new H(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i={...r,...e.header},a=At(H,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new H(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new H(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&rn(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new Xe(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new H(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new H(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),kt(s,t,`verify`);let u=Ve(e.protected===void 0?new Uint8Array:He(e.protected),He(`.`),typeof e.payload==`string`?o?He(e.payload):ze.encode(e.payload):e.payload),d=Bt(e.signature,`signature`,H),f=await Rt(t,s);if(!await mt(s,f,d,u))throw new $e;let p;p=o?Bt(e.payload,`payload`,H):typeof e.payload==`string`?ze.encode(e.payload):e.payload;let m={payload:p};return e.protected!==void 0&&(m.protectedHeader=r),e.header!==void 0&&(m.unprotectedHeader=e.header),l?{...m,key:f}:m}async function on(e,t,n){if(e instanceof Uint8Array&&(e=Be.decode(e)),typeof e!=`string`)throw new H(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new H(`Invalid Compact JWS`);let s=await an({payload:i,protected:r,signature:a},t,n),c={payload:s.payload,protectedHeader:s.protectedHeader};return typeof t==`function`?{...c,key:s.key}:c}async function sn(e,t,n){let r=await on(e,t,n);if(r.protectedHeader.crit?.includes(`b64`)&&r.protectedHeader.b64===!1)throw new Qe(`JWTs MUST NOT use unencoded payload`);let i={payload:en(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t==`function`?{...i,key:r.key}:i}function cn(e){return e.saveState!==void 0&&e.restoreState!==void 0&&e.cleanSavedState!==void 0}function ln(e){for(let t=0;t<e.length;t++)e[t]=0;return e}var un=class{blockSize;digestLength;_inner;_outer;_finished=!1;_innerKeyedState;_outerKeyedState;constructor(e,t){this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;let n=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(n).clean():n.set(t);for(let e=0;e<n.length;e++)n[e]^=54;this._inner.update(n);for(let e=0;e<n.length;e++)n[e]^=106;this._outer.update(n),cn(this._inner)&&cn(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),ln(n)}reset(){if(!cn(this._inner)||!cn(this._outer))throw 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(){cn(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),cn(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(){let e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(!cn(this._inner))throw Error(`hmac: can't saveState() because hash doesn't implement it`);return this._inner.saveState()}restoreState(e){if(!cn(this._inner)||!cn(this._outer))throw 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(!cn(this._inner))throw Error(`hmac: can't cleanSavedState() because hash doesn't implement it`);this._inner.cleanSavedState(e)}};Number.isInteger,Number.isSafeInteger;function dn(e,t=0){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function fn(e,t=new Uint8Array(4),n=0){return t[n+0]=e>>>24,t[n+1]=e>>>16,t[n+2]=e>>>8,t[n+3]=e>>>0,t}function pn(e,t,n,r,i){let a=new un(e,t),o=a.digestLength,s=new Uint8Array(4),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(i),d=a.update(n).saveState();for(let e=0;e*o<i;e++){fn(e+1,s),a.restoreState(d).update(s).finish(l);for(let e=0;e<o;e++)c[e]=l[e];for(let e=2;e<=r;e++){a.reset().update(l).finish(l);for(let e=0;e<o;e++)c[e]^=l[e]}for(let t=0;t<o&&e*o+t<i;t++)u[e*o+t]=c[t]}return ln(c),ln(l),ln(s),a.cleanSavedState(d),a.clean(),u}var mn=class{digestLength=32;blockSize=64;_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(){ln(this._buffer),ln(this._temp),this.reset()}update(e,t=e.length){if(this._finished)throw Error(`SHA256: can't update because hash was finished.`);let n=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&t>0;)this._buffer[this._bufferLength++]=e[n++],t--;this._bufferLength===this.blockSize&&(gn(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=gn(this._temp,this._state,e,n,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[n++],t--;return this}finish(e){if(!this._finished){let e=this._bytesHashed,t=this._bufferLength,n=e/536870912|0,r=e<<3,i=e%64<56?64:128;this._buffer[t]=128;for(let e=t+1;e<i-8;e++)this._buffer[e]=0;fn(n,this._buffer,i-8),fn(r,this._buffer,i-4),gn(this._temp,this._state,this._buffer,0,i),this._finished=!0}for(let t=0;t<this.digestLength/4;t++)fn(this._state[t],e,t*4);return this}digest(){let e=new Uint8Array(this.digestLength);return this.finish(e),e}saveState(){if(this._finished)throw 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){ln(e.state),e.buffer&&ln(e.buffer),e.bufferLength=0,e.bytesHashed=0}},hn=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 gn(e,t,n,r,i){for(;i>=64;){let a=t[0],o=t[1],s=t[2],c=t[3],l=t[4],u=t[5],d=t[6],f=t[7];for(let t=0;t<16;t++)e[t]=dn(n,r+t*4);for(let t=16;t<64;t++){let n=e[t-2],r=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10;n=e[t-15];let i=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3;e[t]=(r+e[t-7]|0)+(i+e[t-16]|0)}for(let t=0;t<64;t++){let n=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&u^~l&d)|0)+(f+(hn[t]+e[t]|0)|0)|0,r=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&o^a&s^o&s)|0;f=d,d=u,u=l,l=c+n|0,c=s,s=o,o=a,a=n+r|0}t[0]+=a,t[1]+=o,t[2]+=s,t[3]+=c,t[4]+=l,t[5]+=u,t[6]+=d,t[7]+=f,r+=64,i-=64}return r}var _n=n(),vn;function yn(e){return{lang:e?.lang??vn?.lang,message:e?.message,abortEarly:e?.abortEarly??vn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??vn?.abortPipeEarly}}var bn;function xn(e){return bn?.get(e)}var Sn;function Cn(e){return Sn?.get(e)}var wn;function Tn(e,t){return wn?.get(e)?.get(t)}function En(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function U(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??En(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Tn(e.reference,c.lang)??(l?Cn(c.lang):null)??r.message??xn(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Dn(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},yn())}}}function On(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function kn(e,t){return{kind:`validation`,type:`check`,reference:kn,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&U(this,`input`,e,t),e}}}function An(e){return{kind:`validation`,type:`integer`,reference:An,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&U(this,`integer`,e,t),e}}}function jn(e,t){return{kind:`validation`,type:`max_length`,reference:jn,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&U(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Mn(e,t){return{kind:`validation`,type:`min_value`,reference:Mn,async:!1,expects:`>=${e instanceof Date?e.toJSON():En(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&U(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():En(e.value)}),e}}}function Nn(e,t){return{kind:`validation`,type:`regex`,reference:Nn,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&U(this,`format`,e,t),e}}}function Pn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Fn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function In(e,t){return{kind:`schema`,type:`array`,reference:In,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else U(this,`type`,e,t);return e}}}function Ln(e){return{kind:`schema`,type:`boolean`,reference:Ln,expects:`boolean`,async:!1,message:e,get"~standard"(){return Dn(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:U(this,`type`,e,t),e}}}function Rn(e,t){return{kind:`schema`,type:`instance`,reference:Rn,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:U(this,`type`,e,t),e}}}function zn(e,t){return{kind:`schema`,type:`literal`,reference:zn,expects:En(e),async:!1,literal:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:U(this,`type`,e,t),e}}}function Bn(e){return{kind:`schema`,type:`number`,reference:Bn,expects:`number`,async:!1,message:e,get"~standard"(){return Dn(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:U(this,`type`,e,t),e}}}function W(e,t){return{kind:`schema`,type:`optional`,reference:W,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Dn(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Fn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Vn(e,t,n){return{kind:`schema`,type:`record`,reference:Vn,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Dn(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(On(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else U(this,`type`,e,t);return e}}}function Hn(e,t){return{kind:`schema`,type:`strict_object`,reference:Hn,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Fn(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Pn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(U(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(!(r in this.entries)){U(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else U(this,`type`,e,t);return e}}}function G(e){return{kind:`schema`,type:`string`,reference:G,expects:`string`,async:!1,message:e,get"~standard"(){return Dn(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:U(this,`type`,e,t),e}}}function Un(){return{kind:`schema`,type:`unknown`,reference:Un,expects:`unknown`,async:!1,get"~standard"(){return Dn(this)},"~run"(e){return e.typed=!0,e}}}function Wn(...e){return{...e[0],pipe:e,get"~standard"(){return Dn(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function Gn(e,t,n){let r=e[`~run`]({value:t},yn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var K={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},q={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,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:18446744073709551615n},J={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Kn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},Y=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`)},qn={MIN:-(2n**63n),MAX:2n**64n-1n},X=class e{static#e=new Map;tag;contents;constructor(e,t=void 0){this.tag=e,this.contents=t}get noChildren(){return!!e.#e.get(this.tag)?.noChildren}static registerDecoder(e,t,n){let r=this.#e.get(e);return this.#e.set(e,t),r&&(`comment`in t||(t.comment=r.comment),`noChildren`in t||(t.noChildren=r.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),r}static clearDecoder(e){let t=this.#e.get(e);return this.#e.delete(e),t}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(t){let n=t?.tags?.get(this.tag)??(t?.ignoreGlobalTags?void 0:e.#e.get(this.tag));return n?n(this,t):this}comment(t,n){let r=t?.tags?.get(this.tag)??(t?.ignoreGlobalTags?void 0:e.#e.get(this.tag));if(r?.comment)return r.comment(this,t,n)}toCBOR(){return[this.tag,this.contents]}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return`${this.tag}(${n(this.contents,t)})`}};function Jn(e){if(typeof e==`object`&&e)return e[Y.ENCODED]}function Yn(e){if(typeof e==`object`&&e)return e[Y.LENGTH]}function Xn(e,t){Object.defineProperty(e,Y.ENCODED,{configurable:!0,enumerable:!1,value:t})}function Zn(e,t){let n=Object(e);return Xn(n,t),n}var Qn=Symbol(`CBOR_RANGES`);function $n(e,t){Object.defineProperty(e,Qn,{configurable:!1,enumerable:!1,writable:!1,value:t})}function er(e){return e[Qn]}function tr(e){return er(e)!==void 0}function nr(e,t=0,n=e.length-1){let r=e.subarray(t,n),i=er(e);if(i){let e=[];for(let r of i)if(r[0]>=t&&r[0]+r[1]<=n){let n=[...r];n[0]-=t,e.push(n)}e.length&&$n(r,e)}return r}function rr(e){let t=Math.ceil(e.length/2),n=new Uint8Array(t);t--;for(let r=e.length,i=r-2;r>=0;r=i,i-=2,t--)n[t]=parseInt(e.substring(i,r),16);return n}function Z(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function ir(e){let t=e.reduce((e,t)=>e+t.length,0),n=e.some(e=>tr(e)),r=[],i=new Uint8Array(t),a=0;for(let t of e){if(!(t instanceof Uint8Array))throw TypeError(`Invalid array: ${t}`);if(i.set(t,a),n){let e=t[Qn]??[[0,t.length]];for(let t of e)t[0]+=a;r.push(...e)}a+=t.length}return n&&$n(i,r),i}function ar(e){let t=atob(e);return Uint8Array.from(t,e=>e.codePointAt(0))}var or={"-":`+`,_:`/`};function sr(e){let t=e.replace(/[_-]/g,e=>or[e]);return ar(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function cr(){let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])}function lr(e){let t=``;for(let n of e){let e=n.codePointAt(0)?.toString(16).padStart(4,`0`);t&&(t+=`, `),t+=`U+${e}`}return t}var ur=class{#e=new Map;registerEncoder(e,t){let n=this.#e.get(e);return this.#e.set(e,t),n}get(e){return this.#e.get(e)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}};function dr(e,t){let[n,r,i]=e,[a,o,s]=t,c=Math.min(i.length,s.length);for(let e=0;e<c;e++){let t=i[e]-s[e];if(t!==0)return t}return 0}var fr=class e{static defaultOptions={chunkSize:4096};#e;#t=[];#n=null;#r=0;#i=0;constructor(t={}){if(this.#e={...e.defaultOptions,...t},this.#e.chunkSize<8)throw RangeError(`Expected size >= 8, got ${this.#e.chunkSize}`);this.#a()}get length(){return this.#i}read(){this.#o();let e=new Uint8Array(this.#i),t=0;for(let n of this.#t)e.set(n,t),t+=n.length;return this.#a(),e}write(e){let t=e.length;t>this.#s()?(this.#o(),t>this.#e.chunkSize?(this.#t.push(e),this.#a()):(this.#a(),this.#t[this.#t.length-1].set(e),this.#r=t)):(this.#t[this.#t.length-1].set(e,this.#r),this.#r+=t),this.#i+=t}writeUint8(e){this.#c(1),this.#n.setUint8(this.#r,e),this.#l(1)}writeUint16(e,t=!1){this.#c(2),this.#n.setUint16(this.#r,e,t),this.#l(2)}writeUint32(e,t=!1){this.#c(4),this.#n.setUint32(this.#r,e,t),this.#l(4)}writeBigUint64(e,t=!1){this.#c(8),this.#n.setBigUint64(this.#r,e,t),this.#l(8)}writeInt16(e,t=!1){this.#c(2),this.#n.setInt16(this.#r,e,t),this.#l(2)}writeInt32(e,t=!1){this.#c(4),this.#n.setInt32(this.#r,e,t),this.#l(4)}writeBigInt64(e,t=!1){this.#c(8),this.#n.setBigInt64(this.#r,e,t),this.#l(8)}writeFloat32(e,t=!1){this.#c(4),this.#n.setFloat32(this.#r,e,t),this.#l(4)}writeFloat64(e,t=!1){this.#c(8),this.#n.setFloat64(this.#r,e,t),this.#l(8)}clear(){this.#i=0,this.#t=[],this.#a()}#a(){let e=new Uint8Array(this.#e.chunkSize);this.#t.push(e),this.#r=0,this.#n=new DataView(e.buffer,e.byteOffset,e.byteLength)}#o(){if(this.#r===0){this.#t.pop();return}let e=this.#t.length-1;this.#t[e]=this.#t[e].subarray(0,this.#r),this.#r=0,this.#n=null}#s(){let e=this.#t.length-1;return this.#t[e].length-this.#r}#c(e){this.#s()<e&&(this.#o(),this.#a())}#l(e){this.#r+=e,this.#i+=e}},pr=1n<<15n,mr=31n<<10n,hr=1n<<9n,gr=hr-1n,_r=hr|gr,vr=1n<<31n,yr=255n<<23n,br=1n<<22n,xr=br-1n,Sr=br|xr,Cr=1n<<63n,wr=2047n<<52n,Tr=1n<<51n,Er=Tr-1n,Dr=Tr|Er,Or=Er-(gr<<42n),kr=Er-(xr<<29n),Ar={2:`0b`,8:`0o`,16:`0x`},jr=(e=>(e[e.NATURAL=-2]=`NATURAL`,e[e.UNKNOWN=-1]=`UNKNOWN`,e[e.F16=2]=`F16`,e[e.F32=4]=`F32`,e[e.F64=8]=`F64`,e))(jr||{});function Mr(e,t,n,r){let i=`nan'`;return e.quiet||(i+=`!`),e.sign===-1&&(i+=`-`),i+=r(Math.abs(e.payload),n),i+=`'`,i+=e.encodingIndicator,i}var Nr=class extends Number{#e;#t=-1;constructor(e,t=!0,n=-1){super(NaN);let r=e;if(typeof e==`number`){if(!Number.isSafeInteger(e))throw Error(`Invalid NAN payload: ${e}`);e=BigInt(e);let i=0n;if(e<0&&(i=Cr,e=-e),e>=Tr)throw Error(`Payload too large: ${r}`);let a=t?Tr:0n;switch(this.#e=i|wr|a|e,n){case-2:throw Error(`NAN_SIZE.NATURAL only valid for bigint constructor`);case-1:n=this.preferredSize;break;case 2:if(this.#e&Or)throw Error(`Invalid size for payload`);break;case 4:if(this.#e&kr)throw Error(`Invalid size for payload`);break;case 8:break;default:throw Error(`Invalid size: ${n}`)}this.#t=n}else if(typeof e==`bigint`){let t=-1;if((e&wr)===wr)this.#e=e,t=8;else if((e&yr)===yr)this.#e=(e&vr)<<32n|wr|(e&Sr)<<29n,t=4;else if((e&mr)===mr)this.#e=(e&pr)<<48n|wr|(e&_r)<<42n,t=2;else throw Error(`Invalid raw NaN value: ${e}`);if(n===-1)this.#t=this.preferredSize;else if(n===-2)this.#t=t;else{if(n<t)throw Error(`Invalid bigint NaN size`);this.#t=n}}else{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw Error(`Invalid CBOR encoding for half float`);let n=BigInt(t.getUint16(1,!1));if((n&mr)!==mr)throw Error(`Not a NaN`);this.#e=(n&pr)<<48n|wr|(n&_r)<<42n,this.#t=2;break}case 5:{if(e[0]!==250)throw Error(`Invalid CBOR encoding for single float`);let n=BigInt(t.getUint32(1,!1));if((n&yr)!==yr)throw Error(`Not a NaN`);this.#e=(n&vr)<<32n|wr|(n&Sr)<<29n,this.#t=4;break}case 9:if(e[0]!==251)throw Error(`Invalid CBOR encoding for double float`);if(this.#e=t.getBigUint64(1,!1),(this.#e&wr)!==wr)throw Error(`Not a NaN (NaNaN)`);this.#t=8;break;default:throw RangeError(`Invalid NAN size (should be 2, 4, or 8): ${e.length-1}`)}}if(!this.payload&&!this.quiet)throw Error(`Signalling NaN with zero payload`)}get bytes(){let e=new ArrayBuffer(this.#t+1),t=new DataView(e);switch(this.#t){case 2:{t.setUint8(0,249);let e=(this.#e&Cr?pr:0n)|mr|(this.#e&Dr)>>42n;t.setUint16(1,Number(e),!1);break}case 4:{t.setUint8(0,250);let e=(this.#e&Cr?vr:0n)|yr|(this.#e&Dr)>>29n;t.setUint32(1,Number(e),!1);break}case 8:t.setUint8(0,251),t.setBigUint64(1,this.#e);break}return new Uint8Array(e)}get quiet(){return!!(this.#e&Tr)}get sign(){return this.#e&Cr?-1:1}get payload(){return Number(this.#e&Er)*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&Or)===0n?2:(this.#e&kr)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return Mr(this,1,{},t=>(Ar[e]??``)+t.toString(e))}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return Mr(this,e,t,n)}};function Pr(e,t=0,n=!1){let r=e[t]&128?-1:1,i=(e[t]&124)>>2,a=(e[t]&3)<<8|e[t+1];if(i===0){if(n&&a!==0)throw Error(`Unwanted subnormal: ${r*5.960464477539063e-8*a}`);return r*5.960464477539063e-8*a}else if(i===31)return a?NaN:r*(1/0);return r*2**(i-25)*(1024+a)}function Fr(e){let t=new DataView(new ArrayBuffer(4));t.setFloat32(0,e,!1);let n=t.getUint32(0,!1);if(n&8191)return null;let r=n>>16&32768,i=n>>23&255,a=n&8388607;if(!(i===0&&a===0))if(i>=113&&i<=142)r+=(i-112<<10)+(a>>13);else if(i>=103&&i<113){if(a&(1<<126-i)-1)return null;r+=a+8388608>>126-i}else if(i===255)r|=31744,r|=a>>13;else return null;return r}function Ir(e){if(e!==0){let t=new ArrayBuffer(8),n=new DataView(t);n.setFloat64(0,e,!1);let r=n.getBigUint64(0,!1);if((r&9218868437227405312n)==0n)return r&9223372036854775808n?-0:0}return e}function Lr(e){switch(e.length){case 2:Pr(e,0,!0);break;case 4:{let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0,!1);if(!(n&2139095040)&&n&8388607)throw Error(`Unwanted subnormal: ${t.getFloat32(0,!1)}`);break}case 8:{let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getBigUint64(0,!1);if((n&9218868437227405312n)==0n&&n&17592186044415n)throw Error(`Unwanted subnormal: ${t.getFloat64(0,!1)}`);break}default:throw TypeError(`Bad input to isSubnormal: ${e}`)}}var Rr=class extends TypeError{code=`ERR_ENCODING_INVALID_ENCODED_DATA`;constructor(){super(`The encoded data was not valid for encoding wtf-8`)}},zr=class extends RangeError{code=`ERR_ENCODING_NOT_SUPPORTED`;constructor(e){super(`Invalid encoding: "${e}"`)}},Br=new Uint8Array,Vr=55296,Hr=56320,Ur=65533,Wr=`wtf-8`;function Gr(e){return e&&typeof e==`object`&&!(e instanceof ArrayBuffer)&&!(e instanceof SharedArrayBuffer)&&e.buffer instanceof ArrayBuffer}function Kr(e){return e?e instanceof Uint8Array?e:Gr(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e):Br}var qr=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3],Jr=class e{static DEFAULT_BUFFERSIZE=4096;encoding=Wr;fatal;ignoreBOM;bufferSize;#e=0;#t=0;#n=0;#r=!0;#i;constructor(t=`wtf8`,n=void 0){if(t.toLowerCase().replace(`-`,``)!==`wtf8`)throw new zr(t);if(this.fatal=!!n?.fatal,this.ignoreBOM=!!n?.ignoreBOM,this.bufferSize=Math.floor(n?.bufferSize??e.DEFAULT_BUFFERSIZE),isNaN(this.bufferSize)||this.bufferSize<1)throw RangeError(`Invalid buffer size: ${n?.bufferSize}`);this.#i=new Uint16Array(this.bufferSize)}decode(e,t){let n=!!t?.stream,r=Kr(e),i=[],a=this.#i,o=this.bufferSize-3,s=0,c=()=>{if(this.#t=0,this.#e=0,this.#n=0,this.fatal)throw new Rr;a[s++]=Ur},l=()=>{let e=this.#n;for(let t=0;t<e;t++)c()},u=e=>{if(this.#e===0)switch(qr[e>>4]){case-1:c();break;case 0:a[s++]=e;break;case 1:this.#t=e&31,this.#t&30?(this.#e=1,this.#n=1):c();break;case 2:this.#t=e&15,this.#e=2,this.#n=1;break;case 3:e&8?c():(this.#t=e&7,this.#e=3,this.#n=1);break}else{if((e&192)!=128||this.#n===1&&this.#e===2&&this.#t===0&&!(e&32)||this.#e===3&&this.#t===0&&!(e&48))return l(),u(e);if(this.#t=this.#t<<6|e&63,this.#n++,--this.#e===0){if(this.ignoreBOM||!this.#r||this.#t!==65279)if(this.#t<65536)a[s++]=this.#t;else{let e=this.#t-65536;a[s++]=e>>>10&1023|Vr,a[s++]=e&1023|Hr}this.#t=0,this.#n=0,this.#r=!1}}};for(let e of r)s>=o&&(i.push(String.fromCharCode.apply(null,a.subarray(0,s))),s=0),u(e);return n||(this.#r=!0,(this.#t||this.#e)&&l()),s>0&&i.push(String.fromCharCode.apply(null,a.subarray(0,s))),i.join(``)}};function Yr(e){let t=0;for(let n of e){let e=n.codePointAt(0);e<128?t++:e<2048?t+=2:e<65536?t+=3:t+=4}return t}var Xr=class{encoding=Wr;encode(e){if(!e)return Br;let t=new Uint8Array(Yr(String(e)));return this.encodeInto(e,t),t}encodeInto(e,t){let n=String(e),r=n.length,i=t.length,a=0,o=0;for(o=0;o<r;o++){let e=n.codePointAt(o);if(e<128){if(a>=i)break;t[a++]=e}else if(e<2048){if(a>=i-1)break;t[a++]=192|e>>6,t[a++]=128|e&63}else if(e<65536){if(a>=i-2)break;t[a++]=224|e>>12,t[a++]=128|e>>6&63,t[a++]=128|e&63}else{if(a>=i-3)break;t[a++]=240|e>>18,t[a++]=128|e>>12&63,t[a++]=128|e>>6&63,t[a++]=128|e&63,o++}}return{read:o,written:a}}},{ENCODED:Zr}=Y,Qr=K.SIMPLE_FLOAT<<5|J.TWO,$r=K.SIMPLE_FLOAT<<5|J.FOUR,ei=K.SIMPLE_FLOAT<<5|J.EIGHT,ti=K.SIMPLE_FLOAT<<5|Kn.TRUE,ni=K.SIMPLE_FLOAT<<5|Kn.FALSE,ri=K.SIMPLE_FLOAT<<5|Kn.UNDEFINED,ii=K.SIMPLE_FLOAT<<5|Kn.NULL,ai=new TextEncoder,oi=new Xr,si={...fr.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:q.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},ci={cde:!0,ignoreOriginalEncoding:!0,sortKeys:dr},li={...ci,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:`NFC`};function ui(e){let t=e<0;return typeof e==`bigint`?[t?-e-1n:e,t]:[t?-e-1:e,t]}function di(e,t,n){if(n.rejectFloats)throw Error(`Attempt to encode an unwanted floating point number: ${e}`);if(isNaN(e))t.writeUint8(Qr),t.writeUint16(32256);else if(!n.float64&&Math.fround(e)===e){let n=Fr(e);n===null?(t.writeUint8($r),t.writeFloat32(e)):(t.writeUint8(Qr),t.writeUint16(n))}else t.writeUint8(ei),t.writeFloat64(e)}function fi(e,t,n){let[r,i]=ui(e);if(i&&n)throw TypeError(`Negative size: ${e}`);n??=i?K.NEG_INT:K.POS_INT,n<<=5,r<24?t.writeUint8(n|r):r<=255?(t.writeUint8(n|J.ONE),t.writeUint8(r)):r<=65535?(t.writeUint8(n|J.TWO),t.writeUint16(r)):r<=4294967295?(t.writeUint8(n|J.FOUR),t.writeUint32(r)):(t.writeUint8(n|J.EIGHT),t.writeBigUint64(BigInt(r)))}function pi(e,t,n){typeof e==`number`?fi(e,t,K.TAG):typeof e==`object`&&!n.ignoreOriginalEncoding&&Y.ENCODED in e?t.write(e[Y.ENCODED]):e<=2**53-1?fi(Number(e),t,K.TAG):(t.writeUint8(K.TAG<<5|J.EIGHT),t.writeBigUint64(BigInt(e)))}function mi(e,t,n){let[r,i]=ui(e);if(n.collapseBigInts&&(!n.largeNegativeAsBigInt||e>=-9223372036854775808n)){if(r<=4294967295n){fi(Number(e),t);return}if(r<=18446744073709551615n){let e=(i?K.NEG_INT:K.POS_INT)<<5;t.writeUint8(e|J.EIGHT),t.writeBigUint64(r);return}}if(n.rejectBigInts)throw Error(`Attempt to encode unwanted bigint: ${e}`);let a=i?q.NEG_BIGINT:q.POS_BIGINT,o=r.toString(16),s=o.length%2?`0`:``;pi(a,t,n);let c=rr(s+o);fi(c.length,t,K.BYTE_STRING),t.write(c)}function hi(e,t,n){n.flushToZero&&(e=Ir(e)),Object.is(e,-0)?n.simplifyNegativeZero?n.avoidInts?di(0,t,n):fi(0,t):di(e,t,n):!n.avoidInts&&Number.isSafeInteger(e)?fi(e,t):n.reduceUnsafeNumbers&&Math.floor(e)===e&&e>=qn.MIN&&e<=qn.MAX?mi(BigInt(e),t,n):di(e,t,n)}function gi(e,t,n){let r=n.stringNormalization?e.normalize(n.stringNormalization):e;if(n.wtf8&&!e.isWellFormed()){let e=oi.encode(r);pi(q.WTF8,t,n),fi(e.length,t,K.BYTE_STRING),t.write(e)}else{let e=ai.encode(r);fi(e.length,t,K.UTF8_STRING),t.write(e)}}function _i(e,t,n){let r=e;bi(r,r.length,K.ARRAY,t,n);for(let e of r)Ci(e,t,n)}function vi(e,t){fi(e.length,t,K.BYTE_STRING),t.write(e)}var yi=new ur;yi.registerEncoder(Array,_i),yi.registerEncoder(Uint8Array,vi);function Q(e,t){return yi.registerEncoder(e,t)}function bi(e,t,n,r,i){let a=Yn(e);a&&!i.ignoreOriginalEncoding?r.write(a):fi(t,r,n)}function xi(e,t,n){if(e===null){t.writeUint8(ii);return}if(!n.ignoreOriginalEncoding&&Y.ENCODED in e){t.write(e[Y.ENCODED]);return}let r=e.constructor;if(r){let i=n.types?.get(r)??(n.ignoreGlobalTags?void 0:yi.get(r));if(i){let r=i(e,t,n);if(r!==void 0){if(!Array.isArray(r)||r.length!==2)throw Error(`Invalid encoder return value`);(typeof r[0]==`bigint`||isFinite(Number(r[0])))&&pi(r[0],t,n),Ci(r[1],t,n)}return}}if(typeof e.toCBOR==`function`){let r=e.toCBOR(t,n);r&&((typeof r[0]==`bigint`||isFinite(Number(r[0])))&&pi(r[0],t,n),Ci(r[1],t,n));return}if(typeof e.toJSON==`function`){Ci(e.toJSON(),t,n);return}let i=Object.entries(e).map(e=>[e[0],e[1],wi(e[0],n)]);n.sortKeys&&i.sort(n.sortKeys),bi(e,i.length,K.MAP,t,n);for(let[e,r,a]of i)t.write(a),Ci(r,t,n)}function Si(e,t,n){if(!e.description||e!==Symbol.for(e.description))throw TypeError(`Private or empty symbol: ${e.toString()}`);pi(280,t,n),gi(e.description,t,n)}function Ci(e,t,n){switch(typeof e){case`number`:hi(e,t,n);break;case`bigint`:mi(e,t,n);break;case`string`:gi(e,t,n);break;case`boolean`:t.writeUint8(e?ti:ni);break;case`undefined`:if(n.rejectUndefined)throw Error(`Attempt to encode unwanted undefined.`);t.writeUint8(ri);break;case`object`:xi(e,t,n);break;case`symbol`:Si(e,t,n);break;default:throw TypeError(`Unknown type: ${typeof e}, ${String(e)}`)}}function wi(e,t={}){let n={...si};t.dcbor?Object.assign(n,li):t.cde&&Object.assign(n,ci),Object.assign(n,t);let r=new fr(n);return Ci(e,r,n),r.read()}var Ti=(e=>(e[e.NEVER=-1]=`NEVER`,e[e.PREFERRED=0]=`PREFERRED`,e[e.ALWAYS=1]=`ALWAYS`,e))(Ti||{}),Ei=class e{static KnownSimple=new Map([[Kn.FALSE,!1],[Kn.TRUE,!0],[Kn.NULL,null],[Kn.UNDEFINED,void 0]]);value;constructor(e){this.value=e}static create(t){return e.KnownSimple.has(t)?e.KnownSimple.get(t):new e(t)}toCBOR(e,t){if(t.rejectCustomSimples)throw Error(`Cannot encode non-standard Simple value: ${this.value}`);fi(this.value,e,K.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return e.KnownSimple.has(this.value)?e.KnownSimple.get(this.value):this}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return`simple(${n(this.value,t)})`}},Di=new TextDecoder(`utf8`,{fatal:!0,ignoreBOM:!0}),Oi=class e{static defaultOptions={maxDepth:1024,encoding:`hex`,requirePreferred:!1};#e;#t;#n=0;#r;constructor(t,n){if(this.#r={...e.defaultOptions,...n},typeof t==`string`)switch(this.#r.encoding){case`hex`:this.#e=rr(t);break;case`base64`:this.#e=ar(t);break;default:throw TypeError(`Encoding not implemented: "${this.#r.encoding}"`)}else this.#e=t;this.#t=new DataView(this.#e.buffer,this.#e.byteOffset,this.#e.byteLength)}toHere(e){return nr(this.#e,e,this.#n)}*[Symbol.iterator](){if(yield*this.#i(0),this.#n!==this.#e.length)throw Error(`Extra data in input`)}*seq(){for(;this.#n<this.#e.length;)yield*this.#i(0)}*#i(e){if(e++>this.#r.maxDepth)throw Error(`Maximum depth ${this.#r.maxDepth} exceeded`);let t=this.#n,n=this.#t.getUint8(this.#n++),r=n>>5,i=n&31,a=i,o=!1,s=0;switch(i){case J.ONE:if(s=1,a=this.#t.getUint8(this.#n),r===K.SIMPLE_FLOAT){if(a<32)throw Error(`Invalid simple encoding in extra byte: ${a}`);o=!0}else if(this.#r.requirePreferred&&a<24)throw Error(`Unexpectedly long integer encoding (1) for ${a}`);break;case J.TWO:if(s=2,r===K.SIMPLE_FLOAT)a=Pr(this.#e,this.#n);else if(a=this.#t.getUint16(this.#n,!1),this.#r.requirePreferred&&a<=255)throw Error(`Unexpectedly long integer encoding (2) for ${a}`);break;case J.FOUR:if(s=4,r===K.SIMPLE_FLOAT)a=this.#t.getFloat32(this.#n,!1);else if(a=this.#t.getUint32(this.#n,!1),this.#r.requirePreferred&&a<=65535)throw Error(`Unexpectedly long integer encoding (4) for ${a}`);break;case J.EIGHT:if(s=8,r===K.SIMPLE_FLOAT)a=this.#t.getFloat64(this.#n,!1);else if(a=this.#t.getBigUint64(this.#n,!1),a<=2**53-1&&(a=Number(a)),this.#r.requirePreferred&&a<=4294967295)throw Error(`Unexpectedly long integer encoding (8) for ${a}`);break;case 28:case 29:case 30:throw Error(`Additional info not implemented: ${i}`);case J.INDEFINITE:switch(r){case K.POS_INT:case K.NEG_INT:case K.TAG:throw Error(`Invalid indefinite encoding for MT ${r}`);case K.SIMPLE_FLOAT:yield[r,i,Y.BREAK,t,0];return}a=1/0;break;default:o=!0}switch(this.#n+=s,r){case K.POS_INT:yield[r,i,a,t,s];break;case K.NEG_INT:yield[r,i,typeof a==`bigint`?-1n-a:-1-Number(a),t,s];break;case K.BYTE_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,this.#a(a),t,a];break;case K.UTF8_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,Di.decode(this.#a(a)),t,a];break;case K.ARRAY:if(a===1/0)yield*this.#o(r,e,t,!1);else{let n=Number(a);yield[r,i,n,t,s];for(let t=0;t<n;t++)yield*this.#i(e+1)}break;case K.MAP:if(a===1/0)yield*this.#o(r,e,t,!1);else{let n=Number(a);yield[r,i,n,t,s];for(let t=0;t<n;t++)yield*this.#i(e),yield*this.#i(e)}break;case K.TAG:yield[r,i,a,t,s],yield*this.#i(e);break;case K.SIMPLE_FLOAT:{let e=a;o&&(a=Ei.create(Number(a))),yield[r,i,a,t,e];break}}}#a(e){let t=nr(this.#e,this.#n,this.#n+=e);if(t.length!==e)throw Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t}*#o(e,t,n,r=!0){for(yield[e,J.INDEFINITE,1/0,n,1/0];;){let n=this.#i(t),i=n.next(),[a,o,s]=i.value;if(s===Y.BREAK){yield i.value,n.next();return}if(r){if(a!==e)throw Error(`Unmatched major type. Expected ${e}, got ${a}.`);if(o===J.INDEFINITE)throw Error(`New stream started in typed stream`)}yield i.value,yield*n}}},ki=new Map([[J.ZERO,1],[J.ONE,2],[J.TWO,3],[J.FOUR,5],[J.EIGHT,9]]),Ai=new Uint8Array;function ji(e,t){return!t.boxed&&!t.preferMap&&e.every(([e])=>typeof e==`string`)?Object.fromEntries(e):new Map(e)}var Mi=class e{static defaultDecodeOptions={...Oi.defaultOptions,ParentType:e,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Ti.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:ji,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:dr};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,t,n,r){if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,this.#e=r,n&&(this.depth=n.depth+1),this.mt===K.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===J.INDEFINITE)throw Error(`Streaming not supported`)}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,r){let[i,a,o,s]=e;switch(i){case K.POS_INT:case K.NEG_INT:{if(n.rejectInts)throw Error(`Unexpected integer: ${o}`);if(n.rejectLargeNegatives&&o<-9223372036854775808n)throw Error(`Invalid 65bit negative number: ${o}`);let e=o;return n.preferBigInt?e=BigInt(e):n.convertUnsafeIntsToFloat&&e>=qn.MIN&&e<=qn.MAX&&(e=Number(o)),n.boxed?Zn(e,r.toHere(s)):e}case K.SIMPLE_FLOAT:if(a>J.ONE){if(typeof o==`symbol`)return o;if(n.rejectFloats)throw Error(`Decoding unwanted floating point number: ${o}`);if(n.rejectNegativeZero&&Object.is(o,-0))throw Error(`Decoding negative zero`);if(isNaN(o)){let e=r.toHere(s),t=new Nr(e);if(n.rejectLongLoundNaN){if(t.payload||e.length>3)throw Error(`Invalid NaN encoding: "${Z(e)}"`)}else if(n.keepNanPayloads&&(t.payload||t.sign===-1)){if(n.rejectLongFloats&&!t.isShortestEncoding)throw Error(`NaN should have been encoded shorter: ${o}`);return t}}if(n.rejectSubnormals&&Lr(r.toHere(s+1)),n.rejectLongFloats){let e=wi(o,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(e[0]>>5!==i)throw Error(`Should have been encoded as int, not float: ${o}`);if(e.length<ki.get(a))throw Error(`Number should have been encoded shorter: ${o}`)}if(typeof o==`number`&&n.boxed)return Zn(o,r.toHere(s))}else{if(n.rejectSimple&&o instanceof Ei)throw Error(`Invalid simple value: ${o}`);if(n.rejectUndefined&&o===void 0)throw Error(`Unexpected undefined`)}return o;case K.BYTE_STRING:case K.UTF8_STRING:if(o===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof o==`string`){let e=o.normalize(n.rejectStringsNotNormalizedAs);if(o!==e)throw Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${lr(o)}] instead of [${lr(e)}]`)}return n.boxed?Zn(o,r.toHere(s)):o;case K.ARRAY:return new n.ParentType(e,o,t,n);case K.MAP:return new n.ParentType(e,o*2,t,n);case K.TAG:{let r=new n.ParentType(e,1,t,n);return r.children=new X(o),r}}throw TypeError(`Invalid major type: ${i}`)}static decodeToEncodeOpts(e){return{...si,avoidInts:e.rejectInts,float64:!e.rejectLongFloats,flushToZero:e.rejectSubnormals,largeNegativeAsBigInt:e.rejectLargeNegatives,sortKeys:e.sortKeys}}push(e,t,n){if(this.children.push(e),this.#t){let r=Jn(e)||t.toHere(n);this.#t.push(r)}return--this.left}replaceLast(e,t,n){let r,i=-1/0;if(this.children instanceof X?(i=0,r=this.children.contents,this.children.contents=e):(i=this.children.length-1,r=this.children[i],this.children[i]=e),this.#t){let r=Jn(e)||n.toHere(t.offset);this.#t[i]=r}return r}convert(e){let t;switch(this.mt){case K.ARRAY:t=this.children;break;case K.MAP:{let e=this.#n();if(this.#e.sortKeys){let t;for(let n of e){if(t&&this.#e.sortKeys(t,n)>=0)throw Error(`Duplicate or out of order key: "0x${n[2]}"`);t=n}}else if(this.#e.rejectDuplicateKeys){let t=new Set;for(let[n,r,i]of e){let e=Z(i);if(t.has(e))throw Error(`Duplicate key: "0x${e}"`);t.add(e)}}t=this.#e.createObject(e,this.#e);break}case K.BYTE_STRING:return ir(this.children);case K.UTF8_STRING:{let n=this.children.join(``);t=this.#e.boxed?Zn(n,e.toHere(this.offset)):n;break}case K.TAG:t=this.children.decode(this.#e);break;default:throw TypeError(`Invalid mt on convert: ${this.mt}`)}return this.#e.saveOriginal&&t&&typeof t==`object`&&Xn(t,e.toHere(this.offset)),t}#n(){let e=this.children,t=e.length;if(t%2)throw Error(`Missing map value`);let n=Array(t/2);if(this.#t)for(let r=0;r<t;r+=2)n[r>>1]=[e[r],e[r+1],this.#t[r]];else for(let r=0;r<t;r+=2)n[r>>1]=[e[r],e[r+1],Ai];return n}},Ni=` `,Pi=new TextEncoder,Fi=class extends Mi{close=``;quote=`"`;get isEmptyStream(){return(this.mt===K.UTF8_STRING||this.mt===K.BYTE_STRING)&&this.count===0}};function Ii(e,t,n,r){let i=``;if(t===J.INDEFINITE)i+=`_`;else{if(r.diagnosticSizes===Ti.NEVER)return``;{let a=r.diagnosticSizes===Ti.ALWAYS;if(!a){let r=J.ZERO;if(Object.is(n,-0))r=J.TWO;else if(e===K.POS_INT||e===K.NEG_INT){let e=n<0,t=typeof n==`bigint`?1n:1,i=e?-n-t:n;r=i<=23?Number(i):i<=255?J.ONE:i<=65535?J.TWO:i<=4294967295?J.FOUR:J.EIGHT}else r=isFinite(n)?Math.fround(n)===n?Fr(n)==null?J.FOUR:J.TWO:J.EIGHT:J.TWO;a=r!==t}a&&(i+=`_`,t<J.ONE?i+=`i`:i+=String(t-24))}}return i}function Li(e,t){let n={...Mi.defaultDecodeOptions,...t,ParentType:Fi},r=new Oi(e,n),i,a,o=``;for(let e of r){let[t,s,c]=e;switch(i&&(i.count>0&&c!==Y.BREAK&&(i.mt===K.MAP&&i.count%2?o+=`: `:(o+=`,`,n.pretty||(o+=` `))),n.pretty&&(i.mt!==K.MAP||i.count%2==0)&&(o+=`
|
|
2
|
+
${Ni.repeat(i.depth+1)}`)),a=Mi.create(e,i,n,r),t){case K.POS_INT:case K.NEG_INT:o+=String(c),o+=Ii(t,s,c,n);break;case K.SIMPLE_FLOAT:if(c!==Y.BREAK)if(typeof c==`number`){let e=Object.is(c,-0)?`-0.0`:String(c);o+=e,isFinite(c)&&!/[.e]/.test(e)&&(o+=`.0`),o+=Ii(t,s,c,n)}else c instanceof Ei?(o+=`simple(`,o+=String(c.value),o+=Ii(K.POS_INT,s,c.value,n),o+=`)`):o+=String(c);break;case K.BYTE_STRING:c===1/0?(o+=`(_ `,a.close=`)`,a.quote=`'`):(o+=`h'`,o+=Z(c),o+=`'`,o+=Ii(K.POS_INT,s,c.length,n));break;case K.UTF8_STRING:c===1/0?(o+=`(_ `,a.close=`)`):(o+=JSON.stringify(c),o+=Ii(K.POS_INT,s,Pi.encode(c).length,n));break;case K.ARRAY:{o+=`[`;let e=Ii(K.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
|
|
3
|
+
${Ni.repeat(a.depth)}]`:a.close=`]`;break}case K.MAP:{o+=`{`;let e=Ii(K.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
|
|
4
|
+
${Ni.repeat(a.depth)}}`:a.close=`}`;break}case K.TAG:o+=String(c),o+=Ii(K.POS_INT,s,c,n),o+=`(`,a.close=`)`;break}if(a===Y.BREAK)if(i?.isStreaming)i.left=0;else throw Error(`Unexpected BREAK`);else i&&(i.count++,i.left--);for(a instanceof Fi&&(i=a);i?.done;){if(i.isEmptyStream)o=o.slice(0,-3),o+=`${i.quote}${i.quote}_`;else{if(i.mt===K.MAP&&i.count%2!=0)throw Error(`Odd streaming map size: ${i.count}`);o+=i.close}i=i.parent}}return o}var Ri=new TextDecoder,zi=class extends Mi{depth=0;leaf=!1;value;length;[Y.ENCODED];constructor(e,t,n,r){super(e,t,n,r),this.parent?this.depth=this.parent.depth+1:this.depth=r.initialDepth,[,,this.value,,this.length]=e}numBytes(){switch(this.ai){case J.ONE:return 1;case J.TWO:return 2;case J.FOUR:return 4;case J.EIGHT:return 8}return 0}};function Bi(e){return e instanceof zi}function Vi(e,t){return e===1/0?`Indefinite`:t?`${e} ${t}${e!==1&&e!==1n?`s`:``}`:String(e)}function Hi(e){return``.padStart(e,` `)}function Ui(e,t,n){let r=``;r+=Hi(e.depth*2);let i=Jn(e);r+=Z(i.subarray(0,1));let a=e.numBytes();a&&(r+=` `,r+=Z(i.subarray(1,a+1))),r=r.padEnd(t.minCol+1,` `),r+=`-- `,n!==void 0&&(r+=Hi(e.depth*2),n!==``&&(r+=`[${n}] `));let o=!1,[s]=e.children;switch(e.mt){case K.POS_INT:r+=`Unsigned: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case K.NEG_INT:r+=`Negative: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case K.BYTE_STRING:r+=`Bytes (Length: ${Vi(e.length)})`;break;case K.UTF8_STRING:r+=`UTF8 (Length: ${Vi(e.length)})`,e.length!==1/0&&(r+=`: ${JSON.stringify(s)}`);break;case K.ARRAY:r+=`Array (Length: ${Vi(e.value,`item`)})`;break;case K.MAP:r+=`Map (Length: ${Vi(e.value,`pair`)})`;break;case K.TAG:{r+=`Tag #${e.value}`;let n=e.children,[a]=n.contents.children,s=new X(n.tag,a);Xn(s,i);let c=s.comment(t,e.depth);c&&(r+=`: `,r+=c),o||=s.noChildren;break}case K.SIMPLE_FLOAT:s===Y.BREAK?r+=`BREAK`:e.ai>J.ONE?Object.is(s,-0)?r+=`Float: -0`:r+=`Float: ${s}`:(r+=`Simple: `,s instanceof Ei?r+=s.value:r+=s);break}if(!o)if(e.leaf){if(r+=`
|
|
5
|
+
`,i.length>a+1){let n=Hi((e.depth+1)*2),o=er(i);if(o?.length){o.sort((e,t)=>e[0]-t[0]||t[1]-e[1]);let s=0;for(let[c,l,u]of o)if(!(c<s)){if(s=c+l,u===`<<`){r+=Hi(t.minCol+1),r+=`--`,r+=n,r+=`<< `;let a=nr(i,c,c+l),o=er(a);if(o){let e=o.findIndex(([e,t,n])=>e===0&&t===l&&n===`<<`);e>=0&&o.splice(e,1)}r+=Li(a),r+=` >>
|
|
6
|
+
`,r+=Gi(a,{initialDepth:e.depth+1,minCol:t.minCol,noPrefixHex:!0});continue}else u===`'`&&(r+=Hi(t.minCol+1),r+=`--`,r+=n,r+=`'`,r+=Ri.decode(i.subarray(c,c+l)),r+=`'
|
|
7
|
+
`);if(c>a)for(let e=c;e<c+l;e+=8){let t=Math.min(e+8,c+l);r+=n,r+=Z(i.subarray(e,t)),r+=`
|
|
8
|
+
`}}}else for(let e=a+1;e<i.length;e+=8)r+=n,r+=Z(i.subarray(e,e+8)),r+=`
|
|
9
|
+
`}}else{r+=`
|
|
10
|
+
`;let n=0;for(let i of e.children){if(Bi(i)){let a=String(n);e.mt===K.MAP?a=n%2?`val ${(n-1)/2}`:`key ${n/2}`:e.mt===K.TAG&&(a=``),r+=Ui(i,t,a)}n++}}return r}var Wi={...Mi.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Gi(e,t){let n={...Wi,...t,ParentType:zi,saveOriginal:!0},r=new Oi(e,n),i,a;for(let e of r){if(a=Mi.create(e,i,n,r),e[2]===Y.BREAK)if(i?.isStreaming)i.left=1;else throw Error(`Unexpected BREAK`);if(!Bi(a)){let t=new zi(e,0,i,n);t.leaf=!0,t.children.push(a),Xn(t,r.toHere(e[3])),a=t}let t=(a.depth+1)*2,o=a.numBytes();for(o&&(t+=1,t+=o*2),n.minCol=Math.max(n.minCol,t),i&&i.push(a,r,e[3]),i=a;i?.done;)a=i,a.leaf||Xn(a,r.toHere(a.offset)),{parent:i}=i}t&&(t.minCol=n.minCol);let o=n.noPrefixHex?``:`0x${Z(r.toHere(0))}
|
|
11
|
+
`;return o+=Ui(a,n),o}var Ki=!cr();function qi(e){if(typeof e==`object`&&e){if(e.constructor!==Number)throw Error(`Expected number: ${e}`)}else if(typeof e!=`number`)throw Error(`Expected number: ${e}`)}function Ji(e){if(typeof e==`object`&&e){if(e.constructor!==String)throw Error(`Expected string: ${e}`)}else if(typeof e!=`string`)throw Error(`Expected string: ${e}`)}function Yi(e){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array: ${e}`)}function Xi(e){if(!Array.isArray(e))throw Error(`Expected Array: ${e}`)}Q(Map,(e,t,n)=>{let r=[...e.entries()].map(e=>[e[0],e[1],wi(e[0],n)]);if(n.rejectDuplicateKeys){let e=new Set;for(let[t,n,i]of r){let t=Z(i);if(e.has(t))throw Error(`Duplicate map key: 0x${t}`);e.add(t)}}n.sortKeys&&r.sort(n.sortKeys),bi(e,e.size,K.MAP,t,n);for(let[e,i,a]of r)t.write(a),Ci(i,t,n)});function Zi(e){return Ji(e.contents),new Date(e.contents)}Zi.comment=e=>{Ji(e.contents);let t=new Date(e.contents);return`(String ${e.tag===q.DATE_FULL?`Full `:``}Date) ${t.toISOString()}`},X.registerDecoder(q.DATE_STRING,Zi),X.registerDecoder(q.DATE_FULL,Zi);function Qi(e){return qi(e.contents),new Date(e.contents*1e3)}Qi.comment=e=>(qi(e.contents),`(Epoch Date) ${new Date(e.contents*1e3).toISOString()}`),X.registerDecoder(q.DATE_EPOCH,Qi);var $i=1e3*60*60*24;function ea(e){return qi(e.contents),new Date(e.contents*$i)}ea.comment=e=>(qi(e.contents),`(Epoch Date) ${new Date(e.contents*$i).toISOString()}`),X.registerDecoder(q.DATE_EPOCH_DAYS,ea),Q(Date,(e,t,n)=>{switch(n.dateTag){case q.DATE_EPOCH:return[n.dateTag,e.valueOf()/1e3];case q.DATE_STRING:return[n.dateTag,e.toISOString().replace(/\.000Z$/,`Z`)];case q.DATE_EPOCH_DAYS:return[n.dateTag,Math.floor(e.valueOf()/$i)];case q.DATE_FULL:return[n.dateTag,e.toISOString().split(`T`)[0]];default:throw Error(`Unsupported date tag: ${n.dateTag}`)}});function ta(e,t,n){if(Yi(t.contents),n.rejectBigInts)throw Error(`Decoding unwanted big integer: ${t}(h'${Z(t.contents)}')`);if(n.requirePreferred&&t.contents[0]===0)throw Error(`Decoding overly-large bigint: ${t.tag}(h'${Z(t.contents)})`);let r=t.contents.reduce((e,t)=>e<<8n|BigInt(t),0n);e&&(r=-1n-r);let i=r>=-(2**53-1)&&r<=2**53-1;if(n.requirePreferred&&i)throw Error(`Decoding bigint that could have been int: ${r}n`);return n.collapseBigInts&&i&&(r=Number(r)),n.boxed?Zn(r,t.contents):r}var na=ta.bind(null,!1),ra=ta.bind(null,!0);na.comment=(e,t)=>`(Positive BigInt) ${ta(!1,e,t)}n`,ra.comment=(e,t)=>`(Negative BigInt) ${ta(!0,e,t)}n`,X.registerDecoder(q.POS_BIGINT,na),X.registerDecoder(q.NEG_BIGINT,ra);function ia(e,t){return Yi(e.contents),e}ia.comment=(e,t,n)=>{Yi(e.contents);let r={...t,initialDepth:n+2,noPrefixHex:!0},i=Jn(e),a=2**((i[0]&31)-24)+1,o=i[a]&31,s=Z(i.subarray(a,++a));o>=24&&(s+=` `,s+=Z(i.subarray(a,a+2**(o-24)))),r.minCol=Math.max(r.minCol,(n+1)*2+s.length);let c=Gi(e.contents,r),l=`Embedded CBOR
|
|
12
|
+
`;return l+=`${``.padStart((n+1)*2,` `)}${s}`.padEnd(r.minCol+1,` `),l+=`-- Bytes (Length: ${e.contents.length})
|
|
13
|
+
`,l+=c,l},ia.noChildren=!0,X.registerDecoder(q.CBOR,ia),X.registerDecoder(q.URI,e=>(Ji(e.contents),new URL(e.contents)),`URI`),Q(URL,e=>[q.URI,e.toString()]),X.registerDecoder(q.BASE64URL,e=>(Ji(e.contents),sr(e.contents)),`Base64url-encoded`),X.registerDecoder(q.BASE64,e=>(Ji(e.contents),ar(e.contents)),`Base64-encoded`),X.registerDecoder(35,e=>(Ji(e.contents),new RegExp(e.contents)),`RegExp`),X.registerDecoder(21065,e=>{Ji(e.contents);let t=`^(?:${e.contents})$`;return new RegExp(t,`u`)},`I-RegExp`),X.registerDecoder(q.REGEXP,e=>{if(Xi(e.contents),e.contents.length<1||e.contents.length>2)throw Error(`Invalid RegExp Array: ${e.contents}`);return new RegExp(e.contents[0],e.contents[1])},`RegExp`),Q(RegExp,e=>[q.REGEXP,[e.source,e.flags]]),X.registerDecoder(64,e=>(Yi(e.contents),e.contents),`uint8 Typed Array`);function $(e,t,n){Yi(e.contents);let r=e.contents.length;if(r%t.BYTES_PER_ELEMENT!==0)throw Error(`Number of bytes must be divisible by ${t.BYTES_PER_ELEMENT}, got: ${r}`);r/=t.BYTES_PER_ELEMENT;let i=new t(r),a=new DataView(e.contents.buffer,e.contents.byteOffset,e.contents.byteLength),o=a[`get${t.name.replace(/Array/,``)}`].bind(a);for(let e=0;e<r;e++)i[e]=o(e*t.BYTES_PER_ELEMENT,n);return i}function aa(e,t,n,r,i){let a=i.forceEndian??Ki;if(pi(a?t:n,e,i),fi(r.byteLength,e,K.BYTE_STRING),Ki===a)e.write(new Uint8Array(r.buffer,r.byteOffset,r.byteLength));else{let t=e[`write${r.constructor.name.replace(/Array/,``)}`].bind(e);for(let e of r)t(e,a)}}X.registerDecoder(65,e=>$(e,Uint16Array,!1),`uint16, big endian, Typed Array`),X.registerDecoder(66,e=>$(e,Uint32Array,!1),`uint32, big endian, Typed Array`),X.registerDecoder(67,e=>$(e,BigUint64Array,!1),`uint64, big endian, Typed Array`),X.registerDecoder(68,e=>(Yi(e.contents),new Uint8ClampedArray(e.contents)),`uint8 Typed Array, clamped arithmetic`),Q(Uint8ClampedArray,e=>[68,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),X.registerDecoder(69,e=>$(e,Uint16Array,!0),`uint16, little endian, Typed Array`),Q(Uint16Array,(e,t,n)=>aa(t,69,65,e,n)),X.registerDecoder(70,e=>$(e,Uint32Array,!0),`uint32, little endian, Typed Array`),Q(Uint32Array,(e,t,n)=>aa(t,70,66,e,n)),X.registerDecoder(71,e=>$(e,BigUint64Array,!0),`uint64, little endian, Typed Array`),Q(BigUint64Array,(e,t,n)=>aa(t,71,67,e,n)),X.registerDecoder(72,e=>(Yi(e.contents),new Int8Array(e.contents)),`sint8 Typed Array`),Q(Int8Array,e=>[72,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),X.registerDecoder(73,e=>$(e,Int16Array,!1),`sint16, big endian, Typed Array`),X.registerDecoder(74,e=>$(e,Int32Array,!1),`sint32, big endian, Typed Array`),X.registerDecoder(75,e=>$(e,BigInt64Array,!1),`sint64, big endian, Typed Array`),X.registerDecoder(77,e=>$(e,Int16Array,!0),`sint16, little endian, Typed Array`),Q(Int16Array,(e,t,n)=>aa(t,77,73,e,n)),X.registerDecoder(78,e=>$(e,Int32Array,!0),`sint32, little endian, Typed Array`),Q(Int32Array,(e,t,n)=>aa(t,78,74,e,n)),X.registerDecoder(79,e=>$(e,BigInt64Array,!0),`sint64, little endian, Typed Array`),Q(BigInt64Array,(e,t,n)=>aa(t,79,75,e,n)),X.registerDecoder(81,e=>$(e,Float32Array,!1),`IEEE 754 binary32, big endian, Typed Array`),X.registerDecoder(82,e=>$(e,Float64Array,!1),`IEEE 754 binary64, big endian, Typed Array`),X.registerDecoder(85,e=>$(e,Float32Array,!0),`IEEE 754 binary32, little endian, Typed Array`),Q(Float32Array,(e,t,n)=>aa(t,85,81,e,n)),X.registerDecoder(86,e=>$(e,Float64Array,!0),`IEEE 754 binary64, big endian, Typed Array`),Q(Float64Array,(e,t,n)=>aa(t,86,82,e,n)),X.registerDecoder(q.SET,(e,t)=>{if(Xi(e.contents),t.sortKeys){let n=Mi.decodeToEncodeOpts(t),r=null;for(let i of e.contents){let e=[i,void 0,wi(i,n)];if(r&&t.sortKeys(r,e)>=0)throw Error(`Set items out of order in tag #${q.SET}`);r=e}}return new Set(e.contents)},`Set`),Q(Set,(e,t,n)=>{let r=[...e];if(n.sortKeys){let e=r.map(e=>[e,void 0,wi(e,n)]);e.sort(n.sortKeys),r=e.map(([e])=>e)}return[q.SET,r]}),X.registerDecoder(q.JSON,e=>(Ji(e.contents),JSON.parse(e.contents)),`JSON-encoded`);function oa(e){return Yi(e.contents),new Jr().decode(e.contents)}oa.comment=e=>{Yi(e.contents);let t=new Jr;return`(WTF8 string): ${JSON.stringify(t.decode(e.contents))}`},X.registerDecoder(q.WTF8,oa),X.registerDecoder(q.SELF_DESCRIBED,e=>e.contents,`Self-Described`),X.registerDecoder(q.INVALID_16,()=>{throw Error(`Tag always invalid: ${q.INVALID_16}`)},`Invalid`),X.registerDecoder(q.INVALID_32,()=>{throw Error(`Tag always invalid: ${q.INVALID_32}`)},`Invalid`),X.registerDecoder(q.INVALID_64,()=>{throw Error(`Tag always invalid: ${q.INVALID_64}`)},`Invalid`),X.registerDecoder(q.SYMBOL,e=>{let t=e.contents;if(Array.isArray(e.contents)){if(e.contents.length!==1)throw Error(`Expected Array of size 1: ${e.contents}`);[t]=e.contents}if(Ji(t),!t.length)throw Error(`Expected non-empty string: ${e.contents}`);return Symbol.for(t)},`Symbol`);function sa(e){throw Error(`Encoding ${e.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Q(ArrayBuffer,sa),Q(DataView,sa),typeof SharedArrayBuffer<`u`&&Q(SharedArrayBuffer,sa);function ca(e){return[NaN,e.valueOf()]}Q(Boolean,ca),Q(Number,ca),Q(String,ca),Q(BigInt,ca);function la(e){let t={...Mi.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Mi.dcborDecodeOptions):e.cde&&Object.assign(t,Mi.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,`rejectLongNumbers`))throw TypeError(`rejectLongNumbers has changed to requirePreferred`);return t.boxed&&(t.saveOriginal=!0),t}var ua=class{parent=void 0;ret=void 0;step(e,t,n){if(this.ret=Mi.create(e,this.parent,t,n),e[2]===Y.BREAK)if(this.parent?.isStreaming)this.parent.left=0;else throw Error(`Unexpected BREAK`);else this.parent&&this.parent.push(this.ret,n,e[3]);for(this.ret instanceof Mi&&(this.parent=this.ret);this.parent?.done;){this.ret=this.parent.convert(n);let e=this.parent.parent;e?.replaceLast(this.ret,this.parent,n),this.parent=e}}};function da(e,t={}){let n=la(t),r=new Oi(e,n),i=new ua;for(let e of r)i.step(e,n,r);return i.ret}var{cdeDecodeOptions:fa,dcborDecodeOptions:pa,defaultDecodeOptions:ma}=Mi,ha=class{constructor(e={}){this.options={id:j(),codec:`cbor`,timeout:10*1e3,share:``,chunkSize:16*1024,chunkCredit:4,topicMake:(e,t,n)=>`${e}/${t}/${n??`any`}`,topicMatch:e=>{let t=e.match(/^(.+)\/([^/]+)\/([^/]+)$/);return t?{name:t[1],operation:t[2],peerId:t[3]===`any`?void 0:t[3]}:null},...e}}},ga=class{static uint8ArrayToBase64(e){return Te.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)}static base64ToUint8Array(e){return new Uint8Array(Te.from(e,`base64`))}static stringify(e){return JSON.stringify(e,(e,t)=>t instanceof Uint8Array?{__Uint8Array:this.uint8ArrayToBase64(t)}:t)}static parse(e){return JSON.parse(e,(e,t)=>typeof t?.__Uint8Array==`string`?this.base64ToUint8Array(t.__Uint8Array):t)}},_a=class{constructor(e){this.format=e,this.types=new ur,this.tags=new Map;let t=64e3;this.types.registerEncoder(Te,e=>[t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),this.tags.set(t,e=>Te.from(e.contents))}encode(e){let t;if(this.format===`cbor`)try{t=wi(e,{types:this.types})}catch(e){throw Error(`failed to encode CBOR format`,{cause:e})}else if(this.format===`json`)try{t=ga.stringify(e)}catch(e){throw Error(`failed to encode JSON format`,{cause:e})}else throw Error(`invalid format "${this.format}"`);return t}decode(e){let t;if(this.format===`cbor`){if(!(e instanceof Uint8Array))throw Error(`failed to decode CBOR format (data type is not Uint8Array)`);if(e.byteLength===0)throw Error(`failed to decode CBOR format (data is empty)`);try{t=da(e,{tags:this.tags})}catch(e){throw Error(`failed to decode CBOR format`,{cause:e})}}else if(this.format===`json`){if(typeof e!=`string`)throw Error(`failed to decode JSON format (data type is not string)`);if(e.length===0)throw Error(`failed to decode JSON format (data is empty)`);try{t=ga.parse(e)}catch(e){throw Error(`failed to decode JSON format`,{cause:e})}}else throw Error(`invalid format "${this.format}"`);return t}},va=class extends ha{constructor(e={}){super(e),this.codec=new _a(this.options.codec)}},ya=class e extends va{static{this.encoder=new TextEncoder}static{this.decoder=new TextDecoder}str2buf(t){return e.encoder.encode(t)}buf2str(t){return e.decoder.decode(t)}arr2buf(e){let t;return t=e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t}buf2arr(e,t){let n,r=t;if(r===Te)n=Te.from(e.buffer,e.byteOffset,e.byteLength);else if(r===Uint8Array)n=e;else if(r===Int8Array)n=new Int8Array(e.buffer,e.byteOffset,e.byteLength);else throw Error(`invalid data type`);return n}},ba=e=>{let t=e.match(/^(\d+)\.(\d+)$/);if(t===null)throw Error(`invalid version string`);let n=parseInt(t[2],10);if(n>99)throw Error(`invalid version string: minor version exceeds 99`);return parseInt(t[1],10)*100+n},xa=ba(`1.4`),Sa=Wn(Vn(G(),Un()),kn(e=>!Array.isArray(e))),Ca=Wn(In(Wn(G(),jn(8192))),jn(8)),wa=class{constructor(e,t,n,r){this.type=e,this.id=t,this.sender=n,this.receiver=r,this.version=`MQTT+/1.4`}},Ta={version:Wn(G(),Nn(/^MQTT\+\/\d+\.\d+$/)),type:G(),id:G(),sender:W(G()),receiver:W(G())},Ea=class extends wa{constructor(e,t,n,r,i,a,o){super(`event-emission`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o}},Da=Hn({...Ta,type:zn(`event-emission`),name:G(),params:W(Wn(In(Un()),jn(64))),auth:W(Ca),meta:W(Sa)}),Oa=class extends wa{constructor(e,t,n,r,i,a,o){super(`service-call-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o}},ka=Hn({...Ta,type:zn(`service-call-request`),name:G(),params:W(Wn(In(Un()),jn(64))),auth:W(Ca),meta:W(Sa)}),Aa=class extends wa{constructor(e,t,n,r,i){super(`service-call-response`,e,r,i),this.result=t,this.error=n}},ja=Hn({...Ta,type:zn(`service-call-response`),result:W(Un()),error:W(G())}),Ma=class extends wa{constructor(e,t,n,r,i,a,o){super(`sink-push-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o}},Na=Hn({...Ta,type:zn(`sink-push-request`),name:G(),params:W(Wn(In(Un()),jn(64))),auth:W(Ca),meta:W(Sa)}),Pa=class extends wa{constructor(e,t,n,r,i,a){super(`sink-push-response`,e,r,i),this.name=t,this.error=n,this.credit=a}},Fa=Hn({...Ta,type:zn(`sink-push-response`),name:G(),error:W(G()),credit:W(Wn(Bn(),An(),Mn(1)))}),Ia=class extends wa{constructor(e,t,n,r,i,a,o){super(`sink-push-chunk`,e,a,o),this.name=t,this.chunk=n,this.error=r,this.final=i}},La=Hn({...Ta,type:zn(`sink-push-chunk`),name:G(),chunk:W(Rn(Uint8Array)),error:W(G()),final:W(Ln())}),Ra=class extends wa{constructor(e,t,n,r,i){super(`sink-push-credit`,e,r,i),this.name=t,this.credit=n}},za=Hn({...Ta,type:zn(`sink-push-credit`),name:G(),credit:Wn(Bn(),An(),Mn(1))}),Ba=class extends wa{constructor(e,t,n,r,i,a,o,s){super(`source-fetch-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.credit=s}},Va=Hn({...Ta,type:zn(`source-fetch-request`),name:G(),params:W(Wn(In(Un()),jn(64))),auth:W(Ca),meta:W(Sa),credit:W(Wn(Bn(),An(),Mn(1)))}),Ha=class extends wa{constructor(e,t,n,r,i,a){super(`source-fetch-response`,e,r,i),this.name=t,this.error=n,this.meta=a}},Ua=Hn({...Ta,type:zn(`source-fetch-response`),name:G(),error:W(G()),meta:W(Sa)}),Wa=class extends wa{constructor(e,t,n,r,i,a,o){super(`source-fetch-chunk`,e,a,o),this.name=t,this.chunk=n,this.error=r,this.final=i}},Ga=Hn({...Ta,type:zn(`source-fetch-chunk`),name:G(),chunk:W(Rn(Uint8Array)),error:W(G()),final:W(Ln())}),Ka=class extends wa{constructor(e,t,n,r,i){super(`source-fetch-credit`,e,r,i),this.name=t,this.credit=n}},qa=Hn({...Ta,type:zn(`source-fetch-credit`),name:G(),credit:Wn(Bn(),An(),Mn(0))}),Ja=class{makeEventEmission(e,t,n,r,i,a,o){return new Ea(e,t,n,r,i,a,o)}makeServiceCallRequest(e,t,n,r,i,a,o){return new Oa(e,t,n,r,i,a,o)}makeServiceCallResponse(e,t,n,r,i){return new Aa(e,t,n,r,i)}makeSinkPushRequest(e,t,n,r,i,a,o){return new Ma(e,t,n,r,i,a,o)}makeSinkPushResponse(e,t,n,r,i,a){return new Pa(e,t,n,r,i,a)}makeSinkPushChunk(e,t,n,r,i,a,o){return new Ia(e,t,n,r,i,a,o)}makeSinkPushCredit(e,t,n,r,i){return new Ra(e,t,n,r,i)}makeSourceFetchRequest(e,t,n,r,i,a,o,s){return new Ba(e,t,n,r,i,a,o,s)}makeSourceFetchResponse(e,t,n,r,i,a){return new Ha(e,t,n,r,i,a)}makeSourceFetchChunk(e,t,n,r,i,a,o){return new Wa(e,t,n,r,i,a,o)}makeSourceFetchCredit(e,t,n,r,i){return new Ka(e,t,n,r,i)}parse(e){if(typeof e!=`object`||!e)throw Error(`invalid argument: not an object`);if(typeof e.version!=`string`)throw Error(`invalid object: missing or invalid "version" field`);let t=e.version.match(/^MQTT\+\/(\d+\.\d+)$/);if((t===null?0:ba(t[1]))!==xa)throw Error(`protocol version mismatch (expected version 1.4, got version ${e.version})`);let n=(e,t,n)=>{let r=Gn(n,e);if(!r.success){let e=r.issues.map(e=>e.message).join(`; `);throw Error(`invalid ${t} object: ${e}`)}return r.output};if(typeof e.type!=`string`)throw Error(`invalid object: missing or invalid "type" field`);if(e.type===`event-emission`){let t=n(e,`EventEmission`,Da);return this.makeEventEmission(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta)}else if(e.type===`service-call-request`){let t=n(e,`ServiceCallRequest`,ka);return this.makeServiceCallRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta)}else if(e.type===`service-call-response`){let t=n(e,`ServiceCallResponse`,ja);return this.makeServiceCallResponse(t.id,t.result,t.error,t.sender,t.receiver)}else if(e.type===`sink-push-request`){let t=n(e,`SinkPushRequest`,Na);return this.makeSinkPushRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta)}else if(e.type===`sink-push-response`){let t=n(e,`SinkPushResponse`,Fa);return this.makeSinkPushResponse(t.id,t.name,t.error,t.sender,t.receiver,t.credit)}else if(e.type===`sink-push-chunk`){let t=n(e,`SinkPushChunk`,La);return this.makeSinkPushChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}else if(e.type===`sink-push-credit`){let t=n(e,`SinkPushCredit`,za);return this.makeSinkPushCredit(t.id,t.name,t.credit,t.sender,t.receiver)}else if(e.type===`source-fetch-request`){let t=n(e,`SourceFetchRequest`,Va);return this.makeSourceFetchRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.credit)}else if(e.type===`source-fetch-response`){let t=n(e,`SourceFetchResponse`,Ua);return this.makeSourceFetchResponse(t.id,t.name,t.error,t.sender,t.receiver,t.meta)}else if(e.type===`source-fetch-chunk`){let t=n(e,`SourceFetchChunk`,Ga);return this.makeSourceFetchChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}else if(e.type===`source-fetch-credit`){let t=n(e,`SourceFetchCredit`,qa);return this.makeSourceFetchCredit(t.id,t.name,t.credit,t.sender,t.receiver)}else throw Error(`invalid object: not of any known type`)}isRequest(e){return e instanceof Ea||e instanceof Oa||e instanceof Ba||e instanceof Ma}isResponse(e){return e instanceof Aa||e instanceof Pa||e instanceof Ia||e instanceof Ra||e instanceof Ha||e instanceof Wa||e instanceof Ka}},Ya=class extends ya{constructor(){super(...arguments),this.msg=new Ja}},Xa=class{constructor(e,t,n,r){this.timestamp=e,this.level=t,this.msg=n,this.data=r}async resolve(){if(this.msg instanceof Promise&&(this.msg=await this.msg.catch(()=>`<resolve-failed>`)),this.data)for(let e of Object.keys(this.data))this.data[e]instanceof Promise&&(this.data[e]=await this.data[e].catch(()=>`<resolve-failed>`))}toString(){let e=new Date(this.timestamp),t=`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)} ${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,n=this.msg instanceof Promise?`<unresolved>`:this.msg,r=``;if(this.data!==void 0){let e=this.data;r=` (${Object.keys(e).map(t=>{let n=e[t]instanceof Promise?`<unresolved>`:e[t];return`${t}: ${ga.stringify(n)}`}).join(`, `)})`}return`[${t}] ${this.level}: ${n}${r}`}},Za=class extends Ya{constructor(){super(...arguments),this._events=new _n.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,t,n){let r=new Xa(Date.now(),e,t,n);this.emitEvent(`log`,r)}error(e,t){let n=e;t!==void 0&&(n=Error(`${t}: ${e.message}`,{cause:e})),this.emitEvent(`error`,n),this.log(`error`,n.message)}},Qa=class extends Za{constructor(e,t={}){super(t),this.onRequest=new Map,this.onResponse=new Map,e===null&&(this.log(`info`,`establishing proxy MQTT client`),e=new Proxy({},{get(e,t,n){return t===`isFakeProxy`?!0:typeof t==`string`&&[`on`,`off`,`once`].includes(t)?()=>{}:()=>{throw Error(`Underlying MQTT operation "${String(t)}" 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=(e,t,n)=>{let r;if(this.options.codec===`json`)r=t.toString();else if(this.options.codec===`cbor`)r=we.isBuffer(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t;else throw Error(`invalid codec configured`);this._onMessage(e,r,n)},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,t,n,r){return{destroy:async()=>{if(!this.onRequest.has(r))throw Error(`destroy: ${t} "${n}" not registered`);await e.unroll(!1)?.catch(e=>{let r=V(e,`destroy: ${t} "${n}" failed to cleanup`);throw this.error(r),r})}}}async subscribeTopic(e,t={}){return this.log(`info`,`subscribing to MQTT topic "${e}"`),new Promise((n,r)=>{this.mqtt.subscribe(e,{qos:2,...t},(t,i)=>{t?(this.error(t,`subscribing to MQTT topic "${e}" failed`),r(t)):n()})})}async unsubscribeTopic(e){return this.log(`info`,`unsubscribing from MQTT topic "${e}"`),new Promise((t,n)=>{this.mqtt.unsubscribe(e,(r,i)=>{r?(this.error(r,`unsubscribing from MQTT topic "${e}" failed`),n(r)):t()})})}async publishToTopic(e,t,n={}){typeof t==`string`?this.log(`info`,`publishing to MQTT topic "${e}" (type: string, length: ${t.length} chars)`):this.log(`info`,`publishing to MQTT topic "${e}" (type: buffer, length: ${t.byteLength} bytes)`);let r=new Ee((e,n)=>{let r;try{let e=this.codec.decode(t);r=this.msg.parse(e)}catch(e){return n(e)}e(r)});return this.log(`debug`,`publishing to MQTT topic "${e}"`,{message:r}),new Promise((r,i)=>{let a=typeof t==`string`?t:we.from(t.buffer,t.byteOffset,t.byteLength);this.mqtt.publish(e,a,n,t=>{t?(this.error(t,`publishing to MQTT topic "${e}" failed`),i(t)):r()})})}_onMessage(e,t,n){let r=this.options.topicMatch(e);if(r===null)return;typeof t==`string`?this.log(`info`,`received from MQTT topic "${e}" (type: string, length: ${t.length} chars)`):this.log(`info`,`received from MQTT topic "${e}" (type: buffer, length: ${t.byteLength} bytes)`);let i;try{i=this.codec.decode(t)}catch(e){this.error(V(e,`failed to parse message into object`));return}let a;try{a=this.msg.parse(i)}catch(e){this.error(V(e,`failed to parse object into typed message object`));return}if(this.log(`debug`,`received from MQTT topic "${e}"`,{message:a}),this.msg.isRequest(a)){let t=this.onRequest.get(`${a.type}:${a.name}`);t!==void 0&&Promise.resolve().then(()=>t(a,r.name)).catch(t=>{this.error(V(t,`dispatching request message from MQTT topic "${e}" failed`))})}else if(this.msg.isResponse(a)){let t=this.onResponse.get(`${a.type}:${a.id}`);t!==void 0&&Promise.resolve().then(()=>t(a,r.name)).catch(t=>{this.error(V(t,`dispatching response message from MQTT topic "${e}" failed`))})}}},$a=class{constructor(e,t,n=30*1e3){this.subscribeFn=e,this.unsubscribeFn=t,this.lingerMs=n,this.counts=new Map,this.pending=new Map,this.lingers=new Map,this.unsubbing=new Map}incrementCount(e){let t=this.counts.get(e)??0;return this.counts.set(e,t+1),t}decrementCount(e){let t=this.counts.get(e);if(t!==void 0)return t<=1?(this.counts.delete(e),0):(this.counts.set(e,t-1),t-1)}async subscribe(e,t={qos:2}){let n=this.incrementCount(e),r=this.lingers.get(e);if(r){clearTimeout(r),this.lingers.delete(e);return}if(n===0){let n,r,i=new Promise((e,t)=>{n=e,r=t});i.catch(()=>{}),this.pending.set(e,i);let a=this.unsubbing.get(e);return a&&await a,this.subscribeFn(e,t).then(()=>{this.pending.delete(e),n()}).catch(t=>{throw this.pending.delete(e),this.decrementCount(e),r(t),t})}else{let t=this.pending.get(e);if(t)return t.catch(t=>{throw this.decrementCount(e),t})}}async unsubscribe(e){if(this.decrementCount(e)===0)if(this.lingerMs>0){let t=setTimeout(()=>{this.lingers.delete(e);let t=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,t)},this.lingerMs);this.lingers.set(e,t)}else{let t=this.unsubscribeFn(e).catch(()=>{}).finally(()=>{this.unsubbing.delete(e)});this.unsubbing.set(e,t),await t}}async flush(){let e=new Set([...this.counts.keys(),...this.lingers.keys(),...this.pending.keys(),...this.unsubbing.keys()]);for(let e of this.lingers.values())clearTimeout(e);this.lingers.clear(),this.counts.clear(),await Promise.allSettled([...this.pending.values(),...this.unsubbing.values()]),await Promise.allSettled([...e].map(e=>this.unsubscribeFn(e).catch(()=>{}))),this.pending.clear(),this.unsubbing.clear()}},eo=class extends Qa{constructor(){super(...arguments),this.subscriptions=new $a((e,t)=>this.subscribeTopic(e,t),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,t,n={}){await Re(`subscribe to MQTT topic "${t}"`,e,()=>this.subscriptions.subscribe(t,{qos:2,...n})),e.roll(()=>this.subscriptions.unsubscribe(t))}async destroy(){await this.subscriptions.flush(),await super.destroy()}},to=class extends eo{constructor(){super(...arguments),this.timers=new Map}async destroy(){for(let e of this.timers.values())clearTimeout(e);this.timers.clear(),await super.destroy()}timerRefresh(e,t){let n=this.timers.get(e);n!==void 0&&clearTimeout(n),this.timers.set(e,setTimeout(async()=>{this.timers.delete(e);try{await t()}catch(t){this.error(V(t),`timer "${e}" failed`)}},this.options.timeout))}timerClear(e){let t=this.timers.get(e);t!==void 0&&(clearTimeout(t),this.timers.delete(e))}},no=class extends to{constructor(){super(...arguments),this._meta=new Map}meta(...e){let[t,n]=e;if(e.length===0)return Object.fromEntries(this._meta);if(e.length===1)return this._meta.get(t);n==null?this._meta.delete(t):this._meta.set(t,n)}metaStore(e){let t=e===void 0||Object.keys(e).length===0;if(!(this._meta.size===0&&t))return this._meta.size>0&&t?Object.fromEntries(this._meta):this._meta.size===0&&!t?e:{...Object.fromEntries(this._meta),...e}}},ro=new TextEncoder,io=class extends no{constructor(){super(...arguments),this._credential=null,this._tokens=new Set}credential(e){if(e.length===0)throw Error(`credential must not be empty`);this._credential=pn(mn,ro.encode(e),ro.encode(`mqtt-plus`),6e5,32)}async issue(e){if(this._credential===null)throw Error(`credential has to be provided before issuing tokens`);if(e.roles.length===0)throw Error(`payload.roles must be a non-empty array`);if(e.roles.length>64)throw Error(`payload.roles must not exceed 64 roles`);let t=new nn(e);return t.setProtectedHeader({alg:`HS256`,typ:`JWT`}),await t.sign(this._credential)}authenticate(e,t){if(e===void 0){let e=Array.from(this._tokens).filter(e=>e.length<=8192).slice(0,8);return e.length>0?e:void 0}else if(t===!0)this._tokens.delete(e);else{if(e.length>8192)throw Error(`token must not exceed 8192 characters`);if(!this._tokens.has(e)&&this._tokens.size>=8)throw Error(`at most 8 tokens can be authenticated at once`);this._tokens.add(e)}}async validateToken(e){if(this._credential===null)throw Error(`credential has to be provided before validating tokens`);return(await sn(e,this._credential).catch(()=>null))?.payload??null}async authenticated(e,t,n){let r=!1,i,a;if(typeof n==`string`?(i=`require`,a=[n]):(i=n.mode,a=n.roles),t!==void 0)for(let n of t.slice(0,8)){if(n.length>8192)continue;let t=await this.validateToken(n);if(t!==null&&!(t.id&&t.id!==e)&&Array.isArray(t.roles)&&!(t.roles.length>64)){for(let e of a)if(t.roles.includes(e)){r=!0;break}if(r)break}}return!r&&i===`optional`&&(r=!0),r}},ao=class extends io{async event(e,...t){let n,r,i={},a=this.options.share,o;typeof e==`object`&&e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]);let s=new Fe;if(this.onRequest.has(`event-emission:${n}`))throw Error(`event: event "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`event-emission`),u=this.options.topicMake(n,`event-emission`,this.options.id);return this.onRequest.set(`event-emission:${n}`,async(e,t)=>{let i=e.sender;if(i===void 0||i===``)throw Error(`invalid request: missing sender`);let a=e.params??[],s={sender:i};e.receiver&&(s.receiver=e.receiver),e.meta&&(s.meta=e.meta);try{if(t!==e.name)throw Error(`event name mismatch (topic: "${t}", payload: "${e.name}")`);if(o&&(s.authenticated=await this.authenticated(i,e.auth,o)),s.authenticated!==void 0&&!s.authenticated)throw Error(`event "${n}" failed authentication`);await r(...a,s)}catch(e){let t=V(e);this.error(t,`handler for event "${n}" failed`)}}),s.roll(()=>{this.onRequest.delete(`event-emission:${n}`)}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`event`,n,`event-emission:${n}`)}emit(e,...t){let n,r,i,a={},o,s;typeof e==`object`&&e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta,s=e.dry):(n=e,r=t);let c=j(),l=this.authenticate(),u=this.metaStore(o),d=this.msg.makeEventEmission(c,n,r,this.options.id,i,l,u),f=this.codec.encode(d),p=this.options.topicMake(n,`event-emission`,i);if(s)return{topic:p,payload:f,options:{qos:2,...a}};this.publishToTopic(p,f,{qos:2,...a}).catch(e=>{this.error(e,`emitting event "${n}" failed`)})}},oo=class extends ao{async service(e,...t){let n,r,i={},a=this.options.share,o;typeof e==`object`&&e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]);let s=new Fe;if(this.onRequest.has(`service-call-request:${n}`))throw Error(`service: service "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`service-call-request`),u=this.options.topicMake(n,`service-call-request`,this.options.id);return this.onRequest.set(`service-call-request:${n}`,async(e,t)=>{let a=e.id,s=e.sender;if(s===void 0||s===``)throw Error(`invalid request: missing sender`);let c=e.params??[],l={sender:s};e.receiver&&(l.receiver=e.receiver),e.meta&&(l.meta=e.meta);try{if(t!==e.name)throw Error(`service name mismatch (topic: "${t}", payload: "${e.name}")`);if(o&&(l.authenticated=await this.authenticated(s,e.auth,o)),l.authenticated!==void 0&&!l.authenticated)throw Error(`service "${n}" failed authentication`);let u=await r(...c,l),d=this.msg.makeServiceCallResponse(a,u,void 0,this.options.id,s),f=this.codec.encode(d),p=this.options.topicMake(n,`service-call-response`,s);await this.publishToTopic(p,f,{qos:i.qos??2})}catch(e){let t=V(e);this.error(t,`handler for service "${n}" failed`);let r=this.msg.makeServiceCallResponse(a,void 0,t.message,this.options.id,s);try{let e=this.codec.encode(r),t=this.options.topicMake(n,`service-call-response`,s);await this.publishToTopic(t,e,{qos:i.qos??2})}catch(e){this.error(V(e),`sending error response for service "${n}" failed`)}}}),s.roll(()=>{this.onRequest.delete(`service-call-request:${n}`)}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`service`,n,`service-call-request:${n}`)}async call(e,...t){let n,r,i,a={},o;typeof e==`object`&&e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new Fe,c=j();for(;this.onResponse.has(`service-call-response:${c}`);)c=j();let l=this.options.topicMake(n,`service-call-response`,this.options.id);await this.subscribeTopicAndSpool(s,l,{qos:a.qos??2});let u=`service-call:${c}`,d,f=new Promise((e,t)=>{d=t,this.timerRefresh(u,async()=>{await s.unroll(),t(Error(`communication timeout`))}),s.roll(()=>{this.timerClear(u)}),this.onResponse.set(`service-call-response:${c}`,async n=>{await s.unroll(),n.error===void 0?e(n.result):t(Error(n.error))}),s.roll(()=>{this.onResponse.delete(`service-call-response:${c}`)})}),p=this.authenticate(),m=this.metaStore(o),h=this.msg.makeServiceCallRequest(c,n,r,this.options.id,i,p,m),g=this.codec.encode(h),_=this.options.topicMake(n,`service-call-request`,i);try{await Re(`publish service request as MQTT message to topic "${_}"`,s,()=>this.publishToTopic(_,g,{qos:2,...a}))}catch(e){return d(e),f}return f}},so=class extends oo{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map}async destroy(){for(let e of this.sourceControllers.values())e.abort(Error(`source destroyed`));this.sourceControllers.clear();for(let e of this.sourceCreditGates.values())e.abort();this.sourceCreditGates.clear(),await super.destroy()}async source(e,...t){let n,r,i={},a=this.options.share,o;typeof e==`object`&&e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]);let s=new Fe;if(this.onRequest.has(`source-fetch-request:${n}`))throw Error(`source: source "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`source-fetch-request`),u=this.options.topicMake(n,`source-fetch-request`,this.options.id);return this.onRequest.set(`source-fetch-request:${n}`,async(e,t)=>{let a=e.id,s=e.params??[],c=e.sender;if(c===void 0||c===``)throw Error(`invalid request: missing sender`);let l=e.receiver,u={sender:c};l&&(u.receiver=l),e.meta&&(u.meta=e.meta);let d=this.options.topicMake(n,`source-fetch-response`,c),f=async e=>{let t=this.metaStore(u.meta),r=this.msg.makeSourceFetchResponse(a,n,e,this.options.id,c,t),o=this.codec.encode(r);await this.publishToTopic(d,o,{qos:i.qos??2})},p=new Fe;p.roll(()=>{this.onResponse.delete(`source-fetch-credit:${a}`),this.sourceControllers.delete(a)});let m=new AbortController;this.sourceControllers.set(a,m);let h=m.signal;h.addEventListener(`abort`,()=>{u.stream instanceof A.Readable&&!u.stream.destroyed&&u.stream.destroy(V(h.reason))},{once:!0});let g=`source-fetch-send:${a}`,_=()=>this.timerRefresh(g,()=>{let e=Error(`source fetch "${n}" timed out`);m.abort(e);let t=this.sourceCreditGates.get(a);t!==void 0&&(t.abort(),this.sourceCreditGates.delete(a)),p.unroll()}),v=()=>this.timerClear(g);_(),p.roll(()=>{v()});let y=async(e,t,r)=>{_();let o=this.msg.makeSourceFetchChunk(a,n,e,t,r,this.options.id,c),s=this.codec.encode(o);await this.publishToTopic(d,s,{qos:i.qos??2})},b=!1,x,S=!1;try{if(t!==e.name)throw Error(`source name mismatch (topic: "${t}", payload: "${e.name}")`);if(o&&(u.authenticated=await this.authenticated(c,e.auth,o)),u.authenticated!==void 0&&!u.authenticated)throw Error(`source "${n}" failed authentication`);let i=e.credit;if(x=i!==void 0&&i>0?new De(i):void 0,x&&(this.sourceCreditGates.set(a,x),p.roll(()=>{x.abort(),this.sourceCreditGates.delete(a)})),this.onResponse.set(`source-fetch-credit:${a}`,e=>{if(e.credit===0){S=!0,m.abort(Error(`source fetch "${n}" cancelled by fetcher`));return}x&&(x.replenish(e.credit),_())}),await r(...s,u),!(u.stream instanceof A.Readable)&&!(u.buffer instanceof Promise))throw Error(`handler did not provide data via info.stream or info.buffer fields`);if(u.stream instanceof A.Readable&&u.buffer instanceof Promise)throw Error(`handler has set both info.stream and info.buffer fields`);await f(),b=!0,u.stream instanceof A.Readable?await Ne(u.stream,this.options.chunkSize,y,x,h):u.buffer instanceof Promise&&await Me(await u.buffer,this.options.chunkSize,y,x,h)}catch(e){let t=V(e,`handler for source "${n}" failed`);m.abort(t),S||(this.error(t),b?await y(void 0,t.message,!0).catch(()=>{}):await f(t.message).catch(()=>{}))}finally{await p.unroll()}}),s.roll(()=>{this.onRequest.delete(`source-fetch-request:${n}`)}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`source`,n,`source-fetch-request:${n}`)}async fetch(e,...t){let n,r,i,a={},o;typeof e==`object`&&e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new Fe,c=j();for(;this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`);)c=j();let l=this.options.topicMake(n,`source-fetch-response`,this.options.id);await this.subscribeTopicAndSpool(s,l,{qos:a.qos??2});let u=this.options.chunkCredit,d=0,f=u,p,m=!1,h=`source-fetch:${c}`,g,_=()=>{this.timerRefresh(h,()=>{g?.destroy(Error(`communication timeout`)),s.unroll()})};s.roll(()=>{this.timerClear(h)}),g=new A.Readable({highWaterMark:u>0?u*this.options.chunkSize:16*1024,read:e=>{if(u<=0||!this.onResponse.has(`source-fetch-response:${c}`))return;let t=p??i;if(!t)return;let r=Math.max(0,d+u-f);if(r>0){f+=r;let e=this.msg.makeSourceFetchCredit(c,n,r,this.options.id,t),i=this.codec.encode(e),o=this.options.topicMake(n,`source-fetch-request`,t);this.publishToTopic(o,i,{qos:a.qos??2}).catch(e=>{this.error(e,`sending credit for fetch "${n}" failed`)}),_()}}});let v=je(g),y,b=new Promise(e=>{y=e});s.roll(()=>{y(void 0)}),_();let x=!1,S=()=>{if(!x&&!m){x=!0;let e=p??i;if(e){let t=this.msg.makeSourceFetchCredit(c,n,0,this.options.id,e),r=this.codec.encode(t),i=this.options.topicMake(n,`source-fetch-request`,e);this.publishToTopic(i,r,{qos:a.qos??2}).catch(()=>{})}}s.unroll()};g.once(`close`,S),g.once(`error`,S),this.onResponse.set(`source-fetch-response:${c}`,e=>{if(!m){if(e.name!==n){m=!0,g.destroy(Error(`source name mismatch (expected "${n}", got "${e.name}")`)),s.unroll();return}e.sender&&(p=e.sender),e.error?(m=!0,g.destroy(Error(e.error)),s.unroll()):(y(e.meta),_())}}),this.onResponse.set(`source-fetch-chunk:${c}`,e=>{m||(e.error?(m=!0,g.destroy(Error(e.error)),s.unroll()):(_(),e.chunk!==void 0&&(d++,g.push(e.chunk)),e.final&&(m=!0,g.push(null),s.unroll())))}),s.roll(()=>{this.onResponse.delete(`source-fetch-response:${c}`),this.onResponse.delete(`source-fetch-chunk:${c}`)});let C=this.authenticate(),w=this.metaStore(o),ee=u>0?u:void 0,te=this.msg.makeSourceFetchRequest(c,n,r,this.options.id,i,C,w,ee),ne=this.codec.encode(te),re=this.options.topicMake(n,`source-fetch-request`,i);Re(`publish fetch request as MQTT message to topic "${re}"`,()=>this.publishToTopic(re,ne,{qos:2,...a})).catch(e=>{g.destroy(V(e))});let ie={stream:g,buffer:v,meta:b};return Pe(ie,`stream`,`buffer`),ie}},co=class extends so{constructor(){super(...arguments),this.pushStreams=new Map,this.pushSpools=new Map}async destroy(){for(let e of this.pushStreams.values())e.destroy(Error(`sink destroyed`));this.pushStreams.clear();for(let e of this.pushSpools.values())await e.unroll();this.pushSpools.clear(),await super.destroy()}async sink(e,...t){let n,r,i={},a=this.options.share,o;typeof e==`object`&&e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]);let s=new Fe;if(this.onRequest.has(`sink-push-request:${n}`))throw Error(`sink: sink "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`sink-push-request`),u=this.options.topicMake(n,`sink-push-request`,this.options.id);return this.onRequest.set(`sink-push-request:${n}`,async(e,t)=>{let a=e.id,s=e.params??[],c=e.sender;if(c===void 0||c===``)throw Error(`invalid request: missing sender`);let l=e.receiver,u=this.options.topicMake(n,`sink-push-response`,c),d=this.options.chunkCredit,f=async(e,t=!1)=>{let r=e===void 0&&t&&d>0?d:void 0,o=this.msg.makeSinkPushResponse(a,n,e,this.options.id,c,r),s=this.codec.encode(o);await this.publishToTopic(u,s,{qos:i.qos??2})},p=new Fe;this.pushSpools.set(a,p),p.roll(()=>{this.pushSpools.delete(a)});try{if(t!==e.name)throw Error(`sink name mismatch (topic: "${t}", payload: "${e.name}")`);let m;if(o&&(m=await this.authenticated(c,e.auth,o)),m!==void 0&&!m)throw Error(`sink "${n}" failed authentication`);let h=d>0?{chunksReceived:0,creditGranted:d}:void 0,g=`sink-push-recv:${a}`,_=()=>this.timerRefresh(g,()=>{if(b)return;let e=this.pushStreams.get(a);e!==void 0&&e.destroy(Error(`push stream timeout`)),this.pushSpools.get(a)?.unroll()}),v=()=>this.timerClear(g),y=new A.Readable({highWaterMark:d>0?d*this.options.chunkSize:16*1024,read:e=>{if(!h||!this.pushSpools.has(a))return;let t=Math.max(0,h.chunksReceived+d-h.creditGranted);if(t>0){h.creditGranted+=t;let e=this.msg.makeSinkPushCredit(a,n,t,this.options.id,c),r=this.codec.encode(e);this.publishToTopic(u,r,{qos:i.qos??2}).catch(e=>{this.error(e,`sending credit for push "${n}" failed`)}),_()}}});this.pushStreams.set(a,y),p.roll(()=>{this.pushStreams.delete(a)}),y.once(`error`,()=>{});let b=!1;this.onResponse.set(`sink-push-chunk:${a}`,async e=>{b||(e.error===void 0?(_(),e.chunk!==void 0&&(h&&h.chunksReceived++,y.push(e.chunk)),e.final&&(b=!0,v(),y.push(null))):(b=!0,v(),y.destroy(Error(e.error))))}),p.roll(()=>{this.onResponse.delete(`sink-push-chunk:${a}`)}),_(),p.roll(()=>{v()});let x=je(y),S=new Promise((e,t)=>{y.once(`end`,()=>{e()}),y.once(`error`,e=>{t(e)})});S.catch(()=>{});let C={sender:c,stream:y,buffer:x};l&&(C.receiver=l),m!==void 0&&(C.authenticated=m),e.meta&&(C.meta=e.meta),Pe(C,`stream`,`buffer`),await f(void 0,!0),await r(...s,C),y.readableFlowing!==!0&&!y.destroyed&&y.resume(),await S;try{await f()}catch(e){this.error(V(e),`sending terminal response for sink "${n}" failed`)}}catch(e){let t=V(e,`handler for sink "${n}" failed`);this.error(t),await f(t.message).catch(()=>{})}finally{let e=this.pushStreams.get(a);e!==void 0&&!e.destroyed&&e.destroy(),await p.unroll()}}),s.roll(()=>{this.onRequest.delete(`sink-push-request:${n}`)}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`sink`,n,`sink-push-request:${n}`)}async push(e,...t){let n,r,i,a,o={},s;if(typeof e==`object`&&e?(n=e.name,r=e.data,i=e.params,a=e.receiver,o=e.options??{},s=e.meta):(n=e,r=t[0],i=t.slice(1)),!(r instanceof A.Readable)&&!(r instanceof Uint8Array))throw Error(`invalid data type: expected Readable or Uint8Array`);let c=new Fe,l=j();for(;this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`);)l=j();let u=this.options.topicMake(n,`sink-push-response`,this.options.id);await this.subscribeTopicAndSpool(c,u,{qos:o.qos??2});let d=new AbortController,f=d.signal;if(r instanceof A.Readable){let e=r;f.addEventListener(`abort`,()=>{e.destroyed||e.destroy(V(f.reason))},{once:!0})}let p=`sink-push-send:${l}`,m=()=>this.timerRefresh(p,()=>{let e=Error(`push to sink "${n}" timed out`);d.abort(e),c.unroll()});c.roll(()=>{this.timerClear(p)}),m();let h,g,_=!1,v=!1,y=!1,b=!1,x,S,C=new Promise((e,t)=>{x=e,S=t});C.catch(()=>{});try{if(await new Promise((e,t)=>{let r=()=>{t(f.reason)};f.addEventListener(`abort`,r,{once:!0}),c.roll(()=>{f.removeEventListener(`abort`,r)}),this.onResponse.set(`sink-push-response:${l}`,n=>{n.error?t(Error(n.error)):(n.sender&&(a=n.sender),h=n.credit,v=!0,e())}),c.roll(()=>{this.onResponse.delete(`sink-push-response:${l}`)});let u=this.authenticate(),d=this.metaStore(s),p=this.msg.makeSinkPushRequest(l,n,i,this.options.id,a,u,d),m=this.codec.encode(p),g=this.options.topicMake(n,`sink-push-request`,a);Re(`publish push request as MQTT message to topic "${g}"`,c,()=>this.publishToTopic(g,m,{qos:2,...o})).catch(e=>{t(e)})}),this.onResponse.set(`sink-push-response:${l}`,e=>{e.error?(_=!0,S(Error(e.error)),d.abort(Error(e.error))):v&&!y&&(y=!0,x())}),h!==void 0&&h>0&&(g=new De(h)),g){let e=g;c.roll(()=>{e.abort()}),this.onResponse.set(`sink-push-credit:${l}`,t=>{e.replenish(t.credit),m()}),c.roll(()=>{this.onResponse.delete(`sink-push-credit:${l}`)})}let e=this.options.topicMake(n,`sink-push-request`,a),t=async(t,r,i)=>{m();let s=this.msg.makeSinkPushChunk(l,n,t,r,i,this.options.id,a),c=this.codec.encode(s);await this.publishToTopic(e,c,{qos:2,...o}),r===void 0&&i&&(b=!0)};r instanceof A.Readable?await Ne(r,this.options.chunkSize,t,g,f):r instanceof Uint8Array&&await Me(r,this.options.chunkSize,t,g,f),y||await new Promise((e,t)=>{let n=()=>{t(f.reason)};f.addEventListener(`abort`,n,{once:!0}),C.then(e,t).finally(()=>{f.removeEventListener(`abort`,n)})})}catch(e){let t=V(e);if(d.abort(t),v&&!_&&!b){let e=this.options.topicMake(n,`sink-push-request`,a),r=this.msg.makeSinkPushChunk(l,n,void 0,t.message,!0,this.options.id,a),i=this.codec.encode(r);await this.publishToTopic(e,i,{qos:2,...o}).catch(()=>{})}throw e}finally{await c.unroll()}}};return class extends co{}});
|