mqtt-plus 1.4.26 → 1.4.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ase/service.log +3 -0
- package/.ase/service.yaml +1 -1
- package/CHANGELOG.md +11 -0
- package/dst-stage1/mqtt-plus.d.ts +5 -1
- package/dst-stage1/mqtt-plus.js +10 -3
- package/dst-stage2/mqtt-plus.cjs.cjs +18 -13
- package/dst-stage2/mqtt-plus.esm.js +18 -4
- package/dst-stage2/mqtt-plus.umd.js +11 -11
- package/etc/eslint.mts +1 -12
- package/etc/vite.mts +1 -1
- package/package.json +7 -8
- package/src/mqtt-plus.ts +14 -5
- /package/package.d/{@typescript-eslint+typescript-estree+8.66.0.patch → @typescript-eslint+typescript-estree+8.67.0.patch} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MQTTp={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),r=n(((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)}})),i=n(((e,t)=>{t.exports=typeof Object.create==`function`?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),a,o=t((()=>{a=globalThis||self}));function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function c(){throw Error(`setTimeout has not been defined`)}function l(){throw Error(`clearTimeout has not been defined`)}function u(e){if(v===setTimeout)return setTimeout(e,0);if((v===c||!v)&&setTimeout)return v=setTimeout,setTimeout(e,0);try{return v(e,0)}catch{try{return v.call(null,e,0)}catch{return v.call(this,e,0)}}}function d(e){if(y===clearTimeout)return clearTimeout(e);if((y===l||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(e);try{return y(e)}catch{try{return y.call(null,e)}catch{return y.call(this,e)}}}function f(){!x||!S||(x=!1,S.length?b=S.concat(b):C=-1,b.length&&p())}function p(){if(!x){var e=u(f);x=!0;for(var t=b.length;t;){for(S=b,b=[];++C<t;)S&&S[C].run();C=-1,t=b.length}S=null,x=!1,d(e)}}function m(e,t){this.fun=e,this.array=t}function h(){}var g,_,v,y,b,x,S,C,w,T,E=t((()=>{g={exports:{}},_=g.exports={},(function(){try{v=typeof setTimeout==`function`?setTimeout:c}catch{v=c}try{y=typeof clearTimeout==`function`?clearTimeout:l}catch{y=l}})(),b=[],x=!1,C=-1,_.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];b.push(new m(e,t)),b.length===1&&!x&&u(p)},m.prototype.run=function(){this.fun.apply(null,this.array)},_.title=`browser`,_.browser=!0,_.env={},_.argv=[],_.version=``,_.versions={},_.on=h,_.addListener=h,_.once=h,_.off=h,_.removeListener=h,_.removeAllListeners=h,_.emit=h,_.prependListener=h,_.prependOnceListener=h,_.listeners=function(e){return[]},_.binding=function(e){throw Error(`process.binding is not supported`)},_.cwd=function(){return`/`},_.chdir=function(e){throw Error(`process.chdir is not supported`)},_.umask=function(){return 0},w=g.exports,T=s(w)})),D=n(((e,t)=>{t.exports=r().EventEmitter})),O=n((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(xe(e,s)||e&&xe(e.buffer,s)||c!==void 0&&(xe(e,c)||e&&xe(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(xe(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`||Se(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(xe(e,o)&&(e=d.from(e,e.offset,e.byteLength)),xe(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(xe(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)||xe(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 _e(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return be(e).length;default:if(i)return r?-1:_e(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 P(this,t,n);case`utf8`:case`utf-8`:return M(this,t,n);case`ascii`:return ie(this,t,n);case`latin1`:case`binary`:return ae(this,t,n);case`base64`:return ne(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return F(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?M(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||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(xe(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,Se(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 k(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(Se(r))return o;e[n+o]=r}return o}function A(e,t,n,r){return V(_e(t,e.length-n),e,n,r)}function ee(e,t,n,r){return V(ve(t),e,n,r)}function j(e,t,n,r){return V(be(t),e,n,r)}function te(e,t,n,r){return V(ye(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 k(this,e,t,n);case`utf8`:case`utf-8`:return A(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return ee(this,e,t,n);case`base64`:return j(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}},d.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function ne(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function M(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 N(r)}let re=4096;function N(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 ie(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 ae(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 P(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+=Ce[e[r]];return i}function F(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 I(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||I(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||I(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||I(e,1,this.length),this[e]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(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||I(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readBigUInt64LE=H(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t+this[++e]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),d.prototype.readBigUInt64BE=H(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),d.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(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||I(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||I(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},d.prototype.readInt16LE=function(e,t){e>>>=0,t||I(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||I(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||I(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||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readBigInt64LE=H(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=this[e+4]+this[e+5]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+this[++e]*2**16+this[++e]*2**24)}),d.prototype.readBigInt64BE=H(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+n)}),d.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),r.read(this,e,!0,23,4)},d.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),r.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),r.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),r.read(this,e,!1,52,8)};function L(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;L(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;L(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||L(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||L(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||L(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||L(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||L(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 oe(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 se(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=H(function(e,t=0){return oe(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),d.prototype.writeBigUInt64BE=H(function(e,t=0){return se(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);L(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);L(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||L(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||L(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||L(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||L(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||L(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=H(function(e,t=0){return oe(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),d.prototype.writeBigInt64BE=H(function(e,t=0){return se(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 le(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 le(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return le(this,e,t,!1,n)};function ue(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 ue(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return ue(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 R={};function de(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}`}}}de(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),de(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),de(`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=z(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function z(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){pe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&me(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 R.ERR_OUT_OF_RANGE(`value`,i,e)}B(r,i,a)}function pe(e,t){if(typeof e!=`number`)throw new R.ERR_INVALID_ARG_TYPE(t,`number`,e)}function me(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):(pe(e,n),new R.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let he=/[^+/0-9A-Za-z-_]/g;function ge(e){if(e=e.split(`=`)[0],e=e.trim().replace(he,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function _e(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}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 ve(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ye(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 be(e){return t.toByteArray(ge(e))}function V(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 xe(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Se(e){return e!==e}let Ce=(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 H(e){return typeof BigInt>`u`?we:e}function we(){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})),k=n(((e,t)=>{t.exports={}})),A=n(((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=O().Buffer,d=k().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.head=this.length===1?this.tail=null: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,this.head=t.next?t.next: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,this.head=n.next?n.next: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}()})),ee=n(((e,t)=>{E();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,T.nextTick(o,this,e)):T.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?T.nextTick(i,n):(n._writableState.errorEmitted=!0,T.nextTick(r,n,e)):T.nextTick(r,n,e):t?(T.nextTick(i,n),t(e)):T.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}})),j=n(((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]}`}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})),te=n(((e,t)=>{var n=j().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:16384}t.exports={getHighWaterMark:i}})),ne=n(((e,t)=>{o(),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(!a.localStorage)return!1}catch{return!1}var t=a.localStorage[e];return t!=null&&String(t).toLowerCase()===`true`}})),M=n(((e,t)=>{o(),E(),t.exports=N;function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){pe(t,e)}}var r;N.WritableState=A;var s={deprecate:ne()},c=D(),l=O().Buffer,u=(a===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:a).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=ee(),m=te().getHighWaterMark,h=j().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,w=p.errorOrDestroy;i()(N,c);function k(){}function A(e,t,i){r||=re(),e||={},typeof i!=`boolean`&&(i=t instanceof r),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=m(this,e,`writableHighWaterMark`,i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){se(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 M;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(M=Function.prototype[Symbol.hasInstance],Object.defineProperty(N,Symbol.hasInstance,{value:function(e){return M.call(this,e)?!0:this===N&&e&&e._writableState instanceof A}})):M=function(e){return e instanceof this};function N(e){r||=re();var t=this instanceof r;if(!t&&!M.call(N,this))return new N(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)}N.prototype.pipe=function(){w(this,new y)};function ie(e,t){var n=new S;w(e,n),T.nextTick(t,n)}function ae(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||(w(e,i),T.nextTick(r,i),!1)}N.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=k),r.ending?ie(this,n):(a||ae(this,r,e,n))&&(r.pendingcb++,i=F(this,r,a,e,t,n)),i},N.prototype.cork=function(){this._writableState.corked++},N.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&ue(this,e))},N.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(N.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function P(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(N.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function F(e,t,n,r,i,a){if(!n){var o=P(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 I(e,t,!1,s,r,i,a);return c}function I(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 L(e,t,n,r,i){--t.pendingcb,n?(T.nextTick(i,r),T.nextTick(B,e,t),e._writableState.errorEmitted=!0,w(e,r)):(i(r),e._writableState.errorEmitted=!0,w(e,r),B(e,t))}function oe(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function se(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new v;if(oe(n),t)L(e,n,r,t,i);else{var a=R(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&ue(e,n),r?T.nextTick(ce,e,n,a,i):ce(e,n,a,i)}}function ce(e,t,n,r){n||le(e,t),t.pendingcb--,r(),B(e,t)}function le(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function ue(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,I(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(I(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}N.prototype._write=function(e,t,n){n(new _(`_write()`))},N.prototype._writev=null,N.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(N.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function R(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function de(e,t){e._final(function(n){t.pendingcb--,n&&w(e,n),t.prefinished=!0,e.emit(`prefinish`),B(e,t)})}function z(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,T.nextTick(de,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function B(e,t){var n=R(t);if(n&&(z(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,B(e,t),n&&(t.finished?T.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function pe(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(N.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),N.prototype.destroy=p.destroy,N.prototype._undestroy=p.undestroy,N.prototype._destroy=function(e,t){t(e)}})),re=n(((e,t)=>{E();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var r=I(),a=M();i()(l,r);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);r.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||T.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)}})})),N=n(((e,t)=>{var n=O(),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)}})),ie=n((e=>{var t=N().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=n(((e,t)=>{var n=j().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})),P=n(((e,t)=>{E();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){T.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){T.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}})),F=n(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),I=n(((e,t)=>{o(),E(),t.exports=L;var n;L.ReadableState=I,r().EventEmitter;var s=function(e,t){return e.listeners(t).length},c=D(),l=O().Buffer,u=(a===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:a).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=k(),m=p&&p.debuglog?p.debuglog(`stream`):function(){},h=A(),g=ee(),_=te().getHighWaterMark,v=j().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,w,ne;i()(L,c);var M=g.errorOrDestroy,N=[`error`,`close`,`destroy`,`pause`,`resume`];function ae(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 I(e,t,r){n||=re(),e||={},typeof r!=`boolean`&&(r=t instanceof n),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=_(this,e,`readableHighWaterMark`,r),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||=ie().StringDecoder,this.decoder=new C(e.encoding),this.encoding=e.encoding)}function L(e){if(n||=re(),!(this instanceof L))return new L(e);var t=this instanceof n;this._readableState=new I(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(L.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),L.prototype.destroy=g.destroy,L.prototype._undestroy=g.undestroy,L.prototype._destroy=function(e,t){t(e)},L.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),oe(this,e,t,!1,r)},L.prototype.unshift=function(e){return oe(this,e,null,!0,!1)};function oe(e,t,n,r,i){m(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,de(e,a);else{var o;if(i||(o=ce(a,t)),o)M(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?M(e,new S):se(e,a,t,!0);else if(a.ended)M(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?se(e,a,t,!1):fe(e,a)):se(e,a,t,!1)}else r||(a.reading=!1,fe(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function se(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&&z(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}L.prototype.isPaused=function(){return this._readableState.flowing===!1},L.prototype.setEncoding=function(e){C||=ie().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 le=1073741824;function ue(e){return e>=le?e=le:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function R(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=ue(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}L.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?V(this):z(this),null;if(e=R(e,t),e===0&&t.ended)return t.length===0&&V(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=R(n,t)));var i=e>0?be(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&&V(this)),i!==null&&this.emit(`data`,i),i};function de(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?z(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,B(e)))}}function z(e){var t=e._readableState;m(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(m(`emitReadable`,t.flowing),t.emittedReadable=!0,T.nextTick(B,e))}function B(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,ye(e)}function fe(e,t){t.readingMore||(t.readingMore=!0,T.nextTick(pe,e,t))}function pe(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}L.prototype._read=function(e){M(this,new x(`_read()`))},L.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)}r.pipesCount+=1,m(`pipe count=%d opts=%j`,r.pipesCount,t);var i=(!t||t.end!==!1)&&e!==T.stdout&&e!==T.stderr?o:g;r.endEmitted?T.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=me(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&&Se(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&&M(e,t)}ae(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 me(e){return function(){var t=e._readableState;m(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&s(e,`data`)&&(t.flowing=!0,ye(e))}}L.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=Se(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)},L.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?z(this):r.reading||T.nextTick(ge,this)),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(e,t){var n=c.prototype.removeListener.call(this,e,t);return e===`readable`&&T.nextTick(he,this),n},L.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&T.nextTick(he,this),t};function he(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 ge(e){m(`readable nexttick read 0`),e.read(0)}L.prototype.resume=function(){var e=this._readableState;return e.flowing||(m(`resume`),e.flowing=!e.readableListening,_e(this,e)),e.paused=!1,this};function _e(e,t){t.resumeScheduled||(t.resumeScheduled=!0,T.nextTick(ve,e,t))}function ve(e,t){m(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),ye(e),t.flowing&&!t.reading&&e.read(0)}L.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 ye(e){var t=e._readableState;for(m(`flow`,t.flowing);t.flowing&&e.read()!==null;);}L.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<N.length;a++)e.on(N[a],this.emit.bind(this,N[a]));return this._read=function(t){m(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(L.prototype[Symbol.asyncIterator]=function(){return w===void 0&&(w=P()),w(this)}),Object.defineProperty(L.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(L.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(L.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),L._fromList=be,Object.defineProperty(L.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function be(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 V(e){var t=e._readableState;m(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,T.nextTick(xe,t,e))}function xe(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`&&(L.from=function(e,t){return ne===void 0&&(ne=F()),ne(L,e,t)});function Se(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),L=n(((e,t)=>{t.exports=u;var n=j().codes,r=n.ERR_METHOD_NOT_IMPLEMENTED,a=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,c=re();i()(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 r(`_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)}})),oe=n(((e,t)=>{t.exports=r;var n=L();i()(r,n);function r(e){if(!(this instanceof r))return new r(e);n.call(this,e)}r.prototype._transform=function(e,t,n){n(null,e)}})),se=n(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=j().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})),ce=n(((e,t)=>{t.exports=a;var n=r().EventEmitter;i()(a,n),a.Readable=I(),a.Writable=M(),a.Duplex=re(),a.Transform=L(),a.PassThrough=oe(),a.finished=ae(),a.pipeline=se(),a.Stream=a;function a(){n.call(this)}a.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}r.on(`data`,i);function a(){r.readable&&r.resume&&r.resume()}e.on(`drain`,a),!e._isStdio&&(!t||t.end!==!1)&&(r.on(`end`,s),r.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(),n.listenerCount(this,`error`)===0)throw e}r.on(`error`,l),e.on(`error`,l);function u(){r.removeListener(`data`,i),e.removeListener(`drain`,a),r.removeListener(`end`,s),r.removeListener(`close`,c),r.removeListener(`error`,l),e.removeListener(`error`,l),r.removeListener(`end`,u),r.removeListener(`close`,u),e.removeListener(`close`,u)}return r.on(`end`,u),r.on(`close`,u),e.on(`close`,u),e.emit(`pipe`,r),e}}))(),le=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,ue=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=le[n[e]&63];return t},R={},de={};de.byteLength=_e,de.toByteArray=ye,de.fromByteArray=xe;for(var z=[],B=[],fe=typeof Uint8Array<`u`?Uint8Array:Array,pe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,me=0,he=pe.length;me<he;++me)z[me]=pe[me],B[pe.charCodeAt(me)]=me;B[45]=62,B[95]=63;function ge(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 _e(e){var t=ge(e),n=t[0],r=t[1];return(n+r)*3/4-r}function ve(e,t,n){return(t+n)*3/4-n}function ye(e){var t,n=ge(e),r=n[0],i=n[1],a=new fe(ve(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 be(e){return z[e>>18&63]+z[e>>12&63]+z[e>>6&63]+z[e&63]}function V(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(be(r));return i.join(``)}function xe(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(V(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(z[t>>2]+z[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(z[t>>10]+z[t>>4&63]+z[t<<2&63]+`=`)),i.join(``)}var Se={};Se.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)},Se.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=de,n=Se,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(V(e,o)||e&&V(e.buffer,o)||s!==void 0&&(V(e,s)||e&&V(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(V(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(V(e,a)&&(e=u.from(e,e.offset,e.byteLength)),V(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(V(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)||V(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 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}}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 ie(this,t,n);case`utf8`:case`utf-8`:return te(this,t,n);case`ascii`:return re(this,t,n);case`latin1`:case`binary`:return N(this,t,n);case`base64`:return j(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ae(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?te(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||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(V(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,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: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(xe(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return be(ge(t,e.length-n),e,n,r)}function k(e,t,n,r){return be(_e(t),e,n,r)}function A(e,t,n,r){return be(ye(t),e,n,r)}function ee(e,t,n,r){return be(ve(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 k(this,e,t,n);case`base64`:return A(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ee(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 j(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function te(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 ne=4096;function M(e){let t=e.length;if(t<=ne)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ne));return n}function re(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 N(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 ie(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+=Ce[e[r]];return i}function ae(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 P(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||P(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||P(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||P(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(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||P(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=H(function(e){e>>>=0,fe(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]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=H(function(e){e>>>=0,fe(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]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(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||P(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||P(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||P(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||P(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||P(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||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=H(function(e){e>>>=0,fe(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]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=H(function(e){e>>>=0,fe(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]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!1,52,8)};function F(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;F(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;F(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||F(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||F(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||F(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||F(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||F(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 I(e,t,n,r,i){B(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){B(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=H(function(e,t=0){return I(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=H(function(e,t=0){return L(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);F(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);F(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||F(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||F(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||F(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||F(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||F(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=H(function(e,t=0){return I(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=H(function(e,t=0){return L(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function oe(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function se(e,t,r,i,a){return t=+t,r>>>=0,a||oe(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return se(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return se(this,e,t,!1,n)};function ce(e,t,r,i,a){return t=+t,r>>>=0,a||oe(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 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=R(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=R(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function R(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 z(e,t,n){fe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&pe(t,e.length-(n+1))}function B(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)}z(r,i,a)}function fe(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):(fe(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}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 be(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 V(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 Ce=(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 H(e){return typeof BigInt>`u`?we:e}function we(){throw Error(`BigInt not supported`)}})(R);var Ce=R.Buffer;R.Blob,R.BlobOptions;var H=R.Buffer;R.File,R.FileOptions,R.INSPECT_MAX_BYTES,R.SlowBuffer,R.TranscodeEncoding,R.atob,R.btoa,R.constants,R.isAscii,R.isUtf8,R.kMaxLength,R.kStringMaxLength,R.resolveObjectURL,R.transcode;var we=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)}},Te=we.default??we,Ee=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)}},De=new TextEncoder;function Oe(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 ke(e){let t;if(e instanceof H)t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof Uint8Array)t=e;else if(typeof e==`string`)t=De.encode(e);else throw Error(`invalid chunk type: expected Buffer, Uint8Array, or string`);return t}var Ae=class extends ce.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(Oe(this._chunks))):e!==void 0&&this._chunks.push(ke(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 je(e,t,n,r,i){if(!(Number.isFinite(t)&&t>0))throw Error(`invalid chunk size`);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 Me(e,t,n,r,i){if(!(Number.isFinite(t)&&t>0))throw Error(`invalid chunk size`);let a;for await(let o of e){if(i?.aborted)throw i.reason??Error(`aborted`);let e=ke(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 Ne(e,t){if(typeof t!=`function`)return e;let n=t.length-1;return e.length>=n?e:[...e,...Array(n-e.length).fill(void 0)]}function Pe(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},set:e=>{a=e},enumerable:!1,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},set:e=>{o=e},enumerable:!1,configurable:!0})}var Fe=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 U(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}return Error(r)}function Ie(e,t,n){if(!t)return e?Promise.resolve():void 0;let r;try{r=t()}catch(t){if(e)return Promise.reject(U(t,n));throw U(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 U(e,n)}):r}function Le(e,t){if(!t)return e?Promise.resolve():void 0;let n=t.unroll();if(!e&&n instanceof Promise)throw Error(`spool unroll returned Promise in non-async context`);return e&&!(n instanceof Promise)&&(n=Promise.resolve(n)),n}function Re(e,t,n,r,i){if(e)return(async()=>{let e;try{await Ie(!0,r,i)}catch(t){e=U(t,i)}if((t!==void 0||e!==void 0)&&(await Le(!0,n),e!==void 0)){if(t!==void 0)t.suppressed=e;else throw e}})();{let e;try{Ie(!1,r,i)}catch(t){e=U(t,i)}if((t!==void 0||e!==void 0)&&(Le(!1,n),e!==void 0)){if(t!==void 0)t.suppressed=e;else throw e}}}function ze(e,t,n,r){let i=t=>{e.suppressed=U(t,r)},a;try{a=n?.()}catch(e){i(e)}if(a instanceof Promise)return a.catch(i).then(()=>t?.unroll()).then(()=>{throw e});let o=t?.unroll();if(o instanceof Promise)return o.then(()=>{throw e});throw e}function Be(...e){let t,n,r,i,a,o;if(e.length===1&&typeof e[0]==`object`&&e[0]!==null?(t=e[0].description,n=e[0].spool,r=e[0].action,i=e[0].oncatch,a=e[0].onfinally,o=e[0].oncleanup):typeof e[0]==`string`?(t=e[0],e[1]instanceof Fe||e[1]===void 0&&typeof e[2]==`function`?(n=e[1],r=e[2],i=e[3],a=e[4],o=e[5]):(r=e[1],i=e[2],a=e[3],o=e[4])):e[0]instanceof Fe||e[0]===void 0&&typeof e[1]==`function`?(n=e[0],r=e[1],i=e[2],a=e[3],o=e[4]):(r=e[0],i=e[1],a=e[2],o=e[3]),o&&!n)throw Error(`oncleanup requires a spool`);let s;try{s=r()}catch(e){let r=U(e,t);if(!i)return ze(r,n,a,t);try{s=i(r)}catch(e){return ze(U(e,t),n,a,t)}i=void 0}return s instanceof Promise?s.then(async e=>(n&&o&&n.roll(e,o),await Re(!0,void 0,n,a,t),e),async e=>{let r=U(e,t);if(i){let e;try{e=await i(r)}catch(e){throw r=U(e,t),await Re(!0,r,n,a,t),r}return n&&o&&n.roll(e,o),await Re(!0,void 0,n,a,t),e}throw await Re(!0,r,n,a,t),r}):(n&&o&&n.roll(s,o),Re(!1,void 0,n,a,t),s)}var Ve=new TextEncoder,He=new TextDecoder,Ue=new TextDecoder(`utf-8`,{fatal:!0});function We(...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 Ge(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 Ke(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 qe(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}var Je=`The input to be decoded is not correctly encoded.`;function Ye(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64(typeof e==`string`?e:He.decode(e),{alphabet:`base64url`})}catch(e){throw TypeError(Je,{cause:e})}let t=e;if(t instanceof Uint8Array&&(t=He.decode(t)),t.includes(`+`)||t.includes(`/`))throw TypeError(Je);t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return qe(t)}catch{throw TypeError(Je)}}function Xe(e){let t=e;return typeof t==`string`&&(t=Ve.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):Ke(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var Ze=(e,t=`algorithm.name`)=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function Qe(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function $e(e,t){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function et(e,t,n){let r=e.algorithm;if(r.name!==t.name)throw Ze(t.name);if(t.hash&&r.hash?.name!==t.hash)throw Ze(t.hash,`algorithm.hash`);if(t.namedCurve&&r.namedCurve!==t.namedCurve)throw Ze(t.namedCurve,`algorithm.namedCurve`);if(t.length!==void 0&&r.length!==t.length)throw Ze(t.length,`algorithm.length`);Qe(e,n)}async function tt(e,t,n){return t instanceof Uint8Array?crypto.subtle.importKey(`raw`,t,e.subtle,!1,[n]):(et(t,e.subtle,n),e.minRsaBits&&$e(e.alg,t),t)}async function nt(e,t,n){let r=await tt(e,t,`sign`),i=await crypto.subtle.sign(e.signing,r,n);return new Uint8Array(i)}async function rt(e,t,n,r){let i=await tt(e,t,`verify`);try{return await crypto.subtle.verify(e.signing,i,n,r)}catch{return!1}}var it=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)}},at=class extends it{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}},ot=class extends it{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}},st=class extends it{static code=`ERR_JOSE_ALG_NOT_ALLOWED`;code=`ERR_JOSE_ALG_NOT_ALLOWED`},ct=class extends it{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},W=class extends it{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},lt=class extends it{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`},ut=class extends it{static code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;constructor(e=`signature verification failed`,t){super(e,t)}};function dt(e){let t={__proto__:null};for(let n in e)t[n]={...e[n],alg:n};return t}var ft=[[`verify`],[`sign`]];function pt(e){let t={name:`HMAC`,hash:`SHA-${e}`};return{kty:[`oct`],secret:!0,subtle:t,signing:t,usages:ft}}function mt(e,t){let n={name:t?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e}`};return{kty:[`RSA`],subtle:n,signing:t?{...n,saltLength:t}:n,usages:ft,minRsaBits:2048}}function ht(e,t){return{kty:[`EC`],crv:e,subtle:{name:`ECDSA`,namedCurve:e},signing:{name:`ECDSA`,hash:`SHA-${t}`},usages:ft}}function gt(){let e={name:`Ed25519`};return{kty:[`OKP`],crv:`Ed25519`,subtle:e,signing:e,usages:ft}}function _t(e){let t={name:`ML-DSA-${e}`};return{kty:[`AKP`],subtle:t,signing:t,usages:ft}}var vt=dt({HS256:pt(256),HS384:pt(384),HS512:pt(512),RS256:mt(256),RS384:mt(384),RS512:mt(512),PS256:mt(256,32),PS384:mt(384,48),PS512:mt(512,64),ES256:ht(`P-256`,256),ES384:ht(`P-384`,384),ES512:ht(`P-521`,512),EdDSA:gt(),Ed25519:gt(),"ML-DSA-44":_t(44),"ML-DSA-65":_t(65),"ML-DSA-87":_t(87)});function yt(e){let t=typeof e==`string`?vt[e]:void 0;if(!t)throw new ct(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}function bt(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=t;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return t===n}function xt(...e){let t=new Set;for(let n of e)if(n)for(let e of Object.keys(n)){if(t.has(e))return!1;t.add(e)}return!0}var St=e=>bt(e)&&typeof e.kty==`string`,Ct=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),wt=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,Tt=e=>e.kty===`oct`&&typeof e.k==`string`,Et={__proto__:null,b64:!0};function Dt(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)}function Ot(e,t){let{crit:n}=t??{};if(Array.isArray(n)&&new Set(n).size!==n.length)throw new e(`"crit" (Critical) Header Parameter MUST NOT contain duplicate values`)}function kt(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[];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=n===void 0?t:{__proto__:null,...n,...t};for(let t of r.crit){if(!(t in a))throw new ct(`Extension Header Parameter "${t}" is not recognized`);if(!Object.hasOwn(i,t)||i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a[t]&&(!Object.hasOwn(r,t)||r[t]===void 0))throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return r.crit}function At(e,t,...n){if(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 jt=(e,t,...n)=>At(`Key for the ${e} algorithm must be `,t,...n),Mt=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},Nt=e=>e?.[Symbol.toStringTag]===`KeyObject`,Pt=e=>Mt(e)||Nt(e);async function Ft(e,t){if(t.kty===`RSA`&&`oth`in t&&t.oth!==void 0)throw new ct(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);if(!e.kty.includes(t.kty))throw new ct(`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`);let n=e.resolve?.({kty:t.kty,crv:t.crv})??e.subtle,r=!!(t.d||t.priv),i={...t};return i.kty!==`AKP`&&delete i.alg,delete i.use,crypto.subtle.importKey(`jwk`,i,n,t.ext??!r,t.key_ops??e.usages[+!!r])}var It=e=>e[Symbol.toStringTag],Lt=(e,t,n)=>{let{alg:r}=e;if(t.use!==void 0){let e=n===`sign`||n===`verify`?`sig`:`enc`;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!==r)throw TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(t.key_ops)){let r=n===`encrypt`||n===`decrypt`?e.ops?.[n===`encrypt`?0:1]:n;if(r&&!t.key_ops.includes(r))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${r}" when present`)}};function Rt(e,t,n){let{alg:r,secret:i}=e,a=n===`decrypt`||n===`sign`;if(i&&t instanceof Uint8Array)return[zt,t];if(St(t)){if(i?!Tt(t):!(a?Ct(t):wt(t)))throw TypeError(i?`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`:`JSON Web Key for this operation must be a ${a?`private`:`public`} JWK`);return Lt(e,t,n),[Ht,t]}if(!Pt(t))throw TypeError(i?jt(r,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`):jt(r,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(i){if(t.type!==`secret`)throw TypeError(`${It(t)} instances for symmetric algorithms must be of type "secret"`)}else{if(t.type===`secret`)throw TypeError(`${It(t)} instances for asymmetric algorithms must not be of type "secret"`);let e=a?`private`:`public`;if((t.type===`public`||t.type===`private`)&&t.type!==e){let r=n===`sign`?`signing`:n===`verify`?`verifying`:`${n.slice(0,-1)}tion`;throw TypeError(`${It(t)} instances for asymmetric algorithm ${r} must be of type "${e}"`)}}return Mt(t)?[Bt,t]:[Vt,t]}var zt=0,Bt=1,Vt=2,Ht=3,Ut,Wt={__proto__:null,prime256v1:`P-256`,secp384r1:`P-384`,secp521r1:`P-521`};function Gt(e,t,n){Ut||=new WeakMap;let r=Ut.get(e);return n&&(r?r[t]=n:Ut.set(e,{__proto__:null,[t]:n})),n??r?.[t]}var Kt=async(e,t,n)=>Gt(e,n.alg)??Gt(e,n.alg,await Ft(n,{...t,alg:n.alg})),qt=(e,t)=>{let n=Gt(e,t.alg);if(n)return n;let r=e.type===`public`,i=t.usages[+!r],{asymmetricKeyType:a}=e,o=Wt[e.asymmetricKeyDetails?.namedCurve],s=t.resolve?.({crv:o,asymmetricKeyType:a})??t.subtle;return Gt(e,t.alg,e.toCryptoKey(s,r,i))};async function Jt(e,t,n){let r=Rt(e,t,n);switch(r[0]){case zt:case Bt:return r[1];case Ht:{let t=r[1];if(t.k)return Ye(t.k);if(!Object.isFrozen(t)){let{key_ops:e}=t;Array.isArray(e)&&Object.freeze(e),Object.freeze(t)}return Kt(t,t,e)}case Vt:{let t=r[1];return t.type===`secret`?t.export():`toCryptoKey`in t&&typeof t.toCryptoKey==`function`?qt(t,e):Kt(t,t.export({format:`jwk`}),e)}}}function Yt(e){return e?.b64===!1&&Array.isArray(e.crit)&&e.crit.includes(`b64`)}async function Xt(e,t){let{protectedHeader:n,unprotectedHeader:r}=e;if(!n&&!r)throw new W(`either setProtectedHeader or setUnprotectedHeader must be called before #sign()`);if(!xt(n,r))throw new W(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i={...n,...r};Ot(W,n);let a=kt(W,Et,e.crit,n,i),o=!0;if(a.includes(`b64`)&&(o=n.b64,typeof o!=`boolean`))throw new W(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:s}=i;if(typeof s!=`string`||!s)throw new W(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);let c=yt(s),l,u;if(o){let t=e.encoded??=[];t[0]??=Xe(e.payload),t[1]??=Ge(t[0]),l=t[0],u=t[1]}else u=e.payload,l=``;let d,f;n?(d=Xe(JSON.stringify(n)),f=Ge(d)):(d=``,f=new Uint8Array);let p=We(f,Ge(`.`),u),m={signature:Xe(await nt(c,await Jt(c,t,`sign`),p)),payload:l};return n&&(m.protected=d),r&&(m.header=r),m}function Zt(e,t){if(e)throw TypeError(`${t} can only be called once`)}function Qt(e,t,n){try{return Ye(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function $t(e,t,n){try{return Ge(e)}catch{throw new n(`The ${t} is not a valid base64url string`)}}function en(e,t,n){let r;try{r=JSON.parse(Ue.decode(Ye(e)))}catch{throw new t(n)}if(!bt(r))throw new t(n);return r}var tn=class{#e;#t;#n;constructor(e){if(!(e instanceof Uint8Array))throw TypeError(`payload must be an instance of Uint8Array`);this.#e=e}setProtectedHeader(e){return Zt(this.#t,`setProtectedHeader`),this.#t=e,this}setUnprotectedHeader(e){return Zt(this.#n,`setUnprotectedHeader`),this.#n=e,this}async sign(e,t){return Xt({payload:this.#e,protectedHeader:this.#t,unprotectedHeader:this.#n,crit:t?.crit},e)}},nn=class{#e;#t;constructor(e){this.#e=new tn(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this.#t=e,this}async sign(e,t){if(Yt(this.#t))throw TypeError(`use the flattened module for creating JWS with b64: false`);let n=await this.#e.sign(e,t);return`${n.protected}.${n.payload}.${n.signature}`}},rn=e=>Math.floor(e.getTime()/1e3),an={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},on=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,sn=`check_failed`;function cn(e){let t=on.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r=Math.round(n*an[t[3][0].toLowerCase()]);return t[1]===`-`||t[4]===`ago`?-r:r}function ln(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}function un(e,t){return typeof e==`number`?ln(t,e):e instanceof Date?ln(t,rn(e)):rn(new Date)+cn(e)}var dn=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`,fn=(e,t)=>typeof e==`string`?t.includes(e):Array.isArray(e)?t.some(t=>e.includes(t)):!1;function pn(e,t,n=!1){let r=e[t];if(!(r===void 0&&!n)){if(typeof r!=`number`)throw new at(`"${t}" claim must be a number`,e,t,`invalid`);return r}}function mn(e,t){throw new at(`unexpected "${t}" claim value`,e,t,sn)}function hn(e,t,n={}){let r;try{r=JSON.parse(Ue.decode(t))}catch{}if(!bt(r))throw new lt(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=n;if(i&&(typeof e.typ!=`string`||dn(e.typ)!==dn(i)))throw new at(`unexpected "typ" JWT header value`,r,`typ`,sn);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(!Object.hasOwn(r,e))throw new at(`missing required "${e}" claim`,r,e,`missing`);o!==void 0&&!(Array.isArray(o)?o:[o]).includes(r.iss)&&mn(r,`iss`),s!==void 0&&r.sub!==s&&mn(r,`sub`),c!==void 0&&!fn(r.aud,typeof c==`string`?[c]:c)&&mn(r,`aud`);let{clockTolerance:d}=n,f=0;if(typeof d==`string`)f=cn(d);else if(d!==void 0){if(typeof d!=`number`)throw TypeError(`Invalid clockTolerance option type`);f=d}ln(`clockTolerance option`,f);let{currentDate:p}=n,m=ln(`currentDate option`,rn(p||new Date)),h=pn(r,`iat`,l!==void 0),g=pn(r,`nbf`);if(g!==void 0&&g>m+f)throw new at(`"nbf" claim timestamp check failed`,r,`nbf`,sn);let _=pn(r,`exp`);if(_!==void 0&&_<=m-f)throw new ot(`"exp" claim timestamp check failed`,r,`exp`,sn);if(l!==void 0){let e=m-h,t=typeof l==`number`?l:cn(l);if(e-f>t)throw new ot(`"iat" claim timestamp check failed (too far in the past)`,r,`iat`,sn);if(e<0-f)throw new at(`"iat" claim timestamp check failed (it should be in the past)`,r,`iat`,sn)}return r}var gn=class{#e;constructor(e){if(!bt(e))throw TypeError(`JWT Claims Set MUST be an object`);this.#e=structuredClone(e)}data(){return Ve.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){this.#e.nbf=un(e,`setNotBefore`)}set exp(e){this.#e.exp=un(e,`setExpirationTime`)}set iat(e){e===void 0?this.#e.iat=rn(new Date):typeof e==`string`?this.#e.iat=ln(`setIssuedAt`,rn(new Date)+cn(e)):this.#e.iat=un(e,`setIssuedAt`)}},_n=class{#e;#t;constructor(e={}){this.#t=new gn(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 nn(this.#t.data());if(n.setProtectedHeader(this.#e),Yt(this.#e))throw new lt(`JWTs MUST NOT use unencoded payload`);return n.sign(e,t)}};function vn(e){return[e&&Dt(`algorithms`,e.algorithms),e?.crit]}async function yn(e,t,n){let{protected:r,header:i,payload:a}=e,o={};r&&(o=en(r,W,`JWS Protected Header is invalid`));let s;if(i!==void 0){if(!xt(o,i))throw new W(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);s={...o,...i}}else s=o;let c=kt(W,Et,t[1],o,s),l=!0;if(c.includes(`b64`)&&(l=o.b64,typeof l!=`boolean`))throw new W(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:u}=s;if(typeof u!=`string`||!u)throw new W(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);if(t[0]&&!t[0].has(u))throw new st(`"alg" (Algorithm) Header Parameter value not allowed`);if(l){if(typeof a!=`string`)throw new W(`JWS Payload must be a string`)}else if(typeof a!=`string`&&!(a instanceof Uint8Array))throw new W(`JWS Payload must be a string or an Uint8Array instance`);let d=!1;typeof n==`function`&&(n=await n(o,e),d=!0);let f=yt(u),p=We(r===void 0?new Uint8Array:Ge(r),Ge(`.`),typeof a==`string`?l?t[2]??=$t(a,`payload`,W):Ve.encode(a):a),m=Qt(e.signature,`signature`,W),h=await Jt(f,n,`verify`);if(!await rt(f,h,m,p))throw new ut;let g;return g=l?Qt(a,`payload`,W):typeof a==`string`?Ve.encode(a):a,[g,o,l,h,d]}async function bn(e,t,n){if(e instanceof Uint8Array&&(e=He.decode(e)),typeof e!=`string`)throw new W(`Compact JWS must be a string or Uint8Array`);let{0:r,1:i,2:a,length:o}=e.split(`.`);if(o!==3)throw new W(`Invalid Compact JWS`);return yn({payload:i,protected:r,signature:a},t,n)}async function xn(e,t,n){let r=await bn(e,vn(n),t);if(!r[2])throw new lt(`JWTs MUST NOT use unencoded payload`);let i={payload:hn(r[1],r[0],n),protectedHeader:r[1]};return typeof t==`function`?{...i,key:r[3]}:i}function Sn(e){return e.saveState!==void 0&&e.restoreState!==void 0&&e.cleanSavedState!==void 0}function Cn(e){for(let t=0;t<e.length;t++)e[t]=0;return e}var wn=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),Sn(this._inner)&&Sn(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Cn(n)}reset(){if(!Sn(this._inner)||!Sn(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(){Sn(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Sn(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(!Sn(this._inner))throw Error(`hmac: can't saveState() because hash doesn't implement it`);return this._inner.saveState()}restoreState(e){if(!Sn(this._inner)||!Sn(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(!Sn(this._inner))throw Error(`hmac: can't cleanSavedState() because hash doesn't implement it`);this._inner.cleanSavedState(e)}};Number.isInteger,Number.isSafeInteger;function Tn(e,t=0){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function En(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 Dn(e,t,n,r,i){let a=new wn(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++){En(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 Cn(c),Cn(l),Cn(s),a.cleanSavedState(d),a.clean(),u}var On=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(){Cn(this._buffer),Cn(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&&(An(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=An(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;En(n,this._buffer,i-8),En(r,this._buffer,i-4),An(this._temp,this._state,this._buffer,0,i),this._finished=!0}for(let t=0;t<this.digestLength/4;t++)En(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){Cn(e.state),e.buffer&&Cn(e.buffer),e.bufferLength=0,e.bytesHashed=0}},kn=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 An(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++){let i=r+t*4;e[t]=Tn(n,i)}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+(kn[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 jn=r(),Mn,Nn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Pn(e){return!e&&!Mn?Nn:{lang:e?.lang??Mn?.lang,message:e?.message,abortEarly:e?.abortEarly??Mn?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Mn?.abortPipeEarly}}var Fn;function In(e){return Fn?.get(e)}var Ln;function Rn(e){return Ln?.get(e)}var zn;function Bn(e,t){return zn?.get(e)?.get(t)}function Vn(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 G(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??Vn(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??Bn(e.reference,c.lang)??(l?Rn(c.lang):null)??r.message??In(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 Hn=new WeakMap;function Un(e){let t=Hn.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},Pn())}},Hn.set(e,t)),t}function Wn(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Gn(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function Kn(e,t){return{kind:`validation`,type:`check`,reference:Kn,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&G(this,`input`,e,t),e}}}function qn(e){return{kind:`validation`,type:`integer`,reference:qn,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&G(this,`integer`,e,t),e}}}function Jn(e,t){return{kind:`validation`,type:`max_length`,reference:Jn,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&G(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Yn(e,t){return{kind:`validation`,type:`min_value`,reference:Yn,async:!1,expects:`>=${e instanceof Date?e.toJSON():Vn(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&G(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Vn(e.value)}),e}}}function Xn(e,t){return{kind:`validation`,type:`regex`,reference:Xn,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&G(this,`format`,e,t),e}}}function Zn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Qn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function $n(e,t){return{kind:`schema`,type:`array`,reference:$n,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Un(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 G(this,`type`,e,t);return e}}}function er(e){return{kind:`schema`,type:`boolean`,reference:er,expects:`boolean`,async:!1,message:e,get"~standard"(){return Un(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:G(this,`type`,e,t),e}}}function tr(e,t){return{kind:`schema`,type:`instance`,reference:tr,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Un(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:G(this,`type`,e,t),e}}}function nr(e,t){return{kind:`schema`,type:`literal`,reference:nr,expects:Vn(e),async:!1,literal:e,message:t,get"~standard"(){return Un(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:G(this,`type`,e,t),e}}}function rr(e){return{kind:`schema`,type:`number`,reference:rr,expects:`number`,async:!1,message:e,get"~standard"(){return Un(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:G(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 Un(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Qn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function ir(e,t){return{kind:`schema`,type:`picklist`,reference:ir,expects:Gn(e.map(Vn),`|`),async:!1,options:e,message:t,get"~standard"(){return Un(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:G(this,`type`,e,t),e}}}function ar(e,t,n){return{kind:`schema`,type:`record`,reference:ar,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Un(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Wn(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 G(this,`type`,e,t);return e}}}function or(e,t){return{kind:`schema`,type:`strict_object`,reference:or,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Un(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]:Qn(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]=Zn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(G(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)){G(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else G(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 Un(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:G(this,`type`,e,t),e}}}function sr(){return{kind:`schema`,type:`unknown`,reference:sr,expects:`unknown`,async:!1,get"~standard"(){return Un(this)},"~run"(e){return e.typed=!0,e}}}function cr(...e){return{...e[0],pipe:e,get"~standard"(){return Un(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 lr(e,t,n){let r=e[`~run`]({value:t},Pn(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},ur={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`)},dr={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 fr(e){if(typeof e==`object`&&e)return e[Z.ENCODED]}function pr(e){if(typeof e==`object`&&e)return e[Z.LENGTH]}function mr(e,t){Object.defineProperty(e,Z.ENCODED,{configurable:!0,enumerable:!1,value:t})}function hr(e,t){let n=Object(e);return mr(n,t),n}var gr=Symbol(`CBOR_RANGES`);function _r(e,t){Object.defineProperty(e,gr,{configurable:!1,enumerable:!1,writable:!1,value:t})}function vr(e){return e[gr]}function yr(e){return vr(e)!==void 0}function br(e,t=0,n=e.length-1){let r=e.subarray(t,n),i=vr(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&&_r(r,e)}return r}function xr(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 Sr(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}function Cr(e){let t=e.reduce((e,t)=>e+t.length,0),n=e.some(e=>yr(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[gr]??[[0,t.length]];for(let t of e)t[0]+=a;r.push(...e)}a+=t.length}return n&&_r(i,r),i}function wr(e){let t=atob(e);return Uint8Array.from(t,e=>e.codePointAt(0))}var Tr={"-":`+`,_:`/`};function Er(e){let t=e.replace(/[_-]/g,e=>Tr[e]);return wr(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 Or(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 kr=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 Ar(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 jr=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,Nr=31n<<10n,Pr=1n<<9n,Fr=Pr-1n,Ir=Pr|Fr,Lr=1n<<31n,Rr=255n<<23n,zr=1n<<22n,Br=zr-1n,Vr=zr|Br,Hr=1n<<63n,Ur=2047n<<52n,Wr=1n<<51n,Gr=Wr-1n,Kr=Wr|Gr,qr=Gr-(Fr<<42n),Jr=Gr-(Br<<29n),Yr={2:`0b`,8:`0o`,16:`0x`},Xr=(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))(Xr||{});function Zr(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 Qr=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=Hr,e=-e),e>=Wr)throw Error(`Payload too large: ${r}`);let a=t?Wr:0n;switch(this.#e=i|Ur|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&qr)throw Error(`Invalid size for payload`);break;case 4:if(this.#e&Jr)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&Ur)===Ur)this.#e=e,t=8;else if((e&Rr)===Rr){let n=(e&Lr)<<32n;this.#e=n|Ur|(e&Vr)<<29n,t=4}else if((e&Nr)===Nr){let n=(e&Mr)<<48n;this.#e=n|Ur|(e&Ir)<<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&Nr)!==Nr)throw Error(`Not a NaN`);let r=(n&Mr)<<48n;this.#e=r|Ur|(n&Ir)<<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&Rr)!==Rr)throw Error(`Not a NaN`);let r=(n&Lr)<<32n;this.#e=r|Ur|(n&Vr)<<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&Ur)!==Ur)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&Hr?Mr:0n)|Nr|(this.#e&Kr)>>42n;t.setUint16(1,Number(e),!1);break}case 4:{t.setUint8(0,250);let e=(this.#e&Hr?Lr:0n)|Rr|(this.#e&Kr)>>29n;t.setUint32(1,Number(e),!1);break}case 8:t.setUint8(0,251),t.setBigUint64(1,this.#e)}return new Uint8Array(e)}get quiet(){return!!(this.#e&Wr)}get sign(){return this.#e&Hr?-1:1}get payload(){return Number(this.#e&Gr)*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&qr)===0n?2:(this.#e&Jr)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return Zr(this,1,{},t=>(Yr[e]??``)+t.toString(e))}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return Zr(this,e,t,n)}};function $r(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}return i===31?a?NaN:1/0*r:r*2**(i-25)*(1024+a)}function ei(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 ti(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 ni(e){switch(e.length){case 2:$r(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 ri=class extends TypeError{code=`ERR_ENCODING_INVALID_ENCODED_DATA`;constructor(){super(`The encoded data was not valid for encoding wtf-8`)}},ii=class extends RangeError{code=`ERR_ENCODING_NOT_SUPPORTED`;constructor(e){super(`Invalid encoding: "${e}"`)}},ai=new Uint8Array,oi=55296,si=56320,ci=65533,li=`wtf-8`;function ui(e){return e&&typeof e==`object`&&!(e instanceof ArrayBuffer)&&!(e instanceof SharedArrayBuffer)&&e.buffer instanceof ArrayBuffer}function di(e){return e?e instanceof Uint8Array?e:ui(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e):ai}var fi=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3],pi=class e{static DEFAULT_BUFFERSIZE=4096;encoding=li;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 ii(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=di(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 ri;a[s++]=ci},l=()=>{let e=this.#n;for(let t=0;t<e;t++)c()},u=e=>{if(this.#e===0)switch(fi[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)}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|oi,a[s++]=e&1023|si}}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 mi(e){let t=0;for(let n of e){let e=n.codePointAt(0);e<128?t++:t+=e<2048?2:e<65536?3:4}return t}var hi=class{encoding=li;encode(e){if(!e)return ai;let t=new Uint8Array(mi(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:gi}=Z,_i=J.SIMPLE_FLOAT<<5|X.TWO,vi=J.SIMPLE_FLOAT<<5|X.FOUR,yi=J.SIMPLE_FLOAT<<5|X.EIGHT,bi=J.SIMPLE_FLOAT<<5|ur.TRUE,xi=J.SIMPLE_FLOAT<<5|ur.FALSE,Si=J.SIMPLE_FLOAT<<5|ur.UNDEFINED,Ci=J.SIMPLE_FLOAT<<5|ur.NULL,wi=new TextEncoder,Ti=new hi,Ei={...jr.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:Ar},Oi={...Di,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:`NFC`};function ki(e){let t=e<0;return typeof e==`bigint`?[t?-e-1n:e,t]:[t?-e-1:e,t]}function Ai(e,t,n){if(n.rejectFloats)throw Error(`Attempt to encode an unwanted floating point number: ${e}`);if(isNaN(e))t.writeUint8(_i),t.writeUint16(32256);else if(!n.float64&&Math.fround(e)===e){let n=ei(e);n===null?(t.writeUint8(vi),t.writeFloat32(e)):(t.writeUint8(_i),t.writeUint16(n))}else t.writeUint8(yi),t.writeFloat64(e)}function ji(e,t,n){let[r,i]=ki(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 Mi(e,t,n){typeof e==`number`?ji(e,t,J.TAG):typeof e==`object`&&!n.ignoreOriginalEncoding&&Z.ENCODED in e?t.write(e[Z.ENCODED]):e<=2**53-1?ji(Number(e),t,J.TAG):(t.writeUint8(J.TAG<<5|X.EIGHT),t.writeBigUint64(BigInt(e)))}function Ni(e,t,n){let[r,i]=ki(e);if(n.collapseBigInts&&(!n.largeNegativeAsBigInt||e>=-9223372036854775808n)){if(r<=4294967295n){ji(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`:``;Mi(a,t,n);let c=xr(s+o);ji(c.length,t,J.BYTE_STRING),t.write(c)}function Pi(e,t,n){n.flushToZero&&(e=ti(e)),Object.is(e,-0)?n.simplifyNegativeZero?n.avoidInts?Ai(0,t,n):ji(0,t):Ai(e,t,n):!n.avoidInts&&Number.isSafeInteger(e)?ji(e,t):n.reduceUnsafeNumbers&&Math.floor(e)===e&&e>=dr.MIN&&e<=dr.MAX?Ni(BigInt(e),t,n):Ai(e,t,n)}function Fi(e,t,n){let r=n.stringNormalization?e.normalize(n.stringNormalization):e;if(n.wtf8&&!e.isWellFormed()){let e=Ti.encode(r);Mi(Y.WTF8,t,n),ji(e.length,t,J.BYTE_STRING),t.write(e)}else{let e=wi.encode(r);ji(e.length,t,J.UTF8_STRING),t.write(e)}}function Ii(e,t,n){let r=e;zi(r,r.length,J.ARRAY,t,n);for(let e of r)Hi(e,t,n)}function Li(e,t){ji(e.length,t,J.BYTE_STRING),t.write(e)}var Ri=new kr;Ri.registerEncoder(Array,Ii),Ri.registerEncoder(Uint8Array,Li);function $(e,t){return Ri.registerEncoder(e,t)}function zi(e,t,n,r,i){let a=pr(e);a&&!i.ignoreOriginalEncoding?r.write(a):ji(t,r,n)}function Bi(e,t,n){if(e===null){t.writeUint8(Ci);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:Ri.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),Hi(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),Hi(r[1],t,n));return}if(typeof e.toJSON==`function`){Hi(e.toJSON(),t,n);return}let i=Object.entries(e).map(e=>[e[0],e[1],Ui(e[0],n)]);n.sortKeys&&i.sort(n.sortKeys),zi(e,i.length,J.MAP,t,n);for(let[e,r,a]of i)t.write(a),Hi(r,t,n)}function Vi(e,t,n){if(!e.description||e!==Symbol.for(e.description))throw TypeError(`Private or empty symbol: ${e.toString()}`);Mi(280,t,n),Fi(e.description,t,n)}function Hi(e,t,n){switch(typeof e){case`number`:Pi(e,t,n);break;case`bigint`:Ni(e,t,n);break;case`string`:Fi(e,t,n);break;case`boolean`:t.writeUint8(e?bi:xi);break;case`undefined`:if(n.rejectUndefined)throw Error(`Attempt to encode unwanted undefined.`);t.writeUint8(Si);break;case`object`:Bi(e,t,n);break;case`symbol`:Vi(e,t,n);break;default:throw TypeError(`Unknown type: ${typeof e}, ${String(e)}`)}}function Ui(e,t={}){let n={...Ei};t.dcbor?Object.assign(n,Oi):t.cde&&Object.assign(n,Di),Object.assign(n,t);let r=new jr(n);return Hi(e,r,n),r.read()}var Wi=(e=>(e[e.NEVER=-1]=`NEVER`,e[e.PREFERRED=0]=`PREFERRED`,e[e.ALWAYS=1]=`ALWAYS`,e))(Wi||{}),Gi=class e{static KnownSimple=new Map([[ur.FALSE,!1],[ur.TRUE,!0],[ur.NULL,null],[ur.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}`);ji(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)})`}},Ki=new TextDecoder(`utf8`,{fatal:!0,ignoreBOM:!0}),qi=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=xr(t);break;case`base64`:this.#e=wr(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 br(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=$r(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,Ki.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=Gi.create(Number(a))),yield[r,i,a,t,e];break}}}#a(e){let t=br(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}}},Ji=new Map([[X.ZERO,1],[X.ONE,2],[X.TWO,3],[X.FOUR,5],[X.EIGHT,9]]),Yi=new Uint8Array;function Xi(e,t){return!t.boxed&&!t.preferMap&&e.every(([e])=>typeof e==`string`)?Object.fromEntries(e):new Map(e)}var Zi=class e{static defaultDecodeOptions={...qi.defaultOptions,ParentType:e,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Wi.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:Xi,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:Ar};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>=dr.MIN&&e<=dr.MAX&&(e=Number(o)),n.boxed?hr(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 Qr(e);if(n.rejectLongLoundNaN){if(t.payload||e.length>3)throw Error(`Invalid NaN encoding: "${Sr(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&&ni(r.toHere(s+1)),n.rejectLongFloats){let e=Ui(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<Ji.get(a))throw Error(`Number should have been encoded shorter: ${o}`)}if(typeof o==`number`&&n.boxed)return hr(o,r.toHere(s))}else{if(n.rejectSimple&&o instanceof Gi)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 [${Or(o)}] instead of [${Or(e)}]`)}return n.boxed?hr(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{...Ei,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=fr(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=fr(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=Sr(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 Cr(this.children);case J.UTF8_STRING:{let n=this.children.join(``);t=this.#e.boxed?hr(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`&&mr(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],Yi];return n}},Qi=` `,$i=new TextEncoder,ea=class extends Zi{close=``;quote=`"`;get isEmptyStream(){return(this.mt===J.UTF8_STRING||this.mt===J.BYTE_STRING)&&this.count===0}};function ta(e,t,n,r){let i=``;if(t===X.INDEFINITE)i+=`_`;else{if(r.diagnosticSizes===Wi.NEVER)return``;{let a=r.diagnosticSizes===Wi.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?ei(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 na(e,t){let n={...Zi.defaultDecodeOptions,...t,ParentType:ea},r=new qi(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
|
-
${
|
|
3
|
-
${
|
|
4
|
-
${
|
|
5
|
-
`,i.length>a+1){let n=
|
|
6
|
-
`,r+=
|
|
7
|
-
`),c>a)for(let e=c;e<c+l;e+=8){let t=Math.min(e+8,c+l);r+=n,r+=
|
|
8
|
-
`}}}else for(let e=a+1;e<i.length;e+=8)r+=n,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,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},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)=>{t.exports=typeof Object.create==`function`?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}: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(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=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(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 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(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 w(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=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 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 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||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 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,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: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(xe(r))return o;e[n+o]=r}return o}function k(e,t,n,r){return H(ge(t,e.length-n),e,n,r)}function te(e,t,n,r){return H(_e(t),e,n,r)}function ne(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 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 ne(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]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+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]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+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]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+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]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+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 ce(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 ce(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 ce(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function le(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function L(e,t,n,i,a){return t=+t,n>>>=0,a||le(e,t,n,4),r.write(e,t,n,i,23,4),n+4}d.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},d.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)};function R(e,t,n,i,a){return t=+t,n>>>=0,a||le(e,t,n,8),r.write(e,t,n,i,52,8),n+8}d.prototype.writeDoubleLE=function(e,t,n){return R(this,e,t,!0,n)},d.prototype.writeDoubleBE=function(e,t,n){return R(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 ue={};function z(e,t,n){ue[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 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 ue.ERR_OUT_OF_RANGE(`value`,i,e)}de(r,i,a)}function V(e,t){if(typeof e!=`number`)throw new ue.ERR_INVALID_ARG_TYPE(t,`number`,e)}function pe(e,t,n){throw Math.floor(e)===e?t<0?new ue.ERR_BUFFER_OUT_OF_BOUNDS:new ue.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(V(e,n),new ue.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}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})),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.head=this.length===1?this.tail=null: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,this.head=t.next?t.next: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,this.head=n.next?n.next: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]}`}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})),ne=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:16384}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&&String(t).toLowerCase()===`true`}})),A=t(((e,t)=>{a(),T(),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=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=ne().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 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){ce(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}})):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(){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)}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&&R(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(de,e,t),e._writableState.errorEmitted=!0,O(e,r)):(i(r),e._writableState.errorEmitted=!0,O(e,r),de(e,t))}function se(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function ce(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=ue(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&R(e,n),r?w.nextTick(le,e,n,a,i):le(e,n,a,i)}}function le(e,t,n,r){n||L(e,t),t.pendingcb--,r(),de(e,t)}function L(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function R(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 ue(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function z(e,t){e._final(function(n){t.pendingcb--,n&&O(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,w.nextTick(z,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function de(e,t){var n=ue(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?w.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&&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=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||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(),_=ne().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,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&&(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&&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,z(e,a);else{var o;if(i||(o=le(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):ce(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?ce(e,a,t,!1):fe(e,a)):ce(e,a,t,!1)}else r||(a.reading=!1,fe(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function ce(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 le(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 L=1073741824;function R(e){return e>=L?e=L:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ue(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=R(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=ue(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=ue(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 z(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,w.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,w.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)}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=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||w.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`&&w.nextTick(me,this),n},I.prototype.removeAllListeners=function(e){var t=c.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&w.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,w.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,w.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=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})),ce=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}}))(),le=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,L=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=le[n[e]&63];return t},R={},ue={};ue.byteLength=he,ue.toByteArray=_e,ue.fromByteArray=H;for(var z=[],B=[],de=typeof Uint8Array<`u`?Uint8Array:Array,fe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,V=0,pe=fe.length;V<pe;++V)z[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 z[e>>18&63]+z[e>>12&63]+z[e>>6&63]+z[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(z[t>>2]+z[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(z[t>>10]+z[t>>4&63]+z[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=ue,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 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 re(this,t,n);case`ascii`:return j(this,t,n);case`latin1`:case`binary`:return M(this,t,n);case`base64`:return ne(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?re(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||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 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,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: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(xe(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return ye(he(t,e.length-n),e,n,r)}function ee(e,t,n,r){return ye(ge(t),e,n,r)}function k(e,t,n,r){return ye(ve(t),e,n,r)}function te(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 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 ne(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]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+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]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+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]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+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]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+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 ce(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 ce(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return ce(this,e,t,!1,n)};function le(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 le(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return le(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 L={};function R(e,t,n){L[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}`}}}R(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),R(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),R(`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=z(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function z(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 L.ERR_OUT_OF_RANGE(`value`,i,e)}B(r,i,a)}function fe(e,t){if(typeof e!=`number`)throw new L.ERR_INVALID_ARG_TYPE(t,`number`,e)}function V(e,t,n){throw Math.floor(e)===e?t<0?new L.ERR_BUFFER_OUT_OF_BOUNDS:new L.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(fe(e,n),new L.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}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`)}})(R);var xe=R.Buffer;R.Blob,R.BlobOptions;var Se=R.Buffer;R.File,R.FileOptions,R.INSPECT_MAX_BYTES,R.SlowBuffer,R.TranscodeEncoding,R.atob,R.btoa,R.constants,R.isAscii,R.isUtf8,R.kMaxLength,R.kStringMaxLength,R.resolveObjectURL,R.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 ce.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(!(Number.isFinite(t)&&t>0))throw Error(`invalid chunk size`);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){if(!(Number.isFinite(t)&&t>0))throw Error(`invalid chunk size`);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){if(typeof t!=`function`)return e;let n=t.length-1;return e.length>=n?e:[...e,...Array(n-e.length).fill(void 0)]}function Me(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},set:e=>{a=e},enumerable:!1,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},set:e=>{o=e},enumerable:!1,configurable:!0})}var Ne=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}return Error(r)}function Pe(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 Fe(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 Ie(e,t,n,r,i){if(e)return(async()=>{let e;try{await Pe(!0,r,i)}catch(t){e=W(t,i)}if((t!==void 0||e!==void 0)&&(await Fe(!0,n),e!==void 0)){if(t!==void 0)t.suppressed=e;else throw e}})();{let e;try{Pe(!1,r,i)}catch(t){e=W(t,i)}if((t!==void 0||e!==void 0)&&(Fe(!1,n),e!==void 0)){if(t!==void 0)t.suppressed=e;else throw e}}}function Le(e,t,n,r){let i=t=>{e.suppressed=W(t,r)},a;try{a=n?.()}catch(e){i(e)}if(a instanceof Promise)return a.catch(i).then(()=>t?.unroll()).then(()=>{throw e});let o=t?.unroll();if(o instanceof Promise)return o.then(()=>{throw e});throw e}function Re(...e){let t,n,r,i,a,o;if(e.length===1&&typeof e[0]==`object`&&e[0]!==null?(t=e[0].description,n=e[0].spool,r=e[0].action,i=e[0].oncatch,a=e[0].onfinally,o=e[0].oncleanup):typeof e[0]==`string`?(t=e[0],e[1]instanceof Ne||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 Ne||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)return Le(r,n,a,t);try{s=i(r)}catch(e){return Le(W(e,t),n,a,t)}i=void 0}return s instanceof Promise?s.then(async e=>(n&&o&&n.roll(e,o),await Ie(!0,void 0,n,a,t),e),async e=>{let r=W(e,t);if(i){let e;try{e=await i(r)}catch(e){throw r=W(e,t),await Ie(!0,r,n,a,t),r}return n&&o&&n.roll(e,o),await Ie(!0,void 0,n,a,t),e}throw await Ie(!0,r,n,a,t),r}):(n&&o&&n.roll(s,o),Ie(!1,void 0,n,a,t),s)}var ze=new TextEncoder,Be=new TextDecoder,Ve=new TextDecoder(`utf-8`,{fatal:!0});function He(...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 Ue(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 We(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 Ge(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}var Ke=`The input to be decoded is not correctly encoded.`;function qe(e){if(Uint8Array.fromBase64)try{return Uint8Array.fromBase64(typeof e==`string`?e:Be.decode(e),{alphabet:`base64url`})}catch(e){throw TypeError(Ke,{cause:e})}let t=e;if(t instanceof Uint8Array&&(t=Be.decode(t)),t.includes(`+`)||t.includes(`/`))throw TypeError(Ke);t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Ge(t)}catch{throw TypeError(Ke)}}function Je(e){let t=e;return typeof t==`string`&&(t=ze.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):We(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var Ye=(e,t=`algorithm.name`)=>TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);function Xe(e,t){if(t&&!e.usages.includes(t))throw TypeError(`CryptoKey does not support this operation, its usages must include ${t}.`)}function Ze(e,t){let{modulusLength:n}=t.algorithm;if(typeof n!=`number`||n<2048)throw TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}function Qe(e,t,n){let r=e.algorithm;if(r.name!==t.name)throw Ye(t.name);if(t.hash&&r.hash?.name!==t.hash)throw Ye(t.hash,`algorithm.hash`);if(t.namedCurve&&r.namedCurve!==t.namedCurve)throw Ye(t.namedCurve,`algorithm.namedCurve`);if(t.length!==void 0&&r.length!==t.length)throw Ye(t.length,`algorithm.length`);Xe(e,n)}async function $e(e,t,n){return t instanceof Uint8Array?crypto.subtle.importKey(`raw`,t,e.subtle,!1,[n]):(Qe(t,e.subtle,n),e.minRsaBits&&Ze(e.alg,t),t)}async function et(e,t,n){let r=await $e(e,t,`sign`),i=await crypto.subtle.sign(e.signing,r,n);return new Uint8Array(i)}async function tt(e,t,n,r){let i=await $e(e,t,`verify`);try{return await crypto.subtle.verify(e.signing,i,n,r)}catch{return!1}}var nt=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)}},rt=class extends nt{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}},it=class extends nt{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}},at=class extends nt{static code=`ERR_JOSE_ALG_NOT_ALLOWED`;code=`ERR_JOSE_ALG_NOT_ALLOWED`},ot=class extends nt{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},G=class extends nt{static code=`ERR_JWS_INVALID`;code=`ERR_JWS_INVALID`},st=class extends nt{static code=`ERR_JWT_INVALID`;code=`ERR_JWT_INVALID`},ct=class extends nt{static code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;code=`ERR_JWS_SIGNATURE_VERIFICATION_FAILED`;constructor(e=`signature verification failed`,t){super(e,t)}};function lt(e){let t={__proto__:null};for(let n in e)t[n]={...e[n],alg:n};return t}var ut=[[`verify`],[`sign`]];function dt(e){let t={name:`HMAC`,hash:`SHA-${e}`};return{kty:[`oct`],secret:!0,subtle:t,signing:t,usages:ut}}function ft(e,t){let n={name:t?`RSA-PSS`:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e}`};return{kty:[`RSA`],subtle:n,signing:t?{...n,saltLength:t}:n,usages:ut,minRsaBits:2048}}function pt(e,t){return{kty:[`EC`],crv:e,subtle:{name:`ECDSA`,namedCurve:e},signing:{name:`ECDSA`,hash:`SHA-${t}`},usages:ut}}function mt(){let e={name:`Ed25519`};return{kty:[`OKP`],crv:`Ed25519`,subtle:e,signing:e,usages:ut}}function ht(e){let t={name:`ML-DSA-${e}`};return{kty:[`AKP`],subtle:t,signing:t,usages:ut}}var gt=lt({HS256:dt(256),HS384:dt(384),HS512:dt(512),RS256:ft(256),RS384:ft(384),RS512:ft(512),PS256:ft(256,32),PS384:ft(384,48),PS512:ft(512,64),ES256:pt(`P-256`,256),ES384:pt(`P-384`,384),ES512:pt(`P-521`,512),EdDSA:mt(),Ed25519:mt(),"ML-DSA-44":ht(44),"ML-DSA-65":ht(65),"ML-DSA-87":ht(87)});function _t(e){let t=typeof e==`string`?gt[e]:void 0;if(!t)throw new ot(`alg ${e} is not supported either by JOSE or your javascript runtime`);return t}function vt(e){if(typeof e!=`object`||!e||Object.prototype.toString.call(e)!==`[object Object]`)return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let n=t;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return t===n}function yt(...e){let t=new Set;for(let n of e)if(n)for(let e of Object.keys(n)){if(t.has(e))return!1;t.add(e)}return!0}var bt=e=>vt(e)&&typeof e.kty==`string`,xt=e=>e.kty!==`oct`&&(e.kty===`AKP`&&typeof e.priv==`string`||typeof e.d==`string`),St=e=>e.kty!==`oct`&&e.d===void 0&&e.priv===void 0,Ct=e=>e.kty===`oct`&&typeof e.k==`string`,wt={__proto__:null,b64:!0};function Tt(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)}function Et(e,t){let{crit:n}=t??{};if(Array.isArray(n)&&new Set(n).size!==n.length)throw new e(`"crit" (Critical) Header Parameter MUST NOT contain duplicate values`)}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[];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=n===void 0?t:{__proto__:null,...n,...t};for(let t of r.crit){if(!(t in a))throw new ot(`Extension Header Parameter "${t}" is not recognized`);if(!Object.hasOwn(i,t)||i[t]===void 0)throw new e(`Extension Header Parameter "${t}" is missing`);if(a[t]&&(!Object.hasOwn(r,t)||r[t]===void 0))throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return r.crit}function Ot(e,t,...n){if(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 kt=(e,t,...n)=>Ot(`Key for the ${e} algorithm must be `,t,...n),At=e=>{if(e?.[Symbol.toStringTag]===`CryptoKey`)return!0;try{return e instanceof CryptoKey}catch{return!1}},jt=e=>e?.[Symbol.toStringTag]===`KeyObject`,Mt=e=>At(e)||jt(e);async function Nt(e,t){if(t.kty===`RSA`&&`oth`in t&&t.oth!==void 0)throw new ot(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);if(!e.kty.includes(t.kty))throw new ot(`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`);let n=e.resolve?.({kty:t.kty,crv:t.crv})??e.subtle,r=!!(t.d||t.priv),i={...t};return i.kty!==`AKP`&&delete i.alg,delete i.use,crypto.subtle.importKey(`jwk`,i,n,t.ext??!r,t.key_ops??e.usages[+!!r])}var Pt=e=>e[Symbol.toStringTag],Ft=(e,t,n)=>{let{alg:r}=e;if(t.use!==void 0){let e=n===`sign`||n===`verify`?`sig`:`enc`;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!==r)throw TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);if(Array.isArray(t.key_ops)){let r=n===`encrypt`||n===`decrypt`?e.ops?.[n===`encrypt`?0:1]:n;if(r&&!t.key_ops.includes(r))throw TypeError(`Invalid key for this operation, its "key_ops" must include "${r}" when present`)}};function It(e,t,n){let{alg:r,secret:i}=e,a=n===`decrypt`||n===`sign`;if(i&&t instanceof Uint8Array)return[Lt,t];if(bt(t)){if(i?!Ct(t):!(a?xt(t):St(t)))throw TypeError(i?`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`:`JSON Web Key for this operation must be a ${a?`private`:`public`} JWK`);return Ft(e,t,n),[Bt,t]}if(!Mt(t))throw TypeError(i?kt(r,t,`CryptoKey`,`KeyObject`,`JSON Web Key`,`Uint8Array`):kt(r,t,`CryptoKey`,`KeyObject`,`JSON Web Key`));if(i){if(t.type!==`secret`)throw TypeError(`${Pt(t)} instances for symmetric algorithms must be of type "secret"`)}else{if(t.type===`secret`)throw TypeError(`${Pt(t)} instances for asymmetric algorithms must not be of type "secret"`);let e=a?`private`:`public`;if((t.type===`public`||t.type===`private`)&&t.type!==e){let r=n===`sign`?`signing`:n===`verify`?`verifying`:`${n.slice(0,-1)}tion`;throw TypeError(`${Pt(t)} instances for asymmetric algorithm ${r} must be of type "${e}"`)}}return At(t)?[Rt,t]:[zt,t]}var Lt=0,Rt=1,zt=2,Bt=3,Vt,Ht={__proto__:null,prime256v1:`P-256`,secp384r1:`P-384`,secp521r1:`P-521`};function Ut(e,t,n){Vt||=new WeakMap;let r=Vt.get(e);return n&&(r?r[t]=n:Vt.set(e,{__proto__:null,[t]:n})),n??r?.[t]}var Wt=async(e,t,n)=>Ut(e,n.alg)??Ut(e,n.alg,await Nt(n,{...t,alg:n.alg})),Gt=(e,t)=>{let n=Ut(e,t.alg);if(n)return n;let r=e.type===`public`,i=t.usages[+!r],{asymmetricKeyType:a}=e,o=Ht[e.asymmetricKeyDetails?.namedCurve],s=t.resolve?.({crv:o,asymmetricKeyType:a})??t.subtle;return Ut(e,t.alg,e.toCryptoKey(s,r,i))};async function Kt(e,t,n){let r=It(e,t,n);switch(r[0]){case Lt:case Rt:return r[1];case Bt:{let t=r[1];if(t.k)return qe(t.k);if(!Object.isFrozen(t)){let{key_ops:e}=t;Array.isArray(e)&&Object.freeze(e),Object.freeze(t)}return Wt(t,t,e)}case zt:{let t=r[1];return t.type===`secret`?t.export():`toCryptoKey`in t&&typeof t.toCryptoKey==`function`?Gt(t,e):Wt(t,t.export({format:`jwk`}),e)}}}function qt(e){return e?.b64===!1&&Array.isArray(e.crit)&&e.crit.includes(`b64`)}async function Jt(e,t){let{protectedHeader:n,unprotectedHeader:r}=e;if(!n&&!r)throw new G(`either setProtectedHeader or setUnprotectedHeader must be called before #sign()`);if(!yt(n,r))throw new G(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);let i={...n,...r};Et(G,n);let a=Dt(G,wt,e.crit,n,i),o=!0;if(a.includes(`b64`)&&(o=n.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=_t(s),l,u;if(o){let t=e.encoded??=[];t[0]??=Je(e.payload),t[1]??=Ue(t[0]),l=t[0],u=t[1]}else u=e.payload,l=``;let d,f;n?(d=Je(JSON.stringify(n)),f=Ue(d)):(d=``,f=new Uint8Array);let p=He(f,Ue(`.`),u),m={signature:Je(await et(c,await Kt(c,t,`sign`),p)),payload:l};return n&&(m.protected=d),r&&(m.header=r),m}function Yt(e,t){if(e)throw TypeError(`${t} can only be called once`)}function Xt(e,t,n){try{return qe(e)}catch{throw new n(`Failed to base64url decode the ${t}`)}}function Zt(e,t,n){try{return Ue(e)}catch{throw new n(`The ${t} is not a valid base64url string`)}}function Qt(e,t,n){let r;try{r=JSON.parse(Ve.decode(qe(e)))}catch{throw new t(n)}if(!vt(r))throw new t(n);return r}var $t=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 Yt(this.#t,`setProtectedHeader`),this.#t=e,this}setUnprotectedHeader(e){return Yt(this.#n,`setUnprotectedHeader`),this.#n=e,this}async sign(e,t){return Jt({payload:this.#e,protectedHeader:this.#t,unprotectedHeader:this.#n,crit:t?.crit},e)}},en=class{#e;#t;constructor(e){this.#e=new $t(e)}setProtectedHeader(e){return this.#e.setProtectedHeader(e),this.#t=e,this}async sign(e,t){if(qt(this.#t))throw TypeError(`use the flattened module for creating JWS with b64: false`);let n=await this.#e.sign(e,t);return`${n.protected}.${n.payload}.${n.signature}`}},tn=e=>Math.floor(e.getTime()/1e3),nn={s:1,m:60,h:3600,d:86400,w:604800,y:31557600},rn=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,an=`check_failed`;function on(e){let t=rn.exec(e);if(!t||t[4]&&t[1])throw TypeError(`Invalid time period format`);let n=parseFloat(t[2]),r=Math.round(n*nn[t[3][0].toLowerCase()]);return t[1]===`-`||t[4]===`ago`?-r:r}function sn(e,t){if(!Number.isFinite(t))throw TypeError(`Invalid ${e} input`);return t}function cn(e,t){return typeof e==`number`?sn(t,e):e instanceof Date?sn(t,tn(e)):tn(new Date)+on(e)}var ln=e=>e.includes(`/`)?e.toLowerCase():`application/${e.toLowerCase()}`,un=(e,t)=>typeof e==`string`?t.includes(e):Array.isArray(e)?t.some(t=>e.includes(t)):!1;function dn(e,t,n=!1){let r=e[t];if(!(r===void 0&&!n)){if(typeof r!=`number`)throw new rt(`"${t}" claim must be a number`,e,t,`invalid`);return r}}function fn(e,t){throw new rt(`unexpected "${t}" claim value`,e,t,an)}function pn(e,t,n={}){let r;try{r=JSON.parse(Ve.decode(t))}catch{}if(!vt(r))throw new st(`JWT Claims Set must be a top-level JSON object`);let{typ:i}=n;if(i&&(typeof e.typ!=`string`||ln(e.typ)!==ln(i)))throw new rt(`unexpected "typ" JWT header value`,r,`typ`,an);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(!Object.hasOwn(r,e))throw new rt(`missing required "${e}" claim`,r,e,`missing`);o!==void 0&&!(Array.isArray(o)?o:[o]).includes(r.iss)&&fn(r,`iss`),s!==void 0&&r.sub!==s&&fn(r,`sub`),c!==void 0&&!un(r.aud,typeof c==`string`?[c]:c)&&fn(r,`aud`);let{clockTolerance:d}=n,f=0;if(typeof d==`string`)f=on(d);else if(d!==void 0){if(typeof d!=`number`)throw TypeError(`Invalid clockTolerance option type`);f=d}sn(`clockTolerance option`,f);let{currentDate:p}=n,m=sn(`currentDate option`,tn(p||new Date)),h=dn(r,`iat`,l!==void 0),g=dn(r,`nbf`);if(g!==void 0&&g>m+f)throw new rt(`"nbf" claim timestamp check failed`,r,`nbf`,an);let _=dn(r,`exp`);if(_!==void 0&&_<=m-f)throw new it(`"exp" claim timestamp check failed`,r,`exp`,an);if(l!==void 0){let e=m-h,t=typeof l==`number`?l:on(l);if(e-f>t)throw new it(`"iat" claim timestamp check failed (too far in the past)`,r,`iat`,an);if(e<0-f)throw new rt(`"iat" claim timestamp check failed (it should be in the past)`,r,`iat`,an)}return r}var mn=class{#e;constructor(e){if(!vt(e))throw TypeError(`JWT Claims Set MUST be an object`);this.#e=structuredClone(e)}data(){return ze.encode(JSON.stringify(this.#e))}get iss(){return this.#e.iss}set iss(e){this.#e.iss=e}get sub(){return this.#e.sub}set sub(e){this.#e.sub=e}get aud(){return this.#e.aud}set aud(e){this.#e.aud=e}set jti(e){this.#e.jti=e}set nbf(e){this.#e.nbf=cn(e,`setNotBefore`)}set exp(e){this.#e.exp=cn(e,`setExpirationTime`)}set iat(e){e===void 0?this.#e.iat=tn(new Date):typeof e==`string`?this.#e.iat=sn(`setIssuedAt`,tn(new Date)+on(e)):this.#e.iat=cn(e,`setIssuedAt`)}},hn=class{#e;#t;constructor(e={}){this.#t=new mn(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 en(this.#t.data());if(n.setProtectedHeader(this.#e),qt(this.#e))throw new st(`JWTs MUST NOT use unencoded payload`);return n.sign(e,t)}};function gn(e){return[e&&Tt(`algorithms`,e.algorithms),e?.crit]}async function _n(e,t,n){let{protected:r,header:i,payload:a}=e,o={};r&&(o=Qt(r,G,`JWS Protected Header is invalid`));let s;if(i!==void 0){if(!yt(o,i))throw new G(`JWS Protected and JWS Unprotected Header Parameter names must be disjoint`);s={...o,...i}}else s=o;let c=Dt(G,wt,t[1],o,s),l=!0;if(c.includes(`b64`)&&(l=o.b64,typeof l!=`boolean`))throw new G(`The "b64" (base64url-encode payload) Header Parameter must be a boolean`);let{alg:u}=s;if(typeof u!=`string`||!u)throw new G(`JWS "alg" (Algorithm) Header Parameter missing or invalid`);if(t[0]&&!t[0].has(u))throw new at(`"alg" (Algorithm) Header Parameter value not allowed`);if(l){if(typeof a!=`string`)throw new G(`JWS Payload must be a string`)}else if(typeof a!=`string`&&!(a instanceof Uint8Array))throw new G(`JWS Payload must be a string or an Uint8Array instance`);let d=!1;typeof n==`function`&&(n=await n(o,e),d=!0);let f=_t(u),p=He(r===void 0?new Uint8Array:Ue(r),Ue(`.`),typeof a==`string`?l?t[2]??=Zt(a,`payload`,G):ze.encode(a):a),m=Xt(e.signature,`signature`,G),h=await Kt(f,n,`verify`);if(!await tt(f,h,m,p))throw new ct;let g;return g=l?Xt(a,`payload`,G):typeof a==`string`?ze.encode(a):a,[g,o,l,h,d]}async function vn(e,t,n){if(e instanceof Uint8Array&&(e=Be.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`);return _n({payload:i,protected:r,signature:a},t,n)}async function yn(e,t,n){let r=await vn(e,gn(n),t);if(!r[2])throw new st(`JWTs MUST NOT use unencoded payload`);let i={payload:pn(r[1],r[0],n),protectedHeader:r[1]};return typeof t==`function`?{...i,key:r[3]}:i}function bn(e){return e.saveState!==void 0&&e.restoreState!==void 0&&e.cleanSavedState!==void 0}function xn(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),bn(this._inner)&&bn(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),xn(n)}reset(){if(!bn(this._inner)||!bn(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(){bn(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),bn(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(!bn(this._inner))throw Error(`hmac: can't saveState() because hash doesn't implement it`);return this._inner.saveState()}restoreState(e){if(!bn(this._inner)||!bn(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(!bn(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 wn(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 Tn(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++){wn(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 xn(c),xn(l),xn(s),a.cleanSavedState(d),a.clean(),u}var En=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(){xn(this._buffer),xn(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&&(On(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(n=On(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;wn(n,this._buffer,i-8),wn(r,this._buffer,i-4),On(this._temp,this._state,this._buffer,0,i),this._finished=!0}for(let t=0;t<this.digestLength/4;t++)wn(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){xn(e.state),e.buffer&&xn(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 On(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++){let i=r+t*4;e[t]=Cn(n,i)}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 kn=n(),An,jn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Mn(e){return!e&&!An?jn:{lang:e?.lang??An?.lang,message:e?.message,abortEarly:e?.abortEarly??An?.abortEarly,abortPipeEarly:e?.abortPipeEarly??An?.abortPipeEarly}}var Nn;function Pn(e){return Nn?.get(e)}var Fn;function In(e){return Fn?.get(e)}var Ln;function Rn(e,t){return Ln?.get(e)?.get(t)}function zn(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 Bn(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??zn(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??Rn(e.reference,c.lang)??(l?In(c.lang):null)??r.message??Pn(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 Vn=new WeakMap;function Hn(e){let t=Vn.get(e);return t||(t={version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},Mn())}},Vn.set(e,t)),t}function Un(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Wn(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function Gn(e,t){return{kind:`validation`,type:`check`,reference:Gn,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Bn(this,`input`,e,t),e}}}function Kn(e){return{kind:`validation`,type:`integer`,reference:Kn,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Bn(this,`integer`,e,t),e}}}function qn(e,t){return{kind:`validation`,type:`max_length`,reference:qn,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Bn(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Jn(e,t){return{kind:`validation`,type:`min_value`,reference:Jn,async:!1,expects:`>=${e instanceof Date?e.toJSON():zn(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Bn(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():zn(e.value)}),e}}}function Yn(e,t){return{kind:`validation`,type:`regex`,reference:Yn,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&Bn(this,`format`,e,t),e}}}function Xn(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Zn(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Qn(e,t){return{kind:`schema`,type:`array`,reference:Qn,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Hn(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 Bn(this,`type`,e,t);return e}}}function $n(e){return{kind:`schema`,type:`boolean`,reference:$n,expects:`boolean`,async:!1,message:e,get"~standard"(){return Hn(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Bn(this,`type`,e,t),e}}}function er(e,t){return{kind:`schema`,type:`instance`,reference:er,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Hn(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:Bn(this,`type`,e,t),e}}}function tr(e,t){return{kind:`schema`,type:`literal`,reference:tr,expects:zn(e),async:!1,literal:e,message:t,get"~standard"(){return Hn(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Bn(this,`type`,e,t),e}}}function nr(e){return{kind:`schema`,type:`number`,reference:nr,expects:`number`,async:!1,message:e,get"~standard"(){return Hn(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Bn(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 Hn(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Zn(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function rr(e,t){return{kind:`schema`,type:`picklist`,reference:rr,expects:Wn(e.map(zn),`|`),async:!1,options:e,message:t,get"~standard"(){return Hn(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Bn(this,`type`,e,t),e}}}function ir(e,t,n){return{kind:`schema`,type:`record`,reference:ir,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Hn(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Un(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 Bn(this,`type`,e,t);return e}}}function ar(e,t){return{kind:`schema`,type:`strict_object`,reference:ar,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Hn(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]:Zn(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]=Xn(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Bn(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)){Bn(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else Bn(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 Hn(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Bn(this,`type`,e,t),e}}}function or(){return{kind:`schema`,type:`unknown`,reference:or,expects:`unknown`,async:!1,get"~standard"(){return Hn(this)},"~run"(e){return e.typed=!0,e}}}function sr(...e){return{...e[0],pipe:e,get"~standard"(){return Hn(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 cr(e,t,n){let r=e[`~run`]({value:t},Mn(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},lr={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`)},ur={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 dr(e){if(typeof e==`object`&&e)return e[Z.ENCODED]}function fr(e){if(typeof e==`object`&&e)return e[Z.LENGTH]}function pr(e,t){Object.defineProperty(e,Z.ENCODED,{configurable:!0,enumerable:!1,value:t})}function mr(e,t){let n=Object(e);return pr(n,t),n}var hr=Symbol(`CBOR_RANGES`);function gr(e,t){Object.defineProperty(e,hr,{configurable:!1,enumerable:!1,writable:!1,value:t})}function _r(e){return e[hr]}function vr(e){return _r(e)!==void 0}function yr(e,t=0,n=e.length-1){let r=e.subarray(t,n),i=_r(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&&gr(r,e)}return r}function br(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 xr(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=>vr(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[hr]??[[0,t.length]];for(let t of e)t[0]+=a;r.push(...e)}a+=t.length}return n&&gr(i,r),i}function Cr(e){let t=atob(e);return Uint8Array.from(t,e=>e.codePointAt(0))}var wr={"-":`+`,_:`/`};function Tr(e){let t=e.replace(/[_-]/g,e=>wr[e]);return Cr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function Er(){let e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])}function Dr(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 Or=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 kr(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 Ar=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}},jr=1n<<15n,Mr=31n<<10n,Nr=1n<<9n,Pr=Nr-1n,Fr=Nr|Pr,Ir=1n<<31n,Lr=255n<<23n,Rr=1n<<22n,zr=Rr-1n,Br=Rr|zr,Vr=1n<<63n,Hr=2047n<<52n,Ur=1n<<51n,Wr=Ur-1n,Gr=Ur|Wr,Kr=Wr-(Pr<<42n),qr=Wr-(zr<<29n),Jr={2:`0b`,8:`0o`,16:`0x`},Yr=(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))(Yr||{});function Xr(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 Zr=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=Vr,e=-e),e>=Ur)throw Error(`Payload too large: ${r}`);let a=t?Ur:0n;switch(this.#e=i|Hr|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&qr)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&Hr)===Hr)this.#e=e,t=8;else if((e&Lr)===Lr){let n=(e&Ir)<<32n;this.#e=n|Hr|(e&Br)<<29n,t=4}else if((e&Mr)===Mr){let n=(e&jr)<<48n;this.#e=n|Hr|(e&Fr)<<42n,t=2}else throw Error(`Invalid raw NaN value: ${e}`);if(n===-1)this.#t=this.preferredSize;else if(n===-2)this.#t=t;else{if(n<t)throw Error(`Invalid bigint NaN size`);this.#t=n}}else{let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw Error(`Invalid CBOR encoding for half float`);let n=BigInt(t.getUint16(1,!1));if((n&Mr)!==Mr)throw Error(`Not a NaN`);let r=(n&jr)<<48n;this.#e=r|Hr|(n&Fr)<<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&Lr)!==Lr)throw Error(`Not a NaN`);let r=(n&Ir)<<32n;this.#e=r|Hr|(n&Br)<<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&Hr)!==Hr)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&Vr?jr:0n)|Mr|(this.#e&Gr)>>42n;t.setUint16(1,Number(e),!1);break}case 4:{t.setUint8(0,250);let e=(this.#e&Vr?Ir:0n)|Lr|(this.#e&Gr)>>29n;t.setUint32(1,Number(e),!1);break}case 8:t.setUint8(0,251),t.setBigUint64(1,this.#e)}return new Uint8Array(e)}get quiet(){return!!(this.#e&Ur)}get sign(){return this.#e&Vr?-1:1}get payload(){return Number(this.#e&Wr)*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&qr)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return Xr(this,1,{},t=>(Jr[e]??``)+t.toString(e))}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return Xr(this,e,t,n)}};function Qr(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}return i===31?a?NaN:1/0*r:r*2**(i-25)*(1024+a)}function $r(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 ei(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 ti(e){switch(e.length){case 2:Qr(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 ni=class extends TypeError{code=`ERR_ENCODING_INVALID_ENCODED_DATA`;constructor(){super(`The encoded data was not valid for encoding wtf-8`)}},ri=class extends RangeError{code=`ERR_ENCODING_NOT_SUPPORTED`;constructor(e){super(`Invalid encoding: "${e}"`)}},ii=new Uint8Array,ai=55296,oi=56320,si=65533,ci=`wtf-8`;function li(e){return e&&typeof e==`object`&&!(e instanceof ArrayBuffer)&&!(e instanceof SharedArrayBuffer)&&e.buffer instanceof ArrayBuffer}function ui(e){return e?e instanceof Uint8Array?e:li(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e):ii}var di=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3],fi=class e{static DEFAULT_BUFFERSIZE=4096;encoding=ci;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 ri(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=ui(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 ni;a[s++]=si},l=()=>{let e=this.#n;for(let t=0;t<e;t++)c()},u=e=>{if(this.#e===0)switch(di[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)}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|ai,a[s++]=e&1023|oi}}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 pi(e){let t=0;for(let n of e){let e=n.codePointAt(0);e<128?t++:t+=e<2048?2:e<65536?3:4}return t}var mi=class{encoding=ci;encode(e){if(!e)return ii;let t=new Uint8Array(pi(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:hi}=Z,gi=J.SIMPLE_FLOAT<<5|X.TWO,_i=J.SIMPLE_FLOAT<<5|X.FOUR,vi=J.SIMPLE_FLOAT<<5|X.EIGHT,yi=J.SIMPLE_FLOAT<<5|lr.TRUE,bi=J.SIMPLE_FLOAT<<5|lr.FALSE,xi=J.SIMPLE_FLOAT<<5|lr.UNDEFINED,Si=J.SIMPLE_FLOAT<<5|lr.NULL,Ci=new TextEncoder,wi=new mi,Ti={...Ar.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},Ei={cde:!0,ignoreOriginalEncoding:!0,sortKeys:kr},Di={...Ei,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:`NFC`};function Oi(e){let t=e<0;return typeof e==`bigint`?[t?-e-1n:e,t]:[t?-e-1:e,t]}function ki(e,t,n){if(n.rejectFloats)throw Error(`Attempt to encode an unwanted floating point number: ${e}`);if(isNaN(e))t.writeUint8(gi),t.writeUint16(32256);else if(!n.float64&&Math.fround(e)===e){let n=$r(e);n===null?(t.writeUint8(_i),t.writeFloat32(e)):(t.writeUint8(gi),t.writeUint16(n))}else t.writeUint8(vi),t.writeFloat64(e)}function Ai(e,t,n){let[r,i]=Oi(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 ji(e,t,n){typeof e==`number`?Ai(e,t,J.TAG):typeof e==`object`&&!n.ignoreOriginalEncoding&&Z.ENCODED in e?t.write(e[Z.ENCODED]):e<=2**53-1?Ai(Number(e),t,J.TAG):(t.writeUint8(J.TAG<<5|X.EIGHT),t.writeBigUint64(BigInt(e)))}function Mi(e,t,n){let[r,i]=Oi(e);if(n.collapseBigInts&&(!n.largeNegativeAsBigInt||e>=-9223372036854775808n)){if(r<=4294967295n){Ai(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`:``;ji(a,t,n);let c=br(s+o);Ai(c.length,t,J.BYTE_STRING),t.write(c)}function Ni(e,t,n){n.flushToZero&&(e=ei(e)),Object.is(e,-0)?n.simplifyNegativeZero?n.avoidInts?ki(0,t,n):Ai(0,t):ki(e,t,n):!n.avoidInts&&Number.isSafeInteger(e)?Ai(e,t):n.reduceUnsafeNumbers&&Math.floor(e)===e&&e>=ur.MIN&&e<=ur.MAX?Mi(BigInt(e),t,n):ki(e,t,n)}function Pi(e,t,n){let r=n.stringNormalization?e.normalize(n.stringNormalization):e;if(n.wtf8&&!e.isWellFormed()){let e=wi.encode(r);ji(Y.WTF8,t,n),Ai(e.length,t,J.BYTE_STRING),t.write(e)}else{let e=Ci.encode(r);Ai(e.length,t,J.UTF8_STRING),t.write(e)}}function Fi(e,t,n){let r=e;Ri(r,r.length,J.ARRAY,t,n);for(let e of r)Vi(e,t,n)}function Ii(e,t){Ai(e.length,t,J.BYTE_STRING),t.write(e)}var Li=new Or;Li.registerEncoder(Array,Fi),Li.registerEncoder(Uint8Array,Ii);function $(e,t){return Li.registerEncoder(e,t)}function Ri(e,t,n,r,i){let a=fr(e);a&&!i.ignoreOriginalEncoding?r.write(a):Ai(t,r,n)}function zi(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:Li.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])))&&ji(r[0],t,n),Vi(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])))&&ji(r[0],t,n),Vi(r[1],t,n));return}if(typeof e.toJSON==`function`){Vi(e.toJSON(),t,n);return}let i=Object.entries(e).map(e=>[e[0],e[1],Hi(e[0],n)]);n.sortKeys&&i.sort(n.sortKeys),Ri(e,i.length,J.MAP,t,n);for(let[e,r,a]of i)t.write(a),Vi(r,t,n)}function Bi(e,t,n){if(!e.description||e!==Symbol.for(e.description))throw TypeError(`Private or empty symbol: ${e.toString()}`);ji(280,t,n),Pi(e.description,t,n)}function Vi(e,t,n){switch(typeof e){case`number`:Ni(e,t,n);break;case`bigint`:Mi(e,t,n);break;case`string`:Pi(e,t,n);break;case`boolean`:t.writeUint8(e?yi:bi);break;case`undefined`:if(n.rejectUndefined)throw Error(`Attempt to encode unwanted undefined.`);t.writeUint8(xi);break;case`object`:zi(e,t,n);break;case`symbol`:Bi(e,t,n);break;default:throw TypeError(`Unknown type: ${typeof e}, ${String(e)}`)}}function Hi(e,t={}){let n={...Ti};t.dcbor?Object.assign(n,Di):t.cde&&Object.assign(n,Ei),Object.assign(n,t);let r=new Ar(n);return Vi(e,r,n),r.read()}var Ui=(e=>(e[e.NEVER=-1]=`NEVER`,e[e.PREFERRED=0]=`PREFERRED`,e[e.ALWAYS=1]=`ALWAYS`,e))(Ui||{}),Wi=class e{static KnownSimple=new Map([[lr.FALSE,!1],[lr.TRUE,!0],[lr.NULL,null],[lr.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}`);Ai(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)})`}},Gi=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=br(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 yr(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=Qr(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,Gi.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=Wi.create(Number(a))),yield[r,i,a,t,e];break}}}#a(e){let t=yr(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}}},qi=new Map([[X.ZERO,1],[X.ONE,2],[X.TWO,3],[X.FOUR,5],[X.EIGHT,9]]),Ji=new Uint8Array;function Yi(e,t){return!t.boxed&&!t.preferMap&&e.every(([e])=>typeof e==`string`)?Object.fromEntries(e):new Map(e)}var Xi=class e{static defaultDecodeOptions={...Ki.defaultOptions,ParentType:e,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Ui.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:Yi,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:kr};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>=ur.MIN&&e<=ur.MAX&&(e=Number(o)),n.boxed?mr(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 Zr(e);if(n.rejectLongLoundNaN){if(t.payload||e.length>3)throw Error(`Invalid NaN encoding: "${xr(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&&ti(r.toHere(s+1)),n.rejectLongFloats){let e=Hi(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<qi.get(a))throw Error(`Number should have been encoded shorter: ${o}`)}if(typeof o==`number`&&n.boxed)return mr(o,r.toHere(s))}else{if(n.rejectSimple&&o instanceof Wi)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 [${Dr(o)}] instead of [${Dr(e)}]`)}return n.boxed?mr(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{...Ti,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=dr(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=dr(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=xr(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?mr(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`&&pr(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}},Zi=` `,Qi=new TextEncoder,$i=class extends Xi{close=``;quote=`"`;get isEmptyStream(){return(this.mt===J.UTF8_STRING||this.mt===J.BYTE_STRING)&&this.count===0}};function ea(e,t,n,r){let i=``;if(t===X.INDEFINITE)i+=`_`;else{if(r.diagnosticSizes===Ui.NEVER)return``;{let a=r.diagnosticSizes===Ui.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?$r(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 ta(e,t){let n={...Xi.defaultDecodeOptions,...t,ParentType:$i},r=new Ki(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
|
+
${Zi.repeat(i.depth+1)}`)),a=Xi.create(e,i,n,r),t){case J.POS_INT:case J.NEG_INT:o+=String(c),o+=ea(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+=ea(t,s,c,n)}else c instanceof Wi?(o+=`simple(`,o+=String(c.value),o+=ea(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+=xr(c),o+=`'`,o+=ea(J.POS_INT,s,c.length,n));break;case J.UTF8_STRING:c===1/0?(o+=`(_ `,a.close=`)`):(o+=JSON.stringify(c),o+=ea(J.POS_INT,s,Qi.encode(c).length,n));break;case J.ARRAY:{o+=`[`;let e=ea(J.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
|
|
3
|
+
${Zi.repeat(a.depth)}]`:a.close=`]`;break}case J.MAP:{o+=`{`;let e=ea(J.POS_INT,s,c,n);o+=e,e&&(o+=` `),n.pretty&&c?a.close=`
|
|
4
|
+
${Zi.repeat(a.depth)}}`:a.close=`}`;break}case J.TAG:o+=String(c),o+=ea(J.POS_INT,s,c,n),o+=`(`,a.close=`)`}if(a===Z.BREAK){if(i?.isStreaming)i.left=0;else throw Error(`Unexpected BREAK`)}else i&&(i.count++,i.left--);for(a instanceof $i&&(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 na=new TextDecoder,ra=class extends Xi{depth=0;leaf=!1;value;length;[Z.ENCODED];constructor(e,t,n,r){super(e,t,n,r),this.depth=this.parent?this.parent.depth+1: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 ia(e){return e instanceof ra}function aa(e,t){return e===1/0?`Indefinite`:t?`${e} ${t}${e!==1&&e!==1n?`s`:``}`:String(e)}function oa(e){return``.padStart(e,` `)}function sa(e,t,n){let r=``;r+=oa(e.depth*2);let i=dr(e);r+=xr(i.subarray(0,1));let a=e.numBytes();a&&(r+=` `,r+=xr(i.subarray(1,a+1))),r=r.padEnd(t.minCol+1,` `),r+=`-- `,n!==void 0&&(r+=oa(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: ${aa(e.length)})`;break;case J.UTF8_STRING:r+=`UTF8 (Length: ${aa(e.length)})`,e.length!==1/0&&(r+=`: ${JSON.stringify(s)}`);break;case J.ARRAY:r+=`Array (Length: ${aa(e.value,`item`)})`;break;case J.MAP:r+=`Map (Length: ${aa(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);pr(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?r+=Object.is(s,-0)?`Float: -0`:`Float: ${s}`:(r+=`Simple: `,s instanceof Wi?r+=s.value:r+=s)}if(!o){if(e.leaf){if(r+=`
|
|
5
|
+
`,i.length>a+1){let n=oa((e.depth+1)*2),o=_r(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+=oa(t.minCol+1),r+=`--`,r+=n,r+=`<< `;let a=yr(i,c,c+l),o=_r(a);if(o){let e=o.findIndex(([e,t,n])=>e===0&&t===l&&n===`<<`);e>=0&&o.splice(e,1)}r+=ta(a),r+=` >>
|
|
6
|
+
`,r+=la(a,{initialDepth:e.depth+1,minCol:t.minCol,noPrefixHex:!0});continue}if(u===`'`&&(r+=oa(t.minCol+1),r+=`--`,r+=n,r+=`'`,r+=na.decode(i.subarray(c,c+l)),r+=`'
|
|
7
|
+
`),c>a)for(let e=c;e<c+l;e+=8){let t=Math.min(e+8,c+l);r+=n,r+=xr(i.subarray(e,t)),r+=`
|
|
8
|
+
`}}}else for(let e=a+1;e<i.length;e+=8)r+=n,r+=xr(i.subarray(e,e+8)),r+=`
|
|
9
9
|
`}}else{r+=`
|
|
10
|
-
`;let n=0;for(let i of e.children){if(
|
|
11
|
-
`;return o+=
|
|
10
|
+
`;let n=0;for(let i of e.children){if(ia(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+=sa(i,t,a)}n++}}}return r}var ca={...Xi.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function la(e,t){let n={...ca,...t,ParentType:ra,saveOriginal:!0},r=new Ki(e,n),i,a;for(let e of r){if(a=Xi.create(e,i,n,r),e[2]===Z.BREAK){if(i?.isStreaming)i.left=1;else throw Error(`Unexpected BREAK`)}if(!ia(a)){let t=new ra(e,0,i,n);t.leaf=!0,t.children.push(a),pr(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||pr(a,r.toHere(a.offset)),{parent:i}=i}t&&(t.minCol=n.minCol);let o=n.noPrefixHex?``:`0x${xr(r.toHere(0))}
|
|
11
|
+
`;return o+=sa(a,n),o}var ua=!Er();function da(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 fa(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 pa(e){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array: ${e}`)}function ma(e){if(!Array.isArray(e))throw Error(`Expected Array: ${e}`)}$(Map,(e,t,n)=>{let r=[...e.entries()].map(e=>[e[0],e[1],Hi(e[0],n)]);if(n.rejectDuplicateKeys){let e=new Set;for(let[t,n,i]of r){let t=xr(i);if(e.has(t))throw Error(`Duplicate map key: 0x${t}`);e.add(t)}}n.sortKeys&&r.sort(n.sortKeys),Ri(e,e.size,J.MAP,t,n);for(let[e,i,a]of r)t.write(a),Vi(i,t,n)});function ha(e){return fa(e.contents),new Date(e.contents)}ha.comment=e=>{fa(e.contents);let t=new Date(e.contents);return`(String ${e.tag===Y.DATE_FULL?`Full `:``}Date) ${t.toISOString()}`},Q.registerDecoder(Y.DATE_STRING,ha),Q.registerDecoder(Y.DATE_FULL,ha);function ga(e){return da(e.contents),new Date(e.contents*1e3)}ga.comment=e=>(da(e.contents),`(Epoch Date) ${new Date(e.contents*1e3).toISOString()}`),Q.registerDecoder(Y.DATE_EPOCH,ga);var _a=864e5;function va(e){return da(e.contents),new Date(e.contents*_a)}va.comment=e=>(da(e.contents),`(Epoch Date) ${new Date(e.contents*_a).toISOString()}`),Q.registerDecoder(Y.DATE_EPOCH_DAYS,va),$(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()/_a)];case Y.DATE_FULL:return[n.dateTag,e.toISOString().split(`T`)[0]];default:throw Error(`Unsupported date tag: ${n.dateTag}`)}});function ya(e,t,n){if(pa(t.contents),n.rejectBigInts)throw Error(`Decoding unwanted big integer: ${t}(h'${xr(t.contents)}')`);if(n.requirePreferred&&t.contents[0]===0)throw Error(`Decoding overly-large bigint: ${t.tag}(h'${xr(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?mr(r,t.contents):r}var ba=ya.bind(null,!1),xa=ya.bind(null,!0);ba.comment=(e,t)=>`(Positive BigInt) ${ya(!1,e,t)}n`,xa.comment=(e,t)=>`(Negative BigInt) ${ya(!0,e,t)}n`,Q.registerDecoder(Y.POS_BIGINT,ba),Q.registerDecoder(Y.NEG_BIGINT,xa);function Sa(e,t){return pa(e.contents),e}Sa.comment=(e,t,n)=>{pa(e.contents);let r={...t,initialDepth:n+2,noPrefixHex:!0},i=dr(e),a=2**((i[0]&31)-24)+1,o=i[a]&31,s=xr(i.subarray(a,++a));o>=24&&(s+=` `,s+=xr(i.subarray(a,a+2**(o-24)))),r.minCol=Math.max(r.minCol,(n+1)*2+s.length);let c=la(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},Ca.noChildren=!0,Q.registerDecoder(Y.CBOR,Ca),Q.registerDecoder(Y.URI,e=>(pa(e.contents),new URL(e.contents)),`URI`),$(URL,e=>[Y.URI,e.toString()]),Q.registerDecoder(Y.BASE64URL,e=>(pa(e.contents),Er(e.contents)),`Base64url-encoded`),Q.registerDecoder(Y.BASE64,e=>(pa(e.contents),wr(e.contents)),`Base64-encoded`),Q.registerDecoder(35,e=>(pa(e.contents),new RegExp(e.contents)),`RegExp`),Q.registerDecoder(21065,e=>{pa(e.contents);let t=`^(?:${e.contents})$`;return new RegExp(t,`u`)},`I-RegExp`),Q.registerDecoder(Y.REGEXP,e=>{if(ha(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=>(ma(e.contents),e.contents),`uint8 Typed Array`);function wa(e,t,n){ma(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 Ta(e,t,n,r,i){let a=i.forceEndian??da;if(Mi(a?t:n,e,i),ji(r.byteLength,e,J.BYTE_STRING),da===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=>wa(e,Uint16Array,!1),`uint16, big endian, Typed Array`),Q.registerDecoder(66,e=>wa(e,Uint32Array,!1),`uint32, big endian, Typed Array`),Q.registerDecoder(67,e=>wa(e,BigUint64Array,!1),`uint64, big endian, Typed Array`),Q.registerDecoder(68,e=>(ma(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=>wa(e,Uint16Array,!0),`uint16, little endian, Typed Array`),$(Uint16Array,(e,t,n)=>Ta(t,69,65,e,n)),Q.registerDecoder(70,e=>wa(e,Uint32Array,!0),`uint32, little endian, Typed Array`),$(Uint32Array,(e,t,n)=>Ta(t,70,66,e,n)),Q.registerDecoder(71,e=>wa(e,BigUint64Array,!0),`uint64, little endian, Typed Array`),$(BigUint64Array,(e,t,n)=>Ta(t,71,67,e,n)),Q.registerDecoder(72,e=>(ma(e.contents),new Int8Array(e.contents)),`sint8 Typed Array`),$(Int8Array,e=>[72,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),Q.registerDecoder(73,e=>wa(e,Int16Array,!1),`sint16, big endian, Typed Array`),Q.registerDecoder(74,e=>wa(e,Int32Array,!1),`sint32, big endian, Typed Array`),Q.registerDecoder(75,e=>wa(e,BigInt64Array,!1),`sint64, big endian, Typed Array`),Q.registerDecoder(77,e=>wa(e,Int16Array,!0),`sint16, little endian, Typed Array`),$(Int16Array,(e,t,n)=>Ta(t,77,73,e,n)),Q.registerDecoder(78,e=>wa(e,Int32Array,!0),`sint32, little endian, Typed Array`),$(Int32Array,(e,t,n)=>Ta(t,78,74,e,n)),Q.registerDecoder(79,e=>wa(e,BigInt64Array,!0),`sint64, little endian, Typed Array`),$(BigInt64Array,(e,t,n)=>Ta(t,79,75,e,n)),Q.registerDecoder(81,e=>wa(e,Float32Array,!1),`IEEE 754 binary32, big endian, Typed Array`),Q.registerDecoder(82,e=>wa(e,Float64Array,!1),`IEEE 754 binary64, big endian, Typed Array`),Q.registerDecoder(85,e=>wa(e,Float32Array,!0),`IEEE 754 binary32, little endian, Typed Array`),$(Float32Array,(e,t,n)=>Ta(t,85,81,e,n)),Q.registerDecoder(86,e=>wa(e,Float64Array,!0),`IEEE 754 binary64, big endian, Typed Array`),$(Float64Array,(e,t,n)=>Ta(t,86,82,e,n)),Q.registerDecoder(Y.SET,(e,t)=>{if(ha(e.contents),t.sortKeys){let n=Zi.decodeToEncodeOpts(t),r=null;for(let i of e.contents){let e=[i,void 0,Ui(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,Ui(e,n)]);e.sort(n.sortKeys),r=e.map(([e])=>e)}return[Y.SET,r]}),Q.registerDecoder(Y.JSON,e=>(pa(e.contents),JSON.parse(e.contents)),`JSON-encoded`);function Ea(e){return ma(e.contents),new pi().decode(e.contents)}Ea.comment=e=>{ma(e.contents);let t=new pi;return`(WTF8 string): ${JSON.stringify(t.decode(e.contents))}`},Q.registerDecoder(Y.WTF8,Ea),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(pa(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 Oa(e){return[NaN,e.valueOf()]}$(Boolean,Oa),$(Number,Oa),$(String,Oa),$(BigInt,Oa);function ka(e){let t={...Zi.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Zi.dcborDecodeOptions):e.cde&&Object.assign(t,Zi.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,`rejectLongNumbers`))throw TypeError(`rejectLongNumbers has changed to requirePreferred`);return t.boxed&&(t.saveOriginal=!0),t}var Aa=class{parent=void 0;ret=void 0;step(e,t,n){if(this.ret=Zi.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 Zi&&(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 ja(e,t={}){let n=ka(t),r=new qi(e,n),i=new Aa;for(let e of r)i.step(e,n,r);return i.ret}var{cdeDecodeOptions:Ma,dcborDecodeOptions:Na,defaultDecodeOptions:Pa}=Zi,Fa=class{constructor(e={}){if(this.options={id:``,codec:`cbor`,timeout:1e4,share:``,chunkSize:16384,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},!(Number.isFinite(this.options.timeout)&&this.options.timeout>0))throw Error(`options: "timeout" must be a positive number`);if(!(Number.isInteger(this.options.chunkSize)&&this.options.chunkSize>0))throw Error(`options: "chunkSize" must be a positive integer`);if(!(Number.isInteger(this.options.chunkCredit)&&this.options.chunkCredit>=0))throw Error(`options: "chunkCredit" must be a non-negative integer`)}},Ia=class e{static uint8ArrayToBase64(e){return H.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)}static base64ToUint8Array(e){return new Uint8Array(H.from(e,`base64`))}static stringify(t){return JSON.stringify(t,function(t,n){let r=this[t];return r instanceof H?{__Buffer:e.uint8ArrayToBase64(r)}:r instanceof Uint8Array?{__Uint8Array:e.uint8ArrayToBase64(r)}:n})}static parse(e){return JSON.parse(e,(e,t)=>typeof t?.__Buffer==`string`?H.from(t.__Buffer,`base64`):typeof t?.__Uint8Array==`string`?this.base64ToUint8Array(t.__Uint8Array):t)}},La=class{constructor(e){this.format=e,this.types=new kr,this.tags=new Map;let t=64e3;this.types.registerEncoder(H,e=>[t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)]),this.tags.set(t,e=>H.from(e.contents))}encode(e){let t;if(this.format===`cbor`)try{t=Ui(e,{types:this.types})}catch(e){throw Error(`failed to encode CBOR format`,{cause:e})}else if(this.format===`json`)try{t=Ia.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=ja(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=Ia.parse(e)}catch(e){throw Error(`failed to decode JSON format`,{cause:e})}}else throw Error(`invalid format "${this.format}"`);return t}},Ra=class extends Fa{constructor(e={}){super(e),this.codec=new La(this.options.codec)}},za=class e extends Ra{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===H)n=H.from(e.buffer,e.byteOffset,e.byteLength);else if(r===Uint8Array)n=e;else if(r===Int8Array)n=new Int8Array(e.buffer,e.byteOffset,e.byteLength);else throw Error(`invalid data type`);return n}},Ba=e=>{let t=e.match(/^(\d+)\.(\d+)$/);if(t===null)throw Error(`invalid version string`);let n=parseInt(t[2],10);if(n>99)throw Error(`invalid version string: minor version exceeds 99`);return parseInt(t[1],10)*100+n},Va=`1.4`,Ha=`1.4`,Ua=Ba(`1.4`),Wa=Ba(`1.4`),Ga=cr(ar(q(),sr()),Kn(e=>!Array.isArray(e))),Ka=cr($n(cr(q(),Jn(8192))),Jn(8)),qa=class{constructor(e,t,n,r){this.type=e,this.id=t,this.sender=n,this.receiver=r,this.version=`MQTT+/1.4`}},Ja={version:cr(q(),Xn(/^MQTT\+\/\d+\.\d+$/)),type:q(),id:q(),sender:K(q()),receiver:K(q())},Ya=class extends qa{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}},Xa=or({...Ja,type:nr(`event-emission`),name:q(),params:K(cr($n(sr()),Jn(64))),auth:K(Ka),meta:K(Ga)}),Za=class extends qa{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}},Qa=or({...Ja,type:nr(`service-call-request`),name:q(),params:K(cr($n(sr()),Jn(64))),auth:K(Ka),meta:K(Ga),qos:K(ir([0,1,2]))}),$a=class extends qa{constructor(e,t,n,r,i,a){super(`service-call-response`,e,i,a),this.name=t,this.result=n,this.error=r}},eo=or({...Ja,type:nr(`service-call-response`),name:q(),result:K(sr()),error:K(q())}),to=class extends qa{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}},no=or({...Ja,type:nr(`sink-push-request`),name:q(),params:K(cr($n(sr()),Jn(64))),auth:K(Ka),meta:K(Ga),qos:K(ir([0,1,2]))}),ro=class extends qa{constructor(e,t,n,r,i,a){super(`sink-push-response`,e,r,i),this.name=t,this.error=n,this.credit=a}},io=or({...Ja,type:nr(`sink-push-response`),name:q(),error:K(q()),credit:K(cr(rr(),qn(),Yn(1)))}),ao=class extends qa{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}},oo=or({...Ja,type:nr(`sink-push-chunk`),name:q(),chunk:K(tr(Uint8Array)),error:K(q()),final:K(er())}),so=class extends qa{constructor(e,t,n,r,i){super(`sink-push-credit`,e,r,i),this.name=t,this.credit=n}},co=or({...Ja,type:nr(`sink-push-credit`),name:q(),credit:cr(rr(),qn(),Yn(0))}),lo=class extends qa{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}},uo=or({...Ja,type:nr(`source-fetch-request`),name:q(),params:K(cr($n(sr()),Jn(64))),auth:K(Ka),meta:K(Ga),credit:K(cr(rr(),qn(),Yn(1))),qos:K(ir([0,1,2]))}),fo=class extends qa{constructor(e,t,n,r,i,a){super(`source-fetch-response`,e,r,i),this.name=t,this.error=n,this.meta=a}},po=or({...Ja,type:nr(`source-fetch-response`),name:q(),error:K(q()),meta:K(Ga)}),mo=class extends qa{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}},ho=or({...Ja,type:nr(`source-fetch-chunk`),name:q(),chunk:K(tr(Uint8Array)),error:K(q()),final:K(er())}),go=class extends qa{constructor(e,t,n,r,i){super(`source-fetch-credit`,e,r,i),this.name=t,this.credit=n}},_o=or({...Ja,type:nr(`source-fetch-credit`),name:q(),credit:cr(rr(),qn(),Yn(0))}),vo=class{makeEventEmission(e,t,n,r,i,a,o){return new Ya(e,t,n,r,i,a,o)}makeServiceCallRequest(e,t,n,r,i,a,o,s){return new Za(e,t,n,r,i,a,o,s)}makeServiceCallResponse(e,t,n,r,i,a){return new $a(e,t,n,r,i,a)}makeSinkPushRequest(e,t,n,r,i,a,o,s){return new to(e,t,n,r,i,a,o,s)}makeSinkPushResponse(e,t,n,r,i,a){return new ro(e,t,n,r,i,a)}makeSinkPushChunk(e,t,n,r,i,a,o){return new ao(e,t,n,r,i,a,o)}makeSinkPushCredit(e,t,n,r,i){return new so(e,t,n,r,i)}makeSourceFetchRequest(e,t,n,r,i,a,o,s,c){return new lo(e,t,n,r,i,a,o,s,c)}makeSourceFetchResponse(e,t,n,r,i,a){return new fo(e,t,n,r,i,a)}makeSourceFetchChunk(e,t,n,r,i,a,o){return new mo(e,t,n,r,i,a,o)}makeSourceFetchCredit(e,t,n,r,i){return new go(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:Ba(t[1]);if(Math.floor(n/100)!==Math.floor(Ua/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=lr(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`,Xa);return this.makeEventEmission(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta)}if(e.type===`service-call-request`){let t=r(e,`ServiceCallRequest`,Qa);return this.makeServiceCallRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}if(e.type===`service-call-response`){let t=r(e,`ServiceCallResponse`,eo);return this.makeServiceCallResponse(t.id,t.name,t.result,t.error,t.sender,t.receiver)}if(e.type===`sink-push-request`){let t=r(e,`SinkPushRequest`,no);return this.makeSinkPushRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}if(e.type===`sink-push-response`){let t=r(e,`SinkPushResponse`,io);return this.makeSinkPushResponse(t.id,t.name,t.error,t.sender,t.receiver,t.credit)}if(e.type===`sink-push-chunk`){let t=r(e,`SinkPushChunk`,oo);return this.makeSinkPushChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}if(e.type===`sink-push-credit`){let t=r(e,`SinkPushCredit`,co);return this.makeSinkPushCredit(t.id,t.name,t.credit,t.sender,t.receiver)}if(e.type===`source-fetch-request`){let t=r(e,`SourceFetchRequest`,uo);return this.makeSourceFetchRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.credit,t.qos)}if(e.type===`source-fetch-response`){let t=r(e,`SourceFetchResponse`,po);return this.makeSourceFetchResponse(t.id,t.name,t.error,t.sender,t.receiver,t.meta)}if(e.type===`source-fetch-chunk`){let t=r(e,`SourceFetchChunk`,ho);return this.makeSourceFetchChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}if(e.type===`source-fetch-credit`){let t=r(e,`SourceFetchCredit`,_o);return this.makeSourceFetchCredit(t.id,t.name,t.credit,t.sender,t.receiver)}throw Error(`invalid object: not of any known type`)}isRequest(e){return e instanceof Ya||e instanceof Za||e instanceof lo||e instanceof to}isResponse(e){return e instanceof $a||e instanceof ro||e instanceof ao||e instanceof so||e instanceof fo||e instanceof mo||e instanceof go}},yo=class extends za{constructor(){super(...arguments),this.msg=new vo}},bo=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}: ${Ia.stringify(n)}`}).join(`, `)})`}return`[${t}] ${this.level}: ${n}${r}`}},xo=class extends yo{constructor(){super(...arguments),this._events=new jn.EventEmitter}on(...e){this._events.on(...e)}off(...e){this._events.off(...e)}emitEvent(...e){return this._events.listenerCount(e[0])!==0&&this._events.emit(...e)}log(e,t,n){let r=new bo(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{}}},So=class extends xo{constructor(e,t={}){if(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.options.id===``){let t=e.isFakeProxy?void 0:e.options?.clientId;this.options.id=typeof t==`string`&&t!==``?t:ue()}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=Ce.isBuffer(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t;else{this.error(Error(`invalid codec configured`));return}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=U(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)=>{if(t)this.error(t,`subscribing to MQTT topic "${e}" failed`),r(t);else if(Array.isArray(i)&&i.some(e=>typeof e?.qos==`number`&&e.qos>=128)){let t=Error(`broker rejected subscription to MQTT topic "${e}" (grant codes: ${i.map(e=>e?.qos).join(`, `)})`);this.error(t,`subscribing to MQTT topic "${e}" failed`),r(t)}else 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 Te((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:Ce.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;try{r=this.options.topicMatch(e)}catch(e){this.error(U(e,`failed to match MQTT topic`));return}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(U(e,`failed to parse message into object`));return}let a;try{a=this.msg.parse(i)}catch(e){this.error(U(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 -- dropped message from direct topic "${e}" (expected "${r.peerId}", got "${a.receiver}")`);return}if(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(U(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(U(t,`dispatching response message from MQTT topic "${e}" (type: ${a.type}, id: ${a.id}, name: ${a.name}) failed`))})}}},Co=class{constructor(e,t,n=3e4){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}{let t=this.pending.get(e);if(t)return t}}async unsubscribe(e){if(this.decrementCount(e)===0){if(this.lingerMs>0&&!e.startsWith(`$share/`)){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()}},wo=class extends So{constructor(){super(...arguments),this.subscriptions=new Co((e,t)=>this.subscribeTopic(e,t),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,t,n={}){await Be(`subscribe to MQTT topic "${t}"`,e,()=>this.subscriptions.subscribe(t,{qos:2,...n})),e.roll(()=>this.subscriptions.unsubscribe(t))}async destroy(){await this.subscriptions.flush(),await super.destroy()}},To=class extends wo{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(U(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);typeof i.unref==`function`&&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);typeof o.unref==`function`&&o.unref(),n!==void 0&&a!==void 0&&n.addEventListener(`abort`,()=>{o!==null&&clearTimeout(o),i(Error(`aborted`))},{once:!0,signal:a.signal})})}},Eo=class extends To{constructor(){super(...arguments),this._meta=new Map}meta(...e){let[t,n]=e;if(e.length===0)return Object.fromEntries(this._meta);if(e.length===1)return this._meta.get(t);n==null?this._meta.delete(t):this._meta.set(t,n)}metaStore(e){let t=e===void 0||Object.keys(e).length===0;if(!(this._meta.size===0&&t))return this._meta.size>0&&t?Object.fromEntries(this._meta):this._meta.size===0&&!t?e:{...Object.fromEntries(this._meta),...e}}},Do=new TextEncoder,Oo=class extends Eo{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=Do.encode(e),n=Do.encode(`mqtt-plus`);this._credential=Dn(On,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 _n(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}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 xn(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}},ko=class extends Oo{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 Fe;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=Ne(e.params??[],r);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!==void 0&&(d.authenticated=await this.authenticated(a,e.auth,o,`event "${n}"`)),await r(...s,d)}catch(e){let t=U(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=ue(),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}}:Be(`publish event as MQTT message to topic "${p}"`,()=>this.publishToTopic(p,f,{qos:2,...a}))}},Ao=class extends ko{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 Fe;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=Ne(e.params??[],r);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!==void 0&&(d.authenticated=await this.authenticated(a,e.auth,o,`service "${n}"`));let t=new Promise((e,t)=>{let n=()=>{t(U(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=U(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(U(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 Fe,c=ue();for(let e=0;e<10&&this.onResponse.has(`service-call-response:${c}`);e++)c=ue();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&&(f=!0,s.unroll(!1)?.catch(e=>{this.error(U(e,`cleanup after call of service "${n}" failed`))}),!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 Be(`publish service request as MQTT message to topic "${b}"`,()=>this.publishToTopic(b,y,{...a,qos:_}))}catch(e){return p()&&d(e),m}return m}},jo=class extends Ao{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map,this.sourceSpools=new Map,this.sourceRequests=new Map,this.fetchAborts=new Map}async destroy(){for(let e of this.fetchAborts.values())e(Error(`instance destroyed`));this.fetchAborts.clear();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 Fe;if(this.onRequest.has(`source-fetch-request:${n}`))throw Error(`source: source "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`source-fetch-request`),u=this.options.topicMake(n,`source-fetch-request`,this.options.id);return this.onRequest.set(`source-fetch-request:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=Ne(e.params??[],r),c=e.sender,l=e.receiver,u=new Fe;if(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)}),this.sourceSpools.set(a,u),u.roll(()=>{this.sourceSpools.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))});let v=()=>{},y=()=>{g.stream instanceof ce.Readable&&!g.stream.destroyed&&(g.stream.on(`error`,v),g.stream.destroy(U(h.reason)))};h.addEventListener(`abort`,y,{once:!0}),u.roll(()=>{h.aborted&&y()});let b,x=new Promise((e,t)=>{b=t});x.catch(()=>{});let S=()=>{b(U(h.reason))};h.aborted?S():h.addEventListener(`abort`,S,{once:!0}),u.roll(()=>{h.removeEventListener(`abort`,S)});let C=`source-fetch-send:${a}`,w=()=>{h.aborted||this.timerRefresh(C,()=>{m.abort(Error(`source fetch "${n}" timed out`))})},T=()=>this.timerClear(C);w(),u.roll(()=>{T()});let E=async(t,r,o)=>{w();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})},D=!1,O,k=!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){k=!0,m.abort(Error(`source fetch "${n}" cancelled by fetcher`));return}O&&(O.replenish(e.credit),w())}}}),u.roll(()=>{this.onResponse.delete(`source-fetch-credit:${a}`)}),o!==void 0&&(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,x]),!(g.stream instanceof ce.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 ce.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(O=l!==void 0&&l>0?new Ee(l):void 0,O){let e=O;this.sourceCreditGates.set(a,e),u.roll(()=>{e.abort(),this.sourceCreditGates.delete(a)})}if(await p(void 0,g.meta),D=!0,g.stream instanceof ce.Readable)await Me(g.stream,this.options.chunkSize,E,O,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,x])}else e=g.buffer;h.throwIfAborted(),await je(e,this.options.chunkSize,E,O,h)}}catch(e){let t=U(e,`handler for source "${n}" failed`);m.abort(t),k||(this.error(t),D?await E(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 Fe,c=ue();for(let e=0;e<10&&(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`));e++)c=ue();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:16384,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 Ae({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=U(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)};this.fetchAborts.set(c,D),s.roll(()=>{this.fetchAborts.delete(c)});let O=!1,k=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(U(e,`sending source fetch cancel failed`)))}}_||x(e===void 0?Error(`stream aborted`):U(e)),s.unroll()?.catch(()=>{})};w.once(`close`,()=>k()),w.once(`error`,e=>k(e));let A=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;A(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}A(e)}}}),s.roll(()=>{this.onResponse.delete(`source-fetch-response:${c}`),this.onResponse.delete(`source-fetch-chunk:${c}`)});let ee=this.authenticate(),j=this.metaStore(o),te=d>0?d:void 0,ne=this.msg.makeSourceFetchRequest(c,n,r,this.options.id,i,ee,j,te,a.qos),M=this.codec.encode(ne),re=this.options.topicMake(n,`source-fetch-request`,i);await Be(`publish fetch request as MQTT message to topic "${re}"`,()=>this.publishToTopic(re,M,{qos:2,...a})).catch(e=>{let t=U(e);x(t),w.destroy(t)});let N={stream:w,buffer:E,meta:S};return Pe(N,`stream`,`buffer`,e=>{e===`stream`?w.stopCollecting():e===`buffer`&&w.resume()}),N}},Mo=class extends jo{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 Fe;if(this.onRequest.has(`sink-push-request:${n}`))throw Error(`sink: sink "${n}" already registered`);let c=a===``?n:`$share/${a}/${n}`,l=this.options.topicMake(c,`sink-push-request`),u=this.options.topicMake(n,`sink-push-request`,this.options.id);return this.onRequest.set(`sink-push-request:${n}`,async(e,t)=>{if(e.receiver&&e.receiver!==this.options.id)return;let a=e.id,s=Ne(e.params??[],r),c=e.sender,l=e.receiver,u=new Fe;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=()=>{_(U(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!==void 0&&(_=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:16384,E=!1,D=`sink-push-recv:${a}`,O=()=>this.timerRefresh(D,()=>{if(E||this.destroying)return;let t=Error(`push stream timeout`);h.abort(t),E=!0;let r=this.pushStreams.get(a);if(r!==void 0&&!r.destroyed&&r.destroy(t),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(()=>{})}}),k=()=>this.timerClear(D),A=new Ae({highWaterMark:T,read:t=>{if(!y||!this.pushSpools.has(a))return;let r=y.creditGranted-y.chunksReceived,o=Math.max(0,T-A.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=U(e,`sending sink push credit failed`);this.error(t),A.destroy(t)}),O()}}});C=A,this.pushStreams.set(a,A),u.roll(()=>{this.pushStreams.delete(a)}),A.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(U(e,`sending sink push cancel failed`)))}}),this.onResponse.set(`sink-push-chunk:${a}`,async e=>{if(!E){if(e.name!==n){E=!0,k(),A.destroy(f(e.name));return}if(e.sender===void 0||e.sender===``){E=!0,k(),A.destroy(Error(`sink chunk for "${n}" missing sender`));return}if(e.sender===c){if(e.error!==void 0)E=!0,k(),A.destroy(Error(e.error));else{if(O(),e.chunk!==void 0){if(y){if(y.chunksReceived>=y.creditGranted){E=!0,k(),A.destroy(Error(`flow control violation`));return}y.chunksReceived++}A.destroyed||A.push(e.chunk)}e.final&&(E=!0,k(),A.destroyed||A.push(null))}}}}),u.roll(()=>{this.onResponse.delete(`sink-push-chunk:${a}`)}),O(),u.roll(()=>{k()});let ee=A.buffer,j=!1,te,ne,M=()=>{j||(j=!0,te())},re=()=>{j||(j=!0,E||A.readableEnded?te():ne(Error(`push stream closed before end`)))},N=e=>{j||(j=!0,ne(e))},ie=new Promise((e,t)=>{te=e,ne=t,A.once(`end`,M),A.once(`close`,re),A.once(`error`,N)});ie.finally(()=>{A.removeListener(`end`,M),A.removeListener(`close`,re),A.removeListener(`error`,N)}).catch(()=>{});let ae={sender:c,signal:g,stream:A,buffer:ee};l&&(ae.receiver=l),_!==void 0&&(ae.authenticated=_),e.meta&&(ae.meta=e.meta),Pe(ae,`stream`,`buffer`,e=>{e===`stream`?A.stopCollecting():e===`buffer`&&A.resume()}),await m(void 0,!0),x=!0;let P=Promise.resolve(r(...s,ae));if(P.catch(()=>{}),await Promise.race([P,v]),A.readableFlowing!==!0&&!A.destroyed&&A.resume(),await ie.catch(e=>{throw this.error(U(e),`stream drain after sink "${n}" callback failed`),e}),A.collecting&&A.stopCollecting(),!g.aborted)try{b=!0,await m()}catch(e){this.error(U(e),`sending terminal response for sink "${n}" failed`)}}catch(e){let t=U(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?U(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 ce.Readable)&&!(r instanceof Uint8Array))throw Error(`invalid data type: expected Readable or Uint8Array`);let c=new Fe,l=ue();for(let e=0;e<10&&(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`));e++)l=ue();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 ce.Readable){let e=r,t=()=>{};f.addEventListener(`abort`,()=>{e.destroyed||(e.on(`error`,t),e.destroy(U(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,k=new Promise((e,t)=>{D=e,O=t});k.catch(()=>{});let A=e=>{d.abort(e),b?S||(S=!0,O(e)):(x=!0,te(e))},ee=(e,t)=>{if(t===void 0||t===``){let t=Error(`received ${e} without sender`);return v=t,A(t),!1}if(E===void 0)E=t;else if(t!==E)return!1;return!0},j,te,ne=new Promise((e,t)=>{j=e,te=t});ne.catch(()=>{}),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,A(t);return}if(ee(`sink response`,e.sender)){if(e.error){let t=Error(e.error);v=t,A(t)}else b?S||(w?(S=!0,D()):T=!0):(h=e.credit,b=!0,x=!0,j())}}),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,A(t);return}if(ee(`sink credit`,e.sender)){if(e.credit===0){y=!0;let e=Error(`push to sink "${n}" cancelled by receiver`);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,A(e)}else _+=e.credit}}),c.roll(()=>{this.onResponse.delete(`sink-push-credit:${l}`)});try{let e=()=>{let e=U(f.reason);x||(x=!0,te(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 Be(`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 Ee(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),A=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 ce.Readable?await Me(r,this.options.chunkSize,A,g,f):r instanceof Uint8Array&&await je(r,this.options.chunkSize,A,g,f),w=!0,T&&!S&&(S=!0,D()),m(),S||await k}catch(e){let t=U(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=>{setTimeout(e,0)}),v||e}finally{await c.unroll()}}},No=class extends Mo{};e.MIN_VERSION=Ha,e.VERSION=Va,e.default=No,e.minVersion=Wa,e.version=Ua,e.versionToNum=Ba});
|
|
13
|
+
`,l+=c,l},Sa.noChildren=!0,Q.registerDecoder(Y.CBOR,Sa),Q.registerDecoder(Y.URI,e=>(fa(e.contents),new URL(e.contents)),`URI`),$(URL,e=>[Y.URI,e.toString()]),Q.registerDecoder(Y.BASE64URL,e=>(fa(e.contents),Tr(e.contents)),`Base64url-encoded`),Q.registerDecoder(Y.BASE64,e=>(fa(e.contents),Cr(e.contents)),`Base64-encoded`),Q.registerDecoder(35,e=>(fa(e.contents),new RegExp(e.contents)),`RegExp`),Q.registerDecoder(21065,e=>{fa(e.contents);let t=`^(?:${e.contents})$`;return new RegExp(t,`u`)},`I-RegExp`),Q.registerDecoder(Y.REGEXP,e=>{if(ma(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=>(pa(e.contents),e.contents),`uint8 Typed Array`);function Ca(e,t,n){pa(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 wa(e,t,n,r,i){let a=i.forceEndian??ua;if(ji(a?t:n,e,i),Ai(r.byteLength,e,J.BYTE_STRING),ua===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=>(pa(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)=>wa(t,69,65,e,n)),Q.registerDecoder(70,e=>Ca(e,Uint32Array,!0),`uint32, little endian, Typed Array`),$(Uint32Array,(e,t,n)=>wa(t,70,66,e,n)),Q.registerDecoder(71,e=>Ca(e,BigUint64Array,!0),`uint64, little endian, Typed Array`),$(BigUint64Array,(e,t,n)=>wa(t,71,67,e,n)),Q.registerDecoder(72,e=>(pa(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)=>wa(t,77,73,e,n)),Q.registerDecoder(78,e=>Ca(e,Int32Array,!0),`sint32, little endian, Typed Array`),$(Int32Array,(e,t,n)=>wa(t,78,74,e,n)),Q.registerDecoder(79,e=>Ca(e,BigInt64Array,!0),`sint64, little endian, Typed Array`),$(BigInt64Array,(e,t,n)=>wa(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)=>wa(t,85,81,e,n)),Q.registerDecoder(86,e=>Ca(e,Float64Array,!0),`IEEE 754 binary64, big endian, Typed Array`),$(Float64Array,(e,t,n)=>wa(t,86,82,e,n)),Q.registerDecoder(Y.SET,(e,t)=>{if(ma(e.contents),t.sortKeys){let n=Xi.decodeToEncodeOpts(t),r=null;for(let i of e.contents){let e=[i,void 0,Hi(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,Hi(e,n)]);e.sort(n.sortKeys),r=e.map(([e])=>e)}return[Y.SET,r]}),Q.registerDecoder(Y.JSON,e=>(fa(e.contents),JSON.parse(e.contents)),`JSON-encoded`);function Ta(e){return pa(e.contents),new fi().decode(e.contents)}Ta.comment=e=>{pa(e.contents);let t=new fi;return`(WTF8 string): ${JSON.stringify(t.decode(e.contents))}`},Q.registerDecoder(Y.WTF8,Ta),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(fa(t),!t.length)throw Error(`Expected non-empty string: ${e.contents}`);return Symbol.for(t)},`Symbol`);function Ea(e){throw Error(`Encoding ${e.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}$(ArrayBuffer,Ea),$(DataView,Ea),typeof SharedArrayBuffer<`u`&&$(SharedArrayBuffer,Ea);function Da(e){return[NaN,e.valueOf()]}$(Boolean,Da),$(Number,Da),$(String,Da),$(BigInt,Da);function Oa(e){let t={...Xi.defaultDecodeOptions};if(e.dcbor?Object.assign(t,Xi.dcborDecodeOptions):e.cde&&Object.assign(t,Xi.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,`rejectLongNumbers`))throw TypeError(`rejectLongNumbers has changed to requirePreferred`);return t.boxed&&(t.saveOriginal=!0),t}var ka=class{parent=void 0;ret=void 0;step(e,t,n){if(this.ret=Xi.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 Xi&&(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 Aa(e,t={}){let n=Oa(t),r=new Ki(e,n),i=new ka;for(let e of r)i.step(e,n,r);return i.ret}var{cdeDecodeOptions:ja,dcborDecodeOptions:Ma,defaultDecodeOptions:Na}=Xi,Pa=class{constructor(e={}){if(this.options={id:``,codec:`cbor`,timeout:1e4,share:``,chunkSize:16384,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},!(Number.isFinite(this.options.timeout)&&this.options.timeout>0))throw Error(`options: "timeout" must be a positive number`);if(!(Number.isInteger(this.options.chunkSize)&&this.options.chunkSize>0))throw Error(`options: "chunkSize" must be a positive integer`);if(!(Number.isInteger(this.options.chunkCredit)&&this.options.chunkCredit>=0))throw Error(`options: "chunkCredit" must be a non-negative integer`)}},Fa=class e{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(t){return JSON.stringify(t,function(t,n){let r=this[t];return r instanceof Se?{__Buffer:e.uint8ArrayToBase64(r)}:r instanceof Uint8Array?{__Uint8Array:e.uint8ArrayToBase64(r)}:n})}static parse(e){return JSON.parse(e,(e,t)=>typeof t?.__Buffer==`string`?Se.from(t.__Buffer,`base64`):typeof t?.__Uint8Array==`string`?this.base64ToUint8Array(t.__Uint8Array):t)}},Ia=class{constructor(e){this.format=e,this.types=new Or,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=Hi(e,{types:this.types})}catch(e){throw Error(`failed to encode CBOR format`,{cause:e})}else if(this.format===`json`)try{t=Fa.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=Aa(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=Fa.parse(e)}catch(e){throw Error(`failed to decode JSON format`,{cause:e})}}else throw Error(`invalid format "${this.format}"`);return t}},La=class extends Pa{constructor(e={}){super(e),this.codec=new Ia(this.options.codec)}},Ra=class e extends La{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}},za=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},Ba=za(`1.4`),Va=za(`1.4`),Ha=sr(ir(q(),or()),Gn(e=>!Array.isArray(e))),Ua=sr(Qn(sr(q(),qn(8192))),qn(8)),Wa=class{constructor(e,t,n,r){this.type=e,this.id=t,this.sender=n,this.receiver=r,this.version=`MQTT+/1.4`}},Ga={version:sr(q(),Yn(/^MQTT\+\/\d+\.\d+$/)),type:q(),id:q(),sender:K(q()),receiver:K(q())},Ka=class extends Wa{constructor(e,t,n,r,i,a,o){super(`event-emission`,e,r,i),this.name=t,this.params=n,this.auth=a,this.meta=o}},qa=ar({...Ga,type:tr(`event-emission`),name:q(),params:K(sr(Qn(or()),qn(64))),auth:K(Ua),meta:K(Ha)}),Ja=class extends Wa{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}},Ya=ar({...Ga,type:tr(`service-call-request`),name:q(),params:K(sr(Qn(or()),qn(64))),auth:K(Ua),meta:K(Ha),qos:K(rr([0,1,2]))}),Xa=class extends Wa{constructor(e,t,n,r,i,a){super(`service-call-response`,e,i,a),this.name=t,this.result=n,this.error=r}},Za=ar({...Ga,type:tr(`service-call-response`),name:q(),result:K(or()),error:K(q())}),Qa=class extends Wa{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}},$a=ar({...Ga,type:tr(`sink-push-request`),name:q(),params:K(sr(Qn(or()),qn(64))),auth:K(Ua),meta:K(Ha),qos:K(rr([0,1,2]))}),eo=class extends Wa{constructor(e,t,n,r,i,a){super(`sink-push-response`,e,r,i),this.name=t,this.error=n,this.credit=a}},to=ar({...Ga,type:tr(`sink-push-response`),name:q(),error:K(q()),credit:K(sr(nr(),Kn(),Jn(1)))}),no=class extends Wa{constructor(e,t,n,r,i,a,o){super(`sink-push-chunk`,e,a,o),this.name=t,this.chunk=n,this.error=r,this.final=i}},ro=ar({...Ga,type:tr(`sink-push-chunk`),name:q(),chunk:K(er(Uint8Array)),error:K(q()),final:K($n())}),io=class extends Wa{constructor(e,t,n,r,i){super(`sink-push-credit`,e,r,i),this.name=t,this.credit=n}},ao=ar({...Ga,type:tr(`sink-push-credit`),name:q(),credit:sr(nr(),Kn(),Jn(0))}),oo=class extends Wa{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}},so=ar({...Ga,type:tr(`source-fetch-request`),name:q(),params:K(sr(Qn(or()),qn(64))),auth:K(Ua),meta:K(Ha),credit:K(sr(nr(),Kn(),Jn(1))),qos:K(rr([0,1,2]))}),co=class extends Wa{constructor(e,t,n,r,i,a){super(`source-fetch-response`,e,r,i),this.name=t,this.error=n,this.meta=a}},lo=ar({...Ga,type:tr(`source-fetch-response`),name:q(),error:K(q()),meta:K(Ha)}),uo=class extends Wa{constructor(e,t,n,r,i,a,o){super(`source-fetch-chunk`,e,a,o),this.name=t,this.chunk=n,this.error=r,this.final=i}},fo=ar({...Ga,type:tr(`source-fetch-chunk`),name:q(),chunk:K(er(Uint8Array)),error:K(q()),final:K($n())}),po=class extends Wa{constructor(e,t,n,r,i){super(`source-fetch-credit`,e,r,i),this.name=t,this.credit=n}},mo=ar({...Ga,type:tr(`source-fetch-credit`),name:q(),credit:sr(nr(),Kn(),Jn(0))}),ho=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 Xa(e,t,n,r,i,a)}makeSinkPushRequest(e,t,n,r,i,a,o,s){return new Qa(e,t,n,r,i,a,o,s)}makeSinkPushResponse(e,t,n,r,i,a){return new eo(e,t,n,r,i,a)}makeSinkPushChunk(e,t,n,r,i,a,o){return new no(e,t,n,r,i,a,o)}makeSinkPushCredit(e,t,n,r,i){return new io(e,t,n,r,i)}makeSourceFetchRequest(e,t,n,r,i,a,o,s,c){return new oo(e,t,n,r,i,a,o,s,c)}makeSourceFetchResponse(e,t,n,r,i,a){return new co(e,t,n,r,i,a)}makeSourceFetchChunk(e,t,n,r,i,a,o){return new uo(e,t,n,r,i,a,o)}makeSourceFetchCredit(e,t,n,r,i){return new po(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:za(t[1]);if(Math.floor(n/100)!==Math.floor(Ba/100)||n<Va)throw Error(`protocol version mismatch (expected version 1.4...1.4, got version ${e.version})`);let r=(e,t,n)=>{let r=cr(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`,qa);return this.makeEventEmission(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta)}if(e.type===`service-call-request`){let t=r(e,`ServiceCallRequest`,Ya);return this.makeServiceCallRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}if(e.type===`service-call-response`){let t=r(e,`ServiceCallResponse`,Za);return this.makeServiceCallResponse(t.id,t.name,t.result,t.error,t.sender,t.receiver)}if(e.type===`sink-push-request`){let t=r(e,`SinkPushRequest`,$a);return this.makeSinkPushRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.qos)}if(e.type===`sink-push-response`){let t=r(e,`SinkPushResponse`,to);return this.makeSinkPushResponse(t.id,t.name,t.error,t.sender,t.receiver,t.credit)}if(e.type===`sink-push-chunk`){let t=r(e,`SinkPushChunk`,ro);return this.makeSinkPushChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}if(e.type===`sink-push-credit`){let t=r(e,`SinkPushCredit`,ao);return this.makeSinkPushCredit(t.id,t.name,t.credit,t.sender,t.receiver)}if(e.type===`source-fetch-request`){let t=r(e,`SourceFetchRequest`,so);return this.makeSourceFetchRequest(t.id,t.name,t.params,t.sender,t.receiver,t.auth,t.meta,t.credit,t.qos)}if(e.type===`source-fetch-response`){let t=r(e,`SourceFetchResponse`,lo);return this.makeSourceFetchResponse(t.id,t.name,t.error,t.sender,t.receiver,t.meta)}if(e.type===`source-fetch-chunk`){let t=r(e,`SourceFetchChunk`,fo);return this.makeSourceFetchChunk(t.id,t.name,t.chunk,t.error,t.final,t.sender,t.receiver)}if(e.type===`source-fetch-credit`){let t=r(e,`SourceFetchCredit`,mo);return this.makeSourceFetchCredit(t.id,t.name,t.credit,t.sender,t.receiver)}throw Error(`invalid object: not of any known type`)}isRequest(e){return e instanceof Ka||e instanceof Ja||e instanceof oo||e instanceof Qa}isResponse(e){return e instanceof Xa||e instanceof eo||e instanceof no||e instanceof io||e instanceof co||e instanceof uo||e instanceof po}},go=class extends Ra{constructor(){super(...arguments),this.msg=new ho}},_o=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}: ${Fa.stringify(n)}`}).join(`, `)})`}return`[${t}] ${this.level}: ${n}${r}`}},vo=class extends go{constructor(){super(...arguments),this._events=new kn.EventEmitter}on(...e){this._events.on(...e)}off(...e){this._events.off(...e)}emitEvent(...e){return this._events.listenerCount(e[0])!==0&&this._events.emit(...e)}log(e,t,n){let r=new _o(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{}}},yo=class extends vo{constructor(e,t={}){if(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.options.id===``){let t=e.isFakeProxy?void 0:e.options?.clientId;this.options.id=typeof t==`string`&&t!==``?t:L()}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{this.error(Error(`invalid codec configured`));return}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)=>{if(t)this.error(t,`subscribing to MQTT topic "${e}" failed`),r(t);else if(Array.isArray(i)&&i.some(e=>typeof e?.qos==`number`&&e.qos>=128)){let t=Error(`broker rejected subscription to MQTT topic "${e}" (grant codes: ${i.map(e=>e?.qos).join(`, `)})`);this.error(t,`subscribing to MQTT topic "${e}" failed`),r(t)}else 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;try{r=this.options.topicMatch(e)}catch(e){this.error(W(e,`failed to match MQTT topic`));return}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 -- dropped message from direct topic "${e}" (expected "${r.peerId}", got "${a.receiver}")`);return}if(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`))})}}},bo=class{constructor(e,t,n=3e4){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}{let t=this.pending.get(e);if(t)return t}}async unsubscribe(e){if(this.decrementCount(e)===0){if(this.lingerMs>0&&!e.startsWith(`$share/`)){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()}},xo=class extends yo{constructor(){super(...arguments),this.subscriptions=new bo((e,t)=>this.subscribeTopic(e,t),e=>this.unsubscribeTopic(e))}async subscribeTopicAndSpool(e,t,n={}){await Re(`subscribe to MQTT topic "${t}"`,e,()=>this.subscriptions.subscribe(t,{qos:2,...n})),e.roll(()=>this.subscriptions.unsubscribe(t))}async destroy(){await this.subscriptions.flush(),await super.destroy()}},So=class extends xo{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);typeof i.unref==`function`&&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);typeof o.unref==`function`&&o.unref(),n!==void 0&&a!==void 0&&n.addEventListener(`abort`,()=>{o!==null&&clearTimeout(o),i(Error(`aborted`))},{once:!0,signal:a.signal})})}},Co=class extends So{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}}},wo=new TextEncoder,To=class extends Co{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=wo.encode(e),n=wo.encode(`mqtt-plus`);this._credential=Tn(En,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 hn(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}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 yn(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}},Eo=class extends To{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 Ne;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=je(e.params??[],r);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!==void 0&&(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=L(),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}}:Re(`publish event as MQTT message to topic "${p}"`,()=>this.publishToTopic(p,f,{qos:2,...a}))}},Do=class extends Eo{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 Ne;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=je(e.params??[],r);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!==void 0&&(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 Ne,c=L();for(let e=0;e<10&&this.onResponse.has(`service-call-response:${c}`);e++)c=L();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&&(f=!0,s.unroll(!1)?.catch(e=>{this.error(W(e,`cleanup after call of service "${n}" failed`))}),!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 Re(`publish service request as MQTT message to topic "${b}"`,()=>this.publishToTopic(b,y,{...a,qos:_}))}catch(e){return p()&&d(e),m}return m}},Oo=class extends Do{constructor(){super(...arguments),this.sourceCreditGates=new Map,this.sourceControllers=new Map,this.sourceSpools=new Map,this.sourceRequests=new Map,this.fetchAborts=new Map}async destroy(){for(let e of this.fetchAborts.values())e(Error(`instance destroyed`));this.fetchAborts.clear();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 Ne;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=je(e.params??[],r),c=e.sender,l=e.receiver,u=new Ne;if(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)}),this.sourceSpools.set(a,u),u.roll(()=>{this.sourceSpools.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))});let v=()=>{},y=()=>{g.stream instanceof ce.Readable&&!g.stream.destroyed&&(g.stream.on(`error`,v),g.stream.destroy(W(h.reason)))};h.addEventListener(`abort`,y,{once:!0}),u.roll(()=>{h.aborted&&y()});let b,x=new Promise((e,t)=>{b=t});x.catch(()=>{});let S=()=>{b(W(h.reason))};h.aborted?S():h.addEventListener(`abort`,S,{once:!0}),u.roll(()=>{h.removeEventListener(`abort`,S)});let C=`source-fetch-send:${a}`,w=()=>{h.aborted||this.timerRefresh(C,()=>{m.abort(Error(`source fetch "${n}" timed out`))})},T=()=>this.timerClear(C);w(),u.roll(()=>{T()});let E=async(t,r,o)=>{w();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})},D=!1,O,ee=!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){ee=!0,m.abort(Error(`source fetch "${n}" cancelled by fetcher`));return}O&&(O.replenish(e.credit),w())}}}),u.roll(()=>{this.onResponse.delete(`source-fetch-credit:${a}`)}),o!==void 0&&(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,x]),!(g.stream instanceof ce.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 ce.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(O=l!==void 0&&l>0?new we(l):void 0,O){let e=O;this.sourceCreditGates.set(a,e),u.roll(()=>{e.abort(),this.sourceCreditGates.delete(a)})}if(await p(void 0,g.meta),D=!0,g.stream instanceof ce.Readable)await Ae(g.stream,this.options.chunkSize,E,O,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,x])}else e=g.buffer;h.throwIfAborted(),await ke(e,this.options.chunkSize,E,O,h)}}catch(e){let t=W(e,`handler for source "${n}" failed`);m.abort(t),ee||(this.error(t),D?await E(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 Ne,c=L();for(let e=0;e<10&&(this.onResponse.has(`source-fetch-response:${c}`)||this.onResponse.has(`source-fetch-chunk:${c}`));e++)c=L();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:16384,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 Oe({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=W(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)};this.fetchAborts.set(c,D),s.roll(()=>{this.fetchAborts.delete(c)});let 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(W(e,`sending source fetch cancel failed`)))}}_||x(e===void 0?Error(`stream aborted`):W(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(),ne=this.metaStore(o),re=d>0?d:void 0,A=this.msg.makeSourceFetchRequest(c,n,r,this.options.id,i,te,ne,re,a.qos),ie=this.codec.encode(A),j=this.options.topicMake(n,`source-fetch-request`,i);await Re(`publish fetch request as MQTT message to topic "${j}"`,()=>this.publishToTopic(j,ie,{qos:2,...a})).catch(e=>{let t=W(e);x(t),w.destroy(t)});let M={stream:w,buffer:E,meta:S};return Me(M,`stream`,`buffer`,e=>{e===`stream`?w.stopCollecting():e===`buffer`&&w.resume()}),M}},ko=class extends Oo{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 Ne;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=je(e.params??[],r),c=e.sender,l=e.receiver,u=new Ne;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,C,w=()=>{};try{if(t!==e.name)throw Error(`sink name mismatch (topic: "${t}", payload: "${e.name}")`);let _;o!==void 0&&(_=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:16384,E=!1,D=`sink-push-recv:${a}`,O=()=>this.timerRefresh(D,()=>{if(E||this.destroying)return;let t=Error(`push stream timeout`);h.abort(t),E=!0;let r=this.pushStreams.get(a);if(r!==void 0&&!r.destroyed&&r.destroy(t),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 Oe({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=W(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(W(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,ne=!1,re,A,ie=()=>{ne||(ne=!0,re())},j=()=>{ne||(ne=!0,E||k.readableEnded?re():A(Error(`push stream closed before end`)))},M=e=>{ne||(ne=!0,A(e))},ae=new Promise((e,t)=>{re=e,A=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),Me(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(W(e),`stream drain after sink "${n}" callback failed`),e}),k.collecting&&k.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(),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 ce.Readable)&&!(r instanceof Uint8Array))throw Error(`invalid data type: expected Readable or Uint8Array`);let c=new Ne,l=L();for(let e=0;e<10&&(this.onResponse.has(`sink-push-response:${l}`)||this.onResponse.has(`sink-push-credit:${l}`));e++)l=L();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 ce.Readable){let e=r,t=()=>{};f.addEventListener(`abort`,()=>{e.destroyed||(e.on(`error`,t),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,C=!1,w=!1,T=!1,E=a,D,O,ee=new Promise((e,t)=>{D=e,O=t});ee.catch(()=>{});let k=e=>{d.abort(e),b?S||(S=!0,O(e)):(x=!0,re(e))},te=(e,t)=>{if(t===void 0||t===``){let t=Error(`received ${e} without sender`);return v=t,k(t),!1}if(E===void 0)E=t;else if(t!==E)return!1;return!0},ne,re,A=new Promise((e,t)=>{ne=e,re=t});A.catch(()=>{}),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,k(t);return}if(te(`sink response`,e.sender)){if(e.error){let t=Error(e.error);v=t,k(t)}else b?S||(w?(S=!0,D()):T=!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,k(t);return}if(te(`sink credit`,e.sender)){if(e.credit===0){y=!0;let e=Error(`push to sink "${n}" cancelled by receiver`);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,k(e)}else _+=e.credit}}),c.roll(()=>{this.onResponse.delete(`sink-push-credit:${l}`)});try{let e=()=>{let e=W(f.reason);x||(x=!0,re(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 Re(`publish push request as MQTT message to topic "${v}"`,()=>this.publishToTopic(v,p,{qos:2,...o})),await A,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=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 ce.Readable?await Ae(r,this.options.chunkSize,k,g,f):r instanceof Uint8Array&&await ke(r,this.options.chunkSize,k,g,f),w=!0,T&&!S&&(S=!0,D()),m(),S||await ee}catch(e){let t=W(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=>{setTimeout(e,0)}),v||e}finally{await c.unroll()}}};return class extends ko{static{this.VERSION=`1.4`}static{this.MIN_VERSION=`1.4`}static{this.version=Ba}static{this.minVersion=Va}static{this.versionToNum=za}}});
|