import{e as s,l as c}from"./main-few-lands-burn.js";const p=e=>({addConnectionHelpingText:s('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:s("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:s("Select Connection"),onConnectionAddChange:"CONNECTION_ADD_CHANGE",onConnectionChange:"SET_CONNECTION",render:!0,value:void 0}),h=({$:e,e:a})=>{e.setThisComponent(t=>{e.util.isConnectionComponent(t)&&t.connectionsTypes.forEach(o=>{o.type==="api_key"&&o.verifyConnection?.headers&&(o.verifyConnection.headers["x-api-key"]=a.value)})})},m=e=>({$:a,e:t})=>{a.setThisComponent(o=>{o.value=t}),a.setDb(o=>{o[e]=t})},l="https://api.anthropic.com/v1/",r=e=>c({headers:{"anthropic-version":"2023-06-01","x-api-key":{encryption:"hmac_decrypt",value:e}},method:"GET",url:`${l}models`}),C=async e=>{e.setComponent("model",n=>{n.loading=!0});const a=await e.getConnection();if(!a){e.setComponent("model",n=>{n.loading=!1});return}const{data:t,status:o}=await r(a.auth_details.value);if(o!=="success"){e.setComponent("model",n=>{e.util.isSelectComponent(n)&&(n.loading=!1,n.status=o,n.invalidMessage=t)}),console.error("Failed to fetch list");return}e.setComponent("model",n=>{e.util.isSelectComponent(n)&&(n.options=t?.data.map(i=>({label:i.display_name,value:i.id})),n.loading=!1)})};export{m as a,p as c,C as f,h};
