@elizaos/plugin-openai 1.5.14 → 1.5.16

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.
@@ -1,3 +1,4 @@
1
- import{createOpenAI as x}from"@ai-sdk/openai";import{EventType as b,logger as X,ModelType as F,VECTOR_DIMS as N}from"@elizaos/core";import{generateObject as M,generateText as V,JSONParseError as P}from"ai";import{encodingForModel as U}from"js-tiktoken";function z(Q,G,W){return Q.getSetting(G)??process.env[G]??W}function h(){return typeof globalThis<"u"&&typeof globalThis.document<"u"}function c(Q){return h()&&!!z(Q,"OPENAI_BROWSER_BASE_URL")}function K(Q,G=!1){if(h())return{};let W=G?y(Q):O(Q);return W?{Authorization:`Bearer ${W}`}:{}}function j(Q){let G=z(Q,"OPENAI_BROWSER_BASE_URL"),W=h()&&G?G:z(Q,"OPENAI_BASE_URL","https://api.openai.com/v1");return X.debug(`[OpenAI] Default base URL: ${W}`),W}function T(Q){let G=h()?z(Q,"OPENAI_BROWSER_EMBEDDING_URL")||z(Q,"OPENAI_BROWSER_BASE_URL"):z(Q,"OPENAI_EMBEDDING_URL");if(G)return X.debug(`[OpenAI] Using specific embedding base URL: ${G}`),G;return X.debug("[OpenAI] Falling back to general base URL for embeddings."),j(Q)}function O(Q){return z(Q,"OPENAI_API_KEY")}function y(Q){let G=z(Q,"OPENAI_EMBEDDING_API_KEY");if(G)return X.debug("[OpenAI] Using specific embedding API key (present)"),G;return X.debug("[OpenAI] Falling back to general API key for embeddings."),O(Q)}function A(Q){return z(Q,"OPENAI_SMALL_MODEL")??z(Q,"SMALL_MODEL","gpt-5-nano")}function D(Q){return z(Q,"OPENAI_LARGE_MODEL")??z(Q,"LARGE_MODEL","gpt-5-mini")}function d(Q){return z(Q,"OPENAI_IMAGE_DESCRIPTION_MODEL","gpt-5-nano")??"gpt-5-nano"}function k(Q){let G=z(Q,"OPENAI_EXPERIMENTAL_TELEMETRY","false"),W=String(G).toLowerCase(),Y=W==="true";return X.debug(`[OpenAI] Experimental telemetry in function: "${G}" (type: ${typeof G}, normalized: "${W}", result: ${Y})`),Y}function B(Q){let G=j(Q),W=O(Q)??(c(Q)?"sk-proxy":void 0);return x({apiKey:W??"",baseURL:G})}async function l(Q,G){let W=Q===F.TEXT_SMALL?process.env.OPENAI_SMALL_MODEL??process.env.SMALL_MODEL??"gpt-5-nano":process.env.LARGE_MODEL??"gpt-5-mini";return U(W).encode(G)}async function u(Q,G){let W=Q===F.TEXT_SMALL?process.env.OPENAI_SMALL_MODEL??process.env.SMALL_MODEL??"gpt-5-nano":process.env.OPENAI_LARGE_MODEL??process.env.LARGE_MODEL??"gpt-5-mini";return U(W).decode(G)}async function E(Q,G,W,Y){let C=B(Q),H=Y(Q);X.log(`[OpenAI] Using ${W} model: ${H}`);let _=G.temperature??0;if(!!G.schema)X.info(`Using ${W} without schema validation (schema provided but output=no-schema)`);try{let{object:$,usage:Z}=await M({model:C.languageModel(H),output:"no-schema",prompt:G.prompt,temperature:_,experimental_repairText:L()});if(Z)v(Q,W,G.prompt,Z);return $}catch($){if($ instanceof P){X.error(`[generateObject] Failed to parse JSON: ${$.message}`);let I=await L()({text:$.text,error:$});if(I)try{let w=JSON.parse(I);return X.info("[generateObject] Successfully repaired JSON."),w}catch(w){let q=w instanceof Error?w.message:String(w);throw X.error(`[generateObject] Failed to parse repaired JSON: ${q}`),w}else throw X.error("[generateObject] JSON repair failed."),$}else{let Z=$ instanceof Error?$.message:String($);throw X.error(`[generateObject] Unknown error: ${Z}`),$}}}function L(){return async({text:Q,error:G})=>{try{if(G instanceof P){let W=Q.replace(/```json\n|\n```|```/g,"");return JSON.parse(W),W}return null}catch(W){let Y=W instanceof Error?W.message:String(W);return X.warn(`Failed to repair JSON text: ${Y}`),null}}}function v(Q,G,W,Y){Q.emitEvent(b.MODEL_USED,{provider:"openai",type:G,prompt:W,tokens:{prompt:Y.inputTokens,completion:Y.outputTokens,total:Y.totalTokens}})}async function f(Q,G){let W=z(Q,"OPENAI_TTS_MODEL","gpt-4o-mini-tts"),Y=z(Q,"OPENAI_TTS_VOICE","nova"),C=z(Q,"OPENAI_TTS_INSTRUCTIONS",""),H=j(Q),_=G.model||W,J=G.voice||Y,$=G.instructions??C,Z=G.format||"mp3";try{let I=await fetch(`${H}/audio/speech`,{method:"POST",headers:{...K(Q),"Content-Type":"application/json",...Z==="mp3"?{Accept:"audio/mpeg"}:{}},body:JSON.stringify({model:_,voice:J,input:G.text,format:Z,...$&&{instructions:$}})});if(!I.ok){let w=await I.text();throw Error(`OpenAI TTS error ${I.status}: ${w}`)}return I.body}catch(I){let w=I instanceof Error?I.message:String(I);throw Error(`Failed to fetch speech from OpenAI TTS: ${w}`)}}var p={name:"openai",description:"OpenAI plugin",config:{OPENAI_API_KEY:process.env.OPENAI_API_KEY,OPENAI_BASE_URL:process.env.OPENAI_BASE_URL,OPENAI_SMALL_MODEL:process.env.OPENAI_SMALL_MODEL,OPENAI_LARGE_MODEL:process.env.OPENAI_LARGE_MODEL,SMALL_MODEL:process.env.SMALL_MODEL,LARGE_MODEL:process.env.LARGE_MODEL,OPENAI_EMBEDDING_MODEL:process.env.OPENAI_EMBEDDING_MODEL,OPENAI_EMBEDDING_API_KEY:process.env.OPENAI_EMBEDDING_API_KEY,OPENAI_EMBEDDING_URL:process.env.OPENAI_EMBEDDING_URL,OPENAI_EMBEDDING_DIMENSIONS:process.env.OPENAI_EMBEDDING_DIMENSIONS,OPENAI_IMAGE_DESCRIPTION_MODEL:process.env.OPENAI_IMAGE_DESCRIPTION_MODEL,OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS:process.env.OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS,OPENAI_EXPERIMENTAL_TELEMETRY:process.env.OPENAI_EXPERIMENTAL_TELEMETRY},async init(Q,G){new Promise(async(W)=>{W();try{if(!O(G)&&!h()){X.warn("OPENAI_API_KEY is not set in environment - OpenAI functionality will be limited");return}try{let Y=j(G),C=await fetch(`${Y}/models`,{headers:{...K(G)}});if(!C.ok)X.warn(`OpenAI API key validation failed: ${C.statusText}`),X.warn("OpenAI functionality will be limited until a valid API key is provided");else X.log("OpenAI API key validated successfully")}catch(Y){let C=Y instanceof Error?Y.message:String(Y);X.warn(`Error validating OpenAI API key: ${C}`),X.warn("OpenAI functionality will be limited until a valid API key is provided")}}catch(Y){let C=Y?.errors?.map((H)=>H.message).join(", ")||(Y instanceof Error?Y.message:String(Y));X.warn(`OpenAI plugin configuration issue: ${C} - You need to configure the OPENAI_API_KEY in your environment variables`)}})},models:{[F.TEXT_EMBEDDING]:async(Q,G)=>{let W=z(Q,"OPENAI_EMBEDDING_MODEL","text-embedding-3-small"),Y=Number.parseInt(z(Q,"OPENAI_EMBEDDING_DIMENSIONS","1536")||"1536",10);if(!Object.values(N).includes(Y)){let _=`Invalid embedding dimension: ${Y}. Must be one of: ${Object.values(N).join(", ")}`;throw X.error(_),Error(_)}if(G===null){X.debug("Creating test embedding for initialization");let _=Array(Y).fill(0);return _[0]=0.1,_}let C;if(typeof G==="string")C=G;else if(typeof G==="object"&&G.text)C=G.text;else{X.warn("Invalid input format for embedding");let _=Array(Y).fill(0);return _[0]=0.2,_}if(!C.trim()){X.warn("Empty text for embedding");let _=Array(Y).fill(0);return _[0]=0.3,_}let H=T(Q);try{let _=await fetch(`${H}/embeddings`,{method:"POST",headers:{...K(Q,!0),"Content-Type":"application/json"},body:JSON.stringify({model:W,input:C})});if(!_.ok){X.error(`OpenAI API error: ${_.status} - ${_.statusText}`);let Z=Array(Y).fill(0);return Z[0]=0.4,Z}let J=await _.json();if(!J?.data?.[0]?.embedding){X.error("API returned invalid structure");let Z=Array(Y).fill(0);return Z[0]=0.5,Z}let $=J.data[0].embedding;if(J.usage){let Z={inputTokens:J.usage.prompt_tokens,outputTokens:0,totalTokens:J.usage.total_tokens};v(Q,F.TEXT_EMBEDDING,C,Z)}return X.log(`Got valid embedding with length ${$.length}`),$}catch(_){let J=_ instanceof Error?_.message:String(_);X.error(`Error generating embedding: ${J}`);let $=Array(Y).fill(0);return $[0]=0.6,$}},[F.TEXT_TOKENIZER_ENCODE]:async(Q,{prompt:G,modelType:W=F.TEXT_LARGE})=>{return await l(W??F.TEXT_LARGE,G)},[F.TEXT_TOKENIZER_DECODE]:async(Q,{tokens:G,modelType:W=F.TEXT_LARGE})=>{return await u(W??F.TEXT_LARGE,G)},[F.TEXT_SMALL]:async(Q,{prompt:G,stopSequences:W=[],maxTokens:Y=8192,temperature:C=0.7,frequencyPenalty:H=0.7,presencePenalty:_=0.7})=>{let J=B(Q),$=A(Q),Z=k(Q);X.log(`[OpenAI] Using TEXT_SMALL model: ${$}`),X.log(G);let{text:I,usage:w}=await V({model:J.languageModel($),prompt:G,system:Q.character.system??void 0,temperature:C,maxOutputTokens:Y,frequencyPenalty:H,presencePenalty:_,stopSequences:W,experimental_telemetry:{isEnabled:Z}});if(w)v(Q,F.TEXT_SMALL,G,w);return I},[F.TEXT_LARGE]:async(Q,{prompt:G,stopSequences:W=[],maxTokens:Y=8192,temperature:C=0.7,frequencyPenalty:H=0.7,presencePenalty:_=0.7})=>{let J=B(Q),$=D(Q),Z=k(Q);X.log(`[OpenAI] Using TEXT_LARGE model: ${$}`),X.log(G);let{text:I,usage:w}=await V({model:J.languageModel($),prompt:G,system:Q.character.system??void 0,temperature:C,maxOutputTokens:Y,frequencyPenalty:H,presencePenalty:_,stopSequences:W,experimental_telemetry:{isEnabled:Z}});if(w)v(Q,F.TEXT_LARGE,G,w);return I},[F.IMAGE]:async(Q,G)=>{let W=G.n||1,Y=G.size||"1024x1024",C=G.prompt,H="gpt-image-1";X.log("[OpenAI] Using IMAGE model: gpt-image-1");let _=j(Q);try{let J=await fetch(`${_}/images/generations`,{method:"POST",headers:{...K(Q),"Content-Type":"application/json"},body:JSON.stringify({model:"gpt-image-1",prompt:C,n:W,size:Y})});if(!J.ok)throw Error(`Failed to generate image: ${J.statusText}`);return(await J.json()).data}catch(J){let $=J instanceof Error?J.message:String(J);throw J}},[F.IMAGE_DESCRIPTION]:async(Q,G)=>{let W,Y,C=d(Q);X.log(`[OpenAI] Using IMAGE_DESCRIPTION model: ${C}`);let H=Number.parseInt(z(Q,"OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS","8192")||"8192",10);if(typeof G==="string")W=G,Y="Please analyze this image and provide a title and detailed description.";else W=G.imageUrl,Y=G.prompt||"Please analyze this image and provide a title and detailed description.";let _=[{role:"user",content:[{type:"text",text:Y},{type:"image_url",image_url:{url:W}}]}],J=j(Q);try{let $={model:C,messages:_,max_tokens:H},Z=await fetch(`${J}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",...K(Q)},body:JSON.stringify($)});if(!Z.ok)throw Error(`OpenAI API error: ${Z.status}`);let w=await Z.json(),q=w.choices?.[0]?.message?.content;if(w.usage)v(Q,F.IMAGE_DESCRIPTION,typeof G==="string"?G:G.prompt||"",{inputTokens:w.usage.prompt_tokens,outputTokens:w.usage.completion_tokens,totalTokens:w.usage.total_tokens});if(!q)return{title:"Failed to analyze image",description:"No response from API"};if(typeof G==="object"&&G.prompt&&G.prompt!=="Please analyze this image and provide a title and detailed description.")return q;let R=q.match(/title[:\s]+(.+?)(?:\n|$)/i)?.[1]?.trim()||"Image Analysis",S=q.replace(/title[:\s]+(.+?)(?:\n|$)/i,"").trim();return{title:R,description:S}}catch($){let Z=$ instanceof Error?$.message:String($);return X.error(`Error analyzing image: ${Z}`),{title:"Failed to analyze image",description:`Error: ${Z}`}}},[F.TRANSCRIPTION]:async(Q,G)=>{let W=z(Q,"OPENAI_TRANSCRIPTION_MODEL","gpt-4o-mini-transcribe");X.log(`[OpenAI] Using TRANSCRIPTION model: ${W}`);let Y=j(Q),C,H=null;if(G instanceof Blob||G instanceof File)C=G;else if(typeof G==="object"&&G!==null&&G.audio!=null){let Z=G;if(!(Z.audio instanceof Blob)&&!(Z.audio instanceof File))throw Error("TRANSCRIPTION param 'audio' must be a Blob/File. Wrap buffers as: new Blob([buffer], { type: 'audio/mpeg' })");if(C=Z.audio,H=Z,typeof Z.model==="string"&&Z.model)W=Z.model}else throw Error("TRANSCRIPTION expects a Blob/File or an object { audio: Blob/File, language?, response_format?, timestampGranularities?, prompt?, temperature?, model? }");let _=C.type||"audio/webm",J=C.name||(_.includes("mp3")||_.includes("mpeg")?"recording.mp3":_.includes("ogg")?"recording.ogg":_.includes("wav")?"recording.wav":_.includes("webm")?"recording.webm":"recording.bin"),$=new FormData;if($.append("file",C,J),$.append("model",String(W)),H){if(typeof H.language==="string")$.append("language",String(H.language));if(typeof H.response_format==="string")$.append("response_format",String(H.response_format));if(typeof H.prompt==="string")$.append("prompt",String(H.prompt));if(typeof H.temperature==="number")$.append("temperature",String(H.temperature));if(Array.isArray(H.timestampGranularities))for(let Z of H.timestampGranularities)$.append("timestamp_granularities[]",String(Z))}try{let Z=await fetch(`${Y}/audio/transcriptions`,{method:"POST",headers:{...K(Q)},body:$});if(!Z.ok)throw Error(`Failed to transcribe audio: ${Z.status} ${Z.statusText}`);return(await Z.json()).text||""}catch(Z){let I=Z instanceof Error?Z.message:String(Z);throw X.error(`TRANSCRIPTION error: ${I}`),Z}},[F.TEXT_TO_SPEECH]:async(Q,G)=>{let W=typeof G==="string"?{text:G}:G,Y=W.model||z(Q,"OPENAI_TTS_MODEL","gpt-4o-mini-tts");X.log(`[OpenAI] Using TEXT_TO_SPEECH model: ${Y}`);try{return await f(Q,W)}catch(C){let H=C instanceof Error?C.message:String(C);throw X.error(`Error in TEXT_TO_SPEECH: ${H}`),C}},[F.OBJECT_SMALL]:async(Q,G)=>{return E(Q,G,F.OBJECT_SMALL,A)},[F.OBJECT_LARGE]:async(Q,G)=>{return E(Q,G,F.OBJECT_LARGE,D)}},tests:[{name:"openai_plugin_tests",tests:[{name:"openai_test_url_and_api_key_validation",fn:async(Q)=>{let G=j(Q),W=await fetch(`${G}/models`,{headers:{Authorization:`Bearer ${O(Q)}`}}),Y=await W.json();if(X.log({data:Y?.data?.length??"N/A"},"Models Available"),!W.ok)throw Error(`Failed to validate OpenAI API key: ${W.statusText}`)}},{name:"openai_test_text_embedding",fn:async(Q)=>{try{let G=await Q.useModel(F.TEXT_EMBEDDING,{text:"Hello, world!"});X.log({embedding:G},"embedding")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in test_text_embedding: ${W}`),G}}},{name:"openai_test_text_large",fn:async(Q)=>{try{let G=await Q.useModel(F.TEXT_LARGE,{prompt:"What is the nature of reality in 10 words?"});if(G.length===0)throw Error("Failed to generate text");X.log({text:G},"generated with test_text_large")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in test_text_large: ${W}`),G}}},{name:"openai_test_text_small",fn:async(Q)=>{try{let G=await Q.useModel(F.TEXT_SMALL,{prompt:"What is the nature of reality in 10 words?"});if(G.length===0)throw Error("Failed to generate text");X.log({text:G},"generated with test_text_small")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in test_text_small: ${W}`),G}}},{name:"openai_test_image_generation",fn:async(Q)=>{X.log("openai_test_image_generation");try{let G=await Q.useModel(F.IMAGE,{prompt:"A beautiful sunset over a calm ocean",n:1,size:"1024x1024"});X.log({image:G},"generated with test_image_generation")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in test_image_generation: ${W}`),G}}},{name:"image-description",fn:async(Q)=>{try{X.log("openai_test_image_description");try{let G=await Q.useModel(F.IMAGE_DESCRIPTION,"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg");if(G&&typeof G==="object"&&"title"in G&&"description"in G)X.log({result:G},"Image description");else X.error("Invalid image description result format:",G)}catch(G){let W=G instanceof Error?G.message:String(G);X.error(`Error in image description test: ${W}`)}}catch(G){let W=G instanceof Error?G.message:String(G);X.error(`Error in openai_test_image_description: ${W}`)}}},{name:"openai_test_transcription",fn:async(Q)=>{X.log("openai_test_transcription");try{let W=await(await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg")).arrayBuffer(),Y=await Q.useModel(F.TRANSCRIPTION,Buffer.from(new Uint8Array(W)));X.log({transcription:Y},"generated with test_transcription")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in test_transcription: ${W}`),G}}},{name:"openai_test_text_tokenizer_encode",fn:async(Q)=>{let W=await Q.useModel(F.TEXT_TOKENIZER_ENCODE,{prompt:"Hello tokenizer encode!"});if(!Array.isArray(W)||W.length===0)throw Error("Failed to tokenize text: expected non-empty array of tokens");X.log({tokens:W},"Tokenized output")}},{name:"openai_test_text_tokenizer_decode",fn:async(Q)=>{let W=await Q.useModel(F.TEXT_TOKENIZER_ENCODE,{prompt:"Hello tokenizer decode!"}),Y=await Q.useModel(F.TEXT_TOKENIZER_DECODE,{tokens:W});if(Y!=="Hello tokenizer decode!")throw Error(`Decoded text does not match original. Expected "Hello tokenizer decode!", got "${Y}"`);X.log({decodedText:Y},"Decoded text")}},{name:"openai_test_text_to_speech",fn:async(Q)=>{try{if(!await f(Q,{text:"Hello, this is a test for text-to-speech."}))throw Error("Failed to generate speech");X.log("Generated speech successfully")}catch(G){let W=G instanceof Error?G.message:String(G);throw X.error(`Error in openai_test_text_to_speech: ${W}`),G}}}]}]},g=p;export{p as openaiPlugin,g as default};
1
+ var H6=Object.create;var{getPrototypeOf:$6,defineProperty:J2,getOwnPropertyNames:B1,getOwnPropertyDescriptor:G6}=Object,w1=Object.prototype.hasOwnProperty;var C6=(w,h,B)=>{B=w!=null?H6($6(w)):{};let U=h||!w||!w.__esModule?J2(B,"default",{value:w,enumerable:!0}):B;for(let I of B1(w))if(!w1.call(U,I))J2(U,I,{get:()=>w[I],enumerable:!0});return U},h1=new WeakMap,_0=(w)=>{var h=h1.get(w),B;if(h)return h;if(h=J2({},"__esModule",{value:!0}),w&&typeof w==="object"||typeof w==="function")B1(w).map((U)=>!w1.call(h,U)&&J2(h,U,{get:()=>w[U],enumerable:!(B=G6(w,U))||B.enumerable}));return h1.set(w,h),h},N6=(w,h)=>()=>(h||w((h={exports:{}}).exports,h),h.exports);var U1=(w,h)=>{for(var B in h)J2(w,B,{get:h[B],enumerable:!0,configurable:!0,set:(U)=>h[B]=()=>U})};var I1=(w,h)=>()=>(w&&(h=w(w=0)),h);var u0={};U1(u0,{transcode:()=>U8,resolveObjectURL:()=>h8,kStringMaxLength:()=>q1,kMaxLength:()=>F2,isUtf8:()=>B8,isAscii:()=>w8,default:()=>I8,constants:()=>D6,btoa:()=>M6,atob:()=>L6,INSPECT_MAX_BYTES:()=>Y1,File:()=>O6,Buffer:()=>_,Blob:()=>x6});function E6(w){var h=w.length;if(h%4>0)throw Error("Invalid string. Length must be a multiple of 4");var B=w.indexOf("=");if(B===-1)B=h;var U=B===h?0:4-B%4;return[B,U]}function W6(w,h){return(w+h)*3/4-h}function V6(w){var h,B=E6(w),U=B[0],I=B[1],X=new Uint8Array(W6(U,I)),Z=0,K=I>0?U-4:U,q;for(q=0;q<K;q+=4)h=R0[w.charCodeAt(q)]<<18|R0[w.charCodeAt(q+1)]<<12|R0[w.charCodeAt(q+2)]<<6|R0[w.charCodeAt(q+3)],X[Z++]=h>>16&255,X[Z++]=h>>8&255,X[Z++]=h&255;if(I===2)h=R0[w.charCodeAt(q)]<<2|R0[w.charCodeAt(q+1)]>>4,X[Z++]=h&255;if(I===1)h=R0[w.charCodeAt(q)]<<10|R0[w.charCodeAt(q+1)]<<4|R0[w.charCodeAt(q+2)]>>2,X[Z++]=h>>8&255,X[Z++]=h&255;return X}function j6(w){return S0[w>>18&63]+S0[w>>12&63]+S0[w>>6&63]+S0[w&63]}function A6(w,h,B){var U,I=[];for(var X=h;X<B;X+=3)U=(w[X]<<16&16711680)+(w[X+1]<<8&65280)+(w[X+2]&255),I.push(j6(U));return I.join("")}function Z1(w){var h,B=w.length,U=B%3,I=[],X=16383;for(var Z=0,K=B-U;Z<K;Z+=X)I.push(A6(w,Z,Z+X>K?K:Z+X));if(U===1)h=w[B-1],I.push(S0[h>>2]+S0[h<<4&63]+"==");else if(U===2)h=(w[B-2]<<8)+w[B-1],I.push(S0[h>>10]+S0[h>>4&63]+S0[h<<2&63]+"=");return I.join("")}function N2(w,h,B,U,I){var X,Z,K=I*8-U-1,q=(1<<K)-1,z=q>>1,G=-7,C=B?I-1:0,O=B?-1:1,x=w[h+C];C+=O,X=x&(1<<-G)-1,x>>=-G,G+=K;for(;G>0;X=X*256+w[h+C],C+=O,G-=8);Z=X&(1<<-G)-1,X>>=-G,G+=U;for(;G>0;Z=Z*256+w[h+C],C+=O,G-=8);if(X===0)X=1-z;else if(X===q)return Z?NaN:(x?-1:1)*(1/0);else Z=Z+Math.pow(2,U),X=X-z;return(x?-1:1)*Z*Math.pow(2,X-U)}function K1(w,h,B,U,I,X){var Z,K,q,z=X*8-I-1,G=(1<<z)-1,C=G>>1,O=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=U?0:X-1,l=U?1:-1,a=h<0||h===0&&1/h<0?1:0;if(h=Math.abs(h),isNaN(h)||h===1/0)K=isNaN(h)?1:0,Z=G;else{if(Z=Math.floor(Math.log(h)/Math.LN2),h*(q=Math.pow(2,-Z))<1)Z--,q*=2;if(Z+C>=1)h+=O/q;else h+=O*Math.pow(2,1-C);if(h*q>=2)Z++,q/=2;if(Z+C>=G)K=0,Z=G;else if(Z+C>=1)K=(h*q-1)*Math.pow(2,I),Z=Z+C;else K=h*Math.pow(2,C-1)*Math.pow(2,I),Z=0}for(;I>=8;w[B+x]=K&255,x+=l,K/=256,I-=8);Z=Z<<I|K,z+=I;for(;z>0;w[B+x]=Z&255,x+=l,Z/=256,z-=8);w[B+x-l]|=a*128}function c0(w){if(w>F2)throw RangeError('The value "'+w+'" is invalid for option "size"');let h=new Uint8Array(w);return Object.setPrototypeOf(h,_.prototype),h}function S2(w,h,B){return class extends B{constructor(){super();Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${w}]`,this.stack,delete this.name}get code(){return w}set code(I){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:I,writable:!0})}toString(){return`${this.name} [${w}]: ${this.message}`}}}function _(w,h,B){if(typeof w==="number"){if(typeof h==="string")throw TypeError('The "string" argument must be of type string. Received type number');return f2(w)}return H1(w,h,B)}function H1(w,h,B){if(typeof w==="string")return R6(w,h);if(ArrayBuffer.isView(w))return k6(w);if(w==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w);if(f0(w,ArrayBuffer)||w&&f0(w.buffer,ArrayBuffer))return R2(w,h,B);if(typeof SharedArrayBuffer<"u"&&(f0(w,SharedArrayBuffer)||w&&f0(w.buffer,SharedArrayBuffer)))return R2(w,h,B);if(typeof w==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let U=w.valueOf&&w.valueOf();if(U!=null&&U!==w)return _.from(U,h,B);let I=S6(w);if(I)return I;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof w[Symbol.toPrimitive]==="function")return _.from(w[Symbol.toPrimitive]("string"),h,B);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof w)}function $1(w){if(typeof w!=="number")throw TypeError('"size" argument must be of type number');else if(w<0)throw RangeError('The value "'+w+'" is invalid for option "size"')}function _6(w,h,B){if($1(w),w<=0)return c0(w);if(h!==void 0)return typeof B==="string"?c0(w).fill(h,B):c0(w).fill(h);return c0(w)}function f2(w){return $1(w),c0(w<0?0:y2(w)|0)}function R6(w,h){if(typeof h!=="string"||h==="")h="utf8";if(!_.isEncoding(h))throw TypeError("Unknown encoding: "+h);let B=G1(w,h)|0,U=c0(B),I=U.write(w,h);if(I!==B)U=U.slice(0,I);return U}function _2(w){let h=w.length<0?0:y2(w.length)|0,B=c0(h);for(let U=0;U<h;U+=1)B[U]=w[U]&255;return B}function k6(w){if(f0(w,Uint8Array)){let h=new Uint8Array(w);return R2(h.buffer,h.byteOffset,h.byteLength)}return _2(w)}function R2(w,h,B){if(h<0||w.byteLength<h)throw RangeError('"offset" is outside of buffer bounds');if(w.byteLength<h+(B||0))throw RangeError('"length" is outside of buffer bounds');let U;if(h===void 0&&B===void 0)U=new Uint8Array(w);else if(B===void 0)U=new Uint8Array(w,h);else U=new Uint8Array(w,h,B);return Object.setPrototypeOf(U,_.prototype),U}function S6(w){if(_.isBuffer(w)){let h=y2(w.length)|0,B=c0(h);if(B.length===0)return B;return w.copy(B,0,0,h),B}if(w.length!==void 0){if(typeof w.length!=="number"||Number.isNaN(w.length))return c0(0);return _2(w)}if(w.type==="Buffer"&&Array.isArray(w.data))return _2(w.data)}function y2(w){if(w>=F2)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F2.toString(16)+" bytes");return w|0}function G1(w,h){if(_.isBuffer(w))return w.length;if(ArrayBuffer.isView(w)||f0(w,ArrayBuffer))return w.byteLength;if(typeof w!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof w);let B=w.length,U=arguments.length>2&&arguments[2]===!0;if(!U&&B===0)return 0;let I=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return B;case"utf8":case"utf-8":return k2(w).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B*2;case"hex":return B>>>1;case"base64":return L1(w).length;default:if(I)return U?-1:k2(w).length;h=(""+h).toLowerCase(),I=!0}}function f6(w,h,B){let U=!1;if(h===void 0||h<0)h=0;if(h>this.length)return"";if(B===void 0||B>this.length)B=this.length;if(B<=0)return"";if(B>>>=0,h>>>=0,B<=h)return"";if(!w)w="utf8";while(!0)switch(w){case"hex":return l6(this,h,B);case"utf8":case"utf-8":return N1(this,h,B);case"ascii":return p6(this,h,B);case"latin1":case"binary":return d6(this,h,B);case"base64":return b6(this,h,B);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m6(this,h,B);default:if(U)throw TypeError("Unknown encoding: "+w);w=(w+"").toLowerCase(),U=!0}}function a0(w,h,B){let U=w[h];w[h]=w[B],w[B]=U}function C1(w,h,B,U,I){if(w.length===0)return-1;if(typeof B==="string")U=B,B=0;else if(B>2147483647)B=2147483647;else if(B<-2147483648)B=-2147483648;if(B=+B,Number.isNaN(B))B=I?0:w.length-1;if(B<0)B=w.length+B;if(B>=w.length)if(I)return-1;else B=w.length-1;else if(B<0)if(I)B=0;else return-1;if(typeof h==="string")h=_.from(h,U);if(_.isBuffer(h)){if(h.length===0)return-1;return J1(w,h,B,U,I)}else if(typeof h==="number"){if(h=h&255,typeof Uint8Array.prototype.indexOf==="function")if(I)return Uint8Array.prototype.indexOf.call(w,h,B);else return Uint8Array.prototype.lastIndexOf.call(w,h,B);return J1(w,[h],B,U,I)}throw TypeError("val must be string, number or Buffer")}function J1(w,h,B,U,I){let X=1,Z=w.length,K=h.length;if(U!==void 0){if(U=String(U).toLowerCase(),U==="ucs2"||U==="ucs-2"||U==="utf16le"||U==="utf-16le"){if(w.length<2||h.length<2)return-1;X=2,Z/=2,K/=2,B/=2}}function q(G,C){if(X===1)return G[C];else return G.readUInt16BE(C*X)}let z;if(I){let G=-1;for(z=B;z<Z;z++)if(q(w,z)===q(h,G===-1?0:z-G)){if(G===-1)G=z;if(z-G+1===K)return G*X}else{if(G!==-1)z-=z-G;G=-1}}else{if(B+K>Z)B=Z-K;for(z=B;z>=0;z--){let G=!0;for(let C=0;C<K;C++)if(q(w,z+C)!==q(h,C)){G=!1;break}if(G)return z}}return-1}function y6(w,h,B,U){B=Number(B)||0;let I=w.length-B;if(!U)U=I;else if(U=Number(U),U>I)U=I;let X=h.length;if(U>X/2)U=X/2;let Z;for(Z=0;Z<U;++Z){let K=parseInt(h.substr(Z*2,2),16);if(Number.isNaN(K))return Z;w[B+Z]=K}return Z}function c6(w,h,B,U){return E2(k2(h,w.length-B),w,B,U)}function u6(w,h,B,U){return E2(a6(h),w,B,U)}function v6(w,h,B,U){return E2(L1(h),w,B,U)}function g6(w,h,B,U){return E2(s6(h,w.length-B),w,B,U)}function b6(w,h,B){if(h===0&&B===w.length)return Z1(w);else return Z1(w.slice(h,B))}function N1(w,h,B){B=Math.min(w.length,B);let U=[],I=h;while(I<B){let X=w[I],Z=null,K=X>239?4:X>223?3:X>191?2:1;if(I+K<=B){let q,z,G,C;switch(K){case 1:if(X<128)Z=X;break;case 2:if(q=w[I+1],(q&192)===128){if(C=(X&31)<<6|q&63,C>127)Z=C}break;case 3:if(q=w[I+1],z=w[I+2],(q&192)===128&&(z&192)===128){if(C=(X&15)<<12|(q&63)<<6|z&63,C>2047&&(C<55296||C>57343))Z=C}break;case 4:if(q=w[I+1],z=w[I+2],G=w[I+3],(q&192)===128&&(z&192)===128&&(G&192)===128){if(C=(X&15)<<18|(q&63)<<12|(z&63)<<6|G&63,C>65535&&C<1114112)Z=C}}}if(Z===null)Z=65533,K=1;else if(Z>65535)Z-=65536,U.push(Z>>>10&1023|55296),Z=56320|Z&1023;U.push(Z),I+=K}return i6(U)}function i6(w){let h=w.length;if(h<=F1)return String.fromCharCode.apply(String,w);let B="",U=0;while(U<h)B+=String.fromCharCode.apply(String,w.slice(U,U+=F1));return B}function p6(w,h,B){let U="";B=Math.min(w.length,B);for(let I=h;I<B;++I)U+=String.fromCharCode(w[I]&127);return U}function d6(w,h,B){let U="";B=Math.min(w.length,B);for(let I=h;I<B;++I)U+=String.fromCharCode(w[I]);return U}function l6(w,h,B){let U=w.length;if(!h||h<0)h=0;if(!B||B<0||B>U)B=U;let I="";for(let X=h;X<B;++X)I+=t6[w[X]];return I}function m6(w,h,B){let U=w.slice(h,B),I="";for(let X=0;X<U.length-1;X+=2)I+=String.fromCharCode(U[X]+U[X+1]*256);return I}function j0(w,h,B){if(w%1!==0||w<0)throw RangeError("offset is not uint");if(w+h>B)throw RangeError("Trying to access beyond buffer length")}function x0(w,h,B,U,I,X){if(!_.isBuffer(w))throw TypeError('"buffer" argument must be a Buffer instance');if(h>I||h<X)throw RangeError('"value" argument is out of bounds');if(B+U>w.length)throw RangeError("Index out of range")}function E1(w,h,B,U,I){M1(h,U,I,w,B,7);let X=Number(h&BigInt(4294967295));w[B++]=X,X=X>>8,w[B++]=X,X=X>>8,w[B++]=X,X=X>>8,w[B++]=X;let Z=Number(h>>BigInt(32)&BigInt(4294967295));return w[B++]=Z,Z=Z>>8,w[B++]=Z,Z=Z>>8,w[B++]=Z,Z=Z>>8,w[B++]=Z,B}function W1(w,h,B,U,I){M1(h,U,I,w,B,7);let X=Number(h&BigInt(4294967295));w[B+7]=X,X=X>>8,w[B+6]=X,X=X>>8,w[B+5]=X,X=X>>8,w[B+4]=X;let Z=Number(h>>BigInt(32)&BigInt(4294967295));return w[B+3]=Z,Z=Z>>8,w[B+2]=Z,Z=Z>>8,w[B+1]=Z,Z=Z>>8,w[B]=Z,B+8}function V1(w,h,B,U,I,X){if(B+U>w.length)throw RangeError("Index out of range");if(B<0)throw RangeError("Index out of range")}function j1(w,h,B,U,I){if(h=+h,B=B>>>0,!I)V1(w,h,B,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return K1(w,h,B,U,23,4),B+4}function A1(w,h,B,U,I){if(h=+h,B=B>>>0,!I)V1(w,h,B,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return K1(w,h,B,U,52,8),B+8}function z1(w){let h="",B=w.length,U=w[0]==="-"?1:0;for(;B>=U+4;B-=3)h=`_${w.slice(B-3,B)}${h}`;return`${w.slice(0,B)}${h}`}function n6(w,h,B){if(w2(h,"offset"),w[h]===void 0||w[h+B]===void 0)z2(h,w.length-(B+1))}function M1(w,h,B,U,I,X){if(w>B||w<h){let Z=typeof h==="bigint"?"n":"",K;if(X>3)if(h===0||h===BigInt(0))K=`>= 0${Z} and < 2${Z} ** ${(X+1)*8}${Z}`;else K=`>= -(2${Z} ** ${(X+1)*8-1}${Z}) and < 2 ** ${(X+1)*8-1}${Z}`;else K=`>= ${h}${Z} and <= ${B}${Z}`;throw new P2("value",K,w)}n6(U,I,X)}function w2(w,h){if(typeof w!=="number")throw new P6(h,"number",w)}function z2(w,h,B){if(Math.floor(w)!==w)throw w2(w,B),new P2(B||"offset","an integer",w);if(h<0)throw new T6;throw new P2(B||"offset",`>= ${B?1:0} and <= ${h}`,w)}function r6(w){if(w=w.split("=")[0],w=w.trim().replace(o6,""),w.length<2)return"";while(w.length%4!==0)w=w+"=";return w}function k2(w,h){h=h||1/0;let B,U=w.length,I=null,X=[];for(let Z=0;Z<U;++Z){if(B=w.charCodeAt(Z),B>55295&&B<57344){if(!I){if(B>56319){if((h-=3)>-1)X.push(239,191,189);continue}else if(Z+1===U){if((h-=3)>-1)X.push(239,191,189);continue}I=B;continue}if(B<56320){if((h-=3)>-1)X.push(239,191,189);I=B;continue}B=(I-55296<<10|B-56320)+65536}else if(I){if((h-=3)>-1)X.push(239,191,189)}if(I=null,B<128){if((h-=1)<0)break;X.push(B)}else if(B<2048){if((h-=2)<0)break;X.push(B>>6|192,B&63|128)}else if(B<65536){if((h-=3)<0)break;X.push(B>>12|224,B>>6&63|128,B&63|128)}else if(B<1114112){if((h-=4)<0)break;X.push(B>>18|240,B>>12&63|128,B>>6&63|128,B&63|128)}else throw Error("Invalid code point")}return X}function a6(w){let h=[];for(let B=0;B<w.length;++B)h.push(w.charCodeAt(B)&255);return h}function s6(w,h){let B,U,I,X=[];for(let Z=0;Z<w.length;++Z){if((h-=2)<0)break;B=w.charCodeAt(Z),U=B>>8,I=B%256,X.push(I),X.push(U)}return X}function L1(w){return V6(r6(w))}function E2(w,h,B,U){let I;for(I=0;I<U;++I){if(I+B>=h.length||I>=w.length)break;h[I+B]=w[I]}return I}function f0(w,h){return w instanceof h||w!=null&&w.constructor!=null&&w.constructor.name!=null&&w.constructor.name===h.name}function i0(w){return typeof BigInt>"u"?e6:w}function e6(){throw Error("BigInt not supported")}function c2(w){return()=>{throw Error(w+" is not implemented for node:buffer browser polyfill")}}var S0,R0,T2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r0,X1,Q1,Y1=50,F2=2147483647,q1=536870888,M6,L6,O6,x6,D6,T6,P6,P2,F1=4096,o6,t6,h8,B8,w8=(w)=>{for(let h of w)if(h.charCodeAt(0)>127)return!1;return!0},U8,I8;var v0=I1(()=>{S0=[],R0=[];for(r0=0,X1=T2.length;r0<X1;++r0)S0[r0]=T2[r0],R0[T2.charCodeAt(r0)]=r0;R0[45]=62;R0[95]=63;Q1=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,M6=globalThis.btoa,L6=globalThis.atob,O6=globalThis.File,x6=globalThis.Blob,D6={MAX_LENGTH:F2,MAX_STRING_LENGTH:q1};T6=S2("ERR_BUFFER_OUT_OF_BOUNDS",function(w){if(w)return`${w} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),P6=S2("ERR_INVALID_ARG_TYPE",function(w,h){return`The "${w}" argument must be of type number. Received type ${typeof h}`},TypeError),P2=S2("ERR_OUT_OF_RANGE",function(w,h,B){let U=`The value of "${w}" is out of range.`,I=B;if(Number.isInteger(B)&&Math.abs(B)>4294967296)I=z1(String(B));else if(typeof B==="bigint"){if(I=String(B),B>BigInt(2)**BigInt(32)||B<-(BigInt(2)**BigInt(32)))I=z1(I);I+="n"}return U+=` It must be ${h}. Received ${I}`,U},RangeError);Object.defineProperty(_.prototype,"parent",{enumerable:!0,get:function(){if(!_.isBuffer(this))return;return this.buffer}});Object.defineProperty(_.prototype,"offset",{enumerable:!0,get:function(){if(!_.isBuffer(this))return;return this.byteOffset}});_.poolSize=8192;_.from=function(w,h,B){return H1(w,h,B)};Object.setPrototypeOf(_.prototype,Uint8Array.prototype);Object.setPrototypeOf(_,Uint8Array);_.alloc=function(w,h,B){return _6(w,h,B)};_.allocUnsafe=function(w){return f2(w)};_.allocUnsafeSlow=function(w){return f2(w)};_.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==_.prototype};_.compare=function(h,B){if(f0(h,Uint8Array))h=_.from(h,h.offset,h.byteLength);if(f0(B,Uint8Array))B=_.from(B,B.offset,B.byteLength);if(!_.isBuffer(h)||!_.isBuffer(B))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===B)return 0;let U=h.length,I=B.length;for(let X=0,Z=Math.min(U,I);X<Z;++X)if(h[X]!==B[X]){U=h[X],I=B[X];break}if(U<I)return-1;if(I<U)return 1;return 0};_.isEncoding=function(h){switch(String(h).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};_.concat=function(h,B){if(!Array.isArray(h))throw TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return _.alloc(0);let U;if(B===void 0){B=0;for(U=0;U<h.length;++U)B+=h[U].length}let I=_.allocUnsafe(B),X=0;for(U=0;U<h.length;++U){let Z=h[U];if(f0(Z,Uint8Array))if(X+Z.length>I.length){if(!_.isBuffer(Z))Z=_.from(Z);Z.copy(I,X)}else Uint8Array.prototype.set.call(I,Z,X);else if(!_.isBuffer(Z))throw TypeError('"list" argument must be an Array of Buffers');else Z.copy(I,X);X+=Z.length}return I};_.byteLength=G1;_.prototype._isBuffer=!0;_.prototype.swap16=function(){let h=this.length;if(h%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let B=0;B<h;B+=2)a0(this,B,B+1);return this};_.prototype.swap32=function(){let h=this.length;if(h%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let B=0;B<h;B+=4)a0(this,B,B+3),a0(this,B+1,B+2);return this};_.prototype.swap64=function(){let h=this.length;if(h%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let B=0;B<h;B+=8)a0(this,B,B+7),a0(this,B+1,B+6),a0(this,B+2,B+5),a0(this,B+3,B+4);return this};_.prototype.toString=function(){let h=this.length;if(h===0)return"";if(arguments.length===0)return N1(this,0,h);return f6.apply(this,arguments)};_.prototype.toLocaleString=_.prototype.toString;_.prototype.equals=function(h){if(!_.isBuffer(h))throw TypeError("Argument must be a Buffer");if(this===h)return!0;return _.compare(this,h)===0};_.prototype.inspect=function(){let h="",B=Y1;if(h=this.toString("hex",0,B).replace(/(.{2})/g,"$1 ").trim(),this.length>B)h+=" ... ";return"<Buffer "+h+">"};if(Q1)_.prototype[Q1]=_.prototype.inspect;_.prototype.compare=function(h,B,U,I,X){if(f0(h,Uint8Array))h=_.from(h,h.offset,h.byteLength);if(!_.isBuffer(h))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(B===void 0)B=0;if(U===void 0)U=h?h.length:0;if(I===void 0)I=0;if(X===void 0)X=this.length;if(B<0||U>h.length||I<0||X>this.length)throw RangeError("out of range index");if(I>=X&&B>=U)return 0;if(I>=X)return-1;if(B>=U)return 1;if(B>>>=0,U>>>=0,I>>>=0,X>>>=0,this===h)return 0;let Z=X-I,K=U-B,q=Math.min(Z,K),z=this.slice(I,X),G=h.slice(B,U);for(let C=0;C<q;++C)if(z[C]!==G[C]){Z=z[C],K=G[C];break}if(Z<K)return-1;if(K<Z)return 1;return 0};_.prototype.includes=function(h,B,U){return this.indexOf(h,B,U)!==-1};_.prototype.indexOf=function(h,B,U){return C1(this,h,B,U,!0)};_.prototype.lastIndexOf=function(h,B,U){return C1(this,h,B,U,!1)};_.prototype.write=function(h,B,U,I){if(B===void 0)I="utf8",U=this.length,B=0;else if(U===void 0&&typeof B==="string")I=B,U=this.length,B=0;else if(isFinite(B))if(B=B>>>0,isFinite(U)){if(U=U>>>0,I===void 0)I="utf8"}else I=U,U=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let X=this.length-B;if(U===void 0||U>X)U=X;if(h.length>0&&(U<0||B<0)||B>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!I)I="utf8";let Z=!1;for(;;)switch(I){case"hex":return y6(this,h,B,U);case"utf8":case"utf-8":return c6(this,h,B,U);case"ascii":case"latin1":case"binary":return u6(this,h,B,U);case"base64":return v6(this,h,B,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g6(this,h,B,U);default:if(Z)throw TypeError("Unknown encoding: "+I);I=(""+I).toLowerCase(),Z=!0}};_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};_.prototype.slice=function(h,B){let U=this.length;if(h=~~h,B=B===void 0?U:~~B,h<0){if(h+=U,h<0)h=0}else if(h>U)h=U;if(B<0){if(B+=U,B<0)B=0}else if(B>U)B=U;if(B<h)B=h;let I=this.subarray(h,B);return Object.setPrototypeOf(I,_.prototype),I};_.prototype.readUintLE=_.prototype.readUIntLE=function(h,B,U){if(h=h>>>0,B=B>>>0,!U)j0(h,B,this.length);let I=this[h],X=1,Z=0;while(++Z<B&&(X*=256))I+=this[h+Z]*X;return I};_.prototype.readUintBE=_.prototype.readUIntBE=function(h,B,U){if(h=h>>>0,B=B>>>0,!U)j0(h,B,this.length);let I=this[h+--B],X=1;while(B>0&&(X*=256))I+=this[h+--B]*X;return I};_.prototype.readUint8=_.prototype.readUInt8=function(h,B){if(h=h>>>0,!B)j0(h,1,this.length);return this[h]};_.prototype.readUint16LE=_.prototype.readUInt16LE=function(h,B){if(h=h>>>0,!B)j0(h,2,this.length);return this[h]|this[h+1]<<8};_.prototype.readUint16BE=_.prototype.readUInt16BE=function(h,B){if(h=h>>>0,!B)j0(h,2,this.length);return this[h]<<8|this[h+1]};_.prototype.readUint32LE=_.prototype.readUInt32LE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216};_.prototype.readUint32BE=_.prototype.readUInt32BE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])};_.prototype.readBigUInt64LE=i0(function(h){h=h>>>0,w2(h,"offset");let B=this[h],U=this[h+7];if(B===void 0||U===void 0)z2(h,this.length-8);let I=B+this[++h]*256+this[++h]*65536+this[++h]*16777216,X=this[++h]+this[++h]*256+this[++h]*65536+U*16777216;return BigInt(I)+(BigInt(X)<<BigInt(32))});_.prototype.readBigUInt64BE=i0(function(h){h=h>>>0,w2(h,"offset");let B=this[h],U=this[h+7];if(B===void 0||U===void 0)z2(h,this.length-8);let I=B*16777216+this[++h]*65536+this[++h]*256+this[++h],X=this[++h]*16777216+this[++h]*65536+this[++h]*256+U;return(BigInt(I)<<BigInt(32))+BigInt(X)});_.prototype.readIntLE=function(h,B,U){if(h=h>>>0,B=B>>>0,!U)j0(h,B,this.length);let I=this[h],X=1,Z=0;while(++Z<B&&(X*=256))I+=this[h+Z]*X;if(X*=128,I>=X)I-=Math.pow(2,8*B);return I};_.prototype.readIntBE=function(h,B,U){if(h=h>>>0,B=B>>>0,!U)j0(h,B,this.length);let I=B,X=1,Z=this[h+--I];while(I>0&&(X*=256))Z+=this[h+--I]*X;if(X*=128,Z>=X)Z-=Math.pow(2,8*B);return Z};_.prototype.readInt8=function(h,B){if(h=h>>>0,!B)j0(h,1,this.length);if(!(this[h]&128))return this[h];return(255-this[h]+1)*-1};_.prototype.readInt16LE=function(h,B){if(h=h>>>0,!B)j0(h,2,this.length);let U=this[h]|this[h+1]<<8;return U&32768?U|4294901760:U};_.prototype.readInt16BE=function(h,B){if(h=h>>>0,!B)j0(h,2,this.length);let U=this[h+1]|this[h]<<8;return U&32768?U|4294901760:U};_.prototype.readInt32LE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24};_.prototype.readInt32BE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]};_.prototype.readBigInt64LE=i0(function(h){h=h>>>0,w2(h,"offset");let B=this[h],U=this[h+7];if(B===void 0||U===void 0)z2(h,this.length-8);let I=this[h+4]+this[h+5]*256+this[h+6]*65536+(U<<24);return(BigInt(I)<<BigInt(32))+BigInt(B+this[++h]*256+this[++h]*65536+this[++h]*16777216)});_.prototype.readBigInt64BE=i0(function(h){h=h>>>0,w2(h,"offset");let B=this[h],U=this[h+7];if(B===void 0||U===void 0)z2(h,this.length-8);let I=(B<<24)+this[++h]*65536+this[++h]*256+this[++h];return(BigInt(I)<<BigInt(32))+BigInt(this[++h]*16777216+this[++h]*65536+this[++h]*256+U)});_.prototype.readFloatLE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return N2(this,h,!0,23,4)};_.prototype.readFloatBE=function(h,B){if(h=h>>>0,!B)j0(h,4,this.length);return N2(this,h,!1,23,4)};_.prototype.readDoubleLE=function(h,B){if(h=h>>>0,!B)j0(h,8,this.length);return N2(this,h,!0,52,8)};_.prototype.readDoubleBE=function(h,B){if(h=h>>>0,!B)j0(h,8,this.length);return N2(this,h,!1,52,8)};_.prototype.writeUintLE=_.prototype.writeUIntLE=function(h,B,U,I){if(h=+h,B=B>>>0,U=U>>>0,!I){let K=Math.pow(2,8*U)-1;x0(this,h,B,U,K,0)}let X=1,Z=0;this[B]=h&255;while(++Z<U&&(X*=256))this[B+Z]=h/X&255;return B+U};_.prototype.writeUintBE=_.prototype.writeUIntBE=function(h,B,U,I){if(h=+h,B=B>>>0,U=U>>>0,!I){let K=Math.pow(2,8*U)-1;x0(this,h,B,U,K,0)}let X=U-1,Z=1;this[B+X]=h&255;while(--X>=0&&(Z*=256))this[B+X]=h/Z&255;return B+U};_.prototype.writeUint8=_.prototype.writeUInt8=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,1,255,0);return this[B]=h&255,B+1};_.prototype.writeUint16LE=_.prototype.writeUInt16LE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,2,65535,0);return this[B]=h&255,this[B+1]=h>>>8,B+2};_.prototype.writeUint16BE=_.prototype.writeUInt16BE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,2,65535,0);return this[B]=h>>>8,this[B+1]=h&255,B+2};_.prototype.writeUint32LE=_.prototype.writeUInt32LE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,4,4294967295,0);return this[B+3]=h>>>24,this[B+2]=h>>>16,this[B+1]=h>>>8,this[B]=h&255,B+4};_.prototype.writeUint32BE=_.prototype.writeUInt32BE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,4,4294967295,0);return this[B]=h>>>24,this[B+1]=h>>>16,this[B+2]=h>>>8,this[B+3]=h&255,B+4};_.prototype.writeBigUInt64LE=i0(function(h,B=0){return E1(this,h,B,BigInt(0),BigInt("0xffffffffffffffff"))});_.prototype.writeBigUInt64BE=i0(function(h,B=0){return W1(this,h,B,BigInt(0),BigInt("0xffffffffffffffff"))});_.prototype.writeIntLE=function(h,B,U,I){if(h=+h,B=B>>>0,!I){let q=Math.pow(2,8*U-1);x0(this,h,B,U,q-1,-q)}let X=0,Z=1,K=0;this[B]=h&255;while(++X<U&&(Z*=256)){if(h<0&&K===0&&this[B+X-1]!==0)K=1;this[B+X]=(h/Z>>0)-K&255}return B+U};_.prototype.writeIntBE=function(h,B,U,I){if(h=+h,B=B>>>0,!I){let q=Math.pow(2,8*U-1);x0(this,h,B,U,q-1,-q)}let X=U-1,Z=1,K=0;this[B+X]=h&255;while(--X>=0&&(Z*=256)){if(h<0&&K===0&&this[B+X+1]!==0)K=1;this[B+X]=(h/Z>>0)-K&255}return B+U};_.prototype.writeInt8=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,1,127,-128);if(h<0)h=255+h+1;return this[B]=h&255,B+1};_.prototype.writeInt16LE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,2,32767,-32768);return this[B]=h&255,this[B+1]=h>>>8,B+2};_.prototype.writeInt16BE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,2,32767,-32768);return this[B]=h>>>8,this[B+1]=h&255,B+2};_.prototype.writeInt32LE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,4,2147483647,-2147483648);return this[B]=h&255,this[B+1]=h>>>8,this[B+2]=h>>>16,this[B+3]=h>>>24,B+4};_.prototype.writeInt32BE=function(h,B,U){if(h=+h,B=B>>>0,!U)x0(this,h,B,4,2147483647,-2147483648);if(h<0)h=4294967295+h+1;return this[B]=h>>>24,this[B+1]=h>>>16,this[B+2]=h>>>8,this[B+3]=h&255,B+4};_.prototype.writeBigInt64LE=i0(function(h,B=0){return E1(this,h,B,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});_.prototype.writeBigInt64BE=i0(function(h,B=0){return W1(this,h,B,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});_.prototype.writeFloatLE=function(h,B,U){return j1(this,h,B,!0,U)};_.prototype.writeFloatBE=function(h,B,U){return j1(this,h,B,!1,U)};_.prototype.writeDoubleLE=function(h,B,U){return A1(this,h,B,!0,U)};_.prototype.writeDoubleBE=function(h,B,U){return A1(this,h,B,!1,U)};_.prototype.copy=function(h,B,U,I){if(!_.isBuffer(h))throw TypeError("argument should be a Buffer");if(!U)U=0;if(!I&&I!==0)I=this.length;if(B>=h.length)B=h.length;if(!B)B=0;if(I>0&&I<U)I=U;if(I===U)return 0;if(h.length===0||this.length===0)return 0;if(B<0)throw RangeError("targetStart out of bounds");if(U<0||U>=this.length)throw RangeError("Index out of range");if(I<0)throw RangeError("sourceEnd out of bounds");if(I>this.length)I=this.length;if(h.length-B<I-U)I=h.length-B+U;let X=I-U;if(this===h&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(B,U,I);else Uint8Array.prototype.set.call(h,this.subarray(U,I),B);return X};_.prototype.fill=function(h,B,U,I){if(typeof h==="string"){if(typeof B==="string")I=B,B=0,U=this.length;else if(typeof U==="string")I=U,U=this.length;if(I!==void 0&&typeof I!=="string")throw TypeError("encoding must be a string");if(typeof I==="string"&&!_.isEncoding(I))throw TypeError("Unknown encoding: "+I);if(h.length===1){let Z=h.charCodeAt(0);if(I==="utf8"&&Z<128||I==="latin1")h=Z}}else if(typeof h==="number")h=h&255;else if(typeof h==="boolean")h=Number(h);if(B<0||this.length<B||this.length<U)throw RangeError("Out of range index");if(U<=B)return this;if(B=B>>>0,U=U===void 0?this.length:U>>>0,!h)h=0;let X;if(typeof h==="number")for(X=B;X<U;++X)this[X]=h;else{let Z=_.isBuffer(h)?h:_.from(h,I),K=Z.length;if(K===0)throw TypeError('The value "'+h+'" is invalid for argument "value"');for(X=0;X<U-B;++X)this[X+B]=Z[X%K]}return this};o6=/[^+/0-9A-Za-z-_]/g;t6=function(){let w=Array(256);for(let h=0;h<16;++h){let B=h*16;for(let U=0;U<16;++U)w[B+U]="0123456789abcdef"[h]+"0123456789abcdef"[U]}return w}();h8=c2("resolveObjectURL"),B8=c2("isUtf8"),U8=c2("transcode"),I8=_});var Y2={};U1(Y2,{setMaxListeners:()=>y1,once:()=>S1,listenerCount:()=>c1,init:()=>p0,getMaxListeners:()=>v1,getEventListeners:()=>f1,default:()=>q8,captureRejectionSymbol:()=>P1,addAbortListener:()=>g1,EventEmitter:()=>p0});function _1(w,h){var{_events:B}=w;if(h[0]??=Error("Unhandled error."),!B)throw h[0];var U=B[T1];if(U)for(var I of x1.call(U))I.apply(w,h);var X=B.error;if(!X)throw h[0];for(var I of x1.call(X))I.apply(w,h);return!0}function Q8(w,h,B,U){h.then(void 0,function(I){queueMicrotask(()=>J8(w,I,B,U))})}function J8(w,h,B,U){if(typeof w[O1]==="function")w[O1](h,B,...U);else try{w[s0]=!1,w.emit("error",h)}finally{w[s0]=!0}}function R1(w,h,B){B.warned=!0;let U=Error(`Possible EventEmitter memory leak detected. ${B.length} ${String(h)} listeners added to [${w.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);U.name="MaxListenersExceededWarning",U.emitter=w,U.type=h,U.count=B.length,console.warn(U)}function k1(w,h,...B){this.removeListener(w,h),h.apply(this,B)}function S1(w,h,B){var U=B?.signal;if(u1(U,"options.signal"),U?.aborted)throw new u2(void 0,{cause:U?.reason});let{resolve:I,reject:X,promise:Z}=$newPromiseCapability(Promise),K=(G)=>{if(w.removeListener(h,q),U!=null)W2(U,"abort",z);X(G)},q=(...G)=>{if(typeof w.removeListener==="function")w.removeListener("error",K);if(U!=null)W2(U,"abort",z);I(G)};if(D1(w,h,q,{once:!0}),h!=="error"&&typeof w.once==="function")w.once("error",K);function z(){W2(w,h,q),W2(w,"error",K),X(new u2(void 0,{cause:U?.reason}))}if(U!=null)D1(U,"abort",z,{once:!0});return Z}function f1(w,h){return w.listeners(h)}function y1(w,...h){g2(w,"setMaxListeners",0);var B;if(h&&(B=h.length))for(let U=0;U<B;U++)h[U].setMaxListeners(w);else t0=w}function c1(w,h){return w.listenerCount(h)}function W2(w,h,B,U){if(typeof w.removeListener==="function")w.removeListener(h,B);else w.removeEventListener(h,B,U)}function D1(w,h,B,U){if(typeof w.on==="function")if(U.once)w.once(h,B);else w.on(h,B);else w.addEventListener(h,B,U)}function U2(w,h,B){let U=TypeError(`The "${w}" argument must be of type ${h}. Received ${B}`);return U.code="ERR_INVALID_ARG_TYPE",U}function K8(w,h,B){let U=RangeError(`The "${w}" argument is out of range. It must be ${h}. Received ${B}`);return U.code="ERR_OUT_OF_RANGE",U}function u1(w,h){if(w!==void 0&&(w===null||typeof w!=="object"||!("aborted"in w)))throw U2(h,"AbortSignal",w)}function g2(w,h,B,U){if(typeof w!=="number")throw U2(h,"number",w);if(B!=null&&w<B||U!=null&&w>U||(B!=null||U!=null)&&Number.isNaN(w))throw K8(h,`${B!=null?`>= ${B}`:""}${B!=null&&U!=null?" && ":""}${U!=null?`<= ${U}`:""}`,w)}function K2(w){if(typeof w!=="function")throw TypeError("The listener must be a function")}function Y8(w,h){if(typeof w!=="boolean")throw U2(h,"boolean",w)}function v1(w){return w?._maxListeners??t0}function g1(w,h){if(w===void 0)throw U2("signal","AbortSignal",w);if(u1(w,"signal"),typeof h!=="function")throw U2("listener","function",h);let B;if(w.aborted)queueMicrotask(()=>h());else w.addEventListener("abort",h,{__proto__:null,once:!0}),B=()=>{w.removeEventListener("abort",h)};return{__proto__:null,[Symbol.dispose](){B?.()}}}var v2,s0,T1,X8,Z8,O1,P1,x1,t0=10,p0=function(h){if(this._events===void 0||this._events===this.__proto__._events)this._events={__proto__:null},this._eventsCount=0;if(this._maxListeners??=void 0,this[s0]=h?.captureRejections?Boolean(h?.captureRejections):C0[s0])this.emit=z8},C0,F8=function(h,...B){if(h==="error")return _1(this,B);var{_events:U}=this;if(U===void 0)return!1;var I=U[h];if(I===void 0)return!1;let X=I.length>1?I.slice():I;for(let Z=0,{length:K}=X;Z<K;Z++){let q=X[Z];switch(B.length){case 0:q.call(this);break;case 1:q.call(this,B[0]);break;case 2:q.call(this,B[0],B[1]);break;case 3:q.call(this,B[0],B[1],B[2]);break;default:q.apply(this,B);break}}return!0},z8=function(h,...B){if(h==="error")return _1(this,B);var{_events:U}=this;if(U===void 0)return!1;var I=U[h];if(I===void 0)return!1;let X=I.length>1?I.slice():I;for(let Z=0,{length:K}=X;Z<K;Z++){let q=X[Z],z;switch(B.length){case 0:z=q.call(this);break;case 1:z=q.call(this,B[0]);break;case 2:z=q.call(this,B[0],B[1]);break;case 3:z=q.call(this,B[0],B[1],B[2]);break;default:z=q.apply(this,B);break}if(z!==void 0&&typeof z?.then==="function"&&z.then===Promise.prototype.then)Q8(this,z,h,B)}return!0},u2,q8;var q2=I1(()=>{v2=Symbol.for,s0=Symbol("kCapture"),T1=v2("events.errorMonitor"),X8=Symbol("events.maxEventTargetListeners"),Z8=Symbol("events.maxEventTargetListenersWarned"),O1=v2("nodejs.rejection"),P1=v2("nodejs.rejection"),x1=Array.prototype.slice,C0=p0.prototype={};C0._events=void 0;C0._eventsCount=0;C0._maxListeners=void 0;C0.setMaxListeners=function(h){return g2(h,"setMaxListeners",0),this._maxListeners=h,this};C0.constructor=p0;C0.getMaxListeners=function(){return this?._maxListeners??t0};C0.emit=F8;C0.addListener=function(h,B){K2(B);var U=this._events;if(!U)U=this._events={__proto__:null},this._eventsCount=0;else if(U.newListener)this.emit("newListener",h,B.listener??B);var I=U[h];if(!I)U[h]=[B],this._eventsCount++;else{I.push(B);var X=this._maxListeners??t0;if(X>0&&I.length>X&&!I.warned)R1(this,h,I)}return this};C0.on=C0.addListener;C0.prependListener=function(h,B){K2(B);var U=this._events;if(!U)U=this._events={__proto__:null},this._eventsCount=0;else if(U.newListener)this.emit("newListener",h,B.listener??B);var I=U[h];if(!I)U[h]=[B],this._eventsCount++;else{I.unshift(B);var X=this._maxListeners??t0;if(X>0&&I.length>X&&!I.warned)R1(this,h,I)}return this};C0.once=function(h,B){K2(B);let U=k1.bind(this,h,B);return U.listener=B,this.addListener(h,U),this};C0.prependOnceListener=function(h,B){K2(B);let U=k1.bind(this,h,B);return U.listener=B,this.prependListener(h,U),this};C0.removeListener=function(h,B){K2(B);var{_events:U}=this;if(!U)return this;var I=U[h];if(!I)return this;var X=I.length;let Z=-1;for(let K=X-1;K>=0;K--)if(I[K]===B||I[K].listener===B){Z=K;break}if(Z<0)return this;if(Z===0)I.shift();else I.splice(Z,1);if(I.length===0)delete U[h],this._eventsCount--;return this};C0.off=C0.removeListener;C0.removeAllListeners=function(h){var{_events:B}=this;if(h&&B){if(B[h])delete B[h],this._eventsCount--}else this._events={__proto__:null};return this};C0.listeners=function(h){var{_events:B}=this;if(!B)return[];var U=B[h];if(!U)return[];return U.map((I)=>I.listener??I)};C0.rawListeners=function(h){var{_events:B}=this;if(!B)return[];var U=B[h];if(!U)return[];return U.slice()};C0.listenerCount=function(h){var{_events:B}=this;if(!B)return 0;return B[h]?.length??0};C0.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};C0[s0]=!1;u2=class u2 extends Error{constructor(w="The operation was aborted",h=void 0){if(h!==void 0&&typeof h!=="object")throw U2("options","Object",h);super(w,h);this.code="ABORT_ERR",this.name="AbortError"}};Object.defineProperties(p0,{captureRejections:{get(){return C0[s0]},set(w){Y8(w,"EventEmitter.captureRejections"),C0[s0]=w},enumerable:!0},defaultMaxListeners:{enumerable:!0,get:()=>{return t0},set:(w)=>{g2(w,"defaultMaxListeners",0),t0=w}},kMaxEventTargetListeners:{value:X8,enumerable:!1,configurable:!1,writable:!1},kMaxEventTargetListenersWarned:{value:Z8,enumerable:!1,configurable:!1,writable:!1}});Object.assign(p0,{once:S1,getEventListeners:f1,getMaxListeners:v1,setMaxListeners:y1,EventEmitter:p0,usingDomains:!1,captureRejectionSymbol:P1,errorMonitor:T1,addAbortListener:g1,init:p0,listenerCount:c1});q8=p0});var d2=N6((S8,o1)=>{var G0=(w,h)=>()=>(h||w((h={exports:{}}).exports,h),h.exports),N0=G0((w,h)=>{class B extends Error{constructor(U){if(!Array.isArray(U))throw TypeError(`Expected input to be an Array, got ${typeof U}`);let I="";for(let X=0;X<U.length;X++)I+=` ${U[X].stack}
2
+ `;super(I);this.name="AggregateError",this.errors=U}}h.exports={AggregateError:B,ArrayIsArray(U){return Array.isArray(U)},ArrayPrototypeIncludes(U,I){return U.includes(I)},ArrayPrototypeIndexOf(U,I){return U.indexOf(I)},ArrayPrototypeJoin(U,I){return U.join(I)},ArrayPrototypeMap(U,I){return U.map(I)},ArrayPrototypePop(U,I){return U.pop(I)},ArrayPrototypePush(U,I){return U.push(I)},ArrayPrototypeSlice(U,I,X){return U.slice(I,X)},Error,FunctionPrototypeCall(U,I,...X){return U.call(I,...X)},FunctionPrototypeSymbolHasInstance(U,I){return Function.prototype[Symbol.hasInstance].call(U,I)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(U,I){return Object.defineProperties(U,I)},ObjectDefineProperty(U,I,X){return Object.defineProperty(U,I,X)},ObjectGetOwnPropertyDescriptor(U,I){return Object.getOwnPropertyDescriptor(U,I)},ObjectKeys(U){return Object.keys(U)},ObjectSetPrototypeOf(U,I){return Object.setPrototypeOf(U,I)},Promise,PromisePrototypeCatch(U,I){return U.catch(I)},PromisePrototypeThen(U,I,X){return U.then(I,X)},PromiseReject(U){return Promise.reject(U)},PromiseResolve(U){return Promise.resolve(U)},ReflectApply:Reflect.apply,RegExpPrototypeTest(U,I){return U.test(I)},SafeSet:Set,String,StringPrototypeSlice(U,I,X){return U.slice(I,X)},StringPrototypeToLowerCase(U){return U.toLowerCase()},StringPrototypeToUpperCase(U){return U.toUpperCase()},StringPrototypeTrim(U){return U.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(U,I,X){return U.set(I,X)},Boolean,Uint8Array}}),b1=G0((w,h)=>{h.exports={format(B,...U){return B.replace(/%([sdifj])/g,function(...[I,X]){let Z=U.shift();if(X==="f")return Z.toFixed(6);else if(X==="j")return JSON.stringify(Z);else if(X==="s"&&typeof Z==="object")return`${Z.constructor!==Object?Z.constructor.name:""} {}`.trim();else return Z.toString()})},inspect(B){switch(typeof B){case"string":if(B.includes("'")){if(!B.includes('"'))return`"${B}"`;else if(!B.includes("`")&&!B.includes("${"))return`\`${B}\``}return`'${B}'`;case"number":if(isNaN(B))return"NaN";else if(Object.is(B,-0))return String(B);return B;case"bigint":return`${String(B)}n`;case"boolean":case"undefined":return String(B);case"object":return"{}"}}}}),L0=G0((w,h)=>{var{format:B,inspect:U}=b1(),{AggregateError:I}=N0(),X=globalThis.AggregateError||I,Z=Symbol("kIsNodeError"),K=["string","function","number","object","Function","Object","boolean","bigint","symbol"],q=/^([A-Z][a-z0-9]*)+$/,z={};function G(j,F){if(!j)throw new z.ERR_INTERNAL_ASSERTION(F)}function C(j){let F="",N=j.length,A=j[0]==="-"?1:0;for(;N>=A+4;N-=3)F=`_${j.slice(N-3,N)}${F}`;return`${j.slice(0,N)}${F}`}function O(j,F,N){if(typeof F==="function")return G(F.length<=N.length,`Code: ${j}; The provided arguments length (${N.length}) does not match the required ones (${F.length}).`),F(...N);let A=(F.match(/%[dfijoOs]/g)||[]).length;if(G(A===N.length,`Code: ${j}; The provided arguments length (${N.length}) does not match the required ones (${A}).`),N.length===0)return F;return B(F,...N)}function x(j,F,N){if(!N)N=Error;class A extends N{constructor(...P){super(O(j,F,P))}toString(){return`${this.name} [${j}]: ${this.message}`}}Object.defineProperties(A.prototype,{name:{value:N.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${j}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),A.prototype.code=j,A.prototype[Z]=!0,z[j]=A}function l(j){let F="__node_internal_"+j.name;return Object.defineProperty(j,"name",{value:F}),j}function a(j,F){if(j&&F&&j!==F){if(Array.isArray(F.errors))return F.errors.push(j),F;let N=new X([F,j],F.message);return N.code=F.code,N}return j||F}class u extends Error{constructor(j="The operation was aborted",F=void 0){if(F!==void 0&&typeof F!=="object")throw new z.ERR_INVALID_ARG_TYPE("options","Object",F);super(j,F);this.code="ABORT_ERR",this.name="AbortError"}}x("ERR_ASSERTION","%s",Error),x("ERR_INVALID_ARG_TYPE",(j,F,N)=>{if(G(typeof j==="string","'name' must be a string"),!Array.isArray(F))F=[F];let A="The ";if(j.endsWith(" argument"))A+=`${j} `;else A+=`"${j}" ${j.includes(".")?"property":"argument"} `;A+="must be ";let P=[],s=[],B0=[];for(let t of F)if(G(typeof t==="string","All expected entries have to be of type string"),K.includes(t))P.push(t.toLowerCase());else if(q.test(t))s.push(t);else G(t!=="object",'The value "object" should be written as "Object"'),B0.push(t);if(s.length>0){let t=P.indexOf("object");if(t!==-1)P.splice(P,t,1),s.push("Object")}if(P.length>0){switch(P.length){case 1:A+=`of type ${P[0]}`;break;case 2:A+=`one of type ${P[0]} or ${P[1]}`;break;default:{let t=P.pop();A+=`one of type ${P.join(", ")}, or ${t}`}}if(s.length>0||B0.length>0)A+=" or "}if(s.length>0){switch(s.length){case 1:A+=`an instance of ${s[0]}`;break;case 2:A+=`an instance of ${s[0]} or ${s[1]}`;break;default:{let t=s.pop();A+=`an instance of ${s.join(", ")}, or ${t}`}}if(B0.length>0)A+=" or "}switch(B0.length){case 0:break;case 1:if(B0[0].toLowerCase()!==B0[0])A+="an ";A+=`${B0[0]}`;break;case 2:A+=`one of ${B0[0]} or ${B0[1]}`;break;default:{let t=B0.pop();A+=`one of ${B0.join(", ")}, or ${t}`}}if(N==null)A+=`. Received ${N}`;else if(typeof N==="function"&&N.name)A+=`. Received function ${N.name}`;else if(typeof N==="object"){var H0;if((H0=N.constructor)!==null&&H0!==void 0&&H0.name)A+=`. Received an instance of ${N.constructor.name}`;else{let t=U(N,{depth:-1});A+=`. Received ${t}`}}else{let t=U(N,{colors:!1});if(t.length>25)t=`${t.slice(0,25)}...`;A+=`. Received type ${typeof N} (${t})`}return A},TypeError),x("ERR_INVALID_ARG_VALUE",(j,F,N="is invalid")=>{let A=U(F);if(A.length>128)A=A.slice(0,128)+"...";return`The ${j.includes(".")?"property":"argument"} '${j}' ${N}. Received ${A}`},TypeError),x("ERR_INVALID_RETURN_VALUE",(j,F,N)=>{var A;let P=N!==null&&N!==void 0&&(A=N.constructor)!==null&&A!==void 0&&A.name?`instance of ${N.constructor.name}`:`type ${typeof N}`;return`Expected ${j} to be returned from the "${F}" function but got ${P}.`},TypeError),x("ERR_MISSING_ARGS",(...j)=>{G(j.length>0,"At least one arg needs to be specified");let F,N=j.length;switch(j=(Array.isArray(j)?j:[j]).map((A)=>`"${A}"`).join(" or "),N){case 1:F+=`The ${j[0]} argument`;break;case 2:F+=`The ${j[0]} and ${j[1]} arguments`;break;default:{let A=j.pop();F+=`The ${j.join(", ")}, and ${A} arguments`}break}return`${F} must be specified`},TypeError),x("ERR_OUT_OF_RANGE",(j,F,N)=>{G(F,'Missing "range" argument');let A;if(Number.isInteger(N)&&Math.abs(N)>4294967296)A=C(String(N));else if(typeof N==="bigint"){A=String(N);let P=BigInt(2)**BigInt(32);if(N>P||N<-P)A=C(A);A+="n"}else A=U(N);return`The value of "${j}" is out of range. It must be ${F}. Received ${A}`},RangeError),x("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error),x("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error),x("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error),x("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error),x("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error),x("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),x("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error),x("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error),x("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error),x("ERR_STREAM_WRITE_AFTER_END","write after end",Error),x("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError),h.exports={AbortError:u,aggregateTwoErrors:l(a),hideStackFrames:l,codes:z}}),H8=G0((w,h)=>{Object.defineProperty(w,"__esModule",{value:!0});var B=new WeakMap,U=new WeakMap;function I(D){let v=B.get(D);return console.assert(v!=null,"'this' is expected an Event object, but got",D),v}function X(D){if(D.passiveListener!=null){if(typeof console<"u"&&typeof console.error==="function")console.error("Unable to preventDefault inside passive event listener invocation.",D.passiveListener);return}if(!D.event.cancelable)return;if(D.canceled=!0,typeof D.event.preventDefault==="function")D.event.preventDefault()}function Z(D,v){B.set(this,{eventTarget:D,event:v,eventPhase:2,currentTarget:D,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:v.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let M=Object.keys(v);for(let V=0;V<M.length;++V){let L=M[V];if(!(L in this))Object.defineProperty(this,L,K(L))}}if(Z.prototype={get type(){return I(this).event.type},get target(){return I(this).eventTarget},get currentTarget(){return I(this).currentTarget},composedPath(){let D=I(this).currentTarget;if(D==null)return[];return[D]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return I(this).eventPhase},stopPropagation(){let D=I(this);if(D.stopped=!0,typeof D.event.stopPropagation==="function")D.event.stopPropagation()},stopImmediatePropagation(){let D=I(this);if(D.stopped=!0,D.immediateStopped=!0,typeof D.event.stopImmediatePropagation==="function")D.event.stopImmediatePropagation()},get bubbles(){return Boolean(I(this).event.bubbles)},get cancelable(){return Boolean(I(this).event.cancelable)},preventDefault(){X(I(this))},get defaultPrevented(){return I(this).canceled},get composed(){return Boolean(I(this).event.composed)},get timeStamp(){return I(this).timeStamp},get srcElement(){return I(this).eventTarget},get cancelBubble(){return I(this).stopped},set cancelBubble(D){if(!D)return;let v=I(this);if(v.stopped=!0,typeof v.event.cancelBubble==="boolean")v.event.cancelBubble=!0},get returnValue(){return!I(this).canceled},set returnValue(D){if(!D)X(I(this))},initEvent(){}},Object.defineProperty(Z.prototype,"constructor",{value:Z,configurable:!0,writable:!0}),typeof window<"u"&&typeof window.Event<"u")Object.setPrototypeOf(Z.prototype,window.Event.prototype),U.set(window.Event.prototype,Z);function K(D){return{get(){return I(this).event[D]},set(v){I(this).event[D]=v},configurable:!0,enumerable:!0}}function q(D){return{value(){let v=I(this).event;return v[D].apply(v,arguments)},configurable:!0,enumerable:!0}}function z(D,v){let M=Object.keys(v);if(M.length===0)return D;function V(L,W){D.call(this,L,W)}V.prototype=Object.create(D.prototype,{constructor:{value:V,configurable:!0,writable:!0}});for(let L=0;L<M.length;++L){let W=M[L];if(!(W in D.prototype)){let b=typeof Object.getOwnPropertyDescriptor(v,W).value==="function";Object.defineProperty(V.prototype,W,b?q(W):K(W))}}return V}function G(D){if(D==null||D===Object.prototype)return Z;let v=U.get(D);if(v==null)v=z(G(Object.getPrototypeOf(D)),D),U.set(D,v);return v}function C(D,v){return new(G(Object.getPrototypeOf(v)))(D,v)}function O(D){return I(D).immediateStopped}function x(D,v){I(D).eventPhase=v}function l(D,v){I(D).currentTarget=v}function a(D,v){I(D).passiveListener=v}var u=new WeakMap,j=1,F=2,N=3;function A(D){return D!==null&&typeof D==="object"}function P(D){let v=u.get(D);if(v==null)throw TypeError("'this' is expected an EventTarget object, but got another value.");return v}function s(D){return{get(){let v=P(this).get(D);while(v!=null){if(v.listenerType===N)return v.listener;v=v.next}return null},set(v){if(typeof v!=="function"&&!A(v))v=null;let M=P(this),V=null,L=M.get(D);while(L!=null){if(L.listenerType===N)if(V!==null)V.next=L.next;else if(L.next!==null)M.set(D,L.next);else M.delete(D);else V=L;L=L.next}if(v!==null){let W={listener:v,listenerType:N,passive:!1,once:!1,next:null};if(V===null)M.set(D,W);else V.next=W}},configurable:!0,enumerable:!0}}function B0(D,v){Object.defineProperty(D,`on${v}`,s(v))}function H0(D){function v(){t.call(this)}v.prototype=Object.create(t.prototype,{constructor:{value:v,configurable:!0,writable:!0}});for(let M=0;M<D.length;++M)B0(v.prototype,D[M]);return v}function t(){if(this instanceof t){u.set(this,new Map);return}if(arguments.length===1&&Array.isArray(arguments[0]))return H0(arguments[0]);if(arguments.length>0){let D=Array(arguments.length);for(let v=0;v<arguments.length;++v)D[v]=arguments[v];return H0(D)}throw TypeError("Cannot call a class as a function")}if(t.prototype={addEventListener(D,v,M){if(v==null)return;if(typeof v!=="function"&&!A(v))throw TypeError("'listener' should be a function or an object.");let V=P(this),L=A(M),W=(L?Boolean(M.capture):Boolean(M))?j:F,b={listener:v,listenerType:W,passive:L&&Boolean(M.passive),once:L&&Boolean(M.once),next:null},e=V.get(D);if(e===void 0){V.set(D,b);return}let X0=null;while(e!=null){if(e.listener===v&&e.listenerType===W)return;X0=e,e=e.next}X0.next=b},removeEventListener(D,v,M){if(v==null)return;let V=P(this),L=(A(M)?Boolean(M.capture):Boolean(M))?j:F,W=null,b=V.get(D);while(b!=null){if(b.listener===v&&b.listenerType===L){if(W!==null)W.next=b.next;else if(b.next!==null)V.set(D,b.next);else V.delete(D);return}W=b,b=b.next}},dispatchEvent(D){if(D==null||typeof D.type!=="string")throw TypeError('"event.type" should be a string.');let v=P(this),M=D.type,V=v.get(M);if(V==null)return!0;let L=C(this,D),W=null;while(V!=null){if(V.once)if(W!==null)W.next=V.next;else if(V.next!==null)v.set(M,V.next);else v.delete(M);else W=V;if(a(L,V.passive?V.listener:null),typeof V.listener==="function")try{V.listener.call(this,L)}catch(b){if(typeof console<"u"&&typeof console.error==="function")console.error(b)}else if(V.listenerType!==N&&typeof V.listener.handleEvent==="function")V.listener.handleEvent(L);if(O(L))break;V=V.next}return a(L,null),x(L,0),l(L,null),!L.defaultPrevented}},Object.defineProperty(t.prototype,"constructor",{value:t,configurable:!0,writable:!0}),typeof window<"u"&&typeof window.EventTarget<"u")Object.setPrototypeOf(t.prototype,window.EventTarget.prototype);w.defineEventAttribute=B0,w.EventTarget=t,w.default=t,h.exports=t,h.exports.EventTarget=h.exports.default=t,h.exports.defineEventAttribute=B0}),H2=G0((w,h)=>{Object.defineProperty(w,"__esModule",{value:!0});var B=H8();class U extends B.EventTarget{constructor(){super();throw TypeError("AbortSignal cannot be constructed directly")}get aborted(){let G=Z.get(this);if(typeof G!=="boolean")throw TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this===null?"null":typeof this}`);return G}}B.defineEventAttribute(U.prototype,"abort");function I(){let G=Object.create(U.prototype);return B.EventTarget.call(G),Z.set(G,!1),G}function X(G){if(Z.get(G)!==!1)return;Z.set(G,!0),G.dispatchEvent({type:"abort"})}var Z=new WeakMap;if(Object.defineProperties(U.prototype,{aborted:{enumerable:!0}}),typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol")Object.defineProperty(U.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});class K{constructor(){q.set(this,I())}get signal(){return z(this)}abort(){X(z(this))}}var q=new WeakMap;function z(G){let C=q.get(G);if(C==null)throw TypeError(`Expected 'this' to be an 'AbortController' object, but got ${G===null?"null":typeof G}`);return C}if(Object.defineProperties(K.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol")Object.defineProperty(K.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});w.AbortController=K,w.AbortSignal=U,w.default=K,h.exports=K,h.exports.AbortController=h.exports.default=K,h.exports.AbortSignal=U}),D0=G0((w,h)=>{var B=(v0(),_0(u0)),{format:U,inspect:I}=b1(),{codes:{ERR_INVALID_ARG_TYPE:X}}=L0(),{kResistStopPropagation:Z,AggregateError:K,SymbolDispose:q}=N0(),z=globalThis.AbortSignal||H2().AbortSignal,G=globalThis.AbortController||H2().AbortController,C=Object.getPrototypeOf(async function(){}).constructor,O=globalThis.Blob||B.Blob,x=typeof O<"u"?function(j){return j instanceof O}:function(j){return!1},l=(u,j)=>{if(u!==void 0&&(u===null||typeof u!=="object"||!("aborted"in u)))throw new X(j,"AbortSignal",u)},a=(u,j)=>{if(typeof u!=="function")throw new X(j,"Function",u)};h.exports={AggregateError:K,kEmptyObject:Object.freeze({}),once(u){let j=!1;return function(...F){if(j)return;j=!0,u.apply(this,F)}},createDeferredPromise:function(){let u,j;return{promise:new Promise((F,N)=>{u=F,j=N}),resolve:u,reject:j}},promisify(u){return new Promise((j,F)=>{u((N,...A)=>{if(N)return F(N);return j(...A)})})},debuglog(){return function(){}},format:U,inspect:I,types:{isAsyncFunction(u){return u instanceof C},isArrayBufferView(u){return ArrayBuffer.isView(u)}},isBlob:x,deprecate(u,j){return u},addAbortListener:(q2(),_0(Y2)).addAbortListener||function(j,F){if(j===void 0)throw new X("signal","AbortSignal",j);l(j,"signal"),a(F,"listener");let N;if(j.aborted)queueMicrotask(()=>F());else j.addEventListener("abort",F,{__proto__:null,once:!0,[Z]:!0}),N=()=>{j.removeEventListener("abort",F)};return{__proto__:null,[q](){var A;(A=N)===null||A===void 0||A()}}},AbortSignalAny:z.any||function(j){if(j.length===1)return j[0];let F=new G,N=()=>F.abort();return j.forEach((A)=>{l(A,"signals"),A.addEventListener("abort",N,{once:!0})}),F.signal.addEventListener("abort",()=>{j.forEach((A)=>A.removeEventListener("abort",N))},{once:!0}),F.signal}},h.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")}),$2=G0((w,h)=>{var{ArrayIsArray:B,ArrayPrototypeIncludes:U,ArrayPrototypeJoin:I,ArrayPrototypeMap:X,NumberIsInteger:Z,NumberIsNaN:K,NumberMAX_SAFE_INTEGER:q,NumberMIN_SAFE_INTEGER:z,NumberParseInt:G,ObjectPrototypeHasOwnProperty:C,RegExpPrototypeExec:O,String:x,StringPrototypeToUpperCase:l,StringPrototypeTrim:a}=N0(),{hideStackFrames:u,codes:{ERR_SOCKET_BAD_PORT:j,ERR_INVALID_ARG_TYPE:F,ERR_INVALID_ARG_VALUE:N,ERR_OUT_OF_RANGE:A,ERR_UNKNOWN_SIGNAL:P}}=L0(),{normalizeEncoding:s}=D0(),{isAsyncFunction:B0,isArrayBufferView:H0}=D0().types,t={};function D($){return $===($|0)}function v($){return $===$>>>0}var M=/^[0-7]+$/,V="must be a 32-bit unsigned integer or an octal string";function L($,y,r){if(typeof $>"u")$=r;if(typeof $==="string"){if(O(M,$)===null)throw new N(y,$,V);$=G($,8)}return e($,y),$}var W=u(($,y,r=z,g=q)=>{if(typeof $!=="number")throw new F(y,"number",$);if(!Z($))throw new A(y,"an integer",$);if($<r||$>g)throw new A(y,`>= ${r} && <= ${g}`,$)}),b=u(($,y,r=-2147483648,g=2147483647)=>{if(typeof $!=="number")throw new F(y,"number",$);if(!Z($))throw new A(y,"an integer",$);if($<r||$>g)throw new A(y,`>= ${r} && <= ${g}`,$)}),e=u(($,y,r=!1)=>{if(typeof $!=="number")throw new F(y,"number",$);if(!Z($))throw new A(y,"an integer",$);let g=r?1:0,Q0=4294967295;if($<g||$>Q0)throw new A(y,`>= ${g} && <= ${Q0}`,$)});function X0($,y){if(typeof $!=="string")throw new F(y,"string",$)}function Y0($,y,r=void 0,g){if(typeof $!=="number")throw new F(y,"number",$);if(r!=null&&$<r||g!=null&&$>g||(r!=null||g!=null)&&K($))throw new A(y,`${r!=null?`>= ${r}`:""}${r!=null&&g!=null?" && ":""}${g!=null?`<= ${g}`:""}`,$)}var S=u(($,y,r)=>{if(!U(r,$)){let g="must be one of: "+I(X(r,(Q0)=>typeof Q0==="string"?`'${Q0}'`:x(Q0)),", ");throw new N(y,$,g)}});function Z0($,y){if(typeof $!=="boolean")throw new F(y,"boolean",$)}function Y($,y,r){return $==null||!C($,y)?r:$[y]}var c=u(($,y,r=null)=>{let g=Y(r,"allowArray",!1),Q0=Y(r,"allowFunction",!1);if(!Y(r,"nullable",!1)&&$===null||!g&&B($)||typeof $!=="object"&&(!Q0||typeof $!=="function"))throw new F(y,"Object",$)}),h0=u(($,y)=>{if($!=null&&typeof $!=="object"&&typeof $!=="function")throw new F(y,"a dictionary",$)}),R=u(($,y,r=0)=>{if(!B($))throw new F(y,"Array",$);if($.length<r){let g=`must be longer than ${r}`;throw new N(y,$,g)}});function I0($,y){R($,y);for(let r=0;r<$.length;r++)X0($[r],`${y}[${r}]`)}function J0($,y){R($,y);for(let r=0;r<$.length;r++)Z0($[r],`${y}[${r}]`)}function q0($,y){R($,y);for(let r=0;r<$.length;r++){let g=$[r],Q0=`${y}[${r}]`;if(g==null)throw new F(Q0,"AbortSignal",g);z0(g,Q0)}}function K0($,y="signal"){if(X0($,y),t[$]===void 0){if(t[l($)]!==void 0)throw new P($+" (signals must use all capital letters)");throw new P($)}}var k=u(($,y="buffer")=>{if(!H0($))throw new F(y,["Buffer","TypedArray","DataView"],$)});function f($,y){let r=s(y),g=$.length;if(r==="hex"&&g%2!==0)throw new N("encoding",y,`is invalid for data of length ${g}`)}function o($,y="Port",r=!0){if(typeof $!=="number"&&typeof $!=="string"||typeof $==="string"&&a($).length===0||+$!==+$>>>0||$>65535||$===0&&!r)throw new j(y,$,r);return $|0}var z0=u(($,y)=>{if($!==void 0&&($===null||typeof $!=="object"||!("aborted"in $)))throw new F(y,"AbortSignal",$)}),F0=u(($,y)=>{if(typeof $!=="function")throw new F(y,"Function",$)}),H=u(($,y)=>{if(typeof $!=="function"||B0($))throw new F(y,"Function",$)}),E=u(($,y)=>{if($!==void 0)throw new F(y,"undefined",$)});function T($,y,r){if(!U(r,$))throw new F(y,`('${I(r,"|")}')`,$)}var p=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function m($,y){if(typeof $>"u"||!O(p,$))throw new N(y,$,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function i($){if(typeof $==="string")return m($,"hints"),$;else if(B($)){let y=$.length,r="";if(y===0)return r;for(let g=0;g<y;g++){let Q0=$[g];if(m(Q0,"hints"),r+=Q0,g!==y-1)r+=", "}return r}throw new N("hints",$,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}h.exports={isInt32:D,isUint32:v,parseFileMode:L,validateArray:R,validateStringArray:I0,validateBooleanArray:J0,validateAbortSignalArray:q0,validateBoolean:Z0,validateBuffer:k,validateDictionary:h0,validateEncoding:f,validateFunction:F0,validateInt32:b,validateInteger:W,validateNumber:Y0,validateObject:c,validateOneOf:S,validatePlainFunction:H,validatePort:o,validateSignalName:K0,validateString:X0,validateUint32:e,validateUndefined:E,validateUnion:T,validateAbortSignal:z0,validateLinkHeaderValue:i}}),e0=G0((w,h)=>{h.exports=globalThis.process}),b0=G0((w,h)=>{var{SymbolAsyncIterator:B,SymbolIterator:U,SymbolFor:I}=N0(),X=I("nodejs.stream.destroyed"),Z=I("nodejs.stream.errored"),K=I("nodejs.stream.readable"),q=I("nodejs.stream.writable"),z=I("nodejs.stream.disturbed"),G=I("nodejs.webstream.isClosedPromise"),C=I("nodejs.webstream.controllerErrorFunction");function O(Y,c=!1){var h0;return!!(Y&&typeof Y.pipe==="function"&&typeof Y.on==="function"&&(!c||typeof Y.pause==="function"&&typeof Y.resume==="function")&&(!Y._writableState||((h0=Y._readableState)===null||h0===void 0?void 0:h0.readable)!==!1)&&(!Y._writableState||Y._readableState))}function x(Y){var c;return!!(Y&&typeof Y.write==="function"&&typeof Y.on==="function"&&(!Y._readableState||((c=Y._writableState)===null||c===void 0?void 0:c.writable)!==!1))}function l(Y){return!!(Y&&typeof Y.pipe==="function"&&Y._readableState&&typeof Y.on==="function"&&typeof Y.write==="function")}function a(Y){return Y&&(Y._readableState||Y._writableState||typeof Y.write==="function"&&typeof Y.on==="function"||typeof Y.pipe==="function"&&typeof Y.on==="function")}function u(Y){return!!(Y&&!a(Y)&&typeof Y.pipeThrough==="function"&&typeof Y.getReader==="function"&&typeof Y.cancel==="function")}function j(Y){return!!(Y&&!a(Y)&&typeof Y.getWriter==="function"&&typeof Y.abort==="function")}function F(Y){return!!(Y&&!a(Y)&&typeof Y.readable==="object"&&typeof Y.writable==="object")}function N(Y){return u(Y)||j(Y)||F(Y)}function A(Y,c){if(Y==null)return!1;if(c===!0)return typeof Y[B]==="function";if(c===!1)return typeof Y[U]==="function";return typeof Y[B]==="function"||typeof Y[U]==="function"}function P(Y){if(!a(Y))return null;let{_writableState:c,_readableState:h0}=Y,R=c||h0;return!!(Y.destroyed||Y[X]||R!==null&&R!==void 0&&R.destroyed)}function s(Y){if(!x(Y))return null;if(Y.writableEnded===!0)return!0;let c=Y._writableState;if(c!==null&&c!==void 0&&c.errored)return!1;if(typeof(c===null||c===void 0?void 0:c.ended)!=="boolean")return null;return c.ended}function B0(Y,c){if(!x(Y))return null;if(Y.writableFinished===!0)return!0;let h0=Y._writableState;if(h0!==null&&h0!==void 0&&h0.errored)return!1;if(typeof(h0===null||h0===void 0?void 0:h0.finished)!=="boolean")return null;return!!(h0.finished||c===!1&&h0.ended===!0&&h0.length===0)}function H0(Y){if(!O(Y))return null;if(Y.readableEnded===!0)return!0;let c=Y._readableState;if(!c||c.errored)return!1;if(typeof(c===null||c===void 0?void 0:c.ended)!=="boolean")return null;return c.ended}function t(Y,c){if(!O(Y))return null;let h0=Y._readableState;if(h0!==null&&h0!==void 0&&h0.errored)return!1;if(typeof(h0===null||h0===void 0?void 0:h0.endEmitted)!=="boolean")return null;return!!(h0.endEmitted||c===!1&&h0.ended===!0&&h0.length===0)}function D(Y){if(Y&&Y[K]!=null)return Y[K];if(typeof(Y===null||Y===void 0?void 0:Y.readable)!=="boolean")return null;if(P(Y))return!1;return O(Y)&&Y.readable&&!t(Y)}function v(Y){if(Y&&Y[q]!=null)return Y[q];if(typeof(Y===null||Y===void 0?void 0:Y.writable)!=="boolean")return null;if(P(Y))return!1;return x(Y)&&Y.writable&&!s(Y)}function M(Y,c){if(!a(Y))return null;if(P(Y))return!0;if((c===null||c===void 0?void 0:c.readable)!==!1&&D(Y))return!1;if((c===null||c===void 0?void 0:c.writable)!==!1&&v(Y))return!1;return!0}function V(Y){var c,h0;if(!a(Y))return null;if(Y.writableErrored)return Y.writableErrored;return(c=(h0=Y._writableState)===null||h0===void 0?void 0:h0.errored)!==null&&c!==void 0?c:null}function L(Y){var c,h0;if(!a(Y))return null;if(Y.readableErrored)return Y.readableErrored;return(c=(h0=Y._readableState)===null||h0===void 0?void 0:h0.errored)!==null&&c!==void 0?c:null}function W(Y){if(!a(Y))return null;if(typeof Y.closed==="boolean")return Y.closed;let{_writableState:c,_readableState:h0}=Y;if(typeof(c===null||c===void 0?void 0:c.closed)==="boolean"||typeof(h0===null||h0===void 0?void 0:h0.closed)==="boolean")return(c===null||c===void 0?void 0:c.closed)||(h0===null||h0===void 0?void 0:h0.closed);if(typeof Y._closed==="boolean"&&b(Y))return Y._closed;return null}function b(Y){return typeof Y._closed==="boolean"&&typeof Y._defaultKeepAlive==="boolean"&&typeof Y._removedConnection==="boolean"&&typeof Y._removedContLen==="boolean"}function e(Y){return typeof Y._sent100==="boolean"&&b(Y)}function X0(Y){var c;return typeof Y._consuming==="boolean"&&typeof Y._dumped==="boolean"&&((c=Y.req)===null||c===void 0?void 0:c.upgradeOrConnect)===void 0}function Y0(Y){if(!a(Y))return null;let{_writableState:c,_readableState:h0}=Y,R=c||h0;return!R&&e(Y)||!!(R&&R.autoDestroy&&R.emitClose&&R.closed===!1)}function S(Y){var c;return!!(Y&&((c=Y[z])!==null&&c!==void 0?c:Y.readableDidRead||Y.readableAborted))}function Z0(Y){var c,h0,R,I0,J0,q0,K0,k,f,o;return!!(Y&&((c=(h0=(R=(I0=(J0=(q0=Y[Z])!==null&&q0!==void 0?q0:Y.readableErrored)!==null&&J0!==void 0?J0:Y.writableErrored)!==null&&I0!==void 0?I0:(K0=Y._readableState)===null||K0===void 0?void 0:K0.errorEmitted)!==null&&R!==void 0?R:(k=Y._writableState)===null||k===void 0?void 0:k.errorEmitted)!==null&&h0!==void 0?h0:(f=Y._readableState)===null||f===void 0?void 0:f.errored)!==null&&c!==void 0?c:(o=Y._writableState)===null||o===void 0?void 0:o.errored))}h.exports={isDestroyed:P,kIsDestroyed:X,isDisturbed:S,kIsDisturbed:z,isErrored:Z0,kIsErrored:Z,isReadable:D,kIsReadable:K,kIsClosedPromise:G,kControllerErrorFunction:C,kIsWritable:q,isClosed:W,isDuplexNodeStream:l,isFinished:M,isIterable:A,isReadableNodeStream:O,isReadableStream:u,isReadableEnded:H0,isReadableFinished:t,isReadableErrored:L,isNodeStream:a,isWebStream:N,isWritable:v,isWritableNodeStream:x,isWritableStream:j,isWritableEnded:s,isWritableFinished:B0,isWritableErrored:V,isServerRequest:X0,isServerResponse:e,willEmitClose:Y0,isTransformStream:F}}),d0=G0((w,h)=>{var B=e0(),{AbortError:U,codes:I}=L0(),{ERR_INVALID_ARG_TYPE:X,ERR_STREAM_PREMATURE_CLOSE:Z}=I,{kEmptyObject:K,once:q}=D0(),{validateAbortSignal:z,validateFunction:G,validateObject:C,validateBoolean:O}=$2(),{Promise:x,PromisePrototypeThen:l,SymbolDispose:a}=N0(),{isClosed:u,isReadable:j,isReadableNodeStream:F,isReadableStream:N,isReadableFinished:A,isReadableErrored:P,isWritable:s,isWritableNodeStream:B0,isWritableStream:H0,isWritableFinished:t,isWritableErrored:D,isNodeStream:v,willEmitClose:M,kIsClosedPromise:V}=b0(),L;function W(S){return S.setHeader&&typeof S.abort==="function"}var b=()=>{};function e(S,Z0,Y){var c,h0;if(arguments.length===2)Y=Z0,Z0=K;else if(Z0==null)Z0=K;else C(Z0,"options");if(G(Y,"callback"),z(Z0.signal,"options.signal"),Y=q(Y),N(S)||H0(S))return X0(S,Z0,Y);if(!v(S))throw new X("stream",["ReadableStream","WritableStream","Stream"],S);let R=(c=Z0.readable)!==null&&c!==void 0?c:F(S),I0=(h0=Z0.writable)!==null&&h0!==void 0?h0:B0(S),J0=S._writableState,q0=S._readableState,K0=()=>{if(!S.writable)o()},k=M(S)&&F(S)===R&&B0(S)===I0,f=t(S,!1),o=()=>{if(f=!0,S.destroyed)k=!1;if(k&&(!S.readable||R))return;if(!R||z0)Y.call(S)},z0=A(S,!1),F0=()=>{if(z0=!0,S.destroyed)k=!1;if(k&&(!S.writable||I0))return;if(!I0||f)Y.call(S)},H=($)=>{Y.call(S,$)},E=u(S),T=()=>{E=!0;let $=D(S)||P(S);if($&&typeof $!=="boolean")return Y.call(S,$);if(R&&!z0&&F(S,!0)){if(!A(S,!1))return Y.call(S,new Z)}if(I0&&!f){if(!t(S,!1))return Y.call(S,new Z)}Y.call(S)},p=()=>{E=!0;let $=D(S)||P(S);if($&&typeof $!=="boolean")return Y.call(S,$);Y.call(S)},m=()=>{S.req.on("finish",o)};if(W(S)){if(S.on("complete",o),!k)S.on("abort",T);if(S.req)m();else S.on("request",m)}else if(I0&&!J0)S.on("end",K0),S.on("close",K0);if(!k&&typeof S.aborted==="boolean")S.on("aborted",T);if(S.on("end",F0),S.on("finish",o),Z0.error!==!1)S.on("error",H);if(S.on("close",T),E)B.nextTick(T);else if(J0!==null&&J0!==void 0&&J0.errorEmitted||q0!==null&&q0!==void 0&&q0.errorEmitted){if(!k)B.nextTick(p)}else if(!R&&(!k||j(S))&&(f||s(S)===!1))B.nextTick(p);else if(!I0&&(!k||s(S))&&(z0||j(S)===!1))B.nextTick(p);else if(q0&&S.req&&S.aborted)B.nextTick(p);let i=()=>{if(Y=b,S.removeListener("aborted",T),S.removeListener("complete",o),S.removeListener("abort",T),S.removeListener("request",m),S.req)S.req.removeListener("finish",o);S.removeListener("end",K0),S.removeListener("close",K0),S.removeListener("finish",o),S.removeListener("end",F0),S.removeListener("error",H),S.removeListener("close",T)};if(Z0.signal&&!E){let $=()=>{let y=Y;i(),y.call(S,new U(void 0,{cause:Z0.signal.reason}))};if(Z0.signal.aborted)B.nextTick($);else{L=L||D0().addAbortListener;let y=L(Z0.signal,$),r=Y;Y=q((...g)=>{y[a](),r.apply(S,g)})}}return i}function X0(S,Z0,Y){let c=!1,h0=b;if(Z0.signal)if(h0=()=>{c=!0,Y.call(S,new U(void 0,{cause:Z0.signal.reason}))},Z0.signal.aborted)B.nextTick(h0);else{L=L||D0().addAbortListener;let I0=L(Z0.signal,h0),J0=Y;Y=q((...q0)=>{I0[a](),J0.apply(S,q0)})}let R=(...I0)=>{if(!c)B.nextTick(()=>Y.apply(S,I0))};return l(S[V].promise,R,R),b}function Y0(S,Z0){var Y;let c=!1;if(Z0===null)Z0=K;if((Y=Z0)!==null&&Y!==void 0&&Y.cleanup)O(Z0.cleanup,"cleanup"),c=Z0.cleanup;return new x((h0,R)=>{let I0=e(S,Z0,(J0)=>{if(c)I0();if(J0)R(J0);else h0()})})}h.exports=e,h.exports.finished=Y0}),I2=G0((w,h)=>{var B=e0(),{aggregateTwoErrors:U,codes:{ERR_MULTIPLE_CALLBACK:I},AbortError:X}=L0(),{Symbol:Z}=N0(),{kIsDestroyed:K,isDestroyed:q,isFinished:z,isServerRequest:G}=b0(),C=Z("kDestroy"),O=Z("kConstruct");function x(M,V,L){if(M){if(M.stack,V&&!V.errored)V.errored=M;if(L&&!L.errored)L.errored=M}}function l(M,V){let L=this._readableState,W=this._writableState,b=W||L;if(W!==null&&W!==void 0&&W.destroyed||L!==null&&L!==void 0&&L.destroyed){if(typeof V==="function")V();return this}if(x(M,W,L),W)W.destroyed=!0;if(L)L.destroyed=!0;if(!b.constructed)this.once(C,function(e){a(this,U(e,M),V)});else a(this,M,V);return this}function a(M,V,L){let W=!1;function b(e){if(W)return;W=!0;let{_readableState:X0,_writableState:Y0}=M;if(x(e,Y0,X0),Y0)Y0.closed=!0;if(X0)X0.closed=!0;if(typeof L==="function")L(e);if(e)B.nextTick(u,M,e);else B.nextTick(j,M)}try{M._destroy(V||null,b)}catch(e){b(e)}}function u(M,V){F(M,V),j(M)}function j(M){let{_readableState:V,_writableState:L}=M;if(L)L.closeEmitted=!0;if(V)V.closeEmitted=!0;if(L!==null&&L!==void 0&&L.emitClose||V!==null&&V!==void 0&&V.emitClose)M.emit("close")}function F(M,V){let{_readableState:L,_writableState:W}=M;if(W!==null&&W!==void 0&&W.errorEmitted||L!==null&&L!==void 0&&L.errorEmitted)return;if(W)W.errorEmitted=!0;if(L)L.errorEmitted=!0;M.emit("error",V)}function N(){let M=this._readableState,V=this._writableState;if(M)M.constructed=!0,M.closed=!1,M.closeEmitted=!1,M.destroyed=!1,M.errored=null,M.errorEmitted=!1,M.reading=!1,M.ended=M.readable===!1,M.endEmitted=M.readable===!1;if(V)V.constructed=!0,V.destroyed=!1,V.closed=!1,V.closeEmitted=!1,V.errored=null,V.errorEmitted=!1,V.finalCalled=!1,V.prefinished=!1,V.ended=V.writable===!1,V.ending=V.writable===!1,V.finished=V.writable===!1}function A(M,V,L){let{_readableState:W,_writableState:b}=M;if(b!==null&&b!==void 0&&b.destroyed||W!==null&&W!==void 0&&W.destroyed)return this;if(W!==null&&W!==void 0&&W.autoDestroy||b!==null&&b!==void 0&&b.autoDestroy)M.destroy(V);else if(V){if(V.stack,b&&!b.errored)b.errored=V;if(W&&!W.errored)W.errored=V;if(L)B.nextTick(F,M,V);else F(M,V)}}function P(M,V){if(typeof M._construct!=="function")return;let{_readableState:L,_writableState:W}=M;if(L)L.constructed=!1;if(W)W.constructed=!1;if(M.once(O,V),M.listenerCount(O)>1)return;B.nextTick(s,M)}function s(M){let V=!1;function L(W){if(V){A(M,W!==null&&W!==void 0?W:new I);return}V=!0;let{_readableState:b,_writableState:e}=M,X0=e||b;if(b)b.constructed=!0;if(e)e.constructed=!0;if(X0.destroyed)M.emit(C,W);else if(W)A(M,W,!0);else B.nextTick(B0,M)}try{M._construct((W)=>{B.nextTick(L,W)})}catch(W){B.nextTick(L,W)}}function B0(M){M.emit(O)}function H0(M){return(M===null||M===void 0?void 0:M.setHeader)&&typeof M.abort==="function"}function t(M){M.emit("close")}function D(M,V){M.emit("error",V),B.nextTick(t,M)}function v(M,V){if(!M||q(M))return;if(!V&&!z(M))V=new X;if(G(M))M.socket=null,M.destroy(V);else if(H0(M))M.abort();else if(H0(M.req))M.req.abort();else if(typeof M.destroy==="function")M.destroy(V);else if(typeof M.close==="function")M.close();else if(V)B.nextTick(D,M,V);else B.nextTick(t,M);if(!M.destroyed)M[K]=!0}h.exports={construct:P,destroyer:v,destroy:l,undestroy:N,errorOrDestroy:A}}),b2=G0((w,h)=>{var{ArrayIsArray:B,ObjectSetPrototypeOf:U}=N0(),{EventEmitter:I}=(q2(),_0(Y2));function X(K){I.call(this,K)}U(X.prototype,I.prototype),U(X,I),X.prototype.pipe=function(K,q){let z=this;function G(j){if(K.writable&&K.write(j)===!1&&z.pause)z.pause()}z.on("data",G);function C(){if(z.readable&&z.resume)z.resume()}if(K.on("drain",C),!K._isStdio&&(!q||q.end!==!1))z.on("end",x),z.on("close",l);let O=!1;function x(){if(O)return;O=!0,K.end()}function l(){if(O)return;if(O=!0,typeof K.destroy==="function")K.destroy()}function a(j){if(u(),I.listenerCount(this,"error")===0)this.emit("error",j)}Z(z,"error",a),Z(K,"error",a);function u(){z.removeListener("data",G),K.removeListener("drain",C),z.removeListener("end",x),z.removeListener("close",l),z.removeListener("error",a),K.removeListener("error",a),z.removeListener("end",u),z.removeListener("close",u),K.removeListener("close",u)}return z.on("end",u),z.on("close",u),K.on("close",u),K.emit("pipe",z),K};function Z(K,q,z){if(typeof K.prependListener==="function")return K.prependListener(q,z);if(!K._events||!K._events[q])K.on(q,z);else if(B(K._events[q]))K._events[q].unshift(z);else K._events[q]=[z,K._events[q]]}h.exports={Stream:X,prependListener:Z}}),V2=G0((w,h)=>{var{SymbolDispose:B}=N0(),{AbortError:U,codes:I}=L0(),{isNodeStream:X,isWebStream:Z,kControllerErrorFunction:K}=b0(),q=d0(),{ERR_INVALID_ARG_TYPE:z}=I,G,C=(O,x)=>{if(typeof O!=="object"||!("aborted"in O))throw new z(x,"AbortSignal",O)};h.exports.addAbortSignal=function(x,l){if(C(x,"signal"),!X(l)&&!Z(l))throw new z("stream",["ReadableStream","WritableStream","Stream"],l);return h.exports.addAbortSignalNoValidate(x,l)},h.exports.addAbortSignalNoValidate=function(O,x){if(typeof O!=="object"||!("aborted"in O))return x;let l=X(x)?()=>{x.destroy(new U(void 0,{cause:O.reason}))}:()=>{x[K](new U(void 0,{cause:O.reason}))};if(O.aborted)l();else{G=G||D0().addAbortListener;let a=G(O,l);q(x,a[B])}return x}}),$8=G0((w,h)=>{var{StringPrototypeSlice:B,SymbolIterator:U,TypedArrayPrototypeSet:I,Uint8Array:X}=N0(),{Buffer:Z}=(v0(),_0(u0)),{inspect:K}=D0();h.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(z){let G={data:z,next:null};if(this.length>0)this.tail.next=G;else this.head=G;this.tail=G,++this.length}unshift(z){let G={data:z,next:this.head};if(this.length===0)this.tail=G;this.head=G,++this.length}shift(){if(this.length===0)return;let z=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,z}clear(){this.head=this.tail=null,this.length=0}join(z){if(this.length===0)return"";let G=this.head,C=""+G.data;while((G=G.next)!==null)C+=z+G.data;return C}concat(z){if(this.length===0)return Z.alloc(0);let G=Z.allocUnsafe(z>>>0),C=this.head,O=0;while(C)I(G,C.data,O),O+=C.data.length,C=C.next;return G}consume(z,G){let C=this.head.data;if(z<C.length){let O=C.slice(0,z);return this.head.data=C.slice(z),O}if(z===C.length)return this.shift();return G?this._getString(z):this._getBuffer(z)}first(){return this.head.data}*[U](){for(let z=this.head;z;z=z.next)yield z.data}_getString(z){let G="",C=this.head,O=0;do{let x=C.data;if(z>x.length)G+=x,z-=x.length;else{if(z===x.length)if(G+=x,++O,C.next)this.head=C.next;else this.head=this.tail=null;else G+=B(x,0,z),this.head=C,C.data=B(x,z);break}++O}while((C=C.next)!==null);return this.length-=O,G}_getBuffer(z){let G=Z.allocUnsafe(z),C=z,O=this.head,x=0;do{let l=O.data;if(z>l.length)I(G,l,C-z),z-=l.length;else{if(z===l.length)if(I(G,l,C-z),++x,O.next)this.head=O.next;else this.head=this.tail=null;else I(G,new X(l.buffer,l.byteOffset,z),C-z),this.head=O,O.data=l.slice(z);break}++x}while((O=O.next)!==null);return this.length-=x,G}[Symbol.for("nodejs.util.inspect.custom")](z,G){return K(this,{...G,depth:0,customInspect:!1})}}}),j2=G0((w,h)=>{var{MathFloor:B,NumberIsInteger:U}=N0(),{validateInteger:I}=$2(),{ERR_INVALID_ARG_VALUE:X}=L0().codes,Z=16384,K=16;function q(O,x,l){return O.highWaterMark!=null?O.highWaterMark:x?O[l]:null}function z(O){return O?K:Z}function G(O,x){if(I(x,"value",0),O)K=x;else Z=x}function C(O,x,l,a){let u=q(x,a,l);if(u!=null){if(!U(u)||u<0){let j=a?`options.${l}`:"options.highWaterMark";throw new X(j,u)}return B(u)}return z(O.objectMode)}h.exports={getHighWaterMark:C,getDefaultHighWaterMark:z,setDefaultHighWaterMark:G}}),G8=G0((w,h)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var B=(v0(),_0(u0)),U=B.Buffer;function I(Z,K){for(var q in Z)K[q]=Z[q]}if(U.from&&U.alloc&&U.allocUnsafe&&U.allocUnsafeSlow)h.exports=B;else I(B,w),w.Buffer=X;function X(Z,K,q){return U(Z,K,q)}X.prototype=Object.create(U.prototype),I(U,X),X.from=function(Z,K,q){if(typeof Z==="number")throw TypeError("Argument must not be a number");return U(Z,K,q)},X.alloc=function(Z,K,q){if(typeof Z!=="number")throw TypeError("Argument must be a number");var z=U(Z);if(K!==void 0)if(typeof q==="string")z.fill(K,q);else z.fill(K);else z.fill(0);return z},X.allocUnsafe=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return U(Z)},X.allocUnsafeSlow=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return B.SlowBuffer(Z)}}),C8=G0((w)=>{var h=G8().Buffer,B=h.isEncoding||function(F){switch(F=""+F,F&&F.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function U(F){if(!F)return"utf8";var N;while(!0)switch(F){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return F;default:if(N)return;F=(""+F).toLowerCase(),N=!0}}function I(F){var N=U(F);if(typeof N!=="string"&&(h.isEncoding===B||!B(F)))throw Error("Unknown encoding: "+F);return N||F}w.StringDecoder=X;function X(F){this.encoding=I(F);var N;switch(this.encoding){case"utf16le":this.text=O,this.end=x,N=4;break;case"utf8":this.fillLast=z,N=4;break;case"base64":this.text=l,this.end=a,N=3;break;default:this.write=u,this.end=j;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=h.allocUnsafe(N)}X.prototype.write=function(F){if(F.length===0)return"";var N,A;if(this.lastNeed){if(N=this.fillLast(F),N===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;if(A<F.length)return N?N+this.text(F,A):this.text(F,A);return N||""},X.prototype.end=C,X.prototype.text=G,X.prototype.fillLast=function(F){if(this.lastNeed<=F.length)return F.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);F.copy(this.lastChar,this.lastTotal-this.lastNeed,0,F.length),this.lastNeed-=F.length};function Z(F){if(F<=127)return 0;else if(F>>5===6)return 2;else if(F>>4===14)return 3;else if(F>>3===30)return 4;return F>>6===2?-1:-2}function K(F,N,A){var P=N.length-1;if(P<A)return 0;var s=Z(N[P]);if(s>=0){if(s>0)F.lastNeed=s-1;return s}if(--P<A||s===-2)return 0;if(s=Z(N[P]),s>=0){if(s>0)F.lastNeed=s-2;return s}if(--P<A||s===-2)return 0;if(s=Z(N[P]),s>=0){if(s>0)if(s===2)s=0;else F.lastNeed=s-3;return s}return 0}function q(F,N,A){if((N[0]&192)!==128)return F.lastNeed=0,"�";if(F.lastNeed>1&&N.length>1){if((N[1]&192)!==128)return F.lastNeed=1,"�";if(F.lastNeed>2&&N.length>2){if((N[2]&192)!==128)return F.lastNeed=2,"�"}}}function z(F){var N=this.lastTotal-this.lastNeed,A=q(this,F,N);if(A!==void 0)return A;if(this.lastNeed<=F.length)return F.copy(this.lastChar,N,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);F.copy(this.lastChar,N,0,F.length),this.lastNeed-=F.length}function G(F,N){var A=K(this,F,N);if(!this.lastNeed)return F.toString("utf8",N);this.lastTotal=A;var P=F.length-(A-this.lastNeed);return F.copy(this.lastChar,0,P),F.toString("utf8",N,P)}function C(F){var N=F&&F.length?this.write(F):"";if(this.lastNeed)return N+"�";return N}function O(F,N){if((F.length-N)%2===0){var A=F.toString("utf16le",N);if(A){var P=A.charCodeAt(A.length-1);if(P>=55296&&P<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=F[F.length-2],this.lastChar[1]=F[F.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=F[F.length-1],F.toString("utf16le",N,F.length-1)}function x(F){var N=F&&F.length?this.write(F):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return N+this.lastChar.toString("utf16le",0,A)}return N}function l(F,N){var A=(F.length-N)%3;if(A===0)return F.toString("base64",N);if(this.lastNeed=3-A,this.lastTotal=3,A===1)this.lastChar[0]=F[F.length-1];else this.lastChar[0]=F[F.length-2],this.lastChar[1]=F[F.length-1];return F.toString("base64",N,F.length-A)}function a(F){var N=F&&F.length?this.write(F):"";if(this.lastNeed)return N+this.lastChar.toString("base64",0,3-this.lastNeed);return N}function u(F){return F.toString(this.encoding)}function j(F){return F&&F.length?this.write(F):""}}),i1=G0((w,h)=>{var B=e0(),{PromisePrototypeThen:U,SymbolAsyncIterator:I,SymbolIterator:X}=N0(),{Buffer:Z}=(v0(),_0(u0)),{ERR_INVALID_ARG_TYPE:K,ERR_STREAM_NULL_VALUES:q}=L0().codes;function z(G,C,O){let x;if(typeof C==="string"||C instanceof Z)return new G({objectMode:!0,...O,read(){this.push(C),this.push(null)}});let l;if(C&&C[I])l=!0,x=C[I]();else if(C&&C[X])l=!1,x=C[X]();else throw new K("iterable",["Iterable"],C);let a=new G({objectMode:!0,highWaterMark:1,...O}),u=!1;a._read=function(){if(!u)u=!0,F()},a._destroy=function(N,A){U(j(N),()=>B.nextTick(A,N),(P)=>B.nextTick(A,P||N))};async function j(N){let A=N!==void 0&&N!==null,P=typeof x.throw==="function";if(A&&P){let{value:s,done:B0}=await x.throw(N);if(await s,B0)return}if(typeof x.return==="function"){let{value:s}=await x.return();await s}}async function F(){for(;;){try{let{value:N,done:A}=l?await x.next():x.next();if(A)a.push(null);else{let P=N&&typeof N.then==="function"?await N:N;if(P===null)throw u=!1,new q;else if(a.push(P))continue;else u=!1}}catch(N){a.destroy(N)}break}}return a}h.exports=z}),A2=G0((w,h)=>{var B=e0(),{ArrayPrototypeIndexOf:U,NumberIsInteger:I,NumberIsNaN:X,NumberParseInt:Z,ObjectDefineProperties:K,ObjectKeys:q,ObjectSetPrototypeOf:z,Promise:G,SafeSet:C,SymbolAsyncDispose:O,SymbolAsyncIterator:x,Symbol:l}=N0();h.exports=g,g.ReadableState=r;var{EventEmitter:a}=(q2(),_0(Y2)),{Stream:u,prependListener:j}=b2(),{Buffer:F}=(v0(),_0(u0)),{addAbortSignal:N}=V2(),A=d0(),P=D0().debuglog("stream",(Q)=>{P=Q}),s=$8(),B0=I2(),{getHighWaterMark:H0,getDefaultHighWaterMark:t}=j2(),{aggregateTwoErrors:D,codes:{ERR_INVALID_ARG_TYPE:v,ERR_METHOD_NOT_IMPLEMENTED:M,ERR_OUT_OF_RANGE:V,ERR_STREAM_PUSH_AFTER_EOF:L,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:W},AbortError:b}=L0(),{validateObject:e}=$2(),X0=l("kPaused"),{StringDecoder:Y0}=C8(),S=i1();z(g.prototype,u.prototype),z(g,u);var Z0=()=>{},{errorOrDestroy:Y}=B0,c=1,h0=2,R=4,I0=8,J0=16,q0=32,K0=64,k=128,f=256,o=512,z0=1024,F0=2048,H=4096,E=8192,T=16384,p=32768,m=65536,i=131072,$=262144;function y(Q){return{enumerable:!1,get(){return(this.state&Q)!==0},set(J){if(J)this.state|=Q;else this.state&=~Q}}}K(r.prototype,{objectMode:y(c),ended:y(h0),endEmitted:y(R),reading:y(I0),constructed:y(J0),sync:y(q0),needReadable:y(K0),emittedReadable:y(k),readableListening:y(f),resumeScheduled:y(o),errorEmitted:y(z0),emitClose:y(F0),autoDestroy:y(H),destroyed:y(E),closed:y(T),closeEmitted:y(p),multiAwaitDrain:y(m),readingMore:y(i),dataEmitted:y($)});function r(Q,J,d){if(typeof d!=="boolean")d=J instanceof g0();if(this.state=F0|H|J0|q0,Q&&Q.objectMode)this.state|=c;if(d&&Q&&Q.readableObjectMode)this.state|=c;if(this.highWaterMark=Q?H0(this,Q,"readableHighWaterMark",d):t(!1),this.buffer=new s,this.length=0,this.pipes=[],this.flowing=null,this[X0]=null,Q&&Q.emitClose===!1)this.state&=~F0;if(Q&&Q.autoDestroy===!1)this.state&=~H;if(this.errored=null,this.defaultEncoding=Q&&Q.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,Q&&Q.encoding)this.decoder=new Y0(Q.encoding),this.encoding=Q.encoding}function g(Q){if(!(this instanceof g))return new g(Q);let J=this instanceof g0();if(this._readableState=new r(Q,this,J),Q){if(typeof Q.read==="function")this._read=Q.read;if(typeof Q.destroy==="function")this._destroy=Q.destroy;if(typeof Q.construct==="function")this._construct=Q.construct;if(Q.signal&&!J)N(Q.signal,this)}u.call(this,Q),B0.construct(this,()=>{if(this._readableState.needReadable)B2(this,this._readableState)})}g.prototype.destroy=B0.destroy,g.prototype._undestroy=B0.undestroy,g.prototype._destroy=function(Q,J){J(Q)},g.prototype[a.captureRejectionSymbol]=function(Q){this.destroy(Q)},g.prototype[O]=function(){let Q;if(!this.destroyed)Q=this.readableEnded?null:new b,this.destroy(Q);return new G((J,d)=>A(this,(n)=>n&&n!==Q?d(n):J(null)))},g.prototype.push=function(Q,J){return Q0(this,Q,J,!1)},g.prototype.unshift=function(Q,J){return Q0(this,Q,J,!0)};function Q0(Q,J,d,n){P("readableAddChunk",J);let U0=Q._readableState,M0;if((U0.state&c)===0){if(typeof J==="string"){if(d=d||U0.defaultEncoding,U0.encoding!==d)if(n&&U0.encoding)J=F.from(J,d).toString(U0.encoding);else J=F.from(J,d),d=""}else if(J instanceof F)d="";else if(u._isUint8Array(J))J=u._uint8ArrayToBuffer(J),d="";else if(J!=null)M0=new v("chunk",["string","Buffer","Uint8Array"],J)}if(M0)Y(Q,M0);else if(J===null)U0.state&=~I0,A0(Q,U0);else if((U0.state&c)!==0||J&&J.length>0)if(n)if((U0.state&R)!==0)Y(Q,new W);else if(U0.destroyed||U0.errored)return!1;else T0(Q,U0,J,!0);else if(U0.ended)Y(Q,new L);else if(U0.destroyed||U0.errored)return!1;else if(U0.state&=~I0,U0.decoder&&!d)if(J=U0.decoder.write(J),U0.objectMode||J.length!==0)T0(Q,U0,J,!1);else B2(Q,U0);else T0(Q,U0,J,!1);else if(!n)U0.state&=~I0,B2(Q,U0);return!U0.ended&&(U0.length<U0.highWaterMark||U0.length===0)}function T0(Q,J,d,n){if(J.flowing&&J.length===0&&!J.sync&&Q.listenerCount("data")>0){if((J.state&m)!==0)J.awaitDrainWriters.clear();else J.awaitDrainWriters=null;J.dataEmitted=!0,Q.emit("data",d)}else{if(J.length+=J.objectMode?1:d.length,n)J.buffer.unshift(d);else J.buffer.push(d);if((J.state&K0)!==0)O0(Q)}B2(Q,J)}g.prototype.isPaused=function(){let Q=this._readableState;return Q[X0]===!0||Q.flowing===!1},g.prototype.setEncoding=function(Q){let J=new Y0(Q);this._readableState.decoder=J,this._readableState.encoding=this._readableState.decoder.encoding;let d=this._readableState.buffer,n="";for(let U0 of d)n+=J.write(U0);if(d.clear(),n!=="")d.push(n);return this._readableState.length=n.length,this};var E0=1073741824;function V0(Q){if(Q>E0)throw new V("size","<= 1GiB",Q);else Q--,Q|=Q>>>1,Q|=Q>>>2,Q|=Q>>>4,Q|=Q>>>8,Q|=Q>>>16,Q++;return Q}function m0(Q,J){if(Q<=0||J.length===0&&J.ended)return 0;if((J.state&c)!==0)return 1;if(X(Q)){if(J.flowing&&J.length)return J.buffer.first().length;return J.length}if(Q<=J.length)return Q;return J.ended?J.length:0}g.prototype.read=function(Q){if(P("read",Q),Q===void 0)Q=NaN;else if(!I(Q))Q=Z(Q,10);let J=this._readableState,d=Q;if(Q>J.highWaterMark)J.highWaterMark=V0(Q);if(Q!==0)J.state&=~k;if(Q===0&&J.needReadable&&((J.highWaterMark!==0?J.length>=J.highWaterMark:J.length>0)||J.ended)){if(P("read: emitReadable",J.length,J.ended),J.length===0&&J.ended)M2(this);else O0(this);return null}if(Q=m0(Q,J),Q===0&&J.ended){if(J.length===0)M2(this);return null}let n=(J.state&K0)!==0;if(P("need readable",n),J.length===0||J.length-Q<J.highWaterMark)n=!0,P("length less than watermark",n);if(J.ended||J.reading||J.destroyed||J.errored||!J.constructed)n=!1,P("reading, ended or constructing",n);else if(n){if(P("do read"),J.state|=I0|q0,J.length===0)J.state|=K0;try{this._read(J.highWaterMark)}catch(M0){Y(this,M0)}if(J.state&=~q0,!J.reading)Q=m0(d,J)}let U0;if(Q>0)U0=r2(Q,J);else U0=null;if(U0===null)J.needReadable=J.length<=J.highWaterMark,Q=0;else if(J.length-=Q,J.multiAwaitDrain)J.awaitDrainWriters.clear();else J.awaitDrainWriters=null;if(J.length===0){if(!J.ended)J.needReadable=!0;if(d!==Q&&J.ended)M2(this)}if(U0!==null&&!J.errorEmitted&&!J.closeEmitted)J.dataEmitted=!0,this.emit("data",U0);return U0};function A0(Q,J){if(P("onEofChunk"),J.ended)return;if(J.decoder){let d=J.decoder.end();if(d&&d.length)J.buffer.push(d),J.length+=J.objectMode?1:d.length}if(J.ended=!0,J.sync)O0(Q);else J.needReadable=!1,J.emittedReadable=!0,h2(Q)}function O0(Q){let J=Q._readableState;if(P("emitReadable",J.needReadable,J.emittedReadable),J.needReadable=!1,!J.emittedReadable)P("emitReadable",J.flowing),J.emittedReadable=!0,B.nextTick(h2,Q)}function h2(Q){let J=Q._readableState;if(P("emitReadable_",J.destroyed,J.length,J.ended),!J.destroyed&&!J.errored&&(J.length||J.ended))Q.emit("readable"),J.emittedReadable=!1;J.needReadable=!J.flowing&&!J.ended&&J.length<=J.highWaterMark,n2(Q)}function B2(Q,J){if(!J.readingMore&&J.constructed)J.readingMore=!0,B.nextTick(k0,Q,J)}function k0(Q,J){while(!J.reading&&!J.ended&&(J.length<J.highWaterMark||J.flowing&&J.length===0)){let d=J.length;if(P("maybeReadMore read 0"),Q.read(0),d===J.length)break}J.readingMore=!1}g.prototype._read=function(Q){throw new M("_read()")},g.prototype.pipe=function(Q,J){let d=this,n=this._readableState;if(n.pipes.length===1){if(!n.multiAwaitDrain)n.multiAwaitDrain=!0,n.awaitDrainWriters=new C(n.awaitDrainWriters?[n.awaitDrainWriters]:[])}n.pipes.push(Q),P("pipe count=%d opts=%j",n.pipes.length,J);let U0=(!J||J.end!==!1)&&Q!==B.stdout&&Q!==B.stderr?P0:Q2;if(n.endEmitted)B.nextTick(U0);else d.once("end",U0);Q.on("unpipe",M0);function M0(o0,y0){if(P("onunpipe"),o0===d){if(y0&&y0.hasUnpiped===!1)y0.hasUnpiped=!0,q6()}}function P0(){P("onend"),Q.end()}let n0,s2=!1;function q6(){if(P("cleanup"),Q.removeListener("close",x2),Q.removeListener("finish",D2),n0)Q.removeListener("drain",n0);if(Q.removeListener("error",O2),Q.removeListener("unpipe",M0),d.removeListener("end",P0),d.removeListener("end",Q2),d.removeListener("data",e2),s2=!0,n0&&n.awaitDrainWriters&&(!Q._writableState||Q._writableState.needDrain))n0()}function t2(){if(!s2){if(n.pipes.length===1&&n.pipes[0]===Q)P("false write response, pause",0),n.awaitDrainWriters=Q,n.multiAwaitDrain=!1;else if(n.pipes.length>1&&n.pipes.includes(Q))P("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(Q);d.pause()}if(!n0)n0=Z6(d,Q),Q.on("drain",n0)}d.on("data",e2);function e2(o0){P("ondata");let y0=Q.write(o0);if(P("dest.write",y0),y0===!1)t2()}function O2(o0){if(P("onerror",o0),Q2(),Q.removeListener("error",O2),Q.listenerCount("error")===0){let y0=Q._writableState||Q._readableState;if(y0&&!y0.errorEmitted)Y(Q,o0);else Q.emit("error",o0)}}j(Q,"error",O2);function x2(){Q.removeListener("finish",D2),Q2()}Q.once("close",x2);function D2(){P("onfinish"),Q.removeListener("close",x2),Q2()}Q.once("finish",D2);function Q2(){P("unpipe"),d.unpipe(Q)}if(Q.emit("pipe",d),Q.writableNeedDrain===!0)t2();else if(!n.flowing)P("pipe resume"),d.resume();return Q};function Z6(Q,J){return function(){let n=Q._readableState;if(n.awaitDrainWriters===J)P("pipeOnDrain",1),n.awaitDrainWriters=null;else if(n.multiAwaitDrain)P("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(J);if((!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&Q.listenerCount("data"))Q.resume()}}g.prototype.unpipe=function(Q){let J=this._readableState,d={hasUnpiped:!1};if(J.pipes.length===0)return this;if(!Q){let U0=J.pipes;J.pipes=[],this.pause();for(let M0=0;M0<U0.length;M0++)U0[M0].emit("unpipe",this,{hasUnpiped:!1});return this}let n=U(J.pipes,Q);if(n===-1)return this;if(J.pipes.splice(n,1),J.pipes.length===0)this.pause();return Q.emit("unpipe",this,d),this},g.prototype.on=function(Q,J){let d=u.prototype.on.call(this,Q,J),n=this._readableState;if(Q==="data"){if(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1)this.resume()}else if(Q==="readable"){if(!n.endEmitted&&!n.readableListening){if(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,P("on readable",n.length,n.reading),n.length)O0(this);else if(!n.reading)B.nextTick(Q6,this)}}return d},g.prototype.addListener=g.prototype.on,g.prototype.removeListener=function(Q,J){let d=u.prototype.removeListener.call(this,Q,J);if(Q==="readable")B.nextTick(m2,this);return d},g.prototype.off=g.prototype.removeListener,g.prototype.removeAllListeners=function(Q){let J=u.prototype.removeAllListeners.apply(this,arguments);if(Q==="readable"||Q===void 0)B.nextTick(m2,this);return J};function m2(Q){let J=Q._readableState;if(J.readableListening=Q.listenerCount("readable")>0,J.resumeScheduled&&J[X0]===!1)J.flowing=!0;else if(Q.listenerCount("data")>0)Q.resume();else if(!J.readableListening)J.flowing=null}function Q6(Q){P("readable nexttick read 0"),Q.read(0)}g.prototype.resume=function(){let Q=this._readableState;if(!Q.flowing)P("resume"),Q.flowing=!Q.readableListening,J6(this,Q);return Q[X0]=!1,this};function J6(Q,J){if(!J.resumeScheduled)J.resumeScheduled=!0,B.nextTick(F6,Q,J)}function F6(Q,J){if(P("resume",J.reading),!J.reading)Q.read(0);if(J.resumeScheduled=!1,Q.emit("resume"),n2(Q),J.flowing&&!J.reading)Q.read(0)}g.prototype.pause=function(){if(P("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)P("pause"),this._readableState.flowing=!1,this.emit("pause");return this._readableState[X0]=!0,this};function n2(Q){let J=Q._readableState;P("flow",J.flowing);while(J.flowing&&Q.read()!==null);}g.prototype.wrap=function(Q){let J=!1;Q.on("data",(n)=>{if(!this.push(n)&&Q.pause)J=!0,Q.pause()}),Q.on("end",()=>{this.push(null)}),Q.on("error",(n)=>{Y(this,n)}),Q.on("close",()=>{this.destroy()}),Q.on("destroy",()=>{this.destroy()}),this._read=()=>{if(J&&Q.resume)J=!1,Q.resume()};let d=q(Q);for(let n=1;n<d.length;n++){let U0=d[n];if(this[U0]===void 0&&typeof Q[U0]==="function")this[U0]=Q[U0].bind(Q)}return this},g.prototype[x]=function(){return o2(this)},g.prototype.iterator=function(Q){if(Q!==void 0)e(Q,"options");return o2(this,Q)};function o2(Q,J){if(typeof Q.read!=="function")Q=g.wrap(Q,{objectMode:!0});let d=z6(Q,J);return d.stream=Q,d}async function*z6(Q,J){let d=Z0;function n(P0){if(this===Q)d(),d=Z0;else d=P0}Q.on("readable",n);let U0,M0=A(Q,{writable:!1},(P0)=>{U0=P0?D(U0,P0):null,d(),d=Z0});try{while(!0){let P0=Q.destroyed?null:Q.read();if(P0!==null)yield P0;else if(U0)throw U0;else if(U0===null)return;else await new G(n)}}catch(P0){throw U0=D(U0,P0),U0}finally{if((U0||(J===null||J===void 0?void 0:J.destroyOnReturn)!==!1)&&(U0===void 0||Q._readableState.autoDestroy))B0.destroyer(Q,null);else Q.off("readable",n),M0()}}K(g.prototype,{readable:{__proto__:null,get(){let Q=this._readableState;return!!Q&&Q.readable!==!1&&!Q.destroyed&&!Q.errorEmitted&&!Q.endEmitted},set(Q){if(this._readableState)this._readableState.readable=!!Q}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(Q){if(this._readableState)this._readableState.flowing=Q}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(Q){if(!this._readableState)return;this._readableState.destroyed=Q}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}}),K(r.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[X0]!==!1},set(Q){this[X0]=!!Q}}}),g._fromList=r2;function r2(Q,J){if(J.length===0)return null;let d;if(J.objectMode)d=J.buffer.shift();else if(!Q||Q>=J.length){if(J.decoder)d=J.buffer.join("");else if(J.buffer.length===1)d=J.buffer.first();else d=J.buffer.concat(J.length);J.buffer.clear()}else d=J.buffer.consume(Q,J.decoder);return d}function M2(Q){let J=Q._readableState;if(P("endReadable",J.endEmitted),!J.endEmitted)J.ended=!0,B.nextTick(K6,J,Q)}function K6(Q,J){if(P("endReadableNT",Q.endEmitted,Q.length),!Q.errored&&!Q.closeEmitted&&!Q.endEmitted&&Q.length===0){if(Q.endEmitted=!0,J.emit("end"),J.writable&&J.allowHalfOpen===!1)B.nextTick(Y6,J);else if(Q.autoDestroy){let d=J._writableState;if(!d||d.autoDestroy&&(d.finished||d.writable===!1))J.destroy()}}}function Y6(Q){if(Q.writable&&!Q.writableEnded&&!Q.destroyed)Q.end()}g.from=function(Q,J){return S(g,Q,J)};var L2;function a2(){if(L2===void 0)L2={};return L2}g.fromWeb=function(Q,J){return a2().newStreamReadableFromReadableStream(Q,J)},g.toWeb=function(Q,J){return a2().newReadableStreamFromStreamReadable(Q,J)},g.wrap=function(Q,J){var d,n;return new g({objectMode:(d=(n=Q.readableObjectMode)!==null&&n!==void 0?n:Q.objectMode)!==null&&d!==void 0?d:!0,...J,destroy(U0,M0){B0.destroyer(Q,U0),M0(U0)}}).wrap(Q)}}),i2=G0((w,h)=>{var B=e0(),{ArrayPrototypeSlice:U,Error:I,FunctionPrototypeSymbolHasInstance:X,ObjectDefineProperty:Z,ObjectDefineProperties:K,ObjectSetPrototypeOf:q,StringPrototypeToLowerCase:z,Symbol:G,SymbolHasInstance:C}=N0();h.exports=e,e.WritableState=W;var{EventEmitter:O}=(q2(),_0(Y2)),x=b2().Stream,{Buffer:l}=(v0(),_0(u0)),a=I2(),{addAbortSignal:u}=V2(),{getHighWaterMark:j,getDefaultHighWaterMark:F}=j2(),{ERR_INVALID_ARG_TYPE:N,ERR_METHOD_NOT_IMPLEMENTED:A,ERR_MULTIPLE_CALLBACK:P,ERR_STREAM_CANNOT_PIPE:s,ERR_STREAM_DESTROYED:B0,ERR_STREAM_ALREADY_FINISHED:H0,ERR_STREAM_NULL_VALUES:t,ERR_STREAM_WRITE_AFTER_END:D,ERR_UNKNOWN_ENCODING:v}=L0().codes,{errorOrDestroy:M}=a;q(e.prototype,x.prototype),q(e,x);function V(){}var L=G("kOnFinished");function W(H,E,T){if(typeof T!=="boolean")T=E instanceof g0();if(this.objectMode=!!(H&&H.objectMode),T)this.objectMode=this.objectMode||!!(H&&H.writableObjectMode);this.highWaterMark=H?j(this,H,"writableHighWaterMark",T):F(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let p=!!(H&&H.decodeStrings===!1);this.decodeStrings=!p,this.defaultEncoding=H&&H.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=Y.bind(void 0,E),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,b(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!H||H.emitClose!==!1,this.autoDestroy=!H||H.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[L]=[]}function b(H){H.buffered=[],H.bufferedIndex=0,H.allBuffers=!0,H.allNoop=!0}W.prototype.getBuffer=function(){return U(this.buffered,this.bufferedIndex)},Z(W.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function e(H){let E=this instanceof g0();if(!E&&!X(e,this))return new e(H);if(this._writableState=new W(H,this,E),H){if(typeof H.write==="function")this._write=H.write;if(typeof H.writev==="function")this._writev=H.writev;if(typeof H.destroy==="function")this._destroy=H.destroy;if(typeof H.final==="function")this._final=H.final;if(typeof H.construct==="function")this._construct=H.construct;if(H.signal)u(H.signal,this)}x.call(this,H),a.construct(this,()=>{let T=this._writableState;if(!T.writing)I0(this,T);k(this,T)})}Z(e,C,{__proto__:null,value:function(H){if(X(this,H))return!0;if(this!==e)return!1;return H&&H._writableState instanceof W}}),e.prototype.pipe=function(){M(this,new s)};function X0(H,E,T,p){let m=H._writableState;if(typeof T==="function")p=T,T=m.defaultEncoding;else{if(!T)T=m.defaultEncoding;else if(T!=="buffer"&&!l.isEncoding(T))throw new v(T);if(typeof p!=="function")p=V}if(E===null)throw new t;else if(!m.objectMode)if(typeof E==="string"){if(m.decodeStrings!==!1)E=l.from(E,T),T="buffer"}else if(E instanceof l)T="buffer";else if(x._isUint8Array(E))E=x._uint8ArrayToBuffer(E),T="buffer";else throw new N("chunk",["string","Buffer","Uint8Array"],E);let i;if(m.ending)i=new D;else if(m.destroyed)i=new B0("write");if(i)return B.nextTick(p,i),M(H,i,!0),i;return m.pendingcb++,Y0(H,m,E,T,p)}e.prototype.write=function(H,E,T){return X0(this,H,E,T)===!0},e.prototype.cork=function(){this._writableState.corked++},e.prototype.uncork=function(){let H=this._writableState;if(H.corked){if(H.corked--,!H.writing)I0(this,H)}},e.prototype.setDefaultEncoding=function(E){if(typeof E==="string")E=z(E);if(!l.isEncoding(E))throw new v(E);return this._writableState.defaultEncoding=E,this};function Y0(H,E,T,p,m){let i=E.objectMode?1:T.length;E.length+=i;let $=E.length<E.highWaterMark;if(!$)E.needDrain=!0;if(E.writing||E.corked||E.errored||!E.constructed){if(E.buffered.push({chunk:T,encoding:p,callback:m}),E.allBuffers&&p!=="buffer")E.allBuffers=!1;if(E.allNoop&&m!==V)E.allNoop=!1}else E.writelen=i,E.writecb=m,E.writing=!0,E.sync=!0,H._write(T,p,E.onwrite),E.sync=!1;return $&&!E.errored&&!E.destroyed}function S(H,E,T,p,m,i,$){if(E.writelen=p,E.writecb=$,E.writing=!0,E.sync=!0,E.destroyed)E.onwrite(new B0("write"));else if(T)H._writev(m,E.onwrite);else H._write(m,i,E.onwrite);E.sync=!1}function Z0(H,E,T,p){--E.pendingcb,p(T),R(E),M(H,T)}function Y(H,E){let T=H._writableState,p=T.sync,m=T.writecb;if(typeof m!=="function"){M(H,new P);return}if(T.writing=!1,T.writecb=null,T.length-=T.writelen,T.writelen=0,E){if(E.stack,!T.errored)T.errored=E;if(H._readableState&&!H._readableState.errored)H._readableState.errored=E;if(p)B.nextTick(Z0,H,T,E,m);else Z0(H,T,E,m)}else{if(T.buffered.length>T.bufferedIndex)I0(H,T);if(p)if(T.afterWriteTickInfo!==null&&T.afterWriteTickInfo.cb===m)T.afterWriteTickInfo.count++;else T.afterWriteTickInfo={count:1,cb:m,stream:H,state:T},B.nextTick(c,T.afterWriteTickInfo);else h0(H,T,1,m)}}function c({stream:H,state:E,count:T,cb:p}){return E.afterWriteTickInfo=null,h0(H,E,T,p)}function h0(H,E,T,p){if(!E.ending&&!H.destroyed&&E.length===0&&E.needDrain)E.needDrain=!1,H.emit("drain");while(T-- >0)E.pendingcb--,p();if(E.destroyed)R(E);k(H,E)}function R(H){if(H.writing)return;for(let m=H.bufferedIndex;m<H.buffered.length;++m){var E;let{chunk:i,callback:$}=H.buffered[m],y=H.objectMode?1:i.length;H.length-=y,$((E=H.errored)!==null&&E!==void 0?E:new B0("write"))}let T=H[L].splice(0);for(let m=0;m<T.length;m++){var p;T[m]((p=H.errored)!==null&&p!==void 0?p:new B0("end"))}b(H)}function I0(H,E){if(E.corked||E.bufferProcessing||E.destroyed||!E.constructed)return;let{buffered:T,bufferedIndex:p,objectMode:m}=E,i=T.length-p;if(!i)return;let $=p;if(E.bufferProcessing=!0,i>1&&H._writev){E.pendingcb-=i-1;let y=E.allNoop?V:(g)=>{for(let Q0=$;Q0<T.length;++Q0)T[Q0].callback(g)},r=E.allNoop&&$===0?T:U(T,$);r.allBuffers=E.allBuffers,S(H,E,!0,E.length,r,"",y),b(E)}else{do{let{chunk:y,encoding:r,callback:g}=T[$];T[$++]=null;let Q0=m?1:y.length;S(H,E,!1,Q0,y,r,g)}while($<T.length&&!E.writing);if($===T.length)b(E);else if($>256)T.splice(0,$),E.bufferedIndex=0;else E.bufferedIndex=$}E.bufferProcessing=!1}e.prototype._write=function(H,E,T){if(this._writev)this._writev([{chunk:H,encoding:E}],T);else throw new A("_write()")},e.prototype._writev=null,e.prototype.end=function(H,E,T){let p=this._writableState;if(typeof H==="function")T=H,H=null,E=null;else if(typeof E==="function")T=E,E=null;let m;if(H!==null&&H!==void 0){let i=X0(this,H,E);if(i instanceof I)m=i}if(p.corked)p.corked=1,this.uncork();if(m);else if(!p.errored&&!p.ending)p.ending=!0,k(this,p,!0),p.ended=!0;else if(p.finished)m=new H0("end");else if(p.destroyed)m=new B0("end");if(typeof T==="function")if(m||p.finished)B.nextTick(T,m);else p[L].push(T);return this};function J0(H){return H.ending&&!H.destroyed&&H.constructed&&H.length===0&&!H.errored&&H.buffered.length===0&&!H.finished&&!H.writing&&!H.errorEmitted&&!H.closeEmitted}function q0(H,E){let T=!1;function p(m){if(T){M(H,m!==null&&m!==void 0?m:P());return}if(T=!0,E.pendingcb--,m){let i=E[L].splice(0);for(let $=0;$<i.length;$++)i[$](m);M(H,m,E.sync)}else if(J0(E))E.prefinished=!0,H.emit("prefinish"),E.pendingcb++,B.nextTick(f,H,E)}E.sync=!0,E.pendingcb++;try{H._final(p)}catch(m){p(m)}E.sync=!1}function K0(H,E){if(!E.prefinished&&!E.finalCalled)if(typeof H._final==="function"&&!E.destroyed)E.finalCalled=!0,q0(H,E);else E.prefinished=!0,H.emit("prefinish")}function k(H,E,T){if(J0(E)){if(K0(H,E),E.pendingcb===0){if(T)E.pendingcb++,B.nextTick((p,m)=>{if(J0(m))f(p,m);else m.pendingcb--},H,E);else if(J0(E))E.pendingcb++,f(H,E)}}}function f(H,E){E.pendingcb--,E.finished=!0;let T=E[L].splice(0);for(let p=0;p<T.length;p++)T[p]();if(H.emit("finish"),E.autoDestroy){let p=H._readableState;if(!p||p.autoDestroy&&(p.endEmitted||p.readable===!1))H.destroy()}}K(e.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(H){if(this._writableState)this._writableState.destroyed=H}},writable:{__proto__:null,get(){let H=this._writableState;return!!H&&H.writable!==!1&&!H.destroyed&&!H.errored&&!H.ending&&!H.ended},set(H){if(this._writableState)this._writableState.writable=!!H}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let H=this._writableState;if(!H)return!1;return!H.destroyed&&!H.ending&&H.needDrain}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var o=a.destroy;e.prototype.destroy=function(H,E){let T=this._writableState;if(!T.destroyed&&(T.bufferedIndex<T.buffered.length||T[L].length))B.nextTick(R,T);return o.call(this,H,E),this},e.prototype._undestroy=a.undestroy,e.prototype._destroy=function(H,E){E(H)},e.prototype[O.captureRejectionSymbol]=function(H){this.destroy(H)};var z0;function F0(){if(z0===void 0)z0={};return z0}e.fromWeb=function(H,E){return F0().newStreamWritableFromWritableStream(H,E)},e.toWeb=function(H){return F0().newWritableStreamFromStreamWritable(H)}}),N8=G0((w,h)=>{var B=e0(),U=(v0(),_0(u0)),{isReadable:I,isWritable:X,isIterable:Z,isNodeStream:K,isReadableNodeStream:q,isWritableNodeStream:z,isDuplexNodeStream:G,isReadableStream:C,isWritableStream:O}=b0(),x=d0(),{AbortError:l,codes:{ERR_INVALID_ARG_TYPE:a,ERR_INVALID_RETURN_VALUE:u}}=L0(),{destroyer:j}=I2(),F=g0(),N=A2(),A=i2(),{createDeferredPromise:P}=D0(),s=i1(),B0=globalThis.Blob||U.Blob,H0=typeof B0<"u"?function(W){return W instanceof B0}:function(W){return!1},t=globalThis.AbortController||H2().AbortController,{FunctionPrototypeCall:D}=N0();class v extends F{constructor(L){super(L);if((L===null||L===void 0?void 0:L.readable)===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if((L===null||L===void 0?void 0:L.writable)===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}}h.exports=function L(W,b){if(G(W))return W;if(q(W))return V({readable:W});if(z(W))return V({writable:W});if(K(W))return V({writable:!1,readable:!1});if(C(W))return V({readable:N.fromWeb(W)});if(O(W))return V({writable:A.fromWeb(W)});if(typeof W==="function"){let{value:X0,write:Y0,final:S,destroy:Z0}=M(W);if(Z(X0))return s(v,X0,{objectMode:!0,write:Y0,final:S,destroy:Z0});let Y=X0===null||X0===void 0?void 0:X0.then;if(typeof Y==="function"){let c,h0=D(Y,X0,(R)=>{if(R!=null)throw new u("nully","body",R)},(R)=>{j(c,R)});return c=new v({objectMode:!0,readable:!1,write:Y0,final(R){S(async()=>{try{await h0,B.nextTick(R,null)}catch(I0){B.nextTick(R,I0)}})},destroy:Z0})}throw new u("Iterable, AsyncIterable or AsyncFunction",b,X0)}if(H0(W))return L(W.arrayBuffer());if(Z(W))return s(v,W,{objectMode:!0,writable:!1});if(C(W===null||W===void 0?void 0:W.readable)&&O(W===null||W===void 0?void 0:W.writable))return v.fromWeb(W);if(typeof(W===null||W===void 0?void 0:W.writable)==="object"||typeof(W===null||W===void 0?void 0:W.readable)==="object"){let X0=W!==null&&W!==void 0&&W.readable?q(W===null||W===void 0?void 0:W.readable)?W===null||W===void 0?void 0:W.readable:L(W.readable):void 0,Y0=W!==null&&W!==void 0&&W.writable?z(W===null||W===void 0?void 0:W.writable)?W===null||W===void 0?void 0:W.writable:L(W.writable):void 0;return V({readable:X0,writable:Y0})}let e=W===null||W===void 0?void 0:W.then;if(typeof e==="function"){let X0;return D(e,W,(Y0)=>{if(Y0!=null)X0.push(Y0);X0.push(null)},(Y0)=>{j(X0,Y0)}),X0=new v({objectMode:!0,writable:!1,read(){}})}throw new a(b,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],W)};function M(L){let{promise:W,resolve:b}=P(),e=new t,X0=e.signal;return{value:L(async function*(){while(!0){let Y0=W;W=null;let{chunk:S,done:Z0,cb:Y}=await Y0;if(B.nextTick(Y),Z0)return;if(X0.aborted)throw new l(void 0,{cause:X0.reason});({promise:W,resolve:b}=P()),yield S}}(),{signal:X0}),write(Y0,S,Z0){let Y=b;b=null,Y({chunk:Y0,done:!1,cb:Z0})},final(Y0){let S=b;b=null,S({done:!0,cb:Y0})},destroy(Y0,S){e.abort(),S(Y0)}}}function V(L){let W=L.readable&&typeof L.readable.read!=="function"?N.wrap(L.readable):L.readable,b=L.writable,e=!!I(W),X0=!!X(b),Y0,S,Z0,Y,c;function h0(R){let I0=Y;if(Y=null,I0)I0(R);else if(R)c.destroy(R)}if(c=new v({readableObjectMode:!!(W!==null&&W!==void 0&&W.readableObjectMode),writableObjectMode:!!(b!==null&&b!==void 0&&b.writableObjectMode),readable:e,writable:X0}),X0)x(b,(R)=>{if(X0=!1,R)j(W,R);h0(R)}),c._write=function(R,I0,J0){if(b.write(R,I0))J0();else Y0=J0},c._final=function(R){b.end(),S=R},b.on("drain",function(){if(Y0){let R=Y0;Y0=null,R()}}),b.on("finish",function(){if(S){let R=S;S=null,R()}});if(e)x(W,(R)=>{if(e=!1,R)j(W,R);h0(R)}),W.on("readable",function(){if(Z0){let R=Z0;Z0=null,R()}}),W.on("end",function(){c.push(null)}),c._read=function(){while(!0){let R=W.read();if(R===null){Z0=c._read;return}if(!c.push(R))return}};return c._destroy=function(R,I0){if(!R&&Y!==null)R=new l;if(Z0=null,Y0=null,S=null,Y===null)I0(R);else Y=I0,j(b,R),j(W,R)},c}}),g0=G0((w,h)=>{var{ObjectDefineProperties:B,ObjectGetOwnPropertyDescriptor:U,ObjectKeys:I,ObjectSetPrototypeOf:X}=N0();h.exports=q;var Z=A2(),K=i2();X(q.prototype,Z.prototype),X(q,Z);{let O=I(K.prototype);for(let x=0;x<O.length;x++){let l=O[x];if(!q.prototype[l])q.prototype[l]=K.prototype[l]}}function q(O){if(!(this instanceof q))return new q(O);if(Z.call(this,O),K.call(this,O),O){if(this.allowHalfOpen=O.allowHalfOpen!==!1,O.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(O.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}B(q.prototype,{writable:{__proto__:null,...U(K.prototype,"writable")},writableHighWaterMark:{__proto__:null,...U(K.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...U(K.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...U(K.prototype,"writableBuffer")},writableLength:{__proto__:null,...U(K.prototype,"writableLength")},writableFinished:{__proto__:null,...U(K.prototype,"writableFinished")},writableCorked:{__proto__:null,...U(K.prototype,"writableCorked")},writableEnded:{__proto__:null,...U(K.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...U(K.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(O){if(this._readableState&&this._writableState)this._readableState.destroyed=O,this._writableState.destroyed=O}}});var z;function G(){if(z===void 0)z={};return z}q.fromWeb=function(O,x){return G().newStreamDuplexFromReadableWritablePair(O,x)},q.toWeb=function(O){return G().newReadableWritablePairFromDuplex(O)};var C;q.from=function(O){if(!C)C=N8();return C(O,"body")}}),p1=G0((w,h)=>{var{ObjectSetPrototypeOf:B,Symbol:U}=N0();h.exports=q;var{ERR_METHOD_NOT_IMPLEMENTED:I}=L0().codes,X=g0(),{getHighWaterMark:Z}=j2();B(q.prototype,X.prototype),B(q,X);var K=U("kCallback");function q(C){if(!(this instanceof q))return new q(C);let O=C?Z(this,C,"readableHighWaterMark",!0):null;if(O===0)C={...C,highWaterMark:null,readableHighWaterMark:O,writableHighWaterMark:C.writableHighWaterMark||0};if(X.call(this,C),this._readableState.sync=!1,this[K]=null,C){if(typeof C.transform==="function")this._transform=C.transform;if(typeof C.flush==="function")this._flush=C.flush}this.on("prefinish",G)}function z(C){if(typeof this._flush==="function"&&!this.destroyed)this._flush((O,x)=>{if(O){if(C)C(O);else this.destroy(O);return}if(x!=null)this.push(x);if(this.push(null),C)C()});else if(this.push(null),C)C()}function G(){if(this._final!==z)z.call(this)}q.prototype._final=z,q.prototype._transform=function(C,O,x){throw new I("_transform()")},q.prototype._write=function(C,O,x){let l=this._readableState,a=this._writableState,u=l.length;this._transform(C,O,(j,F)=>{if(j){x(j);return}if(F!=null)this.push(F);if(a.ended||u===l.length||l.length<l.highWaterMark)x();else this[K]=x})},q.prototype._read=function(){if(this[K]){let C=this[K];this[K]=null,C()}}}),d1=G0((w,h)=>{var{ObjectSetPrototypeOf:B}=N0();h.exports=I;var U=p1();B(I.prototype,U.prototype),B(I,U);function I(X){if(!(this instanceof I))return new I(X);U.call(this,X)}I.prototype._transform=function(X,Z,K){K(null,X)}}),p2=G0((w,h)=>{var B=e0(),{ArrayIsArray:U,Promise:I,SymbolAsyncIterator:X,SymbolDispose:Z}=N0(),K=d0(),{once:q}=D0(),z=I2(),G=g0(),{aggregateTwoErrors:C,codes:{ERR_INVALID_ARG_TYPE:O,ERR_INVALID_RETURN_VALUE:x,ERR_MISSING_ARGS:l,ERR_STREAM_DESTROYED:a,ERR_STREAM_PREMATURE_CLOSE:u},AbortError:j}=L0(),{validateFunction:F,validateAbortSignal:N}=$2(),{isIterable:A,isReadable:P,isReadableNodeStream:s,isNodeStream:B0,isTransformStream:H0,isWebStream:t,isReadableStream:D,isReadableFinished:v}=b0(),M=globalThis.AbortController||H2().AbortController,V,L,W;function b(R,I0,J0){let q0=!1;R.on("close",()=>{q0=!0});let K0=K(R,{readable:I0,writable:J0},(k)=>{q0=!k});return{destroy:(k)=>{if(q0)return;q0=!0,z.destroyer(R,k||new a("pipe"))},cleanup:K0}}function e(R){return F(R[R.length-1],"streams[stream.length - 1]"),R.pop()}function X0(R){if(A(R))return R;else if(s(R))return Y0(R);throw new O("val",["Readable","Iterable","AsyncIterable"],R)}async function*Y0(R){if(!L)L=A2();yield*L.prototype[X].call(R)}async function S(R,I0,J0,{end:q0}){let K0,k=null,f=(F0)=>{if(F0)K0=F0;if(k){let H=k;k=null,H()}},o=()=>new I((F0,H)=>{if(K0)H(K0);else k=()=>{if(K0)H(K0);else F0()}});I0.on("drain",f);let z0=K(I0,{readable:!1},f);try{if(I0.writableNeedDrain)await o();for await(let F0 of R)if(!I0.write(F0))await o();if(q0)I0.end(),await o();J0()}catch(F0){J0(K0!==F0?C(K0,F0):F0)}finally{z0(),I0.off("drain",f)}}async function Z0(R,I0,J0,{end:q0}){if(H0(I0))I0=I0.writable;let K0=I0.getWriter();try{for await(let k of R)await K0.ready,K0.write(k).catch(()=>{});if(await K0.ready,q0)await K0.close();J0()}catch(k){try{await K0.abort(k),J0(k)}catch(f){J0(f)}}}function Y(...R){return c(R,q(e(R)))}function c(R,I0,J0){if(R.length===1&&U(R[0]))R=R[0];if(R.length<2)throw new l("streams");let q0=new M,K0=q0.signal,k=J0===null||J0===void 0?void 0:J0.signal,f=[];N(k,"options.signal");function o(){m(new j)}W=W||D0().addAbortListener;let z0;if(k)z0=W(k,o);let F0,H,E=[],T=0;function p(g){m(g,--T===0)}function m(g,Q0){var T0;if(g&&(!F0||F0.code==="ERR_STREAM_PREMATURE_CLOSE"))F0=g;if(!F0&&!Q0)return;while(E.length)E.shift()(F0);if((T0=z0)===null||T0===void 0||T0[Z](),q0.abort(),Q0){if(!F0)f.forEach((E0)=>E0());B.nextTick(I0,F0,H)}}let i;for(let g=0;g<R.length;g++){let Q0=R[g],T0=g<R.length-1,E0=g>0,V0=T0||(J0===null||J0===void 0?void 0:J0.end)!==!1,m0=g===R.length-1;if(B0(Q0)){let A0=function(O0){if(O0&&O0.name!=="AbortError"&&O0.code!=="ERR_STREAM_PREMATURE_CLOSE")p(O0)};var $=A0;if(V0){let{destroy:O0,cleanup:h2}=b(Q0,T0,E0);if(E.push(O0),P(Q0)&&m0)f.push(h2)}if(Q0.on("error",A0),P(Q0)&&m0)f.push(()=>{Q0.removeListener("error",A0)})}if(g===0)if(typeof Q0==="function"){if(i=Q0({signal:K0}),!A(i))throw new x("Iterable, AsyncIterable or Stream","source",i)}else if(A(Q0)||s(Q0)||H0(Q0))i=Q0;else i=G.from(Q0);else if(typeof Q0==="function"){if(H0(i)){var y;i=X0((y=i)===null||y===void 0?void 0:y.readable)}else i=X0(i);if(i=Q0(i,{signal:K0}),T0){if(!A(i,!0))throw new x("AsyncIterable",`transform[${g-1}]`,i)}else{var r;if(!V)V=d1();let A0=new V({objectMode:!0}),O0=(r=i)===null||r===void 0?void 0:r.then;if(typeof O0==="function")T++,O0.call(i,(k0)=>{if(H=k0,k0!=null)A0.write(k0);if(V0)A0.end();B.nextTick(p)},(k0)=>{A0.destroy(k0),B.nextTick(p,k0)});else if(A(i,!0))T++,S(i,A0,p,{end:V0});else if(D(i)||H0(i)){let k0=i.readable||i;T++,S(k0,A0,p,{end:V0})}else throw new x("AsyncIterable or Promise","destination",i);i=A0;let{destroy:h2,cleanup:B2}=b(i,!1,!0);if(E.push(h2),m0)f.push(B2)}}else if(B0(Q0)){if(s(i)){T+=2;let A0=h0(i,Q0,p,{end:V0});if(P(Q0)&&m0)f.push(A0)}else if(H0(i)||D(i)){let A0=i.readable||i;T++,S(A0,Q0,p,{end:V0})}else if(A(i))T++,S(i,Q0,p,{end:V0});else throw new O("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],i);i=Q0}else if(t(Q0)){if(s(i))T++,Z0(X0(i),Q0,p,{end:V0});else if(D(i)||A(i))T++,Z0(i,Q0,p,{end:V0});else if(H0(i))T++,Z0(i.readable,Q0,p,{end:V0});else throw new O("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],i);i=Q0}else i=G.from(Q0)}if(K0!==null&&K0!==void 0&&K0.aborted||k!==null&&k!==void 0&&k.aborted)B.nextTick(o);return i}function h0(R,I0,J0,{end:q0}){let K0=!1;if(I0.on("close",()=>{if(!K0)J0(new u)}),R.pipe(I0,{end:!1}),q0){let f=function(){K0=!0,I0.end()};var k=f;if(v(R))B.nextTick(f);else R.once("end",f)}else J0();return K(R,{readable:!0,writable:!1},(f)=>{let o=R._readableState;if(f&&f.code==="ERR_STREAM_PREMATURE_CLOSE"&&o&&o.ended&&!o.errored&&!o.errorEmitted)R.once("end",J0).once("error",J0);else J0(f)}),K(I0,{readable:!1,writable:!0},J0)}h.exports={pipelineImpl:c,pipeline:Y}}),l1=G0((w,h)=>{var{pipeline:B}=p2(),U=g0(),{destroyer:I}=I2(),{isNodeStream:X,isReadable:Z,isWritable:K,isWebStream:q,isTransformStream:z,isWritableStream:G,isReadableStream:C}=b0(),{AbortError:O,codes:{ERR_INVALID_ARG_VALUE:x,ERR_MISSING_ARGS:l}}=L0(),a=d0();h.exports=function(...j){if(j.length===0)throw new l("streams");if(j.length===1)return U.from(j[0]);let F=[...j];if(typeof j[0]==="function")j[0]=U.from(j[0]);if(typeof j[j.length-1]==="function"){let V=j.length-1;j[V]=U.from(j[V])}for(let V=0;V<j.length;++V){if(!X(j[V])&&!q(j[V]))continue;if(V<j.length-1&&!(Z(j[V])||C(j[V])||z(j[V])))throw new x(`streams[${V}]`,F[V],"must be readable");if(V>0&&!(K(j[V])||G(j[V])||z(j[V])))throw new x(`streams[${V}]`,F[V],"must be writable")}let N,A,P,s,B0;function H0(V){let L=s;if(s=null,L)L(V);else if(V)B0.destroy(V);else if(!M&&!v)B0.destroy()}let t=j[0],D=B(j,H0),v=!!(K(t)||G(t)||z(t)),M=!!(Z(D)||C(D)||z(D));if(B0=new U({writableObjectMode:!!(t!==null&&t!==void 0&&t.writableObjectMode),readableObjectMode:!!(D!==null&&D!==void 0&&D.readableObjectMode),writable:v,readable:M}),v){if(X(t))B0._write=function(L,W,b){if(t.write(L,W))b();else N=b},B0._final=function(L){t.end(),A=L},t.on("drain",function(){if(N){let L=N;N=null,L()}});else if(q(t)){let L=(z(t)?t.writable:t).getWriter();B0._write=async function(W,b,e){try{await L.ready,L.write(W).catch(()=>{}),e()}catch(X0){e(X0)}},B0._final=async function(W){try{await L.ready,L.close().catch(()=>{}),A=W}catch(b){W(b)}}}let V=z(D)?D.readable:D;a(V,()=>{if(A){let L=A;A=null,L()}})}if(M){if(X(D))D.on("readable",function(){if(P){let V=P;P=null,V()}}),D.on("end",function(){B0.push(null)}),B0._read=function(){while(!0){let V=D.read();if(V===null){P=B0._read;return}if(!B0.push(V))return}};else if(q(D)){let V=(z(D)?D.readable:D).getReader();B0._read=async function(){while(!0)try{let{value:L,done:W}=await V.read();if(!B0.push(L))return;if(W){B0.push(null);return}}catch{return}}}}return B0._destroy=function(V,L){if(!V&&s!==null)V=new O;if(P=null,N=null,A=null,s===null)L(V);else if(s=L,X(D))I(D,V)},B0}}),E8=G0((w,h)=>{var B=globalThis.AbortController||H2().AbortController,{codes:{ERR_INVALID_ARG_VALUE:U,ERR_INVALID_ARG_TYPE:I,ERR_MISSING_ARGS:X,ERR_OUT_OF_RANGE:Z},AbortError:K}=L0(),{validateAbortSignal:q,validateInteger:z,validateObject:G}=$2(),C=N0().Symbol("kWeak"),O=N0().Symbol("kResistStopPropagation"),{finished:x}=d0(),l=l1(),{addAbortSignalNoValidate:a}=V2(),{isWritable:u,isNodeStream:j}=b0(),{deprecate:F}=D0(),{ArrayPrototypePush:N,Boolean:A,MathFloor:P,Number:s,NumberIsNaN:B0,Promise:H0,PromiseReject:t,PromiseResolve:D,PromisePrototypeThen:v,Symbol:M}=N0(),V=M("kEmpty"),L=M("kEof");function W(k,f){if(f!=null)G(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)q(f.signal,"options.signal");if(j(k)&&!u(k))throw new U("stream",k,"must be writable");let o=l(this,k);if(f!==null&&f!==void 0&&f.signal)a(f.signal,o);return o}function b(k,f){if(typeof k!=="function")throw new I("fn",["Function","AsyncFunction"],k);if(f!=null)G(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)q(f.signal,"options.signal");let o=1;if((f===null||f===void 0?void 0:f.concurrency)!=null)o=P(f.concurrency);let z0=o-1;if((f===null||f===void 0?void 0:f.highWaterMark)!=null)z0=P(f.highWaterMark);return z(o,"options.concurrency",1),z(z0,"options.highWaterMark",0),z0+=o,async function*(){let H=D0().AbortSignalAny([f===null||f===void 0?void 0:f.signal].filter(A)),E=this,T=[],p={signal:H},m,i,$=!1,y=0;function r(){$=!0,g()}function g(){y-=1,Q0()}function Q0(){if(i&&!$&&y<o&&T.length<z0)i(),i=null}async function T0(){try{for await(let E0 of E){if($)return;if(H.aborted)throw new K;try{if(E0=k(E0,p),E0===V)continue;E0=D(E0)}catch(V0){E0=t(V0)}if(y+=1,v(E0,g,r),T.push(E0),m)m(),m=null;if(!$&&(T.length>=z0||y>=o))await new H0((V0)=>{i=V0})}T.push(L)}catch(E0){let V0=t(E0);v(V0,g,r),T.push(V0)}finally{if($=!0,m)m(),m=null}}T0();try{while(!0){while(T.length>0){let E0=await T[0];if(E0===L)return;if(H.aborted)throw new K;if(E0!==V)yield E0;T.shift(),Q0()}await new H0((E0)=>{m=E0})}}finally{if($=!0,i)i(),i=null}}.call(this)}function e(k=void 0){if(k!=null)G(k,"options");if((k===null||k===void 0?void 0:k.signal)!=null)q(k.signal,"options.signal");return async function*(){let o=0;for await(let F0 of this){var z0;if(k!==null&&k!==void 0&&(z0=k.signal)!==null&&z0!==void 0&&z0.aborted)throw new K({cause:k.signal.reason});yield[o++,F0]}}.call(this)}async function X0(k,f=void 0){for await(let o of Y.call(this,k,f))return!0;return!1}async function Y0(k,f=void 0){if(typeof k!=="function")throw new I("fn",["Function","AsyncFunction"],k);return!await X0.call(this,async(...o)=>{return!await k(...o)},f)}async function S(k,f){for await(let o of Y.call(this,k,f))return o;return}async function Z0(k,f){if(typeof k!=="function")throw new I("fn",["Function","AsyncFunction"],k);async function o(z0,F0){return await k(z0,F0),V}for await(let z0 of b.call(this,o,f));}function Y(k,f){if(typeof k!=="function")throw new I("fn",["Function","AsyncFunction"],k);async function o(z0,F0){if(await k(z0,F0))return z0;return V}return b.call(this,o,f)}class c extends X{constructor(){super("reduce");this.message="Reduce of an empty stream requires an initial value"}}async function h0(k,f,o){var z0;if(typeof k!=="function")throw new I("reducer",["Function","AsyncFunction"],k);if(o!=null)G(o,"options");if((o===null||o===void 0?void 0:o.signal)!=null)q(o.signal,"options.signal");let F0=arguments.length>1;if(o!==null&&o!==void 0&&(z0=o.signal)!==null&&z0!==void 0&&z0.aborted){let m=new K(void 0,{cause:o.signal.reason});throw this.once("error",()=>{}),await x(this.destroy(m)),m}let H=new B,E=H.signal;if(o!==null&&o!==void 0&&o.signal){let m={once:!0,[C]:this,[O]:!0};o.signal.addEventListener("abort",()=>H.abort(),m)}let T=!1;try{for await(let m of this){var p;if(T=!0,o!==null&&o!==void 0&&(p=o.signal)!==null&&p!==void 0&&p.aborted)throw new K;if(!F0)f=m,F0=!0;else f=await k(f,m,{signal:E})}if(!T&&!F0)throw new c}finally{H.abort()}return f}async function R(k){if(k!=null)G(k,"options");if((k===null||k===void 0?void 0:k.signal)!=null)q(k.signal,"options.signal");let f=[];for await(let z0 of this){var o;if(k!==null&&k!==void 0&&(o=k.signal)!==null&&o!==void 0&&o.aborted)throw new K(void 0,{cause:k.signal.reason});N(f,z0)}return f}function I0(k,f){let o=b.call(this,k,f);return async function*(){for await(let F0 of o)yield*F0}.call(this)}function J0(k){if(k=s(k),B0(k))return 0;if(k<0)throw new Z("number",">= 0",k);return k}function q0(k,f=void 0){if(f!=null)G(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)q(f.signal,"options.signal");return k=J0(k),async function*(){var z0;if(f!==null&&f!==void 0&&(z0=f.signal)!==null&&z0!==void 0&&z0.aborted)throw new K;for await(let H of this){var F0;if(f!==null&&f!==void 0&&(F0=f.signal)!==null&&F0!==void 0&&F0.aborted)throw new K;if(k--<=0)yield H}}.call(this)}function K0(k,f=void 0){if(f!=null)G(f,"options");if((f===null||f===void 0?void 0:f.signal)!=null)q(f.signal,"options.signal");return k=J0(k),async function*(){var z0;if(f!==null&&f!==void 0&&(z0=f.signal)!==null&&z0!==void 0&&z0.aborted)throw new K;for await(let H of this){var F0;if(f!==null&&f!==void 0&&(F0=f.signal)!==null&&F0!==void 0&&F0.aborted)throw new K;if(k-- >0)yield H;if(k<=0)return}}.call(this)}h.exports.streamReturningOperators={asIndexedPairs:F(e,"readable.asIndexedPairs will be removed in a future version."),drop:q0,filter:Y,flatMap:I0,map:b,take:K0,compose:W},h.exports.promiseReturningOperators={every:Y0,forEach:Z0,reduce:h0,toArray:R,some:X0,find:S}}),m1=G0((w,h)=>{var{ArrayPrototypePop:B,Promise:U}=N0(),{isIterable:I,isNodeStream:X,isWebStream:Z}=b0(),{pipelineImpl:K}=p2(),{finished:q}=d0();n1();function z(...G){return new U((C,O)=>{let x,l,a=G[G.length-1];if(a&&typeof a==="object"&&!X(a)&&!I(a)&&!Z(a)){let u=B(G);x=u.signal,l=u.end}K(G,(u,j)=>{if(u)O(u);else C(j)},{signal:x,end:l})})}h.exports={finished:q,pipeline:z}}),n1=G0((w,h)=>{var{Buffer:B}=(v0(),_0(u0)),{ObjectDefineProperty:U,ObjectKeys:I,ReflectApply:X}=N0(),{promisify:{custom:Z}}=D0(),{streamReturningOperators:K,promiseReturningOperators:q}=E8(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:z}}=L0(),G=l1(),{setDefaultHighWaterMark:C,getDefaultHighWaterMark:O}=j2(),{pipeline:x}=p2(),{destroyer:l}=I2(),a=d0(),u=m1(),j=b0(),F=h.exports=b2().Stream;F.isDestroyed=j.isDestroyed,F.isDisturbed=j.isDisturbed,F.isErrored=j.isErrored,F.isReadable=j.isReadable,F.isWritable=j.isWritable,F.Readable=A2();for(let A of I(K)){let P=function(...B0){if(new.target)throw z();return F.Readable.from(X(s,this,B0))},s=K[A];U(P,"name",{__proto__:null,value:s.name}),U(P,"length",{__proto__:null,value:s.length}),U(F.Readable.prototype,A,{__proto__:null,value:P,enumerable:!1,configurable:!0,writable:!0})}for(let A of I(q)){let P=function(...B0){if(new.target)throw z();return X(s,this,B0)},s=q[A];U(P,"name",{__proto__:null,value:s.name}),U(P,"length",{__proto__:null,value:s.length}),U(F.Readable.prototype,A,{__proto__:null,value:P,enumerable:!1,configurable:!0,writable:!0})}F.Writable=i2(),F.Duplex=g0(),F.Transform=p1(),F.PassThrough=d1(),F.pipeline=x;var{addAbortSignal:N}=V2();F.addAbortSignal=N,F.finished=a,F.destroy=l,F.compose=G,F.setDefaultHighWaterMark=C,F.getDefaultHighWaterMark=O,U(F,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return u}}),U(x,Z,{__proto__:null,enumerable:!0,get(){return u.pipeline}}),U(a,Z,{__proto__:null,enumerable:!0,get(){return u.finished}}),F.Stream=F,F._isUint8Array=function(P){return P instanceof Uint8Array},F._uint8ArrayToBuffer=function(P){return B.from(P.buffer,P.byteOffset,P.byteLength)}}),W8=G0((w,h)=>{var B=d2();{let U=n1(),I=m1(),X=U.Readable.destroy;h.exports=U.Readable,h.exports._uint8ArrayToBuffer=U._uint8ArrayToBuffer,h.exports._isUint8Array=U._isUint8Array,h.exports.isDisturbed=U.isDisturbed,h.exports.isErrored=U.isErrored,h.exports.isReadable=U.isReadable,h.exports.Readable=U.Readable,h.exports.Writable=U.Writable,h.exports.Duplex=U.Duplex,h.exports.Transform=U.Transform,h.exports.PassThrough=U.PassThrough,h.exports.addAbortSignal=U.addAbortSignal,h.exports.finished=U.finished,h.exports.destroy=U.destroy,h.exports.destroy=X,h.exports.pipeline=U.pipeline,h.exports.compose=U.compose,Object.defineProperty(U,"promises",{configurable:!0,enumerable:!0,get(){return I}}),h.exports.Stream=U.Stream}h.exports.default=h.exports});o1.exports=W8()});import{createOpenAI as V8}from"@ai-sdk/openai";import{EventType as j8,logger as w0,ModelType as $0,VECTOR_DIMS as r1}from"@elizaos/core";import{generateObject as A8,generateText as a1,JSONParseError as I6}from"ai";import{encodingForModel as X6}from"js-tiktoken";function W0(w,h,B){return w.getSetting(h)??process.env[h]??B}function Z2(){return typeof globalThis<"u"&&typeof globalThis.document<"u"}function M8(w){return Z2()&&!!W0(w,"OPENAI_BROWSER_BASE_URL")}function X2(w,h=!1){if(Z2())return{};let B=h?O8(w):C2(w);return B?{Authorization:`Bearer ${B}`}:{}}function l0(w){let h=W0(w,"OPENAI_BROWSER_BASE_URL"),B=Z2()&&h?h:W0(w,"OPENAI_BASE_URL","https://api.openai.com/v1");return w0.debug(`[OpenAI] Default base URL: ${B}`),B}function L8(w){let h=Z2()?W0(w,"OPENAI_BROWSER_EMBEDDING_URL")||W0(w,"OPENAI_BROWSER_BASE_URL"):W0(w,"OPENAI_EMBEDDING_URL");if(h)return w0.debug(`[OpenAI] Using specific embedding base URL: ${h}`),h;return w0.debug("[OpenAI] Falling back to general base URL for embeddings."),l0(w)}function C2(w){return W0(w,"OPENAI_API_KEY")}function O8(w){let h=W0(w,"OPENAI_EMBEDDING_API_KEY");if(h)return w0.debug("[OpenAI] Using specific embedding API key (present)"),h;return w0.debug("[OpenAI] Falling back to general API key for embeddings."),C2(w)}function s1(w){return W0(w,"OPENAI_SMALL_MODEL")??W0(w,"SMALL_MODEL","gpt-5-nano")}function t1(w){return W0(w,"OPENAI_LARGE_MODEL")??W0(w,"LARGE_MODEL","gpt-5-mini")}function x8(w){return W0(w,"OPENAI_IMAGE_DESCRIPTION_MODEL","gpt-5-nano")??"gpt-5-nano"}function e1(w){let h=W0(w,"OPENAI_EXPERIMENTAL_TELEMETRY","false"),B=String(h).toLowerCase(),U=B==="true";return w0.debug(`[OpenAI] Experimental telemetry in function: "${h}" (type: ${typeof h}, normalized: "${B}", result: ${U})`),U}function l2(w){let h=l0(w),B=C2(w)??(M8(w)?"sk-proxy":void 0);return V8({apiKey:B??"",baseURL:h})}async function D8(w,h){let B=w===$0.TEXT_SMALL?process.env.OPENAI_SMALL_MODEL??process.env.SMALL_MODEL??"gpt-5-nano":process.env.LARGE_MODEL??"gpt-5-mini";return X6(B).encode(h)}async function T8(w,h){let B=w===$0.TEXT_SMALL?process.env.OPENAI_SMALL_MODEL??process.env.SMALL_MODEL??"gpt-5-nano":process.env.OPENAI_LARGE_MODEL??process.env.LARGE_MODEL??"gpt-5-mini";return X6(B).decode(h)}async function h6(w,h,B,U){let I=l2(w),X=U(w);w0.log(`[OpenAI] Using ${B} model: ${X}`);let Z=h.temperature??0;if(!!h.schema)w0.info(`Using ${B} without schema validation (schema provided but output=no-schema)`);try{let{object:q,usage:z}=await A8({model:I.languageModel(X),output:"no-schema",prompt:h.prompt,temperature:Z,experimental_repairText:B6()});if(z)G2(w,B,h.prompt,z);return q}catch(q){if(q instanceof I6){w0.error(`[generateObject] Failed to parse JSON: ${q.message}`);let G=await B6()({text:q.text,error:q});if(G)try{let C=JSON.parse(G);return w0.info("[generateObject] Successfully repaired JSON."),C}catch(C){let O=C instanceof Error?C.message:String(C);throw w0.error(`[generateObject] Failed to parse repaired JSON: ${O}`),C}else throw w0.error("[generateObject] JSON repair failed."),q}else{let z=q instanceof Error?q.message:String(q);throw w0.error(`[generateObject] Unknown error: ${z}`),q}}}function B6(){return async({text:w,error:h})=>{try{if(h instanceof I6){let B=w.replace(/```json\n|\n```|```/g,"");return JSON.parse(B),B}return null}catch(B){let U=B instanceof Error?B.message:String(B);return w0.warn(`Failed to repair JSON text: ${U}`),null}}}function G2(w,h,B,U){w.emitEvent(j8.MODEL_USED,{provider:"openai",type:h,prompt:B,tokens:{prompt:U.inputTokens,completion:U.outputTokens,total:U.totalTokens}})}function w6(w){if(w.length<12)return"application/octet-stream";if(w[0]===82&&w[1]===73&&w[2]===70&&w[3]===70&&w[8]===87&&w[9]===65&&w[10]===86&&w[11]===69)return"audio/wav";if(w[0]===73&&w[1]===68&&w[2]===51||w[0]===255&&(w[1]&224)===224)return"audio/mpeg";if(w[0]===79&&w[1]===103&&w[2]===103&&w[3]===83)return"audio/ogg";if(w[0]===102&&w[1]===76&&w[2]===97&&w[3]===67)return"audio/flac";if(w[4]===102&&w[5]===116&&w[6]===121&&w[7]===112)return"audio/mp4";if(w[0]===26&&w[1]===69&&w[2]===223&&w[3]===163)return"audio/webm";return w0.warn("Could not detect audio format from buffer, using generic binary type"),"application/octet-stream"}async function P8(w){try{let{Readable:h}=await Promise.resolve().then(() => C6(d2(),1)),B=w.getReader();return new h({async read(){try{let{done:U,value:I}=await B.read();if(U)this.push(null);else this.push(I)}catch(U){this.destroy(U)}},destroy(U,I){B.cancel().finally(()=>I(U))}})}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Failed to load node:stream module: ${B}`),Error("Cannot convert stream: node:stream module unavailable. This feature requires a Node.js environment.")}}async function U6(w,h){let B=W0(w,"OPENAI_TTS_MODEL","gpt-4o-mini-tts"),U=W0(w,"OPENAI_TTS_VOICE","nova"),I=W0(w,"OPENAI_TTS_INSTRUCTIONS",""),X=l0(w),Z=h.model||B,K=h.voice||U,q=h.instructions??I,z=h.format||"mp3";try{let G=await fetch(`${X}/audio/speech`,{method:"POST",headers:{...X2(w),"Content-Type":"application/json",...z==="mp3"?{Accept:"audio/mpeg"}:{}},body:JSON.stringify({model:Z,voice:K,input:h.text,format:z,...q&&{instructions:q}})});if(!G.ok){let C=await G.text();throw Error(`OpenAI TTS error ${G.status}: ${C}`)}if(!G.body)throw Error("OpenAI TTS response body is null");if(!Z2())return await P8(G.body);return G.body}catch(G){let C=G instanceof Error?G.message:String(G);throw Error(`Failed to fetch speech from OpenAI TTS: ${C}`)}}var _8={name:"openai",description:"OpenAI plugin",config:{OPENAI_API_KEY:process.env.OPENAI_API_KEY,OPENAI_BASE_URL:process.env.OPENAI_BASE_URL,OPENAI_SMALL_MODEL:process.env.OPENAI_SMALL_MODEL,OPENAI_LARGE_MODEL:process.env.OPENAI_LARGE_MODEL,SMALL_MODEL:process.env.SMALL_MODEL,LARGE_MODEL:process.env.LARGE_MODEL,OPENAI_EMBEDDING_MODEL:process.env.OPENAI_EMBEDDING_MODEL,OPENAI_EMBEDDING_API_KEY:process.env.OPENAI_EMBEDDING_API_KEY,OPENAI_EMBEDDING_URL:process.env.OPENAI_EMBEDDING_URL,OPENAI_EMBEDDING_DIMENSIONS:process.env.OPENAI_EMBEDDING_DIMENSIONS,OPENAI_IMAGE_DESCRIPTION_MODEL:process.env.OPENAI_IMAGE_DESCRIPTION_MODEL,OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS:process.env.OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS,OPENAI_EXPERIMENTAL_TELEMETRY:process.env.OPENAI_EXPERIMENTAL_TELEMETRY},async init(w,h){new Promise(async(B)=>{B();try{if(!C2(h)&&!Z2()){w0.warn("OPENAI_API_KEY is not set in environment - OpenAI functionality will be limited");return}try{let U=l0(h),I=await fetch(`${U}/models`,{headers:{...X2(h)}});if(!I.ok)w0.warn(`OpenAI API key validation failed: ${I.statusText}`),w0.warn("OpenAI functionality will be limited until a valid API key is provided");else w0.log("OpenAI API key validated successfully")}catch(U){let I=U instanceof Error?U.message:String(U);w0.warn(`Error validating OpenAI API key: ${I}`),w0.warn("OpenAI functionality will be limited until a valid API key is provided")}}catch(U){let I=U?.errors?.map((X)=>X.message).join(", ")||(U instanceof Error?U.message:String(U));w0.warn(`OpenAI plugin configuration issue: ${I} - You need to configure the OPENAI_API_KEY in your environment variables`)}})},models:{[$0.TEXT_EMBEDDING]:async(w,h)=>{let B=W0(w,"OPENAI_EMBEDDING_MODEL","text-embedding-3-small"),U=Number.parseInt(W0(w,"OPENAI_EMBEDDING_DIMENSIONS","1536")||"1536",10);if(!Object.values(r1).includes(U)){let Z=`Invalid embedding dimension: ${U}. Must be one of: ${Object.values(r1).join(", ")}`;throw w0.error(Z),Error(Z)}if(h===null){w0.debug("Creating test embedding for initialization");let Z=Array(U).fill(0);return Z[0]=0.1,Z}let I;if(typeof h==="string")I=h;else if(typeof h==="object"&&h.text)I=h.text;else{w0.warn("Invalid input format for embedding");let Z=Array(U).fill(0);return Z[0]=0.2,Z}if(!I.trim()){w0.warn("Empty text for embedding");let Z=Array(U).fill(0);return Z[0]=0.3,Z}let X=L8(w);try{let Z=await fetch(`${X}/embeddings`,{method:"POST",headers:{...X2(w,!0),"Content-Type":"application/json"},body:JSON.stringify({model:B,input:I})});if(!Z.ok){w0.error(`OpenAI API error: ${Z.status} - ${Z.statusText}`);let z=Array(U).fill(0);return z[0]=0.4,z}let K=await Z.json();if(!K?.data?.[0]?.embedding){w0.error("API returned invalid structure");let z=Array(U).fill(0);return z[0]=0.5,z}let q=K.data[0].embedding;if(K.usage){let z={inputTokens:K.usage.prompt_tokens,outputTokens:0,totalTokens:K.usage.total_tokens};G2(w,$0.TEXT_EMBEDDING,I,z)}return w0.log(`Got valid embedding with length ${q.length}`),q}catch(Z){let K=Z instanceof Error?Z.message:String(Z);w0.error(`Error generating embedding: ${K}`);let q=Array(U).fill(0);return q[0]=0.6,q}},[$0.TEXT_TOKENIZER_ENCODE]:async(w,{prompt:h,modelType:B=$0.TEXT_LARGE})=>{return await D8(B??$0.TEXT_LARGE,h)},[$0.TEXT_TOKENIZER_DECODE]:async(w,{tokens:h,modelType:B=$0.TEXT_LARGE})=>{return await T8(B??$0.TEXT_LARGE,h)},[$0.TEXT_SMALL]:async(w,{prompt:h,stopSequences:B=[],maxTokens:U=8192,temperature:I=0.7,frequencyPenalty:X=0.7,presencePenalty:Z=0.7})=>{let K=l2(w),q=s1(w),z=e1(w);w0.log(`[OpenAI] Using TEXT_SMALL model: ${q}`),w0.log(h);let{text:G,usage:C}=await a1({model:K.languageModel(q),prompt:h,system:w.character.system??void 0,temperature:I,maxOutputTokens:U,frequencyPenalty:X,presencePenalty:Z,stopSequences:B,experimental_telemetry:{isEnabled:z}});if(C)G2(w,$0.TEXT_SMALL,h,C);return G},[$0.TEXT_LARGE]:async(w,{prompt:h,stopSequences:B=[],maxTokens:U=8192,temperature:I=0.7,frequencyPenalty:X=0.7,presencePenalty:Z=0.7})=>{let K=l2(w),q=t1(w),z=e1(w);w0.log(`[OpenAI] Using TEXT_LARGE model: ${q}`),w0.log(h);let{text:G,usage:C}=await a1({model:K.languageModel(q),prompt:h,system:w.character.system??void 0,temperature:I,maxOutputTokens:U,frequencyPenalty:X,presencePenalty:Z,stopSequences:B,experimental_telemetry:{isEnabled:z}});if(C)G2(w,$0.TEXT_LARGE,h,C);return G},[$0.IMAGE]:async(w,h)=>{let B=h.n||1,U=h.size||"1024x1024",I=h.prompt,X="gpt-image-1";w0.log("[OpenAI] Using IMAGE model: gpt-image-1");let Z=l0(w);try{let K=await fetch(`${Z}/images/generations`,{method:"POST",headers:{...X2(w),"Content-Type":"application/json"},body:JSON.stringify({model:"gpt-image-1",prompt:I,n:B,size:U})});if(!K.ok)throw Error(`Failed to generate image: ${K.statusText}`);return(await K.json()).data}catch(K){let q=K instanceof Error?K.message:String(K);throw K}},[$0.IMAGE_DESCRIPTION]:async(w,h)=>{let B,U,I=x8(w);w0.log(`[OpenAI] Using IMAGE_DESCRIPTION model: ${I}`);let X=Number.parseInt(W0(w,"OPENAI_IMAGE_DESCRIPTION_MAX_TOKENS","8192")||"8192",10);if(typeof h==="string")B=h,U="Please analyze this image and provide a title and detailed description.";else B=h.imageUrl,U=h.prompt||"Please analyze this image and provide a title and detailed description.";let Z=[{role:"user",content:[{type:"text",text:U},{type:"image_url",image_url:{url:B}}]}],K=l0(w);try{let q={model:I,messages:Z,max_tokens:X},z=await fetch(`${K}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",...X2(w)},body:JSON.stringify(q)});if(!z.ok)throw Error(`OpenAI API error: ${z.status}`);let C=await z.json(),O=C.choices?.[0]?.message?.content;if(C.usage)G2(w,$0.IMAGE_DESCRIPTION,typeof h==="string"?h:h.prompt||"",{inputTokens:C.usage.prompt_tokens,outputTokens:C.usage.completion_tokens,totalTokens:C.usage.total_tokens});if(!O)return{title:"Failed to analyze image",description:"No response from API"};if(typeof h==="object"&&h.prompt&&h.prompt!=="Please analyze this image and provide a title and detailed description.")return O;let a=O.match(/title[:\s]+(.+?)(?:\n|$)/i)?.[1]?.trim()||"Image Analysis",u=O.replace(/title[:\s]+(.+?)(?:\n|$)/i,"").trim();return{title:a,description:u}}catch(q){let z=q instanceof Error?q.message:String(q);return w0.error(`Error analyzing image: ${z}`),{title:"Failed to analyze image",description:`Error: ${z}`}}},[$0.TRANSCRIPTION]:async(w,h)=>{let B=W0(w,"OPENAI_TRANSCRIPTION_MODEL","gpt-4o-mini-transcribe");w0.log(`[OpenAI] Using TRANSCRIPTION model: ${B}`);let U=l0(w),I,X=null;if(h instanceof Blob||h instanceof File)I=h;else if(Buffer.isBuffer(h)){let z=w6(h);w0.debug(`Auto-detected audio MIME type: ${z}`),I=new Blob([h],{type:z})}else if(typeof h==="object"&&h!==null&&h.audio!=null){let z=h;if(!(z.audio instanceof Blob)&&!(z.audio instanceof File)&&!Buffer.isBuffer(z.audio))throw Error("TRANSCRIPTION param 'audio' must be a Blob/File/Buffer.");if(Buffer.isBuffer(z.audio)){let G=z.mimeType;if(!G)G=w6(z.audio),w0.debug(`Auto-detected audio MIME type: ${G}`);else w0.debug(`Using provided MIME type: ${G}`);I=new Blob([z.audio],{type:G})}else I=z.audio;if(X=z,typeof z.model==="string"&&z.model)B=z.model}else throw Error("TRANSCRIPTION expects a Blob/File/Buffer or an object { audio: Blob/File/Buffer, mimeType?, language?, response_format?, timestampGranularities?, prompt?, temperature?, model? }");let Z=I.type||"audio/webm",K=I.name||(Z.includes("mp3")||Z.includes("mpeg")?"recording.mp3":Z.includes("ogg")?"recording.ogg":Z.includes("wav")?"recording.wav":Z.includes("webm")?"recording.webm":"recording.bin"),q=new FormData;if(q.append("file",I,K),q.append("model",String(B)),X){if(typeof X.language==="string")q.append("language",String(X.language));if(typeof X.response_format==="string")q.append("response_format",String(X.response_format));if(typeof X.prompt==="string")q.append("prompt",String(X.prompt));if(typeof X.temperature==="number")q.append("temperature",String(X.temperature));if(Array.isArray(X.timestampGranularities))for(let z of X.timestampGranularities)q.append("timestamp_granularities[]",String(z))}try{let z=await fetch(`${U}/audio/transcriptions`,{method:"POST",headers:{...X2(w)},body:q});if(!z.ok)throw Error(`Failed to transcribe audio: ${z.status} ${z.statusText}`);return(await z.json()).text||""}catch(z){let G=z instanceof Error?z.message:String(z);throw w0.error(`TRANSCRIPTION error: ${G}`),z}},[$0.TEXT_TO_SPEECH]:async(w,h)=>{let B=typeof h==="string"?{text:h}:h,U=B.model||W0(w,"OPENAI_TTS_MODEL","gpt-4o-mini-tts");w0.log(`[OpenAI] Using TEXT_TO_SPEECH model: ${U}`);try{return await U6(w,B)}catch(I){let X=I instanceof Error?I.message:String(I);throw w0.error(`Error in TEXT_TO_SPEECH: ${X}`),I}},[$0.OBJECT_SMALL]:async(w,h)=>{return h6(w,h,$0.OBJECT_SMALL,s1)},[$0.OBJECT_LARGE]:async(w,h)=>{return h6(w,h,$0.OBJECT_LARGE,t1)}},tests:[{name:"openai_plugin_tests",tests:[{name:"openai_test_url_and_api_key_validation",fn:async(w)=>{let h=l0(w),B=await fetch(`${h}/models`,{headers:{Authorization:`Bearer ${C2(w)}`}}),U=await B.json();if(w0.log({data:U?.data?.length??"N/A"},"Models Available"),!B.ok)throw Error(`Failed to validate OpenAI API key: ${B.statusText}`)}},{name:"openai_test_text_embedding",fn:async(w)=>{try{let h=await w.useModel($0.TEXT_EMBEDDING,{text:"Hello, world!"});w0.log({embedding:h},"embedding")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in test_text_embedding: ${B}`),h}}},{name:"openai_test_text_large",fn:async(w)=>{try{let h=await w.useModel($0.TEXT_LARGE,{prompt:"What is the nature of reality in 10 words?"});if(h.length===0)throw Error("Failed to generate text");w0.log({text:h},"generated with test_text_large")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in test_text_large: ${B}`),h}}},{name:"openai_test_text_small",fn:async(w)=>{try{let h=await w.useModel($0.TEXT_SMALL,{prompt:"What is the nature of reality in 10 words?"});if(h.length===0)throw Error("Failed to generate text");w0.log({text:h},"generated with test_text_small")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in test_text_small: ${B}`),h}}},{name:"openai_test_image_generation",fn:async(w)=>{w0.log("openai_test_image_generation");try{let h=await w.useModel($0.IMAGE,{prompt:"A beautiful sunset over a calm ocean",n:1,size:"1024x1024"});w0.log({image:h},"generated with test_image_generation")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in test_image_generation: ${B}`),h}}},{name:"image-description",fn:async(w)=>{try{w0.log("openai_test_image_description");try{let h=await w.useModel($0.IMAGE_DESCRIPTION,"https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg");if(h&&typeof h==="object"&&"title"in h&&"description"in h)w0.log({result:h},"Image description");else w0.error("Invalid image description result format:",h)}catch(h){let B=h instanceof Error?h.message:String(h);w0.error(`Error in image description test: ${B}`)}}catch(h){let B=h instanceof Error?h.message:String(h);w0.error(`Error in openai_test_image_description: ${B}`)}}},{name:"openai_test_transcription",fn:async(w)=>{w0.log("openai_test_transcription");try{let B=await(await fetch("https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg")).arrayBuffer(),U=await w.useModel($0.TRANSCRIPTION,Buffer.from(new Uint8Array(B)));w0.log({transcription:U},"generated with test_transcription")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in test_transcription: ${B}`),h}}},{name:"openai_test_text_tokenizer_encode",fn:async(w)=>{let B=await w.useModel($0.TEXT_TOKENIZER_ENCODE,{prompt:"Hello tokenizer encode!"});if(!Array.isArray(B)||B.length===0)throw Error("Failed to tokenize text: expected non-empty array of tokens");w0.log({tokens:B},"Tokenized output")}},{name:"openai_test_text_tokenizer_decode",fn:async(w)=>{let B=await w.useModel($0.TEXT_TOKENIZER_ENCODE,{prompt:"Hello tokenizer decode!"}),U=await w.useModel($0.TEXT_TOKENIZER_DECODE,{tokens:B});if(U!=="Hello tokenizer decode!")throw Error(`Decoded text does not match original. Expected "Hello tokenizer decode!", got "${U}"`);w0.log({decodedText:U},"Decoded text")}},{name:"openai_test_text_to_speech",fn:async(w)=>{try{if(!await U6(w,{text:"Hello, this is a test for text-to-speech."}))throw Error("Failed to generate speech");w0.log("Generated speech successfully")}catch(h){let B=h instanceof Error?h.message:String(h);throw w0.error(`Error in openai_test_text_to_speech: ${B}`),h}}}]}]},R8=_8;export{_8 as openaiPlugin,R8 as default};
2
3
 
3
- //# debugId=89F51A79E528892264756E2164756E21
4
+ //# debugId=A43263BB5D6D3EA464756E2164756E21