module.exports=[912532,a=>{"use strict";var b=a.i(22169);a.s(["Card",()=>b.default])},102231,a=>{"use strict";var b=a.i(106554);a.s(["Toggle",()=>b.default])},865928,a=>{"use strict";var b=a.i(92126);a.s(["Select",()=>b.default])},629470,a=>{"use strict";var b=a.i(187924),c=a.i(572131),d=a.i(50944),e=a.i(238246);a.i(807284);var f=a.i(912532),g=a.i(401374),h=a.i(640695),i=a.i(865928),j=a.i(102231);a.i(883945);var k=a.i(813364);let l=Object.values(k.AI_PROVIDERS).map(a=>({value:a.id,label:a.name})),m=Object.values(k.AUTH_METHODS).map(a=>({value:a.id,label:a.name}));a.s(["default",0,function(){let a=(0,d.useRouter)(),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)({provider:"",authMethod:"api_key",apiKey:"",displayName:"",isActive:!0}),[r,s]=(0,c.useState)({}),t=(a,b)=>{q(c=>({...c,[a]:b})),r[a]&&s(b=>({...b,[a]:null}))},u=async b=>{let c;if(b.preventDefault(),c={},p.provider||(c.provider="Please select a provider"),"api_key"!==p.authMethod||p.apiKey||(c.apiKey="API Key is required"),s(c),0===Object.keys(c).length){o(!0);try{let b=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(b.ok)a.push("/dashboard/providers");else{let a=await b.json();s({submit:a.error||"Failed to create provider"})}}catch(a){s({submit:"An error occurred. Please try again."})}finally{o(!1)}}},v=k.AI_PROVIDERS[p.provider];return(0,b.jsxs)("div",{className:"max-w-2xl mx-auto",children:[(0,b.jsxs)("div",{className:"mb-8",children:[(0,b.jsxs)(e.default,{href:"/dashboard/providers",className:"inline-flex items-center gap-1 text-sm text-text-muted hover:text-primary transition-colors mb-4",children:[(0,b.jsx)("span",{className:"material-symbols-outlined text-lg",children:"arrow_back"}),"Back to Providers"]}),(0,b.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"Add New Provider"}),(0,b.jsx)("p",{className:"text-text-muted mt-2",children:"Configure a new AI provider to use with your applications."})]}),(0,b.jsx)(f.Card,{children:(0,b.jsxs)("form",{onSubmit:u,className:"flex flex-col gap-6",children:[(0,b.jsx)(i.Select,{label:"Provider",options:l,value:p.provider,onChange:a=>t("provider",a.target.value),placeholder:"Select a provider",error:r.provider,required:!0}),v&&(0,b.jsxs)(f.Card.Section,{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"size-10 rounded-lg flex items-center justify-center bg-bg border border-border",children:(0,b.jsx)("span",{className:"material-symbols-outlined text-xl",style:{color:v.color},children:v.icon})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"font-medium",children:v.name}),(0,b.jsx)("p",{className:"text-sm text-text-muted",children:"Selected provider"})]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,b.jsxs)("label",{className:"text-sm font-medium",children:["Authentication Method ",(0,b.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,b.jsx)("div",{className:"flex gap-3",children:m.map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>t("authMethod",a.value),className:`flex-1 flex items-center justify-center gap-2 p-4 rounded-lg border transition-all ${p.authMethod===a.value?"border-primary bg-primary/5 text-primary":"border-border hover:border-primary/50"}`,children:[(0,b.jsx)("span",{className:"material-symbols-outlined",children:"api_key"===a.value?"key":"lock"}),(0,b.jsx)("span",{className:"font-medium",children:a.label})]},a.value))})]}),"api_key"===p.authMethod&&(0,b.jsx)(h.Input,{label:"API Key",type:"password",placeholder:"Enter your API key",value:p.apiKey,onChange:a=>t("apiKey",a.target.value),error:r.apiKey,hint:"Your API key will be encrypted and stored securely.",required:!0}),"oauth2"===p.authMethod&&(0,b.jsxs)(f.Card.Section,{children:[(0,b.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Connect your account using OAuth2 authentication."}),(0,b.jsx)(g.Button,{type:"button",variant:"secondary",icon:"link",children:"Connect with OAuth2"})]}),(0,b.jsx)(h.Input,{label:"Display Name",placeholder:"e.g., Production API, Dev Environment",value:p.displayName,onChange:a=>t("displayName",a.target.value),hint:"Optional. A friendly name to identify this configuration."}),(0,b.jsx)(j.Toggle,{checked:p.isActive,onChange:a=>t("isActive",a),label:"Active",description:"Enable this provider for use in your applications"}),r.submit&&(0,b.jsx)("div",{className:"p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-600 dark:text-red-400 text-sm",children:r.submit}),(0,b.jsxs)("div",{className:"flex gap-3 pt-4 border-t border-border",children:[(0,b.jsx)(e.default,{href:"/dashboard/providers",className:"flex-1",children:(0,b.jsx)(g.Button,{type:"button",variant:"ghost",fullWidth:!0,children:"Cancel"})}),(0,b.jsx)(g.Button,{type:"submit",loading:n,fullWidth:!0,className:"flex-1",children:"Create Provider"})]})]})})]})}])}];

//# sourceMappingURL=src_0kxffao._.js.map