eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 632 kB
JavaScript
import{c as e,n as t,o as n,r,t as i}from"../../_chunks/node/dist-BdTs18CF.js";import{n as a,t as o}from"../../_chunks/node/retry-DkR2H1Y0.js";import{a as s,c,d as l,f as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"../../_chunks/node/version-TugPKZua.js";import{Readable as y}from"stream";import b,{dirname as x,resolve as S}from"path";import{createWriteStream as C}from"fs";import w from"zlib";import{setTimeout as T}from"node:timers/promises";import E from"os";import{pipeline as D}from"stream/promises";import{mkdir as O}from"fs/promises";import*as k from"node:constants";var A=class e extends Error{constructor(t,n){super(t.statusText),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.response=t,this.message=n?.message??``,this.json=n?.json,this.text=n?.text,this.sandboxName=n?.sandboxName,this.sessionId=n?.sessionId}},j=class e extends Error{constructor(t,n,r){super(n),this.name=`StreamError`,this.code=t,this.sessionId=r,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function M(e){return e==null?[]:Array.isArray(e)?e:[e]}var N=e(r(((e,t)=>{var n=o();function r(e,t){function r(r,i){var a=t||{},o;`randomize`in a||(a.randomize=!0),o=n.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var n;try{n=e(s,t)}catch(e){c(e,t);return}Promise.resolve(n).then(r).catch(function(e){c(e,t)})}o.attempt(l)}return new Promise(r)}t.exports=r}))(),1);function P(e){return async(t,n={})=>{let r=Object.assign({minTimeout:10,retries:5,factor:6,maxRetryAfter:20},n.retry);n.onRetry&&(r.onRetry=(e,t)=>{n.onRetry(e,n),n.retry&&n.retry.onRetry&&n.retry.onRetry(e,t)});try{return await(0,N.default)(async i=>{try{if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));let a=await e(t,n);if(a.status===429){let e=parseInt(a.headers.get(`retry-after`)||``,10);if(e&&!isNaN(e)){if(e>r.maxRetryAfter)return a;await T(e*1e3)}throw new A(a)}if(a.status>=500&&a.status<600)throw new A(a);return a}catch(e){if(F(e))return i(e);if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));throw e}},r)}catch(e){if(e instanceof A)return e.response;throw e}}}function F(e){return e!=null&&e.name===`AbortError`}var I=r(((e,t)=>{t.exports={kClose:Symbol(`close`),kDestroy:Symbol(`destroy`),kDispatch:Symbol(`dispatch`),kUrl:Symbol(`url`),kWriting:Symbol(`writing`),kResuming:Symbol(`resuming`),kQueue:Symbol(`queue`),kConnect:Symbol(`connect`),kConnecting:Symbol(`connecting`),kKeepAliveDefaultTimeout:Symbol(`default keep alive timeout`),kKeepAliveMaxTimeout:Symbol(`max keep alive timeout`),kKeepAliveTimeoutThreshold:Symbol(`keep alive timeout threshold`),kKeepAliveTimeoutValue:Symbol(`keep alive timeout`),kKeepAlive:Symbol(`keep alive`),kHeadersTimeout:Symbol(`headers timeout`),kBodyTimeout:Symbol(`body timeout`),kServerName:Symbol(`server name`),kLocalAddress:Symbol(`local address`),kHost:Symbol(`host`),kNoRef:Symbol(`no ref`),kBodyUsed:Symbol(`used`),kBody:Symbol(`abstracted request body`),kRunning:Symbol(`running`),kBlocking:Symbol(`blocking`),kPending:Symbol(`pending`),kSize:Symbol(`size`),kBusy:Symbol(`busy`),kQueued:Symbol(`queued`),kFree:Symbol(`free`),kConnected:Symbol(`connected`),kClosed:Symbol(`closed`),kNeedDrain:Symbol(`need drain`),kReset:Symbol(`reset`),kDestroyed:Symbol.for(`nodejs.stream.destroyed`),kResume:Symbol(`resume`),kOnError:Symbol(`on error`),kMaxHeadersSize:Symbol(`max headers size`),kRunningIdx:Symbol(`running index`),kPendingIdx:Symbol(`pending index`),kError:Symbol(`error`),kClients:Symbol(`clients`),kClient:Symbol(`client`),kParser:Symbol(`parser`),kOnDestroyed:Symbol(`destroy callbacks`),kPipelining:Symbol(`pipelining`),kSocket:Symbol(`socket`),kHostHeader:Symbol(`host header`),kConnector:Symbol(`connector`),kStrictContentLength:Symbol(`strict content length`),kMaxRedirections:Symbol(`maxRedirections`),kMaxRequests:Symbol(`maxRequestsPerClient`),kProxy:Symbol(`proxy agent options`),kCounter:Symbol(`socket request counter`),kMaxResponseSize:Symbol(`max response size`),kHTTP2Session:Symbol(`http2Session`),kHTTP2SessionState:Symbol(`http2Session state`),kRetryHandlerDefaultRetry:Symbol(`retry agent default retry`),kConstruct:Symbol(`constructable`),kListeners:Symbol(`listeners`),kHTTPContext:Symbol(`http context`),kMaxConcurrentStreams:Symbol(`max concurrent streams`),kHTTP2InitialWindowSize:Symbol(`http2 initial window size`),kHTTP2ConnectionWindowSize:Symbol(`http2 connection window size`),kEnableConnectProtocol:Symbol(`http2session connect protocol`),kRemoteSettings:Symbol(`http2session remote settings`),kHTTP2Stream:Symbol(`http2session client stream`),kPingInterval:Symbol(`ping interval`),kNoProxyAgent:Symbol(`no proxy agent`),kHttpProxyAgent:Symbol(`http proxy agent`),kHttpsProxyAgent:Symbol(`https proxy agent`),kSocks5ProxyAgent:Symbol(`socks5 proxy agent`)}})),L=r(((e,t)=>{let n=0,r=1e3,i,a=Symbol(`kFastTimer`),o=[];function s(){n+=499;let e=0,t=o.length;for(;e<t;){let r=o[e];r._state===0?(r._idleStart=n-499,r._state=1):r._state===1&&n>=r._idleStart+r._idleTimeout&&(r._state=-1,r._idleStart=-1,r._onTimeout(r._timerArg)),r._state===-1?(r._state=-2,--t!==0&&(o[e]=o[t])):++e}o.length=t,o.length!==0&&c()}function c(){i?.refresh?i.refresh():(clearTimeout(i),i=setTimeout(s,499),i?.unref())}var l=class{[a]=!0;_state=-2;_idleTimeout=-1;_idleStart=-1;_onTimeout;_timerArg;constructor(e,t,n){this._onTimeout=e,this._idleTimeout=t,this._timerArg=n,this.refresh()}refresh(){this._state===-2&&o.push(this),(!i||o.length===1)&&c(),this._state=0}clear(){this._state=-1,this._idleStart=-1}};t.exports={setTimeout(e,t,n){return t<=r?setTimeout(e,t,n):new l(e,t,n)},clearTimeout(e){e[a]?e.clear():clearTimeout(e)},setFastTimeout(e,t,n){return new l(e,t,n)},clearFastTimeout(e){e.clear()},now(){return n},tick(e=0){n+=e-r+1,s(),s()},reset(){n=0,o.length=0,clearTimeout(i),i=null},kFastTimer:a}})),R=r(((e,t)=>{let n=Symbol.for(`undici.error.UND_ERR`);var r=class extends Error{constructor(e,t){super(e,t),this.name=`UndiciError`,this.code=`UND_ERR`}static[Symbol.hasInstance](e){return e&&e[n]===!0}get[n](){return!0}};let i=Symbol.for(`undici.error.UND_ERR_CONNECT_TIMEOUT`);var a=class extends r{constructor(e){super(e),this.name=`ConnectTimeoutError`,this.message=e||`Connect Timeout Error`,this.code=`UND_ERR_CONNECT_TIMEOUT`}static[Symbol.hasInstance](e){return e&&e[i]===!0}get[i](){return!0}};let o=Symbol.for(`undici.error.UND_ERR_HEADERS_TIMEOUT`);var s=class extends r{constructor(e){super(e),this.name=`HeadersTimeoutError`,this.message=e||`Headers Timeout Error`,this.code=`UND_ERR_HEADERS_TIMEOUT`}static[Symbol.hasInstance](e){return e&&e[o]===!0}get[o](){return!0}};let c=Symbol.for(`undici.error.UND_ERR_HEADERS_OVERFLOW`);var l=class extends r{constructor(e){super(e),this.name=`HeadersOverflowError`,this.message=e||`Headers Overflow Error`,this.code=`UND_ERR_HEADERS_OVERFLOW`}static[Symbol.hasInstance](e){return e&&e[c]===!0}get[c](){return!0}};let u=Symbol.for(`undici.error.UND_ERR_BODY_TIMEOUT`);var d=class extends r{constructor(e){super(e),this.name=`BodyTimeoutError`,this.message=e||`Body Timeout Error`,this.code=`UND_ERR_BODY_TIMEOUT`}static[Symbol.hasInstance](e){return e&&e[u]===!0}get[u](){return!0}};let f=Symbol.for(`undici.error.UND_ERR_INVALID_ARG`);var p=class extends r{constructor(e){super(e),this.name=`InvalidArgumentError`,this.message=e||`Invalid Argument Error`,this.code=`UND_ERR_INVALID_ARG`}static[Symbol.hasInstance](e){return e&&e[f]===!0}get[f](){return!0}};let m=Symbol.for(`undici.error.UND_ERR_INVALID_RETURN_VALUE`);var h=class extends r{constructor(e){super(e),this.name=`InvalidReturnValueError`,this.message=e||`Invalid Return Value Error`,this.code=`UND_ERR_INVALID_RETURN_VALUE`}static[Symbol.hasInstance](e){return e&&e[m]===!0}get[m](){return!0}};let g=Symbol.for(`undici.error.UND_ERR_ABORT`);var _=class extends r{constructor(e){super(e),this.name=`AbortError`,this.message=e||`The operation was aborted`,this.code=`UND_ERR_ABORT`}static[Symbol.hasInstance](e){return e&&e[g]===!0}get[g](){return!0}};let v=Symbol.for(`undici.error.UND_ERR_ABORTED`);var y=class extends _{constructor(e){super(e),this.name=`AbortError`,this.message=e||`Request aborted`,this.code=`UND_ERR_ABORTED`}static[Symbol.hasInstance](e){return e&&e[v]===!0}get[v](){return!0}};let b=Symbol.for(`undici.error.UND_ERR_INFO`);var x=class extends r{constructor(e){super(e),this.name=`InformationalError`,this.message=e||`Request information`,this.code=`UND_ERR_INFO`}static[Symbol.hasInstance](e){return e&&e[b]===!0}get[b](){return!0}};let S=Symbol.for(`undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH`);var C=class extends r{constructor(e){super(e),this.name=`RequestContentLengthMismatchError`,this.message=e||`Request body length does not match content-length header`,this.code=`UND_ERR_REQ_CONTENT_LENGTH_MISMATCH`}static[Symbol.hasInstance](e){return e&&e[S]===!0}get[S](){return!0}};let w=Symbol.for(`undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH`);var T=class extends r{constructor(e){super(e),this.name=`ResponseContentLengthMismatchError`,this.message=e||`Response body length does not match content-length header`,this.code=`UND_ERR_RES_CONTENT_LENGTH_MISMATCH`}static[Symbol.hasInstance](e){return e&&e[w]===!0}get[w](){return!0}};let E=Symbol.for(`undici.error.UND_ERR_DESTROYED`);var D=class extends r{constructor(e){super(e),this.name=`ClientDestroyedError`,this.message=e||`The client is destroyed`,this.code=`UND_ERR_DESTROYED`}static[Symbol.hasInstance](e){return e&&e[E]===!0}get[E](){return!0}};let O=Symbol.for(`undici.error.UND_ERR_CLOSED`);var k=class extends r{constructor(e){super(e),this.name=`ClientClosedError`,this.message=e||`The client is closed`,this.code=`UND_ERR_CLOSED`}static[Symbol.hasInstance](e){return e&&e[O]===!0}get[O](){return!0}};let A=Symbol.for(`undici.error.UND_ERR_SOCKET`);var j=class extends r{constructor(e,t){super(e),this.name=`SocketError`,this.message=e||`Socket error`,this.code=`UND_ERR_SOCKET`,this.socket=t}static[Symbol.hasInstance](e){return e&&e[A]===!0}get[A](){return!0}};let M=Symbol.for(`undici.error.UND_ERR_NOT_SUPPORTED`);var N=class extends r{constructor(e){super(e),this.name=`NotSupportedError`,this.message=e||`Not supported error`,this.code=`UND_ERR_NOT_SUPPORTED`}static[Symbol.hasInstance](e){return e&&e[M]===!0}get[M](){return!0}};let P=Symbol.for(`undici.error.UND_ERR_BPL_MISSING_UPSTREAM`);var F=class extends r{constructor(e){super(e),this.name=`MissingUpstreamError`,this.message=e||`No upstream has been added to the BalancedPool`,this.code=`UND_ERR_BPL_MISSING_UPSTREAM`}static[Symbol.hasInstance](e){return e&&e[P]===!0}get[P](){return!0}};let I=Symbol.for(`undici.error.UND_ERR_HTTP_PARSER`);var L=class extends Error{constructor(e,t,n){super(e),this.name=`HTTPParserError`,this.code=t?`HPE_${t}`:void 0,this.data=n?n.toString():void 0}static[Symbol.hasInstance](e){return e&&e[I]===!0}get[I](){return!0}};let R=Symbol.for(`undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE`);var ee=class extends r{constructor(e){super(e),this.name=`ResponseExceededMaxSizeError`,this.message=e||`Response content exceeded max size`,this.code=`UND_ERR_RES_EXCEEDED_MAX_SIZE`}static[Symbol.hasInstance](e){return e&&e[R]===!0}get[R](){return!0}};let z=Symbol.for(`undici.error.UND_ERR_REQ_RETRY`);var B=class extends r{constructor(e,t,{headers:n,data:r}){super(e),this.name=`RequestRetryError`,this.message=e||`Request retry error`,this.code=`UND_ERR_REQ_RETRY`,this.statusCode=t,this.data=r,this.headers=n}static[Symbol.hasInstance](e){return e&&e[z]===!0}get[z](){return!0}};let V=Symbol.for(`undici.error.UND_ERR_RESPONSE`);var H=class extends r{constructor(e,t,{headers:n,body:r}){super(e),this.name=`ResponseError`,this.message=e||`Response error`,this.code=`UND_ERR_RESPONSE`,this.statusCode=t,this.body=r,this.headers=n}static[Symbol.hasInstance](e){return e&&e[V]===!0}get[V](){return!0}};let te=Symbol.for(`undici.error.UND_ERR_PRX_TLS`);var U=class extends r{constructor(e,t,n={}){super(t,{cause:e,...n}),this.name=`SecureProxyConnectionError`,this.message=t||`Secure Proxy Connection failed`,this.code=`UND_ERR_PRX_TLS`,this.cause=e}static[Symbol.hasInstance](e){return e&&e[te]===!0}get[te](){return!0}};let W=Symbol.for(`undici.error.UND_ERR_MAX_ORIGINS_REACHED`);var ne=class extends r{constructor(e){super(e),this.name=`MaxOriginsReachedError`,this.message=e||`Maximum allowed origins reached`,this.code=`UND_ERR_MAX_ORIGINS_REACHED`}static[Symbol.hasInstance](e){return e&&e[W]===!0}get[W](){return!0}},G=class extends r{constructor(e,t){super(e),this.name=`Socks5ProxyError`,this.message=e||`SOCKS5 proxy error`,this.code=t||`UND_ERR_SOCKS5`}};let K=Symbol.for(`undici.error.UND_ERR_WS_MESSAGE_SIZE_EXCEEDED`);t.exports={AbortError:_,HTTPParserError:L,UndiciError:r,HeadersTimeoutError:s,HeadersOverflowError:l,BodyTimeoutError:d,RequestContentLengthMismatchError:C,ConnectTimeoutError:a,InvalidArgumentError:p,InvalidReturnValueError:h,RequestAbortedError:y,ClientDestroyedError:D,ClientClosedError:k,InformationalError:x,SocketError:j,NotSupportedError:N,ResponseContentLengthMismatchError:T,BalancedPoolMissingUpstreamError:F,ResponseExceededMaxSizeError:ee,RequestRetryError:B,ResponseError:H,SecureProxyConnectionError:U,MaxOriginsReachedError:ne,Socks5ProxyError:G,MessageSizeExceededError:class extends r{constructor(e){super(e),this.name=`MessageSizeExceededError`,this.message=e||`Max decompressed message size exceeded`,this.code=`UND_ERR_WS_MESSAGE_SIZE_EXCEEDED`}static[Symbol.hasInstance](e){return e&&e[K]===!0}get[K](){return!0}}}})),ee=r(((e,t)=>{let n=`Accept.Accept-Encoding.Accept-Language.Accept-Ranges.Access-Control-Allow-Credentials.Access-Control-Allow-Headers.Access-Control-Allow-Methods.Access-Control-Allow-Origin.Access-Control-Expose-Headers.Access-Control-Max-Age.Access-Control-Request-Headers.Access-Control-Request-Method.Age.Allow.Alt-Svc.Alt-Used.Authorization.Cache-Control.Clear-Site-Data.Connection.Content-Disposition.Content-Encoding.Content-Language.Content-Length.Content-Location.Content-Range.Content-Security-Policy.Content-Security-Policy-Report-Only.Content-Type.Cookie.Cross-Origin-Embedder-Policy.Cross-Origin-Opener-Policy.Cross-Origin-Resource-Policy.Date.Device-Memory.Downlink.ECT.ETag.Expect.Expect-CT.Expires.Forwarded.From.Host.If-Match.If-Modified-Since.If-None-Match.If-Range.If-Unmodified-Since.Keep-Alive.Last-Modified.Link.Location.Max-Forwards.Origin.Permissions-Policy.Pragma.Proxy-Authenticate.Proxy-Authorization.RTT.Range.Referer.Referrer-Policy.Refresh.Retry-After.Sec-WebSocket-Accept.Sec-WebSocket-Extensions.Sec-WebSocket-Key.Sec-WebSocket-Protocol.Sec-WebSocket-Version.Server.Server-Timing.Service-Worker-Allowed.Service-Worker-Navigation-Preload.Set-Cookie.SourceMap.Strict-Transport-Security.Supports-Loading-Mode.TE.Timing-Allow-Origin.Trailer.Transfer-Encoding.Upgrade.Upgrade-Insecure-Requests.User-Agent.Vary.Via.WWW-Authenticate.X-Content-Type-Options.X-DNS-Prefetch-Control.X-Frame-Options.X-Permitted-Cross-Domain-Policies.X-Powered-By.X-Requested-With.X-XSS-Protection`.split(`.`),r={};Object.setPrototypeOf(r,null);let i={};Object.setPrototypeOf(i,null);function a(e){let t=i[e];return t===void 0&&(t=Buffer.from(e)),t}for(let e=0;e<n.length;++e){let t=n[e],i=t.toLowerCase();r[t]=r[i]=i}t.exports={wellknownHeaderNames:n,headerNameLowerCasedRecord:r,getHeaderNameAsBuffer:a}})),z=r(((e,t)=>{let{wellknownHeaderNames:n,headerNameLowerCasedRecord:r}=ee();var i=class e{value=null;left=null;middle=null;right=null;code;constructor(t,n,r){if(r===void 0||r>=t.length)throw TypeError(`Unreachable`);if((this.code=t.charCodeAt(r))>127)throw TypeError(`key must be ascii string`);t.length===++r?this.value=n:this.middle=new e(t,n,r)}add(t,n){let r=t.length;if(r===0)throw TypeError(`Unreachable`);let i=0,a=this;for(;;){let o=t.charCodeAt(i);if(o>127)throw TypeError(`key must be ascii string`);if(a.code===o)if(r===++i){a.value=n;break}else if(a.middle!==null)a=a.middle;else{a.middle=new e(t,n,i);break}else if(a.code<o)if(a.left!==null)a=a.left;else{a.left=new e(t,n,i);break}else if(a.right!==null)a=a.right;else{a.right=new e(t,n,i);break}}}search(e){let t=e.length,n=0,r=this;for(;r!==null&&n<t;){let i=e[n];for(i<=90&&i>=65&&(i|=32);r!==null;){if(i===r.code){if(t===++n)return r;r=r.middle;break}r=r.code<i?r.left:r.right}}return null}},a=class{node=null;insert(e,t){this.node===null?this.node=new i(e,t,0):this.node.add(e,t)}lookup(e){return this.node?.search(e)?.value??null}};let o=new a;for(let e=0;e<n.length;++e){let t=r[n[e]];o.insert(t,t)}t.exports={TernarySearchTree:a,tree:o}})),B=r(((e,t)=>{let r=n(`node:assert`),{kDestroyed:i,kBodyUsed:a,kListeners:o,kBody:s}=I(),{IncomingMessage:c}=n(`node:http`),l=n(`node:stream`),u=n(`node:net`),{stringify:d}=n(`node:querystring`),{EventEmitter:f}=n(`node:events`),p=L(),{InvalidArgumentError:m,ConnectTimeoutError:h}=R(),{headerNameLowerCasedRecord:g}=ee(),{tree:_}=z(),[v,y]=process.versions.node.split(`.`,2).map(e=>Number(e));var b=class{constructor(e){this[s]=e,this[a]=!1}async*[Symbol.asyncIterator](){r(!this[a],`disturbed`),this[a]=!0,yield*this[s]}};function x(){}function S(e){return C(e)?(V(e)===0&&e.on(`data`,function(){r(!1)}),typeof e.readableDidRead!=`boolean`&&(e[a]=!1,f.prototype.on.call(e,`data`,function(){this[a]=!0})),e):e&&typeof e.pipeTo==`function`?new b(e):e&&q(e)?e:e&&typeof e!=`string`&&!ArrayBuffer.isView(e)&&F(e)?new b(e):e}function C(e){return e&&typeof e==`object`&&typeof e.pipe==`function`&&typeof e.on==`function`}function w(e){if(e===null)return!1;if(e instanceof Blob)return!0;if(typeof e!=`object`)return!1;{let t=e[Symbol.toStringTag];return(t===`Blob`||t===`File`)&&(`stream`in e&&typeof e.stream==`function`||`arrayBuffer`in e&&typeof e.arrayBuffer==`function`)}}function T(e){return e.includes(`?`)||e.includes(`#`)}function E(e,t){if(T(e))throw Error(`Query params cannot be passed when url already contains "?" or "#".`);let n=d(t);return n&&(e+=`?`+n),e}function D(e){let t=parseInt(e,10);return t===Number(e)&&t>=0&&t<=65535}function O(e){return e!=null&&e[0]===`h`&&e[1]===`t`&&e[2]===`t`&&e[3]===`p`&&(e[4]===`:`||e[4]===`s`&&e[5]===`:`)}function k(e){if(typeof e==`string`){if(e=new URL(e),!O(e.origin||e.protocol))throw new m("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}if(!e||typeof e!=`object`)throw new m(`Invalid URL: The URL argument must be a non-null object.`);if(!(e instanceof URL)){if(e.port!=null&&e.port!==``&&D(e.port)===!1)throw new m(`Invalid URL: port must be a valid integer or a string representation of an integer.`);if(e.path!=null&&typeof e.path!=`string`)throw new m(`Invalid URL path: the path must be a string or null/undefined.`);if(e.pathname!=null&&typeof e.pathname!=`string`)throw new m(`Invalid URL pathname: the pathname must be a string or null/undefined.`);if(e.hostname!=null&&typeof e.hostname!=`string`)throw new m(`Invalid URL hostname: the hostname must be a string or null/undefined.`);if(e.origin!=null&&typeof e.origin!=`string`)throw new m(`Invalid URL origin: the origin must be a string or null/undefined.`);if(!O(e.origin||e.protocol))throw new m("Invalid URL protocol: the URL must start with `http:` or `https:`.");let t=e.port==null?e.protocol===`https:`?443:80:e.port,n=e.origin==null?`${e.protocol||``}//${e.hostname||``}:${t}`:e.origin,r=e.path==null?`${e.pathname||``}${e.search||``}`:e.path;return n[n.length-1]===`/`&&(n=n.slice(0,n.length-1)),r&&r[0]!==`/`&&(r=`/${r}`),new URL(`${n}${r}`)}if(!O(e.origin||e.protocol))throw new m("Invalid URL protocol: the URL must start with `http:` or `https:`.");return e}function A(e){if(e=k(e),e.pathname!==`/`||e.search||e.hash)throw new m(`invalid url`);return e}function j(e){if(e[0]===`[`){let t=e.indexOf(`]`);return r(t!==-1),e.substring(1,t)}let t=e.indexOf(`:`);return t===-1?e:e.substring(0,t)}function M(e){if(!e)return null;r(typeof e==`string`);let t=j(e);return u.isIP(t)?``:t}function N(e){return JSON.parse(JSON.stringify(e))}function P(e){return e!=null&&typeof e[Symbol.asyncIterator]==`function`}function F(e){return e!=null&&(typeof e[Symbol.iterator]==`function`||typeof e[Symbol.asyncIterator]==`function`)}function B(e){let t=Object.getPrototypeOf(e);return Object.prototype.hasOwnProperty.call(e,Symbol.iterator)||t!=null&&t!==Object.prototype&&typeof e[Symbol.iterator]==`function`}function V(e){if(e==null)return 0;if(C(e)){let t=e._readableState;return t&&t.objectMode===!1&&t.ended===!0&&Number.isFinite(t.length)?t.length:null}else if(w(e))return e.size==null?null:e.size;else if(ae(e))return e.byteLength;return null}function H(e){return e&&!!(e.destroyed||e[i]||l.isDestroyed?.(e))}function te(e,t){e==null||!C(e)||H(e)||(typeof e.destroy==`function`?(Object.getPrototypeOf(e).constructor===c&&(e.socket=null),e.destroy(t)):t&&queueMicrotask(()=>{e.emit(`error`,t)}),e.destroyed!==!0&&(e[i]=!0))}let U=/timeout=(\d+)/;function W(e){let t=e.match(U);return t?parseInt(t[1],10)*1e3:null}function ne(e){return typeof e==`string`?g[e]??e.toLowerCase():_.lookup(e)??e.toString(`latin1`).toLowerCase()}function G(e){return _.lookup(e)??e.toString(`latin1`).toLowerCase()}function K(e,t){t===void 0&&(t={});for(let n=0;n<e.length;n+=2){let r=ne(e[n]),i=t[r];if(i!==void 0)if(Object.hasOwn(t,r))typeof i==`string`&&(i=[i],t[r]=i),i.push(e[n+1].toString(`latin1`));else{let i=typeof e[n+1]==`string`?e[n+1]:Array.isArray(e[n+1])?e[n+1].map(e=>e.toString(`latin1`)):e[n+1].toString(`latin1`);r===`__proto__`?Object.defineProperty(t,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[r]=i}else{let i=typeof e[n+1]==`string`?e[n+1]:Array.isArray(e[n+1])?e[n+1].map(e=>e.toString(`latin1`)):e[n+1].toString(`latin1`);t[r]=i}}return t}function re(e){let t=e.length,n=Array(t),r,i;for(let a=0;a<t;a+=2)r=e[a],i=e[a+1],typeof r!=`string`&&(r=r.toString()),typeof i!=`string`&&(i=i.toString(`latin1`)),n[a]=r,n[a+1]=i;return n}function ie(e){if(!Array.isArray(e))throw TypeError(`expected headers to be an array`);return e.map(e=>Buffer.from(e))}function ae(e){return e instanceof Uint8Array||Buffer.isBuffer(e)}function oe(e,t,n){if(!e||typeof e!=`object`)throw new m(`handler must be an object`);if(typeof e.onRequestStart!=`function`){if(typeof e.onConnect!=`function`)throw new m(`invalid onConnect method`);if(typeof e.onError!=`function`)throw new m(`invalid onError method`);if(typeof e.onBodySent!=`function`&&e.onBodySent!==void 0)throw new m(`invalid onBodySent method`);if(n||t===`CONNECT`){if(typeof e.onUpgrade!=`function`)throw new m(`invalid onUpgrade method`)}else{if(typeof e.onHeaders!=`function`)throw new m(`invalid onHeaders method`);if(typeof e.onData!=`function`)throw new m(`invalid onData method`);if(typeof e.onComplete!=`function`)throw new m(`invalid onComplete method`)}}}function se(e){return!!(e&&(l.isDisturbed(e)||e[a]))}function ce(e){return{localAddress:e.localAddress,localPort:e.localPort,remoteAddress:e.remoteAddress,remotePort:e.remotePort,remoteFamily:e.remoteFamily,timeout:e.timeout,bytesWritten:e.bytesWritten,bytesRead:e.bytesRead}}function le(e){let t;return new ReadableStream({start(){t=e[Symbol.asyncIterator]()},pull(e){return t.next().then(({done:t,value:n})=>{if(t)return queueMicrotask(()=>{e.close(),e.byobRequest?.respond(0)});{let t=Buffer.isBuffer(n)?n:Buffer.from(n);return t.byteLength?e.enqueue(new Uint8Array(t)):this.pull(e)}})},cancel(){return t.return()},type:`bytes`})}function q(e){return e&&typeof e==`object`&&typeof e.append==`function`&&typeof e.delete==`function`&&typeof e.get==`function`&&typeof e.getAll==`function`&&typeof e.has==`function`&&typeof e.set==`function`&&e[Symbol.toStringTag]===`FormData`}function J(e,t){return`addEventListener`in e?(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)):(e.once(`abort`,t),()=>e.removeListener(`abort`,t))}let ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function de(e){return ue[e]===1}let Y=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;function fe(e){if(e.length>=12)return Y.test(e);if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(ue[e.charCodeAt(t)]!==1)return!1;return!0}let pe=/[^\t\x20-\x7e\x80-\xff]/;function X(e){return!pe.test(e)}let me=/^bytes (\d+)-(\d+)\/(\d+)?$/;function he(e){if(e==null||e===``)return{start:0,end:null,size:null};let t=e?e.match(me):null;return t?{start:parseInt(t[1]),end:t[2]?parseInt(t[2]):null,size:t[3]?parseInt(t[3]):null}:null}function ge(e,t,n){return(e[o]??=[]).push([t,n]),e.on(t,n),e}function Z(e){if(e[o]!=null){for(let[t,n]of e[o])e.removeListener(t,n);e[o]=null}return e}function _e(e,t,n){try{t.onError(n),r(t.aborted)}catch(t){e.emit(`error`,t)}}let ve=process.platform===`win32`?(e,t)=>{if(!t.timeout)return x;let n=null,r=null,i=p.setFastTimeout(()=>{n=setImmediate(()=>{r=setImmediate(()=>ye(e.deref(),t))})},t.timeout);return()=>{p.clearFastTimeout(i),clearImmediate(n),clearImmediate(r)}}:(e,t)=>{if(!t.timeout)return x;let n=null,r=p.setFastTimeout(()=>{n=setImmediate(()=>{ye(e.deref(),t)})},t.timeout);return()=>{p.clearFastTimeout(r),clearImmediate(n)}};function ye(e,t){if(e==null)return;let n=`Connect Timeout Error`;Array.isArray(e.autoSelectFamilyAttemptedAddresses)?n+=` (attempted addresses: ${e.autoSelectFamilyAttemptedAddresses.join(`, `)},`:n+=` (attempted address: ${t.hostname}:${t.port},`,n+=` timeout: ${t.timeout}ms)`,te(e,new h(n))}function be(e){if(e[0]===`h`&&e[1]===`t`&&e[2]===`t`&&e[3]===`p`)switch(e[4]){case`:`:return`http:`;case`s`:if(e[5]===`:`)return`https:`}return e.slice(0,e.indexOf(`:`)+1)}let xe=Object.create(null);xe.enumerable=!0;let Se={delete:`DELETE`,DELETE:`DELETE`,get:`GET`,GET:`GET`,head:`HEAD`,HEAD:`HEAD`,options:`OPTIONS`,OPTIONS:`OPTIONS`,post:`POST`,POST:`POST`,put:`PUT`,PUT:`PUT`},Ce={...Se,patch:`patch`,PATCH:`PATCH`};Object.setPrototypeOf(Se,null),Object.setPrototypeOf(Ce,null),t.exports={kEnumerableProperty:xe,isDisturbed:se,isBlobLike:w,parseOrigin:A,parseURL:k,getServerName:M,isStream:C,isIterable:F,hasSafeIterator:B,isAsyncIterable:P,isDestroyed:H,headerNameToString:ne,bufferToLowerCasedHeaderName:G,addListener:ge,removeAllListeners:Z,errorRequest:_e,parseRawHeaders:re,encodeRawHeaders:ie,parseHeaders:K,parseKeepAliveTimeout:W,destroy:te,bodyLength:V,deepClone:N,ReadableStreamFrom:le,isBuffer:ae,assertRequestHandler:oe,getSocketInfo:ce,isFormDataLike:q,pathHasQueryOrFragment:T,serializePathWithQuery:E,addAbortListener:J,isValidHTTPToken:fe,isValidHeaderValue:X,isTokenCharCode:de,parseRangeHeader:he,normalizedMethodRecordsBase:Se,normalizedMethodRecords:Ce,isValidPort:D,isHttpOrHttpsPrefixed:O,nodeMajor:v,nodeMinor:y,safeHTTPMethods:Object.freeze([`GET`,`HEAD`,`OPTIONS`,`TRACE`]),wrapRequestBody:S,setupConnectTimeout:ve,getProtocolFromUrlString:be}})),V=r(((e,t)=>{let{kConnected:n,kPending:r,kRunning:i,kSize:a,kFree:o,kQueued:s}=I();t.exports={ClientStats:class{constructor(e){this.connected=e[n],this.pending=e[r],this.running=e[i],this.size=e[a]}},PoolStats:class{constructor(e){this.connected=e[n],this.free=e[o],this.pending=e[r],this.queued=e[s],this.running=e[i],this.size=e[a]}}}})),H=r(((e,t)=>{let r=n(`node:diagnostics_channel`),i=n(`node:util`),a=i.debuglog(`undici`),o=i.debuglog(`fetch`),s=i.debuglog(`websocket`),c={beforeConnect:r.channel(`undici:client:beforeConnect`),connected:r.channel(`undici:client:connected`),connectError:r.channel(`undici:client:connectError`),sendHeaders:r.channel(`undici:client:sendHeaders`),create:r.channel(`undici:request:create`),bodySent:r.channel(`undici:request:bodySent`),bodyChunkSent:r.channel(`undici:request:bodyChunkSent`),bodyChunkReceived:r.channel(`undici:request:bodyChunkReceived`),headers:r.channel(`undici:request:headers`),trailers:r.channel(`undici:request:trailers`),error:r.channel(`undici:request:error`),open:r.channel(`undici:websocket:open`),close:r.channel(`undici:websocket:close`),socketError:r.channel(`undici:websocket:socket_error`),ping:r.channel(`undici:websocket:ping`),pong:r.channel(`undici:websocket:pong`),proxyConnected:r.channel(`undici:proxy:connected`)},l=!1;function u(e=a){if(!l){if(c.beforeConnect.hasSubscribers||c.connected.hasSubscribers||c.connectError.hasSubscribers||c.sendHeaders.hasSubscribers){l=!0;return}l=!0,r.subscribe(`undici:client:beforeConnect`,t=>{let{connectParams:{version:n,protocol:r,port:i,host:a}}=t;e(`connecting to %s%s using %s%s`,a,i?`:${i}`:``,r,n)}),r.subscribe(`undici:client:connected`,t=>{let{connectParams:{version:n,protocol:r,port:i,host:a}}=t;e(`connected to %s%s using %s%s`,a,i?`:${i}`:``,r,n)}),r.subscribe(`undici:client:connectError`,t=>{let{connectParams:{version:n,protocol:r,port:i,host:a},error:o}=t;e(`connection to %s%s using %s%s errored - %s`,a,i?`:${i}`:``,r,n,o.message)}),r.subscribe(`undici:client:sendHeaders`,t=>{let{request:{method:n,path:r,origin:i}}=t;e(`sending request to %s %s%s`,n,i,r)})}}let d=!1;function f(e=a){if(!d){if(c.headers.hasSubscribers||c.trailers.hasSubscribers||c.error.hasSubscribers){d=!0;return}d=!0,r.subscribe(`undici:request:headers`,t=>{let{request:{method:n,path:r,origin:i},response:{statusCode:a}}=t;e(`received response to %s %s%s - HTTP %d`,n,i,r,a)}),r.subscribe(`undici:request:trailers`,t=>{let{request:{method:n,path:r,origin:i}}=t;e(`trailers received from %s %s%s`,n,i,r)}),r.subscribe(`undici:request:error`,t=>{let{request:{method:n,path:r,origin:i},error:a}=t;e(`request to %s %s%s errored - %s`,n,i,r,a.message)})}}let p=!1;function m(e=s){if(!p){if(c.open.hasSubscribers||c.close.hasSubscribers||c.socketError.hasSubscribers||c.ping.hasSubscribers||c.pong.hasSubscribers){p=!0;return}p=!0,r.subscribe(`undici:websocket:open`,t=>{if(t.address!=null){let{address:n,port:r}=t.address;e(`connection opened %s%s`,n,r?`:${r}`:``)}else e(`connection opened`)}),r.subscribe(`undici:websocket:close`,t=>{let{websocket:n,code:r,reason:i}=t;e(`closed connection to %s - %s %s`,n.url,r,i)}),r.subscribe(`undici:websocket:socket_error`,t=>{e(`connection errored - %s`,t.message)}),r.subscribe(`undici:websocket:ping`,t=>{e(`ping received`)}),r.subscribe(`undici:websocket:pong`,t=>{e(`pong received`)})}}(a.enabled||o.enabled)&&(u(o.enabled?o:a),f(o.enabled?o:a)),s.enabled&&(u(a.enabled?a:s),m(s)),t.exports={channels:c}})),te=r(((e,t)=>{let{InvalidArgumentError:r,NotSupportedError:i}=R(),a=n(`node:assert`),{isValidHTTPToken:o,isValidHeaderValue:s,isStream:c,destroy:l,isBuffer:u,isFormDataLike:d,isIterable:f,hasSafeIterator:p,isBlobLike:m,serializePathWithQuery:h,assertRequestHandler:g,getServerName:_,normalizedMethodRecords:v,getProtocolFromUrlString:y}=B(),{channels:b}=H(),{headerNameLowerCasedRecord:x}=ee(),S=/[^\u0021-\u00ff]/;function C(e){if(typeof e!=`string`||e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}let w=Symbol(`handler`);var T=class{constructor(e,{path:t,method:n,body:i,headers:a,query:x,idempotent:C,blocking:T,upgrade:D,headersTimeout:O,bodyTimeout:k,reset:A,expectContinue:j,servername:M,throwOnError:N,maxRedirections:P,typeOfService:F},I){if(typeof t!=`string`)throw new r(`path must be a string`);if(t[0]!==`/`&&!(t.startsWith(`http://`)||t.startsWith(`https://`))&&n!==`CONNECT`)throw new r(`path must be an absolute URL or start with a slash`);if(S.test(t))throw new r(`invalid request path`);if(typeof n!=`string`)throw new r(`method must be a string`);if(v[n]===void 0&&!o(n))throw new r(`invalid request method`);if(D&&typeof D!=`string`)throw new r(`upgrade must be a string`);if(D&&!s(D))throw new r(`invalid upgrade header`);if(O!=null&&(!Number.isFinite(O)||O<0))throw new r(`invalid headersTimeout`);if(k!=null&&(!Number.isFinite(k)||k<0))throw new r(`invalid bodyTimeout`);if(A!=null&&typeof A!=`boolean`)throw new r(`invalid reset`);if(j!=null&&typeof j!=`boolean`)throw new r(`invalid expectContinue`);if(N!=null)throw new r(`invalid throwOnError`);if(P!=null&&P!==0)throw new r(`maxRedirections is not supported, use the redirect interceptor`);if(F!=null&&(!Number.isInteger(F)||F<0||F>255))throw new r(`typeOfService must be an integer between 0 and 255`);if(this.headersTimeout=O,this.bodyTimeout=k,this.method=n,this.typeOfService=F??0,this.abort=null,i==null)this.body=null;else if(c(i)){this.body=i;let e=this.body._readableState;(!e||!e.autoDestroy)&&(this.endHandler=function(){l(this)},this.body.on(`end`,this.endHandler)),this.errorHandler=e=>{this.abort?this.abort(e):this.error=e},this.body.on(`error`,this.errorHandler)}else if(u(i))this.body=i.byteLength?i:null;else if(ArrayBuffer.isView(i))this.body=i.buffer.byteLength?Buffer.from(i.buffer,i.byteOffset,i.byteLength):null;else if(i instanceof ArrayBuffer)this.body=i.byteLength?Buffer.from(i):null;else if(typeof i==`string`)this.body=i.length?Buffer.from(i):null;else if(d(i)||f(i)||m(i))this.body=i;else throw new r(`body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable`);if(this.completed=!1,this.aborted=!1,this.upgrade=D||null,this.path=x?h(t,x):t,this.origin=e,this.protocol=y(e),this.idempotent=C??(n===`HEAD`||n===`GET`),this.blocking=T??this.method!==`HEAD`,this.reset=A??null,this.host=null,this.contentLength=null,this.contentType=null,this.headers=[],this.expectContinue=j??!1,Array.isArray(a)){if(a.length%2!=0)throw new r(`headers array must be even`);for(let e=0;e<a.length;e+=2)E(this,a[e],a[e+1])}else if(a&&typeof a==`object`)if(p(a))for(let e of a){if(!Array.isArray(e)||e.length!==2)throw new r(`headers must be in key-value pair format`);E(this,e[0],e[1])}else{let e=Object.keys(a);for(let t=0;t<e.length;++t)E(this,e[t],a[e[t]])}else if(a!=null)throw new r(`headers must be an object or an array`);g(I,n,D),this.servername=M||_(this.host)||null,this[w]=I,b.create.hasSubscribers&&b.create.publish({request:this})}onBodySent(e){if(b.bodyChunkSent.hasSubscribers&&b.bodyChunkSent.publish({request:this,chunk:e}),this[w].onBodySent)try{return this[w].onBodySent(e)}catch(e){this.abort(e)}}onRequestSent(){if(b.bodySent.hasSubscribers&&b.bodySent.publish({request:this}),this[w].onRequestSent)try{return this[w].onRequestSent()}catch(e){this.abort(e)}}onConnect(e){if(a(!this.aborted),a(!this.completed),this.error)e(this.error);else return this.abort=e,this[w].onConnect(e)}onResponseStarted(){return this[w].onResponseStarted?.()}onHeaders(e,t,n,r){a(!this.aborted),a(!this.completed),b.headers.hasSubscribers&&b.headers.publish({request:this,response:{statusCode:e,headers:t,statusText:r}});try{return this[w].onHeaders(e,t,n,r)}catch(e){this.abort(e)}}onData(e){a(!this.aborted),a(!this.completed),b.bodyChunkReceived.hasSubscribers&&b.bodyChunkReceived.publish({request:this,chunk:e});try{return this[w].onData(e)}catch(e){return this.abort(e),!1}}onUpgrade(e,t,n){return a(!this.aborted),a(!this.completed),this[w].onUpgrade(e,t,n)}onComplete(e){this.onFinally(),a(!this.aborted),a(!this.completed),this.completed=!0,b.trailers.hasSubscribers&&b.trailers.publish({request:this,trailers:e});try{return this[w].onComplete(e)}catch(e){this.onError(e)}}onError(e){if(this.onFinally(),b.error.hasSubscribers&&b.error.publish({request:this,error:e}),!this.aborted)return this.aborted=!0,this[w].onError(e)}onFinally(){this.errorHandler&&=(this.body.off(`error`,this.errorHandler),null),this.endHandler&&=(this.body.off(`end`,this.endHandler),null)}addHeader(e,t){return E(this,e,t),this}};function E(e,t,n){if(n&&typeof n==`object`&&!Array.isArray(n))throw new r(`invalid ${t} header`);if(n===void 0)return;let a=x[t];if(a===void 0&&(a=t.toLowerCase(),x[a]===void 0&&!o(a)))throw new r(`invalid header key`);if(Array.isArray(n)){let e=[];for(let i=0;i<n.length;i++)if(typeof n[i]==`string`){if(!s(n[i]))throw new r(`invalid ${t} header`);e.push(n[i])}else if(n[i]===null)e.push(``);else if(typeof n[i]==`object`)throw new r(`invalid ${t} header`);else e.push(`${n[i]}`);n=e}else if(typeof n==`string`){if(!s(n))throw new r(`invalid ${t} header`)}else n=n===null?``:`${n}`;if(a===`host`){if(e.host!==null)throw new r(`duplicate host header`);if(typeof n!=`string`)throw new r(`invalid host header`);e.host=n}else if(a===`content-length`){if(e.contentLength!==null)throw new r(`duplicate content-length header`);if(!C(n))throw new r(`invalid content-length header`);e.contentLength=parseInt(n,10)}else if(e.contentType===null&&a===`content-type`)e.contentType=n,e.headers.push(t,n);else if(a===`transfer-encoding`||a===`keep-alive`||a===`upgrade`)throw new r(`invalid ${a} header`);else if(a===`connection`){let t=typeof n==`string`?n:null;if(t===null)throw new r(`invalid connection header`);for(let n of t.toLowerCase().split(`,`)){let t=n.trim();if(!o(t))throw new r(`invalid connection header`);t===`close`&&(e.reset=!0)}}else if(a===`expect`)throw new i(`expect header not supported`);else e.headers.push(t,n)}t.exports=T})),U=r(((e,t)=>{let{InvalidArgumentError:n}=R();t.exports=class e{#e;constructor(e){this.#e=e}static wrap(t){return t.onRequestStart?t:new e(t)}onConnect(e,t){return this.#e.onConnect?.(e,t)}onResponseStarted(){return this.#e.onResponseStarted?.()}onHeaders(e,t,n,r){return this.#e.onHeaders?.(e,t,n,r)}onUpgrade(e,t,n){return this.#e.onUpgrade?.(e,t,n)}onData(e){return this.#e.onData?.(e)}onComplete(e){return this.#e.onComplete?.(e)}onError(e){if(!this.#e.onError)throw e;return this.#e.onError?.(e)}onRequestStart(e,t){this.#e.onConnect?.(t=>e.abort(t),t)}onRequestUpgrade(e,t,n,i){let a=[];for(let[e,t]of Object.entries(n))a.push(Buffer.from(e,`latin1`),r(t));this.#e.onUpgrade?.(t,a,i)}onResponseStart(e,t,n,i){let a=[];for(let[e,t]of Object.entries(n))a.push(Buffer.from(e,`latin1`),r(t));this.#e.onHeaders?.(t,a,()=>e.resume(),i)===!1&&e.pause()}onResponseData(e,t){this.#e.onData?.(t)===!1&&e.pause()}onResponseEnd(e,t){let n=[];for(let[e,i]of Object.entries(t))n.push(Buffer.from(e,`latin1`),r(i));this.#e.onComplete?.(n)}onResponseError(e,t){if(!this.#e.onError)throw new n(`invalid onError method`);this.#e.onError?.(t)}};function r(e){return Array.isArray(e)?e.map(e=>Buffer.from(e,`latin1`)):Buffer.from(e,`latin1`)}})),W=r(((e,t)=>{let r=n(`node:events`),i=U(),a=e=>(t,n)=>e(t,i.wrap(n));t.exports=class extends r{dispatch(){throw Error(`not implemented`)}close(){throw Error(`not implemented`)}destroy(){throw Error(`not implemented`)}compose(...e){let t=Array.isArray(e[0])?e[0]:e,n=this.dispatch.bind(this);for(let e of t)if(e!=null){if(typeof e!=`function`)throw TypeError(`invalid interceptor, expected function received ${typeof e}`);if(n=e(n),n=a(n),n==null||typeof n!=`function`||n.length!==2)throw TypeError(`invalid interceptor`)}return new Proxy(this,{get:(e,t)=>t===`dispatch`?n:e[t]})}}})),ne=r(((e,t)=>{let{parseHeaders:n}=B(),{InvalidArgumentError:r}=R(),i=Symbol(`resume`);var a=class{#e=!1;#t=null;#n=!1;#r;[i]=null;rawHeaders=null;rawTrailers=null;constructor(e){this.#r=e}pause(){this.#e=!0}resume(){this.#e&&(this.#e=!1,this[i]?.())}abort(e){this.#n||(this.#n=!0,this.#t=e,this.#r(e))}get aborted(){return this.#n}get reason(){return this.#t}get paused(){return this.#e}};t.exports=class e{#e;#t;constructor(e){this.#e=e}static unwrap(t){return t.onRequestStart?new e(t):t}onConnect(e,t){this.#t=new a(e),this.#e.onRequestStart?.(this.#t,t)}onResponseStarted(){return this.#e.onResponseStarted?.()}onUpgrade(e,t,r){this.#t.rawHeaders=t,this.#e.onRequestUpgrade?.(this.#t,e,n(t),r)}onHeaders(e,t,r,a){return this.#t[i]=r,this.#t.rawHeaders=t,this.#e.onResponseStart?.(this.#t,e,n(t),a),!this.#t.paused}onData(e){return this.#e.onResponseData?.(this.#t,e),!this.#t.paused}onComplete(e){this.#t.rawTrailers=e,this.#e.onResponseEnd?.(this.#t,n(e))}onError(e){if(!this.#e.onResponseError)throw new r(`invalid onError method`);this.#e.onResponseError?.(this.#t,e)}}})),G=r(((e,t)=>{let n=W(),r=ne(),{ClientDestroyedError:i,ClientClosedError:a,InvalidArgumentError:o}=R(),{kDestroy:s,kClose:c,kClosed:l,kDestroyed:u,kDispatch:d}=I(),f=Symbol(`onDestroyed`),p=Symbol(`onClosed`);t.exports=class extends n{[u]=!1;[f]=null;[l]=!1;[p]=null;get destroyed(){return this[u]}get closed(){return this[l]}close(e){if(e===void 0)return new Promise((e,t)=>{this.close((n,r)=>n?t(n):e(r))});if(typeof e!=`function`)throw new o(`invalid callback`);if(this[u]){let t=new i;queueMicrotask(()=>e(t,null));return}if(this[l]){this[p]?this[p].push(e):queueMicrotask(()=>e(null,null));return}this[l]=!0,this[p]??=[],this[p].push(e);let t=()=>{let e=this[p];this[p]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[c]().then(()=>this.destroy()).then(()=>queueMicrotask(t))}destroy(e,t){if(typeof e==`function`&&(t=e,e=null),t===void 0)return new Promise((t,n)=>{this.destroy(e,(e,r)=>e?n(e):t(r))});if(typeof t!=`function`)throw new o(`invalid callback`);if(this[u]){this[f]?this[f].push(t):queueMicrotask(()=>t(null,null));return}e||=new i,this[u]=!0,this[f]??=[],this[f].push(t);let n=()=>{let e=this[f];this[f]=null;for(let t=0;t<e.length;t++)e[t](null,null)};this[s](e).then(()=>queueMicrotask(n))}dispatch(e,t){if(!t||typeof t!=`object`)throw new o(`handler must be an object`);t=r.unwrap(t);try{if(!e||typeof e!=`object`)throw new o(`opts must be an object.`);if(this[u]||this[f])throw new i;if(this[l])throw new a;return this[d](e,t)}catch(e){if(typeof t.onError!=`function`)throw e;return t.onError(e),!1}}}})),K=r(((e,t)=>{let r=n(`node:net`),i=n(`node:assert`),a=B(),{InvalidArgumentError:o}=R(),s,c=class{constructor(e){this._maxCachedSessions=e,this._sessionCache=new Map,this._sessionRegistry=new FinalizationRegistry(e=>{if(this._sessionCache.size<this._maxCachedSessions)return;let t=this._sessionCache.get(e);t!==void 0&&t.deref()===void 0&&this._sessionCache.delete(e)})}get(e){let t=this._sessionCache.get(e);return t?t.deref():null}set(e,t){if(this._maxCachedSessions!==0){if(this._sessionCache.has(e))this._sessionCache.delete(e);else if(this._sessionCache.size>=this._maxCachedSessions){for(let[e,t]of this._sessionCache)if(t.deref()===void 0){this._sessionCache.delete(e);return}let e=this._sessionCache.keys().next();e.done||this._sessionCache.delete(e.value)}this._sessionCache.set(e,new WeakRef(t)),this._sessionRegistry.register(t,e)}}};function l({allowH2:e,useH2c:t,maxCachedSessions:l,socketPath:u,timeout:d,session:f,...p}){if(l!=null&&(!Number.isInteger(l)||l<0))throw new o(`maxCachedSessions must be a positive integer or zero`);let m={path:u,...p},h=new c(l??100);return d??=1e4,e??=!1,function({hostname:o,host:c,protocol:l,port:u,servername:p,localAddress:g,httpSocket:_},v){let y;if(l===`https:`){s||=n(`node:tls`),p=p||m.servername||a.getServerName(c)||null;let t=p||o;i(t);let r=f||h.get(t)||null;u||=443,y=s.connect({highWaterMark:16384,...m,servername:p,session:r,localAddress:g,ALPNProtocols:e?[`http/1.1`,`h2`]:[`http/1.1`],socket:_,port:u,host:o}),y.on(`session`,function(e){h.set(t,e)})}else i(!_,`httpSocket can only be sent on TLS update`),u||=80,y=r.connect({highWaterMark:64*1024,...m,localAddress:g,port:u,host:o}),t===!0&&(y.alpnProtocol=`h2`);if(m.keepAlive==null||m.keepAlive){let e=m.keepAliveInitialDelay===void 0?6e4:m.keepAliveInitialDelay;y.setKeepAlive(!0,e)}let b=a.setupConnectTimeout(new WeakRef(y),{timeout:d,hostname:o,port:u});return y.setNoDelay(!0).once(l===`https:`?`secureConnect`:`connect`,function(){if(queueMicrotask(b),v){let e=v;v=null,e(null,this)}}).on(`error`,function(e){if(queueMicrotask(b),v){let t=v;v=null,t(e)}}),y}}t.exports=l})),re=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.enumToMap=t;function t(e,t=[],n=[]){let r=(t?.length??0)===0,i=(n?.length??0)===0;return Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`number`&&(r||t.includes(e))&&(i||!n.includes(e))))}})),ie=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_HEADERS=e.MINOR=e.MAJOR=e.HTAB_SP_VCHAR_OBS_TEXT=e.QUOTED_STRING=e.CONNECTION_TOKEN_CHARS=e.HEADER_CHARS=e.TOKEN=e.HEX=e.URL_CHAR=e.USERINFO_CHARS=e.MARK=e.ALPHANUM=e.NUM=e.HEX_MAP=e.NUM_MAP=e.ALPHA=e.STATUSES_HTTP=e.H_METHOD_MAP=e.METHOD_MAP=e.METHODS_RTSP=e.METHODS_ICE=e.METHODS_HTTP=e.HEADER_STATE=e.FINISH=e.STATUSES=e.METHODS=e.LENIENT_FLAGS=e.FLAGS=e.TYPE=e.ERROR=void 0;let t=re();e.ERROR={OK:0,INTERNAL:1,STRICT:2,CR_EXPECTED:25,LF_EXPECTED:3,UNEXPECTED_CONTENT_LENGTH:4,UNEXPECTED_SPACE:30,CLOSED_CONNECTION:5,INVALID_METHOD:6,INVALID_URL:7,INVALID_CONSTANT:8,INVALID_VERSION:9,INVALID_HEADER_TOKEN:10,INVALID_CONTENT_LENGTH:11,INVALID_CHUNK_SIZE:12,INVALID_STATUS:13,INVALID_EOF_STATE:14,INVALID_TRANSFER_ENCODING:15,CB_MESSAGE_BEGIN:16,CB_HEADERS_COMPLETE:17,CB_MESSAGE_COMPLETE:18,CB_CHUNK_HEADER:19,CB_CHUNK_COMPLETE:20,PAUSED:21,PAUSED_UPGRADE:22,PAUSED_H2_UPGRADE:23,USER:24,CB_URL_COMPLETE:26,CB_STATUS_COMPLETE:27,CB_METHOD_COMPLETE:32,CB_VERSION_COMPLETE:33,CB_HEADER_FIELD_COMPLETE:28,CB_HEADER_VALUE_COMPLETE:29,CB_CHUNK_EXTENSION_NAME_COMPLETE:34,CB_CHUNK_EXTENSION_VALUE_COMPLETE:35,CB_RESET:31,CB_PROTOCOL_COMPLETE:38},e.TYPE={BOTH:0,REQUEST:1,RESPONSE:2},e.FLAGS={CONNECTION_KEEP_ALIVE:1,CONNECTION_CLOSE:2,CONNECTION_UPGRADE:4,CHUNKED:8,UPGRADE:16,CONTENT_LENGTH:32,SKIPBODY:64,TRAILING:128,TRANSFER_ENCODING:512},e.LENIENT_FLAGS={HEADERS:1,CHUNKED_LENGTH:2,KEEP_ALIVE:4,TRANSFER_ENCODING:8,VERSION:16,DATA_AFTER_CLOSE:32,OPTIONAL_LF_AFTER_CR:64,OPTIONAL_CRLF_AFTER_CHUNK:128,OPTIONAL_CR_BEFORE_LF:256,SPACES_AFTER_CHUNK_SIZE:512},e.METHODS={DELETE:0,GET:1,HEAD:2,POST:3,PUT:4,CONNECT:5,OPTIONS:6,TRACE:7,COPY:8,LOCK:9,MKCOL:10,MOVE:11,PROPFIND:12,PROPPATCH:13,SEARCH:14,UNLOCK:15,BIND:16,REBIND:17,UNBIND:18,ACL:19,REPORT:20,MKACTIVITY:21,CHECKOUT:22,MERGE:23,"M-SEARCH":24,NOTIFY:25,SUBSCRIBE:26,UNSUBSCRIBE:27,PATCH:28,PURGE:29,MKCALENDAR:30,LINK:31,UNLINK:32,SOURCE:33,PRI:34,DESCRIBE:35,ANNOUNCE:36,SETUP:37,PLAY:38,PAUSE:39,TEARDOWN:40,GET_PARAMETER:41,SET_PARAMETER:42,REDIRECT:43,RECORD:44,FLUSH:45,QUERY:46},e.STATUSES={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,RESPONSE_IS_STALE:110,REVALIDATION_FAILED:111,DISCONNECTED_OPERATION:112,HEURISTIC_EXPIRATION:113,MISCELLANEOUS_WARNING:199,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,ALREADY_REPORTED:208,TRANSFORMATION_APPLIED:214,IM_USED:226,MISCELLANEOUS_PERSISTENT_WARNING:299,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,SWITCH_PROXY:306,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,PAGE_EXPIRED:419,ENHANCE_YOUR_CALM:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE_UNOFFICIAL:430,REQUEST_HEADER_FIELDS_TOO_LARGE:431,LOGIN_TIMEOUT:440,NO_RESPONSE:444,RETRY_WITH:449,BLOCKED_BY_PARENTAL_CONTROL:450,UNAVAILABLE_FOR_LEGAL_REASONS:451,CLIENT_CLOSED_LOAD_BALANCED_REQUEST:460,INVALID_X_FORWARDED_FOR:463,REQUEST_HEADER_TOO_LARGE:494,SSL_CERTIFICATE_ERROR:495,SSL_CERTIFICATE_REQUIRED:496,HTTP_REQUEST_SENT_TO_HTTPS_PORT:497,INVALID_TOKEN:498,CLIENT_CLOSED_REQUEST:499,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,BANDWIDTH_LIMIT_EXCEEDED:509,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511,WEB_SERVER_UNKNOWN_ERROR:520,WEB_SERVER_IS_DOWN:521,CONNECTION_TIMEOUT:522,ORIGIN_IS_UNREACHABLE:523,TIMEOUT_OCCURED:524,SSL_HANDSHAKE_FAILED:525,INVALID_SSL_CERTIFICATE:526,RAILGUN_ERROR:527,SITE_IS_OVERLOADED:529,SITE_IS_FROZEN:530,IDENTITY_PROVIDER_AUTHENTICATION_ERROR:561,NETWORK_READ_TIMEOUT:598,NETWORK_CONNECT_TIMEOUT:599},e.FINISH={SAFE:0,SAFE_WITH_CB:1,UNSAFE:2},e.HEADER_STATE={GENERAL:0,CONNECTION:1,CONTENT_LENGTH:2,TRANSFER_ENCODING:3,UPGRADE:4,CONNECTION_KEEP_ALIVE:5,CONNECTION_CLOSE:6,CONNECTION_UPGRADE:7,TRANSFER_ENCODING_CHUNKED:8},e.METHODS_HTTP=[e.METHODS.DELETE,e.METHODS.GET,e.METHODS.HEAD,e.METHODS.POST,e.METHODS.PUT,e.METHODS.CONNECT,e.METHODS.OPTIONS,e.METHODS.TRACE,e.METHODS.COPY,e.METHODS.LOCK,e.METHODS.MKCOL,e.METHODS.MOVE,e.METHODS.PROPFIND,e.METHODS.PROPPATCH,e.METHODS.SEARCH,e.METHODS.UNLOCK,e.METHODS.BIND,e.METHODS.REBIND,e.METHODS.UNBIND,e.METHODS.ACL,e.METHODS.REPORT,e.METHODS.MKACTIVITY,e.METHODS.CHECKOUT,e.METHODS.MERGE,e.METHODS[`M-SEARCH`],e.METHODS.NOTIFY,e.METHODS.SUBSCRIBE,e.METHODS.UNSUBSCRIBE,e.METHODS.PATCH,e.METHODS.PURGE,e.METHODS.MKCALENDAR,e.METHODS.LINK,e.METHODS.UNLINK,e.METHODS.PRI,e.METHODS.SOURCE,e.METHODS.QUERY],e.METHODS_ICE=[e.METHODS.SOURCE],e.METHODS_RTSP=[e.METHODS.OPTIONS,e.METHODS.DESCRIBE,e.METHODS.ANNOUNCE,e.METHODS.SETUP,e.METHODS.PLAY,e.METHODS.PAUSE,e.METHODS.TEARDOWN,e.METHODS.GET_PARAMETER,e.METHODS.SET_PARAMETER,e.METHODS.REDIRECT,e.METHODS.RECORD,e.METHODS.FLUSH,e.METHODS.GET,e.METHODS.POST],e.METHOD_MAP=(0,t.enumToMap)(e.METHODS),e.H_METHOD_MAP=Object.fromEntries(Object.entries(e.METHODS).filter(([e])=>e.startsWith(`H`))),e.STATUSES_HTTP=[e.STATUSES.CONTINUE,e.STATUSES.SWITCHING_PROTOCOLS,e.STATUSES.PROCESSING,e.STATUSES.EARLY_HINTS,e.STATUSES.RESPONSE_IS_STALE,e.STATUSES.REVALIDATION_FAILED,e.STATUSES.DISCONNECTED_OPERATION,e.STATUSES.HEURISTIC_EXPIRATION,e.STATUSES.MISCELLANEOUS_WARNING,e.STATUSES.OK,e.STATUSES.CREATED,e.STATUSES.ACCEPTED,e.STATUSES.NON_AUTHORITATIVE_INFORMATION,e.STATUSES.NO_CONTENT,e.STATUSES.RE