import{_ as i,da as s}from"./main-tangy-colts-beg.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,o){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,o),o)}};const d=e=>({addConnectionHelpingText:i('You can find credentials from <a target="_blank" class="text-blue-600 underline" rel="noopener noreferrer nofollow" href="https://console.anthropic.com/settings/keys">Here</a>'),componentName:e.componentName.connection,connectionsTypes:[{encryptKeys:["value"],label:i("API Key"),showKey:!1,type:"api_key",verifyConnection:{headers:{"anthropic-version":"2023-06-01","x-api-key":""},method:"GET",responseKeyMatch:["data"],url:"https://api.anthropic.com/v1/models"}}],fieldType:"config",id:"connection-id",label:i("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0}),p=({$:e,e:o})=>{e.setThisComponent(n=>{e.util.isConnectionComponent(n)&&n.connectionsTypes.forEach(a=>{var t;a.type==="api_key"&&((t=a.verifyConnection)!=null&&t.headers)&&(a.verifyConnection.headers["x-api-key"]=o.value)})})},C=e=>({$:o,e:n})=>{o.setThisComponent(a=>{a.value=n}),o.setDb(a=>{a[e]=n})};globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,o){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,o),o)}};const l="https://api.anthropic.com/v1/",h=e=>s({headers:{"anthropic-version":"2023-06-01","x-api-key":{encryption:"hmac_decrypt",value:e}},method:"GET",url:`${l}models`});globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,o){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,o),o)}};const u=async e=>{e.setComponent("model",t=>{t.loading=!0});const o=await e.getConnection();if(!o){e.setComponent("model",t=>{t.loading=!1});return}const{data:n,status:a}=await h(o.auth_details.value);if(a!=="success"){e.setComponent("model",t=>{e.util.isSelectComponent(t)&&(t.loading=!1,t.status=a,t.invalidMessage=n)}),console.error("Failed to fetch list");return}e.setComponent("model",t=>{e.util.isSelectComponent(t)&&(t.options=n==null?void 0:n.data.map(c=>({label:c.display_name,value:c.id})),t.loading=!1)})};export{C as a,d as c,u as f,p as h};
