@kaitranntt/ccs 7.66.0-dev.2 → 7.66.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliproxy/auth/oauth-handler.d.ts +1 -4
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +2 -33
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/auth/oauth-process.d.ts +13 -0
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-process.js +56 -36
- package/dist/cliproxy/auth/oauth-process.js.map +1 -1
- package/dist/cliproxy/auth/token-manager.d.ts +9 -0
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
- package/dist/cliproxy/auth/token-manager.js +104 -58
- package/dist/cliproxy/auth/token-manager.js.map +1 -1
- package/dist/commands/docker/up-subcommand.js +1 -1
- package/dist/commands/docker/up-subcommand.js.map +1 -1
- package/dist/ui/assets/{accounts-l__hcQUq.js → accounts-BUBaJvX6.js} +1 -1
- package/dist/ui/assets/{alert-dialog-BtM3eP43.js → alert-dialog-BSHMTH4-.js} +1 -1
- package/dist/ui/assets/{api-Ddwn7EXC.js → api-ChLCuNLU.js} +1 -1
- package/dist/ui/assets/{auth-section-BnYn1EA3.js → auth-section-BhmOD3zG.js} +1 -1
- package/dist/ui/assets/{backups-section-M4jx3HzK.js → backups-section-Bi22P9k4.js} +1 -1
- package/dist/ui/assets/{channels-D9ywyAj3.js → channels-BzYyOP0U.js} +1 -1
- package/dist/ui/assets/{checkbox-Df-yoPbe.js → checkbox-DXj-4eLk.js} +1 -1
- package/dist/ui/assets/{claude-extension-Cxg0a-Ee.js → claude-extension-Bh9pF8rf.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-DtW-6cPc.js → cliproxy-ai-providers-C5Kw8KgM.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-0TyLDMf7.js → cliproxy-control-panel-DLLoW9yz.js} +1 -1
- package/dist/ui/assets/{cliproxy-DPFdpIHy.js → cliproxy-oJmvPKpC.js} +1 -1
- package/dist/ui/assets/{codex-BtPojOrJ.js → codex-CNDtlY6P.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BMwFBq5G.js → confirm-dialog-CF5EDIrm.js} +1 -1
- package/dist/ui/assets/{copilot-BG3BnHxa.js → copilot-DcsWzY5x.js} +1 -1
- package/dist/ui/assets/{cursor-BfDO73Lu.js → cursor-D35uxPJ3.js} +1 -1
- package/dist/ui/assets/{droid-iW-Vtuhy.js → droid-cwS_m2Fj.js} +1 -1
- package/dist/ui/assets/{globalenv-section-d9h23hIf.js → globalenv-section-B7amS8JA.js} +1 -1
- package/dist/ui/assets/{health-BPPMFQMR.js → health-BMb4MU3S.js} +1 -1
- package/dist/ui/assets/{index-BPyp9RJE.js → index-BBHJt5Yt.js} +1 -1
- package/dist/ui/assets/{index-wIy8qzU9.js → index-Bmd4gqsh.js} +15 -15
- package/dist/ui/assets/{index-CeP2Pr2w.js → index-C90qrEFO.js} +1 -1
- package/dist/ui/assets/{index-DYY3wcwk.js → index-CQSl6vEt.js} +1 -1
- package/dist/ui/assets/{index-DusmDwkD.js → index-Cnp8oH1Z.js} +1 -1
- package/dist/ui/assets/{index-B6Y8wFQ0.css → index-Cw_d3NZ2.css} +1 -1
- package/dist/ui/assets/{index-CctYE17X.js → index-osM0SZ9h.js} +1 -1
- package/dist/ui/assets/{masked-input-DWNtAEKs.js → masked-input-DUqplFGl.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-GS3qroms.js → proxy-status-widget-IxTsEDhP.js} +1 -1
- package/dist/ui/assets/{raw-json-settings-editor-panel-e3Ziu5B1.js → raw-json-settings-editor-panel-eQGtUD6M.js} +1 -1
- package/dist/ui/assets/{searchable-select-D2G6gg3h.js → searchable-select-D_SVA6pH.js} +1 -1
- package/dist/ui/assets/{separator-CR1SGLxF.js → separator-Cuk1ilZb.js} +1 -1
- package/dist/ui/assets/{shared-BpB5GiWS.js → shared-BaW8OUvz.js} +1 -1
- package/dist/ui/assets/{table-BMbwptG_.js → table-BKS_LAxP.js} +1 -1
- package/dist/ui/assets/{updates-iC3kvbKP.js → updates-CunZLYFy.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/web-server/routes/auth-routes.js +11 -11
- package/dist/web-server/routes/auth-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +2 -69
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +18 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/usage/routes.d.ts.map +1 -1
- package/dist/web-server/usage/routes.js +11 -0
- package/dist/web-server/usage/routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as u,h as Ke}from"./react-vendor-CNOkPC89.js";import{B as L,c as D,T as Je,p as Be,q as qe,r as Ve,s as Ye,t as We,v as Ge,w as me,d as v,a as B,n as ae,L as R,I as U,x as J,y as Oe,z as Xe,A as Ze,D as es,E as ss,S as je,F as Z,G as xe,H as Te,J as ts,K as as,M as Ee,N as Ae,O as _e,Q as rs,R as ns,U as Ne,V as ve,W as ee,X as is,Y as os,Z as ge,C as Re,b as Me,j as ls,k as cs,_ as ds,$ as ms,a0 as us,a1 as xs,a2 as hs,a3 as ps,a4 as gs,a5 as fs,a6 as js,a7 as Ns}from"./index-wIy8qzU9.js";import{a as vs,u as be,b as we}from"./tanstack-DWm6aJ-G.js";import{C as he}from"./confirm-dialog-BMwFBq5G.js";import{t as T}from"./notifications-B2HqRBj7.js";import{L as se,R as G,ap as De,aq as bs,a6 as te,V as ws,ar as Le,a7 as fe,C as Ie,as as Cs,a4 as ys,at as Ps,o as pe,X as ks,Z as Fe,au as Ce,m as ye,av as Ue,aw as Ss,aa as Os,ax as Ts,v as He,ay as Es,w as Qe,n as As,az as _s}from"./icons-BxSzn11s.js";import{M as $e}from"./masked-input-DWNtAEKs.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BtM3eP43.js";function Rs({className:s,showTooltip:r=!0}){const n=e.jsxs(L,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return r?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function ze(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Ms(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ds(s,r){const n={...s};return r.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ls({profileName:s,target:r,data:n,settings:m,isLoading:c,isSaving:g,isTargetSaving:a,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:h,onDelete:b,onSave:w}){const k=g||a,j=c||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),ze(m)&&e.jsx(Rs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ve,{value:r,onValueChange:S=>{j||p(S)},disabled:j,children:[e.jsx(Ye,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(We,{})}),e.jsxs(Ge,{children:[e.jsx(me,{value:"claude",children:"Claude Code"}),e.jsx(me,{value:"droid",children:"Factory Droid"}),e.jsx(me,{value:"codex",children:"Codex CLI"})]})]}),a&&e.jsx(se,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:h,disabled:j,children:e.jsx(G,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),b&&e.jsx(v,{variant:"ghost",size:"sm",onClick:b,disabled:k,children:e.jsx(De,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:w,disabled:k||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Is({currentSettings:s,newEnvKey:r,newEnvValue:n,onNewEnvKeyChange:m,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:a}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Pe(t)?e.jsx($e,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"}):e.jsx(U,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>m(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(U,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:a,disabled:!r.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]})}function Fs({profileName:s,target:r,data:n}){const{t:m}=B(),c=r==="droid";return e.jsx(ae,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),m("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(J,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:m("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:r,placeholder:n="Search models...",className:m}){const[c,g]=u.useState(""),[a,f]=u.useState(null),{models:t,isLoading:p,isError:h,isFetching:b}=Oe(),w=Xe(),k=u.useMemo(()=>Ze(t,c,{category:a??void 0}),[t,c,a]),j=u.useMemo(()=>es(t,2),[t]),S=!c.trim()&&!a,H=u.useMemo(()=>{const d={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{d[x.category].push(x)});for(const x of Object.keys(d))d[x]=ss(d[x]);return d},[k]),C=u.useCallback(()=>{w()},[w]),M=t.find(d=>d.id===s);return p&&t.length===0?e.jsxs("div",{className:D("space-y-2",m),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",m),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Le,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(U,{value:c,onChange:d=>g(d.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:b,title:"Refresh models",children:b?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:a===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(Z).map(d=>{const x=H[d].length;return x===0?null:e.jsxs(L,{variant:a===d?"default":"outline",className:"cursor-pointer",onClick:()=>f(d),children:[Z[d]," (",x,")"]},d)})]}),M&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(M.pricing)," |"," ",Te(M.context_length)]})]}),e.jsx(ae,{className:"h-72 w-full rounded-md border",children:h?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:C,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(fe,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(d=>e.jsx(ke,{model:d,isSelected:d.id===s,onClick:()=>r(d.id),showAge:!0},d.id))})]}),Object.keys(Z).map(d=>{const x=H[d];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:Z[d]}),e.jsx("div",{className:"space-y-1",children:x.map(l=>e.jsx(ke,{model:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id))})]},d)})]})})]})}function ke({model:s,isSelected:r,onClick:n,showAge:m=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[m&&s.created&&e.jsx(L,{variant:"outline",className:D("text-[10px] px-1",r?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:D("text-[10px] px-1",r?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Hs({selectedModel:s,value:r,onChange:n,className:m}){const{t:c}=B(),{models:g}=Oe(),a=u.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(a)},t=(h,b)=>{n({...r,[h]:b||void 0})},p=s&&Object.keys(a).length>0;return e.jsxs(Ee,{className:D("group",m),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ie,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),c("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(U,{id:"tier-opus",value:r.opus??"",onChange:h=>t("opus",h.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(U,{id:"tier-sonnet",value:r.sonnet??"",onChange:h=>t("sonnet",h.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(U,{id:"tier-haiku",value:r.haiku??"",onChange:h=>t("haiku",h.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Qs({profileName:s,target:r,data:n,currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:h}){const b=ze(m),w=m?.env,k=u.useMemo(()=>Ms(w??{}),[w]),j=w??{},S=l=>{if(h){const Q={...j,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};h(Q)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);T.success(ee.t("commonToast.appliedModelAllTiers"),{duration:2e3})},H=l=>{if(h){const Q=Ds(j,l);h(Q)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[C,M]=u.useState(!1),d=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(j).filter(([l])=>!d.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:b?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(R,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:j.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Hs,{selectedModel:j.ANTHROPIC_MODEL,value:k,onChange:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"API Key"}),e.jsx($e,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),x.length>0&&e.jsxs(Ee,{open:C,onOpenChange:M,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ie,{className:D("h-4 w-4 transition-transform",C&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([l,Q])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:l}),e.jsx(U,{value:Q,onChange:$=>t(l,$.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:"VARIABLE_NAME",value:c,onChange:l=>a(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(U,{placeholder:"value",value:g,onChange:l=>f(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]}):e.jsx(Is,{currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Fs,{profileName:s,target:r,data:n})})]})]})})}function $s({profileName:s,profileTarget:r,onDelete:n,onHasChangesUpdate:m}){const[c,g]=u.useState({}),[a,f]=u.useState(!1),[t,p]=u.useState(null),[h,b]=u.useState(""),[w,k]=u.useState(""),j=vs(),{data:S,isLoading:H,isError:C,refetch:M}=be({queryKey:["settings",s],queryFn:async()=>{const o=await fetch(`/api/settings/${s}/raw`);if(!o.ok)throw new Error(`Failed to load settings: ${o.status}`);return o.json()}}),d=S?.settings,x=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(d)return{...d,env:{...d.env,...c}}},[d,c,t]),l=u.useMemo(()=>t!==null?t:d?JSON.stringify(d,null,2):"",[t,d]),Q=u.useCallback(o=>{p(o)},[]),$=u.useCallback(o=>{const N={...x??{}},A=N.ccs_image&&typeof N.ccs_image=="object"?{...N.ccs_image}:{};o?A.native_read=!0:delete A.native_read,Object.keys(A).length>0?N.ccs_image=A:delete N.ccs_image,p(JSON.stringify(N,null,2))},[x]),q=(o,N)=>{const A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2))},K=o=>{const N={...x?.env||{},...o};g(A=>({...A,...o})),p(JSON.stringify({...x,env:N},null,2))},X=()=>{if(!h.trim())return;const o=h.trim(),N=w,A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2)),b(""),k("")},y=u.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),I=u.useMemo(()=>t!==null?t!==JSON.stringify(d,null,2):Object.keys(c).length>0,[t,c,d]),O=u.useDeferredValue(l),z=u.useMemo(()=>{if(!I||!y)return null;try{return JSON.parse(O)}catch{return null}},[I,y,O]),{data:V,isFetching:re,isError:Y,isPlaceholderData:ne}=be({queryKey:["settings",s,"image-analysis-status-preview",O],enabled:z!==null,placeholderData:o=>o,queryFn:async()=>{const o=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!o.ok)throw new Error(`Failed to preview image-analysis status: ${o.status}`);return o.json()}}),ie=I&&y&&!Y?V?.imageAnalysisStatus??S?.imageAnalysisStatus:S?.imageAnalysisStatus,oe=I&&y&&!Y&&V?.imageAnalysisStatus?"editor":"saved",le=I?y?Y?"saved":re&&(!V?.imageAnalysisStatus||ne)?"refreshing":"preview":"invalid":"saved",ce=x?.ccs_image?.native_read===!0,de=u.useMemo(()=>{const o=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],N=x?.env||{};return o.filter(A=>!N[A]?.trim())},[x]);u.useEffect(()=>{m?.(I)},[I,m]);const i=we({mutationFn:async()=>{let o;try{o=JSON.parse(l)}catch{o={...S?.settings,env:{...S?.settings?.env,...c}}}const N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o,expectedMtime:S?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),T.success(ee.t("commonToast.settingsSaved"))},onError:o=>{o.message==="CONFLICT"?f(!0):T.error(o.message)}}),E=we({mutationFn:async o=>(await os.profiles.update(s,{target:o}),o),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),T.success(ee.t("commonToast.defaultTargetUpdated"))},onError:(o,N)=>{const A=N==="droid"?"Factory Droid":N==="codex"?"Codex CLI":"Claude Code",W=o.message.trim()?`: ${o.message}`:"";T.error(ee.t("commonToast.failedUpdateDefaultTarget",{target:A,suffix:W}))}}),P=r||"claude",F=i.isPending||E.isPending,_=async o=>{f(!1),o?(await M(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ls,{profileName:s,target:P,data:S,settings:x,isLoading:H,isSaving:i.isPending,isTargetSaving:E.isPending,hasChanges:I,isRawJsonValid:y,onTargetChange:o=>{F||o!==P&&E.mutate(o)},onRefresh:()=>{F||M()},onDelete:n,onSave:()=>{F||i.mutate()}}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(se,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>M(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Qs,{profileName:s,target:P,data:S,currentSettings:x,newEnvKey:h,newEnvValue:w,onNewEnvKeyChange:b,onNewEnvValueChange:k,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:X})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:l,isRawJsonValid:y,rawJsonEdits:t,settings:d,profileTarget:P,imageAnalysisStatus:ie,imageAnalysisStatusSource:oe,imageAnalysisStatusPreviewState:le,nativeReadPreferenceOverride:ce,onToggleNativeRead:$,onChange:Q,missingRequiredFields:de})]})]}),e.jsx(he,{open:a,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>_(!0),onCancel:()=>_(!1)})]},s)}const Se="ccs:openrouter-banner-dismissed";function zs({onCreateClick:s}){const[r,n]=u.useState(!0),{modelCount:m,isLoading:c}=ge();u.useEffect(()=>{const a=localStorage.getItem(Se)==="true";n(a)},[]);const g=()=>{localStorage.setItem(Se,"true"),n(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(fe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${m}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(pe,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ue({badge:s,badgeClassName:r,className:n,title:m,description:c,visual:g,highlights:a,actionLabel:f,actionClassName:t,onAction:p,footer:h}){return e.jsxs(Re,{className:D("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(ls,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(L,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(cs,{className:"text-base",children:m}),e.jsx(ds,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Me,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:a.map(b=>e.jsxs("div",{className:"flex items-center gap-2",children:[b.icon,e.jsx("span",{children:b.label})]},b.label))}),e.jsxs(v,{onClick:p,className:t,children:[f,e.jsx(Ss,{className:"ml-2 h-4 w-4"})]}),h?e.jsx("div",{className:"text-xs text-muted-foreground",children:h}):null]})]})}function Ks({hasProfiles:s,profileCount:r,onOpenRouterClick:n,onAlibabaCodingPlanClick:m,onCliproxyClick:c,onCustomClick:g}){const{t:a}=B(),{modelCount:f,isLoading:t}=ge(),p=t?"300+":`${f}+`,h=s?a("openrouterQuickStart.profileCount",{count:r}):a("openrouterQuickStart.recommended"),b=a(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),w=s?a("openrouterQuickStart.summaryDescriptionWithProfiles",{count:r}):a("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Re,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Me,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:h}),e.jsx(L,{variant:"outline",children:a("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:b}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:w})]})]}),e.jsx(v,{variant:"outline",onClick:g,className:"shrink-0",children:a("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ue,{badge:a("openrouterQuickStart.recommended"),title:a("openrouterQuickStart.title"),description:a("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureOneApi")},{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureTierMapping")}],actionLabel:a("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(pe,{className:"h-3 w-3"})]})]})}),e.jsx(ue,{badge:a("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:a("openrouterQuickStart.runtimeProviderTitle"),description:a("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(Ce,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:a("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:a("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ue,{badge:a("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:a("alibabaCodingPlanQuickStart.title"),description:a("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Ue,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:a("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:m,footer:e.jsxs(e.Fragment,{children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(pe,{className:"h-3 w-3"})]})]})})]})]})})}function Js({onCreateClick:s}){const{modelCount:r,isLoading:n}=ge();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${r}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Bs({onCreateClick:s}){const{t:r}=B();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function it(){const{t:s}=B(),r=Ke(),{data:n,isLoading:m,isError:c,refetch:g}=ms(),a=us(),f=xs(),t=hs(),p=ps(),h=gs(),b=fs(),[w,k]=u.useState(null),[j,S]=u.useState(""),[H,C]=u.useState(!1),[M,d]=u.useState("normal"),[x,l]=u.useState(null),[Q,$]=u.useState(!1),[q,K]=u.useState(null),X=u.useRef(null);js();const y=u.useMemo(()=>n?.profiles||[],[n?.profiles]),I=u.useMemo(()=>y.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[y,j]),O=w?y.find(i=>i.name===w):null,z=i=>{Q&&w!==i?K(i):k(i)},V=i=>{a.mutate(i,{onSuccess:()=>{w===i&&(k(null),$(!1),K(null)),l(null)}})},re=i=>{C(!1),z(i)},Y=i=>{z(i)},ne=(i,E)=>{const P=JSON.stringify(E,null,2)+`
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as u,h as Ke}from"./react-vendor-CNOkPC89.js";import{B as L,c as D,T as Je,p as Be,q as qe,r as Ve,s as Ye,t as We,v as Ge,w as me,d as v,a as B,n as ae,L as R,I as U,x as J,y as Oe,z as Xe,A as Ze,D as es,E as ss,S as je,F as Z,G as xe,H as Te,J as ts,K as as,M as Ee,N as Ae,O as _e,Q as rs,R as ns,U as Ne,V as ve,W as ee,X as is,Y as os,Z as ge,C as Re,b as Me,j as ls,k as cs,_ as ds,$ as ms,a0 as us,a1 as xs,a2 as hs,a3 as ps,a4 as gs,a5 as fs,a6 as js,a7 as Ns}from"./index-Bmd4gqsh.js";import{a as vs,u as be,b as we}from"./tanstack-DWm6aJ-G.js";import{C as he}from"./confirm-dialog-CF5EDIrm.js";import{t as T}from"./notifications-B2HqRBj7.js";import{L as se,R as G,ap as De,aq as bs,a6 as te,V as ws,ar as Le,a7 as fe,C as Ie,as as Cs,a4 as ys,at as Ps,o as pe,X as ks,Z as Fe,au as Ce,m as ye,av as Ue,aw as Ss,aa as Os,ax as Ts,v as He,ay as Es,w as Qe,n as As,az as _s}from"./icons-BxSzn11s.js";import{M as $e}from"./masked-input-DUqplFGl.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BSHMTH4-.js";function Rs({className:s,showTooltip:r=!0}){const n=e.jsxs(L,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return r?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function Pe(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function ze(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Ms(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ds(s,r){const n={...s};return r.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ls({profileName:s,target:r,data:n,settings:m,isLoading:c,isSaving:g,isTargetSaving:a,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:h,onDelete:b,onSave:w}){const k=g||a,j=c||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(L,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),ze(m)&&e.jsx(Rs,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ve,{value:r,onValueChange:S=>{j||p(S)},disabled:j,children:[e.jsx(Ye,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(We,{})}),e.jsxs(Ge,{children:[e.jsx(me,{value:"claude",children:"Claude Code"}),e.jsx(me,{value:"droid",children:"Factory Droid"}),e.jsx(me,{value:"codex",children:"Codex CLI"})]})]}),a&&e.jsx(se,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:h,disabled:j,children:e.jsx(G,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),b&&e.jsx(v,{variant:"ghost",size:"sm",onClick:b,disabled:k,children:e.jsx(De,{className:"w-4 h-4 text-destructive"})}),e.jsx(v,{size:"sm",onClick:w,disabled:k||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(bs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Is({currentSettings:s,newEnvKey:r,newEnvValue:n,onNewEnvKeyChange:m,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:a}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([t,p])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Pe(t)&&e.jsx(L,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Pe(t)?e.jsx($e,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"}):e.jsx(U,{value:p,onChange:h=>g(t,h.target.value),className:"font-mono text-sm h-8"})]},t))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>m(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(U,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&a()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:a,disabled:!r.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]})}function Fs({profileName:s,target:r,data:n}){const{t:m}=B(),c=r==="droid";return e.jsx(ae,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),m("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(J,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:m("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:r})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:m("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(J,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:`ccs-droid ${s} "prompt"`}),e.jsx(J,{value:`ccs-droid ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m(c?"profileEditor.overrideToClaude":"profileEditor.runOnDroidWithFlag")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s," --target ",c?"claude":"droid",' "prompt"']}),e.jsx(J,{value:`ccs ${s} --target ${c?"claude":"droid"} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:m("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(J,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:r,placeholder:n="Search models...",className:m}){const[c,g]=u.useState(""),[a,f]=u.useState(null),{models:t,isLoading:p,isError:h,isFetching:b}=Oe(),w=Xe(),k=u.useMemo(()=>Ze(t,c,{category:a??void 0}),[t,c,a]),j=u.useMemo(()=>es(t,2),[t]),S=!c.trim()&&!a,H=u.useMemo(()=>{const d={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{d[x.category].push(x)});for(const x of Object.keys(d))d[x]=ss(d[x]);return d},[k]),C=u.useCallback(()=>{w()},[w]),M=t.find(d=>d.id===s);return p&&t.length===0?e.jsxs("div",{className:D("space-y-2",m),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",m),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Le,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(U,{value:c,onChange:d=>g(d.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:C,disabled:b,title:"Refresh models",children:b?e.jsx(se,{className:"h-4 w-4 animate-spin"}):e.jsx(G,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(L,{variant:a===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(Z).map(d=>{const x=H[d].length;return x===0?null:e.jsxs(L,{variant:a===d?"default":"outline",className:"cursor-pointer",onClick:()=>f(d),children:[Z[d]," (",x,")"]},d)})]}),M&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(M.pricing)," |"," ",Te(M.context_length)]})]}),e.jsx(ae,{className:"h-72 w-full rounded-md border",children:h?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(v,{variant:"link",onClick:C,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',c,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[S&&j.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(fe,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(d=>e.jsx(ke,{model:d,isSelected:d.id===s,onClick:()=>r(d.id),showAge:!0},d.id))})]}),Object.keys(Z).map(d=>{const x=H[d];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:Z[d]}),e.jsx("div",{className:"space-y-1",children:x.map(l=>e.jsx(ke,{model:l,isSelected:l.id===s,onClick:()=>r(l.id)},l.id))})]},d)})]})})]})}function ke({model:s,isSelected:r,onClick:n,showAge:m=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",r&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",r?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[m&&s.created&&e.jsx(L,{variant:"outline",className:D("text-[10px] px-1",r?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(L,{variant:"secondary",className:D("text-[10px] px-1",r?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",r?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Hs({selectedModel:s,value:r,onChange:n,className:m}){const{t:c}=B(),{models:g}=Oe(),a=u.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(a)},t=(h,b)=>{n({...r,[h]:b||void 0})},p=s&&Object.keys(a).length>0;return e.jsxs(Ee,{className:D("group",m),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(Ie,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),c("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",c("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),c("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(U,{id:"tier-opus",value:r.opus??"",onChange:h=>t("opus",h.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(U,{id:"tier-sonnet",value:r.sonnet??"",onChange:h=>t("sonnet",h.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(R,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(U,{id:"tier-haiku",value:r.haiku??"",onChange:h=>t("haiku",h.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Qs({profileName:s,target:r,data:n,currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:h}){const b=ze(m),w=m?.env,k=u.useMemo(()=>Ms(w??{}),[w]),j=w??{},S=l=>{if(h){const Q={...j,ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};h(Q)}else t("ANTHROPIC_MODEL",l),t("ANTHROPIC_DEFAULT_OPUS_MODEL",l),t("ANTHROPIC_DEFAULT_SONNET_MODEL",l),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l);T.success(ee.t("commonToast.appliedModelAllTiers"),{duration:2e3})},H=l=>{if(h){const Q=Ds(j,l);h(Q)}else l.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",l.opus||""),l.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",l.sonnet||""),l.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",l.haiku||"")},[C,M]=u.useState(!1),d=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(j).filter(([l])=>!d.has(l));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:b?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:b?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(R,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:j.ANTHROPIC_MODEL,onChange:S,placeholder:"Search OpenRouter models..."})]}),e.jsx(Hs,{selectedModel:j.ANTHROPIC_MODEL,value:k,onChange:H}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"API Key"}),e.jsx($e,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:l=>t("ANTHROPIC_AUTH_TOKEN",l.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),x.length>0&&e.jsxs(Ee,{open:C,onOpenChange:M,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(Ie,{className:D("h-4 w-4 transition-transform",C&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([l,Q])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{className:"text-xs text-muted-foreground",children:l}),e.jsx(U,{value:Q,onChange:$=>t(l,$.target.value),className:"font-mono text-xs h-8"})]},l))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(R,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(U,{placeholder:"VARIABLE_NAME",value:c,onChange:l=>a(l.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(U,{placeholder:"value",value:g,onChange:l=>f(l.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:l=>l.key==="Enter"&&c.trim()&&p()}),e.jsx(v,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(te,{className:"w-4 h-4"})})]})]})]}):e.jsx(Is,{currentSettings:m,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:a,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Fs,{profileName:s,target:r,data:n})})]})]})})}function $s({profileName:s,profileTarget:r,onDelete:n,onHasChangesUpdate:m}){const[c,g]=u.useState({}),[a,f]=u.useState(!1),[t,p]=u.useState(null),[h,b]=u.useState(""),[w,k]=u.useState(""),j=vs(),{data:S,isLoading:H,isError:C,refetch:M}=be({queryKey:["settings",s],queryFn:async()=>{const o=await fetch(`/api/settings/${s}/raw`);if(!o.ok)throw new Error(`Failed to load settings: ${o.status}`);return o.json()}}),d=S?.settings,x=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(d)return{...d,env:{...d.env,...c}}},[d,c,t]),l=u.useMemo(()=>t!==null?t:d?JSON.stringify(d,null,2):"",[t,d]),Q=u.useCallback(o=>{p(o)},[]),$=u.useCallback(o=>{const N={...x??{}},A=N.ccs_image&&typeof N.ccs_image=="object"?{...N.ccs_image}:{};o?A.native_read=!0:delete A.native_read,Object.keys(A).length>0?N.ccs_image=A:delete N.ccs_image,p(JSON.stringify(N,null,2))},[x]),q=(o,N)=>{const A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2))},K=o=>{const N={...x?.env||{},...o};g(A=>({...A,...o})),p(JSON.stringify({...x,env:N},null,2))},X=()=>{if(!h.trim())return;const o=h.trim(),N=w,A={...x?.env||{},[o]:N};g(W=>({...W,[o]:N})),p(JSON.stringify({...x,env:A},null,2)),b(""),k("")},y=u.useMemo(()=>{try{return JSON.parse(l),!0}catch{return!1}},[l]),I=u.useMemo(()=>t!==null?t!==JSON.stringify(d,null,2):Object.keys(c).length>0,[t,c,d]),O=u.useDeferredValue(l),z=u.useMemo(()=>{if(!I||!y)return null;try{return JSON.parse(O)}catch{return null}},[I,y,O]),{data:V,isFetching:re,isError:Y,isPlaceholderData:ne}=be({queryKey:["settings",s,"image-analysis-status-preview",O],enabled:z!==null,placeholderData:o=>o,queryFn:async()=>{const o=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!o.ok)throw new Error(`Failed to preview image-analysis status: ${o.status}`);return o.json()}}),ie=I&&y&&!Y?V?.imageAnalysisStatus??S?.imageAnalysisStatus:S?.imageAnalysisStatus,oe=I&&y&&!Y&&V?.imageAnalysisStatus?"editor":"saved",le=I?y?Y?"saved":re&&(!V?.imageAnalysisStatus||ne)?"refreshing":"preview":"invalid":"saved",ce=x?.ccs_image?.native_read===!0,de=u.useMemo(()=>{const o=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],N=x?.env||{};return o.filter(A=>!N[A]?.trim())},[x]);u.useEffect(()=>{m?.(I)},[I,m]);const i=we({mutationFn:async()=>{let o;try{o=JSON.parse(l)}catch{o={...S?.settings,env:{...S?.settings?.env,...c}}}const N=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:o,expectedMtime:S?.mtime})});if(N.status===409)throw new Error("CONFLICT");if(!N.ok)throw new Error("Failed to save");return N.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),T.success(ee.t("commonToast.settingsSaved"))},onError:o=>{o.message==="CONFLICT"?f(!0):T.error(o.message)}}),E=we({mutationFn:async o=>(await os.profiles.update(s,{target:o}),o),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),T.success(ee.t("commonToast.defaultTargetUpdated"))},onError:(o,N)=>{const A=N==="droid"?"Factory Droid":N==="codex"?"Codex CLI":"Claude Code",W=o.message.trim()?`: ${o.message}`:"";T.error(ee.t("commonToast.failedUpdateDefaultTarget",{target:A,suffix:W}))}}),P=r||"claude",F=i.isPending||E.isPending,_=async o=>{f(!1),o?(await M(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ls,{profileName:s,target:P,data:S,settings:x,isLoading:H,isSaving:i.isPending,isTargetSaving:E.isPending,hasChanges:I,isRawJsonValid:y,onTargetChange:o=>{F||o!==P&&E.mutate(o)},onRefresh:()=>{F||M()},onDelete:n,onSave:()=>{F||i.mutate()}}),H?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(se,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>M(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"min-h-0 flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted/5",children:e.jsx(Qs,{profileName:s,target:P,data:S,currentSettings:x,newEnvKey:h,newEnvValue:w,onNewEnvKeyChange:b,onNewEnvValueChange:k,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:X})}),e.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(Ps,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:l,isRawJsonValid:y,rawJsonEdits:t,settings:d,profileTarget:P,imageAnalysisStatus:ie,imageAnalysisStatusSource:oe,imageAnalysisStatusPreviewState:le,nativeReadPreferenceOverride:ce,onToggleNativeRead:$,onChange:Q,missingRequiredFields:de})]})]}),e.jsx(he,{open:a,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>_(!0),onCancel:()=>_(!1)})]},s)}const Se="ccs:openrouter-banner-dismissed";function zs({onCreateClick:s}){const[r,n]=u.useState(!0),{modelCount:m,isLoading:c}=ge();u.useEffect(()=>{const a=localStorage.getItem(Se)==="true";n(a)},[]);const g=()=>{localStorage.setItem(Se,"true"),n(!0)};return r?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(fe,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",c?"300+":`${m}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(v,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(pe,{className:"w-3 h-3"})]}),e.jsxs(v,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(ks,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function ue({badge:s,badgeClassName:r,className:n,title:m,description:c,visual:g,highlights:a,actionLabel:f,actionClassName:t,onAction:p,footer:h}){return e.jsxs(Re,{className:D("flex h-full flex-col border shadow-sm",n),children:[e.jsxs(ls,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(L,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(cs,{className:"text-base",children:m}),e.jsx(ds,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Me,{className:"mt-auto flex flex-1 flex-col gap-4 pt-0",children:[e.jsx("div",{className:"space-y-2 text-xs text-muted-foreground",children:a.map(b=>e.jsxs("div",{className:"flex items-center gap-2",children:[b.icon,e.jsx("span",{children:b.label})]},b.label))}),e.jsxs(v,{onClick:p,className:t,children:[f,e.jsx(Ss,{className:"ml-2 h-4 w-4"})]}),h?e.jsx("div",{className:"text-xs text-muted-foreground",children:h}):null]})]})}function Ks({hasProfiles:s,profileCount:r,onOpenRouterClick:n,onAlibabaCodingPlanClick:m,onCliproxyClick:c,onCustomClick:g}){const{t:a}=B(),{modelCount:f,isLoading:t}=ge(),p=t?"300+":`${f}+`,h=s?a("openrouterQuickStart.profileCount",{count:r}):a("openrouterQuickStart.recommended"),b=a(s?"openrouterQuickStart.selectProfileTitle":"apiProfiles.noProfilesYet"),w=s?a("openrouterQuickStart.summaryDescriptionWithProfiles",{count:r}):a("openrouterQuickStart.summaryDescriptionNoProfiles");return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-auto bg-muted/20 p-4 sm:p-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-7xl flex-col gap-4",children:[e.jsx(Re,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Me,{className:"flex flex-col gap-4 p-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(L,{variant:"secondary",children:h}),e.jsx(L,{variant:"outline",children:a("openrouterQuickStart.openrouterModelsBadge",{modelCountLabel:p})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:b}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:w})]})]}),e.jsx(v,{variant:"outline",onClick:g,className:"shrink-0",children:a("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(ue,{badge:a("openrouterQuickStart.recommended"),title:a("openrouterQuickStart.title"),description:a("openrouterQuickStart.description",{modelCountLabel:p}),visual:e.jsx("div",{className:"rounded-lg bg-accent/10 p-2",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureOneApi")},{icon:e.jsx(fe,{className:"h-3.5 w-3.5 text-accent"}),label:a("openrouterQuickStart.featureTierMapping")}],actionLabel:a("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:n,footer:e.jsxs(e.Fragment,{children:[a("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-accent hover:underline",children:["openrouter.ai/keys",e.jsx(pe,{className:"h-3 w-3"})]})]})}),e.jsx(ue,{badge:a("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:a("openrouterQuickStart.runtimeProviderTitle"),description:a("openrouterQuickStart.runtimeProviderDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(Ce,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(Ce,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:a("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:a("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:a("openrouterQuickStart.runtimeProviderFooter")})}),e.jsx(ue,{badge:a("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",className:"lg:col-span-2",title:a("alibabaCodingPlanQuickStart.title"),description:a("alibabaCodingPlanQuickStart.description"),visual:e.jsx("div",{className:"rounded-lg bg-orange-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Ue,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:a("alibabaCodingPlanQuickStart.featureKeyFormat")}],actionLabel:a("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:m,footer:e.jsxs(e.Fragment,{children:[a("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-orange-700 hover:underline dark:text-orange-400",children:["Alibaba Cloud Model Studio",e.jsx(pe,{className:"h-3 w-3"})]})]})})]})]})})}function Js({onCreateClick:s}){const{modelCount:r,isLoading:n}=ge();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${r}+`," models available"]})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Bs({onCreateClick:s}){const{t:r}=B();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:r("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(v,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function it(){const{t:s}=B(),r=Ke(),{data:n,isLoading:m,isError:c,refetch:g}=ms(),a=us(),f=xs(),t=hs(),p=ps(),h=gs(),b=fs(),[w,k]=u.useState(null),[j,S]=u.useState(""),[H,C]=u.useState(!1),[M,d]=u.useState("normal"),[x,l]=u.useState(null),[Q,$]=u.useState(!1),[q,K]=u.useState(null),X=u.useRef(null);js();const y=u.useMemo(()=>n?.profiles||[],[n?.profiles]),I=u.useMemo(()=>y.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[y,j]),O=w?y.find(i=>i.name===w):null,z=i=>{Q&&w!==i?K(i):k(i)},V=i=>{a.mutate(i,{onSuccess:()=>{w===i&&(k(null),$(!1),K(null)),l(null)}})},re=i=>{C(!1),z(i)},Y=i=>{z(i)},ne=(i,E)=>{const P=JSON.stringify(E,null,2)+`
|
|
2
2
|
`,F=new Blob([P],{type:"application/json"}),_=URL.createObjectURL(F),o=document.createElement("a");o.href=_,o.download=i,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(_)},ie=async()=>{try{const i=await f.mutateAsync();if(i.orphans.length===0){T.success("No orphan profile settings found");return}const E=i.orphans.filter(o=>o.validation.valid).length;if(!window.confirm(`Found ${i.orphans.length} orphan settings file(s). Register ${E} valid profile(s) now?`))return;const F=await t.mutateAsync({}),_=F.skipped.length>0?`, skipped ${F.skipped.length}`:"";T.success(`Registered ${F.registered.length} profile(s)${_}`)}catch(i){T.error(i.message)}},oe=async()=>{if(!O)return;const i=window.prompt(`Copy profile "${O.name}" to new profile name:`,`${O.name}-copy`);if(!i)return;const E=i.trim();if(!E){T.error("Destination profile name cannot be empty");return}try{const P=await p.mutateAsync({name:O.name,data:{destination:E}});z(E),P.warnings&&P.warnings.length>0&&T.info(P.warnings.join(`
|
|
3
3
|
`))}catch(P){T.error(P.message)}},le=async()=>{if(O)try{const i=await h.mutateAsync({name:O.name});ne(`${O.name}.ccs-profile.json`,i.bundle),i.redacted?T.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):T.success("Profile export downloaded")}catch(i){T.error(i.message)}},ce=()=>{X.current?.click()},de=async i=>{const E=i.target.files?.[0];if(i.target.value="",!!E)try{const P=await E.text(),F=JSON.parse(P),_=await b.mutateAsync({bundle:F});_.name&&z(_.name),_.warnings&&_.warnings.length>0&&T.info(_.warnings.join(`
|
|
4
4
|
`))}catch(P){T.error(P.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(zs,{onCreateClick:()=>C(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{size:"sm",variant:"outline",onClick:()=>void ie(),disabled:f.isPending||t.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(G,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(v,{size:"sm",variant:"outline",onClick:ce,disabled:b.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Ts,{className:"w-4 h-4"})}),e.jsxs(v,{size:"sm",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:j,onChange:i=>S(i.target.value)})]})]}),e.jsx(ae,{className:"flex-1 min-h-0",children:m?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):c?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(He,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(G,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):I.length===0?e.jsx("div",{className:"p-4 text-center",children:y.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Es,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>{C(!0)},children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:j})})}):e.jsx("div",{className:"p-2 space-y-1",children:I.map(i=>e.jsx(qs,{profile:i,isSelected:w===i.name,onSelect:()=>Y(i.name),onDelete:()=>l(i.name)},i.name))})}),y.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:y.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qe,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:y.filter(i=>i.configured).length})]})]})}),e.jsx(Js,{onCreateClick:()=>{d("openrouter"),C(!0)}}),e.jsx(Bs,{onCreateClick:()=>{d("alibaba-coding-plan"),C(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:O?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void oe(),disabled:p.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(v,{size:"sm",variant:"outline",onClick:()=>void le(),disabled:h.isPending,children:[e.jsx(_s,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx($s,{profileName:O.name,profileTarget:O.target,onDelete:()=>l(O.name),onHasChangesUpdate:$},O.name)]}):e.jsx(Ks,{hasProfiles:y.length>0,profileCount:y.length,onCliproxyClick:()=>{r("/cliproxy/ai-providers")},onOpenRouterClick:()=>{d("openrouter"),C(!0)},onAlibabaCodingPlanClick:()=>{d("alibaba-coding-plan"),C(!0)},onCustomClick:()=>{d("normal"),C(!0)}})})]}),e.jsx("input",{ref:X,type:"file",accept:".json,application/json",className:"hidden",onChange:i=>void de(i)}),e.jsx(Ns,{open:H,onOpenChange:C,onSuccess:re,initialMode:M}),e.jsx(he,{open:!!x,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:x??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>x&&V(x),onCancel:()=>l(null)}),e.jsx(he,{open:!!q,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:w??"",next:q??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{$(!1),k(q),K(null)},onCancel:()=>K(null)})]})}function qs({profile:s,isSelected:r,onSelect:n,onDelete:m}){return e.jsxs("div",{className:D("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",r?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(Qe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(He,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(L,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(J,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),m()},children:e.jsx(De,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{it as ApiPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bp as W,b9 as X,bb as Y,n as Z,I as C,d as c}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as n}from"./react-vendor-CNOkPC89.js";import{a as V,bp as W,b9 as X,bb as Y,n as Z,I as C,d as c}from"./index-Bmd4gqsh.js";import{R as E,v as _,w as ee,m as se,E as K,f as T,l as R,n as z,ae as te,a7 as ae,N as ne,aq as re}from"./icons-BxSzn11s.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function pe(){const{t:s}=V(),{fetchRawConfig:o}=W(),[a,D]=n.useState(null),[j,S]=n.useState(!0),[i,m]=n.useState(!1),[p,r]=n.useState(null),[g,f]=n.useState(null),[w,P]=n.useState(!1),[y,O]=n.useState(!1),[d,N]=n.useState(null),[u,v]=n.useState(null),[$,b]=n.useState(!1),[F,k]=n.useState(!1),h=n.useCallback(async()=>{try{S(!0),r(null);const t=await fetch("/api/settings/auth/tokens/raw");if(!t.ok)throw new Error(s("settingsAuth.failedFetchTokens"));const l=await t.json();D(l)}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{S(!1)}},[s]);n.useEffect(()=>{h(),o()},[h,o]),n.useEffect(()=>{if(g){const t=setTimeout(()=>f(null),3e3);return()=>clearTimeout(t)}},[g]),n.useEffect(()=>{if(p){const t=setTimeout(()=>r(null),5e3);return()=>clearTimeout(t)}},[p]);const I=async()=>{const t=d!==null&&d!==a?.apiKey.value,l=u!==null&&u!==a?.managementSecret.value;if(!(!t&&!l))try{m(!0),r(null);const x={};t&&(x.apiKey=d),l&&(x.managementSecret=u);const A=await fetch("/api/settings/auth/tokens",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok){const Q=await A.json();throw new Error(Q.error||s("settingsAuth.failedSaveTokens"))}f(s("settingsAuth.tokensUpdated")),N(null),v(null),await h(),await o()}catch(x){r(x instanceof Error?x.message:s("settings.unknownError"))}finally{m(!1)}},U=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/regenerate-secret",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedRegenerate"))}f(s("settingsAuth.secretRegenerated")),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},q=async()=>{try{m(!0),r(null);const t=await fetch("/api/settings/auth/tokens/reset",{method:"POST"});if(!t.ok){const l=await t.json();throw new Error(l.error||s("settingsAuth.failedReset"))}f(s("settingsAuth.tokensReset")),N(null),v(null),await h(),await o()}catch(t){r(t instanceof Error?t.message:s("settings.unknownError"))}finally{m(!1)}},B=async()=>{a&&(await navigator.clipboard.writeText(a.apiKey.value),b(!0),setTimeout(()=>b(!1),2e3))},J=async()=>{a&&(await navigator.clipboard.writeText(a.managementSecret.value),k(!0),setTimeout(()=>k(!1),2e3))},L=async()=>{j||i||(r(null),f(null),await Promise.all([h(),o()]))};if(j||!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:s("settings.loading")})]})});const G=d??a.apiKey.value,H=u??a.managementSecret.value,M=d!==null&&d!==a.apiKey.value||u!==null&&u!==a.managementSecret.value;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${p||g?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[p&&e.jsxs(X,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx(Y,{children:p})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(ee,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(Z,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settingsAuth.description")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(se,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.apiKey")}),a.apiKey.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.apiKeyDesc")}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:w?"text":"password",value:G,onChange:t=>N(t.target.value),placeholder:s("settingsAuth.apiKeyPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P(!w),children:w?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:B,disabled:!a.apiKey.value,children:$?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-primary"}),e.jsx("h3",{className:"text-base font-medium",children:s("settingsAuth.managementSecret")}),a.managementSecret.isCustom&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-100 text-amber-700 dark:bg-amber-900/50 dark:text-amber-300",children:s("settingsAuth.custom")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settingsAuth.managementSecretDesc")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(C,{type:y?"text":"password",value:H,onChange:t=>v(t.target.value),placeholder:s("settingsAuth.managementSecretPlaceholder"),disabled:i,className:"pr-20 font-mono text-sm"}),e.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex gap-1",children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>O(!y),children:y?e.jsx(K,{className:"w-4 h-4"}):e.jsx(T,{className:"w-4 h-4"})}),e.jsx(c,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:J,disabled:!a.managementSecret.value,children:F?e.jsx(R,{className:"w-4 h-4 text-green-600"}):e.jsx(z,{className:"w-4 h-4"})})]})]}),e.jsx(c,{variant:"outline",size:"sm",onClick:U,disabled:i,title:s("settingsAuth.generateSecret"),children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:q,disabled:i||!a.apiKey.isCustom&&!a.managementSecret.isCustom,className:"gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),s("settingsAuth.resetDefaults")]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:s("settingsAuth.resetDesc")})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background flex gap-2",children:[e.jsxs(c,{variant:"outline",size:"sm",onClick:L,disabled:j||i,className:"flex-1",children:[e.jsx(E,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),s("settings.refresh")]}),e.jsxs(c,{variant:"default",size:"sm",onClick:I,disabled:!M||i,className:"flex-1",children:[e.jsx(re,{className:`w-4 h-4 mr-2 ${i?"animate-pulse":""}`}),s(i?"settingsAuth.saving":"settingsAuth.save")]})]})]})}export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bp as E,n as k,S as n,C as g,b9 as R,bb as D,B as T,d as C}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r}from"./react-vendor-CNOkPC89.js";import{a as S,bp as E,n as k,S as n,C as g,b9 as R,bb as D,B as T,d as C}from"./index-Bmd4gqsh.js";import{A as O,a as _,b as F,c as I,d as P,e as z,f as L,g as U}from"./alert-dialog-BSHMTH4-.js";import{v as $,w as H,ab as v,u as M,N as Y,R as J}from"./icons-BxSzn11s.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const q=3e3,G=5e3;function ae(){const{t}=S(),{fetchRawConfig:p}=E(),m=r.useRef(null),d=r.useRef(null),[j,y]=r.useState([]),[f,N]=r.useState(!0),[u,b]=r.useState(null),[i,l]=r.useState(null),[c,w]=r.useState(null),[x,h]=r.useState(null),o=r.useCallback(async()=>{m.current?.abort(),m.current=new AbortController;try{N(!0),l(null);const s=await fetch("/api/persist/backups",{signal:m.current.signal});if(!s.ok)throw new Error(t("settingsBackups.failedFetch"));const a=await s.json();y(a.backups||[])}catch(s){if(s instanceof Error&&s.name==="AbortError")return;l(s instanceof Error?s.message:t("settings.unknownError"))}finally{N(!1)}},[t]),A=r.useCallback(async s=>{d.current?.abort(),d.current=new AbortController;try{b(s),l(null);const a=await fetch("/api/persist/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timestamp:s}),signal:d.current.signal});if(!a.ok){const B=await a.json();throw new Error(B.error||t("settingsBackups.failedRestore"))}w(t("settingsBackups.restoreSuccess")),await o(),await p()}catch(a){if(a instanceof Error&&a.name==="AbortError")return;l(a instanceof Error?a.message:t("settings.unknownError"))}finally{b(null)}},[o,p,t]);return r.useEffect(()=>{o()},[o]),r.useEffect(()=>()=>{m.current?.abort(),d.current?.abort()},[]),r.useEffect(()=>{if(c){const s=setTimeout(()=>w(null),q);return()=>clearTimeout(s)}},[c]),r.useEffect(()=>{if(i){const s=setTimeout(()=>l(null),G);return()=>clearTimeout(s)}},[i]),f?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n,{className:"h-6 w-40"}),e.jsx(n,{className:"h-4 w-full"})]}),[1,2,3].map(s=>e.jsx(g,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(n,{className:"h-4 w-32"}),e.jsx(n,{className:"h-3 w-48"})]}),e.jsx(n,{className:"h-8 w-20"})]})},s))]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsx(n,{className:"h-9 w-full"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${i||c?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[i&&e.jsxs(R,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx(D,{children:i})]}),c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(H,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:c})]})]}),e.jsx(k,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(v,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"text-lg font-semibold",children:t("settingsBackups.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.description")})]}),j.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-3 opacity-30 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("settingsBackups.none")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t("settingsBackups.noneHint")})]})}):e.jsx("div",{className:"space-y-2",children:j.map((s,a)=>e.jsx(g,{className:"p-4 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium font-mono",children:s.timestamp}),a===0&&e.jsx(T,{variant:"secondary",className:"text-xs",children:t("settingsBackups.latest")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.date})]})]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>h(s.timestamp),disabled:u!==null,className:"gap-2 shrink-0",children:[e.jsx(Y,{className:`w-4 h-4 ${u===s.timestamp?"animate-spin":""}`}),u===s.timestamp?t("settingsBackups.restoring"):t("settingsBackups.restore")]})]})},s.timestamp))})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{o(),p()},disabled:f||u!==null,className:"w-full",children:[e.jsx(J,{className:`w-4 h-4 mr-2 ${f?"animate-spin":""}`}),t("settings.refresh")]})}),e.jsx(O,{open:!!x,onOpenChange:()=>h(null),children:e.jsxs(_,{children:[e.jsxs(F,{children:[e.jsx(I,{children:t("settingsBackups.restoreConfirmTitle")}),e.jsxs(P,{children:[t("settingsBackups.restoreConfirmPrefix")," ",e.jsx("code",{className:"font-mono bg-muted px-1.5 py-0.5 rounded text-foreground",children:x}),". ",t("settingsBackups.restoreConfirmSuffix")]})]}),e.jsxs(z,{children:[e.jsx(L,{children:t("settingsBackups.cancel")}),e.jsx(U,{onClick:()=>{x&&A(x),h(null)},children:t("settingsBackups.restore")})]})]})})]})}export{ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{bp as F,b9 as y,bb as w,n as L,B as $,L as M,aE as A,I as B,d as P}from"./index-wIy8qzU9.js";import{R as U,v as N,w as O,a8 as V,aq as K,ap as _,aB as q}from"./icons-BxSzn11s.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const R={selected:[],unattended:!1};async function k(t,a){try{const c=await t.json();return typeof c.error=="string"&&c.error.trim().length>0?c.error:a}catch{return a}}function J(){const[t,a]=i.useState(R),[c,o]=i.useState(null),[v,g]=i.useState(!0),[j,x]=i.useState(!1),[C,u]=i.useState(null),[h,b]=i.useState(null),m=i.useCallback(r=>{b(r),window.setTimeout(()=>b(null),1500)},[]),p=i.useCallback(async()=>{try{g(!0),u(null);const r=await fetch("/api/channels");if(!r.ok)throw new Error(await k(r,"Failed to load Official Channels settings"));const n=await r.json();return a(n.config??R),o(n.status??null),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{g(!1)}},[]),S=i.useCallback(async(r,n="Settings saved")=>{try{x(!0),u(null);const s=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await k(s,"Failed to save Official Channels settings"));const d=await s.json();return a(l=>d.config??{...l,...r}),m(n),!0}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[m]),T=i.useCallback(async(r,n)=>{try{x(!0),u(null);const s=await fetch(`/api/channels/${r}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n})});if(!s.ok)throw new Error(await k(s,`Failed to save ${r} token`));return await p()?(m(`${r} token saved`),!0):!1}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[p,m]),E=i.useCallback(async r=>{try{x(!0),u(null);const n=await fetch(`/api/channels/${r}/token`,{method:"DELETE"});if(!n.ok)throw new Error(await k(n,`Failed to clear ${r} token`));return await p()?(m(`${r} token cleared`),!0):!1}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{x(!1)}},[p,m]);return{config:t,status:c,loading:v,saving:j,error:C,success:h,fetchConfig:p,updateConfig:S,saveToken:T,clearToken:E}}const Y={telegram:"",discord:"",imessage:""};function z(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function G(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function H(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function Q(t,a){return t.length===0?"None selected":t.map(c=>a?.find(o=>o.id===c)?.displayName??c).join(", ")}function ne(){const{config:t,status:a,loading:c,saving:o,error:v,success:g,fetchConfig:j,updateConfig:x,saveToken:C,clearToken:u}=J(),{fetchRawConfig:h}=F(),[b,m]=i.useState(Y),p=Q(t.selected,a?.channels);i.useEffect(()=>{j(),h()},[j,h]);const S=async()=>{await Promise.all([j(),h()])},T=async(s,d)=>{const l=d?[...new Set([...t.selected,s])]:t.selected.filter(D=>D!==s);await x({selected:l},d?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([j(),h()])},E=(s,d)=>{m(l=>({...l,[s]:d}))},r=async s=>{await C(s,b[s])&&(m(l=>({...l,[s]:""})),await h())},n=async s=>{await u(s)&&(m(l=>({...l,[s]:""})),await h())};return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||g?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(y,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:v})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(O,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Official Channels"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure official Claude channels here, then run ",e.jsx("code",{children:"ccs"})," normally on a supported native Claude session."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["CCS stores only channel selection in ",e.jsx("code",{children:"config.yaml"}),". Claude keeps the machine-level channel state under ",e.jsx("code",{children:"~/.claude/channels/"}),"."]})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${z(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:p})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:"Machine checks"}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?"Installed":"Missing"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod??"Unknown"})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:"Fastest path"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"1. Turn on the channels you want below."}),e.jsx("p",{children:"2. Save Telegram or Discord bot tokens here if that channel needs one."}),e.jsxs("p",{children:["3. Run ",e.jsx("code",{children:"ccs"})," or a native Claude account profile. CCS adds"," ",e.jsx("code",{children:"--channels"})," for you on supported runs."]}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced notes and scope"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["If you run ",e.jsx("code",{children:"ccs"})," now"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx($,{variant:H(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"You type:"})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:"CCS adds:"})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):"(nothing yet)"]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const d=t.selected.includes(s.id),l=b[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{variant:G(s.setup.state),children:s.setup.label}),e.jsx(A,{checked:d,disabled:o||!!s.unavailableReason&&!d,onCheckedChange:f=>void T(s.id,f)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?`The current CCS process already has ${s.envKey}. Save it here only if you want persistent Claude channel state.`:s.tokenConfigured&&s.processEnvAvailable?`${s.envKey} is saved in Claude channel state, and the current CCS process env also provides it.`:`Save ${s.envKey} in Claude's official channel env file. The dashboard never reads the token value back after save.`}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(B,{type:"password",value:l,onChange:f=>E(s.id,f.target.value),placeholder:s.tokenConfigured?`Configured. Enter a new ${s.envKey} to replace it.`:!s.tokenConfigured&&s.tokenSource==="process_env"?`Using current CCS process env. Enter a new ${s.envKey} to save it for Claude.`:`Paste ${s.envKey}`,disabled:o}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(P,{onClick:()=>void r(s.id),disabled:o||!l.trim(),children:[e.jsx(K,{className:"mr-2 h-4 w-4"}),"Save Token"]}),e.jsxs(P,{variant:"outline",onClick:()=>void n(s.id),disabled:o||!s.tokenConfigured,children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Clear Saved Token"]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Claude-side setup commands"}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(f=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:f},f))})]})]},s.id)})}),e.jsx(y,{children:e.jsxs(w,{children:["CCS injects ",e.jsx("code",{children:"--channels"})," only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."]})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(q,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(M,{className:"text-sm font-medium",children:"Skip permission prompts on launch"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Optional advanced behavior. CCS adds ",e.jsx("code",{children:"--dangerously-skip-permissions"})," ","only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."]})]})]}),e.jsx(A,{checked:t.unattended,disabled:o,onCheckedChange:s=>void(async()=>{await x({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await h()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(P,{variant:"outline",onClick:()=>void S(),disabled:o,children:[e.jsx(U,{className:`mr-2 h-4 w-4 ${o?"animate-spin":""}`}),"Refresh"]})})]})})]})}export{ne as default};
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{bp as F,b9 as y,bb as w,n as L,B as $,L as M,aE as A,I as B,d as P}from"./index-Bmd4gqsh.js";import{R as U,v as N,w as O,a8 as V,aq as K,ap as _,aB as q}from"./icons-BxSzn11s.js";import"./tanstack-DWm6aJ-G.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const R={selected:[],unattended:!1};async function k(t,a){try{const c=await t.json();return typeof c.error=="string"&&c.error.trim().length>0?c.error:a}catch{return a}}function J(){const[t,a]=i.useState(R),[c,o]=i.useState(null),[v,g]=i.useState(!0),[j,x]=i.useState(!1),[C,u]=i.useState(null),[h,b]=i.useState(null),m=i.useCallback(r=>{b(r),window.setTimeout(()=>b(null),1500)},[]),p=i.useCallback(async()=>{try{g(!0),u(null);const r=await fetch("/api/channels");if(!r.ok)throw new Error(await k(r,"Failed to load Official Channels settings"));const n=await r.json();return a(n.config??R),o(n.status??null),!0}catch(r){return u(r instanceof Error?r.message:"Unknown error"),!1}finally{g(!1)}},[]),S=i.useCallback(async(r,n="Settings saved")=>{try{x(!0),u(null);const s=await fetch("/api/channels",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(await k(s,"Failed to save Official Channels settings"));const d=await s.json();return a(l=>d.config??{...l,...r}),m(n),!0}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[m]),T=i.useCallback(async(r,n)=>{try{x(!0),u(null);const s=await fetch(`/api/channels/${r}/token`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:n})});if(!s.ok)throw new Error(await k(s,`Failed to save ${r} token`));return await p()?(m(`${r} token saved`),!0):!1}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[p,m]),E=i.useCallback(async r=>{try{x(!0),u(null);const n=await fetch(`/api/channels/${r}/token`,{method:"DELETE"});if(!n.ok)throw new Error(await k(n,`Failed to clear ${r} token`));return await p()?(m(`${r} token cleared`),!0):!1}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{x(!1)}},[p,m]);return{config:t,status:c,loading:v,saving:j,error:C,success:h,fetchConfig:p,updateConfig:S,saveToken:T,clearToken:E}}const Y={telegram:"",discord:"",imessage:""};function z(t){return t==="ready"?"border-green-200 bg-green-50 text-green-900 dark:border-green-900/60 dark:bg-green-950/40 dark:text-green-100":t==="limited"?"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100":"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900/60 dark:bg-blue-950/40 dark:text-blue-100"}function G(t){return t==="ready"?"default":t==="not_selected"?"secondary":t==="unavailable"?"destructive":"outline"}function H(t){return t==="ready"?"default":t==="partial"?"outline":t==="blocked"?"destructive":"secondary"}function Q(t,a){return t.length===0?"None selected":t.map(c=>a?.find(o=>o.id===c)?.displayName??c).join(", ")}function ne(){const{config:t,status:a,loading:c,saving:o,error:v,success:g,fetchConfig:j,updateConfig:x,saveToken:C,clearToken:u}=J(),{fetchRawConfig:h}=F(),[b,m]=i.useState(Y),p=Q(t.selected,a?.channels);i.useEffect(()=>{j(),h()},[j,h]);const S=async()=>{await Promise.all([j(),h()])},T=async(s,d)=>{const l=d?[...new Set([...t.selected,s])]:t.selected.filter(D=>D!==s);await x({selected:l},d?`${s} selected for auto-enable`:`${s} removed from auto-enable`)&&await Promise.all([j(),h()])},E=(s,d)=>{m(l=>({...l,[s]:d}))},r=async s=>{await C(s,b[s])&&(m(l=>({...l,[s]:""})),await h())},n=async s=>{await u(s)&&(m(l=>({...l,[s]:""})),await h())};return c?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(U,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${v||g?"translate-y-0 opacity-100":"pointer-events-none -translate-y-2 opacity-0"}`,children:[v&&e.jsxs(y,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:v})]}),g&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-green-200 bg-green-50 px-3 py-2 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(O,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:g})]})]}),e.jsx(L,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Official Channels"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Configure official Claude channels here, then run ",e.jsx("code",{children:"ccs"})," normally on a supported native Claude session."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["CCS stores only channel selection in ",e.jsx("code",{children:"config.yaml"}),". Claude keeps the machine-level channel state under ",e.jsx("code",{children:"~/.claude/channels/"}),"."]})]})]}),a&&e.jsxs("div",{className:`rounded-xl border p-4 ${z(a.summary.state)}`,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:a.summary.state==="ready"?"default":"outline",children:a.summary.title}),e.jsx("span",{className:"text-sm font-medium",children:p})]}),e.jsx("p",{className:"text-sm",children:a.summary.message}),e.jsx("p",{className:"text-sm opacity-90",children:a.summary.nextStep})]}),e.jsxs("div",{className:"min-w-[220px] rounded-lg border border-current/10 bg-background/60 p-3 text-sm text-foreground",children:[e.jsx("p",{className:"font-medium",children:"Machine checks"}),e.jsxs("div",{className:"mt-2 space-y-1 text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Bun"}),e.jsx("span",{children:a.bunInstalled?"Installed":"Missing"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude Code"}),e.jsx("span",{children:a.claudeVersion.current?`v${a.claudeVersion.current}`:"Unknown"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{children:"Claude auth"}),e.jsx("span",{children:a.auth.authMethod??"Unknown"})]})]})]})]}),a.summary.blockers.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm",children:a.summary.blockers.map(s=>e.jsx("p",{children:s},s))})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-muted/20 p-4",children:[e.jsx("p",{className:"font-medium",children:"Fastest path"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"1. Turn on the channels you want below."}),e.jsx("p",{children:"2. Save Telegram or Discord bot tokens here if that channel needs one."}),e.jsxs("p",{children:["3. Run ",e.jsx("code",{children:"ccs"})," or a native Claude account profile. CCS adds"," ",e.jsx("code",{children:"--channels"})," for you on supported runs."]}),e.jsx("p",{children:a.supportMessage})]}),e.jsxs("details",{className:"mt-3 rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Advanced notes and scope"}),e.jsxs("div",{className:"mt-3 space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:a.accountStatusCaveat}),e.jsx("p",{children:a.stateScopeMessage})]})]})]}),a&&e.jsxs("div",{className:"rounded-lg border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["If you run ",e.jsx("code",{children:"ccs"})," now"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.launchPreview.detail})]}),e.jsx($,{variant:H(a.launchPreview.state),children:a.launchPreview.title})]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"You type:"})," ",a.launchPreview.command]}),e.jsxs("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:[e.jsx("span",{className:"text-muted-foreground",children:"CCS adds:"})," ",a.launchPreview.appendedArgs.length>0?a.launchPreview.appendedArgs.join(" "):"(nothing yet)"]})]}),a.launchPreview.skippedMessages.length>0&&e.jsx("div",{className:"mt-3 space-y-1 text-sm text-muted-foreground",children:a.launchPreview.skippedMessages.map(s=>e.jsx("p",{children:s},s))})]}),a?.claudeVersion.message&&a.claudeVersion.state!=="supported"&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.claudeVersion.message})]}),a?.auth.message&&a.auth.state!=="eligible"&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.message})]}),a?.auth.orgRequirementMessage&&e.jsxs(y,{children:[e.jsx(N,{className:"h-4 w-4"}),e.jsx(w,{children:a.auth.orgRequirementMessage})]}),e.jsx("div",{className:"space-y-4",children:a?.channels.map(s=>{const d=t.selected.includes(s.id),l=b[s.id];return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(M,{className:"text-base font-medium",children:s.displayName}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.summary}),e.jsx("p",{className:"mt-2 font-mono text-xs text-muted-foreground",children:s.pluginSpec})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($,{variant:G(s.setup.state),children:s.setup.label}),e.jsx(A,{checked:d,disabled:o||!!s.unavailableReason&&!d,onCheckedChange:f=>void T(s.id,f)})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/30 p-4 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:s.setup.detail}),e.jsx("p",{children:s.setup.nextStep})]}),s.requiresToken&&e.jsxs("div",{className:"space-y-3 rounded-lg bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:!s.tokenConfigured&&s.tokenSource==="process_env"?`The current CCS process already has ${s.envKey}. Save it here only if you want persistent Claude channel state.`:s.tokenConfigured&&s.processEnvAvailable?`${s.envKey} is saved in Claude channel state, and the current CCS process env also provides it.`:`Save ${s.envKey} in Claude's official channel env file. The dashboard never reads the token value back after save.`}),s.tokenConfigured&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Saving here writes the same ",e.jsx("code",{children:".env"})," file as"," ",e.jsxs("code",{children:["/",s.id,":configure"]}),", so you do not need to run the configure command again after a successful save."]}),e.jsx(B,{type:"password",value:l,onChange:f=>E(s.id,f.target.value),placeholder:s.tokenConfigured?`Configured. Enter a new ${s.envKey} to replace it.`:!s.tokenConfigured&&s.tokenSource==="process_env"?`Using current CCS process env. Enter a new ${s.envKey} to save it for Claude.`:`Paste ${s.envKey}`,disabled:o}),s.tokenPath&&s.tokenSource!=="process_env"&&e.jsx("div",{className:"text-xs text-muted-foreground break-all",children:s.tokenPath}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(P,{onClick:()=>void r(s.id),disabled:o||!l.trim(),children:[e.jsx(K,{className:"mr-2 h-4 w-4"}),"Save Token"]}),e.jsxs(P,{variant:"outline",onClick:()=>void n(s.id),disabled:o||!s.tokenConfigured,children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Clear Saved Token"]})]})]}),e.jsxs("details",{className:"rounded-lg border bg-background p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Claude-side setup commands"}),e.jsx("div",{className:"mt-3 space-y-2",children:(s.manualSetupCommands??[]).map(f=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:f},f))})]})]},s.id)})}),e.jsx(y,{children:e.jsxs(w,{children:["CCS injects ",e.jsx("code",{children:"--channels"})," only for the current Claude session. Telegram, Discord, and iMessage stop receiving messages when that Claude session exits."]})}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-lg bg-muted/30 p-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(q,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx(M,{className:"text-sm font-medium",children:"Skip permission prompts on launch"}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Optional advanced behavior. CCS adds ",e.jsx("code",{children:"--dangerously-skip-permissions"})," ","only when at least one selected channel is being auto-enabled and you did not already pass a permission flag yourself."]})]})]}),e.jsx(A,{checked:t.unattended,disabled:o,onCheckedChange:s=>void(async()=>{await x({unattended:s},s?"Unattended mode enabled":"Unattended mode disabled")&&await h()})()})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(P,{variant:"outline",onClick:()=>void S(),disabled:o,children:[e.jsx(U,{className:`mr-2 h-4 w-4 ${o?"animate-spin":""}`}),"Refresh"]})})]})})]})}export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,a1 as i,a2 as t}from"./radix-ui-Zb8sVEtn.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-
|
|
1
|
+
import{j as r,a1 as i,a2 as t}from"./radix-ui-Zb8sVEtn.js";import"./react-vendor-CNOkPC89.js";import{c as s}from"./index-Bmd4gqsh.js";import{l as o}from"./icons-BxSzn11s.js";function b({className:e,...a}){return r.jsx(i,{"data-slot":"checkbox",className:s("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(t,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(o,{className:"size-3.5"})})})}export{b as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b6 as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-wIy8qzU9.js";import{u as K,a as J,b as V}from"./tanstack-DWm6aJ-G.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a7 as Pe,a6 as ke,L as U,aq as De,ap as Be,R as Ie,T as oe,ae as Te,a4 as Re}from"./icons-BxSzn11s.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function ce(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function me(s){return s?.state==="applied"}function Me({state:s}){const a=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&")}function o({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(o,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=c||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(c?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(ce(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!c&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!c&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:c?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"Choose which CCS profile the IDE should inherit."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),c?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),c?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!c,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,c?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:c||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:c,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:c,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(o,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(o,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(o,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(o,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(o,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})]}):e.jsx("div",{className:"text-muted-foreground",children:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"Reset both targets"})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(de,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b6 as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-Bmd4gqsh.js";import{u as K,a as J,b as V}from"./tanstack-DWm6aJ-G.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a7 as Pe,a6 as ke,L as U,aq as De,ap as Be,R as Ie,T as oe,ae as Te,a4 as Re}from"./icons-BxSzn11s.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function ce(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function me(s){return s?.state==="applied"}function Me({state:s}){const a=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&")}function o({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(o,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>ce("default")),c=fe||w.length===0,b=!c&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=c||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(c?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(ce(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!c&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!c&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:c?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"Choose which CCS profile the IDE should inherit."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),c?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),c?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!c,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,c?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:c||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:c,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:c,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(o,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(o,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(o,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(o,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(o,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(o,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})]}):e.jsx("div",{className:"text-muted-foreground",children:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})}),c?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"Reset both targets"})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(oe,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(de,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(o,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(o,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(o,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(o,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(o,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};
|
package/dist/ui/assets/{cliproxy-ai-providers-DtW-6cPc.js → cliproxy-ai-providers-C5Kw8KgM.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as H,aC as me,b3 as ue,B as h,af as He,ag as Ke,ah as Be,ai as De,aj as Fe,L as A,I as k,M as Ge,N as Ve,O as Je,aB as ze,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b4 as be,b5 as _e}from"./index-
|
|
1
|
+
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as m,u as qe,h as $e}from"./react-vendor-CNOkPC89.js";import{c as H,aC as me,b3 as ue,B as h,af as He,ag as Ke,ah as Be,ai as De,aj as Fe,L as A,I as k,M as Ge,N as Ve,O as Je,aB as ze,d as f,Y as ae,S as fe,n as ee,Q as ve,R as ye,U as W,V as X,b4 as be,b5 as _e}from"./index-Bmd4gqsh.js";import{P as Qe}from"./proxy-status-widget-IxTsEDhP.js";import{C as We}from"./confirm-dialog-CF5EDIrm.js";import{k as Xe,v as Pe,l as Ae,m as pe,au as se,r as Ye,R as le,Z as Ze,a6 as Se,o as Ie,aG as es,N as ss,ap as ts,aq as rs,V as je,aH as Ue,aI as Le,ae as Me,at as as,aJ as ns}from"./icons-BxSzn11s.js";import{u as is,a as xe,b as he}from"./tanstack-DWm6aJ-G.js";import{t as G}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-BSHMTH4-.js";function ls(t){switch(t){case"ready":return{icon:Ae,text:"Ready",className:"text-green-600"};case"partial":return{icon:Pe,text:"Needs attention",className:"text-amber-600"};default:return{icon:Xe,text:"Not configured",className:"text-muted-foreground"}}}function os({families:t,selectedFamily:s,onSelect:r}){return e.jsx("div",{className:"space-y-1",children:t.map(a=>{const i=a.id===s,o=ls(a.status),d=o.icon;return e.jsx("button",{type:"button",onClick:()=>r(a.id),className:H("w-full cursor-pointer rounded-lg border px-3 py-2.5 text-left transition-colors",i?"border-primary/20 bg-primary/10":"border-transparent hover:bg-muted/70"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{provider:ue(a.id),size:"md"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:a.displayName}),a.entries.length>0&&e.jsx(h,{variant:"secondary",className:"h-4 px-1 text-[10px]",children:a.entries.length})]}),e.jsxs("div",{className:H("mt-0.5 flex items-center gap-1.5 text-xs",o.className),children:[e.jsx(d,{className:"h-3 w-3"}),e.jsx("span",{children:o.text})]})]}),e.jsx(h,{variant:"outline",className:"h-5 px-1.5 text-[9px] uppercase tracking-wide",children:a.authMode})]})},a.id)})})}function ds(t){switch(t){case"gemini-api-key":return{familyName:"Gemini",description:"Store the Gemini key here so CLIProxy can route Gemini requests without creating a separate CCS API Profile.",requiredNow:["Paste the Gemini API key.","Leave Base URL empty unless you use a custom Gemini host."],optionalLater:["Model mappings only when requested names and Gemini names differ.","Headers only when your provider setup requires them."],keyLabel:"Gemini API Key",keyPlaceholder:"AIza...",keyHelper:"This is the only field most Gemini setups need.",baseUrlPlaceholder:"https://generativelanguage.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Gemini endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave this blank unless the upstream Gemini model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"codex-api-key":return{familyName:"Codex",description:"Store the Codex or OpenAI key here so CLIProxy can route Codex requests without duplicating the setup in API Profiles.",requiredNow:["Paste the Codex or OpenAI API key.","Leave Base URL empty unless this route should target another OpenAI-style endpoint."],optionalLater:["Model mappings only when the upstream model ID differs.","Headers only when org or project routing needs them."],keyLabel:"Codex API Key",keyPlaceholder:"sk-...",keyHelper:"This is the only field most Codex setups need.",baseUrlPlaceholder:"https://api.openai.com/v1",baseUrlHelper:"Optional. Leave blank to keep the default Codex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-5",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model name differs.",headersPlaceholder:"OpenAI-Organization: org_..."};case"claude-api-key":return{familyName:"Claude",description:"Store the Anthropic or compatible key here for CLIProxy-managed Claude routing. Save the key first, then add rewrites only if this route needs them.",requiredNow:["Paste the Claude or Anthropic-compatible API key.","Leave Base URL empty unless this route should target another compatible endpoint."],optionalLater:["Model mappings only when the requested and upstream Claude model IDs differ.","Proxy, prefix, exclusions, and headers only for advanced routing cases."],keyLabel:"Claude API Key",keyPlaceholder:"sk-ant-...",keyHelper:"Most Claude routes can start with the key only.",baseUrlPlaceholder:"https://api.anthropic.com",baseUrlHelper:"Optional. Leave blank to keep the default Claude-compatible endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=claude-3-7-sonnet-latest",aliasesHelper:"Format: requested=upstream. Add a mapping only when the upstream model ID should differ.",headersPlaceholder:"X-Project: internal-routing"};case"vertex-api-key":return{familyName:"Vertex",description:"Store the Vertex key here so CLIProxy can route Vertex traffic without creating a separate CCS API Profile.",requiredNow:["Paste the Vertex API key.","Leave Base URL empty unless a regional or gateway endpoint is required."],optionalLater:["Model mappings only when the upstream name differs.","Headers only when the provider expects extra routing context."],keyLabel:"Vertex API Key",keyPlaceholder:"AIza...",keyHelper:"Most Vertex routes only need the key.",baseUrlPlaceholder:"https://vertex.googleapis.com",baseUrlHelper:"Optional. Leave blank to keep the default Vertex endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gemini-2.5-pro",aliasesHelper:"Format: requested=upstream. Leave blank unless the upstream model name differs.",headersPlaceholder:"X-Goog-User-Project: your-project"};case"openai-compatibility":return{familyName:"OpenAI-Compatible Connector",description:"Create a named connector for OpenRouter, Together, or any OpenAI-style endpoint. This page owns the connector setup directly inside CLIProxy.",requiredNow:["Pick a connector name such as openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Model mappings only when requested and upstream model names differ.","Headers only when the connector requires provider-specific auth or routing."],keyLabel:"API Keys",keyPlaceholder:"sk-...",keyHelper:"Add one key per line. Most connectors start with a single key.",connectorPlaceholder:"openrouter",connectorHelper:"This becomes the connector label in the saved entries list.",baseUrlPlaceholder:"https://openrouter.ai/api/v1",baseUrlHelper:"Required for connectors. This is the upstream OpenAI-style endpoint.",aliasesPlaceholder:"claude-sonnet-4-5=gpt-4.1",aliasesHelper:"Format: requested=upstream. Leave blank unless the connector expects a different model ID.",headersPlaceholder:"HTTP-Referer: https://your-app.example"}}}function Ne(t){return t.split(`
|
|
2
2
|
`).map(s=>s.trim()).filter(s=>s.length>0)}function cs(t){return t.split(`
|
|
3
3
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const r=s.includes(":")?":":"=",[a,...i]=s.split(r);return{key:a.trim(),value:i.join(r).trim()}}).filter(s=>s.key.length>0)}function ms(t){return t.split(`
|
|
4
4
|
`).map(s=>s.trim()).filter(s=>s.length>0).map(s=>{const r=s.indexOf("=");return r===-1?{name:s.trim(),alias:""}:{name:s.slice(0,r).trim(),alias:s.slice(r+1).trim()}}).filter(s=>s.name.length>0||s.alias.length>0)}function Y({value:t,onChange:s,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:t,onChange:i=>s(i.target.value),placeholder:r,className:"flex min-h-24 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50"})}function us(t){return(t?.headers||[]).map(s=>`${s.key}: ${s.value}`).join(`
|