@kaitranntt/ccs 7.69.1-dev.2 → 7.69.1-dev.3
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/ui/assets/accounts-DN0lP-yj.js +1 -0
- package/dist/ui/assets/{alert-dialog-QyEXocpn.js → alert-dialog-BA39vaYL.js} +1 -1
- package/dist/ui/assets/api-D2cjf1H4.js +4 -0
- package/dist/ui/assets/{auth-section-BszF77uT.js → auth-section-BNX8_9MJ.js} +1 -1
- package/dist/ui/assets/{backups-section-D6RgaOx1.js → backups-section-Bt0FA5zl.js} +1 -1
- package/dist/ui/assets/channels-FaDUjf3Y.js +1 -0
- package/dist/ui/assets/{checkbox-Dzwkj_Pg.js → checkbox-DHF-UBrH.js} +1 -1
- package/dist/ui/assets/claude-extension-D-skBToQ.js +1 -0
- package/dist/ui/assets/cliproxy-CD7z-_q8.js +3 -0
- package/dist/ui/assets/cliproxy-ai-providers-QSOOqh8F.js +15 -0
- package/dist/ui/assets/cliproxy-control-panel-D9dLU28p.js +1 -0
- package/dist/ui/assets/codex-CHO5_hku.js +27 -0
- package/dist/ui/assets/confirm-dialog-BICDz_zm.js +1 -0
- package/dist/ui/assets/copilot-BnQrRCuJ.js +3 -0
- package/dist/ui/assets/{cursor-BrcDgu6X.js → cursor-CXopLKfC.js} +1 -1
- package/dist/ui/assets/droid-CLFg9ELE.js +2 -0
- package/dist/ui/assets/{globalenv-section-DoX37DqB.js → globalenv-section-NPjCcYBN.js} +1 -1
- package/dist/ui/assets/{health-D_gdcxnc.js → health-B_3JpCrY.js} +1 -1
- package/dist/ui/assets/index-B5Egq7qY.js +1 -0
- package/dist/ui/assets/index-BY2j-o67.js +1 -0
- package/dist/ui/assets/{index-CTGpqIx6.js → index-BcUkpsGj.js} +1 -1
- package/dist/ui/assets/{index-DoVPk3vW.js → index-BgGHTjTd.js} +1 -1
- package/dist/ui/assets/index-DNmWbKbN.js +72 -0
- package/dist/ui/assets/index-DZddoGfE.js +1 -0
- package/dist/ui/assets/logs-Bb1OVYeK.js +1 -0
- package/dist/ui/assets/{masked-input-C2H-Ax0Z.js → masked-input-b4-lEKNq.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-s89zaj3X.js +1 -0
- package/dist/ui/assets/{raw-json-settings-editor-panel-WxTn7-hS.js → raw-json-settings-editor-panel-Dr_BNQwQ.js} +1 -1
- package/dist/ui/assets/{searchable-select-1zOULoec.js → searchable-select-FJPe_YWv.js} +1 -1
- package/dist/ui/assets/{separator-BCfZ54mZ.js → separator-DJ0ku_ak.js} +1 -1
- package/dist/ui/assets/{shared-DlTbnc9n.js → shared-DyQlJnbj.js} +1 -1
- package/dist/ui/assets/{table-Bx2cnkWN.js → table-6Yg65ZZH.js} +1 -1
- package/dist/ui/assets/{updates-SiZKOnUD.js → updates-DSCXb6Au.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/accounts-D9eEaNx9.js +0 -1
- package/dist/ui/assets/api-7vQe0xOg.js +0 -4
- package/dist/ui/assets/channels-B1vgnNJX.js +0 -1
- package/dist/ui/assets/claude-extension-CKO4bJ22.js +0 -1
- package/dist/ui/assets/cliproxy-ai-providers-CmbFYVoR.js +0 -15
- package/dist/ui/assets/cliproxy-control-panel-M8ZfUq3C.js +0 -1
- package/dist/ui/assets/cliproxy-kHd-oC5W.js +0 -3
- package/dist/ui/assets/codex-BJ0RdMuh.js +0 -27
- package/dist/ui/assets/confirm-dialog-BlSaX2gK.js +0 -1
- package/dist/ui/assets/copilot-NJKZQXQ_.js +0 -3
- package/dist/ui/assets/droid-B9u9ZB-a.js +0 -2
- package/dist/ui/assets/index-BNU4Hhe_.js +0 -1
- package/dist/ui/assets/index-DFEMq3KP.js +0 -1
- package/dist/ui/assets/index-DOn6k1jF.js +0 -72
- package/dist/ui/assets/index-h08p9xL5.js +0 -1
- package/dist/ui/assets/logs-DtH4YMt4.js +0 -1
- package/dist/ui/assets/proxy-status-widget-BOrsn86w.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as C,h as ve}from"./react-vendor-CNOkPC89.js";import{u as Ce,a as $,b as F,e as ke,f as ee,g as we}from"./tanstack-CrmUhA7Z.js";import{T as Pe,a as Ae,b as te,c as De,d as _e,e as Te}from"./table-Bx2cnkWN.js";import{Y as O,a as z,ag as de,ah as ue,ai as xe,aj as me,ak as he,L as T,I as V,x as D,aC as Se,d as b,B as P,C as M,b as R,e as Ge,f as Me,g as Re,n as Oe,j as I,k as q,_ as Q}from"./index-DOn6k1jF.js";import{A as ze,a as $e,b as Fe,c as Le,d as Ke,e as He,f as Ie,g as qe}from"./alert-dialog-QyEXocpn.js";import{t as k}from"./notifications-B2HqRBj7.js";import{b0 as W,b1 as E,b2 as pe,aG as ge,_ as fe,b3 as Ee,b4 as Ue,m as Y,as as Be,Q as Qe,a6 as U,T as J,x as Ze,$ as Xe,o as se,U as Ve,a9 as ae,Z as ne}from"./icons-KVCk4_U8.js";import{C as re}from"./checkbox-Dzwkj_Pg.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";function Z(a){return Array.from(a).sort((r,t)=>r.localeCompare(t))}function We(a){const r=new Map;for(const n of a){if(n.context_mode!=="shared")continue;const h=n.context_group||"default",m=r.get(h)??{group:h,sharedCount:0,deeperCount:0,accountNames:[]};m.sharedCount+=1,m.accountNames.push(n.name),n.continuity_mode==="deeper"&&(m.deeperCount+=1),r.set(h,m)}const t=Array.from(r.values()).sort((n,h)=>n.group.localeCompare(h.group)),u=a.map(n=>{if(n.context_mode!=="shared")return{...n,sameGroupPeerCount:0,sameGroupDeeperPeerCount:0};const h=n.context_group||"default",m=r.get(h),y=Math.max((m?.sharedCount??1)-1,0),x=Math.max((m?.deeperCount??0)-(n.continuity_mode==="deeper"?1:0),0);return{...n,sameGroupPeerCount:y,sameGroupDeeperPeerCount:x}}),s=u.filter(n=>n.context_mode==="shared").length,i=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode==="deeper").length,c=u.filter(n=>n.context_inferred).length,p=u.filter(n=>n.context_mode==="shared"&&n.continuity_mode!=="deeper"&&n.continuity_inferred).length;return{accounts:u,sharedCount:s,sharedStandardCount:Math.max(s-i,0),deeperSharedCount:i,isolatedCount:u.length-s,legacyContextCount:c,legacyContinuityCount:p,sharedAloneCount:u.filter(n=>n.context_mode==="shared"&&n.sameGroupPeerCount===0).length,sharedPeerAccountCount:u.filter(n=>n.sameGroupPeerCount>0).length,deeperReadyAccountCount:u.filter(n=>n.continuity_mode==="deeper"&&n.sameGroupDeeperPeerCount>0).length,sharedPeerGroups:Z(t.filter(n=>n.sharedCount>=2).map(n=>n.group)),deeperReadyGroups:Z(t.filter(n=>n.deeperCount>=2).map(n=>n.group)),sharedGroups:Z(t.map(n=>n.group)),groupSummaries:t}}function Ye(){return Ce({queryKey:["accounts"],queryFn:()=>O.accounts.list(),select:a=>{const r=a.accounts.filter(i=>i.type!=="cliproxy"),t=We(r),u=a.accounts.length-r.length,s=t.accounts.some(i=>i.name===a.default)?a.default:null;return{accounts:t.accounts,default:s,cliproxyCount:u,legacyContextCount:t.legacyContextCount,legacyContinuityCount:t.legacyContinuityCount,sharedCount:t.sharedCount,sharedStandardCount:t.sharedStandardCount,deeperSharedCount:t.deeperSharedCount,isolatedCount:t.isolatedCount,sharedAloneCount:t.sharedAloneCount,sharedPeerAccountCount:t.sharedPeerAccountCount,deeperReadyAccountCount:t.deeperReadyAccountCount,sharedPeerGroups:t.sharedPeerGroups,deeperReadyGroups:t.deeperReadyGroups,sharedGroups:t.sharedGroups,groupSummaries:t.groupSummaries,plainCcsLane:a.plain_ccs_lane??null}}})}function Je(){const a=$();return F({mutationFn:r=>O.accounts.setDefault(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Default account set to "${t}"`)},onError:r=>{k.error(r.message)}})}function et(){const a=$();return F({mutationFn:()=>O.accounts.resetDefault(),onSuccess:()=>{a.invalidateQueries({queryKey:["accounts"]}),k.success("Default account reset to CCS")},onError:r=>{k.error(r.message)}})}function tt(){const a=$();return F({mutationFn:r=>O.accounts.delete(r),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]}),k.success(`Account "${t}" deleted`)},onError:r=>{k.error(r.message)}})}function be(){const a=$();return F({mutationFn:({name:r,context_mode:t,context_group:u,continuity_mode:s})=>O.accounts.updateContext(r,{context_mode:t,context_group:u,continuity_mode:s}),onSuccess:(r,t)=>{a.invalidateQueries({queryKey:["accounts"]});const u=t.context_mode==="shared"?t.continuity_mode==="deeper"?`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, deeper continuity)`:`shared (${(t.context_group||"default").trim().toLowerCase().replace(/\s+/g,"-")}, standard)`:"isolated";k.success(`Updated "${t.name}" context to ${u}`)},onError:r=>{k.error(r.message)}})}function st(){const a=$();return F({mutationFn:async r=>{const t=r.filter(i=>i.context_inferred||i.continuity_inferred),s=(await Promise.allSettled(t.map(i=>{const c=i.context_mode==="shared";return O.accounts.updateContext(i.name,{context_mode:c?"shared":"isolated",context_group:c?i.context_group||"default":void 0,continuity_mode:c?i.continuity_mode==="deeper"?"deeper":"standard":void 0})}))).filter(i=>i.status==="rejected").length;return{updatedCount:t.length-s,failedCount:s}},onSuccess:({updatedCount:r,failedCount:t})=>{if(a.invalidateQueries({queryKey:["accounts"]}),t>0&&r>0){k.error(`Confirmed ${r} legacy account${r>1?"s":""}, but ${t} update${t>1?"s":""} failed. Refreshed account state.`);return}if(t>0){k.error(`Failed to confirm ${t} legacy account${t>1?"s":""}. Refreshed account state.`);return}if(r>0){k.success(`Confirmed explicit sync mode for ${r} legacy account${r>1?"s":""}`);return}k.info("No legacy accounts need confirmation")},onError:r=>{a.invalidateQueries({queryKey:["accounts"]}),k.error(r.message)}})}const oe=64,at=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function nt({account:a,groupSummaries:r,plainCcsLane:t,onClose:u}){const{t:s}=z(),i=be(),[c,p]=C.useState(a.context_mode==="shared"?"shared":"isolated"),[n,h]=C.useState(a.context_group||"default"),[m,y]=C.useState(a.continuity_mode==="deeper"?"deeper":"standard"),x=C.useMemo(()=>n.trim().toLowerCase().replace(/\s+/g,"-"),[n]),l=C.useMemo(()=>r.find(g=>g.group===x),[r,x]),N=x.length>0&&x.length<=oe&&at.test(x),o=c==="isolated"||N,d=c==="shared"?Math.max((l?.sharedCount??0)-(a.context_mode==="shared"&&a.context_group===x?1:0),0):0,f=c==="shared"?Math.max((l?.deeperCount??0)-(a.continuity_mode==="deeper"&&a.context_group===x?1:0),0):0,v=t?.account_name===a.name,j=!!t&&!v,S=`ccs auth default ${a.name}`,_=`ccs auth backup ${a.name}`,w=(g,K,G,H)=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(g.key))return;g.preventDefault();const je=G.indexOf(K),ye=g.key==="ArrowLeft"||g.key==="ArrowUp"?-1:1,Ne=(je+ye+G.length)%G.length;H(G[Ne])},L=t?t.kind==="native"?s("continuityOverview.lane.native"):t.kind==="account-default"?s("continuityOverview.lane.accountDefault",{name:t.account_name||""}):t.kind==="account-inherited"?s("continuityOverview.lane.accountInherited",{name:t.account_name||""}):t.kind==="profile-default"?s("continuityOverview.lane.profileDefault",{name:t.profile_name||"default"}):t.label:"",A=()=>{o&&i.mutate({name:a.name,context_mode:c,context_group:c==="shared"?x:void 0,continuity_mode:c==="shared"?m:void 0},{onSuccess:()=>{u()}})},B=g=>{g||u()};return e.jsx(de,{open:!0,onOpenChange:B,children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(xe,{children:[e.jsx(me,{children:s("editAccountContext.title")}),e.jsx(he,{children:s("editAccountContext.description",{name:a.name})})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(T,{className:"text-sm font-semibold",children:s("editAccountContext.syncMode")})}),e.jsxs("div",{className:"flex p-0.5 bg-muted/60 hover:bg-muted/80 transition-colors rounded-xl border border-border/40 w-full",role:"radiogroup","aria-label":s("editAccountContext.syncMode"),children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":c==="isolated",tabIndex:c==="isolated"?0:-1,onClick:()=>p("isolated"),onKeyDown:g=>w(g,c,["isolated","shared"],p),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${c==="isolated"?"bg-background text-blue-600 dark:text-blue-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(W,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.isolatedOption")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":c==="shared",tabIndex:c==="shared"?0:-1,onClick:()=>p("shared"),onKeyDown:g=>w(g,c,["isolated","shared"],p),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${c==="shared"?"bg-background text-emerald-600 dark:text-emerald-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.sharedOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:s(c==="isolated"?"editAccountContext.isolatedModeHint":"editAccountContext.sharedModeHint")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"context-group",children:s("editAccountContext.historySyncGroup")}),e.jsx(V,{id:"context-group",value:n,onChange:g=>h(g.target.value),placeholder:s("editAccountContext.groupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("editAccountContext.groupHint",{max:oe})}),!N&&e.jsx("p",{className:"text-xs text-destructive",children:s("editAccountContext.invalidGroup")})]}),c==="shared"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(T,{className:"text-sm font-semibold",children:s("editAccountContext.continuityDepth")})}),e.jsxs("div",{className:"flex p-0.5 bg-muted/60 hover:bg-muted/80 transition-colors rounded-xl border border-border/40 w-full",role:"radiogroup","aria-label":s("editAccountContext.continuityDepth"),children:[e.jsxs("button",{type:"button",role:"radio","aria-checked":m==="standard",tabIndex:m==="standard"?0:-1,onClick:()=>y("standard"),onKeyDown:g=>w(g,m,["standard","deeper"],y),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${m==="standard"?"bg-background text-emerald-600 dark:text-emerald-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(E,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.standardOption")})]}),e.jsxs("button",{type:"button",role:"radio","aria-checked":m==="deeper",tabIndex:m==="deeper"?0:-1,onClick:()=>y("deeper"),onKeyDown:g=>w(g,m,["standard","deeper"],y),className:`flex-1 flex justify-center items-center gap-2 px-3 py-1.5 rounded-[10px] text-sm font-medium transition-all duration-200 overflow-hidden ${m==="deeper"?"bg-background text-indigo-600 dark:text-indigo-400 shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(pe,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:s("editAccountContext.deeperOption")})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground pt-1 px-1",children:s(m==="standard"?"editAccountContext.standardHint":"editAccountContext.deeperHint")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("editAccountContext.credentialsIsolated")}),j&&e.jsx("div",{className:"rounded-[14px] border border-amber-200 bg-amber-50/50 p-4 text-xs shadow-sm dark:border-amber-900/40 dark:bg-amber-900/10",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium text-foreground",children:s("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:s("continuityOverview.plainLaneDescription",{lane:L||"plain ccs",name:a.name})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs -r"}),e.jsx(D,{value:"ccs -r",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth backup default"}),e.jsx(D,{value:"ccs auth backup default",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:_}),e.jsx(D,{value:_,size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:S}),e.jsx(D,{value:S,size:"icon"})]})]})]})}),e.jsx("div",{className:`rounded-[14px] border p-4 text-xs shadow-sm transition-colors ${c==="isolated"?"bg-blue-50/50 border-blue-200 dark:bg-blue-900/10 dark:border-blue-800/40":"bg-muted/40 border-border/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[c==="isolated"?e.jsx(ge,{className:"h-4 w-4 text-blue-500 mt-0.5 shrink-0"}):e.jsx(fe,{className:"h-4 w-4 text-muted-foreground mt-0.5 shrink-0"}),e.jsxs("div",{className:"space-y-1.5 flex-1 text-muted-foreground leading-relaxed",children:[c==="isolated"?e.jsx("p",{className:"text-foreground font-medium selection:bg-blue-200",children:s("editAccountContext.isolatedImplication")}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-foreground font-medium",children:s("editAccountContext.sameGroupRule",{group:x})})," ",d>0?s("editAccountContext.sameGroupPeerCount",{count:d}):s("editAccountContext.noSameGroupPeer")]}),m==="deeper"&&e.jsx("p",{children:f>0?s("editAccountContext.deeperReady",{count:f}):e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:s("editAccountContext.deeperNeedsPeers")})})]}),e.jsx("p",{className:`pt-1.5 text-[11px] ${c==="isolated"?"text-blue-700/70 dark:text-blue-300/60":"text-muted-foreground/70"}`,children:s("editAccountContext.resumeOriginalWarning")})]})]})})]}),e.jsxs(Se,{children:[e.jsx(b,{variant:"outline",onClick:u,disabled:i.isPending,children:s("editAccountContext.cancel")}),e.jsx(b,{onClick:A,disabled:!o||i.isPending,children:i.isPending?s("editAccountContext.saving"):s("editAccountContext.save")})]})]})})}function ce({data:a,defaultAccount:r,groupSummaries:t,plainCcsLane:u}){const{t:s}=z(),i=Je(),c=tt(),p=et(),n=be(),[h,m]=C.useState(null),[y,x]=C.useState(null),l=[{accessorKey:"name",header:s("accountsTable.name"),size:200,cell:({row:o})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:o.original.name}),o.original.name===r&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded border border-primary/20",children:s("accountsTable.defaultBadge")})]})},{accessorKey:"type",header:s("accountsTable.type"),size:100,cell:({row:o})=>e.jsx("span",{className:"capitalize text-muted-foreground",children:o.original.type||"oauth"})},{accessorKey:"created",header:s("accountsTable.created"),size:150,cell:({row:o})=>{const d=new Date(o.original.created);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{accessorKey:"last_used",header:s("accountsTable.lastUsed"),size:150,cell:({row:o})=>{if(!o.original.last_used)return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});const d=new Date(o.original.last_used);return e.jsx("span",{className:"text-muted-foreground",children:d.toLocaleDateString()})}},{id:"context",header:s("accountsTable.historySync"),size:170,cell:({row:o})=>{if(o.original.type==="cliproxy")return e.jsx("span",{className:"text-muted-foreground/50",children:"-"});if((o.original.context_mode||"isolated")==="shared"){const f=o.original.context_group||"default",v=o.original.continuity_mode==="deeper";return e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(P,{variant:"outline",className:`font-mono text-[10px] uppercase px-1.5 py-0 border ${v?"text-indigo-700 border-indigo-300/60 bg-indigo-50/50 dark:text-indigo-300 dark:border-indigo-900/40 dark:bg-indigo-900/20":"text-emerald-700 border-emerald-300/60 bg-emerald-50/50 dark:text-emerald-300 dark:border-emerald-900/40 dark:bg-emerald-900/20"}`,children:s(v?"accountsTable.badges.deeper":"accountsTable.badges.shared")}),e.jsx("span",{className:"text-xs font-semibold text-foreground/80",children:f})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:o.original.sameGroupPeerCount>0?s("accountsTable.sameGroupPeerCount",{count:o.original.sameGroupPeerCount}):s("accountsTable.noSameGroupPeer")})]})}return o.original.context_inferred?e.jsxs("div",{className:"flex flex-col items-start gap-1",children:[e.jsx(P,{variant:"outline",className:"text-amber-700 border-amber-300/60 bg-amber-50/50 dark:text-amber-400 dark:border-amber-900/40 dark:bg-amber-900/20 font-mono text-[10px] uppercase px-1.5 py-0",children:s("accountsTable.badges.legacy")}),e.jsx("p",{className:"text-[10px] text-amber-700/80 dark:text-amber-400/80 whitespace-nowrap",children:s("accountsTable.legacyReview")})]}):e.jsx("div",{className:"flex flex-col items-start gap-1.5",children:e.jsx(P,{variant:"secondary",className:"font-mono text-[10px] uppercase px-1.5 py-0 text-muted-foreground bg-muted/60 border-transparent shadow-none",children:s("accountsTable.badges.isolated")})})}},{id:"actions",header:s("accountsTable.actions"),size:220,cell:({row:o})=>{const d=o.original.name===r,f=i.isPending||c.isPending||n.isPending,v=o.original.type==="cliproxy",j=o.original.context_inferred||o.original.continuity_inferred;return e.jsxs("div",{className:"flex items-center gap-1",children:[!v&&e.jsxs(b,{variant:"outline",size:"sm",className:"h-8 px-2",disabled:f,onClick:()=>x(o.original),title:s("accountsTable.syncTitle"),children:[e.jsx(Ee,{className:"w-3.5 h-3.5 mr-1"}),s("accountsTable.sync")]}),!v&&j&&e.jsxs(b,{variant:"ghost",size:"sm",className:"h-8 px-2 text-amber-700 hover:text-amber-700 hover:bg-amber-500/10 dark:text-amber-400 dark:hover:text-amber-400",disabled:f,onClick:()=>n.mutate({name:o.original.name,context_mode:o.original.context_mode==="shared"?"shared":"isolated",context_group:o.original.context_mode==="shared"?o.original.context_group||"default":void 0,continuity_mode:o.original.context_mode==="shared"?o.original.continuity_mode==="deeper"?"deeper":"standard":void 0}),title:s("accountsTable.confirmLegacyTitle"),children:[e.jsx(Ue,{className:"w-3 h-3 mr-1"}),s("accountsTable.confirm")]}),e.jsxs(b,{variant:d?"secondary":"default",size:"sm",className:"h-8 px-2",disabled:d||f,onClick:()=>i.mutate(o.original.name),children:[e.jsx(Y,{className:`w-3 h-3 mr-1 ${d?"opacity-50":""}`}),s(d?"accountsTable.active":"accountsTable.setDefault")]}),e.jsx(b,{variant:"ghost",size:"sm",className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",disabled:d||f,onClick:()=>m(o.original.name),title:s(d?"accountsTable.cannotDeleteDefault":"accountsTable.deleteAccount"),children:e.jsx(Be,{className:"w-4 h-4"})})]})}}],N=ke({data:a,columns:l,getCoreRowModel:we()});return a.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:s("accountsTable.noAccounts")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"border rounded-md",children:e.jsxs(Pe,{children:[e.jsx(Ae,{children:N.getHeaderGroups().map(o=>e.jsx(te,{children:o.headers.map(d=>{const f={name:"w-[200px]",type:"w-[100px]",created:"w-[150px]",last_used:"w-[150px]",context:"w-[170px]",actions:"w-[290px]"}[d.id]||"w-auto";return e.jsx(De,{className:f,children:d.isPlaceholder?null:ee(d.column.columnDef.header,d.getContext())},d.id)})},o.id))}),e.jsx(_e,{children:N.getRowModel().rows.map(o=>e.jsx(te,{children:o.getVisibleCells().map(d=>e.jsx(Te,{children:ee(d.column.columnDef.cell,d.getContext())},d.id))},o.id))})]})}),r&&e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),s("accountsTable.resetToDefault")]})})]}),y&&e.jsx(nt,{account:y,groupSummaries:t,plainCcsLane:u,onClose:()=>x(null)}),e.jsx(ze,{open:!!h,onOpenChange:o=>!o&&m(null),children:e.jsxs($e,{children:[e.jsxs(Fe,{children:[e.jsx(Le,{children:s("accountsTable.deleteDialogTitle")}),e.jsx(Ke,{children:s("accountsTable.deleteDialogDesc",{name:h??""})})]}),e.jsxs(He,{children:[e.jsx(Ie,{children:s("accountsTable.cancel")}),e.jsx(qe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{h&&(c.mutate(h),m(null))},children:s("accountsTable.delete")})]})]})})]})}const X=({titleKey:a,descKey:r})=>{const{t}=z();return e.jsxs(Ge,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"icon","aria-label":t(a),className:"h-5 w-5 rounded-full hover:bg-muted text-muted-foreground/70 transition-colors",children:e.jsx(fe,{className:"h-3 w-3"})})}),e.jsxs(Re,{className:"w-72 p-4 rounded-xl shadow-lg border-border/50 text-sm",side:"top",align:"center",children:[e.jsx("p",{className:"font-semibold tracking-tight",children:t(a)}),e.jsx("p",{className:"mt-1.5 text-muted-foreground leading-relaxed",children:t(r)})]})]})};function ie({totalAccounts:a,primaryAccountName:r,isolatedCount:t,sharedStandardCount:u,deeperSharedCount:s,sharedAloneCount:i,sharedPeerAccountCount:c,deeperReadyAccountCount:p,sharedPeerGroups:n,deeperReadyGroups:h,legacyTargetCount:m,cliproxyCount:y,plainCcsLane:x}){const{t:l}=z(),N=x?x.kind==="native"?l("continuityOverview.lane.native"):x.kind==="account-default"?l("continuityOverview.lane.accountDefault",{name:x.account_name||""}):x.kind==="account-inherited"?l("continuityOverview.lane.accountInherited",{name:x.account_name||""}):x.kind==="profile-default"?l("continuityOverview.lane.profileDefault",{name:x.profile_name||"default"}):x.label:"",o=a<2?"single":n.length===0?t===a?"isolated":"shared-alone":h.length===0?"shared-standard":t>0||i>0||p<c||h.length<n.length?"partial":"ready",d=h[0]||n[0]||"default",f=h.length>0&&(t>0||u>0||n.length>h.length),j={ready:e.jsx(Ze,{className:"h-6 w-6 text-emerald-600 dark:text-emerald-400"}),"shared-standard":e.jsx(E,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"}),single:e.jsx(ge,{className:"h-6 w-6 text-stone-400"}),isolated:e.jsx(W,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"}),"shared-alone":e.jsx(J,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"}),partial:e.jsx(J,{className:"h-6 w-6 text-amber-600 dark:text-amber-400"})}[o],S=!!r&&x?.account_name===r,_=a>0&&!!x&&(!r||!S),w=a>1&&o!=="ready";return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(M,{className:"flex flex-col justify-between overflow-hidden relative group p-0 border-border bg-card shadow-sm hover:shadow-md transition-shadow duration-300",children:e.jsxs(R,{className:"p-6 flex flex-col h-full bg-gradient-to-br from-card to-muted/20 space-y-4",children:[e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-4",children:[e.jsx("div",{className:"rounded-2xl bg-background p-3 shadow-sm ring-1 ring-border/50 self-start shrink-0",children:j}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold tracking-tight",children:l(`continuityReadiness.messages.${o}.title`,{group:d})}),e.jsx(P,{variant:o==="ready"?"default":"secondary",className:"rounded-full px-2.5 py-0.5 font-medium shadow-sm",children:l(`continuityReadiness.state.${o}`)})]}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg leading-relaxed",children:l(`continuityReadiness.messages.${o}.description`,{group:d,count:i})})]})]})}),e.jsxs("div",{className:"mt-auto pt-4 flex flex-wrap items-center gap-2",children:[y>0&&e.jsx(P,{variant:"outline",className:"text-blue-700 bg-blue-50/50 border-blue-200/60 dark:border-blue-900/40 dark:bg-blue-900/20 dark:text-blue-300",children:l("historySyncLearningMap.cliproxyManaged",{count:y})}),m>0&&e.jsx(P,{variant:"outline",className:"text-amber-700 bg-amber-50/50 border-amber-200/60 dark:border-amber-900/40 dark:bg-amber-900/20 dark:text-amber-300",children:l("historySyncLearningMap.legacyConfirmation",{count:m})}),n.length>0&&h.length===0&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.recommendBadge",{group:d})}),f&&e.jsx(P,{variant:"secondary",className:"font-mono text-[11px] px-2 bg-muted/50 text-muted-foreground border-transparent",children:l("continuityOverview.partialBadge",{group:d})})]})]})}),(_||w)&&e.jsx(M,{className:"border-dashed",children:e.jsxs(R,{className:"p-5 space-y-4",children:[_&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityOverview.plainLaneTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("continuityOverview.plainLaneDescription",{lane:N||"plain ccs"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs -r"}),e.jsx(D,{value:"ccs -r",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth backup default"}),e.jsx(D,{value:"ccs auth backup default",size:"icon"})]}),r?e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:`ccs auth default ${r}`}),e.jsx(D,{value:`ccs auth default ${r}`,size:"icon"})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:l("continuityOverview.setDefaultHint")})]})]}),w&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:l("continuityReadiness.stepsTitle")}),e.jsxs("ol",{className:"space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:l("continuityReadiness.steps.syncBoth")}),e.jsx("li",{children:l("continuityReadiness.steps.sameGroup",{group:d})}),e.jsx("li",{children:l("continuityReadiness.steps.enableDeeper")}),e.jsx("li",{children:l("continuityReadiness.steps.resumeOriginal")})]})]})]})}),e.jsxs("div",{className:"flex flex-col md:flex-row items-center gap-3",children:[e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-blue-300/40 bg-blue-50/50 dark:border-blue-900/30 dark:bg-blue-900/10 shadow-sm transition-colors hover:bg-blue-100/40 dark:hover:bg-blue-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-4 w-4 text-blue-700/80 dark:text-blue-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-blue-900 dark:text-blue-200",children:l("historySyncLearningMap.isolated")}),e.jsx(X,{titleKey:"accountsPage.isolated",descKey:"accountsPage.isolatedDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-blue-900 dark:text-blue-200",children:t})]}),e.jsx(U,{className:"hidden md:block h-4 w-4 text-muted-foreground/40 shrink-0"}),e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-emerald-300/40 bg-emerald-50/50 dark:border-emerald-900/30 dark:bg-emerald-900/10 shadow-sm transition-colors hover:bg-emerald-100/40 dark:hover:bg-emerald-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-4 w-4 text-emerald-700/80 dark:text-emerald-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-emerald-900 dark:text-emerald-200",children:l("historySyncLearningMap.shared")}),e.jsx(X,{titleKey:"accountsPage.sharedStandard",descKey:"accountsPage.sharedStandardDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-emerald-900 dark:text-emerald-200",children:u})]}),e.jsx(U,{className:"hidden md:block h-4 w-4 text-muted-foreground/40 shrink-0"}),e.jsxs("div",{className:"flex-1 w-full flex items-center justify-between p-3.5 rounded-xl border border-indigo-300/40 bg-indigo-50/50 dark:border-indigo-900/30 dark:bg-indigo-900/10 shadow-sm transition-colors hover:bg-indigo-100/40 dark:hover:bg-indigo-900/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{className:"h-4 w-4 text-indigo-700/80 dark:text-indigo-400/80"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-indigo-900 dark:text-indigo-200",children:l("historySyncLearningMap.deeper")}),e.jsx(X,{titleKey:"accountsPage.sharedDeeper",descKey:"accountsPage.sharedDeeperDesc"})]}),e.jsx("span",{className:"text-lg font-mono font-bold text-indigo-900 dark:text-indigo-200",children:s})]})]})]})}const le=64;function rt({open:a,onClose:r}){const{t}=z(),[u,s]=C.useState(""),[i,c]=C.useState(!1),[p,n]=C.useState(""),[h,m]=C.useState(!1),[y,x]=C.useState(!1),l=/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(u),N=p.trim().toLowerCase().replace(/\s+/g,"-"),o=N.length===0||N.length<=le&&/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(N),d=u&&l?[`ccs auth create ${u}`,i?N.length>0?`--context-group ${N}`:"--share-context":"",i&&h?"--deeper-continuity":""].filter(Boolean).join(" "):t("createAuthProfileDialog.commandFallback"),f=async()=>{!l||i&&!o||(await navigator.clipboard.writeText(d),x(!0),setTimeout(()=>x(!1),2e3))},v=()=>{s(""),c(!1),n(""),m(!1),x(!1),r()};return e.jsx(de,{open:a,onOpenChange:j=>!j&&v(),children:e.jsxs(ue,{className:"sm:max-w-md",children:[e.jsxs(xe,{children:[e.jsx(me,{children:t("createAuthProfileDialog.title")}),e.jsx(he,{children:t("createAuthProfileDialog.description")})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"profile-name",children:t("createAuthProfileDialog.profileName")}),e.jsx(V,{id:"profile-name",value:u,onChange:j=>s(j.target.value),placeholder:t("createAuthProfileDialog.profileNamePlaceholder"),autoComplete:"off"}),u&&!l&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidProfileName")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{id:"share-context",checked:i,onCheckedChange:j=>c(j===!0)}),e.jsx(T,{htmlFor:"share-context",className:"cursor-pointer",children:t("createAuthProfileDialog.enableSharedHistory")})]}),i&&e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx(T,{htmlFor:"context-group",children:t("createAuthProfileDialog.historySyncGroupOptional")}),e.jsx(V,{id:"context-group",value:p,onChange:j=>n(j.target.value),placeholder:t("createAuthProfileDialog.historySyncGroupPlaceholder"),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.historySyncGroupHint")}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(re,{id:"deeper-continuity",checked:h,onCheckedChange:j=>m(j===!0)}),e.jsx(T,{htmlFor:"deeper-continuity",className:"cursor-pointer",children:t("createAuthProfileDialog.deeperContinuity")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("createAuthProfileDialog.deeperContinuityHint")}),p.trim().length>0&&!o&&e.jsx("p",{className:"text-xs text-destructive",children:t("createAuthProfileDialog.invalidContextGroup",{max:le})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:t("createAuthProfileDialog.command")}),e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md font-mono text-sm",children:[e.jsx(Xe,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("code",{className:"flex-1 break-all",children:d}),e.jsx(b,{variant:"ghost",size:"sm",className:"shrink-0 h-8 px-2",onClick:f,disabled:!l||i&&!o,children:y?e.jsx(Y,{className:"w-4 h-4 text-green-500"}):e.jsx(se,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:t("createAuthProfileDialog.afterRunPrefix")}),e.jsxs("ol",{className:"list-decimal list-inside pl-2 space-y-0.5",children:[e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep1")}),e.jsx("li",{children:t("createAuthProfileDialog.afterRunStep2")})]}),e.jsx("p",{className:"pt-1",children:t("createAuthProfileDialog.poolingHint")})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(b,{variant:"ghost",onClick:v,children:t("createAuthProfileDialog.close")}),e.jsx(b,{onClick:f,disabled:!l||i&&!o,children:y?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copied")]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4 mr-2"}),t("createAuthProfileDialog.copyCommand")]})})]})]})]})})}function bt(){const{t:a}=z(),r=ve(),{data:t,isLoading:u}=Ye(),s=st(),[i,c]=C.useState(!1),p=t?.accounts||[],n=t?.cliproxyCount||0,h=t?.legacyContextCount||0,m=t?.legacyContinuityCount||0,y=t?.sharedCount||0,x=t?.sharedStandardCount||0,l=t?.deeperSharedCount||0,N=t?.isolatedCount||0,o=t?.sharedAloneCount||0,d=t?.sharedPeerAccountCount||0,f=t?.deeperReadyAccountCount||0,v=t?.sharedPeerGroups||[],j=t?.deeperReadyGroups||[],S=t?.sharedGroups||[],_=t?.groupSummaries||[],w=t?.plainCcsLane||null,L=p.filter(H=>H.context_inferred||H.continuity_inferred),A=L.length,B=A>0,g=()=>r("/cliproxy?provider=claude"),K=()=>r("/cliproxy?provider=claude&action=auth"),G=()=>s.mutate(L);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden h-full min-h-0 lg:flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/20 shrink-0",children:[e.jsxs("div",{className:"p-4 border-b bg-background space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:a("accountsPage.title")})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.manageSuffix")]})]}),e.jsx(Oe,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:a("accountsPage.primaryActions")}),e.jsxs(b,{size:"sm",className:"w-full justify-start",onClick:()=>c(!0),children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),a("accountsPage.createAccount")]}),e.jsxs(b,{size:"sm",className:"w-full justify-start",onClick:K,children:[e.jsx(ne,{className:"w-4 h-4 mr-2"}),a("accountsPage.authClaudeInPool")]}),e.jsxs(b,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:g,children:[a("accountsPage.openClaudePoolSettings"),e.jsx(U,{className:"w-4 h-4 ml-auto"})]})]}),B?e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:a("accountsPage.migrationFollowup")}),e.jsxs("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/10 p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(J,{className:"h-4 w-4 mt-0.5 text-amber-700 dark:text-amber-400 shrink-0"}),e.jsxs("div",{className:"space-y-1 text-xs",children:[h>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContextPending",{count:h})}),m>0&&e.jsx("p",{className:"text-amber-800 dark:text-amber-300",children:a("accountsPage.legacyContinuityPending",{count:m})})]})]}),e.jsx(b,{variant:"secondary",size:"sm",className:"w-full justify-start",onClick:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}):e.jsx("div",{className:"rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground",children:a("accountsPage.noLegacyFollowup")}),e.jsxs(M,{children:[e.jsxs(I,{className:"pb-2",children:[e.jsx(q,{className:"text-sm",children:a("accountsPage.quickCommands")}),e.jsx(Q,{children:a("accountsPage.quickCommandsDesc")})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs auth create work --context-group sprint-a --deeper-continuity"}),e.jsx(D,{value:"ccs auth create work --context-group sprint-a --deeper-continuity",size:"icon"})]}),e.jsxs("div",{className:"rounded-md border bg-background px-2 py-2 font-mono text-[11px] flex items-start gap-2",children:[e.jsx("span",{className:"flex-1 break-all",children:"ccs cliproxy auth claude"}),e.jsx(D,{value:"ccs cliproxy auth claude",size:"icon"})]})]})]})]})})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background",children:[e.jsxs("div",{className:"px-5 py-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",children:a("accountsPage.workspaceBadge")}),e.jsx(P,{variant:"secondary",children:a("accountsPage.historySyncBadge")})]}),e.jsx("h2",{className:"mt-2 text-xl font-semibold tracking-tight",children:a("accountsPage.authAccounts")}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[a("accountsPage.tableScopePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.tableScopeMiddle"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:a("accountsTable.sync")}),a("accountsPage.tableScopeSuffix")]})]}),e.jsxs("div",{className:"flex-1 min-h-0 p-5 space-y-4 overflow-y-auto",children:[e.jsx(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{className:"flex flex-col",children:[e.jsxs(I,{className:"pb-3",children:[e.jsx(q,{className:"text-lg",children:a("accountsPage.accountMatrix")}),e.jsx(Q,{children:a("accountsPage.sharedTotalDesc",{count:y})})]}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-4 lg:hidden",children:[e.jsxs(M,{children:[e.jsxs(I,{children:[e.jsx(q,{className:"text-lg",children:a("accountsPage.title")}),e.jsxs(Q,{children:[a("accountsPage.managePrefix"),e.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5",children:"ccs auth"}),a("accountsPage.mobileManageSuffix")]})]}),e.jsxs(R,{className:"space-y-2",children:[e.jsxs(b,{className:"w-full",onClick:()=>c(!0),children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),a("accountsPage.createAccount")]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:g,children:[a("accountsPage.openCliProxyClaudePool"),e.jsx(U,{className:"w-4 h-4 ml-2"})]}),e.jsxs(b,{variant:"outline",className:"w-full",onClick:K,children:[a("accountsPage.authClaudeInPool"),e.jsx(ne,{className:"w-4 h-4 ml-2"})]}),e.jsx(b,{variant:"outline",className:"w-full",onClick:G,disabled:s.isPending||A===0,children:s.isPending?a("accountsPage.confirmingLegacy"):a("accountsPage.confirmLegacy",{count:A})})]})]}),e.jsx(ie,{totalAccounts:p.length,primaryAccountName:p.length===1?p[0]?.name:null,isolatedCount:N,sharedStandardCount:x,deeperSharedCount:l,sharedAloneCount:o,sharedPeerAccountCount:d,deeperReadyAccountCount:f,sharedGroups:S,sharedPeerGroups:v,deeperReadyGroups:j,legacyTargetCount:A,cliproxyCount:n,plainCcsLane:w}),e.jsxs(M,{children:[e.jsx(I,{className:"pb-3",children:e.jsx(q,{className:"text-base",children:a("accountsPage.accountMatrix")})}),e.jsx(R,{children:u?e.jsx("div",{className:"text-muted-foreground",children:a("accountsPage.loadingAccounts")}):e.jsx(ce,{data:p,defaultAccount:t?.default??null,groupSummaries:_,plainCcsLane:w})})]})]}),e.jsx(rt,{open:i,onClose:()=>c(!1)})]})}export{bt as AccountsPage};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as u,h as qe}from"./react-vendor-CNOkPC89.js";import{B as M,c as Q,T as Ve,p as We,q as Ye,r as Ge,s as Xe,t as Ze,v as es,w as xe,d as w,a as B,n as ne,L as D,I as H,x as J,y as Ee,z as ss,A as ts,D as as,E as rs,S as ve,F as ee,G as pe,H as Re,J as ns,K as is,M as Ae,N as _e,O as Le,Q as ls,R as os,U as be,V as we,W as se,X as cs,Y as De,Z as Ne,C as Me,b as Qe,j as ds,k as ms,_ as us,$ as xs,a0 as hs,a1 as ps,a2 as gs,a3 as fs,a4 as js,a5 as Ns,a6 as vs,a7 as bs}from"./index-DOn6k1jF.js";import{a as ws,u as ge,b as Ce}from"./tanstack-CrmUhA7Z.js";import{C as fe}from"./confirm-dialog-BlSaX2gK.js";import{t as E}from"./notifications-B2HqRBj7.js";import{L as te,R as X,as as Fe,at as Cs,a9 as ae,_ as ys,au as Ie,aa as re,C as He,av as ks,a7 as Ss,aw as Ps,p as je,X as Os,ax as Ts,Z as Ue,ay as $e,n as ye,az as ke,aA as Es,aB as he,a6 as Rs,ad as As,aC as _s,w as ze,aD as Ls,x as Ke,o as Ds,aE as Ms}from"./icons-KVCk4_U8.js";import{M as Je}from"./masked-input-C2H-Ax0Z.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-QyEXocpn.js";function Qs({className:s,showTooltip:r=!0}){const a=e.jsxs(M,{variant:"outline",className:Q("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(Ve,{children:[e.jsx(We,{asChild:!0,children:a}),e.jsx(Ye,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):a}function Se(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(a=>a.test(s))}function Be(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Fs(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 Is(s,r){const a={...s};return r.opus?a.ANTHROPIC_DEFAULT_OPUS_MODEL=r.opus:delete a.ANTHROPIC_DEFAULT_OPUS_MODEL,r.sonnet?a.ANTHROPIC_DEFAULT_SONNET_MODEL=r.sonnet:delete a.ANTHROPIC_DEFAULT_SONNET_MODEL,r.haiku?a.ANTHROPIC_DEFAULT_HAIKU_MODEL=r.haiku:delete a.ANTHROPIC_DEFAULT_HAIKU_MODEL,a}function Hs({profileName:s,target:r,data:a,settings:d,isLoading:c,isSaving:g,isTargetSaving:h,hasChanges:f,isRawJsonValid:t,onTargetChange:p,onRefresh:x,onDelete:v,onSave:C}){const y=g||h,j=c||y;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}),a?.path&&e.jsx(M,{variant:"outline",className:"text-xs",children:a.path.replace(/^.*\//,"")}),Be(d)&&e.jsx(Qs,{className:"ml-1"})]}),a&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(a.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(Ge,{value:r,onValueChange:k=>{j||p(k)},disabled:j,children:[e.jsx(Xe,{className:"h-7 w-[170px] text-xs",disabled:j,children:e.jsx(Ze,{})}),e.jsxs(es,{children:[e.jsx(xe,{value:"claude",children:"Claude Code"}),e.jsx(xe,{value:"droid",children:"Factory Droid"}),e.jsx(xe,{value:"codex",children:"Codex CLI"})]})]}),h&&e.jsx(te,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:x,disabled:j,children:e.jsx(X,{className:`w-4 h-4 ${c?"animate-spin":""}`})}),v&&e.jsx(w,{variant:"ghost",size:"sm",onClick:v,disabled:y,children:e.jsx(Fe,{className:"w-4 h-4 text-destructive"})}),e.jsx(w,{size:"sm",onClick:C,disabled:y||!f||!t,children:g?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cs,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Us({currentSettings:s,newEnvKey:r,newEnvValue:a,onNewEnvKeyChange:d,onNewEnvValueChange:c,onEnvValueChange:g,onAddEnvVar:h}){const{t:f}=B();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{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(D,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[t,Se(t)&&e.jsx(M,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),Se(t)?e.jsx(Je,{value:p,onChange:x=>g(t,x.target.value),className:"font-mono text-sm h-8"}):e.jsx(H,{value:p,onChange:x=>g(t,x.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(D,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:f("envEditor.keyPlaceholder"),value:r,onChange:t=>d(t.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(H,{placeholder:f("envEditor.valuePlaceholder"),value:a,onChange:t=>c(t.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:t=>t.key==="Enter"&&r.trim()&&h()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:h,disabled:!r.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]})}function $s({profileName:s,target:r,data:a}){const{t:d}=B(),c=r==="droid";return e.jsx(ne,{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(ys,{className:"w-4 h-4"}),d("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:a&&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:d("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:a.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:d("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:a.path}),e.jsx(J,{value:a.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:d("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(a.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:d("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:d("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(D,{className:"text-xs text-muted-foreground",children:d("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(D,{className:"text-xs text-muted-foreground",children:d(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(D,{className:"text-xs text-muted-foreground",children:d(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(D,{className:"text-xs text-muted-foreground",children:d("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 zs({value:s,onChange:r,placeholder:a="Search models...",className:d}){const[c,g]=u.useState(""),[h,f]=u.useState(null),{models:t,isLoading:p,isError:x,isFetching:v}=Ee(),C=ss(),y=u.useMemo(()=>ts(t,c,{category:h??void 0}),[t,c,h]),j=u.useMemo(()=>as(t,2),[t]),k=!c.trim()&&!h,R=u.useMemo(()=>{const n={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};y.forEach(m=>{n[m.category].push(m)});for(const m of Object.keys(n))n[m]=rs(n[m]);return n},[y]),N=u.useCallback(()=>{C()},[C]),S=t.find(n=>n.id===s);return p&&t.length===0?e.jsxs("div",{className:Q("space-y-2",d),children:[e.jsx(ve,{className:"h-10 w-full"}),e.jsx(ve,{className:"h-32 w-full"})]}):e.jsxs("div",{className:Q("space-y-2 w-full min-w-0 overflow-hidden",d),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ie,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(H,{value:c,onChange:n=>g(n.target.value),placeholder:a,className:"pl-9"})]}),e.jsx(w,{variant:"outline",size:"icon",onClick:N,disabled:v,title:"Refresh models",children:v?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(M,{variant:h===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",t.length,")"]}),Object.keys(ee).map(n=>{const m=R[n].length;return m===0?null:e.jsxs(M,{variant:h===n?"default":"outline",className:"cursor-pointer",onClick:()=>f(n),children:[ee[n]," (",m,")"]},n)})]}),S&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:S.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[pe(S.pricing)," |"," ",Re(S.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:x?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(w,{variant:"link",onClick:N,children:"Retry"})]}):y.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:[k&&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(re,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:j.map(n=>e.jsx(Pe,{model:n,isSelected:n.id===s,onClick:()=>r(n.id),showAge:!0},n.id))})]}),Object.keys(ee).map(n=>{const m=R[n];return m.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:ee[n]}),e.jsx("div",{className:"space-y-1",children:m.map(o=>e.jsx(Pe,{model:o,isSelected:o.id===s,onClick:()=>r(o.id)},o.id))})]},n)})]})})]})}function Pe({model:s,isSelected:r,onClick:a,showAge:d=!1}){return e.jsxs("button",{type:"button",onClick:a,className:Q("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:Q("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:[d&&s.created&&e.jsx(M,{variant:"outline",className:Q("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:ns(s.created)}),s.isFree?e.jsx(M,{variant:"secondary",className:Q("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(M,{variant:"outline",className:Q("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:pe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:pe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Re(s.context_length)})]})]})}function Ks({selectedModel:s,value:r,onChange:a,className:d}){const{t:c}=B(),{models:g}=Ee(),h=u.useMemo(()=>s?is(s,g):{},[s,g]),f=()=>{a(h)},t=(x,v)=>{a({...r,[x]:v||void 0})},p=s&&Object.keys(h).length>0;return e.jsxs(Ae,{className:Q("group",d),children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(He,{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(Le,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:c("modelTierMapping.description")}),p&&e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(ks,{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(D,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(H,{id:"tier-opus",value:r.opus??"",onChange:x=>t("opus",x.target.value),placeholder:c("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(H,{id:"tier-sonnet",value:r.sonnet??"",onChange:x=>t("sonnet",x.target.value),placeholder:c("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(D,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(H,{id:"tier-haiku",value:r.haiku??"",onChange:x=>t("haiku",x.target.value),placeholder:c("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:c("modelTierMapping.footer")})]})]})}function Js({profileName:s,target:r,data:a,currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p,onEnvBulkChange:x}){const v=Be(d),C=d?.env,y=u.useMemo(()=>Fs(C??{}),[C]),j=C??{},k=o=>{if(x){const U={...j,ANTHROPIC_MODEL:o,ANTHROPIC_DEFAULT_OPUS_MODEL:o,ANTHROPIC_DEFAULT_SONNET_MODEL:o,ANTHROPIC_DEFAULT_HAIKU_MODEL:o};x(U)}else t("ANTHROPIC_MODEL",o),t("ANTHROPIC_DEFAULT_OPUS_MODEL",o),t("ANTHROPIC_DEFAULT_SONNET_MODEL",o),t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o);E.success(se.t("commonToast.appliedModelAllTiers"),{duration:2e3})},R=o=>{if(x){const U=Is(j,o);x(U)}else o.opus!==void 0&&t("ANTHROPIC_DEFAULT_OPUS_MODEL",o.opus||""),o.sonnet!==void 0&&t("ANTHROPIC_DEFAULT_SONNET_MODEL",o.sonnet||""),o.haiku!==void 0&&t("ANTHROPIC_DEFAULT_HAIKU_MODEL",o.haiku||"")},[N,S]=u.useState(!1),n=new Set(["ANTHROPIC_AUTH_TOKEN"]),m=Object.entries(j).filter(([o])=>!n.has(o));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(ls,{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(os,{className:"w-full",children:[e.jsx(be,{value:"env",className:"flex-1",children:v?"Configuration":"Environment Variables"}),e.jsx(be,{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(we,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:v?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(D,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(zs,{value:j.ANTHROPIC_MODEL,onChange:k,placeholder:"Search OpenRouter models..."})]}),e.jsx(Ks,{selectedModel:j.ANTHROPIC_MODEL,value:y,onChange:R}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"text-sm font-medium",children:"API Key"}),e.jsx(Je,{value:j.ANTHROPIC_AUTH_TOKEN||"",onChange:o=>t("ANTHROPIC_AUTH_TOKEN",o.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"})]})]}),m.length>0&&e.jsxs(Ae,{open:N,onOpenChange:S,children:[e.jsxs(_e,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(He,{className:Q("h-4 w-4 transition-transform",N&&"rotate-90")}),e.jsx(Ss,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",m.length,")"]})]}),e.jsx(Le,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:m.map(([o,U])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(D,{className:"text-xs text-muted-foreground",children:o}),e.jsx(H,{value:U,onChange:$=>t(o,$.target.value),className:"font-mono text-xs h-8"})]},o))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(D,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(H,{placeholder:"VARIABLE_NAME",value:c,onChange:o=>h(o.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(H,{placeholder:"value",value:g,onChange:o=>f(o.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:o=>o.key==="Enter"&&c.trim()&&p()}),e.jsx(w,{variant:"outline",size:"sm",className:"h-8",onClick:p,disabled:!c.trim(),children:e.jsx(ae,{className:"w-4 h-4"})})]})]})]}):e.jsx(Us,{currentSettings:d,newEnvKey:c,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:t,onAddEnvVar:p})}),e.jsx(we,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx($s,{profileName:s,target:r,data:a})})]})]})})}function Bs({profileName:s,profileTarget:r,onDelete:a,onHasChangesUpdate:d}){const[c,g]=u.useState({}),[h,f]=u.useState(!1),[t,p]=u.useState(null),[x,v]=u.useState(""),[C,y]=u.useState(""),j=ws(),{data:k,isLoading:R,isError:N,refetch:S}=ge({queryKey:["settings",s],queryFn:async()=>{const l=await fetch(`/api/settings/${s}/raw`);if(!l.ok)throw new Error(`Failed to load settings: ${l.status}`);return l.json()}}),n=k?.settings,m=u.useMemo(()=>{if(t!==null)try{return JSON.parse(t)}catch{}if(n)return{...n,env:{...n.env,...c}}},[n,c,t]),o=u.useMemo(()=>t!==null?t:n?JSON.stringify(n,null,2):"",[t,n]),U=u.useCallback(l=>{p(l)},[]),$=u.useCallback(l=>{const b={...m??{}},_=b.ccs_image&&typeof b.ccs_image=="object"?{...b.ccs_image}:{};l?_.native_read=!0:delete _.native_read,Object.keys(_).length>0?b.ccs_image=_:delete b.ccs_image,p(JSON.stringify(b,null,2))},[m]),q=(l,b)=>{const _={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2))},K=l=>{const b={...m?.env||{},...l};g(_=>({..._,...l})),p(JSON.stringify({...m,env:b},null,2))},Z=()=>{if(!x.trim())return;const l=x.trim(),b=C,_={...m?.env||{},[l]:b};g(Y=>({...Y,[l]:b})),p(JSON.stringify({...m,env:_},null,2)),v(""),y("")},P=u.useMemo(()=>{try{return JSON.parse(o),!0}catch{return!1}},[o]),F=u.useMemo(()=>t!==null?t!==JSON.stringify(n,null,2):Object.keys(c).length>0,[t,c,n]),T=u.useDeferredValue(o),z=u.useMemo(()=>{if(!F||!P)return null;try{return JSON.parse(T)}catch{return null}},[F,P,T]),{data:V,isFetching:ie,isError:W,isPlaceholderData:le}=ge({queryKey:["settings",s,"image-analysis-status-preview",T],enabled:z!==null,placeholderData:l=>l,queryFn:async()=>{const l=await fetch(`/api/settings/${s}/image-analysis-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:z})});if(!l.ok)throw new Error(`Failed to preview image-analysis status: ${l.status}`);return l.json()}}),oe=F&&P&&!W?V?.imageAnalysisStatus??k?.imageAnalysisStatus:k?.imageAnalysisStatus,ce=F&&P&&!W&&V?.imageAnalysisStatus?"editor":"saved",de=F?P?W?"saved":ie&&(!V?.imageAnalysisStatus||le)?"refreshing":"preview":"invalid":"saved",me=m?.ccs_image?.native_read===!0,ue=u.useMemo(()=>{const l=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],b=m?.env||{};return l.filter(_=>!b[_]?.trim())},[m]);u.useEffect(()=>{d?.(F)},[F,d]);const i=Ce({mutationFn:async()=>{let l;try{l=JSON.parse(o)}catch{l={...k?.settings,env:{...k?.settings?.env,...c}}}const b=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:l,expectedMtime:k?.mtime})});if(b.status===409)throw new Error("CONFLICT");if(!b.ok)throw new Error("Failed to save");return b.json()},onSuccess:()=>{j.invalidateQueries({queryKey:["settings",s]}),j.invalidateQueries({queryKey:["profiles"]}),g({}),p(null),E.success(se.t("commonToast.settingsSaved"))},onError:l=>{l.message==="CONFLICT"?f(!0):E.error(l.message)}}),A=Ce({mutationFn:async l=>(await De.profiles.update(s,{target:l}),l),onSuccess:()=>{j.invalidateQueries({queryKey:["profiles"]}),E.success(se.t("commonToast.defaultTargetUpdated"))},onError:(l,b)=>{const _=b==="droid"?"Factory Droid":b==="codex"?"Codex CLI":"Claude Code",Y=l.message.trim()?`: ${l.message}`:"";E.error(se.t("commonToast.failedUpdateDefaultTarget",{target:_,suffix:Y}))}}),O=r||"claude",I=i.isPending||A.isPending,L=async l=>{f(!1),l?(await S(),i.mutate()):(g({}),p(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Hs,{profileName:s,target:O,data:k,settings:m,isLoading:R,isSaving:i.isPending,isTargetSaving:A.isPending,hasChanges:F,isRawJsonValid:P,onTargetChange:l=>{I||l!==O&&A.mutate(l)},onRefresh:()=>{I||S()},onDelete:a,onSave:()=>{I||i.mutate()}}),R?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(te,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):N?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(w,{variant:"outline",size:"sm",onClick:()=>S(),children:[e.jsx(X,{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(Js,{profileName:s,target:O,data:k,currentSettings:m,newEnvKey:x,newEnvValue:C,onNewEnvKeyChange:v,onNewEnvValueChange:y,onEnvValueChange:q,onEnvBulkChange:K,onAddEnvVar:Z})}),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(cs,{rawJsonContent:o,isRawJsonValid:P,rawJsonEdits:t,settings:n,profileTarget:O,imageAnalysisStatus:oe,imageAnalysisStatusSource:ce,imageAnalysisStatusPreviewState:de,nativeReadPreferenceOverride:me,onToggleNativeRead:$,onChange:U,missingRequiredFields:ue})]})]}),e.jsx(fe,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>L(!0),onCancel:()=>L(!1)})]},s)}const Oe="ccs:openrouter-banner-dismissed";function qs({onCreateClick:s}){const[r,a]=u.useState(!0),{modelCount:d,isLoading:c}=Ne();u.useEffect(()=>{const h=localStorage.getItem(Oe)==="true";a(h)},[]);const g=()=>{localStorage.setItem(Oe,"true"),a(!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(re,{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+":`${d}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(w,{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(je,{className:"w-3 h-3"})]}),e.jsxs(w,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Os,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Vs(){return ge({queryKey:["profiles","local-runtime-readiness"],queryFn:()=>De.profiles.getLocalRuntimeReadiness(),staleTime:15e3,refetchOnWindowFocus:!1})}function G({badge:s,badgeClassName:r,className:a,title:d,description:c,visual:g,highlights:h,actionLabel:f,actionClassName:t,onAction:p,footer:x}){return e.jsxs(Me,{className:Q("flex h-full flex-col border shadow-sm",a),children:[e.jsxs(ds,{className:"space-y-3 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[g,e.jsx(M,{variant:"secondary",className:r,children:s})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ms,{className:"text-base",children:d}),e.jsx(us,{className:"text-sm leading-6",children:c})]})]}),e.jsxs(Qe,{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:h.map(v=>e.jsxs("div",{className:"flex items-center gap-2",children:[v.icon,e.jsx("span",{children:v.label})]},v.label))}),e.jsxs(w,{onClick:p,className:t,children:[f,e.jsx(Rs,{className:"ml-2 h-4 w-4"})]}),x?e.jsx("div",{className:"text-xs text-muted-foreground",children:x}):null]})]})}function Te(s,r,a){return s?s.status==="ready"?{badge:a("openrouterQuickStart.localRuntimeReadyBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",actionLabel:a("openrouterQuickStart.localRuntimeUseAction",{label:r}),description:a("openrouterQuickStart.localRuntimeReadyDescription"),footer:a("openrouterQuickStart.localRuntimeReadyFooter",{endpoint:s.endpoint})}:s.status==="missing-model"?{badge:a("openrouterQuickStart.localRuntimeNeedsModelBadge"),badgeClassName:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/20 dark:text-amber-200",actionLabel:a("openrouterQuickStart.localRuntimeFinishAction",{label:r}),description:a("openrouterQuickStart.localRuntimeNeedsModelDescription"),footer:a("openrouterQuickStart.localRuntimeMissingModelFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeOfflineBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeOfflineDescription"),footer:a("openrouterQuickStart.localRuntimeOfflineFooter",{command:s.commandHint})}:{badge:a("openrouterQuickStart.localRuntimeCheckingBadge"),badgeClassName:"bg-muted text-muted-foreground",actionLabel:a("openrouterQuickStart.localRuntimeSetupAction",{label:r}),description:a("openrouterQuickStart.localRuntimeCheckingDescription"),footer:a("openrouterQuickStart.localRuntimeCheckingFooter")}}function Ws({hasProfiles:s,profileCount:r,onOpenRouterClick:a,onAlibabaCodingPlanClick:d,onCliproxyClick:c,onCustomClick:g,onOllamaClick:h,onLlamacppClick:f}){const{t}=B(),{modelCount:p,isLoading:x}=Ne(),{data:v}=Vs(),C=x?"300+":`${p}+`,y=s?t("openrouterQuickStart.profileSummaryCount",{count:r}):t("openrouterQuickStart.profileSummaryEmpty"),j=t(s?"openrouterQuickStart.summaryExistingTitle":"openrouterQuickStart.summaryEmptyTitle"),k=s?t("openrouterQuickStart.summaryExistingDescription",{count:r}):t("openrouterQuickStart.summaryEmptyDescription"),R=v?.runtimes.find(m=>m.id==="ollama"),N=v?.runtimes.find(m=>m.id==="llamacpp"),S=Te(R,t("openrouterQuickStart.localOllamaLabel"),t),n=Te(N,t("openrouterQuickStart.localLlamacppLabel"),t);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-5",children:[e.jsx(Me,{className:"border-dashed bg-background/90 shadow-sm",children:e.jsxs(Qe,{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(M,{variant:"secondary",children:y}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeDefaultQuality")}),e.jsx(M,{variant:"outline",children:t("openrouterQuickStart.summaryBadgeLocalLane")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-semibold",children:j}),e.jsx("p",{className:"max-w-3xl text-sm leading-6 text-muted-foreground",children:k})]})]}),e.jsx(w,{variant:"outline",onClick:g,className:"shrink-0",children:t("openrouterQuickStart.createCustomProfile")})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ts,{className:"h-4 w-4 text-accent"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.qualityLanesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(G,{badge:t("openrouterQuickStart.recommended"),title:t("openrouterQuickStart.title"),description:t("openrouterQuickStart.description",{modelCountLabel:C}),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(Ue,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.featureOneApi")},{icon:e.jsx(re,{className:"h-3.5 w-3.5 text-accent"}),label:t("openrouterQuickStart.qualityLaneHighlightDefaultQuality")}],actionLabel:t("openrouterQuickStart.createOpenRouterProfile"),actionClassName:"w-full bg-accent text-white hover:bg-accent/90",onAction:a,footer:e.jsxs(e.Fragment,{children:[t("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(je,{className:"h-3 w-3"})]})]})}),e.jsx(G,{badge:t("alibabaCodingPlanQuickStart.recommended"),badgeClassName:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",title:t("alibabaCodingPlanQuickStart.title"),description:t("openrouterQuickStart.alibabaLaneDescription"),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($e,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("alibabaCodingPlanQuickStart.featureEndpoint")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-orange-600"}),label:t("openrouterQuickStart.alibabaLaneHighlightQuality")}],actionLabel:t("alibabaCodingPlanQuickStart.createAlibabaProfile"),actionClassName:"w-full bg-orange-600 text-white hover:bg-orange-600/90",onAction:d,footer:e.jsxs(e.Fragment,{children:[t("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(je,{className:"h-3 w-3"})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-emerald-600"}),e.jsx("h3",{className:"text-sm font-semibold uppercase tracking-[0.12em] text-foreground/70",children:t("openrouterQuickStart.localRuntimesTitle")})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(G,{badge:S.badge,badgeClassName:S.badgeClassName,title:t("openrouterQuickStart.localOllamaTitle"),description:S.description,visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx("img",{src:"/icons/ollama.svg",alt:"Ollama",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(Es,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.localOllamaHighlight")},{icon:e.jsx(re,{className:"h-3.5 w-3.5 text-emerald-600"}),label:R?.detectedModelCount&&R.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:R.detectedModelCount}):t("openrouterQuickStart.localNoModelsDetected")}],actionLabel:S.actionLabel,actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:h,footer:e.jsx("span",{children:S.footer})}),e.jsx(G,{badge:n.badge,badgeClassName:n.badgeClassName,title:t("openrouterQuickStart.localLlamacppTitle"),description:n.description,visual:e.jsx("div",{className:"rounded-lg bg-sky-500/10 p-2",children:e.jsx("img",{src:"/assets/providers/llama-cpp.svg",alt:"llama.cpp",className:"h-5 w-5"})}),highlights:[{icon:e.jsx(he,{className:"h-3.5 w-3.5 text-sky-600"}),label:t("openrouterQuickStart.localLlamacppHighlight")},{icon:e.jsx(ke,{className:"h-3.5 w-3.5 text-sky-600"}),label:N?.detectedModelCount&&N.detectedModelCount>0?t("openrouterQuickStart.localDetectedModels",{count:N.detectedModelCount}):t("openrouterQuickStart.localWaitingServer")}],actionLabel:n.actionLabel,actionClassName:"w-full bg-sky-600 text-white hover:bg-sky-600/90",onAction:f,footer:e.jsx("span",{children:n.footer})})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:e.jsx(G,{badge:t("openrouterQuickStart.runtimeProviderBadge"),badgeClassName:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",title:t("openrouterQuickStart.runtimeProviderTitle"),description:t("openrouterQuickStart.runtimeProviderManagedDescription"),visual:e.jsx("div",{className:"rounded-lg bg-emerald-500/10 p-2",children:e.jsx(he,{className:"h-5 w-5 text-emerald-700 dark:text-emerald-300"})}),highlights:[{icon:e.jsx(he,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureConnectors")},{icon:e.jsx(ye,{className:"h-3.5 w-3.5 text-emerald-600"}),label:t("openrouterQuickStart.runtimeProviderFeatureSecrets")}],actionLabel:t("openrouterQuickStart.runtimeProviderTitle"),actionClassName:"w-full bg-emerald-600 text-white hover:bg-emerald-600/90",onAction:c,footer:e.jsx("span",{children:t("openrouterQuickStart.runtimeProviderFooter")})})})]})})}function Ys({onCreateClick:s}){const{modelCount:r,isLoading:a}=Ne();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:[a?"300+":`${r}+`," models available"]})]}),e.jsxs(w,{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(Ue,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Gs({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(w,{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($e,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:r("alibabaCodingPlanPromo.add")})]})]})})}function mt(){const{t:s}=B(),r=qe(),{data:a,isLoading:d,isError:c,refetch:g}=xs(),h=hs(),f=ps(),t=gs(),p=fs(),x=js(),v=Ns(),[C,y]=u.useState(null),[j,k]=u.useState(""),[R,N]=u.useState(!1),[S,n]=u.useState("normal"),[m,o]=u.useState(null),[U,$]=u.useState(!1),[q,K]=u.useState(null),Z=u.useRef(null);vs();const P=u.useMemo(()=>a?.profiles||[],[a?.profiles]),F=u.useMemo(()=>P.filter(i=>i.name.toLowerCase().includes(j.toLowerCase())),[P,j]),T=C?P.find(i=>i.name===C):null,z=i=>{U&&C!==i?K(i):y(i)},V=i=>{h.mutate(i,{onSuccess:()=>{C===i&&(y(null),$(!1),K(null)),o(null)}})},ie=i=>{N(!1),z(i)},W=i=>{z(i)},le=(i,A)=>{const O=JSON.stringify(A,null,2)+`
|
|
2
|
-
`,I=new Blob([O],{type:"application/json"}),L=URL.createObjectURL(I),l=document.createElement("a");l.href=L,l.download=i,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(L)},oe=async()=>{try{const i=await f.mutateAsync();if(i.orphans.length===0){E.success("No orphan profile settings found");return}const A=i.orphans.filter(l=>l.validation.valid).length;if(!window.confirm(`Found ${i.orphans.length} orphan settings file(s). Register ${A} valid profile(s) now?`))return;const I=await t.mutateAsync({}),L=I.skipped.length>0?`, skipped ${I.skipped.length}`:"";E.success(`Registered ${I.registered.length} profile(s)${L}`)}catch(i){E.error(i.message)}},ce=async()=>{if(!T)return;const i=window.prompt(`Copy profile "${T.name}" to new profile name:`,`${T.name}-copy`);if(!i)return;const A=i.trim();if(!A){E.error("Destination profile name cannot be empty");return}try{const O=await p.mutateAsync({name:T.name,data:{destination:A}});z(A),O.warnings&&O.warnings.length>0&&E.info(O.warnings.join(`
|
|
3
|
-
`))}catch(O){E.error(O.message)}},de=async()=>{if(T)try{const i=await x.mutateAsync({name:T.name});le(`${T.name}.ccs-profile.json`,i.bundle),i.redacted?E.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):E.success("Profile export downloaded")}catch(i){E.error(i.message)}},me=()=>{Z.current?.click()},ue=async i=>{const A=i.target.files?.[0];if(i.target.value="",!!A)try{const O=await A.text(),I=JSON.parse(O),L=await v.mutateAsync({bundle:I});L.name&&z(L.name),L.warnings&&L.warnings.length>0&&E.info(L.warnings.join(`
|
|
4
|
-
`))}catch(O){E.error(O.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx(qs,{onCreateClick:()=>N(!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:"mb-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"w-5 h-5 text-primary"}),e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"font-semibold",children:"Profiles"})})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{size:"sm",variant:"outline",onClick:()=>void oe(),disabled:f.isPending||t.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(w,{size:"sm",variant:"outline",onClick:me,disabled:v.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(_s,{className:"w-4 h-4"})}),e.jsxs(w,{size:"sm",onClick:()=>{N(!0)},children:[e.jsx(ae,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsx("p",{className:"mb-3 text-xs leading-4 text-muted-foreground",children:"Premium APIs, local runtimes, custom endpoints"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ie,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(H,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:j,onChange:i=>k(i.target.value)})]})]}),e.jsx(ne,{className:"flex-1 min-h-0",children:d?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(ze,{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(w,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):F.length===0?e.jsx("div",{className:"p-4 text-center",children:P.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ls,{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(w,{size:"sm",variant:"outline",onClick:()=>{N(!0)},children:[e.jsx(ae,{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:F.map(i=>e.jsx(Xs,{profile:i,isSelected:C===i.name,onSelect:()=>W(i.name),onDelete:()=>o(i.name)},i.name))})}),P.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:P.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ke,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:P.filter(i=>i.configured).length})]})]})}),e.jsx(Ys,{onCreateClick:()=>{n("openrouter"),N(!0)}}),e.jsx(Gs,{onCreateClick:()=>{n("alibaba-coding-plan"),N(!0)}})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col min-w-0 overflow-hidden",children:T?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(w,{size:"sm",variant:"outline",onClick:()=>void ce(),disabled:p.isPending,children:[e.jsx(Ds,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>void de(),disabled:x.isPending,children:[e.jsx(Ms,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(Bs,{profileName:T.name,profileTarget:T.target,onDelete:()=>o(T.name),onHasChangesUpdate:$},T.name)]}):e.jsx(Ws,{hasProfiles:P.length>0,profileCount:P.length,onCliproxyClick:()=>{r("/cliproxy/ai-providers")},onOpenRouterClick:()=>{n("openrouter"),N(!0)},onAlibabaCodingPlanClick:()=>{n("alibaba-coding-plan"),N(!0)},onOllamaClick:()=>{n("ollama"),N(!0)},onLlamacppClick:()=>{n("llamacpp"),N(!0)},onCustomClick:()=>{n("normal"),N(!0)}})})]}),e.jsx("input",{ref:Z,type:"file",accept:".json,application/json",className:"hidden",onChange:i=>void ue(i)}),e.jsx(bs,{open:R,onOpenChange:N,onSuccess:ie,initialMode:S}),e.jsx(fe,{open:!!m,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:m??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>m&&V(m),onCancel:()=>o(null)}),e.jsx(fe,{open:!!q,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:C??"",next:q??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{$(!1),y(q),K(null)},onCancel:()=>K(null)})]})}function Xs({profile:s,isSelected:r,onSelect:a,onDelete:d}){return e.jsxs("div",{className:Q("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:a,children:[s.configured?e.jsx(Ke,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(ze,{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(M,{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(w,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>{c.stopPropagation(),d()},children:e.jsx(Fe,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{mt as ApiPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{bv as F,be as y,bg as w,n as L,B as $,L as M,aF as A,I as O,d as P}from"./index-DOn6k1jF.js";import{R as U,w as N,x as B,ab as V,at as K,as as _,aG as q}from"./icons-KVCk4_U8.js";import"./tanstack-CrmUhA7Z.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 G(){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)},[]),f=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 f()?(m(`${r} token saved`),!0):!1}catch(s){return u(s instanceof Error?s.message:"Unknown error"),!1}finally{x(!1)}},[f,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 f()?(m(`${r} token cleared`),!0):!1}catch(n){return u(n instanceof Error?n.message:"Unknown error"),!1}finally{x(!1)}},[f,m]);return{config:t,status:c,loading:v,saving:j,error:C,success:h,fetchConfig:f,updateConfig:S,saveToken:T,clearToken:E}}const J={telegram:"",discord:"",imessage:""};function Y(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 z(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}=G(),{fetchRawConfig:h}=F(),[b,m]=i.useState(J),f=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(B,{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 ${Y(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:f})]}),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:z(s.setup.state),children:s.setup.label}),e.jsx(A,{checked:d,disabled:o||!!s.unavailableReason&&!d,onCheckedChange:p=>void T(s.id,p)})]})]}),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(O,{type:"password",value:l,onChange:p=>E(s.id,p.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(p=>e.jsx("div",{className:"rounded-md bg-muted px-3 py-2 font-mono text-sm break-all",children:p},p))})]})]},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 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{bb as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as h,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 xe}from"./index-DOn6k1jF.js";import{u as K,a as J,b as V}from"./tanstack-CrmUhA7Z.js";import{t as E}from"./notifications-B2HqRBj7.js";import{aa as Pe,a9 as ke,L as U,at as De,as as Be,R as Ie,T as oe,ah as Te,a7 as Re}from"./icons-KVCk4_U8.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:xe("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(h,{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 he({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:x,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(h,{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:x,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:xe("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(),x=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=x.isPending&&x.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=x.isPending&&x.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"){x.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(h,{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(h,{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(h,{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(he,{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(he,{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(h,{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(h,{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:x.isPending,children:[x.isPending&&x.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(h,{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(h,{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(h,{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(h,{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(h,{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(h,{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,15 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as c,u as Be,h as Fe}from"./react-vendor-CNOkPC89.js";import{c as D,aD as ue,b4 as pe,B as h,b5 as Me,ag as Ge,ah as Ve,ai as ze,aj as Je,ak as _e,L as M,I as P,M as Qe,N as We,O as Xe,aC as Ye,d as f,b6 as xe,b7 as Ue,Y as ne,S as ye,n as se,Q as be,R as je,U as X,V as Y,b8 as Ne,b9 as Ze,ba as es}from"./index-DOn6k1jF.js";import{P as ss}from"./proxy-status-widget-BOrsn86w.js";import{C as ts}from"./confirm-dialog-BlSaX2gK.js";import{l as rs,w as Ie,m as Le,n as he,aB as te,s as as,R as oe,Z as ns,a9 as Re,p as Te,O as is,Q as ls,as as os,at as ds,_ as we,aL as Ee,aM as qe,ah as Oe,aw as cs,aN as ms}from"./icons-KVCk4_U8.js";import{u as us,a as ge,b as fe}from"./tanstack-CrmUhA7Z.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-QyEXocpn.js";function ps(s){switch(s){case"ready":return{icon:Le,text:"Ready",className:"text-green-600"};case"partial":return{icon:Ie,text:"Needs attention",className:"text-amber-600"};default:return{icon:rs,text:"Not configured",className:"text-muted-foreground"}}}function xs({families:s,selectedFamily:t,onSelect:r}){return e.jsx("div",{className:"space-y-1",children:s.map(a=>{const i=a.id===t,o=ps(a.status),l=o.icon;return e.jsx("button",{type:"button",onClick:()=>r(a.id),className:D("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(ue,{provider:pe(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:D("mt-0.5 flex items-center gap-1.5 text-xs",o.className),children:[e.jsx(l,{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 hs(s){switch(s){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 Ce(s){return s.split(`
|
|
2
|
-
`).map(t=>t.trim()).filter(t=>t.length>0)}function gs(s){return s.split(`
|
|
3
|
-
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[a,...i]=t.split(r);return{key:a.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function fs(s){return Ue(s)}function Z({value:s,onChange:t,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:s,onChange:i=>t(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 vs(s){return(s?.headers||[]).map(t=>`${t.key}: ${t.value}`).join(`
|
|
4
|
-
`)}function ys(s){return(s?.excludedModels||[]).join(`
|
|
5
|
-
`)}function bs(s){return xe(s?.models)}function ke({title:s,items:t,icon:r}){return e.jsxs("div",{className:"rounded-xl border bg-background/80 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r,s]}),e.jsx("div",{className:"mt-3 space-y-3",children:t.map((a,i)=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-muted/40 text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:a})]},`${s}:${a}`))})]})}function js({family:s,entry:t,open:r,onOpenChange:a,onSubmit:i,isSaving:o}){const l=c.useMemo(()=>hs(s),[s]),n=!!t,u=s==="openai-compatibility",y=s==="claude-api-key",[U,K]=c.useState(()=>t?.name||""),[j,q]=c.useState(()=>t?.baseUrl||""),[N,H]=c.useState(()=>t?.proxyUrl||""),[I,J]=c.useState(()=>t?.prefix||""),[w,L]=c.useState(""),[b,p]=c.useState(""),[R,C]=c.useState(()=>vs(t)),[T,B]=c.useState(()=>ys(t)),[O,v]=c.useState(()=>bs(t)),A=c.useMemo(()=>Me(O),[O]),[S,$]=c.useState(()=>!!(t?.headers.length||t?.excludedModels.length||t?.proxyUrl||t?.prefix)),F=c.useMemo(()=>!n||!t?.secretConfigured?null:u?"Leave API keys blank to keep the stored connector secrets.":"Leave the API key blank to keep the stored secret.",[t?.secretConfigured,n,u]),d=async()=>{if(A.length>0)return;const g=w.trim(),_=Ce(b),k=n&&t?.secretConfigured&&!g.length&&_.length===0,le={name:u?U:void 0,baseUrl:j,proxyUrl:y?N:void 0,prefix:y?I:void 0,headers:gs(R),excludedModels:y?Ce(T):void 0,models:fs(O),preserveSecrets:k,...u?_.length>0?{apiKeys:_}:{}:g.length>0?{apiKey:g}:{}};await i(le)};return e.jsx(Ge,{open:r,onOpenChange:a,children:e.jsx(Ve,{className:"overflow-hidden p-0 sm:max-w-3xl",children:e.jsxs("div",{className:"max-h-[85vh] overflow-y-auto",children:[e.jsx("div",{className:"border-b bg-muted/20 px-6 py-5",children:e.jsxs(ze,{className:"gap-4 text-left",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl border bg-background",children:e.jsx(ue,{provider:pe(s),size:"md"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Je,{children:n?`Edit ${l.familyName}`:`Set up ${l.familyName}`}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:u?"connector":"api-key"})]}),e.jsx(_e,{className:"mt-1 max-w-2xl leading-6",children:l.description})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(ke,{title:"Required now",items:l.requiredNow,icon:e.jsx(he,{className:"h-4 w-4 text-primary"})}),e.jsx(ke,{title:"Optional later",items:l.optionalLater,icon:e.jsx(te,{className:"h-4 w-4 text-primary"})})]}),F?e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-800",children:F}):null]})}),e.jsxs("div",{className:"space-y-6 px-6 py-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Required setup"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Save the smallest working configuration first."})]}),u?e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"connector-name",children:"Connector Name"}),e.jsx(P,{id:"connector-name",value:U,onChange:g=>K(g.target.value),placeholder:l.connectorPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.connectorHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"base-url",children:"Base URL"}),e.jsx(P,{id:"base-url",value:j,onChange:g=>q(g.target.value),placeholder:l.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{children:"API Keys"}),e.jsx(Z,{value:b,onChange:p,rows:4,placeholder:`${l.keyPlaceholder}
|
|
6
|
-
${l.keyPlaceholder}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.keyHelper})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"api-key",children:l.keyLabel}),e.jsx(P,{id:"api-key",type:"password",value:w,onChange:g=>L(g.target.value),placeholder:l.keyPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.keyHelper})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Optional routing"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Only fill these when the route needs more than the default behavior."})]}),u?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"base-url",children:"Base URL"}),e.jsx(P,{id:"base-url",value:j,onChange:g=>q(g.target.value),placeholder:l.baseUrlPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.baseUrlHelper})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{children:"Model Mappings"}),e.jsx(Z,{value:O,onChange:v,rows:4,placeholder:l.aliasesPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l.aliasesHelper}),A.length>0?e.jsx("p",{className:"text-xs text-destructive",children:A[0]}):null]})]}),e.jsx(Qe,{open:S,onOpenChange:$,children:e.jsxs("div",{className:"rounded-xl border",children:[e.jsx(We,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-4 px-4 py-4 text-left",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsxs("div",{className:"mt-1 text-sm text-muted-foreground",children:["Headers",y?", proxy, prefix, and exclusions.":" and provider-specific overrides."]})]}),e.jsx(as,{className:D("h-4 w-4 text-muted-foreground transition-transform",S&&"rotate-180")})]})}),e.jsx(Xe,{className:"border-t px-4 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{children:"Headers"}),e.jsx(Z,{value:R,onChange:C,rows:3,placeholder:l.headersPlaceholder}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use headers only when the provider requires extra routing or auth context."})]}),y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"prefix",children:"Prefix"}),e.jsx(P,{id:"prefix",value:I,onChange:g=>J(g.target.value),placeholder:"glm-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Prepends model names before routing."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{htmlFor:"proxy-url",children:"Proxy URL"}),e.jsx(P,{id:"proxy-url",value:N,onChange:g=>H(g.target.value),placeholder:"http://127.0.0.1:8080"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Sends requests through an intermediate proxy."})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(M,{children:"Excluded Models"}),e.jsx(Z,{value:T,onChange:B,rows:3,placeholder:"claude-opus-4-1\\nclaude-sonnet-4-5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. One model ID per line when this route should reject specific upstream models."})]})]}):null]})})]})})]}),e.jsxs(Ye,{className:"border-t bg-muted/10 px-6 py-4",children:[e.jsx(f,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(f,{type:"button",onClick:()=>void d(),disabled:o||A.length>0,children:o?"Saving...":u?n?"Save Connector":"Create Connector":"Save Entry"})]})]})})})}const ie=["cliproxy-ai-providers"];function Ns(){return us({queryKey:ie,queryFn:()=>ne.cliproxy.aiProviders.list()})}function ws(){const s=ge();return fe({mutationFn:({family:t,data:r})=>ne.cliproxy.aiProviders.create(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry created")},onError:t=>{G.error(t.message)}})}function Cs(){const s=ge();return fe({mutationFn:({family:t,entryId:r,data:a})=>ne.cliproxy.aiProviders.update(t,r,a),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry updated")},onError:t=>{G.error(t.message)}})}function ks(){const s=ge();return fe({mutationFn:({family:t,entryId:r})=>ne.cliproxy.aiProviders.delete(t,r),onSuccess:()=>{s.invalidateQueries({queryKey:ie}),G.success("Provider entry removed")},onError:t=>{G.error(t.message)}})}function Q({label:s,value:t,hint:r}){return e.jsxs("div",{className:"rounded-lg border bg-background p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("div",{className:"mt-1 break-all text-sm font-medium leading-5",children:t}),r?e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r}):null]})}function Ps(s){switch(s){case"ready":return{label:"Ready",className:"bg-emerald-50 text-emerald-700 hover:bg-emerald-50"};case"partial":return{label:"Needs attention",className:"bg-amber-50 text-amber-700 hover:bg-amber-50"};default:return{label:"Empty",className:"bg-muted text-muted-foreground hover:bg-muted"}}}function ce(s){return s.proxyUrl?"Proxy override":s.prefix?"Prefixed route":s.baseUrl?"Direct upstream":"Default runtime"}function Ke(s){return s.filter(t=>t.alias.trim().length>0).length}function He(s){return s.filter(t=>t.name.trim().length>0&&t.alias.trim().length===0).length}function re(s){const t=Ke(s),r=He(s),a=[];return t>0&&a.push(`${t} mapped`),r>0&&a.push(`${r} direct`),a.length>0?a.join(" + "):"No model rules"}function me({configured:s}){return e.jsx(h,{variant:"secondary",className:D("border-transparent text-[10px]",s?"bg-emerald-50 text-emerald-700 hover:bg-emerald-50":"bg-muted text-muted-foreground hover:bg-muted"),children:s?"Configured":"Missing secret"})}const V="<stored in CLIProxy>";function $e(s){switch(s.id){case"gemini-api-key":return{requiredNow:["Save the Gemini API key.","Leave Base URL blank unless you use a custom Gemini gateway.","Add model mappings only when Gemini model names differ from the requested ones."],optionalLater:["Headers for provider-specific project routing.","Base URL override for a proxy or regional endpoint.","Mappings such as claude-sonnet-4-5 -> gemini-2.5-pro."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Gemini credentials.`,"The default upstream is enough for most Gemini setups.","Model mappings and headers are optional, not step one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile instead of this CLIProxy-managed Gemini route.",editPrompts:[{label:"Base URL",hint:"Change it only for a custom Gemini gateway or regional endpoint."},{label:"Model mappings",hint:"Add them only when requested names and Gemini names differ."},{label:"Headers",hint:"Keep them empty unless the provider requires project or org routing."}]};case"codex-api-key":return{requiredNow:["Save the Codex or OpenAI API key.","Leave Base URL blank unless this route should hit a different OpenAI-style host.","Add mappings only when the upstream model name differs from what CCS requests."],optionalLater:["Base URL override for a gateway, proxy, or self-hosted endpoint.","Headers for org or project routing.","Mappings such as claude-sonnet-4-5 -> gpt-5."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Codex credentials.`,"Most setups can keep the default upstream and skip extra routing.","Mappings are only needed when the upstream model naming does not match the requested one."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Codex route.",editPrompts:[{label:"Base URL",hint:"Change it only when Codex should resolve through another OpenAI-style endpoint."},{label:"Model mappings",hint:"Map requested model names to the exact upstream model ID only when needed."},{label:"Headers",hint:"Use headers sparingly for project routing or extra auth."}]};case"claude-api-key":return{requiredNow:["Save the Anthropic or compatible API key.","Leave Base URL blank unless this route should point at a custom Claude-compatible endpoint.","Add mappings only when the upstream model ID differs from the requested Claude model name."],optionalLater:["Prefix or proxy overrides for advanced route rewriting.","Excluded models when a route should block specific model IDs.","Headers for project-scoped routing."],emptyStateSummary:[`Requests to ${s.routePath} use a CLIProxy-managed Claude-compatible key.`,"Base URL, proxy, and prefix rewrites are advanced options, not the minimum setup.","Most users can start with a key only, then add mappings or filters if routing needs it."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile or preset instead of this CLIProxy-managed Claude route.",editPrompts:[{label:"Base URL",hint:"Change it only when Claude traffic should target another compatible endpoint."},{label:"Mappings",hint:"Add them only when the requested Claude model name should route to a different upstream ID."},{label:"Advanced routing",hint:"Proxy, prefix, headers, and exclusions are for edge cases. Leave them blank when unsure."}]};case"vertex-api-key":return{requiredNow:["Save the Vertex API key.","Leave Base URL blank unless a regional or gateway endpoint is required.","Add mappings only when the upstream model name differs from the requested name."],optionalLater:["Base URL override for a regional gateway.","Headers for provider-specific routing.","Mappings for translating requested names to Vertex model IDs."],emptyStateSummary:[`Requests to ${s.routePath} use CLIProxy-managed Vertex credentials.`,"Most setups start with the key only and keep the default endpoint.","Mappings and headers are optional follow-up steps."],profileBoundary:"Use API Profiles when you need a CCS-native Anthropic-compatible profile rather than this CLIProxy-managed Vertex route.",editPrompts:[{label:"Base URL",hint:"Use it only for a regional gateway or managed Vertex endpoint."},{label:"Model mappings",hint:"Add them only when the requested names need translating upstream."},{label:"Headers",hint:"Keep them empty unless the provider requires extra routing context."}]};case"openai-compatibility":return{requiredNow:["Name the connector, for example openrouter or together.","Set the connector Base URL.","Add at least one API key before saving."],optionalLater:["Headers for provider-specific auth or project routing.","Model mappings such as claude-sonnet-4-5 -> gpt-4.1.","Additional API keys for the same connector."],emptyStateSummary:[`Requests to ${s.routePath} resolve through a named OpenAI-compatible connector.`,"This flow needs a connector name, a Base URL, and one or more API keys.","Headers and mappings come after the connector is already working."],profileBoundary:"Use API Profiles when you want a CCS-native Anthropic-compatible profile, preset, or provider outside the CLIProxy connector flow.",editPrompts:[{label:"Connector identity",hint:"Keep the connector name and Base URL stable once clients depend on it."},{label:"Model mappings",hint:"Only add them when the connector expects a different upstream model ID."},{label:"Headers",hint:"Use them for provider-specific auth or project routing, not as a default."}]}}}function z(s){return s.split(`
|
|
7
|
-
`).map(t=>t.trim()).filter(t=>t.length>0)}function ae(s){return s.split(`
|
|
8
|
-
`).map(t=>t.trim()).filter(t=>t.length>0).map(t=>{const r=t.includes(":")?":":"=",[a,...i]=t.split(r);return{key:a.trim(),value:i.join(r).trim()}}).filter(t=>t.key.length>0)}function W(s){return Ue(s)}function As(s){return(s?.headers||[]).map(t=>`${t.key}: ${t.value}`).join(`
|
|
9
|
-
`)}function Ss(s){return(s?.excludedModels||[]).join(`
|
|
10
|
-
`)}function Ms(s){return xe(s?.models)}function de(s){return{name:s.name||"",baseUrl:s.baseUrl||"",proxyUrl:s.proxyUrl||"",prefix:s.prefix||"",headersText:As(s),excludedModelsText:Ss(s),modelAliasesText:Ms(s),apiKey:"",apiKeysText:""}}function Us(s){const t=ae(s);if(t.length!==0)return Object.fromEntries(t.map(r=>[r.key,r.value]))}function Is(s){const t=W(s).map(r=>r.alias.trim()?{name:r.name,alias:r.alias}:{name:r.name});return t.length>0?t:void 0}function Pe(s){return Array.isArray(s)?xe(s):""}function Ls(s){const t=z(s);return t.length>0?t:void 0}function Ae(s,t,r){const a=Us(r.headersText),i=Is(r.modelAliasesText),o=Ls(r.excludedModelsText),l=r.apiKey.trim()||(t.secretConfigured?V:"");if(s.id==="openai-compatibility"){const n=z(r.apiKeysText),u=t.apiKeysMasked?.length||1;return{name:r.name.trim()||t.name||"connector","base-url":r.baseUrl.trim(),...a?{headers:a}:{},"api-key-entries":n.length>0?n.map(y=>({"api-key":y})):t.secretConfigured?Array.from({length:u},()=>({"api-key":V})):[],...i?{models:i}:{}}}return{"api-key":l,...r.baseUrl.trim()?{"base-url":r.baseUrl.trim()}:{},...r.proxyUrl.trim()?{"proxy-url":r.proxyUrl.trim()}:{},...r.prefix.trim()?{prefix:r.prefix.trim()}:{},...a?{headers:a}:{},...o?{"excluded-models":o}:{},...i?{models:i}:{}}}function Rs(s,t,r){const a=JSON.parse(r);if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Raw config must be a JSON object.");if(s.id==="openai-compatibility"){const o=a,n=(Array.isArray(o["api-key-entries"])?o["api-key-entries"]:[]).map(u=>typeof u=="string"?u:u&&typeof u=="object"&&typeof u["api-key"]=="string"?u["api-key"]:"").filter(u=>u&&u!==V);return{name:typeof o.name=="string"?o.name:t.name||"",baseUrl:typeof o["base-url"]=="string"?o["base-url"]:"",proxyUrl:"",prefix:"",headersText:o.headers&&typeof o.headers=="object"&&!Array.isArray(o.headers)?Object.entries(o.headers).map(([u,y])=>`${u}: ${y}`).join(`
|
|
11
|
-
`):"",excludedModelsText:"",modelAliasesText:Pe(o.models),apiKey:"",apiKeysText:n.join(`
|
|
12
|
-
`)}}const i=a;return{name:"",baseUrl:typeof i["base-url"]=="string"?i["base-url"]:"",proxyUrl:typeof i["proxy-url"]=="string"?i["proxy-url"]:"",prefix:typeof i.prefix=="string"?i.prefix:"",headersText:i.headers&&typeof i.headers=="object"&&!Array.isArray(i.headers)?Object.entries(i.headers).map(([o,l])=>`${o}: ${l}`).join(`
|
|
13
|
-
`):"",excludedModelsText:Array.isArray(i["excluded-models"])?i["excluded-models"].join(`
|
|
14
|
-
`):"",modelAliasesText:Pe(i.models),apiKey:typeof i["api-key"]=="string"&&i["api-key"]!==V?i["api-key"]:"",apiKeysText:""}}function Ts(s,t,r){if(s.id==="openai-compatibility"){const o=z(r.apiKeysText),l=t.secretConfigured&&o.length===0;return{name:r.name.trim(),baseUrl:r.baseUrl.trim(),headers:ae(r.headersText),models:W(r.modelAliasesText),preserveSecrets:l,...o.length>0?{apiKeys:o}:{}}}const a=r.apiKey.trim(),i=t.secretConfigured&&a.length===0;return{baseUrl:r.baseUrl.trim(),proxyUrl:r.proxyUrl.trim(),prefix:r.prefix.trim(),headers:ae(r.headersText),excludedModels:z(r.excludedModelsText),models:W(r.modelAliasesText),preserveSecrets:i,...a.length>0?{apiKey:a}:{}}}function Es(s,t,r){const a={ANTHROPIC_BASE_URL:`${r.target}${s.routePath}`,ANTHROPIC_AUTH_TOKEN:"ccs-internal-managed"},i=W(t.modelAliasesText).find(o=>o.name.trim());return i?.name&&(a.ANTHROPIC_MODEL=es(i)),{env:a}}function Se({badge:s,title:t,items:r}){return e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(h,{variant:"secondary",className:"text-[11px]",children:s}),e.jsx("div",{className:"text-sm font-medium",children:t})]}),e.jsx("div",{className:"mt-4 space-y-3",children:r.map((a,i)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/10 px-3 py-3",children:[e.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border bg-background text-[11px] font-semibold text-muted-foreground",children:i+1}),e.jsx("div",{className:"text-sm leading-6 text-muted-foreground",children:a})]},`${t}:${a}`))})]})}function E({label:s,helper:t,children:r}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s}),r,t?e.jsx("div",{className:"text-xs leading-5 text-muted-foreground",children:t}):null]})}function ee({value:s,onChange:t,placeholder:r,rows:a=4}){return e.jsx("textarea",{rows:a,value:s,onChange:i=>t(i.target.value),placeholder:r,className:"flex min-h-24 w-full rounded-md border border-input bg-background 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 qs({family:s,entry:t,source:r,isSaving:a,onSave:i,onDelete:o}){const l=$e(s),[n,u]=c.useState(()=>de(t)),[y,U]=c.useState(null),[K,j]=c.useState(!0),[q,N]=c.useState(null),[H,I]=c.useState("config"),[J,w]=c.useState("raw"),L=c.useMemo(()=>JSON.stringify(Ae(s,t,de(t)),null,2),[t,s]),b=c.useMemo(()=>JSON.stringify(Ae(s,t,n),null,2),[n,t,s]),p=y??b,R=c.useMemo(()=>Es(s,n,r),[n,s,r]),C=c.useMemo(()=>W(n.modelAliasesText),[n.modelAliasesText]),T=c.useMemo(()=>Me(n.modelAliasesText),[n.modelAliasesText]),B=c.useMemo(()=>ae(n.headersText),[n.headersText]),O=c.useMemo(()=>z(n.excludedModelsText),[n.excludedModelsText]),v=c.useMemo(()=>JSON.stringify(R,null,2),[R]),A=Ke(C),S=He(C),$=B.length+O.length+(n.proxyUrl.trim()?1:0)+(n.prefix.trim()?1:0),F=s.id==="openai-compatibility"?n.headersText.trim().length>0:!!(n.proxyUrl.trim()||n.prefix.trim()||n.headersText.trim()||n.excludedModelsText.trim()),d=y!==null?y!==L:b!==L,g=c.useMemo(()=>{if(s.id==="openai-compatibility"){const m=[];return n.name.trim()||m.push("name"),n.baseUrl.trim()||m.push("base-url"),!t.secretConfigured&&z(n.apiKeysText).length===0&&m.push("api-key-entries"),m}return!t.secretConfigured&&!n.apiKey.trim()?["api-key"]:[]},[n.apiKey,n.apiKeysText,n.baseUrl,n.name,t.secretConfigured,s.id]),_=K&&g.length===0&&T.length===0&&d,k=m=>{u(x=>m(x)),U(null),j(!0),N(null)},le=m=>{U(m);try{const x=Rs(s,t,m);u(x),j(!0),N(null)}catch(x){j(!1),N(x instanceof Error?x.message:"Invalid JSON")}},De=()=>{u(de(t)),U(null),j(!0),N(null)},ve=m=>{k(x=>m==="minimal"?s.id==="openai-compatibility"?{...x,headersText:"",modelAliasesText:""}:{...x,baseUrl:"",proxyUrl:"",prefix:"",headersText:"",excludedModelsText:"",modelAliasesText:""}:{...x,proxyUrl:"",prefix:"",headersText:"",excludedModelsText:s.id==="openai-compatibility"?x.excludedModelsText:""})};return e.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-[minmax(360px,0.44fr)_minmax(0,0.56fr)] divide-x overflow-hidden rounded-b-xl border-x border-b bg-card",children:[e.jsx("div",{className:"min-h-0 overflow-hidden bg-muted/5",children:e.jsxs(be,{value:H,onValueChange:I,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"truncate text-lg font-semibold",children:t.label}),e.jsx(me,{configured:t.secretConfigured}),e.jsx(h,{variant:"outline",className:"uppercase",children:s.authMode})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:ce(t)}),e.jsx(h,{variant:"outline",className:"text-[11px]",children:r.label})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:De,disabled:!d,children:[e.jsx(ls,{className:"mr-1 h-3.5 w-3.5"}),"Reset"]}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:o,children:[e.jsx(os,{className:"mr-1 h-3.5 w-3.5"}),"Remove"]}),e.jsxs(f,{type:"button",size:"sm",onClick:()=>void i(Ts(s,t,n)),disabled:!_||a,children:[e.jsx(ds,{className:"mr-1 h-3.5 w-3.5"}),a?"Saving...":"Save"]})]})]}),e.jsxs(je,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"config",className:"gap-2 text-xs",children:[e.jsx(te,{className:"h-3.5 w-3.5"}),"Config"]}),e.jsxs(X,{value:"usage",className:"gap-2 text-xs",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),"Info & Usage"]})]})]}),e.jsx(Y,{value:"config",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Workspace presets"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Keep the route lean by default, then layer routing only when this entry actually needs it."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ve("minimal"),children:"Minimal setup"}),e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:()=>ve("clean-routing"),children:"Clear routing noise"})]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 2xl:grid-cols-3",children:[e.jsx(Q,{label:"Secret",value:t.secretConfigured?"Stored in CLIProxy":"Missing",hint:t.secretConfigured?"Rotate only when needed":"Required to save"}),e.jsx(Q,{label:"Model Rules",value:C.length>0?re(C):"No model rules",hint:"Requested model names stay direct unless remapped"}),e.jsx(Q,{label:"Advanced",value:$>0?`${$} active`:"Optional",hint:"Proxy, prefix, headers, and exclusions"})]})]}),g.length>0?e.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50/80 p-4 text-sm text-amber-900",children:["Missing required fields:"," ",e.jsx("span",{className:"font-mono",children:g.join(", ")})]}):null,e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-2 text-sm font-medium",children:[e.jsx(he,{className:"h-4 w-4 text-primary"}),"Connection"]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[s.id==="openai-compatibility"?e.jsx(E,{label:"Connector Name",helper:"This is the saved connector label shown in the entry switcher.",children:e.jsx(P,{value:n.name,onChange:m=>k(x=>({...x,name:m.target.value})),placeholder:"openrouter"})}):e.jsx(E,{label:`${s.displayName} API Key`,helper:t.secretConfigured?"Leave blank to keep the stored secret. Enter a new value only to rotate it.":"Required before this route can authenticate.",children:e.jsx(P,{type:"password",value:n.apiKey,onChange:m=>k(x=>({...x,apiKey:m.target.value})),placeholder:t.secretConfigured?t.apiKeyMasked||V:"Paste provider API key"})}),s.id==="openai-compatibility"?e.jsx(E,{label:"API Keys",helper:t.secretConfigured?"One key per line. Leave empty to preserve the stored connector keys.":"Add one key per line. A connector needs at least one key.",children:e.jsx(ee,{value:n.apiKeysText,onChange:m=>k(x=>({...x,apiKeysText:m})),placeholder:"sk-...",rows:4})}):null,e.jsx(E,{label:"Base URL",helper:s.id==="openai-compatibility"?"Required for connectors. This is the upstream OpenAI-style endpoint.":"Leave blank unless this route should target another upstream host.",children:e.jsx(P,{value:n.baseUrl,onChange:m=>k(x=>({...x,baseUrl:m.target.value})),placeholder:s.id==="codex-api-key"?"https://api.openai.com/v1":s.id==="claude-api-key"?"https://api.anthropic.com":s.id==="openai-compatibility"?"https://openrouter.ai/api/v1":"https://provider.example.com"})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Proxy URL",helper:"Optional intermediary endpoint. Leave blank for direct routing.",children:e.jsx(P,{value:n.proxyUrl,onChange:m=>k(x=>({...x,proxyUrl:m.target.value})),placeholder:"https://proxy.example.com/v1"})}):null,s.id!=="openai-compatibility"?e.jsx(E,{label:"Prefix",helper:"Optional model prefix rewrite for advanced routing only.",children:e.jsx(P,{value:n.prefix,onChange:m=>k(x=>({...x,prefix:m.target.value})),placeholder:"provider/"})}):null]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ee,{className:"h-4 w-4 text-primary"}),"Model rules"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[A>0?e.jsxs(h,{variant:"outline",children:[A," mapped"]}):null,S>0?e.jsxs(h,{variant:"outline",children:[S," direct"]}):null,C.length===0?e.jsx(h,{variant:"outline",children:"Optional"}):null]})]}),e.jsx(E,{label:"Requested [= Upstream]",helper:"Use requested=upstream for remaps. Use a plain model name when you want the route to expose that model directly.",children:e.jsx(ee,{value:n.modelAliasesText,onChange:m=>k(x=>({...x,modelAliasesText:m})),placeholder:`claude-sonnet-4-5=gpt-5
|
|
15
|
-
glm-5`,rows:6})}),T.length>0?e.jsx("div",{className:"mt-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:T[0]}):null]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),"Advanced routing"]}),e.jsx(h,{variant:"outline",children:F?`${$} active`:"Optional"})]}),e.jsxs("div",{className:"grid gap-4 2xl:grid-cols-2",children:[e.jsx(E,{label:"Headers",helper:"One header per line. Use only when the upstream expects org, project, or secondary auth headers.",children:e.jsx(ee,{value:n.headersText,onChange:m=>k(x=>({...x,headersText:m})),placeholder:"OpenAI-Organization: org_...",rows:5})}),s.id!=="openai-compatibility"?e.jsx(E,{label:"Excluded Models",helper:"One model ID per line. These models will be blocked for this entry.",children:e.jsx(ee,{value:n.excludedModelsText,onChange:m=>k(x=>({...x,excludedModelsText:m})),placeholder:"claude-opus-4-1",rows:5})}):e.jsx("div",{className:"rounded-xl border border-dashed bg-muted/10 p-4 text-sm text-muted-foreground",children:"OpenAI-compatible connectors keep advanced routing lean. Add headers or model mappings first before introducing extra route layers elsewhere."})]})]})]})})}),e.jsx(Y,{value:"usage",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(qe,{className:"h-4 w-4 text-primary"}),"How this route behaves"]}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm leading-6 text-muted-foreground",children:[e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:["Calls to ",e.jsx("span",{className:"font-mono",children:s.routePath})," use this saved entry inside CLIProxy."]}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:n.baseUrl.trim()?`Traffic resolves to ${n.baseUrl.trim()} unless you layer another proxy in front.`:"Traffic keeps the family default upstream unless you add a custom base URL."}),e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4",children:C.length>0?`${re(C)} rule${C.length===1?"":"s"} active for this entry.`:"Requested model names pass through unchanged until you add explicit model rules."})]})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(we,{className:"h-4 w-4 text-primary"}),"When API Profiles fits better"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:l.profileBoundary})]}),e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-primary"}),"Editing rule of thumb"]}),e.jsx("div",{className:"mt-3 space-y-3",children:l.editPrompts.map(m=>e.jsxs("div",{className:"rounded-lg border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:m.label}),e.jsx("div",{className:"mt-1 text-sm leading-6 text-muted-foreground",children:m.hint})]},m.label))})]})]})})})]})}),e.jsx("div",{className:"min-h-0 overflow-hidden",children:e.jsxs(be,{value:J,onValueChange:w,className:"flex h-full flex-col",children:[e.jsxs("div",{className:"border-b bg-background px-4 pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Raw configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Target ",e.jsx("span",{className:"font-mono",children:r.target})]})]}),e.jsxs(je,{className:"grid w-full grid-cols-2",children:[e.jsxs(X,{value:"raw",className:"gap-2 text-xs",children:[e.jsx(cs,{className:"h-3.5 w-3.5"}),"Raw Entry Config"]}),e.jsxs(X,{value:"preview",className:"gap-2 text-xs",children:[e.jsx(ms,{className:"h-3.5 w-3.5"}),"settings.json Preview"]})]})]}),e.jsx(Y,{value:"raw",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:t.secretConfigured?`Stored secrets are shown as ${V}. Replace the placeholder only when you want to rotate the secret.`:"Add secrets directly in the JSON or use the form on the left."}),q?e.jsx("div",{className:"mx-6 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:q}):null,e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(Ne,{value:p,onChange:le,language:"json",minHeight:"100%",heightMode:"fill-parent"})})})]})}),e.jsx(Y,{value:"preview",className:"mt-0 min-h-0 flex-1 overflow-hidden data-[state=inactive]:hidden",children:e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"border-b bg-muted/10 px-6 py-3 text-sm text-muted-foreground",children:"Derived preview for a CCS profile that points to this CLIProxy route. The route stays local; the upstream key remains managed here."}),e.jsx("div",{className:"min-h-0 flex-1 px-6 pb-4 pt-4",children:e.jsx("div",{className:"h-full overflow-hidden rounded-md border bg-background",children:e.jsx(Ne,{value:v,onChange:()=>{},language:"json",readonly:!0,minHeight:"100%",heightMode:"fill-parent"})})}),e.jsx("div",{className:"mx-6 mb-4 overflow-hidden rounded-md border",children:e.jsx(Ze,{profileEnv:R.env})})]})})]})})]})}function Os({family:s,onAddEntry:t,onOpenControlPanel:r,onOpenProfiles:a}){const i=$e(s),o=s.supportsNamedEntries?"Create connector":`Add ${s.displayName} entry`;return e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{className:"grid gap-5 2xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"rounded-xl border bg-card",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b px-5 py-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-muted",children:e.jsx(he,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold",children:["Set up ",s.displayName]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Start with the smallest working setup. Add routing rules only after the route is already working."})]})]}),e.jsxs(f,{type:"button",onClick:t,children:[e.jsx(Re,{className:"mr-1 h-4 w-4"}),o]})]}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs("div",{className:"rounded-xl border bg-muted/10 p-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"Recommended setup flow"}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"Finish the left section first. Treat the right section as optional follow-up."}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx(Se,{badge:"Do this first",title:"Minimum working setup",items:i.requiredNow}),e.jsx(Se,{badge:"Only if needed",title:"Optional later",items:i.optionalLater})]})]}),e.jsxs("div",{className:"rounded-xl border bg-muted/15 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Oe,{className:"h-4 w-4 text-emerald-600"}),"Need the other pages?"]}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Use Overview or Control Panel for OAuth sign-ins. Use API Profiles only for CCS-native Anthropic-compatible profiles and presets."}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsx(f,{type:"button",size:"sm",variant:"outline",onClick:r,children:"Control Panel"}),e.jsxs(f,{type:"button",size:"sm",variant:"outline",onClick:a,children:["API Profiles",e.jsx(Te,{className:"ml-1 h-3.5 w-3.5"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(qe,{className:"h-4 w-4 text-primary"}),"What this route does"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:s.routePath}),e.jsx(h,{variant:"outline",className:"uppercase text-[11px]",children:s.authMode})]}),e.jsx("div",{className:"mt-4 space-y-3",children:i.emptyStateSummary.map(l=>e.jsx("div",{className:"rounded-lg border bg-muted/10 p-4 text-sm leading-6 text-muted-foreground",children:l},l))})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Ee,{className:"h-4 w-4 text-primary"}),"When API Profiles is the better fit"]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:i.profileBoundary})]})]})]})})}function Ws(){const s=Be(),t=Fe(),{data:r,error:a,isLoading:i,isFetching:o,refetch:l}=Ns(),n=ws(),u=Cs(),y=ks(),[U,K]=c.useState(!1),[j,q]=c.useState(null),[N,H]=c.useState(null),[I,J]=c.useState(null),w=c.useMemo(()=>r?.families??[],[r?.families]),L=c.useMemo(()=>new URLSearchParams(s.search).get("family")||null,[s.search]),b=c.useMemo(()=>L&&w.some(d=>d.id===L)?L:w[0]?.id??"gemini-api-key",[w,L]),p=c.useMemo(()=>w.find(d=>d.id===b)||null,[w,b]),R=c.useMemo(()=>{const d=p?.entries??[];return d.length===0?null:I&&d.some(g=>g.id===I)?I:d[0]?.id??null},[I,p?.entries]),C=d=>{t({pathname:s.pathname,search:`?family=${d}`},{replace:!0})},T=()=>{q(null),K(!0)};if(i)return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsx(ye,{className:"h-full w-80 rounded-none"}),e.jsx(ye,{className:"h-full flex-1 rounded-none"})]});if(a||!r||!p){const d=a instanceof Error?a.message:"Failed to load CLIProxy AI providers. Check the local server and try again.";return e.jsx("div",{className:"flex h-full min-h-0 items-center justify-center bg-muted/10 p-6",children:e.jsx("div",{className:"w-full max-w-2xl rounded-xl border bg-card p-6 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-lg bg-destructive/10",children:e.jsx(Ie,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Unable to load AI Providers"}),e.jsx("div",{className:"mt-2 text-sm text-muted-foreground",children:d}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(f,{type:"button",onClick:()=>void l(),children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Retry"]}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:"API Profiles"})]})]})]})})})}const B=p.entries.filter(d=>d.secretConfigured),O=w.filter(d=>d.status==="ready").length,v=p.entries.find(d=>d.id===R)??null,A=p.entries.length>1,S=Ps(p.status),$=p.entries.length>0,F=e.jsxs("div",{className:"rounded-xl border bg-background p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Setup status"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:p.routePath})]}),e.jsx(h,{variant:"secondary",className:S.className,children:S.label})]}),e.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:"Entries",value:`${p.entries.length}`,hint:"configured rows"}),e.jsx(Q,{label:"Secrets",value:`${B.length}/${p.entries.length||0}`,hint:"stored in CLIProxy"})]}),e.jsx("div",{className:"mt-3 rounded-lg border bg-muted/15 p-3 text-xs leading-5 text-muted-foreground",children:"Overview handles OAuth sign-ins. This page stores CLIProxy-managed keys and connectors. API Profiles remains for CCS-native Anthropic-compatible profiles."})]});return e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex w-80 flex-col border-r bg-muted/30",children:[e.jsxs("div",{className:"border-b bg-background p-4",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy Plus"})]}),e.jsx(f,{variant:"ghost",size:"icon",className:"h-8 w-8",type:"button",onClick:()=>void l(),disabled:o,children:e.jsx(oe,{className:D("h-4 w-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"AI Providers"}),e.jsxs(f,{variant:"default",size:"sm",className:"w-full gap-2",type:"button",onClick:T,children:[e.jsx(Re,{className:"h-4 w-4"}),p.supportsNamedEntries?"Create Connector":`Add ${p.displayName} Entry`]})]}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Provider Families"}),e.jsx(xs,{families:w,selectedFamily:b,onSelect:C})]})}),e.jsx("div",{className:"border-t p-3",children:e.jsx(ss,{})}),e.jsx("div",{className:"border-t bg-background p-3 text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[w.length," families"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Le,{className:"h-3 w-3 text-emerald-600"}),O," ready"]})]})})]}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col bg-background",children:[e.jsx("div",{className:"shrink-0 border-b bg-background px-6 py-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ue,{provider:pe(p.id),size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:p.displayName}),e.jsx(h,{variant:"secondary",className:S.className,children:S.label}),e.jsx(h,{variant:"outline",className:"uppercase",children:p.authMode}),e.jsx(h,{variant:"outline",className:"font-mono text-[11px]",children:p.routePath})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:p.description})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:()=>void l(),disabled:o,children:e.jsx(oe,{className:D("h-4 w-4",o&&"animate-spin")})}),e.jsx(f,{type:"button",variant:"outline",onClick:()=>t("/cliproxy/control-panel"),children:"Control Panel"}),e.jsxs(f,{type:"button",variant:"outline",onClick:()=>t("/providers"),children:["API Profiles",e.jsx(Te,{className:"ml-1 h-3.5 w-3.5"})]})]})]})}),$?e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 border-b bg-muted/5 px-6 py-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[e.jsx(is,{className:"h-3 w-3"}),A?"Saved entries":"Saved entry"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[p.entries.length," entries"]}),e.jsxs(h,{variant:"outline",className:"text-[11px]",children:[B.length,"/",p.entries.length," secrets stored"]})]})]}),A?e.jsx("div",{className:"flex flex-wrap gap-3",children:p.entries.map(d=>e.jsxs("button",{type:"button",onClick:()=>J(d.id),className:D("min-w-[220px] max-w-[280px] flex-1 rounded-xl border bg-background px-4 py-3 text-left transition-colors",d.id===R?"border-primary/30 bg-primary/5 shadow-sm":"border-border/60 hover:bg-muted/50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:d.label}),e.jsx(me,{configured:d.secretConfigured})]}),e.jsx("div",{className:"mt-2 truncate text-xs text-muted-foreground",children:d.baseUrl||p.routePath}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:ce(d)}),d.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:re(d.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[d.headers.length," hdr"]})]})]},d.id))}):v?e.jsx("div",{className:"rounded-xl border bg-background px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:v.label}),e.jsx(me,{configured:v.secretConfigured})]}),e.jsx("div",{className:"mt-1 truncate text-xs text-muted-foreground",children:v.baseUrl||p.routePath})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(h,{variant:"outline",className:"text-[10px]",children:ce(v)}),v.models.length>0?e.jsx(h,{variant:"outline",className:"text-[10px]",children:re(v.models)}):null,e.jsxs(h,{variant:"outline",className:"text-[10px]",children:[v.headers.length," hdr"]})]})]})}):null]}),v?e.jsx(qs,{family:p,entry:v,source:r.source,isSaving:u.isPending,onSave:async d=>{await u.mutateAsync({family:b,entryId:v.id,data:d}),l()},onDelete:()=>H(v)},v.id):null]}):e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-6 p-6",children:[F,e.jsx(Os,{family:p,onAddEntry:T,onOpenControlPanel:()=>t("/cliproxy/control-panel"),onOpenProfiles:()=>t("/providers")})]})})]}),e.jsx(js,{family:b,entry:j,open:U,onOpenChange:K,onSubmit:async d=>{j?await u.mutateAsync({family:b,entryId:j.id,data:d}):await n.mutateAsync({family:b,data:d}),K(!1),q(null),l()},isSaving:n.isPending||u.isPending},`${b}:${j?.id??"new"}:${U?"open":"closed"}`),e.jsx(ts,{open:N!==null,title:"Remove provider entry?",description:N?`This removes ${N.label} from ${p.displayName}.`:"",confirmText:"Remove",variant:"destructive",onConfirm:async()=>{N&&(await y.mutateAsync({family:b,entryId:N.id}),H(null))},onCancel:()=>H(null)})]})}export{Ws as CliproxyAiProvidersPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-Zb8sVEtn.js";import{r as s}from"./react-vendor-CNOkPC89.js";import{u as R}from"./tanstack-CrmUhA7Z.js";import{bb as g,Y as I}from"./index-DOn6k1jF.js";import{C as S}from"./default-ports-1QQSffYX.js";import{G as z,R as _,w as D}from"./icons-KVCk4_U8.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const k="cli-proxy-auth",T="isLoggedIn",O="apiBase",U="apiUrl",K="managementKey";function $(a){return a.startsWith("/")?new URL(a.replace(/\/$/,""),window.location.origin).href:a.replace(/\/$/,"")}function Q(a,c){window.localStorage.removeItem(k),window.localStorage.setItem(O,a),window.localStorage.setItem(U,a),window.localStorage.setItem(K,c),window.localStorage.setItem(T,"true")}function A(){window.localStorage.removeItem(k),window.localStorage.removeItem(O),window.localStorage.removeItem(U),window.localStorage.removeItem(K),window.localStorage.removeItem(T)}function X({port:a=S}){const c=s.useRef(null),[F,C]=s.useState(null),[M,B]=s.useState(0),[L,N]=s.useState(null),[Y,v]=s.useState(!1),{data:l,error:p}=R({queryKey:["cliproxy-server-config"],queryFn:()=>I.cliproxyServer.get(),staleTime:3e4});s.useEffect(()=>{p&&console.warn("[ControlPanelEmbed] Config fetch failed, using local mode:",p)},[p]);const E=!!(l?.remote?.enabled&&l?.remote?.host),{data:w,error:f}=R({queryKey:["auth-tokens-raw",E?"remote":"local"],enabled:l!==void 0&&!E,queryFn:async()=>{try{const t=await fetch(g("/settings/auth/tokens/raw"));if(!t.ok)throw new Error("Failed to fetch auth tokens");const n=await t.json(),o=n.managementSecret.value.trim();if(!o)throw new Error("Management secret missing");return Q($(g("/cliproxy-local/")),o),n}catch(t){throw A(),t}},staleTime:3e4}),{managementUrl:P,checkUrl:x,authToken:y,isRemote:i,displayHost:m}=s.useMemo(()=>{const t=l?.remote,n=l?.local?.port??a;if(t?.enabled&&t?.host){const o=t.protocol||"http",d=t.port||(o==="https"?443:S),h=o==="https"&&d===443||o==="http"&&d===80?"":`:${d}`,r=`${o}://${t.host}${h}`;return{managementUrl:`${r}/management.html`,checkUrl:`${r}/`,authToken:t.auth_token||void 0,isRemote:!0,displayHost:`${t.host}${h}`}}return{managementUrl:g("/cliproxy-local/management.html"),checkUrl:g("/cliproxy-local/"),authToken:w?.managementSecret?.value||void 0,isRemote:!1,displayHost:`localhost:${n}`}},[l,w,a]),b=`${P}:${i?"remote":"local"}:${x}:${y??"missing"}:${M}`,j=l!==void 0&&(i||!!w||!!f);s.useEffect(()=>{f&&console.warn("[ControlPanelEmbed] Failed to preload local control panel session, falling back to manual login:",f)},[f]),s.useEffect(()=>{if(!i)return()=>{A()}},[i]);const G=!j||!(F===b),q=()=>{if(!(!i||!c.current?.contentWindow||!y))try{const t=$(x),n=new URL(`${t}/`).origin;if(new URL(c.current.src,window.location.origin).origin!==n){console.warn("[ControlPanelEmbed] Remote iframe origin mismatch, skipping postMessage");return}c.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:t,managementKey:y},n)}catch(t){console.debug("[ControlPanelEmbed] Remote postMessage bootstrap failed:",t)}};s.useEffect(()=>{const t=new AbortController;let n=!1;const o=(r,u)=>{n||(v(r),N(u))},d=async()=>{try{if(i){const r=l?.remote,u=await I.cliproxyServer.test({host:r?.host??"",port:r?.port,protocol:r?.protocol??"http",authToken:r?.auth_token});u?.reachable?o(!0,null):o(!1,u?.error?`Remote CLIProxy at ${m}: ${u.error}`:`Remote CLIProxy at ${m} returned an error`)}else(await fetch(x,{signal:t.signal})).ok?o(!0,null):o(!1,"CLIProxy returned an error")}catch(r){if(r instanceof Error&&r.name==="AbortError")return;o(!1,i?`Remote CLIProxy at ${m} is not reachable`:"CLIProxy is not running")}},h=setTimeout(()=>t.abort(),2e3);return d().finally(()=>clearTimeout(h)),()=>{n=!0,t.abort()}},[x,i,m,l]);const H=()=>{C(b),q()},W=()=>{C(null),B(t=>t+1),N(null),v(!1)};return!Y&&L?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:W,children:[e.jsx(_,{className:"w-4 h-4"}),"Retry"]})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(D,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:L}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsx("div",{className:"flex-1 flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[G&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(_,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?`Loading Control Panel from ${m}...`:"Loading Control Panel..."})]})}),j?e.jsx("iframe",{ref:c,src:P,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:H},b):null]})})}function ie(){return e.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:e.jsx(X,{})})}export{ie as CliproxyControlPanelPage};
|