mqtt-plus 1.4.19 → 1.4.21

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.
@@ -1,13 +1,13 @@
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,T=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)})),E=t(((e,t)=>{t.exports=n().EventEmitter})),D=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);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),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(ye(e,s)||e&&ye(e.buffer,s)||c!==void 0&&(ye(e,c)||e&&ye(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(ye(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`||be(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(ye(e,o)&&(e=d.from(e,e.offset,e.byteLength)),ye(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)},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(ye(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)||ye(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 he(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ve(e).length;default:if(i)return r?-1:he(e).length;t=(``+t).toLowerCase(),i=!0}}d.byteLength=w;function T(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 N(this,t,n);case`utf8`:case`utf-8`:return ie(this,t,n);case`ascii`:return ae(this,t,n);case`latin1`:case`binary`:return oe(this,t,n);case`base64`:return re(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return P(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function E(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)E(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)E(this,t,t+3),E(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)E(this,t,t+7),E(this,t+1,t+6),E(this,t+2,t+5),E(this,t+3,t+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ie(this,0,e):T.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(ye(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)};function D(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,be(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:O(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):O(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function O(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 D(this,e,t,n,!0)},d.prototype.lastIndexOf=function(e,t,n){return D(this,e,t,n,!1)};function ee(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(be(r))return o;e[n+o]=r}return o}function k(e,t,n,r){return U(he(t,e.length-n),e,n,r)}function te(e,t,n,r){return U(ge(t),e,n,r)}function A(e,t,n,r){return U(ve(t),e,n,r)}function ne(e,t,n,r){return U(_e(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 ee(this,e,t,n);case`utf8`:case`utf-8`:return k(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return te(this,e,t,n);case`base64`:return A(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ne(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 re(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ie(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 M(r)}let j=4096;function M(e){let t=e.length;if(t<=j)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=j));return n}function ae(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 oe(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 N(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+=xe[e[r]];return i}function P(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 F(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||F(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||F(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||F(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||F(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||F(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||F(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||F(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=W(function(e){e>>>=0,H(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&fe(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=W(function(e){e>>>=0,H(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&fe(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||F(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||F(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||F(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||F(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||F(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||F(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||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=W(function(e){e>>>=0,H(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&fe(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=W(function(e){e>>>=0,H(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&fe(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||F(e,4,this.length),r.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||F(e,4,this.length),r.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||F(e,8,this.length),r.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||F(e,8,this.length),r.read(this,e,!1,52,8)};function I(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;I(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;I(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||I(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||I(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||I(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||I(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||I(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 se(e,t,n,r,i){de(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 L(e,t,n,r,i){de(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=W(function(e,t=0){return se(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=W(function(e,t=0){return L(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);I(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);I(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||I(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||I(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||I(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||I(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||I(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=W(function(e,t=0){return se(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=W(function(e,t=0){return L(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ce(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function R(e,t,n,i,a){return t=+t,n>>>=0,a||ce(e,t,n,4),r.write(e,t,n,i,23,4),n+4}d.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)};function z(e,t,n,i,a){return t=+t,n>>>=0,a||ce(e,t,n,8),r.write(e,t,n,i,52,8),n+8}d.prototype.writeDoubleLE=function(e,t,n){return z(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return z(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 le={};function B(e,t,n){le[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}`}}}B(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),B(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),B(`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=V(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function V(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function ue(e,t,n){H(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&fe(t,e.length-(n+1))}function de(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 le.ERR_OUT_OF_RANGE(`value`,i,e)}ue(r,i,a)}function H(e,t){if(typeof e!=`number`)throw new le.ERR_INVALID_ARG_TYPE(t,`number`,e)}function fe(e,t,n){throw Math.floor(e)===e?t<0?new le.ERR_BUFFER_OUT_OF_BOUNDS:new le.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(H(e,n),new le.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let pe=/[^+/0-9A-Za-z-_]/g;function me(e){if(e=e.split(`=`)[0],e=e.trim().replace(pe,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function he(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 ge(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function _e(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 ve(e){return t.toByteArray(me(e))}function U(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 ye(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function be(e){return e!==e}let xe=(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 W(e){return typeof BigInt>`u`?Se:e}function Se(){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})),O=t(((e,t)=>{t.exports={}})),ee=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=D().Buffer,d=O().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}()})),k=t(((e,t)=>{T();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}})),te=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})),A=t(((e,t)=>{var n=te().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}})),ne=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`}})),re=t(((e,t)=>{a(),T(),t.exports=M;function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H(t,e)}}var o;M.WritableState=re;var s={deprecate:ne()},c=E(),l=D().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=k(),m=A().getHighWaterMark,h=te().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,O=p.errorOrDestroy;r()(M,c);function ee(){}function re(e,t,r){o||=ie(),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){L(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)}re.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(re.prototype,`buffer`,{get:s.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var j;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(j=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(e){return j.call(this,e)?!0:this===M?e&&e._writableState instanceof re:!1}})):j=function(e){return e instanceof this};function M(e){o||=ie();var t=this instanceof o;if(!t&&!j.call(M,this))return new M(e);this._writableState=new re(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)}M.prototype.pipe=function(){O(this,new y)};function ae(e,t){var n=new S;O(e,n),w.nextTick(t,n)}function oe(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?(O(e,i),w.nextTick(r,i),!1):!0}M.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=ee),r.ending?ae(this,n):(a||oe(this,r,e,n))&&(r.pendingcb++,i=P(this,r,a,e,t,n)),i},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&z(this,e))},M.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(M.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function N(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(M.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function P(e,t,n,r,i,a){if(!n){var o=N(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 F(e,t,!1,s,r,i,a);return c}function F(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 I(e,t,n,r,i){--t.pendingcb,n?(w.nextTick(i,r),w.nextTick(ue,e,t),e._writableState.errorEmitted=!0,O(e,r)):(i(r),e._writableState.errorEmitted=!0,O(e,r),ue(e,t))}function se(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function L(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new v;if(se(n),t)I(e,n,r,t,i);else{var a=le(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&z(e,n),r?w.nextTick(ce,e,n,a,i):ce(e,n,a,i)}}function ce(e,t,n,r){n||R(e,t),t.pendingcb--,r(),ue(e,t)}function R(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function z(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,F(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(F(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}M.prototype._write=function(e,t,n){n(new _(`_write()`))},M.prototype._writev=null,M.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||de(this,r,n),this},Object.defineProperty(M.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function le(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function B(e,t){e._final(function(n){t.pendingcb--,n&&O(e,n),t.prefinished=!0,e.emit(`prefinish`),ue(e,t)})}function V(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,w.nextTick(B,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function ue(e,t){var n=le(t);if(n&&(V(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 de(e,t,n){t.ending=!0,ue(e,t),n&&(t.finished?w.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function H(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(M.prototype,`destroyed`,{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),M.prototype.destroy=p.destroy,M.prototype._undestroy=p.undestroy,M.prototype._destroy=function(e,t){t(e)}})),ie=t(((e,t)=>{T();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var i=P(),a=re();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)}})})),j=t(((e,t)=>{var n=D(),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)}})),M=t((e=>{var t=j().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):``}})),ae=t(((e,t)=>{var n=te().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})),oe=t(((e,t)=>{T();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=ae(),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}})),N=t(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),P=t(((e,t)=>{a(),T(),t.exports=I;var o;I.ReadableState=F,n().EventEmitter;var s=function(e,t){return e.listeners(t).length},c=E(),l=D().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=O(),m=p&&p.debuglog?p.debuglog(`stream`):function(){},h=ee(),g=k(),_=A().getHighWaterMark,v=te().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,ne,re;r()(I,c);var j=g.errorOrDestroy,ae=[`error`,`close`,`destroy`,`pause`,`resume`];function P(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 F(e,t,n){o||=ie(),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||=M().StringDecoder,this.decoder=new C(e.encoding),this.encoding=e.encoding)}function I(e){if(o||=ie(),!(this instanceof I))return new I(e);var t=this instanceof o;this._readableState=new F(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(I.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),I.prototype.destroy=g.destroy,I.prototype._undestroy=g.undestroy,I.prototype._destroy=function(e,t){t(e)},I.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),se(this,e,t,!1,r)},I.prototype.unshift=function(e){return se(this,e,null,!0,!1)};function se(e,t,n,r,i){m(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,B(e,a);else{var o;if(i||(o=ce(a,t)),o)j(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?j(e,new S):L(e,a,t,!0);else if(a.ended)j(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?L(e,a,t,!1):de(e,a)):L(e,a,t,!1);else r||(a.reading=!1,de(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function L(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&&V(e)),de(e,t)}function ce(e,t){var n;return!f(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new y(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}I.prototype.isPaused=function(){return this._readableState.flowing===!1},I.prototype.setEncoding=function(e){C||=M().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 R=1073741824;function z(e){return e>=R?e=R:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function le(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=z(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}I.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?U(this):V(this),null;if(e=le(e,t),e===0&&t.ended)return t.length===0&&U(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=le(n,t)));var i=e>0?ve(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&&U(this)),i!==null&&this.emit(`data`,i),i};function B(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?V(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,ue(e)))}}function V(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(ue,e))}function ue(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,_e(e)}function de(e,t){t.readingMore||(t.readingMore=!0,w.nextTick(H,e,t))}function H(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}I.prototype._read=function(e){j(this,new x(`_read()`))},I.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=fe(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&&be(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&&j(e,t)}P(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 fe(e){return function(){var t=e._readableState;m(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&s(e,`data`)&&(t.flowing=!0,_e(e))}}I.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=be(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)},I.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?V(this):r.reading||w.nextTick(me,this)),n},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(e,t){var n=c.prototype.removeListener.call(this,e,t);return e===`readable`&&w.nextTick(pe,this),n},I.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&w.nextTick(pe,this),t};function pe(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 me(e){m(`readable nexttick read 0`),e.read(0)}I.prototype.resume=function(){var e=this._readableState;return e.flowing||(m(`resume`),e.flowing=!e.readableListening,he(this,e)),e.paused=!1,this};function he(e,t){t.resumeScheduled||(t.resumeScheduled=!0,w.nextTick(ge,e,t))}function ge(e,t){m(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),_e(e),t.flowing&&!t.reading&&e.read(0)}I.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 _e(e){var t=e._readableState;for(m(`flow`,t.flowing);t.flowing&&e.read()!==null;);}I.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<ae.length;a++)e.on(ae[a],this.emit.bind(this,ae[a]));return this._read=function(t){m(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(I.prototype[Symbol.asyncIterator]=function(){return ne===void 0&&(ne=oe()),ne(this)}),Object.defineProperty(I.prototype,`readableHighWaterMark`,{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(I.prototype,`readableBuffer`,{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(I.prototype,`readableFlowing`,{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),I._fromList=ve,Object.defineProperty(I.prototype,`readableLength`,{enumerable:!1,get:function(){return this._readableState.length}});function ve(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 U(e){var t=e._readableState;m(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,w.nextTick(ye,t,e))}function ye(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`&&(I.from=function(e,t){return re===void 0&&(re=N()),re(I,e,t)});function be(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),F=t(((e,t)=>{t.exports=u;var n=te().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=ie();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)}})),I=t(((e,t)=>{t.exports=i;var n=F();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)}})),se=t(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=te().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=ae()),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})),L=t(((e,t)=>{t.exports=a;var i=n().EventEmitter;r()(a,i),a.Readable=P(),a.Writable=re(),a.Duplex=ie(),a.Transform=F(),a.PassThrough=I(),a.finished=ae(),a.pipeline=se(),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}}))(),ce=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,R=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=ce[n[e]&63];return t},z={},le={};le.byteLength=me,le.toByteArray=ge,le.fromByteArray=U;for(var B=[],V=[],ue=typeof Uint8Array<`u`?Uint8Array:Array,de=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,H=0,fe=de.length;H<fe;++H)B[H]=de[H],V[de.charCodeAt(H)]=H;V[45]=62,V[95]=63;function pe(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 me(e){var t=pe(e),n=t[0],r=t[1];return(n+r)*3/4-r}function he(e,t,n){return(t+n)*3/4-n}function ge(e){var t,n=pe(e),r=n[0],i=n[1],a=new ue(he(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=V[e.charCodeAt(c)]<<18|V[e.charCodeAt(c+1)]<<12|V[e.charCodeAt(c+2)]<<6|V[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=V[e.charCodeAt(c)]<<2|V[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=V[e.charCodeAt(c)]<<10|V[e.charCodeAt(c+1)]<<4|V[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function _e(e){return B[e>>18&63]+B[e>>12&63]+B[e>>6&63]+B[e&63]}function ve(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(_e(r));return i.join(``)}function U(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(ve(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(B[t>>2]+B[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+`=`)),i.join(``)}var ye={};ye.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)},ye.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);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),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=le,n=ye,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(U(e,o)||e&&U(e.buffer,o)||s!==void 0&&(U(e,s)||e&&U(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(U(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`||be(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(U(e,a)&&(e=u.from(e,e.offset,e.byteLength)),U(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)},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(U(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)||U(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 me(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return _e(e).length;default:if(i)return r?-1:me(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 ae(this,t,n);case`utf8`:case`utf-8`:return ne(this,t,n);case`ascii`:return j(this,t,n);case`latin1`:case`binary`:return M(this,t,n);case`base64`:return A(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return oe(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?ne(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(U(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)};function T(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,be(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:E(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):E(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function E(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 T(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return T(this,e,t,n,!1)};function D(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(be(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return ve(me(t,e.length-n),e,n,r)}function ee(e,t,n,r){return ve(he(t),e,n,r)}function k(e,t,n,r){return ve(_e(t),e,n,r)}function te(e,t,n,r){return ve(ge(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 D(this,e,t,n);case`utf8`:case`utf-8`:return O(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return ee(this,e,t,n);case`base64`:return k(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return te(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 A(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ne(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 ie(r)}let re=4096;function ie(e){let t=e.length;if(t<=re)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=re));return n}function j(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 M(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 ae(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+=xe[e[r]];return i}function oe(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 N(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||N(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||N(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||N(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(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||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=W(function(e){e>>>=0,de(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&H(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=W(function(e){e>>>=0,de(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&H(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||N(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||N(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||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||N(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||N(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||N(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||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=W(function(e){e>>>=0,de(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&H(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=W(function(e){e>>>=0,de(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&H(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||N(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!1,52,8)};function P(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;P(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;P(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||P(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||P(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||P(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||P(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||P(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 F(e,t,n,r,i){ue(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 I(e,t,n,r,i){ue(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=W(function(e,t=0){return F(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=W(function(e,t=0){return I(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);P(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);P(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||P(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||P(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||P(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||P(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||P(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=W(function(e,t=0){return F(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=W(function(e,t=0){return I(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function se(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function L(e,t,r,i,a){return t=+t,r>>>=0,a||se(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)};function ce(e,t,r,i,a){return t=+t,r>>>=0,a||se(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return ce(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return ce(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 R={};function z(e,t,n){R[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}`}}}z(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),z(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),z(`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=B(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=B(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function B(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function V(e,t,n){de(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&H(t,e.length-(n+1))}function ue(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 R.ERR_OUT_OF_RANGE(`value`,i,e)}V(r,i,a)}function de(e,t){if(typeof e!=`number`)throw new R.ERR_INVALID_ARG_TYPE(t,`number`,e)}function H(e,t,n){throw Math.floor(e)===e?t<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(de(e,n),new R.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let fe=/[^+/0-9A-Za-z-_]/g;function pe(e){if(e=e.split(`=`)[0],e=e.trim().replace(fe,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function me(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 he(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ge(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 _e(e){return t.toByteArray(pe(e))}function ve(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 U(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function be(e){return e!==e}let xe=(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 W(e){return typeof BigInt>`u`?Se:e}function Se(){throw Error(`BigInt not supported`)}})(z);var be=z.Buffer;z.Blob,z.BlobOptions;var xe=z.Buffer;z.File,z.FileOptions,z.INSPECT_MAX_BYTES,z.SlowBuffer,z.TranscodeEncoding,z.atob,z.btoa,z.constants,z.isAscii,z.isUtf8,z.kMaxLength,z.kStringMaxLength,z.resolveObjectURL,z.transcode;var W=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)}},Se=W.default??W,Ce=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=r=>{if(e&&e.removeEventListener(`abort`,i),r){n(Error(`credit gate aborted`));return}this.remaining--,t()},i=()=>{let t=this.waiters.indexOf(r);t!==-1&&this.waiters.splice(t,1),n(e?.reason??Error(`aborted`))};if(e&&e.addEventListener(`abort`,i,{once:!0}),e?.aborted){e.removeEventListener(`abort`,i),n(e.reason??Error(`aborted`));return}this.waiters.push(r)})}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)}},we=new TextEncoder;function Te(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 Ee(e){let t;if(e instanceof xe)t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=we.encode(e);else throw Error(`invalid chunk type: expected Buffer, Uint8Array, or string`);return t}var De=class extends L.Readable{constructor(e){let t=e?.read;super({...e,read:()=>{}}),this._chunks=[],this._collecting=!0,this._onRead=t,this.buffer=new Promise((e,t)=>{this._resolve=e,this._reject=t}),this.buffer.catch(()=>{}),this.on(`error`,e=>{this._collecting&&(this._collecting=!1,this._reject(e))})}push(e,t){return this._collecting&&(e===null?(this._collecting=!1,this._resolve(Te(this._chunks))):e!==void 0&&this._chunks.push(Ee(e))),super.push(e,t)}read(e){return this._onRead?.(e??0),super.read(e)}get collecting(){return this._collecting}stopCollecting(){this._collecting&&(this._reject(Error(`collecting stopped`)),this._collecting=!1,this._chunks.length=0)}};async function Oe(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 ke(e,t,n,r,i){let a;for await(let o of e){if(i?.aborted)throw i.reason??Error(`aborted`);let e=Ee(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 Ae(e,t,n,r){if(!(typeof e==`object`&&e))throw Error(`invalid object`);let i,a=e[t],o=e[n];Object.defineProperty(e,t,{get:()=>{if(i===`f2`)throw Error(`field "${t}" is mutually exclusive with field "${n}" and "${n}" was already consumed`);return i||r?.(t),i=`f1`,a},enumerable:!0,configurable:!0}),Object.defineProperty(e,n,{get:()=>{if(i===`f1`)throw Error(`field "${n}" is mutually exclusive with field "${t}" and "${t}" was already consumed`);return i||r?.(n),i=`f2`,o},enumerable:!0,configurable:!0})}var je=class e{constructor(){this.resources=[],this.pending=null}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,e=>e.unroll()),t}unroll(e=!0){if(this.pending!==null)return e?this.pending.catch(()=>{}):this.pending;let t=this.resources;this.resources=[];let n=[],r;for(;t.length>0;){let e=t.pop(),i=e.resource,a=e.cleanup;if(r)r=r.then(()=>a(i)).catch(e=>{n.push(e)});else try{let e=a(i);e instanceof Promise&&(r=e.catch(e=>{n.push(e)}))}catch(e){n.push(e)}}if(r)return this.pending=r.then(()=>{if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n,`multiple cleanup failures`)}).finally(()=>{this.pending=null}),e?this.pending.catch(()=>{}):this.pending;if(!e&&n.length===1)throw n[0];if(!e&&n.length>1)throw AggregateError(n,`multiple cleanup failures`)}};function G(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 Me(e,t,n){if(!t)return e?Promise.resolve():void 0;let r;try{r=t()}catch(t){if(e)return Promise.reject(G(t,n));throw G(t,n)}if(!e&&r instanceof Promise)throw Error(`onfinally callback returned Promise in non-async context`);return e&&!(r instanceof Promise)&&(r=Promise.resolve(r)),e&&r instanceof Promise?r.catch(e=>{throw G(e,n)}):r}function Ne(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 Pe(...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 je||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 je||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=G(e,t);if(i){try{s=i(r)}catch(e){throw r=G(e,t),Me(!1,a,t),Ne(!1,n),r}return Me(!1,a,t),s}throw Me(!1,a,t),Ne(!1,n),r}return s instanceof Promise?s.then(async e=>(await Me(!0,a,t),n&&o&&n.roll(e,o),e),async e=>{let r=G(e,t);if(i)try{let e=await i(r);return await Me(!0,a,t),e}catch(e){throw r=G(e,t),await Me(!0,a,t),await Ne(!0,n),r}throw await Me(!0,a,t),await Ne(!0,n),r}):(Me(!1,a,t),n&&o&&n.roll(s,o),s)}var Fe=new TextEncoder,Ie=new TextDecoder;function Le(...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 Re(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 ze(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 Be(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 Ve(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Ie.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Ie.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Be(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function He(e){let t=e;return typeof t==`string`&&(t=Fe.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):ze(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var Ue=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)}},We=class extends Ue{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}},Ge=class extends Ue{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}},Ke=class extends Ue{static code=`ERR_JOSE_ALG_NOT_ALLOWED`;code=`ERR_JOSE_ALG_NOT_ALLOWED`},qe=class extends Ue{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},K=class extends Ue{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},Je=class extends Ue{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`},Ye=class extends Ue{static code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;constructor(e=`signature verification failed`,t){super(e,t)}},Xe=(e,t=`algorithm.name`)=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),Ze=(e,t)=>e.name===t;function Qe(e){return parseInt(e.name.slice(4),10)}function $e(e,t){if(Qe(e.hash)!==t)throw Xe(`SHA-${t}`,`algorithm.hash`)}function et(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}function tt(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function nt(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!Ze(e.algorithm,`HMAC`))throw Xe(`HMAC`);$e(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!Ze(e.algorithm,`RSASSA-PKCS1-v1_5`))throw Xe(`RSASSA-PKCS1-v1_5`);$e(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!Ze(e.algorithm,`RSA-PSS`))throw Xe(`RSA-PSS`);$e(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!Ze(e.algorithm,`Ed25519`))throw Xe(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!Ze(e.algorithm,t))throw Xe(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!Ze(e.algorithm,`ECDSA`))throw Xe(`ECDSA`);let n=et(t);if(e.algorithm.namedCurve!==n)throw Xe(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}tt(e,n)}function rt(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 it=(e,...t)=>rt(`Key must be `,e,...t),at=(e,t,...n)=>rt(`Key for the ${e} algorithm must be `,t,...n);function ot(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 st(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 qe(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function ct(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(it(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return nt(t,e,n),t}async function lt(e,t,n){let r=await ct(e,t,`sign`);ot(e,r);let i=await crypto.subtle.sign(st(e,r.algorithm),r,n);return new Uint8Array(i)}async function ut(e,t,n,r){let i=await ct(e,t,`verify`);ot(e,i);let a=st(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var dt=e=>typeof e==`object`&&!!e;function ft(e){if(!dt(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 pt(...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 mt=e=>ft(e)&&typeof e.kty==`string`,ht=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),gt=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,_t=e=>e.kty===`oct`&&typeof e.k==`string`,vt=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},yt=e=>e?.[Symbol.toStringTag]===`KeyObject`,bt=e=>vt(e)||yt(e),xt=e=>e?.[Symbol.toStringTag],St=(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},Ct=(e,t,n)=>{if(!(t instanceof Uint8Array)){if(mt(t)){if(_t(t)&&St(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(!bt(t))throw TypeError(at(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${xt(t)} instances for symmetric algorithms must be of type "secret"`)}},wt=(e,t,n)=>{if(mt(t))switch(n){case`decrypt`:case`sign`:if(ht(t)&&St(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if(gt(t)&&St(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!bt(t))throw TypeError(at(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${xt(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${xt(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${xt(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${xt(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${xt(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function Tt(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:Ct(e,t,n);break;default:wt(e,t,n)}}function Et(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 qe(`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 Dt=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function Ot(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 qe(Dt)}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 qe(Dt)}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 qe(Dt)}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 qe(Dt)}break;default:throw new qe(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function kt(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=Ot(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 At=`given KeyObject instance cannot be used for this algorithm`,jt,Mt=async(e,t,n,r=!1)=>{jt||=new WeakMap;let i=jt.get(e);if(i?.[n])return i[n];let a=await kt({...t,alg:n});return r&&Object.freeze(e),i?i[n]=a:jt.set(e,{[n]:a}),a},Nt=(e,t)=>{jt||=new WeakMap;let n=jt.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(At)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(At);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(At);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(At)}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(At);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(At);return n?n[t]=a:jt.set(e,{[t]:a}),a};async function Pt(e,t){if(e instanceof Uint8Array||vt(e))return e;if(yt(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return Nt(e,t)}catch(e){if(e instanceof TypeError)throw e}return Mt(e,e.export({format:`jwk`}),t)}if(mt(e))return e.k?Ve(e.k):Mt(e,e,t,!0);throw Error(`unreachable`)}function Ft(e,t){if(e)throw TypeError(`${t} can only be called once`)}function It(e,t,n){try{return Ve(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}var Lt=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 Ft(this.#t,`setProtectedHeader`),this.#t=e,this}setUnprotectedHeader(e){return Ft(this.#n,`setUnprotectedHeader`),this.#n=e,this}async sign(e,t){if(!this.#t&&!this.#n)throw new K(`either setProtectedHeader or setUnprotectedHeader must be called before #sign()`);if(!pt(this.#t,this.#n))throw new K(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let n={...this.#t,...this.#n},r=Et(K,new Map([[`b64`,!0]]),t?.crit,this.#t,n),i=!0;if(r.has(`b64`)&&(i=this.#t.b64,typeof i!=`boolean`))throw new K(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:a}=n;if(typeof a!=`string`||!a)throw new K(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);Tt(a,e,`sign`);let o,s;i?(o=He(this.#e),s=Re(o)):(s=this.#e,o=``);let c,l;this.#t?(c=He(JSON.stringify(this.#t)),l=Re(c)):(c=``,l=new Uint8Array);let u=Le(l,Re(`.`),s),d={signature:He(await lt(a,await Pt(e,a),u)),payload:o};return this.#n&&(d.header=this.#n),this.#t&&(d.protected=c),d}},Rt=class{#e;constructor(e){this.#e=new Lt(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}`}},zt=e=>Math.floor(e.getTime()/1e3),Bt=60,Vt=Bt*60,Ht=Vt*24,Ut=Ht*7,Wt=Ht*365.25,Gt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function Kt(e){let t=Gt.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*Bt);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:i=Math.round(n*Vt);break;case`day`:case`days`:case`d`:i=Math.round(n*Ht);break;case`week`:case`weeks`:case`w`:i=Math.round(n*Ut);break;default:i=Math.round(n*Wt);break}return t[1]===`-`||t[4]===`ago`?-i:i}function qt(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}var Jt=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`,Yt=(e,t)=>typeof e==`string`?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1;function Xt(e,t,n={}){let r;try{r=JSON.parse(Ie.decode(t))}catch{}if(!ft(r))throw new Je(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=n;if(i&&(typeof e.typ!=`string`||Jt(e.typ)!==Jt(i)))throw new We(`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 We(`missing required "${e}" claim`,r,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(r.iss))throw new We(`unexpected "iss" claim value`,r,`iss`,`check_failed`);if(s&&r.sub!==s)throw new We(`unexpected "sub" claim value`,r,`sub`,`check_failed`);if(c&&!Yt(r.aud,typeof c==`string`?[c]:c))throw new We(`unexpected "aud" claim value`,r,`aud`,`check_failed`);let d;switch(typeof n.clockTolerance){case`string`:d=Kt(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=zt(f||new Date);if((r.iat!==void 0||l)&&typeof r.iat!=`number`)throw new We(`"iat" claim must be a number`,r,`iat`,`invalid`);if(r.nbf!==void 0){if(typeof r.nbf!=`number`)throw new We(`"nbf" claim must be a number`,r,`nbf`,`invalid`);if(r.nbf>p+d)throw new We(`"nbf" claim timestamp check failed`,r,`nbf`,`check_failed`)}if(r.exp!==void 0){if(typeof r.exp!=`number`)throw new We(`"exp" claim must be a number`,r,`exp`,`invalid`);if(r.exp<=p-d)throw new Ge(`"exp" claim timestamp check failed`,r,`exp`,`check_failed`)}if(l){let e=p-r.iat,t=typeof l==`number`?l:Kt(l);if(e-d>t)throw new Ge(`"iat" claim timestamp check failed (too far in the past)`,r,`iat`,`check_failed`);if(e<0-d)throw new We(`"iat" claim timestamp check failed (it should be in the past)`,r,`iat`,`check_failed`)}return r}var Zt=class{#e;constructor(e){if(!ft(e))throw TypeError(`JWT Claims Set MUST be an object`);this.#e=structuredClone(e)}data(){return Fe.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=qt(`setNotBefore`,e):e instanceof Date?this.#e.nbf=qt(`setNotBefore`,zt(e)):this.#e.nbf=zt(new Date)+Kt(e)}set exp(e){typeof e==`number`?this.#e.exp=qt(`setExpirationTime`,e):e instanceof Date?this.#e.exp=qt(`setExpirationTime`,zt(e)):this.#e.exp=zt(new Date)+Kt(e)}set iat(e){e===void 0?this.#e.iat=zt(new Date):e instanceof Date?this.#e.iat=qt(`setIssuedAt`,zt(e)):typeof e==`string`?this.#e.iat=qt(`setIssuedAt`,zt(new Date)+Kt(e)):this.#e.iat=qt(`setIssuedAt`,e)}},Qt=class{#e;#t;constructor(e={}){this.#t=new Zt(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 Rt(this.#t.data());if(n.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes(`b64`)&&this.#e.b64===!1)throw new Je(`JWTs MUST NOT use unencoded payload`);return n.sign(e,t)}};function $t(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 en(e,t,n){if(!ft(e))throw new K(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new K(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new K(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new K(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new K(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!ft(e.header))throw new K(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=Ve(e.protected);r=JSON.parse(Ie.decode(t))}catch{throw new K(`JWS Protected Header is invalid`)}if(!pt(r,e.header))throw new K(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i={...r,...e.header},a=Et(K,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new K(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new K(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&$t(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new Ke(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new K(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new K(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Tt(s,t,`verify`);let u=Le(e.protected===void 0?new Uint8Array:Re(e.protected),Re(`.`),typeof e.payload==`string`?o?Re(e.payload):Fe.encode(e.payload):e.payload),d=It(e.signature,`signature`,K),f=await Pt(t,s);if(!await ut(s,f,d,u))throw new Ye;let p;p=o?It(e.payload,`payload`,K):typeof e.payload==`string`?Fe.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 tn(e,t,n){if(e instanceof Uint8Array&&(e=Ie.decode(e)),typeof e!=`string`)throw new K(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new K(`Invalid Compact JWS`);let s=await en({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 nn(e,t,n){let r=await tn(e,t,n);if(r.protectedHeader.crit?.includes(`b64`)&&r.protectedHeader.b64===!1)throw new Je(`JWTs MUST NOT use unencoded payload`);let i={payload:Xt(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t==`function`?{...i,key:r.key}:i}function rn(e){return e.saveState!==void 0&&e.restoreState!==void 0&&e.cleanSavedState!==void 0}function an(e){for(let t=0;t<e.length;t++)e[t]=0;return e}var on=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),rn(this._inner)&&rn(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),an(n)}reset(){if(!rn(this._inner)||!rn(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(){rn(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),rn(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(!rn(this._inner))throw Error(`hmac: can't saveState() because hash doesn't implement it`);return this._inner.saveState()}restoreState(e){if(!rn(this._inner)||!rn(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(!rn(this._inner))throw Error(`hmac: can't cleanSavedState() because hash doesn't implement it`);this._inner.cleanSavedState(e)}};Number.isInteger,Number.isSafeInteger;function sn(e,t=0){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function cn(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 ln(e,t,n,r,i){let a=new on(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++){cn(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 an(c),an(l),an(s),a.cleanSavedState(d),a.clean(),u}var un=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(){an(this._buffer),an(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&&(fn(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=fn(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;cn(n,this._buffer,i-8),cn(r,this._buffer,i-4),fn(this._temp,this._state,this._buffer,0,i),this._finished=!0}for(let t=0;t<this.digestLength/4;t++)cn(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){an(e.state),e.buffer&&an(e.buffer),e.bufferLength=0,e.bytesHashed=0}},dn=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 fn(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]=sn(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+(dn[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 pn=n(),mn;function hn(e){return{lang:e?.lang??mn?.lang,message:e?.message,abortEarly:e?.abortEarly??mn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??mn?.abortPipeEarly}}var gn;function _n(e){return gn?.get(e)}var vn;function yn(e){return vn?.get(e)}var bn;function xn(e,t){return bn?.get(e)?.get(t)}function Sn(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 Cn(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??Sn(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??xn(e.reference,c.lang)??(l?yn(c.lang):null)??r.message??_n(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 wn(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},hn())}}}function Tn(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function En(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function Dn(e,t){return{kind:`validation`,type:`check`,reference:Dn,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Cn(this,`input`,e,t),e}}}function On(e){return{kind:`validation`,type:`integer`,reference:On,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Cn(this,`integer`,e,t),e}}}function kn(e,t){return{kind:`validation`,type:`max_length`,reference:kn,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Cn(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function An(e,t){return{kind:`validation`,type:`min_value`,reference:An,async:!1,expects:`>=${e instanceof Date?e.toJSON():Sn(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Cn(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Sn(e.value)}),e}}}function jn(e,t){return{kind:`validation`,type:`regex`,reference:jn,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&Cn(this,`format`,e,t),e}}}function Mn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Nn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Pn(e,t){return{kind:`schema`,type:`array`,reference:Pn,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return wn(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 Cn(this,`type`,e,t);return e}}}function Fn(e){return{kind:`schema`,type:`boolean`,reference:Fn,expects:`boolean`,async:!1,message:e,get"~standard"(){return wn(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Cn(this,`type`,e,t),e}}}function In(e,t){return{kind:`schema`,type:`instance`,reference:In,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return wn(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:Cn(this,`type`,e,t),e}}}function Ln(e,t){return{kind:`schema`,type:`literal`,reference:Ln,expects:Sn(e),async:!1,literal:e,message:t,get"~standard"(){return wn(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Cn(this,`type`,e,t),e}}}function Rn(e){return{kind:`schema`,type:`number`,reference:Rn,expects:`number`,async:!1,message:e,get"~standard"(){return wn(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Cn(this,`type`,e,t),e}}}function q(e,t){return{kind:`schema`,type:`optional`,reference:q,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return wn(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Nn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function zn(e,t){return{kind:`schema`,type:`picklist`,reference:zn,expects:En(e.map(Sn),`|`),async:!1,options:e,message:t,get"~standard"(){return wn(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Cn(this,`type`,e,t),e}}}function Bn(e,t,n){return{kind:`schema`,type:`record`,reference:Bn,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return wn(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Tn(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 Cn(this,`type`,e,t);return e}}}function Vn(e,t){return{kind:`schema`,type:`strict_object`,reference:Vn,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return wn(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]:Nn(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]=Mn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Cn(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)){Cn(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else Cn(this,`type`,e,t);return e}}}function J(e){return{kind:`schema`,type:`string`,reference:J,expects:`string`,async:!1,message:e,get"~standard"(){return wn(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Cn(this,`type`,e,t),e}}}function Hn(){return{kind:`schema`,type:`unknown`,reference:Hn,expects:`unknown`,async:!1,get"~standard"(){return wn(this)},"~run"(e){return e.typed=!0,e}}}function Un(...e){return{...e[0],pipe:e,get"~standard"(){return wn(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 Wn(e,t,n){let r=e[`~run`]({value:t},hn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var Y={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},X={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},Z={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Gn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},Kn=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},Q=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[Kn.ENCODED]}function Yn(e){if(typeof e==`object`&&e)return e[Kn.LENGTH]}function Xn(e,t){Object.defineProperty(e,Kn.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 ir(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function ar(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 or(e){let t=atob(e);return Uint8Array.from(t,e=>e.codePointAt(0))}var sr={"-":`+`,_:`/`};function cr(e){let t=e.replace(/[_-]/g,e=>sr[e]);return or(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function lr(){let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])}function ur(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 dr=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 fr(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 pr=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}},mr=1n<<15n,hr=31n<<10n,gr=1n<<9n,_r=gr-1n,vr=gr|_r,yr=1n<<31n,br=255n<<23n,xr=1n<<22n,Sr=xr-1n,Cr=xr|Sr,wr=1n<<63n,Tr=2047n<<52n,Er=1n<<51n,Dr=Er-1n,Or=Er|Dr,kr=Dr-(_r<<42n),Ar=Dr-(Sr<<29n),jr={2:`0b`,8:`0o`,16:`0x`},Mr=(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))(Mr||{});function Nr(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 Pr=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=wr,e=-e),e>=Er)throw Error(`Payload too large: ${r}`);let a=t?Er:0n;switch(this.#e=i|Tr|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&kr)throw Error(`Invalid size for payload`);break;case 4:if(this.#e&Ar)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&Tr)===Tr)this.#e=e,t=8;else if((e&br)===br)this.#e=(e&yr)<<32n|Tr|(e&Cr)<<29n,t=4;else if((e&hr)===hr)this.#e=(e&mr)<<48n|Tr|(e&vr)<<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&hr)!==hr)throw Error(`Not a NaN`);this.#e=(n&mr)<<48n|Tr|(n&vr)<<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&br)!==br)throw Error(`Not a NaN`);this.#e=(n&yr)<<32n|Tr|(n&Cr)<<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&Tr)!==Tr)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&wr?mr:0n)|hr|(this.#e&Or)>>42n;t.setUint16(1,Number(e),!1);break}case 4:{t.setUint8(0,250);let e=(this.#e&wr?yr:0n)|br|(this.#e&Or)>>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&Er)}get sign(){return this.#e&wr?-1:1}get payload(){return Number(this.#e&Dr)*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&kr)===0n?2:(this.#e&Ar)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return Nr(this,1,{},t=>(jr[e]??``)+t.toString(e))}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return Nr(this,e,t,n)}};function Fr(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 Ir(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 Lr(e){if(e!==0){let t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e,!1);let n=t.getBigUint64(0,!1);if((n&9218868437227405312n)==0n)return n&9223372036854775808n?-0:0}return e}function Rr(e){switch(e.length){case 2:Fr(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 zr=class extends TypeError{code=`ERR_ENCODING_INVALID_ENCODED_DATA`;constructor(){super(`The encoded data was not valid for encoding wtf-8`)}},Br=class extends RangeError{code=`ERR_ENCODING_NOT_SUPPORTED`;constructor(e){super(`Invalid encoding: "${e}"`)}},Vr=new Uint8Array,Hr=55296,Ur=56320,Wr=65533,Gr=`wtf-8`;function Kr(e){return e&&typeof e==`object`&&!(e instanceof ArrayBuffer)&&!(e instanceof SharedArrayBuffer)&&e.buffer instanceof ArrayBuffer}function qr(e){return e?e instanceof Uint8Array?e:Kr(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e):Vr}var Jr=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3],Yr=class e{static DEFAULT_BUFFERSIZE=4096;encoding=Gr;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 Br(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=qr(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 zr;a[s++]=Wr},l=()=>{let e=this.#n;for(let t=0;t<e;t++)c()},u=e=>{if(this.#e===0)switch(Jr[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|Hr,a[s++]=e&1023|Ur}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 Xr(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 Zr=class{encoding=Gr;encode(e){if(!e)return Vr;let t=new Uint8Array(Xr(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:Qr}=Kn,$r=Y.SIMPLE_FLOAT<<5|Z.TWO,ei=Y.SIMPLE_FLOAT<<5|Z.FOUR,ti=Y.SIMPLE_FLOAT<<5|Z.EIGHT,ni=Y.SIMPLE_FLOAT<<5|Gn.TRUE,ri=Y.SIMPLE_FLOAT<<5|Gn.FALSE,ii=Y.SIMPLE_FLOAT<<5|Gn.UNDEFINED,ai=Y.SIMPLE_FLOAT<<5|Gn.NULL,oi=new TextEncoder,si=new Zr,ci={...pr.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:X.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},li={cde:!0,ignoreOriginalEncoding:!0,sortKeys:fr},ui={...li,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:`NFC`};function di(e){let t=e<0;return typeof e==`bigint`?[t?-e-1n:e,t]:[t?-e-1:e,t]}function fi(e,t,n){if(n.rejectFloats)throw Error(`Attempt to encode an unwanted floating point number: ${e}`);if(isNaN(e))t.writeUint8($r),t.writeUint16(32256);else if(!n.float64&&Math.fround(e)===e){let n=Ir(e);n===null?(t.writeUint8(ei),t.writeFloat32(e)):(t.writeUint8($r),t.writeUint16(n))}else t.writeUint8(ti),t.writeFloat64(e)}function pi(e,t,n){let[r,i]=di(e);if(i&&n)throw TypeError(`Negative size: ${e}`);n??=i?Y.NEG_INT:Y.POS_INT,n<<=5,r<24?t.writeUint8(n|r):r<=255?(t.writeUint8(n|Z.ONE),t.writeUint8(r)):r<=65535?(t.writeUint8(n|Z.TWO),t.writeUint16(r)):r<=4294967295?(t.writeUint8(n|Z.FOUR),t.writeUint32(r)):(t.writeUint8(n|Z.EIGHT),t.writeBigUint64(BigInt(r)))}function mi(e,t,n){typeof e==`number`?pi(e,t,Y.TAG):typeof e==`object`&&!n.ignoreOriginalEncoding&&Kn.ENCODED in e?t.write(e[Kn.ENCODED]):e<=2**53-1?pi(Number(e),t,Y.TAG):(t.writeUint8(Y.TAG<<5|Z.EIGHT),t.writeBigUint64(BigInt(e)))}function hi(e,t,n){let[r,i]=di(e);if(n.collapseBigInts&&(!n.largeNegativeAsBigInt||e>=-9223372036854775808n)){if(r<=4294967295n){pi(Number(e),t);return}if(r<=18446744073709551615n){let e=(i?Y.NEG_INT:Y.POS_INT)<<5;t.writeUint8(e|Z.EIGHT),t.writeBigUint64(r);return}}if(n.rejectBigInts)throw Error(`Attempt to encode unwanted bigint: ${e}`);let a=i?X.NEG_BIGINT:X.POS_BIGINT,o=r.toString(16),s=o.length%2?`0`:``;mi(a,t,n);let c=rr(s+o);pi(c.length,t,Y.BYTE_STRING),t.write(c)}function gi(e,t,n){n.flushToZero&&(e=Lr(e)),Object.is(e,-0)?n.simplifyNegativeZero?n.avoidInts?fi(0,t,n):pi(0,t):fi(e,t,n):!n.avoidInts&&Number.isSafeInteger(e)?pi(e,t):n.reduceUnsafeNumbers&&Math.floor(e)===e&&e>=qn.MIN&&e<=qn.MAX?hi(BigInt(e),t,n):fi(e,t,n)}function _i(e,t,n){let r=n.stringNormalization?e.normalize(n.stringNormalization):e;if(n.wtf8&&!e.isWellFormed()){let e=si.encode(r);mi(X.WTF8,t,n),pi(e.length,t,Y.BYTE_STRING),t.write(e)}else{let e=oi.encode(r);pi(e.length,t,Y.UTF8_STRING),t.write(e)}}function vi(e,t,n){let r=e;xi(r,r.length,Y.ARRAY,t,n);for(let e of r)wi(e,t,n)}function yi(e,t){pi(e.length,t,Y.BYTE_STRING),t.write(e)}var bi=new dr;bi.registerEncoder(Array,vi),bi.registerEncoder(Uint8Array,yi);function $(e,t){return bi.registerEncoder(e,t)}function xi(e,t,n,r,i){let a=Yn(e);a&&!i.ignoreOriginalEncoding?r.write(a):pi(t,r,n)}function Si(e,t,n){if(e===null){t.writeUint8(ai);return}if(!n.ignoreOriginalEncoding&&Kn.ENCODED in e){t.write(e[Kn.ENCODED]);return}let r=e.constructor;if(r){let i=n.types?.get(r)??(n.ignoreGlobalTags?void 0:bi.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])))&&mi(r[0],t,n),wi(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])))&&mi(r[0],t,n),wi(r[1],t,n));return}if(typeof e.toJSON==`function`){wi(e.toJSON(),t,n);return}let i=Object.entries(e).map(e=>[e[0],e[1],Ti(e[0],n)]);n.sortKeys&&i.sort(n.sortKeys),xi(e,i.length,Y.MAP,t,n);for(let[e,r,a]of i)t.write(a),wi(r,t,n)}function Ci(e,t,n){if(!e.description||e!==Symbol.for(e.description))throw TypeError(`Private or empty symbol: ${e.toString()}`);mi(280,t,n),_i(e.description,t,n)}function wi(e,t,n){switch(typeof e){case`number`:gi(e,t,n);break;case`bigint`:hi(e,t,n);break;case`string`:_i(e,t,n);break;case`boolean`:t.writeUint8(e?ni:ri);break;case`undefined`:if(n.rejectUndefined)throw Error(`Attempt to encode unwanted undefined.`);t.writeUint8(ii);break;case`object`:Si(e,t,n);break;case`symbol`:Ci(e,t,n);break;default:throw TypeError(`Unknown type: ${typeof e}, ${String(e)}`)}}function Ti(e,t={}){let n={...ci};t.dcbor?Object.assign(n,ui):t.cde&&Object.assign(n,li),Object.assign(n,t);let r=new pr(n);return wi(e,r,n),r.read()}var Ei=(e=>(e[e.NEVER=-1]=`NEVER`,e[e.PREFERRED=0]=`PREFERRED`,e[e.ALWAYS=1]=`ALWAYS`,e))(Ei||{}),Di=class e{static KnownSimple=new Map([[Gn.FALSE,!1],[Gn.TRUE,!0],[Gn.NULL,null],[Gn.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}`);pi(this.value,e,Y.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)})`}},Oi=new TextDecoder(`utf8`,{fatal:!0,ignoreBOM:!0}),ki=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=or(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 Z.ONE:if(s=1,a=this.#t.getUint8(this.#n),r===Y.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 Z.TWO:if(s=2,r===Y.SIMPLE_FLOAT)a=Fr(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 Z.FOUR:if(s=4,r===Y.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 Z.EIGHT:if(s=8,r===Y.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 Z.INDEFINITE:switch(r){case Y.POS_INT:case Y.NEG_INT:case Y.TAG:throw Error(`Invalid indefinite encoding for MT ${r}`);case Y.SIMPLE_FLOAT:yield[r,i,Kn.BREAK,t,0];return}a=1/0;break;default:o=!0}switch(this.#n+=s,r){case Y.POS_INT:yield[r,i,a,t,s];break;case Y.NEG_INT:yield[r,i,typeof a==`bigint`?-1n-a:-1-Number(a),t,s];break;case Y.BYTE_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,this.#a(a),t,a];break;case Y.UTF8_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,Oi.decode(this.#a(a)),t,a];break;case Y.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 Y.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 Y.TAG:yield[r,i,a,t,s],yield*this.#i(e);break;case Y.SIMPLE_FLOAT:{let e=a;o&&(a=Di.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,Z.INDEFINITE,1/0,n,1/0];;){let n=this.#i(t),i=n.next(),[a,o,s]=i.value;if(s===Kn.BREAK){yield i.value,n.next();return}if(r){if(a!==e)throw Error(`Unmatched major type. Expected ${e}, got ${a}.`);if(o===Z.INDEFINITE)throw Error(`New stream started in typed stream`)}yield i.value,yield*n}}},Ai=new Map([[Z.ZERO,1],[Z.ONE,2],[Z.TWO,3],[Z.FOUR,5],[Z.EIGHT,9]]),ji=new Uint8Array;function Mi(e,t){return!t.boxed&&!t.preferMap&&e.every(([e])=>typeof e==`string`)?Object.fromEntries(e):new Map(e)}var Ni=class e{static defaultDecodeOptions={...ki.defaultOptions,ParentType:e,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Ei.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:Mi,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:fr};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===Y.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===Z.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 Y.POS_INT:case Y.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 Y.SIMPLE_FLOAT:if(a>Z.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 Pr(e);if(n.rejectLongLoundNaN){if(t.payload||e.length>3)throw Error(`Invalid NaN encoding: "${ir(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&&Rr(r.toHere(s+1)),n.rejectLongFloats){let e=Ti(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<Ai.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 Di)throw Error(`Invalid simple value: ${o}`);if(n.rejectUndefined&&o===void 0)throw Error(`Unexpected undefined`)}return o;case Y.BYTE_STRING:case Y.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 [${ur(o)}] instead of [${ur(e)}]`)}return n.boxed?Zn(o,r.toHere(s)):o;case Y.ARRAY:return new n.ParentType(e,o,t,n);case Y.MAP:return new n.ParentType(e,o*2,t,n);case Y.TAG:{let r=new n.ParentType(e,1,t,n);return r.children=new Q(o),r}}throw TypeError(`Invalid major type: ${i}`)}static decodeToEncodeOpts(e){return{...ci,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 Q?(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 Y.ARRAY:t=this.children;break;case Y.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=ir(i);if(t.has(e))throw Error(`Duplicate key: "0x${e}"`);t.add(e)}}t=this.#e.createObject(e,this.#e);break}case Y.BYTE_STRING:return ar(this.children);case Y.UTF8_STRING:{let n=this.children.join(``);t=this.#e.boxed?Zn(n,e.toHere(this.offset)):n;break}case Y.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],ji];return n}},Pi=` `,Fi=new TextEncoder,Ii=class extends Ni{close=``;quote=`"`;get isEmptyStream(){return(this.mt===Y.UTF8_STRING||this.mt===Y.BYTE_STRING)&&this.count===0}};function Li(e,t,n,r){let i=``;if(t===Z.INDEFINITE)i+=`_`;else{if(r.diagnosticSizes===Ei.NEVER)return``;{let a=r.diagnosticSizes===Ei.ALWAYS;if(!a){let r=Z.ZERO;if(Object.is(n,-0))r=Z.TWO;else if(e===Y.POS_INT||e===Y.NEG_INT){let e=n<0,t=typeof n==`bigint`?1n:1,i=e?-n-t:n;r=i<=23?Number(i):i<=255?Z.ONE:i<=65535?Z.TWO:i<=4294967295?Z.FOUR:Z.EIGHT}else r=isFinite(n)?Math.fround(n)===n?Ir(n)==null?Z.FOUR:Z.TWO:Z.EIGHT:Z.TWO;a=r!==t}a&&(i+=`_`,t<Z.ONE?i+=`i`:i+=String(t-24))}}return i}function Ri(e,t){let n={...Ni.defaultDecodeOptions,...t,ParentType:Ii},r=new ki(e,n),i,a,o=``;for(let e of r){let[t,s,c]=e;switch(i&&(i.count>0&&c!==Kn.BREAK&&(i.mt===Y.MAP&&i.count%2?o+=`: `:(o+=`,`,n.pretty||(o+=` `))),n.pretty&&(i.mt!==Y.MAP||i.count%2==0)&&(o+=`
2
- ${Pi.repeat(i.depth+1)}`)),a=Ni.create(e,i,n,r),t){case Y.POS_INT:case Y.NEG_INT:o+=String(c),o+=Li(t,s,c,n);break;case Y.SIMPLE_FLOAT:if(c!==Kn.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+=Li(t,s,c,n)}else c instanceof Di?(o+=`simple(`,o+=String(c.value),o+=Li(Y.POS_INT,s,c.value,n),o+=`)`):o+=String(c);break;case Y.BYTE_STRING:c===1/0?(o+=`(_ `,a.close=`)`,a.quote=`'`):(o+=`h'`,o+=ir(c),o+=`'`,o+=Li(Y.POS_INT,s,c.length,n));break;case Y.UTF8_STRING:c===1/0?(o+=`(_ `,a.close=`)`):(o+=JSON.stringify(c),o+=Li(Y.POS_INT,s,Fi.encode(c).length,n));break;case Y.ARRAY:{o+=`[`;let e=Li(Y.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
3
- ${Pi.repeat(a.depth)}]`:a.close=`]`;break}case Y.MAP:{o+=`{`;let e=Li(Y.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
4
- ${Pi.repeat(a.depth)}}`:a.close=`}`;break}case Y.TAG:o+=String(c),o+=Li(Y.POS_INT,s,c,n),o+=`(`,a.close=`)`;break}if(a===Kn.BREAK)if(i?.isStreaming)i.left=0;else throw Error(`Unexpected BREAK`);else i&&(i.count++,i.left--);for(a instanceof Ii&&(i=a);i?.done;){if(i.isEmptyStream)o=o.slice(0,-3),o+=`${i.quote}${i.quote}_`;else{if(i.mt===Y.MAP&&i.count%2!=0)throw Error(`Odd streaming map size: ${i.count}`);o+=i.close}i=i.parent}}return o}var zi=new TextDecoder,Bi=class extends Ni{depth=0;leaf=!1;value;length;[Kn.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 Z.ONE:return 1;case Z.TWO:return 2;case Z.FOUR:return 4;case Z.EIGHT:return 8}return 0}};function Vi(e){return e instanceof Bi}function Hi(e,t){return e===1/0?`Indefinite`:t?`${e} ${t}${e!==1&&e!==1n?`s`:``}`:String(e)}function Ui(e){return``.padStart(e,` `)}function Wi(e,t,n){let r=``;r+=Ui(e.depth*2);let i=Jn(e);r+=ir(i.subarray(0,1));let a=e.numBytes();a&&(r+=` `,r+=ir(i.subarray(1,a+1))),r=r.padEnd(t.minCol+1,` `),r+=`-- `,n!==void 0&&(r+=Ui(e.depth*2),n!==``&&(r+=`[${n}] `));let o=!1,[s]=e.children;switch(e.mt){case Y.POS_INT:r+=`Unsigned: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case Y.NEG_INT:r+=`Negative: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case Y.BYTE_STRING:r+=`Bytes (Length: ${Hi(e.length)})`;break;case Y.UTF8_STRING:r+=`UTF8 (Length: ${Hi(e.length)})`,e.length!==1/0&&(r+=`: ${JSON.stringify(s)}`);break;case Y.ARRAY:r+=`Array (Length: ${Hi(e.value,`item`)})`;break;case Y.MAP:r+=`Map (Length: ${Hi(e.value,`pair`)})`;break;case Y.TAG:{r+=`Tag #${e.value}`;let n=e.children,[a]=n.contents.children,s=new Q(n.tag,a);Xn(s,i);let c=s.comment(t,e.depth);c&&(r+=`: `,r+=c),o||=s.noChildren;break}case Y.SIMPLE_FLOAT:s===Kn.BREAK?r+=`BREAK`:e.ai>Z.ONE?Object.is(s,-0)?r+=`Float: -0`:r+=`Float: ${s}`:(r+=`Simple: `,s instanceof Di?r+=s.value:r+=s);break}if(!o)if(e.leaf){if(r+=`
5
- `,i.length>a+1){let n=Ui((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+=Ui(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+=Ri(a),r+=` >>
6
- `,r+=Ki(a,{initialDepth:e.depth+1,minCol:t.minCol,noPrefixHex:!0});continue}else u===`'`&&(r+=Ui(t.minCol+1),r+=`--`,r+=n,r+=`'`,r+=zi.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+=ir(i.subarray(e,t)),r+=`
8
- `}}}else for(let e=a+1;e<i.length;e+=8)r+=n,r+=ir(i.subarray(e,e+8)),r+=`
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),e=null),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,ee,C,w=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},ee=h.exports,C=o(ee)})),T=t(((e,t)=>{t.exports=n().EventEmitter})),E=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);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),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=ee,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(be(e,s)||e&&be(e.buffer,s)||c!==void 0&&(be(e,c)||e&&be(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=C(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(be(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`||xe(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 ee(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(be(e,o)&&(e=d.from(e,e.offset,e.byteLength)),be(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)},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(be(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 C(e,t){if(d.isBuffer(e))return e.length;if(s.isView(e)||be(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 ge(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ye(e).length;default:if(i)return r?-1:ge(e).length;t=(``+t).toLowerCase(),i=!0}}d.byteLength=C;function w(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 N(this,t,n);case`utf8`:case`utf-8`:return ie(this,t,n);case`ascii`:return ae(this,t,n);case`latin1`:case`binary`:return oe(this,t,n);case`base64`:return A(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return P(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function T(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)T(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)T(this,t,t+3),T(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)T(this,t,t+7),T(this,t+1,t+6),T(this,t+2,t+5),T(this,t+3,t+4);return this},d.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ie(this,0,e):w.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(be(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)};function E(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,xe(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:D(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):D(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function D(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 E(this,e,t,n,!0)},d.prototype.lastIndexOf=function(e,t,n){return E(this,e,t,n,!1)};function te(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(xe(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return H(ge(t,e.length-n),e,n,r)}function ne(e,t,n,r){return H(_e(t),e,n,r)}function k(e,t,n,r){return H(ye(t),e,n,r)}function re(e,t,n,r){return H(ve(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 te(this,e,t,n);case`utf8`:case`utf-8`:return O(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return ne(this,e,t,n);case`base64`:return k(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return re(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 A(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ie(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 M(r)}let j=4096;function M(e){let t=e.length;if(t<=j)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=j));return n}function ae(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 oe(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 N(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+=Se[e[r]];return i}function P(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 F(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||F(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||F(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||F(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||F(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||F(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||F(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||F(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=U(function(e){e>>>=0,V(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(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=U(function(e){e>>>=0,V(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(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||F(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||F(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||F(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||F(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||F(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||F(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||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=U(function(e){e>>>=0,V(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(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=U(function(e){e>>>=0,V(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&pe(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||F(e,4,this.length),r.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||F(e,4,this.length),r.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||F(e,8,this.length),r.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||F(e,8,this.length),r.read(this,e,!1,52,8)};function I(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;I(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;I(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||I(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||I(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||I(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||I(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||I(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 se(e,t,n,r,i){fe(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 L(e,t,n,r,i){fe(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=U(function(e,t=0){return se(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=U(function(e,t=0){return L(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);I(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);I(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||I(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||I(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||I(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||I(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||I(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=U(function(e,t=0){return se(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=U(function(e,t=0){return L(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function ce(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function R(e,t,n,i,a){return t=+t,n>>>=0,a||ce(e,t,n,4),r.write(e,t,n,i,23,4),n+4}d.prototype.writeFloatLE=function(e,t,n){return R(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return R(this,e,t,!1,n)};function z(e,t,n,i,a){return t=+t,n>>>=0,a||ce(e,t,n,8),r.write(e,t,n,i,52,8),n+8}d.prototype.writeDoubleLE=function(e,t,n){return z(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return z(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 le={};function ue(e,t,n){le[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}`}}}ue(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),ue(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),ue(`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=B(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=B(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function B(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function de(e,t,n){V(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&pe(t,e.length-(n+1))}function fe(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 le.ERR_OUT_OF_RANGE(`value`,i,e)}de(r,i,a)}function V(e,t){if(typeof e!=`number`)throw new le.ERR_INVALID_ARG_TYPE(t,`number`,e)}function pe(e,t,n){throw Math.floor(e)===e?t<0?new le.ERR_BUFFER_OUT_OF_BOUNDS:new le.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(V(e,n),new le.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let me=/[^+/0-9A-Za-z-_]/g;function he(e){if(e=e.split(`=`)[0],e=e.trim().replace(me,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function ge(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 _e(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ve(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 ye(e){return t.toByteArray(he(e))}function H(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 be(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function xe(e){return e!==e}let Se=(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 U(e){return typeof BigInt>`u`?Ce:e}function Ce(){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})),D=t(((e,t)=>{t.exports={}})),te=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=E().Buffer,d=D().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}()})),O=t(((e,t)=>{w();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,C.nextTick(o,this,e)):C.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?C.nextTick(i,n):(n._writableState.errorEmitted=!0,C.nextTick(r,n,e)):C.nextTick(r,n,e):t?(C.nextTick(i,n),t(e)):C.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}})),ne=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})),k=t(((e,t)=>{var n=ne().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}})),re=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`}})),A=t(((e,t)=>{a(),w(),t.exports=M;function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){V(t,e)}}var o;M.WritableState=A;var s={deprecate:re()},c=T(),l=E().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=O(),m=k().getHighWaterMark,h=ne().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,ee=h.ERR_UNKNOWN_ENCODING,D=p.errorOrDestroy;r()(M,c);function te(){}function A(e,t,r){o||=ie(),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;var i=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){L(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)}A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(A.prototype,`buffer`,{get:s.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var j;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(j=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(e){return j.call(this,e)?!0:this===M?e&&e._writableState instanceof A:!1}})):j=function(e){return e instanceof this};function M(e){o||=ie();var t=this instanceof o;if(!t&&!j.call(M,this))return new M(e);this._writableState=new A(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)}M.prototype.pipe=function(){D(this,new y)};function ae(e,t){var n=new S;D(e,n),C.nextTick(t,n)}function oe(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?(D(e,i),C.nextTick(r,i),!1):!0}M.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=te),r.ending?ae(this,n):(a||oe(this,r,e,n))&&(r.pendingcb++,i=P(this,r,a,e,t,n)),i},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&z(this,e))},M.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 ee(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(M.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function N(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(M.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function P(e,t,n,r,i,a){if(!n){var o=N(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 F(e,t,!1,s,r,i,a);return c}function F(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 I(e,t,n,r,i){--t.pendingcb,n?(C.nextTick(i,r),C.nextTick(de,e,t),e._writableState.errorEmitted=!0,D(e,r)):(i(r),e._writableState.errorEmitted=!0,D(e,r),de(e,t))}function se(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function L(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new v;if(se(n),t)I(e,n,r,t,i);else{var a=le(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&z(e,n),r?C.nextTick(ce,e,n,a,i):ce(e,n,a,i)}}function ce(e,t,n,r){n||R(e,t),t.pendingcb--,r(),de(e,t)}function R(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function z(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,F(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(F(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}M.prototype._write=function(e,t,n){n(new _(`_write()`))},M.prototype._writev=null,M.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||fe(this,r,n),this},Object.defineProperty(M.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function le(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function ue(e,t){e._final(function(n){t.pendingcb--,n&&D(e,n),t.prefinished=!0,e.emit(`prefinish`),de(e,t)})}function B(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,C.nextTick(ue,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function de(e,t){var n=le(t);if(n&&(B(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 fe(e,t,n){t.ending=!0,de(e,t),n&&(t.finished?C.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function V(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(M.prototype,`destroyed`,{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),M.prototype.destroy=p.destroy,M.prototype._undestroy=p.undestroy,M.prototype._destroy=function(e,t){t(e)}})),ie=t(((e,t)=>{w();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var i=P(),a=A();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||C.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)}})})),j=t(((e,t)=>{var n=E(),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)}})),M=t((e=>{var t=j().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):``}})),ae=t(((e,t)=>{var n=ne().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})),oe=t(((e,t)=>{w();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=ae(),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){C.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){C.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}})),N=t(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),P=t(((e,t)=>{a(),w(),t.exports=I;var o;I.ReadableState=F,n().EventEmitter;var s=function(e,t){return e.listeners(t).length},c=T(),l=E().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=D(),m=p&&p.debuglog?p.debuglog(`stream`):function(){},h=te(),g=O(),_=k().getHighWaterMark,v=ne().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,ee,re,A;r()(I,c);var j=g.errorOrDestroy,ae=[`error`,`close`,`destroy`,`pause`,`resume`];function P(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 F(e,t,n){o||=ie(),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&&(ee||=M().StringDecoder,this.decoder=new ee(e.encoding),this.encoding=e.encoding)}function I(e){if(o||=ie(),!(this instanceof I))return new I(e);var t=this instanceof o;this._readableState=new F(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(I.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),I.prototype.destroy=g.destroy,I.prototype._undestroy=g.undestroy,I.prototype._destroy=function(e,t){t(e)},I.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),se(this,e,t,!1,r)},I.prototype.unshift=function(e){return se(this,e,null,!0,!1)};function se(e,t,n,r,i){m(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,ue(e,a);else{var o;if(i||(o=ce(a,t)),o)j(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?j(e,new S):L(e,a,t,!0);else if(a.ended)j(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?L(e,a,t,!1):fe(e,a)):L(e,a,t,!1);else r||(a.reading=!1,fe(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function L(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&&B(e)),fe(e,t)}function ce(e,t){var n;return!f(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new y(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}I.prototype.isPaused=function(){return this._readableState.flowing===!1},I.prototype.setEncoding=function(e){ee||=M().StringDecoder;var t=new ee(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 R=1073741824;function z(e){return e>=R?e=R:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function le(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=z(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}I.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?H(this):B(this),null;if(e=le(e,t),e===0&&t.ended)return t.length===0&&H(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=le(n,t)));var i=e>0?ye(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&&H(this)),i!==null&&this.emit(`data`,i),i};function ue(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?B(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,de(e)))}}function B(e){var t=e._readableState;m(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(m(`emitReadable`,t.flowing),t.emittedReadable=!0,C.nextTick(de,e))}function de(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,ve(e)}function fe(e,t){t.readingMore||(t.readingMore=!0,C.nextTick(V,e,t))}function V(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}I.prototype._read=function(e){j(this,new x(`_read()`))},I.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!==C.stdout&&e!==C.stderr?o:g;r.endEmitted?C.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=pe(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&&xe(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&&j(e,t)}P(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 pe(e){return function(){var t=e._readableState;m(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&s(e,`data`)&&(t.flowing=!0,ve(e))}}I.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=xe(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)},I.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?B(this):r.reading||C.nextTick(he,this)),n},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(e,t){var n=c.prototype.removeListener.call(this,e,t);return e===`readable`&&C.nextTick(me,this),n},I.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&C.nextTick(me,this),t};function me(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 he(e){m(`readable nexttick read 0`),e.read(0)}I.prototype.resume=function(){var e=this._readableState;return e.flowing||(m(`resume`),e.flowing=!e.readableListening,ge(this,e)),e.paused=!1,this};function ge(e,t){t.resumeScheduled||(t.resumeScheduled=!0,C.nextTick(_e,e,t))}function _e(e,t){m(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),ve(e),t.flowing&&!t.reading&&e.read(0)}I.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 ve(e){var t=e._readableState;for(m(`flow`,t.flowing);t.flowing&&e.read()!==null;);}I.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<ae.length;a++)e.on(ae[a],this.emit.bind(this,ae[a]));return this._read=function(t){m(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(I.prototype[Symbol.asyncIterator]=function(){return re===void 0&&(re=oe()),re(this)}),Object.defineProperty(I.prototype,`readableHighWaterMark`,{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(I.prototype,`readableBuffer`,{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(I.prototype,`readableFlowing`,{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),I._fromList=ye,Object.defineProperty(I.prototype,`readableLength`,{enumerable:!1,get:function(){return this._readableState.length}});function ye(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 H(e){var t=e._readableState;m(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,C.nextTick(be,t,e))}function be(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`&&(I.from=function(e,t){return A===void 0&&(A=N()),A(I,e,t)});function xe(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),F=t(((e,t)=>{t.exports=u;var n=ne().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=ie();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)}})),I=t(((e,t)=>{t.exports=i;var n=F();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)}})),se=t(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=ne().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=ae()),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})),L=t(((e,t)=>{t.exports=a;var i=n().EventEmitter;r()(a,i),a.Readable=P(),a.Writable=A(),a.Duplex=ie(),a.Transform=F(),a.PassThrough=I(),a.finished=ae(),a.pipeline=se(),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}}))(),ce=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,R=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=ce[n[e]&63];return t},z={},le={};le.byteLength=he,le.toByteArray=_e,le.fromByteArray=H;for(var ue=[],B=[],de=typeof Uint8Array<`u`?Uint8Array:Array,fe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,V=0,pe=fe.length;V<pe;++V)ue[V]=fe[V],B[fe.charCodeAt(V)]=V;B[45]=62,B[95]=63;function me(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 he(e){var t=me(e),n=t[0],r=t[1];return(n+r)*3/4-r}function ge(e,t,n){return(t+n)*3/4-n}function _e(e){var t,n=me(e),r=n[0],i=n[1],a=new de(ge(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=B[e.charCodeAt(c)]<<18|B[e.charCodeAt(c+1)]<<12|B[e.charCodeAt(c+2)]<<6|B[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=B[e.charCodeAt(c)]<<2|B[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=B[e.charCodeAt(c)]<<10|B[e.charCodeAt(c+1)]<<4|B[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function ve(e){return ue[e>>18&63]+ue[e>>12&63]+ue[e>>6&63]+ue[e&63]}function ye(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(ve(r));return i.join(``)}function H(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(ye(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(ue[t>>2]+ue[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(ue[t>>10]+ue[t>>4&63]+ue[t<<2&63]+`=`)),i.join(``)}var be={};be.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)},be.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);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),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=le,n=be,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(H(e,o)||e&&H(e.buffer,o)||s!==void 0&&(H(e,s)||e&&H(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(H(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`||xe(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(H(e,a)&&(e=u.from(e,e.offset,e.byteLength)),H(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)},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(H(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)||H(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 he(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ve(e).length;default:if(i)return r?-1:he(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=S;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 ae(this,t,n);case`utf8`:case`utf-8`:return re(this,t,n);case`ascii`:return j(this,t,n);case`latin1`:case`binary`:return M(this,t,n);case`base64`:return k(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return oe(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function C(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)C(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)C(this,t,t+3),C(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)C(this,t,t+7),C(this,t+1,t+6),C(this,t+2,t+5),C(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?re(this,0,e):ee.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(H(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)};function w(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,xe(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:T(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):T(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function T(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 w(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return w(this,e,t,n,!1)};function E(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(xe(r))return o;e[n+o]=r}return o}function D(e,t,n,r){return ye(he(t,e.length-n),e,n,r)}function te(e,t,n,r){return ye(ge(t),e,n,r)}function O(e,t,n,r){return ye(ve(t),e,n,r)}function ne(e,t,n,r){return ye(_e(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 E(this,e,t,n);case`utf8`:case`utf-8`:return D(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return te(this,e,t,n);case`base64`:return O(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ne(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 k(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function re(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 ie(r)}let A=4096;function ie(e){let t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=A));return n}function j(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 M(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 ae(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+=Se[e[r]];return i}function oe(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 N(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||N(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||N(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||N(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(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||N(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=U(function(e){e>>>=0,fe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&V(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=U(function(e){e>>>=0,fe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&V(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||N(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||N(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||N(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||N(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||N(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||N(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||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=U(function(e){e>>>=0,fe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&V(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=U(function(e){e>>>=0,fe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&V(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||N(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),n.read(this,e,!1,52,8)};function P(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;P(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;P(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||P(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||P(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||P(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||P(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||P(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 F(e,t,n,r,i){de(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 I(e,t,n,r,i){de(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=U(function(e,t=0){return F(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=U(function(e,t=0){return I(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);P(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);P(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||P(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||P(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||P(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||P(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||P(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=U(function(e,t=0){return F(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=U(function(e,t=0){return I(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function se(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function L(e,t,r,i,a){return t=+t,r>>>=0,a||se(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)};function ce(e,t,r,i,a){return t=+t,r>>>=0,a||se(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return ce(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return ce(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 R={};function z(e,t,n){R[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}`}}}z(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),z(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),z(`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=ue(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ue(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ue(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function B(e,t,n){fe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&V(t,e.length-(n+1))}function de(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 R.ERR_OUT_OF_RANGE(`value`,i,e)}B(r,i,a)}function fe(e,t){if(typeof e!=`number`)throw new R.ERR_INVALID_ARG_TYPE(t,`number`,e)}function V(e,t,n){throw Math.floor(e)===e?t<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(fe(e,n),new R.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let pe=/[^+/0-9A-Za-z-_]/g;function me(e){if(e=e.split(`=`)[0],e=e.trim().replace(pe,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function he(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 ge(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function _e(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 ve(e){return t.toByteArray(me(e))}function ye(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 H(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function xe(e){return e!==e}let Se=(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 U(e){return typeof BigInt>`u`?Ce:e}function Ce(){throw Error(`BigInt not supported`)}})(z);var xe=z.Buffer;z.Blob,z.BlobOptions;var Se=z.Buffer;z.File,z.FileOptions,z.INSPECT_MAX_BYTES,z.SlowBuffer,z.TranscodeEncoding,z.atob,z.btoa,z.constants,z.isAscii,z.isUtf8,z.kMaxLength,z.kStringMaxLength,z.resolveObjectURL,z.transcode;var U=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)}},Ce=U.default??U,we=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=r=>{if(e&&e.removeEventListener(`abort`,i),r){n(Error(`credit gate aborted`));return}this.remaining--,t()},i=()=>{let t=this.waiters.indexOf(r);t!==-1&&this.waiters.splice(t,1),n(e?.reason??Error(`aborted`))};if(e&&e.addEventListener(`abort`,i,{once:!0}),e?.aborted){e.removeEventListener(`abort`,i),n(e.reason??Error(`aborted`));return}this.waiters.push(r)})}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)}},Te=new TextEncoder;function Ee(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 De(e){let t;if(e instanceof Se)t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=Te.encode(e);else throw Error(`invalid chunk type: expected Buffer, Uint8Array, or string`);return t}var Oe=class extends L.Readable{constructor(e){let t=e?.read;super({...e,read:()=>{}}),this._chunks=[],this._collecting=!0,this._onRead=t,this.buffer=new Promise((e,t)=>{this._resolve=e,this._reject=t}),this.buffer.catch(()=>{}),this.on(`error`,e=>{this._collecting&&(this._collecting=!1,this._reject(e))})}push(e,t){return this._collecting&&(e===null?(this._collecting=!1,this._resolve(Ee(this._chunks))):e!==void 0&&this._chunks.push(De(e))),super.push(e,t)}read(e){return this._onRead?.(e??0),super.read(e)}get collecting(){return this._collecting}stopCollecting(){this._collecting&&(this._reject(Error(`collecting stopped`)),this._collecting=!1,this._chunks.length=0)}};async function ke(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 Ae(e,t,n,r,i){let a;for await(let o of e){if(i?.aborted)throw i.reason??Error(`aborted`);let e=De(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 je(e,t,n,r){if(!(typeof e==`object`&&e))throw Error(`invalid object`);let i,a=e[t],o=e[n];Object.defineProperty(e,t,{get:()=>{if(i===`f2`)throw Error(`field "${t}" is mutually exclusive with field "${n}" and "${n}" was already consumed`);return i||r?.(t),i=`f1`,a},enumerable:!0,configurable:!0}),Object.defineProperty(e,n,{get:()=>{if(i===`f1`)throw Error(`field "${n}" is mutually exclusive with field "${t}" and "${t}" was already consumed`);return i||r?.(n),i=`f2`,o},enumerable:!0,configurable:!0})}var Me=class e{constructor(){this.resources=[],this.pending=null}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,e=>e.unroll()),t}unroll(e=!0){if(this.pending!==null)return e?this.pending.catch(()=>{}):this.pending;let t=this.resources;this.resources=[];let n=[],r;for(;t.length>0;){let e=t.pop(),i=e.resource,a=e.cleanup;if(r)r=r.then(()=>a(i)).catch(e=>{n.push(e)});else try{let e=a(i);e instanceof Promise&&(r=e.catch(e=>{n.push(e)}))}catch(e){n.push(e)}}if(r)return this.pending=r.then(()=>{if(n.length===1)throw n[0];if(n.length>1)throw AggregateError(n,`multiple cleanup failures`)}).finally(()=>{this.pending=null}),e?this.pending.catch(()=>{}):this.pending;if(!e&&n.length===1)throw n[0];if(!e&&n.length>1)throw AggregateError(n,`multiple cleanup failures`)}};function W(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 Ne(e,t,n){if(!t)return e?Promise.resolve():void 0;let r;try{r=t()}catch(t){if(e)return Promise.reject(W(t,n));throw W(t,n)}if(!e&&r instanceof Promise)throw Error(`onfinally callback returned Promise in non-async context`);return e&&!(r instanceof Promise)&&(r=Promise.resolve(r)),e&&r instanceof Promise?r.catch(e=>{throw W(e,n)}):r}function Pe(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 Fe(...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 Me||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 Me||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=W(e,t);if(i){try{s=i(r)}catch(e){throw r=W(e,t),Ne(!1,a,t),Pe(!1,n),r}return Ne(!1,a,t),s}throw Ne(!1,a,t),Pe(!1,n),r}return s instanceof Promise?s.then(async e=>(await Ne(!0,a,t),n&&o&&n.roll(e,o),e),async e=>{let r=W(e,t);if(i)try{let e=await i(r);return await Ne(!0,a,t),e}catch(e){throw r=W(e,t),await Ne(!0,a,t),await Pe(!0,n),r}throw await Ne(!0,a,t),await Pe(!0,n),r}):(Ne(!1,a,t),n&&o&&n.roll(s,o),s)}var Ie=new TextEncoder,Le=new TextDecoder;function Re(...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 ze(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 Be(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 Ve(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 He(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Le.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Le.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Ve(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function Ue(e){let t=e;return typeof t==`string`&&(t=Ie.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):Be(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var We=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)}},Ge=class extends We{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}},Ke=class extends We{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}},qe=class extends We{static code=`ERR_JOSE_ALG_NOT_ALLOWED`;code=`ERR_JOSE_ALG_NOT_ALLOWED`},Je=class extends We{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},G=class extends We{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},Ye=class extends We{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`},Xe=class extends We{static code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;constructor(e=`signature verification failed`,t){super(e,t)}},Ze=(e,t=`algorithm.name`)=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`),Qe=(e,t)=>e.name===t;function $e(e){return parseInt(e.name.slice(4),10)}function et(e,t){if($e(e.hash)!==t)throw Ze(`SHA-${t}`,`algorithm.hash`)}function tt(e){switch(e){case`ES256`:return`P-256`;case`ES384`:return`P-384`;case`ES512`:return`P-521`;default:throw Error(`unreachable`)}}function nt(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function rt(e,t,n){switch(t){case`HS256`:case`HS384`:case`HS512`:if(!Qe(e.algorithm,`HMAC`))throw Ze(`HMAC`);et(e.algorithm,parseInt(t.slice(2),10));break;case`RS256`:case`RS384`:case`RS512`:if(!Qe(e.algorithm,`RSASSA-PKCS1-v1_5`))throw Ze(`RSASSA-PKCS1-v1_5`);et(e.algorithm,parseInt(t.slice(2),10));break;case`PS256`:case`PS384`:case`PS512`:if(!Qe(e.algorithm,`RSA-PSS`))throw Ze(`RSA-PSS`);et(e.algorithm,parseInt(t.slice(2),10));break;case`Ed25519`:case`EdDSA`:if(!Qe(e.algorithm,`Ed25519`))throw Ze(`Ed25519`);break;case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:if(!Qe(e.algorithm,t))throw Ze(t);break;case`ES256`:case`ES384`:case`ES512`:{if(!Qe(e.algorithm,`ECDSA`))throw Ze(`ECDSA`);let n=tt(t);if(e.algorithm.namedCurve!==n)throw Ze(n,`algorithm.namedCurve`);break}default:throw TypeError(`CryptoKey does not support this operation`)}nt(e,n)}function it(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 at=(e,...t)=>it(`Key must be `,e,...t),ot=(e,t,...n)=>it(`Key for the ${e} algorithm must be `,t,...n);function st(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 ct(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 Je(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}async function lt(e,t,n){if(t instanceof Uint8Array){if(!e.startsWith(`HS`))throw TypeError(at(t,`CryptoKey`,`KeyObject`,`JSON Web Key`));return crypto.subtle.importKey(`raw`,t,{hash:`SHA-${e.slice(-3)}`,name:`HMAC`},!1,[n])}return rt(t,e,n),t}async function ut(e,t,n){let r=await lt(e,t,`sign`);st(e,r);let i=await crypto.subtle.sign(ct(e,r.algorithm),r,n);return new Uint8Array(i)}async function dt(e,t,n,r){let i=await lt(e,t,`verify`);st(e,i);let a=ct(e,i.algorithm);try{return await crypto.subtle.verify(a,i,n,r)}catch{return!1}}var ft=e=>typeof e==`object`&&!!e;function pt(e){if(!ft(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 mt(...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 ht=e=>pt(e)&&typeof e.kty==`string`,gt=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),_t=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,vt=e=>e.kty===`oct`&&typeof e.k==`string`,yt=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},bt=e=>e?.[Symbol.toStringTag]===`KeyObject`,xt=e=>yt(e)||bt(e),St=e=>e?.[Symbol.toStringTag],Ct=(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},wt=(e,t,n)=>{if(!(t instanceof Uint8Array)){if(ht(t)){if(vt(t)&&Ct(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(!xt(t))throw TypeError(ot(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`));if(t.type!==`secret`)throw TypeError(`${St(t)} instances for symmetric algorithms must be of type "secret"`)}},Tt=(e,t,n)=>{if(ht(t))switch(n){case`decrypt`:case`sign`:if(gt(t)&&Ct(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a private JWK`);case`encrypt`:case`verify`:if(_t(t)&&Ct(e,t,n))return;throw TypeError(`JSON Web Key for this operation must be a public JWK`)}if(!xt(t))throw TypeError(ot(e,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(t.type===`secret`)throw TypeError(`${St(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.type===`public`)switch(n){case`sign`:throw TypeError(`${St(t)} instances for asymmetric algorithm signing must be of type "private"`);case`decrypt`:throw TypeError(`${St(t)} instances for asymmetric algorithm decryption must be of type "private"`)}if(t.type===`private`)switch(n){case`verify`:throw TypeError(`${St(t)} instances for asymmetric algorithm verifying must be of type "public"`);case`encrypt`:throw TypeError(`${St(t)} instances for asymmetric algorithm encryption must be of type "public"`)}};function Et(e,t,n){switch(e.substring(0,2)){case`A1`:case`A2`:case`di`:case`HS`:case`PB`:wt(e,t,n);break;default:Tt(e,t,n)}}function Dt(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 Je(`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 Ot=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function kt(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 Je(Ot)}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 Je(Ot)}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 Je(Ot)}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 Je(Ot)}break;default:throw new Je(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function At(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=kt(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 jt=`given KeyObject instance cannot be used for this algorithm`,Mt,Nt=async(e,t,n,r=!1)=>{Mt||=new WeakMap;let i=Mt.get(e);if(i?.[n])return i[n];let a=await At({...t,alg:n});return r&&Object.freeze(e),i?i[n]=a:Mt.set(e,{[n]:a}),a},Pt=(e,t)=>{Mt||=new WeakMap;let n=Mt.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(jt)}a=e.toCryptoKey(e.asymmetricKeyType,i,r?[]:[`deriveBits`])}if(e.asymmetricKeyType===`ed25519`){if(t!==`EdDSA`&&t!==`Ed25519`)throw TypeError(jt);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(jt);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(jt)}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(jt);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(jt);return n?n[t]=a:Mt.set(e,{[t]:a}),a};async function Ft(e,t){if(e instanceof Uint8Array||yt(e))return e;if(bt(e)){if(e.type===`secret`)return e.export();if(`toCryptoKey`in e&&typeof e.toCryptoKey==`function`)try{return Pt(e,t)}catch(e){if(e instanceof TypeError)throw e}return Nt(e,e.export({format:`jwk`}),t)}if(ht(e))return e.k?He(e.k):Nt(e,e,t,!0);throw Error(`unreachable`)}function It(e,t){if(e)throw TypeError(`${t} can only be called once`)}function Lt(e,t,n){try{return He(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}var Rt=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 It(this.#t,`setProtectedHeader`),this.#t=e,this}setUnprotectedHeader(e){return It(this.#n,`setUnprotectedHeader`),this.#n=e,this}async sign(e,t){if(!this.#t&&!this.#n)throw new G(`either setProtectedHeader or setUnprotectedHeader must be called before #sign()`);if(!mt(this.#t,this.#n))throw new G(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let n={...this.#t,...this.#n},r=Dt(G,new Map([[`b64`,!0]]),t?.crit,this.#t,n),i=!0;if(r.has(`b64`)&&(i=this.#t.b64,typeof i!=`boolean`))throw new G(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:a}=n;if(typeof a!=`string`||!a)throw new G(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);Et(a,e,`sign`);let o,s;i?(o=Ue(this.#e),s=ze(o)):(s=this.#e,o=``);let c,l;this.#t?(c=Ue(JSON.stringify(this.#t)),l=ze(c)):(c=``,l=new Uint8Array);let u=Re(l,ze(`.`),s),d={signature:Ue(await ut(a,await Ft(e,a),u)),payload:o};return this.#n&&(d.header=this.#n),this.#t&&(d.protected=c),d}},zt=class{#e;constructor(e){this.#e=new Rt(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}`}},Bt=e=>Math.floor(e.getTime()/1e3),Vt=60,Ht=Vt*60,Ut=Ht*24,Wt=Ut*7,Gt=Ut*365.25,Kt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;function qt(e){let t=Kt.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*Vt);break;case`hour`:case`hours`:case`hr`:case`hrs`:case`h`:i=Math.round(n*Ht);break;case`day`:case`days`:case`d`:i=Math.round(n*Ut);break;case`week`:case`weeks`:case`w`:i=Math.round(n*Wt);break;default:i=Math.round(n*Gt);break}return t[1]===`-`||t[4]===`ago`?-i:i}function Jt(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}var Yt=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`,Xt=(e,t)=>typeof e==`string`?t.includes(e):Array.isArray(e)?t.some(Set.prototype.has.bind(new Set(e))):!1;function Zt(e,t,n={}){let r;try{r=JSON.parse(Le.decode(t))}catch{}if(!pt(r))throw new Ye(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=n;if(i&&(typeof e.typ!=`string`||Yt(e.typ)!==Yt(i)))throw new Ge(`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 Ge(`missing required "${e}" claim`,r,e,`missing`);if(o&&!(Array.isArray(o)?o:[o]).includes(r.iss))throw new Ge(`unexpected "iss" claim value`,r,`iss`,`check_failed`);if(s&&r.sub!==s)throw new Ge(`unexpected "sub" claim value`,r,`sub`,`check_failed`);if(c&&!Xt(r.aud,typeof c==`string`?[c]:c))throw new Ge(`unexpected "aud" claim value`,r,`aud`,`check_failed`);let d;switch(typeof n.clockTolerance){case`string`:d=qt(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=Bt(f||new Date);if((r.iat!==void 0||l)&&typeof r.iat!=`number`)throw new Ge(`"iat" claim must be a number`,r,`iat`,`invalid`);if(r.nbf!==void 0){if(typeof r.nbf!=`number`)throw new Ge(`"nbf" claim must be a number`,r,`nbf`,`invalid`);if(r.nbf>p+d)throw new Ge(`"nbf" claim timestamp check failed`,r,`nbf`,`check_failed`)}if(r.exp!==void 0){if(typeof r.exp!=`number`)throw new Ge(`"exp" claim must be a number`,r,`exp`,`invalid`);if(r.exp<=p-d)throw new Ke(`"exp" claim timestamp check failed`,r,`exp`,`check_failed`)}if(l){let e=p-r.iat,t=typeof l==`number`?l:qt(l);if(e-d>t)throw new Ke(`"iat" claim timestamp check failed (too far in the past)`,r,`iat`,`check_failed`);if(e<0-d)throw new Ge(`"iat" claim timestamp check failed (it should be in the past)`,r,`iat`,`check_failed`)}return r}var Qt=class{#e;constructor(e){if(!pt(e))throw TypeError(`JWT Claims Set MUST be an object`);this.#e=structuredClone(e)}data(){return Ie.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=Jt(`setNotBefore`,e):e instanceof Date?this.#e.nbf=Jt(`setNotBefore`,Bt(e)):this.#e.nbf=Bt(new Date)+qt(e)}set exp(e){typeof e==`number`?this.#e.exp=Jt(`setExpirationTime`,e):e instanceof Date?this.#e.exp=Jt(`setExpirationTime`,Bt(e)):this.#e.exp=Bt(new Date)+qt(e)}set iat(e){e===void 0?this.#e.iat=Bt(new Date):e instanceof Date?this.#e.iat=Jt(`setIssuedAt`,Bt(e)):typeof e==`string`?this.#e.iat=Jt(`setIssuedAt`,Bt(new Date)+qt(e)):this.#e.iat=Jt(`setIssuedAt`,e)}},$t=class{#e;#t;constructor(e={}){this.#t=new Qt(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 zt(this.#t.data());if(n.setProtectedHeader(this.#e),Array.isArray(this.#e?.crit)&&this.#e.crit.includes(`b64`)&&this.#e.b64===!1)throw new Ye(`JWTs MUST NOT use unencoded payload`);return n.sign(e,t)}};function en(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 tn(e,t,n){if(!pt(e))throw new G(`Flattened JWS must be an object`);if(e.protected===void 0&&e.header===void 0)throw new G(`Flattened JWS must have either of the "protected" or "header" members`);if(e.protected!==void 0&&typeof e.protected!=`string`)throw new G(`JWS Protected Header incorrect type`);if(e.payload===void 0)throw new G(`JWS Payload missing`);if(typeof e.signature!=`string`)throw new G(`JWS Signature missing or incorrect type`);if(e.header!==void 0&&!pt(e.header))throw new G(`JWS Unprotected Header incorrect type`);let r={};if(e.protected)try{let t=He(e.protected);r=JSON.parse(Le.decode(t))}catch{throw new G(`JWS Protected Header is invalid`)}if(!mt(r,e.header))throw new G(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i={...r,...e.header},a=Dt(G,new Map([[`b64`,!0]]),n?.crit,r,i),o=!0;if(a.has(`b64`)&&(o=r.b64,typeof o!=`boolean`))throw new G(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new G(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=n&&en(`algorithms`,n.algorithms);if(c&&!c.has(s))throw new qe(`"alg" (Algorithm) Header Parameter value not allowed`);if(o){if(typeof e.payload!=`string`)throw new G(`JWS Payload must be a string`)}else if(typeof e.payload!=`string`&&!(e.payload instanceof Uint8Array))throw new G(`JWS Payload must be a string or an Uint8Array instance`);let l=!1;typeof t==`function`&&(t=await t(r,e),l=!0),Et(s,t,`verify`);let u=Re(e.protected===void 0?new Uint8Array:ze(e.protected),ze(`.`),typeof e.payload==`string`?o?ze(e.payload):Ie.encode(e.payload):e.payload),d=Lt(e.signature,`signature`,G),f=await Ft(t,s);if(!await dt(s,f,d,u))throw new Xe;let p;p=o?Lt(e.payload,`payload`,G):typeof e.payload==`string`?Ie.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 nn(e,t,n){if(e instanceof Uint8Array&&(e=Le.decode(e)),typeof e!=`string`)throw new G(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new G(`Invalid Compact JWS`);let s=await tn({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 rn(e,t,n){let r=await nn(e,t,n);if(r.protectedHeader.crit?.includes(`b64`)&&r.protectedHeader.b64===!1)throw new Ye(`JWTs MUST NOT use unencoded payload`);let i={payload:Zt(r.protectedHeader,r.payload,n),protectedHeader:r.protectedHeader};return typeof t==`function`?{...i,key:r.key}:i}function an(e){return e.saveState!==void 0&&e.restoreState!==void 0&&e.cleanSavedState!==void 0}function on(e){for(let t=0;t<e.length;t++)e[t]=0;return e}var sn=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),an(this._inner)&&an(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),on(n)}reset(){if(!an(this._inner)||!an(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(){an(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),an(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(!an(this._inner))throw Error(`hmac: can't saveState() because hash doesn't implement it`);return this._inner.saveState()}restoreState(e){if(!an(this._inner)||!an(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(!an(this._inner))throw Error(`hmac: can't cleanSavedState() because hash doesn't implement it`);this._inner.cleanSavedState(e)}};Number.isInteger,Number.isSafeInteger;function cn(e,t=0){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function ln(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 un(e,t,n,r,i){let a=new sn(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++){ln(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 on(c),on(l),on(s),a.cleanSavedState(d),a.clean(),u}var dn=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(){on(this._buffer),on(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&&(pn(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=pn(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;ln(n,this._buffer,i-8),ln(r,this._buffer,i-4),pn(this._temp,this._state,this._buffer,0,i),this._finished=!0}for(let t=0;t<this.digestLength/4;t++)ln(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){on(e.state),e.buffer&&on(e.buffer),e.bufferLength=0,e.bytesHashed=0}},fn=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 pn(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]=cn(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+(fn[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 mn=n(),hn,gn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function _n(e){return!e&&!hn?gn:{lang:e?.lang??hn?.lang,message:e?.message,abortEarly:e?.abortEarly??hn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??hn?.abortPipeEarly}}var vn;function yn(e){return vn?.get(e)}var bn;function xn(e){return bn?.get(e)}var Sn;function Cn(e,t){return Sn?.get(e)?.get(t)}function wn(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 Tn(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??wn(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??Cn(e.reference,c.lang)??(l?xn(c.lang):null)??r.message??yn(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]}var En=new WeakMap;function Dn(e){let t=En.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},_n())}},En.set(e,t)),t}function On(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function kn(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function An(e,t){return{kind:`validation`,type:`check`,reference:An,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Tn(this,`input`,e,t),e}}}function jn(e){return{kind:`validation`,type:`integer`,reference:jn,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Tn(this,`integer`,e,t),e}}}function Mn(e,t){return{kind:`validation`,type:`max_length`,reference:Mn,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Tn(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Nn(e,t){return{kind:`validation`,type:`min_value`,reference:Nn,async:!1,expects:`>=${e instanceof Date?e.toJSON():wn(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Tn(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():wn(e.value)}),e}}}function Pn(e,t){return{kind:`validation`,type:`regex`,reference:Pn,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&Tn(this,`format`,e,t),e}}}function Fn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function In(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Ln(e,t){return{kind:`schema`,type:`array`,reference:Ln,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 Tn(this,`type`,e,t);return e}}}function Rn(e){return{kind:`schema`,type:`boolean`,reference:Rn,expects:`boolean`,async:!1,message:e,get"~standard"(){return Dn(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Tn(this,`type`,e,t),e}}}function zn(e,t){return{kind:`schema`,type:`instance`,reference:zn,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:Tn(this,`type`,e,t),e}}}function Bn(e,t){return{kind:`schema`,type:`literal`,reference:Bn,expects:wn(e),async:!1,literal:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Tn(this,`type`,e,t),e}}}function Vn(e){return{kind:`schema`,type:`number`,reference:Vn,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:Tn(this,`type`,e,t),e}}}function K(e,t){return{kind:`schema`,type:`optional`,reference:K,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=In(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Hn(e,t){return{kind:`schema`,type:`picklist`,reference:Hn,expects:kn(e.map(wn),`|`),async:!1,options:e,message:t,get"~standard"(){return Dn(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Tn(this,`type`,e,t),e}}}function Un(e,t,n){return{kind:`schema`,type:`record`,reference:Un,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 Tn(this,`type`,e,t);return e}}}function Wn(e,t){return{kind:`schema`,type:`strict_object`,reference:Wn,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]:In(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]=Fn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Tn(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)){Tn(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else Tn(this,`type`,e,t);return e}}}function q(e){return{kind:`schema`,type:`string`,reference:q,expects:`string`,async:!1,message:e,get"~standard"(){return Dn(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Tn(this,`type`,e,t),e}}}function Gn(){return{kind:`schema`,type:`unknown`,reference:Gn,expects:`unknown`,async:!1,get"~standard"(){return Dn(this)},"~run"(e){return e.typed=!0,e}}}function Kn(...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 qn(e,t,n){let r=e[`~run`]({value:t},_n(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var J={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},Y={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},X={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Jn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},Z=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`)},Yn={MIN:-(2n**63n),MAX:2n**64n-1n},Q=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 Xn(e){if(typeof e==`object`&&e)return e[Z.ENCODED]}function Zn(e){if(typeof e==`object`&&e)return e[Z.LENGTH]}function Qn(e,t){Object.defineProperty(e,Z.ENCODED,{configurable:!0,enumerable:!1,value:t})}function $n(e,t){let n=Object(e);return Qn(n,t),n}var er=Symbol(`CBOR_RANGES`);function tr(e,t){Object.defineProperty(e,er,{configurable:!1,enumerable:!1,writable:!1,value:t})}function nr(e){return e[er]}function rr(e){return nr(e)!==void 0}function ir(e,t=0,n=e.length-1){let r=e.subarray(t,n),i=nr(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&&tr(r,e)}return r}function ar(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 or(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function sr(e){let t=e.reduce((e,t)=>e+t.length,0),n=e.some(e=>rr(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[er]??[[0,t.length]];for(let t of e)t[0]+=a;r.push(...e)}a+=t.length}return n&&tr(i,r),i}function cr(e){let t=atob(e);return Uint8Array.from(t,e=>e.codePointAt(0))}var lr={"-":`+`,_:`/`};function ur(e){let t=e.replace(/[_-]/g,e=>lr[e]);return cr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function dr(){let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])}function fr(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 pr=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 mr(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 hr=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}},gr=1n<<15n,_r=31n<<10n,vr=1n<<9n,yr=vr-1n,br=vr|yr,xr=1n<<31n,Sr=255n<<23n,Cr=1n<<22n,wr=Cr-1n,Tr=Cr|wr,Er=1n<<63n,Dr=2047n<<52n,Or=1n<<51n,kr=Or-1n,Ar=Or|kr,jr=kr-(yr<<42n),Mr=kr-(wr<<29n),Nr={2:`0b`,8:`0o`,16:`0x`},Pr=(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))(Pr||{});function Fr(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 Ir=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=Er,e=-e),e>=Or)throw Error(`Payload too large: ${r}`);let a=t?Or:0n;switch(this.#e=i|Dr|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&jr)throw Error(`Invalid size for payload`);break;case 4:if(this.#e&Mr)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&Dr)===Dr)this.#e=e,t=8;else if((e&Sr)===Sr){let n=(e&xr)<<32n;this.#e=n|Dr|(e&Tr)<<29n,t=4}else if((e&_r)===_r){let n=(e&gr)<<48n;this.#e=n|Dr|(e&br)<<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&_r)!==_r)throw Error(`Not a NaN`);let r=(n&gr)<<48n;this.#e=r|Dr|(n&br)<<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&Sr)!==Sr)throw Error(`Not a NaN`);let r=(n&xr)<<32n;this.#e=r|Dr|(n&Tr)<<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&Dr)!==Dr)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&Er?gr:0n)|_r|(this.#e&Ar)>>42n;t.setUint16(1,Number(e),!1);break}case 4:{t.setUint8(0,250);let e=(this.#e&Er?xr:0n)|Sr|(this.#e&Ar)>>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&Or)}get sign(){return this.#e&Er?-1:1}get payload(){return Number(this.#e&kr)*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&jr)===0n?2:(this.#e&Mr)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return Fr(this,1,{},t=>(Nr[e]??``)+t.toString(e))}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return Fr(this,e,t,n)}};function Lr(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 Rr(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 zr(e){if(e!==0){let t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e,!1);let n=t.getBigUint64(0,!1);if((n&9218868437227405312n)==0n)return n&9223372036854775808n?-0:0}return e}function Br(e){switch(e.length){case 2:Lr(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 Vr=class extends TypeError{code=`ERR_ENCODING_INVALID_ENCODED_DATA`;constructor(){super(`The encoded data was not valid for encoding wtf-8`)}},Hr=class extends RangeError{code=`ERR_ENCODING_NOT_SUPPORTED`;constructor(e){super(`Invalid encoding: "${e}"`)}},Ur=new Uint8Array,Wr=55296,Gr=56320,Kr=65533,qr=`wtf-8`;function Jr(e){return e&&typeof e==`object`&&!(e instanceof ArrayBuffer)&&!(e instanceof SharedArrayBuffer)&&e.buffer instanceof ArrayBuffer}function Yr(e){return e?e instanceof Uint8Array?e:Jr(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e):Ur}var Xr=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3],Zr=class e{static DEFAULT_BUFFERSIZE=4096;encoding=qr;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 Hr(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=Yr(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 Vr;a[s++]=Kr},l=()=>{let e=this.#n;for(let t=0;t<e;t++)c()},u=e=>{if(this.#e===0)switch(Xr[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|Wr,a[s++]=e&1023|Gr}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 Qr(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 $r=class{encoding=qr;encode(e){if(!e)return Ur;let t=new Uint8Array(Qr(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:ei}=Z,ti=J.SIMPLE_FLOAT<<5|X.TWO,ni=J.SIMPLE_FLOAT<<5|X.FOUR,ri=J.SIMPLE_FLOAT<<5|X.EIGHT,ii=J.SIMPLE_FLOAT<<5|Jn.TRUE,ai=J.SIMPLE_FLOAT<<5|Jn.FALSE,oi=J.SIMPLE_FLOAT<<5|Jn.UNDEFINED,si=J.SIMPLE_FLOAT<<5|Jn.NULL,ci=new TextEncoder,li=new $r,ui={...hr.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:Y.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},di={cde:!0,ignoreOriginalEncoding:!0,sortKeys:mr},fi={...di,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:`NFC`};function pi(e){let t=e<0;return typeof e==`bigint`?[t?-e-1n:e,t]:[t?-e-1:e,t]}function mi(e,t,n){if(n.rejectFloats)throw Error(`Attempt to encode an unwanted floating point number: ${e}`);if(isNaN(e))t.writeUint8(ti),t.writeUint16(32256);else if(!n.float64&&Math.fround(e)===e){let n=Rr(e);n===null?(t.writeUint8(ni),t.writeFloat32(e)):(t.writeUint8(ti),t.writeUint16(n))}else t.writeUint8(ri),t.writeFloat64(e)}function hi(e,t,n){let[r,i]=pi(e);if(i&&n)throw TypeError(`Negative size: ${e}`);n??=i?J.NEG_INT:J.POS_INT,n<<=5,r<24?t.writeUint8(n|r):r<=255?(t.writeUint8(n|X.ONE),t.writeUint8(r)):r<=65535?(t.writeUint8(n|X.TWO),t.writeUint16(r)):r<=4294967295?(t.writeUint8(n|X.FOUR),t.writeUint32(r)):(t.writeUint8(n|X.EIGHT),t.writeBigUint64(BigInt(r)))}function gi(e,t,n){typeof e==`number`?hi(e,t,J.TAG):typeof e==`object`&&!n.ignoreOriginalEncoding&&Z.ENCODED in e?t.write(e[Z.ENCODED]):e<=2**53-1?hi(Number(e),t,J.TAG):(t.writeUint8(J.TAG<<5|X.EIGHT),t.writeBigUint64(BigInt(e)))}function _i(e,t,n){let[r,i]=pi(e);if(n.collapseBigInts&&(!n.largeNegativeAsBigInt||e>=-9223372036854775808n)){if(r<=4294967295n){hi(Number(e),t);return}if(r<=18446744073709551615n){let e=(i?J.NEG_INT:J.POS_INT)<<5;t.writeUint8(e|X.EIGHT),t.writeBigUint64(r);return}}if(n.rejectBigInts)throw Error(`Attempt to encode unwanted bigint: ${e}`);let a=i?Y.NEG_BIGINT:Y.POS_BIGINT,o=r.toString(16),s=o.length%2?`0`:``;gi(a,t,n);let c=ar(s+o);hi(c.length,t,J.BYTE_STRING),t.write(c)}function vi(e,t,n){n.flushToZero&&(e=zr(e)),Object.is(e,-0)?n.simplifyNegativeZero?n.avoidInts?mi(0,t,n):hi(0,t):mi(e,t,n):!n.avoidInts&&Number.isSafeInteger(e)?hi(e,t):n.reduceUnsafeNumbers&&Math.floor(e)===e&&e>=Yn.MIN&&e<=Yn.MAX?_i(BigInt(e),t,n):mi(e,t,n)}function yi(e,t,n){let r=n.stringNormalization?e.normalize(n.stringNormalization):e;if(n.wtf8&&!e.isWellFormed()){let e=li.encode(r);gi(Y.WTF8,t,n),hi(e.length,t,J.BYTE_STRING),t.write(e)}else{let e=ci.encode(r);hi(e.length,t,J.UTF8_STRING),t.write(e)}}function bi(e,t,n){let r=e;Ci(r,r.length,J.ARRAY,t,n);for(let e of r)Ei(e,t,n)}function xi(e,t){hi(e.length,t,J.BYTE_STRING),t.write(e)}var Si=new pr;Si.registerEncoder(Array,bi),Si.registerEncoder(Uint8Array,xi);function $(e,t){return Si.registerEncoder(e,t)}function Ci(e,t,n,r,i){let a=Zn(e);a&&!i.ignoreOriginalEncoding?r.write(a):hi(t,r,n)}function wi(e,t,n){if(e===null){t.writeUint8(si);return}if(!n.ignoreOriginalEncoding&&Z.ENCODED in e){t.write(e[Z.ENCODED]);return}let r=e.constructor;if(r){let i=n.types?.get(r)??(n.ignoreGlobalTags?void 0:Si.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])))&&gi(r[0],t,n),Ei(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])))&&gi(r[0],t,n),Ei(r[1],t,n));return}if(typeof e.toJSON==`function`){Ei(e.toJSON(),t,n);return}let i=Object.entries(e).map(e=>[e[0],e[1],Di(e[0],n)]);n.sortKeys&&i.sort(n.sortKeys),Ci(e,i.length,J.MAP,t,n);for(let[e,r,a]of i)t.write(a),Ei(r,t,n)}function Ti(e,t,n){if(!e.description||e!==Symbol.for(e.description))throw TypeError(`Private or empty symbol: ${e.toString()}`);gi(280,t,n),yi(e.description,t,n)}function Ei(e,t,n){switch(typeof e){case`number`:vi(e,t,n);break;case`bigint`:_i(e,t,n);break;case`string`:yi(e,t,n);break;case`boolean`:t.writeUint8(e?ii:ai);break;case`undefined`:if(n.rejectUndefined)throw Error(`Attempt to encode unwanted undefined.`);t.writeUint8(oi);break;case`object`:wi(e,t,n);break;case`symbol`:Ti(e,t,n);break;default:throw TypeError(`Unknown type: ${typeof e}, ${String(e)}`)}}function Di(e,t={}){let n={...ui};t.dcbor?Object.assign(n,fi):t.cde&&Object.assign(n,di),Object.assign(n,t);let r=new hr(n);return Ei(e,r,n),r.read()}var Oi=(e=>(e[e.NEVER=-1]=`NEVER`,e[e.PREFERRED=0]=`PREFERRED`,e[e.ALWAYS=1]=`ALWAYS`,e))(Oi||{}),ki=class e{static KnownSimple=new Map([[Jn.FALSE,!1],[Jn.TRUE,!0],[Jn.NULL,null],[Jn.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}`);hi(this.value,e,J.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)})`}},Ai=new TextDecoder(`utf8`,{fatal:!0,ignoreBOM:!0}),ji=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=ar(t);break;case`base64`:this.#e=cr(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 ir(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 X.ONE:if(s=1,a=this.#t.getUint8(this.#n),r===J.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 X.TWO:if(s=2,r===J.SIMPLE_FLOAT)a=Lr(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 X.FOUR:if(s=4,r===J.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 X.EIGHT:if(s=8,r===J.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 X.INDEFINITE:switch(r){case J.POS_INT:case J.NEG_INT:case J.TAG:throw Error(`Invalid indefinite encoding for MT ${r}`);case J.SIMPLE_FLOAT:yield[r,i,Z.BREAK,t,0];return}a=1/0;break;default:o=!0}switch(this.#n+=s,r){case J.POS_INT:yield[r,i,a,t,s];break;case J.NEG_INT:yield[r,i,typeof a==`bigint`?-1n-a:-1-Number(a),t,s];break;case J.BYTE_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,this.#a(a),t,a];break;case J.UTF8_STRING:a===1/0?yield*this.#o(r,e,t):yield[r,i,Ai.decode(this.#a(a)),t,a];break;case J.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 J.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 J.TAG:yield[r,i,a,t,s],yield*this.#i(e);break;case J.SIMPLE_FLOAT:{let e=a;o&&(a=ki.create(Number(a))),yield[r,i,a,t,e];break}}}#a(e){let t=ir(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,X.INDEFINITE,1/0,n,1/0];;){let n=this.#i(t),i=n.next(),[a,o,s]=i.value;if(s===Z.BREAK){yield i.value,n.next();return}if(r){if(a!==e)throw Error(`Unmatched major type. Expected ${e}, got ${a}.`);if(o===X.INDEFINITE)throw Error(`New stream started in typed stream`)}yield i.value,yield*n}}},Mi=new Map([[X.ZERO,1],[X.ONE,2],[X.TWO,3],[X.FOUR,5],[X.EIGHT,9]]),Ni=new Uint8Array;function Pi(e,t){return!t.boxed&&!t.preferMap&&e.every(([e])=>typeof e==`string`)?Object.fromEntries(e):new Map(e)}var Fi=class e{static defaultDecodeOptions={...ji.defaultOptions,ParentType:e,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Oi.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:Pi,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:mr};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===J.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===X.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 J.POS_INT:case J.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>=Yn.MIN&&e<=Yn.MAX&&(e=Number(o)),n.boxed?$n(e,r.toHere(s)):e}case J.SIMPLE_FLOAT:if(a>X.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 Ir(e);if(n.rejectLongLoundNaN){if(t.payload||e.length>3)throw Error(`Invalid NaN encoding: "${or(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&&Br(r.toHere(s+1)),n.rejectLongFloats){let e=Di(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<Mi.get(a))throw Error(`Number should have been encoded shorter: ${o}`)}if(typeof o==`number`&&n.boxed)return $n(o,r.toHere(s))}else{if(n.rejectSimple&&o instanceof ki)throw Error(`Invalid simple value: ${o}`);if(n.rejectUndefined&&o===void 0)throw Error(`Unexpected undefined`)}return o;case J.BYTE_STRING:case J.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 [${fr(o)}] instead of [${fr(e)}]`)}return n.boxed?$n(o,r.toHere(s)):o;case J.ARRAY:return new n.ParentType(e,o,t,n);case J.MAP:return new n.ParentType(e,o*2,t,n);case J.TAG:{let r=new n.ParentType(e,1,t,n);return r.children=new Q(o),r}}throw TypeError(`Invalid major type: ${i}`)}static decodeToEncodeOpts(e){return{...ui,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=Xn(e)||t.toHere(n);this.#t.push(r)}return--this.left}replaceLast(e,t,n){let r,i=-1/0;if(this.children instanceof Q?(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=Xn(e)||n.toHere(t.offset);this.#t[i]=r}return r}convert(e){let t;switch(this.mt){case J.ARRAY:t=this.children;break;case J.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=or(i);if(t.has(e))throw Error(`Duplicate key: "0x${e}"`);t.add(e)}}t=this.#e.createObject(e,this.#e);break}case J.BYTE_STRING:return sr(this.children);case J.UTF8_STRING:{let n=this.children.join(``);t=this.#e.boxed?$n(n,e.toHere(this.offset)):n;break}case J.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`&&Qn(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],Ni];return n}},Ii=` `,Li=new TextEncoder,Ri=class extends Fi{close=``;quote=`"`;get isEmptyStream(){return(this.mt===J.UTF8_STRING||this.mt===J.BYTE_STRING)&&this.count===0}};function zi(e,t,n,r){let i=``;if(t===X.INDEFINITE)i+=`_`;else{if(r.diagnosticSizes===Oi.NEVER)return``;{let a=r.diagnosticSizes===Oi.ALWAYS;if(!a){let r=X.ZERO;if(Object.is(n,-0))r=X.TWO;else if(e===J.POS_INT||e===J.NEG_INT){let e=n<0,t=typeof n==`bigint`?1n:1,i=e?-n-t:n;r=i<=23?Number(i):i<=255?X.ONE:i<=65535?X.TWO:i<=4294967295?X.FOUR:X.EIGHT}else r=isFinite(n)?Math.fround(n)===n?Rr(n)==null?X.FOUR:X.TWO:X.EIGHT:X.TWO;a=r!==t}a&&(i+=`_`,t<X.ONE?i+=`i`:i+=String(t-24))}}return i}function Bi(e,t){let n={...Fi.defaultDecodeOptions,...t,ParentType:Ri},r=new ji(e,n),i,a,o=``;for(let e of r){let[t,s,c]=e;switch(i&&(i.count>0&&c!==Z.BREAK&&(i.mt===J.MAP&&i.count%2?o+=`: `:(o+=`,`,n.pretty||(o+=` `))),n.pretty&&(i.mt!==J.MAP||i.count%2==0)&&(o+=`
2
+ ${Ii.repeat(i.depth+1)}`)),a=Fi.create(e,i,n,r),t){case J.POS_INT:case J.NEG_INT:o+=String(c),o+=zi(t,s,c,n);break;case J.SIMPLE_FLOAT:if(c!==Z.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+=zi(t,s,c,n)}else c instanceof ki?(o+=`simple(`,o+=String(c.value),o+=zi(J.POS_INT,s,c.value,n),o+=`)`):o+=String(c);break;case J.BYTE_STRING:c===1/0?(o+=`(_ `,a.close=`)`,a.quote=`'`):(o+=`h'`,o+=or(c),o+=`'`,o+=zi(J.POS_INT,s,c.length,n));break;case J.UTF8_STRING:c===1/0?(o+=`(_ `,a.close=`)`):(o+=JSON.stringify(c),o+=zi(J.POS_INT,s,Li.encode(c).length,n));break;case J.ARRAY:{o+=`[`;let e=zi(J.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
3
+ ${Ii.repeat(a.depth)}]`:a.close=`]`;break}case J.MAP:{o+=`{`;let e=zi(J.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
4
+ ${Ii.repeat(a.depth)}}`:a.close=`}`;break}case J.TAG:o+=String(c),o+=zi(J.POS_INT,s,c,n),o+=`(`,a.close=`)`;break}if(a===Z.BREAK)if(i?.isStreaming)i.left=0;else throw Error(`Unexpected BREAK`);else i&&(i.count++,i.left--);for(a instanceof Ri&&(i=a);i?.done;){if(i.isEmptyStream)o=o.slice(0,-3),o+=`${i.quote}${i.quote}_`;else{if(i.mt===J.MAP&&i.count%2!=0)throw Error(`Odd streaming map size: ${i.count}`);o+=i.close}i=i.parent}}return o}var Vi=new TextDecoder,Hi=class extends Fi{depth=0;leaf=!1;value;length;[Z.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 X.ONE:return 1;case X.TWO:return 2;case X.FOUR:return 4;case X.EIGHT:return 8}return 0}};function Ui(e){return e instanceof Hi}function Wi(e,t){return e===1/0?`Indefinite`:t?`${e} ${t}${e!==1&&e!==1n?`s`:``}`:String(e)}function Gi(e){return``.padStart(e,` `)}function Ki(e,t,n){let r=``;r+=Gi(e.depth*2);let i=Xn(e);r+=or(i.subarray(0,1));let a=e.numBytes();a&&(r+=` `,r+=or(i.subarray(1,a+1))),r=r.padEnd(t.minCol+1,` `),r+=`-- `,n!==void 0&&(r+=Gi(e.depth*2),n!==``&&(r+=`[${n}] `));let o=!1,[s]=e.children;switch(e.mt){case J.POS_INT:r+=`Unsigned: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case J.NEG_INT:r+=`Negative: ${s}`,typeof s==`bigint`&&(r+=`n`);break;case J.BYTE_STRING:r+=`Bytes (Length: ${Wi(e.length)})`;break;case J.UTF8_STRING:r+=`UTF8 (Length: ${Wi(e.length)})`,e.length!==1/0&&(r+=`: ${JSON.stringify(s)}`);break;case J.ARRAY:r+=`Array (Length: ${Wi(e.value,`item`)})`;break;case J.MAP:r+=`Map (Length: ${Wi(e.value,`pair`)})`;break;case J.TAG:{r+=`Tag #${e.value}`;let n=e.children,[a]=n.contents.children,s=new Q(n.tag,a);Qn(s,i);let c=s.comment(t,e.depth);c&&(r+=`: `,r+=c),o||=s.noChildren;break}case J.SIMPLE_FLOAT:s===Z.BREAK?r+=`BREAK`:e.ai>X.ONE?Object.is(s,-0)?r+=`Float: -0`:r+=`Float: ${s}`:(r+=`Simple: `,s instanceof ki?r+=s.value:r+=s);break}if(!o)if(e.leaf){if(r+=`
5
+ `,i.length>a+1){let n=Gi((e.depth+1)*2),o=nr(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+=Gi(t.minCol+1),r+=`--`,r+=n,r+=`<< `;let a=ir(i,c,c+l),o=nr(a);if(o){let e=o.findIndex(([e,t,n])=>e===0&&t===l&&n===`<<`);e>=0&&o.splice(e,1)}r+=Bi(a),r+=` >>
6
+ `,r+=Ji(a,{initialDepth:e.depth+1,minCol:t.minCol,noPrefixHex:!0});continue}else u===`'`&&(r+=Gi(t.minCol+1),r+=`--`,r+=n,r+=`'`,r+=Vi.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+=or(i.subarray(e,t)),r+=`
8
+ `}}}else for(let e=a+1;e<i.length;e+=8)r+=n,r+=or(i.subarray(e,e+8)),r+=`
9
9
  `}}else{r+=`
10
- `;let n=0;for(let i of e.children){if(Vi(i)){let a=String(n);e.mt===Y.MAP?a=n%2?`val ${(n-1)/2}`:`key ${n/2}`:e.mt===Y.TAG&&(a=``),r+=Wi(i,t,a)}n++}}return r}var Gi={...Ni.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Ki(e,t){let n={...Gi,...t,ParentType:Bi,saveOriginal:!0},r=new ki(e,n),i,a;for(let e of r){if(a=Ni.create(e,i,n,r),e[2]===Kn.BREAK)if(i?.isStreaming)i.left=1;else throw Error(`Unexpected BREAK`);if(!Vi(a)){let t=new Bi(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${ir(r.toHere(0))}
11
- `;return o+=Wi(a,n),o}var qi=!lr();function Ji(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 Yi(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 Xi(e){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array: ${e}`)}function Zi(e){if(!Array.isArray(e))throw Error(`Expected Array: ${e}`)}$(Map,(e,t,n)=>{let r=[...e.entries()].map(e=>[e[0],e[1],Ti(e[0],n)]);if(n.rejectDuplicateKeys){let e=new Set;for(let[t,n,i]of r){let t=ir(i);if(e.has(t))throw Error(`Duplicate map key: 0x${t}`);e.add(t)}}n.sortKeys&&r.sort(n.sortKeys),xi(e,e.size,Y.MAP,t,n);for(let[e,i,a]of r)t.write(a),wi(i,t,n)});function Qi(e){return Yi(e.contents),new Date(e.contents)}Qi.comment=e=>{Yi(e.contents);let t=new Date(e.contents);return`(String ${e.tag===X.DATE_FULL?`Full `:``}Date) ${t.toISOString()}`},Q.registerDecoder(X.DATE_STRING,Qi),Q.registerDecoder(X.DATE_FULL,Qi);function $i(e){return Ji(e.contents),new Date(e.contents*1e3)}$i.comment=e=>(Ji(e.contents),`(Epoch Date) ${new Date(e.contents*1e3).toISOString()}`),Q.registerDecoder(X.DATE_EPOCH,$i);var ea=1e3*60*60*24;function ta(e){return Ji(e.contents),new Date(e.contents*ea)}ta.comment=e=>(Ji(e.contents),`(Epoch Date) ${new Date(e.contents*ea).toISOString()}`),Q.registerDecoder(X.DATE_EPOCH_DAYS,ta),$(Date,(e,t,n)=>{switch(n.dateTag){case X.DATE_EPOCH:return[n.dateTag,e.valueOf()/1e3];case X.DATE_STRING:return[n.dateTag,e.toISOString().replace(/\.000Z$/,`Z`)];case X.DATE_EPOCH_DAYS:return[n.dateTag,Math.floor(e.valueOf()/ea)];case X.DATE_FULL:return[n.dateTag,e.toISOString().split(`T`)[0]];default:throw Error(`Unsupported date tag: ${n.dateTag}`)}});function na(e,t,n){if(Xi(t.contents),n.rejectBigInts)throw Error(`Decoding unwanted big integer: ${t}(h'${ir(t.contents)}')`);if(n.requirePreferred&&t.contents[0]===0)throw Error(`Decoding overly-large bigint: ${t.tag}(h'${ir(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 ra=na.bind(null,!1),ia=na.bind(null,!0);ra.comment=(e,t)=>`(Positive BigInt) ${na(!1,e,t)}n`,ia.comment=(e,t)=>`(Negative BigInt) ${na(!0,e,t)}n`,Q.registerDecoder(X.POS_BIGINT,ra),Q.registerDecoder(X.NEG_BIGINT,ia);function aa(e,t){return Xi(e.contents),e}aa.comment=(e,t,n)=>{Xi(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=ir(i.subarray(a,++a));o>=24&&(s+=` `,s+=ir(i.subarray(a,a+2**(o-24)))),r.minCol=Math.max(r.minCol,(n+1)*2+s.length);let c=Ki(e.contents,r),l=`Embedded CBOR
10
+ `;let n=0;for(let i of e.children){if(Ui(i)){let a=String(n);e.mt===J.MAP?a=n%2?`val ${(n-1)/2}`:`key ${n/2}`:e.mt===J.TAG&&(a=``),r+=Ki(i,t,a)}n++}}return r}var qi={...Fi.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Ji(e,t){let n={...qi,...t,ParentType:Hi,saveOriginal:!0},r=new ji(e,n),i,a;for(let e of r){if(a=Fi.create(e,i,n,r),e[2]===Z.BREAK)if(i?.isStreaming)i.left=1;else throw Error(`Unexpected BREAK`);if(!Ui(a)){let t=new Hi(e,0,i,n);t.leaf=!0,t.children.push(a),Qn(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||Qn(a,r.toHere(a.offset)),{parent:i}=i}t&&(t.minCol=n.minCol);let o=n.noPrefixHex?``:`0x${or(r.toHere(0))}
11
+ `;return o+=Ki(a,n),o}var Yi=!dr();function Xi(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 Zi(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 Qi(e){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array: ${e}`)}function $i(e){if(!Array.isArray(e))throw Error(`Expected Array: ${e}`)}$(Map,(e,t,n)=>{let r=[...e.entries()].map(e=>[e[0],e[1],Di(e[0],n)]);if(n.rejectDuplicateKeys){let e=new Set;for(let[t,n,i]of r){let t=or(i);if(e.has(t))throw Error(`Duplicate map key: 0x${t}`);e.add(t)}}n.sortKeys&&r.sort(n.sortKeys),Ci(e,e.size,J.MAP,t,n);for(let[e,i,a]of r)t.write(a),Ei(i,t,n)});function ea(e){return Zi(e.contents),new Date(e.contents)}ea.comment=e=>{Zi(e.contents);let t=new Date(e.contents);return`(String ${e.tag===Y.DATE_FULL?`Full `:``}Date) ${t.toISOString()}`},Q.registerDecoder(Y.DATE_STRING,ea),Q.registerDecoder(Y.DATE_FULL,ea);function ta(e){return Xi(e.contents),new Date(e.contents*1e3)}ta.comment=e=>(Xi(e.contents),`(Epoch Date) ${new Date(e.contents*1e3).toISOString()}`),Q.registerDecoder(Y.DATE_EPOCH,ta);var na=1e3*60*60*24;function ra(e){return Xi(e.contents),new Date(e.contents*na)}ra.comment=e=>(Xi(e.contents),`(Epoch Date) ${new Date(e.contents*na).toISOString()}`),Q.registerDecoder(Y.DATE_EPOCH_DAYS,ra),$(Date,(e,t,n)=>{switch(n.dateTag){case Y.DATE_EPOCH:return[n.dateTag,e.valueOf()/1e3];case Y.DATE_STRING:return[n.dateTag,e.toISOString().replace(/\.000Z$/,`Z`)];case Y.DATE_EPOCH_DAYS:return[n.dateTag,Math.floor(e.valueOf()/na)];case Y.DATE_FULL:return[n.dateTag,e.toISOString().split(`T`)[0]];default:throw Error(`Unsupported date tag: ${n.dateTag}`)}});function ia(e,t,n){if(Qi(t.contents),n.rejectBigInts)throw Error(`Decoding unwanted big integer: ${t}(h'${or(t.contents)}')`);if(n.requirePreferred&&t.contents[0]===0)throw Error(`Decoding overly-large bigint: ${t.tag}(h'${or(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?$n(r,t.contents):r}var aa=ia.bind(null,!1),oa=ia.bind(null,!0);aa.comment=(e,t)=>`(Positive BigInt) ${ia(!1,e,t)}n`,oa.comment=(e,t)=>`(Negative BigInt) ${ia(!0,e,t)}n`,Q.registerDecoder(Y.POS_BIGINT,aa),Q.registerDecoder(Y.NEG_BIGINT,oa);function sa(e,t){return Qi(e.contents),e}sa.comment=(e,t,n)=>{Qi(e.contents);let r={...t,initialDepth:n+2,noPrefixHex:!0},i=Xn(e),a=2**((i[0]&31)-24)+1,o=i[a]&31,s=or(i.subarray(a,++a));o>=24&&(s+=` `,s+=or(i.subarray(a,a+2**(o-24)))),r.minCol=Math.max(r.minCol,(n+1)*2+s.length);let c=Ji(e.contents,r),l=`Embedded CBOR
12
12
  `;return l+=`${``.padStart((n+1)*2,` `)}${s}`.padEnd(r.minCol+1,` `),l+=`-- Bytes (Length: ${e.contents.length})
13
- `,l+=c,l},aa.noChildren=!0,Q.registerDecoder(X.CBOR,aa),Q.registerDecoder(X.URI,e=>(Yi(e.contents),new URL(e.contents)),`URI`),$(URL,e=>[X.URI,e.toString()]),Q.registerDecoder(X.BASE64URL,e=>(Yi(e.contents),cr(e.contents)),`Base64url-encoded`),Q.registerDecoder(X.BASE64,e=>(Yi(e.contents),or(e.contents)),`Base64-encoded`),Q.registerDecoder(35,e=>(Yi(e.contents),new RegExp(e.contents)),`RegExp`),Q.registerDecoder(21065,e=>{Yi(e.contents);let t=`^(?:${e.contents})$`;return new RegExp(t,`u`)},`I-RegExp`),Q.registerDecoder(X.REGEXP,e=>{if(Zi(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`),$(RegExp,e=>[X.REGEXP,[e.source,e.flags]]),Q.registerDecoder(64,e=>(Xi(e.contents),e.contents),`uint8 Typed Array`);function oa(e,t,n){Xi(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 sa(e,t,n,r,i){let a=i.forceEndian??qi;if(mi(a?t:n,e,i),pi(r.byteLength,e,Y.BYTE_STRING),qi===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)}}Q.registerDecoder(65,e=>oa(e,Uint16Array,!1),`uint16, big endian, Typed Array`),Q.registerDecoder(66,e=>oa(e,Uint32Array,!1),`uint32, big endian, Typed Array`),Q.registerDecoder(67,e=>oa(e,BigUint64Array,!1),`uint64, big endian, Typed Array`),Q.registerDecoder(68,e=>(Xi(e.contents),new Uint8ClampedArray(e.contents)),`uint8 Typed Array, clamped arithmetic`),$(Uint8ClampedArray,e=>[68,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),Q.registerDecoder(69,e=>oa(e,Uint16Array,!0),`uint16, little endian, Typed Array`),$(Uint16Array,(e,t,n)=>sa(t,69,65,e,n)),Q.registerDecoder(70,e=>oa(e,Uint32Array,!0),`uint32, little endian, Typed Array`),$(Uint32Array,(e,t,n)=>sa(t,70,66,e,n)),Q.registerDecoder(71,e=>oa(e,BigUint64Array,!0),`uint64, little endian, Typed Array`),$(BigUint64Array,(e,t,n)=>sa(t,71,67,e,n)),Q.registerDecoder(72,e=>(Xi(e.contents),new Int8Array(e.contents)),`sint8 Typed Array`),$(Int8Array,e=>[72,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),Q.registerDecoder(73,e=>oa(e,Int16Array,!1),`sint16, big endian, Typed Array`),Q.registerDecoder(74,e=>oa(e,Int32Array,!1),`sint32, big endian, Typed Array`),Q.registerDecoder(75,e=>oa(e,BigInt64Array,!1),`sint64, big endian, Typed Array`),Q.registerDecoder(77,e=>oa(e,Int16Array,!0),`sint16, little endian, Typed Array`),$(Int16Array,(e,t,n)=>sa(t,77,73,e,n)),Q.registerDecoder(78,e=>oa(e,Int32Array,!0),`sint32, little endian, Typed Array`),$(Int32Array,(e,t,n)=>sa(t,78,74,e,n)),Q.registerDecoder(79,e=>oa(e,BigInt64Array,!0),`sint64, little endian, Typed Array`),$(BigInt64Array,(e,t,n)=>sa(t,79,75,e,n)),Q.registerDecoder(81,e=>oa(e,Float32Array,!1),`IEEE 754 binary32, big endian, Typed Array`),Q.registerDecoder(82,e=>oa(e,Float64Array,!1),`IEEE 754 binary64, big endian, Typed Array`),Q.registerDecoder(85,e=>oa(e,Float32Array,!0),`IEEE 754 binary32, little endian, Typed Array`),$(Float32Array,(e,t,n)=>sa(t,85,81,e,n)),Q.registerDecoder(86,e=>oa(e,Float64Array,!0),`IEEE 754 binary64, big endian, Typed Array`),$(Float64Array,(e,t,n)=>sa(t,86,82,e,n)),Q.registerDecoder(X.SET,(e,t)=>{if(Zi(e.contents),t.sortKeys){let n=Ni.decodeToEncodeOpts(t),r=null;for(let i of e.contents){let e=[i,void 0,Ti(i,n)];if(r&&t.sortKeys(r,e)>=0)throw Error(`Set items out of order in tag #${X.SET}`);r=e}}return new Set(e.contents)},`Set`),$(Set,(e,t,n)=>{let r=[...e];if(n.sortKeys){let e=r.map(e=>[e,void 0,Ti(e,n)]);e.sort(n.sortKeys),r=e.map(([e])=>e)}return[X.SET,r]}),Q.registerDecoder(X.JSON,e=>(Yi(e.contents),JSON.parse(e.contents)),`JSON-encoded`);function ca(e){return Xi(e.contents),new Yr().decode(e.contents)}ca.comment=e=>{Xi(e.contents);let t=new Yr;return`(WTF8 string): ${JSON.stringify(t.decode(e.contents))}`},Q.registerDecoder(X.WTF8,ca),Q.registerDecoder(X.SELF_DESCRIBED,e=>e.contents,`Self-Described`),Q.registerDecoder(X.INVALID_16,()=>{throw Error(`Tag always invalid: ${X.INVALID_16}`)},`Invalid`),Q.registerDecoder(X.INVALID_32,()=>{throw Error(`Tag always invalid: ${X.INVALID_32}`)},`Invalid`),Q.registerDecoder(X.INVALID_64,()=>{throw Error(`Tag always invalid: ${X.INVALID_64}`)},`Invalid`),Q.registerDecoder(X.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(Yi(t),!t.length)throw Error(`Expected non-empty string: ${e.contents}`);return Symbol.for(t)},`Symbol`);function la(e){throw Error(`Encoding ${e.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}$(ArrayBuffer,la),$(DataView,la),typeof SharedArrayBuffer<`u`&&$(SharedArrayBuffer,la);function ua(e){return[NaN,e.valueOf()]}$(Boolean,ua),$(Number,ua),$(String,ua),$(BigInt,ua);function da(e){let t={...Ni.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Ni.dcborDecodeOptions):e.cde&&Object.assign(t,Ni.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,`rejectLongNumbers`))throw TypeError(`rejectLongNumbers has changed to requirePreferred`);return t.boxed&&(t.saveOriginal=!0),t}var fa=class{parent=void 0;ret=void 0;step(e,t,n){if(this.ret=Ni.create(e,this.parent,t,n),e[2]===Kn.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 Ni&&(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 pa(e,t={}){let n=da(t),r=new ki(e,n),i=new fa;for(let e of r)i.step(e,n,r);return i.ret}var{cdeDecodeOptions:ma,dcborDecodeOptions:ha,defaultDecodeOptions:ga}=Ni,_a=class{constructor(e={}){this.options={id:R(),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}}},va=class{static uint8ArrayToBase64(e){return xe.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)}static base64ToUint8Array(e){return new Uint8Array(xe.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)}},ya=class{constructor(e){this.format=e,this.types=new dr,this.tags=new Map;let t=64e3;this.types.registerEncoder(xe,e=>[t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),this.tags.set(t,e=>xe.from(e.contents))}encode(e){let t;if(this.format===`cbor`)try{t=Ti(e,{types:this.types})}catch(e){throw Error(`failed to encode CBOR format`,{cause:e})}else if(this.format===`json`)try{t=va.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=pa(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=va.parse(e)}catch(e){throw Error(`failed to decode JSON format`,{cause:e})}}else throw Error(`invalid format "${this.format}"`);return t}},ba=class extends _a{constructor(e={}){super(e),this.codec=new ya(this.options.codec)}},xa=class e extends ba{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===xe)n=xe.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}},Sa=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},Ca=Sa(`1.4`),wa=Sa(`1.4`),Ta=Un(Bn(J(),Hn()),Dn(e=>!Array.isArray(e))),Ea=Un(Pn(Un(J(),kn(8192))),kn(8)),Da=class{constructor(e,t,n,r){this.type=e,this.id=t,this.sender=n,this.receiver=r,this.version=`MQTT+/1.4`}},Oa={version:Un(J(),jn(/^MQTT\+\/\d+\.\d+$/)),type:J(),id:J(),sender:q(J()),receiver:q(J())},ka=class extends Da{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}},Aa=Vn({...Oa,type:Ln(`event-emission`),name:J(),params:q(Un(Pn(Hn()),kn(64))),auth:q(Ea),meta:q(Ta)}),ja=class extends Da{constructor(e,t,n,r,i,a,o,s){super(`service-call-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.qos=s}},Ma=Vn({...Oa,type:Ln(`service-call-request`),name:J(),params:q(Un(Pn(Hn()),kn(64))),auth:q(Ea),meta:q(Ta),qos:q(zn([0,1,2]))}),Na=class extends Da{constructor(e,t,n,r,i,a){super(`service-call-response`,e,i,a),this.name=t,this.result=n,this.error=r}},Pa=Vn({...Oa,type:Ln(`service-call-response`),name:J(),result:q(Hn()),error:q(J())}),Fa=class extends Da{constructor(e,t,n,r,i,a,o,s){super(`sink-push-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.qos=s}},Ia=Vn({...Oa,type:Ln(`sink-push-request`),name:J(),params:q(Un(Pn(Hn()),kn(64))),auth:q(Ea),meta:q(Ta),qos:q(zn([0,1,2]))}),La=class extends Da{constructor(e,t,n,r,i,a){super(`sink-push-response`,e,r,i),this.name=t,this.error=n,this.credit=a}},Ra=Vn({...Oa,type:Ln(`sink-push-response`),name:J(),error:q(J()),credit:q(Un(Rn(),On(),An(1)))}),za=class extends Da{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}},Ba=Vn({...Oa,type:Ln(`sink-push-chunk`),name:J(),chunk:q(In(Uint8Array)),error:q(J()),final:q(Fn())}),Va=class extends Da{constructor(e,t,n,r,i){super(`sink-push-credit`,e,r,i),this.name=t,this.credit=n}},Ha=Vn({...Oa,type:Ln(`sink-push-credit`),name:J(),credit:Un(Rn(),On(),An(0))}),Ua=class extends Da{constructor(e,t,n,r,i,a,o,s,c){super(`source-fetch-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.credit=s,this.qos=c}},Wa=Vn({...Oa,type:Ln(`source-fetch-request`),name:J(),params:q(Un(Pn(Hn()),kn(64))),auth:q(Ea),meta:q(Ta),credit:q(Un(Rn(),On(),An(1))),qos:q(zn([0,1,2]))}),Ga=class extends Da{constructor(e,t,n,r,i,a){super(`source-fetch-response`,e,r,i),this.name=t,this.error=n,this.meta=a}},Ka=Vn({...Oa,type:Ln(`source-fetch-response`),name:J(),error:q(J()),meta:q(Ta)}),qa=class extends Da{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}},Ja=Vn({...Oa,type:Ln(`source-fetch-chunk`),name:J(),chunk:q(In(Uint8Array)),error:q(J()),final:q(Fn())}),Ya=class extends Da{constructor(e,t,n,r,i){super(`source-fetch-credit`,e,r,i),this.name=t,this.credit=n}},Xa=Vn({...Oa,type:Ln(`source-fetch-credit`),name:J(),credit:Un(Rn(),On(),An(0))}),Za=class{makeEventEmission(e,t,n,r,i,a,o){return new ka(e,t,n,r,i,a,o)}makeServiceCallRequest(e,t,n,r,i,a,o,s){return new ja(e,t,n,r,i,a,o,s)}makeServiceCallResponse(e,t,n,r,i,a){return new Na(e,t,n,r,i,a)}makeSinkPushRequest(e,t,n,r,i,a,o,s){return new Fa(e,t,n,r,i,a,o,s)}makeSinkPushResponse(e,t,n,r,i,a){return new La(e,t,n,r,i,a)}makeSinkPushChunk(e,t,n,r,i,a,o){return new za(e,t,n,r,i,a,o)}makeSinkPushCredit(e,t,n,r,i){return new Va(e,t,n,r,i)}makeSourceFetchRequest(e,t,n,r,i,a,o,s,c){return new Ua(e,t,n,r,i,a,o,s,c)}makeSourceFetchResponse(e,t,n,r,i,a){return new Ga(e,t,n,r,i,a)}makeSourceFetchChunk(e,t,n,r,i,a,o){return new qa(e,t,n,r,i,a,o)}makeSourceFetchCredit(e,t,n,r,i){return new Ya(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+)$/),n=t===null?0:Sa(t[1]);if(Math.floor(n/100)!==Math.floor(Ca/100)||n<wa)throw Error(`protocol version mismatch (expected version 1.4...1.4, got version ${e.version})`);let r=(e,t,n)=>{let r=Wn(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=r(e,`EventEmission`,Aa);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=r(e,`ServiceCallRequest`,Ma);return this.makeServiceCallRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}else if(e.type===`service-call-response`){let t=r(e,`ServiceCallResponse`,Pa);return this.makeServiceCallResponse(t.id,t.name,t.result,t.error,t.sender,t.receiver)}else if(e.type===`sink-push-request`){let t=r(e,`SinkPushRequest`,Ia);return this.makeSinkPushRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}else if(e.type===`sink-push-response`){let t=r(e,`SinkPushResponse`,Ra);return this.makeSinkPushResponse(t.id,t.name,t.error,t.sender,t.receiver,t.credit)}else if(e.type===`sink-push-chunk`){let t=r(e,`SinkPushChunk`,Ba);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=r(e,`SinkPushCredit`,Ha);return this.makeSinkPushCredit(t.id,t.name,t.credit,t.sender,t.receiver)}else if(e.type===`source-fetch-request`){let t=r(e,`SourceFetchRequest`,Wa);return this.makeSourceFetchRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.credit,t.qos)}else if(e.type===`source-fetch-response`){let t=r(e,`SourceFetchResponse`,Ka);return this.makeSourceFetchResponse(t.id,t.name,t.error,t.sender,t.receiver,t.meta)}else if(e.type===`source-fetch-chunk`){let t=r(e,`SourceFetchChunk`,Ja);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=r(e,`SourceFetchCredit`,Xa);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 ka||e instanceof ja||e instanceof Ua||e instanceof Fa}isResponse(e){return e instanceof Na||e instanceof La||e instanceof za||e instanceof Va||e instanceof Ga||e instanceof qa||e instanceof Ya}},Qa=class extends xa{constructor(){super(...arguments),this.msg=new Za}},$a=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}: ${va.stringify(n)}`}).join(`, `)})`}return`[${t}] ${this.level}: ${n}${r}`}},eo=class extends Qa{constructor(){super(...arguments),this._events=new pn.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 $a(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}),n.stack=e.stack);try{this.emitEvent(`error`,n),this.log(`error`,n.message)}catch{}}},to=class extends eo{constructor(e,t={}){super(t),this.destroyed=!1,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)=>{if(this.destroyed)return;let r;if(this.options.codec===`json`)r=t.toString();else if(this.options.codec===`cbor`)r=be.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.destroyed=!0,this.log(`info`,`un-hooking from MQTT client`),this.mqtt.off(`message`,this.messageHandler),this.onRequest.clear(),this.onResponse.clear()}makeRegistration(e,t,n){let r=!1;return{destroy:async()=>{r||(r=!0,await e.unroll(!1)?.catch(e=>{let r=G(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 Se((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:be.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){if(this.destroyed)return;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(G(e,`failed to parse message into object`));return}let a;try{a=this.msg.parse(i)}catch(e){this.error(G(e,`failed to parse object into typed message object`));return}if(this.log(`debug`,`received from MQTT topic "${e}"`,{message:a}),r.peerId!==void 0&&a.receiver!==void 0&&a.receiver!==r.peerId&&this.log(`warning`,`receiver mismatch on direct topic "${e}" (expected "${r.peerId}", got "${a.receiver}")`),this.msg.isRequest(a)){let t=this.onRequest.get(`${a.type}:${a.name}`);t!==void 0&&Promise.resolve().then(()=>{if(!this.destroyed)return t(a,r.name)}).catch(t=>{this.error(G(t,`dispatching request message from MQTT topic "${e}" (type: ${a.type}, id: ${a.id}, name: ${a.name}) failed`))})}else if(this.msg.isResponse(a)){let t=this.onResponse.get(`${a.type}:${a.id}`);t!==void 0&&Promise.resolve().then(()=>{if(!this.destroyed)return t(a,r.name)}).catch(t=>{this.error(G(t,`dispatching response message from MQTT topic "${e}" (type: ${a.type}, id: ${a.id}, name: ${a.name}) failed`))})}}},no=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)}clearCount(e){this.counts.delete(e)}async subscribe(e,t={qos:2}){if(this.incrementCount(e)===0){let n=this.lingers.get(e);if(n){clearTimeout(n),this.lingers.delete(e);return}let r,i,a=new Promise((e,t)=>{r=e,i=t});a.catch(()=>{}),this.pending.set(e,a);let o=this.unsubbing.get(e);return o&&await o,this.subscribeFn(e,t).then(()=>{this.pending.delete(e),r()},t=>{this.pending.delete(e),this.clearCount(e),i(t)}),a}else{let t=this.pending.get(e);if(t)return 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()}},ro=class extends to{constructor(){super(...arguments),this.subscriptions=new no((e,t)=>this.subscribeTopic(e,t),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,t,n={}){await Pe(`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()}},io=class extends ro{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()=>{if(!this.destroyed){this.timers.delete(e);try{await t()}catch(t){this.error(G(t),`timer "${e}" failed`)}}},this.options.timeout))}timerClear(e){let t=this.timers.get(e);t!==void 0&&(clearTimeout(t),this.timers.delete(e))}sleep(e,t){return new Promise(n=>{if(t?.aborted){n();return}let r=t===void 0?void 0:new AbortController,i=setTimeout(()=>{i=null,r!==void 0&&r.abort(),n()},e);i.unref(),t!==void 0&&r!==void 0&&t.addEventListener(`abort`,()=>{i!==null&&clearTimeout(i),n()},{once:!0,signal:r.signal})})}timeout(e,t=`timeout`,n){return new Promise((r,i)=>{if(n?.aborted){i(Error(`aborted`));return}let a=n===void 0?void 0:new AbortController,o=setTimeout(()=>{o=null,a!==void 0&&a.abort(),i(Error(t))},e);o.unref(),n!==void 0&&a!==void 0&&n.addEventListener(`abort`,()=>{o!==null&&clearTimeout(o),i(Error(`aborted`))},{once:!0,signal:a.signal})})}},ao=class extends io{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}}},oo=new TextEncoder,so=class extends ao{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=ln(un,oo.encode(e),oo.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 Qt(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);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`);try{return(await nn(e,this._credential)).payload}catch(e){let t=e?.code??e?.name??`unknown`,n=e?.message??``;return this.log(`warning`,`token validation failed`,{code:t,reason:n}),null}}async authenticated(e,t,n,r){let i=!1,a=typeof n==`string`?[n]:n.roles;if(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)){i=!0;break}if(i)break}}let o=typeof n==`string`||n.mode===`require`;if(!i&&o)throw Error(`${r} failed authentication`);return i}},co=class extends so{constructor(){super(...arguments),this.eventControllers=new Map}async destroy(){for(let e of this.eventControllers.values())e.abort(Error(`event destroyed`));this.eventControllers.clear(),await super.destroy()}async event(e,...t){if(this.destroyed)throw Error(`event: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`event: callback argument is required and must be a function`);let s=new je;if(this.onRequest.has(`event-emission:${n}`))throw Error(`event: event "${n}" already registered`);let c=new Set;s.roll(()=>{for(let e of c)this.eventControllers.get(e)?.abort(Error(`event "${n}" destroyed`)),this.eventControllers.delete(e);c.clear()});let l=a===``?n:`$share/${a}/${n}`,u=this.options.topicMake(l,`event-emission`),d=this.options.topicMake(n,`event-emission`,this.options.id);return this.onRequest.set(`event-emission:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let i=e.id,a=e.sender;if(a===void 0||a===``){this.error(Error(`invalid request: missing sender`));return}if(t!==e.name){this.log(`warning`,`event name mismatch -- dropped request for "${n}" (topic: "${t}", payload: "${e.name}")`,{requestId:i});return}let s=e.params??[];if(this.eventControllers.has(i)){this.log(`warning`,`duplicate event request id -- dropped request for event "${n}"`,{requestId:i});return}let l=new AbortController,u=l.signal;c.add(i),this.eventControllers.set(i,l);let d={sender:a,signal:u};e.receiver&&(d.receiver=e.receiver),e.meta&&(d.meta=e.meta);try{o&&(d.authenticated=await this.authenticated(a,e.auth,o,`event "${n}"`)),await r(...s,d)}catch(e){let t=G(e);this.error(t,`handler for event "${n}" failed`)}finally{l.abort(),c.delete(i),this.eventControllers.delete(i)}}),s.roll(()=>{this.onRequest.delete(`event-emission:${n}`)}),await this.subscribeTopicAndSpool(s,u,i),await this.subscribeTopicAndSpool(s,d,i),this.makeRegistration(s,`event`,n)}emit(e,...t){if(this.destroyed)throw Error(`emit: instance already destroyed`);let n,r,i,a={},o,s;typeof e==`object`&&e&&`name`in 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=R(),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);return s?{topic:p,payload:f,options:{qos:2,...a}}:Pe(`publish event as MQTT message to topic "${p}"`,()=>this.publishToTopic(p,f,{qos:2,...a}))}},lo=class extends co{constructor(){super(...arguments),this.serviceControllers=new Map,this.pendingCalls=new Map}async destroy(){for(let e of this.serviceControllers.values())e.abort(Error(`service destroyed`));this.serviceControllers.clear();let e=[...this.pendingCalls.values()];this.pendingCalls.clear();for(let t of e)t(Error(`instance destroyed`));await super.destroy()}async service(e,...t){if(this.destroyed)throw Error(`service: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`service: callback argument is required and must be a function`);let s=new je;if(this.onRequest.has(`service-call-request:${n}`))throw Error(`service: service "${n}" already registered`);let c=new Set;s.roll(()=>{for(let e of c)this.serviceControllers.get(e)?.abort(Error(`service "${n}" destroyed`)),this.serviceControllers.delete(e);c.clear()});let l=a===``?n:`$share/${a}/${n}`,u=this.options.topicMake(l,`service-call-request`),d=this.options.topicMake(n,`service-call-request`,this.options.id);return this.onRequest.set(`service-call-request:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let i=e.id,a=e.sender,s=e.params??[];if(a===void 0||a===``){this.error(Error(`invalid request: missing sender`));return}if(t!==e.name){this.log(`warning`,`service name mismatch -- dropped request for "${n}" (topic: "${t}", payload: "${e.name}")`,{requestId:i});return}if(this.serviceControllers.has(i)){this.log(`warning`,`duplicate service request id -- dropped request for "${n}"`,{requestId:i});return}let l=new AbortController,u=l.signal;c.add(i),this.serviceControllers.set(i,l);let d={sender:a,signal:u};e.receiver&&(d.receiver=e.receiver),e.meta&&(d.meta=e.meta);let f=`service-call-handler:${i}`,p=()=>{this.timerRefresh(f,()=>{l.abort(Error(`service "${n}" handler timeout`))})},m=()=>this.timerClear(f);p();let h;try{o&&(d.authenticated=await this.authenticated(a,e.auth,o,`service "${n}"`));let t=new Promise((e,t)=>{let n=()=>{t(G(u.reason))};u.aborted?n():(u.addEventListener(`abort`,n,{once:!0}),h=()=>u.removeEventListener(`abort`,n))}),c=await Promise.race([r(...s,d),t]),l=this.msg.makeServiceCallResponse(i,n,c,void 0,this.options.id,a),f=this.codec.encode(l),p=this.options.topicMake(n,`service-call-response`,a);await this.publishToTopic(p,f,{qos:e.qos??2})}catch(t){let r=G(t);this.error(r,`handler for service "${n}" failed`);let o=this.msg.makeServiceCallResponse(i,n,void 0,r.message,this.options.id,a);try{let t=this.codec.encode(o),r=this.options.topicMake(n,`service-call-response`,a);await this.publishToTopic(r,t,{qos:e.qos??2})}catch(e){this.error(G(e),`sending error response for service "${n}" failed`)}}finally{h?.(),m(),l.abort(),c.delete(i),this.serviceControllers.delete(i)}}),s.roll(()=>{this.onRequest.delete(`service-call-request:${n}`)}),await this.subscribeTopicAndSpool(s,u,i),await this.subscribeTopicAndSpool(s,d,i),this.makeRegistration(s,`service`,n)}async call(e,...t){if(this.destroyed)throw Error(`call: instance already destroyed`);let n,r,i,a={},o;typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new je,c=R();for(let e=0;e<10&&this.onResponse.has(`service-call-response:${c}`);e++)c=R();if(this.onResponse.has(`service-call-response:${c}`))throw Error(`failed to generate unique request id`);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=!1,p=()=>f?!1:(f=!0,s.unroll(),!0),m=new Promise((e,t)=>{d=t,this.timerRefresh(u,()=>{p()&&t(Error(`communication timeout`))}),s.roll(()=>{this.timerClear(u)}),this.pendingCalls.set(c,e=>{p()&&t(e)}),s.roll(()=>{this.pendingCalls.delete(c)}),this.onResponse.set(`service-call-response:${c}`,r=>{if(!(i!==void 0&&r.sender!==i)){if(r.sender===void 0||r.sender===``){if(!p())return;t(Error(`received service response without sender`));return}if(r.name!==n){if(!p())return;t(Error(`received service response with name mismatch (expected: "${n}", received: "${r.name}")`));return}p()&&(r.error===void 0?e(r.result):t(Error(r.error)))}}),s.roll(()=>{this.onResponse.delete(`service-call-response:${c}`)})}),h=this.authenticate(),g=this.metaStore(o),_=a.qos??2,v=this.msg.makeServiceCallRequest(c,n,r,this.options.id,i,h,g,_),y=this.codec.encode(v),b=this.options.topicMake(n,`service-call-request`,i);try{await Pe(`publish service request as MQTT message to topic "${b}"`,()=>this.publishToTopic(b,y,{...a,qos:_}))}catch(e){return p()&&d(e),m}return m}},uo=class extends lo{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map,this.sourceSpools=new Map,this.sourceRequests=new Map}async destroy(){for(let e of this.sourceControllers.values())e.abort(Error(`source destroyed`));for(let e of this.sourceCreditGates.values())e.abort();for(let e of[...this.sourceSpools.values()])await e.unroll();this.sourceSpools.clear(),this.sourceControllers.clear(),this.sourceCreditGates.clear(),this.sourceRequests.clear(),await super.destroy()}async source(e,...t){if(this.destroyed)throw Error(`source: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`source: callback argument is required and must be a function`);let s=new je;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)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=e.params??[],c=e.sender,l=e.receiver,u=new je;if(this.sourceSpools.set(a,u),u.roll(()=>{this.sourceSpools.delete(a)}),c===void 0||c===``){this.error(Error(`invalid request: missing sender`)),await u.unroll();return}let d=this.options.topicMake(n,`source-fetch-response`,c),f=(e,t)=>Error(`${e} name mismatch (expected "${n}", got "${t}")`),p=async(t,r)=>{let o=this.metaStore(r),s=this.msg.makeSourceFetchResponse(a,n,t,this.options.id,c,o),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},m=new AbortController,h=m.signal;if(this.sourceControllers.has(a)){let e=Error(`source: duplicate request id "${a}"`);this.error(e),await p(e.message).catch(()=>{}),await u.unroll();return}this.sourceControllers.set(a,m),u.roll(()=>{this.sourceControllers.delete(a)});let g={sender:c,signal:h};l&&(g.receiver=l),e.meta&&(g.meta=e.meta);let _=this.sourceRequests.get(n);_||(_=new Set,this.sourceRequests.set(n,_)),_.add(a),u.roll(()=>{let e=this.sourceRequests.get(n);e===_&&(e.delete(a),e.size===0&&this.sourceRequests.delete(n))}),h.addEventListener(`abort`,()=>{g.stream instanceof L.Readable&&!g.stream.destroyed&&g.stream.destroy(G(h.reason))},{once:!0}),u.roll(()=>{h.aborted&&g.stream instanceof L.Readable&&!g.stream.destroyed&&g.stream.destroy(G(h.reason))});let v,y=new Promise((e,t)=>{v=t});y.catch(()=>{});let b=()=>{v(G(h.reason))};h.aborted?b():h.addEventListener(`abort`,b,{once:!0}),u.roll(()=>{h.removeEventListener(`abort`,b)});let x=`source-fetch-send:${a}`,S=()=>{h.aborted||this.timerRefresh(x,()=>{m.abort(Error(`source fetch "${n}" timed out`))})},C=()=>this.timerClear(x);S(),u.roll(()=>{C()});let w=async(t,r,o)=>{S();let s=this.msg.makeSourceFetchChunk(a,n,t,r,o,this.options.id,c),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},T=!1,E,D=!1;try{if(t!==e.name)throw Error(`source name mismatch (topic: "${t}", payload: "${e.name}")`);this.onResponse.set(`source-fetch-credit:${a}`,e=>{if(!h.aborted){if(e.name!==n){m.abort(f(`source credit`,e.name));return}if(e.sender===void 0||e.sender===``){m.abort(Error(`source credit for "${n}" missing sender`));return}if(e.sender===c){if(e.credit===0){D=!0,m.abort(Error(`source fetch "${n}" cancelled by fetcher`));return}E&&(E.replenish(e.credit),S())}}}),u.roll(()=>{this.onResponse.delete(`source-fetch-credit:${a}`)}),o&&(g.authenticated=await this.authenticated(c,e.auth,o,`source "${n}"`));let i=Promise.resolve(r(...s,g));if(i.catch(()=>{}),await Promise.race([i,y]),!(g.stream instanceof L.Readable)&&!(g.buffer instanceof Promise)&&!(g.buffer instanceof Uint8Array))throw Error(`handler did not provide data via info.stream or info.buffer fields`);if(g.stream instanceof L.Readable&&(g.buffer instanceof Promise||g.buffer instanceof Uint8Array))throw Error(`handler has set both info.stream and info.buffer fields`);let l=e.credit;if(E=l!==void 0&&l>0?new Ce(l):void 0,E){let e=E;this.sourceCreditGates.set(a,e),u.roll(()=>{e.abort(),this.sourceCreditGates.delete(a)})}if(await p(void 0,g.meta),T=!0,g.stream instanceof L.Readable)await ke(g.stream,this.options.chunkSize,w,E,h);else if(g.buffer instanceof Promise||g.buffer instanceof Uint8Array){let e;if(g.buffer instanceof Promise){let t=g.buffer;t.catch(()=>{}),e=await Promise.race([t,y])}else e=g.buffer;h.throwIfAborted(),await Oe(e,this.options.chunkSize,w,E,h)}}catch(e){let t=G(e,`handler for source "${n}" failed`);m.abort(t),D||(this.error(t),T?await w(void 0,t.message,!0).catch(()=>{}):await p(t.message).catch(()=>{}))}finally{await u.unroll()}}),s.roll(()=>{this.onRequest.delete(`source-fetch-request:${n}`)}),s.roll(()=>{let e=this.sourceRequests.get(n);if(e){for(let t of e){let e=this.sourceControllers.get(t);e&&e.abort(Error(`source "${n}" destroyed`));let r=this.sourceCreditGates.get(t);r&&r.abort()}this.sourceRequests.delete(n)}}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`source`,n)}async fetch(e,...t){if(this.destroyed)throw Error(`fetch: instance already destroyed`);let n,r,i,a={},o;typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new je,c=R();for(let e=0;e<10&&(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`));e++)c=R();if(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`))throw Error(`failed to generate unique request id`);let l=this.options.topicMake(n,`source-fetch-response`,this.options.id),u=(e,t)=>Error(`${e} name mismatch (expected "${n}", got "${t}")`);await this.subscribeTopicAndSpool(s,l,{qos:a.qos??2});let d=this.options.chunkCredit,f=d>0?d*this.options.chunkSize:16*1024,p=0,m=d,h=i,g=!1,_=!1,v=[],y=(e,t)=>{if(t===void 0||t===``){_=!0;let t=Error(`received ${e} without sender`);return x(t),w?.destroy(t),s.unroll()?.catch(()=>{}),!1}if(h===void 0)h=t;else if(t!==h)return!1;return!0},b,x,S=new Promise((e,t)=>{b=e,x=t});S.catch(()=>{}),s.roll(()=>{b(void 0)});let C=`source-fetch-recv:${c}`,w,T=()=>{_||w&&w.destroyed||this.timerRefresh(C,()=>{let e=Error(`communication timeout`);x(e),w?.destroy(e)})};s.roll(()=>{this.timerClear(C)}),w=new De({highWaterMark:f,read:e=>{if(d<=0||_)return;let t=h;if(!t)return;let r=m-p,i=Math.max(0,f-(w?.readableLength??0)),o=Math.floor(i/this.options.chunkSize),s=Math.max(0,o-r);if(s>0){m+=s;let e=this.msg.makeSourceFetchCredit(c,n,s,this.options.id,t),r=this.codec.encode(e),i=this.options.topicMake(n,`source-fetch-request`,t);this.publishToTopic(i,r,{qos:a.qos??2}).catch(e=>{let t=G(e,`sending source fetch credit failed`);this.error(t),D(t)}),T()}}});let E=w.buffer;T();let D=e=>{_=!0,x(e),w.destroy(e)},O=!1,ee=e=>{if(!O&&!_){O=!0;let e=h;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(e=>this.error(G(e,`sending source fetch cancel failed`)))}}_||x(e===void 0?Error(`stream aborted`):G(e)),s.unroll()?.catch(()=>{})};w.once(`close`,()=>ee()),w.once(`error`,e=>ee(e));let k=e=>{if(e.error)D(Error(e.error));else{if(T(),e.chunk!==void 0){if(d>0&&p>=m){D(Error(`flow control violation`));return}p++,w.destroyed||w.push(e.chunk)}e.final&&(_=!0,w.destroyed||w.push(null),s.unroll()?.catch(()=>{}))}};this.onResponse.set(`source-fetch-response:${c}`,e=>{if(!_){if(e.name!==n){D(u(`source response`,e.name));return}if(y(`source response`,e.sender))if(e.error)D(Error(e.error));else{if(g)return;g=!0,b(e.meta),T();for(let e of v){if(_)break;k(e)}v.length=0}}}),this.onResponse.set(`source-fetch-chunk:${c}`,e=>{if(!_){if(e.name!==n){D(u(`source chunk`,e.name));return}if(y(`source chunk`,e.sender)){if(!g){if(d>0&&v.length>=m){D(Error(`flow control violation`));return}v.push(e);return}k(e)}}}),s.roll(()=>{this.onResponse.delete(`source-fetch-response:${c}`),this.onResponse.delete(`source-fetch-chunk:${c}`)});let te=this.authenticate(),A=this.metaStore(o),ne=d>0?d:void 0,re=this.msg.makeSourceFetchRequest(c,n,r,this.options.id,i,te,A,ne,a.qos),ie=this.codec.encode(re),j=this.options.topicMake(n,`source-fetch-request`,i);await Pe(`publish fetch request as MQTT message to topic "${j}"`,()=>this.publishToTopic(j,ie,{qos:2,...a})).catch(e=>{let t=G(e);x(t),w.destroy(t)});let M={stream:w,buffer:E,meta:S};return Ae(M,`stream`,`buffer`,e=>{e===`stream`?w.stopCollecting():e===`buffer`&&w.resume()}),M}},fo=class extends uo{constructor(){super(...arguments),this.pushStreams=new Map,this.pushSpools=new Map,this.pushRecvControllers=new Map,this.destroying=!1,this.pushControllers=new Map,this.pushCreditGates=new Map,this.pushSenderSpools=new Map}async destroy(){this.destroying=!0;for(let e of this.pushSenderSpools.keys())this.timerClear(`sink-push-send:${e}`);for(let e of this.pushSpools.keys())this.timerClear(`sink-push-recv:${e}`);for(let e of this.pushControllers.values())e.abort(Error(`sink destroyed`));for(let e of this.pushCreditGates.values())e.abort();for(let e of[...this.pushSenderSpools.values()])await e.unroll();this.pushSenderSpools.clear(),this.pushControllers.clear(),this.pushCreditGates.clear();for(let e of this.pushRecvControllers.values())e.abort(Error(`sink destroyed`));this.pushRecvControllers.clear();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){if(this.destroyed)throw Error(`sink: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`sink: callback argument is required and must be a function`);let s=new je;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)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=e.params??[],c=e.sender,l=e.receiver,u=new je;if(c===void 0||c===``){this.error(Error(`invalid request: missing sender`)),await u.unroll();return}let d=this.options.topicMake(n,`sink-push-response`,c),f=e=>Error(`sink name mismatch (expected "${n}", got "${e}")`),p=this.options.chunkCredit,m=async(t,r=!1)=>{let o=t===void 0&&r&&p>0?p:void 0,s=this.msg.makeSinkPushResponse(a,n,t,this.options.id,c,o),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},h=new AbortController,g=h.signal,_,v=new Promise((e,t)=>{_=t});v.catch(()=>{});let y=()=>{_(G(g.reason))};if(g.aborted?y():g.addEventListener(`abort`,y,{once:!0}),u.roll(()=>{g.removeEventListener(`abort`,y)}),this.pushRecvControllers.has(a)){let e=Error(`sink: duplicate request id "${a}"`);this.error(e),await m(e.message).catch(()=>{}),await u.unroll();return}this.pushRecvControllers.set(a,h),u.roll(()=>{this.pushRecvControllers.delete(a)}),this.pushSpools.set(a,u),u.roll(()=>{this.pushSpools.delete(a)});let b=!1,x=!1,S=!1,C,w=()=>{};try{if(t!==e.name)throw Error(`sink name mismatch (topic: "${t}", payload: "${e.name}")`);let _;o&&(_=await this.authenticated(c,e.auth,o,`sink "${n}"`));let y=p>0?{chunksReceived:0,creditGranted:p}:void 0,T=p>0?p*this.options.chunkSize:16*1024,E=!1,D=`sink-push-recv:${a}`,O=()=>this.timerRefresh(D,()=>{if(!(E||this.destroying)&&(h.abort(Error(`push stream timeout`)),c&&!S)){S=!0;let t=this.msg.makeSinkPushCredit(a,n,0,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(()=>{})}}),ee=()=>this.timerClear(D),k=new De({highWaterMark:T,read:t=>{if(!y||!this.pushSpools.has(a))return;let r=y.creditGranted-y.chunksReceived,o=Math.max(0,T-k.readableLength),s=Math.floor(o/this.options.chunkSize),l=Math.max(0,s-r);if(l>0){y.creditGranted+=l;let t=this.msg.makeSinkPushCredit(a,n,l,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(e=>{let t=G(e,`sending sink push credit failed`);this.error(t),k.destroy(t)}),O()}}});C=k,this.pushStreams.set(a,k),u.roll(()=>{this.pushStreams.delete(a)}),k.on(`error`,w),u.roll(()=>{if(!b&&!g.aborted&&!this.destroying&&h.abort(Error(`push stream closed`)),!b&&!this.destroying&&!S&&c){let t=this.msg.makeSinkPushCredit(a,n,0,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(e=>this.error(G(e,`sending sink push cancel failed`)))}}),this.onResponse.set(`sink-push-chunk:${a}`,async e=>{if(!E){if(e.name!==n){E=!0,ee(),k.destroy(f(e.name));return}if(e.sender===void 0||e.sender===``){E=!0,ee(),k.destroy(Error(`sink chunk for "${n}" missing sender`));return}if(e.sender===c)if(e.error!==void 0)E=!0,ee(),k.destroy(Error(e.error));else{if(O(),e.chunk!==void 0){if(y){if(y.chunksReceived>=y.creditGranted){E=!0,ee(),k.destroy(Error(`flow control violation`));return}y.chunksReceived++}k.destroyed||k.push(e.chunk)}e.final&&(E=!0,ee(),k.destroyed||k.push(null))}}}),u.roll(()=>{this.onResponse.delete(`sink-push-chunk:${a}`)}),O(),u.roll(()=>{ee()});let te=k.buffer,A=!1,ne,re,ie=()=>{A||(A=!0,ne())},j=()=>{A||(A=!0,E||k.readableEnded?ne():re(Error(`push stream closed before end`)))},M=e=>{A||(A=!0,re(e))},ae=new Promise((e,t)=>{ne=e,re=t,k.once(`end`,ie),k.once(`close`,j),k.once(`error`,M)});ae.finally(()=>{k.removeListener(`end`,ie),k.removeListener(`close`,j),k.removeListener(`error`,M)}).catch(()=>{});let oe={sender:c,signal:g,stream:k,buffer:te};l&&(oe.receiver=l),_!==void 0&&(oe.authenticated=_),e.meta&&(oe.meta=e.meta),Ae(oe,`stream`,`buffer`,e=>{e===`stream`?k.stopCollecting():e===`buffer`&&k.resume()}),await m(void 0,!0),x=!0;let N=Promise.resolve(r(...s,oe));if(N.catch(()=>{}),await Promise.race([N,v]),k.readableFlowing!==!0&&!k.destroyed&&k.resume(),await ae.catch(e=>{throw this.error(G(e),`stream drain after sink "${n}" callback failed`),e}),k.collecting&&k.stopCollecting(),!g.aborted)try{b=!0,await m()}catch(e){this.error(G(e),`sending terminal response for sink "${n}" failed`)}}catch(e){let t=G(e,`handler for sink "${n}" failed`);if(h.abort(t),x&&!this.destroying){let e=this.pushStreams.get(a);e!==void 0&&!e.destroyed&&e.destroy(t)}this.error(t),S||(S=!0,await m(t.message).catch(()=>{}))}finally{let e=this.pushStreams.get(a);e!==void 0&&!e.destroyed&&!b&&!S&&e.destroy(g.aborted?G(g.reason):Error(`sink push aborted without cause`)),await u.unroll(),C!==void 0&&C.removeListener(`error`,w)}}),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)}async push(e,...t){if(this.destroyed)throw Error(`push: instance already destroyed`);let n,r,i,a,o={},s;if(typeof e==`object`&&e&&`name`in 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 L.Readable)&&!(r instanceof Uint8Array))throw Error(`invalid data type: expected Readable or Uint8Array`);let c=new je,l=R();for(let e=0;e<10&&(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`));e++)l=R();if(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`))throw Error(`failed to generate unique request id`);this.pushSenderSpools.set(l,c),c.roll(()=>{this.pushSenderSpools.delete(l)});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(this.pushControllers.set(l,d),c.roll(()=>{this.pushControllers.delete(l)}),r instanceof L.Readable){let e=r;f.addEventListener(`abort`,()=>{e.destroyed||e.destroy(G(f.reason))},{once:!0})}let p=`sink-push-send:${l}`,m=()=>{f.aborted||this.timerRefresh(p,()=>{let e=Error(`push to sink "${n}" timed out`);d.abort(e)})};c.roll(()=>{this.timerClear(p)}),m();let h,g,_=0,v,y=!1,b=!1,x=!1,S=!1,C=!1,w=!1,T=!1,E=a,D,O,ee=new Promise((e,t)=>{D=e,O=t});ee.catch(()=>{});let k=(e,t)=>{if(t===void 0||t===``){let t=Error(`received ${e} without sender`);return v=t,d.abort(t),b?S||(S=!0,O(t)):(x=!0,A(t)),!1}if(E===void 0)E=t;else if(t!==E)return!1;return!0},te,A,ne=new Promise((e,t)=>{te=e,A=t});this.onResponse.set(`sink-push-response:${l}`,e=>{if(e.name!==n){let t=Error(`sink response name mismatch (expected "${n}", got "${e.name}")`);v=t,d.abort(t),b?S||(S=!0,O(t)):(x=!0,A(t));return}if(k(`sink response`,e.sender))if(e.error){let t=Error(e.error);v=t,d.abort(t),b?S||(S=!0,O(t)):(x=!0,A(t))}else b?S||(w?(S=!0,D()):T=!0):(h=e.credit,b=!0,x=!0,te())}),c.roll(()=>{this.onResponse.delete(`sink-push-response:${l}`)}),this.onResponse.set(`sink-push-credit:${l}`,e=>{if(e.name!==n){let t=Error(`sink credit name mismatch (expected "${n}", got "${e.name}")`);v=t,d.abort(t),b?S||(S=!0,O(t)):(x=!0,A(t));return}if(k(`sink credit`,e.sender)){if(e.credit===0){y=!0;let e=Error(`push to sink "${n}" cancelled by receiver`);d.abort(e),b?S||(S=!0,O(e)):(x=!0,A(e));return}if(g!==void 0)g.replenish(e.credit),m();else if(b&&h===void 0){let e=Error(`push to sink "${n}" received unsolicited credit (credit-flow disabled)`);v=e,d.abort(e),S||(S=!0,O(e))}else _+=e.credit}}),c.roll(()=>{this.onResponse.delete(`sink-push-credit:${l}`)});try{let e=()=>{let e=G(f.reason);x||(x=!0,A(e)),S||(S=!0,O(e))};f.addEventListener(`abort`,e,{once:!0}),c.roll(()=>{f.removeEventListener(`abort`,e)});let t=this.authenticate(),u=this.metaStore(s),d=this.msg.makeSinkPushRequest(l,n,i,this.options.id,a,t,u,o.qos),p=this.codec.encode(d),v=this.options.topicMake(n,`sink-push-request`,a);if(await Pe(`publish push request as MQTT message to topic "${v}"`,()=>this.publishToTopic(v,p,{qos:2,...o})),await ne,h!==void 0&&h>0)g=new Ce(h+_),_>0&&m(),_=0;else if(_>0)throw Error(`push to sink "${n}" received unsolicited credit (credit-flow disabled)`);if(g&&(this.pushCreditGates.set(l,g),c.roll(()=>{this.pushCreditGates.delete(l)})),g){let e=g;c.roll(()=>{e.abort()})}let y=E;if(y===void 0)throw Error(`push to sink "${n}" missing responder`);let b=this.options.topicMake(n,`sink-push-request`,y),k=async(e,t,r)=>{m();let i=this.msg.makeSinkPushChunk(l,n,e,t,r,this.options.id,y),a=this.codec.encode(i);await this.publishToTopic(b,a,{qos:2,...o}),t===void 0&&r&&(C=!0)};r instanceof L.Readable?await ke(r,this.options.chunkSize,k,g,f):r instanceof Uint8Array&&await Oe(r,this.options.chunkSize,k,g,f),w=!0,T&&!S&&(S=!0,D()),m(),S||await ee}catch(e){let t=G(e);if(d.abort(t),b&&!v&&!y&&!C)try{let e=E;if(e!==void 0){let r=this.options.topicMake(n,`sink-push-request`,e),i=this.msg.makeSinkPushChunk(l,n,void 0,t.message,!0,this.options.id,e),a=this.codec.encode(i);await this.publishToTopic(r,a,{qos:2,...o}).catch(()=>{})}}catch{}throw b&&!v&&await new Promise(e=>{setImmediate(e)}),v||e}finally{await c.unroll()}}};return class extends fo{}});
13
+ `,l+=c,l},sa.noChildren=!0,Q.registerDecoder(Y.CBOR,sa),Q.registerDecoder(Y.URI,e=>(Zi(e.contents),new URL(e.contents)),`URI`),$(URL,e=>[Y.URI,e.toString()]),Q.registerDecoder(Y.BASE64URL,e=>(Zi(e.contents),ur(e.contents)),`Base64url-encoded`),Q.registerDecoder(Y.BASE64,e=>(Zi(e.contents),cr(e.contents)),`Base64-encoded`),Q.registerDecoder(35,e=>(Zi(e.contents),new RegExp(e.contents)),`RegExp`),Q.registerDecoder(21065,e=>{Zi(e.contents);let t=`^(?:${e.contents})$`;return new RegExp(t,`u`)},`I-RegExp`),Q.registerDecoder(Y.REGEXP,e=>{if($i(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`),$(RegExp,e=>[Y.REGEXP,[e.source,e.flags]]),Q.registerDecoder(64,e=>(Qi(e.contents),e.contents),`uint8 Typed Array`);function ca(e,t,n){Qi(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 la(e,t,n,r,i){let a=i.forceEndian??Yi;if(gi(a?t:n,e,i),hi(r.byteLength,e,J.BYTE_STRING),Yi===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)}}Q.registerDecoder(65,e=>ca(e,Uint16Array,!1),`uint16, big endian, Typed Array`),Q.registerDecoder(66,e=>ca(e,Uint32Array,!1),`uint32, big endian, Typed Array`),Q.registerDecoder(67,e=>ca(e,BigUint64Array,!1),`uint64, big endian, Typed Array`),Q.registerDecoder(68,e=>(Qi(e.contents),new Uint8ClampedArray(e.contents)),`uint8 Typed Array, clamped arithmetic`),$(Uint8ClampedArray,e=>[68,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),Q.registerDecoder(69,e=>ca(e,Uint16Array,!0),`uint16, little endian, Typed Array`),$(Uint16Array,(e,t,n)=>la(t,69,65,e,n)),Q.registerDecoder(70,e=>ca(e,Uint32Array,!0),`uint32, little endian, Typed Array`),$(Uint32Array,(e,t,n)=>la(t,70,66,e,n)),Q.registerDecoder(71,e=>ca(e,BigUint64Array,!0),`uint64, little endian, Typed Array`),$(BigUint64Array,(e,t,n)=>la(t,71,67,e,n)),Q.registerDecoder(72,e=>(Qi(e.contents),new Int8Array(e.contents)),`sint8 Typed Array`),$(Int8Array,e=>[72,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),Q.registerDecoder(73,e=>ca(e,Int16Array,!1),`sint16, big endian, Typed Array`),Q.registerDecoder(74,e=>ca(e,Int32Array,!1),`sint32, big endian, Typed Array`),Q.registerDecoder(75,e=>ca(e,BigInt64Array,!1),`sint64, big endian, Typed Array`),Q.registerDecoder(77,e=>ca(e,Int16Array,!0),`sint16, little endian, Typed Array`),$(Int16Array,(e,t,n)=>la(t,77,73,e,n)),Q.registerDecoder(78,e=>ca(e,Int32Array,!0),`sint32, little endian, Typed Array`),$(Int32Array,(e,t,n)=>la(t,78,74,e,n)),Q.registerDecoder(79,e=>ca(e,BigInt64Array,!0),`sint64, little endian, Typed Array`),$(BigInt64Array,(e,t,n)=>la(t,79,75,e,n)),Q.registerDecoder(81,e=>ca(e,Float32Array,!1),`IEEE 754 binary32, big endian, Typed Array`),Q.registerDecoder(82,e=>ca(e,Float64Array,!1),`IEEE 754 binary64, big endian, Typed Array`),Q.registerDecoder(85,e=>ca(e,Float32Array,!0),`IEEE 754 binary32, little endian, Typed Array`),$(Float32Array,(e,t,n)=>la(t,85,81,e,n)),Q.registerDecoder(86,e=>ca(e,Float64Array,!0),`IEEE 754 binary64, big endian, Typed Array`),$(Float64Array,(e,t,n)=>la(t,86,82,e,n)),Q.registerDecoder(Y.SET,(e,t)=>{if($i(e.contents),t.sortKeys){let n=Fi.decodeToEncodeOpts(t),r=null;for(let i of e.contents){let e=[i,void 0,Di(i,n)];if(r&&t.sortKeys(r,e)>=0)throw Error(`Set items out of order in tag #${Y.SET}`);r=e}}return new Set(e.contents)},`Set`),$(Set,(e,t,n)=>{let r=[...e];if(n.sortKeys){let e=r.map(e=>[e,void 0,Di(e,n)]);e.sort(n.sortKeys),r=e.map(([e])=>e)}return[Y.SET,r]}),Q.registerDecoder(Y.JSON,e=>(Zi(e.contents),JSON.parse(e.contents)),`JSON-encoded`);function ua(e){return Qi(e.contents),new Zr().decode(e.contents)}ua.comment=e=>{Qi(e.contents);let t=new Zr;return`(WTF8 string): ${JSON.stringify(t.decode(e.contents))}`},Q.registerDecoder(Y.WTF8,ua),Q.registerDecoder(Y.SELF_DESCRIBED,e=>e.contents,`Self-Described`),Q.registerDecoder(Y.INVALID_16,()=>{throw Error(`Tag always invalid: ${Y.INVALID_16}`)},`Invalid`),Q.registerDecoder(Y.INVALID_32,()=>{throw Error(`Tag always invalid: ${Y.INVALID_32}`)},`Invalid`),Q.registerDecoder(Y.INVALID_64,()=>{throw Error(`Tag always invalid: ${Y.INVALID_64}`)},`Invalid`),Q.registerDecoder(Y.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(Zi(t),!t.length)throw Error(`Expected non-empty string: ${e.contents}`);return Symbol.for(t)},`Symbol`);function da(e){throw Error(`Encoding ${e.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}$(ArrayBuffer,da),$(DataView,da),typeof SharedArrayBuffer<`u`&&$(SharedArrayBuffer,da);function fa(e){return[NaN,e.valueOf()]}$(Boolean,fa),$(Number,fa),$(String,fa),$(BigInt,fa);function pa(e){let t={...Fi.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Fi.dcborDecodeOptions):e.cde&&Object.assign(t,Fi.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,`rejectLongNumbers`))throw TypeError(`rejectLongNumbers has changed to requirePreferred`);return t.boxed&&(t.saveOriginal=!0),t}var ma=class{parent=void 0;ret=void 0;step(e,t,n){if(this.ret=Fi.create(e,this.parent,t,n),e[2]===Z.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 Fi&&(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 ha(e,t={}){let n=pa(t),r=new ji(e,n),i=new ma;for(let e of r)i.step(e,n,r);return i.ret}var{cdeDecodeOptions:ga,dcborDecodeOptions:_a,defaultDecodeOptions:va}=Fi,ya=class{constructor(e={}){this.options={id:R(),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}}},ba=class{static uint8ArrayToBase64(e){return Se.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)}static base64ToUint8Array(e){return new Uint8Array(Se.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)}},xa=class{constructor(e){this.format=e,this.types=new pr,this.tags=new Map;let t=64e3;this.types.registerEncoder(Se,e=>[t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),this.tags.set(t,e=>Se.from(e.contents))}encode(e){let t;if(this.format===`cbor`)try{t=Di(e,{types:this.types})}catch(e){throw Error(`failed to encode CBOR format`,{cause:e})}else if(this.format===`json`)try{t=ba.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=ha(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=ba.parse(e)}catch(e){throw Error(`failed to decode JSON format`,{cause:e})}}else throw Error(`invalid format "${this.format}"`);return t}},Sa=class extends ya{constructor(e={}){super(e),this.codec=new xa(this.options.codec)}},Ca=class e extends Sa{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===Se)n=Se.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}},wa=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},Ta=wa(`1.4`),Ea=wa(`1.4`),Da=Kn(Un(q(),Gn()),An(e=>!Array.isArray(e))),Oa=Kn(Ln(Kn(q(),Mn(8192))),Mn(8)),ka=class{constructor(e,t,n,r){this.type=e,this.id=t,this.sender=n,this.receiver=r,this.version=`MQTT+/1.4`}},Aa={version:Kn(q(),Pn(/^MQTT\+\/\d+\.\d+$/)),type:q(),id:q(),sender:K(q()),receiver:K(q())},ja=class extends ka{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}},Ma=Wn({...Aa,type:Bn(`event-emission`),name:q(),params:K(Kn(Ln(Gn()),Mn(64))),auth:K(Oa),meta:K(Da)}),Na=class extends ka{constructor(e,t,n,r,i,a,o,s){super(`service-call-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.qos=s}},Pa=Wn({...Aa,type:Bn(`service-call-request`),name:q(),params:K(Kn(Ln(Gn()),Mn(64))),auth:K(Oa),meta:K(Da),qos:K(Hn([0,1,2]))}),Fa=class extends ka{constructor(e,t,n,r,i,a){super(`service-call-response`,e,i,a),this.name=t,this.result=n,this.error=r}},Ia=Wn({...Aa,type:Bn(`service-call-response`),name:q(),result:K(Gn()),error:K(q())}),La=class extends ka{constructor(e,t,n,r,i,a,o,s){super(`sink-push-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.qos=s}},Ra=Wn({...Aa,type:Bn(`sink-push-request`),name:q(),params:K(Kn(Ln(Gn()),Mn(64))),auth:K(Oa),meta:K(Da),qos:K(Hn([0,1,2]))}),za=class extends ka{constructor(e,t,n,r,i,a){super(`sink-push-response`,e,r,i),this.name=t,this.error=n,this.credit=a}},Ba=Wn({...Aa,type:Bn(`sink-push-response`),name:q(),error:K(q()),credit:K(Kn(Vn(),jn(),Nn(1)))}),Va=class extends ka{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}},Ha=Wn({...Aa,type:Bn(`sink-push-chunk`),name:q(),chunk:K(zn(Uint8Array)),error:K(q()),final:K(Rn())}),Ua=class extends ka{constructor(e,t,n,r,i){super(`sink-push-credit`,e,r,i),this.name=t,this.credit=n}},Wa=Wn({...Aa,type:Bn(`sink-push-credit`),name:q(),credit:Kn(Vn(),jn(),Nn(0))}),Ga=class extends ka{constructor(e,t,n,r,i,a,o,s,c){super(`source-fetch-request`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o,this.credit=s,this.qos=c}},Ka=Wn({...Aa,type:Bn(`source-fetch-request`),name:q(),params:K(Kn(Ln(Gn()),Mn(64))),auth:K(Oa),meta:K(Da),credit:K(Kn(Vn(),jn(),Nn(1))),qos:K(Hn([0,1,2]))}),qa=class extends ka{constructor(e,t,n,r,i,a){super(`source-fetch-response`,e,r,i),this.name=t,this.error=n,this.meta=a}},Ja=Wn({...Aa,type:Bn(`source-fetch-response`),name:q(),error:K(q()),meta:K(Da)}),Ya=class extends ka{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}},Xa=Wn({...Aa,type:Bn(`source-fetch-chunk`),name:q(),chunk:K(zn(Uint8Array)),error:K(q()),final:K(Rn())}),Za=class extends ka{constructor(e,t,n,r,i){super(`source-fetch-credit`,e,r,i),this.name=t,this.credit=n}},Qa=Wn({...Aa,type:Bn(`source-fetch-credit`),name:q(),credit:Kn(Vn(),jn(),Nn(0))}),$a=class{makeEventEmission(e,t,n,r,i,a,o){return new ja(e,t,n,r,i,a,o)}makeServiceCallRequest(e,t,n,r,i,a,o,s){return new Na(e,t,n,r,i,a,o,s)}makeServiceCallResponse(e,t,n,r,i,a){return new Fa(e,t,n,r,i,a)}makeSinkPushRequest(e,t,n,r,i,a,o,s){return new La(e,t,n,r,i,a,o,s)}makeSinkPushResponse(e,t,n,r,i,a){return new za(e,t,n,r,i,a)}makeSinkPushChunk(e,t,n,r,i,a,o){return new Va(e,t,n,r,i,a,o)}makeSinkPushCredit(e,t,n,r,i){return new Ua(e,t,n,r,i)}makeSourceFetchRequest(e,t,n,r,i,a,o,s,c){return new Ga(e,t,n,r,i,a,o,s,c)}makeSourceFetchResponse(e,t,n,r,i,a){return new qa(e,t,n,r,i,a)}makeSourceFetchChunk(e,t,n,r,i,a,o){return new Ya(e,t,n,r,i,a,o)}makeSourceFetchCredit(e,t,n,r,i){return new Za(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+)$/),n=t===null?0:wa(t[1]);if(Math.floor(n/100)!==Math.floor(Ta/100)||n<Ea)throw Error(`protocol version mismatch (expected version 1.4...1.4, got version ${e.version})`);let r=(e,t,n)=>{let r=qn(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=r(e,`EventEmission`,Ma);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=r(e,`ServiceCallRequest`,Pa);return this.makeServiceCallRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}else if(e.type===`service-call-response`){let t=r(e,`ServiceCallResponse`,Ia);return this.makeServiceCallResponse(t.id,t.name,t.result,t.error,t.sender,t.receiver)}else if(e.type===`sink-push-request`){let t=r(e,`SinkPushRequest`,Ra);return this.makeSinkPushRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}else if(e.type===`sink-push-response`){let t=r(e,`SinkPushResponse`,Ba);return this.makeSinkPushResponse(t.id,t.name,t.error,t.sender,t.receiver,t.credit)}else if(e.type===`sink-push-chunk`){let t=r(e,`SinkPushChunk`,Ha);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=r(e,`SinkPushCredit`,Wa);return this.makeSinkPushCredit(t.id,t.name,t.credit,t.sender,t.receiver)}else if(e.type===`source-fetch-request`){let t=r(e,`SourceFetchRequest`,Ka);return this.makeSourceFetchRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.credit,t.qos)}else if(e.type===`source-fetch-response`){let t=r(e,`SourceFetchResponse`,Ja);return this.makeSourceFetchResponse(t.id,t.name,t.error,t.sender,t.receiver,t.meta)}else if(e.type===`source-fetch-chunk`){let t=r(e,`SourceFetchChunk`,Xa);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=r(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 ja||e instanceof Na||e instanceof Ga||e instanceof La}isResponse(e){return e instanceof Fa||e instanceof za||e instanceof Va||e instanceof Ua||e instanceof qa||e instanceof Ya||e instanceof Za}},eo=class extends Ca{constructor(){super(...arguments),this.msg=new $a}},to=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}: ${ba.stringify(n)}`}).join(`, `)})`}return`[${t}] ${this.level}: ${n}${r}`}},no=class extends eo{constructor(){super(...arguments),this._events=new mn.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 to(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}),n.stack=e.stack);try{this.emitEvent(`error`,n),this.log(`error`,n.message)}catch{}}},ro=class extends no{constructor(e,t={}){super(t),this.destroyed=!1,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)=>{if(this.destroyed)return;let r;if(this.options.codec===`json`)r=t.toString();else if(this.options.codec===`cbor`)r=xe.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.destroyed=!0,this.log(`info`,`un-hooking from MQTT client`),this.mqtt.off(`message`,this.messageHandler),this.onRequest.clear(),this.onResponse.clear()}makeRegistration(e,t,n){let r=!1;return{destroy:async()=>{r||(r=!0,await e.unroll(!1)?.catch(e=>{let r=W(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 Ce((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:xe.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){if(this.destroyed)return;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(W(e,`failed to parse message into object`));return}let a;try{a=this.msg.parse(i)}catch(e){this.error(W(e,`failed to parse object into typed message object`));return}if(this.log(`debug`,`received from MQTT topic "${e}"`,{message:a}),r.peerId!==void 0&&a.receiver!==void 0&&a.receiver!==r.peerId&&this.log(`warning`,`receiver mismatch on direct topic "${e}" (expected "${r.peerId}", got "${a.receiver}")`),this.msg.isRequest(a)){let t=this.onRequest.get(`${a.type}:${a.name}`);t!==void 0&&Promise.resolve().then(()=>{if(!this.destroyed)return t(a,r.name)}).catch(t=>{this.error(W(t,`dispatching request message from MQTT topic "${e}" (type: ${a.type}, id: ${a.id}, name: ${a.name}) failed`))})}else if(this.msg.isResponse(a)){let t=this.onResponse.get(`${a.type}:${a.id}`);t!==void 0&&Promise.resolve().then(()=>{if(!this.destroyed)return t(a,r.name)}).catch(t=>{this.error(W(t,`dispatching response message from MQTT topic "${e}" (type: ${a.type}, id: ${a.id}, name: ${a.name}) failed`))})}}},io=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)}clearCount(e){this.counts.delete(e)}async subscribe(e,t={qos:2}){if(this.incrementCount(e)===0){let n=this.lingers.get(e);if(n){clearTimeout(n),this.lingers.delete(e);return}let r,i,a=new Promise((e,t)=>{r=e,i=t});a.catch(()=>{}),this.pending.set(e,a);let o=this.unsubbing.get(e);return o&&await o,this.subscribeFn(e,t).then(()=>{this.pending.delete(e),r()},t=>{this.pending.delete(e),this.clearCount(e),i(t)}),a}else{let t=this.pending.get(e);if(t)return 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()}},ao=class extends ro{constructor(){super(...arguments),this.subscriptions=new io((e,t)=>this.subscribeTopic(e,t),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,t,n={}){await Fe(`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()}},oo=class extends ao{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()=>{if(!this.destroyed){this.timers.delete(e);try{await t()}catch(t){this.error(W(t),`timer "${e}" failed`)}}},this.options.timeout))}timerClear(e){let t=this.timers.get(e);t!==void 0&&(clearTimeout(t),this.timers.delete(e))}sleep(e,t){return new Promise(n=>{if(t?.aborted){n();return}let r=t===void 0?void 0:new AbortController,i=setTimeout(()=>{i=null,r!==void 0&&r.abort(),n()},e);i.unref(),t!==void 0&&r!==void 0&&t.addEventListener(`abort`,()=>{i!==null&&clearTimeout(i),n()},{once:!0,signal:r.signal})})}timeout(e,t=`timeout`,n){return new Promise((r,i)=>{if(n?.aborted){i(Error(`aborted`));return}let a=n===void 0?void 0:new AbortController,o=setTimeout(()=>{o=null,a!==void 0&&a.abort(),i(Error(t))},e);o.unref(),n!==void 0&&a!==void 0&&n.addEventListener(`abort`,()=>{o!==null&&clearTimeout(o),i(Error(`aborted`))},{once:!0,signal:a.signal})})}},so=class extends oo{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}}},co=new TextEncoder,lo=class extends so{constructor(){super(...arguments),this._credential=null,this._tokens=new Set}credential(e){if(e.length===0)throw Error(`credential must not be empty`);let t=co.encode(e),n=co.encode(`mqtt-plus`);this._credential=un(dn,t,n,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 $t(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);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`);try{return(await rn(e,this._credential)).payload}catch(e){let t=e?.code??e?.name??`unknown`,n=e?.message??``;return this.log(`warning`,`token validation failed`,{code:t,reason:n}),null}}async authenticated(e,t,n,r){let i=!1,a=typeof n==`string`?[n]:n.roles;if(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)){i=!0;break}if(i)break}}let o=typeof n==`string`||n.mode===`require`;if(!i&&o)throw Error(`${r} failed authentication`);return i}},uo=class extends lo{constructor(){super(...arguments),this.eventControllers=new Map}async destroy(){for(let e of this.eventControllers.values())e.abort(Error(`event destroyed`));this.eventControllers.clear(),await super.destroy()}async event(e,...t){if(this.destroyed)throw Error(`event: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`event: callback argument is required and must be a function`);let s=new Me;if(this.onRequest.has(`event-emission:${n}`))throw Error(`event: event "${n}" already registered`);let c=new Set;s.roll(()=>{for(let e of c)this.eventControllers.get(e)?.abort(Error(`event "${n}" destroyed`)),this.eventControllers.delete(e);c.clear()});let l=a===``?n:`$share/${a}/${n}`,u=this.options.topicMake(l,`event-emission`),d=this.options.topicMake(n,`event-emission`,this.options.id);return this.onRequest.set(`event-emission:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let i=e.id,a=e.sender;if(a===void 0||a===``){this.error(Error(`invalid request: missing sender`));return}if(t!==e.name){this.log(`warning`,`event name mismatch -- dropped request for "${n}" (topic: "${t}", payload: "${e.name}")`,{requestId:i});return}let s=e.params??[];if(this.eventControllers.has(i)){this.log(`warning`,`duplicate event request id -- dropped request for event "${n}"`,{requestId:i});return}let l=new AbortController,u=l.signal;c.add(i),this.eventControllers.set(i,l);let d={sender:a,signal:u};e.receiver&&(d.receiver=e.receiver),e.meta&&(d.meta=e.meta);try{o&&(d.authenticated=await this.authenticated(a,e.auth,o,`event "${n}"`)),await r(...s,d)}catch(e){let t=W(e);this.error(t,`handler for event "${n}" failed`)}finally{l.abort(),c.delete(i),this.eventControllers.delete(i)}}),s.roll(()=>{this.onRequest.delete(`event-emission:${n}`)}),await this.subscribeTopicAndSpool(s,u,i),await this.subscribeTopicAndSpool(s,d,i),this.makeRegistration(s,`event`,n)}emit(e,...t){if(this.destroyed)throw Error(`emit: instance already destroyed`);let n,r,i,a={},o,s;typeof e==`object`&&e&&`name`in 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=R(),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);return s?{topic:p,payload:f,options:{qos:2,...a}}:Fe(`publish event as MQTT message to topic "${p}"`,()=>this.publishToTopic(p,f,{qos:2,...a}))}},fo=class extends uo{constructor(){super(...arguments),this.serviceControllers=new Map,this.pendingCalls=new Map}async destroy(){for(let e of this.serviceControllers.values())e.abort(Error(`service destroyed`));this.serviceControllers.clear();let e=[...this.pendingCalls.values()];this.pendingCalls.clear();for(let t of e)t(Error(`instance destroyed`));await super.destroy()}async service(e,...t){if(this.destroyed)throw Error(`service: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`service: callback argument is required and must be a function`);let s=new Me;if(this.onRequest.has(`service-call-request:${n}`))throw Error(`service: service "${n}" already registered`);let c=new Set;s.roll(()=>{for(let e of c)this.serviceControllers.get(e)?.abort(Error(`service "${n}" destroyed`)),this.serviceControllers.delete(e);c.clear()});let l=a===``?n:`$share/${a}/${n}`,u=this.options.topicMake(l,`service-call-request`),d=this.options.topicMake(n,`service-call-request`,this.options.id);return this.onRequest.set(`service-call-request:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let i=e.id,a=e.sender,s=e.params??[];if(a===void 0||a===``){this.error(Error(`invalid request: missing sender`));return}if(t!==e.name){this.log(`warning`,`service name mismatch -- dropped request for "${n}" (topic: "${t}", payload: "${e.name}")`,{requestId:i});return}if(this.serviceControllers.has(i)){this.log(`warning`,`duplicate service request id -- dropped request for "${n}"`,{requestId:i});return}let l=new AbortController,u=l.signal;c.add(i),this.serviceControllers.set(i,l);let d={sender:a,signal:u};e.receiver&&(d.receiver=e.receiver),e.meta&&(d.meta=e.meta);let f=`service-call-handler:${i}`,p=()=>{this.timerRefresh(f,()=>{l.abort(Error(`service "${n}" handler timeout`))})},m=()=>this.timerClear(f);p();let h;try{o&&(d.authenticated=await this.authenticated(a,e.auth,o,`service "${n}"`));let t=new Promise((e,t)=>{let n=()=>{t(W(u.reason))};u.aborted?n():(u.addEventListener(`abort`,n,{once:!0}),h=()=>u.removeEventListener(`abort`,n))}),c=await Promise.race([r(...s,d),t]),l=this.msg.makeServiceCallResponse(i,n,c,void 0,this.options.id,a),f=this.codec.encode(l),p=this.options.topicMake(n,`service-call-response`,a);await this.publishToTopic(p,f,{qos:e.qos??2})}catch(t){let r=W(t);this.error(r,`handler for service "${n}" failed`);let o=this.msg.makeServiceCallResponse(i,n,void 0,r.message,this.options.id,a);try{let t=this.codec.encode(o),r=this.options.topicMake(n,`service-call-response`,a);await this.publishToTopic(r,t,{qos:e.qos??2})}catch(e){this.error(W(e),`sending error response for service "${n}" failed`)}}finally{h?.(),m(),l.abort(),c.delete(i),this.serviceControllers.delete(i)}}),s.roll(()=>{this.onRequest.delete(`service-call-request:${n}`)}),await this.subscribeTopicAndSpool(s,u,i),await this.subscribeTopicAndSpool(s,d,i),this.makeRegistration(s,`service`,n)}async call(e,...t){if(this.destroyed)throw Error(`call: instance already destroyed`);let n,r,i,a={},o;typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new Me,c=R();for(let e=0;e<10&&this.onResponse.has(`service-call-response:${c}`);e++)c=R();if(this.onResponse.has(`service-call-response:${c}`))throw Error(`failed to generate unique request id`);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=!1,p=()=>f?!1:(f=!0,s.unroll(),!0),m=new Promise((e,t)=>{d=t,this.timerRefresh(u,()=>{p()&&t(Error(`communication timeout`))}),s.roll(()=>{this.timerClear(u)}),this.pendingCalls.set(c,e=>{p()&&t(e)}),s.roll(()=>{this.pendingCalls.delete(c)}),this.onResponse.set(`service-call-response:${c}`,r=>{if(!(i!==void 0&&r.sender!==i)){if(r.sender===void 0||r.sender===``){if(!p())return;t(Error(`received service response without sender`));return}if(r.name!==n){if(!p())return;t(Error(`received service response with name mismatch (expected: "${n}", received: "${r.name}")`));return}p()&&(r.error===void 0?e(r.result):t(Error(r.error)))}}),s.roll(()=>{this.onResponse.delete(`service-call-response:${c}`)})}),h=this.authenticate(),g=this.metaStore(o),_=a.qos??2,v=this.msg.makeServiceCallRequest(c,n,r,this.options.id,i,h,g,_),y=this.codec.encode(v),b=this.options.topicMake(n,`service-call-request`,i);try{await Fe(`publish service request as MQTT message to topic "${b}"`,()=>this.publishToTopic(b,y,{...a,qos:_}))}catch(e){return p()&&d(e),m}return m}},po=class extends fo{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map,this.sourceSpools=new Map,this.sourceRequests=new Map}async destroy(){for(let e of this.sourceControllers.values())e.abort(Error(`source destroyed`));for(let e of this.sourceCreditGates.values())e.abort();for(let e of[...this.sourceSpools.values()])await e.unroll();this.sourceSpools.clear(),this.sourceControllers.clear(),this.sourceCreditGates.clear(),this.sourceRequests.clear(),await super.destroy()}async source(e,...t){if(this.destroyed)throw Error(`source: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`source: callback argument is required and must be a function`);let s=new Me;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)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=e.params??[],c=e.sender,l=e.receiver,u=new Me;if(this.sourceSpools.set(a,u),u.roll(()=>{this.sourceSpools.delete(a)}),c===void 0||c===``){this.error(Error(`invalid request: missing sender`)),await u.unroll();return}let d=this.options.topicMake(n,`source-fetch-response`,c),f=(e,t)=>Error(`${e} name mismatch (expected "${n}", got "${t}")`),p=async(t,r)=>{let o=this.metaStore(r),s=this.msg.makeSourceFetchResponse(a,n,t,this.options.id,c,o),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},m=new AbortController,h=m.signal;if(this.sourceControllers.has(a)){let e=Error(`source: duplicate request id "${a}"`);this.error(e),await p(e.message).catch(()=>{}),await u.unroll();return}this.sourceControllers.set(a,m),u.roll(()=>{this.sourceControllers.delete(a)});let g={sender:c,signal:h};l&&(g.receiver=l),e.meta&&(g.meta=e.meta);let _=this.sourceRequests.get(n);_||(_=new Set,this.sourceRequests.set(n,_)),_.add(a),u.roll(()=>{let e=this.sourceRequests.get(n);e===_&&(e.delete(a),e.size===0&&this.sourceRequests.delete(n))}),h.addEventListener(`abort`,()=>{g.stream instanceof L.Readable&&!g.stream.destroyed&&g.stream.destroy(W(h.reason))},{once:!0}),u.roll(()=>{h.aborted&&g.stream instanceof L.Readable&&!g.stream.destroyed&&g.stream.destroy(W(h.reason))});let v,y=new Promise((e,t)=>{v=t});y.catch(()=>{});let b=()=>{v(W(h.reason))};h.aborted?b():h.addEventListener(`abort`,b,{once:!0}),u.roll(()=>{h.removeEventListener(`abort`,b)});let x=`source-fetch-send:${a}`,S=()=>{h.aborted||this.timerRefresh(x,()=>{m.abort(Error(`source fetch "${n}" timed out`))})},ee=()=>this.timerClear(x);S(),u.roll(()=>{ee()});let C=async(t,r,o)=>{S();let s=this.msg.makeSourceFetchChunk(a,n,t,r,o,this.options.id,c),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},w=!1,T,E=!1;try{if(t!==e.name)throw Error(`source name mismatch (topic: "${t}", payload: "${e.name}")`);this.onResponse.set(`source-fetch-credit:${a}`,e=>{if(!h.aborted){if(e.name!==n){m.abort(f(`source credit`,e.name));return}if(e.sender===void 0||e.sender===``){m.abort(Error(`source credit for "${n}" missing sender`));return}if(e.sender===c){if(e.credit===0){E=!0,m.abort(Error(`source fetch "${n}" cancelled by fetcher`));return}T&&(T.replenish(e.credit),S())}}}),u.roll(()=>{this.onResponse.delete(`source-fetch-credit:${a}`)}),o&&(g.authenticated=await this.authenticated(c,e.auth,o,`source "${n}"`));let i=Promise.resolve(r(...s,g));if(i.catch(()=>{}),await Promise.race([i,y]),!(g.stream instanceof L.Readable)&&!(g.buffer instanceof Promise)&&!(g.buffer instanceof Uint8Array))throw Error(`handler did not provide data via info.stream or info.buffer fields`);if(g.stream instanceof L.Readable&&(g.buffer instanceof Promise||g.buffer instanceof Uint8Array))throw Error(`handler has set both info.stream and info.buffer fields`);let l=e.credit;if(T=l!==void 0&&l>0?new we(l):void 0,T){let e=T;this.sourceCreditGates.set(a,e),u.roll(()=>{e.abort(),this.sourceCreditGates.delete(a)})}if(await p(void 0,g.meta),w=!0,g.stream instanceof L.Readable)await Ae(g.stream,this.options.chunkSize,C,T,h);else if(g.buffer instanceof Promise||g.buffer instanceof Uint8Array){let e;if(g.buffer instanceof Promise){let t=g.buffer;t.catch(()=>{}),e=await Promise.race([t,y])}else e=g.buffer;h.throwIfAborted(),await ke(e,this.options.chunkSize,C,T,h)}}catch(e){let t=W(e,`handler for source "${n}" failed`);m.abort(t),E||(this.error(t),w?await C(void 0,t.message,!0).catch(()=>{}):await p(t.message).catch(()=>{}))}finally{await u.unroll()}}),s.roll(()=>{this.onRequest.delete(`source-fetch-request:${n}`)}),s.roll(()=>{let e=this.sourceRequests.get(n);if(e){for(let t of e){let e=this.sourceControllers.get(t);e&&e.abort(Error(`source "${n}" destroyed`));let r=this.sourceCreditGates.get(t);r&&r.abort()}this.sourceRequests.delete(n)}}),await this.subscribeTopicAndSpool(s,l,i),await this.subscribeTopicAndSpool(s,u,i),this.makeRegistration(s,`source`,n)}async fetch(e,...t){if(this.destroyed)throw Error(`fetch: instance already destroyed`);let n,r,i,a={},o;typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.params,i=e.receiver,a=e.options??{},o=e.meta):(n=e,r=t);let s=new Me,c=R();for(let e=0;e<10&&(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`));e++)c=R();if(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`))throw Error(`failed to generate unique request id`);let l=this.options.topicMake(n,`source-fetch-response`,this.options.id),u=(e,t)=>Error(`${e} name mismatch (expected "${n}", got "${t}")`);await this.subscribeTopicAndSpool(s,l,{qos:a.qos??2});let d=this.options.chunkCredit,f=d>0?d*this.options.chunkSize:16*1024,p=0,m=d,h=i,g=!1,_=!1,v=[],y=(e,t)=>{if(t===void 0||t===``){_=!0;let t=Error(`received ${e} without sender`);return x(t),C?.destroy(t),s.unroll()?.catch(()=>{}),!1}if(h===void 0)h=t;else if(t!==h)return!1;return!0},b,x,S=new Promise((e,t)=>{b=e,x=t});S.catch(()=>{}),s.roll(()=>{b(void 0)});let ee=`source-fetch-recv:${c}`,C,w=()=>{_||C&&C.destroyed||this.timerRefresh(ee,()=>{let e=Error(`communication timeout`);x(e),C?.destroy(e)})};s.roll(()=>{this.timerClear(ee)}),C=new Oe({highWaterMark:f,read:e=>{if(d<=0||_)return;let t=h;if(!t)return;let r=m-p,i=Math.max(0,f-(C?.readableLength??0)),o=Math.floor(i/this.options.chunkSize),s=Math.max(0,o-r);if(s>0){m+=s;let e=this.msg.makeSourceFetchCredit(c,n,s,this.options.id,t),r=this.codec.encode(e),i=this.options.topicMake(n,`source-fetch-request`,t);this.publishToTopic(i,r,{qos:a.qos??2}).catch(e=>{let t=W(e,`sending source fetch credit failed`);this.error(t),E(t)}),w()}}});let T=C.buffer;w();let E=e=>{_=!0,x(e),C.destroy(e)},D=!1,te=e=>{if(!D&&!_){D=!0;let e=h;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(e=>this.error(W(e,`sending source fetch cancel failed`)))}}_||x(e===void 0?Error(`stream aborted`):W(e)),s.unroll()?.catch(()=>{})};C.once(`close`,()=>te()),C.once(`error`,e=>te(e));let O=e=>{if(e.error)E(Error(e.error));else{if(w(),e.chunk!==void 0){if(d>0&&p>=m){E(Error(`flow control violation`));return}p++,C.destroyed||C.push(e.chunk)}e.final&&(_=!0,C.destroyed||C.push(null),s.unroll()?.catch(()=>{}))}};this.onResponse.set(`source-fetch-response:${c}`,e=>{if(!_){if(e.name!==n){E(u(`source response`,e.name));return}if(y(`source response`,e.sender))if(e.error)E(Error(e.error));else{if(g)return;g=!0,b(e.meta),w();for(let e of v){if(_)break;O(e)}v.length=0}}}),this.onResponse.set(`source-fetch-chunk:${c}`,e=>{if(!_){if(e.name!==n){E(u(`source chunk`,e.name));return}if(y(`source chunk`,e.sender)){if(!g){if(d>0&&v.length>=m){E(Error(`flow control violation`));return}v.push(e);return}O(e)}}}),s.roll(()=>{this.onResponse.delete(`source-fetch-response:${c}`),this.onResponse.delete(`source-fetch-chunk:${c}`)});let ne=this.authenticate(),k=this.metaStore(o),re=d>0?d:void 0,A=this.msg.makeSourceFetchRequest(c,n,r,this.options.id,i,ne,k,re,a.qos),ie=this.codec.encode(A),j=this.options.topicMake(n,`source-fetch-request`,i);await Fe(`publish fetch request as MQTT message to topic "${j}"`,()=>this.publishToTopic(j,ie,{qos:2,...a})).catch(e=>{let t=W(e);x(t),C.destroy(t)});let M={stream:C,buffer:T,meta:S};return je(M,`stream`,`buffer`,e=>{e===`stream`?C.stopCollecting():e===`buffer`&&C.resume()}),M}},mo=class extends po{constructor(){super(...arguments),this.pushStreams=new Map,this.pushSpools=new Map,this.pushRecvControllers=new Map,this.destroying=!1,this.pushControllers=new Map,this.pushCreditGates=new Map,this.pushSenderSpools=new Map}async destroy(){this.destroying=!0;for(let e of this.pushSenderSpools.keys())this.timerClear(`sink-push-send:${e}`);for(let e of this.pushSpools.keys())this.timerClear(`sink-push-recv:${e}`);for(let e of this.pushControllers.values())e.abort(Error(`sink destroyed`));for(let e of this.pushCreditGates.values())e.abort();for(let e of[...this.pushSenderSpools.values()])await e.unroll();this.pushSenderSpools.clear(),this.pushControllers.clear(),this.pushCreditGates.clear();for(let e of this.pushRecvControllers.values())e.abort(Error(`sink destroyed`));this.pushRecvControllers.clear();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){if(this.destroyed)throw Error(`sink: instance already destroyed`);let n,r,i={},a=this.options.share,o;if(typeof e==`object`&&e&&`name`in e?(n=e.name,r=e.callback,i=e.options??{},a=e.share??this.options.share,o=e.auth):(n=e,r=t[0]),typeof r!=`function`)throw Error(`sink: callback argument is required and must be a function`);let s=new Me;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)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=e.params??[],c=e.sender,l=e.receiver,u=new Me;if(c===void 0||c===``){this.error(Error(`invalid request: missing sender`)),await u.unroll();return}let d=this.options.topicMake(n,`sink-push-response`,c),f=e=>Error(`sink name mismatch (expected "${n}", got "${e}")`),p=this.options.chunkCredit,m=async(t,r=!1)=>{let o=t===void 0&&r&&p>0?p:void 0,s=this.msg.makeSinkPushResponse(a,n,t,this.options.id,c,o),l=this.codec.encode(s);await this.publishToTopic(d,l,{qos:e.qos??i.qos??2})},h=new AbortController,g=h.signal,_,v=new Promise((e,t)=>{_=t});v.catch(()=>{});let y=()=>{_(W(g.reason))};if(g.aborted?y():g.addEventListener(`abort`,y,{once:!0}),u.roll(()=>{g.removeEventListener(`abort`,y)}),this.pushRecvControllers.has(a)){let e=Error(`sink: duplicate request id "${a}"`);this.error(e),await m(e.message).catch(()=>{}),await u.unroll();return}this.pushRecvControllers.set(a,h),u.roll(()=>{this.pushRecvControllers.delete(a)}),this.pushSpools.set(a,u),u.roll(()=>{this.pushSpools.delete(a)});let b=!1,x=!1,S=!1,ee,C=()=>{};try{if(t!==e.name)throw Error(`sink name mismatch (topic: "${t}", payload: "${e.name}")`);let _;o&&(_=await this.authenticated(c,e.auth,o,`sink "${n}"`));let y=p>0?{chunksReceived:0,creditGranted:p}:void 0,w=p>0?p*this.options.chunkSize:16*1024,T=!1,E=`sink-push-recv:${a}`,D=()=>this.timerRefresh(E,()=>{if(!(T||this.destroying)&&(h.abort(Error(`push stream timeout`)),c&&!S)){S=!0;let t=this.msg.makeSinkPushCredit(a,n,0,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(()=>{})}}),te=()=>this.timerClear(E),O=new Oe({highWaterMark:w,read:t=>{if(!y||!this.pushSpools.has(a))return;let r=y.creditGranted-y.chunksReceived,o=Math.max(0,w-O.readableLength),s=Math.floor(o/this.options.chunkSize),l=Math.max(0,s-r);if(l>0){y.creditGranted+=l;let t=this.msg.makeSinkPushCredit(a,n,l,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(e=>{let t=W(e,`sending sink push credit failed`);this.error(t),O.destroy(t)}),D()}}});ee=O,this.pushStreams.set(a,O),u.roll(()=>{this.pushStreams.delete(a)}),O.on(`error`,C),u.roll(()=>{if(!b&&!g.aborted&&!this.destroying&&h.abort(Error(`push stream closed`)),!b&&!this.destroying&&!S&&c){let t=this.msg.makeSinkPushCredit(a,n,0,this.options.id,c),r=this.codec.encode(t);this.publishToTopic(d,r,{qos:e.qos??i.qos??2}).catch(e=>this.error(W(e,`sending sink push cancel failed`)))}}),this.onResponse.set(`sink-push-chunk:${a}`,async e=>{if(!T){if(e.name!==n){T=!0,te(),O.destroy(f(e.name));return}if(e.sender===void 0||e.sender===``){T=!0,te(),O.destroy(Error(`sink chunk for "${n}" missing sender`));return}if(e.sender===c)if(e.error!==void 0)T=!0,te(),O.destroy(Error(e.error));else{if(D(),e.chunk!==void 0){if(y){if(y.chunksReceived>=y.creditGranted){T=!0,te(),O.destroy(Error(`flow control violation`));return}y.chunksReceived++}O.destroyed||O.push(e.chunk)}e.final&&(T=!0,te(),O.destroyed||O.push(null))}}}),u.roll(()=>{this.onResponse.delete(`sink-push-chunk:${a}`)}),D(),u.roll(()=>{te()});let ne=O.buffer,k=!1,re,A,ie=()=>{k||(k=!0,re())},j=()=>{k||(k=!0,T||O.readableEnded?re():A(Error(`push stream closed before end`)))},M=e=>{k||(k=!0,A(e))},ae=new Promise((e,t)=>{re=e,A=t,O.once(`end`,ie),O.once(`close`,j),O.once(`error`,M)});ae.finally(()=>{O.removeListener(`end`,ie),O.removeListener(`close`,j),O.removeListener(`error`,M)}).catch(()=>{});let oe={sender:c,signal:g,stream:O,buffer:ne};l&&(oe.receiver=l),_!==void 0&&(oe.authenticated=_),e.meta&&(oe.meta=e.meta),je(oe,`stream`,`buffer`,e=>{e===`stream`?O.stopCollecting():e===`buffer`&&O.resume()}),await m(void 0,!0),x=!0;let N=Promise.resolve(r(...s,oe));if(N.catch(()=>{}),await Promise.race([N,v]),O.readableFlowing!==!0&&!O.destroyed&&O.resume(),await ae.catch(e=>{throw this.error(W(e),`stream drain after sink "${n}" callback failed`),e}),O.collecting&&O.stopCollecting(),!g.aborted)try{b=!0,await m()}catch(e){this.error(W(e),`sending terminal response for sink "${n}" failed`)}}catch(e){let t=W(e,`handler for sink "${n}" failed`);if(h.abort(t),x&&!this.destroying){let e=this.pushStreams.get(a);e!==void 0&&!e.destroyed&&e.destroy(t)}this.error(t),S||(S=!0,await m(t.message).catch(()=>{}))}finally{let e=this.pushStreams.get(a);e!==void 0&&!e.destroyed&&!b&&!S&&e.destroy(g.aborted?W(g.reason):Error(`sink push aborted without cause`)),await u.unroll(),ee!==void 0&&ee.removeListener(`error`,C)}}),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)}async push(e,...t){if(this.destroyed)throw Error(`push: instance already destroyed`);let n,r,i,a,o={},s;if(typeof e==`object`&&e&&`name`in 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 L.Readable)&&!(r instanceof Uint8Array))throw Error(`invalid data type: expected Readable or Uint8Array`);let c=new Me,l=R();for(let e=0;e<10&&(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`));e++)l=R();if(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`))throw Error(`failed to generate unique request id`);this.pushSenderSpools.set(l,c),c.roll(()=>{this.pushSenderSpools.delete(l)});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(this.pushControllers.set(l,d),c.roll(()=>{this.pushControllers.delete(l)}),r instanceof L.Readable){let e=r;f.addEventListener(`abort`,()=>{e.destroyed||e.destroy(W(f.reason))},{once:!0})}let p=`sink-push-send:${l}`,m=()=>{f.aborted||this.timerRefresh(p,()=>{let e=Error(`push to sink "${n}" timed out`);d.abort(e)})};c.roll(()=>{this.timerClear(p)}),m();let h,g,_=0,v,y=!1,b=!1,x=!1,S=!1,ee=!1,C=!1,w=!1,T=a,E,D,te=new Promise((e,t)=>{E=e,D=t});te.catch(()=>{});let O=(e,t)=>{if(t===void 0||t===``){let t=Error(`received ${e} without sender`);return v=t,d.abort(t),b?S||(S=!0,D(t)):(x=!0,k(t)),!1}if(T===void 0)T=t;else if(t!==T)return!1;return!0},ne,k,re=new Promise((e,t)=>{ne=e,k=t});this.onResponse.set(`sink-push-response:${l}`,e=>{if(e.name!==n){let t=Error(`sink response name mismatch (expected "${n}", got "${e.name}")`);v=t,d.abort(t),b?S||(S=!0,D(t)):(x=!0,k(t));return}if(O(`sink response`,e.sender))if(e.error){let t=Error(e.error);v=t,d.abort(t),b?S||(S=!0,D(t)):(x=!0,k(t))}else b?S||(C?(S=!0,E()):w=!0):(h=e.credit,b=!0,x=!0,ne())}),c.roll(()=>{this.onResponse.delete(`sink-push-response:${l}`)}),this.onResponse.set(`sink-push-credit:${l}`,e=>{if(e.name!==n){let t=Error(`sink credit name mismatch (expected "${n}", got "${e.name}")`);v=t,d.abort(t),b?S||(S=!0,D(t)):(x=!0,k(t));return}if(O(`sink credit`,e.sender)){if(e.credit===0){y=!0;let e=Error(`push to sink "${n}" cancelled by receiver`);d.abort(e),b?S||(S=!0,D(e)):(x=!0,k(e));return}if(g!==void 0)g.replenish(e.credit),m();else if(b&&h===void 0){let e=Error(`push to sink "${n}" received unsolicited credit (credit-flow disabled)`);v=e,d.abort(e),S||(S=!0,D(e))}else _+=e.credit}}),c.roll(()=>{this.onResponse.delete(`sink-push-credit:${l}`)});try{let e=()=>{let e=W(f.reason);x||(x=!0,k(e)),S||(S=!0,D(e))};f.addEventListener(`abort`,e,{once:!0}),c.roll(()=>{f.removeEventListener(`abort`,e)});let t=this.authenticate(),u=this.metaStore(s),d=this.msg.makeSinkPushRequest(l,n,i,this.options.id,a,t,u,o.qos),p=this.codec.encode(d),v=this.options.topicMake(n,`sink-push-request`,a);if(await Fe(`publish push request as MQTT message to topic "${v}"`,()=>this.publishToTopic(v,p,{qos:2,...o})),await re,h!==void 0&&h>0)g=new we(h+_),_>0&&m(),_=0;else if(_>0)throw Error(`push to sink "${n}" received unsolicited credit (credit-flow disabled)`);if(g&&(this.pushCreditGates.set(l,g),c.roll(()=>{this.pushCreditGates.delete(l)})),g){let e=g;c.roll(()=>{e.abort()})}let y=T;if(y===void 0)throw Error(`push to sink "${n}" missing responder`);let b=this.options.topicMake(n,`sink-push-request`,y),O=async(e,t,r)=>{m();let i=this.msg.makeSinkPushChunk(l,n,e,t,r,this.options.id,y),a=this.codec.encode(i);await this.publishToTopic(b,a,{qos:2,...o}),t===void 0&&r&&(ee=!0)};r instanceof L.Readable?await Ae(r,this.options.chunkSize,O,g,f):r instanceof Uint8Array&&await ke(r,this.options.chunkSize,O,g,f),C=!0,w&&!S&&(S=!0,E()),m(),S||await te}catch(e){let t=W(e);if(d.abort(t),b&&!v&&!y&&!ee)try{let e=T;if(e!==void 0){let r=this.options.topicMake(n,`sink-push-request`,e),i=this.msg.makeSinkPushChunk(l,n,void 0,t.message,!0,this.options.id,e),a=this.codec.encode(i);await this.publishToTopic(r,a,{qos:2,...o}).catch(()=>{})}}catch{}throw b&&!v&&await new Promise(e=>{setImmediate(e)}),v||e}finally{await c.unroll()}}};return class extends mo{}});