@web3auth/metamask-adapter
Version:
metamask wallet adapter for web3auth
2 lines • 455 kB
JavaScript
/*! For license information please see metamaskAdapter.umd.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MetamaskAdapter=t():e.MetamaskAdapter=t()}(self,(()=>(()=>{var e={2389:e=>{"use strict";e.exports=function({mustBeMetaMask:e=!1,silent:t=!1,timeout:r=3e3}={}){!function(){if("boolean"!=typeof e)throw new Error("@metamask/detect-provider: Expected option 'mustBeMetaMask' to be a boolean.");if("boolean"!=typeof t)throw new Error("@metamask/detect-provider: Expected option 'silent' to be a boolean.");if("number"!=typeof r)throw new Error("@metamask/detect-provider: Expected option 'timeout' to be a number.")}();let n=!1;return new Promise((i=>{function o(){if(n)return;n=!0,window.removeEventListener("ethereum#initialized",o);const{ethereum:r}=window;if(!r||e&&!r.isMetaMask){const n=e&&r?"Non-MetaMask window.ethereum detected.":"Unable to detect window.ethereum.";!t&&console.error("@metamask/detect-provider:",n),i(null)}else i(r)}window.ethereum?o():(window.addEventListener("ethereum#initialized",o,{once:!0}),setTimeout((()=>{o()}),r))}))}},8266:(e,t,r)=>{"use strict";const{SymbolDispose:n}=r(4545),{AbortError:i,codes:o}=r(6974),{isNodeStream:s,isWebStream:a,kControllerErrorFunction:f}=r(7192),c=r(4501),{ERR_INVALID_ARG_TYPE:u}=o;let d;e.exports.addAbortSignal=function(t,r){if((e=>{if("object"!=typeof e||!("aborted"in e))throw new u("signal","AbortSignal",e)})(t),!s(r)&&!a(r))throw new u("stream",["ReadableStream","WritableStream","Stream"],r);return e.exports.addAbortSignalNoValidate(t,r)},e.exports.addAbortSignalNoValidate=function(e,t){if("object"!=typeof e||!("aborted"in e))return t;const o=s(t)?()=>{t.destroy(new i(void 0,{cause:e.reason}))}:()=>{t[f](new i(void 0,{cause:e.reason}))};if(e.aborted)o();else{d=d||r(8577).addAbortListener;const i=d(e,o);c(t,i[n])}return t}},6738:(e,t,r)=>{"use strict";const{StringPrototypeSlice:n,SymbolIterator:i,TypedArrayPrototypeSet:o,Uint8Array:s}=r(4545),{Buffer:a}=r(1429),{inspect:f}=r(8577);e.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){const t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}unshift(e){const t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}shift(){if(0===this.length)return;const e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(0===this.length)return"";let t=this.head,r=""+t.data;for(;null!==(t=t.next);)r+=e+t.data;return r}concat(e){if(0===this.length)return a.alloc(0);const t=a.allocUnsafe(e>>>0);let r=this.head,n=0;for(;r;)o(t,r.data,n),n+=r.data.length,r=r.next;return t}consume(e,t){const r=this.head.data;if(e<r.length){const t=r.slice(0,e);return this.head.data=r.slice(e),t}return e===r.length?this.shift():t?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[i](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let t="",r=this.head,i=0;do{const o=r.data;if(!(e>o.length)){e===o.length?(t+=o,++i,r.next?this.head=r.next:this.head=this.tail=null):(t+=n(o,0,e),this.head=r,r.data=n(o,e));break}t+=o,e-=o.length,++i}while(null!==(r=r.next));return this.length-=i,t}_getBuffer(e){const t=a.allocUnsafe(e),r=e;let n=this.head,i=0;do{const a=n.data;if(!(e>a.length)){e===a.length?(o(t,a,r-e),++i,n.next?this.head=n.next:this.head=this.tail=null):(o(t,new s(a.buffer,a.byteOffset,e),r-e),this.head=n,n.data=a.slice(e));break}o(t,a,r-e),e-=a.length,++i}while(null!==(n=n.next));return this.length-=i,t}[Symbol.for("nodejs.util.inspect.custom")](e,t){return f(this,{...t,depth:0,customInspect:!1})}}},8217:(e,t,r)=>{"use strict";const{pipeline:n}=r(831),i=r(8599),{destroyer:o}=r(1167),{isNodeStream:s,isReadable:a,isWritable:f,isWebStream:c,isTransformStream:u,isWritableStream:d,isReadableStream:l}=r(7192),{AbortError:h,codes:{ERR_INVALID_ARG_VALUE:p,ERR_MISSING_ARGS:b}}=r(6974),g=r(4501);e.exports=function(...e){if(0===e.length)throw new b("streams");if(1===e.length)return i.from(e[0]);const t=[...e];if("function"==typeof e[0]&&(e[0]=i.from(e[0])),"function"==typeof e[e.length-1]){const t=e.length-1;e[t]=i.from(e[t])}for(let r=0;r<e.length;++r)if(s(e[r])||c(e[r])){if(r<e.length-1&&!(a(e[r])||l(e[r])||u(e[r])))throw new p(`streams[${r}]`,t[r],"must be readable");if(r>0&&!(f(e[r])||d(e[r])||u(e[r])))throw new p(`streams[${r}]`,t[r],"must be writable")}let r,y,m,w,v;const _=e[0],S=n(e,(function(e){const t=w;w=null,t?t(e):e?v.destroy(e):A||E||v.destroy()})),E=!!(f(_)||d(_)||u(_)),A=!!(a(S)||l(S)||u(S));if(v=new i({writableObjectMode:!(null==_||!_.writableObjectMode),readableObjectMode:!(null==S||!S.readableObjectMode),writable:E,readable:A}),E){if(s(_))v._write=function(e,t,n){_.write(e,t)?n():r=n},v._final=function(e){_.end(),y=e},_.on("drain",(function(){if(r){const e=r;r=null,e()}}));else if(c(_)){const e=(u(_)?_.writable:_).getWriter();v._write=async function(t,r,n){try{await e.ready,e.write(t).catch((()=>{})),n()}catch(e){n(e)}},v._final=async function(t){try{await e.ready,e.close().catch((()=>{})),y=t}catch(e){t(e)}}}const e=u(S)?S.readable:S;g(e,(()=>{if(y){const e=y;y=null,e()}}))}if(A)if(s(S))S.on("readable",(function(){if(m){const e=m;m=null,e()}})),S.on("end",(function(){v.push(null)})),v._read=function(){for(;;){const e=S.read();if(null===e)return void(m=v._read);if(!v.push(e))return}};else if(c(S)){const e=(u(S)?S.readable:S).getReader();v._read=async function(){for(;;)try{const{value:t,done:r}=await e.read();if(!v.push(t))return;if(r)return void v.push(null)}catch{return}}}return v._destroy=function(e,t){e||null===w||(e=new h),m=null,r=null,y=null,null===w?t(e):(w=t,s(S)&&o(S,e))},v}},1167:(e,t,r)=>{"use strict";const n=r(3184),{aggregateTwoErrors:i,codes:{ERR_MULTIPLE_CALLBACK:o},AbortError:s}=r(6974),{Symbol:a}=r(4545),{kIsDestroyed:f,isDestroyed:c,isFinished:u,isServerRequest:d}=r(7192),l=a("kDestroy"),h=a("kConstruct");function p(e,t,r){e&&(e.stack,t&&!t.errored&&(t.errored=e),r&&!r.errored&&(r.errored=e))}function b(e,t,r){let i=!1;function o(t){if(i)return;i=!0;const o=e._readableState,s=e._writableState;p(t,s,o),s&&(s.closed=!0),o&&(o.closed=!0),"function"==typeof r&&r(t),t?n.nextTick(g,e,t):n.nextTick(y,e)}try{e._destroy(t||null,o)}catch(t){o(t)}}function g(e,t){m(e,t),y(e)}function y(e){const t=e._readableState,r=e._writableState;r&&(r.closeEmitted=!0),t&&(t.closeEmitted=!0),(null!=r&&r.emitClose||null!=t&&t.emitClose)&&e.emit("close")}function m(e,t){const r=e._readableState,n=e._writableState;null!=n&&n.errorEmitted||null!=r&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),e.emit("error",t))}function w(e,t,r){const i=e._readableState,o=e._writableState;if(null!=o&&o.destroyed||null!=i&&i.destroyed)return this;null!=i&&i.autoDestroy||null!=o&&o.autoDestroy?e.destroy(t):t&&(t.stack,o&&!o.errored&&(o.errored=t),i&&!i.errored&&(i.errored=t),r?n.nextTick(m,e,t):m(e,t))}function v(e){let t=!1;function r(r){if(t)return void w(e,null!=r?r:new o);t=!0;const i=e._readableState,s=e._writableState,a=s||i;i&&(i.constructed=!0),s&&(s.constructed=!0),a.destroyed?e.emit(l,r):r?w(e,r,!0):n.nextTick(_,e)}try{e._construct((e=>{n.nextTick(r,e)}))}catch(e){n.nextTick(r,e)}}function _(e){e.emit(h)}function S(e){return(null==e?void 0:e.setHeader)&&"function"==typeof e.abort}function E(e){e.emit("close")}function A(e,t){e.emit("error",t),n.nextTick(E,e)}e.exports={construct:function(e,t){if("function"!=typeof e._construct)return;const r=e._readableState,i=e._writableState;r&&(r.constructed=!1),i&&(i.constructed=!1),e.once(h,t),e.listenerCount(h)>1||n.nextTick(v,e)},destroyer:function(e,t){e&&!c(e)&&(t||u(e)||(t=new s),d(e)?(e.socket=null,e.destroy(t)):S(e)?e.abort():S(e.req)?e.req.abort():"function"==typeof e.destroy?e.destroy(t):"function"==typeof e.close?e.close():t?n.nextTick(A,e,t):n.nextTick(E,e),e.destroyed||(e[f]=!0))},destroy:function(e,t){const r=this._readableState,n=this._writableState,o=n||r;return null!=n&&n.destroyed||null!=r&&r.destroyed?("function"==typeof t&&t(),this):(p(e,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),o.constructed?b(this,e,t):this.once(l,(function(r){b(this,i(r,e),t)})),this)},undestroy:function(){const e=this._readableState,t=this._writableState;e&&(e.constructed=!0,e.closed=!1,e.closeEmitted=!1,e.destroyed=!1,e.errored=null,e.errorEmitted=!1,e.reading=!1,e.ended=!1===e.readable,e.endEmitted=!1===e.readable),t&&(t.constructed=!0,t.destroyed=!1,t.closed=!1,t.closeEmitted=!1,t.errored=null,t.errorEmitted=!1,t.finalCalled=!1,t.prefinished=!1,t.ended=!1===t.writable,t.ending=!1===t.writable,t.finished=!1===t.writable)},errorOrDestroy:w}},8599:(e,t,r)=>{"use strict";const{ObjectDefineProperties:n,ObjectGetOwnPropertyDescriptor:i,ObjectKeys:o,ObjectSetPrototypeOf:s}=r(4545);e.exports=c;const a=r(7077),f=r(9349);s(c.prototype,a.prototype),s(c,a);{const e=o(f.prototype);for(let t=0;t<e.length;t++){const r=e[t];c.prototype[r]||(c.prototype[r]=f.prototype[r])}}function c(e){if(!(this instanceof c))return new c(e);a.call(this,e),f.call(this,e),e?(this.allowHalfOpen=!1!==e.allowHalfOpen,!1===e.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===e.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}let u,d;function l(){return void 0===u&&(u={}),u}n(c.prototype,{writable:{__proto__:null,...i(f.prototype,"writable")},writableHighWaterMark:{__proto__:null,...i(f.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...i(f.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...i(f.prototype,"writableBuffer")},writableLength:{__proto__:null,...i(f.prototype,"writableLength")},writableFinished:{__proto__:null,...i(f.prototype,"writableFinished")},writableCorked:{__proto__:null,...i(f.prototype,"writableCorked")},writableEnded:{__proto__:null,...i(f.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...i(f.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set(e){this._readableState&&this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}}),c.fromWeb=function(e,t){return l().newStreamDuplexFromReadableWritablePair(e,t)},c.toWeb=function(e){return l().newReadableWritablePairFromDuplex(e)},c.from=function(e){return d||(d=r(9141)),d(e,"body")}},9141:(e,t,r)=>{const n=r(3184),i=r(1429),{isReadable:o,isWritable:s,isIterable:a,isNodeStream:f,isReadableNodeStream:c,isWritableNodeStream:u,isDuplexNodeStream:d,isReadableStream:l,isWritableStream:h}=r(7192),p=r(4501),{AbortError:b,codes:{ERR_INVALID_ARG_TYPE:g,ERR_INVALID_RETURN_VALUE:y}}=r(6974),{destroyer:m}=r(1167),w=r(8599),v=r(7077),_=r(9349),{createDeferredPromise:S}=r(8577),E=r(3597),A=globalThis.Blob||i.Blob,M=void 0!==A?function(e){return e instanceof A}:function(e){return!1},R=globalThis.AbortController||r(1630).AbortController,{FunctionPrototypeCall:x}=r(4545);class I extends w{constructor(e){super(e),!1===(null==e?void 0:e.readable)&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===(null==e?void 0:e.writable)&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}}function k(e){const t=e.readable&&"function"!=typeof e.readable.read?v.wrap(e.readable):e.readable,r=e.writable;let n,i,a,f,c,u=!!o(t),d=!!s(r);function l(e){const t=f;f=null,t?t(e):e&&c.destroy(e)}return c=new I({readableObjectMode:!(null==t||!t.readableObjectMode),writableObjectMode:!(null==r||!r.writableObjectMode),readable:u,writable:d}),d&&(p(r,(e=>{d=!1,e&&m(t,e),l(e)})),c._write=function(e,t,i){r.write(e,t)?i():n=i},c._final=function(e){r.end(),i=e},r.on("drain",(function(){if(n){const e=n;n=null,e()}})),r.on("finish",(function(){if(i){const e=i;i=null,e()}}))),u&&(p(t,(e=>{u=!1,e&&m(t,e),l(e)})),t.on("readable",(function(){if(a){const e=a;a=null,e()}})),t.on("end",(function(){c.push(null)})),c._read=function(){for(;;){const e=t.read();if(null===e)return void(a=c._read);if(!c.push(e))return}}),c._destroy=function(e,o){e||null===f||(e=new b),a=null,n=null,i=null,null===f?o(e):(f=o,m(r,e),m(t,e))},c}e.exports=function e(t,r){if(d(t))return t;if(c(t))return k({readable:t});if(u(t))return k({writable:t});if(f(t))return k({writable:!1,readable:!1});if(l(t))return k({readable:v.fromWeb(t)});if(h(t))return k({writable:_.fromWeb(t)});if("function"==typeof t){const{value:e,write:i,final:o,destroy:s}=function(e){let{promise:t,resolve:r}=S();const i=new R,o=i.signal;return{value:e(async function*(){for(;;){const e=t;t=null;const{chunk:i,done:s,cb:a}=await e;if(n.nextTick(a),s)return;if(o.aborted)throw new b(void 0,{cause:o.reason});({promise:t,resolve:r}=S()),yield i}}(),{signal:o}),write(e,t,n){const i=r;r=null,i({chunk:e,done:!1,cb:n})},final(e){const t=r;r=null,t({done:!0,cb:e})},destroy(e,t){i.abort(),t(e)}}}(t);if(a(e))return E(I,e,{objectMode:!0,write:i,final:o,destroy:s});const f=null==e?void 0:e.then;if("function"==typeof f){let t;const r=x(f,e,(e=>{if(null!=e)throw new y("nully","body",e)}),(e=>{m(t,e)}));return t=new I({objectMode:!0,readable:!1,write:i,final(e){o((async()=>{try{await r,n.nextTick(e,null)}catch(t){n.nextTick(e,t)}}))},destroy:s})}throw new y("Iterable, AsyncIterable or AsyncFunction",r,e)}if(M(t))return e(t.arrayBuffer());if(a(t))return E(I,t,{objectMode:!0,writable:!1});if(l(null==t?void 0:t.readable)&&h(null==t?void 0:t.writable))return I.fromWeb(t);if("object"==typeof(null==t?void 0:t.writable)||"object"==typeof(null==t?void 0:t.readable))return k({readable:null!=t&&t.readable?c(null==t?void 0:t.readable)?null==t?void 0:t.readable:e(t.readable):void 0,writable:null!=t&&t.writable?u(null==t?void 0:t.writable)?null==t?void 0:t.writable:e(t.writable):void 0});const i=null==t?void 0:t.then;if("function"==typeof i){let e;return x(i,t,(t=>{null!=t&&e.push(t),e.push(null)}),(t=>{m(e,t)})),e=new I({objectMode:!0,writable:!1,read(){}})}throw new g(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],t)}},4501:(e,t,r)=>{const n=r(3184),{AbortError:i,codes:o}=r(6974),{ERR_INVALID_ARG_TYPE:s,ERR_STREAM_PREMATURE_CLOSE:a}=o,{kEmptyObject:f,once:c}=r(8577),{validateAbortSignal:u,validateFunction:d,validateObject:l,validateBoolean:h}=r(9984),{Promise:p,PromisePrototypeThen:b,SymbolDispose:g}=r(4545),{isClosed:y,isReadable:m,isReadableNodeStream:w,isReadableStream:v,isReadableFinished:_,isReadableErrored:S,isWritable:E,isWritableNodeStream:A,isWritableStream:M,isWritableFinished:R,isWritableErrored:x,isNodeStream:I,willEmitClose:k,kIsClosedPromise:O}=r(7192);let N;const P=()=>{};function T(e,t,o){var h,p;if(2===arguments.length?(o=t,t=f):null==t?t=f:l(t,"options"),d(o,"callback"),u(t.signal,"options.signal"),o=c(o),v(e)||M(e))return function(e,t,o){let s=!1,a=P;if(t.signal)if(a=()=>{s=!0,o.call(e,new i(void 0,{cause:t.signal.reason}))},t.signal.aborted)n.nextTick(a);else{N=N||r(8577).addAbortListener;const n=N(t.signal,a),i=o;o=c(((...t)=>{n[g](),i.apply(e,t)}))}const f=(...t)=>{s||n.nextTick((()=>o.apply(e,t)))};return b(e[O].promise,f,f),P}(e,t,o);if(!I(e))throw new s("stream",["ReadableStream","WritableStream","Stream"],e);const T=null!==(h=t.readable)&&void 0!==h?h:w(e),B=null!==(p=t.writable)&&void 0!==p?p:A(e),C=e._writableState,L=e._readableState,j=()=>{e.writable||D()};let F=k(e)&&w(e)===T&&A(e)===B,U=R(e,!1);const D=()=>{U=!0,e.destroyed&&(F=!1),(!F||e.readable&&!T)&&(T&&!q||o.call(e))};let q=_(e,!1);const z=()=>{q=!0,e.destroyed&&(F=!1),(!F||e.writable&&!B)&&(B&&!U||o.call(e))},W=t=>{o.call(e,t)};let $=y(e);const H=()=>{$=!0;const t=x(e)||S(e);return t&&"boolean"!=typeof t?o.call(e,t):T&&!q&&w(e,!0)&&!_(e,!1)?o.call(e,new a):!B||U||R(e,!1)?void o.call(e):o.call(e,new a)},V=()=>{$=!0;const t=x(e)||S(e);if(t&&"boolean"!=typeof t)return o.call(e,t);o.call(e)},G=()=>{e.req.on("finish",D)};!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?B&&!C&&(e.on("end",j),e.on("close",j)):(e.on("complete",D),F||e.on("abort",H),e.req?G():e.on("request",G)),F||"boolean"!=typeof e.aborted||e.on("aborted",H),e.on("end",z),e.on("finish",D),!1!==t.error&&e.on("error",W),e.on("close",H),$?n.nextTick(H):null!=C&&C.errorEmitted||null!=L&&L.errorEmitted?F||n.nextTick(V):(T||F&&!m(e)||!U&&!1!==E(e))&&(B||F&&!E(e)||!q&&!1!==m(e))?L&&e.req&&e.aborted&&n.nextTick(V):n.nextTick(V);const K=()=>{o=P,e.removeListener("aborted",H),e.removeListener("complete",D),e.removeListener("abort",H),e.removeListener("request",G),e.req&&e.req.removeListener("finish",D),e.removeListener("end",j),e.removeListener("close",j),e.removeListener("finish",D),e.removeListener("end",z),e.removeListener("error",W),e.removeListener("close",H)};if(t.signal&&!$){const s=()=>{const r=o;K(),r.call(e,new i(void 0,{cause:t.signal.reason}))};if(t.signal.aborted)n.nextTick(s);else{N=N||r(8577).addAbortListener;const n=N(t.signal,s),i=o;o=c(((...t)=>{n[g](),i.apply(e,t)}))}}return K}e.exports=T,e.exports.finished=function(e,t){var r;let n=!1;return null===t&&(t=f),null!==(r=t)&&void 0!==r&&r.cleanup&&(h(t.cleanup,"cleanup"),n=t.cleanup),new p(((r,i)=>{const o=T(e,t,(e=>{n&&o(),e?i(e):r()}))}))}},3597:(e,t,r)=>{"use strict";const n=r(3184),{PromisePrototypeThen:i,SymbolAsyncIterator:o,SymbolIterator:s}=r(4545),{Buffer:a}=r(1429),{ERR_INVALID_ARG_TYPE:f,ERR_STREAM_NULL_VALUES:c}=r(6974).codes;e.exports=function(e,t,r){let u,d;if("string"==typeof t||t instanceof a)return new e({objectMode:!0,...r,read(){this.push(t),this.push(null)}});if(t&&t[o])d=!0,u=t[o]();else{if(!t||!t[s])throw new f("iterable",["Iterable"],t);d=!1,u=t[s]()}const l=new e({objectMode:!0,highWaterMark:1,...r});let h=!1;return l._read=function(){h||(h=!0,async function(){for(;;){try{const{value:e,done:t}=d?await u.next():u.next();if(t)l.push(null);else{const t=e&&"function"==typeof e.then?await e:e;if(null===t)throw h=!1,new c;if(l.push(t))continue;h=!1}}catch(e){l.destroy(e)}break}}())},l._destroy=function(e,t){i(async function(e){const t=null!=e,r="function"==typeof u.throw;if(t&&r){const{value:t,done:r}=await u.throw(e);if(await t,r)return}if("function"==typeof u.return){const{value:e}=await u.return();await e}}(e),(()=>n.nextTick(t,e)),(r=>n.nextTick(t,r||e)))},l}},1518:(e,t,r)=>{"use strict";const{ArrayIsArray:n,ObjectSetPrototypeOf:i}=r(4545),{EventEmitter:o}=r(8621);function s(e){o.call(this,e)}function a(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?n(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}i(s.prototype,o.prototype),i(s,o),s.prototype.pipe=function(e,t){const r=this;function n(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function i(){r.readable&&r.resume&&r.resume()}r.on("data",n),e.on("drain",i),e._isStdio||t&&!1===t.end||(r.on("end",f),r.on("close",c));let s=!1;function f(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){d(),0===o.listenerCount(this,"error")&&this.emit("error",e)}function d(){r.removeListener("data",n),e.removeListener("drain",i),r.removeListener("end",f),r.removeListener("close",c),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",d),r.removeListener("close",d),e.removeListener("close",d)}return a(r,"error",u),a(e,"error",u),r.on("end",d),r.on("close",d),e.on("close",d),e.emit("pipe",r),e},e.exports={Stream:s,prependListener:a}},6036:(e,t,r)=>{"use strict";const n=globalThis.AbortController||r(1630).AbortController,{codes:{ERR_INVALID_ARG_VALUE:i,ERR_INVALID_ARG_TYPE:o,ERR_MISSING_ARGS:s,ERR_OUT_OF_RANGE:a},AbortError:f}=r(6974),{validateAbortSignal:c,validateInteger:u,validateObject:d}=r(9984),l=r(4545).Symbol("kWeak"),h=r(4545).Symbol("kResistStopPropagation"),{finished:p}=r(4501),b=r(8217),{addAbortSignalNoValidate:g}=r(8266),{isWritable:y,isNodeStream:m}=r(7192),{deprecate:w}=r(8577),{ArrayPrototypePush:v,Boolean:_,MathFloor:S,Number:E,NumberIsNaN:A,Promise:M,PromiseReject:R,PromiseResolve:x,PromisePrototypeThen:I,Symbol:k}=r(4545),O=k("kEmpty"),N=k("kEof");function P(e,t){if("function"!=typeof e)throw new o("fn",["Function","AsyncFunction"],e);null!=t&&d(t,"options"),null!=(null==t?void 0:t.signal)&&c(t.signal,"options.signal");let n=1;null!=(null==t?void 0:t.concurrency)&&(n=S(t.concurrency));let i=n-1;return null!=(null==t?void 0:t.highWaterMark)&&(i=S(t.highWaterMark)),u(n,"options.concurrency",1),u(i,"options.highWaterMark",0),i+=n,async function*(){const o=r(8577).AbortSignalAny([null==t?void 0:t.signal].filter(_)),s=this,a=[],c={signal:o};let u,d,l=!1,h=0;function p(){l=!0,b()}function b(){h-=1,g()}function g(){d&&!l&&h<n&&a.length<i&&(d(),d=null)}!async function(){try{for await(let t of s){if(l)return;if(o.aborted)throw new f;try{if(t=e(t,c),t===O)continue;t=x(t)}catch(e){t=R(e)}h+=1,I(t,b,p),a.push(t),u&&(u(),u=null),!l&&(a.length>=i||h>=n)&&await new M((e=>{d=e}))}a.push(N)}catch(e){const t=R(e);I(t,b,p),a.push(t)}finally{l=!0,u&&(u(),u=null)}}();try{for(;;){for(;a.length>0;){const e=await a[0];if(e===N)return;if(o.aborted)throw new f;e!==O&&(yield e),a.shift(),g()}await new M((e=>{u=e}))}}finally{l=!0,d&&(d(),d=null)}}.call(this)}async function T(e,t=void 0){for await(const r of B.call(this,e,t))return!0;return!1}function B(e,t){if("function"!=typeof e)throw new o("fn",["Function","AsyncFunction"],e);return P.call(this,(async function(t,r){return await e(t,r)?t:O}),t)}class C extends s{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}}function L(e){if(e=E(e),A(e))return 0;if(e<0)throw new a("number",">= 0",e);return e}e.exports.streamReturningOperators={asIndexedPairs:w((function(e=void 0){return null!=e&&d(e,"options"),null!=(null==e?void 0:e.signal)&&c(e.signal,"options.signal"),async function*(){let t=0;for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new f({cause:e.signal.reason});yield[t++,n]}}.call(this)}),"readable.asIndexedPairs will be removed in a future version."),drop:function(e,t=void 0){return null!=t&&d(t,"options"),null!=(null==t?void 0:t.signal)&&c(t.signal,"options.signal"),e=L(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new f;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new f;e--<=0&&(yield r)}}.call(this)},filter:B,flatMap:function(e,t){const r=P.call(this,e,t);return async function*(){for await(const e of r)yield*e}.call(this)},map:P,take:function(e,t=void 0){return null!=t&&d(t,"options"),null!=(null==t?void 0:t.signal)&&c(t.signal,"options.signal"),e=L(e),async function*(){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new f;for await(const r of this){var n;if(null!=t&&null!==(n=t.signal)&&void 0!==n&&n.aborted)throw new f;if(e-- >0&&(yield r),e<=0)return}}.call(this)},compose:function(e,t){if(null!=t&&d(t,"options"),null!=(null==t?void 0:t.signal)&&c(t.signal,"options.signal"),m(e)&&!y(e))throw new i("stream",e,"must be writable");const r=b(this,e);return null!=t&&t.signal&&g(t.signal,r),r}},e.exports.promiseReturningOperators={every:async function(e,t=void 0){if("function"!=typeof e)throw new o("fn",["Function","AsyncFunction"],e);return!await T.call(this,(async(...t)=>!await e(...t)),t)},forEach:async function(e,t){if("function"!=typeof e)throw new o("fn",["Function","AsyncFunction"],e);for await(const r of P.call(this,(async function(t,r){return await e(t,r),O}),t));},reduce:async function(e,t,r){var i;if("function"!=typeof e)throw new o("reducer",["Function","AsyncFunction"],e);null!=r&&d(r,"options"),null!=(null==r?void 0:r.signal)&&c(r.signal,"options.signal");let s=arguments.length>1;if(null!=r&&null!==(i=r.signal)&&void 0!==i&&i.aborted){const e=new f(void 0,{cause:r.signal.reason});throw this.once("error",(()=>{})),await p(this.destroy(e)),e}const a=new n,u=a.signal;if(null!=r&&r.signal){const e={once:!0,[l]:this,[h]:!0};r.signal.addEventListener("abort",(()=>a.abort()),e)}let b=!1;try{for await(const n of this){var g;if(b=!0,null!=r&&null!==(g=r.signal)&&void 0!==g&&g.aborted)throw new f;s?t=await e(t,n,{signal:u}):(t=n,s=!0)}if(!b&&!s)throw new C}finally{a.abort()}return t},toArray:async function(e){null!=e&&d(e,"options"),null!=(null==e?void 0:e.signal)&&c(e.signal,"options.signal");const t=[];for await(const n of this){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new f(void 0,{cause:e.signal.reason});v(t,n)}return t},some:T,find:async function(e,t){for await(const r of B.call(this,e,t))return r}}},4123:(e,t,r)=>{"use strict";const{ObjectSetPrototypeOf:n}=r(4545);e.exports=o;const i=r(6105);function o(e){if(!(this instanceof o))return new o(e);i.call(this,e)}n(o.prototype,i.prototype),n(o,i),o.prototype._transform=function(e,t,r){r(null,e)}},831:(e,t,r)=>{const n=r(3184),{ArrayIsArray:i,Promise:o,SymbolAsyncIterator:s,SymbolDispose:a}=r(4545),f=r(4501),{once:c}=r(8577),u=r(1167),d=r(8599),{aggregateTwoErrors:l,codes:{ERR_INVALID_ARG_TYPE:h,ERR_INVALID_RETURN_VALUE:p,ERR_MISSING_ARGS:b,ERR_STREAM_DESTROYED:g,ERR_STREAM_PREMATURE_CLOSE:y},AbortError:m}=r(6974),{validateFunction:w,validateAbortSignal:v}=r(9984),{isIterable:_,isReadable:S,isReadableNodeStream:E,isNodeStream:A,isTransformStream:M,isWebStream:R,isReadableStream:x,isReadableFinished:I}=r(7192),k=globalThis.AbortController||r(1630).AbortController;let O,N,P;function T(e,t,r){let n=!1;return e.on("close",(()=>{n=!0})),{destroy:t=>{n||(n=!0,u.destroyer(e,t||new g("pipe")))},cleanup:f(e,{readable:t,writable:r},(e=>{n=!e}))}}function B(e){if(_(e))return e;if(E(e))return async function*(e){N||(N=r(7077)),yield*N.prototype[s].call(e)}(e);throw new h("val",["Readable","Iterable","AsyncIterable"],e)}async function C(e,t,r,{end:n}){let i,s=null;const a=e=>{if(e&&(i=e),s){const e=s;s=null,e()}},c=()=>new o(((e,t)=>{i?t(i):s=()=>{i?t(i):e()}}));t.on("drain",a);const u=f(t,{readable:!1},a);try{t.writableNeedDrain&&await c();for await(const r of e)t.write(r)||await c();n&&(t.end(),await c()),r()}catch(e){r(i!==e?l(i,e):e)}finally{u(),t.off("drain",a)}}async function L(e,t,r,{end:n}){M(t)&&(t=t.writable);const i=t.getWriter();try{for await(const t of e)await i.ready,i.write(t).catch((()=>{}));await i.ready,n&&await i.close(),r()}catch(e){try{await i.abort(e),r(e)}catch(e){r(e)}}}function j(e,t,o){if(1===e.length&&i(e[0])&&(e=e[0]),e.length<2)throw new b("streams");const s=new k,f=s.signal,c=null==o?void 0:o.signal,u=[];function l(){D(new m)}let g,y,w;v(c,"options.signal"),P=P||r(8577).addAbortListener,c&&(g=P(c,l));const I=[];let N,j=0;function U(e){D(e,0==--j)}function D(e,r){var i;if(!e||y&&"ERR_STREAM_PREMATURE_CLOSE"!==y.code||(y=e),y||r){for(;I.length;)I.shift()(y);null===(i=g)||void 0===i||i[a](),s.abort(),r&&(y||u.forEach((e=>e())),n.nextTick(t,y,w))}}for(let $=0;$<e.length;$++){const H=e[$],V=$<e.length-1,G=$>0,K=V||!1!==(null==o?void 0:o.end),J=$===e.length-1;if(A(H)){if(K){const{destroy:Y,cleanup:X}=T(H,V,G);I.push(Y),S(H)&&J&&u.push(X)}function q(e){e&&"AbortError"!==e.name&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code&&U(e)}H.on("error",q),S(H)&&J&&u.push((()=>{H.removeListener("error",q)}))}if(0===$)if("function"==typeof H){if(N=H({signal:f}),!_(N))throw new p("Iterable, AsyncIterable or Stream","source",N)}else N=_(H)||E(H)||M(H)?H:d.from(H);else if("function"==typeof H){var z;if(N=M(N)?B(null===(z=N)||void 0===z?void 0:z.readable):B(N),N=H(N,{signal:f}),V){if(!_(N,!0))throw new p("AsyncIterable",`transform[${$-1}]`,N)}else{var W;O||(O=r(4123));const Z=new O({objectMode:!0}),Q=null===(W=N)||void 0===W?void 0:W.then;if("function"==typeof Q)j++,Q.call(N,(e=>{w=e,null!=e&&Z.write(e),K&&Z.end(),n.nextTick(U)}),(e=>{Z.destroy(e),n.nextTick(U,e)}));else if(_(N,!0))j++,C(N,Z,U,{end:K});else{if(!x(N)&&!M(N))throw new p("AsyncIterable or Promise","destination",N);{const re=N.readable||N;j++,C(re,Z,U,{end:K})}}N=Z;const{destroy:ee,cleanup:te}=T(N,!1,!0);I.push(ee),J&&u.push(te)}}else if(A(H)){if(E(N)){j+=2;const ne=F(N,H,U,{end:K});S(H)&&J&&u.push(ne)}else if(M(N)||x(N)){const ie=N.readable||N;j++,C(ie,H,U,{end:K})}else{if(!_(N))throw new h("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],N);j++,C(N,H,U,{end:K})}N=H}else if(R(H)){if(E(N))j++,L(B(N),H,U,{end:K});else if(x(N)||_(N))j++,L(N,H,U,{end:K});else{if(!M(N))throw new h("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],N);j++,L(N.readable,H,U,{end:K})}N=H}else N=d.from(H)}return(null!=f&&f.aborted||null!=c&&c.aborted)&&n.nextTick(l),N}function F(e,t,r,{end:i}){let o=!1;if(t.on("close",(()=>{o||r(new y)})),e.pipe(t,{end:!1}),i){function s(){o=!0,t.end()}I(e)?n.nextTick(s):e.once("end",s)}else r();return f(e,{readable:!0,writable:!1},(t=>{const n=e._readableState;t&&"ERR_STREAM_PREMATURE_CLOSE"===t.code&&n&&n.ended&&!n.errored&&!n.errorEmitted?e.once("end",r).once("error",r):r(t)})),f(t,{readable:!1,writable:!0},r)}e.exports={pipelineImpl:j,pipeline:function(...e){return j(e,c(function(e){return w(e[e.length-1],"streams[stream.length - 1]"),e.pop()}(e)))}}},7077:(e,t,r)=>{const n=r(3184),{ArrayPrototypeIndexOf:i,NumberIsInteger:o,NumberIsNaN:s,NumberParseInt:a,ObjectDefineProperties:f,ObjectKeys:c,ObjectSetPrototypeOf:u,Promise:d,SafeSet:l,SymbolAsyncDispose:h,SymbolAsyncIterator:p,Symbol:b}=r(4545);e.exports=J,J.ReadableState=K;const{EventEmitter:g}=r(8621),{Stream:y,prependListener:m}=r(1518),{Buffer:w}=r(1429),{addAbortSignal:v}=r(8266),_=r(4501);let S=r(8577).debuglog("stream",(e=>{S=e}));const E=r(6738),A=r(1167),{getHighWaterMark:M,getDefaultHighWaterMark:R}=r(992),{aggregateTwoErrors:x,codes:{ERR_INVALID_ARG_TYPE:I,ERR_METHOD_NOT_IMPLEMENTED:k,ERR_OUT_OF_RANGE:O,ERR_STREAM_PUSH_AFTER_EOF:N,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:P},AbortError:T}=r(6974),{validateObject:B}=r(9984),C=b("kPaused"),{StringDecoder:L}=r(8488),j=r(3597);u(J.prototype,y.prototype),u(J,y);const F=()=>{},{errorOrDestroy:U}=A,D=1,q=16,z=32,W=64,$=2048,H=4096,V=65536;function G(e){return{enumerable:!1,get(){return!!(this.state&e)},set(t){t?this.state|=e:this.state&=~e}}}function K(e,t,n){"boolean"!=typeof n&&(n=t instanceof r(8599)),this.state=$|H|q|z,e&&e.objectMode&&(this.state|=D),n&&e&&e.readableObjectMode&&(this.state|=D),this.highWaterMark=e?M(this,e,"readableHighWaterMark",n):R(!1),this.buffer=new E,this.length=0,this.pipes=[],this.flowing=null,this[C]=null,e&&!1===e.emitClose&&(this.state&=~$),e&&!1===e.autoDestroy&&(this.state&=~H),this.errored=null,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,e&&e.encoding&&(this.decoder=new L(e.encoding),this.encoding=e.encoding)}function J(e){if(!(this instanceof J))return new J(e);const t=this instanceof r(8599);this._readableState=new K(e,this,t),e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.construct&&(this._construct=e.construct),e.signal&&!t&&v(e.signal,this)),y.call(this,e),A.construct(this,(()=>{this._readableState.needReadable&&te(this,this._readableState)}))}function Y(e,t,r,n){S("readableAddChunk",t);const i=e._readableState;let o;if(i.state&D||("string"==typeof t?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?t=w.from(t,r).toString(i.encoding):(t=w.from(t,r),r=""))):t instanceof w?r="":y._isUint8Array(t)?(t=y._uint8ArrayToBuffer(t),r=""):null!=t&&(o=new I("chunk",["string","Buffer","Uint8Array"],t))),o)U(e,o);else if(null===t)i.state&=-9,function(e,t){if(S("onEofChunk"),!t.ended){if(t.decoder){const e=t.decoder.end();e&&e.length&&(t.buffer.push(e),t.length+=t.objectMode?1:e.length)}t.ended=!0,t.sync?Q(e):(t.needReadable=!1,t.emittedReadable=!0,ee(e))}}(e,i);else if(i.state&D||t&&t.length>0)if(n)if(4&i.state)U(e,new P);else{if(i.destroyed||i.errored)return!1;X(e,i,t,!0)}else if(i.ended)U(e,new N);else{if(i.destroyed||i.errored)return!1;i.state&=-9,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?X(e,i,t,!1):te(e,i)):X(e,i,t,!1)}else n||(i.state&=-9,te(e,i));return!i.ended&&(i.length<i.highWaterMark||0===i.length)}function X(e,t,r,n){t.flowing&&0===t.length&&!t.sync&&e.listenerCount("data")>0?(t.state&V?t.awaitDrainWriters.clear():t.awaitDrainWriters=null,t.dataEmitted=!0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.state&W&&Q(e)),te(e,t)}function Z(e,t){return e<=0||0===t.length&&t.ended?0:t.state&D?1:s(e)?t.flowing&&t.length?t.buffer.first().length:t.length:e<=t.length?e:t.ended?t.length:0}function Q(e){const t=e._readableState;S("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(S("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(ee,e))}function ee(e){const t=e._readableState;S("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||t.errored||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,se(e)}function te(e,t){!t.readingMore&&t.constructed&&(t.readingMore=!0,n.nextTick(re,e,t))}function re(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){const r=t.length;if(S("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function ne(e){const t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!1===t[C]?t.flowing=!0:e.listenerCount("data")>0?e.resume():t.readableListening||(t.flowing=null)}function ie(e){S("readable nexttick read 0"),e.read(0)}function oe(e,t){S("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),se(e),t.flowing&&!t.reading&&e.read(0)}function se(e){const t=e._readableState;for(S("flow",t.flowing);t.flowing&&null!==e.read(););}function ae(e,t){"function"!=typeof e.read&&(e=J.wrap(e,{objectMode:!0}));const r=async function*(e,t){let r,n=F;function i(t){this===e?(n(),n=F):n=t}e.on("readable",i);const o=_(e,{writable:!1},(e=>{r=e?x(r,e):null,n(),n=F}));try{for(;;){const t=e.destroyed?null:e.read();if(null!==t)yield t;else{if(r)throw r;if(null===r)return;await new d(i)}}}catch(e){throw r=x(r,e),r}finally{!r&&!1===(null==t?void 0:t.destroyOnReturn)||void 0!==r&&!e._readableState.autoDestroy?(e.off("readable",i),o()):A.destroyer(e,null)}}(e,t);return r.stream=e,r}function fe(e,t){if(0===t.length)return null;let r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}function ce(e){const t=e._readableState;S("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(ue,t,e))}function ue(e,t){if(S("endReadableNT",e.endEmitted,e.length),!e.errored&&!e.closeEmitted&&!e.endEmitted&&0===e.length)if(e.endEmitted=!0,t.emit("end"),t.writable&&!1===t.allowHalfOpen)n.nextTick(de,t);else if(e.autoDestroy){const e=t._writableState;(!e||e.autoDestroy&&(e.finished||!1===e.writable))&&t.destroy()}}function de(e){e.writable&&!e.writableEnded&&!e.destroyed&&e.end()}let le;function he(){return void 0===le&&(le={}),le}f(K.prototype,{objectMode:G(D),ended:G(2),endEmitted:G(4),reading:G(8),constructed:G(q),sync:G(z),needReadable:G(W),emittedReadable:G(128),readableListening:G(256),resumeScheduled:G(512),errorEmitted:G(1024),emitClose:G($),autoDestroy:G(H),destroyed:G(8192),closed:G(16384),closeEmitted:G(32768),multiAwaitDrain:G(V),readingMore:G(1<<17),dataEmitted:G(1<<18)}),J.prototype.destroy=A.destroy,J.prototype._undestroy=A.undestroy,J.prototype._destroy=function(e,t){t(e)},J.prototype[g.captureRejectionSymbol]=function(e){this.destroy(e)},J.prototype[h]=function(){let e;return this.destroyed||(e=this.readableEnded?null:new T,this.destroy(e)),new d(((t,r)=>_(this,(n=>n&&n!==e?r(n):t(null)))))},J.prototype.push=function(e,t){return Y(this,e,t,!1)},J.prototype.unshift=function(e,t){return Y(this,e,t,!0)},J.prototype.isPaused=function(){const e=this._readableState;return!0===e[C]||!1===e.flowing},J.prototype.setEncoding=function(e){const t=new L(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;const r=this._readableState.buffer;let n="";for(const e of r)n+=t.write(e);return r.clear(),""!==n&&r.push(n),this._readableState.length=n.length,this},J.prototype.read=function(e){S("read",e),void 0===e?e=NaN:o(e)||(e=a(e,10));const t=this._readableState,r=e;if(e>t.highWaterMark&&(t.highWaterMark=function(e){if(e>1073741824)throw new O("size","<= 1GiB",e);return e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,++e}(e)),0!==e&&(t.state&=-129),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return S("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?ce(this):Q(this),null;if(0===(e=Z(e,t))&&t.ended)return 0===t.length&&ce(this),null;let n,i=!!(t.state&W);if(S("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&(i=!0,S("length less than watermark",i)),t.ended||t.reading||t.destroyed||t.errored||!t.constructed)i=!1,S("reading, ended or constructing",i);else if(i){S("do read"),t.state|=8|z,0===t.length&&(t.state|=W);try{this._read(t.highWaterMark)}catch(e){U(this,e)}t.state&=~z,t.reading||(e=Z(r,t))}return n=e>0?fe(e,t):null,null===n?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.multiAwaitDrain?t.awaitDrainWriters.clear():t.awaitDrainWriters=null),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&ce(this)),null===n||t.errorEmitted||t.closeEmitted||(t.dataEmitted=!0,this.emit("data",n)),n},J.prototype._read=function(e){throw new k("_read()")},J.prototype.pipe=function(e,t){const r=this,i=this._readableState;1===i.pipes.length&&(i.multiAwaitDrain||(i.multiAwaitDrain=!0,i.awaitDrainWriters=new l(i.awaitDrainWriters?[i.awaitDrainWriters]:[]))),i.pipes.push(e),S("pipe count=%d opts=%j",i.pipes.length,t);const o=t&&!1===t.end||e===n.stdout||e===n.stderr?b:s;function s(){S("onend"),e.end()}let a;i.endEmitted?n.nextTick(o):r.once("end",o),e.on("unpipe",(function t(n,o){S("onunpipe"),n===r&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,S("cleanup"),e.removeListener("close",h),e.removeListener("finish",p),a&&e.removeListener("drain",a),e.removeListener("error",d),e.removeListener("unpipe",t),r.removeListener("end",s),r.removeListener("end",b),r.removeListener("data",u),f=!0,a&&i.awaitDrainWriters&&(!e._writableState||e._writableState.needDrain)&&a())}));let f=!1;function c(){f||(1===i.pipes.length&&i.pipes[0]===e?(S("false write response, pause",0),i.awaitDrainWriters=e,i.multiAwaitDrain=!1):i.pipes.length>1&&i.pipes.includes(e)&&(S("false write response, pause",i.awaitDrainWriters.size),i.awaitDrainWriters.add(e)),r.pause()),a||(a=function(e,t){return function(){const r=e._readableState;r.awaitDrainWriters===t?(S("pipeOnDrain",1),r.awaitDrainWriters=null):r.multiAwaitDrain&&(S("pipeOnDrain",r.awaitDrainWriters.size),r.awaitDrainWriters.delete(t)),r.awaitDrainWriters&&0!==r.awaitDrainWriters.size||!e.listenerCount("data")||e.resume()}}(r,e),e.on("drain",a))}function u(t){S("ondata");const r=e.write(t);S("dest.write",r),!1===r&&c()}function d(t){if(S("onerror",t),b(),e.removeListener("error",d),0===e.listenerCount("error")){const r=e._writableState||e._readableState;r&&!r.errorEmitted?U(e,t):e.emit("error",t)}}function h(){e.removeListener("finish",p),b()}function p(){S("onfinish"),e.removeListener("close",h),b()}function b(){S("unpipe"),r.unpipe(e)}return r.on("data",u),m(e,"error",d),e.once("close",h),e.once("finish",p),e.emit("pipe",r),!0===e.writableNeedDrain?c():i.flowing||(S("pipe resume"),r.resume()),e},J.prototype.unpipe=function(e){const t=this._readableState;if(0===t.pipes.length)return this;if(!e){const e=t.pipes;t.pipes=[],this.pause();for(let t=0;t<e.length;t++)e[t].emit("unpipe",this,{hasUnpiped:!1});return this}const r=i(t.pipes,e);return-1===r||(t.pipes.splice(r,1),0===t.pipes.length&&this.pause(),e.emit("unpipe",this,{hasUnpiped:!1})),this},J.prototype.on=function(e,t){const r=y.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,S("on readable",i.length,i.reading),i.length?Q(this):i.reading||n.nextTick(ie,this))),r},J.prototype.addListener=J.prototype.on,J.prototype.removeListener=function(e,t){const r=y.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(ne,this),r},J.prototype.off=J.prototype.removeListener,J.prototype.removeAllListeners=function(e){const t=y.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(ne,this),t},J.prototype.resume=function(){const e=this._readableState;return e.flowing||(S("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(oe,e,t))}(this,e)),e[C]=!1,this},J.prototype.pause=function(){return S("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(S("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[C]=!0,this},J.prototype.wrap=function(e){let t=!1;e.on("data",(r=>{!this.push(r)&&e.pause&&(t=!0,e.pause())})),e.on("end",(()=>{this.push(null)})),e.on("error",(e=>{U(this,e)})),e.on("close",(()=>{this.destroy()})),e.on("destroy",(()=>{this.destroy()})),this._read=()=>{t&&e.resume&&(t=!1,e.resume())};const r=c(e);for(let t=1;t<r.length;t++){const n=r[t];void 0===this[n]&&"function"==typeof e[n]&&(this[n]=e[n].bind(e))}return this},J.prototype[p]=function(){return ae(this)},J.prototype.iterator=function(e){return void 0!==e&&B(e,"options"),ae(this,e)},f(J.prototype,{readable:{__proto__:null,get(){const e=this._readableState;return!(!e||!1===e.readable||e.destroyed||e.errorEmitted||e.endEmitted)},set(e){this._readableState&&(this._readableState.readable=!!e)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!(!1===this._readableState.readable||!this._readableState.destroyed&&!this._readableState.errored||this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.objectMode}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return!!this._readableState&&this._readableState.closed}},destroyed:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.destroyed},set(e){this._readableState&&(this._readableState.destroyed=e)}},readableEnded:{__proto__:null,enumerable:!1,get(){return!!this._readableState&&this._readableState.endEmitted}}}),f(K.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return!1!==this[C]},set(e){this[C]=!!e}}}),J._fromList=fe,J.from=function(e,t){return j(J,e,t)},J.fromWeb=function(e,t){return he().newStreamReadableFromReadableStream(e,t)},J.toWeb=function(e,t){return he().newReadableStreamFromStreamReadable(e,t)},J.wrap=function(e,t){var r,n;return new J({objectMode:null===(r=null!==(n=e.readableObjectMode)&&void 0!==n?n:e.objectMode)||void 0===r||r,...t,destroy(t,r){A.destroyer(e,t),r(t)}}).wrap(e)}},992:(e,t,r)=>{"use strict";const{MathFloor:n,NumberIsInteger:i}=r(4545),{validateInteger:o}=r(9984),{ERR_INVALID_ARG_VALUE:s}=r(6974).codes;let a=16384,f=16;function c(e){return e?f:a}e.exports={getHighWaterMark:function(e,t,r,o){const a=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,o,r);if(null!=a){if(!i(a)||a<0)throw new s(o?`options.${r}`:"options.highWaterMark",a);return n(a)}return c(e.objectMode)},getDefaultHighWaterMark:c,setDefaultHighWaterMark:function(e,t){o(t,"value",0),e?f=t:a=t}}},6105:(e,t,r)=>{"use strict";const{ObjectSetPrototypeOf:n,Symbol:i}=r(4545);e.exports=c;const{ERR_METHOD_NOT_IMPLEMENTED:o}=r(6974).codes,s=r(8599),{getHighWaterMark:a}=r(992);n(c.prototype,s.prototype),n(c,s);const f=i("kCallback");function c(e){if(!(this instanceof c))return new c(e);const t=e?a(this,e,"readableHighWaterMark",!0):null;0===t&&(e={...e,highWaterMark:null,readableHighWaterMark:t,writableHighWaterMark:e.writableHighWaterMark||0}),s.call(this,e),this._readableState.sync=!1,this[f]=null,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",d)}function u(e){"function"!=typeof this._flush||this.destroyed?(this.push(null),e&&e()):this._flush(((t,r)=>{t?e?e(t):this.destroy(t):(null!=r&&this.push(r),this.push(null),e&&e())}))}function d(){this._final!==u&&u.call(this)}c.prototype._final=u,c.prototype._transform=function(e,t,r){throw new o("_transform()")},c.prototype._write=function(e,t,r){const n=this._readableState,i=this._writableState,o=n.length;this._transform(e,t,((e,t)=>{e?r(e):(null!=t&&this.push(t),i.ended||o===n.length||n.length<n.highWaterMark?r():this[f]=r)}))},c.prototype._read=function(){if(this[f]){const e=this[f];this[f]=null,e()}}},7192:(e,t,r)=>{"use strict";const{SymbolAsyncIterator:n,SymbolIterator:i,SymbolFor:o}=r(4545),s=o("nodejs.stream.destroyed"),a=o("nodejs.stream.errored"),f=o("nodejs.stream.readable"),c=o("nodejs.stream.writable"),u=o("nodejs.stream.disturbed"),d=o("nodejs.webstream.isClosedPromise"),l=o("nodejs.webstream.controllerErrorFunction");function h(e,t=!1){var r;return!(!e||"function"!=typeof e.pipe||"function"!=typeof e.on||t&&("function"!=typeof e.pause||"function"!=typeof e.resume)||e._writableState&&!1===(null===(r=e._readableState)||void 0===r?void 0:r.readable)||e._writableState&&!e._readableState)}function p(e){var t;return!(!e||"function"!=typeof e.write||"function"!=typeof e.on||e._readableState&&!1===(null===(t=e._writableState)||void 0===t?void 0:t.writable))}function b(e){return e&&(e._readableState||e._writableState||"function"==typeof e.write&&"function"==typeof e.on||"function"==typeof e.pipe&&"function"==typeof e.on)}function g(e){return!(!e||b(e)||"function"!=typeof e.pipeThrough||"function"!=typeof e.getReader||"function"!=typeof e.cancel)}function y(e){return!(!e||b(e)||"function"!=typeof e.getWriter||"function"!=typeof e.abort)}function m(e){return!(!e||b(e)||"object"!=typeof e.readable||"object"!=typeof e.writable)}function w(e){if(!b(e))return null;const t=e._writableState,r=e._readableState,n=t||r;return!!(e.destroyed||e[s]||null!=n&&n.destroyed)}function v(e){if(!p(e))return null;if(!0===e.writableEnded)return!0;const t=e._writableState;return(null==t||!t.errored)&&("boolean"!=typeof(null==t?void 0:t.ended)?null:t.ended)}function _(e,t){if(!h(e))return null;const r=e._readableState;return(null==r||!r.errored)&&("boolean"!=typeof(null==r?void 0:r.endEmitted)?null:!!(r.endEmitted||!1===t&&!0===r.ended&&0===r.length))}function S(e){return e&&null!=e[f]?e[f]:"boolean"!=typeof(null==e?void 0:e.readable)?null:!w(e)&&h(e)&&e.readable&&!_(e)}function E(e){return e&&null!=e[c]?e[c]:"boolean"!=typeof(null==e?void 0:e.writable)?null:!w(e)&&p(e)&&e.writable&&!v(e)}function A(e){return"boolean"==typeof e._closed&&"boolean"==typeof e._defaultKeepAlive&&"boolean"==typeof e._removedConnection&&"boolean"==typeof e._removedContLen}function M(e){return"boolean"==typeof e._sent100&&A(e)}e.exports={isDestroyed:w,kIsDestroyed:s,isDisturbed:function(e){var t;return!(!e||!(null!==(t=e[u])&&void 0!==t?t:e.readableDidRead||e.readableAborted))},kIsDisturbed:u,isErrored:function(e){var t,r,n,i,o,s,f,c,u,d;return!(!e||!(null!==(t=null!==(r=null!==(n=null!==(i=null!==(o=null!==(s=e[a])&&void 0!==s?s:e.readableErrored)&&void 0!==o?o:e.writableErrored)&&void 0!==i?i:null===(f=e._readableState)||void 0===f?void 0:f.errorEmitted)&&void 0!==n?n:null===(c=e._writableState)||void 0===c?void 0:c.errorEmitted)&&void 0!==r?r:null===(u=e._readableState)||void 0===u?void 0:u.errored)&&void 0!==t?t:null===(d=e._writableState)||void 0===d?void 0:d.errored))},kIsErrored:a,isReadable:S,kIsReadable:f,kIsClosedPromise:d,kControllerErrorFunction:l,kIsWritable:c,isClosed:function(e){if(!b(e))return null;if("boolean"==typeof e.closed)return e.closed;const t=e._writableState,r=e._readableState;return"boolean"==typeof(null==t?void 0:t.closed)||"boolean"==typeof(null==r?void 0:r.closed)?(null==t?void 0:t.closed)||(null==r?void 0:r.closed):"boolean"==typeof e._closed&&A(e)?e._closed:null},isDuplexNodeStream:function(e){return!(!e||"function"!=typeof e.pipe||!e._readableState||"function"!=typeof e.on||"function"!=typeof e.write)},isFinished:function(e,t){return b(e)?!(!w(e)&&(!1!==(null==t?void 0:t.readable)&&S(e)||!1!==(null==t?void 0:t.writable)&&E(e))):null},isIterable:function(e,t){return null!=e&&(!0===t?"function"==typeof e[n]:!1===t?"function"==typeof e[i]:"function"==typeof e[n]||"function"==typeof e[i])},isReadableNodeStream:h,isReadableStream:g,isReadableEnded:function(e){if(!h(e))return null;if(!0===e.readableEnded)return!0;const t=e._readableState;return!(!t||t.errored)&&("boolea