"use strict";exports.id=8262,exports.ids=[8262],exports.modules={48262:(a,b,c)=>{c.r(b),c.d(b,{resolveBraveKey:()=>g,searchBrave:()=>f});var d=c(70333),e=c(580);async function f(a){let b=await g();if(!b)throw Error("Brave API key not found. Connect Brave Search MCP in Settings or add the key in Settings -> Images.");let c=new URL("https://api.search.brave.com/res/v1/images/search");c.searchParams.set("q",a.query),c.searchParams.set("count",String(Math.min(a.count,50))),c.searchParams.set("safesearch","strict");let d=await fetch(c,{headers:{Accept:"application/json","X-Subscription-Token":b}});if(!d.ok){let a=await d.text().catch(()=>"");throw Error(`Brave image search ${d.status}: ${a.slice(0,200)}`)}let e=await d.json(),f=[];for(let a of e.results??[]){let b=a.properties?.url,c=a.thumbnail?.src;if(!b||!c)continue;let d=a.url??"",e=a.source||a.meta_url?.hostname||function(a){try{return new URL(a).hostname}catch{return null}}(d)||"Brave";f.push({url:b,thumb:c,attribution:{name:e,link:d||b},provider:"brave"})}return f}async function g(){let a=await (0,d.CG)("brave");if(a)return a;let b=await h();if(b)return b;let c=process.env.BRAVE_API_KEY;return c&&c.length>0?c:null}async function h(){let a=await (0,e.getMcpServer)("brave-search"),b=a?[a]:[];if(!a){let{listMcpServers:a}=await Promise.resolve().then(c.bind(c,580));for(let c of(await a()))"stdio"===c.config.transport&&c.config.env&&"string"==typeof c.config.env.BRAVE_API_KEY&&c.config.env.BRAVE_API_KEY.length>0&&b.push(c)}for(let a of b){if("stdio"!==a.config.transport)continue;let b=a.config.env?.BRAVE_API_KEY;if("string"==typeof b&&b.length>0)return b}return null}}};