(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,98827,e=>{"use strict";var t=e.i(43476),s=e.i(71645);function r(){let[e,r]=(0,s.useState)(""),[a,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[i,c]=(0,s.useState)("free"),[d,x]=(0,s.useState)(!1),[p,u]=(0,s.useState)(!1),[y,h]=(0,s.useState)(null);async function m(){if(e){x(!0),h(null);try{let t=await fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeApiKey:e})}),s=await t.json();t.ok?h({type:"success",text:"API key is valid!"}):h({type:"error",text:s.error})}catch{h({type:"error",text:"Test failed"})}x(!1)}}async function b(){if(e){u(!0),h(null);try{let t=await fetch("/api/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeApiKey:e})});if(t.ok)h({type:"success",text:"API key saved!"}),l(!0),n("sk-ant-•••••"+e.slice(-4)),r("");else{let e=await t.json();h({type:"error",text:e.error})}}catch{h({type:"error",text:"Save failed"})}u(!1)}}return(0,s.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{l(e.hasKey),n(e.maskedKey),c(e.plan)}).catch(console.error)},[]),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-[var(--color-text-secondary)]",children:"Settings"}),(0,t.jsx)("h1",{className:"font-display text-3xl font-bold",children:"Workspace settings"}),(0,t.jsx)("p",{className:"text-[var(--color-text-secondary)]",children:"Manage your Claude API key and workspace configuration."})]}),(0,t.jsxs)("div",{className:"rounded-2xl border border-[var(--color-border-light)] bg-white p-6 shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"font-semibold",children:"Claude API Key (BYOK)"}),(0,t.jsx)("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"Keys are encrypted server-side. Never exposed to the client."})]}),(0,t.jsxs)("span",{className:"rounded-full bg-[var(--color-bg-soft)] px-3 py-1 text-xs font-semibold text-[var(--color-bg-brand)]",children:[i," plan"]})]}),o&&(0,t.jsxs)("div",{className:"mt-4 rounded-xl bg-[var(--color-bg-soft)] px-4 py-3 text-sm",children:["Current key: ",(0,t.jsx)("code",{className:"font-mono",children:a})]}),y&&(0,t.jsx)("div",{className:`mt-4 rounded-xl px-4 py-3 text-sm ${"success"===y.type?"bg-green-50 text-green-700":"bg-red-50 text-red-600"}`,children:y.text}),(0,t.jsxs)("div",{className:"mt-4 flex flex-col gap-3 md:flex-row md:items-center",children:[(0,t.jsx)("input",{type:"password",value:e,onChange:e=>r(e.target.value),placeholder:o?"Enter new key to replace...":"sk-ant-...",className:"input flex-1"}),(0,t.jsx)("button",{onClick:m,disabled:!e||d,className:"inline-flex items-center justify-center rounded-xl bg-[var(--color-bg-brand)] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[var(--color-bg-brand-light)] disabled:opacity-50",children:d?"Testing...":"Test connection"}),(0,t.jsx)("button",{onClick:b,disabled:!e||p,className:"inline-flex items-center justify-center rounded-xl border border-[var(--color-border-subtle)] px-4 py-2 text-sm font-semibold transition hover:bg-[var(--color-bg-soft)] disabled:opacity-50",children:p?"Saving...":"Save key"})]})]})]})}e.s(["default",()=>r])}]);