MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / onUpgrade

Method onUpgrade

package/cli.js:236–236  ·  view source on GitHub ↗
(q,K,_)

Source from the content-addressed store, hash-verified

2340\r
235\r
236`,"latin1");if(K!==null&&z!==K)if(_[T51])throw new S_6;else process.emitWarning(new S_6);if(q[OJ].timeout&&q[OJ].timeoutType===pD6){if(q[OJ].timeout.refresh)q[OJ].timeout.refresh()}_[ie]()}destroy(q){let{socket:K,client:_,abort:z}=this;if(K[re]=!1,q)z3(_[gZ]<=1,"pipeline should only contain this request"),z(q)}}GI7.exports=cI5});var RI7=m((lp$,LI7)=>{var Eh=U6("node:assert"),{pipeline:aI5}=U6("node:stream"),cz=Yz(),{RequestContentLengthMismatchError:N51,RequestAbortedError:vI7,SocketError:Qp6,InformationalError:y51}=Q$(),{kUrl:jO8,kReset:JO8,kClient:BD6,kRunning:MO8,kPending:sI5,kQueue:oe,kPendingIdx:E51,kRunningIdx:OI,kError:jI,kSocket:RW,kStrictContentLength:tI5,kOnError:L51,kMaxConcurrentStreams:EI7,kHTTP2Session:wI,kResume:ae,kSize:eI5,kHTTPContext:qu5}=Jj(),Vl=Symbol("open streams"),kI7,VI7=!1,HO8;try{HO8=U6("node:http2")}catch{HO8={constants:{}}}var{constants:{HTTP2_HEADER_AUTHORITY:Ku5,HTTP2_HEADER_METHOD:_u5,HTTP2_HEADER_PATH:zu5,HTTP2_HEADER_SCHEME:Yu5,HTTP2_HEADER_CONTENT_LENGTH:$u5,HTTP2_HEADER_EXPECT:Au5,HTTP2_HEADER_STATUS:Ou5}}=HO8;function wu5(q){let K=[];for(let[_,z]of Object.entries(q))if(Array.isArray(z))for(let Y of z)K.push(Buffer.from(_),Buffer.from(Y));else K.push(Buffer.from(_),Buffer.from(z));return K}async function ju5(q,K){if(q[RW]=K,!VI7)VI7=!0,process.emitWarning("H2 support is experimental, expect them to change at any time.",{code:"UNDICI-H2"});let _=HO8.connect(q[jO8],{createConnection:()=>K,peerMaxConcurrentStreams:q[EI7]});_[Vl]=0,_[BD6]=q,_[RW]=K,cz.addListener(_,"error",Ju5),cz.addListener(_,"frameError",Mu5),cz.addListener(_,"end",Xu5),cz.addListener(_,"goaway",Pu5),cz.addListener(_,"close",function(){let{[BD6]:Y}=this,{[RW]:$}=Y,A=this[RW][jI]||this[jI]||new Qp6("closed",cz.getSocketInfo($));if(Y[wI]=null,Y.destroyed){Eh(Y[sI5]===0);let O=Y[oe].splice(Y[OI]);for(let w=0;w<O.length;w++){let j=O[w];cz.errorRequest(Y,j,A)}}}),_.unref(),q[wI]=_,K[wI]=_,cz.addListener(K,"error",function(Y){Eh(Y.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[jI]=Y,this[BD6][L51](Y)}),cz.addListener(K,"end",function(){cz.destroy(this,new Qp6("other side closed",cz.getSocketInfo(this)))}),cz.addListener(K,"close",function(){let Y=this[jI]||new Qp6("closed",cz.getSocketInfo(this));if(q[RW]=null,this[wI]!=null)this[wI].destroy(Y);q[E51]=q[OI],Eh(q[MO8]===0),q.emit("disconnect",q[jO8],[q],Y),q[ae]()});let z=!1;return K.on("close",()=>{z=!0}),{version:"h2",defaultPipelining:1/0,write(...Y){return Du5(q,...Y)},resume(){Hu5(q)},destroy(Y,$){if(z)queueMicrotask($);else K.destroy(Y).on("close",$)},get destroyed(){return K.destroyed},busy(){return!1}}}function Hu5(q){let K=q[RW];if(K?.destroyed===!1)if(q[eI5]===0&&q[EI7]===0)K.unref(),q[wI].unref();else K.ref(),q[wI].ref()}function Ju5(q){Eh(q.code!=="ERR_TLS_CERT_ALTNAME_INVALID"),this[RW][jI]=q,this[BD6][L51](q)}function Mu5(q,K,_){if(_===0){let z=new y51(`HTTP/2: "frameError" received - type ${q}, code ${K}`);this[RW][jI]=z,this[BD6][L51](z)}}function Xu5(){let q=new Qp6("other side closed",cz.getSocketInfo(this[RW]));this.destroy(q),cz.destroy(this[RW],q)}function Pu5(q){let K=this[jI]||new Qp6(`HTTP/2: "GOAWAY" frame received with code ${q}`,cz.getSocketInfo(this)),_=this[BD6];if(_[RW]=null,_[qu5]=null,this[wI]!=null)this[wI].destroy(K),this[wI]=null;if(cz.destroy(this[RW],K),_[OI]<_[oe].length){let z=_[oe][_[OI]];_[oe][_[OI]++]=null,cz.errorRequest(_,z,K),_[E51]=_[OI]}Eh(_[MO8]===0),_.emit("disconnect",_[jO8],[_],K),_[ae]()}function Wu5(q){return q!=="GET"&&q!=="HEAD"&&q!=="OPTIONS"&&q!=="TRACE"&&q!=="CONNECT"}function Du5(q,K){let _=q[wI],{method:z,path:Y,host:$,upgrade:A,expectContinue:O,signal:w,headers:j}=K,{body:H}=K;if(A)return cz.errorRequest(q,K,Error("Upgrade not supported for H2")),!1;let J={};for(let T=0;T<j.length;T+=2){let v=j[T+0],V=j[T+1];if(Array.isArray(V))for(let E=0;E<V.length;E++)if(J[v])J[v]+=`,${V[E]}`;else J[v]=V[E];else J[v]=V}let M,{hostname:X,port:P}=q[jO8];J[Ku5]=$||`${X}${P?`:${P}`:""}`,J[_u5]=z;let W=(T)=>{if(K.aborted||K.completed)return;if(T=T||new vI7,cz.errorRequest(q,K,T),M!=null)cz.destroy(M,T);cz.destroy(H,T),q[oe][q[OI]++]=null,q[ae]()};try{K.onConnect(W)}catch(T){cz.errorRequest(q,K,T)}if(K.aborted)return!1;if(z==="CONNECT"){if(_.ref(),M=_.request(J,{endStream:!1,signal:w}),M.id&&!M.pending)K.onUpgrade(null,null,M),++_[Vl],q[oe][q[OI]++]=null;else M.once("ready",()=>{K.onUpgrade(null,null,M),++_[Vl],q[oe][q[OI]++]=null});return M.once("close",()=>{if(_[Vl]-=1,_[Vl]===0)_.unref()}),!0}J[zu5]=Y,J[Yu5]="https";let D=z==="PUT"||z==="POST"||z==="PATCH";if(H&&typeof H.read==="function")H.read(0);let f=cz.bodyLength(H);if(cz.isFormDataLike(H)){kI7??=ID6().extractBody;let[T,v]=kI7(H);J["content-type"]=v,H=T.stream,f=T.length}if(f==null)f=K.contentLength;if(f===0||!D)f=null;if(Wu5(z)&&f>0&&K.contentLength!=null&&K.contentLength!==f){if(q[tI5])return cz.errorRequest(q,K,new N51),!1;process.emitWarning(new N51)}if(f!=null)Eh(H,"no body must not have content length"),J[$u5]=`${f}`;_.ref();let G=z==="GET"||z==="HEAD"||H===null;if(O)J[Au5]="100-continue",M=_.request(J,{endStream:G,signal:w}),M.once("continue",Z);else M=_.request(J,{endStream:G,signal:w}),Z();return++_[Vl],M.once("response",(T)=>{let{[Ou5]:v,...V}=T;if(K.onResponseStarted(),K.aborted){let E=new vI7;cz.errorRequest(q,K,E),cz.destroy(M,E);return}if(K.onHeaders(Number(v),wu5(V),M.resume.bind(M),"")===!1)M.pause();M.on("data",(E)=>{if(K.onData(E)===!1)M.pause()})}),M.once("end",()=>{if(M.state?.state==null||M.state.state<6)K.onComplete([]);if(_[Vl]===0)_.unref();W(new y51("HTTP/2: stream half-closed (remote)")),q[oe][q[OI]++]=null,q[E51]=q[OI],q[ae]()}),M.once("close",()=>{if(_[Vl]-=1,_[Vl]===0)_.unref()}),M.once("error",function(T){W(T)}),M.once("frameError",(T,v)=>{W(new y51(`HTTP/2: "frameError" received - type ${T}, code ${v}`))}),!0;function Z(){if(!H||f===0)NI7(W,M,null,q,K,q[RW],f,D);else if(cz.isBuffer(H))NI7(W,M,H,q,K,q[RW],f,D);else if(cz.isBlobLike(H))if(typeof H.stream==="function")yI7(W,M,H.stream(),q,K,q[RW],f,D);else Zu5(W,M,H,q,K,q[RW],f,D);else if(cz.isStream(H))fu5(W,q[RW],D,M,H,q,K,f);else if(cz.isIterable(H))yI7(W,M,H,q,K,q[RW],f,D);else Eh(!1)}}function NI7(q,K,_,z,Y,$,A,O){try{if(_!=null&&cz.isBuffer(_))Eh(A===_.byteLength,"buffer body must have content length"),K.cork(),K.write(_),K.uncork(),K.end(),Y.onBodySent(_);if(!O)$[JO8]=!0;Y.onRequestSent(),z[ae]()}catch(w){q(w)}}function fu5(q,K,_,z,Y,$,A,O){Eh(O!==0||$[MO8]===0,"stream body cannot be pipelined");let w=aI5(Y,z,(H)=>{if(H)cz.destroy(w,H),q(H);else{if(cz.removeAllListeners(w),A.onRequestSent(),!_)K[JO8]=!0;$[ae]()}});cz.addListener(w,"data",j);function j(H){A.onBodySent(H)}}async function Zu5(q,K,_,z,Y,$,A,O){Eh(A===_.size,"blob body must have content length");try{if(A!=null&&A!==_.size)throw new N51;let w=Buffer.from(await _.arrayBuffer());if(K.cork(),K.write(w),K.uncork(),K.end(),Y.onBodySent(w),Y.onRequestSent(),!O)$[JO8]=!0;z[ae]()}catch(w){q(w)}}async function yI7(q,K,_,z,Y,$,A,O){Eh(A!==0||z[MO8]===0,"iterator body cannot be pipelined");let w=null;function j(){if(w){let J=w;w=null,J()}}let H=()=>new Promise((J,M)=>{if(Eh(w===null),$[jI])M($[jI]);else w=J});K.on("close",j).on("drain",j);try{for await(let J of _){if($[jI])throw $[jI];let M=K.write(J);if(Y.onBodySent(J),!M)await H()}if(K.end(),Y.onRequestSent(),!O)$[JO8]=!0;z[ae]()}catch(J){q(J)}finally{K.off("close",j).off("drain",j)}}LI7.exports=ju5});var XO8=m((np$,bI7)=>{var UB=Yz(),{kBodyUsed:dp6}=Jj(),h51=U6("node:assert"),{InvalidArgumentError:Gu5}=Q$(),Tu5=U6("node:events"),vu5=[300,301,302,303,307,308],hI7=Symbol("body");class R51{constructor(q){this[hI7]=q,this[dp6]=!1}async*[Symbol.asyncIterator](){h51(!this[dp6],"disturbed"),this[dp6]=!0,yield*this[hI7]}}class CI7{constructor(q,K,_,z){if(K!=null&&(!Number.isInteger(K)||K<0))throw new Gu5("maxRedirections must be a positive number");if(UB.validateHandler(z,_.method,_.upgrade),this.dispatch=q,this.location=null,this.abort=null,this.opts={..._,maxRedirections:0},this.maxRedirections=K,this.handler=z,this.history=[],this.redirectionLimitReached=!1,UB.isStream(this.opts.body)){if(UB.bodyLength(this.opts.body)===0)this.opts.body.on("data",function(){h51(!1)});if(typeof this.opts.body.readableDidRead!=="boolean")this.opts.body[dp6]=!1,Tu5.prototype.on.call(this.opts.body,"data",function(){this[dp6]=!0})}else if(this.opts.body&&typeof this.opts.body.pipeTo==="function")this.opts.body=new R51(this.opts.body);else if(this.opts.body&&typeof this.opts.body!=="string"&&!ArrayBuffer.isView(this.opts.body)&&UB.isIterable(this.opts.body))this.opts.body=new R51(this.opts.body)}onConnect(q){this.abort=q,this.handler.onConnect(q,{history:this.history})}onUpgrade(q,K,_){this.handler.onUpgrade(q,K,_)}onError(q){this.handler.onError(q)}onHeaders(q,K,_,z){if(this.location=this.history.length>=this.maxRedirections||UB.isDisturbed(this.opts.body)?null:ku5(q,K),this.opts.throwOnMaxRedirect&&this.history.length>=this.maxRedirections){if(this.request)this.request.abort(Error("max redirects"));this.redirectionLimitReached=!0,this.abort(Error("max redirects"));return}if(this.opts.origin)this.history.push(new URL(this.opts.path,this.opts.origin));if(!this.location)return this.handler.onHeaders(q,K,_,z);let{origin:Y,pathname:$,search:A}=UB.parseURL(new URL(this.location,this.opts.origin&&new URL(this.opts.path,this.opts.origin))),O=A?`${$}${A}`:$;if(this.opts.headers=Vu5(this.opts.headers,q===303,this.opts.origin!==Y),this.opts.path=O,this.opts.origin=Y,this.opts.maxRedirections=0,this.opts.query=null,q===303&&this.opts.method!=="HEAD")this.opts.method="GET",this.opts.body=null}onData(q){if(this.location);else return this.handler.onData(q)}onComplete(q){if(this.location)this.location=null,this.abort=null,this.dispatch(this.opts,this);else this.handler.onComplete(q)}onBodySent(q){if(this.handler.onBodySent)this.handler.onBodySent(q)}}function ku5(q,K){if(vu5.indexOf(q)===-1)return null;for(let _=0;_<K.length;_+=2)if(K[_].length===8&&UB.headerNameToString(K[_])==="location")return K[_+1]}function SI7(q,K,_){if(q.length===4)return UB.headerNameToString(q)==="host";if(K&&UB.headerNameToString(q).startsWith("content-"))return!0;if(_&&(q.length===13||q.length===6||q.length===19)){let z=UB.headerNameToString(q);return z==="authorization"||z==="cookie"||z==="proxy-authorization"}return!1}function Vu5(q,K,_){let z=[];if(Array.isArray(q)){for(let Y=0;Y<q.length;Y+=2)if(!SI7(q[Y],K,_))z.push(q[Y],q[Y+1])}else if(q&&typeof q==="object"){for(let Y of Object.keys(q))if(!SI7(Y,K,_))z.push(Y,q[Y])}else h51(q==null,"headers must be an object or an array");return z}bI7.exports=CI7});var PO8=m((ip$,xI7)=>{var Nu5=XO8();function yu5({maxRedirections:q}){return(K)=>{return function(z,Y){let{maxRedirections:$=q}=z;if(!$)return K(z,Y);let A=new Nu5(K,$,z,Y);return z={...z,maxRedirections:0},K(z,A)}}}xI7.exports=yu5});var UD6=m((rp$,cI7)=>{var Nl=U6("node:assert"),gI7=U6("node:net"),Eu5=U6("node:http"),C_6=Yz(),{channels:gD6}=vD6(),Lu5=Vb7(),Ru5=yD6(),{InvalidArgumentError:lJ,InformationalError:hu5,ClientDestroyedError:Su5}=Q$(),Cu5=Cp6(),{kUrl:QB,kServerName:se,kClient:bu5,kBusy:S51,kConnect:xu5,kResuming:b_6,kRunning:rp6,kPending:op6,kSize:ip6,kQueue:HI,kConnected:Iu5,kConnecting:FD6,kNeedDrain:ee,kKeepAliveDefaultTimeout:II7,kHostHeader:uu5,kPendingIdx:JI,kRunningIdx:yl,kError:mu5,kPipelining:WO8,kKeepAliveTimeoutValue:pu5,kMaxHeadersSize:Bu5,kKeepAliveMaxTimeout:gu5,kKeepAliveTimeoutThreshold:Fu5,kHeadersTimeout:Uu5,kBodyTimeout:Qu5,kStrictContentLength:du5,kConnector:cp6,kMaxRedirections:cu5,kMaxRequests:C51,kCounter:lu5,kClose:nu5,kDestroy:iu5,kDispatch:ru5,kInterceptors:uI7,kLocalAddress:lp6,kMaxResponseSize:ou5,kOnError:au5,kHTTPContext:nJ,kMaxConcurrentStreams:su5,kResume:np6}=Jj(),tu5=TI7(),eu5=RI7(),mI7=!1,te=Symbol("kClosedResolve"),pI7=()=>{};function FI7(q){return q[WO8]??q[nJ]?.defaultPipelining??1}class UI7 extends Ru5{constructor(q,{interceptors:K,maxHeaderSize:_,headersTimeout:z,socketTimeout:Y,requestTimeout:$,connectTimeout:A,bodyTimeout:O,idleTimeout:w,keepAlive:j,keepAliveTimeout:H,maxKeepAliveTimeout:J,keepAliveMaxTimeout:M,keepAliveTimeoutThreshold:X,socketPath:P,pipelining:W,tls:D,strictContentLength:f,maxCachedSessions:G,maxRedirections:Z,connect:T,maxRequestsPerClient:v,localAddress:V,maxResponseSize:E,autoSelectFamily:S,autoSelectFamilyAttemptTimeout:R,maxConcurrentStreams:x,allowH2:I}={}){super();if(j!==void 0)throw new lJ("unsupported keepAlive, use pipelining=0 instead");if(Y!==void 0)throw new lJ("unsupported socketTimeout, use headersTimeout & bodyTimeout instead");if($!==void 0)throw new lJ("unsupported requestTimeout, use headersTimeout & bodyTimeout instead");if(w!==void 0)throw new lJ("unsupported idleTimeout, use keepAliveTimeout instead");if(J!==void 0)throw new lJ("unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead");if(_!=null&&!Number.isFinite(_))throw new lJ("invalid maxHeaderSize");if(P!=null&&typeof P!=="string")throw new lJ("invalid socketPath");if(A!=null&&(!Number.isFinite(A)||A<0))throw new lJ("invalid connectTimeout");if(H!=null&&(!Number.isFinite(H)||H<=0))throw new lJ("invalid keepAliveTimeout");if(M!=null&&(!Number.isFinite(M)||M<=0))throw new lJ("invalid keepAliveMaxTimeout");if(X!=null&&!Number.isFinite(X))throw new lJ("invalid keepAliveTimeoutThreshold");if(z!=null&&(!Number.isInteger(z)||z<0))throw new lJ("headersTimeout must be a positive integer or zero");if(O!=null&&(!Number.isInteger(O)||O<0))throw new lJ("bodyTimeout must be a positive integer or zero");if(T!=null&&typeof T!=="function"&&typeof T!=="object")throw new lJ("connect must be a function or an object");if(Z!=null&&(!Number.isInteger(Z)||Z<0))throw new lJ("maxRedirections must be a positive number");if(v!=null&&(!Number.isInteger(v)||v<0))throw new lJ("maxRequestsPerClient must be a positive number");if(V!=null&&(typeof V!=="string"||gI7.isIP(V)===0))throw new lJ("localAddress must be valid string IP address");if(E!=null&&(!Number.isInteger(E)||E<-1))throw new lJ("maxResponseSize must be a positive number");if(R!=null&&(!Number.isInteger(R)||R<-1))throw new lJ("autoSelectFamilyAttemptTimeout must be a positive number");if(I!=null&&typeof I!=="boolean")throw new lJ("allowH2 must be a valid boolean value");if(x!=null&&(typeof x!=="number"||x<1))throw new lJ("maxConcurrentStreams must be a positive integer, greater than 0");if(typeof T!=="function")T=Cu5({...D,maxCachedSessions:G,allowH2:I,socketPath:P,timeout:A,...S?{autoSelectFamily:S,autoSelectFamilyAttemptTimeout:R}:void 0,...T});if(K?.Client&&Array.isArray(K.Client)){if(this[uI7]=K.Client,!mI7)mI7=!0,process.emitWarning("Client.Options#interceptor is deprecated. Use Dispatcher#compose instead.",{code:"UNDICI-CLIENT-INTERCEPTOR-DEPRECATED"})}else this[uI7]=[qm5({maxRedirections:Z})];this[QB]=C_6.parseOrigin(q),this[cp6]=T,this[WO8]=W!=null?W:1,this[Bu5]=_||Eu5.maxHeaderSize,this[II7]=H==null?4000:H,this[gu5]=M==null?600000:M,this[Fu5]=X==null?2000:X,this[pu5]=this[II7],this[se]=null,this[lp6]=V!=null?V:null,this[b_6]=0,this[ee]=0,this[uu5]=`host: ${this[QB].hostname}${this[QB].port?`:${this[QB].port}`:""}\r
237`,this[Qu5]=O!=null?O:300000,this[Uu5]=z!=null?z:300000,this[du5]=f==null?!0:f,this[cu5]=Z,this[C51]=v,this[te]=null,this[ou5]=E>-1?E:-1,this[su5]=x!=null?x:100,this[nJ]=null,this[HI]=[],this[yl]=0,this[JI]=0,this[np6]=(B)=>b51(this,B),this[au5]=(B)=>QI7(this,B)}get pipelining(){return this[WO8]}set pipelining(q){this[WO8]=q,this[np6](!0)}get[op6](){return this[HI].length-this[JI]}get[rp6](){return this[JI]-this[yl]}get[ip6](){return this[HI].length-this[yl]}get[Iu5](){return!!this[nJ]&&!this[FD6]&&!this[nJ].destroyed}get[S51](){return Boolean(this[nJ]?.busy(null)||this[ip6]>=(FI7(this)||1)||this[op6]>0)}[xu5](q){dI7(this),this.once("connect",q)}[ru5](q,K){let _=q.origin||this[QB].origin,z=new Lu5(_,q,K);if(this[HI].push(z),this[b_6]);else if(C_6.bodyLength(z.body)==null&&C_6.isIterable(z.body))this[b_6]=1,queueMicrotask(()=>b51(this));else this[np6](!0);if(this[b_6]&&this[ee]!==2&&this[S51])this[ee]=2;return this[ee]<2}async[nu5](){return new Promise((q)=>{if(this[ip6])this[te]=q;else q(null)})}async[iu5](q){return new Promise((K)=>{let _=this[HI].splice(this[JI]);for(let Y=0;Y<_.length;Y++){let $=_[Y];C_6.errorRequest(this,$,q)}let z=()=>{if(this[te])this[te](),this[te]=null;K(null)};if(this[nJ])this[nJ].destroy(q,z),this[nJ]=null;else queueMicrotask(z);this[np6]()})}}var qm5=PO8();function QI7(q,K){if(q[rp6]===0&&K.code!=="UND_ERR_INFO"&&K.code!=="UND_ERR_SOCKET"){Nl(q[JI]===q[yl]);let _=q[HI].splice(q[yl]);for(let z=0;z<_.length;z++){let Y=_[z];C_6.errorRequest(q,Y,K)}Nl(q[ip6]===0)}}async function dI7(q){Nl(!q[FD6]),Nl(!q[nJ]);let{host:K,hostname:_,protocol:z,port:Y}=q[QB];if(_[0]==="["){let $=_.indexOf("]");Nl($!==-1);let A=_.substring(1,$);Nl(gI7.isIP(A)),_=A}if(q[FD6]=!0,gD6.beforeConnect.hasSubscribers)gD6.beforeConnect.publish({connectParams:{host:K,hostname:_,protocol:z,port:Y,version:q[nJ]?.version,servername:q[se],localAddress:q[lp6]},connector:q[cp6]});try{let $=await new Promise((A,O)=>{q[cp6]({host:K,hostname:_,protocol:z,port:Y,servername:q[se],localAddress:q[lp6]},(w,j)=>{if(w)O(w);else A(j)})});if(q.destroyed){C_6.destroy($.on("error",pI7),new Su5);return}Nl($);try{q[nJ]=$.alpnProtocol==="h2"?await eu5(q,$):await tu5(q,$)}catch(A){throw $.destroy().on("error",pI7),A}if(q[FD6]=!1,$[lu5]=0,$[C51]=q[C51],$[bu5]=q,$[mu5]=null,gD6.connected.hasSubscribers)gD6.connected.publish({connectParams:{host:K,hostname:_,protocol:z,port:Y,version:q[nJ]?.version,servername:q[se],localAddress:q[lp6]},connector:q[cp6],socket:$});q.emit("connect",q[QB],[q])}catch($){if(q.destroyed)return;if(q[FD6]=!1,gD6.connectError.hasSubscribers)gD6.connectError.publish({connectParams:{host:K,hostname:_,protocol:z,port:Y,version:q[nJ]?.version,servername:q[se],localAddress:q[lp6]},connector:q[cp6],error:$});if($.code==="ERR_TLS_CERT_ALTNAME_INVALID"){Nl(q[rp6]===0);while(q[op6]>0&&q[HI][q[JI]].servername===q[se]){let A=q[HI][q[JI]++];C_6.errorRequest(q,A,$)}}else QI7(q,$);q.emit("connectionError",q[QB],[q],$)}q[np6]()}function BI7(q){q[ee]=0,q.emit("drain",q[QB],[q])}function b51(q,K){if(q[b_6]===2)return;if(q[b_6]=2,Km5(q,K),q[b_6]=0,q[yl]>256)q[HI].splice(0,q[yl]),q[JI]-=q[yl],q[yl]=0}function Km5(q,K){while(!0){if(q.destroyed){Nl(q[op6]===0);return}if(q[te]&&!q[ip6]){q[te](),q[te]=null;return}if(q[nJ])q[nJ].resume();if(q[S51])q[ee]=2;else if(q[ee]===2){if(K)q[ee]=1,queueMicrotask(()=>BI7(q));else BI7(q);continue}if(q[op6]===0)return;if(q[rp6]>=(FI7(q)||1))return;let _=q[HI][q[JI]];if(q[QB].protocol==="https:"&&q[se]!==_.servername){if(q[rp6]>0)return;q[se]=_.servername,q[nJ]?.destroy(new hu5("servername changed"),()=>{q[nJ]=null,b51(q)})}if(q[FD6])return;if(!q[nJ]){dI7(q);return}if(q[nJ].destroyed)return;if(q[nJ].busy(_))return;if(!_.aborted&&q[nJ].write(_))q[JI]++;else q[HI].splice(q[JI],1)}}cI7.exports=UI7});var I51=m((op$,lI7)=>{class x51{constructor(){this.bottom=0,this.top=0,this.list=Array(2048),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&2047)===this.bottom}push(q){this.list[this.top]=q,this.top=this.top+1&2047}shift(){let q=this.list[this.bottom];if(q===void 0)return null;return this.list[this.bottom]=void 0,this.bottom=this.bottom+1&2047,q}}lI7.exports=class{constructor(){this.head=this.tail=new x51}isEmpty(){return this.head.isEmpty()}push(K){if(this.head.isFull())this.head=this.head.next=new x51;this.head.push(K)}shift(){let K=this.tail,_=K.shift();if(K.isEmpty()&&K.next!==null)this.tail=K.next;return _}}});var rI7=m((ap$,iI7)=>{var{kFree:_m5,kConnected:zm5,kPending:Ym5,kQueued:$m5,kRunning:Am5,kSize:Om5}=Jj(),x_6=Symbol("pool");class nI7{constructor(q){this[x_6]=q}get connected(){return this[x_6][zm5]}get free(){return this[x_6][_m5]}get pending(){return this[x_6][Ym5]}get queued(){return this[x_6][$m5]}get running(){return this[x_6][Am5]}get size(){return this[x_6][Om5]}}iI7.exports=nI7});var g51=m((sp$,$u7)=>{var wm5=yD6(),jm5=I51(),{kConnected:u51,kSize:oI7,kRunning:aI7,kPending:sI7,kQueued:ap6,kBusy:Hm5,kFree:Jm5,kUrl:Mm5,kClose:Xm5,kDestroy:Pm5,kDispatch:Wm5}=Jj(),Dm5=rI7(),qV=Symbol("clients"),rT=Symbol("needDrain"),sp6=Symbol("queue"),m51=Symbol("closed resolve"),p51=Symbol("onDrain"),tI7=Symbol("onConnect"),eI7=Symbol("onDisconnect"),qu7=Symbol("onConnectionError"),B51=Symbol("get dispatcher"),_u7=Symbol("add client"),zu7=Symbol("remove client"),Ku7=Symbol("stats");class Yu7 extends wm5{constructor(){super();this[sp6]=new jm5,this[qV]=[],this[ap6]=0;let q=this;this[p51]=function(_,z){let Y=q[sp6],$=!1;while(!$){let A=Y.shift();if(!A)break;q[ap6]--,$=!this.dispatch(A.opts,A.handler)}if(this[rT]=$,!this[rT]&&q[rT])q[rT]=!1,q.emit("drain",_,[q,...z]);if(q[m51]&&Y.isEmpty())Promise.all(q[qV].map((A)=>A.close())).then(q[m51])},this[tI7]=(K,_)=>{q.emit("connect",K,[q,..._])},this[eI7]=(K,_,z)=>{q.emit("disconnect",K,[q,..._],z)},this[qu7]=(K,_,z)=>{q.emit("connectionError",K,[q,..._],z)},this[Ku7]=new Dm5(this)}get[Hm5](){return this[rT]}get[u51](){return this[qV].filter((q)=>q[u51]).length}get[Jm5](){return this[qV].filter((q)=>q[u51]&&!q[rT]).length}get[sI7](){let q=this[ap6];for(let{[sI7]:K}of this[qV])q+=K;return q}get[aI7](){let q=0;for(let{[aI7]:K}of this[qV])q+=K;return q}get[oI7](){let q=this[ap6];for(let{[oI7]:K}of this[qV])q+=K;return q}get stats(){return this[Ku7]}async[Xm5](){if(this[sp6].isEmpty())await Promise.all(this[qV].map((q)=>q.close()));else await new Promise((q)=>{this[m51]=q})}async[Pm5](q){while(!0){let K=this[sp6].shift();if(!K)break;K.handler.onError(q)}await Promise.all(this[qV].map((K)=>K.destroy(q)))}[Wm5](q,K){let _=this[B51]();if(!_)this[rT]=!0,this[sp6].push({opts:q,handler:K}),this[ap6]++;else if(!_.dispatch(q,K))_[rT]=!0,this[rT]=!this[B51]();return!this[rT]}[_u7](q){if(q.on("drain",this[p51]).on("connect",this[tI7]).on("disconnect",this[eI7]).on("connectionError",this[qu7]),this[qV].push(q),this[rT])queueMicrotask(()=>{if(this[rT])this[p51](q[Mm5],[this,q])});return this}[zu7](q){q.close(()=>{let K=this[qV].indexOf(q);if(K!==-1)this[qV].splice(K,1)}),this[rT]=this[qV].some((K)=>!K[rT]&&K.closed!==!0&&K.destroyed!==!0)}}$u7.exports={PoolBase:Yu7,kClients:qV,kNeedDrain:rT,kAddClient:_u7,kRemoveClient:zu7,kGetDispatcher:B51}});var QD6=m((tp$,Hu7)=>{var{PoolBase:fm5,kClients:DO8,kNeedDrain:Zm5,kAddClient:Gm5,kGetDispatcher:Tm5}=g51(),vm5=UD6(),{InvalidArgumentError:F51}=Q$(),Au7=Yz(),{kUrl:Ou7,kInterceptors:km5}=Jj(),Vm5=Cp6(),U51=Symbol("options"),Q51=Symbol("connections"),wu7=Symbol("factory");function Nm5(q,K){return new vm5(q,K)}class ju7 extends fm5{constructor(q,{connections:K,factory:_=Nm5,connect:z,connectTimeout:Y,tls:$,maxCachedSessions:A,socketPath:O,autoSelectFamily:w,autoSelectFamilyAttemptTimeout:j,allowH2:H,...J}={}){super();if(K!=null&&(!Number.isFinite(K)||K<0))throw new F51("invalid connections");if(typeof _!=="function")throw new F51("factory must be a function.");if(z!=null&&typeof z!=="function"&&typeof z!=="object")throw new F51("connect must be a function or an object");if(typeof z!=="function")z=Vm5({...$,maxCachedSessions:A,allowH2:H,socketPath:O,timeout:Y,...w?{autoSelectFamily:w,autoSelectFamilyAttemptTimeout:j}:void 0,...z});this[km5]=J.interceptors?.Pool&&Array.isArray(J.interceptors.Pool)?J.interceptors.Pool:[],this[Q51]=K||null,this[Ou7]=Au7.parseOrigin(q),this[U51]={...Au7.deepClone(J),connect:z,allowH2:H},this[U51].interceptors=J.interceptors?{...J.interceptors}:void 0,this[wu7]=_,this.on("connectionError",(M,X,P)=>{for(let W of X){let D=this[DO8].indexOf(W);if(D!==-1)this[DO8].splice(D,1)}})}[Tm5](){for(let q of this[DO8])if(!q[Zm5])return q;if(!this[Q51]||this[DO8].length<this[Q51]){let q=this[wu7](this[Ou7],this[U51]);return this[Gm5](q),q}}}Hu7.exports=ju7});var Du7=m((ep$,Wu7)=>{var{BalancedPoolMissingUpstreamError:ym5,InvalidArgumentError:Em5}=Q$(),{PoolBase:Lm5,kClients:FZ,kNeedDrain:tp6,kAddClient:Rm5,kRemoveClient:hm5,kGetDispatcher:Sm5}=g51(),Cm5=QD6(),{kUrl:d51,kInterceptors:bm5}=Jj(),{parseOrigin:Ju7}=Yz(),Mu7=Symbol("factory"),fO8=Symbol("options"),Xu7=Symbol("kGreatestCommonDivisor"),I_6=Symbol("kCurrentWeight"),u_6=Symbol("kIndex"),Lh=Symbol("kWeight"),ZO8=Symbol("kMaxWeightPerServer"),GO8=Symbol("kErrorPenalty");function xm5(q,K){if(q===0)return K;while(K!==0){let _=K;K=q%K,q=_}return q}function Im5(q,K){return new Cm5(q,K)}class Pu7 extends Lm5{constructor(q=[],{factory:K=Im5,..._}={}){super();if(this[fO8]=_,this[u_6]=-1,this[I_6]=0,this[ZO8]=this[fO8].maxWeightPerServer||100,this[GO8]=this[fO8].errorPenalty||15,!Array.isArray(q))q=[q];if(typeof K!=="function")throw new Em5("factory must be a function.");this[bm5]=_.interceptors?.BalancedPool&&Array.isArray(_.interceptors.BalancedPool)?_.interceptors.BalancedPool:[],this[Mu7]=K;for(let z of q)this.addUpstream(z);this._updateBalancedPoolStats()}addUpstream(q){let K=Ju7(q).origin;if(this[FZ].find((z)=>z[d51].origin===K&&z.closed!==!0&&z.destroyed!==!0))return this;let _=this[Mu7](K,Object.assign({},this[fO8]));this[Rm5](_),_.on("connect",()=>{_[Lh]=Math.min(this[ZO8],_[Lh]+this[GO8])}),_.on("connectionError",()=>{_[Lh]=Math.max(1,_[Lh]-this[GO8]),this._updateBalancedPoolStats()}),_.on("disconnect",(...z)=>{let Y=z[2];if(Y&&Y.code==="UND_ERR_SOCKET")_[Lh]=Math.max(1,_[Lh]-this[GO8]),this._updateBalancedPoolStats()});for(let z of this[FZ])z[Lh]=this[ZO8];return this._updateBalancedPoolStats(),this}_updateBalancedPoolStats(){let q=0;for(let K=0;K<this[FZ].length;K++)q=xm5(this[FZ][K][Lh],q);this[Xu7]=q}removeUpstream(q){let K=Ju7(q).origin,_=this[FZ].find((z)=>z[d51].origin===K&&z.closed!==!0&&z.destroyed!==!0);if(_)this[hm5](_);return this}get upstreams(){return this[FZ].filter((q)=>q.closed!==!0&&q.destroyed!==!0).map((q)=>q[d51].origin)}[Sm5](){if(this[FZ].length===0)throw new ym5;if(!this[FZ].find((Y)=>!Y[tp6]&&Y.closed!==!0&&Y.destroyed!==!0))return;if(this[FZ].map((Y)=>Y[tp6]).reduce((Y,$)=>Y&&$,!0))return;let _=0,z=this[FZ].findIndex((Y)=>!Y[tp6]);while(_++<this[FZ].length){this[u_6]=(this[u_6]+1)%this[FZ].length;let Y=this[FZ][this[u_6]];if(Y[Lh]>this[FZ][z][Lh]&&!Y[tp6])z=this[u_6];if(this[u_6]===0){if(this[I_6]=this[I_6]-this[Xu7],this[I_6]<=0)this[I_6]=this[ZO8]}if(Y[Lh]>=this[I_6]&&!Y[tp6])return Y}return this[I_6]=this[FZ][z][Lh],this[u_6]=z,this[FZ][z]}}Wu7.exports=Pu7});var dD6=m((qB$,Nu7)=>{var{InvalidArgumentError:TO8}=Q$(),{kClients:q66,kRunning:fu7,kClose:um5,kDestroy:mm5,kDispatch:pm5,kInterceptors:Bm5}=Jj(),gm5=yD6(),Fm5=QD6(),Um5=UD6(),Qm5=Yz(),dm5=PO8(),Zu7=Symbol("onConnect"),Gu7=Symbol("onDisconnect"),Tu7=Symbol("onConnectionError"),cm5=Symbol("maxRedirections"),vu7=Symbol("onDrain"),ku7=Symbol("factory"),c51=Symbol("options");function lm5(q,K){return K&&K.connections===1?new Um5(q,K):new Fm5(q,K)}class Vu7 extends gm5{constructor({factory:q=lm5,maxRedirections:K=0,connect:_,...z}={}){super();if(typeof q!=="function")throw new TO8("factory must be a function.");if(_!=null&&typeof _!=="function"&&typeof _!=="object")throw new TO8("connect must be a function or an object");if(!Number.isInteger(K)||K<0)throw new TO8("maxRedirections must be a positive number");if(_&&typeof _!=="function")_={..._};this[Bm5]=z.interceptors?.Agent&&Array.isArray(z.interceptors.Agent)?z.interceptors.Agent:[dm5({maxRedirections:K})],this[c51]={...Qm5.deepClone(z),connect:_},this[c51].interceptors=z.interceptors?{...z.interceptors}:void 0,this[cm5]=K,this[ku7]=q,this[q66]=new Map,this[vu7]=(Y,$)=>{this.emit("drain",Y,[this,...$])},this[Zu7]=(Y,$)=>{this.emit("connect",Y,[this,...$])},this[Gu7]=(Y,$,A)=>{this.emit("disconnect",Y,[this,...$],A)},this[Tu7]=(Y,$,A)=>{this.emit("connectionError",Y,[this,...$],A)}}get[fu7](){let q=0;for(let K of this[q66].values())q+=K[fu7];return q}[pm5](q,K){let _;if(q.origin&&(typeof q.origin==="string"||q.origin instanceof URL))_=String(q.origin);else throw new TO8("opts.origin must be a non-empty string or URL.");let z=this[q66].get(_);if(!z)z=this[ku7](q.origin,this[c51]).on("drain",this[vu7]).on("connect",this[Zu7]).on("disconnect",this[Gu7]).on("connectionError",this[Tu7]),this[q66].set(_,z);return z.dispatch(q,K)}async[um5](){let q=[];for(let K of this[q66].values())q.push(K.close());this[q66].clear(),await Promise.all(q)}async[mm5](q){let K=[];for(let _ of this[q66].values())K.push(_.destroy(q));this[q66].clear(),await Promise.all(K)}}Nu7.exports=Vu7});var i51=m((KB$,pu7)=>{var{kProxy:l51,kClose:Su7,kDestroy:Cu7,kDispatch:yu7,kInterceptors:nm5}=Jj(),{URL:m_6}=U6("node:url"),im5=dD6(),bu7=QD6(),xu7=yD6(),{InvalidArgumentError:cD6,RequestAbortedError:rm5,SecureProxyConnectionError:om5}=Q$(),Eu7=Cp6(),Iu7=UD6(),vO8=Symbol("proxy agent"),kO8=Symbol("proxy client"),K66=Symbol("proxy headers"),n51=Symbol("request tls settings"),Lu7=Symbol("proxy tls settings"),Ru7=Symbol("connect endpoint function"),hu7=Symbol("tunnel proxy");function am5(q){return q==="https:"?443:80}function sm5(q,K){return new bu7(q,K)}var tm5=()=>{};function em5(q,K){if(K.connections===1)return new Iu7(q,K);return new bu7(q,K)}class uu7 extends xu7{#q;constructor(q,{headers:K={},connect:_,factory:z}){super();if(!q)throw new cD6("Proxy URL is mandatory");if(this[K66]=K,z)this.#q=z(q,{connect:_});else this.#q=new Iu7(q,{connect:_})}[yu7](q,K){let _=K.onHeaders;K.onHeaders=function(A,O,w){if(A===407){if(typeof K.onError==="function")K.onError(new cD6("Proxy Authentication Required (407)"));return}if(_)_.call(this,A,O,w)};let{origin:z,path:Y="/",headers:$={}}=q;if(q.path=z+Y,!("host"in $)&&!("Host"in $)){let{host:A}=new m_6(z);$.host=A}return q.headers={...this[K66],...$},this.#q[yu7](q,K)}async[Su7](){return this.#q.close()}async[Cu7](q){return this.#q.destroy(q)}}class mu7 extends xu7{constructor(q){super();if(!q||typeof q==="object"&&!(q instanceof m_6)&&!q.uri)throw new cD6("Proxy uri is mandatory");let{clientFactory:K=sm5}=q;if(typeof K!=="function")throw new cD6("Proxy opts.clientFactory must be a function.");let{proxyTunnel:_=!0}=q,z=this.#q(q),{href:Y,origin:$,port:A,protocol:O,username:w,password:j,hostname:H}=z;if(this[l51]={uri:Y,protocol:O},this[nm5]=q.interceptors?.ProxyAgent&&Array.isArray(q.interceptors.ProxyAgent)?q.interceptors.ProxyAgent:[],this[n51]=q.requestTls,this[Lu7]=q.proxyTls,this[K66]=q.headers||{},this[hu7]=_,q.auth&&q.token)throw new cD6("opts.auth cannot be used in combination with opts.token");else if(q.auth)this[K66]["proxy-authorization"]=`Basic ${q.auth}`;else if(q.token)this[K66]["proxy-authorization"]=q.token;else if(w&&j)this[K66]["proxy-authorization"]=`Basic ${Buffer.from(`${decodeURIComponent(w)}:${decodeURIComponent(j)}`).toString("base64")}`;let J=Eu7({...q.proxyTls});this[Ru7]=Eu7({...q.requestTls});let M=q.factory||em5,X=(P,W)=>{let{protocol:D}=new m_6(P);if(!this[hu7]&&D==="http:"&&this[l51].protocol==="http:")return new uu7(this[l51].uri,{headers:this[K66],connect:J,factory:M});return M(P,W)};this[kO8]=K(z,{connect:J}),this[vO8]=new im5({...q,factory:X,connect:async(P,W)=>{let D=P.host;if(!P.port)D+=`:${am5(P.protocol)}`;try{let{socket:f,statusCode:G}=await this[kO8].connect({origin:$,port:A,path:D,signal:P.signal,headers:{...this[K66],host:P.host},servername:this[Lu7]?.servername||H});if(G!==200)f.on("error",tm5).destroy(),W(new rm5(`Proxy response (${G}) !== 200 when HTTP Tunneling`));if(P.protocol!=="https:"){W(null,f);return}let Z;if(this[n51])Z=this[n51].servername;else Z=P.servername;this[Ru7]({...P,servername:Z,httpSocket:f},W)}catch(f){if(f.code==="ERR_TLS_CERT_ALTNAME_INVALID")W(new om5(f));else W(f)}}})}dispatch(q,K){let _=qp5(q.headers);if(Kp5(_),_&&!("host"in _)&&!("Host"in _)){let{host:z}=new m_6(q.origin);_.host=z}return this[vO8].dispatch({...q,headers:_},K)}#q(q){if(typeof q==="string")return new m_6(q);else if(q instanceof m_6)return q;else return new m_6(q.uri)}async[Su7](){await this[vO8].close(),await this[kO8].close()}async[Cu7](){await this[vO8].destroy(),await this[kO8].destroy()}}function qp5(q){if(Array.isArray(q)){let K={};for(let _=0;_<q.length;_+=2)K[q[_]]=q[_+1];return K}return q}function Kp5(q){if(q&&Object.keys(q).find((_)=>_.toLowerCase()==="proxy-authorization"))throw new cD6("Proxy-Authorization should be sent in ProxyAgent constructor")}pu7.exports=mu7});var cu7=m((_B$,du7)=>{var _p5=yD6(),{kClose:zp5,kDestroy:Yp5,kClosed:Bu7,kDestroyed:gu7,kDispatch:$p5,kNoProxyAgent:ep6,kHttpProxyAgent:_66,kHttpsProxyAgent:p_6}=Jj(),Fu7=i51(),Ap5=dD6(),Op5={"http:":80,"https:":443},Uu7=!1;class Qu7 extends _p5{#q=null;#K=null;#_=null;constructor(q={}){super();if(this.#_=q,!Uu7)Uu7=!0,process.emitWarning("EnvHttpProxyAgent is experimental, expect them to change at any time.",{code:"UNDICI-EHPA"});let{httpProxy:K,httpsProxy:_,noProxy:z,...Y}=q;this[ep6]=new Ap5(Y);let $=K??process.env.http_proxy??process.env.HTTP_PROXY;if($)this[_66]=new Fu7({...Y,uri:$});else this[_66]=this[ep6];let A=_??process.env.https_proxy??process.env.HTTPS_PROXY;if(A)this[p_6]=new Fu7({...Y,uri:A});else this[p_6]=this[_66];this.#O()}[$p5](q,K){let _=new URL(q.origin);return this.#Y(_).dispatch(q,K)}async[zp5](){if(await this[ep6].close(),!this[_66][Bu7])await this[_66].close();if(!this[p_6][Bu7])await this[p_6].close()}async[Yp5](q){if(await this[ep6].destroy(q),!this[_66][gu7])await this[_66].destroy(q);if(!this[p_6][gu7])await this[p_6].destroy(q)}#Y(q){let{protocol:K,host:_,port:z}=q;if(_=_.replace(/:\d*$/,"").toLowerCase(),z=Number.parseInt(z,10)||Op5[K]||0,!this.#z(_,z))return this[ep6];if(K==="https:")return this[p_6];return this[_66]}#z(q,K){if(this.#$)this.#O();if(this.#K.length===0)return!0;if(this.#q==="*")return!1;for(let _=0;_<this.#K.length;_++){let z=this.#K[_];if(z.port&&z.port!==K)continue;if(!/^[.*]/.test(z.hostname)){if(q===z.hostname)return!1}else if(q.endsWith(z.hostname.replace(/^\*/,"")))return!1}return!0}#O(){let q=this.#_.noProxy??this.#w,K=q.split(/[,\s]/),_=[];for(let z=0;z<K.length;z++){let Y=K[z];if(!Y)continue;let $=Y.match(/^(.+):(\d+)$/);_.push({hostname:($?$[1]:Y).toLowerCase(),port:$?Number.parseInt($[2],10):0})}this.#q=q,this.#K=_}get#$(){if(this.#_.noProxy!==void 0)return!1;return this.#q!==this.#w}get#w(){return process.env.no_proxy??process.env.NO_PROXY??""}}du7.exports=Qu7});var VO8=m((zB$,ru7)=>{var lD6=U6("node:assert"),{kRetryHandlerDefaultRetry:lu7}=Jj(),{RequestRetryError:qB6}=Q$(),{isDisturbed:nu7,parseHeaders:wp5,parseRangeHeader:iu7,wrapRequestBody:jp5}=Yz();function Hp5(q){let K=Date.now();return new Date(q).getTime()-K}class r51{constructor(q,K){let{retryOptions:_,...z}=q,{retry:Y,maxRetries:$,maxTimeout:A,minTimeout:O,timeoutFactor:w,methods:j,errorCodes:H,retryAfter:J,statusCodes:M}=_??{};this.dispatch=K.dispatch,this.handler=K.handler,this.opts={...z,body:jp5(q.body)},this.abort=null,this.aborted=!1,this.retryOpts={retry:Y??r51[lu7],retryAfter:J??!0,maxTimeout:A??30000,minTimeout:O??500,timeoutFactor:w??2,maxRetries:$??5,methods:j??["GET","HEAD","OPTIONS","PUT","DELETE","TRACE"],statusCodes:M??[500,502,503,504,429],errorCodes:H??["ECONNRESET","ECONNREFUSED","ENOTFOUND","ENETDOWN","ENETUNREACH","EHOSTDOWN","EHOSTUNREACH","EPIPE","UND_ERR_SOCKET"]},this.retryCount=0,this.retryCountCheckpoint=0,this.start=0,this.end=null,this.etag=null,this.resume=null,this.handler.onConnect((X)=>{if(this.aborted=!0,this.abort)this.abort(X);else this.reason=X})}onRequestSent(){if(this.handler.onRequestSent)this.handler.onRequestSent()}onUpgrade(q,K,_){if(this.handler.onUpgrade)this.handler.onUpgrade(q,K,_)}onConnect(q){if(this.aborted)q(this.reason);else this.abort=q}onBodySent(q){if(this.handler.onBodySent)return this.handler.onBodySent(q)}static[lu7](q,{state:K,opts:_},z){let{statusCode:Y,code:$,headers:A}=q,{method:O,retryOptions:w}=_,{maxRetries:j,minTimeout:H,maxTimeout:J,timeoutFactor:M,statusCodes:X,errorCodes:P,methods:W}=w,{counter:D}=K;if($&&$!=="UND_ERR_REQ_RETRY"&&!P.includes($)){z(q);return}if(Array.isArray(W)&&!W.includes(O)){z(q);return}if(Y!=null&&Array.isArray(X)&&!X.includes(Y)){z(q);return}if(D>j){z(q);return}let f=A?.["retry-after"];if(f)f=Number(f),f=Number.isNaN(f)?Hp5(f):f*1000;let G=f>0?Math.min(f,J):Math.min(H*M**(D-1),J);setTimeout(()=>z(null),G)}onHeaders(q,K,_,z){let Y=wp5(K);if(this.retryCount+=1,q>=300)if(this.retryOpts.statusCodes.includes(q)===!1)return this.handler.onHeaders(q,K,_,z);else return this.abort(new qB6("Request failed",q,{headers:Y,data:{count:this.retryCount}})),!1;if(this.resume!=null){if(this.resume=null,q!==206&&(this.start>0||q!==200))return this.abort(new qB6("server does not support the range header and the payload was partially consumed",q,{headers:Y,data:{count:this.retryCount}})),!1;let A=iu7(Y["content-range"]);if(!A)return this.abort(new qB6("Content-Range mismatch",q,{headers:Y,data:{count:this.retryCount}})),!1;if(this.etag!=null&&this.etag!==Y.etag)return this.abort(new qB6("ETag mismatch",q,{headers:Y,data:{count:this.retryCount}})),!1;let{start:O,size:w,end:j=w-1}=A;return lD6(this.start===O,"content-range mismatch"),lD6(this.end==null||this.end===j,"content-range mismatch"),this.resume=_,!0}if(this.end==null){if(q===206){let A=iu7(Y["content-range"]);if(A==null)return this.handler.onHeaders(q,K,_,z);let{start:O,size:w,end:j=w-1}=A;lD6(O!=null&&Number.isFinite(O),"content-range mismatch"),lD6(j!=null&&Number.isFinite(j),"invalid content-length"),this.start=O,this.end=j}if(this.end==null){let A=Y["content-length"];this.end=A!=null?Number(A)-1:null}if(lD6(Number.isFinite(this.start)),lD6(this.end==null||Number.isFinite(this.end),"invalid content-length"),this.resume=_,this.etag=Y.etag!=null?Y.etag:null,this.etag!=null&&this.etag.startsWith("W/"))this.etag=null;return this.handler.onHeaders(q,K,_,z)}let $=new qB6("Request failed",q,{headers:Y,data:{count:this.retryCount}});return this.abort($),!1}onData(q){return this.start+=q.length,this.handler.onData(q)}onComplete(q){return this.retryCount=0,this.handler.onComplete(q)}onError(q){if(this.aborted||nu7(this.opts.body))return this.handler.onError(q);if(this.retryCount-this.retryCountCheckpoint>0)this.retryCount=this.retryCountCheckpoint+(this.retryCount-this.retryCountCheckpoint);else this.retryCount+=1;this.retryOpts.retry(q,{state:{counter:this.retryCount},opts:{retryOptions:this.retryOpts,...this.opts}},K.bind(this));function K(_){if(_!=null||this.aborted||nu7(this.opts.body))return this.handler.onError(_);if(this.start!==0){let z={range:`bytes=${this.start}-${this.end??""}`};if(this.etag!=null)z["if-match"]=this.etag;this.opts={...this.opts,headers:{...this.opts.headers,...z}}}try{this.retryCountCheckpoint=this.retryCount,this.dispatch(this.opts,this)}catch(z){this.handler.onError(z)}}}}ru7.exports=r51});var su7=m((YB$,au7)=>{var Jp5=hp6(),Mp5=VO8();class ou7 extends Jp5{#q=null;#K=null;constructor(q,K={}){super(K);this.#q=q,this.#K=K}dispatch(q,K){let _=new Mp5({...q,retryOptions:this.#K},{dispatch:this.#q.dispatch.bind(this.#q),handler:K});return this.#q.dispatch(q,_)}close(){return this.#q.close()}destroy(){return this.#q.destroy()}}au7.exports=ou7});var e51=m(($B$,Om7)=>{var _m7=U6("node:assert"),{Readable:Xp5}=U6("node:stream"),{RequestAbortedError:zm7,NotSupportedError:Pp5,InvalidArgumentError:Wp5,AbortError:o51}=Q$(),Ym7=Yz(),{ReadableStreamFrom:Dp5}=Yz(),yE=Symbol("kConsume"),KB6=Symbol("kReading"),z66=Symbol("kBody"),tu7=Symbol("kAbort"),$m7=Symbol("kContentType"),eu7=Symbol("kContentLength"),fp5=()=>{};class Am7 extends Xp5{constructor({resume:q,abort:K,contentType:_="",contentLength:z,highWaterMark:Y=65536}){super({autoDestroy:!0,read:q,highWaterMark:Y});this._readableState.dataEmitted=!1,this[tu7]=K,this[yE]=null,this[z66]=null,this[$m7]=_,this[eu7]=z,this[KB6]=!1}destroy(q){if(!q&&!this._readableState.endEmitted)q=new zm7;if(q)this[tu7]();return super.destroy(q)}_destroy(q,K){if(!this[KB6])setImmediate(()=>{K(q)});else K(q)}on(q,...K){if(q==="data"||q==="readable")this[KB6]=!0;return super.on(q,...K)}addListener(q,...K){return this.on(q,...K)}off(q,...K){let _=super.off(q,...K);if(q==="data"||q==="readable")this[KB6]=this.listenerCount("data")>0||this.listenerCount("readable")>0;return _}removeListener(q,...K){return this.off(q,...K)}push(q){if(this[yE]&&q!==null)return s51(this[yE],q),this[KB6]?super.push(q):!0;return super.push(q)}async text(){return _B6(this,"text")}async json(){return _B6(this,"json")}async blob(){return _B6(this,"blob")}async bytes(){return _B6(this,"bytes")}async arrayBuffer(){return _B6(this,"arrayBuffer")}async formData(){throw new Pp5}get bodyUsed(){return Ym7.isDisturbed(this)}get body(){if(!this[z66]){if(this[z66]=Dp5(this),this[yE])this[z66].getReader(),_m7(this[z66].locked)}return this[z66]}async dump(q){let K=Number.isFinite(q?.limit)?q.limit:131072,_=q?.signal;if(_!=null&&(typeof _!=="object"||!("aborted"in _)))throw new Wp5("signal must be an AbortSignal");if(_?.throwIfAborted(),this._readableState.closeEmitted)return null;return await new Promise((z,Y)=>{if(this[eu7]>K)this.destroy(new o51);let $=()=>{this.destroy(_.reason??new o51)};_?.addEventListener("abort",$),this.on("close",function(){if(_?.removeEventListener("abort",$),_?.aborted)Y(_.reason??new o51);else z(null)}).on("error",fp5).on("data",function(A){if(K-=A.length,K<=0)this.destroy()}).resume()})}}function Zp5(q){return q[z66]&&q[z66].locked===!0||q[yE]}function Gp5(q){return Ym7.isDisturbed(q)||Zp5(q)}async function _B6(q,K){return _m7(!q[yE]),new Promise((_,z)=>{if(Gp5(q)){let Y=q._readableState;if(Y.destroyed&&Y.closeEmitted===!1)q.on("error",($)=>{z($)}).on("close",()=>{z(TypeError("unusable"))});else z(Y.errored??TypeError("unusable"))}else queueMicrotask(()=>{q[yE]={type:K,stream:q,resolve:_,reject:z,length:0,body:[]},q.on("error",function(Y){t51(this[yE],Y)}).on("close",function(){if(this[yE].body!==null)t51(this[yE],new zm7)}),Tp5(q[yE])})})}function Tp5(q){if(q.body===null)return;let{_readableState:K}=q.stream;if(K.bufferIndex){let _=K.bufferIndex,z=K.buffer.length;for(let Y=_;Y<z;Y++)s51(q,K.buffer[Y])}else for(let _ of K.buffer)s51(q,_);if(K.endEmitted)Km7(this[yE]);else q.stream.on("end",function(){Km7(this[yE])});q.stream.resume();while(q.stream.read()!=null);}function a51(q,K){if(q.length===0||K===0)return"";let _=q.length===1?q[0]:Buffer.concat(q,K),z=_.length,Y=z>2&&_[0]===239&&_[1]===187&&_[2]===191?3:0;return _.utf8Slice(Y,z)}function qm7(q,K){if(q.length===0||K===0)return new Uint8Array(0);if(q.length===1)return new Uint8Array(q[0]);let _=new Uint8Array(Buffer.allocUnsafeSlow(K).buffer),z=0;for(let Y=0;Y<q.length;++Y){let $=q[Y];_.set($,z),z+=$.length}return _}function Km7(q){let{type:K,body:_,resolve:z,stream:Y,length:$}=q;try{if(K==="text")z(a51(_,$));else if(K==="json")z(JSON.parse(a51(_,$)));else if(K==="arrayBuffer")z(qm7(_,$).buffer);else if(K==="blob")z(new Blob(_,{type:Y[$m7]}));else if(K==="bytes")z(qm7(_,$));t51(q)}catch(A){Y.destroy(A)}}function s51(q,K){q.length+=K.length,q.body.push(K)}function t51(q,K){if(q.body===null)return;if(K)q.reject(K);else q.resolve();q.type=null,q.stream=null,q.resolve=null,q.reject=null,q.length=0,q.body=null}Om7.exports={Readable:Am7,chunksDecode:a51}});var q31=m((AB$,Mm7)=>{var vp5=U6("node:assert"),{ResponseStatusCodeError:wm7}=Q$(),{chunksDecode:jm7}=e51();async function kp5({callback:q,body:K,contentType:_,statusCode:z,statusMessage:Y,headers:$}){vp5(K);let A=[],O=0;try{for await(let J of K)if(A.push(J),O+=J.length,O>131072){A=[],O=0;break}}catch{A=[],O=0}let w=`Response status code ${z}${Y?`: ${Y}`:""}`;if(z===204||!_||!O){queueMicrotask(()=>q(new wm7(w,z,$)));return}let j=Error.stackTraceLimit;Error.stackTraceLimit=0;let H;try{if(Hm7(_))H=JSON.parse(jm7(A,O));else if(Jm7(_))H=jm7(A,O)}catch{}finally{Error.stackTraceLimit=j}queueMicrotask(()=>q(new wm7(w,z,$,H)))}var Hm7=(q)=>{return q.length>15&&q[11]==="/"&&q[0]==="a"&&q[1]==="p"&&q[2]==="p"&&q[3]==="l"&&q[4]==="i"&&q[5]==="c"&&q[6]==="a"&&q[7]==="t"&&q[8]==="i"&&q[9]==="o"&&q[10]==="n"&&q[12]==="j"&&q[13]==="s"&&q[14]==="o"&&q[15]==="n"},Jm7=(q)=>{return q.length>4&&q[4]==="/"&&q[0]==="t"&&q[1]==="e"&&q[2]==="x"&&q[3]==="t"};Mm7.exports={getResolveErrorBodyCallback:kp5,isContentTypeApplicationJson:Hm7,isContentTypeText:Jm7}});var Wm7=m((OB$,_31)=>{var Vp5=U6("node:assert"),{Readable:Np5}=e51(),{InvalidArgumentError:nD6,RequestAbortedError:Xm7}=Q$(),EE=Yz(),{getResolveErrorBodyCallback:yp5}=q31(),{AsyncResource:Ep5}=U6("node:async_hooks");class K31 extends Ep5{constructor(q,K){if(!q||typeof q!=="object")throw new nD6("invalid opts");let{signal:_,method:z,opaque:Y,body:$,onInfo:A,responseHeaders:O,throwOnError:w,highWaterMark:j}=q;try{if(typeof K!=="function")throw new nD6("invalid callback");if(j&&(typeof j!=="number"||j<0))throw new nD6("invalid highWaterMark");if(_&&typeof _.on!=="function"&&typeof _.addEventListener!=="function")throw new nD6("signal must be an EventEmitter or EventTarget");if(z==="CONNECT")throw new nD6("invalid method");if(A&&typeof A!=="function")throw new nD6("invalid onInfo callback");super("UNDICI_REQUEST")}catch(H){if(EE.isStream($))EE.destroy($.on("error",EE.nop),H);throw H}if(this.method=z,this.responseHeaders=O||null,this.opaque=Y||null,this.callback=K,this.res=null,this.abort=null,this.body=$,this.trailers={},this.context=null,this.onInfo=A||null,this.throwOnError=w,this.highWaterMark=j,this.signal=_,this.reason=null,this.removeAbortListener=null,EE.isStream($))$.on("error",(H)=>{this.onError(H)});if(this.signal)if(this.signal.aborted)this.reason=this.signal.reason??new Xm7;else this.removeAbortListener=EE.addAbortListener(this.signal,()=>{if(this.reason=this.signal.reason??new Xm7,this.res)EE.destroy(this.res.on("error",EE.nop),this.reason);else if(this.abort)this.abort(this.reason);if(this.removeAbortListener)this.res?.off("close",this.removeAbortListener),this.removeAbortListener(),this.removeAbortListener=null})}onConnect(q,K){if(this.reason){q(this.reason);return}Vp5(this.callback),this.abort=q,this.context=K}onHeaders(q,K,_,z){let{callback:Y,opaque:$,abort:A,context:O,responseHeaders:w,highWaterMark:j}=this,H=w==="raw"?EE.parseRawHeaders(K):EE.parseHeaders(K);if(q<200){if(this.onInfo)this.onInfo({statusCode:q,headers:H});return}let J=w==="raw"?EE.parseHeaders(K):H,M=J["content-type"],X=J["content-length"],P=new Np5({resume:_,abort:A,contentType:M,contentLength:this.method!=="HEAD"&&X?Number(X):null,highWaterMark:j});if(this.removeAbortListener)P.on("close",this.removeAbortListener);if(this.callback=null,this.res=P,Y!==null)if(this.throwOnError&&q>=400)this.runInAsyncScope(yp5,null,{callback:Y,body:P,contentType:M,statusCode:q,statusMessage:z,headers:H});else this.runInAsyncScope(Y,null,null,{statusCode:q,headers:H,trailers:this.trailers,opaque:$,body:P,context:O})}onData(q){return this.res.push(q)}onComplete(q){EE.parseHeaders(q,this.trailers),this.res.push(null)}onError(q){let{res:K,callback:_,body:z,opaque:Y}=this;if(_)this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(_,null,q,{opaque:Y})});if(K)this.res=null,queueMicrotask(()=>{EE.destroy(K,q)});if(z)this.body=null,EE.destroy(z,q);if(this.removeAbortListener)K?.off("close",this.removeAbortListener),this.removeAbortListener(),this.removeAbortListener=null}}function Pm7(q,K){if(K===void 0)return new Promise((_,z)=>{Pm7.call(this,q,(Y,$)=>{return Y?z(Y):_($)})});try{this.dispatch(q,new K31(q,K))}catch(_){if(typeof K!=="function")throw _;let z=q?.opaque;queueMicrotask(()=>K(_,{opaque:z}))}}_31.exports=Pm7;_31.exports.RequestHandler=K31});var zB6=m((wB$,Zm7)=>{var{addAbortListener:Lp5}=Yz(),{RequestAbortedError:Rp5}=Q$(),iD6=Symbol("kListener"),dB=Symbol("kSignal");function Dm7(q){if(q.abort)q.abort(q[dB]?.reason);else q.reason=q[dB]?.reason??new Rp5;fm7(q)}function hp5(q,K){if(q.reason=null,q[dB]=null,q[iD6]=null,!K)return;if(K.aborted){Dm7(q);return}q[dB]=K,q[iD6]=()=>{Dm7(q)},Lp5(q[dB],q[iD6])}function fm7(q){if(!q[dB])return;if("removeEventListener"in q[dB])q[dB].removeEventListener("abort",q[iD6]);else q[dB].removeListener("abort",q[iD6]);q[dB]=null,q[iD6]=null}Zm7.exports={addSignal:hp5,removeSignal:fm7}});var Vm7=m((jB$,km7)=>{var Sp5=U6("node:assert"),{finished:Cp5,PassThrough:bp5}=U6("node:stream"),{InvalidArgumentError:rD6,InvalidReturnValueError:xp5}=Q$(),MI=Yz(),{getResolveErrorBodyCallback:Ip5}=q31(),{AsyncResource:up5}=U6("node:async_hooks"),{addSignal:mp5,removeSignal:Gm7}=zB6();class Tm7 extends up5{constructor(q,K,_){if(!q||typeof q!=="object")throw new rD6("invalid opts");let{signal:z,method:Y,opaque:$,body:A,onInfo:O,responseHeaders:w,throwOnError:j}=q;try{if(typeof _!=="function")throw new rD6("invalid callback");if(typeof K!=="function")throw new rD6("invalid factory");if(z&&typeof z.on!=="function"&&typeof z.addEventListener!=="function")throw new rD6("signal must be an EventEmitter or EventTarget");if(Y==="CONNECT")throw new rD6("invalid method");if(O&&typeof O!=="function")throw new rD6("invalid onInfo callback");super("UNDICI_STREAM")}catch(H){if(MI.isStream(A))MI.destroy(A.on("error",MI.nop),H);throw H}if(this.responseHeaders=w||null,this.opaque=$||null,this.factory=K,this.callback=_,this.res=null,this.abort=null,this.context=null,this.trailers=null,this.body=A,this.onInfo=O||null,this.throwOnError=j||!1,MI.isStream(A))A.on("error",(H)=>{this.onError(H)});mp5(this,z)}onConnect(q,K){if(this.reason){q(this.reason);return}Sp5(this.callback),this.abort=q,this.context=K}onHeaders(q,K,_,z){let{factory:Y,opaque:$,context:A,callback:O,responseHeaders:w}=this,j=w==="raw"?MI.parseRawHeaders(K):MI.parseHeaders(K);if(q<200){if(this.onInfo)this.onInfo({statusCode:q,headers:j});return}this.factory=null;let H;if(this.throwOnError&&q>=400){let X=(w==="raw"?MI.parseHeaders(K):j)["content-type"];H=new bp5,this.callback=null,this.runInAsyncScope(Ip5,null,{callback:O,body:H,contentType:X,statusCode:q,statusMessage:z,headers:j})}else{if(Y===null)return;if(H=this.runInAsyncScope(Y,null,{statusCode:q,headers:j,opaque:$,context:A}),!H||typeof H.write!=="function"||typeof H.end!=="function"||typeof H.on!=="function")throw new xp5("expected Writable");Cp5(H,{readable:!1},(M)=>{let{callback:X,res:P,opaque:W,trailers:D,abort:f}=this;if(this.res=null,M||!P.readable)MI.destroy(P,M);if(this.callback=null,this.runInAsyncScope(X,null,M||null,{opaque:W,trailers:D}),M)f()})}return H.on("drain",_),this.res=H,(H.writableNeedDrain!==void 0?H.writableNeedDrain:H._writableState?.needDrain)!==!0}onData(q){let{res:K}=this;return K?K.write(q):!0}onComplete(q){let{res:K}=this;if(Gm7(this),!K)return;this.trailers=MI.parseHeaders(q),K.end()}onError(q){let{res:K,callback:_,opaque:z,body:Y}=this;if(Gm7(this),this.factory=null,K)this.res=null,MI.destroy(K,q);else if(_)this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(_,null,q,{opaque:z})});if(Y)this.body=null,MI.destroy(Y,q)}}function vm7(q,K,_){if(_===void 0)return new Promise((z,Y)=>{vm7.call(this,q,K,($,A)=>{return $?Y($):z(A)})});try{this.dispatch(q,new Tm7(q,K,_))}catch(z){if(typeof _!=="function")throw z;let Y=q?.opaque;queueMicrotask(()=>_(z,{opaque:Y}))}}km7.exports=vm7});var Sm7=m((HB$,hm7)=>{var{Readable:ym7,Duplex:pp5,PassThrough:Bp5}=U6("node:stream"),{InvalidArgumentError:YB6,InvalidReturnValueError:gp5,RequestAbortedError:z31}=Q$(),Rh=Yz(),{AsyncResource:Fp5}=U6("node:async_hooks"),{addSignal:Up5,removeSignal:Qp5}=zB6(),Nm7=U6("node:assert"),oD6=Symbol("resume");class Em7 extends ym7{constructor(){super({autoDestroy:!0});this[oD6]=null}_read(){let{[oD6]:q}=this;if(q)this[oD6]=null,q()}_destroy(q,K){this._read(),K(q)}}class Lm7 extends ym7{constructor(q){super({autoDestroy:!0});this[oD6]=q}_read(){this[oD6]()}_destroy(q,K){if(!q&&!this._readableState.endEmitted)q=new z31;K(q)}}class Rm7 extends Fp5{constructor(q,K){if(!q||typeof q!=="object")throw new YB6("invalid opts");if(typeof K!=="function")throw new YB6("invalid handler");let{signal:_,method:z,opaque:Y,onInfo:$,responseHeaders:A}=q;if(_&&typeof _.on!=="function"&&typeof _.addEventListener!=="function")throw new YB6("signal must be an EventEmitter or EventTarget");if(z==="CONNECT")throw new YB6("invalid method");if($&&typeof $!=="function")throw new YB6("invalid onInfo callback");super("UNDICI_PIPELINE");this.opaque=Y||null,this.responseHeaders=A||null,this.handler=K,this.abort=null,this.context=null,this.onInfo=$||null,this.req=new Em7().on("error",Rh.nop),this.ret=new pp5({readableObjectMode:q.objectMode,autoDestroy:!0,read:()=>{let{body:O}=this;if(O?.resume)O.resume()},write:(O,w,j)=>{let{req:H}=this;if(H.push(O,w)||H._readableState.destroyed)j();else H[oD6]=j},destroy:(O,w)=>{let{body:j,req:H,res:J,ret:M,abort:X}=this;if(!O&&!M._readableState.endEmitted)O=new z31;if(X&&O)X();Rh.destroy(j,O),Rh.destroy(H,O),Rh.destroy(J,O),Qp5(this),w(O)}}).on("prefinish",()=>{let{req:O}=this;O.push(null)}),this.res=null,Up5(this,_)}onConnect(q,K){let{ret:_,res:z}=this;if(this.reason){q(this.reason);return}Nm7(!z,"pipeline cannot be retried"),Nm7(!_.destroyed),this.abort=q,this.context=K}onHeaders(q,K,_){let{opaque:z,handler:Y,context:$}=this;if(q<200){if(this.onInfo){let O=this.responseHeaders==="raw"?Rh.parseRawHeaders(K):Rh.parseHeaders(K);this.onInfo({statusCode:q,headers:O})}return}this.res=new Lm7(_);let A;try{this.handler=null;let O=this.responseHeaders==="raw"?Rh.parseRawHeaders(K):Rh.parseHeaders(K);A=this.runInAsyncScope(Y,null,{statusCode:q,headers:O,opaque:z,body:this.res,context:$})}catch(O){throw this.res.on("error",Rh.nop),O}if(!A||typeof A.on!=="function")throw new gp5("expected Readable");A.on("data",(O)=>{let{ret:w,body:j}=this;if(!w.push(O)&&j.pause)j.pause()}).on("error",(O)=>{let{ret:w}=this;Rh.destroy(w,O)}).on("end",()=>{let{ret:O}=this;O.push(null)}).on("close",()=>{let{ret:O}=this;if(!O._readableState.ended)Rh.destroy(O,new z31)}),this.body=A}onData(q){let{res:K}=this;return K.push(q)}onComplete(q){let{res:K}=this;K.push(null)}onError(q){let{ret:K}=this;this.handler=null,Rh.destroy(K,q)}}function dp5(q,K){try{let _=new Rm7(q,K);return this.dispatch({...q,body:_.req},_),_.ret}catch(_){return new Bp5().destroy(_)}}hm7.exports=dp5});var pm7=m((JB$,mm7)=>{var{InvalidArgumentError:Y31,SocketError:cp5}=Q$(),{AsyncResource:lp5}=U6("node:async_hooks"),Cm7=Yz(),{addSignal:np5,removeSignal:bm7}=zB6(),xm7=U6("node:assert");class Im7 extends lp5{constructor(q,K){if(!q||typeof q!=="object")throw new Y31("invalid opts");if(typeof K!=="function")throw new Y31("invalid callback");let{signal:_,opaque:z,responseHeaders:Y}=q;if(_&&typeof _.on!=="function"&&typeof _.addEventListener!=="function")throw new Y31("signal must be an EventEmitter or EventTarget");super("UNDICI_UPGRADE");this.responseHeaders=Y||null,this.opaque=z||null,this.callback=K,this.abort=null,this.context=null,np5(this,_)}onConnect(q,K){if(this.reason){q(this.reason);return}xm7(this.callback),this.abort=q,this.context=null}onHeaders(){throw new cp5("bad upgrade",null)}onUpgrade(q,K,_){xm7(q===101);let{callback:z,opaque:Y,context:$}=this;bm7(this),this.callback=null;let A=this.responseHeaders==="raw"?Cm7.parseRawHeaders(K):Cm7.parseHeaders(K);this.runInAsyncScope(z,null,null,{headers:A,socket:_,opaque:Y,context:$})}onError(q){let{callback:K,opaque:_}=this;if(bm7(this),K)this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(K,null,q,{opaque:_})})}}function um7(q,K){if(K===void 0)return new Promise((_,z)=>{um7.call(this,q,(Y,$)=>{return Y?z(Y):_($)})});try{let _=new Im7(q,K);this.dispatch({...q,method:q.method||"GET",upgrade:q.protocol||"Websocket"},_)}catch(_){if(typeof K!=="function")throw _;let z=q?.opaque;queueMicrotask(()=>K(_,{opaque:z}))}}mm7.exports=um7});var dm7=m((MB$,Qm7)=>{var ip5=U6("node:assert"),{AsyncResource:rp5}=U6("node:async_hooks"),{InvalidArgumentError:$31,SocketError:op5}=Q$(),Bm7=Yz(),{addSignal:ap5,removeSignal:gm7}=zB6();class Fm7 extends rp5{constructor(q,K){if(!q||typeof q!=="object")throw new $31("invalid opts");if(typeof K!=="function")throw new $31("invalid callback");let{signal:_,opaque:z,responseHeaders:Y}=q;if(_&&typeof _.on!=="function"&&typeof _.addEventListener!=="function")throw new $31("signal must be an EventEmitter or EventTarget");super("UNDICI_CONNECT");this.opaque=z||null,this.responseHeaders=Y||null,this.callback=K,this.abort=null,ap5(this,_)}onConnect(q,K){if(this.reason){q(this.reason);return}ip5(this.callback),this.abort=q,this.context=K}onHeaders(){throw new op5("bad connect",null)}onUpgrade(q,K,_){let{callback:z,opaque:Y,context:$}=this;gm7(this),this.callback=null;let A=K;if(A!=null)A=this.responseHeaders==="raw"?Bm7.parseRawHeaders(K):Bm7.parseHeaders(K);this.runInAsyncScope(z,null,null,{statusCode:q,headers:A,socket:_,opaque:Y,context:$})}onError(q){let{callback:K,opaque:_}=this;if(gm7(this),K)this.callback=null,queueMicrotask(()=>{this.runInAsyncScope(K,null,q,{opaque:_})})}}function Um7(q,K){if(K===void 0)return new Promise((_,z)=>{Um7.call(this,q,(Y,$)=>{return Y?z(Y):_($)})});try{let _=new Fm7(q,K);this.dispatch({...q,method:"CONNECT"},_)}catch(_){if(typeof K!=="function")throw _;let z=q?.opaque;queueMicrotask(()=>K(_,{opaque:z}))}}Qm7.exports=Um7});var cm7=m((sp5,aD6)=>{sp5.request=Wm7();sp5.stream=Vm7();sp5.pipeline=Sm7();sp5.upgrade=pm7();sp5.connect=dm7()});var O31=m((XB$,nm7)=>{var{UndiciError:zB5}=Q$(),lm7=Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED");class A31 extends zB5{constructor(q){super(q);Error.captureStackTrace(this,A31),this.name="MockNotMatchedError",this.message=q||"The request does not match any registered mock dispatches",this.code="UND_MOCK_ERR_MOCK_NOT_MATCHED"}static[Symbol.hasInstance](q){return q&&q[lm7]===!0}[lm7]=!0}nm7.exports={MockNotMatchedError:A31}});var sD6=m((PB$,im7)=>{im7.exports={kAgent:Symbol("agent"),kOptions:Symbol("options"),kFactory:Symbol("factory"),kDispatches:Symbol("dispatches"),kDispatchKey:Symbol("dispatch key"),kDefaultHeaders:Symbol("default headers"),kDefaultTrailers:Symbol("default trailers"),kContentLength:Symbol("content length"),kMockAgent:Symbol("mock agent"),kMockAgentSet:Symbol("mock agent set"),kMockAgentGet:Symbol("mock agent get"),kMockDispatch:Symbol("mock dispatch"),kClose:Symbol("close"),kOriginalClose:Symbol("original agent close"),kOrigin:Symbol("origin"),kIsMockActive:Symbol("is mock active"),kNetConnect:Symbol("net connect"),kGetNetConnect:Symbol("get net connect"),kConnected:Symbol("connected")}});var $B6=m((WB$,Yp7)=>{var{MockNotMatchedError:B_6}=O31(),{kDispatches:NO8,kMockAgent:YB5,kOriginalDispatch:$B5,kOrigin:AB5,kGetNetConnect:OB5}=sD6(),{buildURL:wB5}=Yz(),{STATUS_CODES:jB5}=U6("node:http"),{types:{isPromise:HB5}}=U6("node:util");function El(q,K){if(typeof q==="string")return q===K;if(q instanceof RegExp)return q.test(K);if(typeof q==="function")return q(K)===!0;return!1}function om7(q){return Object.fromEntries(Object.entries(q).map(([K,_])=>{return[K.toLocaleLowerCase(),_]}))}function am7(q,K){if(Array.isArray(q)){for(let _=0;_<q.length;_+=2)if(q[_].toLocaleLowerCase()===K.toLocaleLowerCase())return q[_+1];return}else if(typeof q.get==="function")return q.get(K);else return om7(q)[K.toLocaleLowerCase()]}function H31(q){let K=q.slice(),_=[];for(let z=0;z<K.length;z+=2)_.push([K[z],K[z+1]]);return Object.fromEntries(_)}function sm7(q,K){if(typeof q.headers==="function"){if(Array.isArray(K))K=H31(K);return q.headers(K?om7(K):{})}if(typeof q.headers>"u")return!0;if(typeof K!=="object"||typeof q.headers!=="object")return!1;for(let[_,z]of Object.entries(q.headers)){let Y=am7(K,_);if(!El(z,Y))return!1}return!0}function rm7(q){if(typeof q!=="string")return q;let K=q.split("?");if(K.length!==2)return q;let _=new URLSearchParams(K.pop());return _.sort(),[...K,_.toString()].join("?")}function JB5(q,{path:K,method:_,body:z,headers:Y}){let $=El(q.path,K),A=El(q.method,_),O=typeof q.body<"u"?El(q.body,z):!0,w=sm7(q,Y);return $&&A&&O&&w}function tm7(q){if(Buffer.isBuffer(q))return q;else if(q instanceof Uint8Array)return q;else if(q instanceof ArrayBuffer)return q;else if(typeof q==="object")return JSON.stringify(q);else return q.toString()}function em7(q,K){let _=K.query?wB5(K.path,K.query):K.path,z=typeof _==="string"?rm7(_):_,Y=q.filter(({consumed:$})=>!$).filter(({path:$})=>El(rm7($),z));if(Y.length===0)throw new B_6(`Mock dispatch not matched for path '${z}'`);if(Y=Y.filter(({method:$})=>El($,K.method)),Y.length===0)throw new B_6(`Mock dispatch not matched for method '${K.method}' on path '${z}'`);if(Y=Y.filter(({body:$})=>typeof $<"u"?El($,K.body):!0),Y.length===0)throw new B_6(`Mock dispatch not matched for body '${K.body}' on path '${z}'`);if(Y=Y.filter(($)=>sm7($,K.headers)),Y.length===0){let $=typeof K.headers==="object"?JSON.stringify(K.headers):K.headers;throw new B_6(`Mock dispatch not matched for headers '${$}' on path '${z}'`)}return Y[0]}function MB5(q,K,_){let z={timesInvoked:0,times:1,persist:!1,consumed:!1},Y=typeof _==="function"?{callback:_}:{..._},$={...z,...K,pending:!0,data:{error:null,...Y}};return q.push($),$}function w31(q,K){let _=q.findIndex((z)=>{if(!z.consumed)return!1;return JB5(z,K)});if(_!==-1)q.splice(_,1)}function qp7(q){let{path:K,method:_,body:z,headers:Y,query:$}=q;return{path:K,method:_,body:z,headers:Y,query:$}}function j31(q){let K=Object.keys(q),_=[];for(let z=0;z<K.length;++z){let Y=K[z],$=q[Y],A=Buffer.from(`${Y}`);if(Array.isArray($))for(let O=0;O<$.length;++O)_.push(A,Buffer.from(`${$[O]}`));else _.push(A,Buffer.from(`${$}`))}return _}function Kp7(q){return jB5[q]||"unknown"}async function XB5(q){let K=[];for await(let _ of q)K.push(_);return Buffer.concat(K).toString("utf8")}function _p7(q,K){let _=qp7(q),z=em7(this[NO8],_);if(z.timesInvoked++,z.data.callback)z.data={...z.data,...z.data.callback(q)};let{data:{statusCode:Y,data:$,headers:A,trailers:O,error:w},delay:j,persist:H}=z,{timesInvoked:J,times:M}=z;if(z.consumed=!H&&J>=M,z.pending=J<M,w!==null)return w31(this[NO8],_),K.onError(w),!0;if(typeof j==="number"&&j>0)setTimeout(()=>{X(this[NO8])},j);else X(this[NO8]);function X(W,D=$){let f=Array.isArray(q.headers)?H31(q.headers):q.headers,G=typeof D==="function"?D({...q,headers:f}):D;if(HB5(G)){G.then((V)=>X(W,V));return}let Z=tm7(G),T=j31(A),v=j31(O);K.onConnect?.((V)=>K.onError(V),null),K.onHeaders?.(Y,T,P,Kp7(Y)),K.onData?.(Buffer.from(Z)),K.onComplete?.(v),w31(W,_)}function P(){}return!0}function PB5(){let q=this[YB5],K=this[AB5],_=this[$B5];return function(Y,$){if(q.isMockActive)try{_p7.call(this,Y,$)}catch(A){if(A instanceof B_6){let O=q[OB5]();if(O===!1)throw new B_6(`${A.message}: subsequent request to origin ${K} was not allowed (net.connect disabled)`);if(zp7(O,K))_.call(this,Y,$);else throw new B_6(`${A.message}: subsequent request to origin ${K} was not allowed (net.connect is not enabled for this origin)`)}else throw A}else _.call(this,Y,$)}}function zp7(q,K){let _=new URL(K);if(q===!0)return!0;else if(Array.isArray(q)&&q.some((z)=>El(z,_.host)))return!0;return!1}function WB5(q){if(q){let{agent:K,..._}=q;return _}}Yp7.exports={getResponseData:tm7,getMockDispatch:em7,addMockDispatch:MB5,deleteMockDispatch:w31,buildKey:qp7,generateKeyValues:j31,matchValue:El,getResponse:XB5,getStatusText:Kp7,mockDispatch:_p7,buildMockDispatch:PB5,checkNetConnect:zp7,buildMockOptions:WB5,getHeaderByName:am7,buildHeadersFromArray:H31}});var D31=m((GB5,W31)=>{var{getResponseData:DB5,buildKey:fB5,addMockDispatch:J31}=$B6(),{kDispatches:yO8,kDispatchKey:EO8,kDefaultHeaders:M31,kDefaultTrailers:X31,kContentLength:P31,kMockDispatch:LO8}=sD6(),{InvalidArgumentError:cB}=Q$(),{buildURL:ZB5}=Yz();class AB6{constructor(q){this[LO8]=q}delay(q){if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw new cB("waitInMs must be a valid integer > 0");return this[LO8].delay=q,this}persist(){return this[LO8].persist=!0,this}times(q){if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw new cB("repeatTimes must be a valid integer > 0");return this[LO8].times=q,this}}class $p7{constructor(q,K){if(typeof q!=="object")throw new cB("opts must be an object");if(typeof q.path>"u")throw new cB("opts.path must be defined");if(typeof q.method>"u")q.method="GET";if(typeof q.path==="string")if(q.query)q.path=ZB5(q.path,q.query);else{let _=new URL(q.path,"data://");q.path=_.pathname+_.search}if(typeof q.method==="string")q.method=q.method.toUpperCase();this[EO8]=fB5(q),this[yO8]=K,this[M31]={},this[X31]={},this[P31]=!1}createMockScopeDispatchData({statusCode:q,data:K,responseOptions:_}){let z=DB5(K),Y=this[P31]?{"content-length":z.length}:{},$={...this[M31],...Y,..._.headers},A={...this[X31],..._.trailers};return{statusCode:q,data:K,headers:$,trailers:A}}validateReplyParameters(q){if(typeof q.statusCode>"u")throw new cB("statusCode must be defined");if(typeof q.responseOptions!=="object"||q.responseOptions===null)throw new cB("responseOptions must be an object")}reply(q){if(typeof q==="function"){let Y=(A)=>{let O=q(A);if(typeof O!=="object"||O===null)throw new cB("reply options callback must return an object");let w={data:"",responseOptions:{},...O};return this.validateReplyParameters(w),{...this.createMockScopeDispatchData(w)}},$=J31(this[yO8],this[EO8],Y);return new AB6($)}let K={statusCode:q,data:arguments[1]===void 0?"":arguments[1],responseOptions:arguments[2]===void 0?{}:arguments[2]};this.validateReplyParameters(K);let _=this.createMockScopeDispatchData(K),z=J31(this[yO8],this[EO8],_);return new AB6(z)}replyWithError(q){if(typeof q>"u")throw new cB("error must be defined");let K=J31(this[yO8],this[EO8],{error:q});return new AB6(K)}defaultReplyHeaders(q){if(typeof q>"u")throw new cB("headers must be defined");return this[M31]=q,this}defaultReplyTrailers(q){if(typeof q>"u")throw new cB("trailers must be defined");return this[X31]=q,this}replyContentLength(){return this[P31]=!0,this}}GB5.MockInterceptor=$p7;GB5.MockScope=AB6});var Z31=m((DB$,Xp7)=>{var{promisify:kB5}=U6("node:util"),VB5=UD6(),{buildMockDispatch:NB5}=$B6(),{kDispatches:Ap7,kMockAgent:Op7,kClose:wp7,kOriginalClose:jp7,kOrigin:Hp7,kOriginalDispatch:yB5,kConnected:f31}=sD6(),{MockInterceptor:EB5}=D31(),Jp7=Jj(),{InvalidArgumentError:LB5}=Q$();class Mp7 extends VB5{constructor(q,K){super(q,K);if(!K||!K.agent||typeof K.agent.dispatch!=="function")throw new LB5("Argument opts.agent must implement Agent");this[Op7]=K.agent,this[Hp7]=q,this[Ap7]=[],this[f31]=1,this[yB5]=this.dispatch,this[jp7]=this.close.bind(this),this.dispatch=NB5.call(this),this.close=this[wp7]}get[Jp7.kConnected](){return this[f31]}intercept(q){return new EB5(q,this[Ap7])}async[wp7](){await kB5(this[jp7])(),this[f31]=0,this[Op7][Jp7.kClients].delete(this[Hp7])}}Xp7.exports=Mp7});var T31=m((fB$,vp7)=>{var{promisify:RB5}=U6("node:util"),hB5=QD6(),{buildMockDispatch:SB5}=$B6(),{kDispatches:Pp7,kMockAgent:Wp7,kClose:Dp7,kOriginalClose:fp7,kOrigin:Zp7,kOriginalDispatch:CB5,kConnected:G31}=sD6(),{MockInterceptor:bB5}=D31(),Gp7=Jj(),{InvalidArgumentError:xB5}=Q$();class Tp7 extends hB5{constructor(q,K){super(q,K);if(!K||!K.agent||typeof K.agent.dispatch!=="function")throw new xB5("Argument opts.agent must implement Agent");this[Wp7]=K.agent,this[Zp7]=q,this[Pp7]=[],this[G31]=1,this[CB5]=this.dispatch,this[fp7]=this.close.bind(this),this.dispatch=SB5.call(this),this.close=this[Dp7]}get[Gp7.kConnected](){return this[G31]}intercept(q){return new bB5(q,this[Pp7])}async[Dp7](){await RB5(this[fp7])(),this[G31]=0,this[Wp7][Gp7.kClients].delete(this[Zp7])}}vp7.exports=Tp7});var Vp7=m((ZB$,kp7)=>{var IB5={pronoun:"it",is:"is",was:"was",this:"this"},uB5={pronoun:"they",is:"are",was:"were",this:"these"};kp7.exports=class{constructor(K,_){this.singular=K,this.plural=_}pluralize(K){let _=K===1,z=_?IB5:uB5,Y=_?this.singular:this.plural;return{...z,count:K,noun:Y}}}});var yp7=m((GB$,Np7)=>{var{Transform:mB5}=U6("node:stream"),{Console:pB5}=U6("node:console"),BB5=process.versions.icu?"✅":"Y ",gB5=process.versions.icu?"❌":"N ";Np7.exports=class{constructor({disableColors:K}={}){this.transform=new mB5({transform(_,z,Y){Y(null,_)}}),this.logger=new pB5({stdout:this.transform,inspectOptions:{colors:!K&&!0}})}format(K){let _=K.map(({method:z,path:Y,data:{statusCode:$},persist:A,times:O,timesInvoked:w,origin:j})=>({Method:z,Origin:j,Path:Y,"Status code":$,Persistent:A?BB5:gB5,Invocations:w,Remaining:A?1/0:O-w}));return this.logger.table(_),this.transform.read().toString()}}});var Sp7=m((TB$,hp7)=>{var{kClients:g_6}=Jj(),FB5=dD6(),{kAgent:v31,kMockAgentSet:RO8,kMockAgentGet:Ep7,kDispatches:k31,kIsMockActive:hO8,kNetConnect:F_6,kGetNetConnect:UB5,kOptions:SO8,kFactory:CO8}=sD6(),QB5=Z31(),dB5=T31(),{matchValue:cB5,buildMockOptions:lB5}=$B6(),{InvalidArgumentError:Lp7,UndiciError:nB5}=Q$(),iB5=hp6(),rB5=Vp7(),oB5=yp7();class Rp7 extends iB5{constructor(q){super(q);if(this[F_6]=!0,this[hO8]=!0,q?.agent&&typeof q.agent.dispatch!=="function")throw new Lp7("Argument opts.agent must implement Agent");let K=q?.agent?q.agent:new FB5(q);this[v31]=K,this[g_6]=K[g_6],this[SO8]=lB5(q)}get(q){let K=this[Ep7](q);if(!K)K=this[CO8](q),this[RO8](q,K);return K}dispatch(q,K){return this.get(q.origin),this[v31].dispatch(q,K)}async close(){await this[v31].close(),this[g_6].clear()}deactivate(){this[hO8]=!1}activate(){this[hO8]=!0}enableNetConnect(q){if(typeof q==="string"||typeof q==="function"||q instanceof RegExp)if(Array.isArray(this[F_6]))this[F_6].push(q);else this[F_6]=[q];else if(typeof q>"u")this[F_6]=!0;else throw new Lp7("Unsupported matcher. Must be one of String|Function|RegExp.")}disableNetConnect(){this[F_6]=!1}get isMockActive(){return this[hO8]}[RO8](q,K){this[g_6].set(q,K)}[CO8](q){let K=Object.assign({agent:this},this[SO8]);return this[SO8]&&this[SO8].connections===1?new QB5(q,K):new dB5(q,K)}[Ep7](q){let K=this[g_6].get(q);if(K)return K;if(typeof q!=="string"){let _=this[CO8]("http://localhost:9999");return this[RO8](q,_),_}for(let[_,z]of Array.from(this[g_6]))if(z&&typeof _!=="string"&&cB5(_,q)){let Y=this[CO8](q);return this[RO8](q,Y),Y[k31]=z[k31],Y}}[UB5](){return this[F_6]}pendingInterceptors(){let q=this[g_6];return Array.from(q.entries()).flatMap(([K,_])=>_[k31].map((z)=>({...z,origin:K}))).filter(({pending:K})=>K)}assertNoPendingInterceptors({pendingInterceptorsFormatter:q=new oB5}={}){let K=this.pendingInterceptors();if(K.length===0)return;let _=new rB5("interceptor","interceptors").pluralize(K.length);throw new nB5(`
238${_.count} ${_.noun} ${_.is} pending:
239

Callers

nothing calls this directly

Calls 1

onUpgradeMethod · 0.45

Tested by

no test coverage detected