blink 0.1.75 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/browser/agent/client/index.cjs +11 -11
  2. package/dist/browser/agent/client/index.js +11 -11
  3. package/dist/cli/{auth-DaiN71bn.js → auth-BfmMOPP_.js} +61 -17
  4. package/dist/cli/{chat-DX7ZIS2D.js → chat-CChZ6Dgt.js} +1 -1
  5. package/dist/cli/{connect-jR1Grkvo.js → connect-D8IAxl-3.js} +1 -1
  6. package/dist/cli/connect-DSyrG7KH.js +1 -0
  7. package/dist/cli/{dev-CrtfdJB5.js → dev-IdmzRYNF.js} +42 -42
  8. package/dist/cli/{getMachineId-bsd-BZVr5tA4.js → getMachineId-bsd-Qx2HBGoH.js} +1 -1
  9. package/dist/cli/{getMachineId-darwin-CovNSxTh.js → getMachineId-darwin--C6ZfZar.js} +1 -1
  10. package/dist/cli/{getMachineId-linux-UJ7XEIYa.js → getMachineId-linux-DLLDRjuc.js} +1 -1
  11. package/dist/cli/{getMachineId-unsupported-DfUiEY7G.js → getMachineId-unsupported-C3vmCtXX.js} +1 -1
  12. package/dist/cli/{getMachineId-win-DYgilU22.js → getMachineId-win-CPTJv39f.js} +1 -1
  13. package/dist/cli/index.js +4 -4
  14. package/dist/cli/{init-B6vWokUI.js → init-D-601hh-.js} +2 -2
  15. package/dist/cli/login-CxmH7hHe.js +1 -0
  16. package/dist/cli/undici-DD9e2s8L.js +1 -0
  17. package/dist/node/agent/index.node.cjs +26 -6
  18. package/dist/node/agent/index.node.d.cts +2 -2
  19. package/dist/node/agent/index.node.d.ts +2 -2
  20. package/dist/node/agent/index.node.js +26 -6
  21. package/dist/node/{index.node-B1oQwv9K.d.cts → index.node-CI1vYz48.d.ts} +21 -3
  22. package/dist/node/{index.node-B502ef3C.d.ts → index.node-rD4Zd2xs.d.cts} +21 -3
  23. package/dist/node/test.d.cts +1 -1
  24. package/dist/node/test.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/dist/cli/connect-BccxYFj9.js +0 -1
  27. package/dist/cli/dist-NqrnQGst.js +0 -45
  28. package/dist/cli/login-BbFxbs7E.js +0 -1
  29. package/dist/cli/undici-jJcag_Yq.js +0 -1
  30. /package/dist/cli/{devtools-BS9tk1Y9.js → devtools-BLozvXLU.js} +0 -0
  31. /package/dist/cli/{esm-DmR1E1ox.js → esm-Dh_XeXMF.js} +0 -0
  32. /package/dist/cli/{events-CWgtj8lb.js → events-NKQ6g4j7.js} +0 -0
  33. /package/dist/cli/{execAsync-q2CSWc1b.js → execAsync-Bms0M8aD.js} +0 -0
  34. /package/dist/cli/{open-CSMQaj0E.js → open-FpexaS6S.js} +0 -0
  35. /package/dist/cli/{undici-BG07ys6c.js → undici-DSA55kyn.js} +0 -0
@@ -1,10 +1,30 @@
1
- import{__commonJSMin as e,__esmMin as t,__export as n,__require as r,__toCommonJS as i,__toESM as a}from"../chunk-___ucjiX.js";import*as o from"http";import{convertToModelMessages as s,createUIMessageStream as c,getToolName as l,isToolUIPart as u}from"ai";const d=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function f(e){return e?.then!=null}function p(e){let t=e;return t&&t.then&&t.catch&&t.finally}function m(e,t,n,r){let i=h().then(e).then(t,n);return r&&(i=i.finally(r)),S(i)}function h(e){return e&&p(e)?e:f(e)?{then:(t,n)=>h(e.then(t,n)),catch:t=>h(e.then(e=>e,t)),finally:t=>h(t?x(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return h(t(e))}catch(e){return v(e)}return this},catch(){return this},finally(t){if(t)try{return h(t()).then(()=>e,()=>e)}catch(e){return v(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[d]:`resolved`}}function g(){if(Promise.withResolvers)return Promise.withResolvers();let e,t,n=new Promise(function(n,r){e=n,t=r});return{promise:n,get resolve(){return e},get reject(){return t}}}function _(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),i=0;function a(){let{done:e,value:o}=r.next();if(e)return;let s=!1;function c(){s=!0}return m(function(){return t(o,c,i++)},function(e){if(e&&n?.push(e),!s)return a()})}return a()}function v(e){return{then(t,n){if(n)try{return h(n(e))}catch(e){return v(e)}return this},catch(t){if(t)try{return h(t(e))}catch(e){return v(e)}return this},finally(e){if(e)try{e()}catch(e){return v(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[d]:`rejected`}}function y(e){return e?.[d]===`resolved`}function b(e){return e?.[d]===`rejected`}function x(e,t){return`finally`in e?e.finally(t):e.then(e=>{let n=t();return f(n)?n.then(()=>e):e},e=>{let n=t();if(f(n))return n.then(()=>{throw e});throw e})}function S(e){if(y(e))return e.__fakePromiseValue;if(b(e))throw e.__fakeRejectError;return e}function C(e,t){let n={...t,...e};for(let r of Object.keys(n))r in e&&r in t&&(n[r]=(n,i)=>e[r](n,()=>t[r](n,i)));return n}const ee=e=>({fn(t,n){return t?(...r)=>{let i;return t(e,()=>{i=n(...r)}),i}:n},asyncFn(t,n){return t?(...r)=>{let i;return m(()=>t(e,()=>(i=n(...r),f(i)?i.then(()=>void 0):void 0)),()=>i)}:n}});var w=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};const T={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function E(e){return e?.[T.dispose]!=null}function D(e){return e?.[T.asyncDispose]!=null}const O=globalThis.SuppressedError||w;var k=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return D(e)?this.callbacks.push(()=>e[T.asyncDispose]()):E(e)&&this.callbacks.push(()=>e[T.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[T.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return m(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new O(e,this._error):e,this._iterateCallbacks()))}[T.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};globalThis.SuppressedError,T.dispose,Symbol.toStringTag,globalThis.DisposableStack;const A=globalThis.AsyncDisposableStack||k;globalThis.SuppressedError;var j=e(((exports,t)=>{function n(){return Object.keys(globalThis).some(e=>e.startsWith(`__NEXT`))}t.exports=function(){return!!(globalThis.Deno||globalThis.Bun||n())}})),te=e(((exports,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>n(e,`name`,{value:t,configurable:!0}),s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{URLPattern:()=>fe}),t.exports=l(u);var d=class{type=3;name=``;prefix=``;value=``;suffix=``;modifier=3;constructor(e,t,n,r,i,a){this.type=e,this.name=t,this.prefix=n,this.value=r,this.suffix=i,this.modifier=a}hasCustomName(){return this.name!==``&&typeof this.name!=`number`}};o(d,`Part`);var f=/[$_\p{ID_Start}]/u,p=/[$_\u200C\u200D\p{ID_Continue}]/u,m=`.*`;function h(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}o(h,`isASCII`);function g(e,t=!1){let n=[],r=0;for(;r<e.length;){let i=e[r],a=o(function(i){if(!t)throw TypeError(i);n.push({type:`INVALID_CHAR`,index:r,value:e[r++]})},`ErrorOrInvalid`);if(i===`*`){n.push({type:`ASTERISK`,index:r,value:e[r++]});continue}if(i===`+`||i===`?`){n.push({type:`OTHER_MODIFIER`,index:r,value:e[r++]});continue}if(i===`\\`){n.push({type:`ESCAPED_CHAR`,index:r++,value:e[r++]});continue}if(i===`{`){n.push({type:`OPEN`,index:r,value:e[r++]});continue}if(i===`}`){n.push({type:`CLOSE`,index:r,value:e[r++]});continue}if(i===`:`){let t=``,i=r+1;for(;i<e.length;){let n=e.substr(i,1);if(i===r+1&&f.test(n)||i!==r+1&&p.test(n)){t+=e[i++];continue}break}if(!t){a(`Missing parameter name at ${r}`);continue}n.push({type:`NAME`,index:r,value:t}),r=i;continue}if(i===`(`){let t=1,i=``,o=r+1,s=!1;if(e[o]===`?`){a(`Pattern cannot start with "?" at ${o}`);continue}for(;o<e.length;){if(!h(e[o],!1)){a(`Invalid character '${e[o]}' at ${o}.`),s=!0;break}if(e[o]===`\\`){i+=e[o++]+e[o++];continue}if(e[o]===`)`){if(t--,t===0){o++;break}}else if(e[o]===`(`&&(t++,e[o+1]!==`?`)){a(`Capturing groups are not allowed at ${o}`),s=!0;break}i+=e[o++]}if(s)continue;if(t){a(`Unbalanced pattern at ${r}`);continue}if(!i){a(`Missing pattern at ${r}`);continue}n.push({type:`REGEX`,index:r,value:i}),r=o;continue}n.push({type:`CHAR`,index:r,value:e[r++]})}return n.push({type:`END`,index:r,value:``}),n}o(g,`lexer`);function _(e,t={}){let n=g(e);t.delimiter??=`/#?`,t.prefixes??=`./`;let r=`[^${v(t.delimiter)}]+?`,i=[],a=0,s=0,c=new Set,l=o(e=>{if(s<n.length&&n[s].type===e)return n[s++].value},`tryConsume`),u=o(()=>l(`OTHER_MODIFIER`)??l(`ASTERISK`),`tryConsumeModifier`),f=o(e=>{let t=l(e);if(t!==void 0)return t;let{type:r,index:i}=n[s];throw TypeError(`Unexpected ${r} at ${i}, expected ${e}`)},`mustConsume`),p=o(()=>{let e=``,t;for(;t=l(`CHAR`)??l(`ESCAPED_CHAR`);)e+=t;return e},`consumeText`),h=o(e=>e,`DefaultEncodePart`),_=t.encodePart||h,y=``,b=o(e=>{y+=e},`appendToPendingFixedValue`),x=o(()=>{y.length&&(i.push(new d(3,``,``,_(y),``,3)),y=``)},`maybeAddPartFromPendingFixedValue`),S=o((e,t,n,o,s)=>{let l=3;switch(s){case`?`:l=1;break;case`*`:l=0;break;case`+`:l=2;break}if(!t&&!n&&l===3){b(e);return}if(x(),!t&&!n){if(!e)return;i.push(new d(3,``,``,_(e),``,l));return}let u;u=n?n===`*`?m:n:r;let f=2;u===r?(f=1,u=``):u===m&&(f=0,u=``);let p;if(t?p=t:n&&(p=a++),c.has(p))throw TypeError(`Duplicate name '${p}'.`);c.add(p),i.push(new d(f,p,_(e),u,_(o),l))},`addPart`);for(;s<n.length;){let e=l(`CHAR`),n=l(`NAME`),r=l(`REGEX`);if(!n&&!r&&(r=l(`ASTERISK`)),n||r){let i=e??``;t.prefixes.indexOf(i)===-1&&(b(i),i=``),x();let a=u();S(i,n,r,``,a);continue}let i=e??l(`ESCAPED_CHAR`);if(i){b(i);continue}if(l(`OPEN`)){let e=p(),t=l(`NAME`),n=l(`REGEX`);!t&&!n&&(n=l(`ASTERISK`));let r=p();f(`CLOSE`);let i=u();S(e,t,n,r,i);continue}x(),f(`END`)}return i}o(_,`parse`);function v(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(v,`escapeString`);function y(e){return e&&e.ignoreCase?`ui`:`u`}o(y,`flags`);function b(e,t,n){return S(_(e,n),t,n)}o(b,`stringToRegexp`);function x(e){switch(e){case 0:return`*`;case 1:return`?`;case 2:return`+`;case 3:return``}}o(x,`modifierToString`);function S(e,t,n={}){n.delimiter??=`/#?`,n.prefixes??=`./`,n.sensitive??=!1,n.strict??=!1,n.end??=!0,n.start??=!0,n.endsWith=``;let r=n.start?`^`:``;for(let i of e){if(i.type===3){i.modifier===3?r+=v(i.value):r+=`(?:${v(i.value)})${x(i.modifier)}`;continue}t&&t.push(i.name);let e=`[^${v(n.delimiter)}]+?`,a=i.value;if(i.type===1?a=e:i.type===0&&(a=m),!i.prefix.length&&!i.suffix.length){i.modifier===3||i.modifier===1?r+=`(${a})${x(i.modifier)}`:r+=`((?:${a})${x(i.modifier)})`;continue}if(i.modifier===3||i.modifier===1){r+=`(?:${v(i.prefix)}(${a})${v(i.suffix)})`,r+=x(i.modifier);continue}r+=`(?:${v(i.prefix)}`,r+=`((?:${a})(?:`,r+=v(i.suffix),r+=v(i.prefix),r+=`(?:${a}))*)${v(i.suffix)})`,i.modifier===0&&(r+=`?`)}let i=`[${v(n.endsWith)}]|$`,a=`[${v(n.delimiter)}]`;if(n.end)return n.strict||(r+=`${a}?`),n.endsWith.length?r+=`(?=${i})`:r+=`$`,new RegExp(r,y(n));n.strict||(r+=`(?:${a}(?=${i}))?`);let o=!1;if(e.length){let t=e[e.length-1];t.type===3&&t.modifier===3&&(o=n.delimiter.indexOf(t)>-1)}return o||(r+=`(?=${a}|${i})`),new RegExp(r,y(n))}o(S,`partsToRegexp`);var C={delimiter:``,prefixes:``,sensitive:!0,strict:!0},ee={delimiter:`.`,prefixes:``,sensitive:!0,strict:!0},w={delimiter:`/`,prefixes:`/`,sensitive:!0,strict:!0};function T(e,t){return e.length?e[0]===`/`?!0:!t||e.length<2?!1:(e[0]==`\\`||e[0]==`{`)&&e[1]==`/`:!1}o(T,`isAbsolutePathname`);function E(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}o(E,`maybeStripPrefix`);function D(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}o(D,`maybeStripSuffix`);function O(e){return!e||e.length<2?!1:e[0]===`[`||(e[0]===`\\`||e[0]===`{`)&&e[1]===`[`}o(O,`treatAsIPv6Hostname`);var k=[`ftp`,`file`,`http`,`https`,`ws`,`wss`];function A(e){if(!e)return!0;for(let t of k)if(e.test(t))return!0;return!1}o(A,`isSpecialScheme`);function j(e,t){if(e=E(e,`#`),t||e===``)return e;let n=new URL(`https://example.com`);return n.hash=e,n.hash?n.hash.substring(1,n.hash.length):``}o(j,`canonicalizeHash`);function te(e,t){if(e=E(e,`?`),t||e===``)return e;let n=new URL(`https://example.com`);return n.search=e,n.search?n.search.substring(1,n.search.length):``}o(te,`canonicalizeSearch`);function M(e,t){return t||e===``?e:O(e)?oe(e):ae(e)}o(M,`canonicalizeHostname`);function N(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.password=e,n.password}o(N,`canonicalizePassword`);function P(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.username=e,n.username}o(P,`canonicalizeUsername`);function F(e,t,n){if(n||e===``)return e;if(t&&!k.includes(t))return new URL(`${t}:${e}`).pathname;let r=e[0]==`/`;return e=new URL(r?e:`/-`+e,`https://example.com`).pathname,r||(e=e.substring(2,e.length)),e}o(F,`canonicalizePathname`);function I(e,t,n){return L(t)===e&&(e=``),n||e===``?e:se(e)}o(I,`canonicalizePort`);function ne(e,t){return e=D(e,`:`),t||e===``?e:R(e)}o(ne,`canonicalizeProtocol`);function L(e){switch(e){case`ws`:case`http`:return`80`;case`wws`:case`https`:return`443`;case`ftp`:return`21`;default:return``}}o(L,`defaultPortForProtocol`);function R(e){if(e===``)return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw TypeError(`Invalid protocol '${e}'.`)}o(R,`protocolEncodeCallback`);function re(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.username=e,t.username}o(re,`usernameEncodeCallback`);function ie(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.password=e,t.password}o(ie,`passwordEncodeCallback`);function ae(e){if(e===``)return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw TypeError(`Invalid hostname '${e}'`);let t=new URL(`https://example.com`);return t.hostname=e,t.hostname}o(ae,`hostnameEncodeCallback`);function oe(e){if(e===``)return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw TypeError(`Invalid IPv6 hostname '${e}'`);return e.toLowerCase()}o(oe,`ipv6HostnameEncodeCallback`);function se(e){if(e===``||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw TypeError(`Invalid port '${e}'.`)}o(se,`portEncodeCallback`);function ce(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.pathname=e[0]===`/`?e:`/-`+e,e[0]===`/`?t.pathname:t.pathname.substring(2,t.pathname.length)}o(ce,`standardURLPathnameEncodeCallback`);function z(e){return e===``?e:new URL(`data:${e}`).pathname}o(z,`pathURLPathnameEncodeCallback`);function B(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.search=e,t.search.substring(1,t.search.length)}o(B,`searchEncodeCallback`);function V(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.hash=e,t.hash.substring(1,t.hash.length)}o(V,`hashEncodeCallback`);var le=class{#i;#n=[];#t={};#e=0;#s=1;#l=0;#o=0;#d=0;#p=0;#g=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=g(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type===`END`){if(this.#o===0){this.#b(),this.#f()?this.#r(9,1):this.#h()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#u(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#A())--this.#d;else continue;if(this.#T()){this.#d+=1;continue}switch(this.#o){case 0:this.#P()&&this.#u(1);break;case 1:if(this.#P()){this.#C();let e=7,t=1;this.#E()?(e=2,t=3):this.#g&&(e=2),this.#r(e,t)}break;case 2:this.#S()?this.#u(3):(this.#x()||this.#h()||this.#f())&&this.#u(5);break;case 3:this.#O()?this.#r(4,1):this.#S()&&this.#r(5,1);break;case 4:this.#S()&&this.#r(5,1);break;case 5:this.#y()?this.#p+=1:this.#w()&&--this.#p,this.#k()&&!this.#p?this.#r(6,1):this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 6:this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 7:this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 8:this.#f()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port=``)}#r(e,t){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#c();break;case 2:break;case 3:this.#t.username=this.#c();break;case 4:this.#t.password=this.#c();break;case 5:this.#t.hostname=this.#c();break;case 6:this.#t.port=this.#c();break;case 7:this.#t.pathname=this.#c();break;case 8:this.#t.search=this.#c();break;case 9:this.#t.hash=this.#c();break;case 10:break}this.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=``),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#g?`/`:``),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??=``)),this.#R(e,t)}#R(e,t){this.#o=e,this.#l=this.#e+t,this.#e+=t,this.#s=0}#b(){this.#e=this.#l,this.#s=0}#u(e){this.#b(),this.#o=e}#m(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#a(e,t){let n=this.#m(e);return n.value===t&&(n.type===`CHAR`||n.type===`ESCAPED_CHAR`||n.type===`INVALID_CHAR`)}#P(){return this.#a(this.#e,`:`)}#E(){return this.#a(this.#e+1,`/`)&&this.#a(this.#e+2,`/`)}#S(){return this.#a(this.#e,`@`)}#O(){return this.#a(this.#e,`:`)}#k(){return this.#a(this.#e,`:`)}#x(){return this.#a(this.#e,`/`)}#h(){if(this.#a(this.#e,`?`))return!0;if(this.#n[this.#e].value!==`?`)return!1;let e=this.#m(this.#e-1);return e.type!==`NAME`&&e.type!==`REGEX`&&e.type!==`CLOSE`&&e.type!==`ASTERISK`}#f(){return this.#a(this.#e,`#`)}#T(){return this.#n[this.#e].type==`OPEN`}#A(){return this.#n[this.#e].type==`CLOSE`}#y(){return this.#a(this.#e,`[`)}#w(){return this.#a(this.#e,`]`)}#c(){let e=this.#n[this.#e],t=this.#m(this.#l).index;return this.#i.substring(t,e.index)}#C(){let e={};Object.assign(e,C),e.encodePart=R;let t=b(this.#c(),void 0,e);this.#g=A(t)}};o(le,`Parser`);var H=[`protocol`,`username`,`password`,`hostname`,`port`,`pathname`,`search`,`hash`],U=`*`;function W(e,t){if(typeof e!=`string`)throw TypeError(`parameter 1 is not of type 'string'.`);let n=new URL(e,t);return{protocol:n.protocol.substring(0,n.protocol.length-1),username:n.username,password:n.password,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search===``?void 0:n.search.substring(1,n.search.length),hash:n.hash===``?void 0:n.hash.substring(1,n.hash.length)}}o(W,`extractValues`);function G(e,t){return t?q(e):e}o(G,`processBaseURLString`);function K(e,t,n){let r;if(typeof t.baseURL==`string`)try{r=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=G(r.protocol.substring(0,r.protocol.length-1),n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=G(r.username,n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=G(r.password,n)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=G(r.hostname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=G(r.port,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=G(r.pathname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=G(r.search.substring(1,r.search.length),n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=G(r.hash.substring(1,r.hash.length),n))}catch{throw TypeError(`invalid baseURL '${t.baseURL}'.`)}if(typeof t.protocol==`string`&&(e.protocol=ne(t.protocol,n)),typeof t.username==`string`&&(e.username=P(t.username,n)),typeof t.password==`string`&&(e.password=N(t.password,n)),typeof t.hostname==`string`&&(e.hostname=M(t.hostname,n)),typeof t.port==`string`&&(e.port=I(t.port,e.protocol,n)),typeof t.pathname==`string`){if(e.pathname=t.pathname,r&&!T(e.pathname,n)){let t=r.pathname.lastIndexOf(`/`);t>=0&&(e.pathname=G(r.pathname.substring(0,t+1),n)+e.pathname)}e.pathname=F(e.pathname,e.protocol,n)}return typeof t.search==`string`&&(e.search=te(t.search,n)),typeof t.hash==`string`&&(e.hash=j(t.hash,n)),e}o(K,`applyInit`);function q(e){return e.replace(/([+*?:{}()\\])/g,`\\$1`)}o(q,`escapePatternString`);function ue(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(ue,`escapeRegexpString`);function de(e,t){t.delimiter??=`/#?`,t.prefixes??=`./`,t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith=``;let n=`[^${ue(t.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,i=``;for(let a=0;a<e.length;++a){let o=e[a];if(o.type===3){if(o.modifier===3){i+=q(o.value);continue}i+=`{${q(o.value)}}${x(o.modifier)}`;continue}let s=o.hasCustomName(),c=!!o.suffix.length||!!o.prefix.length&&(o.prefix.length!==1||!t.prefixes.includes(o.prefix)),l=a>0?e[a-1]:null,u=a<e.length-1?e[a+1]:null;if(!c&&s&&o.type===1&&o.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let e=u.value.length>0?u.value[0]:``;c=r.test(e)}else c=!u.hasCustomName();if(!c&&!o.prefix.length&&l&&l.type===3){let e=l.value[l.value.length-1];c=t.prefixes.includes(e)}c&&(i+=`{`),i+=q(o.prefix),s&&(i+=`:${o.name}`),o.type===2?i+=`(${o.value})`:o.type===1?s||(i+=`(${n})`):o.type===0&&(!s&&(!l||l.type===3||l.modifier!==3||c||o.prefix!==``)?i+=`*`:i+=`(.*)`),o.type===1&&s&&o.suffix.length&&r.test(o.suffix[0])&&(i+=`\\`),i+=q(o.suffix),c&&(i+=`}`),o.modifier!==3&&(i+=x(o.modifier))}return i}o(de,`partsToPattern`);var fe=class{#i;#n={};#t={};#e={};#s={};#l=!1;constructor(e={},t,n){try{let r;if(typeof t==`string`?r=t:n=t,typeof e==`string`){let t=new le(e);if(t.parse(),e=t.result,r===void 0&&typeof e.protocol!=`string`)throw TypeError(`A base URL must be provided for a relative constructor string.`);e.baseURL=r}else{if(!e||typeof e!=`object`)throw TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);if(r)throw TypeError(`parameter 1 is not of type 'string'.`)}typeof n>`u`&&(n={ignoreCase:!1});let i={ignoreCase:n.ignoreCase===!0},a={pathname:U,protocol:U,username:U,password:U,hostname:U,port:U,search:U,hash:U};this.#i=K(a,e,!0),L(this.#i.protocol)===this.#i.port&&(this.#i.port=``);let o;for(o of H){if(!(o in this.#i))continue;let e={},t=this.#i[o];switch(this.#t[o]=[],o){case`protocol`:Object.assign(e,C),e.encodePart=R;break;case`username`:Object.assign(e,C),e.encodePart=re;break;case`password`:Object.assign(e,C),e.encodePart=ie;break;case`hostname`:Object.assign(e,ee),O(t)?e.encodePart=oe:e.encodePart=ae;break;case`port`:Object.assign(e,C),e.encodePart=se;break;case`pathname`:A(this.#n.protocol)?(Object.assign(e,w,i),e.encodePart=ce):(Object.assign(e,C,i),e.encodePart=z);break;case`search`:Object.assign(e,C,i),e.encodePart=B;break;case`hash`:Object.assign(e,C,i),e.encodePart=V;break}try{this.#s[o]=_(t,e),this.#n[o]=S(this.#s[o],this.#t[o],e),this.#e[o]=de(this.#s[o],e),this.#l=this.#l||this.#s[o].some(e=>e.type===2)}catch{throw TypeError(`invalid ${o} pattern '${this.#i[o]}'.`)}}}catch(e){throw TypeError(`Failed to construct 'URLPattern': ${e.message}`)}}get[Symbol.toStringTag](){return`URLPattern`}test(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return!1;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return!1}let r;for(r of H)if(!this.#n[r].exec(n[r]))return!1;return!0}exec(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return null}let r={};t?r.inputs=[e,t]:r.inputs=[e];let i;for(i of H){let e=this.#n[i].exec(n[i]);if(!e)return null;let t={};for(let[n,r]of this.#t[i].entries())if(typeof r==`string`||typeof r==`number`){let i=e[n+1];t[r]=i}r[i]={input:n[i]??``,groups:t}}return r}static compareComponent(e,t,n){let r=o((e,t)=>{for(let n of[`type`,`modifier`,`prefix`,`value`,`suffix`]){if(e[n]<t[n])return-1;if(e[n]===t[n])continue;return 1}return 0},`comparePart`),i=new d(3,``,``,``,``,3),a=new d(0,``,``,``,``,3),s=o((e,t)=>{let n=0;for(;n<Math.min(e.length,t.length);++n){let i=r(e[n],t[n]);if(i)return i}return e.length===t.length?0:r(e[n]??i,t[n]??i)},`comparePartList`);return!t.#e[e]&&!n.#e[e]?0:t.#e[e]&&!n.#e[e]?s(t.#s[e],[a]):!t.#e[e]&&n.#e[e]?s([a],n.#s[e]):s(t.#s[e],n.#s[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#l}};o(fe,`URLPattern`)})),M=e(((exports,t)=>{let{URLPattern:n}=te();t.exports={URLPattern:n},globalThis.URLPattern||(globalThis.URLPattern=n)})),N=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.isPromise=n,exports.isActualPromise=r,exports.handleMaybePromise=i,exports.fakePromise=a,exports.createDeferredPromise=o,exports.iterateAsync=s,exports.iterateAsyncVoid=s,exports.fakeRejectPromise=c,exports.mapMaybePromise=l,exports.mapAsyncIterator=u,exports.promiseLikeFinally=m,exports.unfakePromise=h;let t=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function n(e){return e?.then!=null}function r(e){let t=e;return t&&t.then&&t.catch&&t.finally}function i(e,t,n,r){let i=a().then(e).then(t,n);return r&&(i=i.finally(r)),h(i)}function a(e){return e&&r(e)?e:n(e)?{then:(t,n)=>a(e.then(t,n)),catch:t=>a(e.then(e=>e,t)),finally:t=>a(t?m(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},catch(){return this},finally(t){if(t)try{return a(t()).then(()=>e,()=>e)}catch(e){return c(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[t]:`resolved`}}function o(){if(Promise.withResolvers)return Promise.withResolvers();let e,t,n=new Promise(function(n,r){e=n,t=r});return{promise:n,get resolve(){return e},get reject(){return t}}}function s(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),a=0;function o(){let{done:e,value:s}=r.next();if(e)return;let c=!1;function l(){c=!0}return i(function(){return t(s,l,a++)},function(e){if(e&&n?.push(e),!c)return o()})}return o()}function c(e){return{then(t,n){if(n)try{return a(n(e))}catch(e){return c(e)}return this},catch(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},finally(e){if(e)try{e()}catch(e){return c(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[t]:`rejected`}}function l(e,t,n){return i(()=>e,t,n)}function u(e,t,n,r){Symbol.asyncIterator in e&&(e=e[Symbol.asyncIterator]());let o,s,l;if(r){let e;l=t=>(e||=i(r,()=>t,()=>t),e)}typeof e.return==`function`&&(o=e.return,s=t=>{let n=()=>{throw t};return o.call(e).then(n,n)});function u(e){return e.done?l?l(e):e:i(()=>e.value,e=>i(()=>t(e),d,s))}let f;if(n){let e,t=n;f=n=>(e||=i(()=>n,e=>i(()=>t(e),d,s)),e)}return{next(){return e.next().then(u,f)},return(){let t=o?o.call(e).then(u,f):a({value:void 0,done:!0});return l?t.then(l):t},throw(t){return typeof e.throw==`function`?e.throw(t).then(u,f):s?s(t):c(t)},[Symbol.asyncIterator](){return this}}}function d(e){return{value:e,done:!1}}function f(e){return e?.[t]===`resolved`}function p(e){return e?.[t]===`rejected`}function m(e,t){return`finally`in e?e.finally(t):e.then(e=>{let r=t();return n(r)?r.then(()=>e):e},e=>{let r=t();if(n(r))return r.then(()=>{throw e});throw e})}function h(e){if(f(e))return e.__fakePromiseValue;if(p(e))throw e.__fakeRejectError;return e}})),P=e(((exports,t)=>{let{EventEmitter:n}=r(`node:events`),{inherits:i}=r(`node:util`);function a(e){if(typeof e==`string`&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw TypeError(`The needle has to be a String or a Buffer.`);let t=e.length,n=t-1;if(t===0)throw Error(`The needle cannot be an empty String/Buffer.`);if(t>256)throw Error(`The needle cannot have a length bigger than 256.`);this.maxMatches=1/0,this.matches=0,this._occ=new Uint8Array(256).fill(t),this._lookbehind_size=0,this._needle=e,this._bufpos=0,this._lookbehind=Buffer.alloc(n);for(var r=0;r<n;++r)this._occ[e[r]]=n-r}i(a,n),a.prototype.reset=function(){this._lookbehind_size=0,this.matches=0,this._bufpos=0},a.prototype.push=function(e,t){Buffer.isBuffer(e)||(e=Buffer.from(e,`binary`));let n=e.length;this._bufpos=t||0;let r;for(;r!==n&&this.matches<this.maxMatches;)r=this._sbmh_feed(e);return r},a.prototype._sbmh_feed=function(e){let t=e.length,n=this._needle,r=n.length,i=r-1,a=n[i],o=-this._lookbehind_size,s;if(o<0){for(;o<0&&o<=t-r;){if(s=e[o+i],s===a&&this._sbmh_memcmp(e,o,i))return this._lookbehind_size=0,++this.matches,this.emit(`info`,!0),this._bufpos=o+r;o+=this._occ[s]}for(;o<0&&!this._sbmh_memcmp(e,o,t-o);)++o;if(o>=0)this.emit(`info`,!1,this._lookbehind,0,this._lookbehind_size),this._lookbehind_size=0;else{let n=this._lookbehind_size+o;return n>0&&this.emit(`info`,!1,this._lookbehind,0,n),this._lookbehind_size-=n,this._lookbehind.copy(this._lookbehind,0,n,this._lookbehind_size),e.copy(this._lookbehind,this._lookbehind_size),this._lookbehind_size+=t,this._bufpos=t,t}}if(o=e.indexOf(n,o+this._bufpos),o!==-1)return++this.matches,o===0?this.emit(`info`,!0):this.emit(`info`,!0,e,this._bufpos,o),this._bufpos=o+r;for(o=t-i,o<0&&(o=0);o!==t&&(e[o]!==n[0]||Buffer.compare(e.subarray(o+1,t),n.subarray(1,t-o))!==0);)++o;return o!==t&&(e.copy(this._lookbehind,0,o,t),this._lookbehind_size=t-o),o!==0&&this.emit(`info`,!1,e,this._bufpos,o),this._bufpos=t,t},a.prototype._sbmh_lookup_char=function(e,t){return t<0?this._lookbehind[this._lookbehind_size+t]:e[t]},a.prototype._sbmh_memcmp=function(e,t,n){for(var r=0;r<n;++r)if(this._sbmh_lookup_char(e,t+r)!==this._needle[r])return!1;return!0},t.exports=a})),F=e(((exports,t)=>{let n=r(`node:util`).inherits,i=r(`node:stream`).Readable;function a(e){i.call(this,e)}n(a,i),a.prototype._read=function(e){},t.exports=a})),I=e(((exports,t)=>{t.exports=function(e,t,n){if(!e||e[t]===void 0||e[t]===null)return n;if(typeof e[t]!=`number`||isNaN(e[t]))throw TypeError(`Limit `+t+` is not a valid number`);return e[t]}})),ne=e(((exports,t)=>{let n=r(`node:events`).EventEmitter,i=r(`node:util`).inherits,a=I(),o=P(),s=Buffer.from(`\r
1
+ import{__commonJSMin as e,__esmMin as t,__export as n,__require as r,__toCommonJS as i,__toESM as a}from"../chunk-___ucjiX.js";import*as o from"http";import{z as s}from"zod/v4";import"zod/v3";import{convertToModelMessages as c,createUIMessageStream as l,getToolName as u,isToolUIPart as d}from"ai";const f=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function p(e){return e?.then!=null}function m(e){let t=e;return t&&t.then&&t.catch&&t.finally}function h(e,t,n,r){let i=g().then(e).then(t,n);return r&&(i=i.finally(r)),C(i)}function g(e){return e&&m(e)?e:p(e)?{then:(t,n)=>g(e.then(t,n)),catch:t=>g(e.then(e=>e,t)),finally:t=>g(t?S(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return g(t(e))}catch(e){return y(e)}return this},catch(){return this},finally(t){if(t)try{return g(t()).then(()=>e,()=>e)}catch(e){return y(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[f]:`resolved`}}function _(){if(Promise.withResolvers)return Promise.withResolvers();let e,t,n=new Promise(function(n,r){e=n,t=r});return{promise:n,get resolve(){return e},get reject(){return t}}}function v(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),i=0;function a(){let{done:e,value:o}=r.next();if(e)return;let s=!1;function c(){s=!0}return h(function(){return t(o,c,i++)},function(e){if(e&&n?.push(e),!s)return a()})}return a()}function y(e){return{then(t,n){if(n)try{return g(n(e))}catch(e){return y(e)}return this},catch(t){if(t)try{return g(t(e))}catch(e){return y(e)}return this},finally(e){if(e)try{e()}catch(e){return y(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[f]:`rejected`}}function b(e){return e?.[f]===`resolved`}function x(e){return e?.[f]===`rejected`}function S(e,t){return`finally`in e?e.finally(t):e.then(e=>{let n=t();return p(n)?n.then(()=>e):e},e=>{let n=t();if(p(n))return n.then(()=>{throw e});throw e})}function C(e){if(b(e))return e.__fakePromiseValue;if(x(e))throw e.__fakeRejectError;return e}function w(e,t){let n={...t,...e};for(let r of Object.keys(n))r in e&&r in t&&(n[r]=(n,i)=>e[r](n,()=>t[r](n,i)));return n}const T=e=>({fn(t,n){return t?(...r)=>{let i;return t(e,()=>{i=n(...r)}),i}:n},asyncFn(t,n){return t?(...r)=>{let i;return h(()=>t(e,()=>(i=n(...r),p(i)?i.then(()=>void 0):void 0)),()=>i)}:n}});var E=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};const D={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function O(e){return e?.[D.dispose]!=null}function k(e){return e?.[D.asyncDispose]!=null}const A=globalThis.SuppressedError||E;var j=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return k(e)?this.callbacks.push(()=>e[D.asyncDispose]()):O(e)&&this.callbacks.push(()=>e[D.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[D.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return h(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new A(e,this._error):e,this._iterateCallbacks()))}[D.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};globalThis.SuppressedError,D.dispose,Symbol.toStringTag,globalThis.DisposableStack;const ee=globalThis.AsyncDisposableStack||j;globalThis.SuppressedError;var M=e(((exports,t)=>{function n(){return Object.keys(globalThis).some(e=>e.startsWith(`__NEXT`))}t.exports=function(){return!!(globalThis.Deno||globalThis.Bun||n())}})),N=e(((exports,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>n(e,`name`,{value:t,configurable:!0}),s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{URLPattern:()=>ge}),t.exports=l(u);var d=class{type=3;name=``;prefix=``;value=``;suffix=``;modifier=3;constructor(e,t,n,r,i,a){this.type=e,this.name=t,this.prefix=n,this.value=r,this.suffix=i,this.modifier=a}hasCustomName(){return this.name!==``&&typeof this.name!=`number`}};o(d,`Part`);var f=/[$_\p{ID_Start}]/u,p=/[$_\u200C\u200D\p{ID_Continue}]/u,m=`.*`;function h(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}o(h,`isASCII`);function g(e,t=!1){let n=[],r=0;for(;r<e.length;){let i=e[r],a=o(function(i){if(!t)throw TypeError(i);n.push({type:`INVALID_CHAR`,index:r,value:e[r++]})},`ErrorOrInvalid`);if(i===`*`){n.push({type:`ASTERISK`,index:r,value:e[r++]});continue}if(i===`+`||i===`?`){n.push({type:`OTHER_MODIFIER`,index:r,value:e[r++]});continue}if(i===`\\`){n.push({type:`ESCAPED_CHAR`,index:r++,value:e[r++]});continue}if(i===`{`){n.push({type:`OPEN`,index:r,value:e[r++]});continue}if(i===`}`){n.push({type:`CLOSE`,index:r,value:e[r++]});continue}if(i===`:`){let t=``,i=r+1;for(;i<e.length;){let n=e.substr(i,1);if(i===r+1&&f.test(n)||i!==r+1&&p.test(n)){t+=e[i++];continue}break}if(!t){a(`Missing parameter name at ${r}`);continue}n.push({type:`NAME`,index:r,value:t}),r=i;continue}if(i===`(`){let t=1,i=``,o=r+1,s=!1;if(e[o]===`?`){a(`Pattern cannot start with "?" at ${o}`);continue}for(;o<e.length;){if(!h(e[o],!1)){a(`Invalid character '${e[o]}' at ${o}.`),s=!0;break}if(e[o]===`\\`){i+=e[o++]+e[o++];continue}if(e[o]===`)`){if(t--,t===0){o++;break}}else if(e[o]===`(`&&(t++,e[o+1]!==`?`)){a(`Capturing groups are not allowed at ${o}`),s=!0;break}i+=e[o++]}if(s)continue;if(t){a(`Unbalanced pattern at ${r}`);continue}if(!i){a(`Missing pattern at ${r}`);continue}n.push({type:`REGEX`,index:r,value:i}),r=o;continue}n.push({type:`CHAR`,index:r,value:e[r++]})}return n.push({type:`END`,index:r,value:``}),n}o(g,`lexer`);function _(e,t={}){let n=g(e);t.delimiter??=`/#?`,t.prefixes??=`./`;let r=`[^${v(t.delimiter)}]+?`,i=[],a=0,s=0,c=new Set,l=o(e=>{if(s<n.length&&n[s].type===e)return n[s++].value},`tryConsume`),u=o(()=>l(`OTHER_MODIFIER`)??l(`ASTERISK`),`tryConsumeModifier`),f=o(e=>{let t=l(e);if(t!==void 0)return t;let{type:r,index:i}=n[s];throw TypeError(`Unexpected ${r} at ${i}, expected ${e}`)},`mustConsume`),p=o(()=>{let e=``,t;for(;t=l(`CHAR`)??l(`ESCAPED_CHAR`);)e+=t;return e},`consumeText`),h=o(e=>e,`DefaultEncodePart`),_=t.encodePart||h,y=``,b=o(e=>{y+=e},`appendToPendingFixedValue`),x=o(()=>{y.length&&(i.push(new d(3,``,``,_(y),``,3)),y=``)},`maybeAddPartFromPendingFixedValue`),S=o((e,t,n,o,s)=>{let l=3;switch(s){case`?`:l=1;break;case`*`:l=0;break;case`+`:l=2;break}if(!t&&!n&&l===3){b(e);return}if(x(),!t&&!n){if(!e)return;i.push(new d(3,``,``,_(e),``,l));return}let u;u=n?n===`*`?m:n:r;let f=2;u===r?(f=1,u=``):u===m&&(f=0,u=``);let p;if(t?p=t:n&&(p=a++),c.has(p))throw TypeError(`Duplicate name '${p}'.`);c.add(p),i.push(new d(f,p,_(e),u,_(o),l))},`addPart`);for(;s<n.length;){let e=l(`CHAR`),n=l(`NAME`),r=l(`REGEX`);if(!n&&!r&&(r=l(`ASTERISK`)),n||r){let i=e??``;t.prefixes.indexOf(i)===-1&&(b(i),i=``),x();let a=u();S(i,n,r,``,a);continue}let i=e??l(`ESCAPED_CHAR`);if(i){b(i);continue}if(l(`OPEN`)){let e=p(),t=l(`NAME`),n=l(`REGEX`);!t&&!n&&(n=l(`ASTERISK`));let r=p();f(`CLOSE`);let i=u();S(e,t,n,r,i);continue}x(),f(`END`)}return i}o(_,`parse`);function v(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(v,`escapeString`);function y(e){return e&&e.ignoreCase?`ui`:`u`}o(y,`flags`);function b(e,t,n){return S(_(e,n),t,n)}o(b,`stringToRegexp`);function x(e){switch(e){case 0:return`*`;case 1:return`?`;case 2:return`+`;case 3:return``}}o(x,`modifierToString`);function S(e,t,n={}){n.delimiter??=`/#?`,n.prefixes??=`./`,n.sensitive??=!1,n.strict??=!1,n.end??=!0,n.start??=!0,n.endsWith=``;let r=n.start?`^`:``;for(let i of e){if(i.type===3){i.modifier===3?r+=v(i.value):r+=`(?:${v(i.value)})${x(i.modifier)}`;continue}t&&t.push(i.name);let e=`[^${v(n.delimiter)}]+?`,a=i.value;if(i.type===1?a=e:i.type===0&&(a=m),!i.prefix.length&&!i.suffix.length){i.modifier===3||i.modifier===1?r+=`(${a})${x(i.modifier)}`:r+=`((?:${a})${x(i.modifier)})`;continue}if(i.modifier===3||i.modifier===1){r+=`(?:${v(i.prefix)}(${a})${v(i.suffix)})`,r+=x(i.modifier);continue}r+=`(?:${v(i.prefix)}`,r+=`((?:${a})(?:`,r+=v(i.suffix),r+=v(i.prefix),r+=`(?:${a}))*)${v(i.suffix)})`,i.modifier===0&&(r+=`?`)}let i=`[${v(n.endsWith)}]|$`,a=`[${v(n.delimiter)}]`;if(n.end)return n.strict||(r+=`${a}?`),n.endsWith.length?r+=`(?=${i})`:r+=`$`,new RegExp(r,y(n));n.strict||(r+=`(?:${a}(?=${i}))?`);let o=!1;if(e.length){let t=e[e.length-1];t.type===3&&t.modifier===3&&(o=n.delimiter.indexOf(t)>-1)}return o||(r+=`(?=${a}|${i})`),new RegExp(r,y(n))}o(S,`partsToRegexp`);var C={delimiter:``,prefixes:``,sensitive:!0,strict:!0},w={delimiter:`.`,prefixes:``,sensitive:!0,strict:!0},T={delimiter:`/`,prefixes:`/`,sensitive:!0,strict:!0};function E(e,t){return e.length?e[0]===`/`?!0:!t||e.length<2?!1:(e[0]==`\\`||e[0]==`{`)&&e[1]==`/`:!1}o(E,`isAbsolutePathname`);function D(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}o(D,`maybeStripPrefix`);function O(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}o(O,`maybeStripSuffix`);function k(e){return!e||e.length<2?!1:e[0]===`[`||(e[0]===`\\`||e[0]===`{`)&&e[1]===`[`}o(k,`treatAsIPv6Hostname`);var A=[`ftp`,`file`,`http`,`https`,`ws`,`wss`];function j(e){if(!e)return!0;for(let t of A)if(e.test(t))return!0;return!1}o(j,`isSpecialScheme`);function ee(e,t){if(e=D(e,`#`),t||e===``)return e;let n=new URL(`https://example.com`);return n.hash=e,n.hash?n.hash.substring(1,n.hash.length):``}o(ee,`canonicalizeHash`);function M(e,t){if(e=D(e,`?`),t||e===``)return e;let n=new URL(`https://example.com`);return n.search=e,n.search?n.search.substring(1,n.search.length):``}o(M,`canonicalizeSearch`);function N(e,t){return t||e===``?e:k(e)?se(e):oe(e)}o(N,`canonicalizeHostname`);function P(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.password=e,n.password}o(P,`canonicalizePassword`);function F(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.username=e,n.username}o(F,`canonicalizeUsername`);function I(e,t,n){if(n||e===``)return e;if(t&&!A.includes(t))return new URL(`${t}:${e}`).pathname;let r=e[0]==`/`;return e=new URL(r?e:`/-`+e,`https://example.com`).pathname,r||(e=e.substring(2,e.length)),e}o(I,`canonicalizePathname`);function te(e,t,n){return re(t)===e&&(e=``),n||e===``?e:ce(e)}o(te,`canonicalizePort`);function ne(e,t){return e=O(e,`:`),t||e===``?e:L(e)}o(ne,`canonicalizeProtocol`);function re(e){switch(e){case`ws`:case`http`:return`80`;case`wws`:case`https`:return`443`;case`ftp`:return`21`;default:return``}}o(re,`defaultPortForProtocol`);function L(e){if(e===``)return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw TypeError(`Invalid protocol '${e}'.`)}o(L,`protocolEncodeCallback`);function ie(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.username=e,t.username}o(ie,`usernameEncodeCallback`);function ae(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.password=e,t.password}o(ae,`passwordEncodeCallback`);function oe(e){if(e===``)return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw TypeError(`Invalid hostname '${e}'`);let t=new URL(`https://example.com`);return t.hostname=e,t.hostname}o(oe,`hostnameEncodeCallback`);function se(e){if(e===``)return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw TypeError(`Invalid IPv6 hostname '${e}'`);return e.toLowerCase()}o(se,`ipv6HostnameEncodeCallback`);function ce(e){if(e===``||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw TypeError(`Invalid port '${e}'.`)}o(ce,`portEncodeCallback`);function le(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.pathname=e[0]===`/`?e:`/-`+e,e[0]===`/`?t.pathname:t.pathname.substring(2,t.pathname.length)}o(le,`standardURLPathnameEncodeCallback`);function ue(e){return e===``?e:new URL(`data:${e}`).pathname}o(ue,`pathURLPathnameEncodeCallback`);function R(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.search=e,t.search.substring(1,t.search.length)}o(R,`searchEncodeCallback`);function z(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.hash=e,t.hash.substring(1,t.hash.length)}o(z,`hashEncodeCallback`);var de=class{#i;#n=[];#t={};#e=0;#s=1;#l=0;#o=0;#d=0;#p=0;#g=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=g(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type===`END`){if(this.#o===0){this.#b(),this.#f()?this.#r(9,1):this.#h()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#u(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#A())--this.#d;else continue;if(this.#T()){this.#d+=1;continue}switch(this.#o){case 0:this.#P()&&this.#u(1);break;case 1:if(this.#P()){this.#C();let e=7,t=1;this.#E()?(e=2,t=3):this.#g&&(e=2),this.#r(e,t)}break;case 2:this.#S()?this.#u(3):(this.#x()||this.#h()||this.#f())&&this.#u(5);break;case 3:this.#O()?this.#r(4,1):this.#S()&&this.#r(5,1);break;case 4:this.#S()&&this.#r(5,1);break;case 5:this.#y()?this.#p+=1:this.#w()&&--this.#p,this.#k()&&!this.#p?this.#r(6,1):this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 6:this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 7:this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 8:this.#f()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port=``)}#r(e,t){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#c();break;case 2:break;case 3:this.#t.username=this.#c();break;case 4:this.#t.password=this.#c();break;case 5:this.#t.hostname=this.#c();break;case 6:this.#t.port=this.#c();break;case 7:this.#t.pathname=this.#c();break;case 8:this.#t.search=this.#c();break;case 9:this.#t.hash=this.#c();break;case 10:break}this.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=``),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#g?`/`:``),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??=``)),this.#R(e,t)}#R(e,t){this.#o=e,this.#l=this.#e+t,this.#e+=t,this.#s=0}#b(){this.#e=this.#l,this.#s=0}#u(e){this.#b(),this.#o=e}#m(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#a(e,t){let n=this.#m(e);return n.value===t&&(n.type===`CHAR`||n.type===`ESCAPED_CHAR`||n.type===`INVALID_CHAR`)}#P(){return this.#a(this.#e,`:`)}#E(){return this.#a(this.#e+1,`/`)&&this.#a(this.#e+2,`/`)}#S(){return this.#a(this.#e,`@`)}#O(){return this.#a(this.#e,`:`)}#k(){return this.#a(this.#e,`:`)}#x(){return this.#a(this.#e,`/`)}#h(){if(this.#a(this.#e,`?`))return!0;if(this.#n[this.#e].value!==`?`)return!1;let e=this.#m(this.#e-1);return e.type!==`NAME`&&e.type!==`REGEX`&&e.type!==`CLOSE`&&e.type!==`ASTERISK`}#f(){return this.#a(this.#e,`#`)}#T(){return this.#n[this.#e].type==`OPEN`}#A(){return this.#n[this.#e].type==`CLOSE`}#y(){return this.#a(this.#e,`[`)}#w(){return this.#a(this.#e,`]`)}#c(){let e=this.#n[this.#e],t=this.#m(this.#l).index;return this.#i.substring(t,e.index)}#C(){let e={};Object.assign(e,C),e.encodePart=L;let t=b(this.#c(),void 0,e);this.#g=j(t)}};o(de,`Parser`);var fe=[`protocol`,`username`,`password`,`hostname`,`port`,`pathname`,`search`,`hash`],B=`*`;function pe(e,t){if(typeof e!=`string`)throw TypeError(`parameter 1 is not of type 'string'.`);let n=new URL(e,t);return{protocol:n.protocol.substring(0,n.protocol.length-1),username:n.username,password:n.password,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search===``?void 0:n.search.substring(1,n.search.length),hash:n.hash===``?void 0:n.hash.substring(1,n.hash.length)}}o(pe,`extractValues`);function V(e,t){return t?U(e):e}o(V,`processBaseURLString`);function H(e,t,n){let r;if(typeof t.baseURL==`string`)try{r=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=V(r.protocol.substring(0,r.protocol.length-1),n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=V(r.username,n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=V(r.password,n)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=V(r.hostname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=V(r.port,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=V(r.pathname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=V(r.search.substring(1,r.search.length),n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=V(r.hash.substring(1,r.hash.length),n))}catch{throw TypeError(`invalid baseURL '${t.baseURL}'.`)}if(typeof t.protocol==`string`&&(e.protocol=ne(t.protocol,n)),typeof t.username==`string`&&(e.username=F(t.username,n)),typeof t.password==`string`&&(e.password=P(t.password,n)),typeof t.hostname==`string`&&(e.hostname=N(t.hostname,n)),typeof t.port==`string`&&(e.port=te(t.port,e.protocol,n)),typeof t.pathname==`string`){if(e.pathname=t.pathname,r&&!E(e.pathname,n)){let t=r.pathname.lastIndexOf(`/`);t>=0&&(e.pathname=V(r.pathname.substring(0,t+1),n)+e.pathname)}e.pathname=I(e.pathname,e.protocol,n)}return typeof t.search==`string`&&(e.search=M(t.search,n)),typeof t.hash==`string`&&(e.hash=ee(t.hash,n)),e}o(H,`applyInit`);function U(e){return e.replace(/([+*?:{}()\\])/g,`\\$1`)}o(U,`escapePatternString`);function me(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(me,`escapeRegexpString`);function he(e,t){t.delimiter??=`/#?`,t.prefixes??=`./`,t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith=``;let n=`[^${me(t.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,i=``;for(let a=0;a<e.length;++a){let o=e[a];if(o.type===3){if(o.modifier===3){i+=U(o.value);continue}i+=`{${U(o.value)}}${x(o.modifier)}`;continue}let s=o.hasCustomName(),c=!!o.suffix.length||!!o.prefix.length&&(o.prefix.length!==1||!t.prefixes.includes(o.prefix)),l=a>0?e[a-1]:null,u=a<e.length-1?e[a+1]:null;if(!c&&s&&o.type===1&&o.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let e=u.value.length>0?u.value[0]:``;c=r.test(e)}else c=!u.hasCustomName();if(!c&&!o.prefix.length&&l&&l.type===3){let e=l.value[l.value.length-1];c=t.prefixes.includes(e)}c&&(i+=`{`),i+=U(o.prefix),s&&(i+=`:${o.name}`),o.type===2?i+=`(${o.value})`:o.type===1?s||(i+=`(${n})`):o.type===0&&(!s&&(!l||l.type===3||l.modifier!==3||c||o.prefix!==``)?i+=`*`:i+=`(.*)`),o.type===1&&s&&o.suffix.length&&r.test(o.suffix[0])&&(i+=`\\`),i+=U(o.suffix),c&&(i+=`}`),o.modifier!==3&&(i+=x(o.modifier))}return i}o(he,`partsToPattern`);var ge=class{#i;#n={};#t={};#e={};#s={};#l=!1;constructor(e={},t,n){try{let r;if(typeof t==`string`?r=t:n=t,typeof e==`string`){let t=new de(e);if(t.parse(),e=t.result,r===void 0&&typeof e.protocol!=`string`)throw TypeError(`A base URL must be provided for a relative constructor string.`);e.baseURL=r}else{if(!e||typeof e!=`object`)throw TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);if(r)throw TypeError(`parameter 1 is not of type 'string'.`)}typeof n>`u`&&(n={ignoreCase:!1});let i={ignoreCase:n.ignoreCase===!0},a={pathname:B,protocol:B,username:B,password:B,hostname:B,port:B,search:B,hash:B};this.#i=H(a,e,!0),re(this.#i.protocol)===this.#i.port&&(this.#i.port=``);let o;for(o of fe){if(!(o in this.#i))continue;let e={},t=this.#i[o];switch(this.#t[o]=[],o){case`protocol`:Object.assign(e,C),e.encodePart=L;break;case`username`:Object.assign(e,C),e.encodePart=ie;break;case`password`:Object.assign(e,C),e.encodePart=ae;break;case`hostname`:Object.assign(e,w),k(t)?e.encodePart=se:e.encodePart=oe;break;case`port`:Object.assign(e,C),e.encodePart=ce;break;case`pathname`:j(this.#n.protocol)?(Object.assign(e,T,i),e.encodePart=le):(Object.assign(e,C,i),e.encodePart=ue);break;case`search`:Object.assign(e,C,i),e.encodePart=R;break;case`hash`:Object.assign(e,C,i),e.encodePart=z;break}try{this.#s[o]=_(t,e),this.#n[o]=S(this.#s[o],this.#t[o],e),this.#e[o]=he(this.#s[o],e),this.#l=this.#l||this.#s[o].some(e=>e.type===2)}catch{throw TypeError(`invalid ${o} pattern '${this.#i[o]}'.`)}}}catch(e){throw TypeError(`Failed to construct 'URLPattern': ${e.message}`)}}get[Symbol.toStringTag](){return`URLPattern`}test(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return!1;try{n=typeof e==`object`?H(n,e,!1):H(n,pe(e,t),!1)}catch{return!1}let r;for(r of fe)if(!this.#n[r].exec(n[r]))return!1;return!0}exec(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return;try{n=typeof e==`object`?H(n,e,!1):H(n,pe(e,t),!1)}catch{return null}let r={};t?r.inputs=[e,t]:r.inputs=[e];let i;for(i of fe){let e=this.#n[i].exec(n[i]);if(!e)return null;let t={};for(let[n,r]of this.#t[i].entries())if(typeof r==`string`||typeof r==`number`){let i=e[n+1];t[r]=i}r[i]={input:n[i]??``,groups:t}}return r}static compareComponent(e,t,n){let r=o((e,t)=>{for(let n of[`type`,`modifier`,`prefix`,`value`,`suffix`]){if(e[n]<t[n])return-1;if(e[n]===t[n])continue;return 1}return 0},`comparePart`),i=new d(3,``,``,``,``,3),a=new d(0,``,``,``,``,3),s=o((e,t)=>{let n=0;for(;n<Math.min(e.length,t.length);++n){let i=r(e[n],t[n]);if(i)return i}return e.length===t.length?0:r(e[n]??i,t[n]??i)},`comparePartList`);return!t.#e[e]&&!n.#e[e]?0:t.#e[e]&&!n.#e[e]?s(t.#s[e],[a]):!t.#e[e]&&n.#e[e]?s([a],n.#s[e]):s(t.#s[e],n.#s[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#l}};o(ge,`URLPattern`)})),P=e(((exports,t)=>{let{URLPattern:n}=N();t.exports={URLPattern:n},globalThis.URLPattern||(globalThis.URLPattern=n)})),F=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.isPromise=n,exports.isActualPromise=r,exports.handleMaybePromise=i,exports.fakePromise=a,exports.createDeferredPromise=o,exports.iterateAsync=s,exports.iterateAsyncVoid=s,exports.fakeRejectPromise=c,exports.mapMaybePromise=l,exports.mapAsyncIterator=u,exports.promiseLikeFinally=m,exports.unfakePromise=h;let t=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function n(e){return e?.then!=null}function r(e){let t=e;return t&&t.then&&t.catch&&t.finally}function i(e,t,n,r){let i=a().then(e).then(t,n);return r&&(i=i.finally(r)),h(i)}function a(e){return e&&r(e)?e:n(e)?{then:(t,n)=>a(e.then(t,n)),catch:t=>a(e.then(e=>e,t)),finally:t=>a(t?m(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},catch(){return this},finally(t){if(t)try{return a(t()).then(()=>e,()=>e)}catch(e){return c(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[t]:`resolved`}}function o(){if(Promise.withResolvers)return Promise.withResolvers();let e,t,n=new Promise(function(n,r){e=n,t=r});return{promise:n,get resolve(){return e},get reject(){return t}}}function s(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),a=0;function o(){let{done:e,value:s}=r.next();if(e)return;let c=!1;function l(){c=!0}return i(function(){return t(s,l,a++)},function(e){if(e&&n?.push(e),!c)return o()})}return o()}function c(e){return{then(t,n){if(n)try{return a(n(e))}catch(e){return c(e)}return this},catch(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},finally(e){if(e)try{e()}catch(e){return c(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[t]:`rejected`}}function l(e,t,n){return i(()=>e,t,n)}function u(e,t,n,r){Symbol.asyncIterator in e&&(e=e[Symbol.asyncIterator]());let o,s,l;if(r){let e;l=t=>(e||=i(r,()=>t,()=>t),e)}typeof e.return==`function`&&(o=e.return,s=t=>{let n=()=>{throw t};return o.call(e).then(n,n)});function u(e){return e.done?l?l(e):e:i(()=>e.value,e=>i(()=>t(e),d,s))}let f;if(n){let e,t=n;f=n=>(e||=i(()=>n,e=>i(()=>t(e),d,s)),e)}return{next(){return e.next().then(u,f)},return(){let t=o?o.call(e).then(u,f):a({value:void 0,done:!0});return l?t.then(l):t},throw(t){return typeof e.throw==`function`?e.throw(t).then(u,f):s?s(t):c(t)},[Symbol.asyncIterator](){return this}}}function d(e){return{value:e,done:!1}}function f(e){return e?.[t]===`resolved`}function p(e){return e?.[t]===`rejected`}function m(e,t){return`finally`in e?e.finally(t):e.then(e=>{let r=t();return n(r)?r.then(()=>e):e},e=>{let r=t();if(n(r))return r.then(()=>{throw e});throw e})}function h(e){if(f(e))return e.__fakePromiseValue;if(p(e))throw e.__fakeRejectError;return e}})),I=e(((exports,t)=>{let{EventEmitter:n}=r(`node:events`),{inherits:i}=r(`node:util`);function a(e){if(typeof e==`string`&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw TypeError(`The needle has to be a String or a Buffer.`);let t=e.length,n=t-1;if(t===0)throw Error(`The needle cannot be an empty String/Buffer.`);if(t>256)throw Error(`The needle cannot have a length bigger than 256.`);this.maxMatches=1/0,this.matches=0,this._occ=new Uint8Array(256).fill(t),this._lookbehind_size=0,this._needle=e,this._bufpos=0,this._lookbehind=Buffer.alloc(n);for(var r=0;r<n;++r)this._occ[e[r]]=n-r}i(a,n),a.prototype.reset=function(){this._lookbehind_size=0,this.matches=0,this._bufpos=0},a.prototype.push=function(e,t){Buffer.isBuffer(e)||(e=Buffer.from(e,`binary`));let n=e.length;this._bufpos=t||0;let r;for(;r!==n&&this.matches<this.maxMatches;)r=this._sbmh_feed(e);return r},a.prototype._sbmh_feed=function(e){let t=e.length,n=this._needle,r=n.length,i=r-1,a=n[i],o=-this._lookbehind_size,s;if(o<0){for(;o<0&&o<=t-r;){if(s=e[o+i],s===a&&this._sbmh_memcmp(e,o,i))return this._lookbehind_size=0,++this.matches,this.emit(`info`,!0),this._bufpos=o+r;o+=this._occ[s]}for(;o<0&&!this._sbmh_memcmp(e,o,t-o);)++o;if(o>=0)this.emit(`info`,!1,this._lookbehind,0,this._lookbehind_size),this._lookbehind_size=0;else{let n=this._lookbehind_size+o;return n>0&&this.emit(`info`,!1,this._lookbehind,0,n),this._lookbehind_size-=n,this._lookbehind.copy(this._lookbehind,0,n,this._lookbehind_size),e.copy(this._lookbehind,this._lookbehind_size),this._lookbehind_size+=t,this._bufpos=t,t}}if(o=e.indexOf(n,o+this._bufpos),o!==-1)return++this.matches,o===0?this.emit(`info`,!0):this.emit(`info`,!0,e,this._bufpos,o),this._bufpos=o+r;for(o=t-i,o<0&&(o=0);o!==t&&(e[o]!==n[0]||Buffer.compare(e.subarray(o+1,t),n.subarray(1,t-o))!==0);)++o;return o!==t&&(e.copy(this._lookbehind,0,o,t),this._lookbehind_size=t-o),o!==0&&this.emit(`info`,!1,e,this._bufpos,o),this._bufpos=t,t},a.prototype._sbmh_lookup_char=function(e,t){return t<0?this._lookbehind[this._lookbehind_size+t]:e[t]},a.prototype._sbmh_memcmp=function(e,t,n){for(var r=0;r<n;++r)if(this._sbmh_lookup_char(e,t+r)!==this._needle[r])return!1;return!0},t.exports=a})),te=e(((exports,t)=>{let n=r(`node:util`).inherits,i=r(`node:stream`).Readable;function a(e){i.call(this,e)}n(a,i),a.prototype._read=function(e){},t.exports=a})),ne=e(((exports,t)=>{t.exports=function(e,t,n){if(!e||e[t]===void 0||e[t]===null)return n;if(typeof e[t]!=`number`||isNaN(e[t]))throw TypeError(`Limit `+t+` is not a valid number`);return e[t]}})),re=e(((exports,t)=>{let n=r(`node:events`).EventEmitter,i=r(`node:util`).inherits,a=ne(),o=I(),s=Buffer.from(`\r
2
2
  \r
3
- `),c=/\r\n/g,l=/^([^:]+):[ \t]?([\x00-\xFF]+)?$/;function u(e){n.call(this),e||={};let t=this;this.nread=0,this.maxed=!1,this.npairs=0,this.maxHeaderPairs=a(e,`maxHeaderPairs`,2e3),this.maxHeaderSize=a(e,`maxHeaderSize`,80*1024),this.buffer=``,this.header={},this.finished=!1,this.ss=new o(s),this.ss.on(`info`,function(e,n,r,i){n&&!t.maxed&&(t.nread+i-r>=t.maxHeaderSize?(i=t.maxHeaderSize-t.nread+r,t.nread=t.maxHeaderSize,t.maxed=!0):t.nread+=i-r,t.buffer+=n.toString(`binary`,r,i)),e&&t._finish()})}i(u,n),u.prototype.push=function(e){let t=this.ss.push(e);if(this.finished)return t},u.prototype.reset=function(){this.finished=!1,this.buffer=``,this.header={},this.ss.reset()},u.prototype._finish=function(){this.buffer&&this._parseHeader(),this.ss.matches=this.ss.maxMatches;let e=this.header;this.header={},this.buffer=``,this.finished=!0,this.nread=this.npairs=0,this.maxed=!1,this.emit(`header`,e)},u.prototype._parseHeader=function(){if(this.npairs===this.maxHeaderPairs)return;let e=this.buffer.split(c),t=e.length,n,r;for(var i=0;i<t;++i){if(e[i].length===0)continue;if((e[i][0]===` `||e[i][0]===` `)&&r){this.header[r][this.header[r].length-1]+=e[i];continue}let t=e[i].indexOf(`:`);if(t===-1||t===0)return;if(n=l.exec(e[i]),r=n[1].toLowerCase(),this.header[r]=this.header[r]||[],this.header[r].push(n[2]||``),++this.npairs===this.maxHeaderPairs)break}},t.exports=u})),L=e(((exports,t)=>{let n=r(`node:stream`).Writable,i=r(`node:util`).inherits,a=P(),o=F(),s=ne(),c=Buffer.from(`-`),l=Buffer.from(`\r
3
+ `),c=/\r\n/g,l=/^([^:]+):[ \t]?([\x00-\xFF]+)?$/;function u(e){n.call(this),e||={};let t=this;this.nread=0,this.maxed=!1,this.npairs=0,this.maxHeaderPairs=a(e,`maxHeaderPairs`,2e3),this.maxHeaderSize=a(e,`maxHeaderSize`,80*1024),this.buffer=``,this.header={},this.finished=!1,this.ss=new o(s),this.ss.on(`info`,function(e,n,r,i){n&&!t.maxed&&(t.nread+i-r>=t.maxHeaderSize?(i=t.maxHeaderSize-t.nread+r,t.nread=t.maxHeaderSize,t.maxed=!0):t.nread+=i-r,t.buffer+=n.toString(`binary`,r,i)),e&&t._finish()})}i(u,n),u.prototype.push=function(e){let t=this.ss.push(e);if(this.finished)return t},u.prototype.reset=function(){this.finished=!1,this.buffer=``,this.header={},this.ss.reset()},u.prototype._finish=function(){this.buffer&&this._parseHeader(),this.ss.matches=this.ss.maxMatches;let e=this.header;this.header={},this.buffer=``,this.finished=!0,this.nread=this.npairs=0,this.maxed=!1,this.emit(`header`,e)},u.prototype._parseHeader=function(){if(this.npairs===this.maxHeaderPairs)return;let e=this.buffer.split(c),t=e.length,n,r;for(var i=0;i<t;++i){if(e[i].length===0)continue;if((e[i][0]===` `||e[i][0]===` `)&&r){this.header[r][this.header[r].length-1]+=e[i];continue}let t=e[i].indexOf(`:`);if(t===-1||t===0)return;if(n=l.exec(e[i]),r=n[1].toLowerCase(),this.header[r]=this.header[r]||[],this.header[r].push(n[2]||``),++this.npairs===this.maxHeaderPairs)break}},t.exports=u})),L=e(((exports,t)=>{let n=r(`node:stream`).Writable,i=r(`node:util`).inherits,a=I(),o=te(),s=re(),c=Buffer.from(`-`),l=Buffer.from(`\r
4
4
  `),u=function(){};function d(e){if(!(this instanceof d))return new d(e);if(n.call(this,e),!e||!e.headerFirst&&typeof e.boundary!=`string`)throw TypeError(`Boundary required`);typeof e.boundary==`string`?this.setBoundary(e.boundary):this._bparser=void 0,this._headerFirst=e.headerFirst,this._dashes=0,this._parts=0,this._finished=!1,this._realFinish=!1,this._isPreamble=!0,this._justMatched=!1,this._firstWrite=!0,this._inHeader=!0,this._part=void 0,this._cb=void 0,this._ignoreData=!1,this._partOpts={highWaterMark:e.partHwm},this._pause=!1;let t=this;this._hparser=new s(e),this._hparser.on(`header`,function(e){t._inHeader=!1,t._part.emit(`header`,e)})}i(d,n),d.prototype.emit=function(e){if(e===`finish`&&!this._realFinish){if(!this._finished){let e=this;process.nextTick(function(){if(e.emit(`error`,Error(`Unexpected end of multipart data`)),e._part&&!e._ignoreData){let t=e._isPreamble?`Preamble`:`Part`;e._part.emit(`error`,Error(t+` terminated early due to unexpected end of multipart data`)),e._part.push(null),process.nextTick(function(){e._realFinish=!0,e.emit(`finish`),e._realFinish=!1});return}e._realFinish=!0,e.emit(`finish`),e._realFinish=!1})}}else n.prototype.emit.apply(this,arguments)},d.prototype._write=function(e,t,n){if(!this._hparser&&!this._bparser)return n();if(this._headerFirst&&this._isPreamble){this._part||(this._part=new o(this._partOpts),this.listenerCount(`preamble`)===0?this._ignore():this.emit(`preamble`,this._part));let t=this._hparser.push(e);if(!this._inHeader&&t!==void 0&&t<e.length)e=e.slice(t);else return n()}this._firstWrite&&=(this._bparser.push(l),!1),this._bparser.push(e),this._pause?this._cb=n:n()},d.prototype.reset=function(){this._part=void 0,this._bparser=void 0,this._hparser=void 0},d.prototype.setBoundary=function(e){let t=this;this._bparser=new a(`\r
5
- --`+e),this._bparser.on(`info`,function(e,n,r,i){t._oninfo(e,n,r,i)})},d.prototype._ignore=function(){this._part&&!this._ignoreData&&(this._ignoreData=!0,this._part.on(`error`,u),this._part.resume())},d.prototype._oninfo=function(e,t,n,r){let i,a=this,s=0,l,u=!0;if(!this._part&&this._justMatched&&t){for(;this._dashes<2&&n+s<r;)if(t[n+s]===45)++s,++this._dashes;else{this._dashes&&(i=c),this._dashes=0;break}if(this._dashes===2&&(n+s<r&&this.listenerCount(`trailer`)!==0&&this.emit(`trailer`,t.slice(n+s,r)),this.reset(),this._finished=!0,a._parts===0&&(a._realFinish=!0,a.emit(`finish`),a._realFinish=!1)),this._dashes)return}this._justMatched&&=!1,this._part||(this._part=new o(this._partOpts),this._part._read=function(e){a._unpause()},this._isPreamble&&this.listenerCount(`preamble`)!==0?this.emit(`preamble`,this._part):this._isPreamble!==!0&&this.listenerCount(`part`)!==0?this.emit(`part`,this._part):this._ignore(),this._isPreamble||(this._inHeader=!0)),t&&n<r&&!this._ignoreData&&(this._isPreamble||!this._inHeader?(i&&(u=this._part.push(i)),u=this._part.push(t.slice(n,r)),u||(this._pause=!0)):!this._isPreamble&&this._inHeader&&(i&&this._hparser.push(i),l=this._hparser.push(t.slice(n,r)),!this._inHeader&&l!==void 0&&l<r&&this._oninfo(!1,t,n+l,r))),e&&(this._hparser.reset(),this._isPreamble?this._isPreamble=!1:n!==r&&(++this._parts,this._part.on(`end`,function(){--a._parts===0&&(a._finished?(a._realFinish=!0,a.emit(`finish`),a._realFinish=!1):a._unpause())})),this._part.push(null),this._part=void 0,this._ignoreData=!1,this._justMatched=!0,this._dashes=0)},d.prototype._unpause=function(){if(this._pause&&(this._pause=!1,this._cb)){let e=this._cb;this._cb=void 0,e()}},t.exports=d})),R=e(((exports,t)=>{let n=new TextDecoder(`utf-8`),r=new Map([[`utf-8`,n],[`utf8`,n]]);function i(e){let t;for(;;)switch(e){case`utf-8`:case`utf8`:return a.utf8;case`latin1`:case`ascii`:case`us-ascii`:case`iso-8859-1`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`windows-1252`:case`iso_8859-1:1987`:case`cp1252`:case`x-cp1252`:return a.latin1;case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:return a.utf16le;case`base64`:return a.base64;default:if(t===void 0){t=!0,e=e.toLowerCase();continue}return a.other.bind(e)}}let a={utf8:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.utf8Slice(0,e.length)),latin1:(e,t)=>e.length===0?``:typeof e==`string`?e:e.latin1Slice(0,e.length),utf16le:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.ucs2Slice(0,e.length)),base64:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.base64Slice(0,e.length)),other:(t,n)=>{if(t.length===0)return``;if(typeof t==`string`&&(t=Buffer.from(t,n)),r.has(exports.toString()))try{return r.get(exports).decode(t)}catch{}return typeof t==`string`?t:t.toString()}};function o(e,t,n){return e&&i(n)(e,t)}t.exports=o})),re=e(((exports,t)=>{let n=R(),r=/%[a-fA-F0-9][a-fA-F0-9]/g,i={"%00":`\0`,"%01":``,"%02":``,"%03":``,"%04":``,"%05":``,"%06":``,"%07":`\x07`,"%08":`\b`,"%09":` `,"%0a":`
5
+ --`+e),this._bparser.on(`info`,function(e,n,r,i){t._oninfo(e,n,r,i)})},d.prototype._ignore=function(){this._part&&!this._ignoreData&&(this._ignoreData=!0,this._part.on(`error`,u),this._part.resume())},d.prototype._oninfo=function(e,t,n,r){let i,a=this,s=0,l,u=!0;if(!this._part&&this._justMatched&&t){for(;this._dashes<2&&n+s<r;)if(t[n+s]===45)++s,++this._dashes;else{this._dashes&&(i=c),this._dashes=0;break}if(this._dashes===2&&(n+s<r&&this.listenerCount(`trailer`)!==0&&this.emit(`trailer`,t.slice(n+s,r)),this.reset(),this._finished=!0,a._parts===0&&(a._realFinish=!0,a.emit(`finish`),a._realFinish=!1)),this._dashes)return}this._justMatched&&=!1,this._part||(this._part=new o(this._partOpts),this._part._read=function(e){a._unpause()},this._isPreamble&&this.listenerCount(`preamble`)!==0?this.emit(`preamble`,this._part):this._isPreamble!==!0&&this.listenerCount(`part`)!==0?this.emit(`part`,this._part):this._ignore(),this._isPreamble||(this._inHeader=!0)),t&&n<r&&!this._ignoreData&&(this._isPreamble||!this._inHeader?(i&&(u=this._part.push(i)),u=this._part.push(t.slice(n,r)),u||(this._pause=!0)):!this._isPreamble&&this._inHeader&&(i&&this._hparser.push(i),l=this._hparser.push(t.slice(n,r)),!this._inHeader&&l!==void 0&&l<r&&this._oninfo(!1,t,n+l,r))),e&&(this._hparser.reset(),this._isPreamble?this._isPreamble=!1:n!==r&&(++this._parts,this._part.on(`end`,function(){--a._parts===0&&(a._finished?(a._realFinish=!0,a.emit(`finish`),a._realFinish=!1):a._unpause())})),this._part.push(null),this._part=void 0,this._ignoreData=!1,this._justMatched=!0,this._dashes=0)},d.prototype._unpause=function(){if(this._pause&&(this._pause=!1,this._cb)){let e=this._cb;this._cb=void 0,e()}},t.exports=d})),ie=e(((exports,t)=>{let n=new TextDecoder(`utf-8`),r=new Map([[`utf-8`,n],[`utf8`,n]]);function i(e){let t;for(;;)switch(e){case`utf-8`:case`utf8`:return a.utf8;case`latin1`:case`ascii`:case`us-ascii`:case`iso-8859-1`:case`iso8859-1`:case`iso88591`:case`iso_8859-1`:case`windows-1252`:case`iso_8859-1:1987`:case`cp1252`:case`x-cp1252`:return a.latin1;case`utf16le`:case`utf-16le`:case`ucs2`:case`ucs-2`:return a.utf16le;case`base64`:return a.base64;default:if(t===void 0){t=!0,e=e.toLowerCase();continue}return a.other.bind(e)}}let a={utf8:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.utf8Slice(0,e.length)),latin1:(e,t)=>e.length===0?``:typeof e==`string`?e:e.latin1Slice(0,e.length),utf16le:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.ucs2Slice(0,e.length)),base64:(e,t)=>e.length===0?``:(typeof e==`string`&&(e=Buffer.from(e,t)),e.base64Slice(0,e.length)),other:(t,n)=>{if(t.length===0)return``;if(typeof t==`string`&&(t=Buffer.from(t,n)),r.has(exports.toString()))try{return r.get(exports).decode(t)}catch{}return typeof t==`string`?t:t.toString()}};function o(e,t,n){return e&&i(n)(e,t)}t.exports=o})),ae=e(((exports,t)=>{let n=ie(),r=/%[a-fA-F0-9][a-fA-F0-9]/g,i={"%00":`\0`,"%01":``,"%02":``,"%03":``,"%04":``,"%05":``,"%06":``,"%07":`\x07`,"%08":`\b`,"%09":` `,"%0a":`
6
6
  `,"%0A":`
7
- `,"%0b":`\v`,"%0B":`\v`,"%0c":`\f`,"%0C":`\f`,"%0d":`\r`,"%0D":`\r`,"%0e":``,"%0E":``,"%0f":``,"%0F":``,"%10":``,"%11":``,"%12":``,"%13":``,"%14":``,"%15":``,"%16":``,"%17":``,"%18":``,"%19":``,"%1a":``,"%1A":``,"%1b":`\x1B`,"%1B":`\x1B`,"%1c":``,"%1C":``,"%1d":``,"%1D":``,"%1e":``,"%1E":``,"%1f":``,"%1F":``,"%20":` `,"%21":`!`,"%22":`"`,"%23":`#`,"%24":`$`,"%25":`%`,"%26":`&`,"%27":`'`,"%28":`(`,"%29":`)`,"%2a":`*`,"%2A":`*`,"%2b":`+`,"%2B":`+`,"%2c":`,`,"%2C":`,`,"%2d":`-`,"%2D":`-`,"%2e":`.`,"%2E":`.`,"%2f":`/`,"%2F":`/`,"%30":`0`,"%31":`1`,"%32":`2`,"%33":`3`,"%34":`4`,"%35":`5`,"%36":`6`,"%37":`7`,"%38":`8`,"%39":`9`,"%3a":`:`,"%3A":`:`,"%3b":`;`,"%3B":`;`,"%3c":`<`,"%3C":`<`,"%3d":`=`,"%3D":`=`,"%3e":`>`,"%3E":`>`,"%3f":`?`,"%3F":`?`,"%40":`@`,"%41":`A`,"%42":`B`,"%43":`C`,"%44":`D`,"%45":`E`,"%46":`F`,"%47":`G`,"%48":`H`,"%49":`I`,"%4a":`J`,"%4A":`J`,"%4b":`K`,"%4B":`K`,"%4c":`L`,"%4C":`L`,"%4d":`M`,"%4D":`M`,"%4e":`N`,"%4E":`N`,"%4f":`O`,"%4F":`O`,"%50":`P`,"%51":`Q`,"%52":`R`,"%53":`S`,"%54":`T`,"%55":`U`,"%56":`V`,"%57":`W`,"%58":`X`,"%59":`Y`,"%5a":`Z`,"%5A":`Z`,"%5b":`[`,"%5B":`[`,"%5c":`\\`,"%5C":`\\`,"%5d":`]`,"%5D":`]`,"%5e":`^`,"%5E":`^`,"%5f":`_`,"%5F":`_`,"%60":"`","%61":`a`,"%62":`b`,"%63":`c`,"%64":`d`,"%65":`e`,"%66":`f`,"%67":`g`,"%68":`h`,"%69":`i`,"%6a":`j`,"%6A":`j`,"%6b":`k`,"%6B":`k`,"%6c":`l`,"%6C":`l`,"%6d":`m`,"%6D":`m`,"%6e":`n`,"%6E":`n`,"%6f":`o`,"%6F":`o`,"%70":`p`,"%71":`q`,"%72":`r`,"%73":`s`,"%74":`t`,"%75":`u`,"%76":`v`,"%77":`w`,"%78":`x`,"%79":`y`,"%7a":`z`,"%7A":`z`,"%7b":`{`,"%7B":`{`,"%7c":`|`,"%7C":`|`,"%7d":`}`,"%7D":`}`,"%7e":`~`,"%7E":`~`,"%7f":``,"%7F":``,"%80":`€`,"%81":``,"%82":`‚`,"%83":`ƒ`,"%84":`„`,"%85":`…`,"%86":`†`,"%87":`‡`,"%88":`ˆ`,"%89":`‰`,"%8a":`Š`,"%8A":`Š`,"%8b":`‹`,"%8B":`‹`,"%8c":`Œ`,"%8C":`Œ`,"%8d":``,"%8D":``,"%8e":`Ž`,"%8E":`Ž`,"%8f":``,"%8F":``,"%90":``,"%91":`‘`,"%92":`’`,"%93":`“`,"%94":`”`,"%95":`•`,"%96":`–`,"%97":`—`,"%98":`˜`,"%99":`™`,"%9a":`š`,"%9A":`š`,"%9b":`›`,"%9B":`›`,"%9c":`œ`,"%9C":`œ`,"%9d":``,"%9D":``,"%9e":`ž`,"%9E":`ž`,"%9f":`Ÿ`,"%9F":`Ÿ`,"%a0":`\xA0`,"%A0":`\xA0`,"%a1":`¡`,"%A1":`¡`,"%a2":`¢`,"%A2":`¢`,"%a3":`£`,"%A3":`£`,"%a4":`¤`,"%A4":`¤`,"%a5":`¥`,"%A5":`¥`,"%a6":`¦`,"%A6":`¦`,"%a7":`§`,"%A7":`§`,"%a8":`¨`,"%A8":`¨`,"%a9":`©`,"%A9":`©`,"%aa":`ª`,"%Aa":`ª`,"%aA":`ª`,"%AA":`ª`,"%ab":`«`,"%Ab":`«`,"%aB":`«`,"%AB":`«`,"%ac":`¬`,"%Ac":`¬`,"%aC":`¬`,"%AC":`¬`,"%ad":`­`,"%Ad":`­`,"%aD":`­`,"%AD":`­`,"%ae":`®`,"%Ae":`®`,"%aE":`®`,"%AE":`®`,"%af":`¯`,"%Af":`¯`,"%aF":`¯`,"%AF":`¯`,"%b0":`°`,"%B0":`°`,"%b1":`±`,"%B1":`±`,"%b2":`²`,"%B2":`²`,"%b3":`³`,"%B3":`³`,"%b4":`´`,"%B4":`´`,"%b5":`µ`,"%B5":`µ`,"%b6":`¶`,"%B6":`¶`,"%b7":`·`,"%B7":`·`,"%b8":`¸`,"%B8":`¸`,"%b9":`¹`,"%B9":`¹`,"%ba":`º`,"%Ba":`º`,"%bA":`º`,"%BA":`º`,"%bb":`»`,"%Bb":`»`,"%bB":`»`,"%BB":`»`,"%bc":`¼`,"%Bc":`¼`,"%bC":`¼`,"%BC":`¼`,"%bd":`½`,"%Bd":`½`,"%bD":`½`,"%BD":`½`,"%be":`¾`,"%Be":`¾`,"%bE":`¾`,"%BE":`¾`,"%bf":`¿`,"%Bf":`¿`,"%bF":`¿`,"%BF":`¿`,"%c0":`À`,"%C0":`À`,"%c1":`Á`,"%C1":`Á`,"%c2":`Â`,"%C2":`Â`,"%c3":`Ã`,"%C3":`Ã`,"%c4":`Ä`,"%C4":`Ä`,"%c5":`Å`,"%C5":`Å`,"%c6":`Æ`,"%C6":`Æ`,"%c7":`Ç`,"%C7":`Ç`,"%c8":`È`,"%C8":`È`,"%c9":`É`,"%C9":`É`,"%ca":`Ê`,"%Ca":`Ê`,"%cA":`Ê`,"%CA":`Ê`,"%cb":`Ë`,"%Cb":`Ë`,"%cB":`Ë`,"%CB":`Ë`,"%cc":`Ì`,"%Cc":`Ì`,"%cC":`Ì`,"%CC":`Ì`,"%cd":`Í`,"%Cd":`Í`,"%cD":`Í`,"%CD":`Í`,"%ce":`Î`,"%Ce":`Î`,"%cE":`Î`,"%CE":`Î`,"%cf":`Ï`,"%Cf":`Ï`,"%cF":`Ï`,"%CF":`Ï`,"%d0":`Ð`,"%D0":`Ð`,"%d1":`Ñ`,"%D1":`Ñ`,"%d2":`Ò`,"%D2":`Ò`,"%d3":`Ó`,"%D3":`Ó`,"%d4":`Ô`,"%D4":`Ô`,"%d5":`Õ`,"%D5":`Õ`,"%d6":`Ö`,"%D6":`Ö`,"%d7":`×`,"%D7":`×`,"%d8":`Ø`,"%D8":`Ø`,"%d9":`Ù`,"%D9":`Ù`,"%da":`Ú`,"%Da":`Ú`,"%dA":`Ú`,"%DA":`Ú`,"%db":`Û`,"%Db":`Û`,"%dB":`Û`,"%DB":`Û`,"%dc":`Ü`,"%Dc":`Ü`,"%dC":`Ü`,"%DC":`Ü`,"%dd":`Ý`,"%Dd":`Ý`,"%dD":`Ý`,"%DD":`Ý`,"%de":`Þ`,"%De":`Þ`,"%dE":`Þ`,"%DE":`Þ`,"%df":`ß`,"%Df":`ß`,"%dF":`ß`,"%DF":`ß`,"%e0":`à`,"%E0":`à`,"%e1":`á`,"%E1":`á`,"%e2":`â`,"%E2":`â`,"%e3":`ã`,"%E3":`ã`,"%e4":`ä`,"%E4":`ä`,"%e5":`å`,"%E5":`å`,"%e6":`æ`,"%E6":`æ`,"%e7":`ç`,"%E7":`ç`,"%e8":`è`,"%E8":`è`,"%e9":`é`,"%E9":`é`,"%ea":`ê`,"%Ea":`ê`,"%eA":`ê`,"%EA":`ê`,"%eb":`ë`,"%Eb":`ë`,"%eB":`ë`,"%EB":`ë`,"%ec":`ì`,"%Ec":`ì`,"%eC":`ì`,"%EC":`ì`,"%ed":`í`,"%Ed":`í`,"%eD":`í`,"%ED":`í`,"%ee":`î`,"%Ee":`î`,"%eE":`î`,"%EE":`î`,"%ef":`ï`,"%Ef":`ï`,"%eF":`ï`,"%EF":`ï`,"%f0":`ð`,"%F0":`ð`,"%f1":`ñ`,"%F1":`ñ`,"%f2":`ò`,"%F2":`ò`,"%f3":`ó`,"%F3":`ó`,"%f4":`ô`,"%F4":`ô`,"%f5":`õ`,"%F5":`õ`,"%f6":`ö`,"%F6":`ö`,"%f7":`÷`,"%F7":`÷`,"%f8":`ø`,"%F8":`ø`,"%f9":`ù`,"%F9":`ù`,"%fa":`ú`,"%Fa":`ú`,"%fA":`ú`,"%FA":`ú`,"%fb":`û`,"%Fb":`û`,"%fB":`û`,"%FB":`û`,"%fc":`ü`,"%Fc":`ü`,"%fC":`ü`,"%FC":`ü`,"%fd":`ý`,"%Fd":`ý`,"%fD":`ý`,"%FD":`ý`,"%fe":`þ`,"%Fe":`þ`,"%fE":`þ`,"%FE":`þ`,"%ff":`ÿ`,"%Ff":`ÿ`,"%fF":`ÿ`,"%FF":`ÿ`};function a(e){return i[e]}function o(e){let t=[],i=0,o=``,s=!1,c=!1,l=0,u=``,d=e.length;for(var f=0;f<d;++f){let p=e[f];if(p===`\\`&&s)if(c)c=!1;else{c=!0;continue}else if(p===`"`)if(c)c=!1;else{if(s)for(s=!1,i=0;f+1<d&&e[f+1]!==`;`;)++f;else s=!0;continue}else if(c&&s&&(u+=`\\`),c=!1,(i===2||i===3)&&p===`'`){i===2?(i=3,o=u.substring(1)):i=1,u=``;continue}else if(i===0&&(p===`*`||p===`=`)&&t.length){i=p===`*`?2:1,t[l]=[u,void 0],u=``;continue}else if(!s&&p===`;`){i=0,o?(u.length&&(u=n(u.replace(r,a),`binary`,o)),o=``):u.length&&(u=n(u,`binary`,`utf8`)),t[l]===void 0?t[l]=u:t[l][1]=u,u=``,++l;continue}else if(!s&&(p===` `||p===` `))continue;u+=p}return o&&u.length?u=n(u.replace(r,a),`binary`,o):u&&=n(u,`binary`,`utf8`),t[l]===void 0?u&&(t[l]=u):t[l][1]=u,t}t.exports=o})),ie=e(((exports,t)=>{t.exports=function(e){if(typeof e!=`string`)return``;for(var t=e.length-1;t>=0;--t)switch(e.charCodeAt(t)){case 47:case 92:return e=e.slice(t+1),e===`..`||e===`.`?``:e}return e===`..`||e===`.`?``:e}})),ae=e(((exports,t)=>{let{Readable:n}=r(`node:stream`),{inherits:i}=r(`node:util`),a=L(),o=re(),s=R(),c=ie(),l=I(),u=/^boundary$/i,d=/^form-data$/i,f=/^charset$/i,p=/^filename$/i,m=/^name$/i;h.detect=/^multipart\/form-data/i;function h(e,t){let n,r,i=this,h,v=t.limits,y=t.isPartAFile||((e,t,n)=>t===`application/octet-stream`||n!==void 0),b=t.parsedConType||[],x=t.defCharset||`utf8`,S=t.preservePath,C={highWaterMark:t.fileHwm};for(n=0,r=b.length;n<r;++n)if(Array.isArray(b[n])&&u.test(b[n][0])){h=b[n][1];break}function ee(){M===0&&F&&!e._done&&(F=!1,i.end())}if(typeof h!=`string`)throw Error(`Multipart: Boundary not found`);let w=l(v,`fieldSize`,1*1024*1024),T=l(v,`fileSize`,1/0),E=l(v,`files`,1/0),D=l(v,`fields`,1/0),O=l(v,`parts`,1/0),k=l(v,`headerPairs`,2e3),A=l(v,`headerSize`,80*1024),j=0,te=0,M=0,N,P,F=!1;this._needDrain=!1,this._pause=!1,this._cb=void 0,this._nparts=0,this._boy=e;let I={boundary:h,maxHeaderPairs:k,maxHeaderSize:A,partHwm:C.highWaterMark,highWaterMark:t.highWaterMark};this.parser=new a(I),this.parser.on(`drain`,function(){if(i._needDrain=!1,i._cb&&!i._pause){let e=i._cb;i._cb=void 0,e()}}).on(`part`,function t(a){if(++i._nparts>O)return i.parser.removeListener(`part`,t),i.parser.on(`part`,g),e.hitPartsLimit=!0,e.emit(`partsLimit`),g(a);if(P){let e=P;e.emit(`end`),e.removeAllListeners(`end`)}a.on(`header`,function(t){let l,u,h,v,b,O,k=0;if(t[`content-type`]&&(h=o(t[`content-type`][0]),h[0])){for(l=h[0].toLowerCase(),n=0,r=h.length;n<r;++n)if(f.test(h[n][0])){v=h[n][1].toLowerCase();break}}if(l===void 0&&(l=`text/plain`),v===void 0&&(v=x),t[`content-disposition`]){if(h=o(t[`content-disposition`][0]),!d.test(h[0]))return g(a);for(n=0,r=h.length;n<r;++n)m.test(h[n][0])?u=h[n][1]:p.test(h[n][0])&&(O=h[n][1],S||(O=c(O)))}else return g(a);b=t[`content-transfer-encoding`]?t[`content-transfer-encoding`][0].toLowerCase():`7bit`;let A,F;if(y(u,l,O)){if(j===E)return e.hitFilesLimit||(e.hitFilesLimit=!0,e.emit(`filesLimit`)),g(a);if(++j,e.listenerCount(`file`)===0){i.parser._ignore();return}++M;let t=new _(C);N=t,t.on(`end`,function(){if(--M,i._pause=!1,ee(),i._cb&&!i._needDrain){let e=i._cb;i._cb=void 0,e()}}),t._read=function(e){if(i._pause&&(i._pause=!1,i._cb&&!i._needDrain)){let e=i._cb;i._cb=void 0,e()}},e.emit(`file`,u,t,O,b,l),A=function(e){if((k+=e.length)>T){let n=T-k+e.length;n>0&&t.push(e.slice(0,n)),t.truncated=!0,t.bytesRead=T,a.removeAllListeners(`data`),t.emit(`limit`);return}else t.push(e)||(i._pause=!0);t.bytesRead=k},F=function(){N=void 0,t.push(null)}}else{if(te===D)return e.hitFieldsLimit||(e.hitFieldsLimit=!0,e.emit(`fieldsLimit`)),g(a);++te,++M;let t=``,n=!1;P=a,A=function(e){if((k+=e.length)>w){let r=w-(k-e.length);t+=e.toString(`binary`,0,r),n=!0,a.removeAllListeners(`data`)}else t+=e.toString(`binary`)},F=function(){P=void 0,t.length&&(t=s(t,`binary`,v)),e.emit(`field`,u,t,!1,n,b,l),--M,ee()}}a._readableState.sync=!1,a.on(`data`,A),a.on(`end`,F)}).on(`error`,function(e){N&&N.emit(`error`,e)})}).on(`error`,function(t){e.emit(`error`,t)}).on(`finish`,function(){F=!0,ee()})}h.prototype.write=function(e,t){let n=this.parser.write(e);n&&!this._pause?t():(this._needDrain=!n,this._cb=t)},h.prototype.end=function(){let e=this;e.parser.writable?e.parser.end():e._boy._done||process.nextTick(function(){e._boy._done=!0,e._boy.emit(`finish`)})};function g(e){e.resume()}function _(e){n.call(this,e),this.bytesRead=0,this.truncated=!1}i(_,n),_.prototype._read=function(e){},t.exports=h})),oe=e(((exports,t)=>{let n=/\+/g,r=[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,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,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,1,1,1,1,1,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];function i(){this.buffer=void 0}i.prototype.write=function(e){e=e.replace(n,` `);let t=``,i=0,a=0,o=e.length;for(;i<o;++i)this.buffer===void 0?e[i]===`%`&&(i>a&&(t+=e.substring(a,i),a=i),this.buffer=``,++a):r[e.charCodeAt(i)]?(this.buffer+=e[i],++a,this.buffer.length===2&&(t+=String.fromCharCode(parseInt(this.buffer,16)),this.buffer=void 0)):(t+=`%`+this.buffer,this.buffer=void 0,--i);return a<o&&this.buffer===void 0&&(t+=e.substring(a)),t},i.prototype.reset=function(){this.buffer=void 0},t.exports=i})),se=e(((exports,t)=>{let n=oe(),r=R(),i=I(),a=/^charset$/i;o.detect=/^application\/x-www-form-urlencoded/i;function o(e,t){let r=t.limits,o=t.parsedConType;this.boy=e,this.fieldSizeLimit=i(r,`fieldSize`,1*1024*1024),this.fieldNameSizeLimit=i(r,`fieldNameSize`,100),this.fieldsLimit=i(r,`fields`,1/0);let s;for(var c=0,l=o.length;c<l;++c)if(Array.isArray(o[c])&&a.test(o[c][0])){s=o[c][1].toLowerCase();break}s===void 0&&(s=t.defCharset||`utf8`),this.decoder=new n,this.charset=s,this._fields=0,this._state=`key`,this._checkingBytes=!0,this._bytesKey=0,this._bytesVal=0,this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._hitLimit=!1}o.prototype.write=function(e,t){if(this._fields===this.fieldsLimit)return this.boy.hitFieldsLimit||(this.boy.hitFieldsLimit=!0,this.boy.emit(`fieldsLimit`)),t();let n,i,a,o=0,s=e.length;for(;o<s;)if(this._state===`key`){for(n=i=void 0,a=o;a<s;++a){if(this._checkingBytes||++o,e[a]===61){n=a;break}else if(e[a]===38){i=a;break}if(this._checkingBytes&&this._bytesKey===this.fieldNameSizeLimit){this._hitLimit=!0;break}else this._checkingBytes&&++this._bytesKey}if(n!==void 0)n>o&&(this._key+=this.decoder.write(e.toString(`binary`,o,n))),this._state=`val`,this._hitLimit=!1,this._checkingBytes=!0,this._val=``,this._bytesVal=0,this._valTrunc=!1,this.decoder.reset(),o=n+1;else if(i!==void 0){++this._fields;let n,a=this._keyTrunc;if(n=i>o?this._key+=this.decoder.write(e.toString(`binary`,o,i)):this._key,this._hitLimit=!1,this._checkingBytes=!0,this._key=``,this._bytesKey=0,this._keyTrunc=!1,this.decoder.reset(),n.length&&this.boy.emit(`field`,r(n,`binary`,this.charset),``,a,!1),o=i+1,this._fields===this.fieldsLimit)return t()}else this._hitLimit?(a>o&&(this._key+=this.decoder.write(e.toString(`binary`,o,a))),o=a,(this._bytesKey=this._key.length)===this.fieldNameSizeLimit&&(this._checkingBytes=!1,this._keyTrunc=!0)):(o<s&&(this._key+=this.decoder.write(e.toString(`binary`,o))),o=s)}else{for(i=void 0,a=o;a<s;++a){if(this._checkingBytes||++o,e[a]===38){i=a;break}if(this._checkingBytes&&this._bytesVal===this.fieldSizeLimit){this._hitLimit=!0;break}else this._checkingBytes&&++this._bytesVal}if(i!==void 0){if(++this._fields,i>o&&(this._val+=this.decoder.write(e.toString(`binary`,o,i))),this.boy.emit(`field`,r(this._key,`binary`,this.charset),r(this._val,`binary`,this.charset),this._keyTrunc,this._valTrunc),this._state=`key`,this._hitLimit=!1,this._checkingBytes=!0,this._key=``,this._bytesKey=0,this._keyTrunc=!1,this.decoder.reset(),o=i+1,this._fields===this.fieldsLimit)return t()}else this._hitLimit?(a>o&&(this._val+=this.decoder.write(e.toString(`binary`,o,a))),o=a,(this._val===``&&this.fieldSizeLimit===0||(this._bytesVal=this._val.length)===this.fieldSizeLimit)&&(this._checkingBytes=!1,this._valTrunc=!0)):(o<s&&(this._val+=this.decoder.write(e.toString(`binary`,o))),o=s)}t()},o.prototype.end=function(){this.boy._done||(this._state===`key`&&this._key.length>0?this.boy.emit(`field`,r(this._key,`binary`,this.charset),``,this._keyTrunc,!1):this._state===`val`&&this.boy.emit(`field`,r(this._key,`binary`,this.charset),r(this._val,`binary`,this.charset),this._keyTrunc,this._valTrunc),this.boy._done=!0,this.boy.emit(`finish`))},t.exports=o})),ce=e(((exports,t)=>{let n=r(`node:stream`).Writable,{inherits:i}=r(`node:util`),a=L(),o=ae(),s=se(),c=re();function l(e){if(!(this instanceof l))return new l(e);if(typeof e!=`object`)throw TypeError(`Busboy expected an options-Object.`);if(typeof e.headers!=`object`)throw TypeError(`Busboy expected an options-Object with headers-attribute.`);if(typeof e.headers[`content-type`]!=`string`)throw TypeError(`Missing Content-Type-header.`);let{headers:t,...r}=e;this.opts={autoDestroy:!1,...r},n.call(this,this.opts),this._done=!1,this._parser=this.getParserByHeaders(t),this._finished=!1}i(l,n),l.prototype.emit=function(e){if(e===`finish`){if(this._done){if(this._finished)return}else{this._parser?.end();return}this._finished=!0}n.prototype.emit.apply(this,arguments)},l.prototype.getParserByHeaders=function(e){let t=c(e[`content-type`]),n={defCharset:this.opts.defCharset,fileHwm:this.opts.fileHwm,headers:e,highWaterMark:this.opts.highWaterMark,isPartAFile:this.opts.isPartAFile,limits:this.opts.limits,parsedConType:t,preservePath:this.opts.preservePath};if(o.detect.test(t[0]))return new o(this,n);if(s.detect.test(t[0]))return new s(this,n);throw Error(`Unsupported Content-Type.`)},l.prototype._write=function(e,t,n){this._parser.write(e,n)},t.exports=l,t.exports.default=l,t.exports.Busboy=l,t.exports.Dicer=a})),z=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fakePromise=void 0,exports.getHeadersObj=i,exports.defaultHeadersSerializer=a,exports.isArrayBufferView=s,exports.isNodeReadable=c,exports.isIterable=l,exports.shouldRedirect=u,exports.pipeThrough=d,exports.endStream=f,exports.safeWrite=p;let t=r(`node:events`);function n(e){return e?.forEach!=null}function i(e){return e==null||!n(e)?e:e.headersInit&&!e._map&&!n(e.headersInit)?e.headersInit:Object.fromEntries(e.entries())}function a(e,t){let n=[];return e.forEach((e,r)=>{t&&r===`content-length`&&t(e),n.push(`${r}: ${e}`)}),n}var o=N();Object.defineProperty(exports,`fakePromise`,{enumerable:!0,get:function(){return o.fakePromise}});function s(e){return e!=null&&e.buffer!=null&&e.byteLength!=null&&e.byteOffset!=null}function c(e){return e!=null&&e.pipe!=null}function l(e){return e?.[Symbol.iterator]!=null}function u(e){return e===301||e===302||e===303||e===307||e===308}function d({src:e,dest:t,signal:n,onError:r}){if(r&&t.once(`error`,r),e.once(`error`,e=>{t.destroy(e)}),t.once(`close`,()=>{e.destroyed||e.destroy()}),n){let t=new WeakRef(e),r=new WeakRef(n);function i(){r.deref()?.removeEventListener(`abort`,a),t.deref()?.removeListener(`end`,i),t.deref()?.removeListener(`error`,i),t.deref()?.removeListener(`close`,i)}function a(){t.deref()?.destroy(new m),i()}n.addEventListener(`abort`,a,{once:!0}),e.once(`end`,i),e.once(`error`,i),e.once(`close`,i)}e.pipe(t,{end:!0})}function f(e){return e.end(null,null,null)}function p(e,n){let r=n.write(e);if(!r)return(0,t.once)(n,`drain`)}var m=class extends Error{constructor(e=`The operation was aborted`,t=void 0){super(e,t),this.name=`AbortError`}}})),B=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillReadableStream=void 0;let t=r(`node:buffer`),n=r(`node:events`),i=r(`node:stream`),a=r(`node:stream/promises`),o=N(),s=z();function c(e,n){let r=[],i=!1,a=!1;return{desiredSize:e,enqueue(e){let i=typeof e==`string`?t.Buffer.from(e):e;a?n.push(i):r.push(i)},close(){r.length>0&&this._flush(),n.push(null),i=!0},error(e){r.length>0&&this._flush(),n.destroy(e)},get _closed(){return i},_flush(){if(a=!0,r.length>0){let e=r.length>1?t.Buffer.concat(r):r[0];n.push(e),r=[]}}}}function l(e){return e?.read!=null}function u(e){return e?.getReader!=null}var d=class e{readable;constructor(t){if(t instanceof e&&t.readable!=null)this.readable=t.readable;else if(l(t))this.readable=t;else if(u(t))this.readable=i.Readable.fromWeb(t);else{let e=!1,n=!1,r=n=>{if(!e){let r=c(n,this.readable);return e=!0,(0,o.handleMaybePromise)(()=>t?.start?.(r),()=>(r._flush(),!r._closed))}return!0},a=e=>(0,o.handleMaybePromise)(()=>r(e),r=>{if(!r)return;let i=c(e,this.readable);return(0,o.handleMaybePromise)(()=>t?.pull?.(i),()=>{i._flush(),n=!1})});this.readable=new i.Readable({read(e){if(!n)return n=!0,a(e)},destroy(e,n){if(t?.cancel)try{let r=t.cancel(e);if(r?.then)return r.then(()=>{n(null)},e=>{n(e)})}catch(e){n(e);return}n(null)}})}}cancel(e){return this.readable.destroy(e),(0,n.once)(this.readable,`close`)}locked=!1;getReader(e){let t=this.readable[Symbol.asyncIterator]();this.locked=!0;let r=this.readable;return{read(){return t.next()},releaseLock:()=>{if(t.return){let e=t.return();if(e.then){e.then(()=>{this.locked=!1});return}}this.locked=!1},cancel:e=>{if(t.return){let n=t.return(e);if(n.then)return n.then(()=>{this.locked=!1})}return this.locked=!1,(0,s.fakePromise)()},get closed(){return Promise.race([(0,n.once)(r,`end`),(0,n.once)(r,`error`).then(e=>Promise.reject(e))])}}}[Symbol.asyncIterator](){let e=this.readable[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},next:()=>e.next(),return:()=>(this.readable.destroyed||this.readable.destroy(),e.return?.()||(0,s.fakePromise)({done:!0,value:void 0})),throw:t=>(this.readable.destroyed||this.readable.destroy(t),e.throw?.(t)||(0,s.fakePromise)({done:!0,value:void 0}))}}tee(){throw Error(`Not implemented`)}async pipeToWriter(e){try{for await(let t of this)await e.write(t);await e.close()}catch(t){await e.abort(t)}}pipeTo(e){if(p(e))return(0,a.pipeline)(this.readable,e.writable,{end:!0});{let t=e.getWriter();return this.pipeToWriter(t)}}pipeThrough({writable:e,readable:t}){return this.pipeTo(e).catch(e=>{this.readable.destroy(e)}),f(t)&&(t.readable.once(`error`,e=>this.readable.destroy(e)),t.readable.once(`finish`,()=>this.readable.push(null)),t.readable.once(`close`,()=>this.readable.push(null))),t}static[Symbol.hasInstance](e){return u(e)}static from(t){return new e(i.Readable.from(t))}[Symbol.toStringTag]=`ReadableStream`};exports.PonyfillReadableStream=d;function f(e){return e?.readable!=null}function p(e){return e?.writable!=null}})),V=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillBlob=void 0,exports.hasBufferMethod=o,exports.hasArrayBufferMethod=s,exports.hasBytesMethod=c,exports.hasTextMethod=l,exports.hasSizeProperty=u,exports.hasStreamMethod=d,exports.hasBlobSignature=f,exports.isArrayBuffer=p;let t=r(`node:buffer`),n=B(),i=z();function a(e){return typeof e==`string`?t.Buffer.from(e):t.Buffer.isBuffer(e)?e:(0,i.isArrayBufferView)(e)?t.Buffer.from(e.buffer,e.byteOffset,e.byteLength):t.Buffer.from(e)}function o(e){return e!=null&&e.buffer!=null&&typeof e.buffer==`function`}function s(e){return e!=null&&e.arrayBuffer!=null&&typeof e.arrayBuffer==`function`}function c(e){return e!=null&&e.bytes!=null&&typeof e.bytes==`function`}function l(e){return e!=null&&e.text!=null&&typeof e.text==`function`}function u(e){return e!=null&&typeof e.size==`number`}function d(e){return e!=null&&e.stream!=null&&typeof e.stream==`function`}function f(e){return e!=null&&e[Symbol.toStringTag]===`Blob`}function p(e){return e!=null&&e.byteLength!=null&&e.slice!=null}var m=class{blobParts;type;encoding;_size=null;constructor(e=[],t){if(this.blobParts=e,this.type=t?.type||`application/octet-stream`,this.encoding=t?.encoding||`utf8`,this._size=t?.size||null,e.length===1&&f(e[0]))return e[0]}_buffer=null;buffer(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){let e=this.blobParts[0];return o(e)?e.buffer().then(e=>(this._buffer=e,this._buffer)):c(e)?e.bytes().then(e=>(this._buffer=t.Buffer.from(e),this._buffer)):s(e)?e.arrayBuffer().then(n=>(this._buffer=t.Buffer.from(n,void 0,e.size),this._buffer)):(this._buffer=a(e),(0,i.fakePromise)(this._buffer))}let e=[],n=this.blobParts.map((r,i)=>{if(o(r)){e.push(r.buffer().then(e=>{n[i]=e}));return}else if(s(r)){e.push(r.arrayBuffer().then(e=>{n[i]=t.Buffer.from(e,void 0,r.size)}));return}else if(c(r)){e.push(r.bytes().then(e=>{n[i]=t.Buffer.from(e)}));return}else return a(r)});return e.length>0?Promise.all(e).then(()=>t.Buffer.concat(n,this._size||void 0)):(0,i.fakePromise)(t.Buffer.concat(n,this._size||void 0))}arrayBuffer(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){if(p(this.blobParts[0]))return(0,i.fakePromise)(this.blobParts[0]);if(s(this.blobParts[0]))return this.blobParts[0].arrayBuffer()}return this.buffer()}bytes(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){if(t.Buffer.isBuffer(this.blobParts[0]))return this._buffer=this.blobParts[0],(0,i.fakePromise)(this._buffer);if(this.blobParts[0]instanceof Uint8Array)return this._buffer=t.Buffer.from(this.blobParts[0]),(0,i.fakePromise)(this._buffer);if(c(this.blobParts[0]))return this.blobParts[0].bytes();if(o(this.blobParts[0]))return this.blobParts[0].buffer()}return this.buffer()}_text=null;text(){if(this._text)return(0,i.fakePromise)(this._text);if(this.blobParts.length===1){let e=this.blobParts[0];if(typeof e==`string`)return this._text=e,(0,i.fakePromise)(this._text);if(l(e))return e.text().then(e=>(this._text=e,this._text));let t=a(e);return this._text=t.toString(this.encoding),(0,i.fakePromise)(this._text)}return this.buffer().then(e=>(this._text=e.toString(this.encoding),this._text))}_json=null;json(){return this._json?(0,i.fakePromise)(this._json):this.text().then(e=>(this._json=JSON.parse(e),this._json))}_formData=null;formData(){if(this._formData)return(0,i.fakePromise)(this._formData);throw Error(`Not implemented`)}get size(){if(this._size==null){this._size=0;for(let e of this.blobParts)typeof e==`string`?this._size+=t.Buffer.byteLength(e):u(e)?this._size+=e.size:(0,i.isArrayBufferView)(e)&&(this._size+=e.byteLength)}return this._size}stream(){if(this.blobParts.length===1){let e=this.blobParts[0];if(d(e))return e.stream();let t=a(e);return new n.PonyfillReadableStream({start:e=>{e.enqueue(t),e.close()}})}if(this._buffer!=null)return new n.PonyfillReadableStream({start:e=>{e.enqueue(this._buffer),e.close()}});let e;return new n.PonyfillReadableStream({start:t=>{if(this.blobParts.length===0){t.close();return}e=this.blobParts[Symbol.iterator]()},pull:n=>{let{value:r,done:i}=e.next();if(i){n.close();return}if(r){if(o(r))return r.buffer().then(e=>{n.enqueue(e)});if(c(r))return r.bytes().then(e=>{let r=t.Buffer.from(e);n.enqueue(r)});if(s(r))return r.arrayBuffer().then(e=>{let i=t.Buffer.from(e,void 0,r.size);n.enqueue(i)});let e=a(r);n.enqueue(e)}}})}slice(){throw Error(`Not implemented`)}};exports.PonyfillBlob=m})),le=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillFile=void 0;let t=V();var n=class extends t.PonyfillBlob{name;lastModified;constructor(e,t,n){super(e,n),this.name=t,this.lastModified=n?.lastModified||Date.now()}webkitRelativePath=``};exports.PonyfillFile=n})),H={};n(H,{__addDisposableResource:()=>je,__assign:()=>Fe,__asyncDelegator:()=>Ce,__asyncGenerator:()=>Se,__asyncValues:()=>we,__await:()=>J,__awaiter:()=>me,__classPrivateFieldGet:()=>Oe,__classPrivateFieldIn:()=>Ae,__classPrivateFieldSet:()=>ke,__createBinding:()=>Ie,__decorate:()=>G,__disposeResources:()=>Me,__esDecorate:()=>q,__exportStar:()=>ge,__extends:()=>U,__generator:()=>he,__importDefault:()=>De,__importStar:()=>Ee,__makeTemplateObject:()=>Te,__metadata:()=>pe,__param:()=>K,__propKey:()=>de,__read:()=>ve,__rest:()=>W,__rewriteRelativeImportExtension:()=>Ne,__runInitializers:()=>ue,__setFunctionName:()=>fe,__spread:()=>ye,__spreadArray:()=>xe,__spreadArrays:()=>be,__values:()=>_e,default:()=>Be});function U(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Pe(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function W(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function G(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function K(e,t){return function(n,r){t(n,r,e)}}function q(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function ue(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function de(e){return typeof e==`symbol`?e:`${e}`}function fe(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function pe(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function me(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function he(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ge(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&Ie(t,e,n)}function _e(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function ve(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function ye(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ve(arguments[t]));return e}function be(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function xe(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function J(e){return this instanceof J?(this.v=e,this):new J(e)}function Se(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof J?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Ce(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:J(e[r](t)),done:!1}:i?i(t):t}:i}}function we(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof _e==`function`?_e(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Te(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function Ee(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Re(e),r=0;r<n.length;r++)n[r]!==`default`&&Ie(t,e,n[r]);return Le(t,e),t}function De(e){return e&&e.__esModule?e:{default:e}}function Oe(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function ke(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Ae(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function je(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Me(e){function t(t){e.error=e.hasError?new ze(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Ne(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Pe,Fe,Ie,Le,Re,ze,Be,Ve=t((()=>{Pe=function(e,t){return Pe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Pe(e,t)},Fe=function(){return Fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Fe.apply(this,arguments)},Ie=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),Le=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},Re=function(e){return Re=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Re(e)},ze=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Be={__extends:U,__assign:Fe,__rest:W,__decorate:G,__param:K,__esDecorate:q,__runInitializers:ue,__propKey:de,__setFunctionName:fe,__metadata:pe,__awaiter:me,__generator:he,__createBinding:Ie,__exportStar:ge,__values:_e,__read:ve,__spread:ye,__spreadArrays:be,__spreadArray:xe,__await:J,__asyncGenerator:Se,__asyncDelegator:Ce,__asyncValues:we,__makeTemplateObject:Te,__importStar:Ee,__importDefault:De,__classPrivateFieldGet:Oe,__classPrivateFieldSet:ke,__classPrivateFieldIn:Ae,__addDisposableResource:je,__disposeResources:Me,__rewriteRelativeImportExtension:Ne}})),He=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillSuppressedError=void 0;var t=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};exports.PonyfillSuppressedError=t})),Ue=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.DisposableSymbols=void 0,exports.patchSymbols=t,exports.DisposableSymbols={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function t(){Symbol.dispose||=Symbol.for(`dispose`),Symbol.asyncDispose||=Symbol.for(`asyncDispose`)}})),We=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.isSyncDisposable=n,exports.isAsyncDisposable=r;let t=Ue();function n(e){return e?.[t.DisposableSymbols.dispose]!=null}function r(e){return e?.[t.DisposableSymbols.asyncDispose]!=null}})),Ge=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillAsyncDisposableStack=void 0;let t=N(),n=He(),r=Ue(),i=We(),a=globalThis.SuppressedError||n.PonyfillSuppressedError;var o=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return(0,i.isAsyncDisposable)(e)?this.callbacks.push(()=>e[r.DisposableSymbols.asyncDispose]()):(0,i.isSyncDisposable)(e)&&this.callbacks.push(()=>e[r.DisposableSymbols.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[r.DisposableSymbols.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return(0,t.handleMaybePromise)(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new a(e,this._error):e,this._iterateCallbacks()))}[r.DisposableSymbols.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};exports.PonyfillAsyncDisposableStack=o})),Ke=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillDisposableStack=void 0;let t=He(),n=Ue(),r=We(),i=globalThis.SuppressedError||t.PonyfillSuppressedError;var a=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return(0,r.isSyncDisposable)(e)&&this.callbacks.push(()=>e[n.DisposableSymbols.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}dispose(){return this[n.DisposableSymbols.dispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e){try{e()}catch(e){this._error=this._error?new i(e,this._error):e}return this._iterateCallbacks()}}[n.DisposableSymbols.dispose](){if(this._iterateCallbacks(),this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`DisposableStack`};exports.PonyfillDisposableStack=a})),qe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.SuppressedError=exports.AsyncDisposableStack=exports.DisposableStack=void 0;let t=(Ve(),i(H)),n=Ge(),r=Ke(),a=He();exports.DisposableStack=globalThis.DisposableStack||r.PonyfillDisposableStack,exports.AsyncDisposableStack=globalThis.AsyncDisposableStack||n.PonyfillAsyncDisposableStack,exports.SuppressedError=globalThis.SuppressedError||a.PonyfillSuppressedError,t.__exportStar(Ue(),exports)})),Je=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillIteratorObject=void 0;let t=r(`node:util`),n=qe(),i=z();var a=class{iterableIterator;[Symbol.toStringTag]=`IteratorObject`;constructor(e,t){this.iterableIterator=e,this[Symbol.toStringTag]=t}*map(e){let t=0;for(let n of this.iterableIterator)yield e(n,t++)}*filter(e){let t=0;for(let n of this.iterableIterator)e(n,t++)&&(yield n)}reduce(e,t){let n=0,r=t;for(let t of this.iterableIterator)r=e(r,t,n++);return r}forEach(e){let t=0;for(let n of this.iterableIterator)e(n,t++)}*take(e){let t=0;for(let n of this.iterableIterator){if(t>=e)break;yield n,t++}}*drop(e){let t=0;for(let n of this.iterableIterator)t>=e&&(yield n),t++}*flatMap(e){let t=0;for(let n of this.iterableIterator){let r=e(n,t++);if((0,i.isIterable)(r))for(let e of r)yield e;else for(let e of{[Symbol.iterator]:()=>r})yield e}}some(e){let t=0;for(let n of this.iterableIterator)if(e(n,t++))return!0;return!1}every(e){let t=0;for(let n of this.iterableIterator)if(!e(n,t++))return!1;return!0}find(e){let t=0;for(let n of this.iterableIterator)if(e(n,t++))return n}toArray(){return Array.from(this.iterableIterator)}[n.DisposableSymbols.dispose](){this.iterableIterator.return?.()}next(...[e]){return this.iterableIterator.next(e)}[Symbol.iterator](){return this}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};return this.forEach((n,r)=>{let i=(0,t.inspect)(n);e[r]=i.includes(`,`)?i.split(`,`).map(e=>e.trim()):i}),`${this[Symbol.toStringTag]} ${(0,t.inspect)(e)}`}};exports.PonyfillIteratorObject=a})),Ye=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillFormData=void 0,exports.getStreamFromFormData=o;let t=r(`node:buffer`),n=Je(),i=B();var a=class{map=new Map;append(e,t,n){let r=this.map.get(e);r||(r=[],this.map.set(e,r));let i=c(t)?s(e,t,n):t;r.push(i)}delete(e){this.map.delete(e)}get(e){let t=this.map.get(e);return t?t[0]:null}getAll(e){return this.map.get(e)||[]}has(e){return this.map.has(e)}set(e,t,n){let r=c(t)?s(e,t,n):t;this.map.set(e,[r])}[Symbol.iterator](){return this._entries()}*_entries(){for(let[e,t]of this.map)for(let n of t)yield[e,n]}entries(){return new n.PonyfillIteratorObject(this._entries(),`FormDataIterator`)}_keys(){return this.map.keys()}keys(){return new n.PonyfillIteratorObject(this._keys(),`FormDataIterator`)}*_values(){for(let e of this.map.values())for(let t of e)yield t}values(){return new n.PonyfillIteratorObject(this._values(),`FormDataIterator`)}forEach(e){for(let[t,n]of this)e(n,t,this)}};exports.PonyfillFormData=a;function o(e,n=`---`){let r,a=!1,o,s=!1;function c(e){let{done:i,value:a}=r.next();if(i)return e.enqueue(t.Buffer.from(`\r\n--${n}--\r\n`)),e.close();if(s&&e.enqueue(t.Buffer.from(`\r\n--${n}\r\n`)),a){let[n,r]=a;if(typeof r==`string`)e.enqueue(t.Buffer.from(`Content-Disposition: form-data; name="${n}"\r\n\r\n`)),e.enqueue(t.Buffer.from(r));else{let i=``;r.name&&(i=`; filename="${r.name}"`),e.enqueue(t.Buffer.from(`Content-Disposition: form-data; name="${n}"${i}\r\n`)),e.enqueue(t.Buffer.from(`Content-Type: ${r.type||`application/octet-stream`}\r\n\r\n`));let a=r.stream();o=a[Symbol.asyncIterator]()}s=!0}}return new i.PonyfillReadableStream({start:()=>{r=e.entries()},pull:e=>a?o?o.next().then(({done:t,value:n})=>(t&&(o=void 0),n?e.enqueue(n):c(e))):c(e):(a=!0,e.enqueue(t.Buffer.from(`--${n}\r\n`))),cancel:e=>{r?.return?.(e),o?.return?.(e)}})}function s(e,t,n){return Object.defineProperty(t,`name`,{configurable:!0,enumerable:!0,value:n||t.name||e}),t}function c(e){return e?.arrayBuffer!=null}})),Xe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillBody=void 0;let t=r(`node:buffer`),n=r(`node:stream`),i=ce(),a=N(),o=V(),s=le(),c=Ye(),l=B(),u=z();var d;(function(e){e.ReadableStream=`ReadableStream`,e.Blob=`Blob`,e.FormData=`FormData`,e.String=`String`,e.Readable=`Readable`,e.Buffer=`Buffer`,e.AsyncIterable=`AsyncIterable`})(d||={});var f=class{bodyInit;options;bodyUsed=!1;contentType=null;contentLength=null;constructor(e,t={}){this.bodyInit=e,this.options=t;let{bodyFactory:n,contentType:r,contentLength:i,bodyType:a,buffer:o}=p(e);this._bodyFactory=n,this.contentType=r,this.contentLength=i,this.bodyType=a,this._buffer=o,this._signal=t.signal}bodyType;_bodyFactory=()=>null;_generatedBody=null;_buffer;_signal;generateBody(){if(this._generatedBody?.readable?.destroyed&&this._buffer&&(this._generatedBody.readable=n.Readable.from(this._buffer)),this._generatedBody)return this._generatedBody;let e=this._bodyFactory();return this._generatedBody=e,e}handleContentLengthHeader(e=!1){let t=this.headers.get(`content-type`);t?this.contentType=t:this.contentType&&this.headers.set(`content-type`,this.contentType);let n=this.headers.get(`content-length`);e&&this.bodyInit==null&&!n&&(this.contentLength=0,this.headers.set(`content-length`,`0`)),n?this.contentLength=parseInt(n,10):this.contentLength&&this.headers.set(`content-length`,this.contentLength.toString())}get body(){let e=this.generateBody();if(e!=null){let t=e,n=e.readable;return new Proxy(e.readable,{get(e,r){if(r in t){let e=t[r];return typeof e==`function`?e.bind(t):e}if(r in n){let e=n[r];return typeof e==`function`?e.bind(n):e}}})}return null}_chunks=null;_doCollectChunksFromReadableJob(){if(this.bodyType===d.AsyncIterable){if(Array.fromAsync)return(0,a.handleMaybePromise)(()=>Array.fromAsync(this.bodyInit),e=>(this._chunks=e,this._chunks));let e=this.bodyInit[Symbol.asyncIterator](),t=[],n=()=>(0,a.handleMaybePromise)(()=>e.next(),({value:e,done:r})=>(e&&t.push(e),r?(this._chunks=t,this._chunks):n()));return n()}let e=this.generateBody();if(!e)return this._chunks=[],(0,u.fakePromise)(this._chunks);if(e.readable.destroyed)return(0,u.fakePromise)(this._chunks=[]);let t=[];return new Promise((n,r)=>{e.readable.on(`data`,e=>{t.push(e)}),e.readable.once(`error`,r),e.readable.once(`end`,()=>{n(this._chunks=t)})})}_collectChunksFromReadable(){return this._chunks?(0,u.fakePromise)(this._chunks):(this._chunks||=this._doCollectChunksFromReadableJob(),this._chunks)}_blob=null;blob(){return this._blob?(0,u.fakePromise)(this._blob):(this.bodyType===d.String&&(this._text=this.bodyInit,this._blob=new o.PonyfillBlob([this._text],{type:this.contentType||`text/plain;charset=UTF-8`,size:this.contentLength})),this.bodyType===d.Blob?(this._blob=this.bodyInit,(0,u.fakePromise)(this._blob)):this._buffer?(this._blob=new o.PonyfillBlob([this._buffer],{type:this.contentType||``,size:this.contentLength}),(0,u.fakePromise)(this._blob)):(0,u.fakePromise)((0,a.handleMaybePromise)(()=>this._collectChunksFromReadable(),e=>(this._blob=new o.PonyfillBlob(e,{type:this.contentType||``,size:this.contentLength}),this._blob))))}_formData=null;formData(e){if(this._formData)return(0,u.fakePromise)(this._formData);if(this.bodyType===d.FormData)return this._formData=this.bodyInit,(0,u.fakePromise)(this._formData);this._formData=new c.PonyfillFormData;let t=this.generateBody();if(t==null)return(0,u.fakePromise)(this._formData);let r={...this.options.formDataLimits,...e?.formDataLimits};return new Promise((e,t)=>{let a=this.body?.readable;if(!a)return t(Error(`No stream available`));let o=null,c=new i.Busboy({headers:{"content-length":typeof this.contentLength==`number`?this.contentLength.toString():this.contentLength||``,"content-type":this.contentType||``},limits:r,defCharset:`utf-8`});this._signal&&(0,n.addAbortSignal)(this._signal,c);let l=!1,u=n=>{l||(l=!0,a.unpipe(c),c.destroy(),o&&=(o.destroy(),null),n?t(n):e(this._formData))};a.on(`error`,u),c.on(`field`,(e,t,n,i)=>{if(n)return u(Error(`Field name size exceeded: ${r?.fieldNameSize} bytes`));if(i)return u(Error(`Field value size exceeded: ${r?.fieldSize} bytes`));this._formData.set(e,t)}),c.on(`file`,(e,t,n,i,a)=>{o=t;let c=[];t.on(`data`,e=>{c.push(e)}),t.on(`error`,u),t.on(`limit`,()=>{u(Error(`File size limit exceeded: ${r?.fileSize} bytes`))}),t.on(`close`,()=>{t.truncated&&u(Error(`File size limit exceeded: ${r?.fileSize} bytes`)),o=null;let i=new s.PonyfillFile(c,n,{type:a});this._formData.set(e,i)})}),c.on(`fieldsLimit`,()=>{u(Error(`Fields limit exceeded: ${r?.fields}`))}),c.on(`filesLimit`,()=>{u(Error(`Files limit exceeded: ${r?.files}`))}),c.on(`partsLimit`,()=>{u(Error(`Parts limit exceeded: ${r?.parts}`))}),c.on(`end`,u),c.on(`finish`,u),c.on(`close`,u),c.on(`error`,u),a.pipe(c)})}buffer(){if(this._buffer)return(0,u.fakePromise)(this._buffer);if(this._text)return this._buffer=t.Buffer.from(this._text,`utf-8`),(0,u.fakePromise)(this._buffer);if(this.bodyType===d.String)return this.text().then(e=>(this._text=e,this._buffer=t.Buffer.from(e,`utf-8`),this._buffer));if(this.bodyType===d.Blob){if((0,o.hasBufferMethod)(this.bodyInit))return this.bodyInit.buffer().then(e=>(this._buffer=e,this._buffer));if((0,o.hasBytesMethod)(this.bodyInit))return this.bodyInit.bytes().then(e=>(this._buffer=t.Buffer.from(e),this._buffer));if((0,o.hasArrayBufferMethod)(this.bodyInit))return this.bodyInit.arrayBuffer().then(e=>(this._buffer=t.Buffer.from(e,void 0,e.byteLength),this._buffer))}return(0,u.fakePromise)((0,a.handleMaybePromise)(()=>this._collectChunksFromReadable(),e=>e.length===1?(this._buffer=e[0],this._buffer):(this._buffer=t.Buffer.concat(e),this._buffer)))}bytes(){return this.buffer()}arrayBuffer(){return this.buffer()}_json=null;json(){return this._json?(0,u.fakePromise)(this._json):this.text().then(e=>{try{this._json=JSON.parse(e)}catch(t){throw t instanceof SyntaxError&&(t.message+=`, "${e}" is not valid JSON`),t}return this._json})}_text=null;text(){return this._text?(0,u.fakePromise)(this._text):this.bodyType===d.String?(this._text=this.bodyInit,(0,u.fakePromise)(this._text)):this.buffer().then(e=>(this._text=e.toString(`utf-8`),this._text))}};exports.PonyfillBody=f;function p(e){if(e==null)return{bodyFactory:()=>null,contentType:null,contentLength:null};if(typeof e==`string`){let r=t.Buffer.byteLength(e);return{bodyType:d.String,contentType:`text/plain;charset=UTF-8`,contentLength:r,bodyFactory(){let r=n.Readable.from(t.Buffer.from(e,`utf-8`));return new l.PonyfillReadableStream(r)}}}if(t.Buffer.isBuffer(e)){let t=e;return{bodyType:d.Buffer,contentType:null,contentLength:e.length,buffer:e,bodyFactory(){let e=n.Readable.from(t),r=new l.PonyfillReadableStream(e);return r}}}if((0,u.isArrayBufferView)(e)){let r=t.Buffer.from(e.buffer,e.byteOffset,e.byteLength);return{bodyType:d.Buffer,contentLength:e.byteLength,contentType:null,buffer:r,bodyFactory(){let e=n.Readable.from(r),t=new l.PonyfillReadableStream(e);return t}}}if(e instanceof l.PonyfillReadableStream&&e.readable!=null){let t=e;return{bodyType:d.ReadableStream,bodyFactory:()=>t,contentType:null,contentLength:null}}if(h(e)){let t=e;return{bodyType:d.Blob,contentType:e.type,contentLength:e.size,bodyFactory(){return t.stream()}}}if(e instanceof ArrayBuffer){let r=e.byteLength,i=t.Buffer.from(e,void 0,e.byteLength);return{bodyType:d.Buffer,contentType:null,contentLength:r,buffer:i,bodyFactory(){let e=n.Readable.from(i),t=new l.PonyfillReadableStream(e);return t}}}if(e instanceof n.Readable)return{bodyType:d.Readable,contentType:null,contentLength:null,bodyFactory(){let t=new l.PonyfillReadableStream(e);return t}};if(g(e))return{bodyType:d.String,contentType:`application/x-www-form-urlencoded;charset=UTF-8`,contentLength:null,bodyFactory(){let t=new l.PonyfillReadableStream(n.Readable.from(e.toString()));return t}};if(m(e)){let t=Math.random().toString(36).substr(2),n=`multipart/form-data; boundary=${t}`;return{bodyType:d.FormData,contentType:n,contentLength:null,bodyFactory(){return(0,c.getStreamFromFormData)(e,t)}}}if(_(e))return{contentType:null,contentLength:null,bodyFactory(){return new l.PonyfillReadableStream(e)}};if(e[Symbol.iterator]||e[Symbol.asyncIterator])return{contentType:null,contentLength:null,bodyType:d.AsyncIterable,bodyFactory(){let t=n.Readable.from(e);return new l.PonyfillReadableStream(t)}};throw Error(`Unknown body type`)}function m(e){return e?.forEach!=null}function h(e){return e?.stream!=null&&typeof e.stream==`function`}function g(e){return e?.sort!=null}function _(e){return e?.getReader!=null}})),Ze=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillHeaders=void 0,exports.isHeadersLike=i;let t=r(`node:util`),n=Je();function i(e){return e?.get&&e?.forEach}var a=class{headersInit;_map;objectNormalizedKeysOfHeadersInit=[];objectOriginalKeysOfHeadersInit=[];_setCookies;constructor(e){this.headersInit=e}_get(e){let t=e.toLowerCase();if(t===`set-cookie`&&this._setCookies?.length)return this._setCookies.join(`, `);if(this._map)return this._map.get(t)||null;if(this.headersInit==null)return null;if(Array.isArray(this.headersInit)){let e=this.headersInit.filter(([e])=>e.toLowerCase()===t);return e.length===0?null:e.length===1?e[0][1]:e.map(([,e])=>e).join(`, `)}else if(i(this.headersInit))return this.headersInit.get(t);else{let n=this.headersInit[e]||this.headersInit[t];if(n!=null)return n;this.objectNormalizedKeysOfHeadersInit.length||Object.keys(this.headersInit).forEach(e=>{this.objectOriginalKeysOfHeadersInit.push(e),this.objectNormalizedKeysOfHeadersInit.push(e.toLowerCase())});let r=this.objectNormalizedKeysOfHeadersInit.indexOf(t);if(r===-1)return null;let i=this.objectOriginalKeysOfHeadersInit[r];return this.headersInit[i]}}getMap(){if(!this._map)if(this._setCookies||=[],this.headersInit!=null)if(Array.isArray(this.headersInit)){this._map=new Map;for(let[e,t]of this.headersInit){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies.push(t);continue}this._map.set(n,t)}}else if(i(this.headersInit))this._map=new Map,this.headersInit.forEach((e,t)=>{if(t===`set-cookie`){this._setCookies||=[],this._setCookies.push(e);return}this._map.set(t,e)});else for(let e in this._map=new Map,this.headersInit){let t=this.headersInit[e];if(t!=null){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies||=[],this._setCookies.push(t);continue}this._map.set(n,t)}}else this._map=new Map;return this._map}append(e,t){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies||=[],this._setCookies.push(t);return}let r=this.getMap().get(n),i=r?`${r}, ${t}`:t;this.getMap().set(n,i)}get(e){let t=this._get(e);return t==null?null:t.toString()}has(e){let t=e.toLowerCase();return t===`set-cookie`?!!this._setCookies?.length:!!this._get(e)}set(e,t){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies=[t];return}if(!this._map&&this.headersInit!=null)if(Array.isArray(this.headersInit)){let e=this.headersInit.find(([e])=>e.toLowerCase()===n);e?e[1]=t:this.headersInit.push([n,t]);return}else if(i(this.headersInit)){this.headersInit.set(n,t);return}else{this.headersInit[n]=t;return}this.getMap().set(n,t)}delete(e){let t=e.toLowerCase();if(t===`set-cookie`){this._setCookies=[];return}this.getMap().delete(t)}forEach(e){if(this._setCookies?.forEach(t=>{e(t,`set-cookie`,this)}),!this._map){if(this.headersInit){if(Array.isArray(this.headersInit)){this.headersInit.forEach(([t,n])=>{e(n,t,this)});return}if(i(this.headersInit)){this.headersInit.forEach(e);return}Object.entries(this.headersInit).forEach(([t,n])=>{n!=null&&e(n,t,this)})}return}this.getMap().forEach((t,n)=>{e(t,n,this)})}*_keys(){if(this._setCookies?.length&&(yield`set-cookie`),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit.map(([e])=>e)[Symbol.iterator]();return}if(i(this.headersInit)){yield*this.headersInit.keys();return}yield*Object.keys(this.headersInit)[Symbol.iterator]();return}yield*this.getMap().keys()}keys(){return new n.PonyfillIteratorObject(this._keys(),`HeadersIterator`)}*_values(){if(this._setCookies?.length&&(yield*this._setCookies),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit.map(([,e])=>e)[Symbol.iterator]();return}if(i(this.headersInit)){yield*this.headersInit.values();return}yield*Object.values(this.headersInit)[Symbol.iterator]();return}yield*this.getMap().values()}values(){return new n.PonyfillIteratorObject(this._values(),`HeadersIterator`)}*_entries(){if(this._setCookies?.length&&(yield*this._setCookies.map(e=>[`set-cookie`,e])),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit;return}if(i(this.headersInit)){yield*this.headersInit.entries();return}yield*Object.entries(this.headersInit);return}yield*this.getMap().entries()}entries(){return new n.PonyfillIteratorObject(this._entries(),`HeadersIterator`)}getSetCookie(){return this._setCookies||this.getMap(),this._setCookies}[Symbol.iterator](){return this.entries()}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};return this.forEach((t,n)=>{n===`set-cookie`?e[`set-cookie`]=this._setCookies||[]:e[n]=t?.includes(`,`)?t.split(`,`).map(e=>e.trim()):t}),`Headers ${(0,t.inspect)(e)}`}};exports.PonyfillHeaders=a})),Qe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillResponse=void 0;let t=r(`node:http`),n=Xe(),i=Ze(),a=`application/json; charset=utf-8`;var o=class e extends n.PonyfillBody{headers;constructor(e,n){super(e||null,n),this.headers=n?.headers&&(0,i.isHeadersLike)(n.headers)?n.headers:new i.PonyfillHeaders(n?.headers),this.status=n?.status||200,this.statusText=n?.statusText||t.STATUS_CODES[this.status]||`OK`,this.url=n?.url||``,this.redirected=n?.redirected||!1,this.type=n?.type||`default`,this.handleContentLengthHeader()}get ok(){return this.status>=200&&this.status<300}status;statusText;url;redirected;type;clone(){return this}static error(){return new e(null,{status:500,statusText:`Internal Server Error`})}static redirect(t,n=302){if(n<300||n>399)throw RangeError(`Invalid status code`);return new e(null,{headers:{location:t},status:n})}static json(t,n){let r=JSON.stringify(t);if(!n)n={headers:{"content-type":a,"content-length":Buffer.byteLength(r).toString()}};else if(!n.headers)n.headers={"content-type":a,"content-length":Buffer.byteLength(r).toString()};else if((0,i.isHeadersLike)(n.headers))n.headers.has(`content-type`)||n.headers.set(`content-type`,a),n.headers.has(`content-length`)||n.headers.set(`content-length`,Buffer.byteLength(r).toString());else if(Array.isArray(n.headers)){let e=!1,t=!1;for(let[r]of n.headers){if(t&&e)break;!e&&r.toLowerCase()===`content-type`?e=!0:!t&&r.toLowerCase()===`content-length`&&(t=!0)}e||n.headers.push([`content-type`,a]),t||n.headers.push([`content-length`,Buffer.byteLength(r).toString()])}else typeof n.headers==`object`&&(n.headers?.[`content-type`]??(n.headers[`content-type`]=a),n.headers?.[`content-length`]??(n.headers[`content-length`]=Buffer.byteLength(r).toString()));return new e(r,n)}[Symbol.toStringTag]=`Response`};exports.PonyfillResponse=o})),$e=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchCurl=s;let t=r(`node:stream`),n=r(`node:tls`),i=N(),a=Qe(),o=z();function s(e){let{Curl:r,CurlFeature:s,CurlPause:c,CurlProgressFunc:l}=globalThis.libcurl,u=new r;u.enable(s.NoDataParsing),u.setOpt(`URL`,e.url),process.env.NODE_TLS_REJECT_UNAUTHORIZED===`0`&&u.setOpt(`SSL_VERIFYPEER`,!1),process.env.NODE_EXTRA_CA_CERTS?u.setOpt(`CAINFO`,process.env.NODE_EXTRA_CA_CERTS):u.setOpt(`CAINFO_BLOB`,n.rootCertificates.join(`
8
- `)),u.enable(s.StreamResponse);let d;if(e._signal===null?d=void 0:e._signal&&(d=e._signal),u.setStreamProgressCallback(function(){return d?.aborted?process.env.DEBUG?l.Continue:1:0}),e.bodyType===`String`)u.setOpt(`POSTFIELDS`,e.bodyInit);else{let n=e.body==null?null:(0,o.isNodeReadable)(e.body)?e.body:t.Readable.from(e.body);n&&(u.setOpt(`UPLOAD`,!0),u.setUploadStream(n))}process.env.DEBUG&&u.setOpt(`VERBOSE`,!0),u.setOpt(`TRANSFER_ENCODING`,!1),u.setOpt(`HTTP_TRANSFER_DECODING`,!0),u.setOpt(`FOLLOWLOCATION`,e.redirect===`follow`),u.setOpt(`MAXREDIRS`,20),u.setOpt(`ACCEPT_ENCODING`,``),u.setOpt(`CUSTOMREQUEST`,e.method);let f=e.headersSerializer||o.defaultHeadersSerializer,p,m=f(e.headers,e=>{p=Number(e)});p!=null&&u.setOpt(`INFILESIZE`,p),u.setOpt(`HTTPHEADER`,m),u.enable(s.NoHeaderParsing);let h=(0,i.createDeferredPromise)(),g;function _(){if(u.isOpen)try{u.pause(c.Recv)}catch(e){h.reject(e)}}return d?.addEventListener(`abort`,_,{once:!0}),u.once(`end`,function(){try{u.close()}catch(e){h.reject(e)}d?.removeEventListener(`abort`,_)}),u.once(`error`,function(e){g&&!g.closed&&!g.destroyed?g.destroy(e):(e.message===`Operation was aborted by an application callback`&&(e.message=`The operation was aborted.`),h.reject(e));try{u.close()}catch(e){h.reject(e)}}),u.once(`stream`,function(n,i,s){let c=n.pipe(new t.PassThrough,{end:!0}),l=s.toString(`utf8`).split(/\r?\n|\r/g).filter(t=>t&&!t.startsWith(`HTTP/`)?(e.redirect===`error`&&t.toLowerCase().includes(`location`)&&(0,o.shouldRedirect)(i)&&(n.destroyed||n.resume(),c.destroy(),h.reject(Error(`redirect is not allowed`))),!0):!1),d=l.map(e=>e.split(/:\s(.+)/).slice(0,2)),f=new a.PonyfillResponse(c,{status:i,headers:d,url:u.getInfo(r.info.REDIRECT_URL)?.toString()||e.url,redirected:Number(u.getInfo(r.info.REDIRECT_COUNT))>0});h.resolve(f),g=c}),setImmediate(()=>{u.perform()}),h.promise}})),et=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillURL=void 0;let t=(Ve(),i(H)),n=t.__importDefault(r(`node:buffer`)),a=r(`node:crypto`),o=globalThis.URL;var s=class extends o{static blobRegistry=new Map;static createObjectURL(e){let t=`blob:whatwgnode:${(0,a.randomUUID)()}`;return this.blobRegistry.set(t,e),t}static revokeObjectURL(e){this.blobRegistry.has(e)?this.blobRegistry.delete(e):o.revokeObjectURL(e)}static getBlobFromURL(e){return this.blobRegistry.get(e)||n.default?.resolveObjectURL?.(e)}};exports.PonyfillURL=s})),tt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillRequest=void 0;let t=r(`node:http`),n=r(`node:https`),i=Xe(),a=Ze(),o=et();function s(e){return e[Symbol.toStringTag]===`Request`}function c(e){return e?.href!=null}var l=class extends i.PonyfillBody{constructor(e,r){let i,o,l=null,u;if(typeof e==`string`?i=e:c(e)?o=e:s(e)&&(e._parsedUrl?o=e._parsedUrl:i=e._url?e._url:e.url,l=e.body,u=e),r!=null&&(l=r.body||null,u=r),super(l,u),this._url=i,this._parsedUrl=o,this.cache=u?.cache||`default`,this.credentials=u?.credentials||`same-origin`,this.headers=u?.headers&&(0,a.isHeadersLike)(u.headers)?u.headers:new a.PonyfillHeaders(u?.headers),this.integrity=u?.integrity||``,this.keepalive=u?.keepalive==null?!1:u?.keepalive,this.method=u?.method?.toUpperCase()||`GET`,this.mode=u?.mode||`cors`,this.redirect=u?.redirect||`follow`,this.referrer=u?.referrer||`about:client`,this.referrerPolicy=u?.referrerPolicy||`no-referrer`,this.headersSerializer=u?.headersSerializer,this.duplex=u?.duplex||`half`,this.destination=`document`,this.priority=`auto`,this.method!==`GET`&&this.method!==`HEAD`&&this.handleContentLengthHeader(!0),u?.agent!=null){let e=o?.protocol||i||this.url;u.agent===!1?this.agent=!1:(e.startsWith(`http:`)&&u.agent instanceof t.Agent||e.startsWith(`https:`)&&u.agent instanceof n.Agent)&&(this.agent=u.agent)}}headersSerializer;cache;credentials;destination;headers;integrity;keepalive;method;mode;priority;redirect;referrer;referrerPolicy;_url;get signal(){return this._signal||=new AbortController().signal,this._signal}get url(){if(this._url==null)if(this._parsedUrl)this._url=this._parsedUrl.toString();else throw TypeError(`Invalid URL`);return this._url}_parsedUrl;get parsedUrl(){if(this._parsedUrl==null)if(this._url!=null)this._parsedUrl=new o.PonyfillURL(this._url,`http://localhost`);else throw TypeError(`Invalid URL`);return this._parsedUrl}duplex;agent;clone(){return this}[Symbol.toStringTag]=`Request`};exports.PonyfillRequest=l})),nt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchNodeHttp=f;let t=r(`node:http`),n=r(`node:https`),i=r(`node:stream`),a=r(`node:zlib`),o=N(),s=tt(),c=Qe(),l=et(),u=z();function d(e){if(e.startsWith(`http:`))return t.request;if(e.startsWith(`https:`))return n.request;throw Error(`Unsupported protocol: ${e.split(`:`)[0]||e}`)}function f(e){return new Promise((n,r)=>{try{let p=d(e.parsedUrl?.protocol||e.url),m=e.headersSerializer||u.getHeadersObj,h=m(e.headers);h[`accept-encoding`]??=`gzip, deflate, br`;let g;e._signal==null?g=void 0:e._signal&&(g=e._signal);let _;if(_=e.parsedUrl?p(e.parsedUrl,{method:e.method,headers:h,signal:g,agent:e.agent}):p(e.url,{method:e.method,headers:h,signal:g,agent:e.agent}),_.once(`error`,r),_.once(`response`,o=>{let d,p=o.headers[`content-encoding`];switch(p){case`x-gzip`:case`gzip`:d=(0,a.createGunzip)();break;case`x-deflate`:case`deflate`:d=(0,a.createInflate)();break;case`x-deflate-raw`:case`deflate-raw`:d=(0,a.createInflateRaw)();break;case`br`:d=(0,a.createBrotliDecompress)();break}if(o.headers.location&&(0,u.shouldRedirect)(o.statusCode)){if(e.redirect===`error`){let e=Error(`Redirects are not allowed`);r(e),o.resume();return}if(e.redirect===`follow`){let t=new l.PonyfillURL(o.headers.location,e.parsedUrl||e.url),r=f(new s.PonyfillRequest(t,e));n(r.then(e=>(e.redirected=!0,e))),o.resume();return}}d||=new i.PassThrough,(0,u.pipeThrough)({src:o,dest:d,signal:g,onError:e=>{o.destroyed||o.destroy(e),d.destroyed||d.destroy(e),r(e)}});let m=o.statusCode||200,h=o.statusMessage||t.STATUS_CODES[m];h??=``;let _=new c.PonyfillResponse(d||o,{status:m,statusText:h,headers:o.headers,url:e.url,signal:g});n(_)}),e._buffer!=null)(0,o.handleMaybePromise)(()=>(0,u.safeWrite)(e._buffer,_),()=>(0,u.endStream)(_),r);else{let t=e.body==null?null:(0,u.isNodeReadable)(e.body)?e.body:i.Readable.from(e.body);t?t.pipe(_):(0,u.endStream)(_)}}catch(e){r(e)}})}})),rt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchPonyfill=h;let t=r(`node:buffer`),n=r(`node:fs`),i=r(`node:url`),a=$e(),o=nt(),s=tt(),c=Qe(),l=et(),u=z();async function d(e){let t=(0,i.fileURLToPath)(e);try{await n.promises.access(t,n.promises.constants.R_OK);let e=await n.promises.stat(t,{bigint:!0}),r=(0,n.createReadStream)(t);return new c.PonyfillResponse(r,{status:200,statusText:`OK`,headers:{"content-type":`application/octet-stream`,"last-modified":e.mtime.toUTCString()}})}catch(e){if(e.code===`ENOENT`)return new c.PonyfillResponse(null,{status:404,statusText:`Not Found`});if(e.code===`EACCES`)return new c.PonyfillResponse(null,{status:403,statusText:`Forbidden`});throw e}}function f(e){let[n=`text/plain`,...r]=e.substring(5).split(`,`),i=decodeURIComponent(r.join(`,`));if(n.endsWith(`;base64`)){let e=t.Buffer.from(i,`base64url`),r=n.slice(0,-7);return new c.PonyfillResponse(e,{status:200,statusText:`OK`,headers:{"content-type":r}})}return new c.PonyfillResponse(i,{status:200,statusText:`OK`,headers:{"content-type":n}})}function p(e){let t=l.PonyfillURL.getBlobFromURL(e);if(!t)throw TypeError(`Invalid Blob URL`);return new c.PonyfillResponse(t,{status:200,headers:{"content-type":t.type,"content-length":t.size.toString()}})}function m(e){return e!=null&&e.href!=null}function h(e,t){if(typeof e==`string`||m(e)){let n=new s.PonyfillRequest(e,t);return h(n)}let n=e;if(n.url.startsWith(`data:`)){let e=f(n.url);return(0,u.fakePromise)(e)}if(n.url.startsWith(`file:`)){let e=d(n.url);return e}if(n.url.startsWith(`blob:`)){let e=p(n.url);return(0,u.fakePromise)(e)}return globalThis.libcurl&&!n.agent?(0,a.fetchCurl)(n):(0,o.fetchNodeHttp)(n)}})),it=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTextDecoder=exports.PonyfillTextEncoder=void 0,exports.PonyfillBtoa=o;let t=r(`node:buffer`),n=z();var i=class{encoding;constructor(e=`utf-8`){this.encoding=e}encode(e){return t.Buffer.from(e,this.encoding)}encodeInto(e,t){let n=this.encode(e),r=n.copy(t);return{read:r,written:r}}};exports.PonyfillTextEncoder=i;var a=class{encoding;fatal=!1;ignoreBOM=!1;constructor(e=`utf-8`,t){this.encoding=e,t&&(this.fatal=t.fatal||!1,this.ignoreBOM=t.ignoreBOM||!1)}decode(e){return t.Buffer.isBuffer(e)?e.toString(this.encoding):(0,n.isArrayBufferView)(e)?t.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(this.encoding):t.Buffer.from(e).toString(this.encoding)}};exports.PonyfillTextDecoder=a;function o(e){return t.Buffer.from(e,`binary`).toString(`base64`)}})),at=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillURLSearchParams=void 0,exports.PonyfillURLSearchParams=globalThis.URLSearchParams})),ot=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillWritableStream=void 0;let t=r(`node:events`),n=r(`node:stream`),i=N(),a=z();var o=class{writable;constructor(e){if(e instanceof n.Writable)this.writable=e;else if(e){let t=new n.Writable({write(t,n,r){try{let n=e.write?.(t,i);n instanceof Promise?n.then(()=>{r()},e=>{r(e)}):r()}catch(e){r(e)}},final(t){let n=e.close?.();n instanceof Promise?n.then(()=>{t()},e=>{t(e)}):t()}});this.writable=t;let r=new AbortController,i={signal:r.signal,error(e){t.destroy(e)}};t.once(`error`,e=>r.abort(e)),t.once(`close`,()=>r.abort())}else this.writable=new n.Writable}getWriter(){let e=this.writable;return{get closed(){return(0,t.once)(e,`close`)},get desiredSize(){return e.writableLength},get ready(){return(0,t.once)(e,`drain`)},releaseLock(){},write(t){let n=(0,a.fakePromise)();return t==null?n:n.then(()=>(0,a.safeWrite)(t,e))},close(){return!e.errored&&e.closed?(0,a.fakePromise)():e.errored?(0,i.fakeRejectPromise)(e.errored):(0,a.fakePromise)().then(()=>(0,a.endStream)(e))},abort(n){return e.destroy(n),(0,t.once)(e,`close`)}}}close(){return!this.writable.errored&&this.writable.closed?(0,a.fakePromise)():this.writable.errored?(0,i.fakeRejectPromise)(this.writable.errored):(0,a.fakePromise)().then(()=>(0,a.endStream)(this.writable))}abort(e){return this.writable.destroy(e),(0,t.once)(this.writable,`close`)}locked=!1};exports.PonyfillWritableStream=o})),st=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTransformStream=void 0;let t=r(`node:stream`),n=B(),i=z(),a=ot();var o=class{transform;writable;readable;constructor(e){if(e instanceof t.Transform)this.transform=e;else if(e){let n={enqueue(e){r.push(e)},error(e){r.destroy(e)},terminate(){(0,i.endStream)(r)},get desiredSize(){return r.writableLength}},r=new t.Transform({read(){},write(t,r,i){try{let r=e.transform?.(t,n);r instanceof Promise?r.then(()=>{i()},e=>{i(e)}):i()}catch(e){i(e)}},final(t){try{let r=e.flush?.(n);r instanceof Promise?r.then(()=>{t()},e=>{t(e)}):t()}catch(e){t(e)}}});this.transform=r}else this.transform=new t.Transform;this.writable=new a.PonyfillWritableStream(this.transform),this.readable=new n.PonyfillReadableStream(this.transform)}};exports.PonyfillTransformStream=o})),ct=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillCompressionStream=void 0;let t=r(`node:zlib`),n=st();var i=class extends n.PonyfillTransformStream{static supportedFormats=globalThis.process?.version?.startsWith(`v2`)?[`gzip`,`deflate`,`br`]:[`gzip`,`deflate`,`deflate-raw`,`br`];constructor(e){switch(e){case`x-gzip`:case`gzip`:super((0,t.createGzip)());break;case`x-deflate`:case`deflate`:super((0,t.createDeflate)());break;case`deflate-raw`:super((0,t.createDeflateRaw)());break;case`br`:super((0,t.createBrotliCompress)());break;default:throw Error(`Unsupported compression format: ${e}`)}}};exports.PonyfillCompressionStream=i})),lt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillDecompressionStream=void 0;let t=r(`node:zlib`),n=st();var i=class extends n.PonyfillTransformStream{static supportedFormats=globalThis.process?.version?.startsWith(`v2`)?[`gzip`,`deflate`,`br`]:[`gzip`,`deflate`,`deflate-raw`,`br`];constructor(e){switch(e){case`x-gzip`:case`gzip`:super((0,t.createGunzip)());break;case`x-deflate`:case`deflate`:super((0,t.createInflate)());break;case`deflate-raw`:super((0,t.createInflateRaw)());break;case`br`:super((0,t.createBrotliDecompress)());break;default:throw TypeError(`Unsupported compression format: '${e}'`)}}};exports.PonyfillDecompressionStream=i})),ut=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTextEncoderStream=exports.PonyfillTextDecoderStream=void 0;let t=it(),n=st();var r=class extends n.PonyfillTransformStream{textDecoder;constructor(e,n){super({transform:(e,t)=>t.enqueue(this.textDecoder.decode(e,{stream:!0}))}),this.textDecoder=new t.PonyfillTextDecoder(e,n)}get encoding(){return this.textDecoder.encoding}get fatal(){return this.textDecoder.fatal}get ignoreBOM(){return this.textDecoder.ignoreBOM}};exports.PonyfillTextDecoderStream=r;var i=class extends n.PonyfillTransformStream{textEncoder;constructor(e){super({transform:(e,t)=>t.enqueue(this.textEncoder.encode(e))}),this.textEncoder=new t.PonyfillTextEncoder(e)}get encoding(){return this.textEncoder.encoding}encode(e){return this.textEncoder.encode(e)}};exports.PonyfillTextEncoderStream=i})),dt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.TextEncoderStream=exports.TextDecoderStream=exports.IteratorObject=exports.DecompressionStream=exports.CompressionStream=exports.TransformStream=exports.WritableStream=exports.URLSearchParams=exports.URL=exports.btoa=exports.TextDecoder=exports.TextEncoder=exports.Blob=exports.FormData=exports.File=exports.ReadableStream=exports.Response=exports.Request=exports.Body=exports.Headers=exports.fetch=void 0;var t=rt();Object.defineProperty(exports,`fetch`,{enumerable:!0,get:function(){return t.fetchPonyfill}});var n=Ze();Object.defineProperty(exports,`Headers`,{enumerable:!0,get:function(){return n.PonyfillHeaders}});var r=Xe();Object.defineProperty(exports,`Body`,{enumerable:!0,get:function(){return r.PonyfillBody}});var i=tt();Object.defineProperty(exports,`Request`,{enumerable:!0,get:function(){return i.PonyfillRequest}});var a=Qe();Object.defineProperty(exports,`Response`,{enumerable:!0,get:function(){return a.PonyfillResponse}});var o=B();Object.defineProperty(exports,`ReadableStream`,{enumerable:!0,get:function(){return o.PonyfillReadableStream}});var s=le();Object.defineProperty(exports,`File`,{enumerable:!0,get:function(){return s.PonyfillFile}});var c=Ye();Object.defineProperty(exports,`FormData`,{enumerable:!0,get:function(){return c.PonyfillFormData}});var l=V();Object.defineProperty(exports,`Blob`,{enumerable:!0,get:function(){return l.PonyfillBlob}});var u=it();Object.defineProperty(exports,`TextEncoder`,{enumerable:!0,get:function(){return u.PonyfillTextEncoder}}),Object.defineProperty(exports,`TextDecoder`,{enumerable:!0,get:function(){return u.PonyfillTextDecoder}}),Object.defineProperty(exports,`btoa`,{enumerable:!0,get:function(){return u.PonyfillBtoa}});var d=et();Object.defineProperty(exports,`URL`,{enumerable:!0,get:function(){return d.PonyfillURL}});var f=at();Object.defineProperty(exports,`URLSearchParams`,{enumerable:!0,get:function(){return f.PonyfillURLSearchParams}});var p=ot();Object.defineProperty(exports,`WritableStream`,{enumerable:!0,get:function(){return p.PonyfillWritableStream}});var m=st();Object.defineProperty(exports,`TransformStream`,{enumerable:!0,get:function(){return m.PonyfillTransformStream}});var h=ct();Object.defineProperty(exports,`CompressionStream`,{enumerable:!0,get:function(){return h.PonyfillCompressionStream}});var g=lt();Object.defineProperty(exports,`DecompressionStream`,{enumerable:!0,get:function(){return g.PonyfillDecompressionStream}});var _=Je();Object.defineProperty(exports,`IteratorObject`,{enumerable:!0,get:function(){return _.PonyfillIteratorObject}});var v=ut();Object.defineProperty(exports,`TextDecoderStream`,{enumerable:!0,get:function(){return v.PonyfillTextDecoderStream}}),Object.defineProperty(exports,`TextEncoderStream`,{enumerable:!0,get:function(){return v.PonyfillTextEncoderStream}})})),ft=e(((exports,t)=>{let n=j(),i;t.exports=function(e={}){let t={};if(t.URLPattern=globalThis.URLPattern,!t.URLPattern){let e=M();t.URLPattern=e.URLPattern}if(e.skipPonyfill||n())return{fetch:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response,FormData:globalThis.FormData,ReadableStream:globalThis.ReadableStream,WritableStream:globalThis.WritableStream,TransformStream:globalThis.TransformStream,CompressionStream:globalThis.CompressionStream,DecompressionStream:globalThis.DecompressionStream,TextDecoderStream:globalThis.TextDecoderStream,TextEncoderStream:globalThis.TextEncoderStream,Blob:globalThis.Blob,File:globalThis.File,crypto:globalThis.crypto,btoa:globalThis.btoa,TextEncoder:globalThis.TextEncoder,TextDecoder:globalThis.TextDecoder,URLPattern:t.URLPattern,URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};if(i||=dt(),t.fetch=i.fetch,t.Request=i.Request,t.Response=i.Response,t.Headers=i.Headers,t.FormData=i.FormData,t.ReadableStream=i.ReadableStream,t.URL=i.URL,t.URLSearchParams=i.URLSearchParams,t.WritableStream=i.WritableStream,t.TransformStream=i.TransformStream,t.CompressionStream=i.CompressionStream,t.DecompressionStream=i.DecompressionStream,t.TextDecoderStream=i.TextDecoderStream,t.TextEncoderStream=i.TextEncoderStream,t.Blob=i.Blob,t.File=i.File,t.crypto=globalThis.crypto,t.btoa=i.btoa,t.TextEncoder=i.TextEncoder,t.TextDecoder=i.TextDecoder,e.formDataLimits&&(t.Body=class extends i.Body{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}},t.Request=class extends i.Request{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}},t.Response=class extends i.Response{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}}),!t.crypto){let e=r(`crypto`);t.crypto=e.webcrypto}return t}})),pt=e(((exports,t)=>{let n=ft(),i=j(),a=n();if(!i())try{globalThis.libcurl=globalThis.libcurl||r(`node-libcurl`)}catch{}t.exports.fetch=a.fetch,t.exports.Headers=a.Headers,t.exports.Request=a.Request,t.exports.Response=a.Response,t.exports.FormData=a.FormData,t.exports.ReadableStream=a.ReadableStream,t.exports.WritableStream=a.WritableStream,t.exports.TransformStream=a.TransformStream,t.exports.CompressionStream=a.CompressionStream,t.exports.DecompressionStream=a.DecompressionStream,t.exports.TextDecoderStream=a.TextDecoderStream,t.exports.TextEncoderStream=a.TextEncoderStream,t.exports.Blob=a.Blob,t.exports.File=a.File,t.exports.crypto=a.crypto,t.exports.btoa=a.btoa,t.exports.TextEncoder=a.TextEncoder,t.exports.TextDecoder=a.TextDecoder,t.exports.URLPattern=a.URLPattern,t.exports.URL=a.URL,t.exports.URLSearchParams=a.URLSearchParams,exports.createFetch=n}));function mt(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}function ht(e){if(e.socket?.localPort)return e.socket?.localPort;let t=e.headers?.[`:authority`]||e.headers?.host,n=t?.split(`:`)?.[1];return n||80}function gt(e){if(e.headers?.[`:authority`])return e.headers?.[`:authority`];if(e.headers?.host)return e.headers?.host;let t=ht(e);if(e.hostname)return e.hostname+`:`+t;let n=e.socket?.localAddress;return n&&!n?.includes(`::`)&&!n?.includes(`ffff`)?`${n}:${t}`:`localhost`}function _t(e){let t=gt(e),n=e.protocol||(e.socket?.encrypted?`https`:`http`),r=e.originalUrl||e.url||`/graphql`;return`${n}://${t}${r}`}function vt(e){let t=e[Symbol.toStringTag];return!!(typeof e==`string`||t===`Uint8Array`||t===`Blob`||t===`FormData`||t===`URLSearchParams`||mt(e))}function yt(e,t,n,r){let i=e.raw||e.req||e,a=_t(i);if(e.query){let n=new t.URL(a);for(let t in e.query)n.searchParams.set(t,e.query[t]);a=n.toString()}let o=e.headers;if(e.headers?.[`:method`])for(let t in o={},e.headers)t.startsWith(`:`)||(o[t]=e.headers[t]);let s=r?Bt():new AbortController;if(n?.once){let e=()=>{s.signal.aborted||(Object.defineProperty(i,`aborted`,{value:!0}),s.abort(n.errored??void 0))};n.once(`error`,e),n.once(`close`,e),n.once(`finish`,()=>{n.removeListener(`close`,e)})}if(e.method===`GET`||e.method===`HEAD`)return new t.Request(a,{method:e.method,headers:o,signal:s.signal});let c=e.body;if(c!=null&&Object.keys(c).length>0){if(vt(c))return new t.Request(a,{method:e.method||`GET`,headers:o,body:c,signal:s.signal});let n=new t.Request(a,{method:e.method||`GET`,headers:o,signal:s.signal});return n.headers.get(`content-type`)?.includes(`json`)||n.headers.set(`content-type`,`application/json; charset=utf-8`),new Proxy(n,{get:(e,t,n)=>{switch(t){case`json`:return()=>h(c);case`text`:return()=>h(JSON.stringify(c));default:return globalThis.Bun?Reflect.get(e,t):Reflect.get(e,t,n)}}})}return new t.Request(a,{method:e.method,headers:o,signal:s.signal,body:i,duplex:`half`})}function bt(e){return e.read!=null}function xt(e){return bt(e)}function St(e){return e!=null&&e.setHeader!=null&&e.end!=null&&e.once!=null&&e.write!=null}function Ct(e){return e!=null&&e.getReader!=null}function wt(e){return e!=null&&e.request!=null&&e.respondWith!=null}function Tt(e){e?.socket?.setTimeout?.(0),e?.socket?.setNoDelay?.(!0),e?.socket?.setKeepAlive?.(!0)}function Y(e){e.end(null,null,null)}function Et(e,t){let n=!1,r=()=>{n=!0};e.once(`error`,r),e.once(`close`,r),e.once(`finish`,()=>{e.removeListener(`close`,r),e.removeListener(`error`,r)});let i=t[Symbol.asyncIterator](),a=()=>i.next().then(({done:t,value:r})=>{if(!(n||t))return m(()=>Dt(r,e),()=>n?Y(e):a())});return a()}function Dt(e,t){let n=t.write(e);if(!n)return new Promise(e=>t.once(`drain`,e))}function Ot(e,t,n,r){if(t.closed||t.destroyed||t.writableEnded)return;if(!e){t.statusCode=404,Y(t);return}if(r&&e.headers?.headersInit&&!Array.isArray(e.headers.headersInit)&&!e.headers.headersInit.get&&!e.headers._map&&!e.headers._setCookies?.length)t.writeHead(e.status,e.statusText,e.headers.headersInit);else{if(t.setHeaders)t.setHeaders(e.headers);else{let n=!1;e.headers.forEach((r,i)=>{if(i===`set-cookie`){if(n)return;n=!0;let r=e.headers.getSetCookie?.();if(r){t.setHeader(`set-cookie`,r);return}}t.setHeader(i,r)})}t.writeHead(e.status,e.statusText)}if(e.bodyType===`String`)return m(()=>Dt(e.bodyInit,t),()=>Y(t));let i=e._buffer;if(i)return m(()=>Dt(i,t),()=>Y(t));let a=e.body;if(a==null){Y(t);return}if(a[Symbol.toStringTag]===`Uint8Array`)return m(()=>Dt(a,t),()=>Y(t));if(Tt(n),bt(a)){t.once(`close`,()=>{a.destroy()}),a.pipe(t,{end:!0});return}if(Ct(a))return kt(n,t,a);if(mt(a))return Et(t,a)}function kt(e,t,n){let r=n.getReader();e?.once?.(`error`,e=>{r.cancel(e)});function i(){return r.read().then(({done:e,value:n})=>e?Y(t):m(()=>Dt(n,t),i))}return i()}function At(e){return typeof e==`object`&&!!e&&(`body`in e||`cache`in e||`credentials`in e||`headers`in e||`integrity`in e||`keepalive`in e||`method`in e||`mode`in e||`redirect`in e||`referrer`in e||`referrerPolicy`in e||`signal`in e||`window`in e)}function X(...e){let[t,...n]=e.filter(e=>typeof e==`object`&&!!e);return n.forEach(e=>{let n=Object.getOwnPropertyNames(e).reduce((t,n)=>{let r=Object.getOwnPropertyDescriptor(e,n);return r&&(t[n]=Object.getOwnPropertyDescriptor(e,n)),t},{});Object.getOwnPropertySymbols(e).forEach(t=>{let r=Object.getOwnPropertyDescriptor(e,t);r?.enumerable&&(n[t]=r)}),Object.defineProperties(t,n)}),t}function jt(e,t){return new t(e.stack||e.message||e.toString(),{status:e.status||500})}function Mt(e,t){return e==null?t==null?{}:{waitUntil:t}:X(Object.create(e),{waitUntil:t},e)}function Nt(e,t){if(t?.aborted)throw t.reason;if(f(e)&&t){let n=g();function r(){n.reject(t.reason)}return t.addEventListener(`abort`,r,{once:!0}),e.then(function(e){n.resolve(e)}).catch(function(e){n.reject(e)}).finally(()=>{t.removeEventListener(`abort`,r)}),n.promise}return e}const Pt=[`SIGINT`,`exit`,`SIGTERM`],Ft=new Set;let It=!1;function Lt(){if(!It){It=!0;for(let e of Pt)globalThis.process.once(e,function(){return Promise.allSettled([...Ft].map(e=>!e.disposed&&e.disposeAsync()))})}}function Rt(e){globalThis.process&&(Lt(),Ft.has(e)||(Ft.add(e),e.defer(()=>{Ft.delete(e)})))}var zt=class extends EventTarget{aborted=!1;_onabort=null;_reason;constructor(){super();let e=globalThis.process?.getBuiltinModule?.(`node:events`);e?.kMaxEventTargetListeners&&(this[e.kMaxEventTargetListeners]=0)}throwIfAborted(){if(this._nativeCtrl?.signal?.throwIfAborted)return this._nativeCtrl.signal.throwIfAborted();if(this.aborted)throw this._reason}_nativeCtrl;ensureNativeCtrl(){if(!this._nativeCtrl){let e=this.aborted;this._nativeCtrl=new AbortController,e&&this._nativeCtrl.abort(this._reason)}return this._nativeCtrl}abort(e){if(this._nativeCtrl?.abort)return this._nativeCtrl?.abort(e);this._reason=e||new DOMException(`This operation was aborted`,`AbortError`),this.aborted=!0,this.dispatchEvent(new Event(`abort`))}get signal(){return this._nativeCtrl?.signal?this._nativeCtrl.signal:this}get reason(){return this._nativeCtrl?.signal?this._nativeCtrl.signal.reason:this._reason}get onabort(){return this._onabort,this._onabort}set onabort(e){if(this._nativeCtrl?.signal){this._nativeCtrl.signal.onabort=e;return}this._onabort&&this.removeEventListener(`abort`,this._onabort),this._onabort=e,e&&this.addEventListener(`abort`,e)}};function Bt(){return globalThis.Bun||globalThis.Deno?new AbortController:new Proxy(new zt,{get(e,t,n){if(t.toString().includes(`kDependantSignals`)){let n=e.ensureNativeCtrl();return Reflect.get(n.signal,t,n.signal)}return Reflect.get(e,t,n)},set(e,t,n,r){if(t.toString().includes(`kDependantSignals`)){let r=e.ensureNativeCtrl();return Reflect.set(r.signal,t,n,r.signal)}return Reflect.set(e,t,n,r)},getPrototypeOf(){return AbortSignal.prototype}})}function Vt(e){return!!e.onData}function Ht({req:e,res:t,fetchAPI:n,controller:r}){let i=e.getMethod(),a,o=[],s=[e=>{o.push(e)}],c=e=>{for(let t of s)t(e)},l=!1,u=[()=>{l=!0}],d=()=>{for(let e of u)e()};t.onData(function(e,t){c(Buffer.from(Buffer.from(e,0,e.byteLength))),t&&d()});let f;if(i!==`get`&&i!==`head`){a=`half`,r.signal.addEventListener(`abort`,()=>{d()},{once:!0});let e;f=()=>(e||=new n.ReadableStream({start(e){for(let t of o)e.enqueue(t);if(l){e.close();return}s.push(t=>{e.enqueue(t)}),u.push(()=>{if(r.signal.reason){e.error(r.signal.reason);return}e.desiredSize&&e.close()})}}),e)}let p=new n.Headers;e.forEach((e,t)=>{p.append(e,t)});let m=`http://localhost${e.getUrl()}`,g=e.getQuery();g&&(m+=`?${g}`);let _;function v(){return f?l?b():f():null}let y=new n.Request(m,{method:i,headers:p,get body(){return v()},signal:r.signal,duplex:a});function b(){return _||=o.length===1?o[0]:Buffer.concat(o),_}function x(){return l?h(b()):new Promise((e,t)=>{try{u.push(()=>{e(b())})}catch(e){t(e)}})}return Object.defineProperties(y,{body:{get(){return v()},configurable:!0,enumerable:!0},json:{value(){return x().then(e=>e.toString(`utf8`)).then(e=>JSON.parse(e))},configurable:!0,enumerable:!0},text:{value(){return x().then(e=>e.toString(`utf8`))},configurable:!0,enumerable:!0},arrayBuffer:{value(){return x()},configurable:!0,enumerable:!0}}),y}function Ut(e,t){return new t.WritableStream({write(t){e.cork(()=>{e.write(t)})},close(){e.cork(()=>{e.end()})}})}function Wt(e,t,n,r){if(!t){e.writeStatus(`404 Not Found`),e.end();return}let i=t._buffer,a=t.bodyType===`String`?t.bodyInit:void 0;if(!n.signal.aborted&&(e.cork(()=>{e.writeStatus(`${t.status} ${t.statusText}`);for(let[n,r]of t.headers)if(n!==`content-length`){if(n===`set-cookie`){let r=t.headers.getSetCookie?.();if(r){for(let t of r)e.writeHeader(n,t);continue}}e.writeHeader(n,r)}a?e.end(a):i?e.end(i):t.body||e.end()}),!(a||i||!t.body)))return n.signal.addEventListener(`abort`,()=>{t.body?.locked||t.body?.cancel(n.signal.reason)},{once:!0}),t.body.pipeTo(Ut(e,r),{signal:n.signal}).catch(e=>{if(!n.signal.aborted)throw e})}var Gt=a(pt(),1);function Kt(e){try{return!!e?.request}catch{return!1}}const qt={};function Jt(e,t){let n=t?.__useSingleWriteHead==null?!0:t.__useSingleWriteHead,r={...Gt,...t?.fetchAPI},i=t?.__useCustomAbortCtrl==null?r.Request!==globalThis.Request:t.__useCustomAbortCtrl,a=typeof e==`function`?e:e.handle,o=[],s=[],c,l=new Set,u;function d(){return u||(u=new A,t?.disposeOnProcessTerminate&&Rt(u),u.defer(()=>{if(l.size>0)return Promise.allSettled(l).then(()=>{l.clear()},()=>{l.clear()})})),u}function p(e){f(e)&&(d(),l.add(e),e.then(()=>{l.delete(e)},t=>{console.error(`Unexpected error while waiting: ${t.message||t}`),l.delete(e)}))}if(t?.plugins!=null)for(let e of t.plugins){e.instrumentation&&(c=c?C(c,e.instrumentation):e.instrumentation),e.onRequest&&o.push(e.onRequest),e.onResponse&&s.push(e.onResponse);let t=e[T.dispose];t&&d().defer(t);let n=e[T.asyncDispose];n&&d().defer(n),e.onDispose&&d().defer(e.onDispose)}let g=o.length>0||s.length>0?function(e,t){let n=a,i;if(o.length===0)return u();let c=e.parsedUrl||new Proxy(qt,{get(t,n,i){return c=new r.URL(e.url,`http://localhost`),Reflect.get(c,n,c)}});function l(n){return s.length===0?n:m(()=>_(s,i=>i({request:e,response:n,serverContext:t,setResponse(e){n=e},fetchAPI:r})),()=>n)}function u(){return i?l(i):m(()=>n(e,t),l)}return m(()=>_(o,(a,o)=>a({request:e,setRequest(t){e=t},serverContext:t,fetchAPI:r,url:c,requestHandler:n,setRequestHandler(e){n=e},endResponse(e){i=e,e&&o()}})),u)}:a;if(c?.request){let e=g;g=(t,n)=>ee({request:t}).asyncFn(c.request,e)(t,n)}function v(e,...t){let n=t.length>1?X(...t):t[0]||{};n.waitUntil||=p;let a=yt(e,r,void 0,i);return g(a,n)}function y(e,t,...n){let a=t.raw||t,o=n.length>1?X(...n):n[0]||{};o.waitUntil||=p;let s=yt(e,r,a,i);return g(s,o)}function b(e,t,...i){let a={req:e,res:t,waitUntil:p};return S(h().then(()=>y(e,t,a,...i)).catch(e=>jt(e,r.Response)).then(r=>Ot(r,t,e,n)).catch(e=>console.error(`Unexpected error while handling request: ${e.message||e}`)))}function x(e,t,...n){let a={res:e,req:t,waitUntil:p},o=n.filter(e=>e!=null),s=o.length>0?X(a,...n):a,c=i?Bt():new AbortController,l=e.end.bind(e),u=!1;e.end=function(e){return u=!0,l(e)};let d=e.onAborted.bind(e);d(function(){c.abort()}),e.onAborted=function(e){c.signal.addEventListener(`abort`,e,{once:!0})};let f=Ht({req:t,res:e,fetchAPI:r,controller:c});return m(()=>m(()=>g(f,s),e=>e,e=>jt(e,r.Response)),t=>{if(!c.signal.aborted&&!u)return m(()=>Wt(e,t,c,r),e=>e,e=>{console.error(`Unexpected error while handling request: ${e.message||e}`)})})}function w(e,...t){if(!e.respondWith||!e.request)throw TypeError(`Expected FetchEvent, got ${e}`);let n=t.filter(e=>e!=null),r=n.length>0?X({},e,...n):Mt(e),i=g(e.request,r);e.respondWith(i)}function E(e,...t){let n=t.filter(e=>e!=null),r=n.length>1?X({},...n):Mt(n[0],n[0]==null||n[0].waitUntil==null?p:void 0);return g(e,r)}let D=(e,...t)=>{if(typeof e==`string`||`href`in e){let[n,...i]=t;if(At(n)){let t=new r.Request(e,n),a=E(t,...i),o=n.signal;return o?Nt(a,o):a}let a=new r.Request(e);return E(a,...t)}let n=E(e,...t);return Nt(n,e.signal)},O=(e,...t)=>{let[n,...r]=t;if(xt(e)){if(!St(n))throw TypeError(`Expected ServerResponse, got ${n}`);return b(e,n,...r)}if(Vt(e))return x(e,n,...r);if(St(n))throw TypeError(`Got Node response without Node request`);return Kt(e)?wt(e)?w(e,...t):E(e.request,e,...t):D(e,...t)},k={handleRequest:E,fetch:D,handleNodeRequest:v,handleNodeRequestAndResponse:y,requestListener:b,handleEvent:w,handleUWS:x,handle:O,get disposableStack(){return d()},[T.asyncDispose](){return u&&!u.disposed?u.disposeAsync():h()},dispose(){return u&&!u.disposed?u.disposeAsync():h()},waitUntil:p},j=new Proxy(O,{has:(t,n)=>n in k||n in O||e&&n in e,get:(t,n)=>{if(globalThis.Deno||n===Symbol.asyncDispose||n===Symbol.dispose){let e=Reflect.get(k,n,k);if(e)return e}let r=k[n];if(r)return r.bind?r.bind(k):r;let i=O[n];if(i)return i.bind?i.bind(O):i;if(e){let t=e[n];if(t)return t.bind?function(...t){let r=e[n](...t);return r===e?j:r}:t}},apply(e,t,n){return O(...n)}});return j}var Yt=(e,t,n)=>(r,i)=>{let a=-1;return o(0);async function o(s){if(s<=a)throw Error(`next() called multiple times`);a=s;let c,l=!1,u;if(e[s]?(u=e[s][0][0],r.req.routeIndex=s):u=s===e.length&&i||void 0,u)try{c=await u(r,()=>o(s+1))}catch(e){if(e instanceof Error&&t)r.error=e,c=await t(e,r),l=!0;else throw e}else r.finalized===!1&&n&&(c=await n(r));return c&&(r.finalized===!1||l)&&(r.res=c),r}},Xt=Symbol(),Zt=async(e,t=Object.create(null))=>{let{all:n=!1,dot:r=!1}=t,i=e instanceof bn?e.raw.headers:e.headers,a=i.get(`Content-Type`);return a?.startsWith(`multipart/form-data`)||a?.startsWith(`application/x-www-form-urlencoded`)?Qt(e,{all:n,dot:r}):{}};async function Qt(e,t){let n=await e.formData();return n?$t(n,t):{}}function $t(e,t){let n=Object.create(null);return e.forEach((e,r)=>{let i=t.all||r.endsWith(`[]`);i?en(n,r,e):n[r]=e}),t.dot&&Object.entries(n).forEach(([e,t])=>{let r=e.includes(`.`);r&&(tn(n,e,t),delete n[e])}),n}var en=(e,t,n)=>{e[t]===void 0?t.endsWith(`[]`)?e[t]=[n]:e[t]=n:Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]},tn=(e,t,n)=>{let r=e,i=t.split(`.`);i.forEach((e,t)=>{t===i.length-1?r[e]=n:((!r[e]||typeof r[e]!=`object`||Array.isArray(r[e])||r[e]instanceof File)&&(r[e]=Object.create(null)),r=r[e])})},nn=e=>{let t=e.split(`/`);return t[0]===``&&t.shift(),t},rn=e=>{let{groups:t,path:n}=an(e),r=nn(n);return on(r,t)},an=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,n)=>{let r=`@${n}`;return t.push([r,e]),r}),{groups:t,path:e}},on=(e,t)=>{for(let n=t.length-1;n>=0;n--){let[r]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(r)){e[i]=e[i].replace(r,t[n][1]);break}}return e},sn={},cn=(e,t)=>{if(e===`*`)return`*`;let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let r=`${e}#${t}`;return sn[r]||(n[2]?sn[r]=t&&t[0]!==`:`&&t[0]!==`*`?[r,n[1],RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],RegExp(`^${n[2]}$`)]:sn[r]=[e,n[1],!0]),sn[r]}return null},ln=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},un=e=>ln(e,decodeURI),dn=e=>{let t=e.url,n=t.indexOf(`/`,t.indexOf(`:`)+4),r=n;for(;r<t.length;r++){let e=t.charCodeAt(r);if(e===37){let e=t.indexOf(`?`,r),i=t.slice(n,e===-1?void 0:e);return un(i.includes(`%25`)?i.replace(/%25/g,`%2525`):i)}else if(e===63)break}return t.slice(n,r)},fn=e=>{let t=dn(e);return t.length>1&&t.at(-1)===`/`?t.slice(0,-1):t},Z=(e,t,...n)=>(n.length&&(t=Z(t,...n)),`${e?.[0]===`/`?``:`/`}${e}${t===`/`?``:`${e?.at(-1)===`/`?``:`/`}${t?.[0]===`/`?t.slice(1):t}`}`),pn=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(`:`))return null;let t=e.split(`/`),n=[],r=``;return t.forEach(e=>{if(e!==``&&!/\:/.test(e))r+=`/`+e;else if(/\:/.test(e))if(/\?/.test(e)){n.length===0&&r===``?n.push(`/`):n.push(r);let t=e.replace(`?`,``);r+=`/`+t,n.push(r)}else r+=`/`+e}),n.filter((e,t,n)=>n.indexOf(e)===t)},mn=e=>/[%+]/.test(e)?(e.indexOf(`+`)!==-1&&(e=e.replace(/\+/g,` `)),e.indexOf(`%`)===-1?e:ln(e,vn)):e,hn=(e,t,n)=>{let r;if(!n&&t&&!/[%+]/.test(t)){let n=e.indexOf(`?${t}`,8);for(n===-1&&(n=e.indexOf(`&${t}`,8));n!==-1;){let r=e.charCodeAt(n+t.length+1);if(r===61){let r=n+t.length+2,i=e.indexOf(`&`,r);return mn(e.slice(r,i===-1?void 0:i))}else if(r==38||isNaN(r))return``;n=e.indexOf(`&${t}`,n+1)}if(r=/[%+]/.test(e),!r)return}let i={};r??=/[%+]/.test(e);let a=e.indexOf(`?`,8);for(;a!==-1;){let t=e.indexOf(`&`,a+1),o=e.indexOf(`=`,a);o>t&&t!==-1&&(o=-1);let s=e.slice(a+1,o===-1?t===-1?void 0:t:o);if(r&&(s=mn(s)),a=t,s===``)continue;let c;o===-1?c=``:(c=e.slice(o+1,t===-1?void 0:t),r&&(c=mn(c))),n?(i[s]&&Array.isArray(i[s])||(i[s]=[]),i[s].push(c)):i[s]??=c}return t?i[t]:i},gn=hn,_n=(e,t)=>hn(e,t,!0),vn=decodeURIComponent,yn=e=>ln(e,vn),bn=class{raw;#validatedData;#matchResult;routeIndex=0;path;bodyCache={};constructor(e,t=`/`,n=[[]]){this.raw=e,this.path=t,this.#matchResult=n,this.#validatedData={}}param(e){return e?this.#getDecodedParam(e):this.#getAllDecodedParams()}#getDecodedParam(e){let t=this.#matchResult[0][this.routeIndex][1][e],n=this.#getParamValue(t);return n&&/\%/.test(n)?yn(n):n}#getAllDecodedParams(){let e={},t=Object.keys(this.#matchResult[0][this.routeIndex][1]);for(let n of t){let t=this.#getParamValue(this.#matchResult[0][this.routeIndex][1][n]);t!==void 0&&(e[n]=/\%/.test(t)?yn(t):t)}return e}#getParamValue(e){return this.#matchResult[1]?this.#matchResult[1][e]:e}query(e){return gn(this.url,e)}queries(e){return _n(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,n)=>{t[n]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await Zt(this,e)}#cachedBody=e=>{let{bodyCache:t,raw:n}=this,r=t[e];if(r)return r;let i=Object.keys(t)[0];return i?t[i].then(t=>(i===`json`&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=n[e]()};json(){return this.#cachedBody(`text`).then(e=>JSON.parse(e))}text(){return this.#cachedBody(`text`)}arrayBuffer(){return this.#cachedBody(`arrayBuffer`)}blob(){return this.#cachedBody(`blob`)}formData(){return this.#cachedBody(`formData`)}addValidatedData(e,t){this.#validatedData[e]=t}valid(e){return this.#validatedData[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[Xt](){return this.#matchResult}get matchedRoutes(){return this.#matchResult[0].map(([[,e]])=>e)}get routePath(){return this.#matchResult[0].map(([[,e]])=>e)[this.routeIndex].path}},xn={Stringify:1,BeforeStream:2,Stream:3},Sn=(e,t)=>{let n=new String(e);return n.isEscaped=!0,n.callbacks=t,n},Cn=async(e,t,n,r,i)=>{typeof e==`object`&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let a=e.callbacks;if(!a?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let o=Promise.all(a.map(e=>e({phase:t,buffer:i,context:r}))).then(e=>Promise.all(e.filter(Boolean).map(e=>Cn(e,t,!1,r,i))).then(()=>i[0]));return n?Sn(await o,a):o},wn=`text/plain; charset=UTF-8`,Tn=(e,t)=>({"Content-Type":e,...t}),En=class{#rawRequest;#req;env={};#var;finalized=!1;error;#status;#executionCtx;#res;#layout;#renderer;#notFoundHandler;#preparedHeaders;#matchResult;#path;constructor(e,t){this.#rawRequest=e,t&&(this.#executionCtx=t.executionCtx,this.env=t.env,this.#notFoundHandler=t.notFoundHandler,this.#path=t.path,this.#matchResult=t.matchResult)}get req(){return this.#req??=new bn(this.#rawRequest,this.#path,this.#matchResult),this.#req}get event(){if(this.#executionCtx&&`respondWith`in this.#executionCtx)return this.#executionCtx;throw Error(`This context has no FetchEvent`)}get executionCtx(){if(this.#executionCtx)return this.#executionCtx;throw Error(`This context has no ExecutionContext`)}get res(){return this.#res||=new Response(null,{headers:this.#preparedHeaders??=new Headers})}set res(e){if(this.#res&&e){e=new Response(e.body,e);for(let[t,n]of this.#res.headers.entries()){if(t===`content-type`)continue;if(t===`set-cookie`){let t=this.#res.headers.getSetCookie();e.headers.delete(`set-cookie`);for(let n of t)e.headers.append(`set-cookie`,n)}else e.headers.set(t,n)}}this.#res=e,this.finalized=!0}render=(...e)=>(this.#renderer??=e=>this.html(e),this.#renderer(...e));setLayout=e=>this.#layout=e;getLayout=()=>this.#layout;setRenderer=e=>{this.#renderer=e};header=(e,t,n)=>{this.finalized&&(this.#res=new Response(this.#res.body,this.#res));let r=this.#res?this.#res.headers:this.#preparedHeaders??=new Headers;t===void 0?r.delete(e):n?.append?r.append(e,t):r.set(e,t)};status=e=>{this.#status=e};set=(e,t)=>{this.#var??=new Map,this.#var.set(e,t)};get=e=>this.#var?this.#var.get(e):void 0;get var(){return this.#var?Object.fromEntries(this.#var):{}}#newResponse(e,t,n){let r=this.#res?new Headers(this.#res.headers):this.#preparedHeaders??new Headers;if(typeof t==`object`&&`headers`in t){let e=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(let[t,n]of e)t.toLowerCase()===`set-cookie`?r.append(t,n):r.set(t,n)}if(n)for(let[e,t]of Object.entries(n))if(typeof t==`string`)r.set(e,t);else{r.delete(e);for(let n of t)r.append(e,n)}let i=typeof t==`number`?t:t?.status??this.#status;return new Response(e,{status:i,headers:r})}newResponse=(...e)=>this.#newResponse(...e);body=(e,t,n)=>this.#newResponse(e,t,n);text=(e,t,n)=>!this.#preparedHeaders&&!this.#status&&!t&&!n&&!this.finalized?new Response(e):this.#newResponse(e,t,Tn(wn,n));json=(e,t,n)=>this.#newResponse(JSON.stringify(e),t,Tn(`application/json`,n));html=(e,t,n)=>{let r=e=>this.#newResponse(e,t,Tn(`text/html; charset=UTF-8`,n));return typeof e==`object`?Cn(e,xn.Stringify,!1,{}).then(r):r(e)};redirect=(e,t)=>{let n=String(e);return this.header(`Location`,/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#notFoundHandler??=()=>new Response,this.#notFoundHandler(this))},Q=`ALL`,Dn=`all`,On=[`get`,`post`,`put`,`delete`,`options`,`patch`],kn=`Can not add a route since the matcher is already built.`,An=class extends Error{},jn=`__COMPOSED_HANDLER`,Mn=e=>e.text(`404 Not Found`,404),Nn=(e,t)=>{if(`getResponse`in e){let n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text(`Internal Server Error`,500)},Pn=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath=`/`;#path=`/`;routes=[];constructor(e={}){let t=[...On,Dn];t.forEach(e=>{this[e]=(t,...n)=>(typeof t==`string`?this.#path=t:this.#addRoute(e,this.#path,t),n.forEach(t=>{this.#addRoute(e,this.#path,t)}),this)}),this.on=(e,t,...n)=>{for(let r of[t].flat()){this.#path=r;for(let t of[e].flat())n.map(e=>{this.#addRoute(t.toUpperCase(),this.#path,e)})}return this},this.use=(e,...t)=>(typeof e==`string`?this.#path=e:(this.#path=`*`,t.unshift(e)),t.forEach(e=>{this.#addRoute(Q,this.#path,e)}),this);let{strict:n,...r}=e;Object.assign(this,r),this.getPath=n??!0?e.getPath??dn:fn}#clone(){let e=new Pn({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#notFoundHandler=this.#notFoundHandler,e.routes=this.routes,e}#notFoundHandler=Mn;errorHandler=Nn;route(e,t){let n=this.basePath(e);return t.routes.map(e=>{let r;t.errorHandler===Nn?r=e.handler:(r=async(n,r)=>(await Yt([],t.errorHandler)(n,()=>e.handler(n,r))).res,r[jn]=e.handler),n.#addRoute(e.method,e.path,r)}),this}basePath(e){let t=this.#clone();return t._basePath=Z(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#notFoundHandler=e,this);mount(e,t,n){let r,i;n&&(typeof n==`function`?i=n:(i=n.optionHandler,r=n.replaceRequest===!1?e=>e:n.replaceRequest));let a=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};r||=(()=>{let t=Z(this._basePath,e),n=t===`/`?0:t.length;return e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||`/`,new Request(t,e)}})();let o=async(e,n)=>{let i=await t(r(e.req.raw),...a(e));if(i)return i;await n()};return this.#addRoute(Q,Z(e,`*`),o),this}#addRoute(e,t,n){e=e.toUpperCase(),t=Z(this._basePath,t);let r={basePath:this._basePath,path:t,method:e,handler:n};this.router.add(e,t,[n,r]),this.routes.push(r)}#handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#dispatch(e,t,n,r){if(r===`HEAD`)return(async()=>new Response(null,await this.#dispatch(e,t,n,`GET`)))();let i=this.getPath(e,{env:n}),a=this.router.match(r,i),o=new En(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:this.#notFoundHandler});if(a[0].length===1){let e;try{e=a[0][0][0][0](o,async()=>{o.res=await this.#notFoundHandler(o)})}catch(e){return this.#handleError(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#notFoundHandler(o))).catch(e=>this.#handleError(e,o)):e??this.#notFoundHandler(o)}let s=Yt(a[0],this.errorHandler,this.#notFoundHandler);return(async()=>{try{let e=await s(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#handleError(e,o)}})()}fetch=(e,...t)=>this.#dispatch(e,t[1],t[0],e.method);request=(e,t,n,r)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,r):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${Z(`/`,e)}`,t),n,r));fire=()=>{addEventListener(`fetch`,e=>{e.respondWith(this.#dispatch(e.request,e,void 0,e.request.method))})}},Fn=`[^/]+`,In=`.*`,Ln=`(?:|/.*)`,Rn=Symbol(),zn=new Set(`.\\+*[^]$()`);function Bn(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===In||e===Ln?1:t===In||t===Ln?-1:e===Fn?1:t===Fn?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var Vn=class{#index;#varIndex;#children=Object.create(null);insert(e,t,n,r,i){if(e.length===0){if(this.#index!==void 0)throw Rn;if(i)return;this.#index=t;return}let[a,...o]=e,s=a===`*`?o.length===0?[``,``,In]:[``,``,Fn]:a===`/*`?[``,``,Ln]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),c;if(s){let e=s[1],t=s[2]||Fn;if(e&&s[2]&&(t===`.*`||(t=t.replace(/^\((?!\?:)(?=[^)]+\)$)/,`(?:`),/\((?!\?:)/.test(t))))throw Rn;if(c=this.#children[t],!c){if(Object.keys(this.#children).some(e=>e!==In&&e!==Ln))throw Rn;if(i)return;c=this.#children[t]=new Vn,e!==``&&(c.#varIndex=r.varIndex++)}!i&&e!==``&&n.push([e,c.#varIndex])}else if(c=this.#children[a],!c){if(Object.keys(this.#children).some(e=>e.length>1&&e!==In&&e!==Ln))throw Rn;if(i)return;c=this.#children[a]=new Vn}c.insert(o,t,n,r,i)}buildRegExpStr(){let e=Object.keys(this.#children).sort(Bn),t=e.map(e=>{let t=this.#children[e];return(typeof t.#varIndex==`number`?`(${e})@${t.#varIndex}`:zn.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return typeof this.#index==`number`&&t.unshift(`#${this.#index}`),t.length===0?``:t.length===1?t[0]:`(?:`+t.join(`|`)+`)`}},Hn=class{#context={varIndex:0};#root=new Vn;insert(e,t,n){let r=[],i=[];for(let t=0;;){let n=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let r=`@\\${t}`;return i[t]=[r,e],t++,n=!0,r}),!n)break}let a=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let n=a.length-1;n>=0;n--)if(a[n].indexOf(t)!==-1){a[n]=a[n].replace(t,i[e][1]);break}}return this.#root.insert(a,t,r,this.#context,n),r}buildRegExp(){let e=this.#root.buildRegExpStr();if(e===``)return[/^$/,[],[]];let t=0,n=[],r=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,a)=>i===void 0?(a===void 0||(r[Number(a)]=++t),``):(n[++t]=Number(i),`$()`)),[RegExp(`^${e}`),n,r]}},Un=[],Wn=[/^$/,[],Object.create(null)],Gn=Object.create(null);function Kn(e){return Gn[e]??=RegExp(e===`*`?``:`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:`(?:|/.*)`)}$`)}function qn(){Gn=Object.create(null)}function Jn(e){let t=new Hn,n=[];if(e.length===0)return Wn;let r=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[n,r])=>e?1:n?-1:t.length-r.length),i=Object.create(null);for(let e=0,a=-1,o=r.length;e<o;e++){let[o,s,c]=r[e];o?i[s]=[c.map(([e])=>[e,Object.create(null)]),Un]:a++;let l;try{l=t.insert(s,a,o)}catch(e){throw e===Rn?new An(s):e}o||(n[a]=c.map(([e,t])=>{let n=Object.create(null);for(--t;t>=0;t--){let[e,r]=l[t];n[e]=r}return[e,n]}))}let[a,o,s]=t.buildRegExp();for(let e=0,t=n.length;e<t;e++)for(let t=0,r=n[e].length;t<r;t++){let r=n[e][t]?.[1];if(!r)continue;let i=Object.keys(r);for(let e=0,t=i.length;e<t;e++)r[i[e]]=s[r[i[e]]]}let c=[];for(let e in o)c[e]=n[o[e]];return[a,c,i]}function $(e,t){if(e){for(let n of Object.keys(e).sort((e,t)=>t.length-e.length))if(Kn(n).test(t))return[...e[n]]}}var Yn=class{name=`RegExpRouter`;#middleware;#routes;constructor(){this.#middleware={[Q]:Object.create(null)},this.#routes={[Q]:Object.create(null)}}add(e,t,n){let r=this.#middleware,i=this.#routes;if(!r||!i)throw Error(kn);r[e]||[r,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t[Q]).forEach(n=>{t[e][n]=[...t[Q][n]]})}),t===`/*`&&(t=`*`);let a=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let o=Kn(t);e===Q?Object.keys(r).forEach(e=>{r[e][t]||=$(r[e],t)||$(r[Q],t)||[]}):r[e][t]||=$(r[e],t)||$(r[Q],t)||[],Object.keys(r).forEach(t=>{(e===Q||e===t)&&Object.keys(r[t]).forEach(e=>{o.test(e)&&r[t][e].push([n,a])})}),Object.keys(i).forEach(t=>{(e===Q||e===t)&&Object.keys(i[t]).forEach(e=>o.test(e)&&i[t][e].push([n,a]))});return}let o=pn(t)||[t];for(let t=0,s=o.length;t<s;t++){let c=o[t];Object.keys(i).forEach(o=>{(e===Q||e===o)&&(i[o][c]||=[...$(r[o],c)||$(r[Q],c)||[]],i[o][c].push([n,a-s+t+1]))})}}match(e,t){qn();let n=this.#buildAllMatchers();return this.match=(e,t)=>{let r=n[e]||n[Q],i=r[2][t];if(i)return i;let a=t.match(r[0]);if(!a)return[[],Un];let o=a.indexOf(``,1);return[r[1][o],a]},this.match(e,t)}#buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach(t=>{e[t]||=this.#buildMatcher(t)}),this.#middleware=this.#routes=void 0,e}#buildMatcher(e){let t=[],n=e===Q;return[this.#middleware,this.#routes].forEach(r=>{let i=r[e]?Object.keys(r[e]).map(t=>[t,r[e][t]]):[];i.length===0?e!==Q&&t.push(...Object.keys(r[Q]).map(e=>[e,r[Q][e]])):(n||=!0,t.push(...i))}),n?Jn(t):null}},Xn=class{name=`SmartRouter`;#routers=[];#routes=[];constructor(e){this.#routers=e.routers}add(e,t,n){if(!this.#routes)throw Error(kn);this.#routes.push([e,t,n])}match(e,t){if(!this.#routes)throw Error(`Fatal error`);let n=this.#routers,r=this.#routes,i=n.length,a=0,o;for(;a<i;a++){let i=n[a];try{for(let e=0,t=r.length;e<t;e++)i.add(...r[e]);o=i.match(e,t)}catch(e){if(e instanceof An)continue;throw e}this.match=i.match.bind(i),this.#routers=[i],this.#routes=void 0;break}if(a===i)throw Error(`Fatal error`);return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#routes||this.#routers.length!==1)throw Error(`No active router has been determined yet.`);return this.#routers[0]}},Zn=Object.create(null),Qn=class{#methods;#children;#patterns;#order=0;#params=Zn;constructor(e,t,n){if(this.#children=n||Object.create(null),this.#methods=[],e&&t){let n=Object.create(null);n[e]={handler:t,possibleKeys:[],score:0},this.#methods=[n]}this.#patterns=[]}insert(e,t,n){this.#order=++this.#order;let r=this,i=rn(t),a=[];for(let e=0,t=i.length;e<t;e++){let t=i[e],n=i[e+1],o=cn(t,n),s=Array.isArray(o)?o[0]:t;if(s in r.#children){r=r.#children[s],o&&a.push(o[1]);continue}r.#children[s]=new Qn,o&&(r.#patterns.push(o),a.push(o[1])),r=r.#children[s]}return r.#methods.push({[e]:{handler:n,possibleKeys:a.filter((e,t,n)=>n.indexOf(e)===t),score:this.#order}}),r}#getHandlerSets(e,t,n,r){let i=[];for(let a=0,o=e.#methods.length;a<o;a++){let o=e.#methods[a],s=o[t]||o[Q],c={};if(s!==void 0&&(s.params=Object.create(null),i.push(s),n!==Zn||r&&r!==Zn))for(let e=0,t=s.possibleKeys.length;e<t;e++){let t=s.possibleKeys[e],i=c[s.score];s.params[t]=r?.[t]&&!i?r[t]:n[t]??r?.[t],c[s.score]=!0}}return i}search(e,t){let n=[];this.#params=Zn;let r=this,i=[r],a=nn(t),o=[];for(let t=0,r=a.length;t<r;t++){let s=a[t],c=t===r-1,l=[];for(let r=0,u=i.length;r<u;r++){let u=i[r],d=u.#children[s];d&&(d.#params=u.#params,c?(d.#children[`*`]&&n.push(...this.#getHandlerSets(d.#children[`*`],e,u.#params)),n.push(...this.#getHandlerSets(d,e,u.#params))):l.push(d));for(let r=0,i=u.#patterns.length;r<i;r++){let i=u.#patterns[r],d=u.#params===Zn?{}:{...u.#params};if(i===`*`){let t=u.#children[`*`];t&&(n.push(...this.#getHandlerSets(t,e,u.#params)),t.#params=d,l.push(t));continue}let[f,p,m]=i;if(!s&&!(m instanceof RegExp))continue;let h=u.#children[f],g=a.slice(t).join(`/`);if(m instanceof RegExp){let t=m.exec(g);if(t){if(d[p]=t[0],n.push(...this.#getHandlerSets(h,e,u.#params,d)),Object.keys(h.#children).length){h.#params=d;let e=t[0].match(/\//)?.length??0,n=o[e]||=[];n.push(h)}continue}}(m===!0||m.test(s))&&(d[p]=s,c?(n.push(...this.#getHandlerSets(h,e,d,u.#params)),h.#children[`*`]&&n.push(...this.#getHandlerSets(h.#children[`*`],e,d,u.#params))):(h.#params=d,l.push(h)))}}i=l.concat(o.shift()??[])}return n.length>1&&n.sort((e,t)=>e.score-t.score),[n.map(({handler:e,params:t})=>[e,t])]}},$n=class{name=`TrieRouter`;#node;constructor(){this.#node=new Qn}add(e,t,n){let r=pn(t);if(r){for(let t=0,i=r.length;t<i;t++)this.#node.insert(e,r[t],n);return}this.#node.insert(e,t,n)}match(e,t){return this.#node.search(e,t)}},er=class extends Pn{constructor(e={}){super(e),this.router=e.router??new Xn({routers:[new Yn,new $n]})}},tr=/^[\w!#$%&'*.^`|~+-]+$/,nr=/^[ !#-:<-[\]-~]*$/,rr=(e,t)=>{if(t&&e.indexOf(t)===-1)return{};let n=e.trim().split(`;`),r={};for(let e of n){e=e.trim();let n=e.indexOf(`=`);if(n===-1)continue;let i=e.substring(0,n).trim();if(t&&t!==i||!tr.test(i))continue;let a=e.substring(n+1).trim();if(a.startsWith(`"`)&&a.endsWith(`"`)&&(a=a.slice(1,-1)),nr.test(a)&&(r[i]=a.indexOf(`%`)===-1?a:ln(a,vn),t))break}return r},ir=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},ar=(e,t,n)=>(t=encodeURIComponent(t),ir(e,t,n)),or=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),sr=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??`);e=e.replace(t,r?`/${r}`:``)}return e},cr=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){if(r===void 0)continue;if(Array.isArray(r))for(let e of r)t.append(n,e);else t.set(n,r)}return t},lr=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},ur=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function dr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fr(e,t){if(!dr(e)&&!dr(t))return t;let n={...e};for(let e in t){let r=t[e];dr(n[e])&&dr(r)?n[e]=fr(n[e],r):n[e]=r}return n}var pr=(e,t)=>{let n=new Proxy(()=>{},{get(n,r){if(!(typeof r!=`string`||r===`then`))return pr(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}});return n},mr=class{url;method;queryParams=void 0;pathParams={};rBody;cType=void 0;constructor(e,t){this.url=e,this.method=t}fetch=async(e,t)=>{if(e){if(e.query&&(this.queryParams=cr(e.query)),e.form){let t=new FormData;for(let[n,r]of Object.entries(e.form))if(Array.isArray(r))for(let e of r)t.append(n,e);else t.append(n,r);this.rBody=t}e.json&&(this.rBody=JSON.stringify(e.json),this.cType=`application/json`),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase(),r={...e?.header,...typeof t?.headers==`function`?await t.headers():t?.headers};if(e?.cookie){let t=[];for(let[n,r]of Object.entries(e.cookie))t.push(ar(n,r,{path:`/`}));r.Cookie=t.join(`,`)}this.cType&&(r[`Content-Type`]=this.cType);let i=new Headers(r??void 0),a=this.url;a=ur(a),a=sr(a,this.pathParams),this.queryParams&&(a=a+`?`+this.queryParams.toString()),n=this.method.toUpperCase();let o=!(n===`GET`||n===`HEAD`);return(t?.fetch||fetch)(a,{body:o?this.rBody:void 0,method:n,headers:i,...t?.init})}},hr=(e,t)=>pr(function n(r){let i=[...r.path],a=i.slice(-3).reverse();if(a[0]===`toString`)return a[1]===`name`?a[2]||``:n.toString();if(a[0]===`valueOf`)return a[1]===`name`?a[2]||``:n;let o=``;if(/^\$/.test(a[0])){let e=i.pop();e&&(o=e.replace(/^\$/,``))}let s=i.join(`/`),c=or(e,s);if(o===`url`){let e=c;return r.args[0]&&(r.args[0].param&&(e=sr(c,r.args[0].param)),r.args[0].query&&(e=e+`?`+cr(r.args[0].query).toString())),e=ur(e),new URL(e)}if(o===`ws`){let e=lr(r.args[0]&&r.args[0].param?sr(c,r.args[0].param):c,`ws`),n=new URL(e),i=r.args[0]?.query;i&&Object.entries(i).forEach(([e,t])=>{Array.isArray(t)?t.forEach(t=>n.searchParams.append(e,t)):n.searchParams.set(e,t)});let a=(...e)=>t?.webSocket!==void 0&&typeof t.webSocket==`function`?t.webSocket(...e):new WebSocket(...e);return a(n.toString())}let l=new mr(c,o);if(o){t??={};let e=fr(t,{...r.args[1]});return l.fetch(r.args[0],e)}return l},[]),gr=(e,t,n)=>{let r=e.req.raw.headers.get(`Cookie`);if(typeof t==`string`){if(!r)return;let e=t;n===`secure`?e=`__Secure-`+t:n===`host`&&(e=`__Host-`+t);let i=rr(r,e);return i[e]}if(!r)return{};let i=rr(r);return i},_r=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){if(this.res){let e=new Response(this.res.body,{status:this.status,headers:this.res.headers});return e}return new Response(this.message,{status:this.status})}},vr=(e,t)=>{let n=new Response(e,{headers:{"Content-Type":t}});return n.formData()},yr=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,br=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,xr=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Sr=(e,t)=>async(n,r)=>{let i={},a=n.req.header(`Content-Type`);switch(e){case`json`:if(!a||!yr.test(a))break;try{i=await n.req.json()}catch{throw new _r(400,{message:`Malformed JSON in request body`})}break;case`form`:{if(!a||!(br.test(a)||xr.test(a)))break;let e;if(n.req.bodyCache.formData)e=await n.req.bodyCache.formData;else try{let t=await n.req.arrayBuffer();e=await vr(t,a),n.req.bodyCache.formData=e}catch(e){let t=`Malformed FormData request.`;throw t+=e instanceof Error?` ${e.message}`:` ${String(e)}`,new _r(400,{message:t})}let t={};e.forEach((e,n)=>{n.endsWith(`[]`)?(t[n]??=[]).push(e):Array.isArray(t[n])?t[n].push(e):n in t?t[n]=[t[n],e]:t[n]=e}),i=t;break}case`query`:i=Object.fromEntries(Object.entries(n.req.queries()).map(([e,t])=>t.length===1?[e,t[0]]:[e,t]));break;case`param`:i=n.req.param();break;case`header`:i=n.req.header();break;case`cookie`:i=gr(n);break}let o=await t(i,n);if(o instanceof Response)return o;n.req.addValidatedData(e,o),await r()},Cr=class extends Error{constructor(e,t){super(e),this.response=t}};function wr(){let e={chat:[],ui:[],request:[],error:[]},t={on:(n,r)=>(e[n]=[...e[n]??[],r],t),serve:t=>{t||={},t.host||=process.env.HOST??`127.0.0.1`,t.port||=parseInt(process.env.PORT??`3000`),t.apiUrl||=process.env.BLINK_API_URL;let n=hr(t.apiUrl??``,{fetch:t.apiUrl?void 0:async()=>{throw console.warn(`Your code is attempting to use the Blink API server, but no API server is configured for this Blink agent.`),Error(`No API server is configured for this Blink agent. External APIs are not available.`)}}),r={chat:{async ensure(e){let t=await n.chat[`:key`].$post({param:{key:e}});if(t.status!==200)throw Error(`Failed to ensure chat!`);return t.json()},async message(e,t,r){let i=await n.chat[`:key`].sendMessages.$post({param:{key:e},json:{message:t,options:r??{}}});if(i.status!==204)throw Error(`Failed to send message!`)}},store:{async get(e){let t=await n.kv[`:key`].$get({param:{key:e}});if(t.status!==200)throw Error(`Failed to get value!`);let{value:r}=await t.json();return r},async set(e,t){let r=await n.kv[`:key`].$post({param:{key:e},json:{value:t}});if(r.status!==204)throw Error(`Failed to set value!`)},async delete(e){let t=await n.kv[`:key`].$delete({param:{key:e}});if(t.status!==204)throw Error(`Failed to delete value!`)},async list(e,t){let r=await n.kv.$get({query:{prefix:e,limit:t?.limit,cursor:t?.cursor}});if(r.status!==200)throw Error(`Failed to list values!`);return r.json()}}},i=o.createServer(Jt(t=>Er.fetch(t,{context:r,listeners:e})));return i.listen(t?.port??3e3,t?.host??`127.0.0.1`)}};return t}const Tr=new er().post(`/chat`,Sr(`json`,e=>({messages:e.messages,chat:e.chat})),async e=>{let t=e.env.listeners.chat,n=e.req.valid(`json`);for(let r of t){let t;try{t=await r({chat:n.chat,messages:n.messages,abortSignal:e.req.raw.signal,context:e.env.context})}catch(e){if(e instanceof Cr)t=e.response;else throw e}if(!t)continue;if(t instanceof Response)return t;let i;if(t instanceof ReadableStream)i=t;else if(typeof t==`object`&&`toUIMessageStream`in t)i=t.toUIMessageStream({messageMetadata:({part:e})=>{switch(e.type){case`finish`:return{totalUsage:e.totalUsage};case`finish-step`:return{usage:e.usage,model:e.response.modelId}}}});else throw Error(`Invalid chat handler result! Must be a Response, ReadableStream, or toUIMessageStream function.`);return new Response(i.pipeThrough(new TransformStream({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}\n\n`)},flush(e){e.enqueue(`data: [DONE]
7
+ `,"%0b":`\v`,"%0B":`\v`,"%0c":`\f`,"%0C":`\f`,"%0d":`\r`,"%0D":`\r`,"%0e":``,"%0E":``,"%0f":``,"%0F":``,"%10":``,"%11":``,"%12":``,"%13":``,"%14":``,"%15":``,"%16":``,"%17":``,"%18":``,"%19":``,"%1a":``,"%1A":``,"%1b":`\x1B`,"%1B":`\x1B`,"%1c":``,"%1C":``,"%1d":``,"%1D":``,"%1e":``,"%1E":``,"%1f":``,"%1F":``,"%20":` `,"%21":`!`,"%22":`"`,"%23":`#`,"%24":`$`,"%25":`%`,"%26":`&`,"%27":`'`,"%28":`(`,"%29":`)`,"%2a":`*`,"%2A":`*`,"%2b":`+`,"%2B":`+`,"%2c":`,`,"%2C":`,`,"%2d":`-`,"%2D":`-`,"%2e":`.`,"%2E":`.`,"%2f":`/`,"%2F":`/`,"%30":`0`,"%31":`1`,"%32":`2`,"%33":`3`,"%34":`4`,"%35":`5`,"%36":`6`,"%37":`7`,"%38":`8`,"%39":`9`,"%3a":`:`,"%3A":`:`,"%3b":`;`,"%3B":`;`,"%3c":`<`,"%3C":`<`,"%3d":`=`,"%3D":`=`,"%3e":`>`,"%3E":`>`,"%3f":`?`,"%3F":`?`,"%40":`@`,"%41":`A`,"%42":`B`,"%43":`C`,"%44":`D`,"%45":`E`,"%46":`F`,"%47":`G`,"%48":`H`,"%49":`I`,"%4a":`J`,"%4A":`J`,"%4b":`K`,"%4B":`K`,"%4c":`L`,"%4C":`L`,"%4d":`M`,"%4D":`M`,"%4e":`N`,"%4E":`N`,"%4f":`O`,"%4F":`O`,"%50":`P`,"%51":`Q`,"%52":`R`,"%53":`S`,"%54":`T`,"%55":`U`,"%56":`V`,"%57":`W`,"%58":`X`,"%59":`Y`,"%5a":`Z`,"%5A":`Z`,"%5b":`[`,"%5B":`[`,"%5c":`\\`,"%5C":`\\`,"%5d":`]`,"%5D":`]`,"%5e":`^`,"%5E":`^`,"%5f":`_`,"%5F":`_`,"%60":"`","%61":`a`,"%62":`b`,"%63":`c`,"%64":`d`,"%65":`e`,"%66":`f`,"%67":`g`,"%68":`h`,"%69":`i`,"%6a":`j`,"%6A":`j`,"%6b":`k`,"%6B":`k`,"%6c":`l`,"%6C":`l`,"%6d":`m`,"%6D":`m`,"%6e":`n`,"%6E":`n`,"%6f":`o`,"%6F":`o`,"%70":`p`,"%71":`q`,"%72":`r`,"%73":`s`,"%74":`t`,"%75":`u`,"%76":`v`,"%77":`w`,"%78":`x`,"%79":`y`,"%7a":`z`,"%7A":`z`,"%7b":`{`,"%7B":`{`,"%7c":`|`,"%7C":`|`,"%7d":`}`,"%7D":`}`,"%7e":`~`,"%7E":`~`,"%7f":``,"%7F":``,"%80":`€`,"%81":``,"%82":`‚`,"%83":`ƒ`,"%84":`„`,"%85":`…`,"%86":`†`,"%87":`‡`,"%88":`ˆ`,"%89":`‰`,"%8a":`Š`,"%8A":`Š`,"%8b":`‹`,"%8B":`‹`,"%8c":`Œ`,"%8C":`Œ`,"%8d":``,"%8D":``,"%8e":`Ž`,"%8E":`Ž`,"%8f":``,"%8F":``,"%90":``,"%91":`‘`,"%92":`’`,"%93":`“`,"%94":`”`,"%95":`•`,"%96":`–`,"%97":`—`,"%98":`˜`,"%99":`™`,"%9a":`š`,"%9A":`š`,"%9b":`›`,"%9B":`›`,"%9c":`œ`,"%9C":`œ`,"%9d":``,"%9D":``,"%9e":`ž`,"%9E":`ž`,"%9f":`Ÿ`,"%9F":`Ÿ`,"%a0":`\xA0`,"%A0":`\xA0`,"%a1":`¡`,"%A1":`¡`,"%a2":`¢`,"%A2":`¢`,"%a3":`£`,"%A3":`£`,"%a4":`¤`,"%A4":`¤`,"%a5":`¥`,"%A5":`¥`,"%a6":`¦`,"%A6":`¦`,"%a7":`§`,"%A7":`§`,"%a8":`¨`,"%A8":`¨`,"%a9":`©`,"%A9":`©`,"%aa":`ª`,"%Aa":`ª`,"%aA":`ª`,"%AA":`ª`,"%ab":`«`,"%Ab":`«`,"%aB":`«`,"%AB":`«`,"%ac":`¬`,"%Ac":`¬`,"%aC":`¬`,"%AC":`¬`,"%ad":`­`,"%Ad":`­`,"%aD":`­`,"%AD":`­`,"%ae":`®`,"%Ae":`®`,"%aE":`®`,"%AE":`®`,"%af":`¯`,"%Af":`¯`,"%aF":`¯`,"%AF":`¯`,"%b0":`°`,"%B0":`°`,"%b1":`±`,"%B1":`±`,"%b2":`²`,"%B2":`²`,"%b3":`³`,"%B3":`³`,"%b4":`´`,"%B4":`´`,"%b5":`µ`,"%B5":`µ`,"%b6":`¶`,"%B6":`¶`,"%b7":`·`,"%B7":`·`,"%b8":`¸`,"%B8":`¸`,"%b9":`¹`,"%B9":`¹`,"%ba":`º`,"%Ba":`º`,"%bA":`º`,"%BA":`º`,"%bb":`»`,"%Bb":`»`,"%bB":`»`,"%BB":`»`,"%bc":`¼`,"%Bc":`¼`,"%bC":`¼`,"%BC":`¼`,"%bd":`½`,"%Bd":`½`,"%bD":`½`,"%BD":`½`,"%be":`¾`,"%Be":`¾`,"%bE":`¾`,"%BE":`¾`,"%bf":`¿`,"%Bf":`¿`,"%bF":`¿`,"%BF":`¿`,"%c0":`À`,"%C0":`À`,"%c1":`Á`,"%C1":`Á`,"%c2":`Â`,"%C2":`Â`,"%c3":`Ã`,"%C3":`Ã`,"%c4":`Ä`,"%C4":`Ä`,"%c5":`Å`,"%C5":`Å`,"%c6":`Æ`,"%C6":`Æ`,"%c7":`Ç`,"%C7":`Ç`,"%c8":`È`,"%C8":`È`,"%c9":`É`,"%C9":`É`,"%ca":`Ê`,"%Ca":`Ê`,"%cA":`Ê`,"%CA":`Ê`,"%cb":`Ë`,"%Cb":`Ë`,"%cB":`Ë`,"%CB":`Ë`,"%cc":`Ì`,"%Cc":`Ì`,"%cC":`Ì`,"%CC":`Ì`,"%cd":`Í`,"%Cd":`Í`,"%cD":`Í`,"%CD":`Í`,"%ce":`Î`,"%Ce":`Î`,"%cE":`Î`,"%CE":`Î`,"%cf":`Ï`,"%Cf":`Ï`,"%cF":`Ï`,"%CF":`Ï`,"%d0":`Ð`,"%D0":`Ð`,"%d1":`Ñ`,"%D1":`Ñ`,"%d2":`Ò`,"%D2":`Ò`,"%d3":`Ó`,"%D3":`Ó`,"%d4":`Ô`,"%D4":`Ô`,"%d5":`Õ`,"%D5":`Õ`,"%d6":`Ö`,"%D6":`Ö`,"%d7":`×`,"%D7":`×`,"%d8":`Ø`,"%D8":`Ø`,"%d9":`Ù`,"%D9":`Ù`,"%da":`Ú`,"%Da":`Ú`,"%dA":`Ú`,"%DA":`Ú`,"%db":`Û`,"%Db":`Û`,"%dB":`Û`,"%DB":`Û`,"%dc":`Ü`,"%Dc":`Ü`,"%dC":`Ü`,"%DC":`Ü`,"%dd":`Ý`,"%Dd":`Ý`,"%dD":`Ý`,"%DD":`Ý`,"%de":`Þ`,"%De":`Þ`,"%dE":`Þ`,"%DE":`Þ`,"%df":`ß`,"%Df":`ß`,"%dF":`ß`,"%DF":`ß`,"%e0":`à`,"%E0":`à`,"%e1":`á`,"%E1":`á`,"%e2":`â`,"%E2":`â`,"%e3":`ã`,"%E3":`ã`,"%e4":`ä`,"%E4":`ä`,"%e5":`å`,"%E5":`å`,"%e6":`æ`,"%E6":`æ`,"%e7":`ç`,"%E7":`ç`,"%e8":`è`,"%E8":`è`,"%e9":`é`,"%E9":`é`,"%ea":`ê`,"%Ea":`ê`,"%eA":`ê`,"%EA":`ê`,"%eb":`ë`,"%Eb":`ë`,"%eB":`ë`,"%EB":`ë`,"%ec":`ì`,"%Ec":`ì`,"%eC":`ì`,"%EC":`ì`,"%ed":`í`,"%Ed":`í`,"%eD":`í`,"%ED":`í`,"%ee":`î`,"%Ee":`î`,"%eE":`î`,"%EE":`î`,"%ef":`ï`,"%Ef":`ï`,"%eF":`ï`,"%EF":`ï`,"%f0":`ð`,"%F0":`ð`,"%f1":`ñ`,"%F1":`ñ`,"%f2":`ò`,"%F2":`ò`,"%f3":`ó`,"%F3":`ó`,"%f4":`ô`,"%F4":`ô`,"%f5":`õ`,"%F5":`õ`,"%f6":`ö`,"%F6":`ö`,"%f7":`÷`,"%F7":`÷`,"%f8":`ø`,"%F8":`ø`,"%f9":`ù`,"%F9":`ù`,"%fa":`ú`,"%Fa":`ú`,"%fA":`ú`,"%FA":`ú`,"%fb":`û`,"%Fb":`û`,"%fB":`û`,"%FB":`û`,"%fc":`ü`,"%Fc":`ü`,"%fC":`ü`,"%FC":`ü`,"%fd":`ý`,"%Fd":`ý`,"%fD":`ý`,"%FD":`ý`,"%fe":`þ`,"%Fe":`þ`,"%fE":`þ`,"%FE":`þ`,"%ff":`ÿ`,"%Ff":`ÿ`,"%fF":`ÿ`,"%FF":`ÿ`};function a(e){return i[e]}function o(e){let t=[],i=0,o=``,s=!1,c=!1,l=0,u=``,d=e.length;for(var f=0;f<d;++f){let p=e[f];if(p===`\\`&&s)if(c)c=!1;else{c=!0;continue}else if(p===`"`)if(c)c=!1;else{if(s)for(s=!1,i=0;f+1<d&&e[f+1]!==`;`;)++f;else s=!0;continue}else if(c&&s&&(u+=`\\`),c=!1,(i===2||i===3)&&p===`'`){i===2?(i=3,o=u.substring(1)):i=1,u=``;continue}else if(i===0&&(p===`*`||p===`=`)&&t.length){i=p===`*`?2:1,t[l]=[u,void 0],u=``;continue}else if(!s&&p===`;`){i=0,o?(u.length&&(u=n(u.replace(r,a),`binary`,o)),o=``):u.length&&(u=n(u,`binary`,`utf8`)),t[l]===void 0?t[l]=u:t[l][1]=u,u=``,++l;continue}else if(!s&&(p===` `||p===` `))continue;u+=p}return o&&u.length?u=n(u.replace(r,a),`binary`,o):u&&=n(u,`binary`,`utf8`),t[l]===void 0?u&&(t[l]=u):t[l][1]=u,t}t.exports=o})),oe=e(((exports,t)=>{t.exports=function(e){if(typeof e!=`string`)return``;for(var t=e.length-1;t>=0;--t)switch(e.charCodeAt(t)){case 47:case 92:return e=e.slice(t+1),e===`..`||e===`.`?``:e}return e===`..`||e===`.`?``:e}})),se=e(((exports,t)=>{let{Readable:n}=r(`node:stream`),{inherits:i}=r(`node:util`),a=L(),o=ae(),s=ie(),c=oe(),l=ne(),u=/^boundary$/i,d=/^form-data$/i,f=/^charset$/i,p=/^filename$/i,m=/^name$/i;h.detect=/^multipart\/form-data/i;function h(e,t){let n,r,i=this,h,v=t.limits,y=t.isPartAFile||((e,t,n)=>t===`application/octet-stream`||n!==void 0),b=t.parsedConType||[],x=t.defCharset||`utf8`,S=t.preservePath,C={highWaterMark:t.fileHwm};for(n=0,r=b.length;n<r;++n)if(Array.isArray(b[n])&&u.test(b[n][0])){h=b[n][1];break}function w(){N===0&&I&&!e._done&&(I=!1,i.end())}if(typeof h!=`string`)throw Error(`Multipart: Boundary not found`);let T=l(v,`fieldSize`,1*1024*1024),E=l(v,`fileSize`,1/0),D=l(v,`files`,1/0),O=l(v,`fields`,1/0),k=l(v,`parts`,1/0),A=l(v,`headerPairs`,2e3),j=l(v,`headerSize`,80*1024),ee=0,M=0,N=0,P,F,I=!1;this._needDrain=!1,this._pause=!1,this._cb=void 0,this._nparts=0,this._boy=e;let te={boundary:h,maxHeaderPairs:A,maxHeaderSize:j,partHwm:C.highWaterMark,highWaterMark:t.highWaterMark};this.parser=new a(te),this.parser.on(`drain`,function(){if(i._needDrain=!1,i._cb&&!i._pause){let e=i._cb;i._cb=void 0,e()}}).on(`part`,function t(a){if(++i._nparts>k)return i.parser.removeListener(`part`,t),i.parser.on(`part`,g),e.hitPartsLimit=!0,e.emit(`partsLimit`),g(a);if(F){let e=F;e.emit(`end`),e.removeAllListeners(`end`)}a.on(`header`,function(t){let l,u,h,v,b,k,A=0;if(t[`content-type`]&&(h=o(t[`content-type`][0]),h[0])){for(l=h[0].toLowerCase(),n=0,r=h.length;n<r;++n)if(f.test(h[n][0])){v=h[n][1].toLowerCase();break}}if(l===void 0&&(l=`text/plain`),v===void 0&&(v=x),t[`content-disposition`]){if(h=o(t[`content-disposition`][0]),!d.test(h[0]))return g(a);for(n=0,r=h.length;n<r;++n)m.test(h[n][0])?u=h[n][1]:p.test(h[n][0])&&(k=h[n][1],S||(k=c(k)))}else return g(a);b=t[`content-transfer-encoding`]?t[`content-transfer-encoding`][0].toLowerCase():`7bit`;let j,I;if(y(u,l,k)){if(ee===D)return e.hitFilesLimit||(e.hitFilesLimit=!0,e.emit(`filesLimit`)),g(a);if(++ee,e.listenerCount(`file`)===0){i.parser._ignore();return}++N;let t=new _(C);P=t,t.on(`end`,function(){if(--N,i._pause=!1,w(),i._cb&&!i._needDrain){let e=i._cb;i._cb=void 0,e()}}),t._read=function(e){if(i._pause&&(i._pause=!1,i._cb&&!i._needDrain)){let e=i._cb;i._cb=void 0,e()}},e.emit(`file`,u,t,k,b,l),j=function(e){if((A+=e.length)>E){let n=E-A+e.length;n>0&&t.push(e.slice(0,n)),t.truncated=!0,t.bytesRead=E,a.removeAllListeners(`data`),t.emit(`limit`);return}else t.push(e)||(i._pause=!0);t.bytesRead=A},I=function(){P=void 0,t.push(null)}}else{if(M===O)return e.hitFieldsLimit||(e.hitFieldsLimit=!0,e.emit(`fieldsLimit`)),g(a);++M,++N;let t=``,n=!1;F=a,j=function(e){if((A+=e.length)>T){let r=T-(A-e.length);t+=e.toString(`binary`,0,r),n=!0,a.removeAllListeners(`data`)}else t+=e.toString(`binary`)},I=function(){F=void 0,t.length&&(t=s(t,`binary`,v)),e.emit(`field`,u,t,!1,n,b,l),--N,w()}}a._readableState.sync=!1,a.on(`data`,j),a.on(`end`,I)}).on(`error`,function(e){P&&P.emit(`error`,e)})}).on(`error`,function(t){e.emit(`error`,t)}).on(`finish`,function(){I=!0,w()})}h.prototype.write=function(e,t){let n=this.parser.write(e);n&&!this._pause?t():(this._needDrain=!n,this._cb=t)},h.prototype.end=function(){let e=this;e.parser.writable?e.parser.end():e._boy._done||process.nextTick(function(){e._boy._done=!0,e._boy.emit(`finish`)})};function g(e){e.resume()}function _(e){n.call(this,e),this.bytesRead=0,this.truncated=!1}i(_,n),_.prototype._read=function(e){},t.exports=h})),ce=e(((exports,t)=>{let n=/\+/g,r=[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,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,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,1,1,1,1,1,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];function i(){this.buffer=void 0}i.prototype.write=function(e){e=e.replace(n,` `);let t=``,i=0,a=0,o=e.length;for(;i<o;++i)this.buffer===void 0?e[i]===`%`&&(i>a&&(t+=e.substring(a,i),a=i),this.buffer=``,++a):r[e.charCodeAt(i)]?(this.buffer+=e[i],++a,this.buffer.length===2&&(t+=String.fromCharCode(parseInt(this.buffer,16)),this.buffer=void 0)):(t+=`%`+this.buffer,this.buffer=void 0,--i);return a<o&&this.buffer===void 0&&(t+=e.substring(a)),t},i.prototype.reset=function(){this.buffer=void 0},t.exports=i})),le=e(((exports,t)=>{let n=ce(),r=ie(),i=ne(),a=/^charset$/i;o.detect=/^application\/x-www-form-urlencoded/i;function o(e,t){let r=t.limits,o=t.parsedConType;this.boy=e,this.fieldSizeLimit=i(r,`fieldSize`,1*1024*1024),this.fieldNameSizeLimit=i(r,`fieldNameSize`,100),this.fieldsLimit=i(r,`fields`,1/0);let s;for(var c=0,l=o.length;c<l;++c)if(Array.isArray(o[c])&&a.test(o[c][0])){s=o[c][1].toLowerCase();break}s===void 0&&(s=t.defCharset||`utf8`),this.decoder=new n,this.charset=s,this._fields=0,this._state=`key`,this._checkingBytes=!0,this._bytesKey=0,this._bytesVal=0,this._key=``,this._val=``,this._keyTrunc=!1,this._valTrunc=!1,this._hitLimit=!1}o.prototype.write=function(e,t){if(this._fields===this.fieldsLimit)return this.boy.hitFieldsLimit||(this.boy.hitFieldsLimit=!0,this.boy.emit(`fieldsLimit`)),t();let n,i,a,o=0,s=e.length;for(;o<s;)if(this._state===`key`){for(n=i=void 0,a=o;a<s;++a){if(this._checkingBytes||++o,e[a]===61){n=a;break}else if(e[a]===38){i=a;break}if(this._checkingBytes&&this._bytesKey===this.fieldNameSizeLimit){this._hitLimit=!0;break}else this._checkingBytes&&++this._bytesKey}if(n!==void 0)n>o&&(this._key+=this.decoder.write(e.toString(`binary`,o,n))),this._state=`val`,this._hitLimit=!1,this._checkingBytes=!0,this._val=``,this._bytesVal=0,this._valTrunc=!1,this.decoder.reset(),o=n+1;else if(i!==void 0){++this._fields;let n,a=this._keyTrunc;if(n=i>o?this._key+=this.decoder.write(e.toString(`binary`,o,i)):this._key,this._hitLimit=!1,this._checkingBytes=!0,this._key=``,this._bytesKey=0,this._keyTrunc=!1,this.decoder.reset(),n.length&&this.boy.emit(`field`,r(n,`binary`,this.charset),``,a,!1),o=i+1,this._fields===this.fieldsLimit)return t()}else this._hitLimit?(a>o&&(this._key+=this.decoder.write(e.toString(`binary`,o,a))),o=a,(this._bytesKey=this._key.length)===this.fieldNameSizeLimit&&(this._checkingBytes=!1,this._keyTrunc=!0)):(o<s&&(this._key+=this.decoder.write(e.toString(`binary`,o))),o=s)}else{for(i=void 0,a=o;a<s;++a){if(this._checkingBytes||++o,e[a]===38){i=a;break}if(this._checkingBytes&&this._bytesVal===this.fieldSizeLimit){this._hitLimit=!0;break}else this._checkingBytes&&++this._bytesVal}if(i!==void 0){if(++this._fields,i>o&&(this._val+=this.decoder.write(e.toString(`binary`,o,i))),this.boy.emit(`field`,r(this._key,`binary`,this.charset),r(this._val,`binary`,this.charset),this._keyTrunc,this._valTrunc),this._state=`key`,this._hitLimit=!1,this._checkingBytes=!0,this._key=``,this._bytesKey=0,this._keyTrunc=!1,this.decoder.reset(),o=i+1,this._fields===this.fieldsLimit)return t()}else this._hitLimit?(a>o&&(this._val+=this.decoder.write(e.toString(`binary`,o,a))),o=a,(this._val===``&&this.fieldSizeLimit===0||(this._bytesVal=this._val.length)===this.fieldSizeLimit)&&(this._checkingBytes=!1,this._valTrunc=!0)):(o<s&&(this._val+=this.decoder.write(e.toString(`binary`,o))),o=s)}t()},o.prototype.end=function(){this.boy._done||(this._state===`key`&&this._key.length>0?this.boy.emit(`field`,r(this._key,`binary`,this.charset),``,this._keyTrunc,!1):this._state===`val`&&this.boy.emit(`field`,r(this._key,`binary`,this.charset),r(this._val,`binary`,this.charset),this._keyTrunc,this._valTrunc),this.boy._done=!0,this.boy.emit(`finish`))},t.exports=o})),ue=e(((exports,t)=>{let n=r(`node:stream`).Writable,{inherits:i}=r(`node:util`),a=L(),o=se(),s=le(),c=ae();function l(e){if(!(this instanceof l))return new l(e);if(typeof e!=`object`)throw TypeError(`Busboy expected an options-Object.`);if(typeof e.headers!=`object`)throw TypeError(`Busboy expected an options-Object with headers-attribute.`);if(typeof e.headers[`content-type`]!=`string`)throw TypeError(`Missing Content-Type-header.`);let{headers:t,...r}=e;this.opts={autoDestroy:!1,...r},n.call(this,this.opts),this._done=!1,this._parser=this.getParserByHeaders(t),this._finished=!1}i(l,n),l.prototype.emit=function(e){if(e===`finish`){if(this._done){if(this._finished)return}else{this._parser?.end();return}this._finished=!0}n.prototype.emit.apply(this,arguments)},l.prototype.getParserByHeaders=function(e){let t=c(e[`content-type`]),n={defCharset:this.opts.defCharset,fileHwm:this.opts.fileHwm,headers:e,highWaterMark:this.opts.highWaterMark,isPartAFile:this.opts.isPartAFile,limits:this.opts.limits,parsedConType:t,preservePath:this.opts.preservePath};if(o.detect.test(t[0]))return new o(this,n);if(s.detect.test(t[0]))return new s(this,n);throw Error(`Unsupported Content-Type.`)},l.prototype._write=function(e,t,n){this._parser.write(e,n)},t.exports=l,t.exports.default=l,t.exports.Busboy=l,t.exports.Dicer=a})),R=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fakePromise=void 0,exports.getHeadersObj=i,exports.defaultHeadersSerializer=a,exports.isArrayBufferView=s,exports.isNodeReadable=c,exports.isIterable=l,exports.shouldRedirect=u,exports.pipeThrough=d,exports.endStream=f,exports.safeWrite=p;let t=r(`node:events`);function n(e){return e?.forEach!=null}function i(e){return e==null||!n(e)?e:e.headersInit&&!e._map&&!n(e.headersInit)?e.headersInit:Object.fromEntries(e.entries())}function a(e,t){let n=[];return e.forEach((e,r)=>{t&&r===`content-length`&&t(e),n.push(`${r}: ${e}`)}),n}var o=F();Object.defineProperty(exports,`fakePromise`,{enumerable:!0,get:function(){return o.fakePromise}});function s(e){return e!=null&&e.buffer!=null&&e.byteLength!=null&&e.byteOffset!=null}function c(e){return e!=null&&e.pipe!=null}function l(e){return e?.[Symbol.iterator]!=null}function u(e){return e===301||e===302||e===303||e===307||e===308}function d({src:e,dest:t,signal:n,onError:r}){if(r&&t.once(`error`,r),e.once(`error`,e=>{t.destroy(e)}),t.once(`close`,()=>{e.destroyed||e.destroy()}),n){let t=new WeakRef(e),r=new WeakRef(n);function i(){r.deref()?.removeEventListener(`abort`,a),t.deref()?.removeListener(`end`,i),t.deref()?.removeListener(`error`,i),t.deref()?.removeListener(`close`,i)}function a(){t.deref()?.destroy(new m),i()}n.addEventListener(`abort`,a,{once:!0}),e.once(`end`,i),e.once(`error`,i),e.once(`close`,i)}e.pipe(t,{end:!0})}function f(e){return e.end(null,null,null)}function p(e,n){let r=n.write(e);if(!r)return(0,t.once)(n,`drain`)}var m=class extends Error{constructor(e=`The operation was aborted`,t=void 0){super(e,t),this.name=`AbortError`}}})),z=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillReadableStream=void 0;let t=r(`node:buffer`),n=r(`node:events`),i=r(`node:stream`),a=r(`node:stream/promises`),o=F(),s=R();function c(e,n){let r=[],i=!1,a=!1;return{desiredSize:e,enqueue(e){let i=typeof e==`string`?t.Buffer.from(e):e;a?n.push(i):r.push(i)},close(){r.length>0&&this._flush(),n.push(null),i=!0},error(e){r.length>0&&this._flush(),n.destroy(e)},get _closed(){return i},_flush(){if(a=!0,r.length>0){let e=r.length>1?t.Buffer.concat(r):r[0];n.push(e),r=[]}}}}function l(e){return e?.read!=null}function u(e){return e?.getReader!=null}var d=class e{readable;constructor(t){if(t instanceof e&&t.readable!=null)this.readable=t.readable;else if(l(t))this.readable=t;else if(u(t))this.readable=i.Readable.fromWeb(t);else{let e=!1,n=!1,r=n=>{if(!e){let r=c(n,this.readable);return e=!0,(0,o.handleMaybePromise)(()=>t?.start?.(r),()=>(r._flush(),!r._closed))}return!0},a=e=>(0,o.handleMaybePromise)(()=>r(e),r=>{if(!r)return;let i=c(e,this.readable);return(0,o.handleMaybePromise)(()=>t?.pull?.(i),()=>{i._flush(),n=!1})});this.readable=new i.Readable({read(e){if(!n)return n=!0,a(e)},destroy(e,n){if(t?.cancel)try{let r=t.cancel(e);if(r?.then)return r.then(()=>{n(null)},e=>{n(e)})}catch(e){n(e);return}n(null)}})}}cancel(e){return this.readable.destroy(e),(0,n.once)(this.readable,`close`)}locked=!1;getReader(e){let t=this.readable[Symbol.asyncIterator]();this.locked=!0;let r=this.readable;return{read(){return t.next()},releaseLock:()=>{if(t.return){let e=t.return();if(e.then){e.then(()=>{this.locked=!1});return}}this.locked=!1},cancel:e=>{if(t.return){let n=t.return(e);if(n.then)return n.then(()=>{this.locked=!1})}return this.locked=!1,(0,s.fakePromise)()},get closed(){return Promise.race([(0,n.once)(r,`end`),(0,n.once)(r,`error`).then(e=>Promise.reject(e))])}}}[Symbol.asyncIterator](){let e=this.readable[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return this},next:()=>e.next(),return:()=>(this.readable.destroyed||this.readable.destroy(),e.return?.()||(0,s.fakePromise)({done:!0,value:void 0})),throw:t=>(this.readable.destroyed||this.readable.destroy(t),e.throw?.(t)||(0,s.fakePromise)({done:!0,value:void 0}))}}tee(){throw Error(`Not implemented`)}async pipeToWriter(e){try{for await(let t of this)await e.write(t);await e.close()}catch(t){await e.abort(t)}}pipeTo(e){if(p(e))return(0,a.pipeline)(this.readable,e.writable,{end:!0});{let t=e.getWriter();return this.pipeToWriter(t)}}pipeThrough({writable:e,readable:t}){return this.pipeTo(e).catch(e=>{this.readable.destroy(e)}),f(t)&&(t.readable.once(`error`,e=>this.readable.destroy(e)),t.readable.once(`finish`,()=>this.readable.push(null)),t.readable.once(`close`,()=>this.readable.push(null))),t}static[Symbol.hasInstance](e){return u(e)}static from(t){return new e(i.Readable.from(t))}[Symbol.toStringTag]=`ReadableStream`};exports.PonyfillReadableStream=d;function f(e){return e?.readable!=null}function p(e){return e?.writable!=null}})),de=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillBlob=void 0,exports.hasBufferMethod=o,exports.hasArrayBufferMethod=s,exports.hasBytesMethod=c,exports.hasTextMethod=l,exports.hasSizeProperty=u,exports.hasStreamMethod=d,exports.hasBlobSignature=f,exports.isArrayBuffer=p;let t=r(`node:buffer`),n=z(),i=R();function a(e){return typeof e==`string`?t.Buffer.from(e):t.Buffer.isBuffer(e)?e:(0,i.isArrayBufferView)(e)?t.Buffer.from(e.buffer,e.byteOffset,e.byteLength):t.Buffer.from(e)}function o(e){return e!=null&&e.buffer!=null&&typeof e.buffer==`function`}function s(e){return e!=null&&e.arrayBuffer!=null&&typeof e.arrayBuffer==`function`}function c(e){return e!=null&&e.bytes!=null&&typeof e.bytes==`function`}function l(e){return e!=null&&e.text!=null&&typeof e.text==`function`}function u(e){return e!=null&&typeof e.size==`number`}function d(e){return e!=null&&e.stream!=null&&typeof e.stream==`function`}function f(e){return e!=null&&e[Symbol.toStringTag]===`Blob`}function p(e){return e!=null&&e.byteLength!=null&&e.slice!=null}var m=class{blobParts;type;encoding;_size=null;constructor(e=[],t){if(this.blobParts=e,this.type=t?.type||`application/octet-stream`,this.encoding=t?.encoding||`utf8`,this._size=t?.size||null,e.length===1&&f(e[0]))return e[0]}_buffer=null;buffer(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){let e=this.blobParts[0];return o(e)?e.buffer().then(e=>(this._buffer=e,this._buffer)):c(e)?e.bytes().then(e=>(this._buffer=t.Buffer.from(e),this._buffer)):s(e)?e.arrayBuffer().then(n=>(this._buffer=t.Buffer.from(n,void 0,e.size),this._buffer)):(this._buffer=a(e),(0,i.fakePromise)(this._buffer))}let e=[],n=this.blobParts.map((r,i)=>{if(o(r)){e.push(r.buffer().then(e=>{n[i]=e}));return}else if(s(r)){e.push(r.arrayBuffer().then(e=>{n[i]=t.Buffer.from(e,void 0,r.size)}));return}else if(c(r)){e.push(r.bytes().then(e=>{n[i]=t.Buffer.from(e)}));return}else return a(r)});return e.length>0?Promise.all(e).then(()=>t.Buffer.concat(n,this._size||void 0)):(0,i.fakePromise)(t.Buffer.concat(n,this._size||void 0))}arrayBuffer(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){if(p(this.blobParts[0]))return(0,i.fakePromise)(this.blobParts[0]);if(s(this.blobParts[0]))return this.blobParts[0].arrayBuffer()}return this.buffer()}bytes(){if(this._buffer)return(0,i.fakePromise)(this._buffer);if(this.blobParts.length===1){if(t.Buffer.isBuffer(this.blobParts[0]))return this._buffer=this.blobParts[0],(0,i.fakePromise)(this._buffer);if(this.blobParts[0]instanceof Uint8Array)return this._buffer=t.Buffer.from(this.blobParts[0]),(0,i.fakePromise)(this._buffer);if(c(this.blobParts[0]))return this.blobParts[0].bytes();if(o(this.blobParts[0]))return this.blobParts[0].buffer()}return this.buffer()}_text=null;text(){if(this._text)return(0,i.fakePromise)(this._text);if(this.blobParts.length===1){let e=this.blobParts[0];if(typeof e==`string`)return this._text=e,(0,i.fakePromise)(this._text);if(l(e))return e.text().then(e=>(this._text=e,this._text));let t=a(e);return this._text=t.toString(this.encoding),(0,i.fakePromise)(this._text)}return this.buffer().then(e=>(this._text=e.toString(this.encoding),this._text))}_json=null;json(){return this._json?(0,i.fakePromise)(this._json):this.text().then(e=>(this._json=JSON.parse(e),this._json))}_formData=null;formData(){if(this._formData)return(0,i.fakePromise)(this._formData);throw Error(`Not implemented`)}get size(){if(this._size==null){this._size=0;for(let e of this.blobParts)typeof e==`string`?this._size+=t.Buffer.byteLength(e):u(e)?this._size+=e.size:(0,i.isArrayBufferView)(e)&&(this._size+=e.byteLength)}return this._size}stream(){if(this.blobParts.length===1){let e=this.blobParts[0];if(d(e))return e.stream();let t=a(e);return new n.PonyfillReadableStream({start:e=>{e.enqueue(t),e.close()}})}if(this._buffer!=null)return new n.PonyfillReadableStream({start:e=>{e.enqueue(this._buffer),e.close()}});let e;return new n.PonyfillReadableStream({start:t=>{if(this.blobParts.length===0){t.close();return}e=this.blobParts[Symbol.iterator]()},pull:n=>{let{value:r,done:i}=e.next();if(i){n.close();return}if(r){if(o(r))return r.buffer().then(e=>{n.enqueue(e)});if(c(r))return r.bytes().then(e=>{let r=t.Buffer.from(e);n.enqueue(r)});if(s(r))return r.arrayBuffer().then(e=>{let i=t.Buffer.from(e,void 0,r.size);n.enqueue(i)});let e=a(r);n.enqueue(e)}}})}slice(){throw Error(`Not implemented`)}};exports.PonyfillBlob=m})),fe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillFile=void 0;let t=de();var n=class extends t.PonyfillBlob{name;lastModified;constructor(e,t,n){super(e,n),this.name=t,this.lastModified=n?.lastModified||Date.now()}webkitRelativePath=``};exports.PonyfillFile=n})),B={};n(B,{__addDisposableResource:()=>Ie,__assign:()=>Be,__asyncDelegator:()=>Oe,__asyncGenerator:()=>De,__asyncValues:()=>ke,__await:()=>W,__awaiter:()=>ye,__classPrivateFieldGet:()=>Ne,__classPrivateFieldIn:()=>Fe,__classPrivateFieldSet:()=>Pe,__createBinding:()=>Ve,__decorate:()=>H,__disposeResources:()=>Le,__esDecorate:()=>me,__exportStar:()=>xe,__extends:()=>pe,__generator:()=>be,__importDefault:()=>Me,__importStar:()=>je,__makeTemplateObject:()=>Ae,__metadata:()=>ve,__param:()=>U,__propKey:()=>ge,__read:()=>Ce,__rest:()=>V,__rewriteRelativeImportExtension:()=>Re,__runInitializers:()=>he,__setFunctionName:()=>_e,__spread:()=>we,__spreadArray:()=>Ee,__spreadArrays:()=>Te,__values:()=>Se,default:()=>Ge});function pe(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);ze(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function V(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function H(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function U(e,t){return function(n,r){t(n,r,e)}}function me(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else (d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function he(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function ge(e){return typeof e==`symbol`?e:`${e}`}function _e(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,`name`,{configurable:!0,value:n?`${n} ${t}`:t})}function ve(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ye(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function be(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function xe(e,t){for(var n in e)n!==`default`&&!Object.prototype.hasOwnProperty.call(t,n)&&Ve(t,e,n)}function Se(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Ce(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function we(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ce(arguments[t]));return e}function Te(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function Ee(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function De(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof W?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Oe(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:W(e[r](t)),done:!1}:i?i(t):t}:i}}function ke(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Se==`function`?Se(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Ae(e,t){return Object.defineProperty?Object.defineProperty(e,`raw`,{value:t}):e.raw=t,e}function je(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Ue(e),r=0;r<n.length;r++)n[r]!==`default`&&Ve(t,e,n[r]);return He(t,e),t}function Me(e){return e&&e.__esModule?e:{default:e}}function Ne(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Pe(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Fe(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Ie(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Le(e){function t(t){e.error=e.hasError?new We(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Re(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var ze,Be,Ve,He,Ue,We,Ge,Ke=t((()=>{ze=function(e,t){return ze=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ze(e,t)},Be=function(){return Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Be.apply(this,arguments)},Ve=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),He=Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t},Ue=function(e){return Ue=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Ue(e)},We=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Ge={__extends:pe,__assign:Be,__rest:V,__decorate:H,__param:U,__esDecorate:me,__runInitializers:he,__propKey:ge,__setFunctionName:_e,__metadata:ve,__awaiter:ye,__generator:be,__createBinding:Ve,__exportStar:xe,__values:Se,__read:Ce,__spread:we,__spreadArrays:Te,__spreadArray:Ee,__await:W,__asyncGenerator:De,__asyncDelegator:Oe,__asyncValues:ke,__makeTemplateObject:Ae,__importStar:je,__importDefault:Me,__classPrivateFieldGet:Ne,__classPrivateFieldSet:Pe,__classPrivateFieldIn:Fe,__addDisposableResource:Ie,__disposeResources:Le,__rewriteRelativeImportExtension:Re}})),qe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillSuppressedError=void 0;var t=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};exports.PonyfillSuppressedError=t})),Je=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.DisposableSymbols=void 0,exports.patchSymbols=t,exports.DisposableSymbols={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function t(){Symbol.dispose||=Symbol.for(`dispose`),Symbol.asyncDispose||=Symbol.for(`asyncDispose`)}})),Ye=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.isSyncDisposable=n,exports.isAsyncDisposable=r;let t=Je();function n(e){return e?.[t.DisposableSymbols.dispose]!=null}function r(e){return e?.[t.DisposableSymbols.asyncDispose]!=null}})),Xe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillAsyncDisposableStack=void 0;let t=F(),n=qe(),r=Je(),i=Ye(),a=globalThis.SuppressedError||n.PonyfillSuppressedError;var o=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return(0,i.isAsyncDisposable)(e)?this.callbacks.push(()=>e[r.DisposableSymbols.asyncDispose]()):(0,i.isSyncDisposable)(e)&&this.callbacks.push(()=>e[r.DisposableSymbols.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[r.DisposableSymbols.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return(0,t.handleMaybePromise)(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new a(e,this._error):e,this._iterateCallbacks()))}[r.DisposableSymbols.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};exports.PonyfillAsyncDisposableStack=o})),Ze=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillDisposableStack=void 0;let t=qe(),n=Je(),r=Ye(),i=globalThis.SuppressedError||t.PonyfillSuppressedError;var a=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return(0,r.isSyncDisposable)(e)&&this.callbacks.push(()=>e[n.DisposableSymbols.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}dispose(){return this[n.DisposableSymbols.dispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e){try{e()}catch(e){this._error=this._error?new i(e,this._error):e}return this._iterateCallbacks()}}[n.DisposableSymbols.dispose](){if(this._iterateCallbacks(),this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`DisposableStack`};exports.PonyfillDisposableStack=a})),Qe=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.SuppressedError=exports.AsyncDisposableStack=exports.DisposableStack=void 0;let t=(Ke(),i(B)),n=Xe(),r=Ze(),a=qe();exports.DisposableStack=globalThis.DisposableStack||r.PonyfillDisposableStack,exports.AsyncDisposableStack=globalThis.AsyncDisposableStack||n.PonyfillAsyncDisposableStack,exports.SuppressedError=globalThis.SuppressedError||a.PonyfillSuppressedError,t.__exportStar(Je(),exports)})),$e=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillIteratorObject=void 0;let t=r(`node:util`),n=Qe(),i=R();var a=class{iterableIterator;[Symbol.toStringTag]=`IteratorObject`;constructor(e,t){this.iterableIterator=e,this[Symbol.toStringTag]=t}*map(e){let t=0;for(let n of this.iterableIterator)yield e(n,t++)}*filter(e){let t=0;for(let n of this.iterableIterator)e(n,t++)&&(yield n)}reduce(e,t){let n=0,r=t;for(let t of this.iterableIterator)r=e(r,t,n++);return r}forEach(e){let t=0;for(let n of this.iterableIterator)e(n,t++)}*take(e){let t=0;for(let n of this.iterableIterator){if(t>=e)break;yield n,t++}}*drop(e){let t=0;for(let n of this.iterableIterator)t>=e&&(yield n),t++}*flatMap(e){let t=0;for(let n of this.iterableIterator){let r=e(n,t++);if((0,i.isIterable)(r))for(let e of r)yield e;else for(let e of{[Symbol.iterator]:()=>r})yield e}}some(e){let t=0;for(let n of this.iterableIterator)if(e(n,t++))return!0;return!1}every(e){let t=0;for(let n of this.iterableIterator)if(!e(n,t++))return!1;return!0}find(e){let t=0;for(let n of this.iterableIterator)if(e(n,t++))return n}toArray(){return Array.from(this.iterableIterator)}[n.DisposableSymbols.dispose](){this.iterableIterator.return?.()}next(...[e]){return this.iterableIterator.next(e)}[Symbol.iterator](){return this}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};return this.forEach((n,r)=>{let i=(0,t.inspect)(n);e[r]=i.includes(`,`)?i.split(`,`).map(e=>e.trim()):i}),`${this[Symbol.toStringTag]} ${(0,t.inspect)(e)}`}};exports.PonyfillIteratorObject=a})),et=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillFormData=void 0,exports.getStreamFromFormData=o;let t=r(`node:buffer`),n=$e(),i=z();var a=class{map=new Map;append(e,t,n){let r=this.map.get(e);r||(r=[],this.map.set(e,r));let i=c(t)?s(e,t,n):t;r.push(i)}delete(e){this.map.delete(e)}get(e){let t=this.map.get(e);return t?t[0]:null}getAll(e){return this.map.get(e)||[]}has(e){return this.map.has(e)}set(e,t,n){let r=c(t)?s(e,t,n):t;this.map.set(e,[r])}[Symbol.iterator](){return this._entries()}*_entries(){for(let[e,t]of this.map)for(let n of t)yield[e,n]}entries(){return new n.PonyfillIteratorObject(this._entries(),`FormDataIterator`)}_keys(){return this.map.keys()}keys(){return new n.PonyfillIteratorObject(this._keys(),`FormDataIterator`)}*_values(){for(let e of this.map.values())for(let t of e)yield t}values(){return new n.PonyfillIteratorObject(this._values(),`FormDataIterator`)}forEach(e){for(let[t,n]of this)e(n,t,this)}};exports.PonyfillFormData=a;function o(e,n=`---`){let r,a=!1,o,s=!1;function c(e){let{done:i,value:a}=r.next();if(i)return e.enqueue(t.Buffer.from(`\r\n--${n}--\r\n`)),e.close();if(s&&e.enqueue(t.Buffer.from(`\r\n--${n}\r\n`)),a){let[n,r]=a;if(typeof r==`string`)e.enqueue(t.Buffer.from(`Content-Disposition: form-data; name="${n}"\r\n\r\n`)),e.enqueue(t.Buffer.from(r));else{let i=``;r.name&&(i=`; filename="${r.name}"`),e.enqueue(t.Buffer.from(`Content-Disposition: form-data; name="${n}"${i}\r\n`)),e.enqueue(t.Buffer.from(`Content-Type: ${r.type||`application/octet-stream`}\r\n\r\n`));let a=r.stream();o=a[Symbol.asyncIterator]()}s=!0}}return new i.PonyfillReadableStream({start:()=>{r=e.entries()},pull:e=>a?o?o.next().then(({done:t,value:n})=>(t&&(o=void 0),n?e.enqueue(n):c(e))):c(e):(a=!0,e.enqueue(t.Buffer.from(`--${n}\r\n`))),cancel:e=>{r?.return?.(e),o?.return?.(e)}})}function s(e,t,n){return Object.defineProperty(t,`name`,{configurable:!0,enumerable:!0,value:n||t.name||e}),t}function c(e){return e?.arrayBuffer!=null}})),tt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillBody=void 0;let t=r(`node:buffer`),n=r(`node:stream`),i=ue(),a=F(),o=de(),s=fe(),c=et(),l=z(),u=R();var d;(function(e){e.ReadableStream=`ReadableStream`,e.Blob=`Blob`,e.FormData=`FormData`,e.String=`String`,e.Readable=`Readable`,e.Buffer=`Buffer`,e.AsyncIterable=`AsyncIterable`})(d||={});var f=class{bodyInit;options;bodyUsed=!1;contentType=null;contentLength=null;constructor(e,t={}){this.bodyInit=e,this.options=t;let{bodyFactory:n,contentType:r,contentLength:i,bodyType:a,buffer:o}=p(e);this._bodyFactory=n,this.contentType=r,this.contentLength=i,this.bodyType=a,this._buffer=o,this._signal=t.signal}bodyType;_bodyFactory=()=>null;_generatedBody=null;_buffer;_signal;generateBody(){if(this._generatedBody?.readable?.destroyed&&this._buffer&&(this._generatedBody.readable=n.Readable.from(this._buffer)),this._generatedBody)return this._generatedBody;let e=this._bodyFactory();return this._generatedBody=e,e}handleContentLengthHeader(e=!1){let t=this.headers.get(`content-type`);t?this.contentType=t:this.contentType&&this.headers.set(`content-type`,this.contentType);let n=this.headers.get(`content-length`);e&&this.bodyInit==null&&!n&&(this.contentLength=0,this.headers.set(`content-length`,`0`)),n?this.contentLength=parseInt(n,10):this.contentLength&&this.headers.set(`content-length`,this.contentLength.toString())}get body(){let e=this.generateBody();if(e!=null){let t=e,n=e.readable;return new Proxy(e.readable,{get(e,r){if(r in t){let e=t[r];return typeof e==`function`?e.bind(t):e}if(r in n){let e=n[r];return typeof e==`function`?e.bind(n):e}}})}return null}_chunks=null;_doCollectChunksFromReadableJob(){if(this.bodyType===d.AsyncIterable){if(Array.fromAsync)return(0,a.handleMaybePromise)(()=>Array.fromAsync(this.bodyInit),e=>(this._chunks=e,this._chunks));let e=this.bodyInit[Symbol.asyncIterator](),t=[],n=()=>(0,a.handleMaybePromise)(()=>e.next(),({value:e,done:r})=>(e&&t.push(e),r?(this._chunks=t,this._chunks):n()));return n()}let e=this.generateBody();if(!e)return this._chunks=[],(0,u.fakePromise)(this._chunks);if(e.readable.destroyed)return(0,u.fakePromise)(this._chunks=[]);let t=[];return new Promise((n,r)=>{e.readable.on(`data`,e=>{t.push(e)}),e.readable.once(`error`,r),e.readable.once(`end`,()=>{n(this._chunks=t)})})}_collectChunksFromReadable(){return this._chunks?(0,u.fakePromise)(this._chunks):(this._chunks||=this._doCollectChunksFromReadableJob(),this._chunks)}_blob=null;blob(){return this._blob?(0,u.fakePromise)(this._blob):(this.bodyType===d.String&&(this._text=this.bodyInit,this._blob=new o.PonyfillBlob([this._text],{type:this.contentType||`text/plain;charset=UTF-8`,size:this.contentLength})),this.bodyType===d.Blob?(this._blob=this.bodyInit,(0,u.fakePromise)(this._blob)):this._buffer?(this._blob=new o.PonyfillBlob([this._buffer],{type:this.contentType||``,size:this.contentLength}),(0,u.fakePromise)(this._blob)):(0,u.fakePromise)((0,a.handleMaybePromise)(()=>this._collectChunksFromReadable(),e=>(this._blob=new o.PonyfillBlob(e,{type:this.contentType||``,size:this.contentLength}),this._blob))))}_formData=null;formData(e){if(this._formData)return(0,u.fakePromise)(this._formData);if(this.bodyType===d.FormData)return this._formData=this.bodyInit,(0,u.fakePromise)(this._formData);this._formData=new c.PonyfillFormData;let t=this.generateBody();if(t==null)return(0,u.fakePromise)(this._formData);let r={...this.options.formDataLimits,...e?.formDataLimits};return new Promise((e,t)=>{let a=this.body?.readable;if(!a)return t(Error(`No stream available`));let o=null,c=new i.Busboy({headers:{"content-length":typeof this.contentLength==`number`?this.contentLength.toString():this.contentLength||``,"content-type":this.contentType||``},limits:r,defCharset:`utf-8`});this._signal&&(0,n.addAbortSignal)(this._signal,c);let l=!1,u=n=>{l||(l=!0,a.unpipe(c),c.destroy(),o&&=(o.destroy(),null),n?t(n):e(this._formData))};a.on(`error`,u),c.on(`field`,(e,t,n,i)=>{if(n)return u(Error(`Field name size exceeded: ${r?.fieldNameSize} bytes`));if(i)return u(Error(`Field value size exceeded: ${r?.fieldSize} bytes`));this._formData.set(e,t)}),c.on(`file`,(e,t,n,i,a)=>{o=t;let c=[];t.on(`data`,e=>{c.push(e)}),t.on(`error`,u),t.on(`limit`,()=>{u(Error(`File size limit exceeded: ${r?.fileSize} bytes`))}),t.on(`close`,()=>{t.truncated&&u(Error(`File size limit exceeded: ${r?.fileSize} bytes`)),o=null;let i=new s.PonyfillFile(c,n,{type:a});this._formData.set(e,i)})}),c.on(`fieldsLimit`,()=>{u(Error(`Fields limit exceeded: ${r?.fields}`))}),c.on(`filesLimit`,()=>{u(Error(`Files limit exceeded: ${r?.files}`))}),c.on(`partsLimit`,()=>{u(Error(`Parts limit exceeded: ${r?.parts}`))}),c.on(`end`,u),c.on(`finish`,u),c.on(`close`,u),c.on(`error`,u),a.pipe(c)})}buffer(){if(this._buffer)return(0,u.fakePromise)(this._buffer);if(this._text)return this._buffer=t.Buffer.from(this._text,`utf-8`),(0,u.fakePromise)(this._buffer);if(this.bodyType===d.String)return this.text().then(e=>(this._text=e,this._buffer=t.Buffer.from(e,`utf-8`),this._buffer));if(this.bodyType===d.Blob){if((0,o.hasBufferMethod)(this.bodyInit))return this.bodyInit.buffer().then(e=>(this._buffer=e,this._buffer));if((0,o.hasBytesMethod)(this.bodyInit))return this.bodyInit.bytes().then(e=>(this._buffer=t.Buffer.from(e),this._buffer));if((0,o.hasArrayBufferMethod)(this.bodyInit))return this.bodyInit.arrayBuffer().then(e=>(this._buffer=t.Buffer.from(e,void 0,e.byteLength),this._buffer))}return(0,u.fakePromise)((0,a.handleMaybePromise)(()=>this._collectChunksFromReadable(),e=>e.length===1?(this._buffer=e[0],this._buffer):(this._buffer=t.Buffer.concat(e),this._buffer)))}bytes(){return this.buffer()}arrayBuffer(){return this.buffer()}_json=null;json(){return this._json?(0,u.fakePromise)(this._json):this.text().then(e=>{try{this._json=JSON.parse(e)}catch(t){throw t instanceof SyntaxError&&(t.message+=`, "${e}" is not valid JSON`),t}return this._json})}_text=null;text(){return this._text?(0,u.fakePromise)(this._text):this.bodyType===d.String?(this._text=this.bodyInit,(0,u.fakePromise)(this._text)):this.buffer().then(e=>(this._text=e.toString(`utf-8`),this._text))}};exports.PonyfillBody=f;function p(e){if(e==null)return{bodyFactory:()=>null,contentType:null,contentLength:null};if(typeof e==`string`){let r=t.Buffer.byteLength(e);return{bodyType:d.String,contentType:`text/plain;charset=UTF-8`,contentLength:r,bodyFactory(){let r=n.Readable.from(t.Buffer.from(e,`utf-8`));return new l.PonyfillReadableStream(r)}}}if(t.Buffer.isBuffer(e)){let t=e;return{bodyType:d.Buffer,contentType:null,contentLength:e.length,buffer:e,bodyFactory(){let e=n.Readable.from(t),r=new l.PonyfillReadableStream(e);return r}}}if((0,u.isArrayBufferView)(e)){let r=t.Buffer.from(e.buffer,e.byteOffset,e.byteLength);return{bodyType:d.Buffer,contentLength:e.byteLength,contentType:null,buffer:r,bodyFactory(){let e=n.Readable.from(r),t=new l.PonyfillReadableStream(e);return t}}}if(e instanceof l.PonyfillReadableStream&&e.readable!=null){let t=e;return{bodyType:d.ReadableStream,bodyFactory:()=>t,contentType:null,contentLength:null}}if(h(e)){let t=e;return{bodyType:d.Blob,contentType:e.type,contentLength:e.size,bodyFactory(){return t.stream()}}}if(e instanceof ArrayBuffer){let r=e.byteLength,i=t.Buffer.from(e,void 0,e.byteLength);return{bodyType:d.Buffer,contentType:null,contentLength:r,buffer:i,bodyFactory(){let e=n.Readable.from(i),t=new l.PonyfillReadableStream(e);return t}}}if(e instanceof n.Readable)return{bodyType:d.Readable,contentType:null,contentLength:null,bodyFactory(){let t=new l.PonyfillReadableStream(e);return t}};if(g(e))return{bodyType:d.String,contentType:`application/x-www-form-urlencoded;charset=UTF-8`,contentLength:null,bodyFactory(){let t=new l.PonyfillReadableStream(n.Readable.from(e.toString()));return t}};if(m(e)){let t=Math.random().toString(36).substr(2),n=`multipart/form-data; boundary=${t}`;return{bodyType:d.FormData,contentType:n,contentLength:null,bodyFactory(){return(0,c.getStreamFromFormData)(e,t)}}}if(_(e))return{contentType:null,contentLength:null,bodyFactory(){return new l.PonyfillReadableStream(e)}};if(e[Symbol.iterator]||e[Symbol.asyncIterator])return{contentType:null,contentLength:null,bodyType:d.AsyncIterable,bodyFactory(){let t=n.Readable.from(e);return new l.PonyfillReadableStream(t)}};throw Error(`Unknown body type`)}function m(e){return e?.forEach!=null}function h(e){return e?.stream!=null&&typeof e.stream==`function`}function g(e){return e?.sort!=null}function _(e){return e?.getReader!=null}})),nt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillHeaders=void 0,exports.isHeadersLike=i;let t=r(`node:util`),n=$e();function i(e){return e?.get&&e?.forEach}var a=class{headersInit;_map;objectNormalizedKeysOfHeadersInit=[];objectOriginalKeysOfHeadersInit=[];_setCookies;constructor(e){this.headersInit=e}_get(e){let t=e.toLowerCase();if(t===`set-cookie`&&this._setCookies?.length)return this._setCookies.join(`, `);if(this._map)return this._map.get(t)||null;if(this.headersInit==null)return null;if(Array.isArray(this.headersInit)){let e=this.headersInit.filter(([e])=>e.toLowerCase()===t);return e.length===0?null:e.length===1?e[0][1]:e.map(([,e])=>e).join(`, `)}else if(i(this.headersInit))return this.headersInit.get(t);else{let n=this.headersInit[e]||this.headersInit[t];if(n!=null)return n;this.objectNormalizedKeysOfHeadersInit.length||Object.keys(this.headersInit).forEach(e=>{this.objectOriginalKeysOfHeadersInit.push(e),this.objectNormalizedKeysOfHeadersInit.push(e.toLowerCase())});let r=this.objectNormalizedKeysOfHeadersInit.indexOf(t);if(r===-1)return null;let i=this.objectOriginalKeysOfHeadersInit[r];return this.headersInit[i]}}getMap(){if(!this._map)if(this._setCookies||=[],this.headersInit!=null)if(Array.isArray(this.headersInit)){this._map=new Map;for(let[e,t]of this.headersInit){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies.push(t);continue}this._map.set(n,t)}}else if(i(this.headersInit))this._map=new Map,this.headersInit.forEach((e,t)=>{if(t===`set-cookie`){this._setCookies||=[],this._setCookies.push(e);return}this._map.set(t,e)});else for(let e in this._map=new Map,this.headersInit){let t=this.headersInit[e];if(t!=null){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies||=[],this._setCookies.push(t);continue}this._map.set(n,t)}}else this._map=new Map;return this._map}append(e,t){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies||=[],this._setCookies.push(t);return}let r=this.getMap().get(n),i=r?`${r}, ${t}`:t;this.getMap().set(n,i)}get(e){let t=this._get(e);return t==null?null:t.toString()}has(e){let t=e.toLowerCase();return t===`set-cookie`?!!this._setCookies?.length:!!this._get(e)}set(e,t){let n=e.toLowerCase();if(n===`set-cookie`){this._setCookies=[t];return}if(!this._map&&this.headersInit!=null)if(Array.isArray(this.headersInit)){let e=this.headersInit.find(([e])=>e.toLowerCase()===n);e?e[1]=t:this.headersInit.push([n,t]);return}else if(i(this.headersInit)){this.headersInit.set(n,t);return}else{this.headersInit[n]=t;return}this.getMap().set(n,t)}delete(e){let t=e.toLowerCase();if(t===`set-cookie`){this._setCookies=[];return}this.getMap().delete(t)}forEach(e){if(this._setCookies?.forEach(t=>{e(t,`set-cookie`,this)}),!this._map){if(this.headersInit){if(Array.isArray(this.headersInit)){this.headersInit.forEach(([t,n])=>{e(n,t,this)});return}if(i(this.headersInit)){this.headersInit.forEach(e);return}Object.entries(this.headersInit).forEach(([t,n])=>{n!=null&&e(n,t,this)})}return}this.getMap().forEach((t,n)=>{e(t,n,this)})}*_keys(){if(this._setCookies?.length&&(yield`set-cookie`),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit.map(([e])=>e)[Symbol.iterator]();return}if(i(this.headersInit)){yield*this.headersInit.keys();return}yield*Object.keys(this.headersInit)[Symbol.iterator]();return}yield*this.getMap().keys()}keys(){return new n.PonyfillIteratorObject(this._keys(),`HeadersIterator`)}*_values(){if(this._setCookies?.length&&(yield*this._setCookies),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit.map(([,e])=>e)[Symbol.iterator]();return}if(i(this.headersInit)){yield*this.headersInit.values();return}yield*Object.values(this.headersInit)[Symbol.iterator]();return}yield*this.getMap().values()}values(){return new n.PonyfillIteratorObject(this._values(),`HeadersIterator`)}*_entries(){if(this._setCookies?.length&&(yield*this._setCookies.map(e=>[`set-cookie`,e])),!this._map&&this.headersInit){if(Array.isArray(this.headersInit)){yield*this.headersInit;return}if(i(this.headersInit)){yield*this.headersInit.entries();return}yield*Object.entries(this.headersInit);return}yield*this.getMap().entries()}entries(){return new n.PonyfillIteratorObject(this._entries(),`HeadersIterator`)}getSetCookie(){return this._setCookies||this.getMap(),this._setCookies}[Symbol.iterator](){return this.entries()}[Symbol.for(`nodejs.util.inspect.custom`)](){let e={};return this.forEach((t,n)=>{n===`set-cookie`?e[`set-cookie`]=this._setCookies||[]:e[n]=t?.includes(`,`)?t.split(`,`).map(e=>e.trim()):t}),`Headers ${(0,t.inspect)(e)}`}};exports.PonyfillHeaders=a})),rt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillResponse=void 0;let t=r(`node:http`),n=tt(),i=nt(),a=`application/json; charset=utf-8`;var o=class e extends n.PonyfillBody{headers;constructor(e,n){super(e||null,n),this.headers=n?.headers&&(0,i.isHeadersLike)(n.headers)?n.headers:new i.PonyfillHeaders(n?.headers),this.status=n?.status||200,this.statusText=n?.statusText||t.STATUS_CODES[this.status]||`OK`,this.url=n?.url||``,this.redirected=n?.redirected||!1,this.type=n?.type||`default`,this.handleContentLengthHeader()}get ok(){return this.status>=200&&this.status<300}status;statusText;url;redirected;type;clone(){return this}static error(){return new e(null,{status:500,statusText:`Internal Server Error`})}static redirect(t,n=302){if(n<300||n>399)throw RangeError(`Invalid status code`);return new e(null,{headers:{location:t},status:n})}static json(t,n){let r=JSON.stringify(t);if(!n)n={headers:{"content-type":a,"content-length":Buffer.byteLength(r).toString()}};else if(!n.headers)n.headers={"content-type":a,"content-length":Buffer.byteLength(r).toString()};else if((0,i.isHeadersLike)(n.headers))n.headers.has(`content-type`)||n.headers.set(`content-type`,a),n.headers.has(`content-length`)||n.headers.set(`content-length`,Buffer.byteLength(r).toString());else if(Array.isArray(n.headers)){let e=!1,t=!1;for(let[r]of n.headers){if(t&&e)break;!e&&r.toLowerCase()===`content-type`?e=!0:!t&&r.toLowerCase()===`content-length`&&(t=!0)}e||n.headers.push([`content-type`,a]),t||n.headers.push([`content-length`,Buffer.byteLength(r).toString()])}else typeof n.headers==`object`&&(n.headers?.[`content-type`]??(n.headers[`content-type`]=a),n.headers?.[`content-length`]??(n.headers[`content-length`]=Buffer.byteLength(r).toString()));return new e(r,n)}[Symbol.toStringTag]=`Response`};exports.PonyfillResponse=o})),it=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchCurl=s;let t=r(`node:stream`),n=r(`node:tls`),i=F(),a=rt(),o=R();function s(e){let{Curl:r,CurlFeature:s,CurlPause:c,CurlProgressFunc:l}=globalThis.libcurl,u=new r;u.enable(s.NoDataParsing),u.setOpt(`URL`,e.url),process.env.NODE_TLS_REJECT_UNAUTHORIZED===`0`&&u.setOpt(`SSL_VERIFYPEER`,!1),process.env.NODE_EXTRA_CA_CERTS?u.setOpt(`CAINFO`,process.env.NODE_EXTRA_CA_CERTS):u.setOpt(`CAINFO_BLOB`,n.rootCertificates.join(`
8
+ `)),u.enable(s.StreamResponse);let d;if(e._signal===null?d=void 0:e._signal&&(d=e._signal),u.setStreamProgressCallback(function(){return d?.aborted?process.env.DEBUG?l.Continue:1:0}),e.bodyType===`String`)u.setOpt(`POSTFIELDS`,e.bodyInit);else{let n=e.body==null?null:(0,o.isNodeReadable)(e.body)?e.body:t.Readable.from(e.body);n&&(u.setOpt(`UPLOAD`,!0),u.setUploadStream(n))}process.env.DEBUG&&u.setOpt(`VERBOSE`,!0),u.setOpt(`TRANSFER_ENCODING`,!1),u.setOpt(`HTTP_TRANSFER_DECODING`,!0),u.setOpt(`FOLLOWLOCATION`,e.redirect===`follow`),u.setOpt(`MAXREDIRS`,20),u.setOpt(`ACCEPT_ENCODING`,``),u.setOpt(`CUSTOMREQUEST`,e.method);let f=e.headersSerializer||o.defaultHeadersSerializer,p,m=f(e.headers,e=>{p=Number(e)});p!=null&&u.setOpt(`INFILESIZE`,p),u.setOpt(`HTTPHEADER`,m),u.enable(s.NoHeaderParsing);let h=(0,i.createDeferredPromise)(),g;function _(){if(u.isOpen)try{u.pause(c.Recv)}catch(e){h.reject(e)}}return d?.addEventListener(`abort`,_,{once:!0}),u.once(`end`,function(){try{u.close()}catch(e){h.reject(e)}d?.removeEventListener(`abort`,_)}),u.once(`error`,function(e){g&&!g.closed&&!g.destroyed?g.destroy(e):(e.message===`Operation was aborted by an application callback`&&(e.message=`The operation was aborted.`),h.reject(e));try{u.close()}catch(e){h.reject(e)}}),u.once(`stream`,function(n,i,s){let c=n.pipe(new t.PassThrough,{end:!0}),l=s.toString(`utf8`).split(/\r?\n|\r/g).filter(t=>t&&!t.startsWith(`HTTP/`)?(e.redirect===`error`&&t.toLowerCase().includes(`location`)&&(0,o.shouldRedirect)(i)&&(n.destroyed||n.resume(),c.destroy(),h.reject(Error(`redirect is not allowed`))),!0):!1),d=l.map(e=>e.split(/:\s(.+)/).slice(0,2)),f=new a.PonyfillResponse(c,{status:i,headers:d,url:u.getInfo(r.info.REDIRECT_URL)?.toString()||e.url,redirected:Number(u.getInfo(r.info.REDIRECT_COUNT))>0});h.resolve(f),g=c}),setImmediate(()=>{u.perform()}),h.promise}})),at=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillURL=void 0;let t=(Ke(),i(B)),n=t.__importDefault(r(`node:buffer`)),a=r(`node:crypto`),o=globalThis.URL;var s=class extends o{static blobRegistry=new Map;static createObjectURL(e){let t=`blob:whatwgnode:${(0,a.randomUUID)()}`;return this.blobRegistry.set(t,e),t}static revokeObjectURL(e){this.blobRegistry.has(e)?this.blobRegistry.delete(e):o.revokeObjectURL(e)}static getBlobFromURL(e){return this.blobRegistry.get(e)||n.default?.resolveObjectURL?.(e)}};exports.PonyfillURL=s})),ot=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillRequest=void 0;let t=r(`node:http`),n=r(`node:https`),i=tt(),a=nt(),o=at();function s(e){return e[Symbol.toStringTag]===`Request`}function c(e){return e?.href!=null}var l=class extends i.PonyfillBody{constructor(e,r){let i,o,l=null,u;if(typeof e==`string`?i=e:c(e)?o=e:s(e)&&(e._parsedUrl?o=e._parsedUrl:i=e._url?e._url:e.url,l=e.body,u=e),r!=null&&(l=r.body||null,u=r),super(l,u),this._url=i,this._parsedUrl=o,this.cache=u?.cache||`default`,this.credentials=u?.credentials||`same-origin`,this.headers=u?.headers&&(0,a.isHeadersLike)(u.headers)?u.headers:new a.PonyfillHeaders(u?.headers),this.integrity=u?.integrity||``,this.keepalive=u?.keepalive==null?!1:u?.keepalive,this.method=u?.method?.toUpperCase()||`GET`,this.mode=u?.mode||`cors`,this.redirect=u?.redirect||`follow`,this.referrer=u?.referrer||`about:client`,this.referrerPolicy=u?.referrerPolicy||`no-referrer`,this.headersSerializer=u?.headersSerializer,this.duplex=u?.duplex||`half`,this.destination=`document`,this.priority=`auto`,this.method!==`GET`&&this.method!==`HEAD`&&this.handleContentLengthHeader(!0),u?.agent!=null){let e=o?.protocol||i||this.url;u.agent===!1?this.agent=!1:(e.startsWith(`http:`)&&u.agent instanceof t.Agent||e.startsWith(`https:`)&&u.agent instanceof n.Agent)&&(this.agent=u.agent)}}headersSerializer;cache;credentials;destination;headers;integrity;keepalive;method;mode;priority;redirect;referrer;referrerPolicy;_url;get signal(){return this._signal||=new AbortController().signal,this._signal}get url(){if(this._url==null)if(this._parsedUrl)this._url=this._parsedUrl.toString();else throw TypeError(`Invalid URL`);return this._url}_parsedUrl;get parsedUrl(){if(this._parsedUrl==null)if(this._url!=null)this._parsedUrl=new o.PonyfillURL(this._url,`http://localhost`);else throw TypeError(`Invalid URL`);return this._parsedUrl}duplex;agent;clone(){return this}[Symbol.toStringTag]=`Request`};exports.PonyfillRequest=l})),st=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchNodeHttp=f;let t=r(`node:http`),n=r(`node:https`),i=r(`node:stream`),a=r(`node:zlib`),o=F(),s=ot(),c=rt(),l=at(),u=R();function d(e){if(e.startsWith(`http:`))return t.request;if(e.startsWith(`https:`))return n.request;throw Error(`Unsupported protocol: ${e.split(`:`)[0]||e}`)}function f(e){return new Promise((n,r)=>{try{let p=d(e.parsedUrl?.protocol||e.url),m=e.headersSerializer||u.getHeadersObj,h=m(e.headers);h[`accept-encoding`]??=`gzip, deflate, br`;let g;e._signal==null?g=void 0:e._signal&&(g=e._signal);let _;if(_=e.parsedUrl?p(e.parsedUrl,{method:e.method,headers:h,signal:g,agent:e.agent}):p(e.url,{method:e.method,headers:h,signal:g,agent:e.agent}),_.once(`error`,r),_.once(`response`,o=>{let d,p=o.headers[`content-encoding`];switch(p){case`x-gzip`:case`gzip`:d=(0,a.createGunzip)();break;case`x-deflate`:case`deflate`:d=(0,a.createInflate)();break;case`x-deflate-raw`:case`deflate-raw`:d=(0,a.createInflateRaw)();break;case`br`:d=(0,a.createBrotliDecompress)();break}if(o.headers.location&&(0,u.shouldRedirect)(o.statusCode)){if(e.redirect===`error`){let e=Error(`Redirects are not allowed`);r(e),o.resume();return}if(e.redirect===`follow`){let t=new l.PonyfillURL(o.headers.location,e.parsedUrl||e.url),r=f(new s.PonyfillRequest(t,e));n(r.then(e=>(e.redirected=!0,e))),o.resume();return}}d||=new i.PassThrough,(0,u.pipeThrough)({src:o,dest:d,signal:g,onError:e=>{o.destroyed||o.destroy(e),d.destroyed||d.destroy(e),r(e)}});let m=o.statusCode||200,h=o.statusMessage||t.STATUS_CODES[m];h??=``;let _=new c.PonyfillResponse(d||o,{status:m,statusText:h,headers:o.headers,url:e.url,signal:g});n(_)}),e._buffer!=null)(0,o.handleMaybePromise)(()=>(0,u.safeWrite)(e._buffer,_),()=>(0,u.endStream)(_),r);else{let t=e.body==null?null:(0,u.isNodeReadable)(e.body)?e.body:i.Readable.from(e.body);t?t.pipe(_):(0,u.endStream)(_)}}catch(e){r(e)}})}})),ct=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.fetchPonyfill=h;let t=r(`node:buffer`),n=r(`node:fs`),i=r(`node:url`),a=it(),o=st(),s=ot(),c=rt(),l=at(),u=R();async function d(e){let t=(0,i.fileURLToPath)(e);try{await n.promises.access(t,n.promises.constants.R_OK);let e=await n.promises.stat(t,{bigint:!0}),r=(0,n.createReadStream)(t);return new c.PonyfillResponse(r,{status:200,statusText:`OK`,headers:{"content-type":`application/octet-stream`,"last-modified":e.mtime.toUTCString()}})}catch(e){if(e.code===`ENOENT`)return new c.PonyfillResponse(null,{status:404,statusText:`Not Found`});if(e.code===`EACCES`)return new c.PonyfillResponse(null,{status:403,statusText:`Forbidden`});throw e}}function f(e){let[n=`text/plain`,...r]=e.substring(5).split(`,`),i=decodeURIComponent(r.join(`,`));if(n.endsWith(`;base64`)){let e=t.Buffer.from(i,`base64url`),r=n.slice(0,-7);return new c.PonyfillResponse(e,{status:200,statusText:`OK`,headers:{"content-type":r}})}return new c.PonyfillResponse(i,{status:200,statusText:`OK`,headers:{"content-type":n}})}function p(e){let t=l.PonyfillURL.getBlobFromURL(e);if(!t)throw TypeError(`Invalid Blob URL`);return new c.PonyfillResponse(t,{status:200,headers:{"content-type":t.type,"content-length":t.size.toString()}})}function m(e){return e!=null&&e.href!=null}function h(e,t){if(typeof e==`string`||m(e)){let n=new s.PonyfillRequest(e,t);return h(n)}let n=e;if(n.url.startsWith(`data:`)){let e=f(n.url);return(0,u.fakePromise)(e)}if(n.url.startsWith(`file:`)){let e=d(n.url);return e}if(n.url.startsWith(`blob:`)){let e=p(n.url);return(0,u.fakePromise)(e)}return globalThis.libcurl&&!n.agent?(0,a.fetchCurl)(n):(0,o.fetchNodeHttp)(n)}})),lt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTextDecoder=exports.PonyfillTextEncoder=void 0,exports.PonyfillBtoa=o;let t=r(`node:buffer`),n=R();var i=class{encoding;constructor(e=`utf-8`){this.encoding=e}encode(e){return t.Buffer.from(e,this.encoding)}encodeInto(e,t){let n=this.encode(e),r=n.copy(t);return{read:r,written:r}}};exports.PonyfillTextEncoder=i;var a=class{encoding;fatal=!1;ignoreBOM=!1;constructor(e=`utf-8`,t){this.encoding=e,t&&(this.fatal=t.fatal||!1,this.ignoreBOM=t.ignoreBOM||!1)}decode(e){return t.Buffer.isBuffer(e)?e.toString(this.encoding):(0,n.isArrayBufferView)(e)?t.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString(this.encoding):t.Buffer.from(e).toString(this.encoding)}};exports.PonyfillTextDecoder=a;function o(e){return t.Buffer.from(e,`binary`).toString(`base64`)}})),ut=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillURLSearchParams=void 0,exports.PonyfillURLSearchParams=globalThis.URLSearchParams})),dt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillWritableStream=void 0;let t=r(`node:events`),n=r(`node:stream`),i=F(),a=R();var o=class{writable;constructor(e){if(e instanceof n.Writable)this.writable=e;else if(e){let t=new n.Writable({write(t,n,r){try{let n=e.write?.(t,i);n instanceof Promise?n.then(()=>{r()},e=>{r(e)}):r()}catch(e){r(e)}},final(t){let n=e.close?.();n instanceof Promise?n.then(()=>{t()},e=>{t(e)}):t()}});this.writable=t;let r=new AbortController,i={signal:r.signal,error(e){t.destroy(e)}};t.once(`error`,e=>r.abort(e)),t.once(`close`,()=>r.abort())}else this.writable=new n.Writable}getWriter(){let e=this.writable;return{get closed(){return(0,t.once)(e,`close`)},get desiredSize(){return e.writableLength},get ready(){return(0,t.once)(e,`drain`)},releaseLock(){},write(t){let n=(0,a.fakePromise)();return t==null?n:n.then(()=>(0,a.safeWrite)(t,e))},close(){return!e.errored&&e.closed?(0,a.fakePromise)():e.errored?(0,i.fakeRejectPromise)(e.errored):(0,a.fakePromise)().then(()=>(0,a.endStream)(e))},abort(n){return e.destroy(n),(0,t.once)(e,`close`)}}}close(){return!this.writable.errored&&this.writable.closed?(0,a.fakePromise)():this.writable.errored?(0,i.fakeRejectPromise)(this.writable.errored):(0,a.fakePromise)().then(()=>(0,a.endStream)(this.writable))}abort(e){return this.writable.destroy(e),(0,t.once)(this.writable,`close`)}locked=!1};exports.PonyfillWritableStream=o})),ft=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTransformStream=void 0;let t=r(`node:stream`),n=z(),i=R(),a=dt();var o=class{transform;writable;readable;constructor(e){if(e instanceof t.Transform)this.transform=e;else if(e){let n={enqueue(e){r.push(e)},error(e){r.destroy(e)},terminate(){(0,i.endStream)(r)},get desiredSize(){return r.writableLength}},r=new t.Transform({read(){},write(t,r,i){try{let r=e.transform?.(t,n);r instanceof Promise?r.then(()=>{i()},e=>{i(e)}):i()}catch(e){i(e)}},final(t){try{let r=e.flush?.(n);r instanceof Promise?r.then(()=>{t()},e=>{t(e)}):t()}catch(e){t(e)}}});this.transform=r}else this.transform=new t.Transform;this.writable=new a.PonyfillWritableStream(this.transform),this.readable=new n.PonyfillReadableStream(this.transform)}};exports.PonyfillTransformStream=o})),pt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillCompressionStream=void 0;let t=r(`node:zlib`),n=ft();var i=class extends n.PonyfillTransformStream{static supportedFormats=globalThis.process?.version?.startsWith(`v2`)?[`gzip`,`deflate`,`br`]:[`gzip`,`deflate`,`deflate-raw`,`br`];constructor(e){switch(e){case`x-gzip`:case`gzip`:super((0,t.createGzip)());break;case`x-deflate`:case`deflate`:super((0,t.createDeflate)());break;case`deflate-raw`:super((0,t.createDeflateRaw)());break;case`br`:super((0,t.createBrotliCompress)());break;default:throw Error(`Unsupported compression format: ${e}`)}}};exports.PonyfillCompressionStream=i})),mt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillDecompressionStream=void 0;let t=r(`node:zlib`),n=ft();var i=class extends n.PonyfillTransformStream{static supportedFormats=globalThis.process?.version?.startsWith(`v2`)?[`gzip`,`deflate`,`br`]:[`gzip`,`deflate`,`deflate-raw`,`br`];constructor(e){switch(e){case`x-gzip`:case`gzip`:super((0,t.createGunzip)());break;case`x-deflate`:case`deflate`:super((0,t.createInflate)());break;case`deflate-raw`:super((0,t.createInflateRaw)());break;case`br`:super((0,t.createBrotliDecompress)());break;default:throw TypeError(`Unsupported compression format: '${e}'`)}}};exports.PonyfillDecompressionStream=i})),ht=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.PonyfillTextEncoderStream=exports.PonyfillTextDecoderStream=void 0;let t=lt(),n=ft();var r=class extends n.PonyfillTransformStream{textDecoder;constructor(e,n){super({transform:(e,t)=>t.enqueue(this.textDecoder.decode(e,{stream:!0}))}),this.textDecoder=new t.PonyfillTextDecoder(e,n)}get encoding(){return this.textDecoder.encoding}get fatal(){return this.textDecoder.fatal}get ignoreBOM(){return this.textDecoder.ignoreBOM}};exports.PonyfillTextDecoderStream=r;var i=class extends n.PonyfillTransformStream{textEncoder;constructor(e){super({transform:(e,t)=>t.enqueue(this.textEncoder.encode(e))}),this.textEncoder=new t.PonyfillTextEncoder(e)}get encoding(){return this.textEncoder.encoding}encode(e){return this.textEncoder.encode(e)}};exports.PonyfillTextEncoderStream=i})),gt=e((exports=>{Object.defineProperty(exports,`__esModule`,{value:!0}),exports.TextEncoderStream=exports.TextDecoderStream=exports.IteratorObject=exports.DecompressionStream=exports.CompressionStream=exports.TransformStream=exports.WritableStream=exports.URLSearchParams=exports.URL=exports.btoa=exports.TextDecoder=exports.TextEncoder=exports.Blob=exports.FormData=exports.File=exports.ReadableStream=exports.Response=exports.Request=exports.Body=exports.Headers=exports.fetch=void 0;var t=ct();Object.defineProperty(exports,`fetch`,{enumerable:!0,get:function(){return t.fetchPonyfill}});var n=nt();Object.defineProperty(exports,`Headers`,{enumerable:!0,get:function(){return n.PonyfillHeaders}});var r=tt();Object.defineProperty(exports,`Body`,{enumerable:!0,get:function(){return r.PonyfillBody}});var i=ot();Object.defineProperty(exports,`Request`,{enumerable:!0,get:function(){return i.PonyfillRequest}});var a=rt();Object.defineProperty(exports,`Response`,{enumerable:!0,get:function(){return a.PonyfillResponse}});var o=z();Object.defineProperty(exports,`ReadableStream`,{enumerable:!0,get:function(){return o.PonyfillReadableStream}});var s=fe();Object.defineProperty(exports,`File`,{enumerable:!0,get:function(){return s.PonyfillFile}});var c=et();Object.defineProperty(exports,`FormData`,{enumerable:!0,get:function(){return c.PonyfillFormData}});var l=de();Object.defineProperty(exports,`Blob`,{enumerable:!0,get:function(){return l.PonyfillBlob}});var u=lt();Object.defineProperty(exports,`TextEncoder`,{enumerable:!0,get:function(){return u.PonyfillTextEncoder}}),Object.defineProperty(exports,`TextDecoder`,{enumerable:!0,get:function(){return u.PonyfillTextDecoder}}),Object.defineProperty(exports,`btoa`,{enumerable:!0,get:function(){return u.PonyfillBtoa}});var d=at();Object.defineProperty(exports,`URL`,{enumerable:!0,get:function(){return d.PonyfillURL}});var f=ut();Object.defineProperty(exports,`URLSearchParams`,{enumerable:!0,get:function(){return f.PonyfillURLSearchParams}});var p=dt();Object.defineProperty(exports,`WritableStream`,{enumerable:!0,get:function(){return p.PonyfillWritableStream}});var m=ft();Object.defineProperty(exports,`TransformStream`,{enumerable:!0,get:function(){return m.PonyfillTransformStream}});var h=pt();Object.defineProperty(exports,`CompressionStream`,{enumerable:!0,get:function(){return h.PonyfillCompressionStream}});var g=mt();Object.defineProperty(exports,`DecompressionStream`,{enumerable:!0,get:function(){return g.PonyfillDecompressionStream}});var _=$e();Object.defineProperty(exports,`IteratorObject`,{enumerable:!0,get:function(){return _.PonyfillIteratorObject}});var v=ht();Object.defineProperty(exports,`TextDecoderStream`,{enumerable:!0,get:function(){return v.PonyfillTextDecoderStream}}),Object.defineProperty(exports,`TextEncoderStream`,{enumerable:!0,get:function(){return v.PonyfillTextEncoderStream}})})),_t=e(((exports,t)=>{let n=M(),i;t.exports=function(e={}){let t={};if(t.URLPattern=globalThis.URLPattern,!t.URLPattern){let e=P();t.URLPattern=e.URLPattern}if(e.skipPonyfill||n())return{fetch:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response,FormData:globalThis.FormData,ReadableStream:globalThis.ReadableStream,WritableStream:globalThis.WritableStream,TransformStream:globalThis.TransformStream,CompressionStream:globalThis.CompressionStream,DecompressionStream:globalThis.DecompressionStream,TextDecoderStream:globalThis.TextDecoderStream,TextEncoderStream:globalThis.TextEncoderStream,Blob:globalThis.Blob,File:globalThis.File,crypto:globalThis.crypto,btoa:globalThis.btoa,TextEncoder:globalThis.TextEncoder,TextDecoder:globalThis.TextDecoder,URLPattern:t.URLPattern,URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};if(i||=gt(),t.fetch=i.fetch,t.Request=i.Request,t.Response=i.Response,t.Headers=i.Headers,t.FormData=i.FormData,t.ReadableStream=i.ReadableStream,t.URL=i.URL,t.URLSearchParams=i.URLSearchParams,t.WritableStream=i.WritableStream,t.TransformStream=i.TransformStream,t.CompressionStream=i.CompressionStream,t.DecompressionStream=i.DecompressionStream,t.TextDecoderStream=i.TextDecoderStream,t.TextEncoderStream=i.TextEncoderStream,t.Blob=i.Blob,t.File=i.File,t.crypto=globalThis.crypto,t.btoa=i.btoa,t.TextEncoder=i.TextEncoder,t.TextDecoder=i.TextDecoder,e.formDataLimits&&(t.Body=class extends i.Body{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}},t.Request=class extends i.Request{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}},t.Response=class extends i.Response{constructor(t,n){super(t,{formDataLimits:e.formDataLimits,...n})}}),!t.crypto){let e=r(`crypto`);t.crypto=e.webcrypto}return t}})),vt=e(((exports,t)=>{let n=_t(),i=M(),a=n();if(!i())try{globalThis.libcurl=globalThis.libcurl||r(`node-libcurl`)}catch{}t.exports.fetch=a.fetch,t.exports.Headers=a.Headers,t.exports.Request=a.Request,t.exports.Response=a.Response,t.exports.FormData=a.FormData,t.exports.ReadableStream=a.ReadableStream,t.exports.WritableStream=a.WritableStream,t.exports.TransformStream=a.TransformStream,t.exports.CompressionStream=a.CompressionStream,t.exports.DecompressionStream=a.DecompressionStream,t.exports.TextDecoderStream=a.TextDecoderStream,t.exports.TextEncoderStream=a.TextEncoderStream,t.exports.Blob=a.Blob,t.exports.File=a.File,t.exports.crypto=a.crypto,t.exports.btoa=a.btoa,t.exports.TextEncoder=a.TextEncoder,t.exports.TextDecoder=a.TextDecoder,t.exports.URLPattern=a.URLPattern,t.exports.URL=a.URL,t.exports.URLSearchParams=a.URLSearchParams,exports.createFetch=n}));function yt(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}function bt(e){if(e.socket?.localPort)return e.socket?.localPort;let t=e.headers?.[`:authority`]||e.headers?.host,n=t?.split(`:`)?.[1];return n||80}function xt(e){if(e.headers?.[`:authority`])return e.headers?.[`:authority`];if(e.headers?.host)return e.headers?.host;let t=bt(e);if(e.hostname)return e.hostname+`:`+t;let n=e.socket?.localAddress;return n&&!n?.includes(`::`)&&!n?.includes(`ffff`)?`${n}:${t}`:`localhost`}function St(e){let t=xt(e),n=e.protocol||(e.socket?.encrypted?`https`:`http`),r=e.originalUrl||e.url||`/graphql`;return`${n}://${t}${r}`}function Ct(e){let t=e[Symbol.toStringTag];return!!(typeof e==`string`||t===`Uint8Array`||t===`Blob`||t===`FormData`||t===`URLSearchParams`||yt(e))}function wt(e,t,n,r){let i=e.raw||e.req||e,a=St(i);if(e.query){let n=new t.URL(a);for(let t in e.query)n.searchParams.set(t,e.query[t]);a=n.toString()}let o=e.headers;if(e.headers?.[`:method`])for(let t in o={},e.headers)t.startsWith(`:`)||(o[t]=e.headers[t]);let s=r?Gt():new AbortController;if(n?.once){let e=()=>{s.signal.aborted||(Object.defineProperty(i,`aborted`,{value:!0}),s.abort(n.errored??void 0))};n.once(`error`,e),n.once(`close`,e),n.once(`finish`,()=>{n.removeListener(`close`,e)})}if(e.method===`GET`||e.method===`HEAD`)return new t.Request(a,{method:e.method,headers:o,signal:s.signal});let c=e.body;if(c!=null&&Object.keys(c).length>0){if(Ct(c))return new t.Request(a,{method:e.method||`GET`,headers:o,body:c,signal:s.signal});let n=new t.Request(a,{method:e.method||`GET`,headers:o,signal:s.signal});return n.headers.get(`content-type`)?.includes(`json`)||n.headers.set(`content-type`,`application/json; charset=utf-8`),new Proxy(n,{get:(e,t,n)=>{switch(t){case`json`:return()=>g(c);case`text`:return()=>g(JSON.stringify(c));default:return globalThis.Bun?Reflect.get(e,t):Reflect.get(e,t,n)}}})}return new t.Request(a,{method:e.method,headers:o,signal:s.signal,body:i,duplex:`half`})}function Tt(e){return e.read!=null}function Et(e){return Tt(e)}function Dt(e){return e!=null&&e.setHeader!=null&&e.end!=null&&e.once!=null&&e.write!=null}function Ot(e){return e!=null&&e.getReader!=null}function kt(e){return e!=null&&e.request!=null&&e.respondWith!=null}function At(e){e?.socket?.setTimeout?.(0),e?.socket?.setNoDelay?.(!0),e?.socket?.setKeepAlive?.(!0)}function G(e){e.end(null,null,null)}function jt(e,t){let n=!1,r=()=>{n=!0};e.once(`error`,r),e.once(`close`,r),e.once(`finish`,()=>{e.removeListener(`close`,r),e.removeListener(`error`,r)});let i=t[Symbol.asyncIterator](),a=()=>i.next().then(({done:t,value:r})=>{if(!(n||t))return h(()=>Mt(r,e),()=>n?G(e):a())});return a()}function Mt(e,t){let n=t.write(e);if(!n)return new Promise(e=>t.once(`drain`,e))}function Nt(e,t,n,r){if(t.closed||t.destroyed||t.writableEnded)return;if(!e){t.statusCode=404,G(t);return}if(r&&e.headers?.headersInit&&!Array.isArray(e.headers.headersInit)&&!e.headers.headersInit.get&&!e.headers._map&&!e.headers._setCookies?.length)t.writeHead(e.status,e.statusText,e.headers.headersInit);else{if(t.setHeaders)t.setHeaders(e.headers);else{let n=!1;e.headers.forEach((r,i)=>{if(i===`set-cookie`){if(n)return;n=!0;let r=e.headers.getSetCookie?.();if(r){t.setHeader(`set-cookie`,r);return}}t.setHeader(i,r)})}t.writeHead(e.status,e.statusText)}if(e.bodyType===`String`)return h(()=>Mt(e.bodyInit,t),()=>G(t));let i=e._buffer;if(i)return h(()=>Mt(i,t),()=>G(t));let a=e.body;if(a==null){G(t);return}if(a[Symbol.toStringTag]===`Uint8Array`)return h(()=>Mt(a,t),()=>G(t));if(At(n),Tt(a)){t.once(`close`,()=>{a.destroy()}),a.pipe(t,{end:!0});return}if(Ot(a))return Pt(n,t,a);if(yt(a))return jt(t,a)}function Pt(e,t,n){let r=n.getReader();e?.once?.(`error`,e=>{r.cancel(e)});function i(){return r.read().then(({done:e,value:n})=>e?G(t):h(()=>Mt(n,t),i))}return i()}function Ft(e){return typeof e==`object`&&!!e&&(`body`in e||`cache`in e||`credentials`in e||`headers`in e||`integrity`in e||`keepalive`in e||`method`in e||`mode`in e||`redirect`in e||`referrer`in e||`referrerPolicy`in e||`signal`in e||`window`in e)}function K(...e){let[t,...n]=e.filter(e=>typeof e==`object`&&!!e);return n.forEach(e=>{let n=Object.getOwnPropertyNames(e).reduce((t,n)=>{let r=Object.getOwnPropertyDescriptor(e,n);return r&&(t[n]=Object.getOwnPropertyDescriptor(e,n)),t},{});Object.getOwnPropertySymbols(e).forEach(t=>{let r=Object.getOwnPropertyDescriptor(e,t);r?.enumerable&&(n[t]=r)}),Object.defineProperties(t,n)}),t}function It(e,t){return new t(e.stack||e.message||e.toString(),{status:e.status||500})}function Lt(e,t){return e==null?t==null?{}:{waitUntil:t}:K(Object.create(e),{waitUntil:t},e)}function Rt(e,t){if(t?.aborted)throw t.reason;if(p(e)&&t){let n=_();function r(){n.reject(t.reason)}return t.addEventListener(`abort`,r,{once:!0}),e.then(function(e){n.resolve(e)}).catch(function(e){n.reject(e)}).finally(()=>{t.removeEventListener(`abort`,r)}),n.promise}return e}const zt=[`SIGINT`,`exit`,`SIGTERM`],Bt=new Set;let Vt=!1;function Ht(){if(!Vt){Vt=!0;for(let e of zt)globalThis.process.once(e,function(){return Promise.allSettled([...Bt].map(e=>!e.disposed&&e.disposeAsync()))})}}function Ut(e){globalThis.process&&(Ht(),Bt.has(e)||(Bt.add(e),e.defer(()=>{Bt.delete(e)})))}var Wt=class extends EventTarget{aborted=!1;_onabort=null;_reason;constructor(){super();let e=globalThis.process?.getBuiltinModule?.(`node:events`);e?.kMaxEventTargetListeners&&(this[e.kMaxEventTargetListeners]=0)}throwIfAborted(){if(this._nativeCtrl?.signal?.throwIfAborted)return this._nativeCtrl.signal.throwIfAborted();if(this.aborted)throw this._reason}_nativeCtrl;ensureNativeCtrl(){if(!this._nativeCtrl){let e=this.aborted;this._nativeCtrl=new AbortController,e&&this._nativeCtrl.abort(this._reason)}return this._nativeCtrl}abort(e){if(this._nativeCtrl?.abort)return this._nativeCtrl?.abort(e);this._reason=e||new DOMException(`This operation was aborted`,`AbortError`),this.aborted=!0,this.dispatchEvent(new Event(`abort`))}get signal(){return this._nativeCtrl?.signal?this._nativeCtrl.signal:this}get reason(){return this._nativeCtrl?.signal?this._nativeCtrl.signal.reason:this._reason}get onabort(){return this._onabort,this._onabort}set onabort(e){if(this._nativeCtrl?.signal){this._nativeCtrl.signal.onabort=e;return}this._onabort&&this.removeEventListener(`abort`,this._onabort),this._onabort=e,e&&this.addEventListener(`abort`,e)}};function Gt(){return globalThis.Bun||globalThis.Deno?new AbortController:new Proxy(new Wt,{get(e,t,n){if(t.toString().includes(`kDependantSignals`)){let n=e.ensureNativeCtrl();return Reflect.get(n.signal,t,n.signal)}return Reflect.get(e,t,n)},set(e,t,n,r){if(t.toString().includes(`kDependantSignals`)){let r=e.ensureNativeCtrl();return Reflect.set(r.signal,t,n,r.signal)}return Reflect.set(e,t,n,r)},getPrototypeOf(){return AbortSignal.prototype}})}function Kt(e){return!!e.onData}function qt({req:e,res:t,fetchAPI:n,controller:r}){let i=e.getMethod(),a,o=[],s=[e=>{o.push(e)}],c=e=>{for(let t of s)t(e)},l=!1,u=[()=>{l=!0}],d=()=>{for(let e of u)e()};t.onData(function(e,t){c(Buffer.from(Buffer.from(e,0,e.byteLength))),t&&d()});let f;if(i!==`get`&&i!==`head`){a=`half`,r.signal.addEventListener(`abort`,()=>{d()},{once:!0});let e;f=()=>(e||=new n.ReadableStream({start(e){for(let t of o)e.enqueue(t);if(l){e.close();return}s.push(t=>{e.enqueue(t)}),u.push(()=>{if(r.signal.reason){e.error(r.signal.reason);return}e.desiredSize&&e.close()})}}),e)}let p=new n.Headers;e.forEach((e,t)=>{p.append(e,t)});let m=`http://localhost${e.getUrl()}`,h=e.getQuery();h&&(m+=`?${h}`);let _;function v(){return f?l?b():f():null}let y=new n.Request(m,{method:i,headers:p,get body(){return v()},signal:r.signal,duplex:a});function b(){return _||=o.length===1?o[0]:Buffer.concat(o),_}function x(){return l?g(b()):new Promise((e,t)=>{try{u.push(()=>{e(b())})}catch(e){t(e)}})}return Object.defineProperties(y,{body:{get(){return v()},configurable:!0,enumerable:!0},json:{value(){return x().then(e=>e.toString(`utf8`)).then(e=>JSON.parse(e))},configurable:!0,enumerable:!0},text:{value(){return x().then(e=>e.toString(`utf8`))},configurable:!0,enumerable:!0},arrayBuffer:{value(){return x()},configurable:!0,enumerable:!0}}),y}function Jt(e,t){return new t.WritableStream({write(t){e.cork(()=>{e.write(t)})},close(){e.cork(()=>{e.end()})}})}function Yt(e,t,n,r){if(!t){e.writeStatus(`404 Not Found`),e.end();return}let i=t._buffer,a=t.bodyType===`String`?t.bodyInit:void 0;if(!n.signal.aborted&&(e.cork(()=>{e.writeStatus(`${t.status} ${t.statusText}`);for(let[n,r]of t.headers)if(n!==`content-length`){if(n===`set-cookie`){let r=t.headers.getSetCookie?.();if(r){for(let t of r)e.writeHeader(n,t);continue}}e.writeHeader(n,r)}a?e.end(a):i?e.end(i):t.body||e.end()}),!(a||i||!t.body)))return n.signal.addEventListener(`abort`,()=>{t.body?.locked||t.body?.cancel(n.signal.reason)},{once:!0}),t.body.pipeTo(Jt(e,r),{signal:n.signal}).catch(e=>{if(!n.signal.aborted)throw e})}var Xt=a(vt(),1);function Zt(e){try{return!!e?.request}catch{return!1}}const Qt={};function $t(e,t){let n=t?.__useSingleWriteHead==null?!0:t.__useSingleWriteHead,r={...Xt,...t?.fetchAPI},i=t?.__useCustomAbortCtrl==null?r.Request!==globalThis.Request:t.__useCustomAbortCtrl,a=typeof e==`function`?e:e.handle,o=[],s=[],c,l=new Set,u;function d(){return u||(u=new ee,t?.disposeOnProcessTerminate&&Ut(u),u.defer(()=>{if(l.size>0)return Promise.allSettled(l).then(()=>{l.clear()},()=>{l.clear()})})),u}function f(e){p(e)&&(d(),l.add(e),e.then(()=>{l.delete(e)},t=>{console.error(`Unexpected error while waiting: ${t.message||t}`),l.delete(e)}))}if(t?.plugins!=null)for(let e of t.plugins){e.instrumentation&&(c=c?w(c,e.instrumentation):e.instrumentation),e.onRequest&&o.push(e.onRequest),e.onResponse&&s.push(e.onResponse);let t=e[D.dispose];t&&d().defer(t);let n=e[D.asyncDispose];n&&d().defer(n),e.onDispose&&d().defer(e.onDispose)}let m=o.length>0||s.length>0?function(e,t){let n=a,i;if(o.length===0)return u();let c=e.parsedUrl||new Proxy(Qt,{get(t,n,i){return c=new r.URL(e.url,`http://localhost`),Reflect.get(c,n,c)}});function l(n){return s.length===0?n:h(()=>v(s,i=>i({request:e,response:n,serverContext:t,setResponse(e){n=e},fetchAPI:r})),()=>n)}function u(){return i?l(i):h(()=>n(e,t),l)}return h(()=>v(o,(a,o)=>a({request:e,setRequest(t){e=t},serverContext:t,fetchAPI:r,url:c,requestHandler:n,setRequestHandler(e){n=e},endResponse(e){i=e,e&&o()}})),u)}:a;if(c?.request){let e=m;m=(t,n)=>T({request:t}).asyncFn(c.request,e)(t,n)}function _(e,...t){let n=t.length>1?K(...t):t[0]||{};n.waitUntil||=f;let a=wt(e,r,void 0,i);return m(a,n)}function y(e,t,...n){let a=t.raw||t,o=n.length>1?K(...n):n[0]||{};o.waitUntil||=f;let s=wt(e,r,a,i);return m(s,o)}function b(e,t,...i){let a={req:e,res:t,waitUntil:f};return C(g().then(()=>y(e,t,a,...i)).catch(e=>It(e,r.Response)).then(r=>Nt(r,t,e,n)).catch(e=>console.error(`Unexpected error while handling request: ${e.message||e}`)))}function x(e,t,...n){let a={res:e,req:t,waitUntil:f},o=n.filter(e=>e!=null),s=o.length>0?K(a,...n):a,c=i?Gt():new AbortController,l=e.end.bind(e),u=!1;e.end=function(e){return u=!0,l(e)};let d=e.onAborted.bind(e);d(function(){c.abort()}),e.onAborted=function(e){c.signal.addEventListener(`abort`,e,{once:!0})};let p=qt({req:t,res:e,fetchAPI:r,controller:c});return h(()=>h(()=>m(p,s),e=>e,e=>It(e,r.Response)),t=>{if(!c.signal.aborted&&!u)return h(()=>Yt(e,t,c,r),e=>e,e=>{console.error(`Unexpected error while handling request: ${e.message||e}`)})})}function S(e,...t){if(!e.respondWith||!e.request)throw TypeError(`Expected FetchEvent, got ${e}`);let n=t.filter(e=>e!=null),r=n.length>0?K({},e,...n):Lt(e),i=m(e.request,r);e.respondWith(i)}function E(e,...t){let n=t.filter(e=>e!=null),r=n.length>1?K({},...n):Lt(n[0],n[0]==null||n[0].waitUntil==null?f:void 0);return m(e,r)}let O=(e,...t)=>{if(typeof e==`string`||`href`in e){let[n,...i]=t;if(Ft(n)){let t=new r.Request(e,n),a=E(t,...i),o=n.signal;return o?Rt(a,o):a}let a=new r.Request(e);return E(a,...t)}let n=E(e,...t);return Rt(n,e.signal)},k=(e,...t)=>{let[n,...r]=t;if(Et(e)){if(!Dt(n))throw TypeError(`Expected ServerResponse, got ${n}`);return b(e,n,...r)}if(Kt(e))return x(e,n,...r);if(Dt(n))throw TypeError(`Got Node response without Node request`);return Zt(e)?kt(e)?S(e,...t):E(e.request,e,...t):O(e,...t)},A={handleRequest:E,fetch:O,handleNodeRequest:_,handleNodeRequestAndResponse:y,requestListener:b,handleEvent:S,handleUWS:x,handle:k,get disposableStack(){return d()},[D.asyncDispose](){return u&&!u.disposed?u.disposeAsync():g()},dispose(){return u&&!u.disposed?u.disposeAsync():g()},waitUntil:f},j=new Proxy(k,{has:(t,n)=>n in A||n in k||e&&n in e,get:(t,n)=>{if(globalThis.Deno||n===Symbol.asyncDispose||n===Symbol.dispose){let e=Reflect.get(A,n,A);if(e)return e}let r=A[n];if(r)return r.bind?r.bind(A):r;let i=k[n];if(i)return i.bind?i.bind(k):i;if(e){let t=e[n];if(t)return t.bind?function(...t){let r=e[n](...t);return r===e?j:r}:t}},apply(e,t,n){return k(...n)}});return j}var en=(e,t,n)=>(r,i)=>{let a=-1;return o(0);async function o(s){if(s<=a)throw Error(`next() called multiple times`);a=s;let c,l=!1,u;if(e[s]?(u=e[s][0][0],r.req.routeIndex=s):u=s===e.length&&i||void 0,u)try{c=await u(r,()=>o(s+1))}catch(e){if(e instanceof Error&&t)r.error=e,c=await t(e,r),l=!0;else throw e}else r.finalized===!1&&n&&(c=await n(r));return c&&(r.finalized===!1||l)&&(r.res=c),r}},tn=Symbol(),nn=async(e,t=Object.create(null))=>{let{all:n=!1,dot:r=!1}=t,i=e instanceof Tn?e.raw.headers:e.headers,a=i.get(`Content-Type`);return a?.startsWith(`multipart/form-data`)||a?.startsWith(`application/x-www-form-urlencoded`)?rn(e,{all:n,dot:r}):{}};async function rn(e,t){let n=await e.formData();return n?an(n,t):{}}function an(e,t){let n=Object.create(null);return e.forEach((e,r)=>{let i=t.all||r.endsWith(`[]`);i?on(n,r,e):n[r]=e}),t.dot&&Object.entries(n).forEach(([e,t])=>{let r=e.includes(`.`);r&&(sn(n,e,t),delete n[e])}),n}var on=(e,t,n)=>{e[t]===void 0?t.endsWith(`[]`)?e[t]=[n]:e[t]=n:Array.isArray(e[t])?e[t].push(n):e[t]=[e[t],n]},sn=(e,t,n)=>{let r=e,i=t.split(`.`);i.forEach((e,t)=>{t===i.length-1?r[e]=n:((!r[e]||typeof r[e]!=`object`||Array.isArray(r[e])||r[e]instanceof File)&&(r[e]=Object.create(null)),r=r[e])})},cn=e=>{let t=e.split(`/`);return t[0]===``&&t.shift(),t},ln=e=>{let{groups:t,path:n}=un(e),r=cn(n);return dn(r,t)},un=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,n)=>{let r=`@${n}`;return t.push([r,e]),r}),{groups:t,path:e}},dn=(e,t)=>{for(let n=t.length-1;n>=0;n--){let[r]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(r)){e[i]=e[i].replace(r,t[n][1]);break}}return e},fn={},pn=(e,t)=>{if(e===`*`)return`*`;let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let r=`${e}#${t}`;return fn[r]||(n[2]?fn[r]=t&&t[0]!==`:`&&t[0]!==`*`?[r,n[1],RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],RegExp(`^${n[2]}$`)]:fn[r]=[e,n[1],!0]),fn[r]}return null},mn=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},hn=e=>mn(e,decodeURI),gn=e=>{let t=e.url,n=t.indexOf(`/`,t.indexOf(`:`)+4),r=n;for(;r<t.length;r++){let e=t.charCodeAt(r);if(e===37){let e=t.indexOf(`?`,r),i=t.slice(n,e===-1?void 0:e);return hn(i.includes(`%25`)?i.replace(/%25/g,`%2525`):i)}else if(e===63)break}return t.slice(n,r)},_n=e=>{let t=gn(e);return t.length>1&&t.at(-1)===`/`?t.slice(0,-1):t},q=(e,t,...n)=>(n.length&&(t=q(t,...n)),`${e?.[0]===`/`?``:`/`}${e}${t===`/`?``:`${e?.at(-1)===`/`?``:`/`}${t?.[0]===`/`?t.slice(1):t}`}`),vn=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(`:`))return null;let t=e.split(`/`),n=[],r=``;return t.forEach(e=>{if(e!==``&&!/\:/.test(e))r+=`/`+e;else if(/\:/.test(e))if(/\?/.test(e)){n.length===0&&r===``?n.push(`/`):n.push(r);let t=e.replace(`?`,``);r+=`/`+t,n.push(r)}else r+=`/`+e}),n.filter((e,t,n)=>n.indexOf(e)===t)},yn=e=>/[%+]/.test(e)?(e.indexOf(`+`)!==-1&&(e=e.replace(/\+/g,` `)),e.indexOf(`%`)===-1?e:mn(e,Cn)):e,bn=(e,t,n)=>{let r;if(!n&&t&&!/[%+]/.test(t)){let n=e.indexOf(`?${t}`,8);for(n===-1&&(n=e.indexOf(`&${t}`,8));n!==-1;){let r=e.charCodeAt(n+t.length+1);if(r===61){let r=n+t.length+2,i=e.indexOf(`&`,r);return yn(e.slice(r,i===-1?void 0:i))}else if(r==38||isNaN(r))return``;n=e.indexOf(`&${t}`,n+1)}if(r=/[%+]/.test(e),!r)return}let i={};r??=/[%+]/.test(e);let a=e.indexOf(`?`,8);for(;a!==-1;){let t=e.indexOf(`&`,a+1),o=e.indexOf(`=`,a);o>t&&t!==-1&&(o=-1);let s=e.slice(a+1,o===-1?t===-1?void 0:t:o);if(r&&(s=yn(s)),a=t,s===``)continue;let c;o===-1?c=``:(c=e.slice(o+1,t===-1?void 0:t),r&&(c=yn(c))),n?(i[s]&&Array.isArray(i[s])||(i[s]=[]),i[s].push(c)):i[s]??=c}return t?i[t]:i},xn=bn,Sn=(e,t)=>bn(e,t,!0),Cn=decodeURIComponent,wn=e=>mn(e,Cn),Tn=class{raw;#validatedData;#matchResult;routeIndex=0;path;bodyCache={};constructor(e,t=`/`,n=[[]]){this.raw=e,this.path=t,this.#matchResult=n,this.#validatedData={}}param(e){return e?this.#getDecodedParam(e):this.#getAllDecodedParams()}#getDecodedParam(e){let t=this.#matchResult[0][this.routeIndex][1][e],n=this.#getParamValue(t);return n&&/\%/.test(n)?wn(n):n}#getAllDecodedParams(){let e={},t=Object.keys(this.#matchResult[0][this.routeIndex][1]);for(let n of t){let t=this.#getParamValue(this.#matchResult[0][this.routeIndex][1][n]);t!==void 0&&(e[n]=/\%/.test(t)?wn(t):t)}return e}#getParamValue(e){return this.#matchResult[1]?this.#matchResult[1][e]:e}query(e){return xn(this.url,e)}queries(e){return Sn(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((e,n)=>{t[n]=e}),t}async parseBody(e){return this.bodyCache.parsedBody??=await nn(this,e)}#cachedBody=e=>{let{bodyCache:t,raw:n}=this,r=t[e];if(r)return r;let i=Object.keys(t)[0];return i?t[i].then(t=>(i===`json`&&(t=JSON.stringify(t)),new Response(t)[e]())):t[e]=n[e]()};json(){return this.#cachedBody(`text`).then(e=>JSON.parse(e))}text(){return this.#cachedBody(`text`)}arrayBuffer(){return this.#cachedBody(`arrayBuffer`)}blob(){return this.#cachedBody(`blob`)}formData(){return this.#cachedBody(`formData`)}addValidatedData(e,t){this.#validatedData[e]=t}valid(e){return this.#validatedData[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[tn](){return this.#matchResult}get matchedRoutes(){return this.#matchResult[0].map(([[,e]])=>e)}get routePath(){return this.#matchResult[0].map(([[,e]])=>e)[this.routeIndex].path}},En={Stringify:1,BeforeStream:2,Stream:3},Dn=(e,t)=>{let n=new String(e);return n.isEscaped=!0,n.callbacks=t,n},On=async(e,t,n,r,i)=>{typeof e==`object`&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let a=e.callbacks;if(!a?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let o=Promise.all(a.map(e=>e({phase:t,buffer:i,context:r}))).then(e=>Promise.all(e.filter(Boolean).map(e=>On(e,t,!1,r,i))).then(()=>i[0]));return n?Dn(await o,a):o},kn=`text/plain; charset=UTF-8`,An=(e,t)=>({"Content-Type":e,...t}),jn=class{#rawRequest;#req;env={};#var;finalized=!1;error;#status;#executionCtx;#res;#layout;#renderer;#notFoundHandler;#preparedHeaders;#matchResult;#path;constructor(e,t){this.#rawRequest=e,t&&(this.#executionCtx=t.executionCtx,this.env=t.env,this.#notFoundHandler=t.notFoundHandler,this.#path=t.path,this.#matchResult=t.matchResult)}get req(){return this.#req??=new Tn(this.#rawRequest,this.#path,this.#matchResult),this.#req}get event(){if(this.#executionCtx&&`respondWith`in this.#executionCtx)return this.#executionCtx;throw Error(`This context has no FetchEvent`)}get executionCtx(){if(this.#executionCtx)return this.#executionCtx;throw Error(`This context has no ExecutionContext`)}get res(){return this.#res||=new Response(null,{headers:this.#preparedHeaders??=new Headers})}set res(e){if(this.#res&&e){e=new Response(e.body,e);for(let[t,n]of this.#res.headers.entries()){if(t===`content-type`)continue;if(t===`set-cookie`){let t=this.#res.headers.getSetCookie();e.headers.delete(`set-cookie`);for(let n of t)e.headers.append(`set-cookie`,n)}else e.headers.set(t,n)}}this.#res=e,this.finalized=!0}render=(...e)=>(this.#renderer??=e=>this.html(e),this.#renderer(...e));setLayout=e=>this.#layout=e;getLayout=()=>this.#layout;setRenderer=e=>{this.#renderer=e};header=(e,t,n)=>{this.finalized&&(this.#res=new Response(this.#res.body,this.#res));let r=this.#res?this.#res.headers:this.#preparedHeaders??=new Headers;t===void 0?r.delete(e):n?.append?r.append(e,t):r.set(e,t)};status=e=>{this.#status=e};set=(e,t)=>{this.#var??=new Map,this.#var.set(e,t)};get=e=>this.#var?this.#var.get(e):void 0;get var(){return this.#var?Object.fromEntries(this.#var):{}}#newResponse(e,t,n){let r=this.#res?new Headers(this.#res.headers):this.#preparedHeaders??new Headers;if(typeof t==`object`&&`headers`in t){let e=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(let[t,n]of e)t.toLowerCase()===`set-cookie`?r.append(t,n):r.set(t,n)}if(n)for(let[e,t]of Object.entries(n))if(typeof t==`string`)r.set(e,t);else{r.delete(e);for(let n of t)r.append(e,n)}let i=typeof t==`number`?t:t?.status??this.#status;return new Response(e,{status:i,headers:r})}newResponse=(...e)=>this.#newResponse(...e);body=(e,t,n)=>this.#newResponse(e,t,n);text=(e,t,n)=>!this.#preparedHeaders&&!this.#status&&!t&&!n&&!this.finalized?new Response(e):this.#newResponse(e,t,An(kn,n));json=(e,t,n)=>this.#newResponse(JSON.stringify(e),t,An(`application/json`,n));html=(e,t,n)=>{let r=e=>this.#newResponse(e,t,An(`text/html; charset=UTF-8`,n));return typeof e==`object`?On(e,En.Stringify,!1,{}).then(r):r(e)};redirect=(e,t)=>{let n=String(e);return this.header(`Location`,/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,t??302)};notFound=()=>(this.#notFoundHandler??=()=>new Response,this.#notFoundHandler(this))},J=`ALL`,Mn=`all`,Nn=[`get`,`post`,`put`,`delete`,`options`,`patch`],Pn=`Can not add a route since the matcher is already built.`,Fn=class extends Error{},In=`__COMPOSED_HANDLER`,Ln=e=>e.text(`404 Not Found`,404),Rn=(e,t)=>{if(`getResponse`in e){let n=e.getResponse();return t.newResponse(n.body,n)}return console.error(e),t.text(`Internal Server Error`,500)},zn=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath=`/`;#path=`/`;routes=[];constructor(e={}){let t=[...Nn,Mn];t.forEach(e=>{this[e]=(t,...n)=>(typeof t==`string`?this.#path=t:this.#addRoute(e,this.#path,t),n.forEach(t=>{this.#addRoute(e,this.#path,t)}),this)}),this.on=(e,t,...n)=>{for(let r of[t].flat()){this.#path=r;for(let t of[e].flat())n.map(e=>{this.#addRoute(t.toUpperCase(),this.#path,e)})}return this},this.use=(e,...t)=>(typeof e==`string`?this.#path=e:(this.#path=`*`,t.unshift(e)),t.forEach(e=>{this.#addRoute(J,this.#path,e)}),this);let{strict:n,...r}=e;Object.assign(this,r),this.getPath=n??!0?e.getPath??gn:_n}#clone(){let e=new zn({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#notFoundHandler=this.#notFoundHandler,e.routes=this.routes,e}#notFoundHandler=Ln;errorHandler=Rn;route(e,t){let n=this.basePath(e);return t.routes.map(e=>{let r;t.errorHandler===Rn?r=e.handler:(r=async(n,r)=>(await en([],t.errorHandler)(n,()=>e.handler(n,r))).res,r[In]=e.handler),n.#addRoute(e.method,e.path,r)}),this}basePath(e){let t=this.#clone();return t._basePath=q(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#notFoundHandler=e,this);mount(e,t,n){let r,i;n&&(typeof n==`function`?i=n:(i=n.optionHandler,r=n.replaceRequest===!1?e=>e:n.replaceRequest));let a=i?e=>{let t=i(e);return Array.isArray(t)?t:[t]}:e=>{let t;try{t=e.executionCtx}catch{}return[e.env,t]};r||=(()=>{let t=q(this._basePath,e),n=t===`/`?0:t.length;return e=>{let t=new URL(e.url);return t.pathname=t.pathname.slice(n)||`/`,new Request(t,e)}})();let o=async(e,n)=>{let i=await t(r(e.req.raw),...a(e));if(i)return i;await n()};return this.#addRoute(J,q(e,`*`),o),this}#addRoute(e,t,n){e=e.toUpperCase(),t=q(this._basePath,t);let r={basePath:this._basePath,path:t,method:e,handler:n};this.router.add(e,t,[n,r]),this.routes.push(r)}#handleError(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#dispatch(e,t,n,r){if(r===`HEAD`)return(async()=>new Response(null,await this.#dispatch(e,t,n,`GET`)))();let i=this.getPath(e,{env:n}),a=this.router.match(r,i),o=new jn(e,{path:i,matchResult:a,env:n,executionCtx:t,notFoundHandler:this.#notFoundHandler});if(a[0].length===1){let e;try{e=a[0][0][0][0](o,async()=>{o.res=await this.#notFoundHandler(o)})}catch(e){return this.#handleError(e,o)}return e instanceof Promise?e.then(e=>e||(o.finalized?o.res:this.#notFoundHandler(o))).catch(e=>this.#handleError(e,o)):e??this.#notFoundHandler(o)}let s=en(a[0],this.errorHandler,this.#notFoundHandler);return(async()=>{try{let e=await s(o);if(!e.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return e.res}catch(e){return this.#handleError(e,o)}})()}fetch=(e,...t)=>this.#dispatch(e,t[1],t[0],e.method);request=(e,t,n,r)=>e instanceof Request?this.fetch(t?new Request(e,t):e,n,r):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${q(`/`,e)}`,t),n,r));fire=()=>{addEventListener(`fetch`,e=>{e.respondWith(this.#dispatch(e.request,e,void 0,e.request.method))})}},Bn=`[^/]+`,Vn=`.*`,Hn=`(?:|/.*)`,Un=Symbol(),Wn=new Set(`.\\+*[^]$()`);function Gn(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===Vn||e===Hn?1:t===Vn||t===Hn?-1:e===Bn?1:t===Bn?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var Kn=class{#index;#varIndex;#children=Object.create(null);insert(e,t,n,r,i){if(e.length===0){if(this.#index!==void 0)throw Un;if(i)return;this.#index=t;return}let[a,...o]=e,s=a===`*`?o.length===0?[``,``,Vn]:[``,``,Bn]:a===`/*`?[``,``,Hn]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),c;if(s){let e=s[1],t=s[2]||Bn;if(e&&s[2]&&(t===`.*`||(t=t.replace(/^\((?!\?:)(?=[^)]+\)$)/,`(?:`),/\((?!\?:)/.test(t))))throw Un;if(c=this.#children[t],!c){if(Object.keys(this.#children).some(e=>e!==Vn&&e!==Hn))throw Un;if(i)return;c=this.#children[t]=new Kn,e!==``&&(c.#varIndex=r.varIndex++)}!i&&e!==``&&n.push([e,c.#varIndex])}else if(c=this.#children[a],!c){if(Object.keys(this.#children).some(e=>e.length>1&&e!==Vn&&e!==Hn))throw Un;if(i)return;c=this.#children[a]=new Kn}c.insert(o,t,n,r,i)}buildRegExpStr(){let e=Object.keys(this.#children).sort(Gn),t=e.map(e=>{let t=this.#children[e];return(typeof t.#varIndex==`number`?`(${e})@${t.#varIndex}`:Wn.has(e)?`\\${e}`:e)+t.buildRegExpStr()});return typeof this.#index==`number`&&t.unshift(`#${this.#index}`),t.length===0?``:t.length===1?t[0]:`(?:`+t.join(`|`)+`)`}},qn=class{#context={varIndex:0};#root=new Kn;insert(e,t,n){let r=[],i=[];for(let t=0;;){let n=!1;if(e=e.replace(/\{[^}]+\}/g,e=>{let r=`@\\${t}`;return i[t]=[r,e],t++,n=!0,r}),!n)break}let a=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let e=i.length-1;e>=0;e--){let[t]=i[e];for(let n=a.length-1;n>=0;n--)if(a[n].indexOf(t)!==-1){a[n]=a[n].replace(t,i[e][1]);break}}return this.#root.insert(a,t,r,this.#context,n),r}buildRegExp(){let e=this.#root.buildRegExpStr();if(e===``)return[/^$/,[],[]];let t=0,n=[],r=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(e,i,a)=>i===void 0?(a===void 0||(r[Number(a)]=++t),``):(n[++t]=Number(i),`$()`)),[RegExp(`^${e}`),n,r]}},Jn=[],Yn=[/^$/,[],Object.create(null)],Xn=Object.create(null);function Zn(e){return Xn[e]??=RegExp(e===`*`?``:`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,t)=>t?`\\${t}`:`(?:|/.*)`)}$`)}function Qn(){Xn=Object.create(null)}function $n(e){let t=new qn,n=[];if(e.length===0)return Yn;let r=e.map(e=>[!/\*|\/:/.test(e[0]),...e]).sort(([e,t],[n,r])=>e?1:n?-1:t.length-r.length),i=Object.create(null);for(let e=0,a=-1,o=r.length;e<o;e++){let[o,s,c]=r[e];o?i[s]=[c.map(([e])=>[e,Object.create(null)]),Jn]:a++;let l;try{l=t.insert(s,a,o)}catch(e){throw e===Un?new Fn(s):e}o||(n[a]=c.map(([e,t])=>{let n=Object.create(null);for(--t;t>=0;t--){let[e,r]=l[t];n[e]=r}return[e,n]}))}let[a,o,s]=t.buildRegExp();for(let e=0,t=n.length;e<t;e++)for(let t=0,r=n[e].length;t<r;t++){let r=n[e][t]?.[1];if(!r)continue;let i=Object.keys(r);for(let e=0,t=i.length;e<t;e++)r[i[e]]=s[r[i[e]]]}let c=[];for(let e in o)c[e]=n[o[e]];return[a,c,i]}function Y(e,t){if(e){for(let n of Object.keys(e).sort((e,t)=>t.length-e.length))if(Zn(n).test(t))return[...e[n]]}}var er=class{name=`RegExpRouter`;#middleware;#routes;constructor(){this.#middleware={[J]:Object.create(null)},this.#routes={[J]:Object.create(null)}}add(e,t,n){let r=this.#middleware,i=this.#routes;if(!r||!i)throw Error(Pn);r[e]||[r,i].forEach(t=>{t[e]=Object.create(null),Object.keys(t[J]).forEach(n=>{t[e][n]=[...t[J][n]]})}),t===`/*`&&(t=`*`);let a=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let o=Zn(t);e===J?Object.keys(r).forEach(e=>{r[e][t]||=Y(r[e],t)||Y(r[J],t)||[]}):r[e][t]||=Y(r[e],t)||Y(r[J],t)||[],Object.keys(r).forEach(t=>{(e===J||e===t)&&Object.keys(r[t]).forEach(e=>{o.test(e)&&r[t][e].push([n,a])})}),Object.keys(i).forEach(t=>{(e===J||e===t)&&Object.keys(i[t]).forEach(e=>o.test(e)&&i[t][e].push([n,a]))});return}let o=vn(t)||[t];for(let t=0,s=o.length;t<s;t++){let c=o[t];Object.keys(i).forEach(o=>{(e===J||e===o)&&(i[o][c]||=[...Y(r[o],c)||Y(r[J],c)||[]],i[o][c].push([n,a-s+t+1]))})}}match(e,t){Qn();let n=this.#buildAllMatchers();return this.match=(e,t)=>{let r=n[e]||n[J],i=r[2][t];if(i)return i;let a=t.match(r[0]);if(!a)return[[],Jn];let o=a.indexOf(``,1);return[r[1][o],a]},this.match(e,t)}#buildAllMatchers(){let e=Object.create(null);return Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach(t=>{e[t]||=this.#buildMatcher(t)}),this.#middleware=this.#routes=void 0,e}#buildMatcher(e){let t=[],n=e===J;return[this.#middleware,this.#routes].forEach(r=>{let i=r[e]?Object.keys(r[e]).map(t=>[t,r[e][t]]):[];i.length===0?e!==J&&t.push(...Object.keys(r[J]).map(e=>[e,r[J][e]])):(n||=!0,t.push(...i))}),n?$n(t):null}},tr=class{name=`SmartRouter`;#routers=[];#routes=[];constructor(e){this.#routers=e.routers}add(e,t,n){if(!this.#routes)throw Error(Pn);this.#routes.push([e,t,n])}match(e,t){if(!this.#routes)throw Error(`Fatal error`);let n=this.#routers,r=this.#routes,i=n.length,a=0,o;for(;a<i;a++){let i=n[a];try{for(let e=0,t=r.length;e<t;e++)i.add(...r[e]);o=i.match(e,t)}catch(e){if(e instanceof Fn)continue;throw e}this.match=i.match.bind(i),this.#routers=[i],this.#routes=void 0;break}if(a===i)throw Error(`Fatal error`);return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#routes||this.#routers.length!==1)throw Error(`No active router has been determined yet.`);return this.#routers[0]}},nr=Object.create(null),rr=class{#methods;#children;#patterns;#order=0;#params=nr;constructor(e,t,n){if(this.#children=n||Object.create(null),this.#methods=[],e&&t){let n=Object.create(null);n[e]={handler:t,possibleKeys:[],score:0},this.#methods=[n]}this.#patterns=[]}insert(e,t,n){this.#order=++this.#order;let r=this,i=ln(t),a=[];for(let e=0,t=i.length;e<t;e++){let t=i[e],n=i[e+1],o=pn(t,n),s=Array.isArray(o)?o[0]:t;if(s in r.#children){r=r.#children[s],o&&a.push(o[1]);continue}r.#children[s]=new rr,o&&(r.#patterns.push(o),a.push(o[1])),r=r.#children[s]}return r.#methods.push({[e]:{handler:n,possibleKeys:a.filter((e,t,n)=>n.indexOf(e)===t),score:this.#order}}),r}#getHandlerSets(e,t,n,r){let i=[];for(let a=0,o=e.#methods.length;a<o;a++){let o=e.#methods[a],s=o[t]||o[J],c={};if(s!==void 0&&(s.params=Object.create(null),i.push(s),n!==nr||r&&r!==nr))for(let e=0,t=s.possibleKeys.length;e<t;e++){let t=s.possibleKeys[e],i=c[s.score];s.params[t]=r?.[t]&&!i?r[t]:n[t]??r?.[t],c[s.score]=!0}}return i}search(e,t){let n=[];this.#params=nr;let r=this,i=[r],a=cn(t),o=[];for(let t=0,r=a.length;t<r;t++){let s=a[t],c=t===r-1,l=[];for(let r=0,u=i.length;r<u;r++){let u=i[r],d=u.#children[s];d&&(d.#params=u.#params,c?(d.#children[`*`]&&n.push(...this.#getHandlerSets(d.#children[`*`],e,u.#params)),n.push(...this.#getHandlerSets(d,e,u.#params))):l.push(d));for(let r=0,i=u.#patterns.length;r<i;r++){let i=u.#patterns[r],d=u.#params===nr?{}:{...u.#params};if(i===`*`){let t=u.#children[`*`];t&&(n.push(...this.#getHandlerSets(t,e,u.#params)),t.#params=d,l.push(t));continue}let[f,p,m]=i;if(!s&&!(m instanceof RegExp))continue;let h=u.#children[f],g=a.slice(t).join(`/`);if(m instanceof RegExp){let t=m.exec(g);if(t){if(d[p]=t[0],n.push(...this.#getHandlerSets(h,e,u.#params,d)),Object.keys(h.#children).length){h.#params=d;let e=t[0].match(/\//)?.length??0,n=o[e]||=[];n.push(h)}continue}}(m===!0||m.test(s))&&(d[p]=s,c?(n.push(...this.#getHandlerSets(h,e,d,u.#params)),h.#children[`*`]&&n.push(...this.#getHandlerSets(h.#children[`*`],e,d,u.#params))):(h.#params=d,l.push(h)))}}i=l.concat(o.shift()??[])}return n.length>1&&n.sort((e,t)=>e.score-t.score),[n.map(({handler:e,params:t})=>[e,t])]}},ir=class{name=`TrieRouter`;#node;constructor(){this.#node=new rr}add(e,t,n){let r=vn(t);if(r){for(let t=0,i=r.length;t<i;t++)this.#node.insert(e,r[t],n);return}this.#node.insert(e,t,n)}match(e,t){return this.#node.search(e,t)}},ar=class extends zn{constructor(e={}){super(e),this.router=e.router??new tr({routers:[new er,new ir]})}},or=/^[\w!#$%&'*.^`|~+-]+$/,sr=/^[ !#-:<-[\]-~]*$/,cr=(e,t)=>{if(t&&e.indexOf(t)===-1)return{};let n=e.trim().split(`;`),r={};for(let e of n){e=e.trim();let n=e.indexOf(`=`);if(n===-1)continue;let i=e.substring(0,n).trim();if(t&&t!==i||!or.test(i))continue;let a=e.substring(n+1).trim();if(a.startsWith(`"`)&&a.endsWith(`"`)&&(a=a.slice(1,-1)),sr.test(a)&&(r[i]=a.indexOf(`%`)===-1?a:mn(a,Cn),t))break}return r},lr=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},ur=(e,t,n)=>(t=encodeURIComponent(t),lr(e,t,n)),dr=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),fr=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??`);e=e.replace(t,r?`/${r}`:``)}return e},pr=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e)){if(r===void 0)continue;if(Array.isArray(r))for(let e of r)t.append(n,e);else t.set(n,r)}return t},mr=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},hr=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function gr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _r(e,t){if(!gr(e)&&!gr(t))return t;let n={...e};for(let e in t){let r=t[e];gr(n[e])&&gr(r)?n[e]=_r(n[e],r):n[e]=r}return n}var vr=(e,t)=>{let n=new Proxy(()=>{},{get(n,r){if(!(typeof r!=`string`||r===`then`))return vr(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}});return n},yr=class{url;method;queryParams=void 0;pathParams={};rBody;cType=void 0;constructor(e,t){this.url=e,this.method=t}fetch=async(e,t)=>{if(e){if(e.query&&(this.queryParams=pr(e.query)),e.form){let t=new FormData;for(let[n,r]of Object.entries(e.form))if(Array.isArray(r))for(let e of r)t.append(n,e);else t.append(n,r);this.rBody=t}e.json&&(this.rBody=JSON.stringify(e.json),this.cType=`application/json`),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase(),r={...e?.header,...typeof t?.headers==`function`?await t.headers():t?.headers};if(e?.cookie){let t=[];for(let[n,r]of Object.entries(e.cookie))t.push(ur(n,r,{path:`/`}));r.Cookie=t.join(`,`)}this.cType&&(r[`Content-Type`]=this.cType);let i=new Headers(r??void 0),a=this.url;a=hr(a),a=fr(a,this.pathParams),this.queryParams&&(a=a+`?`+this.queryParams.toString()),n=this.method.toUpperCase();let o=!(n===`GET`||n===`HEAD`);return(t?.fetch||fetch)(a,{body:o?this.rBody:void 0,method:n,headers:i,...t?.init})}},br=(e,t)=>vr(function n(r){let i=[...r.path],a=i.slice(-3).reverse();if(a[0]===`toString`)return a[1]===`name`?a[2]||``:n.toString();if(a[0]===`valueOf`)return a[1]===`name`?a[2]||``:n;let o=``;if(/^\$/.test(a[0])){let e=i.pop();e&&(o=e.replace(/^\$/,``))}let s=i.join(`/`),c=dr(e,s);if(o===`url`){let e=c;return r.args[0]&&(r.args[0].param&&(e=fr(c,r.args[0].param)),r.args[0].query&&(e=e+`?`+pr(r.args[0].query).toString())),e=hr(e),new URL(e)}if(o===`ws`){let e=mr(r.args[0]&&r.args[0].param?fr(c,r.args[0].param):c,`ws`),n=new URL(e),i=r.args[0]?.query;i&&Object.entries(i).forEach(([e,t])=>{Array.isArray(t)?t.forEach(t=>n.searchParams.append(e,t)):n.searchParams.set(e,t)});let a=(...e)=>t?.webSocket!==void 0&&typeof t.webSocket==`function`?t.webSocket(...e):new WebSocket(...e);return a(n.toString())}let l=new yr(c,o);if(o){t??={};let e=_r(t,{...r.args[1]});return l.fetch(r.args[0],e)}return l},[]),xr=(e,t,n)=>{let r=e.req.raw.headers.get(`Cookie`);if(typeof t==`string`){if(!r)return;let e=t;n===`secure`?e=`__Secure-`+t:n===`host`&&(e=`__Host-`+t);let i=cr(r,e);return i[e]}if(!r)return{};let i=cr(r);return i},Sr=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=t?.res,this.status=e}getResponse(){if(this.res){let e=new Response(this.res.body,{status:this.status,headers:this.res.headers});return e}return new Response(this.message,{status:this.status})}},Cr=(e,t)=>{let n=new Response(e,{headers:{"Content-Type":t}});return n.formData()},wr=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Tr=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/,Er=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/,Dr=(e,t)=>async(n,r)=>{let i={},a=n.req.header(`Content-Type`);switch(e){case`json`:if(!a||!wr.test(a))break;try{i=await n.req.json()}catch{throw new Sr(400,{message:`Malformed JSON in request body`})}break;case`form`:{if(!a||!(Tr.test(a)||Er.test(a)))break;let e;if(n.req.bodyCache.formData)e=await n.req.bodyCache.formData;else try{let t=await n.req.arrayBuffer();e=await Cr(t,a),n.req.bodyCache.formData=e}catch(e){let t=`Malformed FormData request.`;throw t+=e instanceof Error?` ${e.message}`:` ${String(e)}`,new Sr(400,{message:t})}let t={};e.forEach((e,n)=>{n.endsWith(`[]`)?(t[n]??=[]).push(e):Array.isArray(t[n])?t[n].push(e):n in t?t[n]=[t[n],e]:t[n]=e}),i=t;break}case`query`:i=Object.fromEntries(Object.entries(n.req.queries()).map(([e,t])=>t.length===1?[e,t[0]]:[e,t]));break;case`param`:i=n.req.param();break;case`header`:i=n.req.header();break;case`cookie`:i=xr(n);break}let o=await t(i,n);if(o instanceof Response)return o;n.req.addValidatedData(e,o),await r()},Or=class extends Error{constructor(e,t){super(e),this.response=t}},kr=`vercel.ai.error`,Ar=Symbol.for(kr),jr,Mr=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[jr]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,kr)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};jr=Ar;var X=Mr,Nr=`AI_APICallError`,Pr=`vercel.ai.error.${Nr}`,Fr=Symbol.for(Pr),Ir,Z=class extends X{constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:Nr,message:e,cause:o}),this[Ir]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return X.hasMarker(e,Pr)}};Ir=Fr;var Lr=`AI_EmptyResponseBodyError`,Rr=`vercel.ai.error.${Lr}`,zr=Symbol.for(Rr),Br,Vr=class extends X{constructor({message:e=`Empty response body`}={}){super({name:Lr,message:e}),this[Br]=!0}static isInstance(e){return X.hasMarker(e,Rr)}};Br=zr;function Hr(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var Ur=`AI_InvalidArgumentError`,Wr=`vercel.ai.error.${Ur}`,Gr=Symbol.for(Wr),Kr,qr=class extends X{constructor({message:e,cause:t,argument:n}){super({name:Ur,message:e,cause:t}),this[Kr]=!0,this.argument=n}static isInstance(e){return X.hasMarker(e,Wr)}};Kr=Gr;var Jr=`AI_InvalidPromptError`,Yr=`vercel.ai.error.${Jr}`,Xr=Symbol.for(Yr),Zr,Qr=class extends X{constructor({prompt:e,message:t,cause:n}){super({name:Jr,message:`Invalid prompt: ${t}`,cause:n}),this[Zr]=!0,this.prompt=e}static isInstance(e){return X.hasMarker(e,Yr)}};Zr=Xr;var $r=`AI_InvalidResponseDataError`,ei=`vercel.ai.error.${$r}`,ti=Symbol.for(ei),ni,ri=class extends X{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:$r,message:t}),this[ni]=!0,this.data=e}static isInstance(e){return X.hasMarker(e,ei)}};ni=ti;var ii=`AI_JSONParseError`,ai=`vercel.ai.error.${ii}`,oi=Symbol.for(ai),si,ci=class extends X{constructor({text:e,cause:t}){super({name:ii,message:`JSON parsing failed: Text: ${e}.
9
+ Error message: ${Hr(t)}`,cause:t}),this[si]=!0,this.text=e}static isInstance(e){return X.hasMarker(e,ai)}};si=oi;var li=`AI_LoadAPIKeyError`,ui=`vercel.ai.error.${li}`,di=Symbol.for(ui),fi;fi=di;var pi=`AI_LoadSettingError`,mi=`vercel.ai.error.${pi}`,hi=Symbol.for(mi),gi;gi=hi;var _i=`AI_NoContentGeneratedError`,vi=`vercel.ai.error.${_i}`,yi=Symbol.for(vi),bi;bi=yi;var xi=`AI_NoSuchModelError`,Si=`vercel.ai.error.${xi}`,Ci=Symbol.for(Si),wi;wi=Ci;var Ti=`AI_TooManyEmbeddingValuesForCallError`,Ei=`vercel.ai.error.${Ti}`,Di=Symbol.for(Ei),Oi,ki=class extends X{constructor(e){super({name:Ti,message:`Too many values for a single embedding call. The ${e.provider} model "${e.modelId}" can only embed up to ${e.maxEmbeddingsPerCall} values per call, but ${e.values.length} values were provided.`}),this[Oi]=!0,this.provider=e.provider,this.modelId=e.modelId,this.maxEmbeddingsPerCall=e.maxEmbeddingsPerCall,this.values=e.values}static isInstance(e){return X.hasMarker(e,Ei)}};Oi=Di;var Ai=`AI_TypeValidationError`,ji=`vercel.ai.error.${Ai}`,Mi=Symbol.for(ji),Ni,Pi=class e extends X{constructor({value:e,cause:t}){super({name:Ai,message:`Type validation failed: Value: ${JSON.stringify(e)}.
10
+ Error message: ${Hr(t)}`,cause:t}),this[Ni]=!0,this.value=e}static isInstance(e){return X.hasMarker(e,ji)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};Ni=Mi;var Fi=Pi,Ii=`AI_UnsupportedFunctionalityError`,Li=`vercel.ai.error.${Ii}`,Ri=Symbol.for(Li),zi,Bi=class extends X{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Ii,message:t}),this[zi]=!0,this.functionality=e}static isInstance(e){return X.hasMarker(e,Li)}};zi=Ri;var Vi=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Hi(e){}function Ui(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Hi,onError:n=Hi,onRetry:r=Hi,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=Wi(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1,i=e.slice(t+r);f(n,i,e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
11
+ `;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Vi(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Vi(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
12
+ `)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function Wi(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
13
+ `,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
14
+ `&&r++}}return[t,n]}var Gi=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Ui({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};function Q(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function Ki(e){return Object.fromEntries([...e.headers])}function qi(e=globalThis){var t,n,r;return e.window?`runtime/browser`:(t=e.navigator)?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(r=(n=e.process)?.versions)?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function Ji(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function Yi(e,...t){let n=Ji(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var Xi=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new qr({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},Zi=Xi();function Qi(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var $i=[`fetch failed`,`failed to fetch`];function ea({error:e,url:t,requestBodyValues:n}){if(Qi(e))return e;if(e instanceof TypeError&&$i.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new Z({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return e}var ta=`3.0.10`,na=/"__proto__"\s*:/,ra=/"constructor"\s*:/;function ia(e){let t=JSON.parse(e);return typeof t!=`object`||!t||na.test(e)===!1&&ra.test(e)===!1?t:aa(t)}function aa(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function oa(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return ia(e)}finally{Error.stackTraceLimit=t}}var sa=Symbol.for(`vercel.ai.validator`);function ca(e){return{[sa]:!0,validate:e}}function la(e){return typeof e==`object`&&!!e&&sa in e&&e[sa]===!0&&`validate`in e}function ua(e){return la(e)?e:da(e)}function da(e){return ca(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new Fi({value:t,cause:n.issues})}})}async function fa({value:e,schema:t}){let n=await pa({value:e,schema:t});if(!n.success)throw Fi.wrap({value:e,cause:n.error});return n.value}async function pa({value:e,schema:t}){let n=ua(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let t=await n.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:Fi.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:Fi.wrap({value:e,cause:t}),rawValue:e}}}async function ma({text:e,schema:t}){try{let n=oa(e);return t==null?n:fa({value:n,schema:t})}catch(t){throw ci.isInstance(t)||Fi.isInstance(t)?t:new ci({text:e,cause:t})}}async function ha({text:e,schema:t}){try{let n=oa(e);return t==null?{success:!0,value:n,rawValue:n}:await pa({value:n,schema:t})}catch(t){return{success:!1,error:ci.isInstance(t)?t:new ci({text:e,cause:t}),rawValue:void 0}}}function ga(e){try{return oa(e),!0}catch{return!1}}function _a({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Gi).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await ha({text:e,schema:t}))}}))}async function va({provider:e,providerOptions:t,schema:n}){if(t?.[e]==null)return;let r=await pa({value:t[e],schema:n});if(!r.success)throw new qr({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:r.error});return r.value}var ya=()=>globalThis.fetch,$=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>ba({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),ba=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=ya()})=>{try{let s=await o(e,{method:`POST`,headers:Yi(t,`ai-sdk/provider-utils/${ta}`,qi()),body:n.content,signal:a}),c=Ki(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw Qi(t)||Z.isInstance(t)?t:new Z({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(Qi(t)||Z.isInstance(t))?t:new Z({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw ea({error:t,url:e,requestBodyValues:n.values})}},xa=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await r.text(),s=Ki(r);if(o.trim()===``)return{responseHeaders:s,value:new Z({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await ma({text:o,schema:e});return{responseHeaders:s,value:new Z({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new Z({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},Sa=e=>async({response:t})=>{let n=Ki(t);if(t.body==null)throw new Vr({});return{responseHeaders:n,value:_a({stream:t.body,schema:e})}},Ca=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await t.text(),a=await ha({text:i,schema:e}),o=Ki(t);if(!a.success)throw new Z({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}},{btoa:wa,atob:Ta}=globalThis;function Ea(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return wa(t)}function Da(e){return e instanceof Uint8Array?Ea(e):e}function Oa(e){return e?.replace(/\/$/,``)}function ka(e){var t,n;return(n=(t=e?.providerOptions)?.openaiCompatible)??{}}function Aa(e){let t=[];for(let{role:n,content:r,...i}of e){let e=ka({...i});switch(n){case`system`:t.push({role:`system`,content:r,...e});break;case`user`:if(r.length===1&&r[0].type===`text`){t.push({role:`user`,content:r[0].text,...ka(r[0])});break}t.push({role:`user`,content:r.map(e=>{let t=ka(e);switch(e.type){case`text`:return{type:`text`,text:e.text,...t};case`file`:if(e.mediaType.startsWith(`image/`)){let n=e.mediaType===`image/*`?`image/jpeg`:e.mediaType;return{type:`image_url`,image_url:{url:e.data instanceof URL?e.data.toString():`data:${n};base64,${Da(e.data)}`},...t}}else throw new Bi({functionality:`file part media type ${e.mediaType}`})}}),...e});break;case`assistant`:{let n=``,i=[];for(let e of r){let t=ka(e);switch(e.type){case`text`:n+=e.text;break;case`tool-call`:i.push({id:e.toolCallId,type:`function`,function:{name:e.toolName,arguments:JSON.stringify(e.input)},...t});break}}t.push({role:`assistant`,content:n,tool_calls:i.length>0?i:void 0,...e});break}case`tool`:for(let e of r){let n=e.output,r;switch(n.type){case`text`:case`error-text`:r=n.value;break;case`content`:case`json`:case`error-json`:r=JSON.stringify(n.value);break}let i=ka(e);t.push({role:`tool`,tool_call_id:e.toolCallId,content:r,...i})}break;default:{let e=n;throw Error(`Unsupported role: ${e}`)}}}return t}function ja({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function Ma(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`unknown`}}var Na=s.object({user:s.string().optional(),reasoningEffort:s.string().optional()}),Pa=s.object({error:s.object({message:s.string(),type:s.string().nullish(),param:s.any().nullish(),code:s.union([s.string(),s.number()]).nullish()})}),Fa={errorSchema:Pa,errorToMessage:e=>e.error.message};function Ia({tools:e,toolChoice:t}){e=e?.length?e:void 0;let n=[];if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:n};let r=[];for(let t of e)t.type===`provider-defined`?n.push({type:`unsupported-tool`,tool:t}):r.push({type:`function`,function:{name:t.name,description:t.description,parameters:t.inputSchema}});if(t==null)return{tools:r,toolChoice:void 0,toolWarnings:n};let i=t.type;switch(i){case`auto`:case`none`:case`required`:return{tools:r,toolChoice:i,toolWarnings:n};case`tool`:return{tools:r,toolChoice:{type:`function`,function:{name:t.toolName}},toolWarnings:n};default:{let e=i;throw new Bi({functionality:`tool choice type: ${e}`})}}}var La=class{constructor(e,t){this.specificationVersion=`v2`;var n,r;this.modelId=e,this.config=t;let i=(n=t.errorStructure)??Fa;this.chunkSchema=Ba(i.errorSchema),this.failedResponseHandler=xa(i),this.supportsStructuredOutputs=(r=t.supportsStructuredOutputs)??!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e,t,n;return(n=(t=(e=this.config).supportedUrls)?.call(e))??{}}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:i,frequencyPenalty:a,presencePenalty:o,providerOptions:s,stopSequences:c,responseFormat:l,seed:u,toolChoice:d,tools:f}){var p,m,h,g;let _=[],v=Object.assign((p=await va({provider:`openai-compatible`,providerOptions:s,schema:Na}))??{},(m=await va({provider:this.providerOptionsName,providerOptions:s,schema:Na}))??{});i!=null&&_.push({type:`unsupported-setting`,setting:`topK`}),l?.type===`json`&&l.schema!=null&&!this.supportsStructuredOutputs&&_.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format schema is only supported with structuredOutputs`});let{tools:y,toolChoice:b,toolWarnings:x}=Ia({tools:f,toolChoice:d});return{args:{model:this.modelId,user:v.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:a,presence_penalty:o,response_format:l?.type===`json`?this.supportsStructuredOutputs===!0&&l.schema!=null?{type:`json_schema`,json_schema:{schema:l.schema,name:(h=l.name)??`response`,description:l.description}}:{type:`json_object`}:void 0,stop:c,seed:u,...Object.fromEntries(Object.entries((g=s?.[this.providerOptionsName])??{}).filter(([e])=>!Object.keys(Na.shape).includes(e))),reasoning_effort:v.reasoningEffort,messages:Aa(e),tools:y,tool_choice:b},warnings:[..._,...x]}}async doGenerate(e){var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_;let{args:v,warnings:y}=await this.getArgs({...e}),b=JSON.stringify(v),{responseHeaders:x,value:S,rawValue:C}=await $({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:Q(this.config.headers(),e.headers),body:v,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Ca(za),abortSignal:e.abortSignal,fetch:this.config.fetch}),w=S.choices[0],T=[],E=w.message.content;E!=null&&E.length>0&&T.push({type:`text`,text:E});let D=(t=w.message.reasoning_content)??w.message.reasoning;if(D!=null&&D.length>0&&T.push({type:`reasoning`,text:D}),w.message.tool_calls!=null)for(let e of w.message.tool_calls)T.push({type:`tool-call`,toolCallId:(n=e.id)??Zi(),toolName:e.function.name,input:e.function.arguments});let O={[this.providerOptionsName]:{},...await(i=(r=this.config.metadataExtractor)?.extractMetadata)?.call(r,{parsedBody:C})},k=(a=S.usage)?.completion_tokens_details;return k?.accepted_prediction_tokens!=null&&(O[this.providerOptionsName].acceptedPredictionTokens=k?.accepted_prediction_tokens),k?.rejected_prediction_tokens!=null&&(O[this.providerOptionsName].rejectedPredictionTokens=k?.rejected_prediction_tokens),{content:T,finishReason:Ma(w.finish_reason),usage:{inputTokens:(s=(o=S.usage)?.prompt_tokens)??void 0,outputTokens:(l=(c=S.usage)?.completion_tokens)??void 0,totalTokens:(d=(u=S.usage)?.total_tokens)??void 0,reasoningTokens:(m=(p=(f=S.usage)?.completion_tokens_details)?.reasoning_tokens)??void 0,cachedInputTokens:(_=(g=(h=S.usage)?.prompt_tokens_details)?.cached_tokens)??void 0},providerMetadata:O,request:{body:b},response:{...ja(S),headers:x,body:C},warnings:y}}async doStream(e){var t;let{args:n,warnings:r}=await this.getArgs({...e}),i={...n,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},a=(t=this.config.metadataExtractor)?.createStreamExtractor(),{responseHeaders:o,value:s}=await $({url:this.config.url({path:`/chat/completions`,modelId:this.modelId}),headers:Q(this.config.headers(),e.headers),body:i,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Sa(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),c=[],l=`unknown`,u={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0},d=!0,f=this.providerOptionsName,p=!1,m=!1;return{stream:s.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:r})},transform(t,n){var r,i,o,s,f,h,g,_,v,y,b,x,S;if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){l=`error`,n.enqueue({type:`error`,error:t.error});return}let C=t.value;if(a?.processChunk(t.rawValue),`error`in C){l=`error`,n.enqueue({type:`error`,error:C.error.message});return}if(d&&(d=!1,n.enqueue({type:`response-metadata`,...ja(C)})),C.usage!=null){let{prompt_tokens:e,completion_tokens:t,total_tokens:n,prompt_tokens_details:r,completion_tokens_details:i}=C.usage;u.promptTokens=e??void 0,u.completionTokens=t??void 0,u.totalTokens=n??void 0,i?.reasoning_tokens!=null&&(u.completionTokensDetails.reasoningTokens=i?.reasoning_tokens),i?.accepted_prediction_tokens!=null&&(u.completionTokensDetails.acceptedPredictionTokens=i?.accepted_prediction_tokens),i?.rejected_prediction_tokens!=null&&(u.completionTokensDetails.rejectedPredictionTokens=i?.rejected_prediction_tokens),r?.cached_tokens!=null&&(u.promptTokensDetails.cachedTokens=r?.cached_tokens)}let w=C.choices[0];if(w?.finish_reason!=null&&(l=Ma(w.finish_reason)),w?.delta==null)return;let T=w.delta,E=(r=T.reasoning_content)??T.reasoning;if(E&&(p||=(n.enqueue({type:`reasoning-start`,id:`reasoning-0`}),!0),n.enqueue({type:`reasoning-delta`,id:`reasoning-0`,delta:E})),T.content&&(m||=(n.enqueue({type:`text-start`,id:`txt-0`}),!0),n.enqueue({type:`text-delta`,id:`txt-0`,delta:T.content})),T.tool_calls!=null)for(let e of T.tool_calls){let t=e.index;if(c[t]==null){if(e.id==null)throw new ri({data:e,message:`Expected 'id' to be a string.`});if((i=e.function)?.name==null)throw new ri({data:e,message:`Expected 'function.name' to be a string.`});n.enqueue({type:`tool-input-start`,id:e.id,toolName:e.function.name}),c[t]={id:e.id,type:`function`,function:{name:e.function.name,arguments:(o=e.function.arguments)??``},hasFinished:!1};let r=c[t];(s=r.function)?.name!=null&&(f=r.function)?.arguments!=null&&(r.function.arguments.length>0&&n.enqueue({type:`tool-input-delta`,id:r.id,delta:r.function.arguments}),ga(r.function.arguments)&&(n.enqueue({type:`tool-input-end`,id:r.id}),n.enqueue({type:`tool-call`,toolCallId:(h=r.id)??Zi(),toolName:r.function.name,input:r.function.arguments}),r.hasFinished=!0));continue}let r=c[t];if(r.hasFinished)continue;(g=e.function)?.arguments!=null&&(r.function.arguments+=(v=(_=e.function)?.arguments)??``),n.enqueue({type:`tool-input-delta`,id:r.id,delta:(y=e.function.arguments)??``}),(b=r.function)?.name!=null&&(x=r.function)?.arguments!=null&&ga(r.function.arguments)&&(n.enqueue({type:`tool-input-end`,id:r.id}),n.enqueue({type:`tool-call`,toolCallId:(S=r.id)??Zi(),toolName:r.function.name,input:r.function.arguments}),r.hasFinished=!0)}},flush(e){var t,n,r,i,o,s;p&&e.enqueue({type:`reasoning-end`,id:`reasoning-0`}),m&&e.enqueue({type:`text-end`,id:`txt-0`});for(let n of c.filter(e=>!e.hasFinished))e.enqueue({type:`tool-input-end`,id:n.id}),e.enqueue({type:`tool-call`,toolCallId:(t=n.id)??Zi(),toolName:n.function.name,input:n.function.arguments});let d={[f]:{},...a?.buildMetadata()};u.completionTokensDetails.acceptedPredictionTokens!=null&&(d[f].acceptedPredictionTokens=u.completionTokensDetails.acceptedPredictionTokens),u.completionTokensDetails.rejectedPredictionTokens!=null&&(d[f].rejectedPredictionTokens=u.completionTokensDetails.rejectedPredictionTokens),e.enqueue({type:`finish`,finishReason:l,usage:{inputTokens:(n=u.promptTokens)??void 0,outputTokens:(r=u.completionTokens)??void 0,totalTokens:(i=u.totalTokens)??void 0,reasoningTokens:(o=u.completionTokensDetails.reasoningTokens)??void 0,cachedInputTokens:(s=u.promptTokensDetails.cachedTokens)??void 0},providerMetadata:d})}})),request:{body:i},response:{headers:o}}}},Ra=s.object({prompt_tokens:s.number().nullish(),completion_tokens:s.number().nullish(),total_tokens:s.number().nullish(),prompt_tokens_details:s.object({cached_tokens:s.number().nullish()}).nullish(),completion_tokens_details:s.object({reasoning_tokens:s.number().nullish(),accepted_prediction_tokens:s.number().nullish(),rejected_prediction_tokens:s.number().nullish()}).nullish()}).nullish(),za=s.object({id:s.string().nullish(),created:s.number().nullish(),model:s.string().nullish(),choices:s.array(s.object({message:s.object({role:s.literal(`assistant`).nullish(),content:s.string().nullish(),reasoning_content:s.string().nullish(),reasoning:s.string().nullish(),tool_calls:s.array(s.object({id:s.string().nullish(),function:s.object({name:s.string(),arguments:s.string()})})).nullish()}),finish_reason:s.string().nullish()})),usage:Ra}),Ba=e=>s.union([s.object({id:s.string().nullish(),created:s.number().nullish(),model:s.string().nullish(),choices:s.array(s.object({delta:s.object({role:s.enum([`assistant`]).nullish(),content:s.string().nullish(),reasoning_content:s.string().nullish(),reasoning:s.string().nullish(),tool_calls:s.array(s.object({index:s.number(),id:s.string().nullish(),function:s.object({name:s.string().nullish(),arguments:s.string().nullish()})})).nullish()}).nullish(),finish_reason:s.string().nullish()})),usage:Ra}),e]);function Va({prompt:e,user:t=`user`,assistant:n=`assistant`}){let r=``;e[0].role===`system`&&(r+=`${e[0].content}
9
15
 
10
- `)}})).pipeThrough(new TextEncoderStream),{headers:Dr})}return e.json({error:`No chat handlers found.`},404)}).get(`/capabilities`,async e=>{let t=e.env.listeners,n={ui:t.ui.length>0,chat:t.chat.length>0,request:t.request.length>0,error:t.error.length>0};return e.json(n,200)}).get(`/health`,async e=>e.body(`OK`,200)).get(`/ui`,async e=>{let t=e.req.query(`selected_options`),n;if(t)try{n=JSON.parse(t)}catch{return e.json({error:`Invalid selected_options query parameter!`},400)}let r=e.env.listeners.ui;for(let t of r){let r=await t({selectedOptions:n});if(!r)continue;return e.json(r,200)}return e.json({error:`No UI listener returned a response`},404)}),Er=new er().route(`/_agent`,Tr).all(`*`,async e=>{let t=e.env.listeners.request;for(let n of t){let t=await n(e.req.raw,e.env.context);if(t)return t}return e.json({error:`No request handlers found.`},404)}),Dr={"content-type":`text/event-stream`,"cache-control":`no-cache, no-transform`,connection:`keep-alive`,"x-accel-buffering":`no`};function Or(e){return e}const kr=Object.freeze({withContext(e,t){let n={};for(let r of Object.keys(e)){let i=e[r];n[r]=i.withContext(t)}return n},with(e,t){let n={};for(let r of Object.keys(e)){let i=e[r];n[r]=i.withContext(t)}return n},async withApproval(e){let t={};for(let[n,r]of Object.entries(e.tools)){let e=r.execute;t[n]={...r,execute:async(t,n)=>{if(r.autoApprove&&e){let i=await r.autoApprove(t);if(i)return e(t,n)}let i={type:`tool-approval`,outcome:`pending`};return i}}}let n=e.messages[e.messages.length-1];if(!n?.parts)return t;let r=[];for(let t of n.parts){if(!u(t))continue;let n=l(t),i=e.tools[n];if(!i||t.state!==`output-available`||!i.execute||!Ar(t.output))continue;t.output.outcome===`approved`&&r.push({toolName:l(t),tool:i,input:t.input,toolCallId:t.toolCallId})}if(r.length>0){let t=c({execute:async({writer:t})=>{t.write({type:`start-step`}),await Promise.all(r.map(async n=>{if(!n.tool.execute)throw Error(`Tool does not support execute.`);t.write({type:`tool-input-available`,toolCallId:n.toolCallId,toolName:n.toolName,input:n.input});try{let r=await n.tool.execute(n.input,{toolCallId:n.toolCallId,messages:s(e.messages,{tools:e.tools}),abortSignal:e.abortSignal});if(mt(r))for await(let e of r)t.write({type:`tool-output-available`,toolCallId:n.toolCallId,output:e,preliminary:!0});t.write({type:`tool-output-available`,toolCallId:n.toolCallId,output:r})}catch(e){t.write({type:`tool-output-error`,toolCallId:n.toolCallId,errorText:e instanceof Error?e.message:String(e)})}})),t.write({type:`finish`})}});throw new Cr(`Executing tools`,t)}return t},prefix(e,t){let n={};for(let[r,i]of Object.entries(e))n[`${t}${r}`]=i;return n}});function Ar(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-approval`}function jr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n!==void 0&&n.role===`user`&&!(typeof n.metadata!=`object`||n.metadata===null)&&`options`in n.metadata)return n.metadata.options}}const Mr=`x-blink-stream-response-format`;function Nr(e,t){let n=new Headers(e.headers);return n.set(Mr,t),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}export{Mr as StreamResponseFormatHeader,wr as agent,Er as api,Ar as isToolApprovalOutput,jr as lastUIOptions,Or as toolWithApproval,kr as tools,Nr as withResponseFormat};
16
+ `,e=e.slice(1));for(let{role:i,content:a}of e)switch(i){case`system`:throw new Qr({message:"Unexpected system message in prompt: ${content}",prompt:e});case`user`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text}}).filter(Boolean).join(``);r+=`${t}:
17
+ ${e}
18
+
19
+ `;break}case`assistant`:{let e=a.map(e=>{switch(e.type){case`text`:return e.text;case`tool-call`:throw new Bi({functionality:`tool-call messages`})}}).join(``);r+=`${n}:
20
+ ${e}
21
+
22
+ `;break}case`tool`:throw new Bi({functionality:`tool messages`});default:{let e=i;throw Error(`Unsupported role: ${e}`)}}return r+=`${n}:
23
+ `,{prompt:r,stopSequences:[`
24
+ ${t}:`]}}function Ha({id:e,model:t,created:n}){return{id:e??void 0,modelId:t??void 0,timestamp:n==null?void 0:new Date(n*1e3)}}function Ua(e){switch(e){case`stop`:return`stop`;case`length`:return`length`;case`content_filter`:return`content-filter`;case`function_call`:case`tool_calls`:return`tool-calls`;default:return`unknown`}}var Wa=s.object({echo:s.boolean().optional(),logitBias:s.record(s.string(),s.number()).optional(),suffix:s.string().optional(),user:s.string().optional()}),Ga=class{constructor(e,t){this.specificationVersion=`v2`;var n;this.modelId=e,this.config=t;let r=(n=t.errorStructure)??Fa;this.chunkSchema=Ja(r.errorSchema),this.failedResponseHandler=xa(r)}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}get supportedUrls(){var e,t,n;return(n=(t=(e=this.config).supportedUrls)?.call(e))??{}}async getArgs({prompt:e,maxOutputTokens:t,temperature:n,topP:r,topK:i,frequencyPenalty:a,presencePenalty:o,stopSequences:s,responseFormat:c,seed:l,providerOptions:u,tools:d,toolChoice:f}){var p;let m=[],h=(p=await va({provider:this.providerOptionsName,providerOptions:u,schema:Wa}))??{};i!=null&&m.push({type:`unsupported-setting`,setting:`topK`}),d?.length&&m.push({type:`unsupported-setting`,setting:`tools`}),f!=null&&m.push({type:`unsupported-setting`,setting:`toolChoice`}),c!=null&&c.type!==`text`&&m.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format is not supported.`});let{prompt:g,stopSequences:_}=Va({prompt:e}),v=[..._??[],...s??[]];return{args:{model:this.modelId,echo:h.echo,logit_bias:h.logitBias,suffix:h.suffix,user:h.user,max_tokens:t,temperature:n,top_p:r,frequency_penalty:a,presence_penalty:o,seed:l,...u?.[this.providerOptionsName],prompt:g,stop:v.length>0?v:void 0},warnings:m}}async doGenerate(e){var t,n,r,i,a,o;let{args:s,warnings:c}=await this.getArgs(e),{responseHeaders:l,value:u,rawValue:d}=await $({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:Q(this.config.headers(),e.headers),body:s,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Ca(qa),abortSignal:e.abortSignal,fetch:this.config.fetch}),f=u.choices[0],p=[];return f.text!=null&&f.text.length>0&&p.push({type:`text`,text:f.text}),{content:p,usage:{inputTokens:(n=(t=u.usage)?.prompt_tokens)??void 0,outputTokens:(i=(r=u.usage)?.completion_tokens)??void 0,totalTokens:(o=(a=u.usage)?.total_tokens)??void 0},finishReason:Ua(f.finish_reason),request:{body:s},response:{...Ha(u),headers:l,body:d},warnings:c}}async doStream(e){let{args:t,warnings:n}=await this.getArgs(e),r={...t,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},{responseHeaders:i,value:a}=await $({url:this.config.url({path:`/completions`,modelId:this.modelId}),headers:Q(this.config.headers(),e.headers),body:r,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Sa(this.chunkSchema),abortSignal:e.abortSignal,fetch:this.config.fetch}),o=`unknown`,s={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},c=!0;return{stream:a.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){var r,i,a;if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){o=`error`,n.enqueue({type:`error`,error:t.error});return}let l=t.value;if(`error`in l){o=`error`,n.enqueue({type:`error`,error:l.error});return}c&&(c=!1,n.enqueue({type:`response-metadata`,...Ha(l)}),n.enqueue({type:`text-start`,id:`0`})),l.usage!=null&&(s.inputTokens=(r=l.usage.prompt_tokens)??void 0,s.outputTokens=(i=l.usage.completion_tokens)??void 0,s.totalTokens=(a=l.usage.total_tokens)??void 0);let u=l.choices[0];u?.finish_reason!=null&&(o=Ua(u.finish_reason)),u?.text!=null&&n.enqueue({type:`text-delta`,id:`0`,delta:u.text})},flush(e){c||e.enqueue({type:`text-end`,id:`0`}),e.enqueue({type:`finish`,finishReason:o,usage:s})}})),request:{body:r},response:{headers:i}}}},Ka=s.object({prompt_tokens:s.number(),completion_tokens:s.number(),total_tokens:s.number()}),qa=s.object({id:s.string().nullish(),created:s.number().nullish(),model:s.string().nullish(),choices:s.array(s.object({text:s.string(),finish_reason:s.string()})),usage:Ka.nullish()}),Ja=e=>s.union([s.object({id:s.string().nullish(),created:s.number().nullish(),model:s.string().nullish(),choices:s.array(s.object({text:s.string(),finish_reason:s.string().nullish(),index:s.number()})),usage:Ka.nullish()}),e]),Ya=s.object({dimensions:s.number().optional(),user:s.string().optional()}),Xa=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){var e;return(e=this.config.maxEmbeddingsPerCall)??2048}get supportsParallelCalls(){var e;return(e=this.config.supportsParallelCalls)??!0}get providerOptionsName(){return this.config.provider.split(`.`)[0].trim()}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:r}){var i,a,o;let s=Object.assign((i=await va({provider:`openai-compatible`,providerOptions:r,schema:Ya}))??{},(a=await va({provider:this.providerOptionsName,providerOptions:r,schema:Ya}))??{});if(e.length>this.maxEmbeddingsPerCall)throw new ki({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:e});let{responseHeaders:c,value:l,rawValue:u}=await $({url:this.config.url({path:`/embeddings`,modelId:this.modelId}),headers:Q(this.config.headers(),t),body:{model:this.modelId,input:e,encoding_format:`float`,dimensions:s.dimensions,user:s.user},failedResponseHandler:xa((o=this.config.errorStructure)??Fa),successfulResponseHandler:Ca(Za),abortSignal:n,fetch:this.config.fetch});return{embeddings:l.data.map(e=>e.embedding),usage:l.usage?{tokens:l.usage.prompt_tokens}:void 0,providerMetadata:l.providerMetadata,response:{headers:c,body:u}}}},Za=s.object({data:s.array(s.object({embedding:s.array(s.number())})),usage:s.object({prompt_tokens:s.number()}).nullish(),providerMetadata:s.record(s.string(),s.record(s.string(),s.any())).optional()}),Qa=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v2`,this.maxImagesPerCall=10}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,size:n,aspectRatio:r,seed:i,providerOptions:a,headers:o,abortSignal:s}){var c,l,u,d,f;let p=[];r!=null&&p.push({type:`unsupported-setting`,setting:`aspectRatio`,details:"This model does not support aspect ratio. Use `size` instead."}),i!=null&&p.push({type:`unsupported-setting`,setting:`seed`});let m=(u=(l=(c=this.config._internal)?.currentDate)?.call(c))??new Date,{value:h,responseHeaders:g}=await $({url:this.config.url({path:`/images/generations`,modelId:this.modelId}),headers:Q(this.config.headers(),o),body:{model:this.modelId,prompt:e,n:t,size:n,...(d=a.openai)??{},response_format:`b64_json`},failedResponseHandler:xa((f=this.config.errorStructure)??Fa),successfulResponseHandler:Ca($a),abortSignal:s,fetch:this.config.fetch});return{images:h.data.map(e=>e.b64_json),warnings:p,response:{timestamp:m,modelId:this.modelId,headers:g}}}},$a=s.object({data:s.array(s.object({b64_json:s.string()}))}),eo=`1.0.19`;function to(e){let t=Oa(e.baseURL),n=e.name,r={...e.apiKey&&{Authorization:`Bearer ${e.apiKey}`},...e.headers},i=()=>Yi(r,`ai-sdk/openai-compatible/${eo}`),a=r=>({provider:`${n}.${r}`,url:({path:n})=>{let r=new URL(`${t}${n}`);return e.queryParams&&(r.search=new URLSearchParams(e.queryParams).toString()),r.toString()},headers:i,fetch:e.fetch}),o=e=>s(e),s=t=>new La(t,{...a(`chat`),includeUsage:e.includeUsage,supportsStructuredOutputs:e.supportsStructuredOutputs}),c=t=>new Ga(t,{...a(`completion`),includeUsage:e.includeUsage}),l=e=>new Xa(e,{...a(`embedding`)}),u=e=>new Qa(e,a(`image`)),d=e=>o(e);return d.languageModel=o,d.chatModel=s,d.completionModel=c,d.textEmbeddingModel=l,d.imageModel=u,d}function no(){let e={chat:[],ui:[],request:[],error:[]},t={on:(n,r)=>(e[n]=[...e[n]??[],r],t),serve:t=>{t||={},t.host||=process.env.HOST??`127.0.0.1`,t.port||=parseInt(process.env.PORT??`3000`),t.apiUrl||=process.env.BLINK_API_URL;let n=br(t.apiUrl??``,{fetch:t.apiUrl?void 0:async()=>{throw console.warn(`Your code is attempting to use the Blink API server, but no API server is configured for this Blink agent.`),Error(`No API server is configured for this Blink agent. External APIs are not available.`)}}),r={chat:{async ensure(e){let t=await n.chat[`:key`].$post({param:{key:e}});if(t.status!==200)throw Error(`Failed to ensure chat!`);return t.json()},async message(e,t,r){let i=await n.chat[`:key`].sendMessages.$post({param:{key:e},json:{message:t,options:r??{}}});if(i.status!==204)throw Error(`Failed to send message!`)}},store:{async get(e){let t=await n.kv[`:key`].$get({param:{key:e}});if(t.status!==200)throw Error(`Failed to get value!`);let{value:r}=await t.json();return r},async set(e,t){let r=await n.kv[`:key`].$post({param:{key:e},json:{value:t}});if(r.status!==204)throw Error(`Failed to set value!`)},async delete(e){let t=await n.kv[`:key`].$delete({param:{key:e}});if(t.status!==204)throw Error(`Failed to delete value!`)},async list(e,t){let r=await n.kv.$get({query:{prefix:e,limit:t?.limit,cursor:t?.cursor}});if(r.status!==200)throw Error(`Failed to list values!`);return r.json()}}},i=o.createServer($t(t=>io.fetch(t,{context:r,listeners:e})));return i.listen(t?.port??3e3,t?.host??`127.0.0.1`)}};return t}const ro=new ar().post(`/chat`,Dr(`json`,e=>({messages:e.messages,chat:e.chat})),async e=>{let t=e.env.listeners.chat,n=e.req.valid(`json`);for(let r of t){let t;try{t=await r({chat:n.chat,messages:n.messages,abortSignal:e.req.raw.signal,context:e.env.context})}catch(e){if(e instanceof Or)t=e.response;else throw e}if(!t)continue;if(t instanceof Response)return t;let i;if(t instanceof ReadableStream)i=t;else if(typeof t==`object`&&`toUIMessageStream`in t)i=t.toUIMessageStream({messageMetadata:({part:e})=>{switch(e.type){case`finish`:return{totalUsage:e.totalUsage};case`finish-step`:return{usage:e.usage,model:e.response.modelId}}}});else throw Error(`Invalid chat handler result! Must be a Response, ReadableStream, or toUIMessageStream function.`);return new Response(i.pipeThrough(new TransformStream({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}\n\n`)},flush(e){e.enqueue(`data: [DONE]
25
+
26
+ `)}})).pipeThrough(new TextEncoderStream),{headers:ao})}return e.json({error:`No chat handlers found.`},404)}).get(`/capabilities`,async e=>{let t=e.env.listeners,n={ui:t.ui.length>0,chat:t.chat.length>0,request:t.request.length>0,error:t.error.length>0};return e.json(n,200)}).get(`/health`,async e=>e.body(`OK`,200)).get(`/ui`,async e=>{let t=e.req.query(`selected_options`),n;if(t)try{n=JSON.parse(t)}catch{return e.json({error:`Invalid selected_options query parameter!`},400)}let r=e.env.listeners.ui;for(let t of r){let r=await t({selectedOptions:n});if(!r)continue;return e.json(r,200)}return e.json({error:`No UI listener returned a response`},404)}),io=new ar().route(`/_agent`,ro).all(`*`,async e=>{let t=e.env.listeners.request;for(let n of t){let t=await n(e.req.raw,e.env.context);if(t)return t}return e.json({error:`No request handlers found.`},404)}),ao={"content-type":`text/event-stream`,"cache-control":`no-cache, no-transform`,connection:`keep-alive`,"x-accel-buffering":`no`},oo=e=>{let t=process.env.BLINK_TOKEN??process.env.BLINK_INVOCATION_AUTH_TOKEN;if(!t)throw Error(`You must be authenticated with Blink to use the model gateway.
27
+
28
+ Authenticate with "blink login".
29
+
30
+ Feel free to use other providers like OpenAI, Anthropic, or Google.`);return to({name:`Blink Gateway`,baseURL:`https://blink.so/api/ai-gateway/v1`,apiKey:t})(e)};function so(e){return e}const co=Object.freeze({withContext(e,t){let n={};for(let r of Object.keys(e)){let i=e[r];n[r]=i.withContext(t)}return n},with(e,t){let n={};for(let r of Object.keys(e)){let i=e[r];n[r]=i.withContext(t)}return n},async withApproval(e){let t={};for(let[n,r]of Object.entries(e.tools)){let e=r.execute;t[n]={...r,execute:async(t,n)=>{if(r.autoApprove&&e){let i=await r.autoApprove(t);if(i)return e(t,n)}let i={type:`tool-approval`,outcome:`pending`};return i}}}let n=e.messages[e.messages.length-1];if(!n?.parts)return t;let r=[];for(let t of n.parts){if(!d(t))continue;let n=u(t),i=e.tools[n];if(!i||t.state!==`output-available`||!i.execute||!lo(t.output))continue;t.output.outcome===`approved`&&r.push({toolName:u(t),tool:i,input:t.input,toolCallId:t.toolCallId})}if(r.length>0){let t=l({execute:async({writer:t})=>{t.write({type:`start-step`}),await Promise.all(r.map(async n=>{if(!n.tool.execute)throw Error(`Tool does not support execute.`);t.write({type:`tool-input-available`,toolCallId:n.toolCallId,toolName:n.toolName,input:n.input});try{let r=await n.tool.execute(n.input,{toolCallId:n.toolCallId,messages:c(e.messages,{tools:e.tools}),abortSignal:e.abortSignal});if(yt(r))for await(let e of r)t.write({type:`tool-output-available`,toolCallId:n.toolCallId,output:e,preliminary:!0});t.write({type:`tool-output-available`,toolCallId:n.toolCallId,output:r})}catch(e){t.write({type:`tool-output-error`,toolCallId:n.toolCallId,errorText:e instanceof Error?e.message:String(e)})}})),t.write({type:`finish`})}});throw new Or(`Executing tools`,t)}return t},prefix(e,t){let n={};for(let[r,i]of Object.entries(e))n[`${t}${r}`]=i;return n}});function lo(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-approval`}function uo(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n!==void 0&&n.role===`user`&&!(typeof n.metadata!=`object`||n.metadata===null)&&`options`in n.metadata)return n.metadata.options}}const fo=`x-blink-stream-response-format`;function po(e,t){let n=new Headers(e.headers);return n.set(fo,t),new Response(e.body,{status:e.status,statusText:e.statusText,headers:n})}export{fo as StreamResponseFormatHeader,no as agent,io as api,lo as isToolApprovalOutput,uo as lastUIOptions,oo as model,so as toolWithApproval,co as tools,po as withResponseFormat};