"use strict";exports.id=9609,exports.ids=[9609],exports.modules={39609:(a,b,c)=>{c.d(b,{proxyAwareFetch:()=>o});var d=c(27910);let e=globalThis.fetch,f=new Map,g=["cloudcode-pa.googleapis.com","daily-cloudcode-pa.googleapis.com","api.individual.githubcopilot.com","q.us-east-1.amazonaws.com","codewhisperer.us-east-1.amazonaws.com","api2.cursor.sh"],h=["8.8.8.8","8.8.4.4"];function i(a){return null==a?"":String(a).trim()}async function j(a){let b=f.get(a);if(b&&Date.now()<b.expiry)return b.ip;try{let b=await Promise.resolve().then(c.t.bind(c,14985,23)),{promisify:d}=await Promise.resolve().then(c.t.bind(c,28354,23)),e=new b.Resolver;e.setServers(h);let g=d(e.resolve4.bind(e)),i=await g(a);return f.set(a,{ip:i[0],expiry:Date.now()+3e5}),i[0]}catch(b){return console.warn(`[ProxyFetch] DNS resolve failed for ${a}:`,b.message),null}}function k(a,b){let c,d=i(b);if(!d)return!1;try{c=new URL(a).hostname.toLowerCase()}catch{return!1}return d.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean).some(a=>"*"===a||(a.startsWith(".")?c.endsWith(a)||c===a.slice(1):c===a||c.endsWith(`.${a}`)))}function l(a){let b=i(a);if(!b)return null;try{return new URL(b),b}catch{return`http://${b}`}}async function m(a){let b=l(a);if(!b)return null;let{ProxyAgent:d}=await c.e(7774).then(c.t.bind(c,47774,19));return new d({uri:b,connections:1,pipelining:0})}async function n(a,b,e){let f=await Promise.resolve().then(c.t.bind(c,55591,23)),g=await Promise.resolve().then(c.t.bind(c,91645,23)),h=f.default??f,i=g.default??g;return new Promise((c,f)=>{let g=new i.Socket;g.connect(443,b,()=>{let b={socket:g,servername:a.hostname,path:a.pathname+a.search,method:e.method||"POST",headers:{...e.headers,Host:a.hostname}},i=h.request(b,a=>{let b={ok:a.statusCode>=200&&a.statusCode<300,status:a.statusCode,statusText:a.statusMessage,headers:new Map(Object.entries(a.headers)),body:d.Readable.toWeb(a),text:async()=>{let b=[];for await(let c of a)b.push(c);return Buffer.concat(b).toString()},json:async()=>JSON.parse(await b.text())};c(b)});i.on("error",f),e.body&&i.write("string"==typeof e.body?e.body:JSON.stringify(e.body)),i.end()}),g.on("error",f)})}async function o(a,b={},c=null){let d="string"==typeof a?a:a.toString(),f=i(c?.vercelRelayUrl);if(f){let a=new URL(d),c={...b.headers,"x-relay-target":`${a.protocol}//${a.host}`,"x-relay-path":`${a.pathname}${a.search}`};return e(f,{...b,headers:c})}let h=function(a,b){if(b?.enabled!==!0&&b?.connectionProxyEnabled!==!0)return null;let c=i(b?.url??b?.connectionProxyUrl);if(!c)return null;let d=i(b?.noProxy??b?.connectionNoProxy);return d&&k(a,d)?null:l(c)}(d,c),p=h?null:l(function(a){let b;if(k(a,process.env.NO_PROXY||process.env.no_proxy))return null;try{b=new URL(a).protocol}catch{return null}return"https:"===b?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy}(d)),q=h||p;if(function(a){try{let b=new URL(a).hostname;return g.some(a=>b.includes(a))}catch{return!1}}(d)){if(q){let d=await m(q);try{return await e(a,{...b,dispatcher:d,headers:{...b.headers,connection:"close"}})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct bypass: ${a.message}`)}}try{let a=new URL(d),c=await j(a.hostname);if(c)return await n(a,c,b)}catch(a){console.warn(`[ProxyFetch] MITM bypass failed: ${a.message}`)}}if(q){let d=await m(q);try{return await e(a,{...b,dispatcher:d,headers:{...b.headers,connection:"close"}})}catch(a){if(c?.strictProxy===!0)throw Error(`[ProxyFetch] Proxy required but failed (strictProxy=true): ${a.message}`);console.warn(`[ProxyFetch] Proxy failed, falling back to direct: ${a.message}`)}}return e(a,b)}async function p(a,b={}){return o(a,b,null)}globalThis.fetch!==p&&(globalThis.fetch=p)}};