import{g as y}from"./gQJcRhou.js";import"./BCwT4WOg.js";const b={"https://api.anthropic.com/":"anthropic","https://api.mistral.ai/":"mistral","https://api.openai.com/":"openai","https://generativelanguage.googleapis.com/":"google-ai"};let p=!1;function O(){if(p||typeof globalThis>"u")return;p=!0;const r=globalThis.fetch.bind(globalThis);globalThis.fetch=async(e,o)=>{const i=typeof e=="string"?e:e instanceof URL?e.href:e.url,n=Object.entries(b).find(([t])=>i.startsWith(t))?.[1];if(!n)return r(e,o);const c={},a=o?.headers??(e instanceof Request?e.headers:{}),d=a instanceof Headers?a:Object.entries(a);for(const[t,g]of d){const f=t.toLowerCase();f!=="x-api-key"&&f!=="authorization"&&(c[t]=g)}let s;try{s=JSON.parse(o?.body??(e instanceof Request?await e.text():"{}"))}catch{s={}}const l=y(),h={"Content-Type":"application/json"};return l&&(h.Authorization=`Bearer ${l}`),r("/api/neurolink-proxy",{body:JSON.stringify({body:s,headers:c,provider:n,url:i}),headers:h,method:"POST"})}}export{O as i};
